paper_id
stringlengths
9
16
version
stringclasses
26 values
yymm
stringclasses
311 values
created
timestamp[s]
title
stringlengths
6
335
secondary_subfield
listlengths
1
8
abstract
stringlengths
25
3.93k
primary_subfield
stringclasses
124 values
field
stringclasses
20 values
fulltext
stringlengths
0
2.84M
1802.06478
3
1802
2019-08-18T10:25:05
An Efficient Local Search for the Minimum Independent Dominating Set Problem
[ "cs.DS" ]
In the present paper, we propose an efficient local search for the minimum independent dominating set problem. We consider a local search that uses $k$-swap as the neighborhood operation. Given a feasible solution $S$, it is the operation of obtaining another feasible solution by dropping exactly $k$ vertices from $S$ and then by adding any number of vertices to it. We show that, when $k=2$, (resp., $k=3$ and a given solution is minimal with respect to 2-swap), we can find an improved solution in the neighborhood or conclude that no such solution exists in $O(n\Delta)$ (resp., $O(n\Delta^3)$) time, where $n$ denotes the number of vertices and $\Delta$ denotes the maximum degree. We develop a metaheuristic algorithm that repeats the proposed local search and the plateau search iteratively, where the plateau search examines solutions of the same size as the current solution that are obtainable by exchanging a solution vertex and a non-solution vertex. The algorithm is so effective that, among 80 DIMACS graphs, it updates the best-known solution size for five graphs and performs as well as existing methods for the remaining graphs.
cs.DS
cs
An Efficient Local Search for the Minimum Independent Dominating Set Problem Kazuya Haraguchi Otaru University of Commerce, Midori 3-5-21, Otaru, Hokkaido, Japan [email protected] Abstract In the present paper, we propose an efficient local search for the minimum independent dominating set problem. We consider a local search that uses k-swap as the neighborhood operation. Given a feasible solution S, it is the operation of obtaining another feasible solution by dropping exactly k vertices from S and then by adding any number of vertices to it. We show that, when k = 2, (resp., k = 3 and a given solution is minimal with respect to 2-swap), we can find an improved solution in the neighborhood or conclude that no such solution exists in O(n∆) (resp., O(n∆3)) time, where n denotes the number of vertices and ∆ denotes the maximum degree. We develop a metaheuristic algorithm that repeats the proposed local search and the plateau search iteratively, where the plateau search examines solutions of the same size as the current solution that are obtainable by exchanging a solution vertex and a non-solution vertex. The algorithm is so effective that, among 80 DIMACS graphs, it updates the best-known solution size for five graphs and performs as well as existing methods for the remaining graphs. 1 Introduction Let G = (V, E) be a graph such that V is the vertex set and E is the edge set. Let n = V and m = E. A vertex subset S (S ⊆ V ) is independent if no two vertices in S are adjacent, and dominating if every vertex in V \ S is adjacent to at least one vertex in S. Given a graph, the minimum independent dominating set (MinIDS) problem asks for a smallest vertex subset that is dominating as well as independent. The MinIDS problem has many practical applications in data communication and networks [13]. There is much literature on the MinIDS problem in the field of discrete mathematics [8]. The problem is NP-hard [6] and also hard even to approximate; there is no constant ε > 0 such that the problem can be approximated within a factor of n1−ε in polynomial time, unless P=NP [11]. For algorithmic perspective, Liu and Song [15] and Bourgeois et al. [4] proposed exact algorithms with polynomial space. The running times of Liu and Song's algorithms are bounded by O∗(20.465n) and O∗(20.620n), and the running time of Bourgeois et al.'s algorithm is bounded by O∗(20.417n), where O∗(·) is introduced to ignore polynomial factors. Laforest and Phan [14] proposed an exact algorithm based on clique partition, and made empirical comparison with one of the Liu and Song's algorithms, in terms of the computation time. Davidson et al. [5] proposed an integer linear optimization model for the weighted version of the MinIDS problem (i.e., weights are given to edges as well as vertices, and the weight of an edge vx is counted as cost if the edge vx is used to assign a non-solution vertex v to a solution vertex x; every non-solution vertex v is automatically assigned to an adjacent solution vertex x such that the weight of vx is the minimum) and performed experimental validation for random graphs. Recently, Wang et al. [20] proposed 1 a tabu-search based memetic algorithm and Wang et al. [21] proposed a metaheuristic algorithm based on GRASP (greedy randomized adaptive search procedure). They showed their effectiveness on DIMACS instances, in comparison with CPLEX12.6 and LocalSolver5.5. A vertex subset S is an IDS iff it is a maximal independent set with respect to set-inclusion [2]. Then one can readily see that the MinIDS problem is equivalent to the maximum minimal vertex cover (MMVC) problem and the minimum maximal clique problem. Zehavi [22] studied the MMVC problem, which has applications to wireless ad hoc networks, from the viewpoint of fixed-parameter- tractability. For a combinatorially hard problem like the MinIDS problem, it is practically meaningful to develop a heuristic algorithm to obtain a nearly-optimal solution in reasonable time. In the present paper, we propose an efficient local search for the MinIDS problem. By the term "efficient", we mean that the proposed local search has a better time bound than one naıvely implemented. The local search can serve as a key tool of local improvement in a metaheuristic algorithm, or can be used in an initial solution generator for an exact algorithm. We may also expect that it is extended to the weighted version of the MinIDS problem in the future work. Our strategy is to search for a smallest maximal independent set. Hereafter, we may call a maximal independent set simply a solution. In the proposed local search, we use k-swap for the neighborhood operation. Given a solution S, k-swap refers to the operation of obtaining another solution by dropping exactly k vertices from S and then by adding any number of vertices to it. The k-neighborhood of S is the set of all solutions that can be obtained by performing k-swap on S. We call S k-minimal if its k-neighborhood contains no S ′ such that S ′ < S. To speed up the local search, one should search the neighborhood for an improved solution as efficiently as possible. For this, we propose k-neighborhood search algorithms for k = 2 and 3. When k = 2 (resp., k = 3 and a given solution is 2-minimal), the algorithm finds an improved solution or decides that no such solution exists in O(n∆) (resp., O(n∆3)) time, where ∆ denotes the maximum degree in the input graph. Furthermore, we develop a metaheuristic algorithm named ILPS (Iterated Local & Plateau Search) that repeats the proposed local search and the plateau search iteratively. ILPS is so effective that, among 80 DIMACS graphs, it updates the best-known solution size for five graphs and performs as well as existing methods for the remaining graphs. The paper is organized as follows. Making preparations in Section 2, we present k-neighborhood search algorithms for k = 2 and 3 in Section 3 and describe ILPS in Section 4. We show com- putational results in Section 5 and then give concluding remark in Section 6. Some proofs and experimental results are included in the appendix. The source code of ILPS is written in C++ and available at http://puzzle.haraguchi-s.otaru-uc.ac.jp/minids/. 2 Preliminaries 2.1 Notation and Terminologies For a vertex v ∈ V , we denote by deg(v) the degree of v, and by N (v) the set of neighbors of v, i.e., N (v) = {u vu ∈ E}. For S ⊆ V , we define N (S) = (Sv∈S N (v)) \ S. We denote by G[S] the subgraph induced by S. The S is called a k-subset if S = k. Suppose that S is an independent set. The tightness of v /∈ S is the number of neighbors of v that belong to S, i.e., N (v) ∩ S. We call the v t-tight if its tightness is t. In particular, a 0-tight vertex is called free. We denote by Tt the set of t-tight vertices. Then V is partitioned into V = S ∪ T0 ∪ · · · ∪ Tn−1, where Tt may be empty. Let T≥t denote the set of vertices that have the tightness no less than t, that is, T≥t = Tt ∪ Tt+1 ∪ · · · ∪ Tn−1. An independent set S is a solution (i.e., a maximal independent set) iff T0 = ∅. We call x ∈ S a solution vertex and v /∈ S a non-solution vertex . When a solution vertex x ∈ S and a t-tight 2 vertex v /∈ S are adjacent, x is a solution neighbor of v, or equivalently, v is a t-tight neighbor of x. A k-swap on a solution S is the operation of obtaining another solution (S \ D) ∪ A such that D is a k-subset of S and that A is a non-empty subset of V \ S. We call D a dropped subset and A an added subset . The k-neighborhood of S is the set of all solutions obtained by performing a k-swap on S. A solution S is k-minimal if the k-neighborhood contains no improved solution S ′ such that S ′ < S. Note that every solution is 1-minimal. If a k-subset D is dropped from S, then trivially, the k solution vertices in D become free, and some non-solution vertices may also become free. Observe that a non-solution vertex becomes free if the solution neighbors are completely contained in D. We denote by F (D) the set of such vertices and it is defined as F (D) = {v ∈ V \ S N (v) ∩ S ⊆ D}. Clearly the added subset A should be a maximal independent set in G[D ∪ F (D)]. We have F (D) ⊆ N (D), and the tightness of any vertex in F (D) is at most k (at the time before dropping D from S). 2.2 Data Structure We store the input graph by means of the typical adjacency list. We maintain a solution based on the data structure that Andrade et al. [1] invented for the maximum independent set problem. For the current solution S, we have an ordering π : V → {1, . . . , n} on all vertices in V such that; • π(x) < π(v) whenever x ∈ S and v /∈ S; • π(v) < π(v′) whenever v ∈ T0 and v′ ∈ T≥1; • π(v′) < π(v′′) whenever v′ ∈ T1 and v′′ ∈ T≥2; • π(v′′) < π(v′′′) whenever v′′ ∈ T2 and v′′′ ∈ T≥3. Note that the ordering is partitioned into five sections; S, T0, T1, T2 and T≥3. In each section, the vertices are arranged arbitrarily. We also maintain the number of vertices in each section and the tightness τ (v) for every non-solution vertex v /∈ S. Let us describe the time complexities of some elementary operations. We can scan each vertex section in linear time. We can pick up a free vertex (if exists) in O(1) time. We can drop (resp., add) a vertex v from (resp., to) the solution in O(deg(v)) time. See [1] for details. Before closing this preparatory section, we mention the time complexities of two essential operations. Proposition 1 Let D be a k-subset of S. We can list all vertices in F (D) in O(k∆) time. Proof: We let every v ∈ V have an integral counter, which we denote by c(v). It suffices to scan vertices in N (D) twice. In the first scan, we initialize the counter value as c(u) ← 0 for every neighbor u ∈ N (x) of every solution vertex x ∈ D. In the second, we increase the counter of u by one (i.e., c(u) ← c(u) + 1) when u is searched in the adjacency list of x ∈ D. Then, if c(u) = τ (u) holds, we output u as a member of F (D) since the equality represents that every solution neighbor of u is contained in D. Obviously the time bound is O(k∆). ✷ Proposition 2 Let D be a k-subset of S. For any non-solution vertex v ∈ F (D), we can decide whether v is adjacent to all vertices in F (D) \ {v} in O(k∆) time. Proof: We use the algorithm of Proposition 1. As preprocessing of the algorithm, we set the counter c(u) of each u ∈ N (v) to 0, i.e., c(u) ← 0, which can be done in O(deg(v)) time. After we acquire F (D) by running the algorithm of Proposition 1, we can see if v is adjacent to all other vertices in F (D) in O(deg(v)) time by counting the number of vertices u ∈ N (v) such that τ (u) ∈ {1, . . . , k} and c(u) = τ (u). If the number equals to (resp., does not equal to) F (D) − 1, then we can conclude that it is true (resp., false). ✷ 3 3 Local Search Assume that, for some k ≥ 2, a given solution S is k′-minimal for every k′ ∈ {1, . . . , k − 1}. Such k always exists, e.g., k = 2. In this section, we consider how we find an improved solution in the k-neighborhood of S or conclude that S is k-minimal efficiently. Let us describe how time-consuming naıve implementation is. In naıve implementation, we search all k-subsets of S as candidates of the dropped subset D, where the number of them is O(nk). Furthermore, for each D, there are O(nk−1) candidates of the added subset A. The number of possible pairs (D, A) is up to O(n2k−1). In the proposed neighborhood search algorithm, we do not search dropped subsets but added subsets; we generate a dropped subset from each added subset. When k ∈ {2, 3}, the added subsets can be searched more efficiently than the dropped subsets. This search strategy stems from Proposition 3, a necessary condition of a k-subset D that the improvement is possible by a k-swap that drops D. We introduce the condition in Section 3.1. Then in Section 3.2 (resp., 3.3), we present a k-neighborhood search algorithm that finds an improved solution or decides that no such solution exists for k = 2 (resp., 3), which runs in O(n∆) (resp., O(n∆3)) time. 3.1 A Necessary Condition for Improvement Let D be a k-subset of S. If there is a subset A ⊆ F (D) such that A is maximal independent in G[D ∪ F (D)] and A < D, then we have an improved solution (S \ D) ∪ A. The connectivity of G[D ∪ F (D)] is necessary for the existence of such A, as stated in the following proposition. Proposition 3 Suppose that a solution S is k′-minimal for every k′ ∈ {1, . . . , k − 1} for some integer k ≥ 2. Let D be a k-subset of S. There is a maximal independent set A in G[D ∪ F (D)] such that A ⊆ F (D) and A < D only when the subgraph is connected. Proof: Suppose that G[D∪F (D)] is not connected. Let q be the number of connected components and D(p) ∪ F (p)(D) be the subset of vertices in the p-th component (q ≥ 2, p = 1, . . . , q, D(p) ⊆ D, F (p)(D) ⊆ F (D)). Each D(p) is not empty since otherwise there would be an isolated vertex in F (p)(D). It is a free vertex with respect to S, which contradicts that S is a solution. Then we have 1 ≤ D(p) < k. The maximal independent set A is a subset of F (D). We partition A into A = A(1) ∪ · · · ∪ A(q), where A(p) = A∩F (p)(D). Each A(p) is maximal independent for the p-th component. As A < D, A(p) < D(p) holds for some p. Then we can construct an improved solution (S \ D(p)) ∪ A(p), which contradicts the k′-minimality of S. ✷ 3.2 2-Neighborhood Search Applying Proposition 3 to the case of k = 2, we have the following proposition. Proposition 4 Let D be a 2-subset of S. There is a non-solution vertex v in F (D) such that (S \ D) ∪ {v} is a solution only when there is a 2-tight vertex in F (D). We can say more on Proposition 4. The vertex v should be 2-tight since, if not so (i.e., v is 1-tight), {v} would not be maximal independent for G[D ∪ F (D)]; v is adjacent to only one of D = {x, y} from the definition of 1-tightness. In summary, if there is an improved solution (S \ D) ∪ {v}, then v is 2-tight and has x and y as the solution neighbors. Instead of searching all 2-subsets of S, we scan all 2-tight vertices, and for each 2-tight vertex v, we take D = {x, y} as the candidate of the dropped set. We have the following theorem. 4 Theorem 1 Given a solution S, we can find an improved solution in the 2-neighborhood or con- clude that S is 2-minimal in O(n∆) time. Proof: Since we maintain the solution by means of the vertex ordering, we can scan all the 2-tight vertices in O(T2) time. For each 2-tight v, we can detect the two solution neighbors, say x and y, in O(deg(v)) time. Let D = {x, y}. The singleton {v} is maximal independent for G[D∪F (D)] and thus we have an improved solution (S \ D)∪{v} iff v is adjacent to all other vertices in F (D). Whether v is adjacent to all other vertices in F (D) is decided in O(∆) time, as we stated in Proposition 2. If it is the case, then we can construct an improved solution (S \ D) ∪ {v} in O(deg(x) + deg(y) + deg(v)) = O(∆) time as the vertex ordering takes O(deg(x)) time to drop x from S and O(deg(v)) time to add v to it [1]. Otherwise, we can conclude that (S \ D) ∪ {v} is not a solution because some vertices in F (D) are not dominated. We have seen that, for each 2-tight vertex v, it takes O(∆) time to find an improved solution (S \ D)∪{v} or to conclude that it is not a solution. Therefore, the overall running time is bounded by O(T2∆) = O(n∆). ✷ 3.3 3-Neighborhood Search We have the following proposition by applying Proposition 3 to the case of k = 3. Proposition 5 Suppose that S is a 2-minimal solution and that D = {x, y, z} is a 3-subset of S. There is a subset A of F (D) such that A is maximal independent in G[D ∪ F (D)] and A < D only when either of the followings holds: (a) there is a 3-tight vertex in F (D) that has x, y and z as the solution neighbors; (b) there are two 2-tight vertices in F (D) such that one has x and y as the solution neighbors and the other has x and z as the solution neighbors. Let us make observation on the added subset. Suppose that, for an arbitrary 3-subset D ⊆ S, there is A ⊆ F (D) such that A is maximal independent in G[D ∪ F (D)] and A < D. When A = 1, the only vertex in A is 3-tight since otherwise some vertex in D would not be dominated. When A = 2, at least one of the two vertices in A is either 2-tight or 3-tight; if both are 1-tight, one vertex of D would not be dominated. Concerning the tightness, the following four situations are possible: (i) A = {a} and a is 3-tight; (ii) A = {a, b}, a is 3-tight, and b is t-tight such that t ∈ {1, 2, 3}; (iii) A = {a, b}, a is 2-tight, and b is 2-tight; (iv) A = {a, b}, a is 2-tight, and b is 1-tight. From (ii) to (iv), the vertices a and b are not adjacent. We illustrate (i) to (iv) in Figure 1. Based on the above, we summarize the search strategy as follows. In order to generate all 3- subsets D of S such that F (D) satisfies either (a) or (b) of Proposition 5, we scan all 3-tight vertices u (Proposition 5 (a)) and all pairs of 2-tight vertices, say v and w, such that (N (v)∪N (w))∩S = 3 (Proposition 5 (b)). For (a), we take D = N (u) ∩ S and search F (D) for a 1- or 2-subset A that is maximal independent in G[D ∪ F (D)], regarding the 3-tight vertex u as the vertex a in (i) and (ii). Similarly, for (b), we take D = (N (v) ∪ N (w)) ∩ S and search F (D) for a 2-subset A that is maximal independent in G[D ∪ F (D)], regarding the 2-tight vertex v as the vertex a in (iii) and (iv). 5 b b a a b a a' F(D) a D (i) A = {a} (ii) A = {a, b} (iii) A = {a, b} (iv) A = {a, b} Figure 1: Illustration of a dropped set D and an added set A for (i) to (iv) in Section 3.3: For clarity of the figure, we draw only edges that are incident to the vertices a, b and a′, where the vertex a′ appears in Lemma 4 in the appendix. Note that every vertex in F (D) is adjacent to at least one vertex in D. We have the following theorem on the time complexity of 3-neighborhood search. The proof is included in the appendix. Theorem 2 Given a 2-minimal solution S, we can find an improved solution in the 3-neighborhood or conclude that S is 3-minimal in O(n∆3) time. 4 Iterated Local & Plateau Search In this section, we present a metaheuristic algorithm named ILPS (Iterated Local & Plateau Search) that repeats the proposed local search and the plateau search iteratively. We show the pseudo code of ILPS in Algorithm 1. The ILPS has four parameters, that is S, k, δ and ν, where S is an initial solution, k is the order of the local search (i.e., a k-minimal solution is searched by LocalSearch(S, k) in Line 6), and δ and ν are integers. The roles of the last two parameters are mentioned in Section 4.2. The LocalSearch(S, k) in Line 6 is the subroutine that returns a k-minimal solution from an initial solution S, where k is set to either two or three. When k = 2, it determines a 2- minimal solution by moving to an improved solution repeatedly as long as the 2-neighborhood search algorithm delivers one. When k = 3, it first finds a 2-minimal solution, and then runs the 3-neighborhood search algorithm. If an improved solution is delivered, then the local search moves to the improved solution and seeks a 2-minimal one again since the solution is not necessarily 2-minimal. Otherwise, the current solution is 3-minimal. Below we explain two key ingredients: the plateau search and the vertex penalty. We describe these in Sections 4.1 and 4.2 respectively. We remark that they are inspired by Dynamic Local Search for the maximum clique problem [19] and Phased Local Search for the unweighted/weighted maximum independent set and minimum vertex cover [18]. 4.1 Plateau Search In the plateau search (referred to as PlateauSearch(S, k) in Line 7), we search solutions of the size S that can be obtained by swapping a solution vertex x ∈ S and a non-solution vertex v /∈ S. Let P(S) be the collection of all solutions that are obtainable in this way. The size of any solution in P(S) is S. We execute LocalSearch(S ′, k) for every solution S ′ ∈ P(S), and if we find an improved solution S ′′ such that S ′′ < S ′ = S, then we do the same for S ′′, i.e., we execute LocalSearch(P, k) for every solution P ∈ P(S ′′). We repeat this until no improved solution is found and employ a best solution among those searched as the output of the plateau search. 6 Algorithm 1 Iterated Local & Plateau Search (ILPS) 1: function ILPS(S, k, δ, ν) 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: S ∗ ← S ρ ← a penalty function such that ρ(v) = 0 for all v ∈ V ρ ← UpdatePenalty(S, ρ, δ) while termination condition is not satisfied do ⊲ S ∗ is used to store the incumbent solution S ← LocalSearch(S, k) S ← PlateauSearch(S, k) if S ≤ S ∗ then S ∗ ← S end if S ← Kick(S ∗, ρ, ν) ρ ← UpdatePenalty(S, ρ, δ) ⊲ The local search returns a k-minimal solution ⊲ The plateau search returns a k-minimal solution ⊲ The initial solution of the next iteration is generated ⊲ The penalty function is updated 13: 14: end while return S ∗ 15: end function We emphasize the efficiency of the plateau search; all solutions in P(S) can be listed in O(T1∆) time. Observe that (S \ {x}) ∪ {v} is a solution iff v is 1-tight such that x is the only solution neighbor of v, and v is adjacent to all vertices in F ({x}) other than v. We can scan all 1-tight vertices in O(T1) time. For each 1-tight vertex v, the solution neighbor x is detected in O(deg(v)) time, and whether the last condition is satisfied or not is identified in O(∆) time from Proposition 2. Dropping x from S and adding v to S \ {x} can be done in O(∆) time. 4.2 Vertex Penalty In order to avoid the search stagnation, one possible approach is to apply a variety of initial solutions. To realize this, we introduce a penalty function ρ : V → Z+ ∪ {0} on the vertices. The penalty function ρ is initialized so that ρ(v) = 0 for all v ∈ V (Line 3). During the algorithm, ρ is managed by the subroutine UpdatePenalty (Lines 4 and 12). When the initial solution S of the next local search is determined, it increases the penalty ρ(v) of every vertex v ∈ S by one, i.e., ρ(v) ← ρ(v) + 1. Furthermore, to "forget" the search history long ago, it reduces ρ(v) to ⌊min{ρ(v), δ}/2⌋ for all v ∈ V in every δ iterations. This δ is the third parameter of ILPS and called the penalty delay. The ρ is used in the subroutine Kick (Line 11), the initial solution generator, so that vertices with fewer penalties are more likely to be included in the initial solution. Kick generates an initial solution by adding non-solution vertices (with respect to the incumbent solution S ∗) "forcibly" to S ∗. The added vertices are chosen one by one as follows; in one trial, Kick picks up one non- solution vertex. It then goes on to the next trial with the probability (ν −1)/ν or stops the selection with the probability 1/ν, where ν is the fourth parameter of ILPS. Observe that ν specifies the expected number of added vertices. In the first trial, Kick randomly picks up a non-solution vertex that has the fewest penalty. In a subsequent r-th trial (r = 2, 3, . . . ), let R = {v1, . . . , vr−1} be the set of vertices chosen so far. Kick samples three vertices randomly from V \ (S ∗ ∪ R ∪ N (R)), and picks up the one that has the fewest penalty among the three. Suppose that R = {v1, . . . , vr} has been picked up as the result of r trials. Then we construct an independent set S = (S ∗ \ N (R))∪R. The S may not be a solution as there may remain free vertices. If so, we repeatedly pick up free vertices by the maximum-degree greedy method until S becomes a solution. We use the acquired S as the initial solution of the next local search. 7 ) c e s ( e m T i 60 50 40 30 20 10 0 Computation time n=100 n=150 n=200 0 .2 .4 .6 Edge density .8 1.0 Figure 2: Computation time of CPLEX12.8 for random graphs 5 Computational Results We report some experimental results in this section. In Section 5.1, to gain insights into what kind of instance is difficult, we examine the phase transition of difficulty with respect to the edge density. The next two subsections are devoted to observation on the behavior of the proposed method. In Section 5.2, we show how a single run of LocalSearch(S, k) improves a given initial solution. In Section 5.3, we show how the penalty delay δ affects the search. Finally in Section 5.4, we compare ILPS with the memetic algorithm [20], GRASP+PC [21], CPLEX12.6 [12] and LocalSolver5.5 [16] in terms of the solution size, using DIMACS graphs. All the experiments are conducted on a workstation that carries an Intel Core i7-4770 Processor (up to 3.90GHz by means of Turbo Boost Technology) and 8GB main memory. The installed OS is Ubuntu 16.04. Under this environment, it takes 0.25 s, 1.54 s and 5.90 s approximately to execute dmclique (http://dimacs.rutgers.edu/pub/dsj/clique/) for instances r300.5.b, r400.5.b and r500.5.b, respectively. The ILPS algorithm is implemented in C++ and compiled by the g++ compiler (ver. 5.4.0) with -O2 option. 5.1 Phase Transition of Difficulty The phase transition has been observed for many combinatorial problems [7, 9, 10]. Roughly, it is said that over-constrained and under-constrained instances are relatively easy, and that interme- diately constrained ones tend to be more difficult. In the MinIDS problem, the amount of constraints is proportional to the edge density p. We examine the change of difficulty with respect to p. We estimate the difficulty of an instance by how long CPLEX12.8 takes to solve it. For each (n, p) ∈ {100, 150, 200}×{0.00, 0.05, . . ., 1.00}, we generate 100 random graphs (Erdos- R´enyi model) with n vertices and the edge density p, i.e., an edge is drawn between two vertices with probability p. We solve the 100 instances by CPLEX12.8 and take the averaged computation time. We set the time limit of each run to 60 s. If CPLEX12.8 terminates by the time limit, then we regard the computation time as 60 s. Figure 2 shows the result. We may say that instances with the edge densities from 0.1 to 0.4 are likely to be more difficult than others. In fact, the experiments in [5, 14] mainly deal with random graphs with the edge densities in this range. 5.2 A Single Run of Local Search We show how a single run of LocalSearch(S, k) improves an initial solution S. Again we take a random graph. We fix the number n of vertices to 103. For every p ∈ {0.1, . . . , 0.9, 0.95, 0.99}, we 8 Table 1: Averaged sizes of random, 2-minimal and 3-minimal solutions in random graphs with 103 vertices random 2-minimal 3-minimal p = .1 44.57 37.37 35.44 .2 24.42 20.36 19.04 .3 16.70 13.84 12.74 .4 12.50 10.18 9.28 .5 9.66 7.86 7.01 .6 7.70 6.12 5.64 .7 6.12 4.95 4.06 .8 4.84 3.95 3.02 .9 3.62 2.99 2.15 .95 3.00 2.00 2.00 .99 2.12 1.95 1.95 Computation time (n=1000) 2- and 3-tight vertices (k=3) 1 0.1 k=2 k=3 ) c e s ( e m T i 0.01 0.001 0.0001 2-tight 3-tight 1000 800 600 400 200 r e b m u N .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0 .1 .2 .3 Edge density .6 .5 .4 .7 Edge density .8 .9 1.0 Figure 3: (Left) averaged computation time that LocalSearch(S, k) takes to decide a k-minimal solution (Right) numbers of 2- and 3-tight vertices with respect to 3-minimal solutions generate 100 random graphs. Then for each graph, we run LocalSearch(S, k) five times, where we use different random seeds in each time and construct the initial solution S randomly. We show the averaged sizes of random, 2-minimal and 3-minimal solutions in Table 1. We see that, the larger the edge density p is, the fewer the solution size becomes. The local search improves a random solution to some extent. LocalSearch(S, 3) improves the solution more than LocalSearch(S, 2). The difference between the two local searches is the largest when p = 0.1, that is 37.37 − 35.44 = 1.93. The difference gets smaller when p gets larger. In particular, when p > 0.9, we see no difference. Let us discuss computation time. In the left of Figure 3, we show how the averaged computation time changes with respect to p. We see that the computation time of LocalSearch(S, 3) is tens to thousands of times the computation time of LocalSearch(S, 2). However, it does not necessarily diminish the value of the 3-neighborhood search. As will be shown in Section 5.4, when k = 3, ILPS can find such a good solution that is not obtained by k = 2. In general, for a fixed k, it takes more computation time when p is larger. Recall Theorem 1 (resp., 2); when k = 2 (resp., 3), the k-neighborhood search algorithm finds an improved solution for the current solution S or concludes that S is k-minimal in O(n∆) (resp., O(n∆3)) time. Roughly, ∆ is increasing as p gets larger. For k = 3, we attribute the peak at p = 0.8 to the number of 3-tight vertices. In the right of Figure 3, We show the averaged numbers of 2- and 3-tight vertices with respect to 3-minimal solutions. The 3-neighborhood search algorithm searches 2- and 3-tight vertices. The numbers of both vertices are generally non-decreasing from p = 0.1 to 0.8, but when p > 0.8, the number of 3-tight vertices decreases dramatically. This is due to the solution size. The solution size gives an upper bound on the tightness of any non-solution vertex, and when p > 0.8, the averaged size of a 3-minimal solution is less than three; see Table 1. Since most of the non-solution vertices are either 1- or 2-tight, we hardly handle the situations (i) and (ii) in Section 3.3. 9 s n o i t a r e t i f o r e b m u N 220 200 180 160 140 120 100 80 60 40 20 Number of iterations for cover/optimum Cover Optimum 0 10 20 30 40 50 60 70 80 90 100 Penalty delay Figure 4: Averaged numbers of iterations to cover all vertices (solid line) and to find the optimum (dashed line) 5.3 Penalty Delay We introduced the notion of vertex penalty to control the search diversification. When the penalty delay δ is larger, more varieties of initial solutions are expected to be tested in ILPS. To illustrate the expectation, we evaluate how many iterations ILPS takes until all vertices are covered by the initial solutions, that is, used in the initial solutions at least once. The solid line in Figure 4 shows the number of iterations taken to cover all vertices. The graph we employ here is a 10 × 10 grid graph such that each vertex is associated with a 2D integral point (i, j) ∈ {1, . . . , 10}2, and that two vertices (i, j) and (i′, j′) are adjacent iff i − i′ + j − j′ = 1. For each δ, the number of iterations is averaged over 500 runs of ILPS with different random seeds, where we fix (k, ν) = (2, 1) and construct the first initial solution S by the maximum-degree greedy algorithm. The observed phenomenon meets our expectation; The number is non-increasing with respect to δ and saturated for δ ≥ 30. In other words, when δ is larger, more varieties of initial solutions are generated in a given number of iterations. However, setting δ to a large value does not necessarily lead to discovery of better solutions. The dashed line in Figure 4 shows the averaged number of iterations that ILPS takes to find an optimal solution; we know that the optimal size is 24 since we solve the instance optimally by CPLEX. When δ ≤ 40, the number is approximately decreasing and takes the minimum at δ = 40, but a larger δ does not make any improvement. Hence, given an instance, we need to choose an appropriate value of δ carefully. 5.4 Performance Validation We run ILPS algorithm for 80 DIMACS instances that are downloadable from [17]. We generate the first initial solution S by the maximum-degree greedy method, and fix the parameter ν to three. For (k, δ), all pairs in {2, 3} × {20, . . . , 26} are tested. For each instance and each (k, δ), we run ILPS algorithm 10 times, using different random seeds. We terminate the algorithm by the time limit. The time limit is set to 200 s. When k = 3, we modify Algorithm 1 so that PlateauSearch(S, k) in Line 7 is called only when S ≤ S ∗ + 2 as the plateau search is rather time-consuming. We take four competitors from [20] and [21]. The first is MEM, a tabu-search based memetic algorithm in [20]. The second is GP, the GRASP+PC algorithm in [21]. The third is CP, which stands for CPLEX12.6 [12] that solves an integer optimization model of the MinIDS problem. The fourth is LS, which stands for LocalSolver5.5 [16], a general discrete optimization solver based on local search. MEM is run on a computer with a 2.0GHz CPU and a 4GB memory, whereas the other competitors are run on computers with a 2.3GHz CPU and an 8GB memory. The time limit 10 Table 2: Selected results from the validation experiments on DIMACS graphs [21] ILPS n p brock400 2 C1000.9 ∗C125.9 C2000.9 C4000.5 C500.9 gen400 p0.9 55 gen400 p0.9 65 ∗hamming8-2 keller6 ∗san200 0.7 1 ∗san200 0.9 1 san400 0.7 3 400 1000 125 2000 4000 500 400 400 256 3361 200 200 400 .25 .10 .10 .10 .50 .10 .10 .10 .03 .18 .30 .10 .30 (k = 2, ν = 26) Min Avg Max TTB Best 9 26 14 32 7 21 20 20 32 16 6 15 7 1.1 0.0 0.1 12.1 49.7 92.3 39.4 99.0 0.0 26.1 85.9 16.7 106.6 10.0 27.8 14.0 33.6 7.9 22.2 20.1 20.7 36.0 18.0 6.1 15.0 7.8 10 27 14 32 7 22 20 20 36 18 6 15 7 10 29 14 35 8 23 21 21 36 18 7 15 8 [20] MEM GP CP LS 9 27 14 33 8 22 20 20 - 18 6 15 7 10 27 15 33 8 23 21 21 32 18 7 16 8 10 29 14 48 - 23 22 21 32 32 6 15 8 11 30 14 36 - 22 22 22 32 19 7 16 9 of MEM and GP is set to 200 s, and that of CP and LS is set to 3600 s. In Table 2, we show the results on selected instances. The columns "n" and "p" indicate the number of vertices and the edge density, respectively. The edge density is between 0.1 and 0.5 in all instances except hamming8-2. In our context, the instances are expected to be difficult. For ILPS, we show the results for (k, δ) = (2, 26) in detail, regarding this pair as the representative. The columns "Min" and "Max" indicate the minimum/maximum solution size over 10 runs, and the column "Avg" indicates the average. The column "TTB" indicates the time to best (in seconds), that is, the average of the computation time that ILPS takes to find the solution of the size "Min". The symbol ε represents that the time is less than 0.1 s. The column "Best" indicates the minimum solution size attained over all (k, δ) ∈ {2, 3} × {20, . . . , 26}. The rightmost four columns indicate the solution size attained by the competitors. The symbol ∗ before the instance name indicates that the solution size attained by CPLEX is optimal. The table contains only results on the 13 selected instances such that the solutions sizes attained by "Best", "MEM" and "GP" are not-all-equal, except hamming8-2. We guarantee that, for the remaining 67 instances, ILPS's "Best" is as good as any competitor. The boldface indicates that the solution size is strictly smaller than those of the competitors. Then we update the best-known solution size in five graphs. These show the effectiveness of the proposed local search and the ILPS algorithm. All results are included in the appendix. For hamming8-2, when k = 2, ILPS cannot find a solution of the optimal size 32 for any penalty delay δ ∈ {20, . . . , 26}. However, when k = 3, ILPS finds an optimal solution with δ = 20, 21 and 22. Before closing this section, let us report our preliminary results briefly. • A preliminary version of ILPS happened to find a solution of the size 31 for C2000.9 and a solution of the size 15 for keller6. See the detail for the appendix. • Let us consider a finer swap operation, (j, k)-swap, that obtains another solution by dropping exactly k vertices from the current one and then by adding exactly j vertices to it. One can prove that, given a solution S and a constant k, we can improve S by (1, k)-swap or conclude that it is not possible in O(n∆) time. We implemented (1, k)-swap in a preliminary version of ILPS, but it does not yield significant improvement even when k is set to a constant larger than three. 11 • We tested Laforest and Phan's exact algorithm [14], and found that the algorithm is not suitable for a task of finding a good solution quickly. The source code is available at http://todo.lamsade.dauphine.fr/spip.php?article42. • BHOSLIB [3] is another well-known collection of benchmark instances. It contains 36 in- stances such that n is between 450 and 4000 and that p is no less than 0.82. Hence, the BHOSLIB instances are expected to be easy in our context. The ILPS with (k, δ) = (2, 26) finds a solution of the size three for all the instances. We also run CPLEX12.8 for 200 s, generating an initial solution by the maximum-degree greedy algorithm. CPLEX12.8 finds a solution of the size five for frb100-40, and a solution of the size three for the other instances. In addition, the solution of the size three is proved to be optimal for 15 instances whose names start with frb30, frb35 and frb40. 6 Concluding Remark We have considered an efficient local search for the MinIDS problem. We proposed fast k- neighborhood search algorithms for k = 2 and 3, and developed a metaheuristic algorithm named ILPS that repeats the local search and the plateau search iteratively. ILPS is so effective that it updates the best-known solution size in five DIMACS graphs. The proposed local search is applicable to other metaheuristics such as genetic algorithms, as a key tool of local improvement. The future work includes an extension of the local search to a weighted version of the MinIDS problem. 12 References [1] D.V. Andrade, M.G.C. Resende, and R.F. Werneck. Fast local search for the maximum independent set problem. Journal of Heuristics, 18:525 -- 547, 2012. [2] C. Berge. Theory of Graphs and its Applications. Methuen, London, 1962. [3] BHOSLIB: Benchmarks with problems. http://sites.nlsde.buaa.edu.cn/~kexu/benchmarks/graph-benchmarks.htm. accessed on February 1, 2018. hidden optimum solutions for graph [4] N. Bourgeois, F.D. Croce, B. Escoffier, and V.Th. Paschos. Fast algorithms for MIN indepen- dent dominating set. Discrete Applied Mathematics, 161(4):558 -- 572, 2013. [5] P.P. Davidson, C. Blum, and J. Lozano. The weighted independent domination problem: ILP model and algorithmic approaches. In Proc. EvoCOP 2017, pages 201 -- 214, 2017. [6] M.R. Garey and D.S. Johnson. Computers and Intractability: A Guide to the Theory of NP-Completeness. W. H. Freeman & Company, 1979. [7] I.P. Gent and T. Walsh. The SAT phase transition. In Proc. ECAI-94, pages 105 -- 109, 1994. [8] W. Goddard and M.A. Henning. Independent domination in graphs: A survey and recent results. Discrete Mathematics, 313:839 -- 854, 2013. [9] C.P. Gomes and B. Selman. Problem structure in the presence of perturbations. In Proc. AAAI-97, pages 221 -- 227, 1997. [10] C.P. Gomes and D.B. Shmoys. Completing quasigroups or latin squares: a structured graph coloring problem. In Proc. Computational Symposium on Graph Coloring and Generalizations, 2002. [11] M.M. Halld´orsson. Approximating the minimum maximal independence number. Information Processing Letters, 46(4):169 -- 172, 1993. [12] IBM ILOG CPLEX. https://www.ibm.com/analytics/data-science/prescriptive-analytics/cplex-optimizer. accessed on February 1, 2018. [13] F. Kuhn, T. Nieberg, T. Moscibroda, and R. Wattenhofer. Local approximation schemes for ad hoc and sensor networks. In Proc. the 2005 Joint Workshop on Foundations of Mobile Computing, pages 97 -- 103, 2005. [14] C. Laforest and R. Phan. Solving the minimum independent domination set problem in graphs by exact algorithm and greedy heuristic. RAIRO-Operations Research, 47(3):199 -- 221, 2013. [15] C. Liu and Y. Song. Exact algorithms for finding the minimum independent dominating set in graphs. In Proc. ISAAC 2006, LNCS 4288, pages 439 -- 448, 2006. [16] LocalSolver. http://www.localsolver.com/. accessed on February 1, 2018. [17] F. Mascia. dimacs benchmark set. http://iridia.ulb.ac.be/~fmascia/maximum_clique/DIMACS-benchmark. accessed on February 1, 2018. [18] W. Pullan. Optimisation of unweighted/weighted maximum independent sets and minimum vertex covers. Discrete Optimization, 6(2):214 -- 219, 2009. [19] W. Pullan and H.H. Hoos. Dynamic local search for the maximum clique problem. Journal of Artificial Intelligence Research, 25:159 -- 185, 2006. 13 [20] Y. Wang, J. Chen, H. Sun, and M. Yin. A memetic algorithm for minimum inde- in press. URL: pendent dominating set problem. Neural Computing and Applications, https://doi.org/10.1007/s00521-016-2813-7. [21] Y. Wang, R. Li, Y. Zhou, and M. Yin. A path cost-based grasp for minimum independent dominating set problem. Neural Computing and Applications, 28(1):143 -- 151, 2017. URL: https://doi.org/10.1007/s00521-016-2324-6. [22] M. Zehavi. Maximum minimal vertex cover parameterized by vertex cover. SIAM Journal on Discrete Mathematics, 31(4):2440 -- 2456, 2017. 14 Appendix Proof of Theorem 2 For preparation, let us introduce the following proposition. This is a generalization of Proposition 2 in the sense that the vertex subset is taken arbitrarily. The proof is similar to Proposition 2. Proposition 6 Given an arbitrary vertex subset F and a vertex v ∈ F , we can decide whether v is adjacent to all vertices in F \ {v} in O(F + deg(v)) time. Proof: We let every v ∈ V have another integral variable, which we denote by χ(v). Initially, χ(v) is set to zero. We also maintain a global integral variable γ that is set to one initially. First, for all v ∈ F , we set χ(v) to the current γ (i.e., χ(v) ← γ). We then count the number of vertices v in N (v0) such that χ(v) = γ. If the number equals to F − 1, then we can regard that v0 is adjacent to all vertices in F \ {v0}. As postprocessing, we increase γ by one (i.e., γ ← γ + 1). ✷ An integral variable is bounded in conventional programming languages. If γ reaches the upper limit (e.g., INT MAX in C), then we reset χ(v) to zero for all v ∈ V and γ to one again. We prove Theorem 2 in Section 3.3. If there is an improved solution (S \ D) ∪ A, then the four situations from (i) to (iv) are possible as to the tightnesses of vertices in A. (For illustration, see Figure 1.) Given a non-solution vertex a in (i) to (iv), the following Lemmas 1 to 4 show time complexities of finding an improved solution or concluding that no such solution exists, respectively. Lemma 1 Suppose that a 3-tight vertex a is given. Let D = {x, y, z} be the set of solution neighbors of a. We can decide whether (S \ D) ∪ {a} is a solution or not in O(∆) time. Proof: The set D can be decided in O(deg(a)) time. It suffices to decide whether a is adjacent to all vertices in F (D) \ {a}. This can be done in O(∆) time from Proposition 2. ✷ Lemma 2 Suppose that a 3-tight vertex a is given. Let D = {x, y, z} be the set of solution neighbors of a. We can find a non-solution vertex b ∈ F (D) such that (S \ D) ∪ {a, b} is a solution or conclude that such b does not exist in O(∆2) time. Proof: Let F be the subset of F (D) such that the vertices in F are not adjacent to a. The sets D, F (D) and F can be constructed in O(∆) time. All we have to do is to check whether there is b ∈ F such that b is adjacent to all vertices in F \ {b}. From Proposition 6 and F = O(∆), this can be done in O(∆2) time. ✷ Lemma 3 Suppose that a 2-tight vertex a is given. We can decide in O(∆2) time whether there exists a 2-tight vertex b such that: • a and b have exactly one solution neighbor in common; • (S \ D) ∪ {a, b} is a solution, where D = (N (a) ∪ N (b)) ∩ S. Proof: Let Da = {x, y} be the set of solution neighbors of a. The target 2-tight vertex b should be a neighbor of either x or y, but not both, as a and b have exactly one solution neighbor in common. Hence, there are at most deg(x) + deg(y) ≤ 2∆ candidates for b. For each candidate of b, let Db = {x, z} be the set of solution neighbors of b. (If z = y, then we discard this candidate.) Let D = Da ∪ Db. To check whether (S \ D) ∪ {a, b} is a solution, it suffices to check whether {a, b} is a solution in the subgraph G[F (D)]. It takes O(∆) time to decide Db, to decide whether {a, b} is independent, and decide whether {a, b} is dominating the vertices in F (D). ✷ 15 Lemma 4 Suppose that a 2-tight vertex a is given. We can decide in O(∆3) time whether there exist a 2-tight vertex a′ and a 1-tight vertex b such that: • a and a′ are adjacent, and have exactly one solution neighbor in common. Let Da = {x, y} and Da′ = {x, z} be the sets of solution neighbors of a and a′ respectively; • the unique solution neighbor of b is z; • (S \ D) ∪ {a, b} is a solution, where D = {x, y, z}. Proof: Similarly to Lemma 3, there are at most deg(x) + deg(y) ≤ 2∆ candidates for a′. The adjacency between a and a′ can be checked in O(∆) time. Note that the number of candidates for z is also at most 2∆. Each candidate of z has at most ∆ 1-tight neighbors that are the candidates of b. Hence, for b, there are O(∆2) candidates. For each candidate of b, to check whether (S \ D) ∪ {a, b} is a solution, it suffices to check whether {a, b} is a solution in the subgraph G[F (D)], which can be done in O(∆) time. Then we have the time bound O(∆3). ✷ (Proof of Theorem 2) For every 3-tight vertex a, check whether there is an improved solution in the situations (i) and (ii). This can be done in O(∆2) time from Lemmas 1 and 2. Similarly, for every 2-tight vertex a, check whether there is an improved solution in the situations (iii) and (iv). This can be done in O(∆3) time from Lemmas 3 and 4. As there are O(n) non-solution vertices, we have the time bound O(n∆3). ✷ 16 All Computational Results on DIMACS Graphs The next Table 3 shows all results on 80 DIMACS graphs that are downloadable from [17]. The column "CP12.8" represents CPLEX12.8. We run CPLEX12.8 for each instance, setting the time limit to 200 seconds. An initial solution is constructed by the maximum-degree greedy algorithm. A hyphen in the rightmost four columns indicates that the corresponding result is not available in [20, 21]. As mentioned in the paper, we happened to find a solution of the size 31 for C2000.9 and a solution of the size 15 for keller6 by a preliminary version of ILPS. The vertices in the solution for C2000.9 have the following IDs: 23, 78, 161, 252, 279, 344, 441, 556, 662, 671, 703, 769, 847, 864, 926, 952, 1056, 1266, 1274, 1475, 1540, 1619, 1636, 1641, 1646, 1673, 1826, 1839, 1915, 1947, 1979. The solution for keller6 is the set of vertices with the following IDs: 169, 601, 659, 855, 1020, 1215, 1352, 1586, 2052, 2376, 2463, 2818, 2847, 2944, 3281. By the ID of a vertex, we mean an integer that is given to the vertex in the DIMACS files. Table 3: All results of the validation experiments on DIMACS graphs ∗ brock200 1 ∗ brock200 2 ∗ brock200 3 ∗ brock200 4 brock400 1 brock400 2 brock400 3 brock400 4 brock800 1 brock800 2 brock800 3 brock800 4 ∗ c-fat200-1 ∗ c-fat200-2 ∗ c-fat200-5 ∗ c-fat500-1 ∗ c-fat500-10 ∗ c-fat500-2 ∗ c-fat500-5 C1000.9 ∗ C125.9 C2000.5 C2000.9 C250.9 C4000.5 C500.9 DSJC1000.5 DSJC500.5 ∗ gen200 p0.9 44 ∗ gen200 p0.9 55 gen400 p0.9 55 gen400 p0.9 65 gen400 p0.9 75 hamming10-2 hamming10-4 ∗ hamming6-2 ∗ hamming6-4 ∗ hamming8-2 ∗ hamming8-4 ∗ johnson16-2-4 ∗ johnson32-2-4 ∗ johnson8-2-4 ∗ johnson8-4-4 ∗ keller4 ILPS (k = 2, ν = 26) Avg Max 8 4 5 6 10 10 10 10 9 9 9 9 10 22 56 12 124 24 62 29 14 7 35 17 8 23 6 5 16 16 21 21 21 133 12 12 2 36 4 8 16 4 7 5 8.0 4.0 5.0 6.0 10.0 10.0 9.3 9.8 8.3 8.7 8.4 8.5 10.0 22.0 56.0 12.0 124.0 24.0 62.0 27.8 14.0 7.0 33.6 17.0 7.9 22.2 6.0 5.0 16.0 16.0 20.1 20.7 20.7 131.1 12.0 12.0 2.0 36.0 4.0 8.0 16.0 4.0 7.0 5.0 Min 8 4 5 6 10 10 9 9 8 8 8 8 10 22 56 12 124 24 62 27 14 7 32 17 7 22 6 5 16 16 20 20 20 128 12 12 2 36 4 8 16 4 7 5 TTB ε 0.3 0.7 0.8 1.1 32.2 168.0 102.8 33.5 85.9 81.2 ε ε ε ε ε ε ε ε ε 1.1 12.1 26.5 49.7 92.3 0.2 1.3 1.6 5.4 39.4 99.0 95.3 28.6 1.2 ε ε ε ε ε ε ε ε ε 8.9 17 Best 8 4 5 6 10 9 9 9 8 8 8 8 10 22 56 12 124 24 62 26 14 7 32 17 7 21 6 5 16 16 20 20 20 128 12 12 2 32 4 8 16 4 7 5 [20] CP MEM GP 12.8 8 4 5 6 10 10 10 10 9 9 10 9 10 22 56 12 124 24 62 30 14 8 33 17 9 23 7 5 16 16 20 22 21 161 14 12 2 32 4 8 16 4 7 5 - 4 - 6 - 9 - 9 - 8 - 8 - - - - - - - 27 14 7 33 17 8 22 6 5 16 16 20 20 20 - 12 12 2 - 4 8 16 4 7 5 - 4 - 6 - 10 - 9 - 8 - 8 - - - - - - - 27 15 7 33 17 8 23 6 5 16 16 21 21 20 - 12 12 2 32 4 8 16 4 7 5 [21] CP 12.6 - 4 - 6 - 10 - 10 - 9 - 9 - - - - - - - 29 14 11 48 18 - 23 6 10 16 16 22 21 21 - 14 12 2 32 4 8 16 4 7 5 LS - 4 - 6 - 11 - 11 - 9 - 9 - - - - - - - 30 14 8 36 18 - 22 6 7 16 16 22 22 22 - 12 12 2 32 4 8 16 4 7 5 keller5 keller6 ∗ MANN a27 ∗ MANN a45 ∗ MANN a81 ∗ MANN a9 ∗ p hat1000-1 p hat1000-2 p hat1000-3 p hat1500-1 p hat1500-2 p hat1500-3 ∗ p hat300-1 ∗ p hat300-2 ∗ p hat300-3 ∗ p hat500-1 ∗ p hat500-2 p hat500-3 ∗ p hat700-1 p hat700-2 p hat700-3 san1000 ∗ san200 0.7 1 ∗ san200 0.7 2 ∗ san200 0.9 1 san200 0.9 2 san200 0.9 3 ∗ san400 0.5 1 san400 0.7 1 san400 0.7 2 san400 0.7 3 san400 0.9 1 ∗ sanr200 0.7 sanr200 0.9 sanr400 0.5 sanr400 0.7 9 18 27 45 81 9 3 6 11 4 8 14 3 5 9 3 6 10 3 6 11 4 6 6 15 16 15 4 7 7 7 20 7 16 5 8 9.0 18.0 27.0 45.0 81.0 9.0 3.0 6.1 12.0 4.0 8.0 14.7 3.0 5.0 9.0 3.0 6.0 10.0 3.0 6.9 11.0 4.8 6.1 6.0 15.0 16.0 15.2 4.0 7.9 7.7 7.8 20.4 7.0 16.0 5.0 8.0 9 18 27 45 81 9 3 7 13 4 8 15 3 5 9 3 6 10 3 7 11 5 7 6 15 16 16 4 8 8 8 21 7 16 5 8 26.1 ε ε ε ε 0.9 54.8 21.5 ε 34.7 13.3 ε ε 0.9 ε 0.3 28.4 0.2 182.4 52.0 48.1 85.9 ε 16.7 2.3 20.4 0.3 64.9 96.1 106.6 59.2 ε 7.0 ε 10.6 ε 9 16 27 45 81 9 3 6 11 4 7 14 3 5 9 3 6 10 3 6 11 4 6 6 15 16 15 4 7 7 7 19 7 16 5 8 11 20 27 45 81 9 3 7 13 4 9 18 3 5 9 3 6 11 3 6 12 4 6 6 15 16 17 4 7 7 8 20 7 16 5 9 9 18 27 45 81 9 - - - - - - - - - - - - - - - 4 6 6 15 16 15 4 7 7 7 - - - - - 9 18 27 45 81 9 - - - - - - - - - - - - - - - 4 7 6 16 16 15 4 7 7 8 - - - - - 11 32 27 45 81 9 - - - - - - - - - - - - - - - 4 6 6 15 16 15 4 8 7 8 - - - - - 10 19 27 45 81 12 - - - - - - - - - - - - - - - 5 7 6 16 16 15 4 8 8 9 - - - - - 18
1304.2077
1
1304
2013-04-07T23:42:35
Nearly Maximum Flows in Nearly Linear Time
[ "cs.DS" ]
We introduce a new approach to the maximum flow problem in undirected, capacitated graphs using $\alpha$-\emph{congestion-approximators}: easy-to-compute functions that approximate the congestion required to route single-commodity demands in a graph to within a factor of $\alpha$. Our algorithm maintains an arbitrary flow that may have some residual excess and deficits, while taking steps to minimize a potential function measuring the congestion of the current flow plus an over-estimate of the congestion required to route the residual demand. Since the residual term over-estimates, the descent process gradually moves the contribution to our potential function from the residual term to the congestion term, eventually achieving a flow routing the desired demands with nearly minimal congestion after $\tilde{O}(\alpha\eps^{-2}\log^2 n)$ iterations. Our approach is similar in spirit to that used by Spielman and Teng (STOC 2004) for solving Laplacian systems, and we summarize our approach as trying to do for $\ell_\infty$-flows what they do for $\ell_2$-flows. Together with a nearly linear time construction of a $n^{o(1)}$-congestion-approximator, we obtain $1+\eps$-optimal single-commodity flows undirected graphs in time $m^{1+o(1)}\eps^{-2}$, yielding the fastest known algorithm for that problem. Our requirements of a congestion-approximator are quite low, suggesting even faster and simpler algorithms for certain classes of graphs. For example, an $\alpha$-competitive oblivious routing tree meets our definition, \emph{even without knowing how to route the tree back in the graph}. For graphs of conductance $\phi$, a trivial $\phi^{-1}$-congestion-approximator gives an extremely simple algorithm for finding $1+\eps$-optimal-flows in time $\tilde{O}(m\phi^{-1})$.
cs.DS
cs
Nearly Maximum Flows in Nearly Linear Time Jonah Sherman∗ University of California, Berkeley May 11, 2014(preliminary draft) Abstract We introduce a new approach to the maximum flow problem in undirected, capacitated graphs using α- congestion-approximators: easy-to-compute functions that approximate the congestion required to route single-commodity demands in a graph to within a factor of α. Our algorithm maintains an arbitrary flow that may have some residual excess and deficits, while taking steps to minimize a potential function measuring the congestion of the current flow plus an over-estimate of the congestion required to route the residual demand. Since the residual term over-estimates, the descent process gradually moves the contribution to our potential function from the residual term to the congestion term, eventually achieving a flow routing the desired demands with nearly minimal congestion after O(αε−2 log2 n) iterations. Our approach is similar in spirit to that used by Spielman and Teng (STOC 2004) for solving Laplacian systems, and we summarize our approach as trying to do for (cid:96)∞-flows what they do for (cid:96)2-flows. Together with a nearly linear time construction of a no(1)-congestion-approximator, we obtain 1 + ε-optimal single-commodity flows undirected graphs in time m1+o(1)ε−2, yielding the fastest known algorithm for that problem. Our requirements of a congestion-approximator are quite low, suggesting even faster and simpler algorithms for certain classes of graphs. For example, an α-competitive oblivious routing tree meets our definition, even without knowing how to route the tree back in the graph. For graphs of conductance φ, a trivial φ−1-congestion-approximator gives an extremely simple algorithm for finding 1 + ε-optimal-flows in time O(mφ−1). 1 Introduction The maximum flow problem and its dual, the minimum cut problem are fundamental combinatorial opti- mization problems with a wide variety of applications. In the well-known maximum s − t flow problem we are given a graph G with edge capacities ce, and aim to route as much flow as possible from s to t while restricting the magnitude of the flow on each edge to its capacity. We will prefer instead to think in terms of the equivalent problem of routing a single unit of flow from s to t while minimizing the maximum congestion fe/ce on any edge; clearly the minimum congestion for unit flow is equal to one divided by the maximum flow of congestion one. Once formulated that way, we need no longer restrict ourselves to s − t flows; given a demand vector b ∈ Rn specifying the excess desired at each vertex, we aim to find a flow f ∈ Rm with divergence equal to b that minimizes the maximum congestion fe/ce.1 In this paper, we introduce a new approach to this problem in undirected graphs. We maintain a flow that may not quite route b exactly, but we also keep track of an upper bound on how much it will cost us in congestion to fix it back up. We will aim to minimize a potential function measuring the current congestion plus an over-estimate on the cost of fixing up the residuals. By not needing to worry about precisely conserving flow at every vertex, we can take large steps in each iteration towards minimizing our potential function. On the other hand, by intentionally over-estimating the cost of fixing up the residuals, in the course of minimizing our potential function we must inevitably fix them up, as it will cost strictly less to do so. For a graph G, let C be the m × m diagonal matrix containing the edge capacities, and let B be the i∈S bS, e:S↔V \S ce, the capacity of the cut (S, V \ S) in G. A valid demand vector n × m divergence matrix, where (Bf )i is the excess at vertex i. For a set S ⊆ V , we’ll write bS =(cid:80) the total excess in S, and cS =(cid:80) satisfies bV = 0. ∗Research supported in part by a Microsoft Graduate Fellowship and in part by a NSF Graduate Fellowship 1In fact the s− t case is no less general, since one could always add a new vertices s and t, connect each v to s or t according to the sign of bv with an edge of capacity βbv and scale β until the additional edges are saturated. The minimum congestion flow problem for demands b, and its dual, the maximum congested cut, are min (cid:107)C−1f(cid:107)∞ s.t. Bf = b max s.t. (cid:107)CB(cid:62)v(cid:107)1 ≤ 1 b(cid:62)v (1) (2) We refer to the optimum value of these problems as opt(b). It is well-known that for problem (2), one of the threshold cuts with respect to v achieves bS/cS ≥ b(cid:62)v. 1.1 History Much of the early work on this problem considers the general, directed edge case, culminating in the still- best binary blocking flow algorithm of Goldberg and Rao[4] that achieves O(m min(m1/2, n2/3) time. Karger and Levine[6] give evidence that the undirected case seems easier in graphs with small flow values. The smooth sparsification technique of Bencz´ur and Karger[1] shows one can split a graph with m edges into t = O(mε2/n) graphs each with with O(nε−2) edges, and each of which has at least (1− ε)/t of the capacity of the original graph. Therefore, for undirected graphs, any algorithm running in time T (m, n) can be replaced with one running in time O(m) + (m/n)T ( On, n). Using the algorithm of Goldberg and Rao yields approximate maximum flows in O(mn1/2) time, and for many years that was the best known. In a breakthrough, Christiano et al. show how to compute approximate maximum flows in O(mn1/3) time[3]. Their new approach uses the nearly linear-time Laplacian solver of Spielman and Teng[12] to take steps in the minimization of a softmax approximation of the edge congestions. Each step involves minimizing (cid:107)W C−1f(cid:107)2, a weighted (cid:96)2-norm of the congestions. While a naive analysis yields immediately yields a method that makes O( m factor), they present a surprising and insightful analysis showing in fact only O(m1/3) such (cid:96)2 iterations suffice. The maximum-flow-specific parts of [3] are quite simple, needing only to maintain the weights W and then using the Spielman-Teng solver as a black box. m) such iterations (because (cid:107) · (cid:107)2 approximates (cid:107) · (cid:107)∞ by a √ √ 1.2 Outline In this work we pry open that box, extract the parts we need, and apply them directly to the maximum flow problem. In the course of doing so, we push the running time for this decades-old problem nearly down to linear. Solving a Laplacian system Lv∗ = b∗, where L = BCB(cid:62), corresponds to finding a flow f∗ with Bf∗ = b∗ minimizing (cid:107)C−1/2f(cid:107)2. While Spielman and Teng work entirely in the dual space of vertex potentials and never explicitly represent flows, we can still translate between spaces throughout the algorithm to get an idea of what is actually going on. At any point, the vertex potentials v induce an optimal flow for some demands b = Lv; just perhaps not the ones desired. The solution of Spielman and Teng is to maintain a simpler graph G(cid:48) that approximates G, in the sense that the (cid:96)2 cost of routing flows in G(cid:48) is within some factor α of the cost in G. The residual flow is routed optimally in G(cid:48)(recursively), by solving L(cid:48)v(cid:48) = b∗ − b. The potentials that induced that flow are added to v, in the hope that Lv + Lv(cid:48) (cid:117) Lv + L(cid:48)v(cid:48) = b∗. Indeed, if G(cid:48) approximates G by a factor α, then b∗ − b gets smaller in a certain norm by (1 − 1/α), nudging the flow towards actually routing b∗. Our first step towards obtaining a ST-like algorithm is the definition of a good approximator for the congestion required by (cid:96)∞-flows. Definition 1.1. An α-congestion-approximator for G is a matrix R such that for any demand vector b, (cid:107)Rb(cid:107)∞ ≤ opt(b) ≤ α(cid:107)Rb(cid:107)∞ Our main result is that we can use good congestion approximators to quickly find near-optimal flows in a graph. We prove the following theorem in section 2. Theorem 1.2. There is an algorithm that, given demands b and access to an α-congestion-approximator R, makes O(αε−2 log2(n)) iterations and then returns a flow f and cut S with Bf = b and (cid:107)C−1f(cid:107) ≤ (1 + ε)bS/cS. Each iteration requires O(m) time, plus a multiplication by R and R(cid:62). For the sake of giving the reader a concrete example of what a congestion-approximator might look like before continuing, we’ll begin with two simple toy examples. 2 Example 1.3. Let T be a maximum weight spanning tree in G, and let R be the n − 1 × n matrix with a row for each edge in T , and (Rb)e = bS cS where (S, V \ S) is the cut in G induced by removing e from T . Then, R is a m-congestion-approximator. Proof. Since (Rb)e is the congestion on the cut in G induced by removing e from T , certainly opt(b) ≥ (cid:107)Rb(cid:107)∞. On the other hand, at least 1/m of the capacity of those cuts is contained in T , so routing b through T congests e by at most m(Rb)e. Multiplication by R and R(cid:62) can be done in O(n) time via elimination on leaves. For graphs of large conductance, we can obtain a trivial approximator by simply looking at how much the demand into each vertex congests its total degree. Example 1.4. Let G have conductance φ. Let R be n × n diagonal matrix with Ri,i = 1/ deg(i) where deg(i) = c{i}. Then, R is a φ−1-congestion-approximator. Proof. Routing bi into or out of vertex i certainly must congest one of its edges by at least bi/ deg(i), so opt(b) ≥ (cid:107)Rb(cid:107)∞. On the other hand, the capacity of any cut in G is at least φ times the total degree of the smaller side. It follows that if no vertex is congested by more than β, then no cut is congested by more than φ−1β. Those two simple examples are analogous to the simple cases for (cid:96)2 flows in the ST-algorithm. The former is analogous to preconditioning by a small-stretch spanning tree, while the latter is analogous to not preconditioning at all. As in the ST-algorithm, those two simple examples in fact capture the ideas behind our real constructions. In section 3, we show how to apply the j-tree decomposition of Madry[10] (itself based on the ultrasparsifiers of Spielman and Teng[12])) to obtain good congestion approximators for any graph. Theorem 1.5. For any 1 ≤ k ≤ log n, there is an algorithm to construct a data structure representing a log(n)O(k)-congestion-approximator R in time O(m + n1+1/k). Once constructed, R and R(cid:62) can each be applied in time O(n1+1/k). √ Combining theorem 1.5 where k = θ( log n) with theorem 1.2 yields our main result of a nearly-linear time algorithm for minimum congestion flows. Theorem 1.6. There is an algorithm to compute (1 + ε)-approximate minimum congestion flows in time mε−2 · exp( O( log n)). For graphs of conductance φ, the same can be done in time O(mφ−1). √ 2 Congestion Potential The key to our scheme lies transforming problem (1) to an unconstrained optimization problem, using the congestion-approximator to bound the cost of routing the residual. To that end, we introduce our potential function. min(cid:107)C−1f(cid:107)∞ + 2α(cid:107)R(b − Bf )(cid:107)∞ (3) We believe the mere statement of the potential function (3) to be the most important idea in this paper. Once (3) has been written down, the remainder of our algorithm is nearly obvious. We solve problem (3) nearly-optimally by approximating (cid:107)·(cid:107)∞ with a softmax. The softmax is well-approximated by its gradient in the region where steps are taken with (cid:96)∞-norm O(1). Since (cid:107)RBC(cid:107)∞→∞ ≤ 1 for a congestion-approximator, we can take steps on edge e of size Ω(α−1)ce. We include the details at the end of this section, proving the following theorem. Theorem 2.1. There is an algorithm AlmostRoute that given b and ε ≤ 1/2, performs O(αε−2 log n) iterations and returns a flow f and cut S with, (cid:107)C−1f(cid:107)∞ + 2α(cid:107)R(b − Bf )(cid:107)∞ ≤ (1 + ε) bS cS Each iteration requires O(m) time plus a multiplication by R and R(cid:62). 3 The flow f may not quite route the demands we wanted. Fortunately, that will be easy to fix. The extra factor of two in equation (3) means that half of the contribution to the objective value from the residual part is pure slack. On the other hand, if f is nearly optimal, there can’t be too much slack. Lemma 2.2. Suppose (cid:107)C−1f(cid:107)∞ + 2α(cid:107)R(b − Bf )(cid:107)∞ ≤ (1 + ε)opt(b). Then, (cid:107)R(b − Bf )(cid:107)∞ ≤ ε(cid:107)Rb(cid:107)∞. Proof. Let f meet the assumption. Let f(cid:48) be a routing of b − Bf in G with (cid:107)C−1f(cid:48)(cid:107)∞ ≤ α(cid:107)R(b − Bf )(cid:107)∞. Then, moving from f to f + f(cid:48) decreases the objective value by atleast α(cid:107)R(b − Bf )(cid:107). On the other hand, that decrease can’t exceed εopt(b). Since opt(b) ≤ α(cid:107)Rb(cid:107)∞, the lemma follows. So while AlmostRoute may not route b, our bound for the congestion to route the residual is at most half of our bound to route the original demands. Furthermore, the objective already pays the cost of routing that residual. In fact, it pays it with a factor of two, so we need only route the remaining residual within a factor-two of optimal. That suggests an obvious way to route demands b: repeatedly invoke AlmostRoute on the remaining residual, until the congestion required to route it is extremely small compared to the congestion required to route b. Then route the final residual in a naive way, such as via a maximal spanning tree. The cost of that final routing will be paid for by the slack in the objective value of the first routing, simply by finding a factor 3/2-optimal routing for each residual after the first case. Formalizing the latter argument completes our proof of theorem 1.2. Set b0 ← b, and let (f0, S0) ← AlmostRoute(b0, ε). Next for i = 1, . . . , T where T = log(2m), set bi ← bi−1 − Bfi−1 and (fi, Si) ← AlmostRoute(bi, 1/2) (we don’t actually need any Si after S0). Finally, let bT +1 = bt − Bft, and let fT +1 be a flow routing bT +1 in a maximal spanning tree of G. Output f1 +··· + fT +1 and S0. Observe that theorem 2.1 yields (cid:107)C−1f0(cid:107)∞ + 2α(cid:107)Rb1(cid:107)∞ ≤ (1 + ε)bS0/cS0 (cid:107)C−1fi(cid:107)∞ + 2α(cid:107)Rbi+1(cid:107)∞ ≤ (3/2)opt(bi) ≤ (3/2)α(cid:107)Rbi(cid:107)∞ Beginning with the former inequality and repeatedly applying the latter yields, (1 + ε) bS0 cS0 ≥ (cid:107)C−1f0(cid:107)∞ + 2α(cid:107)Rb1(cid:107)∞ ≥ (1/2)α(cid:107)Rb1(cid:107)∞ + (cid:107)C−1f0(cid:107)∞ + (cid:107)C−1f1(cid:107)∞ + 2α(cid:107)Rb2(cid:107)∞ ... ≥ (1/2)α(cid:107)Rb1(cid:107)∞ + (cid:107)C−1f0(cid:107)∞ + ··· + (cid:107)C−1fT(cid:107)∞ + 2α(cid:107)RbT +1(cid:107)∞ On the other hand, by choice of T , we have (cid:107)C−1fT +1(cid:107)∞ ≤ mα(cid:107)RbT +1(cid:107)∞ ≤ mα2−T(cid:107)Rb1(cid:107)∞ ≤ (1/2)α(cid:107)Rb1(cid:107)∞ Combining the two yields the theorem. 2.1 Proof of Theorem 2.1 For this preliminary draft, we prove theorem 2.1 with slightly worse parameters of O(α2ε−3 log2(n)), using √ naive steepest descent. The better parameters follow from using Nesterov’s accelerated gradient method[11] √ instead, as will be proved in the final version of this paper. Of course, for the case of α = exp( O( log n), then still α2 = exp( O( log n)), so this naive analysis still yields nearly linear-time flow algorithms. We approximate (cid:107) · (cid:107)∞ using the symmetric softmax function. (cid:32)(cid:88) (cid:33) lmax(x) = log exi + e−xi We make use of some elementary facts about lmax. Fact 2.3. Let x, y ∈ Rd. Then, i (cid:107)∇ lmax(x)(cid:107)1 ≤ 1 ∇ lmax(x)(cid:62)x ≥ lmax(x) − log(2d) (cid:107)∇ lmax(x) − ∇ lmax(y)(cid:107)1 ≤ (cid:107)x − y(cid:107)∞ (4) (5) (6) 4 We will approximate problem (3) with the potential function, φ(f ) = lmax(C−1f ) + lmax (2αR(b − Bf )) (7) Since equation (7) approximates equation (3) to within an additive θ(log n), we will be concerned with minimizing φ(f ) after scaling f, b so φ(f ) = θ(ε−1 log n). AlmostRoute(b, ε): • Initialize f = 0, scale b so 2α(cid:107)Rb(cid:107)∞ = 16ε−1 log(n). • Repeat: – While φ(f ) < 16ε−1 log(n), scale f and b up by 17/16. – Set δ ← (cid:107)C∇φ(f )(cid:107)1. – If δ ≥ ε/4, set fe ← fe − δ – Otherwise, terminate and output f together with the potentials induced by ∇φ(f )(see below), 1+4α2 sgn(∇φ(f )e)ce after undoing any scaling. Each step requires computing ∇φ(f ), which requires O(m) time plus a multiplication by R and a mul- tiplication by R(cid:62). Further, the partial derivative of the residual part for a particular edge is equal to a potential difference between the endpoints of that edge. When φ(f ) is nearly-optimal, those potentials yield a good dual solution for our original problem. Lemma 2.4. When AlmostRoute terminates, we have a flow f and potentials v with, (cid:107)C−1f(cid:107)∞ + 2α(cid:107)R(b − Bf )(cid:107)∞ ≤ (1 + ε) b(cid:62)v (cid:107)CB(cid:62)v(cid:107)1 Proof. Set x1 = C−1f , x2 = 2αR(b−Bf ), and pi = ∇ lmax(xi). Set v = R(cid:62)p2 to be our potentials. Observe that ∇φ(f ) = C−1p1 − 2αB(cid:62)v. First, equation (4) yields 2α(cid:107)CB(cid:62)v(cid:107)1 ≤ (cid:107)p1(cid:107)1 + (cid:107)p1 − 2αCB(cid:62)v(cid:107)1 ≤ 1 + δ By equation (5), using the fact that C and R have at most n2/2 rows and φ(f ) ≥ 16ε−1 log n, p(cid:62) 1 C−1f + 2αp(cid:62) 2 R(b − Bf ) ≥ φ(f ) − 4 log n ≥ φ(f )(1 − ε/4) On the other hand, δφ(f ) ≥ (cid:107)C∇φ(f )(cid:107)1(cid:107)C−1f(cid:107)∞ 2 RBf ≥ ∇φ(f )(cid:62)f = (C−1p1 − 2αBT RT p2)(cid:62)f = p(cid:62) 1 C−1f − 2αp(cid:62) Combining the two yields, 2αb(cid:62)v ≥ φ(f )(1 − ε/4 − δ) Altogether, using the fact that δ < ε/4 at termination, we have b(cid:62)v (cid:107)CB(cid:62)v(cid:107)1 ≥ φ(f )(1 − ε/2) 1 + ε/4 ≥ φ(f ) 1 + ε Observing that φ(f ) overestimates (cid:107)C−1f(cid:107)∞ + 2α(cid:107)R(b − Bf )(cid:107)∞ completes the proof. Lemma 2.5. AlmostRoute terminates after at most O(α2ε−3 log n) iterations. Proof. Let us call the iterations between each scaling a phase. Since (cid:107)Rb(cid:107)∞ gives us the correct scale to within factor α, we will scale at most O(log α) times. 5 Let he = − δ 1+4α2 sgn(∇f φ(f )e)ce be our step. Then, equation (6), together with the fact that (cid:107)RBC(cid:107)∞→∞ ≤ 1 for a congestion-approximator R yields, φ(f + h) ≤ φ(f ) + ∇φ(f )(cid:62)h + 1 + 4α2 2 (cid:107)C−1h(cid:107)2∞ = φ(f ) − δ2 2 + 8α2 = φ(f ) − Ω(ε2α−2) Since we raised φ(f ) by at most ε−1 log n when scaling, and each step drops φ(f ) by at least Ω(ε2α−2), there can be at most O(α2ε−3 log n) steps between phases. 3 Computing Congestion-Approximators In this section we prove theorem 1.5, using a construction of Madry[10], itself based on a construction of Spielman and Teng[12]. Definition 3.1 (Madry[10]). A j-tree is a graph formed by the union of a forest with j components, together with a graph H on j vertices, one from each component. The graph H is called the core. Theorem 3.2 (Madry[10]). For any graph G and t ≥ 1, we can find in time O(tm) a distribution of t graphs (λi, Gi) such that, • Each Gi is a O(m log m/t)-tree, with a core containing at most m edges. • Gi dominates G on all cuts. i λiGi can be routed in G with congestion O(log n). • (cid:80) We briefly remark that while the statement of theorem 3.2 in [10] contains an additional logarithmic dependence on the capacity-ratio of G, that dependence is easily eliminated. We elaborate further in appendix A. Our construction will simply apply theorem 3.2 recursively, sparsifying the core on each iteration. To accomplish that, we use an algorithm of Bencz´ur and Karger[1]. Theorem 3.3 (Bencz´ur, Karger[1]). There is an algorithm Sparsify(G, ε) that, given a graph G with m edges, takes O(m) time and returns a graph G(cid:48) with m(cid:48) = O(nε−2 log n) edges such that the capacity of cuts in the respective graphs satisfy G ≤ G(cid:48) ≤ (1 + ε)G Further, the edges of G(cid:48) are scaled versions of a subset of edges in G, with no edge scaled by more than (1 + ε)m/m(cid:48). We now present the algorithm for computing the data structure representing a congestion-approximator. The algorithm ComputeTrees assumes its input is sparse; our top-level data-structure is constructed by invoking ComputeTrees(Sparsify(G, 1), n1/k), where k is the parameter of theorem 1.5. ComputeTrees(G, t): • If n = 1, return. • Using theorem 3.2, compute distribution (λi, Gi)t(cid:48) • Pick the t graphs of largest λi, throw away the rest, and scale the kept λi to sum to 1. • For i = 1, . . . , t: i of max(1, n/t)-trees. i ← Sparsify(Hi, 1), where Hi is the core of Gi – H(cid:48) – Li ← ComputeTrees(H(cid:48) i, t) • Return the list L = (λi, Fi, Li)t i=1 where Fi is the forest of Gi. 6 The analysis of ComputeTrees correctness will make use of another algorithm for sampling trees. The SampleTree procedure is only used for analysis, and is not part of our flow algorithm. SampleTree(L = (λi, Fi, Ti)t i): • Pick i with probability λi. • Output Fi + SampleTree(Ti) Lemma 3.4. Let G have O(n) edges, and set L ← ComputeTrees(G, t). Then, every tree in the sample space of SampleTree(L) dominates G on all cuts, and E[SampleTree(L)] is routable in G with congestion log(n)log(n)/log(t). Further, the computation of L takes O(tn) time. Proof. By induction on n. For n = 1 the claim is vacuous, so suppose n = tk+1. Since G has O(n log n) edges, i ≥ Hi and Hi + Fi ≥ G. the distribution output by theorem 3.2 will have O(t log2 n) entries. We have H(cid:48) Furthermore, the inductive hypothesis implies that every tree Ti in SampleTree(Li) dominates H(cid:48) i. Then, Sparsifying the distribution from O(t log2 n) to t scales λi by at most O(log2 n), so that (cid:80)t i + Fi ≥ Hi + Fi = Gi ≥ G Ti + Fi ≥ H(cid:48) routable in G with congestion at most log2 n larger than the original distribution. Since H(cid:48) the multicommodity max-flow/min-cut theorem[9] H(cid:48) inductive hypothesis, E[SampleTree(Li)] is routable in H(cid:48) E[SampleTree(L)] is routable in G with congestion at most logO(k+1)(n). i=1 λiGi is i ≤ 2Hi, by i is routable in Hi with congestion O(log n). By the i with congestion logO(k)(n). It follows then that Finally, ComputeTrees requires O(tn) time to compute the distribution, another O(tn) time to sparsify the cores, and then makes t recursive calls on sparse graphs with n/t vertices. It follows that the running time of ComputeTrees is O(tn). Lemma 3.5. Let R be the matrix that has a row for each forest edge in our data structure, and (Rb)e is the congestion on that edge when routing b. If E[SampleTree(L)] is routable in G with congestion α, then R is a α-congestion-approximator for G. Further, R has O(tn) rows. Proof. Since the capacity of each tree-edge dominates the capacity of the corresponding cut in G, opt(b) ≥ (cid:107)Rb(cid:107)∞. On the other hand, b can be routed in every tree with congestion (cid:107)Rb(cid:107)∞. By routing a Pr[T ] fraction of the flow through tree T , we route b in E[SampleTree(L)] with congestion (cid:107)Rb(cid:107)∞. But then b can be routed in G while congesting by at most an α factor larger. The total number of edges in R satisfies the recurrence E(n) ≤ nt + tE(n/t) as each edge is either in one of the t toplevel forests, or in one of the t subgraphs. Having constructed our representation of R, it remains only to show how to multiply by R and R(cid:62). We use the following lemmas as subroutines, which are simple applications of leaf-elimination on trees. Lemma 3.6. There is an algorithm TreeFlow that, given a tree T and a demand vector b, takes O(n) time and outputs for each tree edge, the flow along that edge when routing b in T . Lemma 3.7. There is an algorithm TreePotential that, given a tree T annotated with a price pe for each edge, takes O(n) time and outputs a vector of vertex potentials v such that, for any i, j, the sum of the prices on the path from j to i in T is vi − vj. We begin with computing R. We take as input the demand vector b, and then annotate each forest edge e with the congestion re induced by routing b through a tree containing e. 7 ComputeR(b, L = (λi, Fi, Ti)t i): • For i = 1, . . . , t: – Let T be the tree formed by taking Fi, adding a new vertex s, and an edge from s to each core-vertex of Fi. Augment b with demand zero to the new vertex. j equal to the flow on the edge from s to – f ← TreeFlow(b, T ). – Set re ← fe/ce for each forest edge in Fi. – Set b(cid:48) to a vector indexed by core-vertices, with b(cid:48) core-vertex j. – ComputeR(b(cid:48), Ti). Lemma 3.8. The procedure ComputeR(b, L) correctly annotates each edge e with re = (Rb)e, and takes O(tn) time. Proof. Let L = (λi, Fi, Ti)t i. We argue by induction on the depth of recursion. Fix a level and index i. Observe that the cut in G induced by cutting a forest edge is the same regardless of what tree T lies on the core: it is the cut that separates the part of Fi not containing the core from the rest of the vertices. It follows that we may place any tree on the core vertices, invoke TreeFlow, and obtain the flow on each forest edge. Next, for each component S of Fi, the total excess bS must enter S via the core vertex. It follows that in a flow routing b on Fi + T (cid:48), for any tree T (cid:48), the restriction of that flow to T (cid:48) must have excess bS on the core vertex of S, so it suffices to find a flow in the core with demands b(cid:48) j = bSj . But routing b in Fi + T will place exactly bSj units of flow on the edge from s to core-vertex j. The running time consists of t invocations of TreeFlow each taking O(n) time, plus t recursive calls on graphs of size n/t, for a total running time of O(tn). To compute R(cid:62), we assume each forest edge e has been annotated with a price pe that must be paid by any flow per unit of congestion on that edge, and output potentials v such that vi − vj is the total price to be paid for routing a unit of flow from j to i. ComputeR(cid:62)(L = (λi, Fi, Ti)t i): • v ← 0 • For i = 1, . . . , t: – v(cid:48) ← ComputeR(cid:62)(Ti). – Let T be the tree formed by taking Fi, adding a vertex s, and an edge from s to each core-vertex of Fi. Set qe = pe/ce for each forest edge, and qe = v(cid:48) j for edge e from s to core-vertex j. – v(cid:48)(cid:48) ← TreePotential(T, q) – Add v(cid:48)(cid:48) to v after removing the entry for s. • Return v Lemma 3.9. Given edges annotated with per-congestion prices, the procedure ComputeR(cid:62)(L) correctly re- turns potentials v such that vk − vj is the cost per unit of flow from vertex j to k. Proof. Let L = (λi, Fi, Ti)t i. We argue by induction on the depth of recursion. Fix a level; a flow must pay its toll to each Gi, so the resulting potential equals the sum of the potentials for each i. Fix an index i. A unit of flow from j to k is first routed from j to the core-vertex of the component of Fi containing j, then to the core-vertex of the component containing k, and then finally to k. By induction, we assume that v(cid:48) yields potentials that give the per-unit costs of routing between core-vertices. Placing a star on the core with the edge from s to core-vertex j having per-unit cost v(cid:48) j preserves those costs. If pe is the price of an edge per unit of congestion, then qe = pe/ce is the price of an edge per unit of flow. It follows that the total toll paid is the same as the toll paid in T ; thus, the potentials output by TreePotential(T, q) are correct. The running time consists of t recursive calls to ComputeR(cid:62) on graphs of size n/t, plus t invocations of TreePotential each taking O(n) time, for a total running time of O(tn). 8 4 Final Remarks We remark that there are many other ways to obtain good congestion approximators. The oblivious routing schemes of [5, 2] require polynomial time to compute, but, once computed, give us a single tree whose single- edge cuts yield a log(n)O(1)-congestion approximator. Furthermore, we only need the actual tree, and not the routings of the tree back in the original graph. If such a single tree could be computed in nearly-linear time, it would make an ideal candidate for use in our algorithm. There have been substantial simplifications to Spielman and Teng’s original algorithm (see [8, 7]). It may be possible to use some of those techniques to further simplify our algorithm. References [1] Andr´as A. Bencz´ur and David R. Karger. Randomized approximation schemes for cuts and flows in capacitated graphs. CoRR, cs.DS/0207078, 2002. [2] Marcin Bienkowski, Miroslaw Korzeniowski, and Harald Racke. A practical algorithm for constructing oblivious routing schemes. In SPAA, pages 24–33. ACM, 2003. [3] Paul Christiano, Jonathan A. Kelner, Aleksander Madry, Daniel A. Spielman, and Shang-Hua Teng. Electrical flows, laplacian systems, and faster approximation of maximum flow in undirected graphs. In Lance Fortnow and Salil P. Vadhan, editors, STOC, pages 273–282. ACM, 2011. [4] Andrew V. Goldberg and Satish Rao. Beyond the flow decomposition barrier. J. ACM, 45(5):783–797, 1998. [5] Chris Harrelson, Kirsten Hildrum, and Satish Rao. A polynomial-time tree decomposition to mini- In Proceedings of the fifteenth annual ACM symposium on Parallel algorithms and mize congestion. architectures, SPAA ’03, pages 34–43, New York, NY, USA, 2003. ACM. [6] David R. Karger and Matthew S. Levine. Finding maximum flows in undirected graphs seems easier than bipartite matching. In Jeffrey Scott Vitter, editor, STOC, pages 69–78. ACM, 1998. [7] Jonathan A. Kelner, Lorenzo Orecchia, Aaron Sidford, and Zeyuan Allen Zhu. A simple, combinatorial algorithm for solving sdd systems in nearly-linear time. CoRR, abs/1301.6628, 2013. [8] Ioannis Koutis, Gary L. Miller, and Richard Peng. A fast solver for a class of linear systems. Commun. ACM, 55(10):99–107, 2012. [9] Tom Leighton and Satish Rao. Multicommodity max-flow min-cut theorems and their use in designing approximation algorithms. J. ACM, 46(6):787–832, 1999. [10] Aleksander Madry. Fast approximation algorithms for cut-based problems in undirected graphs. In FOCS, pages 245–254. IEEE Computer Society, 2010. [11] Yu Nesterov. Smooth minimization of non-smooth functions. Math. Program., 103(1):127–152, May 2005. [12] Daniel A. Spielman and Shang-Hua Teng. Nearly-linear time algorithms for preconditioning and solving symmetric, diagonally dominant linear systems. CoRR, abs/cs/0607105, 2006. A Fixing Theorem 3.2 The proof of theorem 3.2 maintains a length function l(e) for each edge, and repeatedly invokes an algorithm SmallStretchTree that returns a spanning tree T on G with, l(e)c(e) (8) (cid:88) (cid:88) lT (e)c(e) ≤ O(log n) e e 9 where lT (e) is the length of the path between e’s endpoints in the tree. Without loss of generality, by scaling, e l(e)c(e) = m. Let χ(e, e(cid:48)) = 1 if e(cid:48) is a tree edge that lies on the path in T containing e. chi(e, e(cid:48))l(e(cid:48)) = l(e(cid:48)) χ(e, e(cid:48))c(e) = l(e(cid:48))cT (e(cid:48)) (cid:88) e(cid:48) (cid:88) e (cid:88) e(cid:48) we assume (cid:80) Then, (cid:88) (cid:88) (cid:88) e(cid:48) lT (e)c(e) = c(e) e e where cT (e(cid:48)) is the total capacity of edges routed through e(cid:48) in T . The dependence on the capacity ratio arises from the fact that there may be many different scales of congestion on the edges of T . The solution is simply to replace l with l(cid:48)(e) = l(e)+c(e)−1 , a mixture of the original lengths with the inverse capacities. Constructing a small-stretch tree with respect to l(cid:48) still satisfies equation (8) with an extra factor of two, but also implies no tree edge is congested by more than O(m). 2 10
1512.02157
2
1512
2016-02-23T03:46:59
Finding $k$ Simple Shortest Paths and Cycles
[ "cs.DS", "cs.DM" ]
The problem of finding multiple simple shortest paths in a weighted directed graph $G=(V,E)$ has many applications, and is considerably more difficult than the corresponding problem when cycles are allowed in the paths. Even for a single source-sink pair, it is known that two simple shortest paths cannot be found in time polynomially smaller than $n^3$ (where $n=|V|$) unless the All-Pairs Shortest Paths problem can be solved in a similar time bound. The latter is a well-known open problem in algorithm design. We consider the all-pairs version of the problem, and we give a new algorithm to find $k$ simple shortest paths for all pairs of vertices. For $k=2$, our algorithm runs in $O(mn + n^2 \log n)$ time (where $m=|E|$), which is almost the same bound as for the single pair case, and for $k=3$ we improve earlier bounds. Our approach is based on forming suitable path extensions to find simple shortest paths; this method is different from the `detour finding' technique used in most of the prior work on simple shortest paths, replacement paths, and distance sensitivity oracles. Enumerating simple cycles is a well-studied classical problem. We present new algorithms for generating simple cycles and simple paths in $G$ in non-decreasing order of their weights; the algorithm for generating simple paths is much faster, and uses another variant of path extensions. We also give hardness results for sparse graphs, relative to the complexity of computing a minimum weight cycle in a graph, for several variants of problems related to finding $k$ simple paths and cycles.
cs.DS
cs
Finding k Simple Shortest Paths and Cycles Udit Agarwal ∗ and Vijaya Ramachandran ∗ February 24, 2016 Abstract We present algorithms and hardness results for several problems related to finding multiple simple shortest paths in a graph. Our main result is a new algorithm for finding k simple shortest paths for all pairs of vertices in a weighted directed graph G = (V, E). For k = 2 our algorithm runs in O(mn + n2 log n) time where m and n are the number of edges and vertices in G. Our approach is based on forming suitable path extensions to find simple shortest paths; this method is different from the 'detour finding' technique used in most of the prior work on simple shortest paths, replacement paths, and distance sensitivity oracles. We complement this result by showing that finding 2 simple shortest paths even for a single pair of vertices is at least as hard as finding a minimum weight cycle in G, for which no sub-mn time algorithm is known. We present new algorithms for generating simple cycles and simple paths in G in non- decreasing order of their weight. The algorithm for generating simple paths is much faster, and uses another variant of path extensions. We also give hardness results for sparse graphs, relative to the complexity of computing a minimum weight cycle in a graph, for several variants of problems related to finding k simple paths and cycles, and we give related results for undirected graphs. 1 Introduction Computing shortest paths in a weighted directed graph is a very well-studied problem. Let G = (V, E) be a directed graph with non-negative edge weights, with V = n, E = m. Then, a shortest path for a single pair of vertices can be computed in O(m) time, and the all pairs shortest paths (APSP) in O(mn) time [3], where O hides polylog(n) factors. A related problem is one of computing a sequence of k shortest paths, for k > 1. If the paths need not be simple, the problem of generating k shortest paths is also well understood, and the most efficient algorithm is due to Eppstein [7], which has the following bounds - O(m + n log n + k) for a single pair of vertices and O(m + n log n + kn) for single source. It is noted in [7] that the simple paths version of the k shortest paths problem is more common than the unconstrained version considered in [7]. In the k simple shortest paths problem, given a pair of vertices s, t, the output is a sequence of k simple paths from s to t, where the i-th path in the collection is a shortest simple path in the graph that is not identical to any of the i − 1 paths preceding it in the output. (Note that these k simple shortest paths need not have the same weight). ∗Dept. Email: of Computer Science, University of Texas, Austin TX 78712. [email protected], [email protected]. This work was supported in part by NSF Grant CCF-1320675. The first author's research was also supported in part by a Calhoun Fellowship. 1 The all-pairs version of this problem (where the paths need not be simple) was considered in the classical papers of Lawler [21, 22] and Minieka [25], and the most efficient current algorithm for k-APSP runs the SSSP algorithm in [7] on each of the n vertices in turn. In this paper, a central problem we consider the all-pairs version of this problem when the paths are required to be simple (k-APSiSP). It was noted in Minieka [25] that the all-pairs version of k shortest paths becomes significantly harder when simple paths are required. Even for a single source-sink pair, the problem of generating k simple shortest paths (k-SiSP) is considerably more challenging than the unrestricted version considered in [7]. Yen's algorithm [35] finds the k simple shortest paths for a specific pair of vertices in O(k· (mn + n2 log n)). Gotthilf and Lewenstein [10] improved the time bound slightly to O(k(mn + n2 log log n)). In terms of hardness of this problem, it is shown by- V. Williams and R. Williams [34] that if the second simple shortest path for a single source-sink pair (i.e., k = 2 in k-SiSP) can be found in O(n3−δ) time for some δ > 0, then APSP can also be computed in O(n3−α) time for some α > 0; the latter is a major open problem. (In this formulation, the dependence on m, the number of edges, is not considered.) The k-SiSP problem is much simpler in the undirected case and is known to be solvable in O(k(m+ n log n)) time [19]. For unweighted directed graphs, Roditty and Zwick [29] gave an O(km√n) randomized algorithm for k-SiSP. They also showed that k-SiSP can be solved with O(k) executions of an algorithm for the 2-SiSP problem. Approximation algorithms for k-SiSP are considered in [28, 1]. Other related results can be found in [8, 9, 11, 12, 13, 14, 20, 24, 23, 26, 30]. A problem related to 2-SiSP is the replacement paths problem. In the s-t version of this problem, we need to output a shortest path from s to t when an edge on the shortest path p is removed; the output is a collection of p paths, each a shortest path from s to t when an edge on p is removed. Clearly, given the solution to the s-t replacement paths problem, the second shortest path from s to t can be computed as the path of minimum weight in this solution. This is essentially the method used in all algorithms for 2-SiSP (and with modifications, for k-SiSP), and thus the current fastest algorithms for 2-SiSP and replacement paths have the same time bound. For the all-pairs case that is of interest to us, the output for the replacement paths problem would be O(n3) paths, where each path is shortest for a specific vertex pair, when a specific edge in its shortest path is removed. In view of the large space needed for this output, in the all-pairs version of replacement paths, the problem of interest is distance sensitivity oracles (DSO). Here, the output is a compact representation from which any specific replacement path can be found with O(1) time. The first [6], and it has size O(n2 log n). The current such oracle was developed in Demetrescu et. al. best construction time for an oracle of this size is O(mn log n + n2 log2 n) time for a randomized algorithm, and a log factor slower for a deterministic algorithm, by Bernstein and Karger [2]. Given such an oracle, the output to 2-APSiSP can be computed with O(n) queries for each source-sink pair, i.e., with O(n3) queries to the DSO. The most well-studied problem relating to k simple cycles is that of finding cycles in the overall graph. The problem of enumerating simple (or elementary) cycles - in no particular order -has been studied extensively [32, 33, 31, 16], and the first algorithm that generated successive simple cycles in polynomial time was given by Tarjan [31]; this algorithm generates each successive cycle in O(mn) time. This result was improved to linear time by Johnson [16]. We are not aware of prior bounds on enumerating simple cycles in nondecreasing order of weight. Another well-studied problem relating to simple cycles is the problem of finding a minimum weight cycle (Min-Wt-Cyc) in a graph. Finding a minimum weight cycle in either a directed or an undi- rected graph is known to be equivalent to APSP for sub-cubic algorithms [34]. The time bound for 2 Min-Wt-Cyc in sparse graphs is O(m · n), and finding a faster algorithm for it is a long-standing open question. In this paper, we concentrate on results for truly sparse graphs with arbitrary non-negative edge weights. Hence we do not consider results for small integers weights or for dense graphs; several subcubic results for such graphs are known using fast matrix multiplication. 1.1 Our Contributions We present several algorithmic results, and complement many of them with hardness results relative to computing Min-Wt-Cyc on sparse graphs. 1 1. Computing k simple shortest paths for all pairs (k-APSiSP) in G. We present a new approach to the k-APSiSP problem. In order to construct the desired set P ∗ k (x, y) of k simple shortest paths from x to y, our method uses the notion of a 'nearly k SiSP set' Qk(x, y), defined as follows. k (x, y) is the set of k∗ simple shortest paths from x to y in G. Definition 1.1. Let G = (V, E) be a directed graph with nonnegative edge weights. For k ≥ 2, and a vertex pair x, y, let k∗ = min{r, k}, where r is the number of simple paths from x to y in G. Then, (i) P ∗ (ii) Qk(x, y) is the set of k nearly simple shortest paths from x to y, defined as follows. If k∗ = k and the k−1 simple shortest paths from x to y share the same first edge (x, a) then Qk(x, y) contains these k − 1 simple shortest paths, together with the simple shortest path from x to y that does not start with edge (x, a), if such a path exists. Otherwise (i.e, if either the former or latter condition does not hold), , Qk(x, y) = P ∗ k (x, y). Our algorithm for k-APSiSP first constructs Qk(x, y) for all pairs of vertices x, y, and then uses these sets in an efficient algorithm, Compute-APSiSP, to compute the P ∗ k (x, y) for all x, y. The latter algorithm runs in time O(k · n2 + n2 log n) for any k, while our method for constructing the Qk(x, y) depends on k. For k = 2 we present an O(mn + n2 log n) time method to compute the Q2(x, y) sets; this gives a 2-APSiSP algorithm that matches Yen's bound of O(mn + n2 log n) for 2-SiSP for a single pair. It is also faster (by a polylogarithmic factor) than the best algorithm for DSO (distance sensitivity oracles) for the all-pairs replacement paths problem [2]. In fact, we also show that the Q2(x, y) sets can be computed in O(n2) time using a DSO, and hence 2-APSiSP can be computed in O(n2 log n) time plus the time to construct the DSO. For k ≥ 3 our algorithm to compute the Qk sets makes calls to an algorithm for (k − 1)-APSiSP, so we combine the two components together in a single recursive method, APSiSP, that takes as input G and k, and outputs the P ∗ k sets for all vertex pairs. The time bound for APSiSP increases with k: it is faster than Yen's method for k = 3 by a factor of n (and hence is faster than the current fastest method by almost a factor of n), it matches Yen for k = 4, and its performance degrades for larger k. Our method for computing k-APSiSP (using the Qk(x, y) sets) extends an existing simple path in the data structure to a new simple path in the data structure by adding a single incoming edge. 1Except for k-All-SiSP (see Section 3.2), we can also handle negative edge-weights as long as there are no negative- weight cycles, by applying Johnson's transformation [17] to obtain an equivalent input with nonnegative edge weights. If the resulting edge-weights include weight 0, we will use the pair (wt(p), len(p)) as the weight for path p, where len(p) is the number of edges in it; this causes the weight of a proper subpath of p to be smaller than the weight of p. 3 Problem Known Results New Results 2-APSiSP (Sec. 2.2.1) 3-APSiSP (Sec. 2.2.2) 2-SiSP (Sec. 1, 4) k-SiSP (for k ≥ 2) (Sec. 1, 4) k-SiSC (Sec. 2.3, 4) k-AVSiSC (Sec. 2.3, 4) k-All-SiSC (Sec. 3.1, 4) k-All-SiSP (Sec. 3.2) Upper Bound: O(n3) (using DSO) Upper Bound: O(mn) Upper Bound: O(mn3) [35] Upper Bound: O(mn2) Hardness: Min-Wt-∆ ≤ 2-SiSP (for subcubic) [34] Upper Bound: O(mn) [10] Hardness: Min-Wt-∆ ≤ k-SiSP (for subcubic) [34] Upper Bound: O(kmn) [10] - - - - Hardness: Min-Wt-Cyc ≤(m+n) 2-SiSP Hardness: Min-Wt-Cyc ≤(m+n) k-SiSP (improvement due to above result) k-SiSP ≡(m+n) k-SiSC Hardness: Min-Wt-Cyc ≤(m+n) 2-AVSiSC Upper Bound: O(mn) for (k = 2) and O(kmn2) for (k > 2) Hardness: Min-Wt-Cyc ≤(m+n) 2-All-SiSC Upper Bound: O(mn) per cycle Upper Bound: amortized O(k) if k < n and O(n) if k ≥ n per path after a startup cost of O(m) Table 1: Our Results for directed graphs. (DSO stands for Distance Sensitivity Oracles; ≤(m+n) reductions are defined in Section 4, as are results for undirected graphs.) These extensions have to be performed carefully in order to ensure that the extended path is simple, and the collection of paths formed includes the k-SiSPs for every pair of vertices. This approach differs from all previous approaches to k simple paths and replacement paths. All known previous algorithms for 2-SiSP compute replacement paths for every edge on the shortest path (by computing suitable 'detours'). In fact, Hershberger et al. [14] present a lower bound for k-SiSP, exclusively for the class of algorithms that use detours, by pointing out that all known algorithms for k-SiSP compute replacement paths, and all known replacement path algorithms use detours. Although this lower bound is for k-SiSP and not k-APSiSP, the model used for this lower bound does not apply to our algorithm, since Compute-APSiSP only computes a subset of the replacement paths (across all vertex pairs), and further, it can generate and inspect paths that are not detours, including paths with cycles. Thus our method is fundamentally new. Our algorithms for k-APSiSP are presented in Section 2. 2. Generating the k simple shortest cycles (k-All-SiSC) or k simple shortest paths (k-All-SiSP) in G. In Section 3 we consider the problem of enumerating simple cycles and paths in the graph, in nondecreasing order of their weights. We present an algorithm for k-All-SiSC that, after an initial preprocessing cost of O(mn + n2 log n), generates each successive simple shortest cycle in G in O(AP SP ) = O(mn + n2 log log n) time. We also observe (in Section 4) that it is unlikely that we can obtain the linear time achieved for generating successive simple cycles in no particular order, since we show that generating each successive simple shortest cycle is at least as hard as Min-Wt-Cyc. Complementing the result for k-All-SiSC, we present an algorithm for k-All-SiSP that generates 4 each successive simple path in O(k) time if k < n, and in O(n) time if k > n, after an initial start-up cost of O(m) to find the first path. Here, O omits polylog(n) factors. This time bound is considerably faster than that for k-All-SiSC and for Min-Wt-Cyc. Our method, All-SiSP, is again one of extending existing paths by an edge; it is, however, different from Compute-APSiSP. Path Extensions. We use two different path extension methods, one for k-APSiSP and the other for k-All-SiSP. Path extensions have been used before in the hidden paths algorithm for APSP [18] and more recently, for fully dynamic APSP [4]. These two path extension methods differ from each other, as noted in [5]. Our path extension method for k-All-SiSP is inspired by the method in [4] to compute 'locally shortest paths'. However, our path extension method for k-APSiSP is not related to the earlier results, except for the fact that all path extension methods place suitable paths on a priority queue and extract paths of minimum weight. 3. Computing k simple shortest cycles through a single vertex (k-SiSC) and k simple shortest cycles through every vertex (k-AVSiSC). We show reductions between k-SiSC and k-SiSP, which give both algorithms and hardness results for k-SiSC. For k-AVSiSC, we give an O(mn + n2 log n) time algorithm for k = 2 using our 2-APSiSP algorithm, and an algorithm that performs n k-SiSP computations for k > 2. Our Major Theorems. Here are the main theorems we establish for our algorithmic results. Some conditional hardness results through reductions are presented in Section 4 for path and cycle problems on sparse graphs (as shown in Table 1). In all cases, the input is a directed graph G = (V, E) with nonnegative edge weights, and V = n, E = m. Theorem 1.2. Given an integer k > 1, and the nearly simple shortest paths sets Qk(x, y) (Def- inition 1.1) for all x, y ∈ V , Algorithm Compute-APSiSP (Section 2.1) produces the k simple shortest paths for every pair of vertices in O(k · n2 + n2 · log n) time. Theorem 1.3. (i) Algorithm 2-APSiSP (Section 2.2.1) correctly computes 2-APSiSP in O(mn + n2 log n) time, and for k > 2, Algorithm APSiSP (Section 2.2.2) correctly computes k-APSiSP. (ii) Let T (m, n, k) be the time bound for Algorithm APSiSP. Then, T (m, n, k) ≤ n · T (m, n, k − 1) + O(mn + k · n2 + n2 · log n). (iii) T (m, n, 3), the time bound for algorithm APSiSP for k = 3, is O(m · n2 + n3 · log n). Theorem 1.4. (i) k-All-SiSC: After an initial start-up cost of O(mn + n2 log n) time, we can compute each successive simple shortest cycle in O(mn + n2 log log n) time (Section 3.1). (ii) k-All-SiSP: After an initial start-up cost of O(m) time to generate the first path, Algo- rithm All-SiSP (Section 3.2) computes each succeeding simple shortest path with the following bounds: amortized O(k + log n) time if k = O(n) and O(n + log k) time if k = Ω(n), or worst-case O(k · log n) time if k = O(n), and O(n · log k) time if k = Ω(n). For the most part, we only consider computing the weights of the paths. The actual paths can be maintained by using pointers to sub-paths that omit the first or last edge on the path. In terms of conditional hardness results, we show that 2-SiSP, 2-AVSiSC and 2-All-SiSP are all at least as hard as finding a minimum weight cycle. We also show that k-SiSP is equivalent in complexity to k-SiSC. These results are presented in Section 4. Table 1 lists our main results. Together they give a fairly complete understanding of the fine- grained complexity of the various natural problems related to computing k simple shortest paths 5 and cycles in a weighted graph, at least for k = 2, assuming that finding a minimum weight cycle in 'sub-mn time' is hard. Of these, we highlight the following contributions: • The algorithms for k-APSiSP (and especially for 2- and 3-APSiSP) and for k-All-SiSP intro- duce the new technique of path extensions for this class of problems. • We show that k-SiSP and k-SiSC are equivalent in complexity, but we provide a hardness result that shows that k-All-SiSC is harder than k-All-SiSP unless we can obtain a significantly faster method for Min-Wt-Cyc. It is nevertheless interesting that we can generate successive simple shortest cycles in O(mn) time, given that the mere enumeration of simple cycles was a much-investigated classical topic until linear-time generation of successive cycles (in no particular order) was given in [16]. • We connect the complexity of several problems related to finding k simple paths and k simple cycles in sparse graphs to the complexity of computing a minimum weight cycle. For the most part, previous hardness results were only for dense graphs, and with respect to the presence of sub-cubic algorithms. • We give related results for undirected graphs and for unweighted graphs in Section 4. 2 The k-APSiSP Algorithm In this section, we present our algorithm to compute k-APSiSP on a directed graph G = (V, E) with nonnegative edge-weight function wt. The algorithm has two main steps. In the first step it computes the nearly k-SiSP sets Qk(x, y) for all pairs x, y. In the second step it computes the exact k-SiSP sets P ∗ k (x, y) for all x, y using the Qk(x, y) sets. This second step is the same for any value of k, and we describe this step first in Section 2.1. We then present efficient algorithms to compute the Qk sets for k = 2 and k > 2 in Section 2.2. In all of our algorithms we will maintain the paths in each P ∗ nondecreasing order of edge-weights. k (x, y) and Qk(x, y) set in an array in 2.1 The Compute-APSiSP Procedure In this section we present an algorithm, Compute-APSiSP, to compute k-APSiSP. This algorithm takes as input, the graph G, together with the nearly k-SiSP sets Qk(x, y), for each pair of distinct vertices x, y, and outputs the k∗ simple shortest paths from x to y in the set P ∗ k (x, y) for each pair of vertices x, y ∈ V (note that k∗, which is defined in Definition 1.1, can be different for different vertex pairs x, y). As noted above, the construction of the Qk(x, y) sets will be described in the next section. The right (left) subpath of a path π is defined as the path obtained by removing the first (last) edge on π. If π is a single edge (x, y) then this path is the vertex y (x). Lemma 2.1. Suppose there are k simple shortest paths from x to y, all having the same first edge (x, a). Then ∀i, 1 ≤ i ≤ k, the right subpath of the i-th simple shortest path from x to y has weight equal to the weight of the i-th simple shortest path from a to y. 6 Proof. By induction on k. Since subpaths of shortest paths are shortest paths, the statement holds for k = 1. Assume the statement is true for all h ≤ k, and consider the case when the h + 1 simple shortest paths from x to y all share the same first edge (x, a). Inductively, the right subpath of each of the first h simple shortest paths have the weight equal to the corresponding simple shortest paths from a to y. Suppose the weight of the right subpath πa,y of the (h + 1)-th simple shortest path from x to y is not equal to the weight of the (h + 1)-th simple shortest path from a to y. Hence, if π a,y). a,y is the (h + 1)-th simple shortest path from a to y, we must have wt(πa,y) > wt(π ′ ′ Since πxa,y is the (h + 1)-th simple shortest path from x to y and wt(πa,y) > wt(π a,y), there exists at least one path from a to y that contains x and is also the j-th simple shortest path from a to y, where j ≤ h + 1. Let this path be π xa′,y. But then wt(π a,y) < wt(πa,y) < wt(πxa,y). But this is a contradiction to our assumption that all the first h + 1 simple shortest paths from x to y contains (x, a) as the first edge. This contradiction establishes the induction step and the lemma. a,y. Let the subpath of π a,y from x to y be π a,y) ≤ wt(π xa′,y) < wt(π ′′ ′′ ′ ′′ ′′ ′′ ′ Algorithm Compute-APSiSP computes the P ∗ k (x, y) sets by extending an existing path by an edge. In particular, if the k-SiSPs from x to y all use the same first edge (x, a), then it computes the k-th SiSP by extending the k-th SiSP from a to y (otherwise, the sets P ∗ k (x, y) are trivially computed from the sets Qk(x, y)). The algorithm first initializes the P ∗ k (x, y) sets with the corresponding k (x, y) have Qk(x, y) sets in Step 4. the same first edge and if so, by definition of Qk(x, y), this P ∗ k (x, y) may not have been correctly initialized, and may need to update its k-th shortest path to obtain the correct output. In this case, the common first edge (x, a) is added to the set Extensions(a, y) in Step 7. We explain this step below. In Step 5, it checks whether the shortest k − 1 paths in P ∗ Algorithm 1 Compute-APSiSP(G = (V, E), wt, k,{Qk (x, y),∀x, y}) {H is a priority queue.} k (x, y) ← Qk(x, y) P ∗ if the k − 1 shortest paths in P ∗ 1: Initialize: 2: H ← φ 3: for all x, y ∈ V, x 6= y do 4: 5: 6: 7: 8: 9: 10: 11: 12: Main Loop: 13: while H 6= φ do 14: 15: 16: 17: 18: 19: k (x, y) have the same first edge then Let (x, a) be the common first edge in the (k − 1) shortest paths in P ∗ Add (x, a) to the set Extensions(a, y) if Qk(a, y) = k then k (x, y) π ← the path of largest weight in Qk(a, y) π′ ← (x, a) ◦ π Add π′ to H with weight wt(x, a) + wt(π) π ← Extract-min(H) Let π = (xa, y) and let the path of largest weight in P ∗ if P ∗ else if wt(π) < wt(π′) then replace π′ with π in P ∗ if update flag is set then k (x, y) = k − 1 then add π to P ∗ k (x, y) and set update flag k (x, y) be π′ k (x, y) and set update flag for all (x′, x) ∈ Extensions(x, y) do add (x′, x) ◦ π to H with weight wt(x′, x) + wt(π) We define the k-Left Extended Simple Path (k-LESiP) πxa,y from x to y as the path πxa,y = (x, a)◦πa,y, where the path πa,y is the k-th shortest path in Qk(a, y), and ◦ denotes the concatenation operation. In our algorithm we will construct k-LESiPs for those pairs x, y for which the k−1 simple shortest paths all start with the edge (x, a). The algorithm also maintains a set Extensions(a, y) for each pair of distinct vertices a, y; this set contains those edges (x, a) incoming to a which are the first edge on all k − 1 SiSPs from x to y. In addition to adding the common first edge (x, a) 7 k in Step 16 or 17. Clearly, P ∗ in the (k − 1) SiSPs in P ∗ with start edge (x, a) and end vertex y using the k-th shortest path in the set P ∗ it to heap H in Steps 8-11. Let U denote the set of P ∗ these are the sets for which the if condition in Step 5 holds. k (x, y) to Extensions(a, y) in Step 7, the algorithm creates the k-LESiP k (a, y), and adds k (x, y) sets which may need to be updated; In the main while loop in Steps 13-19, a min-weight path is extracted in each iteration. We establish below that this min-weight path is added to the corresponding P ∗ k in Step 16 or 17 only if it is the k-th SiSP; in this case, its left extensions are created and added to the heap H in Step 19. Lemma 2.2. Let G = (V, E) be a directed graph with nonnegative edge weight function wt, and ∀x, y ∈ V , let the set Qk(x, y) contain the nearly k-SiSPs from x to y. Then, algorithm Compute- APSiSP correctly computes the sets P ∗ k (x, y) ∀x, y ∈ V . Proof. First, we need to show that the paths in sets P ∗ k (x, y) are indeed simple. Clearly, the paths added to P ∗ k from sets Qk in Step 4 are already simple (from the definition of Qk). So we only need to show that the paths added to P ∗ k in Steps 16 and 17 are simple. To the contrary assume that some of the paths that are added to P ∗ k are non-simple. Clearly these paths must be of length greater than 1. Let πxa,y = x → a y be the first minimum weight path extracted from H that contains a cycle and was added to P ∗ k (x, y) ∈ U and (x, a) ∈ Extensions(a, y) and the right subpath πa,y must be in P ∗ k (otherwise the path πxa,y would never have been added to heap H in Step 11 or 19). The right subpath πa,y must also be simple (as wt(πa,y) < wt(πxa,y)), and it must contain x in order to create a cycle in πxa,y. Let πxa′,y (a′ 6= a) be the subpath of πa,y from x to y. Now there are two cases depending on whether πxa,y was added to P ∗ k in Step 16 or 17. If πxa,y was added to P ∗ k (x, y) ∈ U , it implies that all k − 1 paths in Qk(x, y) have same first edge (x, a) and there is no simple path from x to y in Qk(x, y) with some first edge (x, a′′) 6= (x, a). This is a contradiction as the subpath πxa′,y of πa,y contains (x, a′) 6= (x, a) as its first edge. Otherwise, let πxa′′,y ∈ Qk(x, y) (a′′ k in Step 17 to accommodate πxa,y. Thus, we have wt(πxa′,y) < wt(πxa,y) < wt(πxa′′,y), which is a contradiction as πxa′′,y ∈ Qk(x, y) and is the shortest path from x to y avoiding edge (x, a) (as the other k − 1 shortest paths in Qk(x, y) have (x, a) as the first edge). As path πxa,y is arbitrary, hence all paths in P ∗ Now we need to show that P ∗ From the definition of Qk(x, y), it is evident that P ∗ k (x, y) indeed contains the k − 1 SiSPs from x to y. We now need to show that the k-th shortest path in each of the sets P ∗ k is indeed the corresponding k-th SiSP. To the contrary assume that there exists a P ∗ k set that does not contain the correct k-th SiSP. Let πxa,y = x → a y be the minimum weight k-th SiSP that is not present in P ∗ k (x, y) in Step 4). This implies that πxa,y has the same first edge as that of the k − 1 SiSPs from x to y and hence P ∗ k (x, y) ∈ U and (x, a) ∈ Extensions(a, y). By Lemma 2.1, the right subpath of πxa,y must have weight equal to the k-th SiSP from a to y. Thus, there are at least k SiSPs from a to y and the set P ∗ k (a, y) contains all the k SiSPs from a to y. And as (x, a) ∈ Extensions(a, y), a path π xa,y with the k-th SiSP from a to y as the right subpath and weight equal to wt(πxa,y) must have been added to H either in Step 11 or 19 and would have been added to P ∗ k (x, y) in Step 16 or 17, resulting in a contradiction to our assumption that P ∗ k (x, y) does contain the k∗ SiSPs from x to y. k . Clearly, πxa,y /∈ Qk(x, y) (otherwise it would have been added to P ∗ 6= a) be the path that was removed from P ∗ k are simple. k (x, y) indeed contains the k∗ SiSPs from x to y. k (x, y) in Step 16 and as P ∗ ′ k (x, y) does not contain all the k SiSPs. Thus, P ∗ 8 The time bound for Algorithm Compute-APSiSP in Theorem 1.2 is established with the following sequence of simple lemmas. k , and O(n2) elements across all Extensions sets. k (x, y) = O(kn2) since there are at most k paths in each of the n · (n − 1) sets P ∗ Lemma 2.3. There are O(kn2) paths in P ∗ Proof. P ∗ For the second part, exactly one edge is contributed to a Extensions set by each P ∗ Step 7. k (x, y). k (x, y) ∈ U in Lemma 2.4. Each P ∗ k (x, y) set is updated at most once in the main while loop. Proof. A path can be added to P ∗ k (x, y) at most once in Step 16 since its size will increase to k after the addition. Also, a path is added at most once in either Step 16 or Step 17 since paths are extracted from H in nondecreasing order of their weights. Lemma 2.5. The number of k-LESiPs added to heap H is O(n2). Proof. For each k-LESiP, the right subpath must be the k-th shortest path in P ∗ k . For each pair of vertices x, y ∈ V , there is at most one entry across the Extensions sets (say edge (x, a) ∈ Extensions(a, y)) and hence at most one k-LESiP will be added to heap H in Step 11 for pair (x, y). By lemma 2.4, we know that the set P ∗ k (a, y) is updated at most once and hence at most one k-LESiP will be added to heap H for pair (x, y) in Step 19. Thus, there are only O(n2) k-LESiPs that were added to the heap H in the algorithm. Lemma 2.6. Algorithm Compute-APSiSP runs in O(kn2 + n2 log n) time. Proof. A binary heap suffices for H. The initialization for loop in Steps 3-11 takes O(kn2) time to k sets. It is executed at most n2 times and, outside of the inspection of initialize and inspect the P ∗ k (x, y) an iteration costs Θ(log n) time (cost for insertion in heap), thus contributing O(n2 log n) P ∗ to the running time. The while loop is executed O(n2) times as by lemma 2.5, O(n2) elements are added to the heap. The extract-min operation takes Θ(log n) time and hence Step 14 contributes O(n2 log n) to the running time. Steps 15-17 takes constant time per iteration and hence add O(n2) to the total running time. By lemma 2.3, Step 19 is executed O(n2) times and contributes O(n2 log n) to the running time. Thus, the total running time of the algorithm is O(kn2 + n2 log n). 2.2 Computing the Qk Sets 2.2.1 Computing Qk for k = 2 We now give an O(mn + n2 log n) time algorithm to compute Q2(x, y) for all pairs x, y. We then show that we can also obtain the Q2 sets from a DSO (distance sensitivity oracles, see Introduction), but this algorithm is slightly slower than our first method. Our faster method first computes a shortest path (SP) for each pair using an efficient APSP algorithm [27]. This gives the first path in each Q2 set. To obtain the second path, for each x, y we need to find a shortest path from x to y that avoids first edge (x, a) on the SP. We can trivially compute such paths by running Dijkstra on the subgraph G − {e} with source x where e = (x, a) is the first edge on the shortest path from x to y. With this approach we will make m calls to Dijkstra's algorithm. We now describe a more efficient method that makes only n calls to Dijkstra's 9 algorithm. This method uses the procedure fast-exclude from Demetrescu et al. [6]. We present the input-output specifications of fast-exclude here; full details of this algorithm can be found in [6]. We start with the following definition. Definition 2.7 (Independent Edges [6]). Given a rooted tree T , edges (u1, v1) and (u2, v2) on T are independent if the subtree of T rooted at v1 and the subtree of T rooted at v2 are disjoint. Given the weighted directed graph G = (V, E), the SSSP tree Ts rooted at a source vertex s ∈ V , and a set S of independent edges in Ts, algorithm fast-exclude in [6] computes, for each edge e ∈ S, a shortest path from s to every other vertex in G − {e}. This algorithm runs in time O(m + n log n). We will compute the second path in each Q2(x, y) set, for a given x ∈ V , by running fast-exclude with x as source, and with the set of outgoing edges from x in Tx as the set S. Clearly, this set S is independent, and hence algorithm fast-exclude will produce its specified output. Now consider any vertex y 6= x, and let (x, a) be the first edge on the shortest path from x to y in Tx. Then, by its specification, fast-exclude will compute a shortest path from x to y that avoids edge (x, a) in its output, which is the second path needed for Q2(x, y). This holds for every vertex y ∈ V − {x}. Thus we have the following: Lemma 2.8. The sets Q2(x, y), for all pairs x, y, can be computed in O(mn + n2 log n) time. This leads to the following algorithm for 2-APSiSP. Its time bound in Theorem 1.3, part (i) follows from Lemmas 2.8, 2.2 and 2.6. Algorithm 2 2-APSiSP(G = (V, E); wt) 1: for each x ∈ V do 2: 3: 4: Compute-APSiSP(G, wt, 2, {Q2(x, y), ∀x, y}) Compute the shortest path in each Q2(x, y), y ∈ V − {x}, by running Dijkstra's algorithm with source x. Compute the second path in each Q2(x, y), y ∈ V − {x}, using fast-exclude with source x and S = {(x, a) ∈ Tx} Computing the Q2 sets from distance sensitivity oracle. Let a DSO D with constant query time be given. For each x, y ∈ V , let πxy be the shortest path from x to y. The second SiSP in Q2(x, y) is the shortest path from x to y avoiding the first edge on πxy, so we can compute the second SiSP in Q2(x, y) by making O(1) queries to D. Thus, O(n2) queries suffice to compute the second SiSP in all Q2(x, y) sets. A DSO with constant query time can be computed by a randomized algorithm in O(n log n·(m+n log n)) time, and deterministically in O(n log2 n·(m+n log n)) time [2]. Since Compute-APSiSP runs in O(n2 log n), this gives a O(mn) time algorithm for 2-APSiSP. It is not clear if we can efficiently compute 2-APSiSP directly from a DSO, without using the Q2 sets and Compute-APSiSP. 2.2.2 The Algorithm for k ≥ 3 Our algorithm will use the following types of sets. For each vertex x ∈ V , let Ix be the set of incoming edges to x. Also, for a vertex x ∈ V , and vertices a, y ∈ V − {x}, let P ∗x k (a, y) be the set of k simple shortest paths from a to y in G − Ix, the graph obtained after removing the incoming edges to x. Recall that we maintain all P ∗ and Q sets as sorted arrays. We now present Algorithm APSiSP(G, k), which first computes the sets P ∗x k−1(a, y), for all vertices a, y ∈ V . Once we have these sets, each Qk(x, y) can be computed as the set of all paths in the 10 set P ∗ (which is not present in P ∗ k−1(x, y), together with a shortest path in S{(x,a) outgoing from x}{(x, a)◦ p p ∈ P ∗x k−1(a, y)} k−1(x, y)). for each x ∈ V do compute Q2 sets using algorithm in Section 2.2.1 Algorithm 3 APSiSP(G = (V, E), wt, k) 1: if k = 2 then 2: 3: else 4: 5: 6: 7: 8: 9: 10: Ix ← set of incoming edges to x Compute sets P ∗x for each y ∈ V − {x} do k−1(x, y) k−1(x, y), and P ∗x k−1(a, y) ∀a, y ∈ V by calling APSiSP(G − Ix, wt, k − 1) Qk(x, y) ← P ∗x for all (x, a) ∈ E do counta ← number of paths in Qk(x, y) with (x, a) as the first edge Qk(x, y) ← Qk(x, y) ∪ { a shortest path in S{(x,a) outgoing from x}(x, a) ◦ P ∗x k−1(a, y)[counta + 1]} 11: Compute-APSiSP(G, wt, k, {Qk(x, y) ∀x, y ∈ V }) To compute the P ∗x k−1 sets, APSiSP(G, wt, k) recursively calls APSiSP(G− Ix, wt, k − 1), for each vertex x ∈ V . Once we have computed the P ∗x k−1 sets, the Qk(x, y) sets are readily computed as described in steps 8 - 10. After the computation of Qk(x, y) sets, APSiSP(G, wt, k) calls Compute- APSiSP(G, wt, k,{Qk (x, y) ∀x, y ∈ V }) to compute the P ∗ k sets. This establishes the following lemma and part (ii) of Theorem 1.3. Lemma 2.9. Algorithm APSiSP (G, wt, k) correctly computes the sets P ∗ k (x, y) ∀x, y ∈ V . Proof of Theorem 1.3, part (iii). The for loop starting in Step 4 is executed n times, and the cost of each iteration is dominated by the call to Algorithm 2-APSiSP in Step 6, which takes O(mn + n2 log n) time. This contributes O(mn2 + n3 log n) to the total running time. The inner for loop starting in Step 7 is executed n times per iteration of the outer for loop, and the cost of each iteration is O(k + dx). Summing over all x ∈ V , this contributes O(kn2 + mn) to the total running time. Step 11 runs in O(n2 log n) time as shown in Lemma 2.6. Thus, the total running time is O(mn2 + n3 log n). (cid:3) k-APSiSP. The performance of Algorithm APSiSP degrades by a factor of n with each increase in k. Thus, it matches Yen's algorithm (applied to all-pairs) for k = 4, and for larger values of k its performance is worse than Yen. Since finding the P ∗ k sets is at least as hard as finding the Qk sets (as long as the running time is Ω(k · n2 + n2 log n)), it is possible that the for loop starting in Step 4 could be replaced by a faster algorithm for finding the Qk sets, which in turn would lead to a faster algorithm for k-APSiSP. 2.3 Generating k Simple Shortest Cycles k-SiSC. This is the problem of generating the k simple shortest cycles through a specific vertex z in G (k-SiSC). We can reduce this problem to k-SiSP by forming G′ z, where we replace vertex z by vertices zi and zo in G′ z, and we replace each incoming edge to (outgoing edge from) z with an incoming edge to zi (outgoing edge from zo) in G′ z. It is not difficult to see that the k-th simple shortest path from zo to zi in G′ z corresponds to the k-th simple shortest cycle through z in G. k-AVSiSC. This is the problem of generating k simple shortest cycles that pass through a given vertex x, for every vertex x ∈ V . For k = 2, we can reduce this problem to k-APSiSP by forming the graph G′ where for each vertex x, we replace vertex x in G by vertices xi and xo in G′, we place 11 a directed edge of weight 0 from xi to xo, and we replace each edge (u, x) in G by an edge (uo, xi) in G′ (and hence we also replace each edge (x, v) in G by an edge (xo, vi) in G′). For k > 2 a faster algorithm would repeat k-SiSC for each vertex. This leads to the following theorem. Theorem 2.10. Let G be a directed graph with non-negative edge weights. Then, (i) k-SiSC can be computed in O(k · (mn + n2 log log n)) time, the same time as k-SiSP. (ii) 2-AVSiSC can be computed in O(mn+n2 log n) time, and for k > 2, k-AVSiSC can be computed in O(k · n · (mn + n2 log log n)) time. 3 Enumerating Simple Shortest Paths and Cycles in a Graph In this section we consider the problem of successively generating simple paths and cycles in non- decreasing order of their weights in a directed n-node, m-edge graph G = (V, E) with nonnegative edge weights. In Section 3.1 we give a method to generate each successive simple shortest cycle (k-All-SiSC) in O(m · n) time. For enumerating simple paths in nondecreasing order of weight (k- All-SiSP), we give a faster method in Section 3.2 that uses again a path extension method, different from the one used in Section 2.1. On the other hand, in Section 4 we show that the problem of generating the k-th simple shortest cycle in a graph after the first k − 1 cycles have been generated is at least as hard as the Min-Wt-Cyc problem. 3.1 Generating Successive Simple Shortest Cycles We assume the vertices are numbered 1 through n. Our algorithm for k-All-SiSC maintains an array A[1..n], where each A[j] contains a triple (ptrj, wj, kj ); here ptrj is a pointer to the shortest cycle, not yet generated, that contains j as the minimum vertex (if such a cycle exists), wj is the weight of this cycle, and kj is the number of shortest simple cycles through vertex j that have already been generated. (Note that if a cycle C is pointed to by an entry in A[r], then the minimum vertex on C must be labelled r; thus any given cycle is assigned to exactly one position in array A.) We will work with the graph G′ described in Section 2.3. Initially, we compute the entry for each A[j] by running Dijkstra's algorithm with source jo on the subgraph G′ j of G′ induced on V ′ j = {xi, xo x ≥ j}, to find a shortest path p from jo to ji; we then initialize A[j] with a pointer to the cycle in G associated with p, and with its weight, and with kj = 0. For each k ≥ 1, we generate the k-th simple shortest cycle in G by choosing a minimum weight cycle in array A. Let this entry be in A[r]. We then compute the last path in (kr + 1)-SiSC through vertex r using the algorithm in Section 2.3, and we update the entry in A[r] with this cycle. Correctness of this algorithm is immediate since the k-th simple shortest cycle must be pointed to by some entry in array A after k − 1 iterations. The initialization takes O(mn + n2 log n) for the n calls to Dijkstra's algorithm. Thereafter, the algorithm in Section 2.3 generates each new cycle in the slightly faster APSP time bound of O(mn + n2 log log n), by maintaining the relevant information generated during the computation of earlier cycles, as in [35, 10]. This establishes the correctness of Theorem 1.4, part (i). A similar algorithm can generate successive simple shortest paths. But in the next section, we present a faster algorithm for this problem. For constant k, this algorithm generates a succinct 12 representation of the k-th simple shortest path in O(log n) time, after an initial start-up cost of O(m) to generate a shortest simple path in the graph (which is an edge of minimum weight). 3.2 A Faster Algorithm to Generate Successive Simple Shortest Paths Since all vertices on a simple path must be distinct, an n node graph has O(nn) simple paths. Our algorithm for k-All-SiSP is inspired by the method in [4] for fully dynamic APSP. With each path π, we will associate two sets of paths L(π) and R(π) as described below. Similar sets are used in [4] for 'locally shortest paths' but here they have a different use as described below. Left and right extensions. Let P be a collection of simple paths. For a simple path πxy from x to y in P, its left extension set L(πxy) is the set of simple paths π′ ∈ P such that π′ = (x′, x) ◦ πxy, for some x′ ∈ V . Similarly, the right extension set R(πxy) is the set of simple paths π′′ = πxy ◦ (y, y′) such that π′′ ∈ P. For a trivial path π = hvi, L(π) is the set of incoming edges to v, and R(π) is the set of outgoing edges from v. Algorithm All-SiSP, given below, generates all simple shortest paths in G in nondecreasing order of weight. To generate the k shortest simple paths in G, we can terminate the while loop after k iterations. Algorithm All-SiSP initializes a priority queue H with the edges in G, and it initializes the extension sets for the vertices in G. In each iteration of the main loop, the algorithm extracts the minimum weight path π in H as the next simple path in the output sequence. It then generates suitable extensions of π to be added to H as follows. Let the first edge on π be (x, a) and the last edge (b, y). Then, All-SiSP left extends π along those edges (x′, x) such that there is a path πx′b in L(l(π)); it also requires that x′ 6= y, since extending to x′ would create a cycle in the path. Algorithm All-SiSP forms similar extensions to the right in the for loop starting at Step 14. Add (x, y) to priority queue H with wt(x, y) as key Add (x, y) to L(hyi) and R(hxi) {H is a priority queue.} Algorithm 4 All-SiSP(G = (V, E); wt) 1: Initialization: 2: H ← φ 3: for all (x, y) ∈ E do 4: 5: 6: Main loop: 7: while H 6= φ do 8: 9: 10: 11: 12: 13: 14: π ← Extract-min(H) Add π to the output sequence of simple paths Let πxb = ℓ(π) and πay = r(π) (so (x, a) and (b, y) are the first and last edges on π) for all πx′b ∈ L(πxb) with x′ 6= y do Form πx′y ← (x′, x) ◦ π and add πx′y to H with wt(πx′y) as key Add πx′y to L(πxy) and to R(πx′b) for all πay ′ ∈ R(πay) with y′ 6= x do perform steps complementary to Steps 12 and 13 We now establish that Algorithm All-SiSP generates only simple paths, and that it generates every simple path in G in nondecreasing order of weight. Lemma 3.1. Every path generated by Algorithm All-SiSP is a simple path. Proof. Since edge weights are nonnegative, the first path generated by Algorithm 4 is a minimum weight edge inserted in Step 4, which is a simple path. Assume the algorithm generates a path with a cycle, and let σ be the first path extracted in Step 8 that contains a cycle. Let (x′, a) and (b, y) be the first and last edges on σ. Since σ contains a cycle, it contains at least two edges so (x′, a) and (b, y) are distinct edges. 13 Consider the step when the non-simple path σ is placed on H. This does not occur in Step 4 since σ contains at least two edges. So σ is placed on H in some iteration of the while loop. Let π be the path extracted from H in this iteration; π is a simple path by assumption since it was extracted from H before σ. Then σ is added to H either as a left extension of π (in Step 12) or as a right extension of π in a step complementary to Step 12 in the for loop in Step 14. Consider the left extension case, and let σ be formed when processing path πx′b ∈ L(l(π)) with x′ 6= y in Step 11. Thus σ is formed as (x′, x)◦ π in Step 12. But (x′, x)◦ π = (x′, x)◦ ℓ(π)◦ (b, y) = πx′b ◦ (b, y). Since πx′b ∈ L(l(π)), it was also placed in H in either Step 4 or Step 12. And as wt(πx′b) < wt(σ), the path πx′b is simple. Since πx′b is simple, a cycle can be formed in σ only if x′ = y. But this is specifically forbidden in the condition in Step 11. A similar argument applies to right extensions added to H in Step 14. Hence σ is a simple path, and Algorithm 4 does not generate any path containing a cycle. Lemma 3.2. Algorithm All-SiSP generates all simple paths in G in nondecreasing order of their weights. Proof. Clearly the algorithm correctly generates the minimum weight edge in G as the minimum weight simple path in the output in the first iteration of the while loop. By Lemma 3.1 all generated paths are simple. Also, these simple paths are generated in nondecreasing order of weight since any path added to H in Steps 12 and 14 has weight at least as large as the weights of the paths that have been extracted at that time, due to nonnegative edge-weights. It remains to show that no simple path in G is omitted in the sequence of simple paths generated. Suppose the algorithm fails to generate all simple shortest paths in G and let π be a simple path of smallest weight that is not generated by Algorithm 4. Let π be a path with first edge (x, a) and last edge (b, y); (x, a) 6= (b, y) since all single edge paths is added to H in Step 4, and will be extracted in a future iteration. Let πab be the subpath of π from a to b. By assumption, the paths πxb = ℓ(π) and πay = r(π) are placed in the output by Algorithm 4 since they are simple paths with weight smaller than the weight of π. Without loss of generality assume that πxb was extracted from H before πay. Clearly, πxb was inserted in H before πay was extracted. In the iteration of the while loop when πxb was added to H, πxb was added to L(πab) in Step 13 since r(πxb) = πab. In the later iteration when πay was extracted from H, the paths in L(ℓ(πay)) are considered in Step 12. But ℓ(πay) = πab. When the paths in L(ℓ(πay)) = L(πab) are considered in Step 11 during the processing of πay, the path πxb will be one of the paths processed, and in Step 12 the path (x, a)◦ πay = π will be formed and added to H. Thus π will be added to H, and hence will be extracted and added to the output sequence. We can now prove Theorem 1.4. Proof of Theorem 1.4, part (ii). We will maintain paths with pointers to their left and right subpaths, so each path takes O(1) space. For the amortized bound we will implement H as a Fibonacci heap. The initialization takes O(m) time. Each L and R set can contain at most n − 2 paths, and further, since extensions are formed only with paths already in H, each of these sets has size min{k, n − 2}. The k-th iteration of the while loop takes time O(log H) for the extract-min operation, and O(min{k, n}) time for the processing of the L and R sets. At the start of the k-th iteration, the number of paths in H is at most O(m + k · min{k, n}), and since m = O(n2), log H = O(log(n+k)). Hence the amortized time for the k-th iteration is O(min{k, n}+log(n+k)). 14 For the worst-case bound we will use a binary heap. Then, the initialization takes O(m) time to build a heap on the m edges, and the k-th iteration costs O(min{k, n} · log(n + k)) for the heap operations. (cid:3) 4 Hardness Results We start with the definition of an f (m, n) reduction. Definition 4.1. Given graph problems P and Q, an f (m, n) reduction, P ≤f (m,n) Q, means that an input G = (V, E) to P with V = n, E = m can be reduced in O(f (m, n)) time to an input G′ = (V ′, E′) to Q such that from a solution for Q on G′ we can obtain a solution for P on G in O(f (m, n)) time. The following lemma is straightforward. Lemma 4.2. If P ≤f (m,n) Q then for any f ′(m, n) = Ω(f (m, n)), an f ′(m, n) algorithm for Q implies an f ′(m, n) algorithm for P . We mainly consider f (m, n) = O(m + n), except for one reduction with f (m, n) = (m + n) · log n. We now give some (m + n) reductions from Min-Wt-Cyc to several versions of the SiSP and SiSC problems. Recall that Min-Wt-Cyc is the problem of finding a minimum weight cycle in a directed graph with non-negative edge weights. Lemma 4.3. k-SiSC ≡(m+n) k-SiSP. Proof. The reduction from k-SiSC to k-SiSP is the same as that used in the algorithm for k-SiSC in Section 2.3; we include it again here for completeness. Suppose we are given an instance of the k-SiSC problem, a directed graph G = (V, E) where for some x ∈ V , we want to find k-SiSCs passing through vertex x. We can reduce this problem to k-SiSP by forming the graph G′ where, we replace vertex x in G by vertices xi and xo in G′, and we replace each edge (u, x) in G by an edge (uo, xi) in G′ (and hence we also replace each edge (x, v) in G by an edge (xo, vi) in G′). It is not difficult to see that the k-th simple shortest path from xo to xi in G′ corresponds to the k-th simple shortest cycle through x in G. As the number of vertices and edges in G′ are linear in the number of vertices and edges, respec- tively, in G, we deduce that k-SiSC ≤(m+n) k-SiSP. Now suppose that we are given an instance of the k-SiSP problem, a directed graph G = (V, E) where for some x, y ∈ V , we want to find k-SiSPs from x to y. We can reduce this problem to k-SiSC by forming the graph G′ where, we add a new vertex z and we place a directed edge of weight 0 from y to z and from z to x. Now we can readily see that the k-th simple shortest cycle through z in G′ corresponds to the k-th simple shortest path from x to y in G. Hence, we obtain the desired result. It is shown in [34] that 2-SiSP is at least as hard as APSP for sub-cubic computations, using a reduction from minimum weight triangle. That reduction is an (m + n) reduction. However, a minimum weight triangle in a sparse graph can be found in O(m3/2) time using the triangle finding algorithm in [15]. Here we give an (m+n) reduction from Min-Wt-Cyc to 2-SiSP to establish that a 15 G′ 1o 2o 3o 2W W 1i 2i 3i p2 W 2W 3W p3 3W p0 p1 0 0 0 Figure 1: Construction of G′′ for n = 3 for Lemma 4.4. 'sub-mn' algorithm for 2-SiSP would imply a similar improvement for Min-Wt-Cyc, a long-standing open question. Lemma 4.4. Min-Wt-Cyc ≤(m+n) 2-SiSP Proof. Suppose we are given an instance of the Min-Wt-Cyc problem, a directed graph G = (V, E) with vertex set V = {1, 2, . . . , n}, and we need to find the minimum weight cycle in the graph. We will reduce this instance of the problem to that of computing 2-SiSP in a weighted directed graph, as follows. We first construct the directed graph G′ = (V ′, E′), as described in the proof of Lemma 4.3. Then we create a directed graph G′′ = (V ′′, E′′) such that it contains G′ as a subgraph and also contains a path P (p0 → p1 pn−1 → pn) of n + 1 vertices such that all edges on P have weight 0. Let W = n · w, where w is the maximum weight of any edge in G. For each 1 ≤ j ≤ n, we add an edge of weight (n − j + 1)W from pj−1 to jo and an edge of weight jW from ji to pj. Figure 1 depicts the full construction of G′′ for n = 3. Now the 2-SiSP from p0 to pn is of the form: p0 ps−1 → so ti → pt pn since it must contain a single detour. Further, t > s − 1 since the path is simple. We claim that t = s. If not, then t > s and the weight of the path is at least (n + 2)W . However, any path of the form p0 ps−1 → so si → ps pn has weight strictly less than (n + 2)W , since any simple path in G′ has weight less than W , Hence, t = s as long as there is at least one path of the form xo xi (where x ∈ V ) in G′. Thus the 2-SiSP in G′′ corresponds to the shortest path in G′ of the form xo xi, which in turn corresponds to the minimum weight cycle in the original graph G. As the number of vertices and edges in G′′ is linear in the number of vertices and edges, respectively, in G, we obtain the desired result. Lemma 4.5. Min-Wt-Cyc ≤(m+n) k-AVSiSC. 16 G x d1 d2 e1 e2 Figure 2: Construction of G′ for k = 3 for Lemma 4.6. Proof. Suppose we are given an instance of the Min-Wt-Cyc problem, a directed graph G = (V, E), and we need to find the minimum weight cycle in the graph. We can find the k minimum weight cycles passing through each vertex x ∈ V by computing k- AVSiSC on G. We can then find the minimum weight cycle by taking the minimum of the shortest simple cycles passing through every vertex x ∈ V . Thus, we obtain the desired result. We establish two more hardness results for the following two problems: (a) k-th-All-SiSC is the problem of computing the k-th simple shortest cycle in G after the k − 1 simple shortest cycles in G have been computed (for any constant k > 1). (b) Second-APSiSP is the problem of generating the second simple shortest path for all pairs of vertices after APSP has been computed. Lemma 4.6. Min-Wt-Cyc ≤(m+n) k-th-All-SiSC. Proof. Suppose we are given an instance of the Min-Wt-Cyc, a directed graph G = (V, E). Now we'll reduce this instance of the problem to that of computing k-th-All-SiSC in a weighted directed graph. Now create a directed graph G′ = (V ′, E′) such that it contains G as its subgraph and 2(k − 1) additional vertices coming from the vertex partitions D = {di}k−1 i=1 . Fix some x ∈ V . For each 1 ≤ i ≤ k − 1, add edges of weight 0 from x to di, from di to ei and from ei to x. Figure 2 depicts the full construction of G′ for k = 3. Now the first (k − 1) min-weight cycles in G′ correspond to the cycles involving vertices x, di and ei (for each 1 ≤ i ≤ k − 1). And the k-th min-weight cycle in G′ corresponds to the minimum weight cycle in G. As the number of vertices and edges in G′ are linear in the number of vertices and edges, respec- tively, in G, we get the desired result. i=1 and E = {ei}k−1 Lemma 4.7. APSP ≤(m+n) Second-APSiSP. Proof. Suppose we are given an arbitrary directed graph G = (VG, EG) where VG = {1, 2, . . . , n}. Now we'll reduce the problem of computing APSP on G to one of computing Second-APSiSP in another weighted directed graph. 17 G 2 1 3 a1 a2 a3 s b1 b2 b3 Figure 3: Construction of G′ for n = 3 for Lemma 4.7. i=1. i=1 and B = {bi}n Now construct a graph G′ = (V ′, E′) on 3n + 1 nodes that contains G as its subgraph. Apart from the n vertices present in G, G′ also contains a vertex s and 2n additional vertices coming from the vertex partitions A = {ai}n For each 1 ≤ i ≤ n, add an edge of weight 0 from ai to s and from s to bi. For every 1 ≤ i ≤ n, also add edges of weight 1 from ai to i and from i to bi. Figure 3 depicts the full construction of G′ for n = 3. Now the 2-SiSP from some ai to some bj (where 1 ≤ i, j ≤ n) is of the form :- ai → i j → bj, where the second simple shortest path first takes the edge (ai, i) and then it takes the shortest path from i to j and then the edge (j, bj ). Thus every 2-SiSP in G′ from a vertex ai in A to a vertex bj in B corresponds to a shortest path from i to j in the original graph G. As the number of vertices and edges in G′ are linear in the number of vertices and edges, respec- tively, in G, we get the desired result. The above reductions show that for any k ≥ 2, k-SiSP, k-SiSC, k-AVSiSC and k-th-All-SiSC cannot be solved in o(m· n) time unless an improved algorithm is obtained for Min-Wt-Cyc. Also, the last reduction shows that computing Second-APSiSP is at least as hard as computing APSP. (It can also be seen that Min-Wt-Cyc ≤(m+n) APSP.) Unweighted Graphs. Most of our reductions go through (either unchanged or with small changes) for unweighted graphs. The one exception is Min-Wt-Cyc to 2-SiSP. Here in fact, there is a randomized O(k · m√n) time algorithm for k-SiSP [29]. For the reductions from cycle problems to path problems (k-SiSC to k-SiSP and 2-AVSiSC to 2-APSiSP), we used an edge of weight 0 from vi to vo. In the unweighted case, we can leave the edge weight at 1, and observe that this preserves the ordering of simple shortest paths for any pair of vertices, since a path of length r in G from s to t is now transformed into a path of length 2r − 1 from so to ti in G′. 18 4.1 Undirected Graphs Our algorithms for k-APSiSP and k-All-SiSP work for undirected graphs. Hence k-All-SiSP and 2-APSiSP have the same time bound as for the directed case. However, k-SiSP in undirected graphs can be solved in O(m) time [19], hence for k ≥ 3, k-APSiSP can be computed in O(mn2) time in undirected graphs. Our reduction from k-SiSC to k-SiSP problem given in Section 2.3 does not work for undirected graphs. We give an alternate reduction (with a small O(log n) increase in the bound). Lemma 4.8. k-SiSC ≤((m+n)·log n) k-SiSP. Proof. Let the input be G = (V, E) and the vertex x ∈ V , for which we want to compute k- SiSCs. We assume that the vertices are labeled from 1 to n. We first show that k-SiSC in G can be computed with ⌈log n⌉ calls to k-SiSP. Let N (x) be the neighbor-set of x. We create ⌈log n⌉ graphs Gi = (Vi, Ei) such that ∀1 ≤ i ≤ ⌈log n⌉, Gi contains two additional vertices x0,i and x1,i (instead of the vertex x) and ∀y ∈ N (x), the edge (y, x0,i) ∈ Ei if y′s i-th bit is 0, otherwise the edge (y, x1,i) ∈ Ei. This takes O((m + n) · log n) time and we observe that every cycle through x will appear as a path from x0,i to x1,i in at least one of the Gi. Hence, the k-th shortest path in the collection of k-SiSPs from x0,i to x1,i in Gi ∀1 ≤ i ≤ ⌈log n⌉ (after removing duplicates), If we create new vertices z and z′, connect z corresponds to the k-th SiSC passing through x. to the x0,i vertices and z′ to the x1,i, then computing k′-SiSP between z and z′ in this graph for k′ = k · ⌈log n⌉, gives us k-SiSC through x in G as shown above. Using the above lemma and the results in Sections 2.3 and 3.1 we can compute k-SiSC in O(km) time, k-AVSiSC in O(kmn) time and k-All-SiSC in O(m) time per cycle after a startup cost of O(mn) in undirected graphs. Most of our hardness results (from k-SiSP to k-SiSC, Min-Wt-Cyc to k-AVSiSC, Min-Wt-Cyc to k-All-SiSC) also hold for undirected graphs. However our reduction from Min-Wt-Cyc to 2-SiSP for directed graphs does not hold for undirected graphs. This is not surprising as 2-SiSP can be computed in O(m) time [19]. 4.2 Discussion There are several important problems on sparse graphs for which O(mn) is the current best time bound: Min-Wt-Cyc, APSP (for both problems, either directed or undirected, and either weighted or unweighted), weighted k-SiSP, and the collection of weighted directed graph problems for which we have given O(mn) time algorithms in this paper. This suggests that the class of problems that currently have O(mn) time algorithms is an important one, with Min-Wt-Cyc being the key problem, similar to APSP for cubic computations, and 3SUM for quadratic computations. 5 Conclusion We have presented new algorithms to compute k simple shortest paths and cycles in a weighted directed (or undirected) graph, complementing many of our upper bounds with hardness results for sparse graphs (by reductions from Min-Wt-Cyc). Our results include the following. 19 • A 2-APSiSP algorithm which almost matches the current best O(mn + n2 log n log n) bound for finding the two simple shortest paths for just a single pair of vertices. • A new recursive algorithm to compute k-APSiSP, which improves the best prior bound for k = 3 (for directed graphs) ; although this algorithm, APSiSP, does not give improved bounds for k > 3 (and for k > 2 for undirected graphs) , it presents a new method for finding k shortest paths, and leaves open the possibility for further improvement, if a better algorithm can be found to compute the nearly k SiSP sets Qk(x, y). • Algorithms and hardness results for the simple cycles versions, k-SiSC and k-AVSiSC. • Algorithms to efficiently enumerate simple paths and simple cycles in G in nondecreasing order of weight, and a conditional hardness result that enumerating simple cycles in nondecreasing order of weights is a significantly harder problem than a similar enumeration of simple paths. We conclude with some avenues for further research. 1. The main open question for k-APSiSP is to come up with faster algorithms to compute the Qk(x, y) sets for larger values of k. This is the key to a faster k-APSiSP algorithm using our approach, for k > 2. 2. The space requirements of our all-pairs algorithms are high. Can we come up with space-efficient algorithms that match our time bounds? 3. Can we come up with other hardness results for sparse graphs, for example, can we show that Min-Wt-Cyc ≤(m+n) APSP in undirected graphs? (For directed graphs there is a simple reduction.) References [1] A. Bernstein. A nearly optimal algorithm for approximating replacement paths and k shortest simple paths in general graphs. In Proceedings of the twenty-first annual ACM-SIAM sympo- sium on Discrete Algorithms, pages 742–755. Society for Industrial and Applied Mathematics, 2010. [2] A. Bernstein and D. Karger. A nearly optimal oracle for avoiding failed vertices and edges. In Proceedings of the forty-first annual ACM symposium on Theory of computing, pages 101–110. ACM, 2009. [3] T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein. Introduction to Algorithms, Third Edition. The MIT Press, 3rd edition, 2009. [4] C. Demetrescu and G. F. Italiano. A new approach to dynamic all pairs shortest paths. J. ACM, 51(6):968–992, 2004. [5] C. Demetrescu and G. F. Italiano. Experimental analysis of dynamic all pairs shortest path algorithms. ACM Transactions on Algorithms (TALG), 2(4):578–601, 2006. [6] C. Demetrescu, M. Thorup, R. A. Chowdhury, and V. Ramachandran. Oracles for distances avoiding a failed node or link. SIAM Journal on Computing, 37(5):1299–1318, 2008. [7] D. Eppstein. Finding the k shortest paths. SIAM Journal on Computing, 28(2):652–673, 1998. 20 [8] G. Feng. Finding k shortest simple paths in directed graphs: A node classification algorithm. Networks, 64(1):6–17, 2014. [9] A. Frieder and L. Roditty. An experimental study on approximating k shortest simple paths. Journal of Experimental Algorithmics (JEA), 19:1–5, 2015. [10] Z. Gotthilf and M. Lewenstein. Improved algorithms for the k simple shortest paths and the replacement paths problems. Information Processing Letters, 109(7):352–355, 2009. [11] E. Hadjiconstantinou and N. Christofides. An efficient implementation of an algorithm for finding k shortest simple paths. Networks, 34(2):88–101, 1999. [12] J. Hershberger, M. Maxel, and S. Suri. Finding the k shortest simple paths: A new algorithm and its implementation. ACM Transactions on Algorithms (TALG), 3(4):45, 2007. [13] J. Hershberger and S. Suri. Vickrey prices and shortest paths: What is an edge worth? In Foundations of Computer Science, 2001. Proceedings. 42nd IEEE Symposium on, pages 252– 259. IEEE, 2001. [14] J. Hershberger, S. Suri, and A. Bhosle. On the difficulty of some shortest path problems. ACM Transactions on Algorithms (TALG), 3(1):5, 2007. [15] A. Itai and M. Rodeh. Finding a minimum circuit in an graph. SIAM Journal on Computing, 7(4):413–423, 1978. [16] D. B. Johnson. Finding all the elementary circuits of a directed graph. SIAM Journal on Computing, 4(1):77–84, 1975. [17] D. B. Johnson. Efficient algorithms for shortest paths in sparse networks. Journal of the ACM, 24(1):1–13, 1977. [18] D. R. Karger, D. Koller, and S. J. Phillips. Finding the hidden path: Time bounds for all-pairs shortest paths. SIAM J. Comput., 22(6):1199–1217, 1993. [19] N. Katoh, T. Ibaraki, and H. Mine. An efficient algorithm for k shortest simple paths. Networks, 12(4):411–427, 1982. [20] K. N. Lalgudi and M. C. Papaefthymiou. Computing strictly-second shortest paths. Informa- tion Processing Letters, 63(4):177–181, 1997. [21] E. L. Lawler. A procedure for computing the k best solutions to discrete optimization problems and its application to the shortest path problem. Management Science, 18(7):401–405, 1972. [22] E. L. Lawler. Comment on a computing the k shortest paths in a graph. Communications of the ACM, 20(8):603–605, 1977. [23] E. Q. Martins and M. M. Pascoal. A new implementation of Yen's ranking loopless paths algorithm. Quarterly Journal of the Belgian, French and Italian Operations Research Societies, 1(2):121–133, 2003. [24] W. Matthew Carlyle and R. Kevin Wood. Near-shortest and k-shortest simple paths. Networks, 46(2):98–109, 2005. 21 [25] E. Minieka. On computing sets of shortest paths in a graph. Communications of the ACM, 17(6):351–353, 1974. [26] A. Perko. Implementation of algorithms for k shortest loopless paths. Networks, 16(2):149–160, 1986. [27] S. Pettie. A new approach to all-pairs shortest paths on real-weighted graphs. Theoretical Computer Science, 312(1):47 – 74, 2004. [28] L. Roditty. On the k shortest simple paths problem in weighted directed graphs. SIAM Journal on Computing, 39(6):2363–2376, 2010. [29] L. Roditty and U. Zwick. Replacement paths and k simple shortest paths in unweighted directed graphs. ACM Transactions on Algorithms (TALG), 8(4):33, 2012. [30] A. Sedeno-Noda. An efficient time and space k point-to-point shortest simple paths algorithm. Applied Mathematics and Computation, 218(20):10244–10257, 2012. [31] R. Tarjan. Enumeration of the elementary circuits of a directed graph. SIAM Journal on Computing, 2(3):211–216, 1973. [32] J. C. Tiernan. An efficient search algorithm to find the elementary circuits of a graph. Comm. of the ACM (CACM), 13:722–726, 1970. [33] H. Weinblatt. A new search algorithm to find the elementary circuits of a graph. Journal of the ACM (JACM), 19:43–56, 1972. [34] V. V. Williams and R. Williams. Subcubic equivalences between path, matrix and triangle problems. In Foundations of Computer Science (FOCS), 2010 51st Annual IEEE Symposium on, pages 645–654. IEEE, 2010. [35] J. Y. Yen. Finding the k shortest loopless paths in a network. Management Science, 17(11):712– 716, 1971. 22
1703.01913
1
1703
2017-03-06T15:03:55
Near-Optimal Closeness Testing of Discrete Histogram Distributions
[ "cs.DS", "cs.IT", "cs.LG", "cs.IT", "math.ST", "math.ST" ]
We investigate the problem of testing the equivalence between two discrete histograms. A {\em $k$-histogram} over $[n]$ is a probability distribution that is piecewise constant over some set of $k$ intervals over $[n]$. Histograms have been extensively studied in computer science and statistics. Given a set of samples from two $k$-histogram distributions $p, q$ over $[n]$, we want to distinguish (with high probability) between the cases that $p = q$ and $\|p-q\|_1 \geq \epsilon$. The main contribution of this paper is a new algorithm for this testing problem and a nearly matching information-theoretic lower bound. Specifically, the sample complexity of our algorithm matches our lower bound up to a logarithmic factor, improving on previous work by polynomial factors in the relevant parameters. Our algorithmic approach applies in a more general setting and yields improved sample upper bounds for testing closeness of other structured distributions as well.
cs.DS
cs
Near-Optimal Closeness Testing of Discrete Histogram Distributions Ilias Diakonikolas∗ Daniel M. Kane† University of Southern California University of California, San Diego [email protected] [email protected] Vladimir Nikishkin‡ University of Edinburgh [email protected] March 7, 2017 Abstract We investigate the problem of testing the equivalence between two discrete histograms. A k-histogram over [n] is a probability distribution that is piecewise constant over some set of k intervals over [n]. Histograms have been extensively studied in computer science and statistics. Given a set of samples from two k-histogram distributions p, q over [n], we want to distinguish (with high probability) between the cases that p = q and kp − qk1 ≥ ǫ. The main contribution of this paper is a new algorithm for this testing problem and a nearly matching information- theoretic lower bound. Specifically, the sample complexity of our algorithm matches our lower bound up to a logarithmic factor, improving on previous work by polynomial factors in the relevant parameters. Our algorithmic approach applies in a more general setting and yields improved sample upper bounds for testing closeness of other structured distributions as well. 1 Introduction In this work, we study the problem of testing equivalence (closeness) between two discrete structured distributions. Let D be a family of univariate distributions over [n] (or Z). The problem of closeness testing for D is the following: Given sample access to two unknown distribution p, q ∈ D, we want to distinguish between the case that p = q versus kp − qk1 ≥ ǫ. (Here, kp − qk1 denotes the ℓ1- distance between the distributions p, q.) The sample complexity of this problem depends on the underlying family D. For example, if D is the class of all distributions over [n], then it is known [CDVV14] that the optimal sample complexity is Θ(max{n2/3/ǫ4/3, n1/2/ǫ2}). This sample bound is best possible only if the family D includes all possible distributions over [n], and we may be able to obtain significantly better upper bounds for most natural settings. For example, if both p, q are promised to be (approximately) log-concave over [n], there is an algorithm to test equivalence between them using O(1/ǫ9/4) samples [DKN15a]. This sample bound is independent of the support size n, and is dramatically better than the worst-case tight bound [CDVV14] when n is large. ∗Supported by NSF Award CCF-1652862 (CAREER) and a Sloan Research Fellowship. †Supported by NSF Award CCF-1553288 (CAREER) and a Sloan Research Fellowship. ‡Supported by a University of Edinburgh PCD Scholarship. More generally, [DKN15a] described a framework to obtain sample-efficient equivalence testers for various families of structured distributions over both continuous and discrete domains. While the results of [DKN15a] are sample-optimal for some families of distributions (in particular, over continuous domains), it was not known whether they can be improved for natural families of discrete distributions. In this paper, we work in the framework of [DKN15a] and obtain new nearly-matching algorithms and lower bounds. Before we state our results in full generality, we describe in detail a concrete application of our techniques to the case of histograms – a well-studied family of structured discrete distributions with a plethora of applications. Testing Closeness of Histograms. A k-histogram over [n] is a probability distribution p : [n] → [0, 1] that is piecewise constant over some set of k intervals over [n]. The algorithmic difficulty in testing properties of such distributions lies in the fact that the location and "size" of these intervals is a priori unknown. Histograms have been extensively studied in statistics and computer science. In the database community, histograms [JKM+98, CMN98, TGIK02, GGI+02, GKS06, ILR12, ADH+15] constitute the most common tool for the succinct approximation of data. In statistics, many methods have been proposed to estimate histogram distributions [Sco79, FD81, Sco92, LN96, DL04, WN07, Kle09] in a variety of settings. In recent years, histogram distributions have attracted renewed interested from the theoretical computer science community in the context of learning [DDS12a, CDSS13, CDSS14a, CDSS14b, DHS15, ADLS16, ADLS17, DKS16a] and testing [ILR12, DDS+13, DKN15b, Can16, CDGR16]. Here we study the following testing problem: Given sample access to two distributions p, q over [n] that are promised to be (approximately) k-histograms, distinguish between the cases that p = q versus kp − qk1 ≥ ǫ. As the main application of our techniques, we give a new testing algorithm and a nearly-matching information-theoretic lower bound for this problem. We now provide a summary of previous work on this problem followed by a description of our new upper and lower bounds. We want to ǫ-test closeness in ℓ1-distance between two k-histograms over [n], where k ≤ n. Our goal is to understand the optimal sample complexity of this problem as a function of k, n, 1/ǫ. Previous work is summarized as follows: • In [DKN15a], the authors gave a closeness tester with sample complexity O(max{k4/5/ǫ6/5, k1/2/ǫ2}). • The best known sample lower bound is Ω(max{k2/3/ǫ4/3, k1/2/ǫ2}). This straightforwardly follows from [CDVV14], since k-histograms can simulate any support k distribution. Notably, none of the two bounds depends on the domain size n. Observe that the upper bound of O(max{k4/5/ǫ6/5, k1/2/ǫ2}) cannot be tight for the entire range of parameters. For example, for n = O(k), the algorithm of [CDVV14] for testing closeness between arbitrary support n distributions has sample size O(max{k2/3/ǫ4/3, k1/2/ǫ2}), matching the above sample complexity lower bound, up to a constant factor. This simple example might suggest that the Ω(max{k2/3/ǫ4/3, k1/2/ǫ2}) lower bound is tight in general. We prove that this is not the case. The main conceptual message of our new upper bound and nearly-matching lower bound is the following: The sample complexity of ǫ-testing closeness between two k-histograms over [n] depends in a subtle way on the relation between the relevant parameters k, n and 1/ǫ. We find this fact rather surprising because such a phenomenon does not occur for the sample complexities of closely related problems. Specifically, testing the identity of a k-histogram over [n] to a fixed distribution has sample complexity Θ(k1/2/ǫ2) [DKN15b]; and learning a k-histogram 2 over [n] has sample complexity Θ(k/ǫ2) [CDSS14a]. Note that both these sample bounds are independent of n and are known to be tight for the entire range of parameters k, n, 1/ǫ. Our main positive result is a new closeness testing algorithm for k-histograms over [n] with sample complexity O(cid:0)k2/3 · log4/3(2 + n/k) log(k)/ǫ4/3(cid:1). Combined with the known upper bound of [DKN15a], we obtain the sample upper bound of O(cid:0) max(cid:0) min(k4/5/ǫ6/5, k2/3 log4/3(2 + n/k) log(k)/ǫ4/3), k1/2 log2(k) log log(k)/ǫ2(cid:1)(cid:1). As our main negative result, we prove a lower bound of Ω(min(k2/3 log1/3(2+ n/k)/ǫ4/3, k4/5/ǫ6/5)). The first term in this expression shows that the "log(2 + n/k)" factor that appears in the sample complexity of our upper bound is in fact necessary, up to a constant power. In summary, these bounds provide a nearly-tight characterization of the sample complexity of our histogram testing problem for the entire range of parameters. A few observations are in order to interpret the above bounds: • When n goes to infinity, the O(k4/5/ǫ6/5) upper bound of [DKN15a] is tight for k-histograms. • When n = poly(k) and ǫ is not too small (so that the k1/2/ǫ2 term does not kick in), then the right answer for the sample complexity of our problem is (k2/3/ǫ4/3)polylog(k). • The terms "k4/5/ǫ6/5" and "k2/3 log4/3(2 + n/k) log(k)/ǫ4/3" appearing in the sample com- plexity become equal when n is exponential in k. Therefore, our new algorithm has better sample complexity than that of [DKN15a] for all n ≤ 2O(k). In the following subsection, we state our results in a general setting and explain how the aforementioned applications are obtained from them. 1.1 Our Results and Comparison to Prior Work For a given family D of discrete distributions over [n], we are interested in designing a closeness tester for distributions in D. We work in the general framework introduced by [DKN15b, DKN15a]. Instead of designing a different tester for any given family D, the approach of [DKN15b, DKN15a] proceeds by designing a generic equivalence tester under a different metric than the ℓ1-distance. This metric, termed Ak-distance [DL01], where k ≥ 2 is a positive integer, interpolates between Kolmogorov distance (when k = 2) and the ℓ1-distance (when k = n). It turns out that, for a range of structured distribution families D, the Ak-distance can be used as a proxy for the ℓ1-distance for a value of k ≪ n [CDSS14a]. For example, if D is the family of k-histograms over [n], the A2k distance between them is tantamount to their ℓ1 distance. We can thus obtain an ℓ1 closeness tester for D by plugging in the right value of k in a general Ak closeness tester. To formally state our results, we will need some terminology. Notation. We will use p, q to denote the probability mass functions of our distributions. If p is discrete over support [n] := {1, . . . , n}, we denote by pi the probability of element i in the distribution. For two discrete distributions p, q, their ℓ1 and ℓ2 distances are kp−qk1 = Pn i=1 pi−qi and kp − qk2 = pPn i=1(pi − qi)2. Fix a partition of the domain I into disjoint intervals I := (Ii)ℓ r corresponding to p and I is the discrete distribution over [ℓ] that assigns the i-th "point" the mass that p assigns to the interval Ii; i.e., for i ∈ [ℓ], pI r (i) = p(Ii). Let Jk be the collection of all partitions of the domain I into k intervals. def = For p, q : I → R+ and k ∈ Z+, we define the Ak-distance between p and q by kp − qkAk maxI=(Ii)k i=1. For such a partition I, the reduced distribution pI i=1 p(Ii) − q(Ii) = maxI∈Jk kpI r − qI i=1∈Jk Pk r k1. 3 In this context, [DKN15a] gave a closeness testing algorithm under the Ak-distance using O(max{k4/5/ǫ6/5, k1/2/ǫ2}) samples. It was also shown that this sample bound is information– theoretically optimal (up to constant factors) for some adversarially constructed continuous dis- tributions, or discrete distributions of support size n sufficiently large as a function of k. These results raised two natural questions: (1) What is the optimal sample complexity of the Ak-closeness testing problem as a function of n, k, 1/ǫ? (2) Can we obtain tight sample lower bounds for natural families of structured distributions? We resolve both these open questions. Our main algorithmic result is the following: Theorem 1.1. Given sample access to distributions p and q on [n] and ǫ > 0 there exists an algorithm that takes O(cid:16)max(cid:16)min(cid:16)k4/5/ǫ6/5, k2/3 log4/3(2 + n/k) log(2 + k)/ǫ4/3(cid:17) , k1/2 log2(k) log log(k)/ǫ2(cid:17)(cid:17) samples from each of p and q and distinguishes with 2/3 probability between the cases that p = q and kp − qkAk ≥ ǫ. As explained in [DKN15b, DKN15a], using Theorem 1.1 one can obtain testing algorithms for the ℓ1 closeness testing of various distribution families D, by using the Ak distance as a "proxy" for the ℓ1 distance: Fact 1.2. For a univariate distribution family D and ǫ > 0, let k = k(D, ǫ) be the smallest integer such that for any f1, f2 ∈ D it holds that kf1 − f2k1 ≤ kf1 − f2kAk + ǫ/2. Then there exists an ℓ1 closeness testing algorithm for D with the sample complexity of Theorem 1.1. Applications. Our upper bound for ℓ1-testing of k-histogram distributions follows from the above by noting that for any k-histograms p, q we have kp − qk1 = kp − qkA2k . Also note that our upper bound is robust: it applies even if p, q are O(ǫ)-close in ℓ1-norm to being k-histograms. Finally, we remark that our general Ak closeness tester yields improved upper bounds for various other families of structured distributions. Consider for example the case that D consists of all k- mixtures of some simple family (e.g., discrete Gaussians or log-concave), where the parameter k is large. The algorithm of [DKN15a] leads to a tester whose sample complexity scales with O(k4/5), while Theorem 1.1 implies a O(k2/3) bound. On the lower bound side, we show: Theorem 1.3. Let p and q be distributions on [n] and let ǫ > 0 be less than a sufficiently small constant. Any tester that distinguishes between p = q and kp − qkAk ≥ ǫ for some k ≤ n must use Ω(m) samples for m = min(k2/3 log4/3(2 + n/k)/ǫ4/3, k4/5/ǫ6/5). Furthermore, for m = min(k2/3 log1/3(2 + n/k)/ǫ4/3, k4/5/ǫ6/5), any tester that distinguishes between p = q and kp − qkAk ≥ ǫ must use Ω(m) samples even if p and q are both guaranteed to be piecewise constant distributions on O(k + m) pieces. Note that a lower bound of Ω(√k/ǫ2) straightforwardly applies even for p and q being k- histograms. This dominates the above bounds for ǫ < k−3/8. We also note that our general lower bound with respect to the Ak distance is somewhat stronger, matching the term "log4/3(2 + n/k)" in our upper bound. 4 1.2 Related Work During the past two decades, distribution property testing [BFR+00] – whose roots lie in statistical hypothesis testing [NP33, LR05] – has received considerable attention by the computer science community, see [Rub12, Can15] for two recent surveys. The majority of the early work in this field has focused on characterizing the sample size needed to test properties of arbitrary distributions of a given support size. After two decades of study, this "worst-case" regime is well-understood: for many properties of interest there exist sample-optimal testers (matched by information-theoretic lower bounds) [Pan08, CDVV14, VV14, DKN15b, DK16, DGPP16]. In many settings of interest, we know a priori that the underlying distributions have some "nice structure" (exactly or approximately). The problem of learning a probability distribution under such structural assumptions is a classical topic in statistics, see [BBBB72] for a classical book, and [GJ14] for a recent book on the topic, that has recently attracted the interest of computer scientists [DDS12a, DDS12b, CDSS13, DDO+13, CDSS14a, CDSS14b, ADH+15, DKS16d, DKS16e, DKS16b, DDKT16, ADLS17, DKS16a, DKS16c]. On the other hand, the theory of distribution testing under structural assumptions is less fully developed. More than a decade ago, Batu, Kumar, and Rubinfeld [BKR04] considered a specific instantiation of this question – testing the equivalence between two unknown discrete monotone distributions – and obtained a tester whose sample complexity is poly-logarithmic in the domain size. A recent sequence of works [DDS+13, DKN15b, DKN15a] developed a framework to leverage such structural assumptions and obtained more efficient testers for a number of natural settings. However, for several natural properties of interest there is still a substantial gap between known sample upper and lower bounds. 1.3 Overview of Techniques To prove our upper bound, we use a technique of iteratively reducing the number of bins (domain elements). In particular, we show that if we merge bins together in consecutive pairs, this does not significantly affect the Ak distance between the distributions, unless a large fraction of the discrepancy between our distributions is supported on O(k) bins near the boundaries in the optimal partition. In order to take advantage of this, we provide a novel identity tester that requires few samples to distinguish between the cases where p = q and the case where p and q have a large ℓ1 distance supported on only k of the bins. We are able to take advantage of the small support essentially because having a discrepancy supported on few bins implies that the ℓ2 distance between the distributions must be reasonably large. Our new lower bounds are somewhat more involved. We prove them by exhibiting explicit families of pairs of distributions, where in one case p = q and in the other p and q have large Ak distance, but so that it is information-theoretically impossible to distinguish between these two families with a small number of samples. In both cases, p and q are explicit piecewise constant distributions with a small number of pieces. In both cases, our domain is partitioned into a small number of bins and the restrictions of the distributions to different bins are independent, making our analysis easier. In some bins we will have p = q each with mass about 1/m (where m is the number of samples). These bins will serve the purpose of adding "noise" making harder to read the "signal" from the other bins. In the remaining bins, we will have either that p = q being supported on some interval, or p and q will be supported on consecutive, non-overlapping intervals. If three samples are obtained from any one of these intervals, the order of the samples and the distributions that they come from will provide us with information about which family we came from. Unfortunately, since triple collisions are relatively uncommon, this will not be useful unless 5 m ≫ max(k4/5/ǫ6/5, k1/2/ǫ2). Bins from which we have one or zero samples will tell us nothing, but bins from which we have exactly two samples may provide information. For these bins, it can be seen that we learn nothing from the ordering of the samples, but we may learn something from their spacing. In particular, in the case where p and q are supported on disjoint intervals, we would suspect that two samples very close to each other are far more likely to be taken from the same distribution rather than from opposite distributions. On the other hand, in order to properly interpret this information, we will need to know something about the scale of the distributions involved in order to know when two points should be considered to be "close". To overcome this difficulty, we will stretch each of our distributions by a random exponential amount. This will effectively conceal any information about the scales involved so long as the total support size of our distributions is exponentially large. 2 A Near-Optimal Closeness Tester over Discrete Domains 2.1 Warmup: A Simpler Algorithm We start by giving a simpler algorithm establishing a basic version of Theorem 1.1 with slightly worse parameters: Proposition 2.1. Given sample access to distributions p and q on [n] and ǫ > 0 there exists an algorithm that takes O(cid:16)k2/3 log4/3(3 + n/k) log log(3 + n/k)/ǫ4/3 + √k log2(3 + n/k) log log(3 + n/k)/ǫ2(cid:17) samples from each of p and q and distinguishes with 2/3 probability between the cases that p = q and kp − qkAk ≥ ǫ. The basic idea of our algorithm is the following: From the distributions p and q construct new distributions p′ and q′ by merging pairs of consecutive buckets. Note that p′ and q′ each have much smaller domains (of size about n/2). Furthermore, note that the Ak distance between p and q is PI∈I p(I) − q(I) for some partition I into k intervals. By using essentially the same partition, we can show that kp′ − q′kAk should be almost as large as kp − qkAk . This will in fact hold unless much of the error between p and q is supported at points near the endpoints of intervals in I. If this is the case, it turns out there is an easy algorithm to detect this discrepancy. We require the following definitions: Definition 2.2. For a discrete distribution p on [n], the merged distribution obtained from p is the distribution p′ on ⌈n/2⌉, so that p′(i) def= p(2i) + p(2i + 1). For a partition I of [n] , define the i ∈ I ′ has the points obtained by point-wise gluing divided partition I ′ of domain ⌈n/2⌉, so that I ′ together odd points and even points. Note that one can simulate a sample from p′ given a sample from p by letting p′ = ⌈p/2⌉. Definition 2.3. Let p and q be distributions on [n]. For integers k ≥ 1, let kp − qk1,k be the sum of the largest k values of p(i) − q(i) over i ∈ [n]. We begin by showing that either kp′ − q′kAk is close to kp − qkAk or kp − qk1,k is large. Lemma 2.4. For any two distributions p and q on [n], let p′ and q′ be the merged distributions. Then, kp − qkAk ≤ kp′ − q′kAk + 2kp − qk1,k . 6 Proof. Let I be the partition of [n] into k intervals so that kp − qkAk = PI∈I p(I) − q(I). Let I ′ be obtained from I by rounding each upper endpoint of each interval except for the last down to the nearest even integer, and rounding the lower endpoint of each interval up to the nearest odd integer. Note that XI∈I ′ p(I) − q(I) = XI∈I ′ p′(I/2) − q′(I/2) ≤ kp′ − q′kAk . The partition I ′ is obtained from I by taking at most k points and moving them from one interval to another. Therefore, the difference XI∈I (cid:12)(cid:12)(cid:12)(cid:12)(cid:12) p(I) − q(I) − XI∈I ′ p(I) − q(I)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) , is at most twice the sum of p(i) − q(i) over these k points, and therefore at most 2kp − qk1,k. Combing this with the above gives our result. Next, we need to show that if two distributions have kp − qk1,k large that this can be detected easily. Lemma 2.5. Let p and q be distributions on [n]. Let k > 0 be a positive integer, and ǫ > 0. There exists an algorithm which takes O(k2/3/ǫ4/3 +√k/ǫ2) samples from each of p and q and, with probability at least 2/3, distinguishes between the cases that p = q and kp − qk1,k > ǫ. Note that if we needed to distinguish between p = q and kp − qk1 > ǫ, this would require Ω(n2/3/ǫ4/3 + √n/ǫ2) samples. However, the optimal testers for this problem are morally ℓ2- testers. That is, roughly, they actually distinguish between p = q and kp − qk2 > ǫ/√n. From this viewpoint, it is clear why it would be easier to test for discrepancies in k − k1,k-distance, since if kp− qk1,k > ǫ, then kp− qk2 > ǫ/√k, making it easier for our ℓ2-type tester to detect the difference. Our general approach will be by way of the techniques developed in [DK16]. We begin by giving the definition of a split distribution coming from that paper: Definition 2.6. Given a distribution p on [n] and a multiset S of elements of [n], define the split distribution pS on [n +S] as follows: For 1 ≤ i ≤ n, let ai denote 1 plus the number of elements of S that are equal to i. Thus, Pn i=1 ai = n +S. We can therefore associate the elements of [n +S] to elements of the set B = {(i, j) : i ∈ [n], 1 ≤ j ≤ ai}. We now define a distribution pS with support B, by letting a random sample from pS be given by (i, j), where i is drawn randomly from p and j is drawn randomly from [ai]. We now recall two basic facts about split distributions: Fact 2.7 ([DK16]). Let p and q be probability distributions on [n], and S a given multiset of [n]. Then: (i) We can simulate a sample from pS or qS by taking a single sample from p or q, respectively. (ii) It holds kpS − qSk1 = kp − qk1. Lemma 2.8 ([DK16]). Let p be a distribution on [n]. Then: (i) For any multisets S ⊆ S′ of [n], kpS′k2 ≤ kpSk2, and (ii) If S is obtained by taking m samples from p, then E[kpSk2 2] ≤ 1/m. We also recall an optimal ℓ2 closeness tester under the promise that one of the distributions has smal ℓ2 norm: 7 Lemma 2.9 ([CDVV14]). Let p and q be two unknown distributions on [n]. There exists an algorithm that on input n, b ≥ min{kpk2,kqk2} and 0 < ǫ < √2b, draws O(b/ǫ2) samples from each of p and q and, with probability at least 2/3, distinguishes between the cases that p = q and kp − qk2 > ǫ. Proof of Lemma 2.5: We begin by presenting the algorithm: Algorithm Small-Support-Discrepancy-Tester Input: sample access to pdf's p, q : [n] → [0, 1], k ∈ Z+, and ǫ > 0. Output: "YES" if q = p; "NO" if kq − pk1,k ≥ ǫ. 1. Let m = min(k2/3/ǫ4/3, k). 2. Let S be the multiset obtained by taking m independent samples from p. 3. Use the ℓ2 tester of Lemma 2.9 to distinguish between the cases that pS = qS and kpS − qSk2 2 ≥ k−1ǫ2/2 and return the result. The analysis is simple. By Lemma 2.8, with 90% probability kpSk2 = O(m−1/2), and therefore the number of samples needed (using the ℓ2 tester from Lemma 2.9) is O(m + km−1/2/ǫ2) = O(k2/3/ǫ4/3 +√k/ǫ2). If p = q, then pS = qS and the algorithm will return "YES" with appropriate probability. If kq − pk1,k ≥ ǫ, then kpS − qSk1,k+m ≥ ǫ. Since k + m elements contribute to total ℓ1 error at least ǫ, by Cauchy-Schwarz, we have that kpS − qSk2 2 ≥ ǫ2/(k + m) ≥ k−1ǫ2/2. Therefore, in this case, the algorithm returns "NO" with appropriate probability. Proof of Proposition 2.1: The basic idea of our algorithm is the following: By Lemma 2.5, if kp − qkAk is large, then so is either kp− qk1,k or kp′ − q′kAk . Our algorithm then tests whether kp− qk1,k is large, and recursively tests whether kp′ − q′kAk is large. Since p′, q′ have half the support size, we will only need to do this for log(n/k) rounds, losing only a poly-logarithmic factor in the sample complexity. We present the algorithm here: Algorithm Small-Domain-Ak-tester Input: sample access to pdf's p, q : [n] → [0, 1], k ∈ Z+, and ǫ > 0. Output: "YES" if q = p; "NO" if kq − pkAk ≥ ǫ. 1. For i := 0 to t def= ⌈log2(n/k)⌉, let p(i), q(i) be distributions on [⌈2−in⌉] defined by p(i) = ⌈2−ip⌉ and q(i) = ⌈2−iq⌉. 2. Take Ck2/3 log4/3(3 + n/k) log log(3 + n/k)/ǫ4/3 samples, for C sufficiently large, and use these samples to distinguish between the cases p(i) = q(i) and kp(i) − q(i)k1,k > ǫ/(4 log2(3 + n/k)) with probability of error at most 1/(10 log2(3 + n/k)) for each i from 0 to t, using the same samples for each test. 3. If any test yields that p(i) 6= q(i), return "NO". Otherwise, return "YES". We now show correctness. In terms of sample complexity, we note that by taking a majority over O(log log(3 + n/k)) independent runs of the tester from Lemma 2.5 we can run this algorithm with the stated sample complexity. Taking a union bound, we can also assume that all tests performed in Step 2 returned the correct answer. If p = q then p(i) = q(i) for all i and thus, our algorithm 8 returns "YES". Otherwise, we have that kp − qkAk ≥ ǫ. By repeated application of Lemma 2.4, we have that kp − qkAk ≤ t−1 Xi=0 2kp(i) − q(i)k1,k + kp(t) − q(t)kAk ≤ 2 t Xi=0 kp(i) − q(i)k1,k , where the last step was because p(t) and q(t) have a support of size at most k and so kp(t) − q(t)kAk = kp(t) − q(t)k1 = kp(t) − q(t)k1,k. Therefore, if this is at least ǫ, it must be the case that kp(i) − q(i)k1,k > ǫ/(4 log2(3 + n/k)) for some 0 ≤ i ≤ t, and thus our algorithm returns "NO". This completes our proof. 2.2 Full Algorithm The improvement to Proposition 2.1 is somewhat technical. The key idea involves looking into the analysis of Lemma 2.5. Generally speaking, choosing a larger value of m (up to the total sample complexity), will decrease the ℓ2 norm of p, and thus the final complexity. Unfortunately, taking m > k might lead to problems as it will subdivide the k original bins on which the error is supported into ω(k) bins. This in turn could worsen the lower bounds on kp − qk2. However, this will only be the case if the total mass of these bins carrying the difference is large. Thus, we can obtain an improvement to Lemma 2.5 when the mass of bins on which the error is supported is small. This motivates the following definition: Definition 2.10. For probability distributions p, q, an integer k and real number α > 0, dk,α(p, q) is the maximum over sets T of size at most k so that p(i) ≤ α for all i ∈ T of Pi∈T p(i) − q(i). In other words, dk,α(p, q) is the biggest ℓ1 difference between p and q coming from at most k bins of mass at most α. We have the following lemma: Lemma 2.11. Let p and q be distributions on [n]. Let k > 0 be a positive integer, and ǫ, α > 0. There exists an algorithm which takes O(k2/3/ǫ4/3(1 + mα)) samples from each of p and q and, with probability at least 2/3, distinguishes between the cases that p = q and dk,α(p, q) > ǫ. Proof. The algorithm and its analysis are nearly identical to that of Lemma 2.5. We include them here for completeness: Algorithm Small-Support-Discrepancy-Tester Input: sample access to pdf's p, q : [n] → [0, 1], k ∈ Z+, and ǫ > 0 with kpk2 ≤ α. Output: "YES" if q = p; "NO" if kq − pk1,k ≥ ǫ. 1. Let m = k2/3/ǫ4/3. 2. Let S be the multiset obtained by taking m independent samples from p. 3. Use the ℓ2 tester of Lemma 2.9 to distinguish between the cases pS = qS and kpS − 2 ≥ k−1ǫ2/(1 + O(αm/√k)) and return the result. qSk2 The analysis is quite simple. Firstly, we can assume that kpSk2 2 = O(1/m) as this happens with 90% probability over the choice of S. Next, let T be the set of size at most k such that dk,α(p, q) = Pi∈T p(i)−q(i). With 90% probability over the choice of S, we have that only O(mkα) elements from S land in T . Assuming this is the case, it is sufficient to distinguish between pS = qS 2 ≥ k−1ǫ2/(1 + O(αm)), which can be done in O(kǫ−2(1 + O(αm/√k))/√m) = and kpS − qSk2 O(k2/3ǫ−4/3(1 + O(αm))) samples. This completes the proof. 9 We are now prepared to prove Theorem 1.1. The basic idea behind the improvement is that we want to avoid merging heavy bins. We do this by first taking a large set of elements and defining the p(i) in a way that doesn't involve merging elements of these sets. Proof. We first note that given the algorithm from [DKN15a], it suffices to provide an algorithm when ǫ > k−3/8 and n ≤ 2k. Our algorithm is the following: Algorithm Small-Domain-Ak-tester Input: sample access to pdf's p, q : [n] → [0, 1], k ∈ Z+, and ǫ > 0. Output: "YES" if q = p; "NO" if kq − pkAk ≥ ǫ. 1. Let m = k2/3 log4/3(3 + n/k)/ǫ4/3. Let C be a sufficiently large constant. 2. Let S be a set of Cm log(k) independent samples from p. 3. Let p(0) = p and q(0) = q. For i := 1 to t def= ⌈log2(n/k)⌉, define distributions p(i), q(i) inductively as follows: (a) p(i) will be a flattening of p by merging all bins in certain dyadic intervals (i.e., intervals of the form [a · 2b + 1, (a + 1)2b]). (b) p(i+1) is obtained from p(i) by merging any pair of adjacent bins of p(i) that correspond to intervals [a2i+1 + 1, a2i+1 + 2i] and [a2i+1 + 2i + 1, (a + 1)2i] where neither of these subintervals contains a point of S. (c) q(i+1) is obtained by merging bins in a similar way. 4. Take Cm log log(3 + n/k) samples, and use these samples to distinguish between the cases p(i) = q(i) and dk,1/m(p(i) − q(i)) > ǫ/(8 log2(3 + n/k)) with probability of error at most 1/(10 log2(3 + n/k)) for each i from 0 to t, using the same samples for each test. 5. If any test yields that p(i) 6= q(i), return "NO". 6. Otherwise, test if p(t) = q(t) of kp(t) − q(t)kAk > ǫ/2 using the algorithm from Propo- sition 2.1 and return the answer. We now proceed with the analysis. Firstly, we note that the bins of p(t) corresponds to a dyadic interval either containing an element of S or adjacent to such an element. Therefore, the domain of p(t) is at most O(tS) = poly(k). We also note that the sample complexity of O(m log(k)) + O(k2/3 log4/3(3 + n/k) log log(3 + n/k)/ǫ4/3) + O((k2/3 log4/3(k) log log(k)/ǫ4/3 + √k log2(k) log log(k)/ǫ2)), which is sufficient. We now proceed to prove correctness. For completeness, if p = q, it is easy to see that p(i) = q(i) for all i, and thus, by a union bound, we pass every test and our algorithm returns "YES" with 2/3 probability. It remains to consider the soundness case, i.e., the case where kp − qkAk > ǫ. In this case, let i=1 p(Ii) − q(Ii) > ǫ. We claim that I = {Ii}1≤i≤k be a partition of [n] into intervals so that Pk 10 with high probability over the choice of S every dyadic interval that has mass (under p) at least 1/m and contains an endpoint of some Ii also contains an element of S. To prove this, we note that the Ii contain only O(k) endpoints, and each endpoint is contained in a unique minimal dyadic interval of mass at least 1/m. It suffices to show that each of these O(k) intervals of mass at least 1/m contains a point in S, but this follows easily by a union bound. Henceforth, we will assume that the S we chose has this property. Let I (i) be a partition of the bins for p(i) and q(i) defined inductively by I (0) = I and I (i+1) is obtained from I (i) by flattening it and assigning new bins that partially overlap two of the intervals in I (i) arbitrarily to one of the two corresponding intervals in I (i+1). We note that XI∈I (i) p(i)(I) − q(i)(I) − XI∈I (i+1) (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) p(i+1)(I) − q(i+1)(I)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) is at most twice a sum over k bins b, not containing an element of S of p(i)(b) − q(i)(b). This in turn is at most 2dk,1/m(p(i), q(i)). Inducting, we have that kp − qkAk ≤ 2 t−1 Xi=0 dk,1/m(p(i), q(i)) + kp(t) − q(t)kAk . Therefore, if kp − qkAk > ǫ, we have that either dk,1/m(p(i) − q(i)) > ǫ/(8 log2(3 + n/k)) for some i, or kp(t) − q(t)kAk > ǫ/2. In either case, with probability at least 2/3, our algorithm will detect this and reject. This completes the proof. 3 Nearly Matching Information-Theoretic Lower Bound In this section, we prove a nearly matching sample lower bound. We first show a slightly easier lower bound that holds even for distributions that are piecewise constant on a few pieces, and then modify it to obtain the stronger general bound for testing closeness in Ak distance. 3.1 Lower Bound for k-Histograms We begin with a lower bound for k-histograms (k-flat distributions). Before moving to the discrete setting, we first establish a lower bound for continuous histogram distributions. Our bound on discrete distributions will follow from taking the adversarial distribution from this example and rounding its values to the nearest integer. In order for this to work, we will need ensure to that our adversarial distribution does not have its Ak-distance decrease by too much when we apply this operation. To satisfy this requirement, we will guarantee that our distributions will be piecewise constant with all the pieces of length at least 1. Proposition 3.1. Let k ∈ Z+, ǫ > 0 sufficiently small, and W > 2 . Fix m = min(k2/3 log1/3(W )/ǫ4/3, k4/5/ǫ6/5) . There exist distributions D,D′ over pairs of distributions p and q on [0, 2(m + k)W ], where p and q are O(m + k)-flat with pieces of length at least 1, so that: (a) when drawn from D, we have p = q deterministically, (b) when drawn from D′, we have kp− qkAk > ǫ with 90% probability, and so that o(m) samples are insufficient to distinguish whether or not the pair is drawn from D or D′ with better than 2/3 probability. 11 At a high-level, our lower bound construction proceeds as follows: We will divide our domain into m+k bins so that no information about which distributions had samples drawn from a given bin or the ordering of these samples will help to distinguish between the cases of p = q and otherwise, unless at least three samples are taken from the bin in question. Approximately k of these bins will each have mass ǫ/k and might convey this information if at least three samples are taken from the bin. However, the other m bins will each have mass approximately 1/m and will be used to add noise. In all, if we take s samples, we expect to see approximately s3ǫ3/k2 of the lighter bins with at least three samples. However, we will see approximately s3/m2 of our heavy bins with three samples. In order for the signal to overwhelm the noise, we will need to ensure that we have (s3ǫ3/k2)2 > s3/m2. The above intuitive sketch assumes that we cannot obtain information from the bins in which only two samples are drawn. This naively should not be the case. If p = q, the distance between two samples drawn from that bin will be independent of whether or not they are drawn from the same distribution. However, if p and q are supported on disjoint intervals, one would expect that points that are close to each other should be far more likely to be drawn from the same distribution than from different distributions. In order to disguise this, we will scale the length of the intervals by a random, exponential amount, essentially making it impossible to determine what is meant by two points being close to each other. In effect, this will imply that two points drawn from the same bin will only reveal O(1/ log(W )) bits of information about whether p = q or not. Thus, in order for this information to be sufficient, we will need that (s2ǫ2/k)2/ log(W ) > (s2/m). We proceed with the formal proof below. Proof of Proposition 3.1: We use ideas from [DK16] to obtain this lower bound using an information theoretic argument. that Ω(√k/ǫ2) samples are required to distinguish two distributions on a support of size k. We may assume that ǫ > k1/2, because otherwise we may employ the standard lower bound First, we note that it is sufficient to take D and D′ be distributions over pairs of non-negative, piecewise constant distributions with total mass Θ(1) with 90% probability so that running a Poisson process with parameter o(m) is insufficient to distinguish a pair from D from a pair from D′ [DK16]. We construct these distributions as follows: We divide the domain into m+k bins of length 2W . For each bin i, we independently generate a random ℓi, so that log(ℓi/2) is uniformly distributed over [0, 2 log(W )/3]. We then produce an interval Ii within bin i of total length ℓi and with random offset. In all cases, we will have p and q supported on the union of the Ii's. For each i with probability m/(m + k), we have the restrictions of p and q to Ii both uniform with p(Ii) = q(Ii) = 1/m. The other k/(m + k) of the time we have p(Ii) = q(Ii) = ǫ/k. In this latter case, if p and q are being drawn from D, p and q are each constant on this interval. If they are being drawn from D′, then p + q will be constant on the interval, with all of that mass coming from p on a random half and coming from q on the other half. Note that in all cases p and q are piecewise constant with O(m + k) pieces of length at least 1. It is easy to show that with high probability the total mass of each of p and q is Θ(1), and that if drawn from D′ that kp − qkAk ≫ ǫ with at least 90% probability. We will now show that if one is given m samples from each of p and q, taken randomly from either D or D′, that the shared information between the samples and the source family will be small. This implies that one is unable to consistently guess whether our pair was taken from D or D′. Let X be a random variable that is uniformly at random either 0 or 1. Let A be obtained by applying a Poisson process with parameter s = o(m) on the pair of distributions p, q drawn from 12 D if X = 0 or from D′ if X = 1. We note that it suffices to show that the shared information I(X : A) = o(1). In particular, by Fano's inequality, we have: Lemma 3.2. If X is a uniform random bit and A is a correlated random variable, then if f is any function so that f (A) = X with at least 51% probability, then I(X : A) ≥ 2 · 10−4. Let Ai be the samples of A taken from the ith bin. Note that the Ai are conditionally inde- pendent on X. Therefore, we have that I(X : A) ≤ Pi I(X : Ai) = (m + k)I(X : A1) . We will proceed to bound I(X : A1). We note that I(X : A1) is at most the integral over pairs of multisets a (representing a set of samples from q and a set of samples from p), of O(cid:18) (Pr(A1 = aX = 0) − Pr(A1 = aX = 1))2 Pr(A1 = a) (cid:19) . Thus, I(X : A1) = ∞ Xh=0 Za=h O(cid:18) (Pr(A1 = aX = 0) − Pr(A1 = aX = 1))2 Pr(A1 = a) (cid:19) . We will split this sum up based on the value of h. For h = 0, we note that the distributions for p+q are the same for X = 0 and X = 1. Therefore, the probability of selecting no samples is the same. Therefore, this contributes 0 to the sum. For h = 1, we note that the distributions for p + q are the same in both cases, and conditioning on I1 and (p + q)(I1) that E[p] and E[q] are the same in each of the cases X = 0 and X = 1. Therefore, again in this case, we have no contribution. For h ≥ 3, we note that I(X : A1) ≤ I(X : A1, I1) ≤ I(X : A1I1) , since I1 is independent of X. We note that Pr(A1 = aX = 0, p(I1) = 1/m) = Pr(A1 = aX = 1, p(I1) = 1/m). Therefore, we have that Pr(A1 = aX = 0)−Pr(A1 = aX = 1) = Pr(A1 = aX = 0, p(I1) = ǫ/k)−Pr(A1 = aX = 1, p(I1) = ǫ/k). If p(I1) = ǫ/k, the probability that exactly h elements are selected in this bin is at most k/(m + k)(2sǫ/k)h/h!, and if they are selected, they are uniformly distributed in I1 (although which of the sets p and q they are taken from is non-uniform). However, the probability that h elements are taken from I1 is at least Ω(m/(m + k)(sm)−h/h!) from the case where p(I1) = 1/m, and in this case the elements are uniformly distributed in I1 and uniformly from each of p and q. Therefore, we have that this contribution to our shared information is at most k2/(m(m + k))O(sǫ2m/k2)h/h! . We note that ǫ2m/k2 < 1. Therefore, the sum of this over all h ≥ 3 is k2/(m(m + k))O(sǫ2m/k2)3. Summing over all m + k bins, this is k−4ǫ6s3m2 = o(1). It remains to analyze the case where h = 2. Once again, we have that ignoring which of p and q elements of A1 came from, A1 is identically distributed conditioned on p(I1) = 1/m and A1 = 2 as it is conditioned on p(I1) = ǫ/k and A1 = 2. Since once again, the distributions D and D′ are indistinguishable in the former case, we have that the contribution of the h = 2 terms to the shared information is at most O(cid:18) (k/(k + m)(ǫs/k)2)2 m/(k + m)(s/m)2 (cid:19) dTV ((A1X = 0, p(I1)ǫ/k,A1 = 2), (A1X = 1, p(I1) = ǫ/k,A1 = 2)) or O(cid:0)s2mk−2ǫ4/(k + m)(cid:1) dTV ((A1X = 0, p(I1) = ǫ/k,A1 = 2), (A1X = 1, p(I1) = ǫ/k,A1 = 2)) . 13 It will suffice to show that conditioned upon p(I1) = ǫ/k and A1 = 2 that dTV ((A1X = 0), (A1X = 1)) = O(1/ log(W )). Let f be the order preserving linear function from [0, 2] to I1. Notice that conditional on A1 = 2 and p(I1) = ǫ/k that we may sample from A1 as follows: • Pick two points x > y uniformly at random from [0, 2]. • Assign the points to p and q as follows: – If X = 0 uniformly randomly assign these points to either distribution p or q. – If X = 1 randomly do either: ∗ Assign points in [0, 1] to q and other points to p. ∗ Assign points in [0, 1] to p and other points to q. • Randomly pick I1 and apply f to x and y to get outputs z = f (x), w = f (y). Notice that the four cases: (i) both points coming from p, (ii) both points coming from q, (iii) a point from p preceding a point from q, (iv) a point from q preceding a point from p, are all equally likely conditioned on either X = 0 or X = 1. However, we will note that this ordering is no longer independent of the choice of x and y. Therefore, we can sample from A1 subject to X = 0 and from A1 subject to X = 1 in such a way that this ordering is the same deterministically. We consider running the above sampling algorithm to select (x, y) while sampling from X = 0 and (x′, y′) when sampling from X = 1 so that we are in the same one of the above four cases. We note that dTV ((A1X = 0), (A1X = 1)) ≤ Ex,y,x′,y′[dTV ((f (x), f (y)), (f (x′), f (y′)))] , where the variation distance is over the random choices of f . To show that this is small, we note that f (x) − f (y) is distributed like ℓ1(x − y). This means that log(f (x) − f (y)) is uniform over [log(f (x) − f (y)), log(f (x) − f (y)) + 2 log(W )/3]. Similarly, log(f ′(x′)− f ′(y′)) is uniform over [log(f (x′)− f (y′)), log(f (x′)− f (y′))+ 2 log(W )/3]. These differ in total variation distance by O(cid:18) log(f (x) − f (y)) + log(f (x′) − f (y′)) log(W ) (cid:19) . Taking the expectation over x, y, x′, y′ we get O(1/ log(W )). Therefore, we may further correlate the choices made in selecting our two samples, so that z − w = z′ − w′ except with probability O(1/ log(W )). We note that after conditioning on this, z and z′ are both uniformly distributed over subintervals of [0, 2W ] of length at least 2(W − W 2/3). Therefore, the distributions on z and z′ differ by at most O(W −1/3). Hence, the total variation distance between A1 conditioned on A1 = 2, p(I1) = ǫ/k, X = 0 and conditioned on A1 = 2, p(I1) = ǫ/k, X = 1 is at most O(1/ log(W )) + O(W −1/3) = O(1/ log(W )). This completes our proof. We can now turn this into a lower bound for testing Ak distance on discrete domains. Proof of second half of Theorem 1.3: Assume for sake of contradiction that this is not the case, and that there exists a tester taking o(m) samples. We use this tester to come up with a continuous tester that violates Proposition 3.1. 14 We begin by proving a few technical bounds on the parameters involved. Firstly, note that we already have a lower bound of Ω(k1/2/ǫ2), so we may assume that this is much less than m. We now claim that m = O(min(k2/3 log1/3(3 + n/(m + k))/ǫ4/3, k4/5/ǫ6/5). If m ≤ k, there is nothing to prove. Otherwise, k2/3 log1/3(3 + n/(m + k))/ǫ4/3 ≥ m(m/k)−1/3 log(3 + n/(m + k))1/3. Thus, there is nothing more to prove unless log(3 + n/(m + k)) ≫ m/k. But, in this case, log(3 + n/(m + k)) ≫ log(m/k) and thus log(3 + n/(m + k)) = Θ(log(3 + n/k)), and we are done. We now let W = n/(6(m + k)), and let D and D′ be as specified in Proposition 3.1. We claim that we have a tester to distinguish a p, q from D from ones taken from D′ in o(m) samples. We do this as follows: By rounding p and q down to the nearest third of an integer, we obtain p′,q′ supported on set of size n. Since p and q were piecewise constant on pieces of size at least 1, it is not hard to see that kp′ − q′kAk ≥ kp − qkAk /3. Therefore, a tester to distinguish p′ = q′ from kp′ − q′kAk ≥ ǫ can be used to distinguish p = q from kp − qkAk ≥ 3ǫ. This is a contradiction and proves our lower bound. 3.2 The Stronger Lower Bound In order to improve on the bound from the last section, we will need to modify our previous construction in two ways both having to do with the contribution to the shared information coming from the case where two samples are taken from the same bin. The first is that we will need a different way of distinguishing between D and D′ so that the variation distance between the distributions obtained from taking a pair of samples from the same bin is O(1/ log2(W )) rather than O(1/ log(W )). After that, we will also need a better method of disguising these errors. In particular, in the current construction, most of the information coming from pairs of samples from the same bin occurs when the two samples are very close to each other (as when this happens in D′, the samples usually don't come one from p and the other from q). This is poorly disguised by noise coming from the heavier bins since these are not particularly likely to produce samples that are close. We can improve our way of disguising this by having different heavy bins to better mask this signal. In order to solve the first of these problems, we will need the following construction: Lemma 3.3. Let W be a sufficiently large integer. There exists a family E of pairs of distributions p and q on [0, W ] so that the following holds: Firstly, p and q are deterministically supported on disjoint intervals, and thus have A1 distance 2. Furthermore, let E0 be the family of pairs of distributions p and q on [W ] obtained by taking (p′, q′) from E and letting p = q = (p′ + q′)/2. In other words, a sample from E0 can be thought of as taking a sample from E and then re-randomizing the label. Consider the distribution obtained by sampling (p, q) from E, and then taking two independent samples x and y from (p + q)/2. We let E 2 be the induced distribution on x and y along with the labels of which of p and q each were 0 similarly, and note that it is equivalent to taking a sample from E 2 and taken from. Define E 2 re-randomizing the labels. Then dTV (E 2,E 2 Proof. We note that it is enough to construct a family of continuous distributions p and q on [0, W ] so that deterministically p and q are supported on intervals separated by distance 2, and so that the second condition above holds. By then rounding the values of p and q to the nearest integer, we obtain an appropriate discrete distribution. 0 ) = O(1/ log2(W )). The construction of E is straightforward. First, choose a uniformly from [W 2/3, W − W 2/3], ℓ uniformly from [0, log(W )/3], and b uniformly from {±1}. To sample from p, take an α uniformly 15 from [0, log(W )/3] and return a + beℓeα. To sample from q, take an α uniformly from [0, log(W )/3] and return a − beℓeα. prove the more complicated claim. It is clear that p and q are supported on disjoint intervals of distance at least 2. It remains to Let E 2 0 ) = O(dTV (E 2 s ,E 2 s and (w, z) a sample from E 2 Let (x, y) be a sample from E 2 d . On the other hand, in any of these cases, a pair of samples from E 2 s be the distribution obtained by picking a pair of distributions from E and then re- turning two independent samples from p. Let E 2 d be the distribution obtained by picking a pair of distributions from E and then returning independent samples from p and q. We claim that d )). This is because if a sample from E 2 has both points coming from p dTV (E 2,E 2 or both from q, the points come from E 2 s , whereas if one point comes from each, the points come from E 2 d )/2. d . We claim that dTV ((x, y), (w, z)) ≤ dTV (x − y, w − z) + O(W −1/3). This is because of the averaging over a in the definition of E. In particular, consider the following mechanism for taking a sample from E 2 d . First, randomly select values of s and ℓ. Then select the α and α′ for the two sample points. Finally, sample the defining value of a. Notice that the difference between the two final points does not depend on the choice of a. In fact, after making all other choices, the final distribution is within O(W −1/3) of the uniform distribution over pairs of points in [0, W ] with this distance. Thus, (x, y) is close distributionally to the distribution on pairs in [0, W ] with separation x−y. A similar statement holds for (z, w) and points with separation z−w. Thus, dTV ((x, y), (w, z)) = dTV (x−y, w−z)+O(W −1/3), as desired. Next, we claim that dTV (x− y, z − w) = dTV (x− y,z − w). This is easily seen to be the case by averaging over b. We have left to bound the latter distance. If x and y are chosen using αx and αy, we have that x − y = eℓeαx − eαy. Similarly, if z and w are chosen using αz and αw, we have that z − w = eℓeαz + eαw. Notice that if we fix αx, αy, αz and αw, the variation distance between these two distributions (given the distributions over the values of ℓ) is 0 comes from (E 2 s +E 2 s or E 2 O  eαz +eαw (cid:17)(cid:12)(cid:12)(cid:12) (cid:12)(cid:12)(cid:12) log(cid:16) eαx −eαy log(W )   . Therefore, the variation distance between x − y and z − w is O(1/ log(W )) times the earth mover distance between log(eαx − eαy) and log(eαz + eαw). Correlating these variables so that αx = αz = α and αy = αw = β, this is at most the expectation of log(tanh((α − β)/2)), which 0 ) = O(1/ log2(W )), completing can easily be seen to be O(1/ log(W )). This shows that dTV (E 2,E 2 our proof. We are now ready to prove the first part of Theorem 1.3. Proof. The overall outline is very similar to the methods used in the last section. For sufficiently large integers m, k, W and ǫ > 0 we are going to define families of pairs of pseudo-distributions D and D′ on [(k + 2m)W ] so that: • With 90% probability a random sample from either D or D′ consists of two pseudo-distributions with total mass Θ(1). • The distributions picked by a sample from D are always the same. • The two distributions picked by a sample from D′ have Ak distance Ω(ǫ) with 90% probability. 16 • Letting A be the outcome of a Poisson process with parameter m run on a random sample from either D or D′, the family used cannot be reliably determined from A unless m ≫ k4/5/ǫ6/5 or m ≫ k2/3 log4/3(W )/ǫ4/3. Before we define D and D′, we will need to define one more family. Firstly, let E and E0 be the families of distributions on [W ] from Lemma 3.3. Let E 2 and E 2 0 be as described in that lemma. We define another family, F of pairs of distributions on [W ] as follows. First select a point (x, y) from the renormalized version of E 2 − E 2 0. Then return the pair of distributions p = q equals the uniform distribution over {x, y}. To define D and D′, we split [(k + 2m)W ] into k + 2m blocks of size W . A sample from D assigns to each block independently the pseudo-distribution: • E0/m (i.e., a random sample from E0 scaled by a factor of 1/m) with probability m/(k + 2m) • E0ǫ/k with probability k/(k + 2m) • F/m with probability m/(k + 2m). A sample from D′ assigns to each block independently the pseudo-distribution: • E0/m with probability m/(k + 2m) • Eǫ/k with probability k/(k + 2m) • F/m with probability m/(k + 2m). It is easy to see that D and D′ satisfy the first three of the properties listed above. To demon- strate the fourth, let X be a uniform Bernoulli random variable. Let A be obtained by applying a Poisson process of parameter m to a sample from D if X = 0, and to a sample from D′ if X = 1. We will show that I(X : A) = o(1). Once again, letting A = (A1, A2, . . . , Ak+2m), where Ai are the samples taken from the ith block, we note that the Ai are conditionally independent on X and therefore, I(X : A) ≤ (k + 2m)I(X : A1). As before, no information is gained when A1 < 2, and the contribution when A1 ≥ 3 is O((k/(k + m))2(mǫ/k)6/(m/(k + m))), which leads to a total contribution of o(1) when m = o(k4/5/ǫ6/5). It remains to consider the contribution from events where A1 = 2. (cid:19) . O(cid:18) (Pr(A1 = xX = 0) − Pr(A1 = xX = 1))2 This is Xx∈([W ]×{p,q})2 Pr(A1 = x) Note that the contribution to Pr(A1 = xX = 0) − Pr(A1 = xX = 1) from cases where D and D′ on block 1 are E0/m or F/m cancel out. Therefore, we have that Pr(A1 = xX = 0) − Pr(A1 = xX = 1) = O((k/(k + m))(mǫ/k)2E 2(x) − E 2 0 (x)) = O((k/(k + m))(mǫ/k)2F(x)/ log2(W )). On the other hand, the Pr(A1 = x) is at least the probability that A1 = x when the restriction to block 1 is F/m, which is Ω(m/(k + m)F(x)). Therefore, the contribution to I(X : A1) coming 17 from events where A1 = 2 is O(cid:18) (Pr(A1 = xX = 0) − Pr(A1 = xX = 1))2 (cid:19) Xx∈([W ]×{p,q})2 O(cid:18) ((k/(k + m))(mǫ/k)2F 2(x)/ log2(W ))2 (cid:19) = Xx∈([W ]×{p,q})2 = Xx∈([W ]×{p,q})2 F 2(x)O(k2(mǫ/k)4 log−4(W )/(m(k + m))) m/(k + m)F 2(x) Pr(A1 = x) = O(m3ǫ4k−2 log−4(W )/(m + k)). Hence, the total contribution to I(X : A) from such terms is O(m3ǫ4k−2 log−4(W )/(m + k)). This is o(1) if m = o(k2/3 log4/3(W )/ǫ4/3). This completes our proof. References [ADH+15] J. Acharya, I. Diakonikolas, C. Hegde, J. Li, and L. Schmidt. Fast and Near-Optimal Algorithms for Approximating Distributions by Histograms. In 34th ACM SIGMOD- SIGACT-SIGAI Symposium on Principles of Database Systems, PODS 2015, pages 249–263, 2015. [ADLS16] J. Acharya, I. Diakonikolas, J. Li, and L. Schmidt. Fast algorithms for segmented regression. In Proceedings of the 33nd International Conference on Machine Learning, ICML 2016, pages 2878–2886, 2016. [ADLS17] J. Acharya, I. Diakonikolas, J. Li, and L. Schmidt. Sample-optimal density estimation in nearly-linear time. In Proceedings of the Twenty-Eighth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2017, pages 1278–1289, 2017. Full version available at https://arxiv.org/abs/1506.00671. [BBBB72] R.E. Barlow, D.J. Bartholomew, J.M. Bremner, and H.D. Brunk. Statistical Inference under Order Restrictions. Wiley, New York, 1972. [BFR+00] T. Batu, L. Fortnow, R. Rubinfeld, W. D. Smith, and P. White. Testing that distri- In IEEE Symposium on Foundations of Computer Science, pages butions are close. 259–269, 2000. [BKR04] T. Batu, R. Kumar, and R. Rubinfeld. Sublinear algorithms for testing monotone and unimodal distributions. In ACM Symposium on Theory of Computing, pages 381–390, 2004. [Can15] [Can16] C. L. Canonne. A survey on distribution testing: Your data is big. but is it blue? Electronic Colloquium on Computational Complexity (ECCC), 22:63, 2015. C. L. Canonne. Are few bins enough: Testing histogram distributions. In Proceedings of the 35th ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Sys- tems, PODS 2016, pages 455–463, 2016. [CDGR16] C. L. Canonne, I. Diakonikolas, T. Gouleakis, and R. Rubinfeld. Testing shape restric- tions of discrete distributions. In 33rd Symposium on Theoretical Aspects of Computer Science, STACS 2016, pages 25:1–25:14, 2016. 18 [CDSS13] S. Chan, I. Diakonikolas, R. Servedio, and X. Sun. Learning mixtures of structured distributions over discrete domains. In SODA, pages 1380–1394, 2013. [CDSS14a] S. Chan, I. Diakonikolas, R. Servedio, and X. Sun. Efficient density estimation via piecewise polynomial approximation. In STOC, pages 604–613, 2014. [CDSS14b] S. Chan, I. Diakonikolas, R. Servedio, and X. Sun. Near-optimal density estimation in near-linear time using variable-width histograms. In NIPS, pages 1844–1852, 2014. [CDVV14] S. Chan, I. Diakonikolas, P. Valiant, and G. Valiant. Optimal algorithms for testing closeness of discrete distributions. In SODA, pages 1193–1203, 2014. [CMN98] S. Chaudhuri, R. Motwani, and V. R. Narasayya. Random sampling for histogram construction: How much is enough? In SIGMOD Conference, pages 436–447, 1998. [DDKT16] C. Daskalakis, A. De, G. Kamath, and C. Tzamos. A size-free CLT for poisson multi- nomials and its applications. In Proceedings of the 48th Annual ACM Symposium on the Theory of Computing, STOC '16, New York, NY, USA, 2016. ACM. [DDO+13] C. Daskalakis, I. Diakonikolas, R. O'Donnell, R.A. Servedio, and L. Tan. Learning Sums of Independent Integer Random Variables. In FOCS, pages 217–226, 2013. [DDS12a] C. Daskalakis, I. Diakonikolas, and R.A. Servedio. Learning k-modal distributions via testing. In SODA, pages 1371–1385, 2012. [DDS12b] C. Daskalakis, I. Diakonikolas, and R.A. Servedio. Learning Poisson Binomial Distri- butions. In STOC, pages 709–728, 2012. [DDS+13] C. Daskalakis, I. Diakonikolas, R. Servedio, G. Valiant, and P. Valiant. Testing k-modal distributions: Optimal algorithms via reductions. In SODA, pages 1833–1852, 2013. [DGPP16] I. Diakonikolas, T. Gouleakis, J. Peebles, and E. Price. Collision-based testers are opti- mal for uniformity and closeness. Electronic Colloquium on Computational Complexity (ECCC), 23:178, 2016. [DHS15] I. Diakonikolas, M. Hardt, and L. Schmidt. Differentially private learning of structured discrete distributions. In NIPS, pages 2566–2574, 2015. [DK16] I. Diakonikolas and D. M. Kane. A new approach for testing properties of discrete distributions. In FOCS, pages 685–694, 2016. Full version available at abs/1601.05557. [DKN15a] I. Diakonikolas, D. M. Kane, and V. Nikishkin. Optimal algorithms and lower bounds for testing closeness of structured distributions. In IEEE 56th Annual Symposium on Foundations of Computer Science, FOCS 2015, pages 1183–1202, 2015. [DKN15b] I. Diakonikolas, D. M. Kane, and V. Nikishkin. Testing identity of structured distribu- tions. In Proceedings of the Twenty-Sixth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2015, pages 1841–1854, 2015. [DKS16a] I. Diakonikolas, D. M. Kane, and A. Stewart. Efficient robust proper learning of log- concave distributions. CoRR, abs/1606.03077, 2016. [DKS16b] I. Diakonikolas, D. M. Kane, and A. Stewart. The fourier transform of poisson multino- mial distributions and its algorithmic applications. In Proceedings of STOC'16, 2016. 19 [DKS16c] I. Diakonikolas, D. M. Kane, and A. Stewart. Learning multivariate log-concave distri- butions. CoRR, abs/1605.08188, 2016. [DKS16d] I. Diakonikolas, D. M. Kane, and A. Stewart. Optimal Learning via the Fourier Trans- form for Sums of Independent Integer Random Variables. In COLT, volume 49, pages 831–849, 2016. Full version available at arXiv:1505.00662. [DKS16e] I. Diakonikolas, D. M. Kane, and A. Stewart. Properly learning poisson binomial distri- butions in almost polynomial time. In Proceedings of the 29th Conference on Learning Theory, COLT 2016, pages 850–878, 2016. Full version available at arXiv:1511.04066. [DL01] [DL04] [FD81] L. Devroye and G. Lugosi. Combinatorial methods in density estimation. Springer Series in Statistics, Springer, 2001. L. Devroye and G. Lugosi. Bin width selection in multivariate histograms by the combinatorial method. Test, 13(1):129–145, 2004. D. Freedman and P. Diaconis. On the histogram as a density estimator:l2 theory. Zeitschrift fur Wahrscheinlichkeitstheorie und Verwandte Gebiete, 57(4):453–476, 1981. [GGI+02] A. C. Gilbert, S. Guha, P. Indyk, Y. Kotidis, S. Muthukrishnan, and M. Strauss. Fast, small-space algorithms for approximate histogram maintenance. In STOC, pages 389–398, 2002. [GJ14] P. Groeneboom and G. Jongbloed. Nonparametric Estimation under Shape Constraints: Estimators, Algorithms and Asymptotics. Cambridge University Press, 2014. [GKS06] S. Guha, N. Koudas, and K. Shim. Approximation and streaming algorithms for his- togram construction problems. ACM Trans. Database Syst., 31(1):396–438, 2006. [ILR12] P. Indyk, R. Levi, and R. Rubinfeld. Approximating and Testing k-Histogram Distri- butions in Sub-linear Time. In PODS, pages 15–22, 2012. [JKM+98] H. V. Jagadish, N. Koudas, S. Muthukrishnan, V. Poosala, K. C. Sevcik, and T. Suel. Optimal histograms with quality guarantees. In VLDB, pages 275–286, 1998. [Kle09] [LN96] [LR05] [NP33] J. Klemela. Multivariate histograms with data-dependent partitions. Statistica Sinica, 19(1):159–176, 2009. G. Lugosi and A. Nobel. Consistency of data-driven histogram methods for density estimation and classification. Ann. Statist., 24(2):687–706, 04 1996. E. L. Lehmann and J. P. Romano. Testing statistical hypotheses. Springer Texts in Statistics. Springer, 2005. J. Neyman and E. S. Pearson. On the problem of the most efficient tests of statis- tical hypotheses. Philosophical Transactions of the Royal Society of London. Series A, Containing Papers of a Mathematical or Physical Character, 231(694-706):289–337, 1933. [Pan08] L. Paninski. A coincidence-based test for uniformity given very sparsely-sampled dis- crete data. IEEE Transactions on Information Theory, 54:4750–4755, 2008. [Rub12] R. Rubinfeld. Taming big probability distributions. XRDS, 19(1):24–28, 2012. 20 [Sco79] D. W. Scott. On optimal and data-based histograms. Biometrika, 66(3):605–610, 1979. [Sco92] D.W. Scott. Multivariate Density Estimation: Theory, Practice and Visualization. Wiley, New York, 1992. [TGIK02] N. Thaper, S. Guha, P. Indyk, and N. Koudas. Dynamic multidimensional histograms. In SIGMOD Conference, pages 428–439, 2002. [VV14] [WN07] G. Valiant and P. Valiant. An automatic inequality prover and instance optimal identity testing. In FOCS, 2014. R. Willett and R. D. Nowak. Multiscale poisson intensity and density estimation. IEEE Transactions on Information Theory, 53(9):3171–3187, 2007. 21
1207.0043
2
1207
2013-01-15T21:48:00
Routing Regardless of Network Stability
[ "cs.DS" ]
We examine the effectiveness of packet routing in this model for the broad class next-hop preferences with filtering. Here each node v has a filtering list D(v) consisting of nodes it does not want its packets to route through. Acceptable paths (those that avoid nodes in the filtering list) are ranked according to the next-hop, that is, the neighbour of v that the path begins with. On the negative side, we present a strong inapproximability result. For filtering lists of cardinality at most one, given a network in which an equilibrium is guaranteed to exist, it is NP-hard to approximate the maximum number of packets that can be routed to within a factor of O(n^{1-\epsilon}), for any constant \epsilon >0. On the positive side, we give algorithms to show that in two fundamental cases every packet will eventually route with probability one. The first case is when each node's filtering list contains only itself, that is, D(v)={v}. Moreover, with positive probability every packet will be routed before the control plane reaches an equilibrium. The second case is when all the filtering lists are empty, that is, $\mathcal{D}(v)=\emptyset$. Thus, with probability one packets will route even when the nodes don't care if their packets cycle! Furthermore, with probability one every packet will route even when the control plane has em no equilibrium at all.
cs.DS
cs
Routing regardless of Network Stability Bundit Laekhanukit∗ Adrian Vetta† Gordon Wilfong‡ November 8, 2018 Abstract How effective are interdomain routing protocols, such as the Border Gateway Protocol, at routing packets? Theoretical analyses have attempted to answer this question by ignoring the packets and instead focusing upon protocol stability. To study stability, it suffices to model only the control plane (which determines the routing graph) -- an approach taken in the Stable Paths Problem. To analyse packet routing requires modelling the interactions between the control plane and the forwarding plane (which determines where packets are forwarded), and our first contribution is to introduce such a model. We then examine the effectiveness of packet routing in this model for the broad class next-hop preferences with filtering. Here each node v has a filtering list D(v) consisting of nodes it does not want its packets to route through. Acceptable paths (those that avoid nodes in the filtering list) are ranked according to the next-hop, that is, the neighbour of v that the path begins with. On the negative side, we present a strong inapproximability result. For filtering lists of cardinality at most one, given a network in which an equilibrium is guaranteed to exist, it is NP-hard to approximate the maximum number of packets that can be routed to within a factor of n1−, for any constant  > 0. On the positive side, we give algorithms to show that in two fundamental cases every packet will eventually route with probability one. The first case is when each node's filtering list contains only itself, that is, D(v) = {v}; this is the fundamental case in which a node does not want its packets to cycle. Moreover, with positive probability every packet will be routed before the control plane reaches an equilibrium. The second case is when all the filtering lists are empty, that is, D(v) = ∅. Thus, with probability one packets will route even when the nodes do not care if their packets cycle! Furthermore, with probability one every packet will route even when the control plane has no equilibrium at all. To our knowledge, these are the first results to guarantee the possibility that all packets get routed without stability. These positive results are tight -- for the general case of filtering lists of cardinality one, it is not possible to ensure that every packet will eventually route. 1 Introduction In the Stable Paths Problem (SPP) [5], we are given a directed graph G = (V, A) and a sink (or destination) node r. Furthermore, each node v has a ranked list of some of its paths to r. The ∗School of Computer Science, McGill University. Supported by a Dr. and Mrs. Milton Leong Fellowship and by 3 1 0 2 n a J 5 1 ] S D . s c [ 2 v 3 4 0 0 . 7 0 2 1 : v i X r a NSERC grant 288334. Email: [email protected] †Department of Mathematics and Statistics and School of Computer Science, McGill University. Supported in ‡Bell Laboratories. Email: [email protected] part by NSERC grants 288334 and 429598. Email: [email protected] 1 lowest ranked entry in the list is the "empty path"1; paths that are not ranked are considered unsatisfactory. This preference list is called v's list of acceptable paths. A set of paths, one path P(v) from each node v's list of acceptable paths, is termed stable if (i) they are consistent: if u ∈ P(v), then P(u) must be the subpath of P(v) beginning at u, and (ii) they form an equilibrium: for each node v, P(v) is the path ranked highest by v of the form vP(w) where w is a neighbour of v. The stable paths problem asks whether a stable set of paths exists in the network. The SPP has risen to prominence as it is viewed as a static description of the problem that the Border Gateway Protocol (BGP) is trying dynamically to solve. BGP can be thought of as trying to find a set of stable routes to r so that routers can use these routes to send packets to r. Due to the importance of BGP, both practical and theoretical aspects of the SPP have been studied in great depth. In the main text, to avoid overloading the reader with practical techni- calities, we focus on the combinatorial aspects of packet routing; in the Appendix we discuss the technical aspects and present a motivating sample of the vast literature on BGP. Two observations concerning the SPP, though, are pertinent here and motivate our work: (1) Even if a stable solution exists, the routing tree induced by a consistent set of paths might not be spanning. Hence, a stable solution may not actually correspond to a functioning network -- there may be isolated nodes that cannot route packets to the sink! Disconnectivities arise because nodes may prefer the empty-path to any of the paths proffered by its neighbours; for example, a node might not trust certain nodes to handle its packets securely or in a timely fashion, so it may reject routes traversing such unreliable domains. This problem of non- spanning routing trees has quite recently been studied in the context of a version of BGP called iBGP [19]. In Section 3, we show that non-connectivity is a very serious problem (at least, from the theoretical side) by presenting an n1− hardness result for the combinatorial problem of finding a maximum cardinality stable subtree. (2) The SPP says nothing about the dynamic behaviour of BGP. Stable routings are significant for many practical reasons (e.g., network operators want to know the routes their packets are taking), but while BGP is operating at the control plane level, packets are being sent at the forwarding plane level without waiting for stability (if, indeed, stability is ever achieved). Thus, it is important to study network performance in the dynamic case. For example, what happens to the packets whilst a network is unstable? This is the main focus of our paper: to investigate packet routing under network dynamics. Towards this goal, we define a distributed protocol, inspired by BGP, that stops making changes to the routing graph (i.e., becomes stable) if it achieves a stable solution to the underlying instance of SPP. The current routing graph itself is determined by the control plane but the movement of packets is determined by the forwarding plane. Thus, our distributed protocol provides a framework under which the control and forwarding planes interact; essentially, this primarily means that we need to understand the relative speeds at which links change and packets move. Given this model, we analyse the resulting trajectory of packets. In a stable solution, a node in the stable tree containing the sink would have its packets route whereas an isolated node would 1Clearly, the empty path is not a real path to the sink; we call it a path for clarity of exposition. 2 not. For unstable networks, or for stable networks that have not converged, things are much more complicated. Here the routes selected by nodes are changing over time and, as we shall see, this may cause the packets to cycle. If packets can cycle, then keeping track of them is highly non-trivial. Our main results, however, are that for two fundamental classes of preference functions (i.e., two ways of defining acceptable paths and their rankings) all packets will route with probability one in our model. That is, there is an execution of our distributed protocol such that every packet in the network will reach the destination (albeit, possibly, slowly) even in instances where the network has no stable solution. (Note that we are ignoring the fact that in BGP packets typically have a time-to-live attribute meaning that after traversing a fixed number of nodes the packet will be dropped.) Furthermore, when the network does have a stable solution, we are able to guarantee packet routing even before the time when the network converges. These positive results on the routing rate are to our knowledge, the first results to guarantee the possibility of packet routing without stability. The results are also tight in the sense that, for any more expressive class of preference function, our hardness results show that guaranteeing that all packets eventually route is not possible -- thus, packets must be lost. 2 The Model and Results We represent a network by a directed graph G = (V, A) on n nodes. The destination node in the network is denoted by a distinguished node r called a sink node. We assume that, for every node v ∈ V , there is at least one directed path in G from v to the sink r, and that the sink r has no outgoing arc. At any point in time t, each node v chooses at most one of its out-neighbours w as its chosen next-hop; thus, v selects one arc (v, w) or selects none. These arcs form a routing graph R t, each component of which is a 1-arborescence, an in-arborescence2 T plus possibly one arc (v, w) emanating from the root v of T ; for example, T and T ∪ {(v, w)} are both 1-arborescences. (If the root of a component does select a neighbour, then that component contains a unique cycle.) When the context is clear, for clarity of exposition, we abuse the term tree to mean a 1-arborescence, and we use the term forest to mean a set of trees. A component (tree) in a routing graph is called a sink-component if it has the sink r as a root; all other components are called non-sink components. Each node selects its outgoing arc according to its preference list of acceptable paths. We examine the case where these lists can be generated using two of the most common preference criteria in practice: next-hop preferences and filtering. For next-hop preferences, each node v ∈ V has a ranking on its out-neighbours, nodes w such that (v, w) ∈ A. We say that w is the k-th choice of v if w is an out-neighbour of v with the k-th rank. For k = 1, 2, . . . , n, we define a set of arcs Ak to be such that (v, w) ∈ Ak if w is the k-th choice of v, i.e., Ak is the set of the k-th choice arcs. Thus, A1, A2, . . . , An partition the set of arcs A, i.e., A = A1 ∪ A2 ∪ . . . An. We call the entire graph G = (V, A) an all-choice graph. A filtering list, D(v), is a set of nodes that v never wants its packets to route through. We allow nodes to use filters and otherwise rank routes via next-hop preferences, namely next-hop preferences with filtering. To be able to apply these preferences, each node v ∈ V is also associated with a path P(v), called v's routing path. The routing path P(v) may not be the same as an actual v, r-path in the routing graph. We say that a routing path P(v) is consistent if P(v) is a v, r-path in the routing graph; otherwise, we say that P(v) is inconsistent. Similarly, we say that a node v is consistent if 2An in-arborescence is a graph T such that the underlying undirected graph is a tree and every node has a unique path to a root node. 3 its routing path P(v) is consistent; otherwise, we say that v is inconsistent. A node v is clear if the routing path P(v) (cid:54)= ∅, i.e., v (believes it) has a path to the sink; otherwise, v is opaque. We say that a node w is valid for v or is a valid choice for v if w is clear and P(w) contains no nodes in the filtering list D(w). If w is a valid choice for v, and v prefers w to all other valid choices, then we say that w is the best valid choice of v. A basic step in the dynamic behaviour of BGP is that, at any time t, some subset Vt of nodes is activated meaning that every node v ∈ Vt chooses the highest ranked acceptable path P(v) that is consistent with one of its neighbours' routing paths at time t − 1. The routing graph R t consists of the first arc in each routing path at time t. Protocol variations result from such things as restricting Vt so that Vt = 1, specifying the relative rates that nodes are chosen to be activated and allowing other computations to occur between these basic steps. In our protocol, we assume that activation orderings are fair in that each node activates exactly once in each time period -- a round -- the actual ordering however may differ in each round. While our protocol is not intended to model exactly the behaviour of BGP, we tried to let BGP inspire our choices and to capture the essential coordination problem that makes successful dynamic routing hard. Again, a detailed discussion on these issues and on the importance of a fairness-type criteria is deferred to the Appendix. Procedure 1 Activate(v) Input: A node v ∈ V − {r}. 1: if v has a valid choice then 2: 4: 5: else 6: Update P(v) := ∅. 7: end if 3: Choose the best valid choice w of v. Change the outgoing arc of v to (v, w). Update P(v) := vP(w) (the concatenation of v and P(w)). Procedure 2 Protocol(G,r,R 0) Input: A network G = (V, A), a sink node r and a routing graph R 0 1: Initially, every node generates a packet. 2: for round t := 1 to . . . do 3: Generate a permutation πt of nodes in V − {r} using an external algorithm A. 4: Control Plane: Apply Activate(v) to activate each node in the order in πt. This forms a routing graph R t. Forwarding Plane: Ask every node to forward the packets it has, and wait until every packet is moved by at most n hops (forwarded n times) or gets to the sink. P(v) := v, r-path in R t. 6: Route-Verification: Every node learns which path it has in the routing graph, i.e., update 5: 7: end for This entire mechanism can thus be described using two algorithms as follows. Once activated, a node v updates its routing path P(v) using the algorithm in Procedure 1. The generic protocol is described in Procedure 2. This requires an external algorithm A which acts as a scheduler that generates a permutation -- an order in which nodes will be activated in each round. We will assume that these permutations are independent and randomly generated. Our subsequent routing 4 guarantees will be derived by showing the existence of specific permutations that ensure all packets route. These permutations are different in each of our models, which differ only in the filtering lists. We remark that our model is incorporated with a route-verification step, but this is not a feature of BGP (see the Appendix for a discussion). With the model defined, we examine the efficiency of packet routing for the three cases of next-hop preferences with filtering: • General Filtering. The general case where the filtering list D(v) of any node v can be an arbitrary subset of nodes. • Not me! The subcase where the filtering list of node v consists only of itself, D(v) = {v}. Thus, a node does not want a path through itself, but otherwise has no nodes it wishes to avoid. • Anything Goes! The case where every filtering list is empty, D(v) = ∅. Thus a node does not even mind if its packets cycle back through it! 2.1 Our Results. We partition our analyses based upon the types of filtering lists. Our first result is a strong hardness result presented in Section 3. Not only can it be hard to determine if every packet can be routed but the maximum number of packets that can be routed cannot be approximated well even if the network can reach equilibrium. Specifically, Theorem 1. For filtering lists of cardinality at most one, it is NP-hard to approximate the maxi- mum cardinality stable subtree to within a factor of n1−, for any constant  > 0. Corollary 2. For filtering lists of cardinality at most one, given a network in which an equilibrium is guaranteed to exist, it is NP-hard to approximate the maximum number of packets that can be routed to within a factor of n1−, for any constant  > 0. However, for its natural subcase where the filtering list of a node consists only of itself (that is, a node does not want to route via a cycle!), we obtain a positive result in Section 5. Theorem 3. If the filtering list of a node consists only of itself, then an equilibrium can be obtained in n rounds. Moreover, every packet will be routed in n 3 rounds, that is, before stability is obtained! Interestingly, we can route every packet in the case D(v) = ∅ for all v ∈ V ; see Section 4. Thus, even if nodes do not care whether their packets cycle, the packets still get through! Theorem 4. If the filtering list is empty then every packet can be routed in 4 rounds, even when the network has no equilibrium. Theorems 3 and 4 are the first theoretical results showing that packet routing can be done in the absence of stability. For example, every packet will be routed even in the presence of dispute wheels [5]. Indeed, packets will be routed even if some nodes never actually have paths to the sink. Note that when we say that every packet will route with probability one we mean that, assuming permutations are drawn at random, we will eventually get a fair activation sequence that routes every packet. It is a nice open problem to obtain high probability guarantees for fast packet routing under such an assumption. 5 3 General Filtering. Here we consider hardness results for packet routing with general filtering lists. As discussed, traditionally the theory community has focused upon the stability of R -- the routing graph is stable if every node is selecting their best valid neighbour (and is consistent). For example, there are numerous intractability results regarding whether a network has an equilibrium; e.g., see [6, 2]. However, notice that the routing graph may be stable even if it is not spanning! There may be singleton nodes that prefer to stay disconnected rather than take any of the offered routes. Thus, regardless of issues such as existence and convergence, an equilibrium may not even route the packets. This can be particularly problematic when the nodes use filters. Consider our problem of maximising the number of nodes that can route packets successfully. We show that this cannot be approximated to within a factor of n1−, for any  > 0 unless P = NP. The proof is based solely upon a control plane hardness result: it is NP-hard to approximate the maximum cardinality stable tree to within a factor of n1−. Thus, even if equilibria exist, it is hard to determine if there is one in which the sink-component (the component of R containing the sink) is large. Formally, in the maximum cardinality stable tree problem, we are given a directed graph G = (V, E) and a sink node r; each node v ∈ V has a ranking of its neighbours and has a filtering list D(v). Given a tree (arborescence) T ⊆ G, we say that a node v is valid for a node u if (u, v) ∈ E and a v, r-path in T does not contain any node of D(v). We say that T is stable if, for every arc (u, v) of T , we have that v is valid for u, and u prefers v to any of its neighbours in G that are valid for u (w.r.t. T ). Our goal is to find a stable tree (sink-component) with the maximum number of nodes. We will show that even when D(v) = 1 for all nodes v ∈ V , the maximum-size stable tree problem cannot be approximated to within a factor of n1−, for any constant  > 0, unless P = NP. The proof is based on the hardness of 3SAT [10]: given a CNF-formula on N variables and M clauses, it is NP-hard to determine whether there is an assignment satisfying all the clauses. Take an instance of 3SAT with N variables, x1, x2, . . . , xN and M clauses C1, C2, . . . , CM . We now create a network G = (V, A) using the following gadgets: • Variable-Gadget: For each variable xi, we have a gadget H(xi) with four nodes ai, uT i , uF i , bi. i , ai) and second-choice arcs (uT The nodes uT i , bi), (uF i ); the ranking of these arcs can be arbitrary. Each node in this gadget has itself in the filtering list, i.e., D(v) = {v} for all nodes v in H(xi). i , bi). The node ai has two arcs (ai, uT i and uF i have first-choice arcs (uT i , ai), (uF i ) and (ai, uF • Clause-Gadget: For each clause Cj with three variables xi(1), xi(2), xi(3), we have a gadget Q(Cj). The gadget Q(Cj) has four nodes sj, q1,j, q2,j, q3,j, tj. The nodes q1,j, q2,j, q3,j have first-choice arcs (q1,j, tj), (q2,j, tj), (q3,j, tj). The node sj has three arcs (sj, q1,j), (sj, q2,j), (sj, q3,j); the ranking of these arcs can be arbitrary, so we may assume that (sj, qz,j) is a zth-choice arc. Define the filtering list of sj and tj as D(sj) = {sj} and D(tj) = {d0}. (The node d0 will be defined later.) For z = 1, 2, 3, let uT i(z) and uF i(z) be nodes in the corresponding Variable-Gadget H(xi(z)). The node qz,j has a filtering list D(qz,j) = {uT i(z)}, if assigning xi(z) = False satisfies the clause Cj; otherwise, D(qz,j) = {uF i(z)}. To build G, we first add a sink node r and a dummy "sink" d0. We then connect d0 to r by a first-choice arc (d0, r). We number the Variable-Gadgets and Clause-Gadgets in any order. Then we add a first-choice arc from the node a1 of the first Variable-Gadget H(x1) to the sink r. For i = 2, 3, . . . , N , we add a first-choice arc (bi, ai−1) joining gadgets H(xi−1) and H(xi). We join the 6 last Variable-Gadget H(xN ) and the first Clause-Gadget Q(C1) by a first-choice arc (t1, aN ). For j = 2, 3, . . . , M , we add a first-choice arc (tj, sj−1) joining gadgets Q(Cj−1) and Q(Cj). This forms a line of gadgets. Then, for each node qz,j of each Clause-Gadget Q(Cj), we add a second-choice arc (qz,j, d0) joining qz,j to the dummy sink d0. Finally, we add L padding nodes d1, d2, . . . , dL and join each node di, for i = 1, 2, . . . , L, to the last Clause-Gadget Q(CM ) by a first-choice arc (di, sM ); the filtering list of each node di is D(di) = {d0}, for all i = 0, 1, . . . , L. The parameter L can be any positive integer depending on a given parameter. Observe that the number of nodes in the graph G is 4N + 5M + L + 2, and D(v) = 1 for all nodes v of G. The reduction is illustrated in Figure 1. Figure 1: The hardness construction. The correctness of the reduction is proven in the next theorem. Theorem 5. For any constant  > 0, given an instance of the maximum-size stable tree problems with a directed graph G on n nodes and filtering lists of cardinality D(v) = 1 for all nodes v, it is NP-hard to distinguish between the following two cases of the maximum cardinality stable tree problem. • Yes-Instance: The graph G has a stable tree spanning all the nodes. • No-Instance: The graph G has no stable tree spanning n nodes. Proof. We apply the above reduction from 3SAT with a parameter L = J 1/ − J, where J = 4n + 5m + 2. Thus, the graph G has n = J 1/ nodes and has n = J non-padding nodes. First, we show that there is a one-to-one mapping between choices of each Variable-Gadget H(xi) and an assignment of xi. Consider any Variable-Gadget H(xi). To connect to the next gadget, nodes uT i of H(xi) must choose at least one second-choice arc. However, in a stable tree, they cannot choose both second-choice arcs (uT i would prefer to choose the node ai. Thus, the gadget G(xi) must choose either arcs i , bi); otherwise, uT i , bi) and (uF i and uF i or uF (1) (uT i , bi), (uF i , ai), (ai, uT i ) or (2) (uF i , bi), (uT i , ai), (ai, uF i ). These two cases correspond to the the assignments xi = True and xi = False, respectively. Thus, there is a one-to-one mapping between the choices of gadget H(xi) in the stable tree and the assignment of xi. We refer to each of these two alternatives as an assignment of xi. Now, we prove the correctness of the reduction. Yes-Instance: Suppose there is an assignment satisfying all the clauses. Then there is a stable tree T corresponding to such an assignment. To see this, within Variable-Gadget we select arcs in accordance with the assignment as detailed above. We also choose the arc (d0, r) and all the 7 Q(Cj)sid0ruiTuiFaibiq1, jtiq2, jq3, jH(xi)d1,d2,...,dL horizontal arcs connecting adjacent gadgets in the line (or from the first Variable-Gadget to the sink r). For each Clause-Gadget Q(Cj) and each z = 1, 2, 3, we choose the first-choice arc (qz,j, tj) if the assignment to xi(z) satisfies Cj; otherwise, we choose the second-choice arc (qz,j, d0). For the node sj of Q(Cj), we choose an arc (sj, qz,j), where z is the smallest number such that the assignment to xi(z) satisfies Cj (i.e., qz,j chooses tj); since the given assignment satisfies all the clauses, sj has at least one valid choice. Now, we have that the node sM of the last Clause-Gadget Q(Cj) has a path P(sM ) to the sink r that does not contain the dummy sink d0. Thus, every padding node can choose sM and, therefore, is in the stable tree T . This implies that T spans all the nodes. No-Instance: Suppose there is no assignment satisfying all the clauses. Let T be any stable tree of G. As in the previous discussion, the choices of nodes in Variable-Gadgets correspond to the assignment of variables of 3SAT. Consider any Clause-Gadget Q(Cj). Since D(sj) = {d0}, the node sj of Q(Cj) has a path to the sink r only if (1) a tj, r-path P(tj) in T does not contain the dummy sink d0, and (2) one of q1,j, q2,j, q3,j chooses tj. These two conditions hold only if T corresponds to an assignment satisfying Cj. To see this, suppose the first condition holds. Then P(tj) has to visit either vF i of every Variable-Gadget H(xi), depending on the assignment of xi. Thus, by the construction of D(qz,j), tj is valid for qz,j only if the assignment to xi(z) satisfies Cj. Since there is no assignment satisfying all the clauses, a node s(cid:96) of some Clause-Gadget Q(C(cid:96)) is not in T . This means that nodes in the remaining Clause-Gadget have to use the dummy sink d0 to connect to the sink r. Thus, the node sM of the last Clause-Gadget Q(CM ) is not in T and neither are any of the padding nodes d1, d2, . . . , dL. Therefore, the size of T is at most J = n, proving the theorem. i or vT Observe this means that, from the perspective of the nodes, it is NP-hard to determine whether adding an extra node to its filtering list can lead to solutions where none of its packets ever route. In other words, it cannot avoid using an intermediate node it dislikes! 4 Filtering: Anything-Goes! Here we consider the case where every node has an empty filtering list. This case is conceptually simple but still contains many technical difficulties involved in tracking packets when nodes become mistaken in their connectivity assessments. In this case, networks with no equilibrium can exist. Figure 2 presents such an example. Moreover, in this example, fair activation sequences exist where the node v will never be in the sink component; for example, repeatedly activate nodes according to the permutation {v, u, w, x, y}. Despite this, every packet will route in two rounds! This example nicely illustrates the need to track packets if we want to understand the efficacy of BGP-like protocols. For this class of preference functions, we show that the property of successful routing is universal. In any network, every packet will reach the sink. Specifically, we present a fair activation sequence of four rounds that routes every packet, even when there is no equilibrium. Observe that when filtering lists are empty, a node v only needs to known whether its neighbour u has a path to the sink, as v will never discount a path because it contains a node it dislikes. 8 Figure 2: A network with no stable spanning tree. (Arc numbers indicate rankings, e.g., the number 2 on the arc (u, x) means that x is the second choice of u.) Thus, we can view each node as having two states: clear or opaque. A node is clear if it is in the sink-component (the nomenclature derives from the fact that a packet at such a node will then reach the sink -- that is, "clear"); otherwise, a node is opaque. Of course, as nodes update their chosen next-hop over time, they may be mistaken in their beliefs (inconsistent) as the routing graph changes. In other words, some clear nodes may not have "real" paths to the sink. After the learning step at the end of the round, these clear-opaque states become correct again. Our algorithm and analysis are based on properties of the network formed by the first-choice arcs, called the first class network. We say that an arc (u, v) of G is a first-choice arc if v is the most preferred neighbour of u. We denote the first class network by F = (V, A1), where A1 is the set of the first-choice arcs. As in a routing graph R , every node in F has one outgoing arc. Thus, every component of F is a 1-arborescence, a tree-like structure with either a cycle or a single node as a root. We denote the components of F by F0, F1, . . . , F(cid:96), where F0 is the component containing the sink r. Each Fj has a unique cycle Cj, called a first class cycle. We may assume the first class cycle in F0 is a self-loop at the sink r. Furthermore, when activated, every node in F0 will always choose its neighbour in F0; so, we may assume wlog that F0 is the singleton node {r}. The routing graph at the beginning of round t is denoted by R t. We denote by K t and Ot the set of clear and the set of opaque nodes at the start of round t. Now we show that there is an activation sequence which routes every packet in four rounds. The proof has two parts: a coordination phase and a routing phase. In the first phase, we give a coordination algorithm that generates a permutation that gives a red-blue colouring of the nodes with the following two properties: (i) For each Fj, every node in Fj has the same colour, i.e., the colouring is coordinated. (ii) If the first class cycle Cj of Fj contains a clear node, then all nodes in Fj must be coloured blue. We remark that, subject to the these two properties, our algorithm will maximise the number of nodes coloured red, but this is not needed to prove that we can route a packet successfully. The usefulness of this colouring mechanism lies in the fact that the corresponding permutation is a fair activation sequence that will force the red nodes to lie in the sink-component and the blue nodes to lie in non-sink components. Moreover, bizarrely, running this coordination algorithm four 9 wxurvy1111122 times in a row ensures that every packet routes! So, in the second phase (the routing phase), we simply run the coordination algorithm three more times. 4.1 The Coordination Phase. The algorithm Coordinate(K t) presented in Procedure 3 constructs a red-blue colouring of the nodes, i.e., a partition (R, B) of V (where v ∈ R means that v is coloured red and v ∈ B means that v is coloured blue) and which has the property that any node v ∈ R prefers some node in R to any node w ∈ B, and any node v ∈ B prefers some node in B to any node w ∈ R. Procedure 3 Coordinate(K t) Input: A set of clear nodes K t. Output: A partition (R, B) of V . i:V (Cj )∩K t(cid:54)=∅ V (Fi) be a set of nodes contained in an F -component whose first class 1: Let B0 :=(cid:83) cycle Ci has a clear node. 2: Initialise q := 0. 3: repeat 4: Update q := q + 1. 5: 6: while ∃ a node v ∈ U that prefers a node in Rq to nodes in Bq−1 ∪ (U ∩ Kt) do Initialise Bq := Bq−1, Rq := {r} and U := V − (Rq ∪ Bq) = Rq−1 − {r}. 7: Move v from U to Rq. end while 8: 9: Add all the remaining nodes in U to Bq. 10: until Bq = Bq−1. 11: return (Rq, Bq). Observe that Coordinate(K t) contains many loops. However, we only wish to generate a single activation sequence πt from the procedure. To do this, we take the output partition (R, B) and use it to build an activation sequence. We begin by activating nodes in B0 = (cid:83) i:Ci∩Ki(cid:54)=∅ V (Fi), the components Fi whose first class cycles contain at least one clear node. To order the nodes of B0, we proceed as follows. For each Fi with V (Fi) ⊆ B0, take a clear node v ∈ Ci ∩ K t. Then activate the nodes of Fi (except v) in increasing order of distance from v in Fi, and after that activate v. This forms a non-sink- component Fi in the routing graph as every node can choose its first-choice. Next, we activate the remaining nodes in B. We order the nodes of B − B0 in a greedy fashion; a node can be activated once its most-preferred clear neighbour is in B. Finally, we activate the nodes in R. Again, this can be done greedily. Specifically, we activate nodes of R in the same order as when they were added to R. Lemma 6. Given a partition (R, B) from Coordinate(K t), the activation sequence πt induces a sink-component on R and non-sink-components on B. Proof. First, let us verify by induction that each node in R ends up in the sink-component. For the base case, the sink r is clearly in the sink-component. Now, the red nodes are activated after the blue nodes. Let q∗ be the last iteration of Coordinate(K t); hence, Bq∗ = Bq∗−1. So, at the start of this iteration, Bq∗ = B and Rq∗ = {r}. Despite this, at the end of the round, we have Rq∗ = R. This implies that every node v of R prefers a node of Rq∗ to a node of Bq∗−1∪(U∩Kt) = B∪(U∩Kt) ⊇ B 10 when it is added to Rq∗. But, then πt orders the nodes such that, on activation, every node v of R prefers a node of Rq∗ (which are in the sink component by induction) to a node of B. Thus, regardless of which components the blue nodes were placed in upon activation, all the red nodes are placed in the sink-component (it can only help if the some of the red nodes were placed in the sink-component). Now, let us show that the blue nodes do not end up in the sink-component. By the construction of πt, the nodes of B0 connect together via their first class components. Consequently, they belong to non-sink components. Finally, consider the nodes in B−B0. Observe that the size of Bq increases in each iteration, that is, Bq (cid:40) Bq−1 for all q < q∗. So, at the end of their iterations, Rq ⊆ Rq−1. Now, take a node v added to Bq in Step 9 in iteration q. At this point, the remaining nodes are U = Rq−1 − Rq, and v prefers some node w in Bq−1 ∪ (U ∩ Kt) to any node in Rq (or has no neighbours in Rq at all). But, Bq−1∪(U ∩Kt) = Bq−1∪(Rq−1−Rq∩Kt) ⊆ Bq−1∪(Rq−1−Rq) = Bq. Thus, v either prefers some node in Bq∗ to any node in Rq∗ or has no neighbours in Rq∗. But, by assumption, every node has a path to the sink in the "all-choice" graph G. So, when considering the blue nodes, there must be a node in B − B0 that has its most preferred "clear" neighbour in B. Therefore, πt induces non-sink components on B. The coordination and other desirable properties hold when we apply πt. Lemma 7. Given the activation sequence πt for (R, B), at the end of the round, the following hold: • The sink-component includes R and excludes B. • Coordination: For each Fi, either all the nodes of Fi are in the sink-component or none of i:V (Ci)∩K t(cid:54)=∅ V (Fi) and suppose K t = B0. If a packet travels for n hops but does not • Let B0 =(cid:83) them are. reach the sink, then it must be at a node in K t. Proof. The first statement follows Lemma 6. For the second statement, it suffices to show that, for each Fi, either V (Fi) ⊆ R or V (Fi) ⊆ B. If not, then there is an Fi containing both red and blue nodes. Thus, there are two possibilities. (i) There is a node v ∈ Fi such that v is in R and its first choice is w ∈ B. This is not possible. To see this, observe that we must have w ∈ Bq−1 because of the stopping condition Bq = Bq−1. But, then v could not be added to Rq, a contradiction. (ii) There is a node v ∈ Fi such that v is in B and its first choice is w ∈ R. Again, this is not possible. To see this, observe that we must have v /∈ B0 because each B0 consists only of first class components that are monochromatic blue. Recall also that Rq ⊆ Rq−1 for all q. Thus, we must have w ∈ Rq for all q. But, then v would have been added to Rq, a contradiction. For the third statement, note that a packet that travels for n hops but does not reach the sink must be stuck in some cycle. Consider the construction of (R, B). Since K t = B0, we only add a node to B whenever it prefers some node in B to any node in R. Because U ∩ K t = ∅, nodes in B − B0 cannot form a cycle on their own. Thus, the packet is stuck in a cycle that contains a clear node; the only such cycles are the first class cycles of B0 since K t = B0. The following lemma follows by the construction of a partition (R, B). be a partition obtained by calling Coordinate(K t) where(cid:83) Lemma 8. Let (R(cid:48), B(cid:48)) be any partition generated from the procedure Coordinate( ), and let (R, B) i:V (Ci)∩K t(cid:54)=∅ V (Fi) ⊆ B(cid:48). Then R(cid:48) ⊆ R. 11 B0 ⊆ B(cid:48) because B0 =(cid:83) Proof. Consider a partition (Rq, Bq) constructed during a call to Coordinate(K t). Observe that i:V (Ci)∩K t(cid:54)=∅ V (Fi). By the construction of (R(cid:48), B(cid:48)), since B0 ⊆ B(cid:48), every node of R(cid:48) must have been added to R1, i.e., R(cid:48) ⊆ R1. Inductively, if R(cid:48) ⊆ Rq for some q ≥ 1, then Bq ⊆ B(cid:48) and thus R(cid:48) ⊆ Rq+1 by the same argument. 4.2 The Routing Phase Running the coordination algorithm four times ensures every packet will have been in the sink- component at least once, and thus, every packet routes. Theorem 9. In four rounds, every packet routes. Proof. The first round t = 1 is simply the coordination phase. We will use subscripts on R and B (e.g., Rt and Bt) to denote the final colourings output in each round and not the intermediate sets Rq and Bq used in Coordinate( ). Now, consider a packet generated by any node of V . First, we run Coordinate(K 1) and obtain a partition (R1, B1). By Lemma 7, if the packet is in R1, then it is routed successfully, and we are done. Hence, we may assume that the packet does not reach the sink and thus must be in B1. Note that, now, each Fi is either contained in R1 or B1 by Lemma 7. We now run Coordinate(K 2) and obtain a partition (R2, B2). By Lemma 7, K 2 = R1. So, if the packet does not reach the sink, it must be in B2. Since no first class component intersects both i:V (Ci)∩K 2(cid:54)=∅ V (Fi). Thus the nodes K 2 are all initially coloured blue in Step 1 of Coordinate(K 2). As the set of blue nodes only expands throughout the round So, R1 ⊆ B2 (since K 2 ⊆ B2) and R2 ⊆ B1, and Lemma 7 implies that the packet is in R1. Third, we run Coordinate(K 3) and obtain a partition (R3, B3). Applying the same argument as before, we have that the packet is in R2 (or it is routed), R2 ⊆ B3 and R3 ⊆ B2. Now, we run i:V (Ci)∩K 4(cid:54)=∅ V (Fi). Since R3 = K 4 ⊆ B2, Lemma 8 implies that R2 ⊆ R4. Thus, the packet is routed successfully since R4 is contained in the sink-component. R1 and B1, we have R1 = K 2 =(cid:83) Coordinate(K 4) and obtain a partition (R4, B4). By Lemma 7, we have K 4 =(cid:83) 5 Filtering: Not-Me! In practice, it is important to try to prevent cycles forming in the routing graph of a network. To achieve this, loop-detection is implemented in the BGP-4 protocol [17]. The "Not-Me!" filtering encodes loop-detection in the BGP-4 protocol simply by having a filtering list D(v) = {v}, for every node v. For this class of preference function, we again show that every packet will route. Recall, this is in contrast to Theorem 5, which says that it is NP-hard to determine whether we can route every packet for general filtering lists of cardinality one. Moreover, we exhibit a constructive way to obtain a stable spanning tree via fair activation sequences. Interestingly, all of the packets will have routed before stability is obtained. In particular, we give an algorithm that constructs an activation sequence such that every packet routes successfully in 1 3 n rounds whereas the network itself becomes stable in n rounds. This result is the most complicated part of our paper, so we will first give a high level overview. Clearly, when filtering lists are non-empty, we have an additional difficulty: even if w is the most preferred choice of v and w has a non-empty routing path P , v still may not be able to choose w because P contains a node on v's filter list (in this case, v itself). This can cause the routing graph to evolve in ways that are very difficult to keep track of. Thus, the key idea is to design activation 12 permutations that manipulate the routing graph in a precise and minor fashion in each round. To do this, we search for a spanning tree with a Strong Stability Property. Property 10 (Strong Stability - Informal). A spanning tree S has the strong stability property on O ⊆ V if and only if, for every node v ∈ O, the most preferred choice of v is its parent w in S, even if v can choose any node outside O and any node outside its subtree in the forest S[O]. To illustrate this property, consider a simple setting where S is just the path S = (e, d, c, b, a, r) and O = {b, c, e}. If S is strongly stable on O, then b must prefer a to nodes in {r, d, e}. Observe that e, whilst a descendent of b in S, is not a descendent of b in S[{b, c, e}]. So, even if b is allowed to choose e, which is a descendent of b in S, b still wants to choose a as its parent. Thus, the strong stability property says that the choice of a vertex v ∈ O in S is the best one even if all the nodes outsides O change their choices. (that is, even if we replace S[V − O] with a completely different subgraph). For the special case where O = O, the set of opaque nodes, if we activate nodes of S in increasing order of distance from the sink r then every node in O will choose its parent in S -- as the clear nodes in Sv are not desirable to connect to. As we will see, under certain conditions, we can even maintain the choices of nodes in O even if some of them are clear and some are opaque. A stable spanning tree, a tree where no node wants to change its choice, can be found in polynomial-time, and given a stable spanning tree S, it is easy to force opaque nodes in Ot to make the same choices as in S. But, this only applies to the set of opaque nodes, which changes with each round. The strong stability property allows us to make a stronger manipulation. Intuitively, the strong stability property says that once we force every node v ∈ O to make the same choice as in S, we can maintain these choices in all the later rounds. Moreover, in each round, if we cannot route all the packets, then we can make the strong stability property spans three more nodes; otherwise, the property spans one more node. Thus, in 1 3 n rounds, every packet will route, but we need n rounds to obtain stability. With this overview complete we introduce some formal definitions needed for the proof. Again, Ot and K t denote the set of opaque and clear nodes, respectively, at the beginning of round t. Given a graph R and a set of nodes U , we denote by R[U ] = {(u, v) : u, v ∈ U, (u, v) ∈ R} the R(U ) = {(u, v) : u ∈ U, (u, v) ∈ R}, the subgraph subgraph of R induced by U , and we denote by A+ of arcs of R induced by U plus arcs leaving U . Given a set of nodes Q ⊆ V , the Q-subtree of v, with respect to a tree T , is the maximal subtree rooted at v of the forest T [Q]. A (spanning) tree T is stable if every node v with (v, w) ∈ T , prefers its parent w in T to every non-descendant; thus, no node wants to change its next hop. A spanning tree S has the strong stability property on the set of nodes O if every node v ∈ O with (v, w) ∈ S prefers its parent w to every node outside its O-subtree; observe that if O = V (or V − {r}), then S is also stable. We say that S is a skeleton of a (non-spanning) tree T if, for every (maximal) subtree F ⊆ S[O], either T contains A+ S (F ) or T contains no node of F . 5.1 Finding a Strongly Stable Tree In this section, we present a subroutine for finding a spanning tree with the strong stability property. The input of this algorithm (see Procedure 4) is a sink-component T in and a spanning tree Sin with the strong stability property on a given set of nodes O. The algorithm expands the strong stability property to also hold on O, the set of nodes not in the sink-component T in. 13 Output: A stable spanning tree Sout with the strong stability property on O ∪ O, where O = Procedure 4 FindStable(T in, Sin, O) Input: A sink-component T in and a spanning (or empty) tree Sin such that (1) The tree Sin has the strong stability property on O, and (2) Sin is a skeleton of T in. V − V (T in). 1: Let O = V − V (T in) be the set of nodes not in the sink component T in. 2: Initialise Sout := T in ∪ A+ 3: Initialise C1 := Sout[O]. 4: for iteration t := 1 to O do Sin(O). Pick an arbitrary leaf v of Ct. Pick a node w ∈ V (Sout) such that v prefers w to any other node not in its O-subtree in Sout. Replace the arc (v, y) in Sout by the arc (v, w). 5: 6: 7: 8: Update Ct+1 := Ct − {v}. 9: end for 10: return Sout. Before proving the correctness of the procedure FindStable(T in,Sin, O), we prove some basic facts. Lemma 11 (Union Lemma). Let S be a spanning tree that is strongly stable on A ⊆ V and also on B ⊆ V . Then S is strongly stable on Q = A ∪ B. Proof. Without loss of generality, take a vertex v ∈ A ⊆ Q. Let FA and FQ be the (maximal) A-subtree and Q-subtree of v in S, respectively. Then V (FA) ⊆ V (FQ) because A ⊆ Q. By the strong stability property of S on A, we have that v prefers its parent w in S to any other node in V − V (FA). But, V − V (FQ) ⊆ V − V (FA). It follows that S is strongly stable on Q = A ∪ B. The next lemma proves an important property of a skeleton of a tree T . Lemma 12 (Skeleton Lemma). Let T be any tree. Let S be a spanning tree that is strongly stable on a set of vertices O and be a skeleton of T . Let O = V − V (T ). Then, for any spanning tree T (cid:48) such that T ⊆ T (cid:48), the tree T (cid:48) is strongly stable on O − O. Proof. Consider any node v ∈ O − O. Let Fv be the O-subtree of v in S. By the definition of skeleton, for any (maximal) subtree F ⊆ S[O], either (i) A+ S (F ) ⊆ T or (ii) V (F ) ∩ V (T ) = ∅. Since v ∈ V (T ) ∩ O, it must be that A+ S (Fv) ⊆ T ⊆ T (cid:48). Thus, V (Fv) ⊆ O − O as V (T ) = V − O. Therefore Fv is also the (O − O)-subtree of v in S. By the strong stability property of S on O, we know that v prefers its parent w in S to any node in V − V (Fv). So, S has the strong stability property on O − O. The next lemma shows the correctness of the procedure Stabilise(T in, Sin, O). Lemma 13. The procedure FindStable(T in, Sin, O) outputs a spanning tree Sout with the strong stability property on O ∪ O. 14 Proof. To begin, we show that Sout is a spanning tree throughout the procedure. Initially Sout = T in ∪ A+ Sin(O). Therefore, Sout contains every node, since O = V − V (T in). Let us see that Sout is also connected. As Sin is a spanning tree, we have that each component F of A+ Sin(O) is a tree Sin(O) leaving (arborescence). Furthermore as the sink r is not in O, there is exactly one arc in A+ F (from its root) and entering V (T in). Thus, Sout = T in ∪ A+ Sin(O) is a spanning tree. Now, consider how Sout changes during the loop phase of the procedure. No node in V − O is considered during this phase, so Sout never contains any arc leaving V − O and entering O. As a result, the O-subtree of v in Sout coincides exactly with the set of all descendants of v in Sout. Hence, in Step 6, node v never selects a descendant node to be w. So, we can safely replace the arc (v, y) ∈ Sout by the arc (v, w) without creating a cycle. This shows that Sout is always a spanning tree. Next, we show that Sout has the strong stability property both on O − O and on O. By Lemma 11, this will imply that Sout is strongly stable on O ∪ O. Now, Sin is strongly stable on O and is a skeleton on T in. Furthermore, T in ⊆ Sout by construction. Thus, applying Lemma 12, we have that Sout is strongly stable on O − O. It only remains to show that Sout is strongly stable on O. To achieve this, we show by induction that Sout is strongly stable on L t = O − V (Ct) in each iteration t. (Note that, on termination, L t = O.) This is true for t = 1 as L 1 = ∅. Now, consider iteration t > 1, and assume that strong stability holds on L t−1. Observe that no node u ∈ O − L t−1 has a parent x ∈ L t−1; otherwise, x would have not been added to L t−1. Since v is a leaf of Ct, all the nodes in the O-subtree of v in Sout must be in L t−1. Because nodes in L t−1 can not change their parents after this time, every descendant of v in O will remain a descendant of v. Consequently, v prefers w to other any non-descendant in Sout throughout the rest of the procedure. Thus, Sout is strongly stable on L t. 5.2 Routing Every Packet in n Rounds. We are now ready to present an algorithm that routes every packet in n rounds (recall that each round consists of a single fair-activation sequence). In addition to the procedure FindStable(), two procedures (namely, Procedures 5 and 6) based upon a breath-first-search (BFS) algorithm are our basic building block for generating an activation sequence. Given a spanning tree F and a set of nodes U ⊆ V , the procedure BFS(U, F ) activates the nodes of U in breadth-first-search (BFS) order. That is, the nodes of U are activated in increasing order of distance to the sink r in F . Procedure 5 BFS(U, F ) Input: A set U ⊆ V and a spanning tree F . 1: Let v1, v2, . . . , vq be nodes in U −{r} sorted in increasing order of distance to the root r of F . 2: for i := 1 to q do 3: 4: end for Activate vi. Similarly, the procedure reverse-BFS(U, F ) activates the nodes of U in breadth-first-search (BFS) reverse-order. Over the course of these n rounds, the main algorithm (Procedure 7) utilises these three proce- dures on the following two classes of nodes. (1) The set of nodes that have been clear in every round up to time t, denoted by Kt = ∩t i=1K i. 15 Procedure 6 reverse-BFS(U, F ) Input: A set U ⊆ V and a spanning tree F . 1: Let v1, v2, . . . , vq be nodes in U −{r} sorted in increasing order of distance to the root r of F . 2: for i := q to 1 do 3: Activate vi. 4: end for (2) The complement of Kt, which is the set of nodes that have been opaque at least once by time t, denoted by Ot = ∪t i=1Oi. Procedure 7 Fair-Stabilise() 1: Let Tt be the sink-component at the beginning of round t. 2: Initialise S0 := an arbitrary spanning tree, K0 := V and O0 := ∅. 3: for round t := 1 to n do Apply FindStable(Tt, St−1, Ot−1) to compute a spanning tree St. 4: Update Ot := Ot−1 ∪ Ot and Kt := V − Ot. 5: 6: Activate BFS(Ot, St). 7: Activate reverse-BFS(Kt, St). 8: Pick a node v∗ that is the first node activated by reverse-BFS(Kt, St). Replace the arc (v∗, y) in St by (v∗, w) the arc chosen by v∗ in the routing graph. 9: 10: Update Ot := Ot ∪ {v∗}. 11: end for Observe that Procedure 7 is clearly fair because Kt and Ot partition the set of nodes. The basic intuition behind the method is that if we can make our routing graph Tt+1 look like the spanning tree St, then every packet will route. Typically, any activation sequence that attempts to do this, though, will induce inconsistencies. This, in turn, will force nodes to go opaque. But, it turns out that we can make those nodes in Ot choose arcs in accordance with St via the use of BFS(Ot, St). (It is not at all obvious that this can be done because nodes in Ot may actually be clear, that is, they need not be in Ot.) Then the question becomes how do we keep track of the packets. The key point is that nodes in Ot choose arcs in accordance with the spanning tree St. Therefore, since O1 ⊂ O2 ⊂ O3 ⊂ ··· and the containments are strict, we will eventually have Ot = V , and our routing graph will be a spanning tree. Thus, every packet routes! Moreover, the strong stability property of St on Ot = V also implies that the final routing graph is a stable spanning tree. The following lemma presents the key properties we need to prove all this. St (Ot) is contained in the routing graph at the end of round. Specifically, for each node v ∈ Ot, Lemma 14. At the end of round t of Fair-Stabilise(), we have that: • The spanning tree St has the strong stability on Ot, and • A+ if (v, w) ∈ St then, upon activation, v chooses w as its next hop. Proof. We proceed by induction on t. The statement is clearly true for t = 0 because O0 = ∅. Now, suppose that the statements hold up to round t − 1 for some t > 0. We first show that St has a strong stability property on Ot (before adding v∗). To do this, we have to show that 16 St−1 St−1 FindStable(Tt, St−1, Ot−1) is called with a valid input, i.e., St−1 is a skeleton of Tt and has the strong stability property on Ot−1. The latter fact, that St−1 has the strong stability property on Ot−1, follows from the induction hypothesis. So, we need to show St−1 is a skeleton of Tt. By induction, at the end of the previous round (before the learning phase) we have that A+ (Ot−1) is contained in the routing graph. So, for each (maximal) subtree F ⊆ St−1[Ot−1] rooted at a node v, every node of F has a path to the sink r if and only if v has a path to r. Thus, either A+ (F ) is contained in the sink component Tt or no node of F is in the sink component Tt. In other words, St−1 is a skeleton of Tt, as desired. Consequently, by Lemma 13, FindStable(Tt, St−1, Ot−1) builds a spanning tree St that is strongly stable on Ot (before the arc emanating from v∗ is updated in Step 8). Next, we claim that after applying BFS(Ot, St), the routing graph looks exactly like St. This is true for all nodes outside Ot by the construction of St. To see this, observe that the tree St is constructed from FindStable(Tt, St−1, Ot−1) by adding arcs joining opaque nodes in Ot ⊆ Ot to V (Tt). Since no nodes in V − Ot have been activated at this point, we must have that Tt[V − Ot] ⊆ Tt[V − Ot] = St[V − Ot]. For the remaining nodes, we proceed by induction on the order in which nodes are activated by BFS(Ot, St). Our induction hypothesis is that every node activated during this time will choose its parent in St as its next hop and become consistent, so it has a "real" path as its chosen route. Let us prove the base case. Consider the first node x activated by BFS(Ot, St). Suppose x chooses z in the routing graph, that is, (x, z) ∈ Tt. At the time we activate v∗, we have (1) Tt[V − Ot] = St[V − Ot] and (2) z is clear and is in V − Ot (because the sink node r is in V − Ot). There are two cases. First, if x is opaque, then z is valid for x because every node now has a real path as its chosen route. Second, if x is clear, then z cannot have x in its chosen route because (x, z) is in the routing graph. Also, each node in the Ot-subtree of x in St either is a descendant of x or is opaque by (1). Thus, by the strong stability property of St on Ot, z is the best valid choice of x. Consequently, x must choose z and must be consistent upon activation because z has a real path as its chosen route. Inductively, assume that every node activated before x by BFS(Ot, St) chooses its parent in St as its next hop and is consistent at the time we activate x. Now activate x and let Q0 be the set of nodes already activated by BFS(Ot, St). Then R[Q] = St[Q] where R is the current routing graph and Q = (V − O) ∪ Q0. Thus, by induction, the node x must have a parent z ∈ Q which is clear and consistent. But this situation is now similar to case where we activated the first node (with Q replacing V − Ot). Therefore, we conclude that x must choose z and become consistent. This proves the claim that the routing graph looks like St. Finally, consider the node v∗. By the choice of v∗, all the descendants of v∗ in St must be in Ot. Since the routing graph now looks exactly like St and every node is consistent, v∗ can choose any node outside its Ot-subtree in St. Consequently, as w is the best valid choice of v∗, the modification of the tree St (replacing (v∗, y) by (v∗, w)) results in a tree St that is strongly stable on Ot after adding v∗. Also, since (v∗, w) is now in both the routing graph and St, both statements hold at the end of the iteration. Lemma 14 produces a guarantee that the cardinality of Ot is increasing. Lemma 15. The cardinality of Ot strictly increases with each round t, until Ot = V . Furthermore if some packet does not route in round t − 1, then Ot ≥ Ot−1 + 3. 17 St−1 (Ot−1) is a forest because A+ Proof. By construction, we have Ot ≥ Ot + 1. Thus, the first statement holds. To prove the second statement, it suffices to show that if there is an opaque node in Ot then there are at least two opaque nodes not in Ot−1. This would imply that we add at least three nodes to Ot, two nodes from Ot − Ot−1 and the node v∗ at the end of the iteration. So, we have to prove that Ot − Ot−1 ≥ 2 for all t ≥ 1. Suppose Ot (cid:54)= ∅; if not then every packet routed in round t− 1. Now consider the routing graph Rt−1 at the end of round t − 1 (before the learning phase). Since there is an opaque node in Ot, the routing graph Rt−1 must contain a cycle C. By Lemma 14, A+ (Ot−1) is contained in Rt−1. St−1 The subgraph A+ [Ot−1] and St−1 is a tree. So, at St−1 least one vertex of C is not in Ot−1. Thus, we have shown that Ot − Ot−1 ≥ 1. If C has no vertex in Ot−1, then C must have at least two vertices and all of them are in Ot − Ot−1, so we are done. If C has some vertex in Ot−1, then C must contain an arc (u, v) such that u ∈ Ot−1 and v /∈ Ot−1. Follow the cycle C starting from the vertex v. If the node w after v in C is not in Ot−1, then we have found two nodes in Ot − Ot−1, and we are done. So, w is in Ot−1. Now, continue traversing C from w to u. By Lemma 14, after applying BFS(Ot−1, St−1), the forest A+ (Ot−1) is contained in the routing graph. In fact, the routing graph at this point is exactly St−1, and no nodes change their choice. Hence, all nodes are consistent after applying BFS(Ot−1, St−1). This means that w is not a descendant of u or v in the forest A+ (Ot−1); otherwise, w would have u and v (in fact, the arc (u, v)) in its chosen route. So, the only way C can go from w to u is to leave the set of nodes Ot−1. But then the next node y on C we reach outside Ot−1 satisfies y (cid:54)= v. Therefore, again, C has two distinct nodes not in Ot−1. [Ot−1] = A+ Rt−1 St−1 St−1 It is immediate from Lemma 15 that we can route every packet in (cid:98)n/3(cid:99) rounds, and that the network becomes stable in n rounds. Moreover, we can deduce a stronger failure guarantee. We say that round t is a imperfect round if we cannot route every packet. Then there can be at most (cid:98)n/3(cid:99) imperfect rounds (note that these may not be consecutive rounds) even if the routing graph is not yet stable. Theorem 16. There is an activation sequence that routes every packet in (cid:98)n/3(cid:99) rounds, gives a stable spanning tree in n rounds, and guarantees that there are at most (cid:98)n/3(cid:99) imperfect rounds. Acknowledgements. We thank Michael Schapira and Sharon Goldberg for interesting discussions on this topic. References [1] Thomas Erlebach, Alexander Hall, Alessandro Panconesi, and Danica Vukadinovic. Cuts and disjoint paths in the valley-free model. Internet Mathematics, 3(3), 2007. 21 [2] Alex Fabrikant and Christos H. Papadimitriou. The complexity of game dynamics: BGP oscillations, sink equilibria, and beyond. In SODA, pages 844 -- 853, 2008. 6 [3] Alex Fabrikant, Umar Syed, and Jennifer Rexford. There's something about MRAI: Timing diversity can exponentially worsen BGP convergence. In INFOCOM, pages 2975 -- 2983, 2011. 20 18 [4] Lixin Gao and Jennifer Rexford. Stable internet routing without global coordination. IEEE/ACM Trans. Netw., 9(6):681 -- 692, 2001. 20 [5] Timothy Griffin, F. Bruce Shepherd, and Gordon T. Wilfong. The stable paths problem and interdomain routing. IEEE/ACM Trans. Netw., 10(2):232 -- 243, 2002. 1, 5, 20 [6] Timothy Griffin and Gordon T. Wilfong. An analysis of BGP convergence properties. In SIGCOMM, pages 277 -- 288, 1999. 6, 20 [7] Timothy G. Griffin and Brian J. Premore. An experimental analysis of BGP convergence time. In ICNP, pages 53 -- 61, 2001. 20 [8] John P. John, Ethan Katz-Bassett, Arvind Krishnamurthy, Thomas E. Anderson, and Arun Venkataramani. Consensus routing: The internet as a distributed system. (best paper). In NSDI, pages 351 -- 364, 2008. 21 [9] Howard J. Karloff. On the convergence time of a path-vector protocol. In SODA, pages 605 -- 614, 2004. 20 [10] Richard M. Karp. Reducibility among combinatorial problems. In Complexity of Computer Computations, pages 85 -- 103, 1972. 6 [11] Nate Kushman, Srikanth Kandula, Dina Katabi, and Bruce M. Maggs. R-BGP: Staying connected in a connected world. In NSDI, 2007. 20 [12] Craig Labovitz, Abha Ahuja, Abhijit Bose, and Farnam Jahanian. Delayed internet routing convergence. IEEE/ACM Trans. Netw., 9(3):293 -- 306, 2001. 20 [13] Hagay Levin, Michael Schapira, and Aviv Zohar. Interdomain routing and games. SIAM J. Comput., 40(6):1892 -- 1912, 2011. 21 [14] Zhuoqing Morley Mao, Jennifer Rexford, Jia Wang, and Randy H. Katz. Towards an accurate as-level traceroute tool. In SIGCOMM, pages 365 -- 378, 2003. 21 [15] Dan Pei, Matt Azuma, Daniel Massey, and Lixia Zhang. BGP-RCN: improving BGP conver- gence through root cause notification. Computer Networks, 48(2):175 -- 194, 2005. 20 [16] Michael Schapira, Yaping Zhu, and Jennifer Rexford. Putting BGP on the right path: a case for next-hop routing. In HotNets, page 3, 2010. 20, 21 [17] John W. Stewart, III. BGP4: Inter-Domain Routing in the Internet. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 1998. 12, 20 [18] Kannan Varadhan, Ramesh Govindan, and Deborah Estrin. Persistent route oscillations in inter-domain routing. Computer Networks, 32(1):1 -- 16, 2000. 20 [19] Stefano Vissicchio, Luca Cittadini, Laurent Vanbever, and Olivier Bonaventure. iBGP decep- tions: More sessions, fewer routes. In INFOCOM, 2012. 2 19 Appendix: Interdomain Routing and Model Technicalities. The Internet is a union of subnetworks called domains or Autonomous Systems (ASes). The inter- domain routing protocol used in the Internet today is called the Border Gateway Protocol (BGP), and it works as follows [17]. For destination r and router v, each neighbouring router of v announces to v the route to r that it has chosen and from amongst these announced routes, v chooses the route P(v) that it ranks highest. The router v then in turn announces to its neighbouring routers its routing path P(v). This process continues until an equilibrium is reached in which each router has chosen a route and for each router v, no neighbour of v announces a route that v would rank higher than its currently routing path. The ranking of routes at a router depends on a number of route attributes such as which neighbour announced the route, how long the route is, and which domains the route traverses. In fact, the ranking of routes at v is a function of v's traffic engineering goals as well as the Service Level Agreements (SLAs), that is, the economic contracts v has made with its neighbours. It is well known that BGP can be thought of as a game [5] and that BGP as a game may have no Nash equilibrium [18, 6]. There is now a vast literature studying the conditions under which BGP will or will not have an equilibrium (for example [5, 4]). It has been shown that in a BGP instance, the absence of a structure known as a dispute wheel implies that the BGP instance will have a unique equilibrium [5]. There have been a number of papers analysing the worst-case convergence time of BGP instances having no dispute wheel [9, 3, 16]. There have also been many experimental papers measuring BGP convergence times [12, 7] and papers offering modifications to BGP with the goal of speeding up convergence [15, 11]. However, BGP convergence is only a step towards the ultimate goal of successfully delivering packets to the destination. In fact, routers perform operations simultaneously on two basic levels: (1) on the control plane (i.e., where BGP exchanges routing information with other routers as described above) and (2) on the forwarding plane where routers use the routing information from BGP to forward packets to neighbouring routers towards the packets' ultimate destinations. That is, packets are being forwarded during the time that the control plane is attempting to settle on an equilibrium. Recall our model in Section 2. We base our idealised routing protocols on BGP and two particularly important attributes that a routers uses to rank its available routes. Firstly, a router might not trust certain domains to handle its packets securely or in a timely fashion, so it may reject routes traversing such unreliable domains. This motivates a (no-go) filtering, which will filter out any route that goes through an undesirable domain (i.e., a domain on the router's no-go filtering list). Secondly, it has been argued that perhaps the most important attribute in how a router v ranks routes is the neighbour of v announcing the route to v [16]. That is, one can think of each router ordering its neighbours and ranking any route from a lower ordered router over any route from a higher ordered router. This is called next-hop routing. Thus, in our protocols, a node ranks routes by first filtering out any route that goes through nodes on its filtering list and then choosing from amongst the remaining routes the one announced by the lowest ordered neighbour (next-hop preference with filtering). As discussed, to analyse stability, it suffices to consider only the control plane. But, to under- stand packet routing, we need to understand the interaction between the forwarding and control planes. Thus, we need to incorporate the actions of the forwarding plane into the standard model of the control plane [5]. To do so, some assumptions must be made, particularly concerning the synchronisation between the planes. In setting up a model for a practical problem, it is impor- 20 tant to examine how the modelling assumptions relate to reality. So, here we briefly address some technical aspects: • Synchronisation of the Planes. Observe that, in our model, the control plane and the forwarding plane operate at a similar speed. This assumption is the worst case in that it maximises the rate at which inconsistencies are produced between the nodes routing paths. In practice, updates in the control plane are much slower than the rate of packet transfer. • Packet Cycling. When a packet gets stuck in a cycle, we will assume that, at the start of the next round, an adversary can position the packet at whichever node in the cycle they wish. • Fair Activation Sequences. We insist that activation sequences in the control plane are fair in that all nodes update their routes at a similar rate. Clearly, the use of permutations ensures fairness. From the theoretical point of view, fairness is important as it avoids artificially routing packets by the use of unnatural and pathological activation sequences. For example, it prohibits the use of activation sequences that are biased towards nodes in regions where disconnectivities arise and attempts to fix this by "freezing" other nodes until consistency is obtained. Moreover, in practice, routers timings on the control plane are similar. • Routing in Rounds. The use of rounds (defined by permutations) for routing is not vital and is used for clarity of exposition and to emphasise fairness. Also, packet forwarding is clearly not delayed until the end of a "round" in practice but, again, this is also not needed for the model. The assumption is made as it clarifies the arguments needed in the analyses. For example, forwarding at the end of a round can be shown to be equivalent to forwarding continuously throughout the round with the planes in sync; that is, packets are forwarded immediately and, within a round, the routing path at a node is updated just before the first packet a node sees is about to leave it. • Route-Verification. Route-verification at the end of the round is our one non-worst case assumption and is not a standard aspect of BGP, albeit one that can be incorporated in a fairly simple fashion by tools such as traceroute or an AS-level traceroute tool such as that described by Mao et al. [14]. Route-verification is the focus of the influential paper of John et al. [8] on consensus routing. It is also used in the theory literature on incentives under BGP [13]. Due to the manipulative power provided by unfair activation sequences, it is not hard to simplify our algorithms and omit the route-verification step given the use of unfair activation sequences; see also [16]. It remains an interesting open problem to obtain consistency using fair sequences without route-verification. • Filtering. In this paper, we assume that each node can apply what is known as import filtering -- that is, not accepting certain routes from its neighbours. This implicitly assumes that each node announces its routing path to all of its neighbours. In reality, each node may choose to apply export filtering -- that is, it may announce any particular route to only a subset of its neighbours (e.g., in order to assure "valley-free routing" [1]). Export filtering can be incorporated into our model by allowing for neighbour specific import filtering rules, where a node v can have a filtering list D(v, w) for each neighbour w. Of course, our lower bounds would still hold for this more general model, but it would allow for more special cases to explore. 21
1610.08154
1
1610
2016-10-26T03:03:57
LP Rounding and Combinatorial Algorithms for Minimizing Active and Busy Time
[ "cs.DS" ]
We consider fundamental scheduling problems motivated by energy issues. In this framework, we are given a set of jobs, each with a release time, deadline and required processing length. The jobs need to be scheduled on a machine so that at most g jobs are active at any given time. The duration for which a machine is active (i.e., "on") is referred to as its active time. The goal is to find a feasible schedule for all jobs, minimizing the total active time. When preemption is allowed at integer time points, we show that a minimal feasible schedule already yields a 3-approximation (and this bound is tight) and we further improve this to a 2-approximation via LP rounding techniques. Our second contribution is for the non-preemptive version of this problem. However, since even asking if a feasible schedule on one machine exists is NP-hard, we allow for an unbounded number of virtual machines, each having capacity of g. This problem is known as the busy time problem in the literature and a 4-approximation is known for this problem. We develop a new combinatorial algorithm that gives a 3-approximation. Furthermore, we consider the preemptive busy time problem, giving a simple and exact greedy algorithm when unbounded parallelism is allowed, i.e., g is unbounded. For arbitrary g, this yields an algorithm that is 2-approximate.
cs.DS
cs
LP Rounding and Combinatorial Algorithms for Minimizing Active and Busy Time (cid:63) Jessica Chang, Samir Khuller, and Koyel Mukherjee University of Maryland, College Park {jschang,samir,koyelm}@cs.umd.edu Abstract. We consider fundamental scheduling problems motivated by energy issues. In this framework, we are given a set of jobs, each with a release time, deadline and required processing length. The jobs need to be scheduled on a machine so that at most g jobs are active at any given time. The duration for which a machine is active (i.e., "on") is referred to as its active time. The goal is to find a feasible schedule for all jobs, minimizing the total active time. When preemption is allowed at integer time points, we show that a minimal feasible schedule already yields a 3-approximation (and this bound is tight) and we further improve this to a 2-approximation via LP rounding techniques. Our second contribution is for the non-preemptive version of this problem. However, since even asking if a feasible schedule on one machine exists is NP-hard, we allow for an unbounded number of virtual machines, each having capacity of g. This problem is known as the busy time problem in the literature and a 4-approximation is known for this problem. We develop a new combinatorial algorithm that gives a 3-approximation. Furthermore, we consider the preemptive busy time problem, giving a simple and exact greedy algorithm when unbounded parallelism is allowed, i.e., g is unbounded. For arbitrary g, this yields an algorithm that is 2-approximate. 1 Introduction Scheduling jobs on multiple parallel or batch machines has received extensive attention in the computer science and operations research communities for decades. For the most part, these studies have focused primarily on "job-related" metrics such as minimizing makespan, total completion time, flow time, tardiness and maximizing throughput under various deadline constraints. Despite this rich history, some of the most environmentally (not to mention, financially) costly scheduling problems are those driven by a pressing need to reduce energy consumption and power costs, e.g. at data centers. In general, this need is not addressed by the traditional scheduling objectives. Toward that end, our work is most concerned with minimization of the total time that a machine is on [2,5,9,12] to schedule a collection of jobs. This measure was recently introduced in an effort to understand energy-related problems in cloud computing contexts, and the busy/active time models cleanly capture many central issues in this space. Furthermore, it has connections to several key problems in optical network design, perhaps most notably in the minimization of the fiber costs of Optical Add Drop Multiplexers (OADMs) [5]. The application of busy time models to optical network design has been extensively outlined in the literature [5,6,8,14]. With the widespread adoption of data centers and cloud computing, recent progress in virtualization has facilitated the consolidation of multiple virtual machines (VMs) into fewer hosts. As a consequence, many computers can be shut off, resulting in substantial power savings. Today, products such as Citrix XenServer an VMware Distributed Resource Scheduler (DRS) offer VM consolidation as a feature. In this sense, minimizing busy time (described next) is closely related to the basic problem of mapping VMs to physical hosts. In the active time model, the input is a set J of n jobs J1, . . . , Jn that needs to be scheduled on one machine. Each job Jj has release time rj, deadline dj and length pj. We assume that time is slotted (to be defined formally) and that all job parameters are integral. At each time slot, we have to decide if the machine is "on" or "off". When the machine is on at time [t, t + 1), time slot t is active, and we may schedule one unit of up to g distinct jobs in it, as long as we satisfy the release time and deadline constraints for those jobs. When the machine is off at time [t, t + 1), no jobs may be scheduled on it at that time. Each job Jj has to be scheduled in at least pj active slots between rj and dj. The goal is to schedule all the jobs while minimizing the active time of the machine, i.e., the total duration that the (cid:63) This work has been supported by NSF Grants CCF-1217890 and CCF-0937865. A preliminary version of this paper appeared in ACM Symposium on Parallelism in Algorithms and Architectures (SPAA 2014). machine is on. In the special case where jobs have unit length (pj = 1 for all j), there is a fast exact algorithm due to Chang, Gabow and Khuller [2]. However, in general, the exact complexity of minimizing active time remains open. In this work, we demonstrate that any minimal feasible solution has active time within 3 of the optimal active time. We also show that this bound is tight. We then further improve the approximation ratio by considering a natural IP formulation and rounding a solution of its LP relaxation to obtain a solution that is within twice the integer optimum (again this bound is tight). We note that if the on/off decisions are given, then determining feasibility is straightforward by reducing the problem to a flow computation. We conjecture that the active time problem itself is likely NP-hard. We next consider a slight variant of the active time problem, called the busy time problem. Again, the input is a set J of n jobs J1, . . . Jn that need to be scheduled. Each job Jj has release time rj, deadline dj and length pj. In the busy time problem, we want to assign and non-preemptively schedule the jobs over a set of identical machines. (A job is non-preemptive means that once it starts, it must continue to be processed without interruption until it completes. In other words, if job Jj starts at time sj, then it finishes at time sj + pj.) We want to partition jobs into groups so that at most g jobs are running simultaneously on a given machine. Each group will be scheduled on its own machine. A machine is busy at time t means that there is at least one job running on it at t; otherwise the machine is idle at t. The amount of time during which a machine M is busy is called its busy time, denoted busy(M). The objective is to find a feasible schedule of all the jobs on the machines (partitioning jobs into groups) to minimize the cumulative busy time over all the machines. We call this the busy time problem, consistent with the literature [5,9]. That the schedule has access to an unbounded number of machines is motivated by the case when each group is a virtual machine. A well-studied special case of this model is one in which each job Jj is rigid, i.e. dj = pj + rj. Here, there is no question about when each job must start. Jobs of this form are called interval jobs. (Jobs that are not interval jobs are called flexible jobs.) The busy time problem for interval jobs is N P -hard [14] even when g = 2. Thus, we will look for approximation algorithms. What makes this special case particularly central is that one can convert an instance of flexible jobs to an instance of interval jobs in polynomial time, by solving a dynamic program with unbounded g [9]. The dynamic program's solution fixes the positions of the jobs to minimize their "shadow" (projection on the time-axis, formally defined in Section 4). The shadow of this solution with g = ∞ is the smallest possible of any solution to the original problem and can lower bound the optimal solution for bounded g. Then, we adjust the release times and deadlines to artificially fix the position of each job to where it was scheduled in the solution for unbounded g. This creates an instance of interval jobs. We then run an approximation for interval jobs on this instance. Figure 1 shows a set of jobs and the corresponding packing that yields an optimal solution, i.e., minimizing busy time. Busy time scheduling in this form was first studied by Flammini et al. [5]. They prove that a simple greedy algorithm FIRSTFIT for interval jobs is 4-approximate. It considers jobs in non-increasing order by length, greedily packing each job in the first group in which it fits. In the same paper, they highlight an instance on which the cost of FIRSTFIT is three times that of the optimal solution. Closing this gap would be very interesting1. However, unknown to Flammini et al, earlier work by Alicherry and Bhatia [1] and Kumar and Rudra [11] already considered a problem in the context of wavelength assignment. Their algorithms immediately yield two different 2- approximations for the busy time problem with interval jobs (see the Appendix). Khandekar et al. [9] consider the generalization in which each job has an associated width or "demand" on its machine. For any set of jobs assigned to the same machine, the cumulative demand of the active ones can be at most g at any time. The authors apply FIRSTFIT ideas to this problem and obtain a 5-approximation. The main idea involves partitioning jobs into those of "narrow" and "wide" demand. Each wide job is assigned to its own machine, while FIRSTFIT is applied to the set of narrow jobs. In addition, the authors give improved bounds for special cases of busy-time scheduling with jobs of unit demand. When the interval jobs form a clique, they provide a PTAS. They also give an exact algorithm when the intervals of the jobs are laminar, i.e. two jobs' intervals intersect only if one interval is contained in the other. However, we note that for the case of unit width jobs, the same approach gives a 4- 1 In an attempt to improve approximation guarantees, Flammini et al. [5] consider two special cases. The first case pertains to "proper intervals", where no job's interval is strictly contained in that of another. For instances of this type, they show that the greedy algorithm ordering jobs by release times is actually 2-approximate. The second special case involve instances whose corresponding interval graph is a clique - in other words, there exists a time t such that each interval [rj, dj) contains t. In this case, a greedy algorithm also yields a 2-approximation. As with proper intervals, it is not obvious that minimizing busy time on clique instances is NP-hard. However, when the interval jobs are both proper and form a clique, a very simple dynamic program gives an optimal solution [12]. 2 Fig. 1: (A) Collection of interval jobs with unit demand, numbered arbitrarily. (B) Optimal packing of the jobs on two machines with g = 3 minimizing total busy time. 3 2 3 4 7 6 1 (A) 5 2 3 4 7 6 1 (B) 5 approximation for flexible jobs, by solving a dynamic program for g = ∞. It turns out that the methods of Kumar and Rudra [11] and Alicherry and Bhatia [1] can be similarly extended to also give 4-approximations. There are examples demonstrating that this analysis is tight. We break this barrier with a different approach, obtaining a 3-approximation. 1.1 Problem Definition In this section we formally define the notions of active time and busy time. Both models are motivated by the total amount of time that a machine is actively working. of these unit jobs can be scheduled. The running times of the algorithms are polynomial in n and P (=(cid:80) Active Time. The input consists of a set of jobs J , where each job j has a release time rj, a deadline dj, and a length pj. We let slot t denote the unit of time [t−1, t). Since time is slotted, job j can start as early at rj and as late as dj−pj. For example, if a unit-length job has release time 1 and deadline 2, it can be scheduled in slot t = 2, but not in slot t = 1. Equivalently, it can have a start time of 1, but not a start time of zero. The set of slots {rj + 1, . . . , dj} comprise job j's window. We sometimes abuse notation and let [rj, dj) refer to the slots in j's window. Then pj units of job j must be scheduled in its window, but not necessarily in consecutive slots (in other words jobs can be considered to be a chain of pj unit jobs), with identical release times and deadlines and the restriction that in any time slot, at most one j∈J pj). We have access to a single machine that is either active ('on') or not at any point of time. The machine can process only g jobs at any time instant. Since there is a single machine, we simply refer to the time axis henceforth in place of the machine. Assume without loss of generality that the earliest release time of any job j ∈ J is 0 and denote by T the latest relevant time slot, i.e., T = maxj dj. Then, it will be convenient to let T refer to the set of time slots {1, . . . , T}. When preemption is not allowed, determining whether there exists a feasible solution for non-unit length jobs becomes strongly NP-hard, by a reduction from 3-PARTITION, even for the special case when the windows of all the jobs are identical. Busy Time. Given that even determining the feasibility for the non-preemptive problem is hard in the active time model, we consider a relaxation of the model. The key difference between busy time and active time is that while active time assumes access to a single machine, busy time can open an unbounded number of machines if necessary. (One can think of each machine as a virtual machine.) As in the active time problem, there is a set of jobs, J , where each job j has a release time rj, a deadline dj, and a length pj, and each machine has capacity g. There is no restriction on the integrality of the release times or deadlines. The jobs need to be partitioned into groups so that when each group is scheduled non-preemptively on its own machine, at most g jobs are running simultaneously on a given machine. We say that a machine is busy at time t if there is at least one job running on the machine at t; otherwise the machine is idle. The time intervals during which a machine M is processing at least one job is called its busy time, denoted as busy(M). The goal is to partition the jobs onto machines so that no machine is working on more than g jobs at a time, and the cumulative busy time over all machines is minimized. We will call this the busy time problem. Note that every instance is feasible in the busy time model. 1.2 Our Results For the active time problem when we are allowed preemption at integer time points and time is slotted, we first show that considering any minimal feasible solution gives us a 3-approximation. A minimal feasible solution can be found by starting with a feasible solution and making slots inactive in any order, as long as the instance remains feasible (we will explain later how to test feasibility given a set of active slots). We then consider a natural IP formulation for this problem and show that considering an LP relaxation allows us to convert a fractional schedule to an integral schedule by paying a factor of 2. As a by product, this yields a 2-approximation. We note that the integrality gap of 2 is tight [2]. Since the busy time problem for interval jobs is NP-hard [14], the focus in this paper is the development of a polynomial-time algorithm GREEDYTRACKING with a worst-case approximation guarantee of 3, improving the previous bounds of 4 (as mentioned earlier, there seem to be several different routes to arrive at this bound). As before we use the dynamic program to first solve the problem for unbounded g [9] and then reduce the problem to the case of interval jobs. The central idea is to iteratively identify a set of disjoint jobs; we call such a set a "track". Then, the 4 subset of jobs assigned to a particular machine is the union of g such tracks; we call the set of jobs assigned to the same machine a bundle of jobs. Intuitively, this approach is less myopic than FIRSTFIT, which schedules jobs one at a time. We also construct examples where GREEDYTRACKING yields a solution twice that of the optimum for interval jobs. One important consequence of GREEDYTRACKING is an improved bound for the busy time problem on flexible jobs. Similar to Khandekar et al. [9], we first solve the problem assuming unbounded machine capacity to get a solution that minimizes the projection of the jobs onto the time-axis. Then, we can map the original instance to one of interval jobs, forcing each job to be done exactly as it was in the unbounded capacity solution. We prove that in total, this approach has busy time within 3 times that of the optimal solution. In addition, we explore the preemptive version of the problem and provide a greedy 2-approximation. 1.3 Related Work While in both active time and busy time models, we assign jobs to machines where up to g jobs can run concurrently, the key difference between the two models is that the former model operates on a single machine, while the latter assumes access to an unbounded number of machines. In the active time model, when jobs are unit in length, Chang, Gabow and Khuller [2] present a fast linear time greedy algorithm. When the release times and deadlines can be real numbers, they give an O(n7) dynamic program to solve it; this result has since been improved to an O(n3)-time algorithm in the work of Koehler and Khuller [10]. In fact, their result holds even for a finite number of machines. Chang, Gabow and Khuller [2] also consider generalizations to the case where jobs can be scheduled in a union of time intervals (in contrast to the usual single release time and deadline). Under this generalization, once the capacity constraints exceeds two, minimizing active time becomes NP-hard via a reduction from 3-EXACT-COVER. Mertzios et al. [12] consider a dual problem to busy time minimization: the resource allocation maximization version. Here, the goal is to maximize the number of jobs scheduled without violating a budget constraint given in terms of busy time and the parallelism constraint. They show that the maximization version is NP-hard whenever the (busy time) minimization problem is NP-hard. They give a 6-approximation algorithm for clique instances and a polynomial time algorithm for proper clique instances for the maximization problem. The online version of both the busy time minimization and resource allocation maximization was considered by Shalom et al. [13]. They prove a lower bound of g where g is the parallelism parameter, for any deterministic algorithm for general instances and give an O(g)-competitive algorithm. Then they consider special cases, and show a lower bound of 2 and an upper bound of (1 + φ) for a one-sided clique instances (a special case of laminar cliques), where φ is the golden ratio. They also show that the bounds increase by a factor of 2 for clique instances. For the maximization version of the problem with parallelism g and busy time budget T , they show that any deterministic algorithm cannot be more than gT competitive. They give a 4.5-competitive algorithm for one-sided clique instances. Flammini et al. [7] consider the problem of optimizing the cost of regenerators that need to be placed on light paths in optical networks, after every d nodes, to regenerate the signal. They show that the 4-approximation algorithm for minimizing busy time [5] solves this problem for a path topology and d = 1 and extend it to ring and tree topologies for general d. Faigle et al. [4] consider the online problem of maximizing "busy time" but their objective function is totally different from ours. Their setting consists of a single machine and no parallelism. Their objective is to maximize the total length of intervals scheduled as they arrive online, such that at a given time, at most one interval job has been scheduled on the machine. They give a randomized online algorithm for this problem. 2 Active time scheduling of preemptive jobs Definition 1. A job j is said to be live at slot t if t ∈ [rj + 1, dj]. Definition 2. A slot is active if at least one job is scheduled in it. It is inactive otherwise. Definition 3. An active slot is full if there are g jobs assigned to it. It is non-full otherwise. 5 A feasible solution σ is specified by a set of active time slots A ⊆ T , and a mapping or assignment of jobs to time slots in A, such that at most g jobs are scheduled in any slot in A, at most one unit of any job j is scheduled in any time slot in A and every job j has been assigned to pj active slots within its window. Once the set A of active slots has been determined, a feasible integral assignment can be found by computing a max-flow computation on the following graph. Define Gfeas to be the flow network whose vertex set is a source s, a sink v and a bipartite subgraph (J ,T ) where J contains a node xj for every job Jj and T contains a node for every timeslot, from 1 to T . For each node xj ∈ J , there is an edge from s to xj with capacity pj. For any job j that is feasible in slot t, there is an edge of capacity one between xj and t's node in T . Finally, there exists an edge of capacity g between each active slot node of T and the sink (see Figure 2). Nodes ti corresponding to inactive slots i may be deleted; alternatively, the capacity of edge (ti, v) can be set to 0. An active time instance has a feasible schedule if and only if the maximum flow that can be sent on j=1 pj. (Note that since capacities are integral, the maximum flow is the corresponding graph Gfeas has value P =(cid:80)n also integral without loss of generality.) s cap. pj cap. 1 . . . . . . J x1 x2 x3 . . . xj . . . xn T t1 t2 . . . ti−1 ti ti+1 . . . cap. 0 cap. g cap. 0 cap. g cap. g cap. g v Fig. 2: Flow network Gfeas. Nodes in T corresponding to inactive slots are gray. An integral flow of value(cid:80) tT corresponds to a feasible schedule. j pj The cost of a feasible solution σ is the number of active slots in the solution, denoted by A. Let Af denote the set of active slots that are full, and let An denote the set of active slots which are non-full. Therefore, A = Af + An. Definition 4. A minimal feasible solution is one for which closing any active slot renders the remaining active slots an infeasible solution. In other words, no proper subset of active slots can feasibly satisfy the entire job set. Given a feasible solution, one can easily find a minimal feasible solution by closing slots (in any order) and checking if a feasible solution still exists. Definition 5. A non-full-rigid job is one which is scheduled for one unit in every non-full slot where it is live. 6 Lemma 1. For any minimal feasible solution σ, there exists another solution σ(cid:48) of same cost, where every active slot that is non-full, has at least one non-full-rigid job scheduled in it. Proof. Consider any non-full slot in a minimal feasible solution σ, which does not have any non-full-rigid job sched- uled in it. Move any job in that slot to any other (non-full, active) slot that it may be scheduled in, and where it is not already scheduled2. There must at least one such slot, otherwise this would be a non-full-rigid job. Continue this process for as long as possible. Note that in moving these jobs, we are not increasing the cost of the solution, as we are only moving jobs to already active slots. If we can do this until there are no jobs scheduled in this slot, then we would have found a smaller cost solution, violating our assumption of minimal feasibility. Otherwise, there must be at least one job left in that slot, which cannot be moved to any other active slots. This can only happen if all the slots in the window of this job are either full, or inactive, or non-full where one unit of this job has been scheduled, thus making this a non-full rigid job. (cid:117)(cid:116) Continue this process until for each non-full slot, there is at least one non-full-rigid job scheduled. Lemma 2. There exists a minimal set J ∗ of non-full-rigid jobs such that 1. at least one of these jobs is scheduled in every non-full slot, and 2. no jobs Jj and Jj(cid:48) exist in J ∗ such that Jj's window is contained in Jj(cid:48)s window, and 3. at every time slot, at most two of the jobs in J ∗ are live. Let OP T be the cost of the optimal solution. This lemma allows us to charge the cost of the non-full slots to the quantity J ∗ ≤ 2OP T . In addition, any optimal solution must have cost at least the sum of job lengths divided by capacity g. The cost incurred by the full slots is trivially no more than this latter quantity. Thus, once we bound the cost of the non-full slots by 2OP T , the final approximation ratio of three follows (see Theorem 1). Proof. Consider a set J ∗ of non-full-rigid jobs that are covering all the non-full slots. Suppose it contains a pair of non-full-rigid jobs j and j(cid:48), such that the [rj, dj) ⊆ [rj(cid:48), dj(cid:48)). One unit of j(cid:48) must be scheduled in every non-full slot in the window of j(cid:48). However, this also includes the non-full slots in the window of j, hence we can discard j from J ∗ without loss. We repeat this with every pair of non-full-rigid jobs in J ∗, such that the window of one is contained within the window of another, until there exists no such pair. Now consider the first time slot t where 3 or more jobs of J ∗ are live. Let these jobs be numbered according to their deadlines (j1, j2, j3, . . . .j(cid:96), (cid:96) ≥ 3). By definition, the deadline of all of these jobs must be at least t since they are all live at t. Moreover, they are all non-full-rigid, by their membership in J ∗, which means they are scheduled in every non-full active slot in their window. Since J ∗ is minimal, no job window is contained within another, hence none of the jobs j2, . . . , j(cid:96) have release time earlier than that of j1. Therefore, all non-full slots before the deadline of j1 must be charging either j1 or some other job with an earlier release time. Consequently, discarding any of the jobs j2, . . . , j(cid:96) will not affect the charging of these slots. Let t(cid:48) be the first non-full active slot after the deadline of j1; then t(cid:48) must charge one of j2, j3, . . . , j(cid:96). Among these, all jobs which have a deadline earlier than t(cid:48), can be discarded from J ∗, without any loss, since no non-full slot needs to charge it. Hence, let us assume that all of these jobs j2, j3, . . . , j(cid:96) are live at t(cid:48). However, all of them being non-full-rigid, and t(cid:48) being non-full and active, all of them must have one unit scheduled in t(cid:48). Therefore, if we discard all of the jobs j2, . . . , j(cid:96)−1 and keep j(cid:96) alone, that would be enough since it can be charged all the non-full slots between t(cid:48) and its deadline d(cid:96). Hence, after discarding these intermediate jobs from J ∗, there would be only two jobs j1 and j(cid:96) left which overlap at t. (cid:117)(cid:116) Repeat this for the next slot t(cid:48)(cid:48) where 3 or more jobs of J ∗ are live, until there are no such time slots left. The cost of the non-full slots of the minimal feasible solution σ(cid:48) is An ≤(cid:80) j∈J ∗ pj. Theorem 1. The cost of any minimal feasible solution is at most 3OP T . Proof. It follows from Lemma 2 that J ∗ can be partitioned into two job sets J1 and J2, such that the jobs in each set have windows disjoint from one another. Therefore the sum of the processing times of the jobs in each such partition 2 Such an action might make the other slot a full slot, and change the status of a job which could become non-full-rigid. 7 pj +(cid:80) is a lower bound on the cost of any optimal solution. Hence, the cost of of the non-full slots is An ≤(cid:80) (cid:80) j∈J ∗ pj ≤ pj(cid:48) ≤ 2OP T . Furthermore, the full slots charge once to OP T , since they have a mass of g ≤ OP T . Therefore, in total the cost of any (cid:117)(cid:116) scheduled in them, which is a lower bound on OP T . Af ≤ minimal feasible solution cost(σ) = cost(σ(cid:48)) = A = Af + An ≤ 3OP T . This proves the theorem. j∈J1 j(cid:48)∈J2 (cid:80) j∈J pj g The above bound is asymptotically tight as demonstrated by the following example. There are two jobs each of length g. One has window [0, 2g) and the other has window [g, 3g). Also, there are g − 2 rigid jobs, each of length g − 2, with windows [g + 1, 2g − 1). Finally, there are g − 2 unit-length jobs with windows [g + 1, 2g) and another g − 2 unit-length jobs with windows [g, 2g − 1). See Figure 3. An optimal solution schedules the two longest jobs in [g, 2g), one set of g − 2 unit-length jobs at time slot g, and the other set of unit-length jobs at time slot 2g − 1, for an active time of g. However, a minimal feasible solution could schedule the two sets of g − 2 unit-length jobs in the window [g + 1, 2g − 1), with the rigid jobs of length g − 2. Now, the two longest jobs cannot fit anywhere in the window [g + 1, 2g − 1), since these slots are full. The minimal feasible solution must put these jobs somewhere; one feasible way would be to pack one of the longest jobs from [1, g + 1) and the other one from [2g − 1, 3g − 1). The total cost of this minimal feasible solution would then be 3g − 2, which approaches to 3OP T as g increases. Fig. 3: An instance where a minimal feasible solution has active time almost 3 times the optimal solution. 3 A 2-approximation LP rounding algorithm In this section, we give a 2-approximate LP-rounding algorithm for the active time problem with non-unit length jobs, where preemption is allowed at integral boundaries. Consider the following integer program for this problem. 8 g-2 rigid jobs of length g-2g-2 flexible unit jobs1job of length g1job of length g0gg+12g-12g3gg-2 flexible unit jobs IP : min. (cid:88) (cid:88) (cid:88) j∈J t∈T yt xt,j ≤ yt xt,j ≤ g · yt xt,j ≥ pj yt ∈ {0, 1} xt,j ∈ {0, 1} xt,j = 0 t∈T s.t. ∀ t ∈ T , j ∈ J ∀ t ∈ T ∀ j ∈ J ∀ t ∈ T ∀ t ∈ T , j ∈ J ∀ t /∈ {rj + 1, . . . , dj} In the integer program, the indicator variables yt denote whether slot t is active (open). The assignment variables xt,j specify whether any unit of job j is assigned to slot t. The first set of inequalities ensures that a unit of any job can be scheduled in a time slot only if that slot is active. Without this constraint, the LP relaxation of IP has an unbounded integrality gap. This constraint, along with the range specification on the indicator y variables, also ensures that at most one unit of a job can be assigned to a single slot. The second set of inequalities ensures that at most g units of jobs can be assigned to an active slot. The third set of inequalities ensures that pj units of a job j get assigned to active slots. The remaining constraints are range specifiers for the indicator and assignment variables. We relax the integer requirements of yt and xt,j to get the LP relaxation LP 1. In LP 1, the objective function and all the constraint inequalities remain unchanged from the integer program IP , except the range specifiers at the end. Those get modified as follows: 0 ≤ yt ≤ 1 for every slot t, and xt,j ≥ 0 for every job j and slot t. As in the IP, xt,j is forced to 0 for slots t not in job j's window {rj + 1, . . . , dj}. Henceforth, we focus on LP 1. We first solve LP 1 to optimality. Since any integral optimal solution is a feasible LP solution, the optimal LP solution is a lower bound on the cost of any optimal solution. Our goal is to round it to a feasible integral solution that is within twice the cost of the optimal LP solution. However, before we do the rounding, we preprocess the optimal LP solution so that it has a certain structure without increasing the cost of the solution. Then we round this solution to obtain an integral feasible solution. We use the following notation to denote the LP solution. A slot t with yt = 1 is said to be fully open, a slot with 1 > yt ≥ 1 2 > yt > 0 is said to be barely open and a slot with yt = 0 is said to be closed. 2 is said to be half open, a slot with 1 In the rounding, our goal will be to find a set of slots to open integrally, such that there exists a feasible fractional assignment for the jobs in the integrally open slots. As described earlier, given a set of integrally open slots with feasible fractional assignment of jobs for the active time problem, an integral assignment can be found at the end of the rounding procedure, via a maximum flow computation. Since the capacities are integral and integrality of flow, the flow computation returns an integral assignment, without loss of generality. 3.1 Preprocessing: Creating a Right-Shifted Solution First, consider the set of distinct deadlines D = {td1 , td2, . . . , td(cid:96)}, sorted in increasing order. We will process the LP solution sequentially according to this order. Denote by Ji the set of jobs with deadline tdi, and define a dummy deadline td0 ≤ td1 to be the earliest slot t where yt > 0 in the optimal solution LP 1. Note that td0 does not correspond to an actual deadline (and hence, J0 = ∅), but is defined simply for ease of notation. If td0 < td1, we add td0 to D, Next, we consider the slots open between successive deadlines in the optimal solution for LP 1. Yi is the sum of yt over the slots numbered {tdi−1 + 1, . . . , tdi} for all i ≥ 1. For the rest of the paper, [q] is shorthand notation for {1, 2, . . . , q}. Definition 6. Yi =(cid:80) By definition, the cost of the LP solution is:(cid:80) t∈{tdi−1 +1,...,tdi} yt, ∀ i ∈ [(cid:96)], where (cid:96) is the number of distinct deadlines in J , and Y0 = 0. tdi∈D Yi. Now, we modify the optimal LP solution as follows to create a right-shifted structure. Intuitively, we want to push open slots to the "right" (i.e., delay them to later time slots) as much as possible without violating feasibility, or changing Yi. t∈T yt =(cid:80) 9 For all i ∈ [(cid:96)], we open the slots {tdi−(cid:98)Yi(cid:99)+1, . . . , tdi} integrally, and the slot tdi−(cid:98)Yi(cid:99) partially, up to Yi−(cid:98)Yi(cid:99), Using the notation stated earlier, slots {tdi − (cid:98)Yi(cid:99) + 1, . . . , tdi} are fully open, and the slot tdi − (cid:98)Yi(cid:99) is either 2. Refer to the Figure 4 if Yi − (cid:98)Yi(cid:99) > 0, and close all slots {tdi−1 + 1, . . . , tdi − (cid:98)Yi(cid:99) − 1}. closed if Yi − (cid:98)Yi(cid:99) = 0, barely open if 1 for an example. 2 > Yi − (cid:98)Yi(cid:99) > 0, or half open if 1 > Yi − (cid:98)Yi(cid:99) ≥ 1 Fig. 4: Figure showing the right shifted solution LP 2 corresponding to LP 1. We now prove that there exists a feasible fractional assignment of all the jobs in the right-shifted LP solution. Lemma 3. All jobs in J can be feasibly fractionally assigned in the right-shifted LP solution. + ytdi−1 − 1. If δ ≤ 0, move the job assignments as is from ytdi−1 to ytdi Proof. For any tdi > td0, Yi is unchanged in the right-shifted LP solution. Consider the following processing of the original LP solution for a pair of slots tdi and tdi − 1 for some i > 0. If ytdi < 1 in the original LP solution, let , and update the x variables of δ = ytdi the respective jobs moved to reflect the new slot they are assigned to. In other words, xtdi ,j is incremented by xtdi−1,j and xtdi−1,j is reduced to 0. At the same time, also increment the ytdi by ytdi−1 and decrement ytdi−1 to 0. This does not violate LP feasibility. , and decrement ytdi−1 by 1−ytdi . The new values are y(cid:48) tdi−1 = δ. If δ > 0, increment ytdi tdi For every job j with a positive assignment to tdi − 1, decrement xtdi−1,j by δ(cid:48) = max(0, xtdi−1,j − δ), and increment xtdi ,j by δ(cid:48). By this transformation, for every job j, the updated xtdi−1,j ≤ y(cid:48) . Moreover, the ). Hence, the total mass of jobs in total mass of jobs transferred to tdi is at most(cid:80) (cid:17) ≤ g(1 − ytd1 tdi is at most g and at tdi − 1 is at most gδ. Again, this maintains LP feasibility. Now, repeat this process for the updated ytdi−1 and ytdi−2. Continue this till the pair of adjacent slots tdi−1+1 and tdi−1+2 are processed. We end up with a feasible right-shifted LP solution for time slots {tdi−1+1, . . . , tdi}. Repeat (cid:117)(cid:116) this for all i ∈ [(cid:96)]. We get a feasible fractional right-shifted LP solution. (cid:16) j∈J xtdi−1,j − δ by 1−ytdi = 1 and y(cid:48) tdi−1, and xtdi ,j ≤ y(cid:48) tdi 10 𝑡𝑑1𝑡𝑑2𝑡𝑑30.60.530.620.570.550.30.5710.4710.93𝐿𝑃1𝐿𝑃20.8𝑡𝑦𝑡𝑦𝑡𝑡𝑑1𝑡𝑑2𝑡𝑑3𝑡: fully open: half-open: barely open We can solve a feasibility LP with the yt for any t pre-set, as dictated by the right-shifting process. The right-shifted (1) LP is described below. LP 2 : xt,j ≤ yt ∀ t ∈ T , j ∈ J (cid:80) (cid:80) j∈J xt,j ≤ g · yt ∀ t ∈ T ∀ j ∈ J t∈T xt,j ≥ pj ∀ t ∈ T , j ∈ J xt,j ≥ 0 ∀ t /∈ {rj + 1, . . . , dj} xt,j = 0 Henceforth, we work with this feasible, right-shifted optimal LP solution, LP 2. Observation 1 In a right-shifted fractional solution, a slot t, tdi−1 < t < tdi for any i ∈ [(cid:96)], is fully open only if slots {t + 1, . . . , tdi} are fully open. The above observation follows from the description of the preprocessing step to convert an optimal LP solution to a right-shifted solution structure. 3.2 Overview of Rounding In this section, we will give an informal overview of the rounding process for ease of exposition. The formal description of rounding and the proofs are given in the following sections. We process the set of (cid:96) distinct deadlines D, in increasing order of time. In each iteration i ∈ [(cid:96)], we consider the jobs in Ji, and we will integrally open a subset of slots, denoted Oi ⊆ {tdi−1 + 1, . . . , tdi}, maintaining the following k∈[i] Jk in the set of k∈[i] Ok; (ii) the total number of integrally open slots thus far is at most twice the cost invariants at the end of every iteration i: (i) there exists a feasible assignment of all jobs in(cid:83) integrally open slots thus far(cid:83) of LP solution thus far, i.e., (cid:83) k∈[i] Ok ≤ 2(cid:80) k∈[i] Yk. t. Note that while fully open refers to any slot t, such that Let the cost of a slot t after rounding be denoted as y(cid:48) yt = 1, integrally open refers to any slot t(cid:48) such that after rounding, y(cid:48) Definition 7. For all i ∈ [(cid:96)], the set of integrally open slots Oi = {t ∈ {tdi−1 + 1, . . . , tdi} y(cid:48) rounded value of yt for any slot t. t(cid:48) = 1. t = 1}, where y(cid:48) t is the In our rounding scheme, every fully open slot in the right-shifted solution will also be integrally open; however, there may be integrally open slots that were not fully open in the fractional optimal solution. These slots will need to be accounted for carefully. The rounding algorithm is as follows. At every iteration i, it first opens (cid:98)Yi(cid:99) slots integrally, going backwards from tdi in the right-shifted solution. Note that these slots were fully open in the right-shifted solution, and hence, obviously, do not charge anything extra to the LP solution. If Yi−(cid:98)Yi(cid:99) = 0, we are done with this iteration. Otherwise, 2, there is one half-open slot tdi − (cid:98)Yi(cid:99), which the rounding opens up integrally. This is fine since a if Yi − (cid:98)Yi(cid:99) ≥ 1 half-open slot can be integrally opened, incurring a rounded cost of 1, and thereby, charging their fractional LP cost 2, the slot tdi − (cid:98)Yi(cid:99) is barely open. The rounding algorithm first tries to close at most 2 times. In case, Yi − (cid:98)Yi(cid:99) < 1 a barely open slot when it is processing such a slot, by trying to accommodate all the jobs with deadlines up to the current one, in the current set of integrally open slots. If no such assignment exists, then the algorithm opens up such a slot integrally, after accounting for its value, by charging other fully open or half open slots. We next describe the possible ways of charging a barely open slot that needs to be opened by the rounding. When a single barely open slot charges a fully open slot, we say that the barely open slot is dependent on the fully open slot. Now, the barely open slot can be opened integrally charging the fully open slot twice, and not charging the barely open slot at all. First, the algorithm tries to charge a barely open slot (that needs to be opened) to the earliest fully open slot without a dependent. Note here fully open slot refers to slots fully open in the right-shifted LP solution, and not the set of slots opened integrally after rounding. If all the earlier fully open slots have dependents, the algorithm tries to find the earliest fully open slot with a dependent, such that the sum of the y's of the barely open slot (that is currently being processed) and the dependent 11 of the fully open slot add up to at least 1 2. Once the algorithm finds the earliest fully open slot with a dependent that satisfies the above condition, it opens up the barely open slot, since the cumulative sum of the y's of the three slots is 2. We refer to such a triple of slots as a trio. Note that this trio or triple of slots cumulatively charges at most at least 3 twice to the cumulative y (LP cost) of the trio. Finally, if no trio is possible or all of the earlier fully open slots are already part of trios, we find the earliest half-open slot, such that the sum of the y of the half open and the barely open slot together is at least 1. Note that here we require that the half-open slot be an earlier slot that is already processed. In fact, as a rule of thumb, the rounding algorithm can only charge slots already processed. We say that the barely open slot is a filler of the half open slot in this case, and open up the barely open slot. Note that the two integrally open slots corresponding to the half open slot and its filler charge their LP cost at most twice in the process. In the first case, where a barely open slot is a dependent on a fully open slot, we do not charge its y value or LP cost at all; however, in both the latter cases (trio and filler), we must charge the y or LP cost of all the slots involved including the barely open one. A barely open slot that is charged in one iteration as a dependent (when its y value was not charged at all) on a fully open slot can get charged as a trio (when its y value gets charged) in a later iteration. Similarly, a half-open slot, charging itself alone in an iteration, can later get charged with a filler. Refer to Figure 5 for an example of the charging process of a barely open slot that cannot be closed by flow-based assignments. Fig. 5: Figure showing the three ways of charging of a barely open slot that needs to be opened by the rounding algorithm. We will additionally maintain the invariant that at every iteration, every barely open slot that we have opened is either a dependent on a fully open slot, or is part of a trio, or is a filler of a half-open slot. Moreover, we ensure that every fully open slot has at most one dependent or it is part of at most one trio, and every half-open slot has at most one filler. As already mentioned, in the rounding process we sometimes close a barely open slot tdi − k, while processing a k∈[i] Ok. At the deadline tdi. This will be done only if the jobs in(cid:83) k∈[i] Jk can be fully accommodated in the slots(cid:83) 12 …𝑡𝑑𝑘𝑡𝑑𝑖𝑡𝑑𝑖𝑡𝑑𝑖−2…23 iftyif𝑦𝑑𝑘+𝑦𝑑𝑖≥1Charge as a dependent: Charge as a trio: Charge as a filler: 𝑡𝑑𝑘𝑡𝑑𝑘−1: fully open: half-open: barely open𝑡𝑑𝑘𝑡𝑑𝑖𝑡𝑑𝑖 same time, the cost of ytdi−k in the LP solution is not charged at all. However, the LP solution might have assigned jobs of a later deadline in this barely open slot and hence, we might need to open up this slot later to accommodate such jobs. In order to do this, and account for the the total charge on the LP solution, we create a "proxy" copy of the slot that we closed, and carry it over to the next iteration. The idea behind carrying forward this "proxy" slot is that, if needed, we can come back and open up this slot in the future, while processing the jobs of a later deadline, and account for it without double counting. Informally, this is a safety deposit that we can come back and use if needed. The y cost of this proxy slot p = tdi − k is denoted as y(cid:48)(cid:48) p = ytdi−k, that is, the y of the slot we have just closed. The proxy points to the actual slot p that it is a proxy for, so that we know where we can open up a slot charging the proxy value, if needed. In any iteration i, when we have a proxy (which by definition is a barely open slot), we treat it as a regular fractionally open slot (though there may not be any actual slot at that point). If this slot remains closed after the rounding, the proxy gets carried over to the next iteration, whereas if it does get opened by the rounding, the actual slot which it points to gets opened. However, now the cost of opening it will be accounted for by the current solution. It may also happen that the proxy from the previous iteration i gets merged with a fractionally open slot in the current iteration i + 1. This does not affect the feasibility of job assignments, since the jobs of a later deadline that were assigned by the LP in some slot tdi − k, are also feasible to be assigned in slots tdi < t(cid:48) ≤ tdi+1. This is outlined in detail in Section 3.4. There can be at most one proxy slot at any iteration. We next give a detailed description of the rounding process. 3.3 Processing td1 Claim. Y1 ≥ 1. Proof. This is obvious as a feasible LP solution would have assigned at least one unit of the jobs with deadline td1 in slots t ≤ td1. (cid:117)(cid:116) Slots {td1 −(cid:98)Y1(cid:99) + 1, . . . , td1} are fully opened in the right-shifted optimal LP solution. We keep these slots open, t = yt = 1 for these slots. In the following, we outline how we deal with the slot td1 − (cid:98)Y1(cid:99), if Y1 − (cid:98)Y1(cid:99) > 0. i.e., y(cid:48) Case 1. Y1 − (cid:98)Y1(cid:99) ≥ 1 2 . In this case, the slot td1−(cid:98)Y1(cid:99) is half open. We open it fully in the rounding process, in other words, set y(cid:48) td1−(cid:98)Y1(cid:99) = 1, and charge the cost of fully opening it to ytd1−(cid:98)Y1(cid:99). Therefore, the LP cost ytd1−(cid:98)Y1(cid:99) is charged at most twice by this process. Case 2. 0 < Y1 − (cid:98)Y1(cid:99) < 1 2 . In this case, the slot td1 − (cid:98)Y1(cid:99) is barely open. The rounding algorithm first checks if a feasible assignment of J1 exists in the slots {td1 − (cid:98)Y1(cid:99) + 1, . . . , td1} (the fully open slots), using the maximum-flow construction described earlier. If such an assignment exists, the slot td1 − (cid:98)Y1(cid:99) is closed, that is, y(cid:48) td1−(cid:98)Y1(cid:99) = 0, and we proceed to the next iteration (processing td2), after passing over a proxy slot with y = Y1 − (cid:98)Y1(cid:99) to iteration 2. Note that ytd1−(cid:98)Y1(cid:99) is not charged at all so far by the rounding process. We denote the proxy as y(cid:48)(cid:48) td1−(cid:98)Y1(cid:99) = 1; its cost needs to be accounted for. In order to account for the cost of opening it, we consider the slot to be dependent on td1 − (cid:98)Y1(cid:99) + 1, the earliest fully open slot without a dependent. We charge the cost of this slot to ytd1−(cid:98)Y1(cid:99)+1. By this process, ytd1−(cid:98)Y1(cid:99)+1 is charged at most twice. We are guaranteed to find a fully open slot on which to make it dependent since Y1 > 1 in this case. Otherwise, if a feasible assignment does not exist, the rounding algorithm opens it fully, that is, y(cid:48) p = ytd1−(cid:98)Y1(cid:99), where p = td1 − (cid:98)Y1(cid:99). We next argue that there exists a feasible assignment of all jobs with deadline td1 in the slots opened by the above rounding algorithm up to deadline td1. This will form the base case of the argument for the general case that we will prove by induction. Lemma 4. There exists a feasible integral assignment of all jobs with deadline td1 in the slots opened by the rounding algorithm up to deadline td1. Moreover, O1 ≤ 2Y1. 13 Proof. Suppose by contradiction that flow could not find an assignment of all jobs with deadline td1 in the slots opened by the rounding algorithm up to td1. Consider the following assignment. Assign the jobs with release time td1 − 1 to slot td1. If the slot gets full, then move on to td1 − 1. Otherwise, next assign jobs with release time td1 − 2, till td1 gets full, then move on to td1 − 1. Continue this till td1 − (cid:98)Y1(cid:99) slots. If flow could not find an assignment, clearly, all slots are completely full, and still there is at least one job left. Therefore, there are ≥ ((cid:98)Y1(cid:99) + 1)g + 1 jobs with deadline td1. However, the LP cost up to td1 is Y1, hence the LP could not have scheduled more than Y1g ≤ ((cid:98)Y1(cid:99) + 1)g jobs in td1. Therefore, this gives a contradiction. Now, we know that Y1 ≥ 1, otherwise LP would not be feasible. Moreover, by the right-shifted nature, there can be only one barely open slot in Y1. Clearly, O1 ≤ 2Y1, and if at all, a barely open slot was rounded to integrally (cid:117)(cid:116) open, we have at least one fully open slot to charge it to. This completes the proof. 3.4 Processing deadline tdi, i > 1 Next we describe the rounding process for an arbitrary deadline tdi, i > 1, after the previous deadlines {td1, . . . , tdi−1} have been processed. Since we are working with a right shifted solution, the slots {tdi − (cid:98)Yi(cid:99) + 1, . . . , tdi} are fully open. Hence, these slots will remain integrally open in the rounded solution, i.e., for these slots, y(cid:48) t = yt for t ∈ {tdi − (cid:98)Yi(cid:99) + 1, . . . , tdi}. Dealing with a proxy slot. While processing a deadline tdi, suppose there is a proxy of value y(cid:48)(cid:48) iteration (i − 1). Here, p denotes the slot pointed to by the proxy. Before we do any rounding in iteration i, we merge the proxy with Yi in the following way. p carried over from Case 1. y(cid:48)(cid:48) p + Yi − (cid:98)Yi(cid:99) ≤ 1. p(cid:48) = y(cid:48)(cid:48) Create a new proxy y(cid:48)(cid:48) p + Yi − (cid:98)Yi(cid:99). If tdi−1 (cid:54)= tdi − (cid:98)Yi(cid:99) (this will always hold if Yi − (cid:98)Yi(cid:99) > 0, and may or may not hold otherwise), we set p(cid:48) = tdi − (cid:98)Yi(cid:99). Otherwise, we set p(cid:48) = p (i.e., keep the pointer unchanged). We remover the earlier proxy, or, set y(cid:48)(cid:48) p(cid:48). This changing of the proxy pointer is without loss of generality as explained next. Clearly, the proxy cost in iteration i − 1, i > 1, is incurred by the LP in accommodating jobs of a later deadline and hence it was passed over to iteration i. Further, observe that the jobs of a later deadline that were feasible in tdi−1 or earlier, are also feasible at tdi − (cid:98)Yi(cid:99). p + Yi − (cid:98)Yi(cid:99) = 1, then tdi − (cid:98)Yi(cid:99) is now fully open (hence gets added to Oi) and no proxy will get carried p = 0. After this, we consider Yi = Yi + y(cid:48)(cid:48) If y(cid:48)(cid:48) over from this iteration3. p + Yi − (cid:98)Yi(cid:99) < 1 2, and alternatively, Otherwise, we process p(cid:48) as a regular fractional slot, that is barely open if y(cid:48)(cid:48) p < 1 p + Yi − (cid:98)Yi(cid:99) ≥ 1 2. p + Yi − (cid:98)Yi(cid:99) > 1. p(cid:48) is set to 1), then no proxy is carried p(cid:48) and it will continue to point to slot half open if 1 > y(cid:48)(cid:48) If the slot p(cid:48) pointed to by the proxy gets opened by the rounding process (y(cid:48) over from the iteration i. Otherwise, the new proxy carried over will be of value y(cid:48)(cid:48) p(cid:48). Case 2. y(cid:48)(cid:48) By definition of proxy, y(cid:48)(cid:48) 2, and hence, it holds that there exists a p + Yi − (cid:98)Yi(cid:99) − 1, setting the earlier slot tdi − (cid:98)Yi(cid:99) (cid:54)= tdi−1, that is half open. We create a new proxy of cost y(cid:48)(cid:48) p = 0. If a slot tdi − (cid:98)Yi(cid:99) − 1 (cid:54)= tdi−1 exists, we point the new proxy to this slot, in other words, proxy cost to y(cid:48)(cid:48) p(cid:48)(cid:48) = tdi − (cid:98)Yi(cid:99) − 1. On the other hand, if no such slot exists, we keep p(cid:48) = p, that is, we do not change the slot p + Yi − (cid:98)Yi(cid:99) − 1. p(cid:48) is pointed to by the proxy. Now, we process p(cid:48) as a regular barely open fractional slot of y = y(cid:48)(cid:48) processed in the same manner as a fractionally open slot tdi − (cid:98)Yi(cid:99) − 1 in the right-shifted solution, even if the proxy points to some other slot p(cid:48). If the fractional slot p(cid:48) gets opened (y(cid:48) p(cid:48) becomes 1 by the rounding process), then we do not pass over any proxy. Otherwise, a proxy of cost y(cid:48)(cid:48) p(cid:48) gets carried over to iteration i + 1, pointing to p(cid:48). By the above proxy merging procedure, there can be at most one proxy in an iteration. 3 Note that this can only happen if Yi − (cid:98)Yi(cid:99) > 1 is barely open. 2. Therefore, this case implies that Yi − (cid:98)Yi(cid:99) > 1 p(cid:48) = y(cid:48)(cid:48) 2 , in other words, if the slot tdi − (cid:98)Yi(cid:99) is half open, since by definition a proxy 14 Processing Yi. In the following discussion, we assume Yi already takes into account any proxy from iteration i − 1 as described above. Case 1. Yi − (cid:98)Yi(cid:99) = 0. In this case, slots {tdi − Yi + 1, . . . , tdi} are fully open. We set y(cid:48) t = yt for all t ∈ {tdi − Yi + 1, . . . , tdi}, and add slots {tdi − Yi + 1, . . . , tdi} to Oi. Case 2. Yi > 1 and Yi − (cid:98)Yi(cid:99) ≥ 1 2 . Here, slots {tdi − (cid:98)Yi(cid:99) + 1, . . . , tdi} are fully open and the slot tdi − (cid:98)Yi(cid:99) is half-open. We set y(cid:48) {tdi − (cid:98)Yi(cid:99) + 1, . . . , tdi}, and y(cid:48) twice in the process. We add the slots {tdi − (cid:98)Yi(cid:99), . . . , tdi} to Oi. Case 3. Yi > 1 and Yi − (cid:98)Yi(cid:99) < 1 2 . tdi−(cid:98)Yi(cid:99) = 1. We charge the cost of y(cid:48) t = yt for t ∈ tdi−(cid:98)Yi(cid:99) to ytdi−(cid:98)Yi(cid:99), charging ytdi−(cid:98)Yi(cid:99) at most j≤i Jj exists in the slots(cid:83) tdi − (cid:98)Yi(cid:99), and check if a feasible assignment of all jobs in(cid:83) In this case, slots {tdi − (cid:98)Yi(cid:99) + 1, . . . , tdi} are fully open and the slot tdi − (cid:98)Yi(cid:99) is barely open. We first close k∈[i−1] Ok ∪ {tdi − (cid:98)Yi(cid:99) + 1, . . . , tdi} using the maximum-flow construction described earlier. If successful, we add {tdi − (cid:98)Yi(cid:99) + 1, . . . , tdi} to Oi, and pass on a proxy of of cost Yi − (cid:98)Yi(cid:99) and move to the next deadline (iteration i + 1). The pointer to this proxy would be the slot tdi −(cid:98)Yi(cid:99) if this is not coincident with tdi−1, otherwise to an earlier slot pointed to by a proxy coming from iteration (i − 1), as described earlier. Otherwise, if no feasible assignment is found by the maximum-flow procedure, we need to open the barely open slot tdi − (cid:98)Yi(cid:99), and account for its cost. We add tdi − (cid:98)Yi(cid:99) to Oi over and above the slots {tdi − (cid:98)Yi(cid:99) + 1, . . . , tdi}. We charge tdi − (cid:98)Yi(cid:99) as a dependent on the earliest fully open slot that has no dependents4. Suppose all earlier fully open slots have dependents or are parts of trios, then, we charge the cost of opening the slot tdi − (cid:98)Yi(cid:99) to tdi − (cid:98)Yi(cid:99) + 1. This is feasible, since Yi > 1, and therefore, tdi − (cid:98)Yi(cid:99) + 1 is fully open. Moreover, the slot tdi −(cid:98)Yi(cid:99) + 1 cannot have any dependents from earlier, because the rounding process in any iteration k allows charging fully open slots in time slots equal to or before tdk. Case 1. 1 > Yi ≥ 1 2 . In this case, we open the slot tdi integrally, charging the cost Yi at most twice. Also, since this already takes any proxy coming from earlier iteration into account, no proxy is passed over from this iteration. Case 2. Yi < 1 2 . j≤i Jj exists in the slots(cid:83) We will first try to close tdi. We check if a feasible assignment of all jobs in(cid:83) Suppose closing tdi and finding a feasible assignment of jobs in(cid:83) k∈[i−1] Ok, using the max-flow construction described earlier. If such an assignment exists, we keep tdi closed and move on to the next deadline, passing over a proxy of cost Yi = ytdi to the iteration i + 1, pointing to the slot tdi. Note that this takes into account any proxy from the previous iteration i − 1, since the Yi already takes proxy into account and the pointer is set to tdi without loss of generality as described earlier. j≤i Jj is not successful. Then we are forced to open tdi, but we need to account for it. We need to charge it either to an earlier fully open slot either as a dependent or a trio, or to an earlier half-open slot as a filler. We find the earliest fully open slot that does not have a dependent and charge to it. If all the fully open earlier slots have dependents, we find the earliest fully open slot with a dependent with which it can form a trio, that is, the cumulative y cost of the fully open slot along with its dependent and the 2. If all the earlier fully open slots are already parts of trios, or if not, no trio is current barely open slot tdi is at least 3 possible with them and their dependents, then we find the earliest half-open slot to charge it as a filler. This is possible 4 Note that here fully open slots denote the slots t, where yt = 1 either in the original LP solution or after processing for proxy slot from earlier iteration. In other words, fully open slots are those that are open in the rounded solution, charging their costs to themselves, and none else. The set of fully open slots may not be the same as(cid:83) k∈[i] Ok in iteration i. 15 x∈[1,...,i] Ox x∈[1,...,i−1] Jx x∈[1,...,i−1] Ox after processing deadline tdi−1. x∈[1,...,i−1] Ox. Hence, considering only the jobs(cid:83) x∈[i−1] Ox, and on the slots [tdi − (cid:98)(Yi + y(cid:48)(cid:48) pi−1 only if the cumulative sum of the y cost of the half-open slot and tdi is at least 1. This completes the description of the rounding process. We will now show that after we process deadline tdi by the rounding algorithm, there will exist feasible assignment of all jobs with deadline ≤ tdi in the integrally opened slots up to tdi. After this, we will show that we will always be able to find a way to charge such a barely open slot that needs to be opened by the rounding algorithm, given a feasible LP solution. Lemma 5. There exists a feasible assignment of all jobs in(cid:83) x∈[1,...,i] Jx in the set of integrally opened slots(cid:83) after we process deadline tdi for some i > 1, provided that there exists a feasible assignment of all jobs in(cid:83) in the set of integrally opened slots(cid:83) barely open slot tdi. In this case, clearly there exists a feasible assignment of all jobs in(cid:83) integrally opened slots(cid:83) all jobs in(cid:83) jobs in(cid:83) x∈[1,...,i] Jx in the set of integrally opened slots(cid:83) flow is able to find a feasible assignment of all jobs in(cid:83) assignment of(cid:83) x∈[i−1] Jx in integrally open slots(cid:83) feasible fractional LP solution would exist on the slots(cid:80) Proof. Consider the iteration when we are processing deadline tdi. If Yi is 0, no processing is required and we trivially satisfy the claim in the Lemma. Hence, consider Yi > 0. First consider the case when 0 < Yi ≤ 1 2 and we close the x∈[1,...,i] Jx in the set of x∈[1,...,i−1] Ox, since we close the slot tdi only if flow is able to find a feasible assignment of x∈[1,...,i] Jx in the set of integrally opened slots thus far. Next, consider the case when 0 < (cid:100)Yi(cid:101)−Yi < 1 2, and we open (cid:98)Yi(cid:99) slots, closing the barely open slot tdi − (cid:98)Yi(cid:99). Again, clearly there exists a feasible assignment of all x∈[1,...,i−1] Ox, since we close the slot tdi − (cid:98)Yi(cid:99) only if x∈[1,...,i] Jx in the set of integrally opened slots thus far. The above cases correspond to the scenario when the rounding algorithm opens (cid:98)Yi(cid:99) slots integrally. Now, let us consider the cases when the rounding algorithm opens (cid:100)Yi(cid:101) slots integrally. In this case, clearly, there would be no proxy passed over from iteration i. We will integrally open slots tdi − (cid:98)Yi(cid:99), . . . , tdi. We know that there exists a feasible x∈[i] Jx, a )(cid:99), . . . , tdi], (where we have explicitly indicated that the proxy from iteration i − 1 gets added to Yi, when it gets processed). Recall from Section 3.4, that a proxy gets passed over only when a feasible assignment of jobs exist in the integrally opened slots without considering the cost of the proxy slot (corresponding to a barely open slot). Hence, a feasible LP solution could open the integrally open slots up to iteration i − 1, as fully open, the slot tdi − (cid:98)(Yi + y(cid:48)(cid:48) ) pi−1 )(cid:99) + 1, . . . , tdi ], as fully open. In case fractionally up to Yi + y(cid:48)(cid:48) )(cid:99), −(cid:98)(Yi +y(cid:48)(cid:48) tdi−1 = tdi−(cid:98)(Yi +y(cid:48)(cid:48) pi−1 and by the property of the rounding algorithm as explained in Section 3.4, such an unopened slot will exist for a proxy with non-zero cost. Clearly, such an LP solution would still be feasible if we now open the only fractionally slot (either slot tdi − (cid:98)(Yi + y(cid:48)(cid:48) )(cid:99), or, the actual slot pointed to by the proxy pi−1) fully as well. However, now we get x∈[1,...,i−1] Ox ∪ [tdi − (cid:98)(Yi + pi−1)(cid:99), . . . , tdi]. Since Oi = [tdi−(cid:98)(Yi +pi−1)(cid:99), . . . , tdi], therefore, by integrality of flow, there would exist a feasible (cid:117)(cid:116) Lemma 6. If the rounding process decides to open a barely open slot tdi − t, t ≥ 0 in an iteration i, then we will always find a fully open slot to charge it as a dependent or as a trio, or else, a half-open slot to charge it as a filler. Proof. If the rounding process opens a barely open slot tdi − t, t > 0, then that would imply Yi > 1 because of the right-shifted LP solution structure. (Specifically, a slot tdi − t, with t > 0 can be barely open only if Yi > 1.) In such a case, we can always find a fully open slot ≤ tdi to charge it to, if not a slot earlier. This is because, as already argued, tdi must be fully open, and because of the sequential processing of deadlines in increasing order by the rounding algorithm, no barely-open slots from the previous iterations could have charged it. 2). We assume that the rounding process was feasible till the iteration i − 1, without loss of generality as argued earlier. In iteration i, for contradiction, assume that all the fully open slots t < tdi in the right-shifted LP solution have dependents or are parts of trios, or no trio is possible with the current dependent of any fully open slot, since the sum of the ys are not sufficient, and no filler is possible with any earlier half-open slot (either because they already have fillers, or because the sum of the ys is not sufficient). We show some structural properties of the right shifted LP solution, which we will use to derive the contradiction. a feasible fractional assignment of all jobs in(cid:83) integral assignment of all jobs in(cid:83) x∈[i] Jx in(cid:83) x∈[i] Jx in the integrally open slots(cid:83) Now, let us consider the case when the rounding opens a barely-open slot tdi (this implies Yi < 1 pi−1 )(cid:99), we open the actual slot pointed to by the proxy slot: pi−1 up to Yi +y(cid:48)(cid:48) pi−1 pi−1 x∈[i] Ox. This completes the proof. − (cid:98)(Yi + y(cid:48)(cid:48) )(cid:99), and the slots [tdi − (cid:98)(Yi + y(cid:48)(cid:48) pi−1 pi−1 pi−1 16 The first property we show is as follows: the last fully open slot occurring earlier to tdi corresponds to a deadline. Claim 1.1: Let tmax denote the latest fully open slot in the right-shifted LP solution, that occurs before tdi. More formally, tmax = arg max tt < tdi ∩ yt = 1. Then tmax must correspond to a deadline. Proof. Suppose the above claim is false, and tmax does not correspond to any deadline. Let the deadline immediately after tmax be tdk; therefore, tdk > tmax and tdk−1 < tmax. Since tmax is the latest fully open slot occurring before tdi, tdk must be either closed or barely open or half open. However, from Observation 1, in the right-shifted solution structure, if tmax is fully open, tdk > tmax must be fully open. Therefore, this proves the above claim by contradiction. (cid:117)(cid:116) Let tmax correspond to the kth deadline, i.e., tmax = tdk, where k < i. The next property we show is as follows: any slot in t(cid:48) ∈ [tdk + 1, . . . tdi − 1] such that yt(cid:48) > 0 must correspond to a deadline. Claim 1.2: Any slot t(cid:48) ∈ [tdk+1, . . . , tdi] such that yt(cid:48) > 0 in the right-shifted LP solution must correspond to a deadline, i.e., t(cid:48) = tdj for some j ∈ J . Proof. Suppose t(cid:48) does not correspond to any deadline. We know that tdk is the first fully open slot going backwards from tdi. Let the first deadline after t(cid:48) be tdj where tdj ≤ tdi. Clearly, tdj is well-defined and exists. Moreover, tdj is either closed, or barely open or half-open. However, from Observation 1, if yt(cid:48) > 0, then ytdj = 1. Since that is not (cid:117)(cid:116) true, this completes the proof by contradiction. Next, we argue that if any slot in t ∈ [tdk + 1, . . . tdi − 1] (with yt > 0) was opened by the rounding process, i.e., y(cid:48) t = 1, then it must be half-open with which tdi can form a filler. Claim 1.3: Let t be the last slot ∈ [tdk + 1, . . . tdi − 1], with yt > 0, that was opened by the rounding process in an ≥ 1, hence tdi can be opened by earlier iteration, i.e., y(cid:48) charging t as a filler at most twice the cost of yt + ytdi Proof. Suppose for the sake of contradiction t ∈ [tdk + 1, . . . tdi − 1], the last slot with yt > 0, is either barely open, or half-open, such that yt + ytdi < 1 (i.e., filler is not possible), and has been opened by the rounding process in an earlier iteration, i.e., y(cid:48) t = 1. Then t must be a half-open deadline such that yt + ytdi . t = 1. We know that this t is a deadline from Claim 1.2, and also, it cannot be fully open, since by assumption, tdk is the last fully open deadline occurring before tdi. Let t correspond to the pth deadline, i.e, t = tdp, where k < p < i. We have assumed that the rounding is feasible till iteration i − 1, at at most twice the cost of the LP solution up to deadline i − 1. Therefore, for opening tdp, for p < i, tdp must have feasibly charged an earlier fully open slot (in case tdp was barely open) or itself, if it was half-open. Since tdi itself is barely open, the jobs in Ji must be feasible in tdp, as the LP solution would have had to schedule some portion of all the jobs scheduled in tdi in tdp or earlier, due to the feasibility constraint xi,j ≤ yi. Therefore, the job assignments can be shifted as is from tdi to tdp, after increasing ydp to ydp + ydi, without violating LP feasibility (by assumption ydp + ydi < 1), or without increasing the LP cost. However, that implies that there exists a feasible, equivalent LP solution where the slot tdi is closed, and tdp is either half-open or barely open. In the former case, tdi would charge itself and in the latter case, tdi would continue to be a dependenttriofiller on the slot it was already charging. From the argument in Lemma 5, we can see that this implies that there exists a feasible assignment of all b∈[p] Jb, where p < i. In other words, there exists a feasible a∈[i] Ja in integrally open b∈[p] Ob. Hence, this contradicts the assumption that flow could not find a feasible assignment of all the jobs in b∈[p] Ob, which is why the LP had to open tdi in the first place (cid:117)(cid:116) From Claim 1.3, it is clear, that if there is any slot t ∈ [tdk + 1, . . . tdi − 1] with yt > 0 that has been opened by the rounding process already, then the last such slot must be half-open with which tdi can form a filler. Therefore, if such a slot exists, then in iteration i, if the rounding algorithm needs to open tdi integrally, we can charge it at most twice the cost to tdp feasibly. This is a contradiction to the assumption in Lemma 6. Henceforth, we assume that no slot t ∈ [tdk + 1, . . . tdi − 1] has been opened by the rounding algorithm. jobs in(cid:83) a∈[i] Ja in the set of integrally open slots(cid:83) fractional (hence, integral) flow of an amount equal to the cumulative size of all jobs in(cid:83) slots(cid:83) a∈[i] Ja in the current set of integrally open slots(cid:83) (cid:83) and hence charge it somewhere. Therefore, we have proved the claim by contradiction. 17 Now, we only need to consider the cases where the rounding algorithm needs to open tdi and we are unable to charge it to any fully open slot as dependent or trio, where the fully open slot must be tdk or earlier. However, this implies that tdk must have a dependent, or be a part of a trio. Let us consider the case when tdk is a part of a trio. A trio can happen only when a fully open slot is charged by two barely open slots, one occurring before it, and one occurring after it. However, that would mean that there is some slot with positive y between t ∈ [tdk + 1, . . . tdi − 1] that has been opened by the rounding algorithm, that is not possible. Lemma 6. 5 If there was a fully open slot, it would have remained uncharged so far since no barely open slot has opened from iteration j till iteration k. 18 also implies that all the jobs in(cid:83) Hence, we only need to consider the case when tdk has a dependent charging it, where the dependent occurs earlier than tdk. However, this means that the dependent cannot be processed in any iteration earlier than the iteration in which deadline tdk is processed by the definition of the rounding process. At the same time, it must hold that all fully open slots occurring earlier than tdk must have dependents with which trios are not possible. Therefore, either the dependent is the barely open slot t = tdk − 1 (due to the right-shifted LP solution structure) and clearly, Yk < 2, or it is a proxy slot coming from earlier iterations. However, if it is a proxy, then that means an earlier barely open slot t(cid:48), was closed without any loss of feasibility, where tdj−1 + 1 ≤ t(cid:48) ≤ tdj , for some j < k. It also means that no barely open or half open slots could have opened between tdj and tdk as otherwise it would have absorbed the proxy. Moreover, there are no fully open slots between tdj (inclusive of tdj ) and tdk since the proxy 5. Therefore, tdk must be the first fully open slot from tdj onwards. It would have charge this earlier slot instead of tdk x∈{1,k−1} Jx do not need the proxy value for a feasible assignment. Hence, we can change the pointer of the proxy slot to tdk − 1 without any loss of generality and consider tdk − 1 as dependent on tdk. (Note that tdk − 1 may also be equal to tdj , in which case we do not need to change anything.) Hence, without loss of generality, we can consider the dependent on tdk to be the barely open slot tdk − 1. We next argue that the above case is not possible, in other words, flow will find a feasible assignment for all jobs with deadlines ≤ tdi, even after closing tdi. We know by induction hypothesis, that all jobs with deadline ≤ tdk have a feasible assignment in the integrally open slots up to slot tdk. Consider an optimal packing of the jobs in the integrally open slots. Now, flow could not find a feasible assignment, hence there is at least one job with deadline tdi that could not be accommodated in the fully open slot tdk, that must in turn be fully packed. Either none of these jobs could be moved earlier due to release time constraints, otherwise, slot tdk − 1 is also full. We continue moving backwards in this manner, traversing through the fully packed integrally open slots, till we finally come across a pair of adjacent integrally open slots, t and t(cid:48), t(cid:48) < t, where all integrally open slots going backwards between tdk and t (both inclusive) are completely packed, while t(cid:48) has space, however none of the jobs assigned in slots {t, . . . , tdk}, including those with deadline tdi, can be moved any earlier due to release time constraints. This clearly implies that the LP solution, being feasible, would have to schedule this set of jobs in slots also in the same time range [t, . . . , tdi]. Let there be N integrally open slots in [t, . . . tdk ], including slots tdk and tdk − 1 (we have argued that tdk − 1 must be a barely open slot dependent on tdk, that was opened integrally by the rounding algorithm). The LP solution would have therefore scheduled N job units in the time range [t, . . . , tdk ]. Now, in the N − 2 integrally open slots occurring before tdk − 1, let there be x1 fully open slots with dependents (with which trios were not possible) and x2 be fully open slots that are part of trios. Since all fully open slots were already charged (as tdk − 1 had to charge tdk), there are no other fully open slots. Furthermore, this implies that there are x1 barely open slots dependent on x1 fully open slots and 2x2 barely open slots forming trios with the x2 fully open slots. The remaining slots must be half open. Let x3 of the half open slots have fillers (with x3 barely open slots) and x4 of the remaining half-open slots. 4 on an average to the Clearly, 2x1 + 3x3 + 2x3 + x4 + 2 = N. Each of the dependent-fully open pair contribute < 3 LP solution cost, the trios contribute < 2 4 on an average, and the remaining half-open slots contribute < 1 each. Finally, tdk − 1, tdk and tdi together contribute < 3 2 since they cannot form trio. Therefore, the total LP solution cost up to tdi is < 2x1 2 < N. This gives a contradiction. Hence, this case too cannot arise, and a barely open slot will always find a fully open slot or half-open slot to charge, if flow cannot find an assignment of all jobs up to the current deadline being processed. (cid:117)(cid:116) The next theorem, proving the approximation guarantee of the LP rounding algorithm follows from Lemma 5 and 3 on an average, the half-open slots with fillers contribute < 3 The proof of Lemma 6 therefore follows. 3 4 + 3x3 2 3 + 2x3 3 4 + x4 + 3 Theorem 2. There exists a polynomial time algorithm which gives a solution of cost at most twice that of any optimal solution to the active time problem on non-unit length jobs with integral preemption. twice the cost of the LP solution up to tdi. Formally, at the end of every iteration i, (cid:83) from Lemma 5, it follows by induction that there exists a feasible integral assignment of jobs in(cid:83) Proof. From Lemma 6, it follows that at the end of every iteration i, the number of integrally open slots is at most x∈[i] Yi, and x∈[i] Ox. The base case is given by Lemma 4. We repeat this until the last deadline d(cid:96). At the end, by induction we are assured of an integral feasible assignment on the set of opened slots via maximum flow, while the number of open slots is at most twice the optimal LP objective function value. Hence, we get a 2-approximation. The time complexity of the rounding algorithm is O((cid:96)T F ), where F is the complexity of the maximum flow algorithm and (cid:96) is the number of distinct deadlines. The preprocessing is linear in T and the LP is polynomial in T , where T is the number of distinct (cid:117)(cid:116) time slots in the union of the feasible time intervals for all the jobs in the instance. x∈[i] Ox ≤ 2(cid:80) x≤i Jx in(cid:83) 3.5 LP Integrality Gap We show here that the natural LP for this problem has an integrality gap of two. Hence, a 2-approximation is the best possible using LP rounding. Consider, g pairs of adjacent slots. In each pair, there are g + 1 jobs which can only be assigned to that pair of slots. An integral optimal solution will have cost 2g, where as in an optimal fractional solution, g+1 to the fully open slot, each such pair will be opened up to 1 and 1 g+1, to the barely open slot, thus maintaining all the constraints. Therefore, optimal LP solution has cost and up to 1 2g → 2 as g → ∞. g + 1 and g+1 g , and all the g + 1 jobs will be assigned up to g 4 Busy Time 4.1 Notation and Preliminaries In the busy time problem, there are an unbounded number of machines to which jobs can be assigned, with each machine limited to working on at most g jobs at any given time t. Informally, the busy time of a single machine is the total time it spends working on at least one assigned job. Unlike in the active time model, time is not slotted and job release times, deadlines and start times may take on real values. The goal is to feasibly assign jobs to machines to minimize the schedule's busy time, that is, the sum of busy times over all machines. If pj < dj − sj, then start times should also be specified. However, for the following insightful special case, job start times are determined by their release times. Definition 8. A job j is said to be an interval job when pj = dj − rj. The special case of interval jobs is central to understanding the general problem. In this section, we give improve- ments for the busy time problem via new insights for the interval job case. In general, we will let J (cid:48) refer to an instance of jobs that are not necessarily interval, and J to an instance of interval jobs. Job Jj is active on machine m at some time t ∈ [rj, dj) if Jj is being processed by machine m at time t. Definition 9. The length of time interval I = [a, b) is (cid:96)(I) = b − a. The span of I is also Sp(I) = b − a. We generalize these definitions to sets of intervals. The span of a set of intervals is informally the magnitude of the projection onto the time axis and is at most its length. Sometimes we refer to (cid:96)(S) as the "mass" of the set S. Definition 10. For a set S of interval jobs, its length is (cid:96)(S) =(cid:80) I∈S (cid:96)(I). For two interval jobs I and I(cid:48), the span of S = {I, I(cid:48)} is defined as Sp(S) = (cid:96)(I) + Sp(I(cid:48)) − (cid:96)(I ∩ I(cid:48)). For general sets S of interval jobs, Sp(S) = (cid:96)(I1) + Sp(S\I1) − (cid:96)(I1 ∩ (S\I1)), where I1 is the job in S with earliest release time. 19 Then the total busy time of the solution is(cid:80)κ We need to find a partition of the jobs into groups or bundles, so that every bundle has at most g jobs active at any time t. Each bundle B is assigned to its own machine, with busy time Sp(B). Suppose we have partitioned the job set into κ feasible bundles (the feasibility respects the parallelism bound g as well as the release times and deadlines). k=1 Sp(Bk). The goal is to minimize this quantity. We consider two problem variants: g bounded and g unbounded. For the preemptive version of the problem, the problem definition remains the same, the only difference being that the jobs can be processed preemptively across various machines. If the jobs are not necessarily interval jobs, then the difficulty of finding the minimum busy time lies not just in finding a good partition of jobs, but also in deciding when each job should start. We study both the preemptive and non-preemptive versions of this problem. Without loss of generality, the busy time of a machine is contiguous. If it is not, we can break it up into disjoint periods of contiguous busy time, assigning each of them to different machines, without increasing the total busy time of the solution. Let OP T (J (cid:48)) be the optimal busy time of an instance J (cid:48), and OP T∞(J (cid:48)) the optimal busy time when unbounded parallelism is allowed. The next lower bounds on any optimal solution for a given instance J (cid:48) were introduced ear- lier ([1], [11]). The following "mass" lower bound follows from the fact that on any machine, there are at most g simultaneously active jobs. Observation 2 OP T (J (cid:48)) ≥ (cid:96)(J (cid:48)) . g The following "span" lower bound follows from the fact that any solution for bounded g is also a feasible solution when the bounded parallelism constraint is removed. If all jobs in J are interval jobs, then OP T∞(J ) = Sp(J ). Observation 3 OP T (J (cid:48)) ≥ OP T∞(J (cid:48)). However, the above lower bounds individually can be arbitrarily bad. For example, consider an instance of g disjoint unit length interval jobs. The mass bound would simply give a lower bound of 1, whereas the optimal solution pays g. Similarly, consider an instance of g2 identical unit length interval jobs. The span bound would give a lower bound of 1, whereas the optimal solution has to open up g machines for unit intervals, paying g. We introduce a stronger lower bound, which we call the demand profile. In fact, the algorithm of Alicherry and Bhatia [1] as well as that of Kumar and Rudra [11] implicitly charge the demand profile. This lower bound holds for the case of interval jobs. Definition 11. Let A(t) be the set of interval jobs that are active at time t, i.e., A(t) = {j : t ∈ [rj, dj)}. Also, let A(t) be the raw demand at time t, and D(t) = Definition 12. An interval I = [a, b) is interesting if no jobs begin or end within I, and minj rj ≤ a ≤ b ≤ maxj dj. For a given instance, there are at most 2n interesting intervals. Also, the raw demand, and hence the demand, is uniform over an interesting interval. Thus, it makes sense to talk about the demand over such an interval. Let A(Ii) (D(Ii), respectively) denote the raw demand (demand, resp.) over interesting interval Ii. Then for a set I of interesting intervals, I = {I1, I2, . . . , I(cid:96)}, (cid:96) ≤ 2n, we have that D(Ii) = D(t), ∀t ∈ Ii. the demand at time t. (cid:108)A(t) (cid:109) g Additionally, Sp(J ) = Sp((cid:83) Ii∈I Ii). Definition 13. For an instance J of interval jobs, its demand profile DeP (J ) is the set of tuples {(Ii, D(Ii))}Ii∈I. The demand profile is expressed in terms of O(n) tuples, regardless of whether or not release times, deadlines, or job lengths are polynomial in n. The demand profile of an instance yields a lower bound on the optimal busy time. We can think of the cost of an instance J 's demand profile as(cid:80) Observation 4 For an instance J of interval jobs, OP T (J ) ≥ (cid:80) Ii∈I D(Ii), where I is the set of interesting Ii∈I D(Ii). intervals taken with respect to J . Proof. There are A(Ii) active jobs within an interesting interval Ii. Then any feasible solution has busy during the interval Ii. Moreover, Sp(J ) = Sp(I). (cid:108)A(Ii) (cid:109) g machines (cid:117)(cid:116) 20 4.2 A 2-approximation for busy time with interval jobs In this section, we briefly outline how the work of Alicherry and Bhatia [1] and that of Kumar and Rudra [11] for related problems imply 2-approximations for the busy time problem for interval jobs, improving the best known factor of four [5]. A detailed description can be found in Appendix A. Both the above mentioned works consider request routing problems on interval graphs, motivated by optical design systems. The requests need to use links on the graphs for being routed from source to destination, and the number of requests that can use a link is bounded. The polynomial time complexity of the algorithms crucially depends on the fact that the request (job) lengths are linear in the number of time slots; this does not hold for the busy time problem where release times, deadlines and processing lengths may be real numbers. However, even if release times and deadlines of jobs are not integral, there can be at most 2n interesting intervals, such that no jobs begin or end within the interval. The demand profile is uniform over every interesting interval. Therefore, their algorithms can be applied to the busy time problem with this simple modification, thus maintaining polynomial complexity. In order to bound the performance of their algorithms for the busy time problem, we additionally need to assume that the demand everywhere is a multiple of g. However, for an arbitrary instance, we can add dummy jobs spanning any interesting interval Ii where the raw demand A(Ii) is not a multiple of g without changing the demand profile. Specifically, if cg < A(Ii) ≤ (c + 1)g for some c ≥ 0, then DeP (Ii) = c + 1 and adding (c + 1)g − A(Ii) jobs spanning Ii does not change the demand profile. Hence, applying their algorithms to a suitably modified busy time instance of interval jobs, will cost at most twice the demand profile. Theorem 3. There exist 2-approximation polynomial time algorithms for the busy time problem on interval jobs. The approximation factor is tight. 4.3 A 3-approximation for busy time with non-interval non-preemptive jobs The busy time problem for flexible jobs was studied by Khandekar et al. [9]6. They gave a 5-approximation for this problem when the interval jobs can have arbitrary widths. For the unit width interval job case, their analysis can be modified to give a 4-approximation. As a first step towards proving the 5-approximation for flexible jobs of non-unit width, Khandekar et al. [9] prove that if g is unbounded, then the problem is polynomial-time solvable. The output of their dynamic program converts an instance of jobs with flexible windows to an instance of interval jobs, by fixing the start and end times of every job. Theorem 4. [9] If g is unbounded, the busy time scheduling problem is polynomial-time solvable. From Theorem 4, the busy time of the output of the dynamic program on the set of (not necessarily interval) jobs J (cid:48) is equal to OP T∞(J (cid:48)). Once Khandekar et al. [9] obtain the modified interval instance, they apply their 5-approximation to interval jobs of arbitrary widths to get the final bound. However, for jobs having unit width, their algorithm and analysis can be modified to apply the 4-approximation algorithm of Flammini et al. [5] for interval jobs with bounded g to get a final bound of four. Moreover, extending the algorithms of Alicherry and Bhatia [1] and Kumar and Rudra [11] to the general busy time problem, by converting an instance of flexible jobs to an interval job instance (similar to Khandekar et al. [9]) also gives a 4-approximation7. We give a 3-approximation for the busy time problem, improving the existing 4-approximation. Analogous to Khandekar et al. [9], we first convert the instance J (cid:48) to an instance J of interval jobs by running the dynamic program on J (cid:48) and then fixing the job windows according to the start times found by the dynamic program. Then we run the GREEDYTRACKING algorithm described below on J . For the rest of this section, we work with the instance J of interval jobs. Before describing the algorithm, consider the notion of a track of jobs. Definition 14. A track is a set of interval jobs with pair-wise disjoint windows. 6 In their paper, the problem is called real-time scheduling. 7 The bound of four for these algorithms is tight, as shown in the Appendix B. 21 Given a feasible solution, one can think of each bundle B as the union of g individual tracks of jobs. The main idea behind the algorithm is to identify such tracks iteratively, bundling the first g tracks into a single bundle, the second g tracks into the second bundle, etc. FIRSTFIT [5] suffers from the fact that it greedily considers jobs one-by-one; GREEDYTRACKING is less myopic in that it identifies jobs whole tracks at a time. k=1 Tk of maximum length (cid:96)(Ti) and . One can find such a track efficiently by considering the job lengths as their assigns it to bundle Bp, where p = weights and finding the maximum weight set of interval jobs with disjoint windows via weighted interval scheduling i=1 Sp(Bi). In the ith iteration, GREEDYTRACKING identifies a track Ti ⊆ J \(cid:83)i−1 algorithms [3]. Denoting by κ the final number of bundles, GREEDYTRACKING's total busy time is(cid:80)κ (cid:108) i (cid:109) g The pseudocode for GREEDYTRACKING is provided in Algorithm 1. Algorithm 1 GREEDYTRACKING. Inputs: J , g. 1: S ← J , i ← 1. 2: while S (cid:54)= ∅ do Compute the longest track Ti from S and assign it to bundle B(cid:100) i g (cid:101). 3: S ← S \ Ti, i ← i + 1. 4: 5: end while 6: Return bundles {Bp}(cid:100) i−1 g (cid:101) p=1 Theorem 5. GREEDYTRACKING is 3-approximate. Proof. By Observation 3, Sp(B1) ≤ OP T∞(J (cid:48)) ≤ OP T (J (cid:48)). Therefore, it suffices to show that(cid:80) i>1 Sp(Bi) ≤ g (cid:96)(J (cid:48)) ≤ 2OP T (J (cid:48)). We will achieve this by charging the span of bundle Bi to the mass (cid:96)(Bi−1), for i > 1. In particular, if we could identify a subset Qi of jobs in Bi with span Sp(Qi) = Sp(Bi) and with the additional property that at most two jobs of Qi are live at any point in time, then 2 Sp(Bi) = Sp(Qi) ≤ (cid:96)(Qi) ≤ 2(cid:96)(T (cid:63)) ≤ 2 g (cid:96)(Bi−1) where T (cid:63) is the first track of bundle Bi. The right-most inequality follows by the greedy nature of GREEDYTRACKING, as does the inequality preceding it: (cid:96)(T (cid:63)) is at least that of any other track in Bi and at most the average over tracks in Bi−1. To find Qi, start with jobs of Bi and remove any job Jj whose window is a subset of another job Ji's window, i.e. such that [rj, dj) ⊆ [ri, di). This can be done in polynomial time. The subset Q(cid:48) i of remaining jobs has the property i, if rj < ri, then dj ≤ di. As in the literature, instances with this structure are that for any two jobs Jj and Ji in Q(cid:48) called "proper" instances [5]. Sort jobs of Q(cid:48) i in non-decreasing order by release time. Iteratively add to subset Qi from these jobs, breaking ties in favor of jobs later in the ordering. Initially, Qi is empty. Repeat the following until Q(cid:48) i is empty: let dmax be the current maximum deadline of Qi, or 0 if Qi is empty. Consider the jobs in Q(cid:48) i that are i all but the "last" one (i.e., the one with latest deadline); move this "last" one from Q(cid:48) live at dmax. Remove from Q(cid:48) to Qi. When this process terminates, Qi will have the two properties we want. Suppose that three jobs J1, J2, J3 of i Qi were live at t with r1 ≤ r2 ≤ r3. Then at the time the process added J1 to Qi, it considered J3 as a possible "last" job, and J2 could never have been added to Qi. So, no more than two jobs of Qi are live at any point in time. Also, by construction, Sp(Qi) = Sp(Bi). (cid:117)(cid:116) Figure 6 shows that the approximation factor of 3 achieved by GREEDYTRACKING is tight. In the instance shown, a gadget of 2g interval jobs is repeated g times. In this gadget, there are g identical unit length interval jobs which overlap for  amount with another g identical unit length interval jobs. The g gadgets are disjoint from one another, which means, there is no overlap among the jobs of any two gadgets. There are 2g flexible jobs, whose windows span the windows of all the g gadgets. These jobs are of length 1 −  2. An optimal packing would pack each set of g identical jobs of each gadget in one bundle, and the flexible jobs in 2 bundles, giving a total busy time of 2g + 2 − . 22 However, the dynamic program minimizing the span does not take capacity into consideration, hence in a possible output, the flexible jobs may be packed 2 each with each of the g gadgets, in a manner such that they intersect with all of the jobs of the gadget. Hence, the flexible jobs cannot be considered in the same track as any unit interval job in the gadget it is packed with. Due to the greedy nature of GREEDYTRACKING, the tracks selected would not consider the flexible jobs in the beginning, and the interval jobs may also get split up as in Figure 7, giving a total busy time of 4(1 − )g + (2 − o())g = (6 − o())g, hence it approaches a factor 3 asymptotically. Fig. 6: Gadget for factor 3 for GREEDYTRACKING 4.4 Preemptive busy time In this section, we remove the restriction, a job needs to be assigned to a single machine. A job j needs to be assigned a total of pj time units within the interval [rj, dj) and at most one machine may be working on it at any given time. Theorem 6. For unbounded g and preemptive jobs, there is an exact algorithm to minimize busy time. Proof. The algorithm is a simple greedy one. Let J1 be the set of jobs of earliest deadline d1 and let the longest job jmax,1 in J1 have length (cid:96)max,1. We open the interval [d1 − (cid:96)max,1, d1), and for every the job j ∈ J such that [rj, dj) ∩ [d1 − (cid:96)max,1, d1) (cid:54)= ∅, we schedule it up to d1 − rj in the interval [rj, d1). Then we shrink the interval [d1 − (cid:96)max,1, d1) and adjust the windows and remaining processing lengths of the jobs in J and then repeat till all jobs in J have been completely scheduled. In the first iteration, without loss of generality, the optimal solution will also open the interval [d1 − (cid:96)max,1, d1); jmax,1 has to be scheduled completely d1 and since d1 is the earliest deadline, opening this length of interval as late as possible ensures that we can schedule the maximum length of any job in the instance J with jmax,1. The correctness (cid:117)(cid:116) follows by induction on the remaining iterations. 23 g g 1 ϵ 1 Repeated g times  2g flexible jobs, each of length 1 - ϵ/2 Fig. 7: Possible packing by GREEDYTRACKING As a consequence, one can approximate preemptive busy time scheduling for bounded g. First, solve the instance under the assumption that g is unbounded; denote by S∞ this (possibly infeasible) solution. The busy time of S∞ is OP T∞(J ), and is a lower bound on the optimal solution for bounded g. The algorithm for bounded g will commit to working on job j precisely in the time intervals where S∞ had scheduled it. Partition the busy time of S∞ into the set of interesting intervals {I1, . . . , Ik}, where k = θ(n). g (cid:101) machines in arbitrary order, filling the For every interesting interval Ii, assign the jobs scheduled in Ii to (cid:100) n(Ii) For each Ii, at most one machine contains less than g jobs, which we charge to OP T∞(J ) All other machines are machines greedily such that there is at most one machine with strictly less than g jobs. at capacity, i.e., have exactly g jobs and hence we charge them to (cid:96)(J ) g . This implies an approximation of 2. Theorem 7. There is a preemptive algorithm whose busy time is at most twice that of the optimal preemptive solution, for bounded g. References 1. Mansoor Alicherry and Randeep Bhatia. Line system design and a generalized coloring problem. In Proceedings of the 11th Annual European Symposium on Algorithms (ESA), pages 19 -- 30, 2003. 2. Jessica Chang, Harold N. Gabow, and Samir Khuller. A model for minimizing active processor time. Algorithmica, 70(3):368 -- 405, 2014. 3. Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. Introduction to Algorithms. MIT press, 2001. 4. Ulrich Faigle, R. Garbe, and Walter Kern. Randomized online algorithms for maximizing busy time interval scheduling. Computing, 56(2):95 -- 104, 1996. 5. Michele Flammini, Gianpiero Monaco, Luca Moscardelli, Hadas Shachnai, Mordechai Shalom, Tami Tamir, and Shmuel Zaks. In Proceedings of the IEEE 23rd Minimizing total busy time in parallel scheduling with application to optical networks. International Parallel and Distributed Processing Symposium, pages 1 -- 12, 2009. 24  g interval jobs 1 ϵ 1 Repeated g times Packing of flexible jobs 2 -- o(ϵ)  g interval jobs 2 flexible jobs 6. Michele Flammini, Gianpiero Monaco, Luca Moscardelli, Mordechai Shalom, and Shmuel Zaks. Approximating the traffic grooming problem with respect to adms and oadms. In Proceedings of the 14th International Euro-Par Conference on Parallel Processing, pages 920 -- 929, 2008. 7. Michele Flammini, Gianpiero Monaco, Luca Moscardelli, Mordechai Shalom, and Shmuel Zaks. Optimizing regenerator cost in traffic grooming. Theoretical Computer Science, 412(52):7109 -- 7121, 2011. 8. Michele Flammini, Luca Moscardelli, Mordechai Shalom, and Shmuel Zaks. Approximating the traffic grooming problem. In Proceedings of the 16th International Conference on Algorithms and Computation (ISAAC), pages 915 -- 924, 2005. 9. Rohit Khandekar, Baruch Schieber, Hadas Shachnai, and Tami Tamir. Minimizing busy time in multiple machine real-time scheduling. In Proceedings of the 30th Annual Conference on Foundations of Software Technology and Theoretical Computer Science (FSTTCS), pages 169 -- 180, 2010. 10. Frederic Koehler and Samir Khuller. Optimal batch schedules for parallel machines. In Proceedings of the 13th Algorithms and Data Structures Symposium (WADS), pages 475 -- 486, 2013. 11. Vijay Kumar and Atri Rudra. Approximation algorithms for wavelength assignment. In Proceedings of the 25th Conference on Foundations of Software Technology and Theoretical Computer Science (FSTTCS), pages 152 -- 163, 2005. 12. George B. Mertzios, Mordechai Shalom, Ariella Voloshin, Prudence W. H. Wong, and Shmuel Zaks. Optimizing busy time on parallel machines. In Proceedings of the IEEE 26th International Parallel & Distributed Processing Symposium (IPDPS), pages 238 -- 248, 2012. 13. Mordechai Shalom, Ariella Voloshin, Prudence W. H. Wong, Fencol C.C. Yung, and Shmuel Zaks. Online optimization of busy time on parallel machines. Theory and Applications of Models of Computation. Lecture Notes in Computer Science, 7287:448 -- 460, 2012. 14. Peter Winkler and Lisa Zhang. Wavelength assignment and generalized interval graph coloring. In Proceedings of the 14th ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 830 -- 831, 2003. A Appendix of full version: Interval Jobs A.1 Kumar and Rudra's Algorithm Here we provide an overview of the algorithm of Kumar and Rudra [11] for fiber minimization problem which implies a 2-approximation for the busy time problem on interval jobs. The fiber minimization problem is as follows. An optical fiber network needs to satisfy the given set of requests, that need to be assigned to consecutive links or edges connected in a line. There are n of these links. Each request needs some links {i, i + 1, . . . , j}, where 1 ≤ i < j ≤ n. Each segment of an optical fiber can support µ wavelengths over the consecutive links that it spans, and no two requests can be assigned the same wavelength on the same fiber, if they need to use the same link. We want a feasible assignment of the requests such that total length of optical fiber used is minimized. Notice, this is very similar to the busy time problem on interval jobs. Think of the requests as interval jobs. If a request needs the consecutive links {i, i+1, . . . , j}, where 1 ≤ i < j ≤ n, then this can be equivalently thought of as an interval job with release time i and deadline j, i.e., with a window [i, j), with processing length j − i, in a discrete setting where time is slotted. The total number of links being n, the processing lengths of the jobs here is linear. In this case, we can think of each slot as an interesting interval (since jobs begin and end only at slots) and define the demand profile as the tuples (i, D(i)), where i is a time slot in {1, . . . , n}. Their algorithm proceeds in two phases. In the first phase they assign the jobs to levels within the demand profile (where the total number of levels equals the maximum raw demand at any point), and potentially allow for a limited infeasibility in this packing. Specifically, at most two jobs can be assigned to the same level anywhere within the demand profile. In the second phase, they give a feasible packing of the jobs, considering µ levels at a time, removing the infeasibility introduced earlier, but without exceeding the cost by more than a factor of 2. This is done as follows. For levels {(i − 1)µ + 1, . . . , iµ}, (i ∈ {1, . . . , Dmax}) where Dmax is the maximum height of the demand profile), Kumar and Rudra [11] open two fibers, instead of one, and assign jobs to fibers, such that two jobs which were assigned to the same level in the demand profile, get assigned to separate fibers according to a simple parity based assignment. Their analysis assumes that the raw demand at every time slot t, A(t) is a multiple of µ and charges to such a demand profile. It is clear that the demand profile gets charged at most twice, respecting the µ capacity constraint of the fibers, and since the demand profile is a lower bound on the cost of an optimal solution, this gives a 2-approximation algorithm. The polynomial time complexity of the algorithm crucially depends on the fact that we have n links, and hence the job lengths being linear, we need to consider only a linear number of slots. The above does not hold for the busy time 25 problem for interval jobs with arbitrary release times, deadlines and processing lengths. The number of time instants to consider may not be polynomial. However, the key observation is that even if the release times and deadlines of jobs are not integral, there can be at most 2n interesting intervals, such that no jobs begin or end within the interval. The demand profile is uniform over every interesting interval. Therefore, their algorithm can be applied to the busy time problem, with this simple modification, still maintaining the polynomial complexity. The assumption regarding multiple of µ (in the busy time case, this would be g) at every slot, would translate as a multiple of g jobs over every interesting interval. However, note that for an arbitrary instance, we can add dummy jobs spanning any interesting interval Ii where the raw demand A(Ii) is not a multiple of g without changing the demand profile. Specifically, if cg < A(Ii) < (c + 1)g, for some c ≥ 0, then DeP (Ii) = c + 1, hence adding (c + 1)g − A(Ii) jobs spanning Ii does not change the demand profile. Thus we can apply their algorithm on the busy time instance, where the demand profile is defined only interesting intervals and the demand everywhere is a multiple of g. The assignments to the fibers as done by their algorithm in Phase 2, will give the bundles for the busy time problem. A.2 Alicherry and Bhatia's Algorithm Now, we describe how the work of Alicherry and Bhatia [1], implies another, elegant algorithm with a 2-approximation for interval jobs. Alicherry and Bhatia study a generalized coloring and routing problem on interval and circular graphs, motivated by optical design systems. Though the problems they consider are not directly related to the busy time problem, we can use their techniques to develop the 2-approximation algorithm. Similar to Kumar and Rudra's work, their goal is to route certain requests, which require to be assigned to consecutive links or edges in the interval or circular graph. At each link, we color the requests assigned to that link. The colors are partitioned into sets, which are ordered, such that colors in the higher numbered sets cost more. The total cost of the solution is the sum of the costs of the highest colors used at all the links, and the objective is to minimize this cost. Though this problem seems quite different from the busy time problem on interval jobs, the one of the key observations is that the cost needs to be a monotonically non-decreasing function respecting the set order. It need not be a strictly increasing function. Hence, we can think of the sets numbered in a linear order, and give each set g colors. We set the number of all the colors in a set i as i. If c · g + k requests use a link, the cost of that link would be the cost of the highest color used at the link, which is c + 1. Hence, what we are really summing is the total cost of the demand profile defined on a set of interval jobs, which have integral release times, and deadlines, and linear processing lengths, since the number of links is n (part of the input). Therefore, a 2 approximation algorithm minimizing the cost is really providing a solution that costs at most twice the demand profile of this restricted instance. The technique used involves setting up a flow graph with a certain structure, depending on the current demands or requests as yet unassigned. It can be easily proved that the graph has a cut of size at least 2 everywhere if the demand everywhere is at least 2. Now, we find a flow of size two in this graph from the source to the sink. Each flow path will consist of a set of disjoint requests or demands (where the disjointness refers to the links they need to use), and the union of the two flows will reduce a demand of at least unity from every link. This is repeated till the demand is 0 or 1 everywhere. As in Section A.1, we use the following observation: the time slots can be considered to be interesting intervals for a set of interval jobs. The busy time instance with non-polynomial job lengths and arbitrary release times and deadlines has a linear number of interesting intervals, and hence we can think of our instance in this discretized setting. Therefore, we can apply their algorithm, modified accordingly, to our problem to get a solution of cost within twice of the optimal solution. The algorithm will consider a busy time instance with the demand profile defined on interesting intervals and with a multiple of g jobs everywhere without any loss of generality. It will first open up two bundles. The flow graph is then set up as defined by Alicherry and Bhatia. For the first g iterations, the algorithm will find 2g flow paths (each consisting of disjoint interval jobs), the union of which removes at least a demand of g from everywhere. We assign g of these paths to one bundle and the remaining g to the other. Each flow path consists of disjoint jobs, hence, each bundle will have at most g jobs at time instant. Moreover, together, these bundles have removed a demand g from everywhere in the demand profile, hence they have charged the lowermost level (which is also the widest level) of the demand profile at most twice. The demand profile is now suitably modified after removing the jobs already assigned. Once again two bundles are opened, and the same procedure is performed for the next g iterations. This continues till the demand profile becomes empty everywhere, in other words, all jobs are assigned. The resultant bundles are feasible and charge the demand profile at most twice. 26 A.3 Lower bound Though the upper bound of 2 was shown by Kumar and Rudra [11] and Alicherry and Bhatia [1] for their algorithms, a lower bound on the performance of the algorithms was not provided. Here we show that for both these algorithms, the approximation ratio obtained can be arbitrarily close to 2. Figure 8 shows an instance of interval jobs, for which both the algorithms implied by the work of Kumar and Rudra and Alicherry and Bhatia approach a factor of 2 of the optimal solution. In this example, g = 2 and there are two interval jobs of length 1, one interval job of length , one of length (cid:48) < , and one of length  − (cid:48). As required by the analysis of Kumar and Rudra and Alicherry and Bhatia, the demand everywhere is a multiple of g. A possible output by both algorithms (adapted to the busy time problem as described) has cost 2 + , whereas the optimal solution has cost 1 + . For  → 0, the approximation factor approaches 2. Fig. 8: (A) An instance of interval jobs and g = 2. (B) A possible output by the algorithms of Kumar and Rudra [11] and Alicherry and Bhatia [1], of cost = 2 + . (C) The optimal solution of cost 1 + . Theorem 8. There exist 2-approximation polynomial time algorithms for the busy time problem on interval jobs. The approximation factor is tight. Proof. The proof follows from the discussions of Sections A.1, A.2, and A.3. (cid:117)(cid:116) B Appendix of full version: Flexible Jobs B.1 Prior 4-approximation In this section we discuss the busy time problem with flexible jobs. This problem was studied by Khandekar et al. [9], who refer to this problem as the real-time scheduling problem. They gave a 5-approximation for this problem when the jobs can have arbitrary widths. For the unit width jobs, their analysis can be modified to give a 4-approximation. 27 (A) (B) (C) 1 ϵ ϵ' 1 1 +ϵ' 1 ϵ ϵ -ϵ' As a first step towards proving the 5-approximation for flexible jobs of non-unit width, Khandekar et al. [9] prove that if g is unbounded, then this problem is polynomial-time solvable. The output of their dynamic program essentially converts an instance of jobs with flexible windows to an instance of interval jobs (with rigid windows), by fixing the start and end times of every job. Theorem 9. [9] If g is unbounded, the real-time scheduling problem is polynomial-time solvable. From Theorem 9, the busy time of the output of the dynamic program on the set of (not necessarily interval) jobs J is equal to OP T∞(J ). Once Khandekar et al. obtain the modified interval instance, they apply their 5-approximation algorithm for non- unit width interval jobs to get the final bound. However, for jobs with unit width, one can apply the same dynamic program to convert the instance to interval jobs and then apply the 4-approximation algorithm of Flammini et al. [5] for interval jobs with bounded g to get the final bound of 4. The 2-approximation algorithm [9] for interval instance charges the demand profile, hence it is immediately not clear how to extend it to handle flexible jobs since the demand profile cannot be defined analogous to the interval case. One possible natural extension is to follow the approach of Khandekar et al., to convert a flexible instance to an interval instance, and then apply the algorithm to this modified instance. Furthermore, the algorithm of Kumar and Rudra assumes that the demand profile everywhere is a multiple of g. Hence, after modifying the instance to an interval instance, we need to add dummy jobs accordingly to interesting intervals to bring up their demands to multiples of g. However, there exists an instance where this algorithm will approach a factor of 4 of the optimal solution. This is the worst that it can do, since we prove in the following lemma that the demand profile of the modified instance of interval jobs is at most twice the demand profile of the optimal solution (note that once the jobs have been assigned in the optimal solution, their positions get fixed, and hence the demand profile can now be computed easily). Lemma 7. The demand profile of the output of the dynamic program converting the flexible jobs to interval jobs is at most 2 times the demand profile of an optimal solution structure. Proof. The objective function of the dynamic program (Theorem 9) is to minimize the total busy time of a flexible job instance assuming g is unbounded. Since the dynamic program is optimal, it will pack as many jobs and as much length as possible together. Hence, if a job has a choice of being assigned to a spot where other jobs need to be assigned as well, then it will be assigned at that spot instead of at some other spot where no jobs need to be assigned. Therefore, at any level of the demand profile, we can charge it to the mass of the level below, and if it is the first (or, lowest) level, we charge it to OP T∞ bound. Hence, in total the optimal solution gets charged twice, once by the mass bound, and (cid:117)(cid:116) once by the span bound, giving a 2-approximation. There exists an instance of flexible jobs for which the demand profile output by the dynamic program of Khandekar et al. approaches 2 times the cost of the demand profile of the optimal solution structure. We have shown such an instance in Figure 9. The instance consists of the following types of jobs: one interval job of unit length, followed by (g− 1) disjoint sets of identical g interval jobs, where in the ith set, each job is of length 1 + i, (i ∈ {1, . . . , (g− 1)}). Apart from these, there are g − 1 flexible jobs, where the ith job is of length 1 + i, where i ∈ {1, . . . , (g − 1)} and has a feasible window spanning the the windows of the first i + 1 disjoint sets of interval jobs, as shown in the figure. An optimal solution would pack the g − 1 flexible jobs with the first interval job, and the remaining (g − 1) disjoint . The dynamic sets of identical g interval jobs in their respective windows, with a total busy time of g + program however disregards capacity constraints of the machines, and simply tries to minimize the span of the solution. Hence, with a little effort it can be seen that the unique output of the dynamic program (as shown in Figure 9) would have a span of g + g(g−1) , and the demand profile on imposing a capacity of g is of cost 2g − 1 + g(g − 1), which approaches 2 the cost of the optimal solution when  → 0. (cid:16) g(g+1) 2 − 1 (cid:17) 2 Theorem 10. A natural extension of the 2-approximation algorithm of Kumar and Rudra [11] (or the algorithm of Alicherry and Bhatia [1]) for the interval jobs problem, to the flexible jobs problem, gives an approximation of 4. This factor is tight. 28 Fig. 9: (A) An instance of interval and flexible jobs. (B)The optimal solution of busy time g + g2+g−2 of the dynamic program of Khandekar et al. [9] of busy time = 2g − 1 + g(g − 1). 2 . (C)The output 29 g 1 1 + (g-1)ϵ 1 + ϵ 1 + 2ϵ 1 + (g-1)ϵ g g 1 + ϵ 1 + 2ϵ 1 + (g-1)ϵ 1 g-1 (A) Instance of jobs (B) Optimal solution (C) Possible output generated by the dynamic program 1 + ϵ 1 +2 ϵ 1 + (g-1)ϵ 1 + ϵ 1 + 2ϵ 1 + (g-1)ϵ 1 Proof. The approximation upper bound of 4 follows from Lemma 7 and Theorem 8. However, there is a tight example as well. In this example, we have an instance of interval and flexible jobs. The instance consists of a unit length interval job, followed by g − 1 disjoint occurrences of the gadget shown in Figure 10. The gadget consists of g unit length interval jobs, 2g − 2 interval jobs of length , 2 interval jobs of length (cid:48) and 2 jobs of length  − (cid:48), as shown in the figure. There are g − 1 unit length flexible jobs, each with windows spanning the windows of the union of all of the interval jobs. Fig. 10: The gadget for the factor 4 example. On running the dynamic program to minimize span, a possible output is when each of g−1 flexible jobs are packed along with the g − 1 gadgets. For applying the algorithms of Kumar and Rudra (or Alicherry and Bhatia), we need to make sure the demand everywhere is a multiple of g. Hence we add g − 1 dummy jobs of unit length coincident with the first unit length interval job, as well as with each of the g − 1 gadgets with a flexible job. This is shown in Figure 11. Now, one possible run of the algorithm of Kumar and Rudra [11] (or Alicherry and Bhatia [1]) may result in the packing shown in Figure 12, of cost 1 + 4(g − 1) + O(). In contrast, the optimal solution packs the flexible jobs with the first unit-length interval job, and packs all the identical unit length jobs together, for a total cost of g + O(). Hence the ratio approaches 4 for large g and small . (cid:117)(cid:116) 30 2g-2 g ϵ' ϵ 1 Fig. 11: Output of the dynamic program on the instance of interval and flexible jobs for the factor 4 example. Fig. 12: Possible busy time bundling produced by a run of Kumar and Rudra's [11] or Alicherry and Bhatia's [1] algorithms on one gadget along with the flexible job and dummy jobs. 31 2g-2 g ϵ' ϵ 1 Repeated (g-1) times.  (g-1) dummy jobs flexible job (g-1) dummy jobs 1  g-2 interval jobs g-1 g-1 interval jobs interval jobs flexible job g-2 dummy jobs 1 dummy job 1 interval job 
1903.10700
2
1903
2019-05-17T05:47:35
On the tractability of the maximum clique problem
[ "cs.DS" ]
The maximum clique problem is a classical NP-complete problem in graph theory and has important applications in many domains. In this paper we show, in a partially non-constructive way, the existence of an exact polynomial-time algorithm for this problem. We outline the algorithm in pseudo-code style. Then we prove its exactness and efficiency by analysis.
cs.DS
cs
On the tractability of the maximum clique problem R. Dharmarajan1 and D. Ramachandran2 1Niels Abel Foundation, Palakkad 678011, Kerala, India. [email protected] and [email protected] 1Corresponding author Abstract The maximum clique problem is a classical NP-complete problem in graph theory and has important applications in many domains. In this paper we show, in a partially non- constructive way, the existence of an exact polynomial-time algorithm for this problem. We outline the algorithm in pseudo-code style. Then we prove its exactness and efficiency by analysis. Keywords: Maximum clique; clique number; induced subgraph; algorithm; polynomial-time. Mathematics Subject Classification: 05C69 1. Introduction The maximum clique problem (MCP) asks for a clique of the largest possible size in a given graph G. Such a clique is called a maximum clique of G, and the size of any maximum clique of G is the clique number (denoted by ω(G) ) of G. The MCP is an NP-complete problem [11]. Since it is one among a number of computational problems that are NP-hard [8], no polynomial-time exact algorithm to solve it is expected to be developed. Nevertheless, it is worthwhile to attempt algorithms for the MCP because it has a wide variety of important applications in fields such as social networking, bioinformatics, document clustering, computer vision, image processing and pattern recognition [1,7,15,21]. There are exact algorithms, approximation algorithms and heuristics for the MCP, the latter two types constituting the class of non-exact MCP algorithms. Informative surveys and reviews on algorithms for the MCP are in [1,4,16,18,25]. Exact algorithms report ω(G) (G being the input graph, or the problem instance) and a maximum clique of G. A few outstanding exact algorithms for the MCP are by Harary and Ross [10], Tarjan [19], Carraghan and Pardalos [5] and Ostergaard [14]. Tarjan and Trojanowski [20], Robson [17] and Bourgeois et al [2] gave exact algorithms for the maximum independent set problem which is an NP-complete problem computationally equivalent to the MCP [11,14]. But all the known exact algorithms for the MCP (or any of its equivalent problems) run only in exponential time, and so are not fast in solving practical instances of large sizes. Non-exact algorithms can run faster than exact ones and can return cliques of sizes approaching (or perhaps equal to) the clique number of the input instance. Many popular non-exact MCP algorithms [1,15,21,18,13,22,23,24] are based on the branch-and-bound approach. Approximation algorithms come with a provable guarantee that the optimal 1 solution is always within a multiplicative factor of the reported solution. Heuristics have no such guarantees. Non-exact algorithms can be of interest in practical applications even though none of the output cliques may be a maximum clique [1]. But such algorithms do not conclusively say anything on the gap between the reported largest clique size and the true clique number of the input graph. Though MCP algorithms are accompanied by experimental reports and discussions on their performances, very little analysis is given in support of such reports [4]. Consequently, for any algorithm, there seems to be a considerable gap between its reported capabilities and its worst-case performance. In this article we outline an algorithm (named ωMAX) for the MCP. Then, in a partially non-constructive way [3], we follow up with analysis that culminates in proving the exactness and the efficiency of the algorithm. In section 2 we give relevant definitions (and notation) from graph theory. In section 3 we establish the preliminary results essential to our proposed algorithm ωMAX. In section 4 we outline the algorithm ωMAX in pseudo-code style. In section 5 we give theory relevant to the running of ωMAX and prove its exactness. In section 6 we show our algorithm is of polynomial-time complexity. 2. Basic concepts Let V be a finite nonempty set. The cardinality (or, size) of V is denoted by V, and is the number of elements in V. The power set of V is denoted by 2V, and is the set of all the subsets of V including the empty set ϕ. The set of all nonempty subsets of V is denoted by 2V* - i.e. 2V = 2V − {ϕ}. An undirected simple graph is an ordered pair G = (V, E) where V is a finite set and E ⊆ 2V* such that (i) ⋃ X ∈ E X ⊆ V, and (ii) X ≤ 2 for each X ∈ E. The sets V and E are, respectively, the vertex set and the edge set of G. Each element of V is a vertex of G and each member of E is an edge of G. The integers V and E are, respectively, the order (= the number of vertices) and the number of edges of G. The order of G is also denoted by G. A loop is an edge X with X = 1. G is loop-free if X = 2 for each X ∈ E. If G is loop-free and {x, y} is an edge in G then x and y are the end points (or, ends) of this edge. Throughout this paper, if G = (V, E), then the expressions x ∈ V and x ∈ G will both mean x is a vertex of G; similarly, the expressions {x, y} ∈ E and {x, y} ∈ G will both mean {x, y} is an edge of G. Further, the term graph will mean an undirected simple loop-free graph. Let G = (V, E) be a graph. Two distinct vertices x and y of G are adjacent in G if {x, y} ∈ E. If x and y are adjacent in G then each of x and y is a neighbour of the other in G. For x ∈ V, the set N(x) consisting of all the neighbours of x in G is the neighbourhood of x in G. The degree of x in G is denoted by dx or by dx(G), and is defined as dx = N(x). A vertex y of G is isolated in G if dy = 0. G is null if dx = 0 for every x ∈ V. Let G1 = (V1, E1) and G2 = (V2, E2) be graphs. Then G1 is isomorphic to G2 if there is a bijective map f: V1 → V2 such that for each pair x and y of vertices of G1, {x, y} ∈ E1 if and only if {f(x), f(y)} ∈ E2. 2 In the following definitions, assume G = (V, E). A subgraph of G is a graph J = (W, F) such that: (i) W ⊆ V, (ii) F ⊆ E and (iii) each edge of J has the same end points in J as in G. A subgraph J = (W, F) is a proper subgraph of G if either W ≠ V or F ≠ E. If A ⊆ V then the subgraph induced by A is the subgraph G[A] = (A, E[A]) where E[A] is the set of all those edges {x, y} ∈ E such that x ∈ A and y ∈ A. In particular, if a ∈ V then the subgraph induced by V − {a} will be denoted by G − a. G is complete if all of its vertices are pairwise adjacent - i.e. {x, y} ∈ E whenever x, y ∈ V and x ≠ y. A clique of G is a nonempty set M ⊆ V such that G[M] is complete - i.e. {x, y} ∈ E whenever x and y are distinct elements of M. M is a maximal clique of G if (i) M is a clique of G and (ii) M is not a proper subset of any clique of G. M is a maximum clique of G if (i) M is a clique of G and (ii) M ≥ S for every clique S of G. A graph has a maximum clique though such a clique is not necessarily unique. Obviously, if M1 and M2 are maximum cliques of G then M1 = M2. If M is a maximum clique of G then the positive integer M is the clique number (ω(G)) of G. If G is null then ω(G) = 1. 3. Preliminaries Throughout this section, G = (V, E) and G ≥ 2 are assumed. Proposition 3.1. Let W be a nonempty proper subset of V. If M is a clique of G such that M ⊆ W then M is a clique of the induced subgraph G[W] of G. Proof. Let x and y be distinct vertices in M. Then the edge {x, y} is in G[W] because the end points of this edge (x and y) are in W. ■ Corollary 3.2. Let a ∈ V and M be a clique of G such that a ∉ M. Then M is a clique of the subgraph G − a. Proof. The graph G − a is the induced subgraph G[W] where W = V − {a} . Also, M ⊆ W. The conclusion now follows from proposition 3.1. ■ Proposition 3.3. ω(G) ≥ ω(G − a) for every a ∈ V. Proof. Every clique of G − a is a clique of G. ■ Proposition 3.4. Suppose x and y are any two distinct non-adjacent vertices of G. Then either ω(G) = ω( G − x ) or ω(G) = ω( G − y ). Proof. Let ω(G) = r, ω( G − x) = p and ω(G − y ) =q. By proposition 3.3, r ≥ p and r ≥ q. We assert that either r = p or r = q. Let M be any maximum clique of G. Then M = r. Since x and y are non-adjacent in G, either x ∉ M or y ∉ M. Here we invoke Corollary 3.2. If x ∉ M then M is a clique of G − x and so M ≤ p. If y ∉ M then M is a clique of G − y and so M ≤ q. So either r ≤ p or r ≤ q, whence either r = p or r = q. ■ Corollary 3.5. Suppose G is not complete. Then ω(G) = ω(G − a) for some vertex a of G. 3 (←) If M is not maximal, then M ∪ {x \} is a clique of G for some x ∈ V − M. So x is Corollary 3.6. If x and y are distinct non-adjacent vertices of G then ω(G) = ω(G − x) ⋁ ω( G − y), where r1 ⋁ r2 denotes the larger of two given real numbers r1 and r2. Corollary 3.7. If G is not complete then for some vertex a of G, every maximum clique of G − a is also a maximum clique of G. Proposition 3.8. Let M be a clique of G. Then M is a maximal clique if and only if to each x ∈ V − M there exists y ∈ M such that x and y are not adjacent. Proof. (→) Assume M is a maximal clique. Let x ∈ V − M be given. If x were adjacent to each vertex in M then M ∪ {x} would be a clique in G, contradicting the maximality of M. adjacent to every vertex in M. ■ Proposition 3.9. Let W be a nonempty proper subset of V and let J = (W, F) be the subgraph (of G) induced by W. Let x ∈ V − W and suppose x is adjacent to every vertex of J. Let H be the subgraph induced by W ∪ {x}. Then: (i) ω(H) = ω(J) + 1. (ii) Suppose M ⊆ W. Then M ∪ {x} is a maximum clique of H if and only if M is a maximum clique of J. Proof. (i) Obviously x is adjacent to every vertex of J. Let ω(J) = p and M be a maximum clique of J. Then M = p, x ∉ M and M ∪ {x} is a clique of H. So ω(H) ≥ p + 1. If H had a clique of size p + 2 then H − x would have a clique of size at least p + 1. This, in view of H − x being isomorphic to J, contradicts ω(J) = p. This proves (i). (ii) Clearly x ∉ M. Assume M ∪ {x} is a maximum clique of H. Let M ∪ {x} = p + 1. Then ω(H) = i + 1. Also, M is a clique of J. If J had a clique S such that S > M then S ∪ {x} would be a clique of H owing to x being adjacent to every vertex of J. This would mean ω(H) ≥ S ∪ {x} > p + 1, patently contradicting ω(H) = p + 1. Hence M is a maximum clique of J. Conversely, suppose M is a maximum clique of J and M = p. Then clearly M ∪ {x} is a clique of H. If H were to have a clique S of size exceeding p + 1 then S − {x} would be a clique of J of size exceeding p, an impossibility. Further, M ∪ {x} = p + 1. ■ Proposition 3.10. Upto isomorphism, there is only one graph G = (V, E) such that V = 3 and E = 1. Proof. Let V = {x, y, z} and E consist of the edge {x, y}. Let J = (W, F) be any graph with order 3 and exactly one edge. Let W = {a, b, c} and F consist of the edge {a, b}. Then the map h: G → J defined by h = {(x, a), (y, b), (z, c)} is an isomorphism of G onto J. ■ Proposition 3.11. Upto isomorphism, there is only one graph G = (V, E) such that V = 3 and E = 2. Proof. Let V = {x, y, z} and E consist of the two edges {x, y} and {x, z}. Let J = (W, F) be any graph with order 3 and exactly two edges. Let W = {a, b, c} and F consist of the two 4 edges {a, b} and {a, c}. Then the map h: G → J defined by h = {(x, a), (y, b), (z, c)} is an isomorphism of G onto J. ■ 4. The proposed algorithm ω MAX The principal idea behind this algorithm is Proposition 3.4: if G is not complete then ω(G) = ω( J) for some proper subgraph J of G. Input: The vertex set V and the edge set E of a graph G = (V, E). Pre-processing (i) Compute the adjacency list of G (ii) Compute the adjacency matrix of G (iii) Go to the main algorithm The main algorithm BEGIN with (1) (1) (i) Compute n = V and e = E ; (ii) order the vertices of G as x1, . . ., xn where dxj ≥ dxj + 1 for j = 1, . . ., n − 1 and (iii) Ver = [x1, . . ., xn] ; go to (2) (2) If e = n(n − 1) / 2 then output: (i) ω(G) = n and (ii) the only maximum clique of G is V and END, else go to (3) (3) If e = 0 then output: (i) ω(G) = 1 and (ii) the only maximum cliques of G are the singleton subsets of V and END, else go to (4) (4) LC(STORED) = {x1} ; ω(STORED) = 1 and r = 2; go to (5) (5) W = [Ver(1), . . ., Ver(r)] ; go to (6) (6) If the last element, say z, of W is adjacent to every other element of W then ω(STORED) ← ω(STORED) + 1 and LC(STORED) ← LC(STORED) ∪ {z} and go to (7) else go to (8) (7) r ← r + 1 and return to (5) (8) Let m be the largest index (≤ r − 1) such that xm ∈ W and xm is not adjacent to the last element of W; go to (9) (9) (i) Let S = [W(1), . . ., W(m − 1), W(m + 1), . . ., W(r)] ; go to (10) (10) j = 1; go to (11) (11) IP = S; OP = ϕ; go to (12) (12) Lead = IP(1) ; OP ← [OP, Lead]; RevIP = ϕ; go to (13) (13) k = IP ; go to (14) (14) if k > 1 got to (15), else go to (16); (15) for a = 2 to k if IP(a) is adjacent to Lead then RevIP ← [RevIP, a] else end end for; go to (16) (16) if RevIP = ϕ then go to (18) else go to (17); (17) IP ← RevIP and go to (12) 5 (18) ω(CURRENT) = OP ; go to (19) (19) If ω(CURRENT) > ω(STORED) then ω(STORED) ← ω(CURRENT) and LC(STORED) ← OP else end; go to (20) (20) j ← j + 1; go to (21) (21) If j ≤ S then S ← [S( 2), . . ., S(r − 1), S(1)] and go to (11) else r ← r + 1 and go to (22) (22) if r ≤ n go to (5) else go to (23) (23) OUTPUT: (i) ω(G) = ω(STORED) and (ii) LC(STORED) is a maximum clique of G END Remark. The notation S ← [S( 2), . . ., S(r − 1), S(1)] in step (21) of the pseudo-code is a cyclic permutation of the current S. It results in the current S being replaced by 𝜎(S) where 𝜎 is the permutation defined on the set {1, . . ., k} by 𝜎(i) = i + 1 for i = 1, . . ., k − 1 and 𝜎(k) = 1. 5. Proof of the exactness of ω MAX A few definitions and notations are needed to discuss the feasibility and capabilities of ωMAX. Let X be a nonempty finite set and X = n. An ordered set (or, an ordered r-set) over X is a 1 x r matrix P = [x1, . . ., xr] where (i) 0 ≤ r ≤ n, (ii) xj ∈ X for j = 1, . . ., r and (iii) if xj, xk ∈ X with 1≤ j < k ≤ r then xj ≠ xk. The set X is the base set for P. The integer r is the cardinality (or, size) of P. As with unordered sets, P denotes the size of the ordered set P. If r = 0 then P is the empty ordered set (ϕ) over X. An ordered r-set will be referred to as an ordered set unless the mention of r is warranted. An ordered set over X will be referred to as an ordered set if X is understood from the context. The empty ordered set will be called the empty set. If P = [x1, . . ., xr] is an ordered set over X and x ∈ X then x ∈ P if and only if x = xj for some j with 1 ≤ j ≤ P . For j ∈ {1, . . ., r}, P(j) will denote the jth element of P (which is xj). Let P1 and P2 be two ordered sets over X. Write P1 = [x1, . . ., xk] and P2 = [y1, . . ., yr]. Then P1 = P2 if and only if (i) k = r and (ii) xj = yj for j = 1, . . ., k. If P = [x1, . . ., xr] is an ordered set over X, y ∈ X and y ∉ P then the augmentation of P by y (or, the y- augumentation of P) is denoted by [P, y] and is defined to be the ordered set [x1, . . ., xr, y]. In the algorithm ωMAX, the first iteration begins when r is assigned the value 2 in step (4) of the pseudo-code. It ends when r ← r + 1 is executed, which happens in step (7) or step (21) according as the control is directed to. This is also where the second iteration begins. In general, the ith iteration begins when step (7) or (21) does the assignation r ← r + 1. By (4) and (22) it is clear that there are exactly n − 1 iterations (corresponding to r = 2 through n) if the input graph has order n. From the beginning of an iteration to its end, the value of r is constant. In each iteration, there are sub-iterations corresponding to j = 1 through S. It is clear from steps (5) and (9) that S = r − 1. Hence if an iteration corresponds to r = k then this iteration consists of k − 1 sub-iterations. The total number of sub-iterations in the algorithm is, then, 1 + . . . + n − 1 which is n(n − 1) /2. 6 Proposition 5.1. The sets Ver, W, S, IP, RevIP and OP are all ordered sets over the base set V, the vertex set of the instance graph G. Proof. Ver = [x1, . . ., xn] is an ordered set over V, from (1)(iii) of the pseudo-code of ωMAX. So are W and S, from (5) and (9), respectively. (11) makes it clear that IP is an ordered set over V. (12) and (15) show, respectively, that OP and RevIP are ordered sets over V. ■ Steps (4) through (9) clearly involve only finitely many computations. So do (20) In ωMAX, if A is an ordered set and m is a positive integer, then A(m) will denote the mth element of A. For instance, W(m − 1) in step 9 is the (m -- 1)th element of W, and IP(1) in step 12 is the first element of IP. Proposition 5.2. The algorithm ωMAX terminates in a finite number of computations. Proof. The pre-processing phase of the ωMAX terminates in finitely many computations because V and E are finite sets. Let n be the order of the input graph G. If G is null or complete, then the running of ωMAX begins with step (1) and terminates with either step (2) or step (3). Each of these steps executes only a finite number of computations. So suppose G is neither null nor complete. through (23). The first iteration begins when r = 2 and the last iteration begins when r = n. For each r = 2, . . ., n, the first sub-iteration begins when j = 1 and the last subiteration begins when j = S = r − 1. For each j, the loop in (15) is executed k − 1 times for k > 1, where k = IP. But then by (15) and (17), the value of k decreases by at least 1 every time the control returns to (12), and so k = 1 happens in a finite number of computations. Hence (15) is done only finitely many times. Also, the steps (11) through (14) and (16) through (19) all depend on IP. Since RevIP = ϕ must happen when k = 1, it follows that (11) through (14) and (16) through (19) all involve only a finite number of computations. Consequently, ωMAX executes only finitely many computations for each r = 2, . . ., n. and (23), it is clear that the algorithm terminates when r = n + 1. ■ Next, by (21) it is clear that r = n + 1 happens after finitely many iterations. By (22) The ordered set OP obained at the end of a sub-iteration is called the ordered output set from this sub-iteration, or, simply, an ordered output set, if the ordinal of the sub-iteration need not be mentioned. An ordered output set will be denoted by OOS. Proposition 5.3. If OP = [y1, . . ., yk] is an OOS, then the vertex yj is adjacent to each of yj + 1 through yk for each j = 1, \ . . ., k − 1. Proof. Suppose there were yp, yt ∈ OP (1 ≤ p < t ≤ k) with yp not adjacent to yt. Since yp is in OP, it happened that Lead = yp at some point of the sub-iteration under consideration. Then when (15) is executed in this sub-iteration, yt would not be included in RevIP. Then yt would not be in IP at any subsequent point in this sub-iteration, and so yt would not be in OP at the end of this sub-iteration. But this contradicts yt ∈ OP. ■ 7 Proposition 5.4. Let OP= [y1, . . ., yt] be an OOS. If x ∈ V and x ∉ OP, then x ∉ N(yj) for some yj in OP. Proof. Note that OP = t. Clearly x was not Lead at any point - else x would be in OP by dint of (12). Next, if it were true that x ∈ N(yj) for every yj ∈ OP, then when Lead = yt, we would subsequently have x ∈ RevIP, and so RevIP ≠ ϕ. Then there would be a subsequent computation in which Lead = yq for some yq ∈ RevIP and q > t, with yq ≠ x. This would entail yq ∈ OP at the end of the iteration, thereby giving yj ∈ OP for j = 1, . . ., t, q, leading to OP > t, a patent contradiction. ■ Corollary 5.5. Let OP= [y1, . . ., yt] be an OOS at the end of a sub-iteration. If x ∈ V and x ∉ OP then for some z ∈ OP, x was not augmented to RevIP at some point during the sub- iteration when Lead = z. Proof. If the conclusion were not true for any z ∈ OP at the end of the sub-iteration, then x would be a neighbour of each vertex of OP. But then x would consequently be in OP, contradicting x ∉ OP. ■ Proposition 5.6. Let OP= [y1, . . ., yt] be an OOS. Then then the set M = {y1, . . ., yt} is a maximal clique of G. Proof. If yi and yj are in OP where i ≠ j, then yi is adjacent to yj by proposition 5.1. So M is a clique of G. Next, let x ∈ V − M be given. Let OP be the OOS at the end of a sub-iteration. Since x ∉ OP, x was excluded form RevIP by some vertex z in a computation subsequent to Lead = z during the sub-iteration. Clearly, then, z and x are not neighbours. Further, since Lead = z during this sub-iteration, we have that z ∈ OP at the end of this sub-iteration, whence z = yp for some p ∈ {1, . . ., t}. So x is not adjacent to the vertex in yp ∈ M. By dint of proposition 3.8, M is a maximal clique of G. ■ Proposition 5.7. If G = (V, E) is complete or null, then ωMAX returns ω(G) and a maximum clique in G. Proof. Let n = V and e = E. Suppose G is complete. Then e = E = n(n − 1) /2. The algorithm checks this to be true - from steps (1) and (2) - and reports: (i) ω(G) = n and (ii) V is the only maximum clique of G. Suppose G is null. Then e = 0. The algorithm checks this to be true - from steps (1) and (3) - and reports: (i) ω(G) = 1 and (ii) the only maximum cliques of G are the singleton subsets of V. ■ Proposition 5.8. Let G = (V, E) be of order 3. The algorithm ωMAX returns the clique number of G and a maximum clique of G. Proof. Let V = {x, y, z}. If G is complete then ωMAX runs on G as follows: (1) n = 3; e = 3 (2) e = n(n − 1) / 2; so report: (i) ω(G) = 3 and the only maximum clique of G is V . (1) n = 3; e = 0 If G is null then ωMAX runs on G as follows: 8 (2) e = 0, so report: (i) ω(G) = 1 and the maximum cliques of G are the singleton subsets of V. If G is neither complete nor null, then G has at least one edge and at most two edges. Case 1. Suppose E is the set consisting of one edge - say, {x, y}. Here Ver = [x, y, z] in accordance with (ii) and (iii) of step (1) of the pseudo-code, since dx = dy = 1 and dz = 0. Then ωMAX runs on G as follows (with each right arrow denoting the passing from one computation to the logical next): n = 3 → e = 1 → e ≠ 0 → e ≠ n( n − 1) /2 → LC(STORED) = {x} → ω(STORED ) = 1 → r = 2 → W = [x, y] → ω(STORED) = 2 → LC(STORED) = {x, y} → r = 3 → W = [x, y, z] → S = [x, z] → j = 1 → IP = [x, z] → OP = ϕ → Lead = x → OP = [x] → RevIP = ϕ → k = 2 → ω(CURRENT) = 1 → j = 2 → S = [z, x] → IP = [z, x] → OP = ϕ → Lead = z → OP = [z] → RevIP = ϕ → k = 2 → ω(CURRENT) = 1 → j = 3 → r = 4 → ω(G) = 2 → a maximum clique of G is {x, y} → END. Case 2. Suppose E consists of two edges - say, {x, y} and {x, z}. Here Ver = [x, y, z] since dx = 2 and dy = dz = 1. Then ωMAX runs on G as follows: n = 3 → e = 2 → e ≠ 0 → e ≠ n( n − 1) /2 → LC(STORED) = {x} → ω(STORED) = 1 → r = 2 → W = [x, y] → ω(STORED) = 2 → LC(STORED) = {x, y} → r = 3 → W = [x, y, z] → S = [x, z] → j = 1 → IP = [x, z] → OP = ϕ → Lead = x → OP = [x] → RevIP = ϕ → k = 2 → RevIP = [z] → IP = [z] → Lead = z → OP = [x, z] → RevIP = ϕ → k = 1 → ω(CURRENT) = 2 → j = 2 → S = [z, x] → IP = [z, x] → OP = ϕ → Lead = z → OP = [z] → RevIP = ϕ → k = 2 → RevIP = [x] → IP = [x] → Lead = x → OP = [z, x] → RevIP = ϕ → k = 1 → ω(CURRENT) = 2 → j = 3 → r = 4 → ω(G) = 2 → a maximum clique of G is {x, y} → END OUTPUT: ω(G) = 2 and {x, y} is a maximum clique of G. Thus, when G has order n = 3, ωMAX returns ω(G) and a maximum clique of G. ■ Proposition 5.9. Let G = (V, E) be of order n. Then there is a linear ordering of vertices of G for which ωMAX returns ω(G) and a maximum clique of G, by returning ω(J) and a maximum clique of J for some subgraph J of G such that ω(G) = ω(J). In other words, ωMAX converges to a desired output, which is a pair (ω(G), M) where M is a maximum clique of G. Proof. Let the proposition be called P(n). The proof is by induction on n. The proof for n = 3 was done by proposition 5.8. Assume P(k) is true. Next, suppose n = k + 1. If G is complete then, by proposition 5.7, ωMAX returns (i) ω(G) = k + 1 and (ii) V is the only maximum clique of G. If G is null then, again by proposition 5.7, the algorithm returns (i) ω(G) = 1 and (ii) the only maximum cliques of G are the singleton subsets of V. In both these cases the subgraph J in the statement of the current proposition is G. So P(k + 1) is true when G is complete or null. Suppose G neither complete nor null. Then G has two vertices - say, a and b - that are not neighbours in G. Clearly G − a and G − b have order k. By the induction hypothesis, there is a linear vertex ordering in G − a and one in G − b for which ωMAX returns the following: 9 (i) ω(G − a) = r1 (say), (ii) a maximum clique M1 of G − a, (iii) ω(G − b) = r2 (say) and (iv) a maximum clique M2 of G − b. Here M1 = r1 and M2 = r2. Let r = r1 ⋁ r2. By corollary 3.6, ω(G) = r. Further, either M1 or M2 is a clique of size r - and hence a maximum clique of G. But then ω MAX has returned r and a clique M (=M1 or M2) that are respectively ω(G) and a maximum clique of G. The required subgraph J in the current proposition is either G − a (if r = r1) or G − b (if r = r2). And the required linear ordering of vertices of G is the one in G − a (if r = r1) or the one in G − b (if r = r2). This completes the induction. ■ 6. The worst-case time complexity of ωMAX The worst-case time complexity of ωMAX is discussed using the asymptotic growth rate function O (big oh). The term time complexity will mean the worst-case one, throughout this section. Primitive computational steps. Throughout this section, by the phrases "(*) is bounded by time O(nd)" and "(*) takes O(nd) time," we will mean that there are absolute constants c > 0 and d > 0 so that on every input graph of order n, the running time of the process in the place of (*) is bounded by cnd primitive computational steps ([12], chapter 2). The following are the primitive computational steps in ωMAX: (p-c 1) Assigning a value to a variable; (p-c 2) placing a new element at the end of a list of elements; (p-c 3) reading an element from a list; and (p-c 4) any of the four fundamental operation on real numbers. Further, the term "instance" in this section will mean an input graph. For each instance, steps (1) through (4) of ωMAX are run once, and so is step (23). Steps (5) through (9) are run at most n times each. Steps (10) through (22) are run at most n2 times each. In the algorithm, the positive integer r ranges from 2 to n (the order of the input instance) and each value of r corresponds to an iteration. The computation of the adjacency matrix is bounded by time O(n3); so is the computation of the adjacency list. Consequently the pre-processing phase of ωMAX is bounded by O(n3) time. In the following analysis of the main algorithm phase of ωMAX, the time complexity of steps (1) through (4) and (23) are for one instance and that of steps (5) through (22) are for an arbitrary iteration. In step (1) of the pseudo-code (section 4), computing V takes O(n) time whereas computing E takes O(n2) time. Next, computing the ordered set Ver takes O(n) time. Hence step (1) is bounded by time O(n2). Step (2) is bounded by time O(n); so is (3). If G is neither complete nor null then the control goes to (4). The assignations ω(STORED) = 1 and LC(STORED) = {x1} require time O(1) each. Hence steps (1) through (4) are bounded by time O(n2). Step (5) is bounded by O(n) since it is a finite sequence of primitive computational step of the type (p-c 2) seen above. In step (6), checking if Ver(r) is adjacent to any other element of W can be done in O(n) time using the adjacency matrix. The assignations seen in (6) are bounded by time O(n). (7) obviously requires only constant time. Finding an element 10 xm as in (8) is done using the adjacency matrix, and so (8) is bounded by O(n2). (9) is similar to (5) and so is bounded by O(n). Obviously (10), (11) and (12) require only constant time. (13) is bounded by O(n) since IP ≤ n. (14) is done in constant time. Whether a is adjacent to Lead is determined by checking the adjacency matrix for an edge connecting Lead and a. This can be done in constant time ([12], chapter 3). Further, k ≤ n − 1. So each time the for loop in (15) is executed fully, there are at most ∑(n − 1) computational steps, each of constant time. In each iteration, (15) is run at most n times. Hence (15) is bounded by time O(n3). In (16), the algorithm needs to access only the first element of RevIP (if there is one). So (16) takes O(1) time. (17) is bounded by time O(n); so is (18). In (19), the logical operation requires constant time, as does the assignation ω(STORED) ← ω(CURRENT). The other assignation LC(STORED) = OP is bounded by time O(n) . So (19) takes time O(n). It is clear that (20) is done in O(1) time. Next, (21) is bounded by time O(n) whereas (22) and (23) are each bounded by O(1) time. Hence each iteration is bounded by time O(n3). Since there are n − 1 iterations for each instance (corresponding to r = 2 through n), the time complexity of ωMAX is O(n4). 7. An example and some comments Let G = (V, E) be the graph with V = {1, 2, 3, 4, 5, 6, 7}. The adjacency list of G is: (i) N(1) = {2, 3, 4}, (ii) N(2) = {1}, (iii) N(3) = {1}, (iv) N(4) = {1} , (v) N(5) = {6, 7}, (vi) N(6) = {5, 7} and (vii) N(7) = {5, 6}, where N(x) denotes the neighbourhood (in G) of the vertex x ∈ G. The vertices of G in a non-ascending order of degrees are: 1, 5, 6, 7, 2, 3, 4. In the following steps, the numbering (1) through (9) is not connected with that in the pseudo-code of ωMAX. The arrows (→) indicate the sequence of computations. BEGIN with (1) (1) n = V = 7, e = E = 6 and Ver = [1, 5, 6, 7, 2, 3, 4] . Go to (2). (2) ω(STORED) = 1 and LC(STORED) = {1}. Go to (3). (3) r = 2 → W = [1, 5] → S = [5] → j = 1 → ω(CURRENT) = 1 → j = 2. Go to (4). (4) r = 3 → W = [1, 5, 6] → S = [5, 6] → j = 1 → ω(CURRENT) = 2 → ω(STORED) = 2 → LC(STORED) = {5, 6} → j = 2 → ω(CURRENT) = 2 → j = 3. Go to (5). (5) r = 4 → W = [1, 5, 6, 7] → S = [5, 6, 7] → j = 1 → ω(CURRENT) = 3 → ω(STORED) = 3 → LC(STORED) = {5, 6, 7} → j = 2 → ω(CURRENT) = 3 → j = 3 → ω(CURRENT) = 3 → j = 4. Go to (6). 11 (6) r = 5 → W = [1, 5, 6, 7, 2] → S = [1, 5, 6, 2] → j = 1 → ω(CURRENT) = 2 → j = 2 → ω(CURRENT) = 2 → j = 3 → ω(CURRENT) = 2→ j = 4 → ω(CURRENT) = 2 → j = 5. Go to (7). (7) r = 6 → W = [1, 5, 6, 7, 2, 3] → S = [1, 5, 6, 7, 3] → j = 1 → ω(CURRENT) = 2 → j = 2 → ω(CURRENT) = 3 → j = 3 → ω(CURRENT) = 3 → j = 4 → ω(CURRENT) = 3 → j = 5 → ω(CURRENT) = 2 → j = 6. Go to (8). (8) r = 7 → W = [1, 5, 6, 7, 2, 3, 4] → S = [1, 5, 6, 7, 2, 3] → j = 1 → ω(CURRENT) = 2 → j = 2 → ω(CURRENT) = 3 → j = 3 → ω(CURRENT) = 3 → j = 4 → ω(CURRENT) = 3 → j = 5 → ω(CURRENT) = 2 → j = 6 → ω(CURRENT) = 2 → j = 7. Go to (9). (9) r = 8 → ω(G) = 3 and {5, 6, 7} is a maximum clique of G. END Comments on Propositions. Propositions 3.1 and 3.3 are important to establish proposition 3.4. Proposition 3.4 proves that for a given graph G = (V, E) that is not complete, there is a proper subgraph J such that ω(G) = ω(J). This is crucial to ωMAX because the required subgraph J is either G − x or G − y, where x and y are any two non-adjacent vertices of G. Inherent in the algorithm is the existence of a linear ordering of the elements of some nonempty subset W of V. The ωMAX returns an optimal solution under this linear ordering of the elements of W. Such an ordering is explicit in the proof of proposition 5.8 and implicit in the proof of proposition 5.9. Proposition 5.9 proves the exactness of ωMAX - i.e. for a given instance G, ωMAX does return ω(G) and a maximum clique of G. Propositions 5.7 and 5.8 are essential to proposition 5.9. The propositions 5.1 through 5.6 of section 5 prove the feasibility and some capabilities of ωMAX. The non-constructive facet of ω MAX. Since ω(G) is known for every graph G of order 3, the proof of proposition 5.8 (the base case for our induction) was straightforward. However, in the proof of proposition 5.9, it is reasoned that there exists an ordering of vertices of G for which ωMAX returns ω(G), but such an order is not constructed explicitly here. This linear vertex ordering is the only aspect of ωMAX that is not explicit, which is the reason we deem ωMAX partially non-constructive. 8. Concluding remarks We have presented an exact polynomial-time algorithm for determining ω(G) of a given graph G. The independence number and the vertex cover number of a given graph G can be found by applying ωMAX on the complement graph [15] of G. We have not reported any experimentation with ωMAX because we have analytically proved its exactness and efficiency (in sections 5 and 6, respectively). 12 To sum up: (i) there exists an exact polynomial-time algorithm for the MCP for all graphs of order 3 (Proposition 5.8) and (ii) if this algorithm returns ω(G) for all graphs of G order k then the algorithm returns ω(G) for all graphs G of order k + 1 (Proposition 5.9). Hence there exists an exact polynomial-time algorithm (ωMAX) for the MCP for all graphs of order n ≥ 3. Symbolically: (i) P(3) is true and (ii) P(k + 1) is true whenever P(k) is true; hence P(n) is true for all n ≥ 3. Thus, the MCP is tractable. For an account of tractability of problems, we refer the reader to [3,6,9,12]. Acknowledgements This research was fully supported by Niels Abel Foundation, Palakkad, Kerala State, India. The authors thank Dr. K. Kannan, Professor of Mathematics with SASTRA University (Thanjavur, India) and Dr. V. Swaminathan, Assistant Professor of Mathematics with SASTRA University SRC (Kumbakonam, India) for discussions and their suggestions on analysing algorithms. References [1] I. M. Bomze, M. Budinich, P. M. Pardalos, M.Pelillo, The maximum clique problem, Handbook of Combinatorial Optimization 4 (1999) 1-74. Doi.10.1.1.56.6221 [2] N. Bourgeois, B. Escoffier, V. T. Paschos, J. M. M. van Rooij, Fast Algorithms for max independent set, Algorithmica 62(1) (2012) 382-415. [3] D. P. Bovet and P. Crescenzi, Introduction to the theory of complexity, Creative Commons Attribution - NonCommercial 2.5, Citeseer (2006). [4] R. Carmo and A. Zuge, Branch and bound algorithms for the maximum clique problem under a unified framework. J. Braz. Comput. Soc. 18(2) (2012) 137-151. Doi: 10.1007/s13173-011-0050-6 [5] R. Carraghan, P. M. Pardalos, An exact algorithm for the maximum clique problem, Oper. Res. Lett. 9(6) (1990) 375-382. [6} T. H. Cormen, C. E. Leiserson, R. L. Rivest, C. Stein, Introduction to Algorithms (MIT Press, 2009). [7] D. Eppstein, M. Loffler, D. Strash, Listing all maximal cliques in sparse graphs in near- optimal time, in Proc. Intl. Symp. on Algorithms and Computation, LNCS 6506 (Springer, 2010), pp. 403-414. 13 [8] M. R. Garey, D. S. Johnson, Computers and Intractability: A guide to the Theory of NP- completeness, Computers and Intractability 340 (1979). [9] S. H. Gerez, Algorithms for VLSI Design Automation (John Wiley and Sons, 1999). [10] F. Harary, I.C. Ross, A Procedure for Clique Detection Using the Group Matrix, Sociometry 20(3) (1957) 205-215. [11] R. Karp, Reducibility among Combinatorial Problems, in Complexity of Computer Computations (Springer, 1972), pp. 85-103. [12] J. Kleinberg, E. Tardos, Algorithm Design (Pearson Education, 2006). [13] J. Konc, D. Janezic, An improved branch and bound algorithm for the maximum clique problem, MATCH Commun. Math. Comput. Chem. 58(3) (2007) 569-590. [14] P. R. J. Ostergard, A fast algorithm for the maximum clique problem, Discrete Appl. Math. 120 (2002) 197-207. [15] P.M. Pardalos, J. Xue, The maximum clique problem, J. Global Optim. 4(3) (1994) 301- 328. [16] P. Prosser, Exact Algorithms for Maximum Clique: A Computational Study, Algorithms 5(4) (2012) 545-587. [17] J. M. Robson, Algorithms for maximum independent sets, J. Algorithms 7(3) (1986) 425-440. [18] K. Singh, A. K. Pandey, Survey of Algorithms on Maximum Clique Problem, Int. Advanced Research J. in Sci., Eng. and Tech. 2(2) (2015) 15-20. 19] R. E. Tarjan, Finding a maximum clique, Technical Report TR 72 - 123 (1972), Computer Science Department, Cornell University, Ithaca, New York. [20] R. E. Tarjan, A. E. Trojanowski, Finding a maximum independent set, SIAM J. Comput. 6(3) (1977) 537-546. [21] E. Tomita, T. Akutsu, T. Matsunaga, Efficient Algorithms for Finding Maximum and Maximal Cliques: Effective Tools for Bioinformatics, in Biomedical Engineering, Trends in Electronics, Communications and Software (2011) 625-640. [22] E. Tomita, T. Kameda, An efficient branch-and-bound algorithm for finding a maximum clique with computational experiments, J. Glob. Optim. 37(1) (2007) 95-111. Doi: 10.1007/s10898-006-9039-7 14 [23] E. Tomita, T. Seki, An efficient branch-and-bound algorithm for finding a maximum clique, in Discrete Mathematics and Theoretical Computer Science, LNCS 2731 (Springer, 2003), pp. 278-289. [24] E. Tomita, Y. Sutani, T. Higashi, M. Wakatsuki, A simple and faster branch-and-bound algorithm for finding a maximum clique with computational experiments, IEICE Trans. Inf. \& Syst. 96(6) (2013) 1286-1298. [25] Q. Wu, J. Hao, A review on algorithms for maximum clique problems, European J. Oper. Res. 242(3) (2015) 693-709. ___________________________________________________________________________ © R. Dharmarajan, Niels Abel Foundation, 7 / 538, 'Vidhyashree', Karekkaattu Parambu, Ambikapuram (P.O.), Palakkad 678011, Kerala, India. 15
1812.03572
1
1812
2018-12-09T23:01:26
Rounding semidefinite programs for large-domain problems via Brownian motion
[ "cs.DS" ]
We present a new simple method for rounding a semidefinite programming relaxation of a constraint satisfaction problem. We apply it to the problem of approximate angular synchronization. Specifically, we are given directed distances on a circle (i.e., directed angles) between pairs of elements and our goal is to assign the elements to positions on a circle so as to preserve these distances as much as possible. The feasibility of our rounding scheme is based on properties of the well-known stochastic process called Brownian motion. Based on computational and other evidence, we conjecture that this rounding scheme yields an approximation guarantee that is very close to the best-possible guarantee (assuming the Unique-Games Conjecture).
cs.DS
cs
Rounding semidefinite programs for large-domain problems via Brownian motion Kevin L. Chang∗ Alantha Newman† December 11, 2018 Abstract We present a new simple method for rounding a semidefinite programming relaxation of a constraint satisfaction problem. We apply it to the problem of approximate angular synchro- nization studied in [MN11]. Specifically, we are given directed distances on a circle (i.e., directed angles) between pairs of elements and our goal is to assign the elements to positions on a circle so as to preserve these distances as much as possible. The feasibility of our rounding scheme is based on properties of the well-known stochastic process called Brownian motion. Based on computational and other evidence, we conjecture that this rounding scheme yields an approxi- mation guarantee that is very close to the best-possible guarantee (assuming the Unique-Games Conjecture). 1 Introduction We present an alternate approach to the Relaxed Linear Equations mod p (Rel-Lin-Eq) problem studied in [MN11]. Our new approach is also based on rounding a semidefinite program- ming relaxation but uses a different rounding technique. Based on computational evidence and other justification, we believe this approach has essentially the same approximation guarantee of .854 for Rel-Lin-Eq as proven for a different algorithm presented in [MN11]. We are given a set E of equations in the form of xj − xi ≡ dij( mod p). Let X = {xi} be the set of elements and let n = X. We assign each element in X a (integral) value from the set [0, p). For a fixed assignment, an equation has value xj − xi ≡ dij ± yij(mod p), for yij ≤ p/2. Since yij can have a nonnegative value of at most p/2, we divide yij by p/2 in order to obtain a normalized value between 0 and 1. Our goal is to find an assignment that maximizes the sum Pij∈E(1 − 2yij/s). More precisely, we formulate our objective function as follows. max Xij∈E(cid:18)1 − 2 · min{(xj − xi − dij) mod p, − (xj − xi − dij) mod p} p (cid:19) . ∗Research done at Max-Planck-Institut fur Informatik, Saarbrucken, Germany. [email protected]. †Research done at Max-Planck-Institut fur Informatik, Saarbrucken, Germany. CNRS-Universit´e Grenoble Alpes. [email protected]. 1 This problem generalizes the Max-Cut problem: For any edge ij in a graph, we write the con- straint xj−xi ≡ p/2( mod p). Then an α-approximation to Rel-Lin-Eq yields an α-approximation for Max-Cut. It can be viewed as an approximate version of the angular synchronization problem studied by Singer [Sin11]. Originally, our motivation was to develop rounding methods for con- straint satisfaction problems whose solutions to assignment-constraint based SDPs can have the property that no pair of assignment vectors have a high dot product despite the solution having a high objective value. (e.g., A problem with this property is Maximum Acyclic Subgraph, which has since been proven to be Unique-Games hard to approximate to within a factor greater than 1 2 [GHM+11]. On the other hand, Unique Games does not have this property.) Our rounding scheme is based on properties of the well-known stochastic process called Brown- ian motion. Theoretically, this procedure could be applied to other problems that can be modeled using the standard assignment-constraint based SDP framework (i.e., SDP formulation (P +) in Section 2.1). However, it does seem tailor-made for our particular objective function. It is also reminiscent of "sticky" random walks used in constructive approaches to discrepancy minimiza- tion [Ban10], although these results focus on assigning each element a binary value and one of our main motivations was to study how to approximate large-domain problems. 1.1 Organization After presenting our quadratic formulations and relaxations in Section 2, we present our rounding procedure in Section 3. In Section 4, we discuss Brownian motion and how it relates to our rounding procedure. Then we prove that our rounding procedure is feasible most of the time; precisely, at least .96 of the time, it assigns a (non-random) position to a variable. First, we prove this for a continuous process (Section 5) and then for a discrete process (Section 6). Finally, in Section 7, we state a conjecture regarding the correlation of two random walks, which is supported by extensive computational experiments. A positive resolution to this conjecture would be one way to prove that this rounding procedure has a guarantee close to the best-known guarantee of .854 [MN11] (and close to the best-possible guarantee of .878 under the Unique-Games Conjecture). 2 Quadratic Programs For each variable xi, we have a set of p unit vectors, v0 , for a total of pn vectors. For b > a, let d(a, b) = min{b − a, p − (b − a)}. Note that d(a, b) = d(b, a). Let Fp denote a particular (fixed) set of p vectors with the property that for va, vb ∈ Fp, va · vb = 1 − 4d(a,b) . For example, if p = 8, then the set Fp can be the following eight vectors. i , v1 p i , v2 i , . . . , vp−1 i v0 i 1 2 1 2 1 2 1 2 v1 i - 1 2 1 2 1 2 1 2 v2 i - 1 2 - 1 2 1 2 1 2 v3 i - 1 2 - 1 2 - 1 2 1 2 v4 i - 1 2 - 1 2 - 1 2 - 1 2 v5 i 1 2 - 1 2 - 1 2 - 1 2 v6 i 1 2 1 2 - 1 2 - 1 2 v7 i 1 2 1 2 1 2 - 1 2 2 This formula for creating such a set Fp of vectors can be generalized for any even value of p (where √2√p ). We obtain the following quadratic the absolute value of each coordinate of each vector is program for Rel-Lin-Eq. Let P denote the set of integers in [0, p). A Quadratic Program (Q ): i · vdij j 1 + v0 2 max Xij∈E va i · vb i = 1 − j = vk+a va i · vb i va i · va i = 1, vk i ∈ Fp, 4 · d(a, b) p · vk+b , j , ∀xi ∈ X , a, b ∈ P, ∀xi, xj ∈ X , a, b, k ∈ P, ∀xi ∈ X , a ∈ P, ∀xi ∈ X , k ∈ P. (1) (2) (3) (4) For each variable xi ∈ X , the corresponding set of p vectors has the same configuration up to rotation, reflection and translation. This is enforced by Constraints (1) and (3). In an integral solution, the set of p vectors corresponding to variable xi is identical to the set of p vectors corre- sponding to the variable xj, for all variables xi, xj ∈ X . This follows from the fact that all vectors belong to Fp. The only difference is that vectors in the two sets may have different labels (i.e., one set of vectors can be viewed as a rotation of the other set). Then the relative values or positions of two variables only depends on the rotations of the labels. In other words, if for variables xi and xj, the same vectors have the same labels, then the two variables will be assigned to the same position. If vk and xi is in position k, xj should be in position k + 3. Given an integral solution, we can determine the position of each variable by picking a vector, and assigning each variable to the label to which that vector corresponds for that variable. i = vk+3 j 2.1 Semidefinite Relaxations To obtain a semidefinite relaxation of (Q), we remove Constraint (4) and require only that each pn. Note that even in the semidefinite relaxation, the set of p vectors corresponding to a vk i ∈ R particular variable xi have the same configuration for each variable up to rotation, reflection and translation. We refer to the set of vectors corresponding to a variable xi as a constellation Ci. We show that certain properties hold for each constellation. 3 A Semidefinite Program (P ): i · vdij j 1 + v0 2 4 · d(a, b) p · vk+b , j max Xij∈E va i · vb i = 1 − va i · vb j = vk+a i i · va va i = 1, vk i ∈ R pn, , ∀xi ∈ X , a, b ∈ P, ∀xi, xj ∈ X , a, b, k ∈ P, ∀xi ∈ X , a ∈ P, ∀xi ∈ X , k ∈ P. (5) (6) (7) (8) p √2√p . Let ei ∈ R √2 √p ei. k Let vp be a vector in R 2 be the indicator vector which has a 1 in the ith position and 0 elsewhere. For k such that 0 ≤ k ≤ p/2, we define wk as follows: 2 in which each entry is p wk = Xi=0 Definition 1. Let the constellation C0 be the set of s unit vectors {v0 } defined as follows. For k such that 0 ≤ k ≤ p/2, define vk 0 = −2 · wk + vp. For k such that p/2 < k < p, let 0 = −vk−p/2 vk Lemma 1. For any xi ∈ X , the constellation Ci = {v0 lation C0 up to rotation, reflection and translation. i , . . . , vp−1 0, . . . vp−1 i , v1 0, v2 0, v1 . 0 0 i i ) i −vk−1 Proof. Let vik = (vk p/2. We can assume this since for all k ∈ P , we have (i) vik = for all j, k ∈ P such that j 6= k (Lemma 3). 2 . Without loss of generality, let us assume that vik = i = vk−1 Note that vk i + 2 · vik. This implies that vp/2 k=1 vik. Thus, there is some rotation of the vectors in Ci such that the resulting set of vectors is equivalent to C0. Lemma 2. For all xi ∈ X and k ∈ P , (vk i = −Pp/2 √2√p . i = Pp/2 i −vk−1 = 2 ) i } is equivalent to the constel- √2√p ek for 1 ≤ k ≤ √2√p (Lemma 2) and (ii) vij · vik = 0 k=1 vik and that v0 Proof. (vk i − vk−1 i ) 2 ! · (vk i − vk−1 i 2 ) ! = = = 1 4 1 4 1 4 i − vk−1 (vk i )(vk i − vk−1 i ) · vk−1 i − 2vk i · vk−1 i ) i + vk−1 (vk i · vk (2 − 2(1 − i 4 p )) = 2/p. 4 Lemma 3. For xi ∈ X and for a, b, c, d ∈ [0, p/2], the vectors (va [c, d] are non-overlapping intervals. i − vb i ) · (vc i − vd i ) = 0 if [a, b] and Proof. (va i − vb i ) · (vc i − vd i ) = va = − i · vd i − va i · vc 4d(a, c) + i − vb 4d(a, d) i · vc + p p i i · vd i + vb 4d(b, c) − p 4d(b, d) p . This equals 0 if the intervals [a, b] and [c, d] are non-overlapping, since then d(a, c) + d(b, d) = d(a, d) + d(b, c). Another way to write a semidefinite program is to use a standard formulation based on assign- ment constraints (e.g., see Quadratic Program (Q2) in [MN11]). A Semidefinite Program (P +): max Xij∈EXk∈P (p − 2d(k, dij )) ui0 · ujk uih · ujk ≥ 0, uih · uik = 0, uih · ujk = uih+a · ujk+a, uih · uih = , 1 p ujk2 = 0, uih ∈ R pn, Xh∈P uih −Xk∈P xi, xj ∈ X , h, k ∈ P, xi, xj ∈ X , h, k ∈ P, xi, xj ∈ X , h, k, a ∈ P, ∀xi ∈ X , ∀xi, xj ∈ X , ∀xi ∈ X , h ∈ P. (9) (10) (11) (12) (13) (14) Given a solution for (P +), we can construct a solution for (P ) as follows. vk i = k+p/2−1 Xh=k uih − k+p−1 Xh=k+p/2 uih. (15) It is not difficult to see that the transformation in (15) preserves the objective value. In our computational experiments, we used solutions for (P +), which are more constrained than solutions for (P ) (e.g., Constraint (9) is not implied by the constraints in (P )). However, we feel it is somewhat clearer to present the rounding algorithm in the next section based on a solution for (P ). 5 2.2 Relaxation on an Arbitrarily Large Domain Note that we can replace p with an arbitrarily large constant s. Suppose s is a multiple of p (i.e., s = ℓp). Then we can scale each constraint so that xj − xi ≡ dij(mod p) becomes xj − xi ≡ ℓdij(mod s). The optimal objective value of the original and the scaled problem are the same. Moreover, given a solution for (P ) on the domain of size p, we can create a solution for the scaled problem on the domain of size s = ℓp with the same objective value without resolving the relaxation (P ). Thus, we can assume that s is an extremely large constant. We assume this since our rounding algorithms work best on a large domain. 3 Rounding the Relaxation i , . . . , r · vs−1 i i , r · v1 i is given by the dot product va Our algorithm for Rel-Lin-Eq is based on rounding a solution for the semidefinite relaxation (P ) presented in Section 2.1. The first issue is, how do we use the constellation of vectors Ci to determine the position or value of variable xi? We will consider the following random process with sn be a random vector in which each coordinate is chosen according to the normal s steps. Let r ∈ R distribution N (0, 1). We can view the s values r · v0 as a discrete random process in which the expected correlation of r · va i and r · vb Let us view these s values as a discrete random process on the interval [0, s]. For a subinterval [t, t′], we say time step q is in the interval [t, t′] if d(s· t/2, s· q/2) ≤ d(s· t/2, s· t′/2) and d(s· t′/2, s· q/2) ≤ d(s · t/2, s · t′/2). Given such a random process, we say that there is an extreme sign change with threshold α q · r < α for all q ∈ [t, t′]. Our algorithm between times t and t′ if vi is based on the observation that in this random process, it is very likely that there is exactly one extreme sign change for the threshold α = 1 (i.e., there do not exist two disjoint intervals that both contain extreme sign changes). This is stated in Theorem 1. If this random process has exactly one extreme sign change, then we say that the process first reaches a threshold α at time t if there q · r < α for all q ∈ [t′, t]. Note that these is an interval [t′, t] such that vi intervals are taken modulo s (i.e., they are intervals on a circle). Definition 2. An extreme sign change with threshold α in the sequence {v0 occurs when vi t′ · r ≤ −α, and vi i · r, v1 i · r, . . . , vs−1 t1 · r ≤ −α and vi t2 · r ≥ α and for no value of t : t1 < t < t2 is vi t · r ≤ −α, vi t′ · r ≥ α and vi t · r ≥ α, vi i · vb i . i · r} t · r ≥ α. Theorem 1. If s is a sufficiently large constant, then with probability at least .96, the random process {vk i · r} with s steps has exactly one extreme sign change with threshold 1. 3.1 Rounding Algorithm Given Theorem 1, we present the following rounding algorithm. 6 3 2 1 0 −1 −2 −3 0 20 40 60 80 100 120 140 160 180 200 2 1.5 1 0.5 0 −0.5 −1 −1.5 −2 0 20 40 60 80 100 120 140 160 180 200 2 1.5 1 0.5 0 −0.5 −1 −1.5 −2 0 20 40 60 80 100 120 140 160 180 200 Figure 1: The first two figures depict instances with one extreme sign change for threshold 1. The third figure shows an instance with three extreme sign changes for threshold 1. The blue dots represent the values greater than 1 and the green dots represent the values less than -1. (i) Solve the semidefinite relaxation (P ). (ii) Choose a random vector r ∈ R (iii) For each variable xi ∈ X, consider the sequence {vk i · r} for all k ∈ S. sn where each coordinate ri ∼ N (0, 1) for i ∈ {1, . . . , sn}. (a) If there is one extreme sign change: Place xi at the k where {vk i · r} first reaches threshold 1. (b) If there are no extreme sign changes: Assign xi a random position in [0, s − 1]. For each xi ∈ X, we associate the random walk wi. Each walk wi has the same expected behaviour. This follows from the fact that for each i, there is a rotation matrix such that the set of vectors {vk i } is equal to a canonical set of vectors, as stated in Lemma 1 (i.e., for a fixed vertex i, the pairwise (setwise) relationships of the vectors is exactly prescribed by constraints (2) and (4) of the SDP). We prove Theorem 1 in Section 5. First, we briefly discuss Brownian motion, which we will use in the proof of Theorem 1. To measure the quality of the solution produced by this rounding algorithm, one must analyze the correlation of two random walks. In Section 7, we state a conjecture regarding this correlation, which is supported by extensive computational experiments. 4 Brownian Motion In order to analyze the randomized rounding scheme presented above, we will interpret the sequence of vectors corresponding to any fixed variable, v1 · r, v2 · r, . . . , vs · r as a random walk. We will show that this random walk is a discrete sampling of a fundamental continuous stochastic process 7 called Brownian motion. We will then use properties of Brownian motion to prove properties of our discrete walk. For background in Brownian motion, we refer the reader to the textbook [KS88]. A stochastic process Wt for 0 ≤ t < ∞ is a Brownian motion if it satisfies the following properties: 1. For times t1 < t2, Wt2 − Wt1 ∼ N (0, t2 − t1). 2. For all choices of times 0 ≤ t0 < t1 < . . . < tn < ∞, Wti+1 − Wti is independent of Wtj+1 − Wtj for all choices of i, j, n. 3. W0 = 0. 4. Wt has continuous sample paths with probability 1. Our proofs will rely on two basic properties of Brownian motion: the distributions of hitting times and the Reflection Principle. The first hitting time for level b, denoted by τb, is defined to be the first time at which Wt takes the value b: τb = inf {t : Wt = b}. τb is a random variable whose distribution has the density function: (16) Pr[τb ∈ dt] = √2πt3/2 b exp(cid:18)− b2 2t(cid:19) dt. Roughly stated, the Reflection Principle is the intuitive property that once a Brownian motion hits a level b, it is equally likely to be above and below the level b in the future. More precisely, it states that if Wt is a Brownian motion and τb its hitting time to b, then the process W ′t defined by W ′t =(cid:26) Wt 2b − Wt for 0 ≤ t ≤ τb for t ≥ τb (which is the formula for Wt "reflected" about the horizontal line y = b after it hits b) is also a Brownian motion. We will use the reflection principle many times in our calculations. 4.1 Mapping Our Process to Brownian Motion Given a constellation of vectors Ci, we can assume by Lemma 1 that the vectors have the following configuration. Each vector in this configuration has dimension s/2. Note that in order to make each vector a unit vector, we can multiply each entry by √2√s . v0′ i 1 1 1 1 . . . v1′ i -1 1 1 1 . . . v2′ i -1 -1 1 1 . . . v3′ i -1 -1 -1 1 . . . . . . . . . . . . . . . . . . . . . vs−1′ i 1 1 1 1 . . . 8 Suppose that r ∈ N (0, 1)s/2 is a vector such that r = (r1, r2, . . . rs/2). Let a′ = Ps/2 i=0 rk. Thus, we have that: Define the process wi′ k as wi′ i=1 ri = v0′ i · r. k =Pk a′ − 2wi′ k = vk′ · r, wi′ k = a′ − vk′ · r 2 . Let the vector vk represent the vector vk′ with each entry multiplied by √2√s = v0 · r = (v0′ · r) · √2√s , so that {vk} is a √2√s , and define the process wi k as wi set of unit vectors. Let a = Ps/2 k =Pk i=1 ri · √2√s . Thus, we have that: i=0 rk · a − 2wi k = vk · r, wi k = a − vk · r 2 . Note that when vk · r = 1 or −1, it is the case that wi 2 , respectively. If we define Wt to be a Brownian motion on the continuous interval [0, 1], then wt is a discretization of this continuous process. In the remainder of the paper, when we refer to a particular process wi k, we will drop the superscript i when it is clear from the context, or when we are just referring to a single process. 2 and a+1 k = a−1 5 Probability of Exactly One Extreme Sign Change In this section, we we prove Theorem 1. We adopt standard statistical notation and denote density function of a continuous random variable X by Pr[X ∈ dx]. For example, if X ∼ N (0, 1), then e−x2/2dx. (Heuristically, dx denotes a very small region around the value x.) We Pr[X ∈ dx] = 1√2π will furthermore write Pr[X ∈ dx(1)] to denote the density function of X when x takes the specific value of 1. We compute the probability of an event A conditioned on a random variable X taking value X = x by applying the formula: Pr[AX = x] = Pr[A and X ∈ dx] Pr[X ∈ dx] . 5.1 Probability of at Least One Sign Change Suppose Brownian motion Wt begins at W0 = 0 and at t = 1 satisfies W1 = a. Let H + be the minimum time that W reaches the threshold a/2 + 1/2, and H− be the minimum time that W reaches a/2 − 1/2. Note that H + = τW1/2+1/2 and that H− = τW1/2−1/2. These hitting times depend on the value of Wt at time 1, and are therefore are not stopping times. In order to calculate their distributions, we will first fix a and then calculate the distributions of H + and H−, conditioned on the value of W1 = a. For our proof, we will find it helpful to generalize our definition of H− and H + as follows. Suppose a Brownian motion satisfies W1 = a. Define H + to be the first time that Wt finishes i hitting the following sequence of barriers: a/2 + 1/2, then a/2 − 1/2, then a/2 + 1/2 and so forth 9 until it has crossed i barriers, alternating between the upper and lower barriers. As an example, H + 3 would be the first time that the path hits a/2 + 1/2 after having first hit a/2 + 1/2, and then a/2− 1/2. Similarly, define H−i to be the first time that Wt finishes hitting the sequence of barriers: below a/2 − 1/2, above a/2 + 1/2, and so forth until it has crossed i barriers. Lemma 4. Pr[H + ≤ 1 or H− ≤ 1] ≥ .985612. Our approach will be to consider the decomposition of the total probability into probabilities conditioned on W1 = a: Pr[H + ≤ 1 or H− ≤ 1] =Z ∞ −∞ Pr[H + ≤ 1 or H− ≤ 1 W1 = a]φ(a)da. and calculate the integral on the right-hand-side. We break the domain of the integral into three parts. 5.1.1 Case (i): a ≥ 1 In this case, the upper barrier is a/2 + 1/2 ≤ a. The condition W1 = a implies that Wt crosses this barrier with probability 1 (i.e. H + ≤ 1). Therefore, Z ∞ 5.1.2 Case (ii): a ≤ −1 Analogous to Case (i). 1 Pr[H + ≤ 1 W1 = a]φ(a)da =Z ∞ 1 φ(a)da ≥ .158655. 5.1.3 Case (iii): −1 < a < 1 From an application of the inclusion-exclusion principle, note that: Pr(cid:2)H + ≤ 1 or H− ≤ 1 W1 = a(cid:3) = Pr[H + ≤ 1 W1 = a] + Pr[H− ≤ 1 W1 = a] − Pr[H + ≤ 1 and H− ≤ 1 W1 = a]. 5.1.4 An example of applying the reflection principle We now sketch the reasoning behind a standard calculation involving the reflection principle of Brownian motion and apply it to calculating Pr[H + ≤ 1 W1 = a] for the case −1 < a < 1. We will use this sort of calculation many times in our proofs. Fix a value of a. Suppose a Brownian motion Wt (but not restricted to satisfy W1 = a) hits the value b = a/2 + 1/2 at time τb (i.e., Wτb = b). Define W ′t to be the process W ′t = Wt for 0 ≤ t ≤ τb and W ′t = 2b− Wt for t ≥ τb. By the reflection principle, the random process W ′t is also a Brownian motion. Now consider the subset of Brownian motions {WtH + ≤ 1, W1 = a} (i.e., they satisfy τa/1+1/2 ≤ 1, W1 = a). Note that these processes correspond exactly to reflected processes W ′ that satisfy 10 W ′1 = 2b − W1 = 1. Thus, the elements in the set {WtH + ≤ 1, W1 = a} correspond exactly to elements in the set {W ′tW ′1 = 1}. Then Pr[H + ≤ 1 W1 = a] = Pr[W ′1 ∈ dx(1)] Pr[W1 ∈ da] = φ(1) φ(a) . For a more rigorous justification of these calculations, see [Cha01]. Similarly, one can show that: Pr[H− ≤ 1 W1 = a] = φ(1)/φ(a). Therefore Pr[H− ≤ 1 W1 = a]φ(a)da =Z 1 Z 1 Pr[H + ≤ 1 W1 = a]φ(a)da =Z 1 −1 −1 −1 φ(1)da ≥ .483941. 5.1.5 An example applying the reflection principle twice Note that the event {WtH + ≤ 1 and H− ≤ 1, W1 = a} corresponds to processes that either cross above the barrier a/2 + 1/2 then below a/2 − 1/2 or vice versa, i.e. processes that satisfy H + 2 ≤ 1 or H−2 ≤ 1. Therefore, from the inclusion-exclusion principle we have: Pr[H + ≤ 1 and H− ≤ 1 W1 = a] = Pr[H + − Pr[H + 2 ≤ 1 W1 = a] + Pr[H−2 ≤ 1 W1 = a] 2 ≤ 1 and H−2 ≤ 1 W1 = a]. In order to calculate Pr[H + 2 ≤ 1 W1 = a], we apply the reflection principle twice. First, we reflect Wt about the line a/2 + 1/2 when it first hits a/2 + 1/2. Call this reflected process W ′t . A process Wt that hits a/2 + 1/2, then hits a/2 − 1/2, then satisfies W1 = a will correspond exactly to a reflected process W ′t that first hits a/2 + 1/2 then hits a/2 + 3/2 then achieves W ′1 = 1. Next, we reflect the process W ′t the first time it hits a/2 + 3/2 about the line a/2 + 3/2; call this new process W ′′t . It is easy to verify that a process Wt (prior to reflection) that hits a/2 + 1/2, then a/2 − 1/2, then achieves W1 = a will correspond exactly to a reflected process W ′′t that satisfies W ′′1 = 2 + a. Therefore, Pr[H + 2 ≤ 1 W1 = a] = = = Pr[H + 2 ≤ 1 and W1 ∈ da] Pr[W1 ∈ da] Pr[W ′′1 ∈ dx(2a + 1)] Pr[W1 ∈ da] φ(2 + a) . φ(a) n order to calculate Pr[H + 2 ≤ 1 W1 = a], we apply the reflection principle twice. After the process Wt Wt first hits a/2 + 1/2 and then hits a/2− 1/2, we reflect the process Wt about the line a/2 − 1/2. Call this reflected process W ′t . A process Wt that hits a/2 + 1/2, then hits a/2 − 1/2, then achieves W1 = a will be reflected to a process W ′t that first hits a/2 + 1/2 and then achieves W ′1 = −1. Next, we reflect the process W ′t the first time it hits a/2 + 1/2 about the line a/2 + 1/2; call this new process W ′′t . It is easy to verify that a process Wt (prior to reflection) that hits 11 a/2 + 1/2, then a/2− 1/2, then achieves W1 = a will correspond exactly to a twice reflected process W ′′t that achieves W ′′1 = 2 + a. Therefore, Pr[H + 2 ≤ 1 W1 = a] = = = Pr[H + 2 ≤ 1 and W1 ∈ da] Pr[W1 ∈ da] Pr[W ′′1 ∈ dx(2a + 1)] Pr[W1 ∈ da] φ(2 + a) . φ(a) Therefore, −1 Similarly, one can show Z 1 Pr[H + 2 ≤ 1 W1 = a]φ(a)da =Z 1 −1 φ(2 + a)da ≤ .157305. Z 1 Pr[H−2 ≤ 1 W1 = a]φ(a)da =Z 1 2 ≤ 1 and H−2 ≤ 1 W1 = a] corresponds to the event [H + 1]. From the calcuations in Section 5.6, the following bound can be easily derived: φ(2 + a)da ≤ .157305. Note that the event [H + −1 −1 3 ≤ 1 or H + 3 ≤ Z 1 −1 Pr[H + 3 ≤ 1 or H−3 ≤ 1 W1 = a]φ(a)da ≥ .01503. Combining these calculations, we arrive at: Z 1 −1 Pr[H−1 ≤ 1 or H + 1 ≤ 1 W1 = a]φ(a)da ≥ .668302 5.2 Totals Combining the results of the three cases, we obtain: Pr[H + ≤ 1 or H− ≤ 1] ≥ .158655 · 2 + .668302 = .985612. 5.3 Probability of Three or More Sign Changes In this section, we prove the following Lemma: Lemma 5. Pr[H + 3 ≤ 1 or H−3 ≤ 1] ≤ .0178. Since the barriers in H + 3 and H−3 depend on the value of W1, as in the previous section, it will be necessary to decompose the total probability into probabilities conditioned on a = W1: Pr[H + 3 ≤ 1 or H−3 ≤ 1] =Z ∞ −∞ Pr[H + 3 ≤ 1 or H−3 ≤ 1 W1 = a]φ(a)da. 12 We partition the domain of the integral into three cases, and calculate the probabilities in each case using the reflection principle. Brownian motion, W , begins at 0 and after t time steps achieves the value W1 = a. Then let H + be the minimum time that W finishes reaching the thresholds a/2+1/2, a/2−1/2, a/2+1/2 in that order. (Let H− be the min time that W reaches the thresholds a/2− 1/2, a/2+ 1/2, a/2− 1/2 in that order.) We define another process Bt, which is a reflection of the process Wt over certain thresholds (depending on the case). There are three cases. 5.4 Case (i): a > 1 Figure 2: Case (i). then H−3 must also occur. In this case, we only need to calculate the probability that H−3 ≤ 1 occurs, since if H + To obtain W ′t , the process Wt is reflected the first time it hits a/2 + 1/2, then the first time this reflected process hits a/2 + 3/2. Using reasoning similar to Section 5.1.5, it can be shown that if the process Wt (prior to reflection) hits a/2 + 1/2, then a/2 − 1/2, then a/2 + 1/2, then satisfies W1 = a (i.e., it satisfies H + 3 ≤ 1 for fixed a), then it will correspond exactly to a process W ′t that achieves W ′1 = a + 2. Therefore, 3 occurs, Pr[H−3 ≤ 1 W1 = a] = = Pr[W ′1 ∈ dx(a + 2)]/ Pr[W1 ∈ da] = φ(a + 2)/φ(a). Pr[H−3 ≤ 1, W1 ∈ da] Pr[W1 ∈ da] 13 Thus, we have: Z ∞ 1 Pr[H−3 ≤ 1 W1 = a]φ(a)da. = Z ∞ 1 φ(a + 2)da ≤ .0013499. 5.5 Case (ii): a ≤ −1 Analogous to Case (i). 5.6 Case (iii): −1 < a < 1 By the inclusion-exclusion principle, we have: Pr[H + 3 ≤ 1 or H−3 ≤ 1 W1 = a] = Pr[H + − Pr[H + 3 ≤ 1 W1 = a] + Pr[H−3 ≤ 1 W1 = a] 3 ≤ 1 and H−3 ≤ 1 W1 = a]. First, we calculate Pr[H + 3 ≤ 1 W1 = a]. The process W ′t is obtained by reflecting Wt the first Figure 3: Case (ii), H +. time it hits a/2 + 1/2, then the first the reflected process hits a/2 + 3/2, then the first time the twice reflected process hits a/2 + 5/2. If Wt (prior to reflection) hits a/2 + 1/2, then a/2 − 1/2, then a/2 + 1/2, then achieves W1 = a, then it will correspond exactly to a thrice reflected process W ′t that satisfies W ′1 = 3. We want to calculate: Z 1 −1 Pr[H−3 ≤ 1 W1 = a]φ(a)da. (17) We have: 14 Pr[H−3 ≤ 1 W1 = a] = Pr[H−3 ≤ 1, W1 ∈ da] Pr[W1 ∈ da] = Pr[W ′1 ∈ dx(3)]/ Pr[W1 ∈ da] = φ(3)/φ(a). Thus, we have: Z 1 −1 Pr[H−3 ≤ 1 W1 = a]φ(a)da. = 2Z 1 0 φ(3)da ≤ .0088637. Figure 4: Case (ii), H−. Now we calculate Pr[H−3 ≤ 1 W1 = a]. In this case, the process W ′t is obtained by reflecting Wt the first time it hits a/2 − 1/2, then the first time the reflected process hits a/2 − 3/2, then the first time the twice reflected process hits a/2 − 5/2. A process Wt that hits a/2 − 1/2, then a/2 + 1/2, then a/2− 1/2, then satisfies W1 = a (i.e., it satisfies H−3 ≤ 1 for fixed a) will correspond exactly to a thrice reflected process W ′t that satisfies W ′1 = −3. We want to compute: Z 1 −1 Pr[H−3 ≤ 1 W1 = a]φ(a)da. (18) We have: Pr[H−3 ≤ 1 W1 = a] = Pr[H−3 ≤ 1, W1 ∈ da]/ Pr[W1 ∈ da] = Pr[W ′1 ∈ dx(−3)]/ Pr[W1 ∈ da] = φ(−3)/φ(a). 15 Thus, we have: Z 1 −1 Pr[H−3 ≤ t Wt = a]φ(a)da. = 2Z 1 0 φ(−3)da ≤ .0088637. Thus, a naive bound on the probability of three sign changes would be to add expressions (17) and (18): Z 1 −1 Pr[H−3 ≤ 1 or H + 3 ≤ 1 W1 = a]φ(a)da ≤ Z 1 Pr[H−3 ≤ 1W1 = a]φ(a)da +Z 1 Pr[H + 0 3 ≤ 1W1 = a]φ(a)da = .0017728. The above bound is an overestimate of the probability, because the event [H−3 ≤ 1 and H + 3 ≤ 1 W1 = a] is contained in both (17) and (18). 3 ≤ 1 W1 = a]. Note that the event(cid:8)WH−3 ≤ 1 and H + 3 ≤ 1(cid:9) occurs when there are at least four sign changes; either H + 4 ≤ 1 or H−4 ≤ 1 occurs, or possibly both. Using the same argument as we did for H + We now calculate Pr[H−3 ≤ 1 and H + 3 , H−3 , it can be shown that: 0 Pr[H−4 ≤ 1 W1 = a]φ(a)da +Z 1 −1 Pr[H + 4 ≤ 1 W1 = a]φ(a)da = 2Z 1 −1 φ(4 + a)da ≥ .00269922 Z 1 −1 and that Z 1 −1 Pr[H + 5 ≤ 1 W1 = a]φ(a)da +Z 1 −1 Pr[H−5 ≤ 1 W1 = a]φ(a)da = 4Z 1 0 φ(5)da ≤ 5.94688 · 10−6. Again applying the inclusion-exclusion principle, we have: Z 1 −1 Pr[H−3 ≤ 1 and H + 3 ≤ 1 W1 = a]φ(a)da = Z 1 −1(cid:0)Pr[H−4 ≤ 1 W1 = a] + Pr[H + −Z 1 ≤ Z 1 −1(cid:0)Pr[H−4 ≤ 1 W1 = a] + Pr[H + −Z 1 −1(cid:0)Pr[H−5 ≤ 1 W1 = a] + Pr[H + Pr[H−4 ≤ 1 and H + −1 ≤ .0026328. 4 ≤ 1 W1 = a](cid:1) φ(a)da 5 ≤ 1 W1 = a](cid:1) φ(a)da 4 ≤ 1 W1 = a](cid:1) φ(a)da 4 ≤ 1 W1 = a]φ(a)da Therefore: Z 1 −1 Pr[H− ≤ 1 and H + ≤ 1]φ(a)da ≤ .0176734 − .00263828 ≤ .015035. 16 5.7 Totals Combining the results of the three cases, we arrive at: Pr[H + 3 ≤ 1 or H−3 ≤ 1] ≤ .015035 + .0013499 · 2 = .017735. 6 From Brownian Motion to Discrete Random Walks The randomized rounding procedure for our algorithm involves a discrete random walk; we have proven Lemmas 4 and 5 for the continuous process, Brownian motion. We show in this section that the discretized random walk of the rounding procedure will also satisfy Lemmas 4 and 5. Suppose Wt is a Brownian motion. As we showed earlier, the discretized random walk of s steps, w1, . . . , ws, can be modeled as the sequence: w1 = W1, w2 = W2/s, w3 = W3/s, . . . , ws = W1. First, consider the question of whether Lemma 5 implies that w1, . . . , ws also does not touch the sequence of barriers ws 2 before time t = 1. Certainly, if Wt does not hit this sequence of barriers, then its discretized version also does not hit these three barriers, since ws = W1. Therefore Lemma 5 holds for the discrete random walk as well. 2 − 1 2 + 1 2 + 1 2 , ws 2 , ws 2 or ws 2 − 1 Now consider the question of whether Lemma 4 implies that w1, . . . , ws hits either of the barriers ws 2 + 1 2 . Note that if Wt hits the barrier b at time τb, it is not necessarily true that there exists an i such that wi ≥ b, since Wt could have hit b at some time between the steps of the discretized walk. Therefore, Lemma 4 cannot be immediately adapted to proving properties of the discretized walk. We now prove that the Lemma is true for the discretized walk when the number of steps is a sufficiently large constant. Recall that random variables H + and H− were defined as the first times that the Brownian motion Wt hits the barrier defined by W1 2 , respectively. We slightly strengthen these conditions by defining random variables H + and H− to be the first times that Wt hits the barriers W1 2 − η, respectively, for some very small constant η. Since η will be chosen to be very small, it will not have a large impact on the distributions of H + and H− relative to H + and H−. The proof of the following lemma involves the same calculations as in the proof of Lemma 4. 2 + η and W1 2 and W1 2 − 1 2 − 1 2 + 1 2 + 1 Lemma 6. For η > 0 chosen sufficiently small, Pr[ H + ≤ 1 or H− ≤ 1] ≥ 0.9855. We use the above Lemma to prove that if the continuous process Wt hits the barrier a 2 − 1 then the discrete random walk will hit the barrier a barrier a Lemma 7. If the number of steps s of the discretized random walk satisfies s ≥ c constant c, then: 2 is similar. 2 + 1 2 + η, 2 with high probability. The case for the 2 + 1 η2 for some where W1 = a and τ a 2 + 1 2 Pr(cid:20)w⌈s·τ a 2 +η⌉ ≥ + 1 2 a 2 + 1 2 τ a 2 + 1 2 +η ≤ 1(cid:21) ≥ .997, is the time the continuous process hits the barrier a 2 + 1 2 . 17 2 + 1 Proof. Let b = a and 5.3, we will work with probabilities conditioned on the event {WW1 = a, τb ≤ 1}. 2 be the barrier of interest. Since b depends on value of W1 = a, as in Sections 5.1 Note that (a) a = W1 ∼ N (0, 1); therefore, with probability at least .999, a ≤ 10 and b+η < 6. Also, (b) the probability that τb+η ≤ 1 − c, for some constant c > 0, conditioned on τb+η ≤ 1, is at least 0.999. This is because the density function of τb+η conditioned on W1 = a is given by: Pr [τb+η ∈ dt W1 = a] = b + η √2πt3/2 exp(cid:18)− (b + η)2 2t (cid:19) 1 √1 − t φ(cid:18) b + η − a √1 − t (cid:19) . Therefore, (b + η)2 2t (cid:19)(19) (20) (21) (22) (23) 1 1 1−c exp(cid:18)− Pr [τb+η ∈ [1 − c, 1] W1 = a,a ≤ 10, τb+η ≤ 1] ≤ (.999)2 Z 1 √1 − t · ((.999)2 · π)Z 1 ((.999)2 · π)(cid:0)1 ((.999)2 · π) for appropriately chosen c. In particular c ≈ 10−9 is sufficiently small. b + η √2πt3/2 φ(cid:18) b + η − a √1 − t (cid:19) dt √1 − t 1−c (−2√1 − t)(cid:1) (2√c) ≤ .001, 1−c ≤ ≤ ≤ dt 1 6 6 6 If τb+η is the time that the process Wt hits the barrier b + η, let the index ⌈s · τb+η⌉ denote the step in the discretized random walk that immediately follows τb+η. The value of this step is w⌈s·τb+η⌉ = W⌈s·τb+η⌉/s. Intuitively, this value should be very close to b + η if the number of steps is sufficiently large. Indeed, we will prove the lemma by showing that if the number of steps in the discrete random walk satisfies s ≥ 20 a 2 2 τb+η ≤ 1 − c, W1 = a,a ≤ 10(cid:21) ≥ .999. Pr(cid:20)W ⌈s·τb+η⌉ cη2 , then ≥ + 1 s Suppose that W is conditioned on reaching the barrier b + η at time T and that W is restricted to satisfying W1 = a. We use basic properties of the distribution of the increments of a Brownian Bridge (see [Cha01] for details) to show that the value of a Brownian motion at time T + t < 1, under the condition that WT = b + η and W1 = a, has the following distribution: WT +tWT = b + η, W1 = a ∼ N(cid:18)b + η − t(b + η − a) 1 − T , t 1 − T · (1 − T − t)(cid:19) . (24) Note that ⌈s·τb+η⌉ is the index of the closest step in the discretization to τb+η and that ⌈s·τb+η⌉/s− τb+η ≤ 1/s ≤ cη2/20. If a ≤ 10, T < (1 − c) and s ≥ 20/(cη2), then Equation (24) implies that w⌈s·τb+η⌉ = W⌈s·τb+η⌉/s is distributed with mean at least b + η/2 and variance at most η2/20. Thus, if s ≥ 20/(cη2), Pr[w⌈s·τb+η⌉ ≤ b a ≤ 10, τb+η ≤ 1 − c, W1 = a] ≤ .001. The Lemma follows. 18 Lemma 7 can thus be applied to prove Theorem 1. 7 Correlated walks To prove an approximation ratio of our rounding algorithm, we need to show that the positions of xi and xj (corresponding to the constraint xj − xi ≡ dij( mod s)), determined by the random walks wi and wj, are close to the required distance if the vectors v0 j ) are close. In other words, without loss of generality, let us assume that for a fixed constraint, we have dij = 0. Then our goal is to show that the distance between the two positions assigned by our rounding procedure to xi and xj are close if the vectors v0 j are close. After extensive computational investigation (on solutions obeying the constraints of (P +)), we believe the following conjecture holds. i and vdij i and v0 Conjecture 1. In our rounding scheme, the expected distance between xi and xj is bounded above by θ 2π if both wi and wj each have exactly one extreme sign change. Proving the above conjecture would lead to an approximation guarantee slightly below αGW = .87856, because we do not have an extreme sign change with probability 1. We can show that if v0 j have a small angle, then the two walks are (globally) close to each other in the sense that the area between the two walks is small. However, this does not immediately lead to a proof that the positions of their extreme sign changes are close. i and v0 Lemma 8. Given two unit vectors x and y with angle θ, and a vector r ∈ R drawn from N (0, 1), then, n with each coordinate E[x · r − y · r] = 2√2 √π sin θ 2 . Proof. Let x = (cos θ 2 , sin θ 2 ) and y = (cos θ 2 ). Let r = (r1, r2). 2 ,− sin θ θ 2 = E[r2] · 2 sin θ 2 . E[x · r − y · r] = 2r2 sin The expected value of r2 given that it is non-negative is θ from 0 to π, the above statement follows by linearity of expectation. √2√π . Since sin θ 2 is always non-negative for smaller interval [0, 1]), then the expected area between the two walks is 2√2√π sin θ If we consider the random walks on the interval [0, 1] (i.e. we map the interval [0, 2] to the 2 . Thus, as the contribution to the objective function increases, the two walks converge and the positions assigned to them by the rounding procedure should converge to one another. 19 "PlotA2" "PlotB2" 2 2 2 1 1 1 0 0 0 -1 -1 -1 -2 -2 -2 0 0 0 50 50 50 100 100 100 150 150 150 200 200 200 250 250 250 300 300 300 350 350 350 400 400 400 3 3 3 2 2 2 1 1 1 0 0 0 -1 -1 -1 -2 -2 -2 -3 -3 -3 0 0 0 "PlotA2" "PlotB2" 50 50 50 100 100 100 150 150 150 200 200 200 250 250 250 300 300 300 350 350 350 400 400 400 Figure 5: In the first example, cos θ = .86. In the second, cos θ = .945455. "PlotA" "PlotB" 200 200 200 400 400 400 600 600 600 800 800 800 1000 1000 1000 1200 1200 1200 1400 1400 1400 1600 1600 1600 "PlotA" "PlotB" "PlotA" "PlotB" 2 2 2 1 1 1 0 0 0 -1 -1 -1 -2 -2 -2 0 0 0 200 200 200 400 400 400 600 600 600 800 800 800 1000 1000 1000 1200 1200 1200 1400 1400 1400 1600 1600 1600 3 3 3 2 2 2 1 1 1 0 0 0 -1 -1 -1 -2 -2 -2 -3 -3 -3 0 0 0 2 2 2 1 1 1 0 0 0 -1 -1 -1 -2 -2 -2 0 0 0 200 200 200 400 400 400 600 600 600 800 800 800 1000 1000 1000 1200 1200 1200 1400 1400 1400 1600 1600 1600 Figure 6: More examples of correlated walks. 20 Acknowledgements We would like to thank Martin Becker and Larry Shepp for helpful discussions about Brownian mo- tion. Most of this work was done in 2007 at the Max-Planck-Institut fur Informatik in Saarbrucken, Germany. References [Ban10] Nikhil Bansal. Constructive algorithms for discrepancy minimization. In Proceedings of 51st Annual IEEE Symposium on Foundations of Computer Science (FOCS), pages 3 -- 10, 2010. [Cha01] Joe Chang. Brownian motion. Lecture notes for Statistics 251/551, Yale University, 2001. [GHM+11] Venkatesan Guruswami, Johan Hastad, Rajsekar Manokaran, Prasad Raghavendra, and Moses Charikar. Beating the random ordering is hard: Every ordering CSP is approximation resistant. SIAM Journal on Computing, 40(3):878 -- 914, 2011. [KS88] [MN11] Ioannis Karatzas and Steven E. Shreve. Brownian Motion and Stochastic Calculus. Springer-Verlag, New York, 1988. Konstantin Makarychev and Alantha Newman. Complex semidefinite programming revisited and the assembly of circular genomes. In Innovations in Computer Science (ICS), pages 444 -- 459, 2011. [Sin11] Amit Singer. Angular synchronization by eigenvectors and semidefinite programming. Applied and computational harmonic analysis, 30(1):20, 2011. 21
1611.06605
1
1611
2016-11-20T22:44:12
Algorithmic and Hardness Results for the Hub Labeling Problem
[ "cs.DS" ]
There has been significant success in designing highly efficient algorithms for distance and shortest-path queries in recent years; many of the state-of-the-art algorithms use the hub labeling framework. In this paper, we study the approximability of the Hub Labeling problem. We prove a hardness of $\Omega(\log n)$ for Hub Labeling, matching known approximation guarantees. The hardness result applies to graphs that have multiple shortest paths between some pairs of vertices. No hardness of approximation results were known previously. Then, we focus on graphs that have a unique shortest path between each pair of vertices. This is a very natural family of graphs, and much research on the Hub Labeling problem has studied such graphs. We give an $O(\log D)$ approximation algorithm for graphs of diameter $D$ with unique shortest paths. In particular, we get an $O(\log \log n)$ approximation for graphs of polylogarithmic diameter, while previously known algorithms gave an $O(\log n)$ proximation. Finally, we present a polynomial-time approximation scheme (PTAS) and quasi-polynomial time algorithms for Hub Labeling on trees; additionally, we analyze a simple combinatorial heuristic for Hub Labeling on trees, proposed by Peleg in 2000. We show that this heuristic gives an approximation factor of 2.
cs.DS
cs
Algorithmic and Hardness Results for the Hub Labeling Problem Haris Angelidakis1, Yury Makarychev1 and Vsevolod Oparin2 1Toyota Technological Institute at Chicago 2Saint Petersburg Academic University of the Russian Academy of Sciences Abstract There has been significant success in designing highly efficient algorithms for distance and shortest-path queries in recent years; many of the state-of-the-art algorithms use the hub labeling framework. In this paper, we study the approximability of the Hub Labeling problem. We prove a hardness of Ω(log n) for Hub Labeling, matching known approximation guarantees. The hardness result applies to graphs that have multiple shortest paths between some pairs of vertices. No hardness of approximation results were known previously. Then, we focus on graphs that have a unique shortest path between each pair of vertices. This is a very natural family of graphs, and much research on the Hub Labeling problem has studied such graphs. We give an O(log D) approximation algorithm for graphs of diameter D with unique shortest paths. In particular, we get an O(log log n) approximation for graphs of polylogarithmic diameter, while previously known algorithms gave an O(log n) approximation. Finally, we present a polynomial-time approximation scheme (PTAS) and quasi-polynomial time algorithms for Hub Labeling on trees; additionally, we analyze a simple combinatorial heuristic for Hub Labeling on trees, proposed by Peleg in 2000. We show that this heuristic gives an approximation factor of 2. 1 Introduction There has been significant success in designing highly efficient algorithms for distance and shortest- path queries in recent years; many of the state-of-the-art algorithms use the hub labeling framework. In this paper, we present approximation algorithms as well as prove hardness results for the Hub Labeling problem. The Hub Labeling problem was introduced by Cohen et al.1 in 2003 [15]. Definition 1 (Hub Labeling). Consider an undirected graph G = (V, E) with edge lengths l(e) > 0. Suppose that we are given a set system {Hu}u∈V with one set Hu ⊂ V for every vertex u. We say that {Hu}u∈V is a hub labeling if it satisfies the following covering property: for every pair of vertices (u, v) (u and v are not necessarily distinct), there is a vertex in Hu ∩ Hv (a common "hub" for u and v) that lies on a shortest path between u and v. We call vertices in sets Hu hubs: a vertex v ∈ Hu is a hub for u. In the Hub Labeling problem (HL), our goal is to find a hub labeling with a small number of hubs; specifically, we want to minimize the (cid:96)p-cost of a hub labeling. 1See also prior papers on bit labeling schemes [13, 14, 22, 20, 27, 24, 18]. 1 Definition 2. The (cid:96)p-cost of a hub labeling {Hu}u∈V equals ((cid:80) u∈V Hup)1/p for p ∈ [1,∞); the (cid:96)∞-cost is maxu∈V Hu. The hub labeling problem with the (cid:96)p-cost, which we denote by HLp, asks to find a hub labeling with the minimum possible (cid:96)p-cost. Note: When we talk about HL and do not specify the cost function explicitly, we mean HL1; we sometimes refer to the (cid:96)1-cost of {Hu}u∈V simply as the cost of {Hu}u∈V . distance query in time O(max(Hu,Hv)). We need to keep a lookup table of size O((cid:80) We are interested in the Hub Labeling problem because of its connection to the shortest-path problem. Nowadays hundreds of millions of people worldwide use web mapping services and GPS devices to get driving directions. That creates a huge demand for fast algorithms for computing shortest paths (algorithms that are even faster than the classic Dijkstra's algorithm). Hub labelings provide a highly efficient way for computing shortest paths (see also the paper of Bast et al. [10] for a review and discussion of various methods for computing shortest paths that are used in practice). Let us briefly explain the connection between the Hub Labeling and shortest-path problems. Consider a graph G = (V, E) with edge lengths l(e). Let d(u, v) be the shortest path metric on G. Suppose that we have a hub labeling {Hu}u. During the preprocessing step, we compute and store the distance d(u, w) between every vertex u and each hub w ∈ Hu of u. Observe that now we can very quickly answer a distance query: to find d(u, v) we compute minw∈Hu∩Hv (d(u, w) + d(v, w)). By the triangle inequality, d(u, v) ≤ minw∈Hu∩Hv (d(u, w) + d(v, w)), and the covering property guarantees that there is a hub w ∈ Hu ∩ Hv on a shortest path between u and v; so d(u, v) = minw∈Hu∩Hv (d(u, w) + d(v, w)). We can compute minw∈Hu∩Hv (d(u, w) + d(v, w)) and answer the u∈V Hu) to store the distances between the vertices and their hubs. So, if, say, all hub sets Hu are of polylogarithmic size, the algorithm answers a distance query in polylogarithmic time and requires n polylog n space. The outlined approach can be used not only for computing distances but also shortest paths between vertices. It is clear from this discussion that it is important to have a hub labeling of small size, since both the running time and storage space depend on the number of hubs. Recently, there has been a lot of research on algorithms for computing shortest paths using the hub labeling framework (see e.g. the following papers by Abraham et al. [6, 4, 3, 5, 1, 2]). It was noted that these algorithms perform really well in practice (see e.g. [4]). A systematic attempt to explain why this is the case led to the introduction of the notion of highway dimension [6]. Highway dimension is an interesting concept that managed to explain, at least partially, the success of the above methods: it was proved that graphs with small highway dimension have hub labelings with a small number of hubs; moreover, there is evidence that most real-life road networks have low highway dimension [11]. However, most papers on HL offer only algorithms with absolute guarantees on the cost of the hub labeling they find (e.g., they show that a graph with a given highway dimension has a hub labeling of a certain size and provide an algorithm that finds such a hub labeling); they do not relate the cost of the hub labeling to the cost of the optimal hub labeling. There are very few results on the approximability of the Hub Labeling problem. Only very recently, Babenko et al. [9] and White [26] proved respectively that HL1 and HL∞ are NP-hard. Cohen et al. [15] gave an O(log n)-approximation algorithm for HL1 by reducing the problem to a Set Cover instance and using the greedy algorithm for Set Cover to solve the obtained instance (the latter step is non-trivial since the reduction gives a Set Cover instance of exponential size); later, Babenko et al. [8] gave a combinatorial O(log n)-approximation algorithm for HLp, for any p ∈ [1,∞]. 2 In this paper, we obtain the following results. We prove an Ω(log n) hardness Our Results. for HL1 and HL∞ on graphs that have multiple shortest paths between some pairs of vertices (assuming that P (cid:54)= NP). The result shows that the algorithms by Cohen et al. and Babenko et al. are asymptotically optimal. Since it is impossible to improve the approximation guarantee of O(log n) for arbitrary graphs, we focus on special families of graphs. We consider the family of graphs with unique shortest paths - graphs in which there is only one shortest path between every pair of vertices. This family of graphs appears in the majority of prior works on hub labeling (see e.g. [1, 9, 5]) and is very natural, in our opinion, since in real life all edge lengths are somewhat random, and, therefore, any two paths between two vertices u and v have different lengths. For such graphs, we design an approximation algorithm with approximation guarantee O(log D), where D is the shortest-path diameter of the graph (which equals the maximum hop length of a shortest path; see Section 2.1 for the definition); the algorithm works for every fixed p ∈ [1,∞) (the constant in the O-notation depends on p). In particular, this algorithm gives an O(log log n) factor approximation for graphs of diameter polylog n, while previously known algorithms give only an O(log n) approximation. Our algorithm crucially relies on the fact that the input graph has unique shortest paths; in fact, our lower bounds of Ω(log n) on the approximation ratio apply to graphs of constant diameter (with non-unique shortest paths). We also extensively study HL on trees. Somewhat surprisingly, the problem is not at all trivial on trees. In particular, the standard LP relaxation for the problem is not integral. We obtain the following results for trees. 1. Design a polynomial-time approximation scheme (PTAS) for HLp for every p ∈ [1,∞]. 2. Design an exact quasi-polynomial time algorithm for HLp for every p ∈ [1,∞], with the running time nO(log n) for p ∈ {1,∞} and nO(log2 n) for p ∈ (1,∞). 3. Analyze a simple combinatorial heuristic for trees, proposed by Peleg in 2000, and prove that it gives a 2-approximation for HL1 (we also show that this heuristic does not work well for HLp when p is large). Organization and overview of results. We first present an O(log D) approximation algorithm for graphs with unique shortest paths (see Sections 2 and 4). The algorithm solves a natural linear programming (LP) relaxation for the problem. Then, it uses the LP solution to find a system of "pre-hubs" {(cid:98)Hu}u∈V - pre-hubs do not necessarily satisfy the covering property (which hubs must labeling {(cid:98)Hu}u∈V to a hub labeling {Hu}u∈V . To this end, it runs a randomized "correlated" satisfy), instead, they satisfy a "weak" covering property (see Definition 4 for details). The cost of the pre-hub labeling is at most 2 times the LP value. Finally, the algorithm converts the pre-hub rounding scheme (which always finds a feasible hub labeling). The expected cost of the obtained labeling is at most O(log D) times the cost of the pre-hub labeling. Thus, the algorithm finds an O(log D)-approximate solution. We present the algorithm for HL1 in Section 4 and the algorithm for general HLp in Appendix A (the algorithms for HL1 and HLp are almost identical, but the analysis for HL1 is slightly simpler). A key property of our rounding procedure that we would like to emphasize is that it might add a vertex v to a hub set Hu, even if the corresponding LP indicator variable xuv (which, in an intended integral solution, is 1 if and only if v ∈ Hu) is set to zero in the fractional solution that we consider. This may seem surprising since often rounding schemes satisfy the following natural property: the rounding scheme adds an element to a set or makes an assignment only if the LP indicator variable 3 In particular, known rounding schemes for Set for the corresponding event is strictly positive. Cover, as well as many other thresholding and randomized rounding schemes, satisfy this property (we call such rounding schemes "natural"). However, we show in Appendix C that any rounding scheme that satisfies this property cannot give a better than Θ(log n) approximation for HL1. Then, in Section 5, we present our algorithms for trees. We consider a special class of hub labelings - hierarchical hub labelings - introduced by Abraham et al. [5] (we define and briefly discuss hierarchical hub labelings in Section 2.3). We start with proving that there is an optimal solution for a tree, which is a hierarchical hub labeling. We observe that there is a simple dynamic program (DP) of exponential size for computing the optimal hierarchical hub labeling on a tree: roughly speaking, we have an entry B[T (cid:48)] for every subtree T (cid:48) of the input tree T in the DP table; entry B[T (cid:48)] equals the cost of the optimal hub labeling for T (cid:48); its value can be computed from the values B[T (cid:48)(cid:48)] of subtrees T (cid:48)(cid:48) of T (cid:48). We then modify the DP and obtain a polynomial-time approximation scheme (PTAS). We do that by restricting the DP table to subtrees T (cid:48) with a "small boundary", proving that the obtained algorithm finds a (1 + ε)-approximate solution and bounding its running time. We also describe a quasi-polynomial time algorithm, based on the same DP approach. We first present the algorithm for HL1 and then a slightly more involved algorithm for any HLp (see Sections 5.3, 5.4, and Appendices B.1-B.4). In Section 5.2, we analyze the heuristic for trees proposed by Peleg [24]. Using the primal-dual technique, we show that the heuristic finds a 2-approximation for HL1. We also give an example where the gap between the optimal solution and the solution that the heuristic finds is 3/2−ε. (For p > 1, the gap between the optimal solution for HLp and the solution that the heuristic finds can be at least Ω(p/ log p).) Finally, in Section 6, we prove an Ω(log n)-hardness for HL1 and HL∞ by constructing a reduc- tion from Set Cover. Let us very informally describe the intuition behind the proof for HL1 (the proof for HL∞ is similar). Given a Set Cover instance, we construct a graph of constant diameter. In this graph, we have a special vertex r, vertices S1, . . . , Sm, and vertices x1, . . . , xn (as well as auxiliary vertices). Vertices S1, . . . , Sm correspond to the sets, and vertices x1, . . . , xn correspond to the elements of the universe in the Set Cover instance. We design the HL instance in such a way that we only have to satisfy the covering property for pairs (r, xi) (satisfying other pairs of vertices requires very few hubs); furthermore, the cost of the solution is approximately equal to the size of Hr (to guarantee that, we have many copies of r in the graph; their total contribution to the objective is much greater than the contribution of other vertices). There are multiple shortest paths between r and each xi: if xi ∈ Sj in the Set Cover instance, then there is a path r → Sj → xi. In order to cover the pair (r, xi) we have to choose one of the paths between r and xi, then choose a vertex w on it, and add it to Hr. The instance is designed in such a way, that if we choose path r → Sj → xi, then the "optimal choice" of w is Sj (in particular, we ensure that all xi cannot choose r as their hub; we do so by having many copies of vertex r and using auxiliary vertices). Therefore, to satisfy all pairs (r, xi), we have to find the smallest possible number of subsets Sj that cover vertices x1, . . . , xn and add them to Hr; that is, we need to solve the Set Cover instance. Note: For completeness, we also include a short note (Appendix D) in which we explain how many of our results can be extended to the case of directed graphs. 4 2 Preliminaries 2.1 Definitions We will say that a graph G = (V, E) with non-negative edge lengths l(e) has unique shortest paths if there is a unique shortest path between every pair of vertices. (We note that if the lengths of the edges are obtained by measurements, affected by some noise, the graph will satisfy the unique shortest path property with probability 1.) Recall that the shortest-path diameter D of a graph G is the maximum hop length of a shortest path in G (that is, it is the minimum number D such that every shortest path contains at most D edges). Note that D is upper bounded by the aspect ratio ρ of the graph: D ≤ ρ ≡ maxu,v∈V d(u, v) min(u,v)∈E l(u, v) . Here, d(u, v) is the shortest-path distance in G w.r.t. edge lengths l(e). In particular, if all edges in G have length at least 1, then D ≤ diam(G), where diam(G) = maxu,v∈V d(u, v). (u, u) requires that u ∈ Hu. We will use the following observation about hub labelings: the covering property for the pair 2.2 Linear programming relaxation In this section, we introduce a natural LP formulation of HL1. Let I be the set of all (unordered) pairs of vertices, including pairs (u, u), which we also denote as {u, u}, u ∈ V . We use indicator variables xuv, for all (u, v) ∈ V × V , that represent whether v ∈ Hu or not. Let Suv(≡ Svu) be the set of all vertices that appear in any of the (possibly many) shortest paths between u and v (including the endpoints u and v). Note that, although the number of shortest paths between u and v might, in general, be exponential in n, the set Suv can always be computed in polynomial time. In case there is a unique shortest path between u and v, we use both Suv and Puv to denote the vertices of that unique shortest path. The constraint implied by the covering property min{xuw, xvw} ≥ 1, for all {u, v} ∈ I". The resulting LP relaxation is given below. is "(cid:80) w∈Suv xuv v∈V min{xuw, xvw} ≥ 1, ∀{u, v} ∈ I, ∀(u, v) ∈ V × V. (cid:88) (cid:88) (cid:88) u∈V w∈Suv xuv ≥ 0, (LP1) min : s.t.: We note that the constraint (cid:80) (cid:80) w∈Suv min{xuw, xvw} ≥ 1 can be equivalently rewritten as follows: yuvw ≥ 1, xuw ≥ yuvw and xvw ≥ yuvw. Observe that the total number of variables and w∈Suv constraints remains polynomial, and thus, an optimal solution can always be found efficiently. One indication that the above LP is indeed an appropriate relaxation of HL is that we can reproduce the result of [15] and get an O(log n)-approximation algorithm for HL by using a very simple rounding scheme. But, we will use the above LP in more refined ways, mainly in conjunction with the notion of pre-hubs, which we introduce later on. 5 2.3 Hierarchical hub labeling We now define and discuss the notion of hierarchical hub labeling (HHL), introduced by Abraham et al. [5]. The presentation in this section follows closely the one in [5]. Definition 3. Consider a set system {Hu}u∈V . Let us say that v (cid:22) u if v ∈ Hu. The set system {Hu}u∈V is a hierarchical hub labeling if it is a hub labeling, and (cid:22) is a partial order. We will say that u is higher ranked than v if u (cid:22) v. Every two vertices u and v have a common hub w ∈ Hu ∩ Hv, and thus there is a vertex w such that w (cid:22) u and w (cid:22) v. Therefore, there is the highest ranked vertex in G. We now define a special type of hierarchical hub labelings. Given a total order π : [n] → V , labeling is the hub labeling H that is obtained as follows: v ∈ Hu if and only if a canonical π−1(v) ≤ π−1(w) for all w ∈ Suv. It is easy to see that a canonical labeling is a feasible hierarchical hub labeling. We say that a hierarchical hub labeling H respects a total order π if the implied (by H) partial order is consistent with π. Observe that there might be many different total orders that H respects. In [5], it is proved that all total orders that H respects have the same canonical labeling H(cid:48), and H(cid:48) is a subset of H. Therefore, H(cid:48) is a minimal hierarchical hub labeling that respects the partial order that H implies. From now on, all hierarchical hub labelings we consider will be canonical hub labelings. Any canonical hub labeling can be obtained by the following process [5]. Start with empty sets Hu, choose a vertex u1 and add it to each hub set Hu. Then, choose another vertex u2. Consider all pairs u and v that currently do not have a common hub, but such that u2 lies on a shortest path between u and v. Add u2 to Hu and Hv. Then, choose u3, . . . , un, and perform the same step. We get a hierarchical hub labeling. (The hub labeling, of course, depends on the order in which we choose vertices of G.) This procedure is particularly simple if the input graph is a tree (we will use this in Section 5). In a tree, we choose a vertex u1 and add it to each hub set Hu. We remove u1 from the tree and recursively process each connected component of G − u1. No matter how we choose vertices u1, . . . , un, we get a canonical hierarchical hub labeling; given a hierarchical hub labeling H, in order to get a canonical hub labeling H(cid:48), we need to choose the vertex ui of highest rank in T (cid:48) (w.r.t. to the order (cid:22) defined by H) when our recursive procedure processes subinstance T (cid:48). A canonical hub labeling gives a recursive decomposition of the tree to subproblems of gradually smaller size. 3 Pre-hub labeling We introduce the notion of a pre-hub labeling that we will use in designing algorithms for HL. Definition 4 (Pre-hub labeling). Consider a graph G = (V, E) and a length function l : E → R+; assume that all shortest paths are unique. A family of sets {(cid:98)Hu}u∈V , with (cid:98)Hu ⊆ V , is called a pre-hub labeling, if for every pair {u, v}, there exist u(cid:48) ∈ (cid:98)Hu ∩ Puv and v(cid:48) ∈ (cid:98)Hv ∩ Puv such that u(cid:48) ∈ Pv(cid:48)v; that is, vertices u, v, u(cid:48), and v(cid:48) appear in the following order along Puv: u, v(cid:48), u(cid:48), v (possibly, some of the adjacent, with respect to this order, vertices coincide). Observe that any feasible HL is a valid pre-hub labeling. We now show how to find a pre-hub labeling given a feasible LP solution. 6 Lemma 5. Consider a graph G = (V, E) and a length function l : E → R+; assume that all shortest paths are unique. Let {xuv} be a feasible solution to LP1. Then, there exists a pre-hub labeling u∈V (cid:98)Hu ≤ 2 OP T . Furthermore, the v∈V xuv. In particular, if {xuv} is an optimal LP solution and OP T {(cid:98)Hu}u∈V such that (cid:98)Hu ≤ 2(cid:80) is the (cid:96)1-cost of the optimal hub labeling (for HL1), then (cid:80) pre-hub labeling {(cid:98)Hu}u∈V can be constructed efficiently given the LP solution {xuv}. w∈T (cid:48) uv xuw. uv) =(cid:80) uv of Tu such that W(T (cid:48) a pre-hub labeling. To this end, we prove the following two claims. Proof. Let us fix a vertex u. We build the breadth-first search tree Tu (w.r.t. edge lengths; i.e. the shortest-path tree) from u; tree Tu is rooted at u and contains those edges e ∈ E that appear on a shortest path between u and some vertex v ∈ V . Observe that Tu is indeed a tree and is uniquely defined, since we have assumed that shortest paths in G are unique. For every vertex v, let T (cid:48) uv be the subtree of Tu rooted at vertex v. Given a feasible LP solution {xuv}, we define the weight of We now use the following procedure to construct set (cid:98)Hu. We process the tree Tu bottom up uv to be W(T (cid:48) T (cid:48) (cid:98)Hu. We then set xuw = 0 for all w ∈ T (cid:48) (i.e. we process a vertex v after we have processed all other vertices in the subtree rooted at v), uv) ≥ 1/2, we add vertex v to the set and whenever we detect a subtree T (cid:48) reach the root u of Tu. Observe that every time we add one vertex to (cid:98)Hu, we decrease the value of (cid:80) v∈V xuv by at least 1/2. Therefore, (cid:98)Hu ≤ 2 ·(cid:80) v∈V xuv. We will now show that sets {(cid:98)Hu} form uv, and continue (with the updated xuw values) until we Claim 6. Consider a vertex u and two vertices v1, v2 such that v1 ∈ Puv2. If (cid:98)Hu ∩ Pv1v2 = ∅, then (cid:80) Proof. Consider the execution of the algorithm that defined (cid:98)Hu. Consider the moment M when we processed vertex v1. Since we did not add v1 to (cid:98)Hu, we had W(T (cid:48) uv1, we have(cid:80) M . Since none of the vertices on the path Pv1v2 were added to (cid:98)Hu, none of the variables xuw for w∈Pv1v2 for w ∈ Pv1v2. We conclude that(cid:80) w ∈ Pv1v2 had been set to 0. Therefore, x(cid:48) Claim 7. For any shortest path Puv, let u(cid:48) ∈ (cid:98)Hu ∩ Puv be the vertex closest to v among all vertices w∈Pv1v2 in (cid:98)Hu ∩ Puv and v(cid:48) ∈ (cid:98)Hv ∩ Puv be the vertex closest to u among all vertices in (cid:98)Hv ∩ Puv. Then u(cid:48) ∈ Pv(cid:48)v. (Note that (cid:98)Hu ∩ Puv (cid:54)= ∅, since always xuu = 1 and hence u ∈ (cid:98)Hu ∩ Puv; similarly, (cid:98)Hv ∩ Puv (cid:54)= ∅.) uw = xuw (where xuw is the initial value of the variable) xuw < 1/2, as required. uv1) < 1/2. In particular, uw is the value of xuw at the moment x(cid:48) uw < 1/2, where x(cid:48) since Pv1v2 lies in T (cid:48) xuw < 1/2. w∈Pv1v2 Proof. Let us assume that this is not the case; that is, u(cid:48) /∈ Pv(cid:48)v. Then v(cid:48) (cid:54)= u and u(cid:48) (cid:54)= v (otherwise, we would trivially have u(cid:48) ∈ Pv(cid:48)v). Let u(cid:48)(cid:48) be the first vertex after u(cid:48) on the path Pu(cid:48)v, and v(cid:48)(cid:48) be the first vertex after v(cid:48) on the path Pv(cid:48)u. Since u(cid:48) /∈ Pv(cid:48)v, every vertex of Puv lies either on Pv(cid:48)(cid:48)u or Pu(cid:48)(cid:48)v, or both (i.e. Pv(cid:48)(cid:48)u ∪ Pu(cid:48)(cid:48)v = Puv). By our choice of u(cid:48), there are no pre-hubs for u on Pu(cid:48)(cid:48)v. By Claim 6, (cid:80) Similarly,(cid:80) w∈Puv(cid:48)(cid:48) xvw +(cid:80) xuw ≥(cid:80) Claim 7 shows that {(cid:98)Hu} is a valid pre-hub labeling. We get a contradiction since {xuv} is a feasible LP solution. xvw < 1/2. Thus, 1 >(cid:80) xuw < 1/2. min{xuw, xvw}. w∈Pv(cid:48)(cid:48)u w∈Pu(cid:48)(cid:48)v w∈Pu(cid:48)(cid:48)v w∈Puv 7 4 Hub labeling on graphs with unique shortest paths Consider Algorithm 1 in the figure. The algorithm solves the LP relaxation and computes a In this section, we present an O(log D)-approximation algorithm for HLp on graphs with unique shortest paths, where D is the shortest-path diameter of the graph. The algorithm works for every fixed p ∈ [1,∞) (the hidden constant factor in the approximation factor O(log D) depends on p). To simplify the exposition, we present the algorithm for HL1 in this section, and the algorithm for HLp, for arbitrary fixed p ≥ 1, in Appendix A. pre-hub labeling {(cid:98)Hu}u∈V as described in Lemma 5. Then it chooses a random permutation π of Hu if there is a pre-hub u(cid:48) ∈ (cid:98)Hu such that the following conditions hold: πi lies on the path Puu(cid:48), V and goes over all vertices one-by-one in the order specified by π: π1, π2,. . . , πn. It adds πi to there are no pre-hubs for u between πi and u(cid:48) (other than u(cid:48)), and currently there are no hubs for u between πi and u(cid:48). 2 Obtain a set of pre-hubs {(cid:98)Hu}u∈V from x as described in Lemma 5. 1 Solve LP1 and get an optimal solution {xuv}(u,v)∈V ×V . 3 Generate a random permutation π : [n] → V of the vertices. 4 Set Hu = ∅, for every u ∈ V . 5 for i = 1 to n do 6 for every u ∈ V do for every u(cid:48) ∈ (cid:98)Hu, such that πi ∈ Puu(cid:48) and Pπiu(cid:48) ∩ (cid:98)Hu = {u(cid:48)} do if Pπiu(cid:48) ∩ Hu = ∅ then Hu := Hu ∪ {πi} 7 8 9 end end 10 11 end 12 Return {Hu}u∈V . Algorithm 1: Algorithm for HL1 on graphs with unique shortest paths Theorem 8. Algorithm 1 always returns a feasible hub labeling H. The cost of the hub labeling is u Hu] = O(log D) · OP TLP1 in expectation, where OP TLP1 is the optimal value of LP1. Remark 9. Note that Algorithm 1 can be easily derandomized using the method of conditional instead of choosing a random permutation π, we first choose π1 ∈ V , then π2 ∈ expectations: V \ {π1} and so on; each time we choose πi ∈ V \ {π1, . . . , πi−1} so as to minimize the conditional u Hu π1, . . . , πi]. E[(cid:80) expectation E[(cid:80) if u = v since u ∈ (cid:98)Hu and thus u ∈ Hu. So, we assume that u (cid:54)= v. Consider the path Puv. Because of the pre-hub property, there exist u(cid:48) ∈ (cid:98)Hu and v(cid:48) ∈ (cid:98)Hv such that u(cid:48) ∈ Pv(cid:48)v. In fact, (cid:98)Hu ∩ (Pu(cid:48)v(cid:48) \ {u(cid:48), v(cid:48)}) = (cid:98)Hv ∩ (Pu(cid:48)v(cid:48) \ {u(cid:48), v(cid:48)}) = ∅ (for instance, choose the closest pair of u(cid:48) and there may be several possible ways to choose such u(cid:48) and v(cid:48). Let us choose u(cid:48) and v(cid:48) so that v(cid:48) among all possible pairs). Consider the first iteration i of the algorithm such that πi ∈ Pu(cid:48)v(cid:48). We claim that the algorithm adds πi to both Hu and Hv. Indeed, let us verify that the algorithm adds πi to Hu. We have: (i) πi lies on Pv(cid:48)u(cid:48) ⊂ Puu(cid:48), (ii) there are no pre-hubs for u on Pv(cid:48)u(cid:48) ⊃ Pπiu(cid:48) Proof. We first show that the algorithm always finds a feasible hub labeling. Consider a pair of vertices u and v. We need to show that they have a common hub on Puv. The statement is true 8 other than u(cid:48), (iii) πi is the first vertex we process on the path Pu(cid:48)v(cid:48), thus currently there are no hubs on Pu(cid:48)v(cid:48). Therefore, the algorithm adds πi to Hu. Similarly, the algorithm adds πi to Hv. Now we upper bound the expected cost of the solution. We will charge every hub that we add to Hu to a pre-hub in (cid:98)Hu; namely, when we add πi to Hu (see line 8 of the algorithm), we charge it to pre-hub u(cid:48). For every vertex u, we have (cid:98)Hu ≤ 2(cid:80) u(cid:48) ∈ (cid:98)Hu is charged at most O(log D) times in expectation. Therefore, the expected number of hubs in Hu is at most O(2(cid:80) Consider a vertex u and a pre-hub u(cid:48) ∈ (cid:98)Hu (u(cid:48) (cid:54)= u). Let u(cid:48)(cid:48) ∈ (cid:98)Hu be the closest pre-hub We get that the number of hubs charged to u(cid:48) is (cid:80)k E(cid:2)(cid:80) to u(cid:48) on the path Pu(cid:48)u. Observe that all hubs charged to u(cid:48) lie on the path Pu(cid:48)(cid:48)u(cid:48) \ {u(cid:48)(cid:48)}. Let k = Pu(cid:48)(cid:48)u(cid:48) \ {u(cid:48)(cid:48)}. Note that k ≤ D. Consider the order σ : [k] → Pu(cid:48)(cid:48)u(cid:48) \ {u(cid:48)(cid:48)} in which the vertices of Pu(cid:48)(cid:48)u(cid:48) \ {u(cid:48)(cid:48)} were processed by the algorithm (σ is a random permutation). Note that σi charges u(cid:48) if and only if σi is closer to u(cid:48) than σ1, . . . , σi−1. The probability of this event is 1/i. 1 i = log k + O(1), in expectation. Hence, u∈V Hu(cid:3) ≤ 2 (log D + O(1)) · OP TLP1. w xuw × log D). w xuw. We are going to show that every i=1 5 Hub labeling on trees In this section, we study the Hub Labeling problem on trees. Observe that if the graph is a tree, the length function l does not play any role in the task of choosing the optimal hubs (it only affects the actual distances between the vertices), and so we assume that we are simply given an unweighted tree T = (V, E), V = n. We start with proving a structural result about optimal solutions in trees; we show that there always exists a hierarchical hub labeling that is also an optimal hub labeling. We then analyze a simple and fast heuristic for HL on trees proposed by Peleg [24], and prove that it gives a 2-approximation for HL1. We do not know if our analysis is tight, but we prove that 2 − ε)OP T there are instances where the heuristic finds a suboptimal solution of cost at least ( 3 (for every ε > 0). Finally, we present a polynomial-time approximation scheme (PTAS) and a quasi-polynomial time exact algorithm for HL1 on trees. We then modify our approach in order to obtain a PTAS and a quasi-polynomial-time exact algorithm for HLp on trees for any p ∈ [1,∞], thus providing a thorough algorithmic understanding of HL, under any cost function, on trees. 5.1 Optimal solutions for trees are hierarchical We show that any feasible hub labeling solution H can be converted to a hierarchical hub labeling H(cid:48) of at most the same (cid:96)p-cost (for every p ∈ [1,∞]). Therefore, there always exists an optimal solution that is hierarchical. Theorem 10. For every tree T = (V, E), there always exists an optimal HLp solution that is hierarchical, for every p ∈ [1,∞]. Proof. To prove this, we consider a feasible solution H and convert it to a hierarchical solution H(cid:48) such that H(cid:48) u ≤ Hu for every u. In particular, the (cid:96)p-cost of H(cid:48) is at most the (cid:96)p-cost of H for every p. The construction is recursive (the underlying inductive hypothesis for smaller subinstances being u ≤ Hu for every that a feasible HL H can be converted to a hierarchical solution H(cid:48) such that H(cid:48) u.) First, for each u ∈ V , define an induced subtree Tu ⊆ T as follows: Tu is the union of paths 9 Puv over all v ∈ Hu. In other words, a vertex w belongs to Hu if there is a hub v ∈ Hu such that w ∈ Puv. Note that Tu is a connected subtree of T . The crucial property that we need is that Tu ∩ Tv (cid:54)= ∅, for every u, v ∈ V . To see this, consider any pair {u, v}, u (cid:54)= v. We know that Hu ∩ Hv ∩ Puv (cid:54)= ∅. Let w ∈ Hu ∩ Hv ∩ Puv. By construction, w ∈ Tu and w ∈ Tv, and so Tu ∩ Tv (cid:54)= ∅. We now use the fact that a family of subtrees of a tree satisfies the Helly property (which first appeared as a consequence of the work of Gilmore [19], and more explicitly a few years later in [21]): suppose that we are given a family of subtrees of T such Let r ∈(cid:84) that every two subtrees in the family intersect, then all subtrees in the family intersect (i.e. they share a common vertex). Denote the connected component that contains vertex u by Qu. Let (cid:101)Hu = Hu ∩ Qu. Note that u∈V Tu. We remove r from T . Consider the connected components of T−r: Q1, . . . , Qc. (cid:101)Hu ≤ Hu − 1, since r ∈ Tu, which, by the definition of Tu, implies that there exists some Puv ⊂ Qu = Qv = Qi, we have w ∈ (cid:101)Hu∩(cid:101)Hv∩Puv. Therefore, {(cid:101)Hu : u ∈ Qi} is a feasible hub labeling u ≤ (cid:101)Hu ≤ Hu − 1. for Qi. Now, we recursively find hierarchical hub labelings for Q1, . . . , Qc. Denote the hierarchical u. The inductive hypothesis ensures that H(cid:48)(cid:48) hub labeling for u in Qu by H(cid:48)(cid:48) u is a hub labeling. v ∩ Puv (cid:54)= ∅ since H(cid:48)(cid:48) is u ∩ H(cid:48)(cid:48) Consider u, v ∈ V . If u, v ∈ Qi for some i, then H(cid:48) v ∩ Puv. Also, if either u = r a hub labeling for Qi. If u ∈ Qi and v ∈ Qj (i (cid:54)= j), then r ∈ H(cid:48) v ∩ Puv. We conclude that H(cid:48) is a hub labeling. Furthermore, H(cid:48) or v = r, then again r ∈ H(cid:48) is a hierarchical hub labeling: r (cid:22) u for every u and (cid:22) is a partial order on every set Qi; elements from different sets Qi and Qj are not comparable w.r.t. (cid:22). w /∈ Qu with w ∈ Hu. Consider u, v ∈ Qi. They have a common hub w ∈ Hu ∩ Hv ∩ Puv. Since r = {r}. We show that H(cid:48) v ∩ Puv ⊃ H(cid:48)(cid:48) u ∩ H(cid:48) u = H(cid:48)(cid:48) u ∪ {r}, for u (cid:54)= r, and H(cid:48) Finally, define H(cid:48) We have H(cid:48) u = H(cid:48)(cid:48) u + 1 ≤ Hu for u (cid:54)= r and H(cid:48) r = 1 ≤ Hr, as required. u ∩ H(cid:48) u ∩ H(cid:48) This theorem allows us to restrict our attention only to hierarchical hub labelings, which have a much simpler structure than arbitrary hub labelings, when we design algorithms for HL on trees. 5.2 An analysis of Peleg's heuristic for HL1 on trees In this section, we analyze a purely combinatorial algorithm for HL proposed by Peleg in [24] and show that it returns a hierarchical 2-approximate hub labeling on trees (see Algorithm 2). (Peleg's result [24], expressed in the hub labeling context, shows that the algorithm returns a hub labeling H with maxu∈V Hu = O(log n) for a tree on n vertices.) Definition 11. Consider a tree T on n vertices. We say that a vertex u is a balanced separator vertex if every connected component of T − u has at most n/2 vertices. The weighted balanced separator vertex for a vertex-weighted tree is defined analogously. It is well-known that every tree T has a balanced separator vertex (in fact, a tree may have either exactly one or exactly two balanced separator vertices) and such a separator vertex can be found efficiently (i.e. in linear time) given T . The algorithm by Peleg, named here Tree Algorithm, is described in the figure below (Algorithm 2). It is easy to see that the algorithm always returns a feasible hierarchical hub labeling, in total time O(n log n). To bound its cost, we use the primal–dual approach. We consider the dual of LP1. Then, we define a dual feasible solution whose cost is at least half of the cost of the solution that the algorithm returns. We formally prove the following theorem. 10 Input: a tree T (cid:48) Output: a hub labeling H for T (cid:48) 1 Find a balanced separator vertex r in T (cid:48). 2 Remove r and recursively find a HL in each subtree Ti of T (cid:48) − r. Let H(cid:48) be the labeling obtained by the recursive procedure. (If T (cid:48) consists of a single vertex and, therefore, T (cid:48) − r is empty, the algorithm does not make any recursive calls.) 3 Return Hu := H(cid:48) u ∪ {r}, for every vertex u in T (cid:48) − {r}, and Hr = {r}. Algorithm 2: Tree Algorithm min : s.t.: xuv v∈V yuvw ≥ 1, ∀{u, v} ∈ I (PRIMAL-LP) (cid:88) (cid:88) (cid:88) u∈V w∈Puv xuw ≥ yuvw, xvw ≥ yuvw, xuv ≥ 0, yuvw ≥ 0, (DUAL-LP) variables: αuv and βuvw for w ∈ Puv (cid:88) max : αuv {u,v}∈I s.t.: αuv ≤ βuvw + βvuw, ∀{u, v} ∈ I , u (cid:54)= v ∀{u, v} ∈ I, ∀ w ∈ Puv ∀{u, v} ∈ I, ∀ w ∈ Puv ∀{u, v} ∈ V × V ∀{u, v} ∈ I, ∀ w ∈ Puv αuu ≤ βuuu, (cid:88) βuvw ≤ 1, v:w∈Puv αuv ≥ 0, βuvw ≥ 0, βvuw ≥ 0, ∀ w ∈ Puv ∀ u ∈ V ∀ (u, w) ∈ V × V ∀{u, v} ∈ I ∀{u, v} ∈ I,∀ w ∈ Puv ∀{u, v} ∈ I,∀ w ∈ Puv Table 1: Primal and Dual LPs for HL on trees Theorem 12. The Tree Algorithm is a 2-approximation algorithm for HL1 on trees. Proof. The primal and dual linear programs for HL on trees are given in Figure 1. We note that the dual variables {auv}u,v correspond to unordered pairs {u, v} ∈ I, while the variables {βuvw}u,v,w correspond to ordered pairs (u, v) ∈ V × V , i.e. βuvw and βvuw are different variables. As already mentioned, it is straightforward that the algorithm finds a feasible hierarchical hub labeling. We now bound the cost of the solution by constructing a fractional solution for the DUAL-LP. To this end, we track the execution of the algorithm and gradually define the fractional solution. Consider one iteration of the algorithm in which the algorithm processes a tree T (cid:48) (T (cid:48) is a subtree of T ). Let r be the balanced separator vertex that the algorithm finds in line 1. At this iteration, we assign dual variables auv and βuvw for those pairs u and v in T (cid:48) for which Puv contains vertex r. Let n(cid:48) be the size of T (cid:48), A = 2/n(cid:48) and B = 1/n(cid:48). Denote the connected components of T (cid:48) − r by T1, ..., Tt; each Ti is a subtree of T (cid:48). Observe that we assign a value to each auv and βuvw exactly once. Indeed, since we split u and v at some iteration, we will assign a value to auv and βuvw at least once. Consider the first iteration in which we assign a value to auv and βuvw. At this iteration, vertices u and v lie in different subtrees Ti and Tj of T (cid:48) (or r ∈ {u, v}). Therefore, vertices u and v do not lie in the same subtree T (cid:48)(cid:48) in the consecutive iterations; consequently, we will not assign new values to auv and βuvw later. For u ∈ Ti and v ∈ Tj (with i (cid:54)= j), we define αuv and βuvw as follows 11 • αuv = A, • For w ∈ Pur \ {r}: βuvw = 0 and βvuw = A. • For w ∈ Prv \ {r}: βuvw = A and βvuw = 0. • For w = r: βuvr = βvur = B. For u ∈ Ti and v = r, we define αuv and βuvw as follows • αur = A. • For w ∈ Pur \ {r}: βurw = 0 and βruw = A. • For w = r: βurr = βrur = B. Let us verify now that the third constraint,(cid:80) Finally, we set αrr = βrrr = B. We now show that the obtained solution {α, β} is a feasible solution for DUAL-LP. Consider the first constraint: αuv ≤ βuvw + βvuw. If u (cid:54)= r or v (cid:54)= r, A = αuv = βuvw + βvuw = 2B. The second constraint is satisfied since αrr = βrrr. βuvw ≤ 1, is satisfied. Consider a non-zero variable βuvw appearing in the sum. Consider the iteration of the algorithm in which we assign βuvw a value. Let r be the balanced separator vertex during this iteration. Then, r ∈ Puv (otherwise, we would not assign any value to βuvw) and w ∈ Prv. Therefore, r ∈ Puw; that is, the algorithm assigns the value to βuvw in the iteration when it splits u and w (the only iteration when r ∈ Puw). In particular, we assign a value to all non-zero variables βuvw appearing in the constraint in the same iteration of the algorithm. Let us consider this iteration. If u ∈ Ti ∪{r} and w ∈ Tj, then every v satisfying w ∈ Puv lies in Tj. For every such v, we have v:w∈Puv βuvw = A. Therefore, (cid:88) v:w∈Puv βuvw ≤ Tj · A ≤ n(cid:48) (cid:88) (cid:88) 2 · 2 n(cid:48) = 1, B ≤ n(cid:48)B = 1, as required. If u ∈ Ti ∪ {r} and w = r, then we have βuvr = βuvw = (cid:88) v:w∈Puv v:r∈Puv v:r∈Puv as required. We have showed that {α, β} is a feasible solution. Now we prove that its value is at least half of the value of the hub labeling found by the algorithm. Since the value of any feasible solution of DUAL-LP is at most the cost of the optimal hub labeling, this will prove that the algorithm gives a 2-approximation. We consider one iteration of the algorithm. In this iteration, we add r to the hub set Hu of every vertex u ∈ T (cid:48). Thus, we increase the cost of the hub labeling by n(cid:48). We are going to show that the dual variables that we set during this iteration contribute at least n(cid:48)/2 to the value of DUAL-LP. i ki = n(cid:48) − 1. The contribution C of the variables αuv that we set during this iteration to the objective function equals 2 n(cid:48) Let ki = Ti ≤ n(cid:48)/2, for all i ∈ {1, . . . , t}. We have(cid:80) (cid:88) (cid:88) Now, since(cid:80) j:j(cid:54)=i kj = (n(cid:48) − 1 − ki) ≥ (n(cid:48) − 2)/2, we have (cid:88) kikj + 2n(cid:48) − 1 n(cid:48) . kikj + A(n(cid:48) − 1) + B = αur + αrr = A (cid:88) (cid:88) (cid:88) (cid:88) (cid:88) i<j u∈Ti,v∈Tj u∈Ti i αuv + C = i<j (cid:88) i (n(cid:48) − 1)(n(cid:48) − 2) 2n(cid:48) . ki =  ≥ n(cid:48) − 2 2n(cid:48) kj 2 n(cid:48) i<j kikj = kikj = 1 n(cid:48) i(cid:54)=j 1 n(cid:48) ki i (cid:88) (cid:88) i<j j:j(cid:54)=i 12 Thus, C ≥ (4n(cid:48) − 2) + (n(cid:48)2 − 3n(cid:48) + 2) 2n(cid:48) n(cid:48) + 1 2 . = We proved that C ≥ n(cid:48)/2. This finishes the proof. Given the simplicity of the Tree Algorithm, it is interesting to understand whether the 2 approx- imation factor is tight or not. We do not have a matching lower bound, but we show an asymptotic lower bound of 3/2. The instances that give this 3/2 lower bound are the complete binary trees. We present the proof of the following lemma in Appendix B.5. Lemma 13. The approximation factor of the Tree Algorithm is at least 3/2 − ε, for every fixed ε > 0. Remark 14. The Tree Algorithm does not find a good approximation for the (cid:96)p-cost, when p is large. Let k > 1 be an integer. Consider a tree T defined as follows: it consists of a path a1, . . . , ak and leaf vertices connected to the vertices of the path; vertex ai is connected to 2k−i − 1 leaves. The tree consists of n = 2k − 1 vertices. It is easy to see that the Tree Algorithm will first choose vertex a1, then it will process the subtree of T that contains ak and will choose a2, then a3 and so this hub labeling is greater than k. However, there is a hub labeling (cid:101)H for the path a1, . . . , ak with on. Consequently, the hub set Hak equals {a1, . . . , ak} in the obtained hub labeling. The (cid:96)p-cost of (cid:101)Hai ≤ O(log k), for all i ∈ [k]. This hub labeling can be extended to a hub labeling of T , by letting (cid:101)Hl = (cid:101)Hai ∪ {l} for each leaf l adjacent to a vertex ai. Then we still have (cid:101)Hu ≤ O(log k), for any vertex u ∈ T . The (cid:96)p-cost of this solution is O(n1/p log k). Thus, for k = p, the gap between the solution H and the optimal solution is at least Ω(p/ log p). For p = ∞, the gap is at least Ω(log n/ log log n), asymptotically. 5.3 A PTAS for HL on trees We now present a polynomial-time approximation scheme (PTAS) for HL on trees. For simplicitly, we only present the algorithm for HL1, based on dynamic programming (DP). A modified DP approach along similar lines can also be used in the case of HLp, for any p ∈ [1,∞]. More details and formal proofs can be found in Appendix B.1 (for HLp, for every p ∈ [1, +∞)), and Appendix B.2 (for HL∞). Theorem 10 shows that we can restrict our attention only to hierarchical hub labelings. That is, we can find an optimal solution by choosing an appropriate vertex r, adding r to every Hu, and then recursively solving HL on each connected component of T − r (see Section 2.3). Of course, we do not know what vertex r we should choose, so to implement this approach, we use dynamic programming (DP). Let us first consider a very basic dynamic programming solution. We store a table B with an entry B[T (cid:48)] for every subtree T (cid:48) of T . Entry B[T (cid:48)] equals the cost of the optimal hub labeling for tree T (cid:48). Now if r is the common hub of all vertices in T (cid:48), we have (cid:88) (cid:88) B[T (cid:48)] = T (cid:48) + B[T (cid:48)(cid:48)] T (cid:48)(cid:48) is a connected component of T (cid:48)−r (the term T (cid:48) captures the cost of adding r to each Hu). We obtain the following recurrence formula for the DP: B[T (cid:48)(cid:48)]. (1) B[T (cid:48)] = T (cid:48) + min r∈T (cid:48) T (cid:48)(cid:48) is a connected component of T (cid:48)−r 13 (cid:0)n (cid:1) +(cid:80) i=2 i Fix ε < 1. Let k = 4 · (cid:100)1/ε(cid:101). ∂(T (cid:48)) ≤ k. Then, the total number of entries is upper bounded by (cid:80)k The problem with this approach, however, is that a tree may have exponentially many subtrees, which means that the size of the dynamic program and the running time may be exponential. To work around this, we will instead store B[T (cid:48)] only for some subtrees T (cid:48), specifically for subtrees with a "small boundary". For each subtree T (cid:48) of T , we define its boundary ∂(T (cid:48)) as ∂(T (cid:48)) := {v /∈ T (cid:48) : ∃u ∈ T (cid:48) with (u, v) ∈ E}. Consider now a subtree T (cid:48) of T and its boundary S = ∂(T (cid:48)). Observe that if S ≥ 2, then the set S uniquely identifies the subtree T (cid:48): T (cid:48) is the unique connected component of T − S that has all vertices from S on its boundary (every other connected component of T − S has only one vertex from S on its boundary). If S = 1, that is, S = {u} for some u ∈ V , then it is easy to see that u can serve as a boundary point for deg(u) different subtrees. In our dynamic program, we only consider subtrees T (cid:48) with u∈V deg(u) = O(nk). Note that now we cannot simply use formula (1). In fact, if ∂(T (cid:48)) < k, formula (1) is well defined since each connected component T (cid:48)(cid:48) of T (cid:48) − r has boundary of size at most ∂(T (cid:48)) + 1 ≤ k for any choice of r (since ∂(T (cid:48)(cid:48)) ⊆ ∂(T (cid:48)) ∪ {r}). However, if ∂(T (cid:48)) = k, it is possible that ∂(T (cid:48)(cid:48)) = k + 1, and formula (1) cannot be used. Accordingly, there is no clear way to find the optimal vertex r. Instead, we choose a vertex r0 such that for every connected component T (cid:48)(cid:48) of T (cid:48) − r0, we have ∂(T (cid:48)(cid:48)) ≤ k/2 + 1. To prove that such a vertex exists, we consider the tree T (cid:48) with vertex weights w(u) = {v ∈ ∂(T (cid:48)) : (u, v) ∈ E} and find a balanced separator vertex r0 for T (cid:48) w.r.t. weights w(u) (see Definition 11). Then, the weight w of every connected component T (cid:48)(cid:48) of T (cid:48) − r0 is at most k/2. Thus, ∂(T (cid:48)(cid:48)) ≤ k/2 + 1 < 3k/4 < k (we add 1 because r0 ∈ ∂(T (cid:48)(cid:48))). The above description implies that the only cases where our algorithm does not perform "op- timally" are the subproblems T (cid:48) with ∂(T (cid:48)) = k. It is also clear that these subproblems cannot occur too often, and more precisely, we can have at most 1 every k/2 steps during the recursive decomposition into subproblems. Thus, we will distribute the cost (amortization) of each such non- optimal step that the algorithm makes over the previous k/4 steps before it occurs, whenever it occurs, and then show that all subproblems with boundary of size at most 3k/4 are solved "almost" optimally (more precisely, the solution to such a subproblem is (1 + 4/k)-approximately optimal). This implies that the final solution will also be (1 + 4/k)-approximately optimal, since its boundary size is 0. We now describe our algorithm in more detail. We keep two tables B[T (cid:48)] and C[T (cid:48)]. We will define their values so that we can find, using dynamic programming, a hub labeling for T (cid:48) of cost at most B[T (cid:48)]+C[T (cid:48)]. Informally, the table C can be viewed as some extra budget that we use in order to pay for all the recursive steps with ∂(T (cid:48)) = k. We let C[T (cid:48)] = max{0, (∂(T (cid:48)) − 3k/4) · 4T (cid:48)/k} for every T (cid:48) with ∂(T (cid:48)) ≤ k. We define B (for T (cid:48) ≥ 3) by the following recurrence (where r0 is a balanced separator): (cid:88) B[T (cid:48)(cid:48)] , B[T (cid:48)(cid:48)] , if ∂(T (cid:48)) < k, if ∂(T (cid:48)) = k. B[T (cid:48)] = (1 + 4/k) · T (cid:48) + min r∈T (cid:48) (cid:88) T (cid:48)(cid:48) is a connected component of T (cid:48)−r B[T (cid:48)] = T (cid:48)(cid:48) is a connected component of T (cid:48)−r0 The base cases of our recursive formulas are when the subtree T (cid:48) is of size 1 or 2. In this case, we simply set B[T (cid:48)] = 1, if T (cid:48) = 1, and B[T (cid:48)] = 3, if T (cid:48) = 2. In order to fill in the table, we generate all possible subsets of size at most k that are candidate boundary sets, and for each such set we look at the resulting subtree, if any, and compute its size. 14 We process subtrees in increasing order of size, which can be easily done if the generated subtrees are kept in buckets according to their size. Overall, the running time will be nO(k). We will now show that the algorithm has approximation factor (1 + 4/k) for any k = 4t, t ≥ 1. That is, it is a polynomial-time approximation scheme (PTAS). Theorem 15. The algorithm is a polynomial-time approximation scheme (PTAS) for HL1 on trees. k B[T (cid:48)] + C[T (cid:48)], and B[T (cid:48)] ≤(cid:0)1 + 4 (cid:1)· OP TT (cid:48). Then, the total cost of the solution to the original HL Proof. We first argue about the approximation guarantee. The argument consists of an induction that incorporates the amortized analysis that was described above. More specifically, we will show that for any subtree T (cid:48), with ∂(T (cid:48)) ≤ k, the total cost of the algorithm's solution is at most instance is at most B[T ]+C[T ], and, since C[T ] = 0, we get that the cost is at most (1+4/k)·OP T . The induction is on the size of the subtree T (cid:48). For T (cid:48) = 1 or T (cid:48) = 2, the hypothesis holds. Let's assume now that it holds for all trees of size at most t ≥ 2. We will argue that it then holds for trees T (cid:48) of size t + 1. We distinguish between the cases where ∂(T (cid:48)) < k and ∂(T (cid:48)) = k: Case ∂(T (cid:48)) < k: Let u0 ∈ T (cid:48) be the vertex that the algorithm picks and removes. The vertex u0 T (cid:48)(cid:48) is a connected component of T (cid:48)−r(cid:48) B[T (cid:48)(cid:48)], and thus, using the induction hypothesis, we get that the total cost of the solution returned by the algorithm is at most: is the minimizer of the expression minr(cid:48)∈T (cid:48)(cid:80) ALG(T (cid:48)) ≤ T (cid:48) + ≤ T (cid:48) + = T (cid:48) + (cid:16) B[T (cid:48)(cid:48)] + C[T (cid:48)(cid:48)] B[T (cid:48)(cid:48)] + (cid:17) (cid:88) T (cid:48)(cid:48) is comp. of T (cid:48)−u0 T (cid:48)(cid:48) is comp. of T (cid:48)−u0 T (cid:48)(cid:48) is comp. of T (cid:48)−u0 T (cid:48)(cid:48) is comp. of T (cid:48)−u0 B[T (cid:48)(cid:48)] + max{0,∂(T (cid:48)) + 1 − 3k/4} · (4/k) · T (cid:48)(cid:48) T (cid:48)(cid:48) is comp. of T (cid:48)−u0 max(cid:8)0, (∂(T (cid:48)) + 1 − 3k/4) · 4T (cid:48)(cid:48)/k(cid:9) (cid:88) (cid:88) (cid:88) (cid:88) (cid:88)  (cid:88) ≤ T (cid:48) + T (cid:48)(cid:48) is comp. of T (cid:48)−u0 ≤ (1 + 4/k) · T (cid:48) + B[T (cid:48)(cid:48)] + 4T (cid:48)/k + max{0,∂(T (cid:48)) − 3k/4} · 4T (cid:48)/k  + C[T (cid:48)] the highest rank in this optimal solution. We have, OP TT (cid:48) = T (cid:48) +(cid:80) We proved the first part. We now have to show that B[T (cid:48)] ≤ (1 + 4/k)OP TT (cid:48). Consider an optimal HL for T (cid:48). We may assume that it is a hierarchical labeling. Let r ∈ T (cid:48) be the vertex with T (cid:48)(cid:48) is comp. of T (cid:48)−r OP TT (cid:48)(cid:48). By = B[T (cid:48)] + C[T (cid:48)]. T (cid:48)(cid:48) is comp. of T (cid:48)−u0 B[T (cid:48)(cid:48)] definition, we have that (cid:88) B[T (cid:48)] = (1 + 4/k)T (cid:48) + min u∈T (cid:48) B[T (cid:48)(cid:48)] (cid:88) T (cid:48)(cid:48) is comp. of T (cid:48)−u B[T (cid:48)(cid:48)] ≤ (1 + 4/k)T (cid:48) + T (cid:48)(cid:48) is comp. of T (cid:48)−r (1 + 4/k)T (cid:48) + (1 + 4/k) · (ind.hyp.)≤ (cid:88) T (cid:48)(cid:48) is comp. of T (cid:48)−r OP TT (cid:48)(cid:48) = (1 + 4/k) · OP TT (cid:48). 15 Case ∂(T (cid:48)) = k: Using the induction hypothesis, we get that the total cost of the solution returned by the algorithm is at most: (cid:88) (cid:88) ALG(T (cid:48)) ≤ T (cid:48) + B[T (cid:48)(cid:48)] + C[T (cid:48)(cid:48)]. T (cid:48)(cid:48) is comp. of T (cid:48)−r0 T (cid:48)(cid:48) is comp. of T (cid:48)−r0 By our choice of r0, we have ∂(T (cid:48)(cid:48)) ≤ 3k/4, and so C[T (cid:48)(cid:48)] = 0, for all trees T (cid:48)(cid:48) of the forest T (cid:48) − r0. Thus, (cid:88) ALG(T (cid:48)) ≤ T (cid:48) + B[T (cid:48)(cid:48)] T (cid:48)(cid:48) is comp. of T (cid:48)−r0 = C[T (cid:48)] + B[T (cid:48)]. (cid:88) We now need to prove that B[T (cid:48)] ≤ (1 + 4/k) · OP TT (cid:48). We have, (cid:88) (cid:18) (cid:19) OP TT (cid:48)(cid:48) ≤ (cid:19) (cid:18) 1 + 4 k OP TT (cid:48), 1 + 4 k B[T (cid:48)] = B[T (cid:48)(cid:48)] (ind.hyp.)≤ where in the the last inequality we use that(cid:80) T (cid:48)(cid:48) is comp. of T (cid:48)−r0 T (cid:48)(cid:48) is comp of T (cid:48)−r0 T (cid:48)(cid:48) OP TT (cid:48)(cid:48) ≤ OP TT (cid:48), which can be proved as follows. We convert the optimal hub labeling H(cid:48) for T (cid:48) to a set of hub labelings for all subtrees T (cid:48)(cid:48) of T (cid:48): v∩ V (T (cid:48)(cid:48)) for every vertex the hub labeling H(cid:48)(cid:48) for T (cid:48)(cid:48) is the restriction of H(cid:48) to T (cid:48)(cid:48); namely, H(cid:48)(cid:48) v ∈ T (cid:48)(cid:48); it is clear that the total number of hubs in labelings H(cid:48)(cid:48) for all subtrees T (cid:48)(cid:48) is at most the cost of H(cid:48). Also, the cost of each hub labeling H(cid:48)(cid:48) is at least OP TT (cid:48)(cid:48). The inequality follows. We have considered both cases, S < k and S = k, and thus shown that the hypothesis holds for any subtree T (cid:48) of T . In particular, it holds for T . Therefore, the algorithm finds a solution of Setting k = 4 · (cid:100)1/ε(cid:101), as already mentioned, we get a (1 + ε)-approximation, for any fixed cost at most B[T ] + C[T ] = B[T ] ≤(cid:0)1 + 4 (cid:1) OP T . v = H(cid:48) k ε ∈ (0, 1), and the running time of the algorithm is nO(1/ε). 5.4 A quasi-polynomial time algorithm for HL on trees The dynamic programming approach of the previous section can also be used to obtain a quasi- polynomial time algorithm for HLp on trees. This is done by observing that the set of boundary vertices of a subtree is a subset of the hub set of every vertex in that subtree, and by proving that in an optimal solution for HLp, all vertices have hub sets of size at most O(log n), for p ∈ {1,∞}, and of size at most O(log2 n) in the case of p ∈ (1,∞). Thus, restricting our DP to subinstances with polylogarithmic boundary size, we are able to get an exact quasi-polynomial time algorithm. Again, we only present the case for HL1. More details for HLp are given in Appendix B.3 (for HLp, for every p ∈ [1,∞)) and Appendix B.4 (for HL∞). any optimal hierarchical hub labeling solution H satisfies maxu∈V Hu = O(log n). In order to get an exact quasi-polynomial time algorithm for HL1 on trees, we first prove that Theorem 16. Let H be an optimal (for HL1) hierarchical hub labeling for a tree T . Then maxu∈T Hu = O(log n). We will need to prove a few auxiliary claims before we proceed with the proof of Theorem 16. Consider a canonical hierarchical labeling for T . Recall that we may assume that H is constructed 16 as follows: we choose a vertex r in T of highest rank and add it to each hub set Hv (for v in T ), then recursively process each tree in the forest T − r. For every vertex u, let Tu be the subtree of T , which we process when we choose r = u. (Note that u is the vertex of highest rank in Tu.) Let us consider the following "move ahead" operation that transforms a hierarchical hub labeling H to a hierarchical hub labeling H(cid:48). The operation is defined by two elements r1 ≺ r2 (i.e. r2 ∈ Tr1) as follows. Consider the process that constructs sets Hu, described in the previous paragraph. Consider the recursive step when we process subtree Tr1. At this step, let us intervene in the process: choose vertex r2 instead of choosing r1. Then, when we recursively process a subtree T (cid:48) of Tr1 − r2, we choose the vertex of highest rank in T (cid:48) (as indicated by H). Clearly, we obtain a hierarchical hub labeling. Denote it by H(cid:48). Lemma 17. Suppose that we move r2 ahead of r1 (r1 ≺ r2) and obtain labeling H(cid:48). Let (cid:101)T be the connected component of Tr1 − r2 that contains r1. The following statements hold. 1. If u /∈ Tr1, then H(cid:48) 3. If u ∈ Tr1 \ (cid:101)T , then r1 /∈ H(cid:48) 2. If u ∈ Tr1, then H(cid:48) Proof. 1. The "move ahead" operation affects only the processing of the tree Tr1 and its subtrees. Therefore, if u /∈ Tr1, then H(cid:48) u = Hu. u \ {r2}; we will prove that v ∈ Hu. Consider the step when we add 2. Consider a vertex v ∈ H(cid:48) u. Denote the tree that we process at this step by T (cid:48). Then u ∈ T (cid:48) and v is the highest v to H(cid:48) ranked element in T (cid:48). In particular, v ≺ u, and, by the definition of the ordering (cid:22), v ∈ Hu. u does not contain r1 (because r1 lies in the subtree (cid:101)T ), and, thus, u and r1 never lie in the same 3. If u = r2, the statement is trivial. Otherwise, note that the subtree of Tr1 − r2 that contains u = Hu. u ⊂ Hu ∪ {r2}. subtree during later recursive calls. Therefore, we do not add r1 to H(cid:48) u. u. Consider a canonical hierarchical labeling H, a vertex u and subtree Tu, as defined before. Let T (cid:48) be the largest connected component of Tu − u. We define Mu = Tu − T (cid:48). Claim 18. Assume that H is an optimal hierarchical hub labeling for a tree T . Consider two vertices u and v. If u ≺ v, then Mu ≥ Mv. Proof. Without loss of generality, we can assume that there is no element w between u and v in the partial order (cid:22) (the result for arbitrary u ≺ v will follow by transitivity). Let T (cid:48) be the largest connected component of Tu − u. Consider two cases. Case v /∈ T (cid:48). Then Mv ≤ Tv < Tu − T (cid:48), since Tv is a proper subset of Tu \ T (cid:48). Case v ∈ T (cid:48). Then T (cid:48) = Tv, and v is the highest ranked vertex in T (cid:48). Let T (cid:48)(cid:48) be the union of v and all subtrees of Tu − v that do not contain u. Note that T (cid:48) − T (cid:48)(cid:48) is a connected component of T (cid:48) − v = Tv − v, and, thus, Mv ≤ T (cid:48) − T (cid:48) − T (cid:48)(cid:48) ≤ T (cid:48)(cid:48). Also, note that v ∈ Hw for w ∈ T (cid:48), since v is the highest ranked vertex in T (cid:48). Let us move v ahead of u, and obtain a hub labeling H(cid:48). We have, by Lemma 17, 1. If w /∈ Tu, then H(cid:48) 2. If w ∈ Tu − T (cid:48), then H(cid:48) 3. If w ∈ T (cid:48) − T (cid:48)(cid:48), then H(cid:48) w = Hw. w ⊂ Hw ∪ {v}; thus, H(cid:48) w ⊂ Hw ∪ {v} = Hw; thus, H(cid:48) w = Hw; thus, H(cid:48) w ≤ Hw + 1. w ≤ Hw. 17 4. If w ∈ T (cid:48)(cid:48), then H(cid:48) w ⊂ Hw and u ∈ Hw \ H(cid:48) w; thus, H(cid:48) w ≤ Hw − 1. Since H is an optimal labeling (cid:88) Hw ≤(cid:88) H(cid:48) w. Therefore, Tu − T (cid:48) ≥ T (cid:48)(cid:48). Recall that Mu = Tu − T (cid:48) and T (cid:48)(cid:48) ≥ Mv. We conclude that Mu ≥ Mv. w w Claim 19. Assume that H is an optimal hierarchical hub labeling for a tree T . For every vertex u, we have Mu ≥ Tu/6. Proof. Assume to the contrary that there is a vertex u1 such that Mu1 < Tu1/6. Denote n(cid:48) = Tu1. Let T (cid:48) be the largest connected component of Tu1 − u1, and u2 be the vertex of highest rank in T (cid:48). Let T (cid:48)(cid:48) be the largest connected component of T (cid:48) − u2, and u3 be the vertex of highest rank in T (cid:48)(cid:48). Denote M1 = Mu1 and M2 = Mu2. We have u1 (cid:22) u2, and, therefore, n(cid:48)/6 > M1 ≥ M2. By the definition of T (cid:48), T (cid:48)(cid:48) and numbers M1, M2, we have T (cid:48) = Tu1 − M1 > n(cid:48); 5 6 T (cid:48)(cid:48) = T (cid:48) − M2 > n(cid:48). 4 6 (cid:124) 6 n(cid:48) hub sets Hw. Note that u1 belongs to n(cid:48) hub sets Hw (namely, it belongs to Hw for w ∈ Tu1), u2 belongs to more 6 n(cid:48) hub sets Hw, and u3 belongs to more than 4 than 5 Let c be balanced separator vertex in Tu1. Clearly, in H we have u1 (cid:22) c. Consider the hub w ⊂ Hw ∪ {c} for w ∈ Tu1, and labeling H(cid:48) obtained by moving c ahead of u1. By Lemma 17, H(cid:48) w = Hw for w /∈ Tu1. Since every connected component of Tu1 − c contains at most n(cid:48)/2 vertices, H(cid:48) each of the vertices u1, u2, and u3 will lie in a connected component of size at most n(cid:48)/2. This means that u1 belongs to at most n(cid:48)/2 hub sets H(cid:48) w, and similarly u2 and u3 belong to at most (cid:88) n(cid:48)/2 hub sets (each) in H(cid:48). We get that (n(cid:48) − n(cid:48)/2) + (5n(cid:48)/6 − n(cid:48)/2) + (4n(cid:48)/6 − n(cid:48)/2) w ≤(cid:0)(cid:88) Hw(cid:1) + n(cid:48) − 1 (cid:124) (cid:123)(cid:122) (cid:125) −(cid:16) (cid:88) Hw. H(cid:48) (cid:17) (cid:125) (cid:123)(cid:122) w w < w bound on cost of new hub c difference in number of appearances of hubs u1,u2,u3 in hub labelings H and H(cid:48) We get a contradiction with the optimality of the hub labeling {Hw}. Proof of Theorem 16. By Claim 19, we get that during the decomposition of T into subproblems, the sizes of the subproblems drop by a constant factor. Therefore, the depth of the decomposition tree is O(log n), and so for every u ∈ V , we must have Hu = O(log n). We are now ready to present our quasi-polynomial time algorithm. Theorem 20. There exists a DP algorithm that is an exact quasi-polynomial time algorithm for HL1 on trees, with running time nO(log n). Proof. The DP algorithm is the same as the algorithm presented in Section 5.3, with k = O(log n), without the balancing steps that occur when the boundary of a subproblem is of size exactly k. The proof relies on the simple observation that the set of boundary vertices that describes a subtree is equal to, or a subset of, the set of hubs that have been assigned so far by an HHL solution to all the vertices of this subtree. In other words, the set of boundary vertices corresponds to some of 18 the vertices of the path in the recursion tree that starts from the root (the vertex with the highest rank in T ), and goes down to the internal vertex in the recursion tree that describes the current subproblem. By Theorem 16, we know that any such path has at most k = c · log n vertices, for some constant c. Thus, when looking for an optimal solution, we only have to consider subproblems that can be described by such paths, and so we can store entries in the dynamic program table only for subtrees T (cid:48) with ∂(T (cid:48)) ≤ k = c · log n. This implies that we can use a simple DP algorithm with entries defined by formula (1) of Section 5.3 for T (cid:48) with ∂(T (cid:48)) ≤ k and B[T (cid:48)] = ∞ for T (cid:48) with ∂(T (cid:48)) > k. As we already showed, the DP table has size nO(k) = nO(log n) (since we don't need to have any entries B[T (cid:48)] for T (cid:48) with ∂(T (cid:48)) > k). The running time of the algorithm is nO(log n). 6 Hardness of approximating hub labeling on general graphs In this section, we prove that HL1 and HL∞ are NP-hard to approximate on general graphs with multiple shortest paths within a factor better than Ω(log n), by using the Ω(log n)-hardness results for Set Cover. This implies that the current known algorithms for HL1 and HL∞ are optimal (up to constant factors). 6.1 An Ω(log n)-hardness for HL1 In this section, we show that it is NP-hard to approximate HL1 on general graphs with multiple shortest paths within a factor better than Ω(log n). We will use the hardness results for Set Cover, that, through a series of works spanning more than 20 years [23, 17, 25, 7], culminated in the following theorem. Theorem 21 (Dinur & Steurer [16]). For every α > 0, it is NP-hard to approximate Set Cover to within a factor (1 − α) · ln n, where n is the size of the universe. We start with an arbitrary unweighted instance of Set Cover. Let X = {x1, ..., xn} be the universe and S = {S1, ..., Sm} be the family of subsets of X , with m = poly(n). Our goal is to pick the smallest set of indices I ⊆ [m] (i.e. minimize I) such that(cid:83) i∈I Si = X . We will construct an instance of HL such that, given an f (n)-approximation algorithm for HL1, we can use it to construct a solution for the original Set Cover instance of cost O(f (poly(n))) · OP TSC, where OP TSC is the cost of the optimal Set Cover solution. Formally, we prove the following theorem. Theorem 22. Given an arbitrary unweighted Set Cover instance (X ,S), X = n, S = m, with optimal value OP TSC, and an f (n)-approximation algorithm for HL1, there is an algorithm that returns a solution for the Set Cover instance of cost O(f (Θ(max{n, m}3))) · OP TSC. Using the above theorem, if we assume that f (n) = o(log n), then O(f (Θ(max{n, m}3))) = O(f (poly(n))) = o(log poly(n)) = o(log n), and so this would imply that we can get a o(log n)- approximation algorithm for Set Cover. By Theorem 21, this is NP-hard, and so we must have f (n) = Ω(log n). Corollary 23. It is NP-hard to approximate HL1 to within a factor c · log n, for some constant c, on general graphs (with multiple shortest paths). 19 Before proving Theorem 22, we need the following lemma. Lemma 24. Let G = (V, E) and l : E → R+ be an instance of HL1, in which there exists at least one vertex u ∈ V with degree 1, and let w be its unique neighbor. Then, any feasible solution {Hv}v∈V w ∪ {u} can be converted to a solution H(cid:48) of at most the same cost, with the property that H(cid:48) and u /∈ H(cid:48) Proof. Let {Hv} be any feasible solution for HL, and let u be a vertex of degree 1, and w its unique neighbor. If the desired property already holds for every vertex of degree 1, then we are done. So let us assume that the property does not hold for some vertex u. Let w be its neighbor and v, for every vertex v (cid:54)= u. u = H(cid:48) (cid:40) B = Hw \ {u}, Hu \ {u}, Hw \ {u} ≤ Hu \ {u}, if otherwise. We now set • H(cid:48) • H(cid:48) u = B ∪ {u, w}. w = B ∪ {w}. • ∀v ∈ V \ {u, w}, H(cid:48) v = (cid:40) Hv, (Hv \ {u}) ∪ {w}, if u /∈ Hv, otherwise. We first check the feasibility of H(cid:48). The pairs {u, w}, and {v, v}, for all v ∈ V , are clearly satisfied. Also, every pair {v, v(cid:48)} with v, v(cid:48) /∈ {u, w} is satisfied, since u /∈ Svv(cid:48). Consider now a pair {u, v}, with v ∈ V \{u, w}. If u ∈ Hu ∩ Hv, we have w ∈ H(cid:48) v. Otherwise, {u, v} is covered with some vertex z ∈ Suv \ {u}, and since Suv \ {u} = Swv, we have that z ∈ Hu ∩ Hv and z ∈ Hw ∩ Hv. It follows that z ∈ H(cid:48) v. Now, consider a pair {w, v}, v ∈ V \ {u, w}. We have either w = (Hw \ {u}) ∪ {w}, which gives H(cid:48) w = (Hu \ {u}) ∪ {w}. In the w ∩ Swv = Hw ∩ Svw, or H(cid:48) H(cid:48) v, or Hu ∩ Suv = Hu ∩ Swv. It is easy to see that in all cases latter case, either u ∈ Hv and so w ∈ H(cid:48) the covering property is satisfied. u ∩ H(cid:48) u ∩ H(cid:48) We now argue about the cost of H(cid:48). We distinguish between the two possible values of B: • B = Hw \ {u}: In this case, H(cid:48) v ≤ Hv. Otherwise, it holds that Hw ≤ Hu−1, and so H(cid:48) it is obvious that H(cid:48) w ≤ Hw, since w ∈ B. If u ∈ Hw, then H(cid:48) u = Hw ≤ Hu. u = Hw+1 ≤ Hu. For all v ∈ V \{u, w}, u = Hu. w = Hu < Hw, w ≤ Hu+Hw. • B = Hu \ {u}: If w ∈ Hu, then H(cid:48) w = Hu − 1 < Hw \ {u} ≤ Hw, and H(cid:48) Otherwise, we must have u ∈ Hw, which means that Hu < Hw. Thus, H(cid:48) and H(cid:48) u+H(cid:48) Again, it is obvious that H(cid:48) w < Hu+1+Hw, and so H(cid:48) u = Hu+1, which gives H(cid:48) v ≤ Hv, for all v ∈ V \ {u, w}. u+H(cid:48) Thus, in all cases, H(cid:48) is a feasible hub labeling that satisfies the desired property and whose cost is(cid:80) v ≤(cid:80) v∈V H(cid:48) We are now ready to prove Theorem 22. v∈V Hv. Proof of Theorem 22. Given an unweighted Set Cover instance, we create a graph G = (V, E) and HL1 instance. We fix two parameters A and B (whose values we specify later) and do the following (see Figure 1): 20 • The 2 layers directly corresponding to the Set Cover instance are the 3rd and the 4th layer. In the 3rd layer we introduce one vertex for each set Si ∈ S, and in the 4th layer we introduce one vertex for each element xj ∈ X . We then connect xj to Si if and only if xj ∈ Si. • The 2nd layer contains A vertices in total ({r1, ..., rA}), where ri is connected to every vertex Sj of the 3rd layer. • For each vertex ri we introduce B new vertices in the 1st layer, where each such vertex t(i) j has degree one and is connected to ri. • Similarly, for each xi we introduce B new vertices in the 5th layer, where each such y(i) j has • Finally, we introduce a single vertex W in the 6th layer, which is connected to every xi of the degree one and is connected to xi. 4th layer. We also assign lengths to the edges. The (black) edges (W, xi) have length ε < 1/2 for every xi ∈ X , while all other (brown) edges have length 1. We will show that by picking the parameters A and B appropriately, we can get an O(f (poly(n))-approximation for the Set Cover instance, given an f (n)-approximation for HL1. 1st layer 2nd layer 3rd layer 4th layer 5th layer 6th layer t(1) 1 t(1) 2 t(1) B r1 S1 x1 r2 rA Sm x2 xn    y(1) 1 y(1) 2 y(1) B W Figure 1: The HL1 instance corresponding to an arbitrary unweighted Set Cover instance We will now define a solution for this HL instance, whose cost depends on the cost of the optimal Set Cover. Let I ⊆ [m] be the set of indices of an optimal Set Cover solution. We define the following HL solution, given in the array below. We use the notation S(xi) to denote an (arbitrarily chosen) set of the optimal Set Cover solution that covers xi. We also write [n] = {1, ..., n}. Layer 1st 2st 3st 4st 5st 6st ∀i ∈ [m], HSi = {Si, W} ∪ {r1, ..., rA} ∪ {xj : xj ∈ Si} Hubs = Hri ∪ {t(i) j } ∀i ∈ [A], j ∈ [B], H ∀i ∈ [A], Hri = {ri} ∪ {Sj : j ∈ I} t(i) j ∀i ∈ [n], Hxi = {xi, W, S(xi)} = Hxi ∪ {y(i) ∀i ∈ [n], j ∈ [B], H j } HW = {W} ∪ {S1, ..., Sm} ∪ {r1, ..., rA} y(i) j 21 We argue that the above solution is a feasible solution for the constructed instance. To this end, we consider all possible pairs of vertices for all layers. The notation "i - j" means that we check a pair with one vertex at layer i and the other at layer j. The pairs {u, u} are trivially satisfied, so we will not consider them below: • 1 - 1: {t(i) a , t(j) b }. If i = j, then the pair is covered by ri. If i (cid:54)= j, then H t(i) a the same sets from the 3rd layer, and so at least one shortest path is covered. and H contain t(j) b • 1 - 2: {t(i) a , rj}. If i = j, then ri ∈ H . If i (cid:54)= j, then H t(i) a and Hrj contain the same sets t(i) a from the 3rd layer, and so at least one shortest path is covered. , and so the pair is covered. b }. Again, the pair is covered by S(xj). a , Sj}. Observe that ri ∈ HSj ∩ H t(i) a a , xj}. The pair is covered by S(xj). a , y(j) a , W}. The pair is covered by ri. • 1 - 3: {t(i) • 1 - 4: {t(i) • 1 - 5: {t(i) • 1 - 6: {t(i) • 2 - 2: Any such pair is covered by any of the Sj's, with j ∈ I. • 2 - 3: {ri, Sj}. We have ri ∈ HSj . • 2 - 4: {ri, xj}. The pair is covered by S(xj). • 2 - 5: Since the "2 - 4" pairs are covered, the "2 - 5" pairs are covered as well. • 2 - 6: Vertex W is directly connected to all vertices of the 2nd layer. • 3 - 3: Any {Si, Sj} is covered by any vertex of the 2nd layer. • 3 - 4: {Si, xj}. If xj ∈ Si, then xj ∈ HSi. If xj /∈ Si, then W ∈ HSi ∩ Hxj . • 3 - 5: {Si, y(j) • 3 - 6: There is a direct connection. • 4 - 4: Any such pair is covered by W . • 4 - 5: {xi, y(j) a }. If i = j, then xi ∈ H • 4 - 6: There is a direct connection. • 5 - 5: {y(i) • 5 - 6: There is a direct connection. . If not, then they are covered by W . y(i) a a , y(j) b }. If i = j, then they are covered by xj. If not, then they are covered by W . a }. If xj ∈ Si, then they are covered by xj. If not, then they are covered by W . Thus, the above solution is indeed a feasible one. We compute its cost (each term from left to right corresponds to the total cost of the vertices of the corresponding layer): COST ≤ A · B · (OP TSC + 2) + A · (OP TSC + 1) + m · (A + n + 2) + 3n + 4B · n + (1 + m + A) = O(AB · OP TSC) + O(A · OP TSC) + O(Am + mn) + O(n) + O(Bn) + O(m + A). We set A = B = max{m, n}3/2, and let N = Θ(A · B) denote the number of vertices of the graph. Then, the total cost is dominated by the term AB · OP TSC, and so we get that the cost OP T of the optimal HL1 solution is at most c· AB · OP TSC, for some constant c. It is also easy to see that OP T ≥ A · B. 22 i = H(cid:48)(cid:48) rj ∪ {t(j) i } and t(j) i /∈ H(cid:48)(cid:48) (cid:107)H(cid:48)(cid:107)1 AB . i we have H(cid:48)(cid:48) t(j) i Assuming that we have an f (n)-approximation for HL1, we can get a solution H(cid:48) of cost (cid:107)H(cid:48)(cid:107)1 ≤ c · f (N ) · AB · OP TSC. We will show that we can extract a feasible Set Cover solution of cost at most To extract a feasible Set Cover, we first modify H(cid:48). Using Lemma 24, we can obtain a solution v , for every vertex v (cid:54)= t(j) H(cid:48)(cid:48) such that for every t(j) . We also apply the lemma for the vertices of the 5th layer. In addition to that, we add {r1, ..., rA} to the hub set of W , increasing the cost by at most A. Thus, we end up with a solution H(cid:48)(cid:48) of cost at most c · f (N ) · AB · OP TSC + A ≤ c(cid:48) · f (N ) · AB · OP TSC. ri, for some j ∈ [n[. a }'s. In that case, we can remove xj . The cost of the solution cannot increase, We now look at every vertex ri of the 2nd layer for which we have xj ∈ H(cid:48)(cid:48) This xj can only be used to connect ri to xj and to the {y(j) from H(cid:48)(cid:48) , and add ri to H(cid:48)(cid:48) and we again call this new solution H(cid:48)(cid:48). xj and to all H(cid:48)(cid:48) j∈Fi We are ready to define our Set Cover solution. For each i ∈ [A], we define Fi = H(cid:48)(cid:48) ri∩{S1, ..., Sm}. Sj be the number of uncovered elements. If Zi = 0, then Fi is a valid Set Cover. If Zi > 0, then we cover the remaining elements using some extra sets (at most Zi such sets). At the end, we return mini∈[A]{Fi + Zi}. In order to analyze the cost of the above algorithm, we need the following observation. Let ri, and an element xj that is not covered. By the structure of H(cid:48)(cid:48), this means that us look at H(cid:48)(cid:48) ri ∈ H(cid:48)(cid:48) xj . Thus, the number of uncovered elements Zi contributes a term (B + 1)Zi to the cost of the HL1 solution. For each i, the number of uncovered elements Zi implies an increase in the cost of the 4th and 5th layer, which is "disjoint" with the increase for j (cid:54)= i, and so the total cost of the ri + Zi). So, there must exist an i 1st, 2nd, 4th and 5th layer combined is at least(cid:80)A i=1(B + 1)(H(cid:48)(cid:48) Let Zi = X \(cid:83) ri and all H(cid:48)(cid:48) y(j) a t(i) b such that ri + Zi ≤ (cid:107)H(cid:48)(cid:48)(cid:107)1 H(cid:48)(cid:48) A(B + 1) . We pick the Set Cover with cost at most minj{Fj + Zj} ≤ minj{H(cid:48)(cid:48) with a feasible Set Cover solution of cost at most c(cid:48) · f (N ) · AB · OP TSC = c(cid:48) · f (N ) · OP TSC. AB rj + Zj}, and so we end up 6.2 An Ω(log n)-hardness for HL∞ In this section, we will show that it is NP-hard to approximate HL∞ to within a factor better than Ω(log n). We will again use the hardness results for Set Cover. Theorem 25. Given an arbitrary unweighted Set Cover instance (X ,S), X = n, S = m = poly(n), with optimal value OP TSC, and an f (n)-approximation algorithm for HL∞, there is an algorithm that returns a solution for the Set Cover instance with cost at most O(cid:0)f (O(n4 · m))(cid:1) · be able to solve the Set Cover instance within a factor of O(cid:0)f (O(n4m))(cid:1). We now describe our OP TSC. Proof. Let X = {x1, ..., xn} and S = {S1, ..., Sm}, Si ⊆ X be a Set Cover instance. We will construct an instance of HL∞, such that, given an f (n)-approximation algorithm for it, we will construction: 23 • We introduce a complete bipartite graph (A, B, E). By slightly abusing notation, we denote A = A and B = B, where A and B are two parameters to be set later on. • Each vertex u ∈ A "contains" K vertices {ru,1, ..., ru,K}. • Each vertex vertex v ∈ B "contains" a copy of the universe {xv,1, ..., xv,n}. • Each edge (u, v) is replaced by an intermediate layer of vertices Suv = {Suv,1, ..., Suv,m}, which is essentially one copy of S. We then connect every vertex ru,i, i ∈ [K], to every vertex Suv,j, j ∈ [m], and we also connect each Suv,j to xv,t, if xt ∈ Sj. All these edges (colored red in the figure) have length 1. • Finally, we introduce three extra vertices WA and WB and WS, and the edges (WA, ru,i), for all u ∈ A and i ∈ [K], the edges (WB, xv,j), for all v ∈ B and j ∈ [n], and the edges (WS, Suv,j), for all u ∈ A, v ∈ B and j ∈ [m]. All these edges (colored black in the figure) have length ε < 1. The construction is summarized in Figures 2a, 2b. WA ru,1 u ∈ A WA Suv,1 Suv WB A B (a) The general structure of the graph v ∈ B xv,1 WS Suv,m ru,K xv,n (b) A closer look at an edge (u, v) ∈ E WB In the resulting construction, the number of vertices, denoted by N , is N = AK +Bn+ABm+3, and the number of edges, denoted by M , is at least M ≥ AB(Km+m)+AK +ABm+Bn. Let OP T denote the cost of an optimal HL∞ solution H for this instance. Then, by a standard pigeonhole principle argument, and since every edge is a unique shortest path, we get that OP T ≥ M N . We now set the parameters, as follows: A = B = K = n2. With these values, we have N = Θ(n4 · m), M = Ω(n6 · m) and OP T = Ω(n2). We will describe an intended feasible solution for this instance, that will give an upper bound on OPT. Let I ⊆ [m] denote an optimal Set Cover of our original Set Cover instance, and let Ij ∈ I denote the index of a chosen set that covers xj. The HL solution is the following: • Hru,i = {ru,i} ∪(cid:0)(cid:83) • Hxv,j = {xv,j} ∪(cid:0)(cid:83) v∈B{Suv,j : j ∈ I}(cid:1) ∪ {WA, WB, WS}, for u ∈ A and i ∈ [K]. u∈A{Suv,Ij}(cid:1) ∪ {WA, WB, WS}, for v ∈ B and j ∈ [n]. 24 t ∈ [m]. • HSuv,t = {Suv,t} ∪ {ru,1, ..., ru,K} ∪ {xv,1, ..., xv,n} ∪ {WA, WB, WS}, for u ∈ A, v ∈ B and • HWq = {WA, WB, WS}, for q ∈ {A, B, S}. We now compute the sizes of these hub sets. We have: • Hru,i = BI + 4 = Θ(n2 · I), for u ∈ A and i ∈ [K]. • Hxv,j = A + 4 = Θ(n2), for v ∈ B and j ∈ [n]. • HSuv,t = K + n + 4 = Θ(n2), for u ∈ A, v ∈ B and t ∈ [m]. • HWq = 3, for q ∈ {A, B, S}. Thus, we get that the value of the above solution is (cid:107)H(cid:107)∞ = V al = Θ(n2 · I). We now show that the above is indeed a feasible solution. For that, we consider all possible pairs of vertices: • ru,i - rv,j: WA is a hub for both vertices. • ru,i - Suv,j: ru,i ∈ HSuv,j . • ru,i - Swv,j, w (cid:54)= u, v (cid:54)= u: WS is a hub for both vertices. • ru,i - xv,j: Suv,Ij is a hub for both vertices. • ru,i - Wq, for q ∈ {A, B, S}: Wq ∈ Hru,i. • Suv,i - Su(cid:48)v(cid:48),j: WS is a hub for both vertices. • Suv,i - xv,j: xv,j ∈ HSuv,i. • Suv,i - xv(cid:48),j, u (cid:54)= v(cid:48), v (cid:54)= v(cid:48): WB (or WS) is a hub for both vertices. • Suv,i - Wq, for q ∈ {A, B, S}: Wq ∈ HSuv,i. • xv,i - xv(cid:48),j: WB is hub for both vertices. • xv,j - Wq, for q ∈ {A, B, S}: Wq ∈ Hxv,j • Wq - Wq(cid:48), for q, q(cid:48) ∈ {A, B, S}: Wq(cid:48) ∈ HWq . Thus, the proposed solution is indeed a feasible solution. Assuming now that we have an f (n)- approximation algorithm for HL∞, we can obtain a solution H(cid:48) of cost (cid:107)H(cid:48)(cid:107)∞ ≤ f (N ) · OP T ≤ c· f (N )· n2 ·I. We will now show that we can extract a feasible solution for the original Set Cover instance, of cost O(f (N )) · I. Let H(cid:48) be the solution that the algorithm returns. As a reminder, we have already proved that (cid:107)H(cid:48)(cid:107)∞ = Ω(n2). We first transform H(cid:48) to a solution H(cid:48)(cid:48) that will look more like our intended solution, as follows: • H(cid:48)(cid:48) Suv,t := H(cid:48) t ∈ [m]. We have H(cid:48)(cid:48) := H(cid:48) O((cid:107)H(cid:48)(cid:107)∞). Wq Wq • H(cid:48)(cid:48) Suv,t ∪ {ru,1, ..., ru,K} ∪ {xv,1, ..., xv,n} ∪ {WA, WB, WS}, for u ∈ A, v ∈ B and ) = ∪ {WA, WB, WS}, for q ∈ {A, B, S}. We have H(cid:48)(cid:48) Suv,t + K + n + 3 ≤ (cid:107)H(cid:48)(cid:107)∞ + n2 + n + 3 = O((cid:107)H(cid:48)(cid:107)∞). + 3 = O(H(cid:48) Suv,t ≤ H(cid:48) ≤ H(cid:48) Wq Wq Wq • We now look at H(cid:48) that we will use to cover it. Now, if xv,j ∈ H(cid:48) H(cid:48) ru,i. This doesn't change the size of H(cid:48) increases the size of H(cid:48) advance which set we will use to cover xj, then H(cid:48) (u, v). Thus, the total increase in H(cid:48) ru,i. For every xj ∈ X , we pick (arbitrarily) a set S(xj) ∈ S with xj ∈ S(xj), ru,i and add Suv(xj) to ru,i. We also add Suv(xj) to the hub set of xv,j. This xv,j by 1. The crucial observation here is that since we have decided in xv,j can only increase by 1, for every edge xv,j + n2 = O((cid:107)H(cid:48)(cid:107)∞). ru,i, we remove xv,j from H(cid:48) xv,j is at most A, i.e. H(cid:48)(cid:48) xv,j ≤ H(cid:48) 25 In order to recover a good Set Cover solution, we look at the sets H(cid:48)(cid:48) are not covered by Cu,v,i, i.e. Zu,v,i = X \ ((cid:83) The above transformed solution, as shown, has the same (up to constant factors) cost as the solution that the algorithm returns, i.e. (cid:107)H(cid:48)(cid:48)(cid:107)∞ = O((cid:107)H(cid:48)(cid:107)∞) = O(f (N )) · n2 · I, and is clearly feasible. ru,i ∩ Suv. Each such intersection can be viewed as a subset Cu,v,i of S. Let Zu,v,i denote the number of elements that S). Our goal is to show that there exists a {u, v, i} such that Cu,v,i + Zu,v,i = O((cid:107)H(cid:48)(cid:48)(cid:107)∞/n2). Since there is a polynomial number of choices of {u, v, i}, we can then enumerate over all choices and find a Set Cover with cost O(f (N )) · I. To prove that such a good choice exists, we will make a uniformly random choice over {u, v, i}, and look at the expected value E [Cu,v,i + Zu,v,i]. We have E [Cu,v,i + Zu,v,i] = E [Cu,v,i] + E[Zu,v,i]. We look separately at the two terms. We make the following 2 observations: S∈Cu,v,i and (cid:88) u∈A Cu,v,i ≤ H(cid:48)(cid:48) (cid:88) Zu,v,i ≤ (cid:88) (cid:88) v∈B i∈K j∈[n] ru,i = O((cid:107)H(cid:48)(cid:107)∞), H(cid:48)(cid:48) xv,j = n · O((cid:107)H(cid:48)(cid:107)∞). (cid:88) (cid:88) (cid:88) (cid:88) v∈B u∈A,i∈[K] (cid:88) The second observation follows from the fact that for any given ru,i and edge (u, v), the uncovered elements xv,j must have ru,i ∈ H(cid:48)(cid:48) xv,j . With these, we have E[Cu,v,i] = 1 ABK Cu,v,i ≤ 1 ABK · AK · O((cid:107)H(cid:48)(cid:107)∞) = O((cid:107)H(cid:48)(cid:107)∞/B). Similarly, B + n 1 E[Zu,v,i] = Thus, we get that E [Cu,v,i + Zu,v,i] = (cid:0) 1 ABK u∈A v∈B i∈K Zu,v,i ≤ 1 ABK · B · n · O((cid:107)H(cid:48)(cid:107)∞) = (cid:1) · O((cid:107)H(cid:48)(cid:107)∞) = O((cid:107)H(cid:48)(cid:107)∞/n2) = O(f (N )) · I. · O((cid:107)H(cid:48)(cid:107)∞). n AK AK This means that there exists a choice of {u, v, i} such that the corresponding Set Cover has size O(f (N )) · I. As already mentioned, there are polynomially many choices, so we can enumerate them and find the appropriate {u, v, i}, and, thus, recover a Set Cover solution for our original Set Cover instance of cost O(f (N )) · I, where, as already stated, N = Θ(n4 · m). Corollary 26. It is NP-hard to approximate HL∞ to within a factor better than Ω(log n). Proof. The previous theorem gives an O(f (O(n4m))-approximation algorithm for Set Cover, given that an f (n)-approximation algorithm for HL∞ exists. If we assume that there exists such an algorithm with f (n) = o(log n), then we could use it to approximate Set Cover within a factor o(log O(n4m)) = o(log poly(n)) = o(log n), and this is impossible, assuming that P (cid:54)= NP. Acknowledgments We would like to thank Robert Krauthgamer and Konstantin Makarychev for useful discussions, and the anonymous referees for their valuable comments. Research was supported by the second author's NSF grants CAREER CCF-1150062 and IIS-1302662. 26 References [1] Ittai Abraham, Daniel Delling, Amos Fiat, Andrew V. Goldberg, and Renato Fonseca F. Wer- neck. VC-Dimension and Shortest Path Algorithms. In Proceedings of the 38th International Colloquium on Automata, Languages, and Programming (ICALP), pages 690–699, 2011. [2] Ittai Abraham, Daniel Delling, Amos Fiat, Andrew V. Goldberg, and Renato Fonseca F. Werneck. HLDB: location-based services in databases. In Proceedings of the 20th International Conference on Advances in Geographic Information Systems (SIGSPATIAL - formerly known as GIS), pages 339–348, 2012. [3] Ittai Abraham, Daniel Delling, Andrew V. Goldberg, and Renato F. Werneck. Alternative routes in road networks. ACM Journal of Experimental Algorithmics, 18, 2013. [4] Ittai Abraham, Daniel Delling, Andrew V. Goldberg, and Renato Fonseca F. Werneck. A Hub-Based Labeling Algorithm for Shortest Paths in Road Networks. In Proceedings of the 10th International Symposium on Experimental Algorithms (SEA), pages 230–241, 2011. [5] Ittai Abraham, Daniel Delling, Andrew V. Goldberg, and Renato Fonseca F. Werneck. Hi- In Proceedings of the 20th Annual European erarchical Hub Labelings for Shortest Paths. Symposium on Algorithms (ESA), pages 24–35, 2012. [6] Ittai Abraham, Amos Fiat, Andrew V. Goldberg, and Renato Fonseca F. Werneck. Highway In Proceedings of the 21st Dimension, Shortest Paths, and Provably Efficient Algorithms. Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 782–793, 2010. [7] Noga Alon, Dana Moshkovitz, and Shmuel Safra. Algorithmic construction of sets for k - restrictions. ACM Trans. Algorithms, 2(2):153–177, 2006. [8] Maxim A. Babenko, Andrew V. Goldberg, Anupam Gupta, and Viswanath Nagarajan. Algo- rithms for Hub Label Optimization. In Proceedings of the 40th International Colloquium on Automata, Languages, and Programming (ICALP), pages 69–80, 2013. [9] Maxim A. Babenko, Andrew V. Goldberg, Haim Kaplan, Ruslan Savchenko, and Mathias Weller. On the Complexity of Hub Labeling. In Proceedings of the 40th International Sympo- sium on Mathematical Foundations of Computer Science 2015 (MFCS), pages 62–74, 2015. [10] Hannah Bast, Daniel Delling, Andrew V. Goldberg, Matthias Muller-Hannemann, Thomas Pajor, Peter Sanders, Dorothea Wagner, and Renato F. Werneck. Route planning in trans- portation networks. CoRR, abs/1504.05140, 2015. [11] Holger Bast, Stefan Funke, and Domagoj Matijevic. TRANSIT - ultrafast shortest-path queries with linear-time preprocessing. In 9th DIMACS Implementation Challenge, 2006. [12] Daniel Berend and Tamir Tassa. Improved bounds on bell numbers and on moments of sums of random variables. Probability and Math. Statistics, 30:185–205, 2010. [13] Melvin A. Breuer. Coding the vertexes of a graph. IEEE Trans. Information Theory, 12(2):148– 153, 1966. 27 [14] Melvin A Breuer and Jon Folkman. An unexpected result in coding the vertices of a graph. Journal of Mathematical Analysis and Applications, 20(3):583–600, 1967. [15] Edith Cohen, Eran Halperin, Haim Kaplan, and Uri Zwick. Reachability and Distance Queries via 2-Hop Labels. SIAM J. Comput., 32(5):1338–1355, 2003. [16] Irit Dinur and David Steurer. Analytical approach to parallel repetition. In Proceedings of the 46th ACM Symposium on Theory of Computing (STOC), pages 624–633, 2014. [17] Uriel Feige. A threshold of ln n for approximating set cover. J. ACM, 45(4):634–652, 1998. [18] Cyril Gavoille, David Peleg, St´ephane P´erennes, and Ran Raz. Distance labeling in graphs. J. Algorithms, 53(1):85–112, 2004. [19] P.C. Gilmore. Families of sets with faithful graph representations. Res. Note N. C. (2nd ed.), 184, 1962. [20] R. L. Graham and H. O. Pollak. On embedding graphs in squashed cubes. Lecture Notes in Mathematics, 303:99–110, 1972. [21] Andr´as Gy´arf´as and Jeno Lehel. A Helly-type problem in trees. Colloq. Math. Soc. J. Bolyai., 4, 1970. [22] Sampath Kannan, Moni Naor, and Steven Rudich. Implicit Representation of Graphs. SIAM J. Discrete Math., 5(4):596–603, 1992. [23] Carsten Lund and Mihalis Yannakakis. On the hardness of approximating minimization prob- lems. J. ACM, 41(5):960–981, 1994. [24] David Peleg. Proximity-preserving labeling schemes. Journal of Graph Theory, 33(3):167–176, 2000. [25] Ran Raz and Shmuel Safra. A Sub-Constant Error-Probability Low-Degree Test, and a Sub- In Proceedings of the 29th ACM Constant Error-Probability PCP Characterization of NP. Symposium on Theory of Computing (STOC), pages 475–484, 1997. [26] Colin White. Lower bounds in the preprocessing and query phases of routing algorithms. In Algorithms - ESA 2015 - 23rd Annual European Symposium, Patras, Greece, September 14-16, 2015, Proceedings, pages 1013–1024, 2015. [27] Peter M. Winkler. Proof of the squashed cube conjecture. Combinatorica, 3(1):135–139, 1983. A HLp on graphs with unique shortest paths In this section, we analyze Algorithm 1, assuming that the objective function is(cid:0)(cid:80) for arbitrary fixed p ≥ 1. To do so, we first modify LP1 and turn it into a convex program, with the same constraints and the following objective function: u∈V Hup(cid:1)1/p, min : xuv . (cid:33)p(cid:33)1/p (cid:32)(cid:88) (cid:32)(cid:88) u∈V v∈V 28 To analyze the performance of Algorithm 1 in this case, we need the following theorem by Berend and Tassa [12]. Theorem 27 (Theorem 2.4, [12]). Let X1, ..., Xt be a sequence of independent random variables for which Pr[0 ≤ Xi ≤ 1] = 1, and let X =(cid:80)t where (E[X p])1/p ≤ 0.792 · v(p) · (cid:18) v(p) = with {p} denoting the fractional part of p. Theorem 28. For any p ≥ 1, Algorithm 1 is an O HLp. 1 + i=1 Xi. Then, for all p ≥ 1, p · max{E[X]1/p, E[X]}, ln(p + 1) 1 (cid:98)p(cid:99) p (cid:19) {p}·(1−{p}) (cid:16) , ln(p+1) · log D p (cid:17) -approximation algorithm for u(cid:48)∈(cid:98)Hu Proof. In order to simplify the analysis and be able to use the above theorem (Theorem 27) as is, Puu(cid:48) (observe that this is indeed a tree), for every u ∈ V , and define Fu ⊂ V (Tu) to be the set of vertices of Tu whose degree (in Tu) is at we slightly modify Algorithm 1 as follows. After we obtain the set of pre-hubs {(cid:98)Hu}u∈V at step 2, we consider the rooted tree Tu, defined as Tu =(cid:83) u := (cid:98)Hu ∪ Fu", and then least 3. The modified algorithm then adds the additional step (2(cid:48)): "(cid:98)H(cid:48) continues the execution of Algorithm 1 at step 3, as usual, using the modified sets (cid:98)H(cid:48) u. Let ALG be the cost of original algorithm, and ALG(cid:48) be the cost of this modified algorithm. It is not hard u ≤ 2 · (cid:98)Hu. pre-hubs of the set (cid:98)Hu, we must have Fu ≤ (cid:98)Hu, and so (cid:98)H(cid:48) to prove that it always holds ALG ≤ ALG(cid:48). It is also easy to see that, since all leaves of Tu are between consecutive pre-hubs u(cid:48)(cid:48) and u(cid:48) of (cid:98)H(cid:48) Let Pu be the collection of subpaths of Tu defined as follows: P belongs to Pu if P is a path pre-hub u(cid:48)(cid:48)(cid:48) ∈ (cid:98)Hu appears in P . For convenience, we exclude the endpoint u(cid:48)(cid:48) that is closer to u: u, with u(cid:48)(cid:48) being an ancestor of u(cid:48) in Tu, and no other P = Pu(cid:48)(cid:48)u(cid:48) − u(cid:48)(cid:48). Note that any such path P is uniquely defined by the pre-hub u(cid:48) of u, and so we will write P = P(uu(cid:48)). The modification we made in the algorithm allows us now to observe that P ∩ P (cid:48) = ∅, for P, P (cid:48) ∈ Pu, P (cid:54)= P (cid:48). Let ALG(cid:48) be the cost of the solution {Hu}u that the modified algorithm returns. We have (cid:33)1/p ≤(cid:16)(cid:88) E[Hup] (cid:17)1/p Hup (Jensen's inequality). u X u v , where X u v is the random variable indicating how many vertices are added to Hu "because of" the pre-hub v (see Line 8 of algorithm). Observe that we can write X u v as follows: X u Y uv w , with Y uv w being 1 if w is added in Hu, and zero otherwise. The modification that we made in the algorithm implies, as already observed, that any variable Y uv w , w ∈ P(uv), is independent from Y uv(cid:48) , w(cid:48) ∈ P(uv(cid:48)), for v (cid:54)= v(cid:48), as the corresponding paths P(uv) and w(cid:48) P(uv(cid:48)) are disjoint. Let πuv : [P(uv)] → P(uv) be the permutation we obtain when we restrict π (see Line 3 of the , l = P(uv), where is 1 if the i-th vertex considered by the algorithm that belongs to P(uv) (i.e. the i-th vertex of algorithm) to the vertices of P(uv). We can then write(cid:80) w =(cid:80)l i=1 Zuv i w∈P(uv) Y uv Zuv i E[ALG(cid:48)] = E (cid:32)(cid:88) We can write Hu ≤(cid:80) v∈(cid:98)H(cid:48) v =(cid:80) w∈P(uv) u∈V 29 i = 1 Zuv permutation πuv) is added to Hu and zero otherwise. It is easy to see that Pr[Zuv i = 1] = 1/i. We now need one last observation. We have Pr[Zuv i−1] = 1/i. To see this, note that the variables Zuv i do not reveal which particular vertex is picked from the permutation at each step, but only the relative order of the current draw (i.e. i-th random choice) with respect to the current best draw (where best here means the closest vertex to v that we have seen so far, i.e. in positions πuv(1), ..., πuv(i−1)). Thus, regardless of the relative order of πuv(1), ..., πuv(i−1), there are exactly i possibilities to extend that order when the permutation picks πuv(i), each with probability 1/i. This shows that the variables {Zuv v, i∈[P(uv)] are independent. i }v∈(cid:98)H(cid:48) 1 , ..., Zuv i }i are independent, and thus all variables {Zuv P(uv)(cid:88) (cid:18) p p ≤ 0.792 · v(p) · Zuv i ln(p + 1) i=1 (cid:88) v∈(cid:98)H(cid:48) u We can now apply Theorem 27. This gives E[Hup] ≤ E Here, HarmD =(cid:80)D 1 i = log D + O(1) is the D-th harmonic number. Thus, i=1 (cid:19)p · Harmp D ·(cid:98)H(cid:48) up. (cid:33)1/p (cid:32)(cid:88) (cid:33)p(cid:33)1/p xuv v∈V (cid:32)(cid:88) (cid:32)(cid:88) u∈V u∈V (cid:98)H(cid:48) up 4p · E[ALG(cid:48)] ≤ 0.792 · v(p) · p ln(p + 1) · HarmD · ≤ 0.792 · v(p) · ≤ c · p ln(p + 1) p · HarmD · ln(p + 1) · HarmD ·OP TREL, where OP TREL is the optimal value of the convex relaxation, and c ≤ 7 is some constant. B Trees: Missing proofs of Section 5 B.1 A PTAS for HLp on trees In this section, we describe a polynomial-time approximation scheme (PTAS) for HLp for arbitrary p ∈ [1,∞). Our algorithm is a modification of the dynamic programming algorithm for HL1. The main difficulty that we have to deal with is that the (cid:96)p-cost of an instance cannot be expressed in terms of the (cid:96)p-cost of the subproblems, since it might happen that suboptimal solutions for its subproblems give an optimal solution for the instance itself. Thus, it is not enough to store only the cost of the "optimal" solution for each subproblem. Let OP T [T (cid:48), t]p = min H is an HHL for T (cid:48) (Hu + t)p. Clearly, OP T [T, 0]p is the cost of an optimal HLp solution for T , raised to the power p. Observe that OP T [T (cid:48), t]p satisfies the following recurrence relation: OP T [T (cid:48), t]p = (1 + t)p + min r∈T (cid:48) OP T [T (cid:48)(cid:48), t + 1]p. (2) (cid:88) u∈T (cid:48) (cid:88) T (cid:48)(cid:48) is a component of T (cid:48)−r 30 Indeed, let (cid:101)H be an HHL for T (cid:48) that minimizes (cid:80) u∈T (cid:48)((cid:101)Hu + t)p. Let r(cid:48) be the highest ranked vertex in T (cid:48) w.r.t. the ordering defined by (cid:101)H. For each tree T (cid:48)(cid:48) in the forest T (cid:48) − r(cid:48), consider the hub labeling {(cid:101)Hu ∩ T (cid:48)(cid:48)}u∈T (cid:48)(cid:48) = (cid:101)Hu − r(cid:48). Since (cid:101)Hu = (cid:101)Hu ∩ T (cid:48)(cid:48) + 1, we have ((cid:101)Hu ∩ T (cid:48)(cid:48) + t + 1)p ≥ OP T [T (cid:48)(cid:48), t + 1]p. Also, (cid:101)Hr(cid:48) = 1. Therefore, (cid:88) ((cid:101)Hu + t)p ≥ (1 + t)p + ((cid:101)Hu + t)p = ((cid:101)Hu + t)p = ((cid:101)Hr(cid:48) + t)p + OP T [T (cid:48)(cid:48), t + 1]p. OP T [T (cid:48), t]p = (cid:88) (cid:88) (cid:88) (cid:88) (cid:88) u∈T (cid:48)(cid:48) u∈T (cid:48)(cid:48) u∈T (cid:48) T (cid:48)(cid:48) u∈T (cid:48)(cid:48) T (cid:48)(cid:48) The proof of the inequality in the other direction is similar. Consider r that minimizes the expression on the right hand side of (2) and optimal HHLs for subtrees T (cid:48)(cid:48) of T (cid:48) − r. We combine these HHLs and obtain a feasible HHL (cid:101)H. We get, (cid:88) OP T [T (cid:48), t]p ≤ (1 + t)p + ((cid:101)Hu + t + 1)p = (1 + t)p + u∈T (cid:48) (cid:88) T (cid:48)(cid:48) OP T [T (cid:48)(cid:48), t + 1]p. This concludes the proof of the recurrence. If we were not concerned about the running time of the algorithm, we could have used this recursive formula for OP T [T (cid:48), t]p to find the exact solution (the running time would be exponential). In order to get a polynomial-time algorithm, we again consider only subtrees T (cid:48) with boundary of size at most k. We consider two cases when ∂(T (cid:48)) < k and when ∂(T (cid:48)) = k. In the former case, we use formula (2). In the latter case, when ∂(T (cid:48)) = k, we perform the same step as the one performed in the algorithm for HL1: we pick a weighted balanced separator vertex r0 of T (cid:48) such that ∂(T (cid:48)(cid:48)) ≤ k/2 + 1 for every subtree T (cid:48)(cid:48) of T (cid:48)− r0. Formally, we define a dynamic-programming table B[T (cid:48), t] as follows: B[T (cid:48), t] = (1 + t)p + min r∈T (cid:48) B[T (cid:48), t] = (1 + t)p + T (cid:48)(cid:48) is a conn. comp. of T (cid:48)−r T (cid:48)(cid:48) is a conn. comp. of T (cid:48)−r0 B[T (cid:48)(cid:48), t + 1], if ∂(T (cid:48)) < k, B[T (cid:48)(cid:48), t], if ∂(T (cid:48)) = k. The base cases of our recursive formulas are when the subtree T (cid:48) is of size 1 or 2. In this case, we simply set B[T (cid:48), t] = (1 + t)p, if T (cid:48) = 1, and B[T (cid:48), t] = (1 + t)p + (2 + t)p, if T (cid:48) = 2. We will need the following two claims. Claim 29. For any tree T and a partition of T into disjoint subtrees {T1, ..., Tj} such that(cid:83)j i=1 Ti = T , we have (cid:88) (cid:88) j(cid:88) i=1 OP T [Ti, t]p ≤ OP T [T, t]p. Proof. Consider an optimal hierarchical solution H for the HLp problem defined by (T, t). Define H (i) = {Hu ∩ Ti : u ∈ Ti}. Observe that {H (i) u }u∈Ti is a feasible hub labeling for Ti, since the original instance is a tree. We have OP T [T, t]p = (Hu + t)p ≥ j(cid:88) j(cid:88) (cid:88) i=1 u∈Ti u + t)p ≥ j(cid:88) (H (i) (cid:88) u∈Ti OP T [Ti, t]p. i=1 i=1 31 Claim 30. For any T (cid:48) and t ≥ 0, B[T (cid:48), t] ≤ OP T [T (cid:48), t]p. Proof. We do induction on the size of T (cid:48). For T (cid:48) ∈ {1, 2}, the claim holds trivially for all t ≥ 0. Let us assume that it holds for all subtrees of size at most s and for all t ≥ 0. We will prove that it holds for all subtrees of size s + 1 and for all t ≥ 0. We again consider two cases. Case ∂(T (cid:48)) < k: B[T (cid:48), t] = (1 + t)p + min r∈T (cid:48) ≤ (1 + t)p + min r∈T (cid:48) = OP T [T (cid:48), t]p. T (cid:48)(cid:48) is comp. of T (cid:48)−r T (cid:48)(cid:48) is comp. of T (cid:48)−r B[T (cid:48)(cid:48), t + 1] (cid:88) (cid:88) (cid:88) (cid:88) OP T [T (cid:48)(cid:48), t + 1]p (by ind. hyp.) B[T (cid:48)(cid:48), t] OP T [T (cid:48)(cid:48), t]p (by ind. hyp.) Case ∂(T (cid:48)) = k: B[T (cid:48), t] = (1 + t)p + ≤ (1 + t)p + T (cid:48)(cid:48) is comp. of T (cid:48)−r0 T (cid:48)(cid:48) is comp. of T (cid:48)−r0 (cid:88) = OP T [{r0}, t]p + ≤ OP T [T (cid:48), t]p, OP T [T (cid:48)(cid:48), t]p T (cid:48)(cid:48) is comp. of T (cid:48)−r0 where the last inequality follows from Claim 29 and the fact that the connected components of T (cid:48) − r0 together with {r0} form a partition of T (cid:48). Theorem 31. There is a polynomial-time approximation scheme (PTAS) for HLp for every p ∈ [1,∞). The algorithm finds a (1 + ε) approximate solution in time nO(1/ε); the running time does not depend on p. Proof. Fix ε < 1, and set k = 2·(cid:100)4/ε(cid:101). Let H be the solution returned by the dynamic programming algorithm presented in this section. Consider the set X of all weighted balanced separators that the algorithm uses during its execution; that is, X is the set of hubs r0 that the algorithm adds when it processes trees T (cid:48) with ∂(T (cid:48)) = k. Let (cid:101)Hu = (Hu \ X) ∪ {u}; the set (cid:101)Hu consists of the hubs added to Hu during the steps when ∂(T (cid:48)) < k, with the exception that we include u in (cid:101)Hu even if u ∈ X. Therefore, B[T, 0] =(cid:80) (cid:16)(cid:101)Hu ∩ T (cid:48) + t (cid:17)p induction (along the lines of the previous inductive proofs) that Now, consider a vertex u and its hub set Hu. We want to estimate the ratio Hu ∩ X/Hu. We look at the decomposition tree implied by the algorithm and find the subinstance T (cid:48) in which the algorithm picked u as the highest ranked vertex in T (cid:48). The path from the root of the decomposition tree to that particular subinstance T (cid:48) contains exactly Hu nodes. Observe that in any such path, the nodes of the path that correspond to subinstances with boundary size exactly k are at distance at least k/2 from each other (since the size of the boundary increases by at most 1 when we move u∈V (cid:101)Hup. It is easy to prove by (cid:88) u∈T (cid:48) B[T (cid:48), t] = . 32 from one node to the consecutive node along the path). Thus, there can be at most 2Hu/k such nodes. This means that Hu∩X ≤ 2Hu/k, which gives Hu ≤ (1+ 2 So, the (cid:96)p-cost of the hub labeling is k−2 )·Hu\X ≤ (1+ 2 k−2 )·(cid:101)Hu. Hup(cid:17)1/p ≤(cid:16) (cid:16)(cid:88) (cid:16) u∈V 1 + (cid:107)H(cid:107)p = = 2 1 + k − 2 (cid:17) · B[T, 0]1/p ≤(cid:16) 1 + 2 k − 2 (cid:17) ·(cid:16)(cid:88) u∈V 2 k − 2 (cid:101)Hup(cid:17)1/p (cid:17) · OP T [T, 0], where the last inequality follows from Claim 30. We get that the algorithm finds a hub labeling of (cid:96)p-cost at most (1 + 2 k−2 ) · OP T . The running time is nO(k) · n = nO(k). B.2 A PTAS for HL∞ on trees Our approach for HL1 works almost as is for HL∞ as well. The only modifications that we need to make are the following: • B[T (cid:48)] is now defined as B[T (cid:48)] = (1 + 4/k) + min r(cid:48)∈T (cid:48) B[T (cid:48)] = max T (cid:48)(cid:48) is comp. of T (cid:48)−r0 max T (cid:48)(cid:48) is comp. of T (cid:48)−r(cid:48) B[T (cid:48)(cid:48)], B[T (cid:48)(cid:48)], for ∂(T (cid:48)) < k, for ∂(T (cid:48)) = k, where r0 is the weighted balanced separator vertex of T (cid:48), as defined in the description of the algorithm for HL1. • C[T (cid:48)] is now equal to C[T (cid:48)] = max(cid:8)0,(cid:0)∂(T (cid:48)) − 3k (cid:1) · 4 (cid:9). 4 k We can again prove using induction (along the same lines as the proof for HL1) that the total cost of the solution that the algorithm returns at any subinstance T (cid:48) is at most B[T (cid:48)] + C[T (cid:48)], and that it always holds that B[T (cid:48)] ≤ (1 + 4/k) · OP TT (cid:48). Thus, for T (cid:48) = T we have C[T ] = 0, and so we obtain a solution of cost at most (1 + 4/k)OP T , in time nO(k). B.3 A quasi-polynomial time algorithm for HLp We prove a bound on the infinity norm of an optimal HHL solution for HLp, and then use that bound as the value of the parameter k in the DP approach of Appendix B.1. We are able to prove a slightly weaker bound (compared to the one obtained for HL1). Lemma 32. Given a tree T , any optimal HHL solution H for HLp must satisfy maxu∈V Hu = O(log2 n). Proof. As already mentioned, the Tree Algorithm (Algorithm 2) returns a feasible solution H that satisfies maxu∈H Hu = O(log n). Thus, (cid:33)1/p (cid:32)(cid:88) u∈V (cid:107)H(cid:107)p ≤ (c · log n)p = c · n1/p · log n. This means that there always exists a solution for HLp of cost at most c · n1/p · log n. 33 Since we are again looking at hierarchical solutions, we now need the following observation: every (2c · log n + 1) levels at an optimal recursive decomposition, the size of the resulting subproblems must have reduced by at least a factor of 2. To see this, consider the first 2c · log n + 1 levels of the recursion implied by an optimal HHL solution H. All subinstances that haven't been solved yet are leaves of the bottom level. Each vertex contained in these subinstances already has 2c · log n hubs. Thus, if we assume that there are strictly more than (cid:98)n/2(cid:99) vertices in these subinstances, 2 · 2c log n ≥ n1/p · c log n, which is a contradiction. Thus, we must have at most then OP TT > n (cid:98)n/2(cid:99) vertices corresponding to the subproblems that are not yet solved. Applying this argument inductively to the subproblems that we obtain every 2c log n consecutive levels of the recursion tree, we get that after i · 2c log n + 1 levels of recursion, we will have at most (cid:98)n/2i(cid:99) vertices whose hubs will not have been finalized. It is now clear that no vertices will remain after at most i = (cid:100)log n(cid:101) + 1 "rounds", which implies a total depth of at most O(log2 n) levels in the recursion tree. Thus, since the level at which a vertex u is picked as the highest ranked vertex (in the corresponding subinstance in the recursion tree) is exactly equal to the number of hubs that vertex has, we get that maxu∈V Hu = O(log2 n). The lemma implies that by setting k = O(log2 n) in the DP approach for HLp, we can optimally solve HLp on trees, using the formula B[T (cid:48), t] = (1 + t)p + min r(cid:48)∈T (cid:48) (cid:88) B[T (cid:48)(cid:48), t + 1], T (cid:48)(cid:48) is comp. of T (cid:48)−r(cid:48) in total time nO(log2 n) (with the optimal cost being B[T, 0]1/p). B.4 A quasi-polynomial time algorithm for HL∞ We note that the optimal solution for HL∞ on a tree has (cid:96)∞-cost O(log n), since the Tree Algorithm (Algorithm 2) returns a feasible solution H of cost at most maxu∈H Hu = O(log n) (this was first proved by Peleg [24]). Thus, by setting k = O(log n), we can again use a simple DP algorithm with entries defined by the formula (cid:18) T (cid:48)(cid:48) is a connected component of T (cid:48)−r(cid:48) B[T (cid:48)(cid:48)] max (cid:19) , B[T (cid:48)] = 1 + min r(cid:48)∈T (cid:48) and obtain an optimal solution for HL∞, in total time nO(log n). B.5 Proof of Lemma 13 Proof of Lemma 13. We consider the complete binary tree of height h, whose size is nh = 2h+1 − 1 (a single vertex is considered to have height 0). The cost of the Tree Algorithm on a complete binary tree of height h, denoted by ALG(h), can be written as (cid:40) ALG(h) = (2h+1 − 1) + 2 · ALG(h − 1), h ≥ 1, h = 0. 1 It is easy to see that the above implies that ALG(h) = 2 · h · 2h + 1, for all h ≥ 0. To obtain a 3/2 gap, we now present an algorithm that gives a hub labeling of size (1 + oh(1))· 4 3 · h· 2h on complete binary trees (where the oh(1) term goes to 0 as h → ∞). 34 It will be again a recursive algorithm (i.e. a hierarchical labeling), only this time the recursion handles complete binary trees that may have some "tail" at the root. More formally, the algorithm operates on graphs that can be decomposed into two disjoint parts, a complete binary tree of height h, and a path of length t. The two components are connected with an edge between the root of the binary tree and an endpoint of the path. Such a graph can be fully described by a pair (h, t), where h is the height of the tree and t is the length of the path attached to the root of the tree. The proposed algorithm for complete binary trees works as follows. Let p be the root of the tree. Assuming h ≥ 2, let l be the left child of p, and r be the right child of p. The algorithm picks l as the vertex with the highest rank, and then recurses on the children of l and on r. Observe that on the recursive step for r, we have a rooted tree on r, and the original root p is now considered part of the tail. For h = 0, we have a path of length t + 1, and for h = 1, we simply remove p and then end up with a path of length t and two single vertices. Let Path(t) denote the optimal HL cost for a path of length t. It is not hard to show that the Tree Algorithm performs optimally for paths, and a closed formula for Path is Path(t) = (t + 1)(cid:100)log(t + 1)(cid:101) − 2(cid:100)log(t+1)(cid:101) + 1, t ≥ 0. So, at the base cases, the proposed algorithm uses the Tree Algorithm on paths. Let P (h, t) be the cost of this algorithm. Putting everything together, we obtain the recursive formula (2h+1 − 1) + t + 2 · P (h − 2, 0) + P (h − 1, t + 1), h ≥ 2, t ≥ 0, h = 1, t ≥ 0, h = 0, t ≥ 0. 5 + t + Path(t) Path(t + 1), P (h, t) = The cost of the solution we obtain from this algorithm is P (h, 0). Let f (n) = Path(n + 1) + 5, h, h ≥ 0, for some appropriate constant C. We prove by induction on h √ n ≥ 0, and g(h) = C/ that P (h, t) ≤ 4 3 · h · 2h + g(h) · h · 2h + f (h + t) + h · t, ∀h ≥ 0, t ≥ 0. The cases with h = 0 and h = 1 are obvious. If h ≥ 2, then P (h, t) = 2h+1 − 1 + t + 2 · P (h − 2, 0) + P (h − 1, t + 1). By the induction hypothesis, we have that 2 · P (h − 2, 0) ≤ 1 2 P (h − 1, t + 1) ≤ 1 2 · 4 3 · 4 3 h · 2h − 4 3 h · 2h − 2 3 2h + 2h + 1 2 1 2 g(h − 2) · (h − 2)2h + 2 · f (h − 2), g(h − 1) · (h − 1)2h + f (h + t) + (h − 1) · (t + 1). and Thus, we obtain P (h, t) ≤ 4 3 h·2h + (cid:18) g(h − 2) · (h − 2) + g(h − 1) · (h − 1) 2 (cid:19) h + 2f (h − 2) − 2 2h + ·2h +f (h+t)+h·t. Choosing the right constant C, we can show that for all h ≥ 2, we have g(h − 2) · (h − 2) + g(h − 1) · (h − 1) 2 h + 2f (h − 2) − 2 2h + ≤ h · g(h), 35 and so the inductive step is true. This means that (cid:18) P (h, 0) ≤ 4 3 · h · 2h · (cid:19) = (1 + oh(1)) · 4 3 · h · 2h, 1 + 3 4 g(h) + 3f (h) 4h · 2h (where the oh(1) term goes to 0 as h → ∞) and so, for any ε > 0 there are instances where OP T ≥ 3 2 − ε. ALG C Any "natural" rounding scheme cannot break the O(log n) bar- rier for HL1 on graphs with unique shortest paths and diameter D and two stars A and B, with N =(cid:0) k In this section, we show that any rounding scheme that may assign v ∈ Hu only if xuv > 0 gives Ω(log n) approximation, even on graphs with shortest-path diameter D = O(log n). For that, consider the following tree T , which consists of a path P = {1, ..., k} of length k = 3t, t ∈ N \ {0}, exactly 2t). The center a of A is connected to vertex "1" of P and the center b of B is connected to vertex "k" of P . The total number of vertices of T is n = 2N + 2 + k, which implies that t = Ω(log n). (cid:1) leaves each (each leaf corresponding to a subset of [k] of size 2t A B P a 1 2 k b Figure 2: An instance that cannot be rounded well with any "natural" rounding scheme Consider now the following LP solution (all variables not assigned below are set to zero): • xuu = 1, for all u ∈ T . • xSa = 1, for all S ∈ A. • xW b = 1, for all W ∈ B. • xSi = 1/t, for all S ∈ A, i ∈ S ⊆ P . • xW i = 1/t, for all W ∈ B, i ∈ W ⊆ P . • xab = xba = 1. • xia = xib = 1, for all i ∈ [k]. • {xij}i,j∈[k] is an optimal solution for P . 36 Observe that the above solution is indeed a feasible fractional solution. Its cost is at most n + 3(A + B) + 2 + 2k + c · k · log k = Θ(n), for some constant c. Suppose now that we are looking for a rounding scheme that assigns v ∈ Hu only if xuv > 0, and let's assume that there exists a vertex S ∈ A whose resulting hub set satisfies HS ∩ P < t. We must also have HS ∩ B = ∅, since xSu = 0 for all u ∈ B. This implies that there exists a W ∈ B such that W ∩ HS = ∅. Since the above fractional solution assigns non-zero values only to xW i with i ∈ W and xW b, this means that xW i = 0 for all i ∈ HS. Thus, the resulting hub set cannot be feasible, which implies that any rounding that satisfies the aforementioned property and returns a feasible solution must satisfy HS ∩ P ≥ t for all S ∈ A (similarly, the same holds for all W ∈ B). This means that the returned solution has cost Ω(n· t) = Ω(n· log n), and so the approximation factor must be at least Ω(log n). D Hub labeling on directed graphs In this section, we sketch how some of the presented techniques can be used for the case of directed graphs. Let G = (V, E) be a directed graph with edge lengths l(e) > 0. Instead of having one set of hubs, each vertex u has two sets of hubs, the forward hubs H (f ) and the backward hubs H (b) u . The covering property is now stated as follows: for every (directed) pair (u, v) and some directed u ∩ H (b) v ∩ P (cid:54)= ∅. The HLp objective function can shortest path P from u to v, we must have H (f ) u . u + H (b) (cid:1)1/p, where Lu = H (f ) be written as(cid:0)(cid:80) u u u∈V Lp The Set Cover based approach of Cohen et al. ([15]) and Babenko et al. ([8]) can be used in this setting in order to obtain an O(log n) approximation for HLp, p ∈ [1,∞]. It is also straightforward to see that there is a very simple 2-approximation preserving reduction from undirected HLp to directed HLp, implying that an α-approximation for directed HLp would give a 2α-approximation for undirected HLp. Thus, the hardness results of Section 6 can be applied to the directed case as well, and so we end up with the following theorem. Theorem 33. HLp is Ω(log n)-hard to approximate in directed graphs with multiple shortest paths, for p ∈ {1,∞}, unless P= NP. Having matching lower and upper bounds (up to constant factors) for the general case, we turn again to graphs with unique (directed) shortest paths. The notion of pre-hubs can be extended to u )}u∈V is a family of pre-hubs if for every u , (cid:98)H (b) v ∩ Puv such that u(cid:48) ∈ Pv(cid:48)v. (DIR − LP1) We now present the LP relaxation for the (cid:96)1 case. the directed case as follows: a family of sets {((cid:98)H (f ) pair (u, v) there exist u(cid:48) ∈ (cid:98)H (f ) u ∩ Puv and v(cid:48) ∈ (cid:98)H (b) (cid:17) (cid:88) (cid:88) (cid:88) vw} ≥ 1, w∈Puv uv ≥ 0, x(f ) uv ≥ 0, x(b) v∈V min{x(f ) x(f ) uv + x(b) uv uw, x(b) (cid:16) min : u∈V s.t.: In order to obtain a feasible set of pre-hubs, for each vertex u ∈ V we construct two trees (both is the union is the union of all directed paths from u to all other vertices, and T (b) u rooted at u): T (f ) u ∀(u, v) ∈ V × V, ∀(u, v) ∈ V × V, ∀(u, v) ∈ V × V. 37 that these are indeed trees. We proceed as in the undirected case and obtain a set (cid:98)H (f ) uv ) of size at most 2(cid:80) uv . It is not hard to see that the obtained sets ((cid:98)H (f ) u , (cid:98)H (b) of all directed paths to u from all other vertices. We drop the orientation on the edges, and we note from T (f ) (using the variables u )u∈V are uv ) of size at most 2(cid:80) uv , and a set (cid:98)H (b) from T (b) u v∈V x(f ) v∈V x(b) u u u (using the variables x(f ) x(b) indeed pre-hubs. We can now use a modified version of Algorithm 1, as given below. uv )}(u,v)∈V ×V . 1 Solve DIR − LP1 and get an optimal solution {(x(f ) 2 Obtain a set of pre-hubs {((cid:98)H (f ) u )}u∈V from x. u , (cid:98)H (b) 3 Generate a random permutation π : [n] → V of the vertices. 4 Set (H (f ) 5 for i = 1 to n do 6 u ) = (∅, ∅), for every u ∈ V . for every u ∈ V do u , H (b) uv , x(b) for every u(cid:48) ∈ (cid:98)H (f ) if Pπiu(cid:48) ∩ H (f ) for every u(cid:48) ∈ (cid:98)H (b) if Pu(cid:48)πi ∩ H (b) end end u , such that πi ∈ Puu(cid:48) and Pπiu(cid:48) ∩ (cid:98)H (f ) u , such that πi ∈ Pu(cid:48)u and Pu(cid:48)πi ∩ (cid:98)H (b) u = ∅ then H (f ) u ∪ {πi} := H (f ) u u = ∅ then H (b) u := H (b) u ∪ {πi} 7 8 9 10 11 12 u = {u(cid:48)} do u = {u(cid:48)} do end 13 14 end 15 Return {(H (f ) u , H (b) u )}u∈V . Algorithm 3: Algorithm for HL1 on directed graphs with unique shortest paths u ] ≤ 2(log D + O(1))·(cid:80) we prove that E[(cid:98)H (f ) It is easy to see that the obtained solution is always feasible, and, with similar analysis as before, uv . Thus, in expectation, we obtain a solution of cost O(log D) · OP TDIR−LP1. The analysis can also be generalized for arbitrary fixed p ≥ 1, similar to the analysis of Ap- pendix A. The algorithm is modified in the same way, and using the fact that for x, y, p ≥ 1, we have xp + yp ≤ (x + y)p ≤ 2p(xp + yp), we can again obtain an approximation of the form c · ln(p+1) HarmD ·OP TREL, where OP TREL is the optimal value of the corresponding convex re- laxation. Thus, we obtain the following theorem. u ] ≤ 2(log D + O(1))·(cid:80) uv and E[(cid:98)H (b) v x(f ) v x(b) p (cid:16) (cid:17) Theorem 34. There is an O graphs with unique shortest paths. ln(p+1) · log D p -approximation algorithm for HLp, p ≥ 1, on directed 38
1102.3491
1
1102
2011-02-17T04:22:13
A simple PTAS for Weighted Matroid Matching on Strongly Base Orderable Matroids
[ "cs.DS" ]
We give a simple polynomial time approximation scheme for the weighted matroid matching problem on strongly base orderable matroids. We also show that even the unweighted version of this problem is NP-complete and not in oracle-coNP.
cs.DS
cs
A simple PTAS for Weighted Matroid Matching on Strongly Base Orderable Matroids∗ † Jos´e A. Soto‡ Abstract We give a simple polynomial time approximation scheme for the weighted matroid matching problem on strongly base orderable matroids. We also show that even the unweighted version of this problem is NP-complete and not in oracle-coNP. 1 Preliminaries We assume familiarity with basic graph and matroid theory. For reference, see Schrijver's book [4]. Given a matroid M = (S, I) and a graph G = (S, E), we say that a matching F ⊆ E is feasible for M if the set S F ⊆ S of vertices covered by F is independent in M. Given a weight function, w : E → R+, the weighted matroid matching problem consists on finding a feasible matching of maximum weight. This problem is a common generalization to both the weighted graphic matching and the weighted matroid intersection problems. Even for the unweighted version (where every edge has unit weight), the previous problem is not polynomially solvable when the matroid is given by an independence oracle [1, 3]: there are instances where checking that no feasible matching of a given size exists requires an exponential number of oracle queries. These instances can be modified to show NP-completeness [4]. For the unweighted version, Lov´asz [3] has given a polynomial time algorithm for linear matroids. Recently, Lee et al. [2] have developed a PTAS for general matroids using local search techniques. For arbitrary weights, the situation is less developed. We only have polynomial time algorithms for the case where the matroid is a gammoid [5]. An open problem of Lee et al. [2] is to get a PTAS for the weighted version on general matroids. In this note we focus on a special class of matroids containing gammoids and not comparable with linear matroids. A matroid M = (S, I) is strongly base orderable if for every pair of bases I and J, there is a bijection π : I → J such that for all K ⊆ I, the set π(K) ∪ (I \ K) is also a base of the matroid. On the positive side, we give a local search based PTAS for the weighted matroid matching problem on strongly base orderable matroids. On the negative side, we show that even the unweighted version of this problem is NP-complete and not in oracle co-NP. The negative results follow since the matroids used to prove the analogue hardness results for matroid matching are strongly base orderable. ∗This work was partially supported by NSF contract CCF-0829878 and by ONR grant N00014-11-1-0053. †Extended abstract of this article to appear in the proceedings of the Sixth Latin-American Algorithms, Graphs and Optimization Symposium (LAGOS) 2011. ‡MIT, Dept. of Math., Cambridge, MA 02139. [email protected]. 1 An important special case of the weighted matroid matching problem is the weighted matroid parity problem. In this version, the set E of edges (also denoted as pairs or mates) is itself a matching. The following reduction [2] shows that both problems are equivalent. Given an instance (M, G, w) of the weighted matroid matching problem, define a new set S′ of elements containing as many copies of every vertex s as its degree in G = (S, E). Construct a new graph G′ = (S′, E′) by creating for every edge {u, v} ∈ E, one edge of the same weight between a copy of u and a copy of v in S′, in such a way that the new collection of edges E′ is a matching. Let M′ = (S′, I ′) be the matroid in which a set I ′ ⊆ S′ is independent if it has at most one copy of each element of S and the respective set I of original elements is independent in M. It is easy to check that the previous construction gives an approximation preserving reduction and that if M is strongly base orderable then so is the matroid M′. The last statement follows since strong base orderability of matroids is closed under taking parallel extensions [4, Section 42.6c]. 2 A local search PTAS for Weighted Matroid Parity Consider a matroid M = (S, I), a partition E of S into n pairs and a weight function w : E → R+. A folklore result (see, e.g. [2]) is that the greedy solution obtained by processing the pairs in decreasing order of weight, and selecting only those pairs that keep the current solution feasible, is a 2-approximation for the weighted matroid parity problem. Definition 2.1. An s-move for a feasible set of pairs A is a choice of pairs A ⊆ A and B ⊆ E \ A, with A + B ≤ s, such that D = A∆(A ∪ B) is feasible. The value w(B) − w(A) is the gain of the move. The move improves A if its gain is positive (equiv., if w(D) > w(A)). For a given δ > 0, the move δ-improves A if its gain is at least δw(A) (equiv., if w(D) > (1 + δ)w(A)). A feasible set is a local optimum for s-moves if no s-move improves it. A feasible set is a δ-local optimum for s-moves if no s-move δ-improves it. Consider the following local search algorithms for the unweighted and weighted matroid parity problems respectively, parameterized by an integer s ≥ 1. Algorithm 1. While there is an s-move improving the current solution, initially empty, perform the s-move of maximum gain. Return the solution found. Algorithm 2. Start from a greedy solution A0 for the problem. While there is an s-move 1/n2- improving the current solution, perform the s-move with maximum gain. Return the solution found. Lemma 2.2. Given s ≥ 1, Algorithm 1 (resp. Algorithm 2) returns a local optimum (resp. a 1/n2- local optimum) for s-moves for the unweighted (resp. weighted) matroid parity problem in O(ns+1) time (resp. O(ns+2) time). Proof. Clearly, both algorithms are finite and correct and the greedy solution A0 can be found in O(n log n) time, which is O(ns+2). Given a feasible solution A, the number of possible s-moves for A is O(ns). Then each iteration of both algorithms can be done in O(ns) time and using the same number of oracle calls. To conclude, we show that the number of iterations is bounded. Since every iteration of the first algorithm improves the current solution by one unit and the optimum solution has cardinality at most n, this algorithm performs at most n iterations. In the second algorithm, every iteration improves the weight of the current solution by a factor (1 + 1/n2). 2 Since the initial solution A0 and the solution returned are at most a factor two apart, the number of iterations is at most log(1+1/n2)(2) ≤ (1 + n2) log(2) = O(n2). The following lemma, which we prove at the end of this section, is useful to obtain a PTAS when M is strongly base orderable. Lemma 2.3. Let t ≤ n be a positive integer and B be an optimal feasible solution of the weighted matroid parity problem on an strongly base orderable matroid. If A is a local optimum for (2t + 1)- moves then w(A) ≥ (1 − 1/(t + 1)) w(B). If A is a 1/n2-local optimum for (2t + 1)-moves then w(A) ≥ (1 − 2/(t + 2)) w(B). Given 0 < ε < 1, set t(ε) = ⌈1/ε⌉ and t′(ε) = 2t(ε). By Lemma 2.3, any local optimum for (2t(ε)+1)-moves is a (1+ε)-approximation, and so is any 1/n2-local optimum for (2t′(ε)+1)-moves. By choosing s appropriately in Lemma 2.2, we have the following corollary. Corollary 2.4. Algorithm 1 (resp. Algorithm 2) returns a (1+ε)-approximation for the unweighted (resp. weighted) matroid parity problem for strongly base orderable matroids in time O(n2⌈1/ε⌉+2) (resp. O(n4⌈1/ε⌉+3)). Using the reduction from matroid matching to matroid parity we obtain our main positive result. Theorem 2.5. There is a PTAS for both the weighted and the unweighted matroid matching prob- lems on strongly base orderable matroids. Proof of Lemma 2.3. For two feasible solutions A and B, consider the collections A′ and B′ obtained by adding dummy pairs of zero weight to the set of smaller cardinality, so that A′ = B′ ≤ n. Let X be the set of elements added and M′ = (S ∪ X, I ′) be the matroid obtained from M = (S, I) by first adding X as coloops and then truncating M′ to rank 2A′ = S A′. By properties of strongly base orderable matroids (see, e.g. [4, Section 42.6c]), M′ is also strongly base orderable and both I = S A′ and J = S B′ are bases of M′. Consider a bijection π : I → J such that for all K ⊆ I, π(K) ∪ (I \ K) is a base of M′. We can further impose πI∩J to be the identity map (see, e.g. [4, Section 42.6c]). Let H be the multigraph on the set A′ ∪ B′ having one edge between a = {u, v} ∈ A′ \ B′ and b = {u′, v′} ∈ B′ \ A′ if only one element in {u, v} is mapped to {u′, v′} and two parallel edges between them if π({u, v}) = {u′, v′}. Since every vertex has degree two and the graph is bipartite, H is a collection of vertex-disjoint even cycles. Orient the edges so that every cycle is properly directed to obtain a digraph ~H. See Figure 1. For a positive integer t, let C+ t be the collection of long cycles in ~H, having length at least 2t + 2 t be the collection of short cycles in ~H, having length at most 2t (for convenience, include t all the isolated nodes in A′ ∩ B′ as zero-length cycles). Let V + and V − be the sets of nodes and C− in C− in long and short cycles respectively. Note that V + and V − form a partition of A′ ∪ B′. For every cycle C of ~H, π(S(C ∩ A′)) = S(C ∩ B′). Hence A′∆C is a feasible matching for M′. t , the collection of pairs C \ X defines a 2t-move for A in Therefore, for every short cycle C ∈ C− the original matroid M. For every a ∈ V + ∩ A′, define the set Ha of nodes reachable from a by using at most 2t directed arcs in ~H. This is, Ha is the node set of the directed path starting in a, having t + 1 nodes from A′ and having t nodes from B′. By construction, for every a ∈ V + ∩ A′, the image under π of 3 B \ A A′ \ B′ B′ \ A′ A′ \ B′ B′ \ A′ A \ B A ∩ B A′ ∩ B′ A′ ∩ B′ Figure 1: In the left, feasible sets A and B sharing one pair. In the middle, sets A′ and B′ and the bijection π : S A′ → S B′. In the right, a possible orientation of H. S(Ha ∩ A′) contains S(Ha ∩ B′). This observation, together with the definition of π, implies that A′∆Ha is feasible for the matroid M′. Therefore, Ha \ X defines a (2t + 1)-move for A in M. The total gain of moves coming from short cycles, {C \ X : C ∈ C − t }, is [w(C ∩ B′) − w(C ∩ A′)] X C∈C− t and the total gain of moves from long cycles, {Ha \ X : a ∈ V + ∩ A′}, is X a∈V +∩A′ [w(Ha ∩ B′) − w(Ha ∩ A′)] = X C∈C+ t [tw(C ∩ B′) − (t + 1)w(C ∩ A′)]. Suppose that B is optimal and A is a local optimum for (2t + 1)-moves. Then each of the above t , we have 0 ≥ w(C ∩ B′) − w(C ∩ A′) ≥ moves has nonpositive gain. In particular, for each C ∈ C− tw(C ∩ B′) − (t + 1)w(C ∩ A′). Therefore, 0 ≥ X C∈C− t ∪C+ t [tw(C ∩ B′) − (t + 1)w(C ∩ A′)] = tw(B′) − (t + 1)w(A′) = tw(B) − (t + 1)w(A). From here, we have that w(A) ≥ tw(B)/(t + 1) = (1 − 1/(t + 1))w(B). If A is a 1/n2-local optimum for (2t + 1)-moves, then each move has gain of at most w(A)/n2. Since t ≤ n, C− t ≤ V − ∩ A′ and A′ ≤ n, we have w(A) ≥ w(A) n2 (tC− t + V + ∩ A′) ≥ X C∈C− t ∪C+ t [tw(C ∩ B′) − (t + 1)w(C ∩ A′)] = tw(B′) − (t + 1)w(A′) = tw(B) − (t + 1)w(A). From here, we have that w(A) ≥ tw(B)/(t + 2) = (1 − 2/(t + 2))w(B). 3 Matroid parity is hard on strongly base orderable matroids. Here we review the proofs of hardness of matroid parity on general matroids (see [4, Section 43.9] for more details). Let ν ∈ Z+, S be a set of even size and E be a partition of S into pairs. Let M be the matroid on S, where T ⊆ S is independent if T ≤ 2ν − 1, or if T = 2ν and T is not 4 the union of ν pairs in E. For every set F ⊆ E of size ν, let MF be the matroid extending M by an independent set IF = S F ⊆ S. Also, given a graph G = (E, X), construct MG by extending M by all independent sets IC = S C, where C is the vertex set of a clique of size ν in G. It can be shown that M, MF and MG are matroids, that E has no matching of size ν feasible for M, that F ⊆ E is the unique matching of size ν feasible for MF , and that E contains a matching of size ν feasible for MG if and only if G has a clique of size ν. Given ν, the above set E and an oracle for a matroid N that is known to be either M or any of the possible MF with F = ν, it is known that the number of oracle calls needed to check if there is a matching of size ν feasible for N is at least (cid:0)E ν (cid:1), showing that the matroid parity problem is not in oracle co-NP. Similarly, as the maximum-size clique problem is NP-complete, the matroid parity problem on matroids MG constructed as above is NP-complete. Note that M and MF are special cases of MG, obtained from a graph having zero or one clique of cardinality ν. The following lemma implies that the hardness guarantees for the matroid parity problem are maintained if we restrict to strongly base orderable matroids. Lemma 3.1. For every ν ∈ Z+ and every graph G, the matroid MG is strongly base orderable. Proof. Let ν ∈ Z+ and G = (E, X) be a graph. Create a set S having two copies of each element in E, and interpret E as a partition of S into pairs or mates. The bases of MG are then B(MG) = {I ⊆ S : I = 2ν, and I is not the union of ν pairs of E} ∪ {I ⊆ S : I is the union of ν pairs F , where F is a clique in G}. Let I, J ⊆ S be two bases in B(MG). In what follows we construct a bijection π : I → J, such that for all K ⊆ I, L = π(K) ∪ (I \ K) is also a base. We divide the problem in cases. In each of them we impose conditions on π that can easily be satisfied by some bijection. In particular, for every case, we impose πI∩J to be the identity map. By assuming that L is the union of ν pairs, we either show that L ∈ {I, J} or we get a contradiction, proving in both situations that L is a base. Under the assumption that L is the union of ν pairs, the following two properties hold. Property 1: An element is in L if and only if its mate is in L. Property 2: An element in I∆J is in L if and only if its image or preimage under π is not in L. There are nine cases to consider for I and J. For visual aid on the first five cases, see Figure 2. (i) If there is u ∈ I ∩ J whose mate is in S \ (I ∪ J), then any bijection π works. Since π(u) = u, any set L = π(K) ∪ (I \ K) as above contains u but not its mate. Thus, L is not the union of ν pairs. (ii) Else, if there are u ∈ I \ J and v ∈ J \ I with mates in S \ (I ∪ J), then select any such u and v, and set π(u) = v. (iii) Else, if there are u ∈ I \ J and v ∈ J \ I with {u, v} ∈ E, then select any such pair and set π(u) = v. Cases (ii) and (iii) are similar: any set L = π(K) ∪ (I \ K) contains either u or v, but not its corresponding mate. Thus, L is not the union of ν pairs. 5 u v u v u (i) (iii) v2 v1 (ii) ¯u2 u2 u1 ¯u1 u ¯u v ¯v (iv) (v) Figure 2: Cases (i) -- (v). In each case, ν = 4, the top-left region is I \ J, the top-right region is J \ I and the bottom region is I ∩ J. Thick lines represent E. Thin arrows represent a possible map π : I → J. (iv) Else, if there are pairs {u, ¯u} and {v, ¯v} in E with u ∈ I \ J, v ∈ J \ I and {¯u, ¯v} ⊆ I ∩ J, then set π(u) = v. For case (iv), note that any set L as above contains both ¯u and ¯v but only one of their mates. Thus, L is not the union of ν pairs. (v) Else, if there are pairs {u1, ¯u1}, {u2, ¯u2}, {v1, v2} in E with ui ∈ I \ J, vi ∈ J \ I, for i ∈ {1, 2}, ¯u1 ∈ I ∩ J, and ¯u2 ∈ S \ (I ∪ J), then set π(ui) = vi, for i ∈ {1, 2}. (Also consider here the same case with I and J interchanged.) For case (v), consider a set L as above and assume L is the union of ν pairs. Since ¯u1 is in I ∩ J, we have π(¯u1) = ¯u1, and so ¯u1 must be in L. In what follows we apply Properties 1 and 2 iteratively. Since ¯u1 is in L, its mate u1 is also in L. Then, π(u1) = v1 is outside set L, and so is its mate v2 = π(u2). This implies that u2 is in L. But its mate ¯u2 is outside L, contradicting the assumption. If none of the previous cases hold, then only one of I \ J or J \ I can contain an element with mate in I ∩ J, and only one can contain an element with mate in S \ (I ∪ J). Furthermore, none of the two sets can contain both types of elements. The rest of the pairs intersecting I ∪ J are completely inside I \ J, J \ I or I ∩ J. Therefore, by possibly interchanging the roles of I and J, we can assume that (1) the set I \ J contains a ≥ 0 elements with mates in I ∩ J, and k ≥ 0 pairs completely inside; (2) the set J \ I contains b ≥ 0 elements with mates in S \ (I ∪ J) and ℓ ≥ 0 6 Under these assumptions, let (u1, u′ pairs completely inside; (3) the set I ∩ J contains c ≥ 0 pairs completely inside; and (4) no pair other than the ones described before intersects I ∪ J. 1), . . . , (uk, u′ ℓ) be the pairs com- pletely inside I \ J and J \ I respectively. Note that 2k + a = 2ℓ + b = I \ J = J \ I. In particular, if b > a, then k > ℓ and viceversa. We proceed with the rest of the cases. For visual aid, see Figure 3. k) and (v1, v′ 1), . . . , (vℓ, v′ u1 u′ 1 uk u′ k v1 v′ 1 vℓ v′ ℓ u1 u′ 1 uk u′ k v1 v′ 1 vℓ v′ ℓ u1 u′ 1 uk u′ k v1 v′ 1 vℓ v′ ℓ uk+1 vk+1 u1 u′ 1 uk u′ k v1 v′ 1 vℓ v′ ℓ (vi) (vii) (viii) (ix) In each Figure 3: Cases (vi) -- (ix), corresponding to (a, b, ν) = (1, 5, 7); (5, 1, 7); (3, 3, 7); (0, 0, 6). case, the top-left region is I \ J, the top-right region is J \ I and the bottom region is I ∩ J. Thick lines represent E. Thin arrows represent a possible map π : I → J. The elements of I \ J and J \ I are numbered from up to down as u1, u′ 2, . . ., respectively. 2, . . . and v1, v′ 1, u2, u′ 1, v2, v′ (vi) If a < b, let {vi, v′ i : i = ℓ + 1, . . . , k} be a set of 2(k − ℓ) = b − a different elements of J \ I with mates in S \ (I ∪ J). Set π(ui) = v′ i and π(u′ i) = vi+1 (mod k) for every 1 ≤ i ≤ k. Assume that L is the union of ν pairs. Then no element with mate in S \ (I ∩ J) is in L. Using Property 2, the preimages under π of these elements are in L. In particular, uℓ+1, . . . , uk are in L. By repeatedly using Properties 1 and 2, starting on element uk, we conclude that all u1, u′ 1, . . . , uk, u′ k are in L, and that their images, v1, v′ k are not in L. Furthermore, since the a elements of I with mates in I ∩ J are also in L, we conclude that L = I. 1, . . . , vk, v′ (vii) If b < a, let {ui, u′ i : i = k + 1, . . . , ℓ} be a set of 2(ℓ − k) = a − b different elements of I \ J with mates in I ∩ J. Set π(ui) = v′ i and π(u′ i) = vi+1 (mod ℓ) for every 1 ≤ i ≤ ℓ. Assume that L is the union of ν pairs. Then every element with mate in I ∩ J is in L. Using Prop- erty 2, the images of these elements are not in L. This is, the elements v′ ℓ, v1 are not in L. By repeatedly using Properties 1 and 2, starting on element v1, we conclude that L = I. k+2, . . . , vℓ, v′ k+1, vk+2, v′ 7 (viii) If b = a > 0, let uk+1 be an element in I \ J with mate in I ∩ J, and vk+1 be an element i) = vi+1 for every 1 ≤ i ≤ k and in J \ I with mate in S \ (I ∪ J). Set π(ui) = v′ π(uk+1) = v1. i, π(u′ If L is the union of ν pairs, then every element with mate in I ∩ J is in L. In particular, uk+1 ∈ L and, by Property 2, its image v1 is outside L. By repeatedly using Properties 1 and 2, starting on element v1 we get L = I. This proof also holds in the degenerated case where k = ℓ = 0. (ix) If b = a = 0. Set π(ui) = v′ i, π(u′ i) = vi+1 (mod k) for every 1 ≤ i ≤ k. For this final case, let L be a union of ν pairs. If u1 ∈ L then it is easy to see, using Properties 1 and 2, that L = I. Similarly, if u1 6∈ L then L = J. We have proved that for every case, and for every K ⊆ I, if the set L = π(K) ∪ (I \ K) is a union of pairs then L ∈ {I, J}. Thus, L is always a base of MG, and therefore MG is an strongly base orderable matroid. Acknowledgment The author would like to thank Jan Vondr´ak for helpful discussions. References [1] P. M. Jensen and B. Korte. Complexity of matroid property algorithms. SIAM Journal on Computing, 11(1):184 -- 190, 1982. [2] J. Lee, M. Sviridenko, and J. Vondr´ak. Matroid matching: the power of local search. In Proceedings of the 42th ACM Symposium on Theory of Computing, pages 369 -- 378, 2010. [3] L. Lov´asz. Matroid matching problems. In L. Lov´asz and V. T. S´os, editors, Algebraic Methods in Graph Theory, volume 25 of Colloquia Mathematica Societatis J´anos Bolyai, pages 495 -- 517. North-Holland, 1981. [4] A. Schrijver. Combinatorial Optimization - Polyhedra and Efficiency. Springer, 2003. [5] P. Tong, E. Lawler, and V. Vazirani. Solving the weighted parity problem for gammoids by reduction to graphic matching. Progress in combinatorial optimization (Waterloo, Ont.), pages 363 -- 374, 1982. 8
1503.02416
1
1503
2015-03-09T10:17:30
Approximating LZ77 in Small Space
[ "cs.DS" ]
Given a positive \(\epsilon \leq 1\) and read-only access to a string \(S [1..n]\) whose LZ77 parse consists of $z$ phrases, with high probability we can build an LZ77-like parse of $S$ that consists of $\Oh{z / \epsilon}$ phrases using $\Oh{n^{1 + \epsilon}}$ time, $\Oh{n^{1 + \epsilon} / B}$ I/Os (where $B$ is the size of a disk block) and $\Oh{z / \epsilon}$ space.
cs.DS
cs
Approximating LZ77 in Small Space Travis Gagie Department of Computer Science, University of Helsinki, Finland 1 Introduction Although nearly forty years old, Ziv and Lempel's LZ77 [5] is still one of the best algorithms for compressing repetitive datasets such as genomic databases, software repositories and versioned text. The LZ77 parse of a string can also be used to speed up online pattern-matching and to reduce the size of indexes; see, e.g., [1]. When the dataset is too large to fit in internal memory, however, com- puting the parse is a challenge. The best known external-memory algorithm [2] for computing the parse exactly takes O(cid:0)n2/(M B)(cid:1) I/Os, where M is the size of the internal memory and B is the size of a disk block. There are more efficient external-memory algorithms that can be used to approximate the parse -- see, e.g., [4] -- but the known approximation ratios are at least logarithmic. In this paper we describe a randomized algorithm with which, given a positive ǫ ≤ 1 and read-only access to a string S[1..n] whose LZ77 parse consists of z phrases, with high probability we can build an LZ77-like parse of S that consists of O(z/ǫ) phrases using O(cid:0)n1+ǫ(cid:1) time, O(cid:0)n1+ǫ/B(cid:1) I/Os and O(z/ǫ) space. By "LZ77-like" we mean that, first, the concatenation of the phrases is S; second, for each phase S[i..j], either i = j, in which case we encode S[i] as h0, S[i]i, or S[i..j] first occurs at position i′ in S[1..j − 1], in which case we encode S[i..j] as hi′, j − i + 1i. 2 Algorithm Assume we have an easy way to determine where substrings of lengths n, f (n), f (f (n)), . . . , 2 first occur in S, where f (ℓ) = min(⌈ℓ(1 − 1/nǫ)⌉, ℓ − 1). Then we can approximate the LZ77 parse by calling parse(1, n, n), where parse(i, j, ℓ) is the following recursive procedure: 1. if ℓ = 1 then we encode S[i], . . . , S[j] as h0, S[i]i, . . . , h0, S[j]i and return; 2. if j − i + 1 < ℓ then we call parse(i, j, f (ℓ)) and return; 3. if S[j −ℓ+1..j] first occurs at position i′ in S[1..j −1], then we call parse(i, j − ℓ, ℓ), encode S[j − ℓ + 1..j] as hi′, ℓi, and return; 4. for k from 0 to ⌊(j − i + 1)/ℓ⌋ − 1, if S[i + kℓ..i + (k + 1)ℓ − 1] first occurs at position i′ in S[1..i + (k + 1)ℓ − 2], then we call parse(i, i + kℓ − 1, f (ℓ)), encode S[i + kℓ..i + (k + 1)ℓ − 1] as hi′, ℓi, call parse(i + (k + 1)ℓ, j, ℓ), and return; 5. if none of the conditions above are met, then we call parse(i, j, f (ℓ)) and return. For example, suppose S = ababbabbaabbabbaababa and 21ǫ = 4, so f (ℓ) = min(⌈3ℓ/4⌉, ℓ − 1): 1. parse(1, 21, 21) calls parse(1, 21, 16); 2. parse(1, 21, 17) calls parse(1, 21, 12); 3. parse(1, 21, 14) calls parse(1, 21, 9); 4. parse(1, 21, 9) calls parse(1, 9, 9), encodes S[10..18] as h3, 9i, and calls parse(19, 21, 9); 5. parse(1, 9, 9) calls parse(1, 9, 7); 6. parse(1, 9, 7) calls parse(1, 9, 6); 7. parse(1, 9, 6) calls parse(1, 9, 5); 8. parse(1, 9, 5) calls parse(1, 4, 5), and encodes S[5..9] as h2, 5i; 9. parse(1, 4, 5) calls parse(1, 4, 4); 10. parse(1, 4, 4) calls parse(1, 4, 3); 11. parse(1, 4, 3) calls parse(1, 4, 2); 12. parse(1, 4, 2) calls parse(1, 2, 2) and encodes S[3..4] as h1, 2i; 13. parse(1, 2, 2) calls parse(1, 2, 1); 14. parse(1, 2, 1) encodes S[1] as h0, ai, and encodes S[2] as h0, bi; 15. parse(19, 21, 9) calls parse(19, 21, 7); 16. parse(19, 21, 7) calls parse(19, 21, 6); 17. parse(19, 21, 6) calls parse(19, 21, 5); 18. parse(19, 21, 5) calls parse(19, 21, 4); 19. parse(19, 21, 4) calls parse(19, 21, 3); 20. parse(19, 21, 3) encodes S[19..21] as h1, 3i. Thus, our parse is encoded as a, b, ab, babba, abbabbaab, aba , h0, ai, h0, bi, h1, 2i, h2, 5i, h3, 9i, h1, 3i , while the true LZ77 parse is a, b, abb, abbaa, bbabbaaba, ba . It is not difficult to verify that our algorithm terminates and, assuming we find the first occurrences of substrings correctly, produces a valid encoding. The interesting problems are, first, to show how we can easily determine where sub- strings first occur in S and, second, to analyse its performance. Notice that if we make a recursive call on an interval S[i..j], the only substrings of length ℓ we ever consider in that interval are in {S[i + kℓ..i + (k + 1)ℓ − 1] {S[j − (k + 1)ℓ + 1..j − kℓ] : 0 ≤ k ≤ ⌊(j − i + 1)/ℓ⌋ − 1} ∪ : 0 ≤ k ≤ ⌊(j − i + 1)/ℓ⌋ − 1} . If we compute the Karp-Rabin fingerprints [3] of those substrings and store them in a membership data structure, such as a hash table, then we can search for their first occurrences by passing a sliding window of length ℓ over S, maintaining the fingerprint of the window and performing a membership query for it at each step. In fact, if we keep the branches of the recursion synchronized properly, we can use a single membership data structure and a single pass of a sliding window to find the first occurrences of all the substrings of length ℓ we ever consider while parsing S. Of course, using Karp-Rabin fingerprints means our algorithm is randomized and could produce an invalid encoding, albeit with a very low probability. We can check an encoding by comparing each phrase to the earlier substring it should match. In our example, step 1 requires passes with sliding windows of length 21 and 16 before we can execute parse(1, 21, 21) and parse(1, 21, 16); step 2, with one of length 12; step 3, with one of length 9; step 4 does not require a pass; steps 5 and 15, with one of length 7; steps 6 and 16, with one of length 6; steps 7 and 17, with one of length 5; step 8 does not require a pass; steps 9 and 18, with one of length 4; steps 10 and 19, with one of length 3; step 11, with one of length 2; steps 12, 13, 14 and 20 do not require a pass. A practical optimization would be to build a table that stores the position of the first occurrence of each substring of S of length f [i](n) < logσ M − c, where M is the size of the internal memory and c is a constant. Building this table takes O(n logσ M ) time, one pass over S and a 1/σc fraction of the internal memory. It allows us to avoid making passes with sliding windows shorter than logσ M − c. 3 Time, I/O and Space Bounds 1 Our algorithm's time and I/O complexities are dominated by the time and I/Os needed to make a pass over S for each length n, f (n), f (f (n)), . . . , 2. If we use a perfect hash table for the fingerprints, the time for each pass is O(n), and 1−1/nǫ n(cid:17) = O(nǫ log n). calculation shows that the number of passes is O(cid:16)log Therefore, we use O(cid:0)n1+ǫ log n(cid:1) total time and O(cid:0)n1+ǫ log(n)/B(cid:1) total I/Os. The space complexity is dominated by the data structures for handling the recursion itself, and by the hash tables. The total size of the data structures for the recursion can be bounded in terms of the number of phrases in our parse, which we show in the next section to be O(z/ǫ). We need only store one hash table at a time, and its size is proportional to the number of substrings we are currently considering. We consider a substring only if the all larger substrings overlapping it do not occur earlier in S, meaning they cross or end at a bounary between phrases in the LZ77 parse. It follows that each substring of length ℓ we 1−1/nǫ of a phrase boundary. Therefore, we consider must be within distance consider O(z) substrings of any given length. ℓ 4 Approximation Ratio Consider how many phrases in our parse can overlap a phrase S[i..j] in the LZ77 parse. The longest phrase we use that overlaps S[i..j] either completely covers S[i..j], covers a proper prefix of it, covers a proper suffix of it, or is properly contained in it. The first case is trivial; the second and third cases are essentially symmetric, as we are left trying to bound the number of our phrases that can overlap either a proper suffix or a proper prefix of S[i..j] that is immediately preceded or followed by one of our phrases; and the fourth case is a combination of the second and third, as we are left trying to bound the number of our phrases that can overlap a proper prefix and a proper suffix of S[i..j] that are separate by one of our phrases. Without loss of generality, we consider only the second case. That is, assume S[i..i′−1] is covered by one of our phrases, for some i′ > i, and consider how many of our phrases can overlap S[i′..j]. By inspection of our algorithm, the longest phrase we use that overlaps S[i′..j] either covers a suffix of it, say S[j ′ + 1..j], or starts at i′ and covers at least a 1 − 1/nǫ fraction of S[i′..j]. In the first case now, the longest phrase we use that overlaps S[i′..j ′] must end at S[j ′] and cover at least a 1 − 1/nǫ fraction of S[i′..j ′]. The second case is essentially the same as what we just considered. It follows that the number of our phrases that can overlap an LZ77 phrase is O(lognǫ n) = O(1/ǫ), so we use O(z/ǫ) phrases in total. We can summarize the previous section and this one so far as follows: given ǫ > 0 and read-only access to a string S[1..n] whose LZ77 parse consists of z phrases, with high probability we can build an LZ77-like parse consisting of O(z/ǫ) phrases using O(cid:0)n1+ǫ log n(cid:1) time, O(cid:0)n1+ǫ log(n)/B(cid:1) I/Os and O(z/ǫ) space. Notice that, if we divide ǫ by 2 before running our algorithm, then the time and I/O bounds are O(cid:0)n1+ǫ/2 log n(cid:1) = O(cid:0)n1+ǫ(cid:1) and O(cid:0)n1+ǫ/2 log(n)/B(cid:1) = O(cid:0)n1+ǫ/B(cid:1), so we get the slightly neater results stated in the introduction. Theorem 1. Given a positive ǫ ≤ 1 and read-only access to a string S[1..n] whose LZ77 parse consists of z phrases, with high probability we can build an LZ77-like parse of S that consists of O(z/ǫ) phrases using O(cid:0)n1+ǫ(cid:1) time, O(cid:0)n1+ǫ/B(cid:1) I/Os and O(z/ǫ) space. References 1. Travis Gagie and Simon J. Puglisi. Searching and indexing genomic databases via kernelization. Frontiers in Bioengineering and Biotechnology, 3(12), 2015. 2. Juha Karkkainen, Dominik Kempa, and Simon J. Puglisi. Lempel-Ziv parsing in external memory. In Proceedings of the Data Compression Conference, pages 153 -- 162, 2014. 3. Richard M. Karp and Michael O. Rabin. Efficient randomized pattern-matching algorithms. IBM Journal of Research and Development, 31(2):249 -- 260, 1987. 4. Shirou Maruyama and Yasuo Tabei. Fully online grammar compression in constant space. In Proceedings of the Data Compression Conference, pages 173 -- 182, 2014. 5. Jacob Ziv and Abraham Lempel. A universal algorithm for sequential data com- pression. IEEE Transactions on Information Theory, 23(3):337 -- 343, 1977.
1906.04120
1
1906
2019-06-10T16:53:27
Parallel Streaming Random Sampling
[ "cs.DS" ]
This paper investigates parallel random sampling from a potentially-unending data stream whose elements are revealed in a series of element sequences (minibatches). While sampling from a stream was extensively studied sequentially, not much has been explored in the parallel context, with prior parallel random-sampling algorithms focusing on the static batch model. We present parallel algorithms for minibatch-stream sampling in two settings: (1) sliding window, which draws samples from a prespecified number of most-recently observed elements, and (2) infinite window, which draws samples from all the elements received. Our algorithms are computationally and memory efficient: their work matches the fastest sequential counterpart, their parallel depth is small (polylogarithmic), and their memory usage matches the best known.
cs.DS
cs
Parallel Streaming Random Sampling Kanat Tangwongsan* Srikanta Tirthapura† 9 1 0 2 n u J 0 1 ] S D . s c [ 1 v 0 2 1 4 0 . 6 0 9 1 : v i X r a Abstract This paper investigates parallel random sampling from a potentially-unending data stream whose elements are revealed in a series of element sequences (minibatches). While sampling from a stream was extensively studied sequentially, not much has been explored in the parallel context, with prior parallel random-sampling algorithms focusing on the static batch model. We present parallel algorithms for minibatch-stream sampling in two settings: (1) sliding window, which draws samples from a prespecified number of most-recently observed elements, and (2) infinite window, which draws samples from all the elements received. Our algorithms are computationally and memory efficient: their work matches the fastest sequential counterpart, their parallel depth is small (polylogarithmic), and their memory usage matches the best known. 1 Introduction Consider a model of data processing where data is revealed to the processor in a series of element sequences (minibatches) of varying sizes. A minibatch must be processed soon after it arrives. However, the data is too large for all the minibatches to be stored within memory, though the current minibatch is available in memory until it is processed. Such a minibatch streaming model is a generalization of the traditional data stream model, where data arrives as a sequence of elements. If each minibatch is of size 1, our model reduces to the streaming model. Use of minibatches are common. For instance, in a data stream warehousing system [JS15], data is collected for a specified period (such as an hour) into a minibatch and then ingested, and statistics and properties need to be maintained during the ingestion. Minibatches may be relatively large, potentially of the order of Gigabytes or more, and could leverage parallelism (e.g., a distributed memory cluster or a shared-memory multicore machine) to achieve the desired throughput. Furthermore, this model matches the needs of modern "big data" stream processing systems such as Apache Spark Streaming [ZDL`13], where newly-arrived data is stored as a distributed data set (an "RDD" in Spark) that is processed in parallel. Queries are posed on all the data received up to the most recent minibatch. This paper investigates the foundational aggregation task of random sampling in the minibatch streaming model. Algorithms in this model observe a (possibly infinite) sequence of minibatches B1, B2, . . . , Bt, . . .. We consider the following variants of random sampling, all of which have been well studied in the context of sequential streaming algorithms. In the infinite window model, a random sample is chosen from all the minibatches seen so far. Thus, after observing Bt, a random sample is drawn from Yt i"1Bi. In the sliding window model with window size w, the sample after observing Bt is chosen from the w most-recent elements. Typically, the window size w is much larger than a minibatch size. 1 In this work, the window size w is provided at query time, but an upper bound W on w is known beforehand. *CS Program, Mahidol University International College, [email protected] †Dept. of Electrical and Computer Engineering, Iowa State University, [email protected] 1One could also consider a window to be the w most recent minibatches, and similar techniques are expected to work. 1 We focus on optimizing the work and parallel depth of our parallel algorithms. This is a significant point of departure from the traditional streaming algorithms literature, which has mostly focused on optimizing the memory consumed. In addition, we consider memory to be a scarce resource and design for scenarios where the size of the stream is very large -- and the stream, or even a sliding window of the stream, does not fit in memory. Hence, this work strives for parallel computational efficiency in addition to memory efficiency. 1.1 Our Contributions We present parallel random-sampling algorithms for the minibatch streaming model, in both infinite window and sliding window settings. These algorithms can use the power of shared-memory parallelism to speedup the processing of a new minibatch as well as a query for random samples. (cid:66) Efficient Parallel Algorithms. Our algorithms are provably efficient in parallel processing. We analyze them in the work-depth model, showing (1) they are work-efficient, i.e., total work across all processors is of the same order as an efficient sequential algorithm, and (2) their parallel depth is logarithmic in the target sample size, which implies that they can use processors nearly linear in the input size while not substantially increasing the total work performed. In the infinite-window case, the algorithm is work-optimal since the total work across all processors matches a lower bound on work, which we prove in this paper, up to constant factors. Interestingly, for all our algorithms, the work of the parallel algorithm is sublinear in the size of the minibatch. (cid:66) Small Memory. While the emphasis of this work is on improving processing time and throughput, our algorithms retain the property of having a small memory footprint, matching the best sequential algorithms from prior work. Designing such parallel algorithms requires overcoming several challenges. Sliding-window sampling is typically implemented with Priority Sampling [BDM02, BOZ09], whose work performed (per minibatch) is linear in the size of the minibatch. Parallelizing it reduces depth but does not reduce work. Generating skip offsets, à la Algorithm Z [Vit85] (reservoir sampling), can significantly reduce work but offers no parallelism. Prior algorithms, such as in [Vit85], seem inherently sequential, since the next location to sample from is derived as a function of the previously chosen location. This work introduces a new technique called R3 sampling, which combines reversed reservoir sampling with rejection sampling. R3 sampling is a new perspective on Priority Sampling that mimics the sampling distribution of Priority Sampling, but is simpler and has less computational dependency, making it amendable to parallelization. To enable parallelism, we draw samples simultaneously from different areas of the stream using a close approximation of the distribution. This leads to slight oversampling, which is later corrected by rejection sampling. We show that all these steps can be implemented in parallel. In addition, we develop a data layout that permits convenient update and fast queries. As far as we know, this is the first efficient parallelization of the popular reservoir-sampling-style algorithms. 1.2 Related Work Reservoir sampling (attributed to Waterman) was known since the 1960s. There has been much follow-up work, including methods for speeding up reservoir sampling by "skipping past elements" [Vit85], weighted reservoir sampling [ES06], and sampling over a sliding window [BOZ09, XTB08, BDM02, GL08]. The difference between the distributed streams model [Cor13, CMYZ12, GT01, CTW16] considered earlier, and the parallel stream model considered here is that in the distributed streams model, the focus is on minimizing the communication between processors while in our model, processors can coordinate using shared memory, and the focus is on work-efficiency of the parallel algorithm. Prior work on shared- memory parallel streaming has considered frequency counting [DAAE09, TTW14] and aggregates on graph streams [TPT13], but to our knowledge, there is none so far on random sampling. Prior work on warehousing 2 of sample data [BH06] has considered methods for sampling under minibatch arrival, where disjoint partitions of new data are handled in parallel. Our work also considers how to sample from a single partition in parallel, and can be used in conjunction with a method such as [BH06]. 2 Preliminaries and Notation řt A stream S is a potentially infinite sequence of minibatches B1B2, . . ., where each minibatch consists of one or more elements. Let St denote the stream so far until time t, consisting of all elements in minibatches i"1 ni, so Nt is the size of St. The size of a minibatch is not known B1, B2, . . . , Bt. Let ni " Bi and Nt " until the minibatch is received, and the minibatch is received as an array in memory. A stream segment is a finite sequence of consecutive elements of a stream. For example, a minibatch is a stream segment. A window of size w is the stream segment consisting of the w most recent elements. Let rns denote the set t1, . . . , nu. For sequence X " xx1, x2, . . . , xXy, the i-th element is denoted by Xi or Xris. For convenience, negative index ´i, written Xr´is or X´i, refers to the i-th index from the right end -- i.e., XrX ´ i ` 1s. Following common array slicing notation, let Xra:s be the subsequence of X starting from index a onward. An event happens with high probability (whp) if it happens with probability at least 1 ´ n´c for some constant c ě 1. Let UniformSamplepa, bq, a ď b, be a function that returns an element from ta, a ` 1, . . . , bu chosen uniformly at random. For 0 ă p ď 1, coin(p) P tH, Tu returns heads (H) with probability p and tails (T ) with probability 1 ´ p. For m ď n, an m-permutation of a set S , S " n, is an ordering of m elements chosen from S . We analyze algorithms in the work-depth model assuming concurrent reads and arbitrary-winner concur- rent writes. The work of an algorithm is the total operation count, and depth (also called parallel time or span) is the length of the longest chain of dependencies within that algorithm. The gold standard in this model is for an algorithm to perform the same amount of work as the best sequential counterpart (work-efficient) and to have polylogarithmic depth. This setting has been fertile ground for research and experimentation on parallel algorithms. Moreover, results in this model are readily portable to other related models, e.g., exclusive read and exclusive write, with a modest increase in cost (see, e.g., [BM04]). Parallel semisorting is the problem of reordering an input sequence of keys so that like sorting, equal keys are arranged contiguously, but unlike sorting, different keys are not necessarily in sorted order. We rely on the following result: Theorem 1 ([GSSB15]) On input a sequence X " xx1, . . . , xny, where xi can be uniformly hashed to rnks in constant time, parallel semisorting can be implemented in Opnq expected work and space, and Oplog nq depth whp. A Random permutation of a finite set n-element set X can be generated in parallel using Opnq work and Oplog nq depth (e.g., [Rei85]). Later, we use the following bound: Theorem 2 (Theorem 1.1 of [DP09]) Let X " r0, 1s. For t ą 2e ErXs, we have PrrX ě ts ď 2´t. řn i"1 Xi, where Xis are independent random variables in We measure the space complexity of our algorithms in terms of the number of elements stored. Our space bounds do not represent bit complexity. Often, the space used by the algorithm is a random variable, so we present bounds on the expected space complexity. 3 Parallel Sampling from a Sliding Window This section discusses parallel algorithms for sampling without replacement from a sliding window (SWOR- Sliwin). The task is as follows: For target sample size s and maximum window size W, SWOR-Sliwin is 3 to maintain a data structure R that supports two operations: (i) insertpBiq incorporates a minibatch Bi of new elements that arrived at time i into R, and (ii) For parameters q ď s and w ď W, samplepq, wq when posed at time i returns a random sample of q elements chosen uniformly without replacement from the w most recent elements in Si. In our implementation, samplepq, wq does something stronger, and returns a q-permutation (not only a set) chosen uniformly at random from the w newest elements from R -- this can additionally be used to generate a sample of any size j from 1 till q by only consider the first j elements of the permutation. One popular approach to sampling from a sliding window in the sequential setting [BDM02, BOZ09] is the Priority Sampling algorithm: Assign a random priority to each stream element, and in response to sample(s, w) return the s elements with the smallest priorities among the latest w arrivals. To reduce the space consumption to be sub-linear in the window size, the idea is to store only those elements that can potentially be included in the set of s smallest priorities for any window size w. A stream element e can be discarded if there are s or more elements with a smaller priority than e that are more recent than e. Doing so systematically leads to an expected space bound of Ops ` s logpW{sqq [BDM02]2. As stated, this approach expends work linear in the stream length to examine/assign priorities, but ends up choosing only a small fraction of the elements examined. This motivates the question: How can one determine which elements to choose, ideally in parallel, without expending linear work to generate or look at random priorities? We are most interested in the case where W " ni ě s, where ni is the size of minibatch i. The main result of this section is as follows: Theorem 3 There is a data structure for SWOR-Sliwin that uses Ops ` s logpW{sqq expected space and supports the following operations: (i) insertpBq for a new minibatch B uses Ops ` s logp W (ii) sample(q, w) for sample size q ď s and window size w ď W uses Opqq work and Oplog Wq parallel s qq work and Oplog Wq parallel depth; and depth. Note that the work of the data structure for inserting a new minibatch is only logarithmic in the maximum window size W and independent of the size of the minibatch. To prove this theorem, we introduce R3 sampling, which brings together reversed reservoir sampling and rejection sampling. We begin by describing reversed reservoir sampling, a new perspective on priority sampling that offers more parallelism opportunities. After that, we show how to implement this sampling process efficiently in parallel via rejection sampling. ` ´i " min 3.1 Simple Reversed Reservoir Algorithm We now describe reversed reservoir (RR) sampling, which mimics the behaviors of priority sampling but provides more independence and more parallelism opportunities. This process will be refined and expanded in subsequent sections. After observing sequence X, Simple-RR(Algorithm 1) yields uniform sampling without replacement of up to s elements for any suffix of X. For maximum sample size s ą 0 and integer i ą 0, define ppsq We say the i-th most-recent element has age i; this position/element will be called age i when the context is clear. The algorithm examines X in reverse, Xr´1s, Xr´2s, . . ., and stores a subset in data structure A, which records the index of an element in X as well as a slot (from rss) into which the element is mapped. Multiple elements may be mapped to the same slot. The probability of Xr´is being chosen into A decreases as i increases. ´i " minp1, s{iq, the same probability it would in priority sampling (aka.bottom-k sampling). Also, every element sampled is assigned a random slot number between 1 and s. This is used to generate a random permutation. This algorithm samples an element at index ´i (age i) with probability ppsq 1, s i . 2The original algorithm stores the largest priorities but is equivalent to our view. 4 Algorithm 1: Simple-RRpX, sq -- Naïve reversed reservoir sampling Input: a stream segment X " xx1, . . . , xXy and a parameter s ą 0, s ď X. Output: a set tpki, (cid:96)iqu, where ki is an index into X and (cid:96)i P rss 1: π Ð Random permutation of rss, A0 " H 2: for i = 1, 2, . . . , s do Ai " Ai´1 Y tpi, πiqu 3: for i = s ` 1, 2, . . . ,X do ´iq == H then (cid:96) ÐUniformSamplep1, sq Ai " Ai´1 Y tpi, (cid:96)qu if coinpppsq 4: 5: 6: else Ai " Ai´1 7: 8: return AX Reserved reservoir sampling has a number of nice properties: Lemma 4 For input a stream segment X and a parameter 0 ă s ď X, the number of elements sampled by Simple-RR is expected s ` Ops logpX{sqq. Proof: The elements at indicies ´1,´2, . . . ,´s are always chosen, contributing s elements to the output. For i " s ` 1, . . . ,X, the probability that x´i is sampled is s{i, so the expected number of samples among these elements is Xÿ ż X x"s ď s s i which completes the proof. i"s`1 dx " s lnpX{sq, s x (cid:4) Let A denote the result of Simple-RR. Using this, sampling s elements without replacement from any suffix of X is pretty straightforward. Define χpAq " pνAp1q, νAp2q, . . . , νApsqq where νAp(cid:96)q " arg maxkě1tpk, (cid:96)q P Au is3 the oldest element assigned to slot (cid:96). Given A, we can derive Ai for any i ď X by considering the appropriate subset of A. We have that χpAiq is an s-permutation of the i most recent elements of X. Lemma 5 If R is any s-permutation of Xr´i:s, then PrrR " χpAiqs " pi ´ sq! (3.1) Proof: We proceed by induction on i. The base case of i " s is easy to verify since π is a random permutation of rss and χpAsq is a permutation of Xr´s :s according to π. For the inductive step, assume that equation (3.1) holds for for any R that is an s-permutation of Xr´i :s. Now let R1 be an s-permutation of Xr´pi ` 1q :s. Consider two cases: i! • Case I: x´pi`1q appears in R1, say at at R1 (cid:96). For R1 " χpAi`1q, it must be the case that x´pi`1q was chosen and was assigned to slot (cid:96). Furthermore, χpAiq must be identical to R1 except in position (cid:96), 3Because X ě s, the function ν is always defined. 5 where it could have been any of the i ´ ps ´ 1q choices. This happens with probability pi ´ rs ´ 1sq pi´sq! i! p´pi`1q 1 i ´ s ` 1 s " pi ´ sq! i! " pri ` 1s ´ sq! pi ` 1q! s s i ` 1 • Case II: x´pi`1q does not appear in R1. Therefore, R1 must be an s-permutation of Xr´i :s and x´pi`1q was not sampled. This happens with probability pi´sq! i! p1 ´ p´pi`1qq " pi´sq! i! i`1 " pri`1s´sq! i´s`1 pi`1q! In either case, this gives the desired probability. (cid:4) Note that the space taken by this algorithm (the size of AX) is Ops ` s logpX{sqq, which is opti- mal [GL08]. The steps are easily parallelizable but still need OpXq work, which can be much larger than the ps ` s logpX{sqq bound on the number of elements the algorithm must sample. We improve on this next. Improved Single-Element Sampler 3.2 This section addresses the special case of s " 1. Our key ingredient will be the ability to compute the next index that will be sampled, without touching elements that are not sampled. Let x´i be an element just sampled. We can now define a random variable Skippiq that indicates how many elements past x´i will be skipped over before selecting index ´pi ` Skippiqq according to the distribution given by Simple-RR. Conveniently, this random variable can be efficiently generated in Op1q time using the inverse transformation method [Ros09] because its cumulative distribution function (CDF) has a simple, efficiently-solvable form: PrrSkippiq ď ks " 1 ´ i`k . This leads to the following improved algorithm: śi`k t"i`1p1 ´ p´tq " 1 ´ i i`k " k Algorithm 2: Fast-Single-RRpXq -- Fast RR sampling for s " 1 Input: a stream segment X " xx1, . . . , xXy. Output: a set tpki, (cid:96)iqu, where ki is an index into X and (cid:96)i " 1 (cid:66) The same input/output behaviors as Simple-RR. 1: i Ð 1 2: while i ă X do A Ð A Y tpi, 1qu i Ð i ` Skippiq 3: 4: 5: return A This improvement significantly reduces the number of iterations: Lemma 6 Let TFSRpnq be the number of times the while-loop in the Fast-Single-RR algorithm is exe- cuted on input X with n " X. Then, ErTFSRpnqs " Op1 ` logpnqq. Also, for m ě n and c ě 4, PrrTFSRpnq ě 1 ` c logpmqs ď m´c. Proof: Let Zi be an indicator variable for whether x´i contributes to an iteration of the while-loop. Hence, TFSRpnq " 1 ` Z, where Z " n ď ln n. This proves the expectation bound. řX i"2 Zi. But PrrZi " 1s " 1{i, so ErZs " 1 3 ` ` 1 2 ` 1 6 Let t " c log2 m, so t ě 4 log2 m ą 2e lnp2q log2 m " 2e ln m ě 2e ln n ě 2e ErZs. Therefore, by Theorem 2, we have that PrrTFSRpnq ě 1 ` c log2pmqs ď PrrZ ě c log2 ms ď 2´t " m´c, which concludes the proof. (cid:4) Immediately, this means that if A " Fast-Single-RRpXq is kept as a simple sequence (e.g., an array), the running time -- as well as the length of A -- will be Op1 ` logpXqq in expectation. Moreover, A follows the same distribution as Simple-RR with s " 1, only more efficiently computed. Remark 3.1 Vitter [Vit85] studied a related problem that requires sampling from the same distribution as Simple-RR. He developed a sophisticated algorithm (Algorithm Z) for generating the skip offsets for s ě 1. Our Fast-Single-RR algorithm addresses the special case where s " 1, which is significantly simpler and does not require the same level of machinery as Vitter's Algorithm Z. Improved Multiple-Element Sampler 3.3 In the general case of reversed reservoir sampling, generating skip offsets from the distribution for s ą 1 turns out to be significantly more involved than for s " 1. While this is still possible, e.g., using a variant of Vitter's Algorithm Z [Vit85], prior algorithms appear inherently sequential. This section describes a new parallel algorithm that builds on Fast-Single-RR. In broad strokes, it first "oversamples" using a simpler distribution and subsequently, "downsamples" to correct the sampling probability. To enable parallelism, we logically divide the stream segment into s "tracks" of roughly the same size and have the single-element algorithm work on each track in parallel. Division of Work via Tracks. The aim of the first phase is to sample each element x´i with a slightly higher probability than ppsq ´i , in a way that results in about s ` s logpX{sq elements sampled at the end of the phase -- and the sampling could be carried out in parallel, with depth less than s. To this end, we logically divide the stream segment into s tracks of about the same size and in parallel, have the single-element algorithm work on each track. Track View. Define Create-ViewpX, kq to return a view corresponding to track k on X: if Y " Create-ViewpX, kq, pkq pkq then Y´i is Xr´α s piqs, where α s piq " i s ` k. That is, track k contains, in reverse order, indices ´ps ` kq,´p2s ` kq,´p3s ` kq, . . . . Importantly, these views never have to be materialized. Algorithm 3 combines the ideas developed so far. We now argue that Fast-RR yields the same distribution 1 as Simple-RR: Lemma 7 Let A be a return result of Fast-RRpX, sq. Then, for j " 1, . . . ,X and (cid:96) P rss, Prrp j, (cid:96)q P As " s ppsq ´ j. Proof: For j ď s, age j is paired with a slot (cid:96) drawn from a random permutation of rss, so Prrp j, (cid:96)q P As " s ppsq s " 1 1 ‚ . Now age j appears in A if both of these events happen: (1) age i was chosen into Tτ and (2) the coin turned up heads so it was retained in T1 ´ j. For j ą s, write j as j " s i ` τ, so age j appears as age i in view Xpτq τ. These two independent events happen together with probability s 1 " 1 pp1q ´i i s pτq s piq α " 1 i i s s i ` τ " s j " ppsq ´ j. 7 Algorithm 3: Fast-RRpX, sq -- Fast reversed reservoir sampling Input: a stream segment X " xx1, . . . , xXy and a parameter s ą 0, s ď X. Output: a set tpki, (cid:96)iqu, where ki is an index into X and (cid:96)i P rss 1: π Ð draw a random permutation of rss 2: T0 Ð tpi, πiq i " 1, 2, . . . , su 3: for τ " 1, 2, . . . , s in parallel do Xpτq ‚ Ð Create-ViewpX, τq Tτ Ð Fast-Single-RRpXpτq ‚ q pτq τ Ð tpi, (cid:96)q P Tτ coinpi s{α s piqq " Hu (cid:66) filter, keep if coin shows heads T1 τ Ð tpi, UniformSamplep1, sqq pi, _) P T1 T2 2 Y Y T2 8: return T0 Y T2 τu (cid:66) map 1 Y T2 4: 5: 6: 7: s Once age j is chosen, it goes to slot (cid:96) with probability 1{s. Hence, Prrp j, (cid:96)q P As " 1 s ppsq ´ j. (cid:4) Because the cost of an algorithm depends on the choice of data structures, we defer the cost analysis of Fast-RR to the next section, after we discuss how the reserved samples will be stored. 3.4 Storing and Retrieving Reserved Samples How should we store the sampled elements? An important design goal is for samples of any size q ď s to be generated without first generating s samples. To this end, observe that restricting χpAq to its first q ď s coordinates yields a q-permutation over the input. This motivates a data structure that stores the contents of different slots separately. Denote by RpAq, or simply R in clear context, the binned-sample data structure for storing reserved i"1, with Ri storing slot i's samples. Within samples A. The samples are organized by their slot numbers pRiqs each slot, samples are binned by their ages. In particular, each Ri contains rlog2prX{ssqs` 1 bins, numbered 0, 1, 2, . . . , rlog2prX{ssqs -- with bin k storing ages j in the range 2k´1 ă r j{ss ď 2k. Below, bin t of slot i will be denoted by Rirts. Additional information is kept in each bin for fast queries: every bin k stores φpkq, defined to be the age Below is an example. Use s " 3 and X " 16. Let the result from Fast-RR be A " tp1, 2q,p2, 3q,p3, 1q,p7, 1q,p10, 3q,p11, 3q,p14, 2qu. of the oldest element in bin k and all younger bins for the same slot number. Then, R keeps the following bins, together with φ values: Bin: Slot i " 1 Slot i " 2 Slot i " 3 Rir0s t3uφ"3 t1uφ"1 t2uφ"2 Rir1s Hφ"3 Hφ"1 Hφ"2 Rir2s t7uφ"7 Hφ"1 t10, 11uφ"11 Rir3s Hφ"7 t14uφ"14 Hφ"11 From this construction, the following claims can be made: Claim 8 The expected size of the bin Rirts is ErRirtss ď 1. Proof: Bin t of Ri is responsible for negative indices j in the range 2t´1 ă r´ j{ss ď 2t, for a total of sp2t ´ 2t´1q " s 2t´1 indices. Among these indices, the index that has the highest probability of being 8 sampled is ´ps2t´1 ` 1q, which is sampled into slot i with probability 1 s s 2t´1 " 1, ErRirtss ď s 2t´1 1 s2t´1`1 ď 1 s s2t´1 . Therefore, which concludes the proof. (cid:4) Claim 9 The size of slot Ri is expected Op1`logpX{sqq. Furthermore, for c ě 4, PrrRi ď 1 ` c log2pXqs ě 1 ´ X´c. Proof: Let Yt " 1tx´t is chosen into slot iu, so Ri " Xÿ t"1 ErRis " ErYts " 1 ` řX t"1 Yt. Since ErYts " ppsq Xÿ ż X ď 1 ` 1 t dt t t"s t"s`1 ´t{s " 1 ´ s minp1, s{tq, we have ¯ " 1 ` ln X s , which proves the expectation bound. Because Yt's are independent, using an argument similar to the proof of (cid:4) Lemma 6, we have the probability bound. Data Structuring Operations. Algorithm 4 shows algorithms for constructing a binned-sample data structure and answering queries. To Construct a binned-sample data structure, the algorithm first arranges the entries into groups by slot number, using a parallel semisorting algorithm, which reorders an input sequence of keys so that like sorting, equal keys are arranged contiguously, but unlike sorting, different keys are not necessarily in sorted order. Parallel semisorting of n elements can be achieved using Opnq expected work and space, and Oplog nq depth [GSSB15]. It then, in parallel, processes each slot, putting every entry into the right bin. Moreover, it computes a min-prefix, yielding φpq for all bins. There is not much computation within a slot, so we do it sequentially but the different slots are done in parallel. To answer a Sample query, the algorithm computes, for each slot i, the oldest age within Xr´w:s that was assigned to slot i. This can be found quickly by figuring out the bin k where w should be. Once this is known, it simply has to look at φ of bin k ´ 1 and go through the entries in bin k. This means a query touches at most two bins per slot. i 's as simple arrays, Fast-RRpX, sq runs in expected Ops ` s log X s q Cost Analysis. We now analyze Fast-RR, Construct, and Sample for their work and parallel depth. More concretely, the following claims are made: Claim 10 By storing T0, Ti's, and T1 work and OplogXq parallel depth. Proof: Generating a permutation of rss can be done in Opsq work and Oplog sq ď OplogXq depth. There are s tracks, each, in parallel, calling Fast-Single-RR, which is a sequential algorithm. Once Tτ is known, the re- maining steps are simple map and filter operations, which have OpTτq work and OpOpTτq ď OplogXq depth. Therefore, the dominant cost is Fast-Single-RR. By Lemma 6, each track performs Op1 ` lnpX{sqq work in expectation. Summing across s tracks, the total work is expected Ops ` s logpX{sqq. In terms of parallel depth, by Lemma 6, each track finishes after 1 ` 4 log2pXq iterations with probability at least 1 ´ X´4. Applying the union bound, we have that the expected depth overall is at most OplogXq provided that X ě s. (cid:4) 9 Algorithm 4: Construction of binned-sample data structure and query (cid:66) Below, use the convention that maxH " ´8 1: ConstructpA, n, sq: and s is the target sample size used to generate A. Input: A is a sequence of reserved samples, n is the length of the underlying stream segment X, Output: an instance of binned-sample structure RpAq Use semisorting to arrange A into G1, G2, . . . , Gs by slot number for i " 1, . . . , s in parallel do Create bins Rir0s, . . . ,Rirβs, β " rlog2prn{ssqs foreach p j, _q P Gi do Write j into Rirks, where 2k´1 ă r j{ss ď 2k Let φpRir0sq " maxRir0s (cid:66) prefix max for k " 1, . . . , β do φpRirksq Ð maxpφpRirk ´ 1sq, maxRirksq 2: 3: 4: 5: 6: 7: 8: 9: 12: 13: 14: 15: 16: 10: 11: SamplepR, q, wq: return R Input: R is a binned-sample structure, q is the number of samples desired, w tells the algorithm to draw sample from Xr´w :s. Output: a q-permutation of Xr´w :s for i " 1, . . . , q in parallel do Let k be such that 2k´1 ă rw{ss ď 2k γ Ð maxt j P Rirks j ď wu (cid:66) The oldest that is at least as young as w ri Ð maxpγ, φpRirk ´ 1sqq return pr1, r2, . . . , rqq sq work and Oplog nq parallel depth. Claim 11 ConstructpA, n, sq runs in Ops ` s log n Proof: Let ψ " s ` Ops logpn{sqq. The algorithm starts with a semisorting step, which takes OpAq work and OplogAq depth to arrange the entries of A into G1, . . . G2. Since A is expected ψ but never exceeds n. This step takes Opψq work and Oplog nq depth. For each i " 1, . . . , s, the size of Gi is expected 1 s ψ (Claim 9). Therefore, the work performed for each i is expected 1 s ψ, for a total of ψ across all s slots in expectation. Because by Claim 9, the size of a Gi exceeds 1 ` 4 log2pnq with probability at most 1{n4. The overall depth is at most Oplog nq whp. (cid:4) Lemma 12 SamplepR, q, tq runs in Opqq work and Oplog nq parallel depth, where n is the length of X on which R was built. Proof: The algorithm looks into q slots in parallel. For each slot Ri, it takes Ti " Op1 ` Rirksq sequential time, which is expected Op1q by Claim 8. Hence, the total work is expected Opsq. Then, it follows from Claim 9 that Ti exceeds 1 ` 4 log2pnq with probability at most 1{n4, so the overall depth is at most Oplog nq (cid:4) whp. 3.5 Handling Minibatch Arrival This section describes how to incorporate a minibatch into our data structure to maintain a sliding window of size W. Assume that the minibatch size is ni ď W. If not, we can only consider its W most recent elements. 10 When a minibatch arrives, retired sampled elements must be removed and the remaining sampled elements are "downsampled" to maintain the correct distribution. Remember that the number of selected elements is Ops ` s logpW{sqq in expectation, so we have enough budget in the work bound to make a pass over them to filter out retired elements. Instead of revisiting every element of the window, we apply the process below to the selected elements to maintain the correct s ppsq distribution. Notice that an element at age i was sampled into slot (cid:96) with probability 1 ´i . A new minibatch will cause this element to shift to age j, j ą i, in the window. At age j, an element is sampled into slot (cid:96) with ´i ď 1 and probability 1 retain this sample only if the coin comes up heads. Therefore, insertpBiq, Bi " ni handles a minibatch arrival as follows: Step i: Discard and downsample elements (above) in R; the index shifts by ni. Step ii: Apply Fast-RR on Bi, truncated to the last W elements if ni ą W. Step iii: Run Construct on the result of Fast-RR with a modification where the it appends to an existing R s ppsq ´ j. To correct for this, we flip a coin that turns up heads with probability ppsq ´ j{ppsq as opposed to creating a new structure. Overall, this leads to the following cost bound for insert: Lemma 13 insert takes Ops ` s logpW{sqq work and Oplog Wq depth. Proof: The cost of discarding and downsampling elements in the existing R is no more than the cost of running Construct with n " W because the cost of the former is upper-bounded by the cost of going through every element in R once. Hence, this step takes Ops` s logpW{sqq work and Oplog Wq depth. When Fast-RR is run, it is run with input length minpW, niq. Thus, it performs no more work than allowed by the lemma. Finally, Construct is called with n ď W, costing Ops` s logpW{sqq work and Oplog Wq depth, which is also (cid:4) the total cost of insert. 3.6 Total Cost of SWOR-Sliwin The cost of handling a minibatch's arrival is given by Lemma 13, and the cost of answering a query is given by Lemma 12. Altogether, this proves Theorem 3. Furthermore, across t minibatches, the total work is ¸ t ` tÿ i"1 O ps ` s lnpW{sqq . 4 Parallel Sampling from an Infinite Window This section addresses sampling without replacement from the infinite window, which includes all elements seen so far in the stream. This is formulated as the SWOR-Infwin task: For each time i " 1, . . . , t, maintain a random sample of size mints, Niu chosen uniformly without replacement from Si. While SWOR-Infwin can be reduced to the sliding-window setting, by setting the window size to the number of elements received so far, in this section, we show that there is an algorithm for infinite window that is simpler and more efficient. We further show it to be work optimal, up to constant factors. For p, q P rrs, let Hpp, q, rq be the hypergeometric random variable, which can take an integer value from 0 to mintp, qu. Suppose there are q balls of type 1 and pr´ qq balls of type 2 in an urn. Then, Hpp, q, rq is the number of balls of type 1 drawn in p trials, where in each trial, a ball is drawn at random from the urn without replacement. It is known that ErHpp, q, rqs " pq r . 11 Work Lower Bound. We first show a lower bound on the work of any algorithm for SWOR-Infwin, sequential or parallel, by considering the expected change in the sample output after a new minibatch is received. Lemma 14 Any algorithm that solves SWOR-Infwin must have expected work at least t ` tÿ i"1 " *¸ sni Ni Ω min ni, over t timesteps. Proof: First consider the number of elements that are sampled from each minibatch. If Ni ď s, then the entire minibatch is sampled, resulting in a work of Ωpniq. Otherwise, the number of elements sampled from the new minibatch Bi is Hps, ni, Niq. The expectation is ErHps, ni, Niqs " sni , which is a lower bound on the expected cost of processing the minibatch. Next, note that any algorithm must pay Ωp1q for examining minibatch Bi, since in our model the size of the minibatch is not known in advance. If an algorithm does not examine a minibatch, then the size of the minibatch may be as large as ΩpNiq, causing Ωp1q elements to be sampled from it. The algorithm needs to pay at least Ωptq over t minibatches. Hence, the total expected work (cid:4) of any algorithm for SWOR-Infwin after t steps must be Ω řt i"1 mintni, sni Ni u ´ t ` ¯ Ni . Sequential Algorithm for SWOR-Infwin. We present a simple sequential algorithm for SWOR-Infwin, whose work matches the lower bound from Lemma 14. It uses a subroutine for sampling without replacement from a static array. Observation 15 ([AD85, Vit87]) There is an algorithm for choosing a random sample of size s without replacement from a (static) array of size r using Opsq work. The idea in a solution to SWOR-Infwin, described in Algorithm 5, is as follows. When a minibatch Bi arrives, a random variable κ is generated according to the hypergeometric distribution to determine how many of the s samples need to be chosen from Bi, rather than minibatches that arrived before Bi. The algorithm then chooses a random sample of size κ without replacement from Bi, and updates the sample S accordingly. Algorithm 5: Work-Optimal Sequential Algorithm for SWOR-Infwin. 1: Initialization: Sample S Ð H j"1 ni (cid:66) ni " Bi and Ni " ři 2: if minibatch Bi is received then 3: if Ni ď s then 4: 5: 6: 7: 8: else S Ð S Y Bi (cid:66) Store the entire minibatch Let κ be a random number drawn from Hps, ni, Niq Let S i be a set of κ elements sampled without replacement from Bi Replace κ randomly chosen elements in S with S i. Lemma 16 Algorithm 5 is a sequential solution to SWOR-Infwin with work O process t minibatches B1, . . . , Bt. This work is optimal given the lower bound from Lemma 14. 12 ´ t ` řt i"1 mintni, sni Ni u ¯ to Proof: If Ni ď s, then the arriving minibatch Bi is added to the sample in its entirety, for a total work of Θpniq. If Ni ą s, then the algorithm has to pay for (1) generating a random variable according to the hypergeometric distribution, which can be done in Op1q time by an algorithm such as described in [Sta90], (2) selecting a sample of size κ ď ni from Bi, which can be done in Opκq time, from Observation 15, and (3) replacing κ randomly chosen elements from S -- this can be done in Opκq time by choosing κ random elements without replacement from S using Observation 15, and overwriting these locations with the new samples. The overall time for processing this batch is Op1 ` κq " Op1 ` Hps, ni, Niqq. The expected time for processing the řt minibatch is OpEr1 ` Hps, ni, Niqsq " Op1` sni Ni q. Overall, the cost of processing Bi is Op1` mintni, sni Ni uq, i"1 mintni, sni Ni u (cid:4) and the total work of the algorithm is O t ` ´ ¯ . Parallel Algorithm for SWOR-Infwin. Our solution is presented in Algorithm 6. The main idea is as follows: When a minibatch Bi arrives, generate a random variable κ according to the hypergeometric distribution to determine how many of the s samples will be chosen from Bi, as opposed to prior minibatches. Then, choose a random sample of size κ without replacement from Bi and update the sample S accordingly. We leverage Sanders et al. [SLHS`18]'s recent algorithm for parallel sampling without replacement (from static data), restated below in the work-depth model: Observation 17 ([SLHS`18]) There is a parallel algorithm to draw s elements at random without replace- ment from N elements using Opsq work and Oplog sq depth. Our algorithm uses static parallel sampling without replacement in two places: once to sample new elements from the new minibatch, and then again to update the current sample. In more detail, when a minibatch arrives, the algorithm (i) chooses κ, the number of elements to be sampled from Bi, in Op1q time; (ii) samples κ elements without replacement from Bi in parallel; and (iii) replaces κ randomly chosen elements in S with the new samples using a two-step process, by first choosing the locations in S to be replaced, followed by writing the new samples to the chosen locations. Details appear in Algorithm 6. Algorithm 6: Parallel Algorithm for SWOR-Infwin. 1: Initialization: Sample S Ð H 2: if minibatch Bi is received then (cid:66) Recall ni " Bi and Ni " if Ni ď s then Copy Bi into S in parallel else ři j"1 ni 3: 4: 5: 6: 7: 8: Let κ be a random number generated by Hps, ni, Niq S i Ð κ elements sampled without replacement from Bi (Obs. 17) Ri Ð κ elements sampled without replacement from t1, . . . , su (Obs. 17) for j " 1 to κ do Replace SrRir jss Ð S ir js ¯ ´ t ` řt i"1 mintni, sni Ni u Theorem 18 Algorithm 6 is a work-efficient algorithm for SWOR-Infwin. The total work to process t minibatches B1, . . . , Bt is O and the parallel depth of the algorithm for processing a single minibatch is Oplog sq. This work is optimal up to constant factors, given the lower bound from Lemma 14. 13 Proof: When a new minibatch Bi arrives, for the case case Ni ď s, copying ni elements from Bi to S can be done in parallel in Opniq work and Op1q depth, by organizing array S so that the empty locations in the array are all contiguous, so that the destination for writing an element can be computed in Op1q time. For the case Ni ą s, random variable κ can be generated in Op1q work. The next two steps of sampling κ elements from Bi and from t1, . . . , nu can each be done using Opκq work and Oplog κq depth, using Obser- vation 17. The final for loop of copying data can be performed in Opκq work and Op1q depth. Hence, the expected total work for processing Bi is 1 ` mintni, sni Ni u, and the depth is Oplog κq. Added up over all the t minibatches, we get our result. Since κ ď s, the parallel depth is Oplog sq. (cid:4) 4.1 Fixed Length Sliding Window In the fixed length sliding window model with window size w, the sample is desired from the w most recent elements, where the window size w " s is known in advance. While it is more restrictive than the variable length sliding model, this model is relevant when the aggregation function and their parameters are known in advance, as is often the case in a streaming system with long-lived continuous queries. Algorithms for this model are simpler than those for variable length sliding window. Task SWOR-Fixed-Win: For each time i " 1 . . . t, after observing minibatch Bi, maintain a random sample of size mints, Niu chosen uniformly without replacement from the w most recent elements in the stream. We ( ` first present a lower bound on the work of any algorithm for SWOR-Fixed-Win. Lemma 19 For any algorithm for SWOR-Fixed-Win, the expected work to process minibatch i is at least 1 ` min Ω . The expected work to process t minibatches is at least Ω řt ( t ` s (cid:32) (cid:32) ` s, sni w i"1 min 1, ni w . Proof: After minibatch Bi is received, the random sample must contain s elements randomly chosen from the w most recent elements in Si. In expectation, the number of elements that will be chosen from Bi is (1) If ni ě w, then s, since the entire window is contained within mini-batch Bi, and (2) If ni ă w, then s ni w , since s elements are chosen out of a total of w elements. Since the batch size ni is not known in advance, the work to process the new batch is at least Ωp1q, since the batch has to be examined. If the batch were not examined, it is possible that ni ě w, and the sample will no longer be correct. The work to process Bi is at least Ωp1 ` min (cid:4) q, and the result for t batches follows. s, sni (cid:32) ( w Algorithm for SWOR-Fixed-Win: We first consider a sequential algorithm for SWOR-Fixed-Win, which follows by combining our algorithm for SWOR-Infwin with a reduction (due to Braverman et al. [BOZ09]) from the problem of sampling from a fixed-size sliding window to the problem of sampling from an infinite window. This reduction is based on partitioning the stream into "buckets", each with a fixed starting and ending point. Each bucket has a width of w elements, where w is the size of the sliding window. For i " 1, 2, . . ., the ith bucket consists of the stream elements at positions ppi ´ 1q w ` 1q till i w. Note that buckets are distinct from minibatches, which could be of arbitrary sizes. A bucket is also different from a query window, whose boundary need not coincide with a bucket boundary. The algorithm maintains a sample without replacement of size s within each bucket i, using the infinite window algorithm. Each per-bucket sample is completed when the bucket ends, and a new sample is started for the next bucket. A bucket that overlaps with the current sliding window is called "active". Only active buckets are retained and the rest are discarded. Clearly, there are no more than two active buckets at any time. We call the older of the active buckets as the "old" bucket (oldbkt) and the more recent active bucket as the "new" bucket (newbkt). It is possible that there is no old bucket, if the current window is exactly aligned with the new bucket. We have a sample of size s from oldbkt, 14 called oldsmp, and a sample of size s from newbkt, called newsmp. Except for corner cases when the new bucket has seen less than s elements, we have that the sizes of both oldsmp and newsmp equal s. When a sample is desired from the sliding window, there are two cases. (1) If the window overlaps only with newbkt, then return newsmp. (2) If the window overlaps partially with oldbkt and partially with newbkt, then the algorithm selects as many elements from oldbktthat are not expired yet -- say this is of size s1 ď s. It then selects the remaining ps ´ s1q elements by (uniformly) subsampling from newsmp. It is shown in [BOZ09] that this constitutes a random sample chosen without replacement from a sliding window of size w. Parallel Algorithm for SWOR-Fixed-Win. We now show how to implement this reduction in a parallel algorithm. We note that the focus of [BOZ09] was on the space complexity, while we are interested in the time complexity and work of the sampling algorithm. For maintaining the sample without replacement of size s within each bucket, we use one instance of the parallel algorithm for SWOR-Infwin (Algorithm 6) for each bucket. When queried, the algorithm uses Opsq work to combine the two sampled. Lemma 20 There is a parallel algorithm for SWOR-Fixed-Win whose total work for processing t mini- batches is O ¯ . Its parallel depth for processing a single minibatch is Oplog sq. ´ 1 ` Nt ´ t ` s ¯ log w s w Proof: For the above algorithm, consider the total work involved in processing a single bucket of w elements. If the entire bucket was contained within a minibatch, the total work to process it is Θpsq (or possibly even smaller), since no more than s elements are chosen from this bucket (Observation 17). Suppose that the bucket was split across two or more minibatches. The total work to maintain a sample for this bucket depends on the sizes of the minibatches that constitute this bucket -- the larger the minibatches, the closer the work is to Opsq. But in the worst case, each minibatch could be of size 1, and in this case the total work is the number of times the sample changes over observing s elements -- this is s ` i " Ops ` s logpw{sqq. Over t minibatches, the number of different buckets is Nt{w, which leads to a total work of OpsNtplogpw{sqq{wq. We also note that Op1q time is required for each minibatch. Further, in the case Nt ă w, when a single bucket has not completed yet, we still need Ops log wq work. The parallel depth follows because for each minibatch that arrives, it is needed to determine which of Cases (1)-(3) apply here, which can be done in Op1q steps, followed by updating oldbkt and newbkt. The depth of the update process for these follows (cid:4) from Observation 17 and Theorem 18. řw i"ps`1q s 5 Parallel Sampling with Replacement We now consider SWR-Infwin, sampling with replacement. Intuitively, parallelizing sampling with re- placement is easier than without replacement because random samples can be independently drawn without checking for distinctness. Observation 21 There is an Opsq-work Op1q-depth parallel algorithm for computing a sample of size s with replacement from an input array of size n. The above is easy to see: Each sample element can be independently chosen by selecting a random integer in the interval r1, ns and choosing the corresponding element from the input. We will use the binomial random variable. For integer α ą 0 and 0 ă β ď 1, let Bpα, βq be the the number of successes in α trials, where each trial has probability β of success. SWR-Infwin: Sampling with replacement, infinite window. A simple algorithm is to run s independent parallel copies of a single element stream sampling algorithm, which is clearly correct. When minibatch 15 be replaced. sampling algorithm (Observation 17). Bi is received, each single element sampling algorithm decides whether or not to replace its sample, with probability ni{Ni, which can be done in Op1q time. The algorithm has Opsq work per minibatch, and parallel depth Op1q. However, we can do better than this as follows. Suppose the current samples after observing i minibatches are stored in an array Sr1, 2, . . . , ss. For each sample, the probability of it being replaced after the minibatch arrives is pi " ni{Ni. Instead of testing each sample separately to see if needs to be replaced, the algorithm carries out the following steps: (A) Generate a random number s1 ď s according to Bps, piq to determine how many of the samples need to (B) Sample L, a set of s1 ď s elements without replacement from the set t1, 2, . . . , su, using a parallel (C) For each location (cid:96) P L, sample Sr(cid:96)s is overwritten with a randomly chosen element from Bi. Steps (A) and (B) in the above procedure can be shown to generate the same distribution of locations as iterating through each location in S , and separately determining whether the sample needs to be replaced. Step (A) can be performed in Op1q work, while Step (B) can be performed in Ops1q work with Oplog s1q " Oplog sq parallel depth. Since Ers1s " spi " sni{Ni, the expected work of this step is Opsni{Niq. Step (C) can be performed in Ops1q work and Op1q depth. Below are the overall properties of the algorithm: řt Theorem 22 There is a parallel algorithm for SWR-Infwin such that for a target sample size s, the total work to process minibatches B1, . . . , Bt is Opt` i"1 sni{Niq, and the depth for processing any one minibatch Bi is Oplog sq. This work is optimal, up to constant factors. This work bound is optimal -- the expected number of elements in the sample that change due to a new minibatch is psni{Niq. The theorem means the minibatches, at least the initial few, should be large. To see why: if they are of size 1, the first element would require Θpsq work, because every sample needs to be updated! Similarly, the first s{2 elements each requires Opsq work, totaling Ops2q work for the initial Θpsq elements. With minibatches sized Ωpsq, the total work decreases significantly. Importantly, this is not an artifact of our algorithm -- any algorithm for SWR-Infwin needs this cost when minibatches are small. 6 Conclusion We presented low-depth, work-efficient parallel algorithms for the fundamental data streaming problem of streaming sampling. Both the sliding-window and infinite-window cases were addressed. Interesting directions for future work include the parallelization of other types of streaming sampling problems, such as weighted sampling and stratified sampling. References [AD85] J. H. Ahrens and U. Dieter. Sequential random sampling. ACM Trans. Math. Softw., 11(2):157 -- 169, June 1985. [BDM02] Brian Babcock, Mayur Datar, and Rajeev Motwani. Sampling from a moving window over [BH06] [BM04] streaming data. In SODA, pages 633 -- 634, 2002. Paul G. Brown and Peter J. Haas. Techniques for warehousing of sample data. In ICDE, page 6, 2006. Guy E. Blelloch and Bruce M. Maggs. Chapter 10: Parallel algorithms. In The Computer Science and Engineering Handbook. Chapman and Hall/CRC, 2nd edition, 2004. 16 [BOZ09] V. Braverman, R. Ostrovsky, and C. Zaniolo. Optimal sampling from sliding windows. In PODS, pages 147 -- 156, 2009. [CMYZ12] Graham Cormode, S. Muthukrishnan, Ke Yi, and Qin Zhang. Continuous sampling from [Cor13] distributed streams. Journal of the ACM, 59(2):10:1 -- 10:25, 2012. Graham Cormode. The continuous distributed monitoring model. SIGMOD Record, 42(1):5 -- 14, 2013. [CTW16] Y. Chung, S. Tirthapura, and D. P. Woodruff. A simple message-optimal algorithm for random sampling from a distributed stream. TKDE, 28(6):1356 -- 1368, 2016. [DP09] [DAAE09] Sudipto Das, Shyam Antony, Divyakant Agrawal, and Amr El Abbadi. Thread cooperation in multicore architectures for frequency counting over multiple data streams. PVLDB, 2(1):217 -- 228, 2009. Devdatt Dubhashi and Alessandro Panconesi. Concentration of Measure for the Analysis of Randomized Algorithms. Cambridge University Press, 2009. Pavlos S. Efraimidis and Paul G. Spirakis. Weighted random sampling with a reservoir. Infor- mation Processing Letters, 97(5):181 -- 185, 2006. Rainer Gemulla and Wolfgang Lehner. Sampling time-based sliding windows in bounded space. In SIGMOD, pages 379 -- 392, 2008. [GL08] [ES06] [GSSB15] Yan Gu, Julian Shun, Yihan Sun, and Guy E. Blelloch. A top-down parallel semisort. In SPAA, [GT01] [JS15] pages 24 -- 34, 2015. P. Gibbons and S. Tirthapura. Estimating simple functions on the union of data streams. In SPAA, pages 281 -- 291, 2001. Theodore Johnson and Vladislav Shkapenyuk. Data stream warehousing in tidalrace. In CIDR, 2015. John H. Reif. An optimal parallel algorithm for integer sorting. In FOCS, pages 496 -- 504, 1985. Sheldon M. Ross. Introduction to Probability Models. Academic Press, 10th edition, 2009. [Rei85] [Ros09] [SLHS`18] Peter Sanders, Sebastian Lamm, Lorenz Hübschle-Schneider, Emanuel Schrade, and Carsten Dachsbacher. Efficient parallel random sampling - vectorized, cache-efficient, and online. ACM Trans. Math. Softw., 44(3):29:1 -- 29:14, 2018. E. Stadlober. The ratio of uniforms approach for generating discrete random variates. J. Comput. Appl. Math., 31(1):181 -- 189, 1990. Kanat Tangwongsan, A. Pavan, and Srikanta Tirthapura. Parallel triangle counting in massive streaming graphs. In CIKM, pages 781 -- 786, 2013. [TPT13] [Sta90] [TTW14] Kanat Tangwongsan, Srikanta Tirthapura, and Kun-Lung Wu. Parallel streaming frequency- [Vit85] [Vit87] [XTB08] based aggregates. In SPAA, pages 236 -- 245, 2014. J. S. Vitter. Random sampling with a reservoir. ACM Transactions on Mathematical Software, 11(1):37 -- 57, 1985. J. S. Vitter. An efficient algorithm for sequential random sampling. ACM Trans. Math. Softw., 13(1):58 -- 67, 1987. B. Xu, S. Tirthapura, and C. Busch. Sketching asynchronous data streams over sliding windows. Distributed Computing, 20(5):359 -- 374, 2008. [ZDL`13] M. Zaharia, T. Das, H. Li, T. Hunter, S. Shenker, and I. Stoica. Discretized streams: Fault- tolerant streaming computation at scale. In SOSP, pages 423 -- 438, 2013. 17
1807.08331
1
1807
2018-07-22T18:07:00
Independent Sets in Vertex-Arrival Streams
[ "cs.DS" ]
We consider the classic maximal and maximum independent set problems in three models of graph streams: In the edge-arrival model we see a stream of edges which collectively define a graph, this model has been well-studied for a variety of problems. We first show that the space complexity for a one-pass streaming algorithm to find a maximal independent set is quadratic (i.e. we must store all edges). We further show that the problem does not become much easier if we only require approximate maximality. In the "explicit" vertex stream model, the input stream is a sequence of vertices making up the graph, where every vertex arrives along with its incident edges that connect to previously arrived vertices. Various graph problems require substantially less space to solve in this setting than for edge-arrival streams. We show that every one-pass $c$-approximation algorithm for maximum independent set (MIS) on explicit vertex streams requires space $\Omega(\frac{n^2}{c^7})$, where $n$ is the number of vertices of the input graph, and it is already known that space $\tilde{\Theta}(\frac{n^2}{c^2})$ is necessary and sufficient in the edge arrival model (Halld\'orsson et al. 2012). The MIS problem is thus not significantly easier to solve under the explicit vertex arrival order assumption. Our result is proved via a reduction to a new multi-party communication problem closely related to pointer jumping. In the "implicit" vertex stream model, the input stream consists of a sequence of objects, one per vertex. The algorithm is equipped with a function that can map a pair of objects to the presence or absence of an edge, thus defining the graph. This model captures, for example, geometric intersection graphs such as unit disc graphs. Our final set of results consists of several improved upper and lower bounds for ball intersection graphs, in both explicit and implicit streams.
cs.DS
cs
Independent Sets in Vertex-Arrival Streams Graham Cormode1, Jacques Dark1, and Christian Konrad2 1Department of Computer Science, University of Warwick, Coventry, UK, {g.cormode,j.dark}@warwick.ac.uk 2Department of Computer Science, University of Bristol, Bristol, UK, [email protected] We consider the classic maximal and maximum independent set problems in three models of graph streams: In the edge-arrival model we see a stream of edges which collectively define a graph; this model has been well-studied for a variety of problems. We first show that the space complexity for a one-pass streaming algorithm to find a maximal independent set is quadratic (i.e. we must store all edges). We further show that the problem does not become much easier if we only require approximate maximality. This contrasts strongly with the other two vertex-based models, where one can greedily find an exact solution using only the space needed to store the independent set. In the "explicit" vertex stream model, the input stream is a sequence of vertices making up the graph, where every vertex arrives along with its incident edges that connect to previously arrived vertices. Various graph problems require substantially less space to solve in this setting than for edge-arrival streams. We show that every one-pass c-approximation streaming algorithm for maximum independent set (MIS) on explicit vertex streams requires space Ω( n2 c7 ), where n is the number of vertices of the input graph, and it is already known that space Θ( n2 c2 ) is necessary and sufficient in the edge arrival model (Halld´orsson et al. 2012). The MIS problem is thus not significantly easier to solve under the explicit vertex arrival order assumption. Our result is proved via a reduction to a new multi-party communication problem closely related to pointer jumping. In the "implicit" vertex stream model, the input stream consists of a sequence of objects, one per vertex. The algorithm is equipped with a function that can map a pair of objects to the presence or absence of an edge, thus defining the graph. This model captures, for example, geometric intersection graphs such as unit disc graphs. Our final set of results consists of several improved upper and lower bounds for ball intersection graphs, in both explicit and implicit streams. 1 Introduction The streaming model supposes that, rather than being loaded into memory all at once, the input is received piece-by-piece over a period of time. Only a sublinear amount of memory (in the input size) is made available, preventing any algorithm from "seeing" even a constant fraction of the whole input at once. In graph streams (see [19] for an excellent survey), we distinguish between the "edge-arrival" model, where the stream consists of individual edges arriving in any order, and the "vertex-arrival" model, where the stream consists of batches of edges incident to a particular vertex -- as each vertex "arrives" we are given all the edges from the new vertex to previously arrived vertices. We will shorten the names to edge streams and vertex streams, respectively. Problems on edge streams are always at least as hard as on vertex streams (as any vertex stream is also a valid edge stream). There is a further variant which we will call "implicit" vertex streams (as opposed to the normal explicit representation). In this model, the stream consists of a series of small (polylog(n)-sized) identifiers, one per vertex. We are additionally provided with some function or oracle which maps a pair of identifiers to a Boolean output indicating whether the two vertices are connected or not. This implicitly defines a graph over the list of identifiers received. Geometric intersection graphs, received as a stream of geometric objects, are the most natural member of this class. For example, a unit interval intersection graph might be received as a series of points in R. Then a pair of vertices x, y are adjacent if and only if x − y ≤ 1. Explicit and implicit vertex streams are closely related but distinct, with neither being strictly "harder" than the other. For example: it is easy to count exactly the number of edges in O(1) space (of words) for an explicit vertex stream, however, doing so for an implicit stream requires linear space, otherwise we cannot hope to know how many edges are incident to the final vertex. On the other hand: implicit vertex streams can be stored entirely in O(n) space1, whereas explicit vertex streams require Ω(n2) space to store the full structure. Maximum independent set is an important problem on graphs. The task is to find a largest subset of ver- tices which have no edges between them. Unfortunately, the offline problem is NP-hard to find a maximum set in a general graph [16], and even hard to approximate within a factor of n1−ǫ, for any ǫ > 0 [20]. It is also known to be hard (requiring Θ( n2 c2 ) space to c-approximate on an n-vertex graph) in the edge streaming model, despite being allowed unlimited computation [14]. However, we can do much better for graphs of bounded independence, given as vertex streams [8]. In this paper, we study the hardness of approximate maximum independent set in the explicit and implicit vertex streaming model. First, we motivate the study of vertex streams by showing a large space complexity gap between the edge and (both) vertex models for the related problem of finding a maximal independent set. The gap remains non-trivial even when we only ask for a set which is "nearly" maximal. Then, we propose a new communication problem (closely related to index and pointer jumping) and use it to show that MIS for general graphs cannot be much easier in the explicit vertex streaming model than in the edge streaming model. Last, we show various improved upper and lower bounds for certain geometric intersection graphs in both vertex streaming models. 1.1 Our Contributions For a graph G, let α(G) denote the size of a maximum independent set. Further, let χ(G) denote the chromatic number, i.e., the number of colors needed in any (legal) coloring of the input graph. We arrange our contributions according to the three models of streaming graphs that we consider (defined more formally below): • Edge streams. We show that solving maximal independent set in an edge stream requires Ω(n2) 1We use O, Θ, and Ω to mean O, Θ, and Ω (respectively) with log factors suppressed. 1 Space Bound Unit Interval Approx. MIS O(α(G)) Approx. α(G) poly(log n) Ω(n) 2 (Greedy alg.) O(cid:16) log2 n log log n(cid:17) [8] < 5/3 Figure 1: Approximation factors for Explicit Vertex Streams. Space Bound Unit Interval Interval Unit Square Approx. MIS Approx. α(G) O(α(G)) 3/2 [10] 2 [10] 3 poly(log n, ǫ−1) Ω(n) 3/2 + ǫ [6] 2 + ǫ [6] 3 + ǫ < 3/2 [10] < 2 [10] < 5/2 Figure 2: Approximation factors for Implicit Vertex Streams. The first column concerns algorithms that output independent sets themselves, while the second columns concerns algorithms that output estimations of the maximum independent set size. Our results are highlighted in gray. space, significantly more than the O(α(G)) sufficient to solve it on an explicit or implicit vertex stream. We further show that even finding any independent set which covers all but an n−ǫ fraction of the vertices for ǫ > 0 (a nearly maximal independent set) in an edge stream requires n2−o(1) space, while covering just a constant fraction of the vertices requires n1+Ω( space. The techniques rely on reductions from problems in communication complexity -- initially, a relatively simple reduc- tion from INDEX to show the hardness of MIS, but a more involved reduction to a graph-based variant of INDEX based on Ruzsa-Szemer´edi graphs for the approximate relaxation. log log n ) 1 • Explicit vertex streams. For general explicit vertex streams, we show that c-approximating α(G) requires Ω( n2 c7 ) space. We further observe that the construction leads to the same space bound for approximating χ(G), the chromatic number. We rely on the communication complexity of a novel multiparty generalization of the well-known INDEX problem, which is closely related to pointer- jumping problems but allows us to more directly show hardness. The hardness of the MIS problem itself then relies on a careful construction based on erasure codes to bound the size of cliques in our hard instance graphs. • Implicit vertex streams. Next, we show several results for geometric intersection graphs. We can 3-approximate MIS for a stream of unit squares in the plane using O(α(G)) space, and achieving better than a 5 2 -approximation to α(G) requires Ω(n) space. Unit interval intersection graphs given as an explicit vertex stream require Ω(n) space to get a better than 5 3 approximation to α(G), making it harder than the implicit stream equivalent. Figures 2 and 1 illustrate these results and put them in context to previously known bounds (see also Section 1.3). The two-dimensional upper bounds can be viewed as a generalization of the one-dimensional bounds, with more work to cover the increased number of cases that occur in 2D. However, the lower bounds involve an intricate packing argument, to show that the MIS size can be used to recover encoded information, which is used in conjunction with our multiparty INDEX variant problem to demonstrate approximation hardness. 2 1.2 Problem Definitions Our problems are defined with respect to a graph G = (V, E) with n vertices (V = n). Definition 1 (Independent Sets). An independent set of G is a subset of the vertices U ⊆ V that contains no edges ((U × U ) ∩ E = ∅). We use α(G) to refer to the maximum size of any independent set of G. An MIS (maximum independent set) of G is any independent set of size α(G). A maximal independent set is an independent set that no other independent sets contain as a proper subset. We are also interested in allowing approximations: Definition 2 (Approximate MIS). A c-approximate MIS of G is an independent set of size at least α(G) algorithm is said to return a c-approximation to α(G) if it returns a value γ satisfying 1 . An c α(G) ≤ γ ≤ α(G). The one-sided nature of the c-approximation requirement for α(G) follows by analogy with the problem of finding a c-approximate MIS, where of course no overestimate is possible. A two-sided approximation can of course be made one-sided by rescaling by √c. c Definition 3 (Graph Streams). We define the three different input arrival models as follows: • An edge stream consists of a sequence of m edges S = he1, e2,··· , emi over a pre-determined vertex set V , arriving one-by-one in arbitrary order. Then the edge set is given by E = {ei : i ∈ [m]}. • An explicit vertex stream is a sequence of n vertices S = hv1, v2,··· , vni arriving one-by-one in arbitrary order. Each vertex vi arrives with a list of all the edges between vi and previous vertices (vj with j < i). Thus, each edge {vi, vj} is presented exactly once in the stream, with the arrival of vertex vmax{i,j}. • An implicit vertex stream consists of a sequence of n identifiers S = hI1, I2,··· , Ini. Each identifier represents a vertex of the graph and is taken from some universe [U ] with U ∈ O(2polylog(n)). Thus, the identifiers have a succinct representation of polylog(n) bits. We are equipped with oracle access to a symmetric function σ : U × U → {0, 1} which determines the presence or absence of an edge between a particular pair of vertices based on their identifiers. So the edge set of the streamed graph is Eσ = {{i, j} : σ(Ii, Ij) = 1}. Implicit vertex streams can be understood as being defined over a large pre-defined graph on O(2polylog(n)) vertices, so that the stream describes the induced sub-graph arising by selecting n of these vertices. We also mention several special classes of graphs which have natural implicit representations or are easier to approximate MIS on. Definition 4 (Bounded Independence Graphs). • A graph G has f -bounded independence for some bounding function f : N → N if every r- neighborhood (the set of vertices within distance r) of every vertex of G contains no independent set larger than f (r). • A family of graphs F has polynomially bounded independence if there is a polynomial P such that every graph G ∈ F has P -bounded independence. Bounded-independence graphs admit greedy approximation algorithms. Consider the greedy algorithm that maintains an independent set by arbitrarily ordering the vertices, and adding each subsequent vertex so long as the set stays independent. For an f -bounded independence graph this greedy procedure will give an f (1)-approximation to MIS. This algorithm can be implemented in any vertex stream (implicit or explicit) by following the vertex arrival order and using O(α(G)) space. 3 Definition 5 (Intersection Graphs). The geometric intersection graph G = (V, E) of objects drawn from some geometric space {X1, X2,··· , Xn} has one vertex associated with each object, and an edge between a pair of vertices if and only if the corresponding pair of objects intersect: V = [n], E = {{i, j} : Xi∩Xj 6= ∅}. For example, an lp d-ball graph is the geometric intersection graph of n closed lp balls in d dimensions, each of the form Bp(x, r) = {y ∈ Rd : kx − ykp ≤ r} ⊂ Rd. Of particular interest is the unit lp d-ball graph, where all the balls have radius 1. By specifying p and d, we can define intersection graphs on disks, spheres, squares, rectangles, hyper-cubes, and generalize to any combination of these and other geometric objects. Many of these classes have polynomially bounded independence (as long as the ratio between the sizes of the smallest ball which can cover any of the objects and the largest ball which can fit inside any object is constant). These geometric intersection graphs also form natural implicit vertex streams, assuming that the geometry is discretised to allow polylog(n) sized representation of the shapes. 1.3 Prior Work space is required to obtain a c-approximation to the maximum independent set size (or maximum clique size) Edge Streams Halld´orsson et al. [14] showed that for general graphs in the edge-arrival model Ω(cid:16) n2 c2 log2 n(cid:17) if c = Ω(log n), and Ω(cid:16) n2 c2(cid:17) space random sam- c4(cid:17) is required if c = o(log n) [14]. A corresponding O(cid:16) n2 pling algorithm shows this is tight up to logarithmic factors. Braverman et al. [5] showed that space Ω( m c2 ) is needed, even if c = o(log n), where m is the number of edges of the input graph. This bound though only holds for small values of m. Explicit Vertex Streams The work of Halld´orsson et al. [12] gives an O(n log n) space streaming deg(v)+1 . On general graphs, this only gives a Θ(n)-approximation, but for polynomially bounded independence graphs, this gives a polylog(n)-approximation [13]. algorithm which can find an independent set of expected size at least β(G) = Pv∈V In our prior work, it was shown how to return an estimate γ ∈ Ω(cid:16) β(G) explicit vertex arrival stream using only O(log3 n) space [8]. This result for example gives a O( log2 n log log n )- approximation on unit interval graphs (see Figure 1). However, the technique samples vertices based on their degree and so does not extend to implicit vertex streams. log n(cid:17) with γ ≤ α(G) from an 1 Braverman et al. [5] showed that in a vertex arrival model, where every vertex arrives together with all its incident edges (as opposed to the explicit vertex stream model considered here where every vertex arrives together with its incident edges connecting to vertices that have previously arrived), space Ω( m c3 ) is required for computing a c-approximate MIS. In their construction the input graph has Θ(nc) edges, which thus yields a lower bound of Ω( n c7 ), which is a quadratic improvement for constant c. c2 ). Observe that our lower bound for explicit vertex streams is Ω( n2 Implicit Vertex Streams In [10], it was shown that it is possible to 3 2 -approximate MIS for the intersec- tion graph of a unit interval stream using O(α(G)) space. In the same space, a 2-approximation is possible for arbitrary interval streams. Both these results are shown to be tight: any ( 3 2 − ǫ)-approximation for unit intervals -- or (2 − ǫ) for general intervals -- requires Ω(n) space. By clever use of sampling, the result can be adapted to provide an approximation of α(G) of 3 2 + ǫ for unit intervals and 2 + ǫ for general intervals with space only polylog(n, ǫ−1) [6]. 4 2 Bounds for Maximal Independent Set In this section, we consider streaming algorithms for the maximal independent set problem. Vertex-arrival streams (both explicit and implicit) are well-suited to the maximal independent set problem, since they allow the implementation of the GREEDY algorithm for independent sets, which greedily add every incoming vertex v to an initially empty independent set I if this is possible, i.e., if I ∪ {v} is an independent set. This yields the following result: Fact 1. The GREEDY algorithm for independent sets is a one-pass O(n log n) space maximal independent set algorithm in the vertex-arrival order streaming model (for both implicit and explict vertex streams). Since the only space required by the algorithm is to store a valid independent set, the storage is in fact bounded by O(α(G)), the space needed to store an MIS, which is bounded by O(n log n). This fact raises the question how well we can solve the maximal independent set problem in edge-arrival streams, which we address in the remainder of this section. We will first show that computing a maximal independent set in one pass in the edge-arrival model is not possible using sublinear space, i.e., space Ω(n2) is required. We then ask whether we can compute an independent set that is approximately maximal in a single pass: Definition 6 (Approximate Maximality). Let G = (V, E) be an n-vertex graph, and let I ⊆ V be an independent set. Then I is δ-maximal, if I ∪ ΓG[I] ≥ δn. A δ-maximal independent set I covers a δ-fraction of the vertices, or, in other words, when removing I and its neighbors ΓG[I] from the graph, then (1 − δ)n vertices are remaining. We will next show that establishing approximate maximality in edge-arrival streams requires strictly more space that computing a maximal independent set in vertex-arrival streams (i.e., ω(n) space), even if δ = 24 25 . Regarding stronger approximate maximality, our lower bound yields that computing a (1− 1 nǫ )-maximal independent set requires space Ω(n2−o(1)), for every ǫ > 0. Interestingly, if we allow an algorithm to perform multiple passes, then sublinear space algorithms for maximal independent set can be obtained. Such algorithms are in fact immediately implied by the correlation clustering algorithms given in Ahn et al. [1]. Their result yields the following theorem: Theorem 1. There is a O(log log n)-pass streaming algorithm for maximal independent set that uses space O(n). 2.1 Lower Bound for Maximal Independent Set in Edge-arrival Streams We give a reduction to the well-known two-party communication complexity problem INDEX: Definition 7. In the two-party communication problem INDEX, Alice holds an N -bit string X ∈ {0, 1}N and Bob holds an index σ ∈ [N ]. Alice sends a single message to Bob, who, upon receipt, outputs Xσ. It is well-known that Alice essentially needs to send all N bits to Bob: Theorem 2 ([18]). The randomized constant error communication complexity of INDEX is Ω(N ). Theorem 3. Every randomized constant error one-pass streaming algorithm in the edge arrival model that computes a maximal independent set requires Ω(n2) space. 5 Ai Bi A∗ 2 b2 a2 B∗ 2 ? ? b1 A∗ 1 a1 B∗ 1 (a) Alice encodes X in each Gi. (b) Bob adds all inter-Gi edges, except those incident to vertex pairs ai, bi linked to Xσ. Figure 3: Construction of the gadget used to prove theorem 3. . Proof. For an integer n, consider an instance (X, σ) of INDEX with N = n2. Given X, Alice constructs the ∪ G2, which is the disjoint union of graphs G1 and G2, where G2 is a disjoint copy input graph G = G1 of G1. Graph G1(A1, B1, E1) is a bipartite graph with A1 = B1 = n. The vector X ∈ {0, 1}n2 is seen as the n × n incident matrix of the bipartite graph G1, which defines the edge sets of G1 (and thus also of G2). Alice simulates a streaming algorithm for maximal independent set on the stream of edges of G1 and G2 and sends the memory state to Bob. Given index σ, Bob identifies the pair of vertices (a1, b1) ∈ A1 × B1 that corresponds to the index σ. Let (a2, b2) be the copy of (a1, b1) in G2. Let A∗ 2 . Given the message from Alice, i.e., the memory state of the run of the maximal independent set streaming algorithm, Bob continues the algorithm by adding all edges between the two sets of vertices A∗ 2 . This cannot cause a conflict, because no edges were previously present between G1 and G2. The construction is shown in figure 3. 1 = A1 \ {a1}, similarly for A∗ 1 ∪ B∗ 2 ∪ B∗ 1 and A∗ 1 , B∗ 2, B∗ Let I be the output maximal independent set computed by the algorithm. We argue that Bob can decide whether edge (a1, b1) is in the input graph and hence determine the value of Xσ. First, suppose that Xσ = 1. Then, for every j ∈ {1, 2}, {aj, bj} 6⊆ I, i.e., aj and bj are not both included in I. We argue now that if Xσ = 0, then {a1, b1} ⊆ I or {a2, b2} ⊆ I. Suppose that this is not the case, i.e., there are vertices x1 ∈ {a1, b1} and x2 ∈ {a2, b2} which are not included in I. Since I is maximal, there exists a vertex y1 ∈ I ∩ ΓG(x1) and y2 ∈ I ∩ ΓG(x2). Furthermore, since a1, b1, a2, b2 can only have edges to B∗ 1, A∗ 2 . However, since Bob added all edges between these vertex sets, there must be an edge between y1 and y2, which contradicts I being an IS. Hence, if Xσ = 0, then {a1, b1} ∈ I or {a2, b2} ∈ I and we can thus determine the value of Xσ. The space required by the streaming algorithm is therefore at least the communication complexity of INDEX, which is Ω(N ) = Ω(n2), by Theorem 2. 2 respectively, we have y1 ∈ A∗ 1 and y2 ∈ A∗ 1 ∪ B∗ 2 ∪ B∗ 1, B∗ 2, A∗ 2.2 Lower Bound for Approximate Maximality in Edge-arrival Streams We now extend the lower bound given in the previous subsection to approximate maximality. Central to our construction are Ruzsa-Szemer´edi graphs, which have previously been used for the construction of space lower bounds for streaming algorithms for the maximum matching problem [11, 17, 3]: Definition 8 (Ruzsa-Szemer´edi graph). A bipartite graph G is an (r, s)-Ruzsa-Szemer´edi graph if its edge 6 A∗ 2 A∗ 1 b2 a2 b1 a1 B∗ 2 B∗ 1 A∗ 2 A∗ 1 b2 a2 b1 a1 B∗ 2 B∗ 1 (a) When Xσ = 1, clearly ai and bi cannot both be in any IS. So neither pair {ai, bi} is in output. (b) When Xσ = 0, in any IS only one pair can be covered by neighbours. So any maximal IS output contains a pair {ai, bi}. Figure 4: Sketch proof for theorem 3 that at least one pair ai, bi is in any maximal IS when Xσ = 0. set can be partitioned into r induced matchings each of size s. subgraph G[V (M )] equals M , i.e., there are no other edges interconnecting V (M ) different from M . Recall that a matching M ⊆ E in a graph G = (V, E) is induced, if the edge set of the vertex-induced Our lower bound for approximate maximality is obtained by a reduction to the two-party communication problem RS-INDEX, defined as follows: Definition 9 (RS-INDEX). Let H be an (r, s)-Ruzsa-Szemer´edi graph with induced matchings M1, M2, . . . , Mr. For each induced matching Mi, let M ′ i ⊆ Mi be a uniform random subset of size s/2 (we assume that s is even). The RS-INDEX problem is a one-way two-party communication problem, where H, and, in particu- lar, M1, M2, . . . , Mr are known by both parties. In addition, Alice holds the graph G = H[∪iM ′ i], and Bob holds a uniform random index i ∈ {1, 2, . . . , r}. Alice sends a single message to Bob, who, upon receipt, outputs at least C · s edges of M ′ i , for an arbitrary small constant C. Observe that this problem is similar in spirit to INDEX: In INDEX, Bob needs to learn one uniform i . A lower bound on random bit, while in RS-INDEX, Bob needs to learn the presence of many edges of M ′ the communication complexity of RS-INDEX is implicit in [11] 2: Theorem 4 ([11]). The randomized constant error communication complexity of RS-INDEX is Ω(r · s). Equipped with the RS-INDEX problem, we now give a reduction from approximate maximality to RS- INDEX, which yields our lower bound for streaming algorithms: Lemma 1. Let r, s, n be integers such that there is an n-vertex (r, s)-Ruzsa-Szemer´edi graph. Then, every randomized constant error one-pass streaming algorithm in the edge arrival model that computes a (1− s 6n )- maximal independent set requires Ω(r · s) space. Proof. Let H be an n-vertex (r, s)-Ruzsa-Szemer´edi graph, and let G be Alice's input graph for the RS- INDEX problem derived from H. Let M1, M2, . . . , Mr denote the induced matchings in H, let Vi = V (Mi), and let M ′ i ⊆ Mi denote the subset of edges of matching Mi that is included in G. Let i be Bob's input. Furthermore, let A be a constant error randomized one-pass streaming algorithm for the edge-arrival model that computes a (1 − s 6N )-maximal independent set on a graph on N vertices. We now show how A can be used to solve RS-INDEX: 2In [11] a lower bound is given for the task of computing a maximum matching. Their hardness stems from the fact that it is hard to learn many edges of M ′ i under the distribution described in the definition of RS-INDEX. 7 i := Mi \ M ′ . Given G, let G be the graph obtained from G, where every induced matching M ′ Observe that the graph processed by algorithm A contains N = 2n vertices. Since I is (1− s Let a, b be the incident vertices to an arbitrary edge of M ′ i in G is replaced by edges M ′ i (observe that E(G) ∪ E( G) = E(H)). Alice now constructs two disjoint copies G1 and G2 of G, runs algorithm A on G1 ∪ G2 (on an arbitrary ordering of their edges), and sends the memory state to Bob. Bob constructs the edge set F that connects every vertex v1 ∈ V (G1) \ Vi1 with every vertex v2 ∈ V (G2)\ Vi2, where Vi1 and Vi2 are the copies of the vertices Vi in graphs G1 and G2, respectively, and continues the execution of A on F . Let I be the independent set produced by algorithm A. 6N )-maximal, 6N )N = s/6. This allows us to identify Ω(s) edges of M ′ we have V \ Γ[I] ≤ N − (1 − s i , let a1, b1 be the copies of a, b in G1, and let a2, b2 be the copies of a, b in G2. Observe that a1 and b1 are not connected in G1, and a2 and b2 are not connected in G2. We now claim that if all vertices a1, b1, a2, b2 are covered by I, i.e., {a1, b1, a2, b2} ⊆ Γ[I], then either {a1, b1} ⊆ I or {a2, b2} ⊆ I (or both). Indeed, suppose that this is not the case. Then there are vertices x1 ∈ {a1, b1} and x2 ∈ {a2, b2} with x1, x2 /∈ I. Let y1 ∈ I be a vertex incident to x1, and let y2 ∈ I be a vertex incident to x2. By the construction of the input graph, y1 ∈ V (G1) \ Vi1, and y2 ∈ V (G2) \ Vi2. Observe however that the edge y1y2 was included by Bob, which implies that y1, y2 are not independent, a contradiction. Hence, either {a1, b1} ⊆ I or {a2, b2} ⊆ I (or both) holds. Observe that this implies that the algorithm identified that there is no edge between a1, b1, which in turn implies that we learned one edge of M ′ i , either at least one vertex among {a1, b1, a2, b2} is not covered by I, or we learn one edge of M ′ i , and at most s/6 vertices of the input graph are not covered by I, we learn at least s/2 − s/6 = Ω(s) edges of M ′ i , which thus solves RS-INDEX. By Theorem 4, algorithm A therefore requires space Ω(r · s). i . Hence, for every pair of vertices a, b of M ′ i . Since there are s/2 edges in M ′ i as follows: In [11] it is shown that there are n-vertex (nΘ( 4 − ǫ)n) Ruzsa-Szemer´edi graphs, for every ǫ > 0, and in [2], it is shown that there are n-vertex Ruzsa-Szemer´edi graphs with Θ(n2−o(1)) edges such that each matching is of size n1−o(1). Combined with Lemma 1, we obtain our main theorem: log log n ), ( 1 1 Theorem 5. Every randomized constant error one-pass streaming algorithm that computes a 24 log log n ), and every such algorithm computing a (1 − 1 independent set requires space n1+Ω( independent set requires space Ω(n2−o(1)), for every ǫ > 0. 1 25 -maximal nǫ )-maximal 3 Maximum Independent Set in Explicit Vertex Streams We first introduce and show the hardness of a "chained index" problem, which we then use to show the hardness of approximating the size α(G) (and hence also for finding an MIS). 3.1 Chained Index Communication Problem We define a multi-party communication problem, which allows us to prove new lower bounds on several streaming problems. The problem is closely related to pointer jumping and generalizes the classic 2-party index communication problem to more parties by "chaining" together multiple instances which have the same answer but are otherwise independent. In our setting, each party (other than the last) holds a vector that contains (somewhere) a bit which is "the answer" to the instance. Each party (other than the first) knows where the answer bit is located in the previous party's vector. Communication is one-way and private, with each player receiving a message from the previous player and then sending a message to the next player. This rules out any trivial solution where a party can simply look up the bit announced by a later party. Formally, 8 Definition 10. The k-party chained index problem CHAINk consists of (k−1) n-bit binary vectors {X (i)}k−1 i=1 , along with corresponding indices {σi}k−1 σi }k−1 are all equal to the desired answer bit z ∈ {0, 1}. The input is initially allocated as follows: i=1 from the range [n]. We have the promise that the entries {X (i) i=1 • The first party P1 knows X (1) • Each intermediate party Pp for 1 < p < k knows X (p) and σp−1 • The final party Pk knows just σk−1 Communication proceeds as follows: P1 sends a single message to P2, then P2 communicates to P3, and so on, with each party sending exactly one message to its immediate successor. After all messages are sent, Pk must correctly output z, succeeding with probability at least 2/3. If the promise condition is violated, any output is considered correct. There is a trivial communication upper bound of O(n) bits: for instance, simply have the penultimate σk−1 . We now show lower bounds by a reduction party send X (k−1) to the final party who can then return X (k−1) from a different multi-party communication problem. Definition 11 ([9]). The Boolean conservative one-way k-party pointer jumping problem JUMPk consists of a constant α ∈ [n] and k − 1 functions {fi}k i=2. The first k − 2 are of the form fi : [n] → [n], and the final one is of the form fk−1 : [n] → {0, 1}. We use fi:j to refer to the composition3 of functions fi ◦ fi+1 ◦ ··· ◦ fj−1 ◦ fj. The input is divided as follows: i=2 • The first party P1 knows all the functions {fi}k • The second party P2 knows α and every fj for j ≥ 3 • Each other party Pi knows f2:i−1(α) and every fj for j ≥ i + 1 Each party sends exactly one message in ascending order to their immediate successor, i.e. P1 sends to P2, then P2 sends to P3, and so on. After all messages are sent, Pk must correctly output f2:k(α) with probability at least 2/3. The conservative version of one-way k-party pointer jumping problem was introduced and studied in [9], 3 ) for a version with a non-Boolean final layer. Later, [7] extended this 1 showing Ω( n k2 ) hardness for k ∈ o(n to all k and to the Boolean version. Theorem 6 (Theorem 2 in [7]). Any communication scheme A which solves JUMPk must communicate at least Ω( n k2 ) bits. Hardness for our new problem is then as follows. Theorem 7. Any communication scheme B which solves CHAINk must communicate at least Ω( n Proof. We prove the claim by showing that any instance of JUMPk can be reduced to an instance of CHAINk without any communication. Hence, any algorithm which solves CHAINk can solve JUMPk with no change in the communication cost. Combining this with the lower bound of Theorem 6 gives the result. k2 ) bits. Fix an instance of JUMPk. For each i let X (i) be the binary vector whose jth entry is fi+1:k(j). For each i let σi = f2:i(α). Now we observe three facts: • Every {X (i) σi }k−1 i=1 is equal to f2:k(α) 3Using the convention that (g ◦ h)(x) = h(g(x)). 9 • Each party Pi for i < k knows all the information required to compute X (i) • Each party Pi for i > 1 knows all the information required to compute σi−1 So we have constructed (with no communication) a k-party chained index problem which, if solved, will tell us exactly f2:k(α). It therefore follows that the commnication cost for any solution to CHAINk is at least that for JUMPk. In particular, for constant k, we have a tight bound on the communication complexity of the k-party chained index problem of Θ(n). We conjecture that a dependence on k is not necessary. Conjecture 1. Any communication scheme which solves CHAINk requires Ω(n) communication. If proven, this would give a hardness of Ω( n2 Although the two problems of JUMPk and CHAINk may look fairly similar, we find that the form of CHAINk is much more convenient to show lower bounds for independent set and related problems, as we show in the subsequent sections. c5 ) for theorem 8. 3.2 MIS hardness in explicit vertex streams We show a new lower bound for the vertex streaming space complexity of approximate maximum indepen- dent set. Theorem 8. Any algorithm for the explicit vertex stream model which finds a c-approximation to α(G) with probability at least 2/3 requires Ω(cid:16) n2 c7(cid:17) space. For ease of argument, we will actually prove an equivalent result for the problem of clique number approx- imation, and then note that the complement of the constructed graph can be used with the same arguments to prove Theorem 8. To see this equivalence, note that an MIS of a graph is a maximum clique in its comple- ment, and in a vertex streaming model an algorithm can simulate operation on the complement by taking the complement of each vertex as it arrives. Importantly, in the edge-arrival model this reduction is not possible, since the model does not allow to 'subtract' the observed edges from the complete graph. Theorem 9. Any algorithm for the explicit vertex stream model which finds a c-approximation to the size of the largest clique ω(G) with probability at least 2/3 requires Ω(cid:16) n2 c7(cid:17) space. The heart of our construction is to use an erasure code to encode a length O( n2 c4 ) binary vector on O( n c ) vertices, with each bit corresponding to the presence or absences of a clique of size 2c. The use of the erasure code is to ensure that no pair of these cliques can share an edge. We can then chain together 2c such gadgets to encode an instance of CHAIN2c such that if the correct answer is 1, the resulting graph has an independent set of size 4c2, while if the correct answer is 0 the graph has no independent sets of size larger than 4c− 1. Any (one-sided) c-approximation algorithm could distinguish these two cases, and so the result is proved. First we define our clique gadget. Lemma 2. For any positive integers n and c2 < n edge-disjoint cliques of size 2c and no cliques of size larger than 2c. 8 , there exists a graph on n vertices containing n2 16c2 10 p ... ... ... ... V2c V3 V2 V1 p ... ... ... V2c V3 V2 V1 p ... ... V2c V3 V2 V1 (a) Select an edge. (b) Extend linearly to size 2c. (c) Can make p2 such cliques. Figure 5: Clique gadget construction in lemma 2. 4c ≤ p ≤ n are added to the final graph as isolated vertices. Proof. We construct the sets from an erasure code with block size 2c and message size 2. Choose a prime p such that n 2c (which is guaranteed to exist). Now take 2c < p groups of vertices, each of size p. Label the groups Vi (for i ∈ [2c]) and label the items in each group Vi as vi j (for j ∈ [p]). Leftover vertices P(i)i ∈ [2c]}. This can be viewed as taking each of the p2 possible edges between V1 and V2 and extending them "linearly" to the other layers (see Figure 5). Clearly K = {KPP ∈ GF(p2)} consists of p2 > n2 16c2 cliques, each of size 2c. For each polynomial P ∈ GF(p2) we define KP to be the clique over vertices {vi We next show that they are pairwise edge-disjoint and that their union contains no larger cliques. Each clique contains exactly one vertex from each group Vi, so for two cliques to share an edge there must be distinct polynomials P,Q ∈ GF (p2) that have the same value at two different points: P(i) = Q(i) and P(j) = Q(j) for i 6= j -- a contradiction. Finally, because no clique contains a pair of vertices from a single Vi, their union can contain no internal edges on any Vi. So any clique can contain at most 1 vertex from each Vi, giving a maximum size of 2c. Hence,SP∈GF(p2) KP is a graph with the required properties. p V4 V3 V2 V1 p × V4 V3 V2 V1 (a) No edge belongs to two differ- (b) No edges within layers, so no ent lines (cliques). cliques larger than 2c. Figure 6: Clique gadget proof sketch for theorem 9. Proof of Theorem 9. Suppose we have an algorithm C for explicit vertex streams which can, with probability at least 2 3 , produce a c-approximation to ω(G), the size of the largest clique. We will show that such an algorithm can be used to solve CHAIN2c, by communicating its state 2c − 1 times. 11 Fix an instance of CHAIN2c with vectors of length b = n2 64c4 . Our lower bound implies any algorithm that can solve this must send at least one message of size Ω(cid:0) b nodes into 2c groups of size n c3(cid:1) = Ω(cid:16) n2 c7(cid:17). Take n vertices and partition the 2c . Each group will be added to the stream by one of the parties. Intra-party edges. First, consider the group of nodes associated with party Pi. We will encode the bits of X (i) onto the internal edges of this group using the construction from Lemma 2. The size n c sub-graph can fit b cliques of size 2c. We include the edges of clique j if and only if X (i) j = 1. This is well-defined as the cliques are edge-disjoint. Label the clique in party Pi corresponding to bit j of X (i) as Ki j . The final party P2c has no associated vector. Instead, it constructs a single clique of size 2c and leaves the other vertices isolated. Inter-party edges. We also need edges between the sub-graphs associated with different parties. Each party Pi will connect all its vertices to some of the vertices belonging to previous parties (Pj for j < i). These edges are considered to belong to party Pi, as they will be added by this party in the vertex streaming model. For each j < i the party Pi connects every one of its vertices to all of Kj σj (the clique corresponding to index σj). For this to happen, Pi must know all σj for j < i. This information is not known initially, but can be appended to the communications between players with only O(c) overhead. σi = 1. In this case we have each of the cliques Ki Now that we have our construction, we need to show bounds on ω(G) for the two cases. First, consider when every X (i) σi present and connected together, forming a clique of size 4c2. Now consider the case when every X (i) σi = 0. Consider a clique K in the graph. If K contains multiple vertices belonging to one party Pi, then it can contain none from any subsequent party Pj (j > i), and at most one from each preceding party Pl (l < i). Hence the size of any clique is bounded by 4c − 1. To see why this holds, observe that for any i < 2c, our clique can contain only one vertex from Ki , as none of its edges are included in the graph. So to contain multiple vertices from party Pi, the clique K must contain a vertex v from some Ki j with j 6= σi. But then all subsequent parties Pj (j > i) will have no vertices adjacent to v, so cannot contribute anything to K. So the best we can do is include one vertex from each Ki To complete the proof, observe that this gap in clique sizes can be distinguished by a c-approximation algorithm, and any streaming algorithm gives a communication protocol by having each party update the algorithm state with their information and then passing it to the next player. σi and then 2c from party P2c giving a clique of size 4c − 1. σi P1 P2 P3 P4 Figure 7: Example lower bound instance with 4 players for theorem 9. Cliques corresponding to σ1, σ2, and σ3 are shown in bold red -- other cliques are omitted. 12 Interestingly, the same construction gives us hardness for approximating the chromatic number of a graph. This is notably not possible in the 2-party edge stream construction in [14], as the random graphs used as gadgets have large chromatic number with high probability (see [4]). Corollary 1. Any explicit vertex streaming algorithm to find a c-approximation to χ(G) (the chromatic number), succeeding with probability at least 2/3 requires Ω(cid:16) n2 c7(cid:17) space. Proof. Consider the construction in the proof of Theorem 8. In the case of all X (i) a clique of size 4c2, so it requires at least as many colours. σi = 1, the graph contains Conversely, in the case of every X (i) σi = 0, we can construct a 4c-colouring of the graph. First colour each of the nodes in each Ki σi with the ith colour (this is allowed, as they have no internal edges). Now, the remaining vertices in each party are not adjacent to any uncoloured vertices from other parties, so we simply need to be able to complete the colouring of each party in isolation with 2c new colours and we are finished. This is easily done, as each party's sub-graph is 2c-partite by construction. 4 Maximum Independent Set in Geometric Intersection Graphs In this section we present a collection of results around geometric intersection graphs given as explicit or implicit vertex streams. This represents a first study of how the difficulty of these problems differs between the models, and with other factors such as dimension. Recall that a geometric intersection graph is a graph where nodes correspond to geometric objects, and edges indicate whether or not a particular pair of objects intersect. These graphs can be described implicitly, by just giving the collection of geometric objects, or explicitly as a collection of vertices and edges under the promise that some geometric representation exists. For sufficiently complex geometry, every graph will have a geometric representation (simply take hyper-rectangles of a high enough dimension), so to define meaningful classes, we must limit the universe of objects. We will consider the lp closed balls in Rd, particularly for p = 1, 2, and ∞. A d-dimensional lp ball is uniquely defined by its center and radius. The ball with center c and radius r is exactly the region {x ∈ Rd : kx − ckp ≤ r}. For the implicit representation, we discretize the space of possible centers as [M ]d and the space of possible radii as [M ]. Then, the input stream is defined as follows: Definition 12. A d-dimensional lp ball stream consists of sequence of n pairs in [M ]d × [M ] indicating the center and radius of each ball respectively. This defines an implicit vertex stream, with the intersection function: σ ((p1, w1), (p2, w2)) =(1, if kp1 − p2kp ≤ w1 + w2 0, otherwise. Typically M will be some polynomial in n, so that the balls can be represented in polylog(n) space. We also define a dilation parameter, which will capture some of the difficulty of the problem. Definition 13. Let the dilation, ∆ = rmax rmin , be the ratio between the largest and smallest radii in the stream. We refer to the interesting special case of ∆ = 1, when all the balls are uniform in size, as a unit ball stream. 13 4.1 Interval Graphs: d = 1 In d = 1, the choice of p is irrelevant, as any lp ball is simply an interval. As discussed in Section 1.3, 2 -approximation to MIS in O(α(G)) space, and any better given an interval (ball) stream we can compute a 3 approximation requires Ω(n) space. A natural question is how this compares with the space complexity for an interval intersection graph given as an explicit vertex stream. Theorem 10. Any algorithm with constant error probability that returns a ( 5 for a unit interval intersection graph given as an explicit vertex stream requires Ω(n) space. 3 − ǫ)-approximation of α(G) A1 A0 B0 B1 x A1 B0 aσ bσ B1 A0 x z y (a) First party makes 3 cliques. (b) After second party adds y and A1 aσ y B0 A0 x z, if Xσ = 0 then α(G) = 3. B1 z bσ (c) Conversely, if Xσ = 1 then α(G) = 5. Figure 8: Interval representations for the construction in theorem 10. Horizontal positioning represents the location of the intervals in R, vertical positioning is for clarity only. Proof. We will show this bound by a reduction from the 2-party INDEX communication problem for an n-bit vector. construct a 2n + 3 vertex graph as an explicit vertex stream. Consider an instance of INDEX with bit vector X ∈ {0, 1}n and index to be queried σ ∈ [n]. We will Label the vertices x, y, z and ai, bi for i ∈ [n]. Split the ai's into two sets based on the bit vector X: A1 = {ai}Xi=1 and A0 = {ai}Xi=0. Similarly let B1 = {bi}Xi=1 and B0 = {bi}Xi=0. Now the first party creates the following subgraph in the stream: a clique consisting of all the vertices in A1, a second clique made from B1, and a third clique containing A0 ∪ B0 ∪ {x}. So far this represents a valid interval graph, which can be interpreted as three adjacent "stacks" of inter- vals. Now, the second player adds y with edges to every ai except aσ and then adds z with edges to every bi except bσ. This can still be viewed as a valid interval graph, but we now require some intervals from each stack to be "shifted" to overlap with the two new intervals. In the case of Xσ = 0, the resulting graph has α(G) = 3. Otherwise, α(G) = 5. Hence, any algorithm giving a better than 5 3 (one-sided) approximation factor could distinguish them and solve INDEX. This shows that MIS for interval graphs is strictly more difficult in explicit vertex streams than implicit ones. 14 4.2 Square Graphs: d = 2 Observe that in d = 2, the geometry defined by l1 and l∞ balls is equivalent, after fixed scaling and rotation. Thus any instance in one geometry can be transformed into an equivalent (intersection-wise) instance of the other, after ensuring that the discretization is not too coarse. Our first result for 2 dimensions is a 3-approximation algorithm for MIS on a unit square stream. This is a generalization the algorithm of [6] for unit interval streams -- we perform a decomposition of the plane into 2-by-3 strips, similar to their decomposition of the line into length 3 segments. Theorem 11. For d = 2 and ∆ = 1 we can 3-approximate MIS for an l1 or l∞ ball stream using O(α(G)) space. Proof. Let r be the radius of the balls, and let w = 2r. Without loss of generality, we consider the l∞ version of the problem. First we look at the problem restricted to squares in the half open strip [0, 3w) × [0, 2w), referring to the first axis as "left-right", and the second as "up-down". At most 2 non-overlapping closed unit squares can fit fully within the open region, and for them not to overlap one must be left of the other. Hence, by storing the leftmost and rightmost squares seen within the strip, we can determine exactly an MIS in the region. Now, consider the whole of [M ]2. We partition this up into 3w-by-2w half-open strips and consider only the squares which fall exactly within one of the strips. By solving MIS within each strip as before and taking the union, we can solve exactly MIS on this substream. This requires us to store at most twice as many squares as the solution. Finally, we consider 6 different copies of the partitioning shifted by 0, w, or 2w horizontally and 0 or w vertically. Any square from the stream must be fully contained in a strip in at least 2 of the 6 partition- ings. In particular, this holds for every square in a fixed MIS of the full stream. Using Gx,y for the graph of the substream of squares that fit exactly in the partitioning shifted by (x, y), we know the following: (α(Gx,y))! ≥ 2α(G). That is, the sum of the sizes of the substream MIS's for the 6 Px=0,w,2w Py=0,w x=0,w,2w(cid:18) max y=0,w (α(Gx,y))(cid:19) ≥ 1 3 α(G) partitionings is at least 2 times the size of the true MIS. Therefore max Therefore, we simply take the largest of the 6 substream MIS's and this must give a 3-approximation. In total, we must store at most 12 squares per MIS square. As in [6] for unit intervals, this immediately leads to a sublinear space algorithm for estimating α(G) with only a (1 + ǫ) factor loss in approximation factor, through a combination of distinct elements and sampling. Corollary 2. For d = 2 and ∆ = 1 we can (3 + ǫ)-approximate α(G) with constant probability for an l1 or l∞ ball stream using O(ǫ−2 log ǫ−1 + log n) space. Proof. Observe that if we can get a (1 + ǫ)-approximation to each α(Gx,y) from the proof of theorem 11, then we are done. Each strip can have 0, 1, or 2 disjoint squares in it. To approximate α(Gx,y) we estimate γ, the number of strips of a given partitioning which are non-empty, and δ, the average number of disjoint squares in the non-empty strips. Then α(Gx,y) ≈ γδ. constant probability in O(ǫ−2 + log n) space (see [15]). Observe that approximating γ is a distinct elements problem, which we can (1 + ǫ)-approximate with Then δ can be approximated by using nearly-uniform permutations to keep a nearly-uniform sample of the non-empty strips. For full details see [6, lemma 16]. 15 One might speculate whether this decomposition approach could afford a better approximation factor based on some different partioning of the place. We give evidence for the negative, since any larger strips result in the fixed-size sub-problems not being solvable exactly, as the following result shows. Theorem 12. Given a stream of w-by-w squares (2 dimensional l∞ balls) contained in a (2 + δ)w-by- (2 + δ)w region, achieving a ( 3 2 − ǫ)-approximation to α(G), with constant probability of success, for any ǫ, δ > 0 requires Ω(n) space. Proof. We show this by a reduction from 2-party INDEX. Fix an instance with bit vector X ∈ {0, 1}n and query index σ ∈ [n]. For the lower bound, we use squares of width w = 4n δ , which meets the requirements for an implicit vertex stream as long as δ is constant. Party one constructs the following collection of squares arranged along a diagonal line: for each i ∈ [n] with Xi = 1 include the square centered on ( 2n δ + 2n + 2 − 2i). Now, observe that the parties could use a ( 3 2 − ǫ)-approximation streaming algorithm to allow party two to determine Xσ. Simply have party one run the algorithm on its collection, then pass the state to party two and append squares centered on δ + 2n + 2 − 2σ) and ( 2n ( 6n δ + 2n + 3 − 2σ). If Xσ = 1, there exists a square in the original collection sandwiched between the two new squares giving α(G) = 3. Otherwise, α(G) = 2. δ + 2σ + 1, 2n δ + 2i, 2n δ + 2σ, 6n Our next result for two dimensions is a stronger lower bound for approximating α(G) of a stream of unit squares in an unrestricted region, based on a reduction from the chained index communication problem used in our main result in Section 3. Theorem 13. Achieving a ( 5 l∞ ball stream with d = 2 and ∆ = 1 requires Ω(n) space for any ǫ > 0. 2 − ǫ)-approximation of α(G), with constant probability of success, on an l1 or Proof. We show the lower bound for l∞, which then implies the result for l1. This proof works by reducing from the 3-party chained index problem. As with the general result in Section 3, more than 2 parties are necessary in order to give a bound for approximation factors greater than 2. Suppose we have an instance of CHAIN3 with n-bit vectors. We will describe a way for each party to construct a collection of unit l1 balls based on the part of the input they hold, such that their union has small or large α(G) depending on the solution to the communication problem. Thus, a streaming algorithm for approximating α(G) can be used to solve the communication problem, giving a space bound. For the lower construction we use domain size M = 10n3 and ball radius r = 2n2, which are small enough to allow succinct polylog n sized descriptions of the balls (as required for an implicit vertex stream), but large enough to create the gadgets we require. Fix integer k ∈ [n]. The first party has the bit vector X (1). For each entry with X (1) i = 1, add balls centered at (i(4n + 3) + (j + 1)(4n2 + 3n), 4n2) and (i(4n + 3) + (j + 1)(4n2 + 3n), 8n2) for each j ∈ [k]. Essentially, this makes two horizontal lines of balls stacked on top of each other. There are potentially nk ball locations along the line with centers 4n + 3 apart. The first n locations are associated with the n entries of X (1); we place a ball if X (1) = 1, and omit it otherwise; then this is repeated k times in succession. The two lines produce a collection of balls G1 of size at most 2nk, with α(G1) = 2k. Importantly, the collection of balls associated with any index X (1) i = 1 forms an MIS. Party two will obliviously add their own set of balls, such that α(G) will increase exactly when the answer bit X (1) σ1 = 1. The second party has its bit vector X (2) and the index σ1 of the answer bit in the first party's bit vector. For each entry with X (2) 2 )(4n2 + 3n), 6n2 − n + 2i) for each j ∈ [k]. Essentially, this produces k columns of n balls. The columns are spaced with centers n2 + 3n apart, lined up to fit in the gaps between the balls corresponding to bit X (1) σ1 of the first party (if those balls are present). Each column is constructed as follows: place n balls spaced with centers 1 apart, each associated with one of the entries of X (2), but exclude each ball whose X (2) i = 0. The result is a i = 1 add a ball centered at (σ1(4n + 3) + (j + 3 16 collection of balls G2 of size nk with α(G2) = k. Again, the collection of balls associated with any index X (1) i = 1 forms an MIS. Now, party three will add the final collection of balls G3. Party three knows σ1 (this can be appended to any message from player two) and σ2, the index of the answer bit in party two's bit vector. This party adds balls centered at (σ1(4n + 3) + (j + 3 2 )(4n2 + 3n), 2n2 − n + 2σ2 − 1) for each j ∈ [k]. These balls sit at the top and bottom of each column from party 2 sandwiching the ball corresponding to X (2) σ2 (if present). This final collection has an independent set of size 2k. 2 )(4n2 + 3n), 10n2 − n + 2σ2 + 1) and (σ1(4n + 3) + (j + 3 At this point we wish to determine α(G) for the union G = G1 ∪ G2 ∪ G3. In the case that X (1) σ1 = X (2) σ2 = 1, we can take the MIS of G1 associated with X (1) σ2 along with all the balls in G3 to form an MIS of G of size 5k. However, if X (1) σ2 = 0, then choosing any ball from G1 (other than the left-most σ1 − 1 balls in each row) excludes every ball in a column of G2 and a ball from G3. Similar exclusions occur between the other pairs of collections. The result is that the best we can do is to choose an MIS from G1 corresponding to an index smaller than σ1 along with 1 ball from each of G2 and G3 in the rightmost column, giving a total of α(G) = 2k + 2. σ1 and the MIS of G2 associated with X (2) σ1 = X (2) space. This holds for any constant k (just take n large enough to allow that k), giving the result. This shows that a streaming algorithm achieving an approximation factor better than 5k 2k+2 must use Ω(n) X (1) 1 X (1) 2 X (1) 4 X (2) 4 X (2) 1 X (2) X (2) 3 2 X (1) 3 (a) Balls are excluded or included based on corresponding X (1) i . (b) First party adds 2 rows each made of k consecu- tive copies of figure 9a. (c) Similarly, choose balls based on X (2). (d) Second party adds copies of figure 9c to fit in between balls for X (1) balls from the first party omitted). σ1 (other (e) Final party adds 2k balls to fit in be- σ2 (other tween balls for X (1) balls from previous parties omitted). σ1 and X (2) Figure 9: Example for theorem 13 with X (1) = (1, 1, 0, 1), X (2) = (1, 0, 0, 1), σ1 = 2, σ2 = 4, and k = 2. If we are allowed a combination of large and small balls, we can slightly improve the lower bound up to the maximum possible for a 3-party construction. Theorem 14. Achieving a (3 − ǫ)-approximation of α(G), with constant probability of success, on an l1 or l∞ ball stream with d = 2 and arbitrary ∆ requires Ω(n) space for any ǫ > 0. 17 Proof. We adapt the construction from Theorem 13 as follows: the first party inserts k rows stacked on top of each other, rather than 2, the second party inserts copies of its columns between every consecutive pair of rows from the first party, and the third party places smaller balls in between the columns of party 2 such that they are independent of the squares corresponding to the answer bit but overlap the squares either side. This results in a gap of k2 + k + 1 to 3k2 for the two cases, giving the result. 5 Conclusion We have addressed the complexity of Maximal and Maximum Independent Set (and various relaxations and related problems) under three natural models of graph streams: edge-arrival, explicit vertex arrival, and implict vertex arrival. The central problems of maximal and maximum independent set separate the models: maximal independent set has high space complexity in the edge-arrival model but an easy greedy algorithm in the vertex models; however, MIS has high space complexity for explicit vertex arrival (and hence also the harder edge arrival model), while there are small-space constant factor approximations for some cases of implicit vertex arrival. A natural extension is to consider weighted versions of the MIS problem, where each vertex is assigned a weight and the aim is to maximize the weight of the independent set. Our upper bounds generalize naturally to this case. Consider, for example, the two-dimensional geometric case (l1 or l∞). A naive first approach is to round all weights to the nearest power of epsilon, and solve each weight class separately, before com- bining the results. An improved result follows by observing that for each "strip" in the decomposition of Theorem 13, we only need to track at most O(ǫ−1) weight classes: if a given strip contains a ball of weight w then we can ignore any intervals of weight less than ǫw without affecting the quality of the solution by more than a (1+ǫ) factor. Thus we obtain a (3+ǫ)-approximate weighted MIS for the unit square case using only O(log W + α(G) ). It remains to consider the complexity of other weighted variants of MIS problems. ǫ There are a number of other natual open questions that follow from our study: • Is there a multi-pass lower bound for maximal independent set in edge streams? • Are there o(α(G)) space algorithms for achieving constant factor approximations to α(G) for classes of geometric intersection graphs given as explicit vertex streams? • Can we close the gap between the upper and lower bounds for approximating MIS in a unit square stream? • Is there a constant factor approximation algorithm for MIS on streams of arbitrary sized squares? References [1] Kook Jin Ahn, Graham Cormode, Sudipto Guha, Andrew McGregor, and Anthony Wirth. "Corre- lation Clustering in Data Streams". In: Proceedings of the 32Nd International Conference on Inter- national Conference on Machine Learning - Volume 37. ICML'15. Lille, France: JMLR.org, 2015, pp. 2237 -- 2246. URL: http://dl.acm.org/citation.cfm?id=3045118.3045356. [2] Noga Alon, Ankur Moitra, and Benny Sudakov. "Nearly Complete Graphs Decomposable into Large Induced Matchings and Their Applications". In: Proceedings of the Forty-fourth Annual ACM Sympo- sium on Theory of Computing. STOC '12. New York, New York, USA: ACM, 2012, pp. 1079 -- 1090. ISBN: 978-1-4503-1245-5. DOI: 10.1145/2213977.2214074. URL: http://doi.acm.org/10.1145/2213977.2214074. 18 [3] Sepehr Assadi, Sanjeev Khanna, Yang Li, and Grigory Yaroslavtsev. "Maximum Matchings in Dy- namic Graph Streams and the Simultaneous Communication Model". In: Proceedings of the Twenty- seventh Annual ACM-SIAM Symposium on Discrete Algorithms. SODA '16. Arlington, Virginia: So- ciety for Industrial and Applied Mathematics, 2016, pp. 1345 -- 1364. ISBN: 978-1-611974-33-1. URL: http://dl.acm.org/citation.cfm?id=2884435.2884528. [4] B´ela Bollob´as. "The chromatic number of random graphs". In: Combinatorica 8.1 (1988), pp. 49 -- 55. [5] Vladimir Braverman, Zaoxing Liu, Tejasvam Singh, N. V. Vinodchandran, and Lin F. Yang. "New Bounds for the CLIQUE-GAP Problem Using Graph Decomposition Theory". In: Algorithmica 80.2 (2018), pp. 652 -- 667. ISSN: 1432-0541. DOI: 10.1007/s00453-017-0277-5. URL: https://doi.org/10.1007/s00453-017-0277-5. [6] Sergio Cabello and Pablo P´erez-Lantero. "Interval selection in the streaming model". In: Theoretical Computer Science 702 (2017), pp. 77 -- 96. [7] Amit Chakrabarti. "Lower bounds for multi-player pointer jumping". In: Computational Complexity, 2007. CCC'07. Twenty-Second Annual IEEE Conference on. IEEE. 2007, pp. 33 -- 45. [8] Graham Cormode, Jacques Dark, and Christian Konrad. "Approximating the Caro-Wei Bound for Independent Sets in Graph Streams". In: Combinatorial Optimization. Ed. by Jon Lee, Giovanni Rinaldi, and A. Ridha Mahjoub. Cham: Springer International Publishing, 2018, pp. 101 -- 114. ISBN: 978-3-319-96151-4. [9] Carsten Damm, Stasys Jukna, and Jir´ı Sgall. "Some bounds on multiparty communication complexity of pointer jumping". In: computational complexity 7.2 (1998), pp. 109 -- 127. [10] Yuval Emek, Magn´us M Halld´orsson, and Adi Ros´en. "Space-constrained interval selection". In: ACM Transactions on Algorithms (TALG) 12.4 (2016), p. 51. [11] Ashish Goel, Michael Kapralov, and Sanjeev Khanna. "On the communication and streaming com- plexity of maximum bipartite matching". In: Proceedings of the Twenty-Third Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2012, Kyoto, Japan, January 17-19, 2012. 2012, pp. 468 -- 485. [12] Bjarni V Halld´orsson, Magn´us M Halld´orsson, Elena Losievskaja, and Mario Szegedy. "Streaming algorithms for independent sets". In: International Colloquium on Automata, Languages, and Pro- gramming. Springer. 2010, pp. 641 -- 652. [13] Magn´us M. Halld´orsson and Christian Konrad. "Computing Large Independent Sets in a Single Round". In: Distrib. Comput. 31.1 (Feb. 2018), pp. 69 -- 82. ISSN: 0178-2770. DOI: 10.1007/s00446-017-0298-y. URL: https://doi.org/10.1007/s00446-017-0298-y. [14] Magn´us M Halld´orsson, Xiaoming Sun, Mario Szegedy, and Chengu Wang. "Streaming and com- munication complexity of clique approximation". In: International Colloquium on Automata, Lan- guages, and Programming. Springer. 2012, pp. 449 -- 460. [15] Daniel M Kane, Jelani Nelson, and David P Woodruff. "An optimal algorithm for the distinct ele- ments problem". In: Proceedings of the twenty-ninth ACM SIGMOD-SIGACT-SIGART symposium on Principles of database systems. ACM. 2010, pp. 41 -- 52. [16] R. M. Karp. "Reducibility among combinatorial problems". In: Complexity of Computer Computa- tions. Ed. by R. E. Miller and J. W. Thatcher. Plenum Press, 1972, pp. 85 -- 103. [17] Christian Konrad. "Maximum Matching in Turnstile Streams". In: Algorithms - ESA 2015. Ed. by Nikhil Bansal and Irene Finocchi. Berlin, Heidelberg: Springer Berlin Heidelberg, 2015, pp. 840 -- 852. ISBN: 978-3-662-48350-3. 19 [18] I. Kremer, N. Nisan, and D. Ron. "On Randomized One-round Communication Complexity". In: com- putational complexity 8.1 (1999), pp. 21 -- 49. ISSN: 1420-8954. DOI: 10.1007/s000370050018. URL: http://dx.doi.org/10.1007/s000370050018. [19] Andrew McGregor. "Graph Stream Algorithms: A Survey". In: SIGMOD Rec. 43.1 (May 2014), pp. 9 -- 20. ISSN: 0163-5808. DOI: 10.1145/2627692.2627694. URL: http://doi.acm.org/10.1145/2627692.2627694. [20] David Zuckerman. "Linear Degree Extractors and the Inapproximability of Max Clique and Chro- matic Number". In: Theory of Computing 3.1 (2007), pp. 103 -- 128. 20
1602.05391
2
1602
2017-01-06T08:11:34
Simple average-case lower bounds for approximate near-neighbor from isoperimetric inequalities
[ "cs.DS" ]
We prove an $\Omega(d/\log \frac{sw}{nd})$ lower bound for the average-case cell-probe complexity of deterministic or Las Vegas randomized algorithms solving approximate near-neighbor (ANN) problem in $d$-dimensional Hamming space in the cell-probe model with $w$-bit cells, using a table of size $s$. This lower bound matches the highest known worst-case cell-probe lower bounds for any static data structure problems. This average-case cell-probe lower bound is proved in a general framework which relates the cell-probe complexity of ANN to isoperimetric inequalities in the underlying metric space. A tighter connection between ANN lower bounds and isoperimetric inequalities is established by a stronger richness lemma proved by cell-sampling techniques.
cs.DS
cs
Simple average-case lower bounds for approximate near-neighbor from isoperimetric inequalities Yitong Yin∗ Abstract We prove an Ω(d/ log sw nd ) lower bound for the average-case cell-probe complexity of determin- istic or Las Vegas randomized algorithms solving approximate near-neighbor (ANN) problem in d-dimensional Hamming space in the cell-probe model with w-bit cells, using a table of size s. This lower bound matches the highest known worst-case cell-probe lower bounds for any static data structure problems. This average-case cell-probe lower bound is proved in a general framework which relates the cell-probe complexity of ANN to isoperimetric inequalities in the underlying metric space. A tighter connection between ANN lower bounds and isoperimetric inequalities is established by a stronger richness lemma proved by cell-sampling techniques. 1 Introduction The nearest neighbor search (NNS) problem is a fundamental problem in Computer Science. In this problem, a database y = (y1, y2, . . . , yn) of n points from a metric space (X, dist) is preprocessed to a data structure, and at the query time given a query point x from the same metric space, we are asked to find the point yi in the database which is closest to x according to the metric. In this paper, we consider a decision and approximate version of NNS, the approximate near- neighbor (ANN) problem, where the algorithm is asked to distinguish between the two cases: (1) there is a point in the databases that is λ-close to the query point for some radius λ, or (2) all points in the database are γλ-far away from the query point, where γ ≥ 1 is the approximation ratio. The complexity of nearest neighbor search has been extensively studied in the cell-probe model, a classic model for data structures. In this model, the database is encoded to a table consisting of memory cells. Upon each query, a cell-probing algorithm answers the query by making adaptive cell-probes to the table. The complexity of the problem is measured by the tradeoff between the time cost (in terms of number of cell-probes to answer a query) and the space cost (in terms of sizes of the table and cells). There is a substantial body of work on the cell-probe complexity of NNS for various metric space [2, 3, 5 -- 8, 11, 12, 14, 16, 17, 20]. It is widely believed that NNS suffers from the "curse of dimensionality" [10]: The problem may become intractable to solve when the dimension of the metric space becomes very high. Consider the most important example, d-dimensional Hamming space {0, 1}d with d ≥ C log n for a sufficiently ∗State Key Lab for Novel Software Technology, Nanjing University, China. [email protected]. This work was supported by NSFC grants 61272081 and 61321491. 1 large constant C. The conjecture is that NNS in this metric remains hard to solve when either approximation or randomization is allowed individually. In a series of pioneering works [3, 5, 6, 11, 14], by a rectangle-based technique of asymmetric communication complexity known as the richness lemma [15], cell-probe lower bounds in form of Ω(d/ log s), where s stands for the number of cells in the table, were proved for deterministic ap- proximate near-neighbor (due to Liu [14]) and randomized exact near-neighbor (due to Barkol and Rabani [5]). Such lower bound is the highest possible lower bound one can prove in the commu- nication model. This fundamental barrier was overcome by an elegant self-reduction technique introduced in the seminal work of Patra¸scu and Thorup [18], in which the cell-probe lower bounds for deterministic ANN and randomized exact near-neighbor were improved to Ω(d/ log sw n ), where w represents the number of bits in a cell. More recently, in a previous work of us [20], by applying the technique of Patra¸scu and Thorup to the certificates in data structures, the lower bound for deterministic ANN was further improved to Ω(d/ log sw nd ). This last lower bound behaves differently for the polynomial space where sw = poly(n), near-linear space where sw = n · polylog(n), and linear space where sw = O(nd). In particular, the bound becomes Ω(d) when the space cost is strictly linear in the entropy of the database, i.e. when sw = O(nd). When both randomization and approximation are allowed, the complexity of NNS is substan- tially reduced. With polynomial-size tables, a Θ(log log d/ log log log d) tight bound was proved for randomized approximate NNS in d-dimensional Hamming space [7, 8]. If we only consider the decision version, the randomized ANN can be solved with O(1) cell-probes on a table of polynomial size [8]. For tables of near-linear size, a technique called cell-sampling was introduced by Pani- grahy et al. [16, 17] to prove Ω(log n/ log sw n ) lower bounds for randomized ANN. This was later extended to general asymmetric metrics [1]. Among these lower bounds, the randomized ANN lower bounds of Panigrahy et al. [16, 17] were proved explicitly for average-case cell-probe complexity. The significance of average-case complexity for NNS was discussed in their papers. A recent breakthrough in upper bounds [4] also attributes to solving the problem on a random database. Retrospectively, the randomized exact near-neighbor lower bounds due to the density version of richness lemma [5,6,11] also hold for random inputs. All these average-case lower bounds hold for Monte Carlo randomized algorithms with fixed worst-case cell-probe complexity. This leaves open an important case: the average-case cell-probe complexity for the deterministic or Las Vegas randomized algorithms for ANN, where the number of cell-probes may vary for different inputs. 1.1 Our contributions We study the average-case cell-probe complexity of deterministic or Las Vegas randomized algo- rithms for the approximate near-neighbor (ANN) problem, where the number of cell-probes to answer a query may vary for different query-database pairs and the average is taken with respect to the distribution over input queries and databases. For ANN in Hamming space {0, 1}n, the hard distribution over inputs is very natural: Every point yi in the database y = (y1, y2, . . . , yn) is sampled uniformly and independently from the Hamming space {0, 1}d, and the query point x is also a point sampled uniformly and independently from {0, 1}d. According to earlier average-case lower bounds [16,17] and the recent data-dependent LSH algorthm [4], this input distribution seems to capture the hardest case for nearest neighbor search and is also a central obstacle to overcome for efficient algorithms. 2 By a simple proof, we show the following lower bound for the average-case cell-probe complexity of ANN in Hamming space with this very natural input distribution. Theorem 1.1. For d ≥ 32 log n and d < no(1), any deterministic or Las Vegas randomized al- gorithm solving (γ, λ)-approximate near-neighbor problem in d-dimensional Hamming space in the cell-probe model with w-bit cells for w < no(1), using a table of size s < 2d, must have expected cell-probe complexity t = Ω(cid:18) γ2 log swγ2 independent input database and query and the random bits of the algorithm. d nd (cid:19), where the expectation is taken over both the uniform and This lower bound matches the highest known worst-case cell-probe lower bounds for any static data structure problems. Such lower bound was only known for polynomial evaluation [13, 19] and also worst-case deterministic ANN due to our previous work [20]. We also prove an average-case cell-probe lower bound for ANN under ℓ∞-distance. The lower bound matches the highest known worst-case lower bound for the problem [2]. In fact, we prove these lower bounds in a unified framework that relates the average-case cell- probe complexity of ANN to isoperimetric inequalities regarding an expansion property of the metric space. Inspired by the notions of metric expansion defined in [17], we define the following notion of expansion for metric space. Let (X, dist) be a metric space. The λ-neighborhood of a point x ∈ X, denoted as Nλ(x) is the set of all points in X within distance λ from x. Consider a distribution µ over X. We say the λ-neighborhoods are weakly independent under distribution µ, if for any point x ∈ X, the measure of the λ-neighborhood µ(Nλ(x)) < β n for a constant β < 1. We say the λ-neighborhoods are (Φ, Ψ)-expanding under distribution µ, if for any point set A ⊆ X with µ(A) ≥ 1 Ψ , where Nλ(A) denotes the set of all points within distance λ from some point in A. Φ , we have µ(Nλ(A)) ≥ 1 − 1 Consider the database y = (y1, y2, . . . , yn) ∈ X n with every point yi sampled independently from µ, and the query x ∈ X sampled independently from µ. We denote this input distribution as µ × µn. We prove the following lower bound. Theorem 1.2. For a metric space (X, dist), assume the followings: • the γλ-neighborhoods are weakly independent under distribution µ; • the λ-neighborhoods are (Φ, Ψ)-expanding under distribution µ. Then any deterministic or Las Vegas randomized algorithm solving (γ, λ)-approximate near-neighbor problem in (X, dist) in the cell-probe model with w-bit cells, using a table of size s, must have expected cell-probe complexity t = Ω log Φ n log Ψ! or log sw w + log s(cid:19) t = Ω(cid:18) n log Ψ under input distribution µ × µn. The key step to prove such a theorem is a stronger version of the richness lemma that we prove in Section 3. The proof of this stronger richness lemma uses an idea called "cell-sampling" introduced by Panigrahy et al. [17] and later refined by Larsen [13]. This new richness lemma as well as this connection between the rectangle-based techniques (such as the richness lemma) and information-theory-based techniques (such as cell-sampling) are of interests by themselves. 3 2 Preliminary Let (X, dist) be a metric space. Let γ ≥ 1 and λ ≥ 0. The (γ, λ)-approximate near-neighbor problem (γ, λ)-ANNn X is defined as follows: A database y = (y1, y2, . . . , yn) ∈ X n of n points from X is preprocessed and stored as a data structure. Upon each query x ∈ X, by accessing the data structure we want to distinguish between the following two cases: (1) there is a point yi in the database such that dist(x, z) ≤ λ; (2) for all points yi in the database we have dist(x, z) > γλ. For all other cases the answer can be arbitrary. More abstractly, given a universe X of queries and a universe Y of all databases, a data structure problem is a function f : X × Y → Z that maps every pair of query x ∈ X and database y ∈ Y to an answer f (x, y) ∈ Z. In our example of (γ, λ)-ANNn X, the query universe is the metric space X, the database universe is the set Y = X n of all tuples of n points from X, and f maps each query x ∈ X and database y ∈ Y to an Boolean answer: f (x, y) = 0 if there is a λ-near neighbor of x in the database y; f (x, y) = 1 if no points in the database y is a γλ-near neighbor of x; and f (x, y) can be arbitrary if otherwise. Note that due to a technical reason, we usually use 1 to indicate the "no near-neighbor" case. Given a data structure problem f : X × Y → Z, a code T : Y → Σs with alphabet Σ = {0, 1}w encodes every database y ∈ Y to a table Ty of s cells with each cell storing a word of w bits. We use [s] = {1, 2, . . . , s} to denote the set of indices of cells. For each i ∈ [s], we use Ty[i] to denote the content of the i-th cell of table Ty; and for S ⊆ [s], we write Ty[S] = (Ty[i])i∈S for the tuple of the contents of the cells in S. Upon each query x ∈ X, a cell-probing algorithm adaptive retrieves the contents of the cells in the table Ty (which is called cell-probes) and outputs the answer f (x, y) at last. Being adaptive means that the cell-probing algorithm is actually a decision tree: In each round of cell-probing the address of the cell to probe next is determined by the query x as well as the contents of the cells probed in previous rounds. Together, this pair of code and decision tree is called a cell-probing scheme. For randomized cell-probing schemes, the cell-probing algorithm takes a sequence of random bits as its internal random coin. In this paper we consider only deterministic or Las Vegas randomized cell-probing algorithms, therefore the algorithm is guaranteed to output a correct answer when it terminates. When a cell-probing scheme is fixed, the size s of the table as well as the length w of each cell are fixed. These two parameters together give the space complexity. And the number of cell-probes may vary for each pair of inputs (x, y) or may be a random variable if the algorithm is randomized. Given a distribution D over X × Y , the average-case cell-probe complexity for the cell-probing scheme is given by the expected number of cell-probes to answer f (x, y) for a (x, y) sampled from D, where the expectation is taken over both the input distribution D and the internal random bits of the cell-probing algorithm. 3 A richness lemma for average-case cell-probe complexity The richness lemma (or the rectangle method) introduced in [15] is a classic tool for proving cell- probe lower bounds. A data structure problem f : X × Y → {0, 1} is a natural communication problem, and a cell-probing scheme can be interpreted as a communication protocol between the cell-probing algorithm and the table, with cell-probes as communications. Given a distribution D over X × Y , a data structure problem f : X × Y → {0, 1} is α-dense 4 under distribution D if ED[f (x, y)] ≥ α. A combinatorial rectangle A × B for A ⊆ X and B ⊆ Y is a monochromatic 1-rectangle in f if f (x, y) = 1 for all (x, y) ∈ A × B. The richness lemma states that if a problem f is dense enough (i.e. being rich in 1's) and is easy to solve by communication, then f contains large monochromatic 1-rectangles. Specifically, if an α-dense problem f can be solved by Alice sending a bits and Bob sending b bits in total, then f contains a monochromatic 1-rectangle of size α · 2−O(a) × α · 2−O(a+b) in the uniform measure. In the cell-probe model with w-bit cells, tables of size s and cell-probe complexity t, it means the monochromatic 1-rectangle is of size α · 2−O(t log s) × α · 2−O(t log s+tw). The cell-probe lower bounds can then be proved by refuting such large 1-rectangles for specific data structure problems f . We prove the following richness lemma for average-case cell-probe complexity. Lemma 3.1. Let µ, ν be distributions over X and Y respectively, and let f : X × Y → {0, 1} be α-dense under the product distribution µ × ν. If there is a deterministic or randomized Las Vegas cell-probing scheme solving f on a table of s cells, each cell containing w bits, with expected t cell-probes under input distribution µ × ν, then for any ∆ ∈(cid:2)32t/α2, s(cid:3), there is a monochromatic 1-rectangle A × B ⊆ X × Y in f such that µ(A) ≥ α ·(cid:0) ∆ Compared to the classic richness lemma, this new lemma has the following advantages: and ν(B) ≥ α · 2−O(∆ ln s s(cid:1)O(t/α2) ∆ +∆w). • It holds for average-case cell-probe complexity. • It gives stronger result even restricted to worst-case complexity. The newly introduced pa- rameter ∆ should not be confused as an overhead caused by the average-case complexity argument, rather, it strengthens the result even for the worst-case lower bounds. When ∆ = t it gives the bound in the classic richness lemma. • The lemma claims the existence of a family of rectangles parameterized by ∆, therefore to prove a cell-probe lower bound it is enough to refute any one rectangle from this family. As we will see, this gives us a power to prove the highest lower bounds (even for the worst case) known to any static data structure problems. The proof of this lemma uses an argument called "cell-sampling" introduced by Panigrahy et al. [16, 17] for approximate nearest neighbor search and later refined by Larsen [13] for polynomial evaluation. Our proof is greatly influenced by Larsen's approach. The rest of this section is dedicated to the proof of this lemma. 3.1 Proof of the average-case richness lemma (Lemma 3.1) By fixing random bits, it is sufficient to consider only deterministic cell-probing algorithms. The high level idea of the proof is simple. Fix a table Ty. A procedure called the "cell-sampling procedure" chooses the subset Γ of ∆ many cells that resolve the maximum amount of positive queries. This associates each database y to a string ω = (Γ, Ty[Γ]), which we call a certificate, where Ty[Γ] = (Ty[i])i∈Γ represent the contents of the cells in Γ. Due to the nature of the cell- probing algorithm, once the certificate is fixed, the set of queries it can resolve is fixed. We also observe that if the density of 1's in the problem f is Ω(1), then there is a Ω(1)-fraction of good databases y such that amount of positive queries resolved by the certificate ω constructed by the cell-sampling procedure is at least an ( ∆ s )O(t)-fraction of all queries. On the other hand, since ∆ +∆w) many certificates ω. Therefore, ω ∈ (cid:0)[s] ∆(cid:1) × {0, 1}∆w there are at most (cid:0) s ∆(cid:1)2∆w = 2O(∆ ln s 5 ∆ +∆w)-fraction of good databases (which is at least 2−O(∆ ln s at least 2−O(∆ ln s ∆ +∆w)-fraction of all databases) are associated with the same ω. Pick this popular certificate ω, the positive queries that ω resolves together with the good databases that ω is associated with form the large monochromatic 1-rectangle. Now we proceed to the formal parts of the proof. Given a database y ∈ Y , let X + y = {x ∈ X to denote the distribution f (x, y) = 1} denote the set of positive queries on y. We use µ+ induced by µ on X + y . y = µX + y Let Pxy ⊆ [s] denote the set of cells probed by the algorithm to resolve query x on database y. Fix a database y ∈ Y . Let Γ ⊆ [s] be a subset of cells. We say a query x ∈ X is resolved by Γ if x can be resolved by probing only cells in Γ on the table storing database y, i.e. if Pxy ⊆ Γ. We denote by X + y (Γ) = {x ∈ X + y Pxy ⊆ Γ} the set of positive queries resolved by Γ on database y. Assume two databases y and y′ are indistinguishable over Γ: meaning that for the tables Ty and Ty′ storing y and y′ respectively, the cell contents Ty[i] = Ty′[i] for all i ∈ Γ. Then due to the determinism of the cell-probing algorithm, we have X + y′ (Γ), i.e. Γ resolve the same set of positive queries on both databases. y (Γ) = X + The cell-sampling procedure: Fix a database y ∈ Y and any ∆ ∈ (cid:2)32t/α2, s(cid:3). Suppose we have a cell-sampling procedure which does the following: The procedure deterministically1 chooses a unique Γ ⊆ [s] such that Γ = ∆ and the measure µ(X + y (Γ)) of positive queries resolved by Γ is maximized (and if there are more than one such Γ, the procedure chooses an arbitrary one of them). We use Γ∗ y to denote this set of cells chosen by the cell-sampling procedure. We also denote by X ∗ y) the set of positive queries resolved by this chosen set of cells. y = X + On each database y, the cell-sampling procedure chooses for us the most informative set Γ of cells of size Γ = ∆ that resolve the maximum amount of positive queries. We use ωy = (Γ∗ y, Ty[Γ∗ y]) to denote the contents (along with addresses) of the cells chosen by the cell-sampling procedure for database y. We call such ωy a certificate chosen by the cell-sampling procedure for y. y (Γ∗ Let y and y′ be two databases. A simple observation is that if two databases y and y′ have the y , X ∗ y′ same certificate ωy = ωy′ chosen by the cell-sampling procedure, then the respective sets X ∗ of positive queries resolved on the certificate are going to be the same as well. Proposition 3.2. For any databases y, y′ ∈ Y , if ωy = ωy′ then X ∗ y = X ∗ y′. Let τ (x, y) = P (x, y) denote the number of cell-probes to resolve query x on database y. By the assumption of the lemma, Eµ×ν[τ (x, y)] ≤ t for the inputs (x, y) sampled from the product distribution µ × ν. We claim that there are many "good" columns (databases) with high density of 1's and low average cell-probe costs. Claim 3.3. There is a collection Ygood ⊆ Y of substantial amount of good databases, such that ν(Ygood) ≥ α 4 and for every y ∈ Ygood, the followings are true: • the amount of positive queries is large: µ(X + y ) ≥ α 2 ; • the average cell-probe complexity among positive queries is bounded: 1Being deterministic here means that the chosen set Γ∗ y is a function of y. E x∼µ+ y [τ (x, y)] ≤ 8t α2 . 6 y ) ≥ α 2 } the set of databases with at least α Proof. The claim is proved by a series of averaging principles. First consider Ydense = {y ∈ Y µ(X + 2 -density of positive queries. By the averaging principle, we have ν(Ydense) ≥ α/2. Since E[τ (x, y)] ≥ ν(Ydense)E[τ (x, y) y ∈ Ydense], we have Eµ×νdense[τ (x, y)] ≤ 2t α , where νdense = νYdense is the distribution induced by ν on Ydense. We then construct Ygood ⊆ Ydense as the set of y ∈ Ydense with average cell-probe complexity bounded as Ex∼µ[τ (x, y)] ≤ 4t 4 . Note that y ) ≤ 8t Ex∼µ[τ (x, y)] ≥ E α2 for all y ∈ Ygood. α . By Markov inequality νdense(Ygood) ≥ 1 x∼µ+ y 2 and hence ν(Ygood) ≥ α [τ (x, y)] ≤ Ex∼µ[τ (x, y)]/µ(X + y ). We have E [τ (x, y)]µ(X + x∼µ+ y For the rest, we consider only these good databases. Fix any ∆ ∈ (cid:2)32t/α2, s(cid:3). We claim that for every good database y ∈ Ygood, the cell-sampling procedure always picks a subset Γ∗ many cells, which can resolve a substantial amount of positive queries: y ⊆ [s] of ∆ Claim 3.4. For every y ∈ Ygood, it holds that µ(X ∗ y ) ≥ α 2s(cid:1)8t/α2 4 (cid:0) ∆ . Proof. Fix any good database y ∈ Ygood. We only need to prove there exists a Γ ⊆ [s] with Γ = ∆ that resolve positive queries µ(X + . The claims follows immediately. y (Γ)) ≥ α We construct a hypergraph H ⊆ 2[s] with vertex set [s] as H = {Pxy x ∈ X + y }, so that each positive queries x ∈ X + y on database y is associated (many-to-one) to a hyperedge e ∈ H such that e = Pxy is precisely the set of cells probed by the cell-probing algorithm to resolve query x on database y. 2s(cid:1)8t/α2 4 (cid:0) ∆ We also define a measure µ over hyperedges e ∈ H as the total measure (in µ+ y ) of the positive queries x associated to e. Formally, for every e ∈ H, µ(e) = Xx∈X + y :Pxy=e µ+ y (x). µ+ y (x) = 1, this µ is a well-defined probability distribution over hyper- Since Pe∈H µ(e) = Px∈X + y edges in H. Moreover, recalling that τ (x, y) = Pxy, the the average size of hyperedges Ee∼µ[e] = E x∼µ+ y [τ (x, y)] ≤ 8t α2 . By the probabilistic method (whose proof is in the full paper [21]), there must exist a Γ ⊆ [s] of size Γ = ∆, such that the sub-hypergraph HΓ induced by Γ has µ(HΓ) ≥ 1 2s(cid:19)8t/α2 2(cid:18) ∆ . By our construction of H, the positive queries associated (many-to-one) to the hyperedges in the induced sub-hypergraph HΓ = {Pxy x ∈ X + y ∧ Pxy ⊆ Γ} are precisely those positive queries in X + y Pxy ⊆ Γ}. Therefore, y (Γ) = {x ∈ X + µ+ y (X + y (Γ)) = Xx∈X + y ,Pxy⊆Γ µ+ y (x) = µ(HΓ) ≥ 1 2s(cid:19)8t/α2 2(cid:18) ∆ . 7 Recall that µ(X + y ) ≥ α 2 for every y ∈ Ygood. And since X + y (Γ) ⊆ X + y , we have µ(X + y (Γ)) = µ+ y (X + y (Γ))µ(X + y ) ≥ α 2s(cid:19)8t/α2 4 (cid:18) ∆ . The claim is proved. Recall that the certificate ωy = (Γ∗ y, Ty[Γ∗ y]) is constructed by the cell-sampling procedure for ν(Ygood) ≥ α 4 . By the averaging principle, the following proposition is natural. good databases y ∈ Ygood with this certificate ωy = ω. Due to the determinism of the cell-sampling database y. For every possible assignment ω ∈(cid:0)[s] ∆(cid:1) × {0, 1}∆w of certificate, let Yω denote the set of procedure, this classifies the Ygood into at most (cid:0) s ∆(cid:1)2∆w many disjointed subclasses Yω. Recall that Proposition 3.5. There exists a certificate ω ∈(cid:0)[s] ∆(cid:1) × {0, 1}∆w, denoted as ω∗, such that 4(cid:0) s ∆(cid:1)2∆w On the other hand, fixed any ω, since all databases y ∈ Yω have the same ω∗ y . We can abuse the notation and write Xω = X ∗ they must have the same X ∗ y, by Proposition 3.2 y for all y ∈ Yω. ν(Yω∗ ) ≥ α . Now we let A = Xω∗ and B = Yω∗ , where ω∗ satisfies Proposition 3.5. Due to Claim 3.4 and Proposition 3.5, we have µ(A) ≥ α 4 (cid:18) ∆ 2s(cid:19)8t/α2 = α ·(cid:18) ∆ s(cid:19)O(t/α2) and ν(B) ≥ = α · 2−O(∆ ln s ∆ +∆w). α 4(cid:0) s ∆(cid:1)2∆w Note for every y ∈ B = Yω∗, the A = Xω∗ = X + A × B is a monochromatic 1-rectangle in f . This finishes the proof of Lemma 3.1. y) is a set of positive queries on database y, thus y (Γ∗ 4 Rectangles in conjunction problems Many natural data structure problems can be expressed as a conjunction of point-wise relations between the query point and database points. Consider data structure problem f : X × Y → {0, 1}. Let Y = Y n, so that each database y ∈ Y is a tuple y = (y1, y2, . . . , yn) of n points from Y. A point-wise function g : X × Y → {0, 1} is given. The data structure problem f is defined as the conjunction of these subproblems: ∀x ∈ X, ∀y = (y1, y2, . . . , yn) ∈ Y, f (x, y) = g(x, yi), n ^i=1 Many natural data structure problems can be defined in this way, for example: • Membership query: X = Y is a finite domain. The point-wise function g(·, ·) is 6= that indicates whether the two points are unequal. • (γ, λ)-approximate near-neighbor (γ, λ)-ANNn X: X = Y is a metric space with distance dist(·, ·). The point-wise function g is defined as: for x, z ∈ X, g(x, z) = 1 if dist(x, z) > γλ, or g(x, z) = 0 if dist(x, z) ≤ λ. The function value can arbitrary for all other cases. 8 • Partial match PMd,n Σ : Σ is an alphabet, Y = Σd and X = (Σ ∪ {⋆})d. The point-wise function g is defined as: for x ∈ X and z ∈ Y, g(x, z) = 1 if there is an i ∈ [d] such that xi 6∈ {⋆, zi}, or g(x, z) = 0 if otherwise. We show that refuting the large rectangles in the point-wise function g can give us lower bounds for the conjunction problem f . Let µ, ν be distributions over X and Y respectively, and let νn be the product distribution on Y = Y n. Let g : X × Y → {0, 1} be a point-wise function and f : X × Y → {0, 1} a data structure problem defined by the conjunction of g as above. Lemma 4.1. For f, g, µ, ν defined as above, assume that there is a deterministic or randomized Las Vegas cell-probing scheme solving f on a table of s cells, each cell containing w bits, with expected t cell-probes under input distribution µ × νn. If the followings are true: • the density of 0's in g is at most β n under distribution µ × ν for some constant β < 1; • g does not contain monochromatic 1-rectangle of measure at least 1 Φ × 1 Ψ under distribution µ × ν; then n log Ψ(cid:19)O(t) (cid:18) sw ≥ Φ or t = Ω(cid:18) n log Ψ w + log s(cid:19) . Proof. By union bound, the density of 0's in f under distribution µ × νn is: y=(y1,...,yn)∼νn " n ^i=1 Pr x∼µ g(x, yi) = 0# ≤ n · Pr x∼µ z∼ν [g(x, z) = 0] ≤ n · β n = β. By Lemma 3.1, the Ω(1)-density of 1's in f and the assumption of existing a cell-probing scheme with parameters s, w and t, altogether imply that for any 4t ≤ ∆ ≤ s, f has a monochromatic 1-rectangle A × B such that µ(A) ≥(cid:18) ∆ s(cid:19)c1t and νn(B) ≥ 2−c2∆(ln s ∆ +w), (1) for some constants c1, c2 > 0 depending only on β. Let C ⊂ Y be the largest set of columns in g to form a 1-rectangle with A. Formally, C = {z ∈ Y ∀x ∈ A, g(x, z) = 1}. Clearly, for any monochromatic 1-rectangle A × D in g, we must have D ⊆ C. By definition of f as a conjunction of g, it must hold that for all y = (y1, y2, . . . , yn) ∈ B, none of yi ∈ y has g(x, yi) = 0 for any x ∈ A, which means B ⊆ C n, and hence νn(B) ≤ νn(C n) = ν(C)n. Recall that A × C is monochromatic 1-rectangle in g. Due to the assumption of the lemma, either µ(A) < 1 Ψ . Therefore, either µ(A) < 1 Φ or νn(B) < 1 Ψn . Φ or ν(C) < 1 9 We can always choose a ∆ such that ∆ = O(cid:16) n log Ψ w (cid:17) and ∆ = Ω(cid:16) n log Ψ w+log s(cid:17) to satisfy 2−c2∆(ln s ∆ +w) > 1 Ψn . If such ∆ is less than 32t/(1 − β)2, then we immediately have a lower bound t = Ω(cid:18) n log Ψ w + log s(cid:19) . Otherwise, due to (1), A × B is monochromatic 1-rectangle in f with νn(B) > 1 must hold that µ(A) < 1 Φ , which by (1) gives us Ψn , therefore it 1 Φ which gives the lower bound > µ(A) ≥(cid:18) ∆ s(cid:19)O(t) n log Ψ(cid:19)O(t) (cid:18) sw =(cid:18) n log Ψ sw (cid:19)O(t) , ≥ Φ. 5 Isoperimetry and ANN lower bounds Given a metric space X with distance dist(·, ·) and λ ≥ 0, we say that two points x, x′ ∈ X are λ-close if dist(x, x′) ≤ λ, and λ-far if otherwise. The λ-neighborhood of a point x ∈ X, denoted by Nλ(x), is the set of all points from X which are λ-close to x. Given a point set A ⊆ X, we define Nλ(A) =Sx∈A Nλ(x) to be the set of all points which are λ-close to some point in A. In [17], a natural notion of metric expansion was introduced. Definition 5.1 (metric expansion [17]). Let X be a metric space and µ a probability distribution over X. Fix any radius λ > 0. Define Φ(δ) , min A⊂X,µ(A)≤δ µ(Nλ(A)) µ(A) . The expansion Φ of the λ-neighborhoods in X under distribution µ is defined as the largest k such that for all δ ≤ 1 2k , Φ(δ) ≥ k. We now introduce a more refined definition of metric expansion using two parameters Φ and Ψ. Definition 5.2 ((Φ, Ψ)-expanding). Let X be a metric space and µ a probability distribution over X. The λ-neighborhoods in X are (Φ, Ψ)-expanding under distributions µ if we have µ(Nλ(A)) ≥ 1 − 1/Ψ for any A ⊆ X that µ(A) ≥ 1/Φ. The metric expansion defined in [17] is actually a special case of (Φ, Ψ)-expanding: The expan- sion of λ-neighborhoods in a metric space X is Φ means the λ-neighborhoods are (Φ, 2)-expanding. The notion of (Φ, Ψ)-expanding allows us to describe a more extremal expanding situation in metric space: The expanding of λ-neighborhoods does not stop at measure 1/2, rather, it can go all the way 10 to be very close to measure 1. This generality may support higher lower bounds for approximate near-neighbor. Given a radius λ > 0 and an approximation ratio γ > 1, recall that the (γ, λ)-approximate near neighbor problem (γ, λ)-ANNn function g : X × X → {0, 1} where g(x, z) = 0 if x is λ-close to z; g(x, z) = 1 if x is γλ-far from z; and g(x, z) is arbitrary for all other cases. Observe that g is actually (γ, λ)-ANN1 X , the point-to-point version of the (γ, λ)-approximate near neighbor. X can be defined as a conjunction f (x, y) = Vi g(x, yi) of point-wise The following proposition gives an intrinsic connection between the expansion of metric space and size of monochromatic rectangle in the point-wise near-neighbor relation. Proposition 5.1. If the λ-neighborhoods in X are (Φ, Ψ)-expanding under distribution µ, then the Φ × 1.01 function g defined as above does not contain a monochromatic 1-rectangle of measure ≥ 1 under distribution µ × µ. Ψ Proof. Since the λ-neighborhoods in X are (Φ, Ψ)-expanding, for any A ⊆ X with µ(A) ≥ 1 have µ(Nλ(A)) ≥ 1 − 1 B ∩ Nλ(A) = ∅, i.e. B ⊆ X \ Nλ(A). Therefore, either µ(A) < 1 1.01 Ψ . Φ , we Ψ . And by definition of g, for any monochromatic A × B, it must hold that Ψ < Φ , or µ(B) = 1 − µ(Nλ(A)) ≤ 1 The above proposition together with Lemma 4.1 immediately gives us the following corollary which reduces lower bounds for near-neighbor problems to the isoperimetric inequalities. Corollary 5.2. Let µ be a distribution over a metric space X. Let λ > 0 and γ ≥ 1. Assume that there is a deterministic or randomized Las Vegas cell-probing scheme solving (γ, λ)-ANNn X on a table of s cells, each cell containing w bits, with expected t cell-probes under input distribution µ × µn. If the followings are true: • Ex∼µ [µ(Nγλ(x))] ≤ β n for a constant β < 1; • the λ-neighborhoods in X are (Φ, Ψ)-expanding under distribution µ; then n log Ψ(cid:19)O(t) (cid:18) sw ≥ Φ or t = Ω(cid:18) n log Ψ w + log s(cid:19) . Remark 5.1. In [17], a lower bound for (γ, λ)-ANNn X was proved with the following form: n (cid:19)t (cid:18) swt ≥ Φ. In our Corollary 5.2, unless the cell-size w is unrealistically large to be comparable to n, the corollary always gives the first lower bound n log Ψ(cid:19)O(t) (cid:18) sw This strictly improves the lower bound in [17]. For example, when the metric space is (cid:0)2Θ(d), 2Θ(d)(cid:1)- expanding, this would give us a lower bound t = Ω(cid:16) d nd(cid:17), which in particular, when the space is linear (sw = O(nd)), becomes t = Ω(d). ≥ Φ. log sw 11 5.1 Lower bound for ANN in Hamming space Let X = {0, 1}d be the Hamming space with Hamming distance dist(·, ·). Recall that Nλ(x) represents the λ-neighborhood around x, in this case, the Hamming ball of radius λ centered at x; and for a set A ⊂ X, the Nλ(A) is the set of all points within distance λ to any point in A. For any 0 ≤ r ≤ d B(r) = Nr(¯0) denote the volume of Hamming ball of radius r, where ¯0 ∈ {0, 1}d is the zero vector. Obviously B(r) =Pk≤r(cid:0)d k(cid:1). The following isoperimetric inequality of Harper is well known. Lemma 5.3 (Harper's theorem [9]). Let X = {0, 1}d be the d-dimensional Hamming space. For A ⊂ X, let r be such that A ≥ B(r). Then for every λ > 0, Nλ(A) ≥ B(r + λ). In words, Hamming balls have the worst vertex expansion. For 0 < r < d 2 , the following upper bound for the volume of Hamming ball is well known: 2(1−o(1))dH(r/d) ≤(cid:18)d r(cid:19) ≤ B(r) ≤ 2dH(r/d), where H(x) = −x log2 x − (1 − x) log2(1 − x) is the Boolean entropy function. Consider the Hamming (γ, λ)-approximate near-neighbor problem (γ, λ)-ANNn X. The hard dis- tribution for this problem is just the uniform and independent distribution: For the database y = (y1, y2, . . . , yn) ∈ X n, each database point yi is sampled uniformly and independently from X = {0, 1}n; and the query point x is sampled uniformly and independently from X. Theorem 5.4. Let d ≥ 32 log n. For any γ ≥ 1, there is a λ > 0 such that if (γ, λ)-ANNn X can be solved by a deterministic or Las Vegas randomized cell-probing scheme on a table of s cells, each cell containing w bits, with expected t cell-probes for uniform and independent database and query, then t = Ω(cid:18) d γ2 log swγ2 nd (cid:19) or t = Ω(cid:16) Proof. Choose λ to satisfy γλ = d going to show: nd γ2(w+log s)(cid:17). 2 −p2d ln(2n). Let µ be uniform distribution over X. We are • Ex∼µ[µ(Nγλ(x))] ≤ 1 2n ; • the λ-neighborhoods in X are (Φ, Ψ)-expanding under distribution µ for some Φ = 2Ω(d/γ2) and Ψ = 2Ω(d/γ2). Then the cell-probe lower bounds follows directly from Corollary 5.2. First, by the Chernoff bound, µ(Nγλ(x)) ≤ 1 2n for any point x ∈ X. Thus trivially Ex∼µ[µ(Nγλ(x))] ≤ 1 2n . On the other hand, for d ≥ 32 log n and n being sufficiently large, it holds that λ ≥ d 2 − d 4γ . Let 8γ . And consider any A ⊆ X with µ(A) ≥ 2−(1−H(r/d))d. We have A ≥ 2dH(r/d) ≥ B(r). r = d Then by Harper's theorem, Nλ(A) ≥ B (r + λ) ≥ B(cid:16) d 2 + d 8γ(cid:17) ≥ 2d − B(cid:16) d 2 − d 8γ(cid:17) = 2d − B(r) ≥ 2d − 2dH(r/d), which means µ(Nλ(A)) ≥ 1 − 2−(1−H(r/d))d. In other words, the λ-neighborhoods in X are (Φ, Ψ)- expanding under distribution µ for Φ = Ψ = 2(1−H(r/d))d, where r/d = 1 8γ . Apparently 1 − H( 1 2 − x) = Θ(x2) for small enough x > 0. Hence, Φ = Ψ = 2Θ(d/γ2). 2 − 1 12 5.2 Lower bound for ANN under L-infinity norm Let Σ = {0, 1, . . . , m} and the metric space is X = Σd with ℓ∞ distance dist(x, y) = kx − yk∞ for any x, y ∈ X. Let µ be the distribution over X as defined in [2]: First define a distribution π over Σ as p(i) = 2−(2ρ)i π(x1)π(x2) . . . π(xd). for all i > 0 and π(0) = 1 −Pi>0 π(i); and then µ is defined as µ(x1, x2, . . . , xd) = The following isoperimetric inequality is proved in [2]. Lemma 5.5 (Lemma 9 of [2]). For any A ⊆ X, it holds that µ(N1(A)) ≥ (µ(A))1/ρ. Consider the (γ, λ)-approximate near-neighbor problem (γ, λ)-ANNn ℓ∞ defined in the metric space X under ℓ∞ distance. The hard distribution for this problem is µ × µn: For the database y = (y1, y2, . . . , yn) ∈ X n, each database point yi is sampled independently according to µ; and the query point x is sampled independently from X according to µ. The following lower bound has been proved in [2] and [12]. Fix any ǫ > 0 and 0 < δ < 1 2 ( ǫ 4 log d)1/c > 10. Now we choose γ = logρ log d and λ = 1. 2 . Assume Ω(cid:0)log1+ǫ n(cid:1) ≤ d ≤ o(n). For 3 < c ≤ O(log log d), define ρ = 1 Theorem 5.6. With d, γ, λ, ρ and the metric space X defined as above, if (γ, λ)-ANNn ℓ∞ can be solved by a deterministic or Las Vegas randomized cell-probing scheme on a table of s cells, each cell containing w ≤ n1−2δ bits, with expected t ≤ ρ cell-probes under input distribution µ × µn, then sw = nΩ(ρ/t). Proof. The followings are true • µ(Nγλ(x)) = e− log1+ǫ/3 n n ≤ 1 2n for any x ∈ X (Claim 6 in [2]); • the λ-neighborhoods in X are (nδρ, nδ nδ −1 )-expanding under distribution µ for Φ = nδρ and Ψ = 2Ω(d/γ2). To see the expansion is true, let Φ = nδρ and Ψ = nδ with µ(A) ≥ Φ, we have µ(Nλ(A)) ≥ n−δ ≥ 1 − 1 (nδρ, nδ nδ −1 )-expanding. nδ −1 . By Lemma 5.5, for any set A ⊂ X Ψ . This means λ-neighborhoods of M are Due to Corollary 5.2, either (cid:0) sw n1−δ(cid:1)O(t) ≥ nδρ or t = Ω(cid:16) n1−δ w+log s(cid:17). The second bound is always higher with our ranges for w and t. The first bound gives sw = nΩ(ρ/t). References [1] Amirali Abdullah and Suresh Venkatasubramanian. A directed isoperimetric inequality with application to bregman near neighbor lower bounds. In STOC'15. [2] Alexandr Andoni, Dorian Croitoru, and Mihai Patra¸scu. Hardness of nearest neighbor under L-infinity. In FOCS'08. [3] Alexandr Andoni, Piotr Indyk, and Mihai Patra¸scu. On the optimality of the dimensionality reduction method. In FOCS'06. 13 [4] Alexandr Andoni and Ilya Razenshteyn. Optimal data-dependent hashing for approximate near neighbors. In STOC'15. [5] Omer Barkol and Yuval Rabani. Tighter lower bounds for nearest neighbor search and related problems in the cell probe model. Journal of Computer and System Sciences, 64(4):873 -- 896, 2002. Conference version in STOC'00. [6] Allan Borodin, Rafail Ostrovsky, and Yuval Rabani. Lower bounds for high dimensional nearest neighbor search and related problems. In Discrete and Computational Geometry, pages 253 -- 274, 2003. Conference version in STOC'99. [7] Amit Chakrabarti, Bernard Chazelle, Benjamin Gum, and Alexey Lvov. A lower bound on the complexity of approximate nearest-neighbor searching on the hamming cube. In Discrete and Computational Geometry, pages 313 -- 328, 2003. Conference version in STOC'99. [8] Amit Chakrabarti and Oded Regev. An optimal randomised cell probe lower bound for ap- proximate nearest neighbour searching. In SIAM Journal on Computing, 39(5):1919 -- 1940,2010. Conference version in FOCS'04. [9] L.H. Harper. Optimal numberings and isoperimetric problems on graphs. Journal of Combi- natorial Theory, 1(3):385 -- 393, 1966. [10] Piotr Indyk. Nearest neighbors in high-dimensional spaces. Handbook of Discrete and Compu- tational Geometry, pages 877 -- 892, 2004. [11] T.S. Jayram, Subhash Khot, Ravi Kumar, and Yuval Rabani. Cell-probe lower bounds for the partial match problem. In Journal of Computer and System Sciences, 69(3):435 -- 447, 2004. Conference version in STOC'03. [12] Michael Kapralov and Rina Panigrahy. NNS lower bounds via metric expansion for ℓ∞ and EMD. In ICALP'12. [13] Kasper Green Larsen. Higher cell probe lower bounds for evaluating polynomials. In FOCS'12. [14] Ding Liu. A strong lower bound for approximate nearest neighbor searching. Information Processing Letters, 92(1):23 -- 29, 2004. [15] Peter Bro Miltersen, Noam Nisan, Shmuel Safra, and Avi Wigderson. On data structures and asymmetric communication complexity. Journal of Computer and System Sciences, 57(1):37 -- 49, 1998. Conference version in STOC'95. [16] Rina Panigrahy, Kunal Talwar, and Udi Wieder. A geometric approach to lower bounds for approximate near-neighbor search and partial match. In FOCS'08. [17] Rina Panigrahy, Kunal Talwar, and Udi Wieder. Lower bounds on near neighbor search via metric expansion. In FOCS'10. [18] Mihai Patra¸scu and Mikkel Thorup. Higher lower bounds for near-neighbor and further rich problems. SIAM Journal on Computing, 39(2):730 -- 741, 2010. Conference version in FOCS'06. 14 [19] Alan Siegel. On universal classes of fast high performance hash functions, their time-space tradeoff, and their applications. In FOCS'89. [20] Yaoyu Wang and Yitong Yin. Certificates in data structures. In ICALP'14. [21] Yitong Yin. Simple average-case lower bounds for approximate near-neighbor from isoperimet- ric inequalities. arXiv preprint arXiv:1602.05391. 15
1907.05391
4
1907
2019-11-06T02:27:31
Walking Randomly, Massively, and Efficiently
[ "cs.DS", "cs.DC" ]
We introduce a set of techniques that allow for efficiently generating many independent random walks in the Massive Parallel Computation (MPC) model with space per machine strongly sublinear in the number of vertices. In this space-per-machine regime, many natural approaches to graph problems struggle to overcome the $\Theta(\log n)$ MPC round complexity barrier. Our techniques enable breaking this barrier for PageRank---one of the most important applications of random walks---even in more challenging directed graphs, and for approximate bipartiteness and expansion testing. In the undirected case, we start our random walks from the stationary distribution, which implies that we approximately know the empirical distribution of their next steps. This allows for preparing continuations of random walks in advance and applying a doubling approach. As a result we can generate multiple random walks of length $l$ in $\Theta(\log l)$ rounds on MPC. Moreover, we show that under the popular 1-vs.-2-Cycles conjecture, this round complexity is asymptotically tight. For directed graphs, our approach stems from our treatment of the PageRank Markov chain. We first compute the PageRank for the undirected version of the input graph and then slowly transition towards the directed case, considering convex combinations of the transition matrices in the process. For PageRank, we achieve the following round complexities for damping factor equal to $1 - \epsilon$: * in $O(\log \log n + \log 1 / \epsilon)$ rounds for undirected graphs (with $\tilde O(m / \epsilon^2)$ total space), * in $\tilde O(\log^2 \log n + \log^2 1/\epsilon)$ rounds for directed graphs (with $\tilde O((m+n^{1+o(1)}) / poly\, \epsilon)$ total space).
cs.DS
cs
Walking Randomly, Massively, and Efficiently Jakub Łącki Slobodan Mitrović Google Research MIT Krzysztof Onak IBM Research Piotr Sankowski University of Warsaw Abstract We introduce a set of techniques that allow for efficiently generating many independent ran- dom walks in the Massive Parallel Computation (MPC) model with space per machine strongly sublinear in the number of vertices. In this space-per-machine regime, many natural approaches to graph problems struggle to overcome the Θ(log n) MPC round complexity barrier. Our tech- niques enable breaking this barrier for PageRank -- one of the most important applications of random walks -- even in more challenging directed graphs, and for approximate bipartiteness and expansion testing. In the undirected case, we start our random walks from the stationary distribution, which implies that we approximately know the empirical distribution of their next steps. This allows for preparing continuations of random walks in advance and applying a doubling approach. As a result we can generate multiple random walks of length l in Θ(log l) rounds on MPC. Moreover, we show that under the popular 1-vs.-2-Cycles conjecture, this round complexity is asymptotically tight. For directed graphs, our approach stems from our treatment of the PageRank Markov chain. We first compute the PageRank for the undirected version of the input graph and then slowly transition towards the directed case, considering convex combinations of the transition matrices in the process. For PageRank, we achieve the following round complexities for damping factor equal to 1− ǫ: • in O(log log n + log 1/ǫ) rounds for undirected graphs (with O(m/ǫ2) total space), • in O(log2 log n + log2 1/ǫ) rounds for directed graphs (with O((m + n1+o(1))/poly ǫ) total space). The round complexity of our result for computing PageRank has only logarithmic dependence on 1/ǫ. We use this to show that our PageRank algorithm can be used to construct directed length-l random walks in O(log2 log n + log2 l) rounds (with O((m + n1+o(1))poly l) total space). Namely, by letting ǫ = Θ(1/l), a length-l PageRank walk with constant probability contains no random jump, and hence is a directed random walk. 9 1 0 2 v o N 6 ] S D . s c [ 4 v 1 9 3 5 0 . 7 0 9 1 : v i X r a 1 Introduction Computing random walks in graphs is a fundamental algorithmic primitive. Random walks find applications in a plethora of computer science research areas. A non-exhaustive list includes optimal PRAM algorithms for connectivity [Rei85, HZ96a, HZ96b], rating web pages [PBMW99, DMPU15], partitioning graphs [ACL06], minimizing query complexity in property testing [GR99, KKR04, CMOS19, CS10, KS11, NS10, CPS15, CKK+18], finding graph matchings [GKK13], generating random spanning trees [KM09], and counting problems [JS96]. Intuitively, computing random walks, especially independent random walks from all vertices, should be highly parallelizable, since random walks are memoryless. However, even if we start a single random walk from each vertex, after a constant number of steps many of the walks may collide in the same vertex. This is especially problematic in directed graphs, since it is not known how to precompute the vertices where many collisions would happen, other than by simulating length-l walks in l steps or computing the l-th power of the transition matrix, which takes quadratic space. The focus of this work is on generating a large number of independent random walks in a parallel setting. For undirected graphs, we take advantage of the fact that the stationary distribution is proportional to vertex degrees and can thus be computed in a trivial way. If the starting points of the random walks are distributed according to the stationary distribution, then after any number of steps the distribution of the endpoints is the same. We exploit this to pre-sample continuations of random walks and recursively stitch them together in order to generate length-l walks in O(log l) parallel rounds. The situation becomes more complicated for directed graphs (or Markov chains such as the one defining PageRank), since we do not know the stationary distribution a priori and hence cannot apply this approach directly. Instead, to compute PageRank, we start from the undirected closure ¯G of the input graph G, for which we can generate random walks, using the ideas described above. We then slowly transition from ¯G to G, and gradually update our approximation of the stationary distribution. Roughly speaking, at each step we consider a convex combination of the transition matrices of ¯G and G. This technique, together with its analysis, is the most important and complex technical contribution of the paper. Another challenge in computing random walks in directed graphs is the fact that the probabilities of some vertices in the stationary distribution π can be as low as O(1/2n). Hence, computing t(v) ∼ π(v) random walks from each vertex v, where t(v) ≥ 1, would result in exponentially many walks. This challenge can be addressed by using the Markov chain that is used to define PageRank. In this Markov chain, each random walk ending at v is either extended with a random outedge of v (with probability 1 − ǫ), or jumps to a random vertex of the graph (with probability ǫ). This small change influences the stationary distribution π significantly, since in the modified graph we have π(v) ≥ ǫ/n for each vertex v. At the same time, by setting ǫ = O(1/l), one can guarantee that each random walk does not make a random jump with constant probability, and is thus a random walk in the original graph. Altogether, our ideas lead to an algorithm for computing length-l random walks in directed graphs in O(log2 log n + log2 l) rounds and an algorithm for PageRank that uses O(log2 log n) rounds. Both these algorithms require total space that is almost linear in the input size (assuming we only compute random walks of length l = poly log n). We show that our algorithms can be implemented in the Massively Parallel Computation (MPC) model, which has been extensively studied by the theory community in the recent years [LMSV11, ANOY14, CŁM+18, ABB+19, BFU18, GGK+18, GU19, Ona18, GKMS18, GLM19, HLL18, ASW19, ASS+18, ACK19, BHH19, GKU19, BDE+19]. We use the most challenging space-per-machine 1 regime of the MPC model, in which the space available on each machine is strongly sublinear in the number of vertices of the graph, i.e., at most n1−Ω(1). This allows for handling large graphs that do not fit onto a single machine, even if they are sparse, which is the case for social networks and the webgraph. 1.1 Our Results We give new algorithms for sampling independent random walks and show that they can be efficiently implemented in the MPC model. For the formal description of the model see Section 2.1. The first result is an algorithm for sampling random walks in undirected graphs. Theorem 1. Let G be an undirected graph and C ≥ 1. Let l be a positive integer such that l = o(S), where S is the available space per machine. There exists an MPC algorithm that samples deg+(v)⌈C ln n⌉ independent random walks of length l starting in v for each vertex v in G. The algorithm runs in O(log l) rounds and uses O(Cml log l log n) total space and strongly sublinear space per machine. If the algorithm has to return only the endpoints of each random walk, the total space complexity can be reduced to O(Cml log n) and l can be arbitrarily large. The algorithm is an imperfect sampler (see Definition 8) that does not fail with probability 1 − n− C 6 +1. Our algorithm assumes that the length of each random walk is at most the space available per machine, which is nγ for γ ∈ (0, 1). We believe this assumption is not limiting, since in applications the most interesting regime, l = no(1), especially l = O(poly log n). One of the main results of this paper is an algorithm for sampling random walks in directed graphs. To the best of our knowledge, this is the first o(l)-round algorithm for sampling length-l independent random walks in any distributed or parallel model, other than the trivial algorithm based on matrix exponentiation, which requires quadratic space. Theorem 2. Let G be a directed graph. Let D and l be positive integers such that l = o(S)/ log3 n, where S is the available space per machine. There exists an MPC algorithm that samples D independent random walks of length l starting in v for each v in G. The algorithm runs in O(log2 log n + log2 l) rounds and uses O(cid:0)m + n1+o(1)l3.5 + Dnl2+o(1)(cid:1) total space and strongly sub- linear space per machine. The algorithm is an imperfect sampler (see Definition 8) that does not fail with probability 1 − O(n−1). We also show that the algorithm for undirected graphs is almost optimal under the 1-vs.-2- Cycles conjecture, which is the most popular conjecture for showing conditional hardness in the MPC model. Theorem 3. Let γ ∈ (0, 1) be a constant. In the MPC model with O(n1−γpoly log n) machines, each having space O(nγ), the following holds. Each algorithm that can sample Θ(log n) independent random walks of length Θ(log4 n) starting at each vertex of the graph requires Ω(log log n) rounds, unless the 1-vs.-2-Cycles conjecture does not hold. By using our random walk sampling primitive, we give an algorithm for computing PageRank in undirected graphs. Theorem 4. Let α ∈ [1/n, 1/4] and ǫ ∈ [log n/o(S), 1], where S is the available space per machine. There exists an MPC algorithm that, with probability at least 1− 5 n2 , computes a (1+α)-approximate PageRank vector in undirected graphs with jumping probability of ǫ in O (log log n + log 1/ǫ) rounds using O(cid:16) m log2 n log log n (cid:17) space. ǫ2α2 2 Our next result is an algorithm for computing PageRank in directed graphs. This is by far the most technically involved part of the paper. In fact, our algorithm for sampling random walks in directed graphs is a corollary from the lemmas that we develop to obtain the following result. Theorem 5. Let G be a directed graph. Let α ∈ [1/n, 1/4] and ǫ ∈ [log3 n/o(S), 1], where S is the available space per machine. There exists an MPC algorithm that, with probability at least 1− O( 1 n ), computes a (1 + α)-approximate ǫ-PageRank vector of G in O(cid:0)log2 log n + log2 1/ǫ(cid:1) rounds, using O(cid:16) m ǫ3.5α2 (cid:17) total space and strongly sublinear space per machine. α2 + n1+o(1) This gives an exponential improvement in the number of rounds with respect to the previously known results [DMPU15]. Recently, it was shown that computing Θ(1)-approximate maximum matching, Θ(1)-approximate minimum vertex cover, and maximal independent set admit Ω(log log n) conditional lower bound on the round complexity in the MPC model [GKU19] in the regime with strongly sublinear space per machine. Hence, obtaining O(poly(log log n))-round algorithms seem to be the new complexity benchmark to reach. Random Walks in PRAM. We show that our algorithm for sampling random walks is generic enough to yield interesting results beyond the MPC model. In particular, we show that it can also be implemented in PRAM. Note that the following theorem gives a nontrivial result whenever l = ω(poly log n). Theorem 6. Let G be a directed graph and 1 ≤ l ≤ n. There exists an NC algorithm that uses O((n + m)1+o(1)) processors and samples one random walk from each vertex of G. All sampled walks are independent. The algorithm is an imperfect sampler (see Definition 8) that fails with probability 1 − O(n−1). We could also formulate a similar theorem for computing PageRank, but an NC algorithm for PageRank is already known, since it can be obtained by simply using power method. Applications to Property Testing. We show how to use our random walk algorithm to ap- proximately test bipartiteness and expansion. Instead of solving the exact version of the problems, we consider relaxed versions of these problems known from property testing. Our algorithms ei- ther show that the graph is close to having a given property or far away from satisfying it. It is unlikely that the exact versions of these problems have o(log n)-round algorithms, due to the 1-vs.-2-Cycles conjecture (see Section 4.4 for conjecture statement). We now sketch the reductions. For testing expansion it suffices to observe that to solve the problem from the 1-vs.-2-Cycles conjecture, it suffices to determine whether the expansion is positive. For bipartiteness testing, we observe that if we start with two cycles and independently replace each edge with a path of length 2 with probability 1/2, then with constant probability, we obtain a graph that has an even number of edges overall, but is not bipartite. This will never occur in this transformation if the input is a single cycle. Hence if we could exactly check if a graph is bipartite, we could distinguish inputs that are a single cycle from those that are a disjoint union of two cycles. • Testing Bipartiteness (Section 7). We show how to use our random walk algorithm for testing bipartiteness. In this promise problem, we are given a graph G on n vertices with m 3 edges and a parameter ǫ ∈ (0, 1). We want to distinguish the case that G is bipartite from the case that at least ǫm edges have to be removed to achieve this property. Our parallel algorithm first reduces the size of the input graph by sampling, and then combines property testing techniques for bipartiteness [GR99, KKR04] with our simulation of random walks. Similar ideas were used in [CFSV16] for the CONGEST model. • Testing Expansion (Section 8). We say that a graph G of maximum degree d is ǫ-far from every α⋆-vertex-expander if it is needed to change (add/remove) more than ǫdn edges of G so that the obtained graph is α⋆-vertex-expander. Our algorithm gets α as its input, and returns Accept if G is an α-vertex-expander, or returns Reject if G is far from being such an expander. The idea of the algorithm is as follows. From each vertex, for O(poly log n) many times we run a pair of "long" random walks. The collision probability of thus generated random walks can be used for approximately testing expansion in O(log log(n/ǫ)) rounds. Our starting point here is the analysis of random walk collision probability, introduced by Czumaj and Sohler [CS10]. 1.2 Previous Research Random walks in the streaming model. The problem of generating random walks was con- sidered in a number of streaming and parallel computation papers. The paper of Sarma, Gollapudi, and Panigrahy [DGP11] introduced multi-pass streaming algorithms for simulating random walks. For a single starting point, they can, for instance, simulate single a length l random walk in O(n) space and O(√l) passes. The paper by Jin [Jin19] gives algorithms for generating a single random walk from a prespecified vertex in one pass. For directed graphs the algorithm requires roughly Θ(nl) space and for undirected graphs Θ(n√l) space. Parallel distributed computation. Bahmani, Chakrabarti, and Xin [BCX11] give an MPC algorithm for constructing length-l random walks in directed graphs. Their algorithm runs in O(log l) rounds, but the walks it generates are not independent. A recent result by Assadi, Sun and Weinstein [ASW19] gives an MPC algorithm for detecting well-connected components in small space per machine and with exponential speed-up over the direct exploration. As a subroutine, the paper presents an algorithm for generating random walks in an undirected regular graph. Note that in regular graphs the stationary distribution is uniform and thus the problem of generating random walks becomes somewhat simpler. Let us also mention that there exist random walk generating algorithms for the distributed CONGEST model [DNPT13]. These algorithms require however a number of rounds that is at least linear in the diameter, which can be Ω(log n) even for expanders. Computing random walks has also been used in PRAM model as a subroutine in algorithms for computing connected components using a near-linear number of processors [KNP99, HZ96a]. However, in both these algorithms random walks starting at different vertices are not independent. PageRank. Since it was introduced in [BP98, PBMW99], the computation of PageRank has been extensively studied in various settings. We refer a reader to [Ber05a, LM04, DSB09] for the early development and theoretical foundations of PageRank. [DGP11] consider PageRank approximation in the streaming setting. As their main result, they show how to compute an l-length random walk in O(√l) passes by using O(n) space. By using this primitive, [DGP11] show how to approximate 4 PageRank for directed graphs in O(M 3/4) passes by using O(nM−1/4) space, where M is the mixing time of the underlying graph. By building on [ALNO07], [DMPU15] studied PageRank in a distributed model of computation. ǫ (cid:17), where For directed graphs, they design a PageRank approximation algorithm that runs in O(cid:16) log n ǫ is the jumping probability, i.e., 1 − ǫ is the damping factor. To achieve this bound, they use the ǫ (cid:17) steps. fact that w.h.p. a random walk from a vertex jumps to a random vertex within O(cid:16) log n Moreover, to estimate PageRank it suffices to count the number of random walks ending at a given vertex while ignoring how those random walks reached at the vertex. The authors of [DMPU15] exploited this observation to show that many PageRank random walks can be simulated in parallel The authors also show how to extend the ideas of [DGP11] and obtain an algorithm for undirected while not over-congesting the network. This approach can be implemented in O(cid:16) log n graphs that approximates PageRank in O(cid:16)√log n ǫ (cid:17) rounds. ǫ (cid:17) MPC rounds. Another line of work considered approximate PageRank in the context of sublinear time algo- rithms, e.g., [CGS04, BP11, BBCT12, BPP18] just to name a few. This research culminated in a result of [BPP18] who show that a PageRank of a given vertex can be approximated by examining only O(cid:0)min{m2/3∆1/3d−2/3, m4/5d−3/5}(cid:1) many vertices/arcs, where ∆ and d are the maximum and the average degree, respectively. It is not clear how to simulate this approach in MPC efficiently for all vertices, in terms of both round and total space complexity. Bahmani, Chakrabarti, and Xin [BCX11] show how to use their result for generating random walks to get a constant additive approximation to Personalized PageRank of each vertex, which can be used to obtain a constant additive approximation to PageRank.1 Note that in the case of PageRank constant additive approximation is a weak guarantee, since an all-zero vector provides a constant additive approximation for all but O(1) vertices. In particular, the algorithm of [BCX11] provides non-zero estimates for only O(log n) vertices. In this paper, we show how to compute a multiplicative approximation of PageRank, and hence provide an estimate for each vertex. We now comment why using random walks generated by the algorithm of [BCX11] would require at least quadratic space to obtain multiplicative approximation to PageRank (assuming a standard approach). To compute a length-l random walk from each vertex, the algorithm of [BCX11] samples O(l) random edges from each vertex. Then, these random edges are used to construct the desired random walks by doubling, that is two walks of length 2i are concatenated to form a walk of length 2i+1. The same random edge sample can be used for multiple walks, which results in the following undesirable behavior. Consider a star-graph with the center being vertex s and use the algorithm of [BCX11] to construct T random walks of length O(l) from each vertex. Let W be the collection of these walks. Each of the walks in W either starts at s or visits s directly after the first step. Since the algorithm samples O(l · T ) edges from s, there exists a set of vertices V ′ of size O(l · T ), such that except for staring vertices, all vertices of all random walks belong to V ′. Hence, for l · T = o(n) there exists a vertex different than s that among the walks of W appears Ω(nT /(l· T )) = Ω(n/l) many times, and also a vertex different than s that appears only T times (but only as the starting vertex of some of the walks). A standard approach to estimating the PageRank of vertex v consists in counting the number of occurrences of v in the endpoints of walks in W . To estimate PageRank, the value of l is set to be O(log n). So, unless T = Ω(n/ log n), there exist two vertices u and v, both different from s, whose 1Compared to PageRank, in the Personalized PageRank of vertex v a random jump is always performed to v. 5 visit counts differ by a super-constant multiplicative factor. However, u and v are symmetric and their PageRanks, both personalized and non-personalized, are equal. 2 Preliminaries In this paper we consider directed multigraphs, that is we allow multiple edges between each pair G(v) and deg−G(v) to denote the of vertices. Let G = (V, E) be a directed multigraph. We use deg+ number of outgoing and incoming edges of v respectively. We also define degG(v) := deg−G(v) + deg+ G(v). The subscript G is often omitted if it is clear from the context. A graph G = (V, E, w) is weighted if w : E → R is a function assigning real weights to the edges. Note that different edges between the same pair of vertices may have different weights. We extend the definitions for unweighted graphs to weighted graphs in a natural way. For a weighted graph G = (V, E, w) and s ∈ R we define s · G (often abbreviated as sG) to be a graph G′ = (V, E, w′), where w′(e) := s · w(e) for each e ∈ E. For two weighted graphs G1 = (V, E1, w1) and G2 = (V, E2, w2), we define G1 + G2 := (V, E1 + E2, w1.w2). Here, E1 + E2 denotes the multiset sum of E1 and E2, i.e., an element of cardinality c1 in E1 and c2 in E2 has cardinality c1 + c2 in the sum. The weights w1.w2 : E1 + E2 → R are defined as (w1.w2)(e) =(w1(e) w2(e) if e ∈ E1, if e ∈ E2. If G1 = (V, E1) and G2 = (V, E2) are unweighted, then G1 + G2 = (V, E1 + E2). The transpose of a graph G = (V, E) is a graph GT = (V, ET ) where ET = {vu uv ∈ E}. A graph is called undirected if it is equal to its transpose. We define the undirected closure of G, denoted by ¯G to be ¯G = G + GT . Note that deg+ ¯G(v) = degG(v). We call a weighted graph G = (V, E, w) stochastic if all edge weights are nonnegative and for each v ∈ V we have Pvx∈E w(vx) = 1.2 Observe that if G1 = (V, E1, w1) and G2 = (V, E2, w2) are stochastic x, y ≥ 0 and x + y = 1, then xG1 + yG2 is stochastic as well. For a stochastic graph G = (V, E, w), we define T (G) : V × V → R to be the transition matrix of G, where T (G)u,v is the total weight of edges uv. For a transition matrix T (G), a stationary distribution is a probability distribution π : V → R, such that π · T (G) = π. Note that the stationary distribution may not be unique. A stationary distribution of a stochastic graph is a stationary distribution of its transition matrix. We say that a vertex v ∈ V is dangling if deg+ G(v) = 0. For an unweighted graph G = (V, E) with no dangling vertices we denote by RW(G) the weighted graph obtained by assigning a weight of 1/ deg+ G(v) to each outgoing edge of v. Note that RW(G) is stochastic. vi = ui+1. The length of a walk is the number of edges it consists of. A walk in a graph G is a sequence of edges u1v1, u2v2, . . . , ukvk, such that for 1 ≤ i < k, For a stochastic graph G = (V, E, w), a random walk in G of length k starting in s ∈ V is a walk W = u1v1, u2v2, . . . , ukvk in G, where s = u1, which is constructed with the following algorithm. For each 1 ≤ i ≤ k, the edge uivi is chosen independently at random among all outgoing edges of ui. The probability of choosing a particular outgoing edge is equal to the edge weight. 2Note that we slightly abuse notation and each outgoing edge of v corresponds to a separate summand, even in the presence of parallel edges. 6 2.1 The MPC Model In this paper we will work with the computational model introduced by Karloff, Suri, and Vassil- vitskii [KSV10] and refined in later works [GSZ11, BKS13, ANOY14]. We call it massively parallel computation (MPC), which is similar to the name in Beame et al. [BKS13]. This model captures main aspects of modern parallel systems, where we have M machines and each of them has S words of space. The total space available on all the machines should not be much higher than the size of the input. In the case of graph algorithms studied here the input is a collection E of edges and each machine receives approximately E/M of them at the very beginning. In MPC model the computation proceeds in rounds. During the round, each machine first processes its local data without communicating with other machines. Then machines exchange messages. When sending a message the machine specifies unique recipient of this message. Moreover, we require that all messages sent and received by each machine in each round fit into local memory of this machine. Hence, their total length of these messages is bounded by S.3 This implies that the total communication of the MPC model is bounded by M · S in each round. The messages put into recipients local space and can be processed by them in the next round. At the end of the computation, machines collectively output the solution, i.e., the solution is formed by the union of the outputs of all the machines. The data output by each machine has to fit in its local memory. Hence again, each machine can output at most S words. Possible Values for S and M . Typically in MPC models, one assumes that S is sublinear in ǫ > 0. the input size N . In such case M ≥ N/S. Formally, one usually considers S = Θ(cid:0)N 1−ǫ(cid:1), for some In this paper, the focus is on graph algorithms. By n we denote the number of vertices in the graph, and m is the number of edges. The input size is O(n + m), where m can be as large as Θ(cid:0)n2(cid:1). The algorithms presented in this paper use total space which is almost linear in the input size, that is M · S = (m + n)1+o(1). The value of S, which is the amount of space available on each machine, is strongly sublinear in the number of vertices in the graph, that is they use O(nγ) space per machine for a constant γ ∈ (0, 1). This range of parameters is the most interesting one due to the popular 1-vs.-2-Cycles conjecture that implies that many graph problems cannot be solved in o(log n) rounds (see Section 4.4). Our algorithms work for any 0 < γ < 1 so for simplicity we omit this parameter in our theorems. However, we specify only the total space that needs to be available on all the M . Communication vs. Computation Complexity. The main complexity measure in this work will be the number of rounds required to finish computation, i.e., communication rounds are typically the most costly component in the MPC computation. Also, even though we do not make an effort to explicitly bound it, it is apparent from the design of our algorithms that every machine performs O(S polylog S) computation steps locally. This in particular implies that the overall work across all the machines is O(r(n + m) polylog n), where r is the number of rounds. The total communication during the computation is O(r(n + m)) words. 3This for instance allows a machine to send a single word to S/100 machines or S/100 words to one machine, but not S/100 words to S/100 machines if S = ω(1), even if the messages are identical. 7 2.2 PageRank Let G be a directed graph and let ǫ ∈ (0, 1). PageRank [BP98] is the stationary distribution of the following Markov chain on the vertices of G. At a given vertex v, with probability ǫ, the next vertex is selected uniformly at random from the set of all vertices of G, and with probability 1 − ǫ, it is selected uniformly at random from the heads of outedges of v. Note that PageRank is unique, because the Markov chain described above is ergodic. 1 − ǫ is called the damping factor. 2.3 Relevant Concentration Bounds Throughout the paper, we will use the following well-known variants of Chernoff bound. Theorem 7 (Chernoff bound). Let X1, . . . , Xk be independent random variables taking values in i=1 Xi and µ def= E [X]. Then, [0, 1]. Let X def= Pk (A) For any δ ∈ [0, 1] it holds P [X − µ ≥ δµ] ≤ 2 exp(cid:0)−δ2µ/3(cid:1). (B) For any δ ∈ [0, 1] it holds P [X ≤ (1 − δ)µ] ≤ exp(cid:0)−δ2µ/2(cid:1). (C) For any δ ∈ [0, 1] it holds P [X ≥ (1 + δ)µ] ≤ exp(cid:0)−δ2µ/3(cid:1). (D) For any δ ≥ 1 it holds P [X ≥ (1 + δ)µ] ≤ exp (−δµ/3). 3 Overview of Our Techniques In order to speed up the generation of a random walk, one may be tempted to generate in parallel its different sections and then stitch them together. This approach becomes challenging with limited space if, for instance, one wants to generate a large number of random walks that all start from the same vertex. Unfortunately, until we know where the walks are after k steps, it is difficult to limit the number of continuations corresponding to the consecutive steps -- k + 1, k + 2, and so on -- that we have to consider. This seems to be an issue that many, if not all, attempts at generating random walks with limited space encounter [DGP11]. However, if starting points of random walks are sampled from the stationary distribution, the distribution after any number of steps is the same. (This observation was previously used by Censor-Hillel et al. [CFSV16] to construct bipartiteness testers in constant-degree graphs for the CONGEST model.) Hence we can sample only slightly more mid-points from the same stationary distribution and recursively generate random walks from them. The key observation is that the stationary distribution in undirected graphs is known in advance, i.e., it is proportional to vertex degrees. This approach enables generating many fully independent random walks of length l from each vertex in Θ(log l) rounds of MPC using space near-linear in the size of the input. We present this idea in detail in Section 4. We also argue that this round complexity is tight under the 1-vs.- 2-Cycles conjecture (see Section 4.4). 3.1 Random Walks and PageRank in Directed Graphs The problem of generating random walks is much more challenging in directed graphs. We do not know a priori a stationary distribution, so it is not possible to directly apply the previous approach. Namely, our sampler for undirected graphs crucially uses the fact that we know the stationary 8 distribution in advance and the probabilities in this distribution are not too small. This is because the number of random walks sampled from each vertex has to be both proportional to the stationary distribution and large enough to obtain concentration guarantees. In general directed graphs these assumptions do not hold. Some vertices in the stationary distribution may have small or even zero probability. One can also show that even an exponential number of samples (i.e., 2Θ(n)) may not be enough to estimate the stationary distribution for some vertices. Hence, even if we knew the stationary distribution π and wanted to compute t(v) random walks from each vertex v, such that t(v) ∼ π and t(v) ≥ 1, we may need to compute exponentially many walks altogether. In fact, in some computational models, there is a known separation between the difficulty of generating random walks for directed and undirected graphs [Jin19]. If the outdegrees in the graph are bounded by poly log n we can use the following simple ap- proach (see Appendix A for a more detailed description). For each vertex v, we find all vertices whose distance from v is at most ǫ log n/ log log n. Once we know this set, we are able to simulate ǫ log n/ log log n steps of a random walk in a single round. At the same time the assumption on the outdegrees allows us to bound the total space usage. This approach does not generalize to the case when the outdegrees are arbitrary or we want to generate random walks of length ω(log n). Instead of dealing with the problem of sampling random walks in directed graphs, we first con- sider the specific case of computing PageRank. The starting point of our approach is the algorithm of [Bre02] that we review in Section 5. At a high level, the algorithm boils down to computing O(log n/ǫ) random walks of length O(log n/ǫ) in a graph Gǫ, which is defined by Gǫ = (1 − ǫ)RW(G) + ǫ n J, where J is complete directed graphs with self loops. In other words, we consider walks that with probability 1 − ǫ perform a single step of a random walk on G, and with probability ǫ jump to a random vertex in G. Note that PageRank is exactly the stationary distribution of Gǫ. Note that in order to make Gǫ well defined, we need to assume that G does not contain dangling vertices, i.e., vertices without outedges. The usual approaches for handling graphs with dangling vertices are discussed in Appendix B. In particular, we show that the two most typical approaches: adding self-loops and restarting the walks, are equivalent up to a simple transformation. To our surprise this relation was not previously observed, e.g., [DCGR05] argues why one method is better than the other. Using Gǫ instead of G for sampling random walks resolves one of the challenges. Namely, we show that in the stationary distribution of Gǫ the probability of each vertex is at least ǫ/n. Hence, by sampling Θ(n log n) random walks we are actually able to approximate the stationary distribution. This observation was already used by Das Sarma et al. [DMPU15] to obtain an O(log n)-round algorithm for directed and O(√log n) round algorithm for undirected graphs. However, we are still left with the other difficulty: we do not know the stationary distribution. We overcome it by using a novel sampling technique, which is the main technical contribution of the paper and may be of independent interest. In the remaining part of this section we give an overview of the technique. The core part of our algorithm is a procedure for adjusting sampling probabilities. Let D1 and D2 be two discrete probability distributions that are, roughly speaking, similar, i.e., the elementary events are assigned similar probabilities in both distributions. The procedure, given a random sample from D1 either produces a sample from D2 or fails. As long as D1 does not differ much from D2, the failure probability is small. We give two implementations of the procedure, each of 9 which is well suited for some specific distributions D1 and D2. The easier implementation is based on rejection sampling. This means that the procedure has the property that it either returns the sample it gets or fails. As a result, the procedure never actually needs to sample from any of the distributions D1 or D2. It actually only needs to make a single Bernoulli trial in order to decide whether to fail. This is a very useful property, as in our case sampling a random walk is much more expensive than doing a Bernoulli trial. Let us now describe our sampling technique using the above idea. Recall that ¯G denotes the undirected closure of G. We note that by using Algorithm 1 we can efficiently sample PageRank walks in ¯G. Hence we are going to first sample PageRank walks in ¯G and then gradually shift towards PageRank walks in G by adjusting transition probabilities. The main technical challenge is to overcome the fact that even small changes to the transition probabilities can cause large changes to stationary distribution. Small changes can be amplified Θ(n) times by the network structure, so that we cannot use stationary distribution computed at one step for sampling walks in the following step even if the difference is very similar. Instead we reinterpret walks directly using the procedure for adjusting sampling probabilities, i.e., in each step we sample slightly more walks and then reinterpret them as walks for modified graph. In this process we lose some fraction of walks. Finally, we use the resulting walks to estimate the stationary distribution for the next step. Let us now describe this idea more formally. Consider a sequence ¯G = G1, G2, . . . , Gk = G of graphs, where, informally speaking, each Gi is a mixture of ¯G and G. (In the algorithm we are going to use k = Θ(1/ log log n).) Formally, Gi = (k − i)/(k − 1) ¯G + (i − 1)/(k − 1)G. Our algorithm computes PageRank walks in Gi for i = 1, . . . , k. The first step is easy: as we In each of the noted above, computing PageRank walks in G1 can be done using Algorithm 1. remaining steps the algorithm starts with PageRank walks in Gi. Then, it uses the procedure for adjusting sampling probabilities to obtain PageRank walks in Gi+1. However, the number of random walks in Gi+1 obtained this way is significantly smaller than the number of walks in Gi that we had at the beginning of the step. Still, the number of walks is large enough to estimate the stationary distribution of PageRank walks in Gi+1. The algorithm then uses this estimated stationary distribution to compute more PageRank walks in Gi+1, which allows the process to continue. Intuitively, the first steps of this process are the most challenging due to potential existence of vertices, whose degrees in G and ¯G differ significantly. As an example, consider a vertex v in G with a single outgoing edge vw and n− 1 incoming edges. A random walk in ¯G of length 1 starting at v (that is, a random edge incident to v) is the edge vw only with probability O(1/n). Hence, the rejection sampling would fail with a very large probability. To alleviate that, we first transform our input graph into a directed graph such that for each vertex v it holds c · deg+(v) ≥ deg(v), where c is a constant that we set later. We call such graphs c-balanced. This transformation is explained in Section 5.2. We show how to compute PageRank of c-balanced graphs in Section 5.1. In the process of transforming an input to a c-balanced graph, each edge is replaced by a path of length log n. This means that a PageRank walk of length k in the input graph corresponds to a PageRank walk of length k log n in the transformed c-balanced one. As a result, informally speaking, PageRank walks in a c-balanced graphs for the jump factor ǫ jump to random vertices more often then the corresponding walks in the original graph. Hence, if we applied the algorithm unchanged to the transformed algorithm, we would effectively compute (ǫ log n)-PageRank walks. 10 A natural idea is to run our algorithm for ǫ′ = ǫ/ log n, but this would increase the round complexity or space usage of our algorithm significantly. Instead, we reuse the idea of gradually adjusting the transition matrix that we use for sampling random walks. We start with a jump factor of 1/2 and then move towards ǫ/ log n in steps, in that way ensuring that the space requirement and round complexity is as desired. This approach is presented in Section 5.3. Once we obtain PageRank walks for a c-balanced graph with respect to jump factor ǫ/ log n, in Section 5.4 we show how to map those walks back to the input graph. Finally, we observe that the algorithm for computing random walks in Gǫ can be used to compute random walks in G. Assume we are interested in random walks of length l. Then, each walk in Gǫ for ǫ = 1/l does not contain any random jumps with constant probability and is thus a random walk in G. Hence, by sampling sufficiently many random walks in G1/l we are able to compute random walks in G. The key property here is that the round complexity of sampling random walks in Gǫ is O(log2(1/ǫ) + log2 log n), so as long as l = poly log n, the overall round complexity is O(poly log log n). 4 Sampling Random Walks In this section we show algorithms for sampling random walks from a given stochastic graph G. The algorithms require that we know (at least approximately) the stationary distribution of G. This is easy in the case when we deal with undirected graphs, that is G = RW(GU ), where GU is an undirected graph. In this case the stationary distribution of G is given by π(v) = deg+ G(v) 2m . (1) Hence, if we sample the starting point of a random walk from from π, then after any number of steps the endpoint will follow distribution π as well. This allows us to use doubling. Since the number of random walks ending in each vertex is (in expectation) the same as the number of random walks starting in each vertex, we can pair up these random walks and stitch together each pair of walks of length k into one walk of length 2k. The pseudocode of our algorithm is given as Algorithm 1. Algorithm 1 Given G, l, t0, . . . , t⌈log l⌉, sample t⌈log l⌉(v) random walks of length l according to T from each v ∈ V (G). 1: function RandomWalks(G, l, t) for all v ∈ V (G) in parallel do 2: Generate t0(v) length 1 random walks in G staring in v. Let W0(v) be the set of these 3: walks. 4: 5: 6: 7: 8: 9: for i ← 1 . . . ⌈log l⌉ do for all v ∈ V in parallel do Select ti(v) random walks from Wi−1(v). Let that set be Ui(v). For each walk w ∈ Ui(v), consider its endpoint u. Ask u to extend w by a yet unused walk from Wi−1(u) \ Ui(u). Let Wi(v) denote the set of all these extended walks originating at v. If u does not have unused walks anymore, the algorithm fails. For each v ∈ V truncate walks in W⌈log l⌉(v) to length l. Return W⌈log l⌉(v) for each v ∈ V 11 The algorithm takes the following parameters. G is the input graph, which has to be stochastic, l is the desired walk length and ti(v) controls the number of walks starting in vertex v that we would like to sample in the i-th iteration of the algorithm. Note that the algorithm requires that ti has certain properties, e.g., for undirected graphs we show that the algorithm works for ti(v) being proportional to deg+ v (G). Also, for a fixed v the sequence t0(v), t1(v), . . . has to fulfill certain properties. In the ideal scenario for each vertex the number of random walks that start and finish in each vertex are equal to the expected value. In such case, in each step we could match all walks into pairs and obtain two times fewer walks of twice the length. However, the numbers may diverge from the expected values and thus we need to sample a bit more random walks to ensure that there are enough of them with high probability. We set ti(v) = deg+ G(v)⌈C log n· ki⌉, whereas the sequence ki controls how many more walks we sample in each step. A simple solution is to set ki = 22⌈log l⌉−2i, which implies that k⌈log l⌉ = 1 and ki = ki−1/4. By doing so, in each step, in expectation we have twice as many walks as we really need, and it is easy to show that the number of walks is sufficient with high probability. For the proof we are going to use fewer walks and thus slightly reduce the space complexity. Observe that if Algorithm 1 never failed, it would have generated independent random walks. However, when many walks collide, i.e., end in the same vertex, the algorithm is forced to fail. This means that we get a random sample from a modified distribution in which the probability of some elements is decreased. This fraction on which the algorithm fails will be very small. We formalize this notion using the following definition. Definition 8. Let (X, p) be a discrete probability space. An imperfect sampler for (X, p) is an algorithm that returns samples from a probability space (X ∪ {fail}, p′), such that p′(x) ≤ p(x) for all x ∈ X. The failure probability of the sampler is p′(fail). We are going to construct samplers where p′(fail) is arbitrarily small. Note that an algorithm A using a (perfect) sampler for a probability space (X, p) can be naturally translated to an algorithm A′ using an imperfect sampler. Unless the sampler fails, A′ produces the same result as A. We now define the sequence ki that we use k0 = 2⌈log l⌉+6 · (⌈log l⌉ + 6) ki−1 = 2ki +pki. The following bounds can be proven for ki. Lemma 9. For 0 ≤ i ≤ ⌈log l⌉ we have (i) ki ≥ 26, (ii) ki ≤ 2⌈log l⌉−i+6 · (⌈log l⌉ + 6). Proof. In order to show (i) we will prove that ki ≥ 2⌈log l⌉−i+6 · (⌈log l⌉ − i + 6). We will show (4) by induction on i. For i = 0, (4) follows by definition of k0. 12 (2) (3) (4) Assume now that kj ≥ 2(⌈log l⌉)−j+6 · (⌈log l⌉ − j + 6) for each j ≤ i − 1, and we want to prove that the inequality holds for j = i as well. Recall that ki−1 = 2ki + √ki. Towards a contradiction, assume that ki < 2⌈log l⌉−i+6 · (⌈log l⌉ − i + 6). For the sake of brevity, define t def= ⌈log l⌉ − i + 6. Then, we have ki−1 = 2ki +pki < 2t+1 · t + √2t · t < 2t+1 · t + 2t < 2t+1 · (t + 1) ≤ ki−1, which is a contradiction. Hence, (4) holds, and (i) follows. As for (ii) we have ki−1 = 2ki +√ki ≥ 2ki. Hence, ki ≤ 2−1ki−1 ≤ 2−ik0 = 2⌈log l⌉−i+6· (⌈log l⌉ + 6). We now show that Algorithm 1 can be used to sample random walks in undirected graphs. The proof is a relatively simple application of Chernoff bound. Lemma 10. Let G be a stochastic graph, such that G = RW(GU ) for some undirected graph GU , l, C ≥ 1, l = o(S), ti(v) = deg+ G(v)⌈C log n · ki⌉, where ki is given by (2) and (3). Then RandomWalks(G, l, t) (Algorithm 1) does not fail with probability at least 1 − n− C Proof. Let X u i be the number of random walks that end at vertex u in iteration i. As long as X u i + ti(u) ≤ ti−1(u) holds for each vertex u, the algorithm does not fail, whereas failure happens when X u i + ti(u) > ti−1(u). Let δi be such that 1 + δi = (ti−1(u) − ti(u))/ti(u). 6 +1. deg+(v) · ⌈C ln n(2ki + √ki)⌉ − deg+(v) · ⌈C ln n · ki⌉ deg+(v)⌈C ln n · ki⌉ 1 + δi = ti−1(u) − ti(u) = ti(u) = ⌈C ln n(2ki + √ki)⌉ − ⌈C ln nki⌉ ⌈C ln nki⌉ = ⌈C ln n(2ki + √ki)⌉ C ln n(2ki + √ki) − 1 ⌈C ln nki⌉ C ln n · √ki − 2 ⌈C ln n · ki⌉ Now, by Chernoff bound, we have ⌈C ln nki⌉ = 1 + − 1 ≥ P [X v i > ti−1(v) − ti(v)] = P [X u ≤ exp(cid:18)− ≤ exp(cid:18)− i > (1 + δi)E [X u i ]] ≤ exp(cid:18)− (C ln n · √ki − 2)2kiC ln n 3⌈C ln n · ki⌉2 3 · 2 (cid:19) = n−C/6. C ln n 3 δ2 (cid:19) i · ti(v) · deg+(v)(cid:19) Where the last inequality follows from the fact that (√x − 2)2x/(x + 1)2 ≥ 1/2 for x ≥ 64. By taking union bound over all vertices and all iterations of the algorithm the probability of failure is less than n− C 6 +1. 13 Lemma 11. Assume that G, l, t, are defined as in Lemma 10. Then RandomWalks(G, l, t) (Algorithm 1) can be implemented to run in O(log l) MPC rounds using O(Cml log l log n) total space. Proof. The space is bounded by max1≤i≤⌈log l⌉ O(cid:0)Pv∈V ti(v) · 2i · ki(cid:1). By Lemma 9 (ii) we have deg+(v) · ⌈C ln n⌉ · 2i · 2⌈log l⌉−i+6 = O(Cml log l ln n). Xv∈V ti(v) · 2i · ki = Xv∈V The MPC implementation is described in Section 4.1. 4.1 MPC Implementation of RandomWalks We now describe how to implement RandomWalks. First, we show how to implement every iteration of the loop on Line 4 in O(1) rounds. Then, we show how to implement Line 2 also in O(1) rounds. We begin by defining primitives NumberingSublists and Predecessor. • NumberingSublists: Given a list L of tuples, let L(x) be the sublist of L containing all the tuples whose first coordinate is x. NumberingSublists assigns distinct numbers 1 through L(x) to the tuples of L(x), for all values x. The numbers are assigned arbitrarily. • Predecessor: Considered an ordered list of tuples such that each tuple is labeled by 0 or by 1. Then, for each tuple t labeled by 0 Predecessor associates the closest tuple t′ labeled by 1 such that t′ comes before t in the ordering. In [BDE+19] was proved that Predecessor can be implemented in O(1) MPC rounds with nδ space per machine, for any constant δ > 0. NumberingSublists in O(1) rounds. Given a list L of tuples, sort all the tuples with respect to their first coordinate. Number by j the j-th tuple in that sorted list; let j(t) be the number of tuple t. Values j(t) can be computed by prefix sums with each tuple having value 1. In [GSZ11] was shown how to find prefix sums in O(1) rounds. Observe that this number would assign consecutive numbers to the tuples of L(x), but not necessarily starting from 1. We now show how to shift these numbers so that the tuples of L(x) are numbered 1 through L(x). Define m(x) = arg mint∈L(x) j(t). Label m(x) by 1, and all other tuples of L(x) label by 0. A tuple t ∈ L(x) is not m(x) if on its machine there is another tuple in L(x) with number smaller than t, or if t has the smallest number on its machine but on the previous machine there is also a tuple from L(x). So, to perform this labeling, it suffices that each machine sends to the next machine its tuple with the highest number. Use Predecessor to assign m(x) to each tuple of L(x). Finally, assign to each tuple t ∈ L(x) value 1 + j(t) − j(m(x)). These values are the assignments that NumberingSublists is supposed to output. Implementation of Line 4 of RandomWalks. Consider the i-th iteration of the loop on Line 4. Assume that so far we have Wi−1 and our goal is to obtain Wi. First, invoke NumberingSublists to number all the walks from each Wi−1(v) with the numbers 1 through Wi−1(v). For each walk w ∈ Wi−1(v), let j(w) be the number assigned to w by NumberingSublists. Create a list of tuples as follows: 14 • If j(w) ≤ ti(v), create a tuple (wlast, j(w), w), where wlast is the last vertex of w. This effectively creates Ui(v). • If j(w) > ti(v), create a tuple (v, j(w) − ti(v), w). This effectively creates Wi−1(v) \ Ui(v). Sort all these created tuples. Now, in this sorted list, next to each other will be tuples (u, z, w1) and (u, z, w2) such that u is the last vertex of w1 and the first vertex of w2. Let v be the first vertex of w1. We append w2 to w1 to obtain a random walk in Wi(v). Since each of these operations requires O(1) rounds, a single iteration of Line 4 can be implemented in O(1) rounds. Implementation of Line 2 of RandomWalks. The loop on Line 2 generates t0(v) random edges incident to v. We implement this step in MPC as follows. First, we create a sorted array of lengthPv∈V t0(v) such that this array contains t0(v) copies of v. Then, each copy of v in this array will be "in charge" of choosing one random edge incident to v. To store this array across machines, we think of the array being partitioned into subarrays of length S′ = Θ(S), where the i-th machine holds subarray i. Next, we explain how to replicate vertex v t0(v) many times. Consider x = (cid:6)Pv∈V t0(v)/S′(cid:7) machines and assume that their IDs are 1 through x. For each vertex v compute X(v) =Pu<v t0(u). For each v, if 1 + X(v) is not divisible by S′, v sends to machine ⌈(1 + X(v))/S′⌉ pair ((1 + X(v)) mod S′, v) and otherwise v sends (S′, v). In addition, to machine x we send Pv∈V t0(v). Intuitively, in our big array this effectively marks the first position where the copies of v begin. After this, each machine labels the received pair (y, v) by 1 and also creates (z,⊥) for each z ∈ {1, . . . , S′} such that the machine did not receive pair (z, u); the exception is for machine x in which z ranges until the last value representing position Pv∈V t0(v). Pairs (z,⊥) are labeled by 0. Within each machine, pairs (z,⊥) and (y, v) are sorted (they are not sorted between the machines). Next, we use Predecessor to associate the closest (y, v) to (z,⊥). After this step, we replace (z,⊥) by (z, v). Then, each pair (z, v) samples a random integers j between 1 and d(v) and creates pair (v, j). Notice that there might be pairs (v, j1) and (v, j2) such that j1 6= j2 or there might be multiples pairs (v, j1). Let J denote the multiset of these pairs across all machines. Now, for each edge {u, v} create two pairs (u, v) and (v, u). By using NumberingSublists, assign numbers 1 through d(v) to pairs {(v, w) w ∈ N (v)}. Let j be the number assigned to (v, w). Create triples (v, j, w). Finally, sort all these triples together with J, where in the ordering triple (v, j, w) comes before a pair (v, j) ∈ I. Label triples by 1 and the pairs of J by 0. Use Predecessor to assign a triple to each pair from J. If triple (v, j, w) is associated to a pair (v, j), then add (v, w) to W0(v). This concludes the implementation of Line 2. 4.2 Sampling Endpoints In this section we show that if we only need to find the endpoint of each random walk, then the space usage of Algorithm 1 can be improved. Actually, this will be the case for some of our applications. In order to reduce the space requirement we observe that Algorithm 1 only looks on endpoints of the sampled walks. Hence, we do not need to store internal vertices of the walks in the algorithm. This alone does not suffice to improve the space usage, as the first iteration, which samples random walks of length 1, still achieves the peak space usage (and clearly does not benefit from not storing the internal vertices of the random walks). However, we can first sample random walks of length roughly log log l using a simple simulation taking O(log log l) steps and after that continue similarly 15 to Algorithm 1. Another benefit of the algorithm is that since it does not store the entire walks, the walks that it produces can be arbitrarily long, i.e., their length is not bounded by the space available on each machine. For simplicity of presentation in this section we assume that l is a power of 2. The new algorithm is given as Algorithm 2. Algorithm 2 Given G, l, t1, . . . , t⌈log l⌉, sample t⌈log l⌉(v) endpoints of random walks of length l in G each v ∈ V (G). 1: function RandomWalkEndpoints(G, l, t) 2: for all v ∈ V in parallel do Perform t⌈log log l⌉(v) length 2⌈log log l⌉ random walks in G starting at v. Let W⌈log log l⌉(v) be the set of endpoints of these walks. Randomly select ti(v) elements from Wi−1(v). Let that set be Ui(v). For vertex w ∈ Ui(v) take yet unused element from Wi−1(u)\Ui(u). Let Wi(v) denote the set of all these elements. If u does not have unused elements, the algorithm fails. 3: 4: 5: 6: 7: 8: 9: for i ← ⌈log log l⌉ + 1 . . . log l do for all v ∈ V in parallel do Return Wlog l(v) for each v ∈ V Lemma 12. Let G be a stochastic graph, such that G = RW(GU ) for some undirected graph GU , l, C ≥ 1, t(v) = deg+ (Algorithm 2) does not fail with probability at least 1 − n− C G(v)⌈C log n⌉ and ki be given by (2) and (3). Then RandomWalkEndpoints(G, l, t) 6 +1. Proof. The proof is almost identical to the proof of Lemma 10. It suffices to observe that the first loop of RandomWalkEndpoints effectively replaces the first ⌈log log l⌉ iterations of the loop in Algorithm 1 by a procedure that does not fail. Lemma 13. Assume that G, l, t are defined as in Lemma 12. Then RandomWalkEndpoints (Algorithm 2) requires O(log l) rounds and O(Cml log n) total space. Proof. The space is bounded by O(cid:0)Pv∈V t⌈log log l⌉(v)(cid:1) and we have t⌈log log l⌉(v) = Xv∈V deg+(v) · ⌈C ln n⌉⌈k⌈log log l⌉⌉ Xv∈V (C + 1)m ln n · 2⌈log l⌉−⌈log log l⌉+6 · (⌈log l⌉ + 6) (C + 1)m ln n · (⌈log l⌉ + 6) 2⌈log l⌉ log l O(Cml ln n). by Lemma 9 (ii) ≤ ≤ = By combining Lemmas 10 to 13 we obtain the first result of the paper. Theorem 1. Let G be an undirected graph and C ≥ 1. Let l be a positive integer such that l = o(S), where S is the available space per machine. There exists an MPC algorithm that samples 16 deg+(v)⌈C ln n⌉ independent random walks of length l starting in v for each vertex v in G. The algorithm runs in O(log l) rounds and uses O(Cml log l log n) total space and strongly sublinear space per machine. If the algorithm has to return only the endpoints of each random walk, the total space complexity can be reduced to O(Cml log n) and l can be arbitrarily large. The algorithm is an imperfect sampler (see Definition 8) that does not fail with probability 1 − n− C 6 +1. 4.3 Sampling Random Walks Given Approximate π While computing the stationary distribution π is easy for undirected graphs, the problem is signifi- cantly more involved if we consider directed graphs. In this section we show how to use Algorithm 1 to sample random walks in a directed graph given an approximation π of π. Our approach would also require that π = Ω(1/n). In Section 5 we show how to use this sampling procedure for computing PageRank and for sampling random walks in directed graphs. As the first step, in the next lemma we show that if π and π are close, then taking a 1-step random walks starting from π results in a distribution that also is also close to π. Lemma 14. Let G be a stochastic graph and T = T (G). Let π be the stationary distribution for matrix T and let π ∈ RV be an arbitrary vector. Then, the following holds: (A) If π(v) − π(v) ≤ απ(v) for all v ∈ V , then (T π)(v) − π(v) ≤ απ(v) for all v ∈ V . (B) If π(v) − π(v) ≤ α for all v ∈ V , then (T π)(v) − π(v) ≤ α for all v ∈ V . Proof. We prove each of the claims separately. Claim (A). Let ∆ = π − π. The statement implies that ∆(v) ≤ απ(v). Now we have Therefore, T π = T (π + ∆) = π + T ∆. (T π)(v) − π(v) = (T ∆)(v). Let Tv be the v-th row-vector of T . Hence, (T ∆)(v) = Tv∆. We next obtain Tv∆ ≤ Xu∈V Tv,u∆(u) ≤ αXu∈V Tv,uπ(u). Using the fact that the entries of T and of π are non-negative, from the last chain of inequalities we derive Tv∆ ≤ αXu∈V Tv,uπ(u) = αTvπ = απ(v), as desired. Claim (B). Similarly as above define ∆ = π − π, so T π = π + T ∆. Moreover, ∆(v) ≤ α, so (T π)(v) − π(v) = (T ∆)(v) = Tv∆ ≤ Xu∈V Tv,u∆(u) ≤ αTv ≤ α. 17 Note that Algorithm 1 is parameterized by G, l, t and in particular it does not take stationary distribution as an argument. Instead, the stationary distribution which is encoded in t. To define t in our earlier analysis of RandomWalks we used ki defined by (2) and (3). Intuitively, ki defines the overhead of the number of random walks that we have to sample from each vertex so that the algorithm has sufficiently many random walks for the next iteration of doubling. When we do not have access to the exact value of π, but instead to its (1 + α)-approximation, we have to use larger values of ki to accommodate that approximation. So, for 1 ≤ i ≤ ⌈log l⌉, we define ki = (2 + 4α)⌈log l⌉−i. (5) Comparison between (5) and (3). Note that for α = 0 the value of ki given by (5) does not equal to the one given by (3). We made such choice so to simplify the expression of ki when we have access to only an approximation of π. As a consequence of definition (5), the space requirement in our analysis depends on 1/α, which can be very large for small values of α. Nevertheless, if π is a (1 + α)-approximation of π, then π is also a (1 + α′)-approximation for any α′ ≥ α. Hence, and without loss of generality, we can assume that α ≥ 1/ log n. We are now ready to analyze properties of RandomWalks when it has access to only an approximation of π. Lemma 15. Let G be a stochastic graph. Let π be the stationary distribution of G, and ǫ be such that π(v) ≥ ǫ/n for all v. Let l, C ≥ 1 and l = o(S). Finally, let α ∈ (0, 1/4] be a parameter, and let π be a probability distribution on V such that π(v) − π(v) ≤ απ(v) for all v. Define ki as in (5) and ti(v) = ⌈C π(v)n ln n · ki⌉. Then, RandomWalks (G, l, t) (Algorithm 1) has the following properties: (i) The algorithm is an imperfect sampler (see Definition 8) for generating ⌈C π(v)n ln n⌉ length l 3 +2e2. random walks starting from each vertex v ∈ V . The failure probability is at most n− Cαǫ (ii) The algorithm can be executed in O(log l) MPC rounds. Proof. Property (ii) follows by Lemma 11. Property (iii) follows from the fact that the space requirement is dominated by the first iteration of RandomWalks. Hence, as k0 = (2 + 4α)⌈log l⌉, (iii) The space requirement of the algorithm is O(cid:0)m + Cl1+2αn ln n(cid:1). the space requirement is O(cid:0)m + C(2 + 4α)log ln ln n(cid:1) = O(cid:0)m + Cl1+2αn ln n(cid:1). Property (i). At the end of i-th step of Algorithm 1, ti(v) denotes the number of random walks of length 2i−1 that originate at vertex v. At step i, each vertex v doubles ti(v) walks arbitrarily chosen from Wi−1(v). Let X u i be the number of these random walks ending at vertex u. Note that X u i,j equals 1 iff the j-th selected random walk of i Wi−1(v) ends at u. Let T = T (G) be the transition matrix of G. From Lemma 14, and as T π = π, we have is a sum of 0/1 random variables Y v i,j, where Y v (T jti)(u) = (T j−1(T ti))(u) ≤ (T j−1(T (C πkin log n + ~1)))(u) ≤ (1 + α)Cπ(u)kin log n + 1. (6) 18 Using this upper-bound, we further derive E [X u i ] − ti(u) ≤ = ≤ ≤ ≤ from (6) i ] − C π(u)kin ln n + 1 E [X u (T (2i−1)ti)(u) − C π(u)kin log n + 1 (T (2i−1)ti)(u) − C(1 − α)π(u)kin ln n + 1 (1 + α)Cπ(u)kin ln n − C(1 − α)π(u)kin ln n + 2 2αCπ(u)kin ln n + 2. (7) As long as X u i ≤ ti−1(u) − ti(u) holds for each vertex u, a vertex u is able to (1) extend all i random walks that ended at u, and (2) double the length of ti(u) random walks from Ui(u) the X u staring in u. We have ti−1(u) − ti(u) = = = ≥ ≥ ≥ ≥ ≥ from (7) from α ≤ 1/4 ⌈C π(u)ki−1 · n ln n⌉ − ⌈C π(u)ki · n ln n⌉ ⌈C π(u) · (2 + 2α)ki · n ln n⌉ − ⌈C π(u)ki · n ln n⌉ ⌈2αC π(u)ki · n ln n − 2⌉ + 2⌈C π(u)ki · n ln n⌉ − ⌈C π(u)ki · n ln n⌉ 4αC π(u)ki · n ln n − 2 + ti(u) 4α(1 − α)Cπ(u)ki · n ln n − 2 + ti(u) (2α − 4α2)Cπ(u)ki · n ln n − 4 + E [X u i ] αCπ(u)ki · n ln n − 4 + E [X u i ] αCǫki · ln n − 4 + E [X u i ] , where the last inequality follows from our assumption that π(u) ≥ ǫ/n. Now, by Chernoff bound, it holds i > E [X u i ] + αCǫki · ln n − 4] P [X u i > ti−1(u) − ti(u)] ≤ P [X u ≤ exp(cid:18)− ≤ exp(cid:18)− αCǫki · ln n − 4 3 (cid:19) αCǫ 3 ln n(cid:19)e2 = n− αCǫ 3 e2. By taking union bound over all vertices and all rounds of the algorithm the probability of failure is less than n− Cαǫ 3 +2e2. 4.4 Lower Bound In this section we show that our algorithm for sampling random walks in undirected graphs is con- ditionally optimal under the popular 1-vs.-2-Cycles conjecture [BKS13, RVW18]. The conjecture states that any algorithm in the MPC model which distinguishes between a graph being a cycle of length n from a graph consisting of two cycles of length n/2, and uses O(nγ) space per machine and O(n1−γ) machines requires Ω(log n) rounds. 19 Theorem 3. Let γ ∈ (0, 1) be a constant. In the MPC model with O(n1−γpoly log n) machines, each having space O(nγ), the following holds. Each algorithm that can sample Θ(log n) independent random walks of length Θ(log4 n) starting at each vertex of the graph requires Ω(log log n) rounds, unless the 1-vs.-2-Cycles conjecture does not hold. The proof is based on the fact that by running Θ(log n) random walks of length Θ(log4 n) from a vertex v one discovers Θ(log2 n) nearest vertices to v with high probability. This property follows from the following well known lemma. Lemma 16. Let t > 1 be an even integer and X1, . . . , Xt be a sequence of i.i.d random variables, i=1 Xi. Then, P (X ≥ √t/2) = Ω(1). such that P (Xi = 1) = P (Xi = −1) = 1/2. Let X =Pt Proof. (X−t)/2 follows a binomial distribution with p = 1/2. Hence, the mode of the distribution of t/2(cid:1)(1/2)t ≤ c/√t, X is 0, that is for every integer i, P (X = 0) ≥ P (X = i). Moreover, P (X = 0) =(cid:0) t for some constant c where the inequality follows from Stirling's approximation. Hence, P (X ≥ √t/(2c)) ≥ 1 −P⌈√t/(2c)⌉ P (X = 0) ≥ 1 − (√t/(2c) + 3)c/√t = 1 − 1/2 + 3c/√t = Ω(1). P (X = i) ≥ 1 −P⌈√t/(2c)⌉ i=−⌈√t/(2c)⌉ i=−⌈√t/(2c)⌉ Proof of Theorem 3. Let us assume that there exists an algorithm which samples Θ(log n) indepen- dent random walks of length Θ(log4 n) starting at each vertex and takes f (n) = o(log log n) rounds. Note that we allow the algorithm to use total space that is poly log n factor more than the size of the graph (otherwise storing the output would not be possible). We will use it to solve the problem from the problem from the 1-vs.-2-Cycles conjecture more efficiently. We begin by dealing with the following technical difficulty. The 1-vs.-2-Cycles conjecture considers a setting, in which the total space is linear in the graph size. Thus, we first show an algorithm that in O(poly log log n) rounds shrinks the length of each cycle by a constant factor with probability 1 − n−d, where the constant d can be made arbitrarily large. The algorithm samples a random bit Xv for each vertex v. Then, for each tree vertices a, b, c which are adjacent on the cycle (or cycles), if Xa = Xc = 0 and Xb = 1, we connect a and c with an edge and remove b from the graph. It is easy to see that this indeed shrinks each cycle by a constant factor with probability at least 1 − n−d, as long as the length of each cycle is ω(d log n). By running this algorithm O(log log n) times, we can shrink each cycle by a factor of Ω(poly log n). We obtain a graph having n′ = O(n/poly log n) vertices and edges, so from now on we can afford to use an algorithm whose total space usage is O(n′poly log n′), since n′poly log n′ = O(n). We now show how to use random walks to shrink the cycles further, namely shrink them by a factor of Ω(log n) in f (n) rounds. Let us sample each vertex independently with probability 1/ log n. With probability at least 1 − n−d among every Ω(log2 n) consecutive vertices along each cycle at least one vertex is sampled. Our goal is to use random walks to contract the graph to the set of sampled vertices. To that end, we run Θ(log n) random walks of length Θ(log4 n) from each vertex and show that with high probability for each pair of consecutive sampled vertices on the cycle, there exists at least one random walks which visits both of them. Consider a sampled vertex. We show that with high probability, random walks starting at this vertex visits the two neighboring sampled vertices along the cycle. Indeed, since we have sample Θ(log n) random walks per vertex, it suffices to show that each random walk visits one of the neighboring vertices with constant probability. This in turn follows from the fact that with constant probability, a random walk on a line of length Ω(t) ends in some vertex at distance √t with constant probability (see Lemma 16). 20 As a result, in f (n) rounds we are able to contract each cycle to the set of sampled vertices, whose size is clearly O(n/ log n) with high probability. By repeating this step Θ(log n/ log log n) times, we can reduce the total number of vertices to o(nγ), at which point the remaining graph can be sent to one machine to check whether it is a cycle or two cycles. The total number of rounds is Θ(log n/ log log n)f (n) = o(log n). 5 PageRank In this section we show MPC algorithms for computing PageRank both in undirected and directed graphs, that is we prove Theorem 4 and Theorem 5. As an easy corollary we obtain an algorithm for sampling random walks in directed graphs (Theorem 2). We are going to use the following most basic algorithm for estimating PageRank using random walks. Let 0 ≤ ǫ ≤ 1 be a parameter. We are going to sample random walks form a stochastic graph Gǫ = (1 − ǫ)G + ǫ n J, (8) where J is a complete directed graph on the vertex set V (G) (containing a self loop in every vertex). In other words, with probability ǫ we jump to a random vertex, and with probability 1 − ǫ we walk according to edges of G. Definition 17 (Jump transition). Let Gǫ be the stochastic graph defined by (8). Then, jump transition refers to the transition performed within the graph J. Consider the transition matrix Tǫ = T (Gǫ). The stationary distribution πǫ of Tǫ satisfies Tǫπǫ = πǫ, which implies the following equation (I − (1 − ǫ)T (G)) πǫ = ~1. ǫ n The crucial property of πǫ is that the probabilities of ending in a given vertex do not decrease much relatively to decrease of ǫ, as shown by the following lemma. Lemma 18. For any 0 < δ ≤ 1 we have where inequality is taken over all coordinates. This result follows from the Taylor expansion of πǫ πǫ·δ ≥ δ · πǫ, Proof. Using Eq. (9) we get πǫ = ǫ n ∞ Xi=0 ((1 − ǫ)T (G))i~1. πǫ·δ = ∞ ((1 − ǫδ)T (G))i~1 = δ ǫ ǫ · δ Xi=0 n (1 − ǫ)iT (G)i~1! = δ ǫ ≥ δ ǫ Xi=0 ∞ n ∞ (1 − ǫδ)iT (G)i~1! Xi=0 ((1 − ǫ)T (G))i~1! = δ · πǫ. Xi=0 ∞ n n 21 (9) (10) (11) The next follows from the observations that π1(v) = 1 n . Corollary 19. For any 0 < ǫ ≤ 1 and any v ∈ V we have πǫ(v) ≥ ǫ n . The Taylor expansion Eq. (9) suggests the following algorithm for estimating PageRank (see e.g., [Bre02]). Algorithm 3 An algorithm for approximating the PageRank with damping factor 1 − ǫ by using a set of random walks W . 1: function StationaryDistribution(W, ǫ) 2: for all v ∈ V in parallel do Remove from W all but K =(cid:6) 9 ln n Truncate each walk in W just before the first jump transition (see Definition 17). for all v ∈ V in parallel do ǫα2 (cid:7) walks starting in v. If W does not contain enough walks, then "fail". Let nv be the number of the walks from W ending in v. π(v) ← nv Kn . Return π 3: 4: 5: 6: 7: 8: Algorithm 4 An algorithm for approximating PageRank using random walks. 1: Sample a set W of K = (cid:6) 9 ln n (cid:6) 9 ln n ǫ (cid:7). 2: Return StationaryDistribution (W, ǫ) ǫα2 (cid:7) random walks starting from each vertex of Gǫ of length l = Lemma 20. Let ǫ ≤ 1 and assume we mark each edge of a walk of length l = ⌈ 9 ln n with probability ǫ. The probability that no edge is marked is less than 1 Proof. (1 − ǫ)l ≤ (1 − ǫ)9 ln n ǫ ≤ e−9 ln n = 1 n9 . n9 . ǫ ⌉ independently Let us prove the approximation ratio obtained by Algorithm 4. Note that the lower bounds for α and ǫ are not limiting, since the interesting values for both parameters are constant. Lemma 21. Let α ∈ [1/n, 1/4], ǫ ∈ [1/n, 1], and 0 < α < 1. Denote by π the output of Algorithm 4. Then, πǫ(v)− πǫ(v) ≤ απǫ(v) for all v ∈ V (i.e., π is (1 + α)-approximation of πǫ) with probability at least 1 − 4 n2 . Proof. The probability that some walk is not truncated by Lemma 20 is 1 n9 , as jump transition happens with probability ǫ. Hence, by union bound over nK ≤ 10n5 walks some walk is not truncated with probability at most 10 Observe that nv is a sum of nK 0, 1-random variables. Moreover, its expectation by Corollary 19 n5 ≤ 2 n2 . is E [nv] ≥ ǫ n · nK = ǫK, so by Chernoff bound (see Theorem 7(A)) Pr [nv − E [nv] ≤ αE [nv]] ≤ 2 exp(cid:18)− α2E [nv] 3 α2ǫK 3 (cid:19) (cid:19) ≤ 2 exp(cid:18)− 2 n3 . ≤ 2 exp (−3 ln(n)) = 22 Again, by union bound over all n vertices some estimate is incorrect with probability at most 2 n2 . Hence, the total probability of failure is 4 n2 . StationaryDistribution also has an efficient MPC implementation. Lemma 22. StationaryDistribution (Algorithm 3) can be implemented in O(1) MPC rounds. Proof. To implement Line 2, we invoke NumberingSublists on the walks from W ; the numbering (See Section 4.1 for details about of walks is performed with respect to their starting vertices. NumberingSublists.) Those walks that get number larger than K are removed. This can be implemented in O(1) rounds. Line 4 is performed without additional communication. To simulate the loop on Line 5, on the remaining walks we again invoke NumberingSublists, but this time we perform numbering of the walks with respect to their ending vertices. For each vertex v, we calculate the maximum among those numbers. That maximum value equals nv. These operations can be performed in O(1) rounds. Theorem 4. Let α ∈ [1/n, 1/4] and ǫ ∈ [log n/o(S), 1], where S is the available space per machine. There exists an MPC algorithm that, with probability at least 1− 5 n2 , computes a (1+α)-approximate PageRank vector in undirected graphs with jumping probability of ǫ in O (log log n + log 1/ǫ) rounds using O(cid:16) m log2 n log log n Proof. We set K = (cid:6) 9 ln n Space requirement. By Lemma 11 we require O(Cml log l log n) = O(cid:16) m log2 n log log n (cid:17) space. ǫδ2 (cid:7), l = (cid:6) 9 ln n ǫα2 . We first execute Algorithm 1 with C and l. ǫ2α2 (cid:17) total space. ǫ2α2 Next, we give sampled walks to Algorithm 4 with K and l. ǫ (cid:7) and C = 6 Round complexity. By Lemmas 11 and 22 we require O(log l) = O(log log n + log 1/ǫ) rounds. 3 +3 = n− 2 Success probability. On one hand, by Theorem 1 the algorithm fails with probability at most n− C ǫα2 +3 ≤ n−32+3 = n−29. On the other hand, by Lemma 21 we obtain (1 + α)- approximation of π with probability at least 1 − 4 n2 . Hence, the final success probability is at least 1 − 5 n2 . 5.1 Directed Balanced Graphs The first step towards our algorithm for directed graphs is considering balanced directed graphs. A directed graph G is called c-balanced when for all v ∈ V we have c deg+(v) ≥ deg(v). In particular in c-balanced graphs there are no dangling vertices, i.e., vertices that do not have any out edge. The idea is to first consider ¯G -- the undirected closure of G. In ¯G we can compute long walks fast and then gradually move towards directed graph G. The c-balanced property allows as to argue that each edge from a random walk in ¯G is with probability at least 1/c directed according to G, enabling us to prove the following result. 23 Theorem 23. let G be a c-balanced graph. Let α ∈ [1/n, 1/4], ǫ ∈ [log n/o(S), 1], and δ ∈ (0, 1] such that δ−1 ∈ N. There exists an MPC algorithm that with probability at least 1 − 12 δn2 com- putes (1 + α)-approximate ǫ-PageRank vector of G in O(cid:0)δ−1(log log n + log 1/ǫ)(cid:1) rounds using O(cid:16) m ln2 n ln ln n ǫ3.5·α2 (cid:17) total space and strongly sublinear space per machine. For this we need few more definitions. We are going to sample random walks from the stochastic + n18 cδ ǫ n ln2.5 n ǫ2α2 graph defined as follows Gǫ,σ = (1 − ǫ)σRW( ¯G) + (1 − ǫ)(1 − σ)RW(G) + ǫ n J. (12) We denote by πǫ,σ the stationary distribution of Gǫ,σ. In our algorithms we will be using Gǫ,σ, but the graph corresponding to J will be constructed only implicitly. That is, instead of constructing graph J explicitly, which contains n2 edges, each vertex v of Gǫ,σ will hold a value ǫ/n implying that v has an edge of weight ǫ/n to each vertex. We also note that Gǫ,σ can be constructed in O(1) MPC rounds. Namely, we first broadcast ǫ and σ to each machine, which can be done in O(1) rounds as described in [GSZ11]. Then, each edge is copied and annotated so to construct (1 − ǫ)σRW( ¯G) + (1 − ǫ)(1 − σ)RW(G). Finally, each vertex is annotated by ǫ which, as described, suffices to implicitly construct ǫ n J. Observation 24. A stochastic graph as defined by (12) can be implicitly constructed in O(1) MPC rounds. We now define three transition types that capture different components of stochastic graphs. Definition 25 (Transition types). Let Gǫ,σ be the stochastic graph as defined by (12). Each edge of Gǫ,σ originates from one of the graphs G, ¯G and J. We call an edge of Gǫ,σ a • directed transition, if it originates from G, and • undirected transition, if it originates from ¯G, and • jump transition, if it originates from J. In the following we assume that each edge of each walk in Gǫ,σ has its edges labeled with the transition types defined above. In the main algorithm of this section (see Algorithm 5), we start from σ = 1 and then gradually decrease the value to obtain σ = 0. This sequence is defined as σj+1 = σj − δ, for 1 ≤ j ≤ δ−1. (We will set δ so that δ−1 is an integer.) We now state the main algorithm of this section. It uses RandomWalks (Algorithm 1) as a subroutine. 5.1.1 Algorithms We now describe our algorithms used to compute approximate PageRank for c-balanced graphs. The main algorithm is PageRankOfBalancedGraphs (see Algorithm 5) that essentially repeats Algorithm 4 (see the steps within loop Line 4) δ−1 many times. This loop implements the gradual change from an undirected to the corresponding directed graph. 24 Algorithm 5 An algorithm for computing (1 + α)-approximate ǫ-PageRank of a c-balanced graph G. 1: function PageRankOfBalancedGraphs(G, ǫ, α, δ) 2: Compute approximate stationary distribution πǫ,1 using Theorem 4. l ←(cid:6) 9 ln n ǫ (cid:7) for j ← 1 . . . δ−1 do Implicitly compute Gǫ,σj using Eq. (12). Run RandomWalks(Gǫ,σj , l, t) where ti(v) = ⌈C πǫ,σj (v)n ln n · ki⌉ and ki is defined ⊲ C is defined in Theorem 23 WT ← ∅ for all w ∈ W in parallel do by (5). Let W be the set of resulting walks. if wT = TranslateWalk-σ(G, ǫ, j, w) did not "fail" then Add wT to WT . πǫ,σj+1 = StationaryDistribution(WT , ǫ) 3: 4: 5: 6: 7: 8: 9: 10: 11: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: As the main primitive, PageRankOfBalancedGraphs invokes TranslateWalk-σ (Algorithm 6) on Line 9, which takes a PageRank walk in Gǫ,σj and either returns a PageRank walk in Gǫ,σj+1 or fails. In the following we say that it translates the given walk. Each translation can fail with relatively large probability, but we will take enough walks so that the whole process has a small failure probability. Algorithm 6 Given a random walk w in Gǫ,σj , return a random walk in Gǫ,σj+1 or "fail". 1: function TranslateWalk-σ(G, ǫ, j, w) 2: if σj < 1/2 then Let d be the number of directed transitions in w. Let u be the number of undirected transitions in w. p ← rl σu j+1(1−σj+1)d σu j (1−σj )d With probability p return w; otherwise, return "fail". ⊲ r is set in Lemma 26 to guarantee that p ≤ 1. else Let wT equal w. We annotate the transitions of wT as follows. for each edge e = uv of wT do if e is an undirected transition in w then define ρ(v) later in Lemma 26. -- With probability 1 − ρ(v) we keep e in wT as an undirected transition. -- With probability ρ(v) do the following: If uv is an arc in G, then we replace e ⊲ We in wT with this directed edge; otherwise, return "fail". else if e is a directed transition in w then Keep e in wT as a directed transition. else if e is a random jump in w then With probability β(v) return "fail", and otherwise keep e in wT as a random jump. ⊲ We define β(v) later in Lemma 26, (17). return wT together with its transition types In the rest of this section we analyze Algorithm 5 and show that it satisfies the claim given in 25 Theorem 5. 5.1.2 The Success Probability of Algorithm 5 We now prove the correctness of TranslateWalk-σ, which transforms a random walk w in Gǫ,σj to a random walk in Gǫ,σj+1, or returns "fail". We show that the output walk is a random walk in Gǫ,σj+1 and that the probability of "failing" is relatively small. Lemma 26. Let w be a random walk of length l in Gǫ,σj . Assume that δ ≤ 1/(2c). Then, TranslateWalk-σ(w) (Algorithm 6) does not fail and outputs a random walk wT of length l in Gǫ,σj+1 with probability at least (1 − 2cδ)l. The proof analyzes two separate cases. In one of them we use the following procedure, which is often called rejection sampling Lemma 27. Consider two discrete probability spaces P and Q over the same space {e1, . . . , en}. For 1 ≤ i ≤ n, let pi and qi give the probabilities of ei in P and Q respectively. Finally, let 0 ≤ r ≤ min1≤i≤n,qi6=0 pi/qi. Consider an algorithm which given a random sample X = ei from P returns it with probability qi/pi · r, and does nothing with the remaining probability. Then, the algorithm returns a result with probability r and each time it does so, it is an element sampled according to Q. Proof. We first note that the probability qi/pi · r is well-defined. Indeed, it is only evaluated when Xi = ei, which implies pi > 0. Moreover, thanks to the choice of r, it does not exceed 1. The probability of the algorithm not failing is n Xi=1 pi · qi/pi · r = n Xi=1 qi · r = r. Moreover, the probability of returning ej is pj · qj/pj · r = qj · r. Hence, if we condition on the algorithm not failing, the probability of returning ej is qj, as desired. We can now prove Lemma 26. Proof of Lemma 26. For the proof we consider a procedure that translates the input walk w in l steps, one edge at a time. We are going to show that after i steps either the procedure has failed or the first i edges of the walk are now sampled according from Gǫ,σj+1. We split the proof into two cases: σj < 1/2 and σj ≥ 1/2. Case σj < 1/2. Observe that in this case TranslateWalk-σ(w) either returns the walk w or fails. Recall that we consider a procedure that translates the consecutive edges of the walk one by one. At each step we are going to use Lemma 27. Each edge of the walk is either a jump transition (with probability ǫ), directed transition (with probability (1− ǫ)σ) or an undirected transition (with probability (1 − ǫ)(1 − σ). Fix a vertex v and let e be some transition that can be chosen by a random walk that has reached v. Denote by f (σ, e) the probability of choosing e. In order to use Lemma 27, we need to consider the ratios f (σj, e)/f (σj+1, e). For any jump transition ej we have f (σj, ej )/f (σj+1, ej) = 1. For a directed transition ed, f (σj, ed)/f (σj+1, ed) = ((1 − ǫ)(1 − σj))/((1 − ǫ)(1 − σj+1)) = (1 − σj)/(1 − 26 σj+1). Finally, for an undirected transition eu we have f (σj, eu)/f (σj+1, eu) = σj/σj+1. Note that out of the three ratios, only the second one is smaller than 1 and hence is the smallest one. Hence, for any transition e we have 1 − σj 1 − σj+1 1 − σj + δ ≥ 1 − 1 − σj 1 − σj + δ f (σj, e) f (σj+1, e) ≥ 2 + δ ≥ = 1 − 1 + 2δ = 1 δ δ 1 . In order to use Lemma 27 we are going to set r = 1/(1 + 2δ). The definition of r together with the sampling ratios define the probability that the algorithm of Lemma 27 does not fail. Altogether, if the input walk consists of l edges, has d directed transitions and u undirected transitions, then the probability that none of the l applications of Lemma 27 fails is rl (1 − σj+1)dσu (1 − σj)dσu j j+1 . Observe that this is exactly what TranslateWalk-σ does, which implies that the procedure is correct in the case when σj < 1/2. Finally, to bound the success probability note that 1/(1 + 2δ)l ≥ (1 − 2cδ)l. Case σj ≥ 1/2. As in the previous case, we prove the claim separately for each edge of the walk. Differently from the previous case, though, in this case the translation procedure may actually change the transition types along the walk. Let w be a random walk in Gǫ,σj . Consider an edge e belonging to the walk w, which the walk traverses after reaching vertex v. Observe that Line 15 translates e to an undirected transition only if e is an undirected transition and a coin toss with probability 1 − ρ(v) succeeds. Thus, this happens with probability pU (v) = (1 − ǫ)σj(1 − ρ(v)). On the other hand, e is translated to a directed transition either when e is a directed transition, or when it is an undirected transition, and coin toss with probability 1− ρ(v) fails, and there exists a corresponding directed transition. The latter happens with probability deg+ G(v)/ degG(v), since in this case e is a randomly chosen undirected transition incident to v. Hence, the overall probability of translating e to a directed transition is pD(v) = (1 − ǫ)(cid:16)1 − σj + Since the output of Line 15 should be a random walk in Gǫ,σj+1, we must have degG(v) ρ(v)σj(cid:17). G(v) deg+ pU (v) pD(v) = (1 − ǫ)(σj − δ) (1 − ǫ)(1 − σj + δ) . (13) This allows us to derive ρ(v), let r(v) = degG(v) G(v) from (13) we have deg+ and let y(v) = ρ(v)/r(v) = deg+ G(v) degG(v) ρ(v). Then, σj(1 − ρ(v)) (1 − σj + δ) = (1 − σj + y(v)σj) (σj − δ) =⇒ y(v)σj (σj − δ + r(v) − r(v)σj + r(v)δ) = δ =⇒ y(v)σj = σj − δ + r(v) − r(v)σj + r(v)δ δ , (14) which in particular gives us a formula for ρ(v). In the following we verify ρ(v) ∈ [0, 1]. To that end, we upper-bound y(v). Given that σj ≥ 1/2, (14) implies y(v) ≤ 2δ σj − δ + r(v) − r(v)σj + r(v)δ 27 . (15) The values r(v) and δ are fixed for a given vertex v. We upper-bound y(v) from (15) by minimizing the denominator of (15). Since r(v) appears in the form r(v)(1−σj )+r(v)δ > 0 in the denominator, and r(v) ∈ [1, c], the denominator is minimized for r(v) = 1. For r(v) = 1, the denominator of (15) becomes 1. This implies that y(v) and ρ(v) are nonnegative. Moreover, y(v) ≤ 2δ and ρ(v) ≤ 2r(v)δ ≤ 2cδ ≤ 1. (16) Now we can upper bound the probability that translation of an edge sampled from Gǫ,σj to an edge sampled from Gǫ,σj+1 "fails", conditioned on e not being a random jump. Denote that probability by β(v). Then, we have β(v) = 1 − pU (v) − pD(v) = 1 − σj(1 − ρ(v)) −(cid:18)1 − σj + deg+ G(v) degG(v) ρ(v)σj(cid:19) (17) = σjρ(v)(cid:18)1 − deg+ G(v) degG(v)(cid:19) ≤ ρ(v) (16) ≤ 2cδ. We now comment on random jumps. From our analysis, a transition which is not a random jump is rejected (i.e., "fails") with probability β(v). To account for that, if a transition of w is a random jump, TranslateWalk-σ will also "fail" with probability β(v), and with the remaining probability keep this random jump. In this way, conditioned that TranslateWalk-σ does not "fail", an edge eT of the output of TranslateWalk-σ(w) is a random jump with probability ǫ, a directed edge with probability (1−ǫ)(1−σj+1), and an undirected edge with probability (1−ǫ)σj+1. Hence, TranslateWalk-σ outputs "fail" per edge with probability ǫβ(v) + (1 − ǫ)β(v) = β(v) ≤ 2cδ, and hence an invocation of this method does not output "fail" with probability at least (1 − 2cδ)l. 5.1.3 Proof of Theorem 23 We now prove Theorem 23 by showing that Algorithm 5 has the properties given in the theorem statement. To show correctness, observe that an iteration of the loop of Algorithm 5 simulates algorithm Algorithm 4 for computing πǫ,σj+1. We split the rest of the proof into three parts: the space requirements; the round complexity; and, the probability of success. Throughout the proof, we set parameters as l = (cid:6) 9 ln n K =(cid:6) 9 ln n ǫ·α2 . The proof of the success probability fixes the value of C. ǫ·α2 (cid:7) ≤ 10 ln n Round complexity. Algorithm 5 executes O(δ−1) iterations. Each iteration implicitly constructs a stochastic graph on Line 5, which by Observation 24 can be done in O(1) rounds. Also in each iteration is invoked Algorithm 1, which takes O(log l) = O(log log n + log 1/ǫ) rounds. Since we assume that each walk is stored entirely on a machine, TranslateWalk-σ on Line 9 can be implemented without extra communication. To obtain WT defined by Line 10, each walk that "fails" is marked by flag fail, and otherwise marked by flag succeed. Those walks marked by succeed define WT . ǫ (cid:7) and By Lemma 22, Line 11 can be implemented in O(1) rounds. Hence, the total round complexity is O(cid:0)δ−1(log log n + log 1/ǫ)(cid:1). 28 Success probability. By Lemma 21, the probability that any πǫ,σj is not (1 + α)-approximation of πǫ,σj is at most 3 n2 . The next place when Algorithm 5 can fail is Line 11, i.e., we need to have at least K walks staring in each vertex v. Note that algorithm generates ⌈C πǫ,σj (v)n ln nk⌈log l⌉⌉ ≥ C πǫ,σj (v)n ln n ≥ Cπǫ,σj (v)(1 − α)n ln n ≥ Cǫ(1 − α) ln n. walks from each vertex. These walks are subsampled with probability at least (1−2cδ)l by Lemma 26. We will aim to have 2K walks in expectations, so that by Chernoff bound (Theorem 7 (C)) the probability of this number being smaller than K is exp(cid:0)−δ2µ/3(cid:1) = exp (−K/3) ≤ exp (−3 ln n) = 1 n3 . Using union bound over all vertices we will have not enough walks with probability at most 1 n2 . Hence, we need to set C so that 2K ≤ (1 − 2cδ)l · Cǫ(1 − α) ln n. This gives C ≥ 20 80 ǫ2α2(1 − α) · (1 − 2cδ)l ≥ 3ǫ2α2(1 − 2cδ)l . Hence, this inequality is satisfied by setting C = algorithm fails with probability at most 28 α2ǫ2·(1−2cδ)l . Now, by Lemma 15 (i) the sampling n− Cαǫ 3 +2e2 ≤ n− 28 3αǫ +2e2 ≤ n−4+2e2. The probability of any of these failures happening in each round is at most 3 Hence, over all round the failure probability is O( 1 n2δ ). n2 + 1 n2 + e2 n2 < 12 n2 . Space requirement. By Lemma 15 (iii) and from 1/n ≤ α ≤ 1/4, the space required is 1 1 1 O(cid:0)m + Cl1+2αn ln n(cid:1) = O(cid:18)m + = O(cid:18)m + = O(cid:18)m + = O m + = O(cid:18)m + = O(cid:18)m + (cid:17) space in Line 2 of Algorithm 5. This completes the proof of α2ǫ2 · (1 − 2cδ)l l1+2αn ln n(cid:19) α2ǫ2 · (1 + 2cδ)ll1+2αn ln n(cid:19) α2ǫ2 · (1 + 2cδ)ll1.5n ln n(cid:19) ǫ (cid:19)1.5 ǫ (cid:18)9 α2ǫ2 · (1 + 2cδ)9 ln n ǫ n ln2.5 n(cid:19) α2ǫ3.5 · (1 + 2cδ)9 ln n ǫ n ln2.5 n(cid:19) . α2ǫ3.5 · n18 cδ n ln n! ln n 1 1 1 Moreover, we need O(cid:16) m log2 n log log n Theorem 23. ǫ2α2 29 5.2 Transformation to a c-balanced Graph In this section we will describe how to reduce a general graph G = (V, E) without dangling vertices to a 3-balanced multigraph Gc = (Vc, EC ). The ways to handle dangling vertices are discussed in Appendix B. The idea is to replace each vertex by a path of length λ = ⌈log n⌉. The graph Gc = (Vc, Ec) is defined as follows Vc = {vi : v ∈ V, i ∈ [1, . . . , λ]}, Ec = {uλv1 : uv ∈ V } ∪ {(uiui+1)j : i ∈ [1, . . . , λ − 1], j ∈ [0, . . . ,⌈deg−(u)/2i⌉]}. Lemma 28. If G does not contain dangling vertices then Gc is a 3-balanced graph. Moreover, Gc contains n⌈log n⌉ vertices and at most 2m + n⌈log n⌉ edges. Proof. In order to prove that Gc is c-balanced, consider three cases for vi ∈ Vc: i = 1 then vi has deg−(v) inedges, and ⌈deg−(v)/2⌉ outedges, so 3 deg+(vi) = 3⌈deg−(v)/2⌉ ≥ ⌈deg−(v)/2⌉ + deg−(v) = deg(vi). 1 < i < λ then vi has ⌈deg−(v)/2i−1⌉ inedges, and ⌈deg−(v)/2i⌉ outedges, so 3 deg+(vi) = 3⌈deg−(v)/2i⌉ ≥ ⌈deg−(v)/2i⌉ + ⌈deg−(v)/2i−1⌉ = deg(vi). i = λ then vi has ⌈deg−(v)/2λ−1⌉ inedges and at least 1 outedge, so 3 deg+(vi) ≥ deg+(vi)+2 ≥ deg+(vi)+⌈2 deg−(v)/n⌉ ≥ deg+(vi)+⌈deg−(v)/2λ−1⌉ = deg(vi). By construction the number of vertices is n⌈log n⌉, whereas the number of edges added to Gc can be accounted to inedges in G, i.e., for a vertex v with indegree deg−(v) we are adding λ−1 Xi=1 ⌈deg−(v)/2i⌉ ≤ λ−1 Xi=1 deg−(v)/2i + 1 ≤ deg−(v) + λ − 1, edges. This gives m + nλ = m + n⌈log n⌉ additional edges. For each uv ∈ E we call the edge uλv1 ∈ EC core. From the construction of Gc we easily get the following. Observation 29. Let W = e1, e2, . . . , ek be a walk in GC. Then, there exists 1 ≤ i ≤ λ that has the following property. Let WR be a subsequence of W consisting of edges ei+jλ for 0 ≤ j ≤ (k − i)/λ. Then, WR is a walk in G, which contains all core edges of W . 30 5.3 Increasing Damping Factor In Section 5.2 we described how to transform the input graph G to a c-balanced graph Gc. In this process, each edge of G is replaced by a path of length ⌈log n⌉. That means that a random walk of length l in G corresponds to a random walk of length l · ⌈log n⌉ in Gc. In order make a correspondence between PageRank walks in G to those in Gc, we need PageRank walks in Gc to make jump transitions roughly log n times less frequently than in G. (We make this statement precise in Section 5.4.) In light of this, we design method PageRankLargerDampingFactor (Algorithm 8) that given an approximate ǫ-PageRank of G outputs an approximate ǫ′-PageRank of G for ǫ′ < ǫ. Moreover, for a given parameter τ , it does so in O(cid:0)log1+τ is implemented by invoking RandomWalks for length O(log n/ǫ′). The parameter τ also affects space complexity (for details see Theorem 33), and in the final setup we let τ = o(1). ǫ′(cid:1) iterations each of which ǫ PageRankLargerDampingFactor uses TranslateWalk-ǫ (Algorithm 7) as a subroutine. Given a random walk w in Gǫj ,0 and ǫj+1 ≤ ǫj, TranslateWalk-ǫ either returns a walk wT which is a random walk in Gǫj+1,0 or "fails". This method is very similar to TranslateWalk-σ for the case σj < 1/2. Algorithm 7 1: function TranslateWalk-ǫ(G, ǫj, ǫj+1, w) 2: Let g be the number of directed transitions in w. Let t be the number of jump transitions in w. p ← r ǫt j+1(1−ǫj+1)g ǫt j(1−ǫj )g 3: 4: 5: With probability p return w; otherwise, return "fail". ⊲ r is set in Lemma 30 to guarantee that p ≤ 1. Algorithm 8 An algorithm that given a (1 + α)-approximate ǫ1-PageRank πǫ1 of G for ǫ1 ≤ 1/2, outputs a (1 + α)-approximate ǫ′-PageRank πǫ′ of G for ǫ′ < ǫ1. Parameter τ ∈ (0, 1/2) affects success probability, round complexity and space complexity. 1: function PageRankLargerDampingFactor(G, πǫ1, ǫ′, τ ) 2: for j ← 1 . . . ⌈log1/(1−τ ) ǫ1/ǫ′⌉ do Let W be the set of resulting walks. l ← ⌈ 9 ln n ǫj ⌉ Implicitly compute Gǫj ,0 using Eq. (12). Run RandomWalks(cid:0)Gǫj ,0, l, t(cid:1) where ti(v) = ⌈Rπǫj (v)n ln n · ki⌉, ki is defined by (5). WT ← ∅ ǫj+1 ← max{ǫ′, ǫj(1 − τ )} for all w ∈ W in parallel do ⊲ R is set in Theorem 33 if wT = TranslateWalk-ǫ(G, ǫj, ǫj+1, w) did not "fail" then 3: 4: 5: 6: 7: 8: 9: 10: 11: Add wT to WT . πǫj+1 = StationaryDistribution(WT , ǫj) 1−ǫj+1(cid:17)l Lemma 30. Given a random walk w of length l in Gǫj,0, with probability at least (cid:16) 1−ǫj TranslateWalk-ǫ(w) outputs a random walk of length l in Gǫj+1,0; otherwise, TranslateWalk-ǫ(w) reports "fail". the call 31 Proof. The proof of this lemma is similar to one of Lemma 26 for σj < 1/2. In this proof as well, we would like to use Lemma 27 for each edge of walk w. Each edge of w is either a jump transition (with probability ǫj) or a (directed) graph transition (with probability 1 − ǫj). As in Lemma 26, fix a vertex v and let e be some transition that can be chosen by a random walk that has reached v. Denote by f (ǫ, e) the probability of choosing e. To use Lemma 27, consider the ratios f (ǫj, e)/f (ǫj+1, e). For any jump transition ej we have f (ǫj, ej )/f (ǫj+1, ej) = ǫj ǫj+1 ≥ 1. For a graph transition eg, we have f (ǫj, eg)/f (ǫj+1, eg) = 1−ǫj < 1. Hence, for any transition e we have 1−ǫj+1 1 − ǫj 1 − ǫj+1 f (ǫj, e) f (ǫj+1, e) ≥ . So, we set r = (1− ǫj)/(1− ǫj+1) and the proof follows by application of Lemma 27 in the same way as in the proof of Lemma 26 for σj < 1/2. We now want to use Lemma 30 to lower-bound the success probability of TranslateWalk-ǫ invoked within Algorithm 8. For that, we first establish the following inequality. Lemma 31. For any y ∈ [0, 1/2] we have 1 − y ≥ exp(−2y). Proof. From Taylor expansion we have 1 − x + x2/2 ≥ exp(−x). Since for x ∈ [0, 1] it holds that x/2 ≥ x2/2, we have 1 − x/2 ≥ 1 − x + x2/2 ≥ exp(−x). Now the lemma follows by letting y = x/2. Lemma 32. Let τ ≤ 1/2. If ǫj+1 = (1 − τ )ǫj, then TranslateWalk-ǫ invoked by Algorithm 8 succeeds with probability at least n−36τ . Proof. By Lemma 30, TranslateWalk-ǫ "fails" with probability at most ((1 − ǫj)/(1 − ǫj+1))l for l = c ln n . We now upper-bound this probability. We have ǫj 1 − ǫj 1 − ǫj+1 = 1 − τ ǫj 1 − (1 − τ )ǫj . Therefore, 1 − ǫj+1(cid:19)l (cid:18) 1 − ǫj =(cid:18)1 − τ ǫj 1 − (1 − τ )ǫj(cid:19) 9 ln n ǫj Lemma 31 ≥ n− 18τ 1−(1−τ )ǫj ≥ n−36τ , where we used the fact that ǫj, τ ≤ 1/2. Theorem 33. Let G be a directed graph. Let ǫ1 > ǫ′ ≥ log n/o(S), and let πǫ1 be a (1 + α)-approximate ǫ1-PageRank of G. Given τ ∈ (0, 1/2], PageRankLargerDampingFactor (Algorithm 8) outputs a (1 + α)-approximate ǫ′-PageRank πǫ′ of G. Moreover, PageRankLarger- DampingFactor can be implemented in O(τ−1·log 1/ǫ′·(log log n + log 1/ǫ′)) MPC rounds and the ǫ′3.5α2 n36τ n ln2.5 n(cid:1) with strongly sublinear space per machine. This algorithm total space of O(cid:0)m + 1 is randomized and outputs a correct result with probability at least 1 − O( 1 Proof. We split the proof into three parts: upper-bounding the success probability, deriving the space requirement, and analyzing the round complexity. τ n2 · log 1/ǫ′). 32 Round complexity. The main loop of Algorithm 8 is executed at most llog1/(1−τ ) 1/ǫ′m = O(cid:0)τ−1 · log 1/ǫ′(cid:1) times. Each loop invokes RandomWalks for length O(cid:0) ln n ǫ′ (cid:1), which can be exe- cuted in O(log log n + log 1/ǫ′) MPC rounds. Line 9 to Line 11 can be implemented in O(1) rounds in the same way as described in the proof of Theorem 23 (see Section 5.1.3). Success probability. By Lemma 21 each πǫj computed on Line 11 is a (1 + α)-approximation of πǫ′ with probability at least 1 − 3/n2. Note that algorithm generates at least ⌈Rπǫj (v)n ln nk⌈log l⌉⌉ ≥ Rπǫj (v)n ln n ≥ Rπǫj (v)(1 − α)n ln n ≥ Rǫj(1 − α) ln n, random walks from each vertex. Next, these walks are downsampled using Lemma 32 with proba- bility n−36τ . Similarly as in Theorem 23, we want the expected number of walks to be 2Kj, so that the failure probability is less than 1 n2 . Hence, the following requirement on R 2Kj ≤ n−36τ · Rǫj(1 − α) ln n what gives R ≥ 20 n−36τ ǫ2 j (1 − α)α2 ≤ 28 j α2 n36τ ǫ2 j α2 n36τ and, similarly, as in Theorem 23 the sampling algorithm fails with probability n2 of each round, and over all rounds we get We set R = 28 ǫ2 at most n−2e2. This gives the failure probability 12 12 τ n2 · log 1/ǫ′. Space requirement. The space usage is dominated by calls to Algorithm 1, which from Lemma 15 are bounded by O(cid:0)m + Rl1+2αn ln n(cid:1). Observe that l is the highest in the last round and equals l = ⌈ 9 ln n 1 1 ǫ′ ⌉ = O(ln n/ǫ′). This gives the following upper-bound on space ǫ′2α2 n36τ l1+2αn ln n(cid:19) ǫ′2α2 n36τ l1.5n ln n(cid:19) ǫ′ (cid:19)1.5 ǫ′2α2 n36τ (cid:18) 9 ln n ǫ′ (cid:19)1.5 ǫ′2α2 n36τ (cid:18) 9 ln n ǫ′3.5α2 n36τ n ln2.5 n(cid:19) . O(cid:0)m + Rl1+2αn ln n(cid:1) = O(cid:18)m + = O(cid:18)m + = O m + = O m + = O(cid:18)m + 1 1 1 n ln n! n ln n! 33 5.4 From PageRank in c-balanced to PageRank in General Graphs In the previous sections we developed a way for efficiently approximating PageRank of c-balanced graphs. Here, we describe how to use that result to approximate the PageRank of a graph G, which is not necessarily c-balanced. Let Gc be a c-balanced graph obtained from G by applying the transformation described in Section 5.2. Recall that to approximate PageRank it suffices to sample random walks up to the point of their first random jump (see Algorithm 5). For the input ǫ graph G and damping factor 1 − ǫ such a random walk with high probability has length O(cid:16) log n ǫ (cid:17). Instead of generating PageRank walks in G, we will generate them in Gc, but for a damping factor 1 − ǫ/poly log n (see Lemma 34). This will be done using Algorithm 8. Let Wc be an poly log n )-PageRank walk. We observe that with constant probability the first jump in Wc appears ( ǫ (cid:17) steps. Assuming this from Wc we can obtain a random walk W in G of length after Ω(cid:16) log2 n Ω(cid:16) log n In order to obtain ǫ-PageRank we reintroduce random jumps with probability ǫ and truncate walks after first such jump. This is done by sequentially iterating over the edges of W and with probability ǫ truncating W at any given step. This process is given as algorithm TranslateToPageRankWalk (Algorithm 9). ǫ (cid:17) such that no transition of W is a random jump. Algorithm 9 Let G be a graph and Gc its c-balanced version. Given a PageRank walk w in Gc that has no random jumps, the algorithm returns an ǫ-PageRank walk in G that has exactly one random jump transition or the algorithm "fails". This random jump transition is the last one in the walk. 1: function TranslateToPageRankWalk(G, ǫ, w) 2: if w contains random jump then "fail". Let wR be the walk in G consisting of all core edges of w. Mark each edge of wR independently and with probability ǫ. if at least one edge of wR is marked then Truncate wR before the first marked edge. Return wR. else "fail" 3: 4: 5: 6: 7: 8: 9: ⊲ See Observation 29 Now we present the main algorithm of this entire section. The algorithm outputs an approximate PageRank for the input graph. 34 ǫ m, and ǫ′ ← 1/(4ℓ). ℓ ← ⌈log n⌉ ·l 9 log n ǫ′ ← PageRankLargerDampingFactor(Gc, πc Let πc Implicitly compute (Gc)ǫ′,0 using Eq. (12). Run RandomWalks((Gc)ǫ′,0, ℓ, t) where ti(v) = ⌈Lπc WT ← ∅ for all w ∈ W in parallel do 1/2, ǫ′). if wT = TranslateToPageRankWalk(G, ǫ, w) did not "fail" then ǫ′(v)n ln n· ki⌉, ki is defined by (5) and d′ is a sufficiently large constant. Let W be the set of resulting walks. ⊲ L is set in Theorem 5 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: Algorithm 10 An algorithm for computing a (1 + α)-approximate PageRank πǫ of a graph G. 1: function PageRankOfGeneralGraphs(G, ǫ, α) 2: Let Gc be the balanced graph of G obtained as described in Section 5.2. Let πc 1/2 ← PageRankOfBalancedGraphs(Gc, 1/2, α). Add wT to WT . πǫ = StationaryDistribution(WT , ǫ) Note that Algorithm 10 does not directly map PageRank walks from Gc to PageRank walks in G. Instead, it takes advantage of the fact that in order to approximate PageRank one only needs to know the random walks until the first jump transition and proceeds as follows. It first computes PageRank walks in Gc, then discards all walks that have at least one jump transition and finally truncates the resulting walks by simple coin tossing. Note that this truncation step is equivalent to truncating the walks just before the first jump transition. Now we analyze the correctness of Algorithm 10. The following result will be useful in estab- lishing failure probability of TranslateToPageRankWalk. Lemma 34. Let ℓ ≥ 1 be a parameter. Define ǫ′ = 1/(4ℓ). An ǫ′-PageRank walk does not make a random jump within the first ℓ steps with probability at least 0.6. Proof. An ǫ′-PageRank walk does not make a random jump within the first ℓ steps with probability (1 − ǫ′)l Lemma 31 ≥ exp(cid:0)−2ǫ′l(cid:1) = exp (−1/2) ≥ 0.6. Lemma 34 essentially states the following. If we are given an ǫ′-PageRank walks in Gc then with probability at 1/2 it can be turned into a ǫ-PageRank walk in G. Lemma 35. The invocation TranslateToPageRankWalk(G, ǫ, w) on Line 10 of Algorithm 10 "fails" with probability at most 1/2. If the algorithm succeeds, then it returns an ǫ-PageRank walk of G that has exactly one jump transition and that jump transition is the last one in the walk. Proof. We first analyze the success probability of TranslateToPageRankWalk and then show the claim for its output. Success probability. There are two lines where TranslateToPageRankWalk can "fail" -- Lines 2 and 9. By Lemma 34, it "fails" in Line 2 with probability at most 1/2. Line 9 is executed only if no edge of wR is marked on Line 4. We have wR = ⌊ℓ/⌈log n⌉⌋ =j⌈log n⌉ ·l 9 log n ǫ m /⌈log n⌉k =l 9 log n ǫ m . 35 Hence, by Lemma 20 no edge of wR is marked with probability at most 1 n9 ≤ 1/512. This implies that the invocation of TranslateToPageRankWalk succeeds with probability at least 0.6 − 1/512 ≥ 1/2, as desired. Output of TranslateToPageRankWalk. As input, TranslateToPageRankWalk gets a PageRank walk w in Gc; this walk is generated on Line 7 of Algorithm 10. On Line 2 of TranslateToPageRankWalk, w is discarded if it contains any jump transition. So, if the algorithm does not "fail", w is a random walk in Gc. By the transformation on Line 3 we obtain a walk wR which is a random walk in G. After that, each transition of wR is marked with probability ǫ (that is implemented by marking on Line 4), i.e., we toss a random coin to see potential steps for random jumps. Then we truncate the walk at the moment of the first jump in wR occurs, and return this truncated walk. By construction, this walk is an ǫ-PageRank walk in G. Now we are ready to prove the correctness of Algorithm 10, which establishes one of the main α2 + n1+o(1) results of the paper. Theorem 5. Let G be a directed graph. Let α ∈ [1/n, 1/4] and ǫ ∈ [log3 n/o(S), 1], where S is the available space per machine. There exists an MPC algorithm that, with probability at least 1− O( 1 n ), computes a (1 + α)-approximate ǫ-PageRank vector of G in O(cid:0)log2 log n + log2 1/ǫ(cid:1) rounds, using O(cid:16) m ǫ3.5α2 (cid:17) total space and strongly sublinear space per machine. Proof. We will show that Algorithm 10 satisfies properties of this claim. As in previous proofs we split the proof into three parts: the space requirements; the round complexity; and, the probability of success. This is the moment when we set all the parameters of the algorithms. We set δ to be the largest value not greater than (log log n)−1 such that δ−1 ∈ N. Observe that δ ≥ 1/(1 + log log n). Also, we set τ = log log log−1 n. We will use the following bounds O(1/ǫ′) = O(ℓ) = O(log2 n/ǫ). O(log 1/ǫ′) = O(log ℓ) = O(log log n + log 1/ǫ), and when cruder bound is enough we bound O(log 1/ǫ′) = O(log log n + log n) = O(log n). Round complexity. By Theorem 23 the execution of PageRankOfBalancedGraphs(Gc, 1/2, α, δ) takes O(δ−1 log log n) = O(log2 log n) rounds. PageRankLargerDampingFactor on Line 5 of Algorithm 10 takes Recall that ǫ′ = Θ(cid:16) ǫ log2 n(cid:17) in Algorithm 10 (see Line 4). By Theorem 33 the execution of O(τ−1 · log 1/ǫ′ · (log log n + log 1/ǫ′)) = O(log log log n · (log log n + log 1/ǫ) · (log log n + log 1/ǫ)) = O(log2 log n + log2 1/ǫ) rounds. Note that since ǫ ≥ log3 n/o(S), we have ǫ′ ≥ log n/o(S), which is required by Theorem 33. Line 10 to Line 12 can be implemented in O(1) rounds in the same way as described in the proof of Theorem 23 (see Section 5.1.3). 36 Success probability. As in proof of Theorem 23 we require that there are 2K walks starting in each vertex before the call to StationaryDistribution, so that we have K walks in each vertex with probability at least 1 − 1 n2 . Using the downsampling from Lemma 35 this gives what bounds L as 2K ≤ 1 2⌈Lπ(v)n ln n⌉ ≤ Lǫ′(1 − α) ln n, L ≥ 40 ǫ2α2(1 − α) ≥ 160 3ǫ2α2 . We set L = 54 α2ǫ2 . Now, by Lemma 15 (i) the sampling algorithm fails with probability at most n− Cαǫ 3 +2e2 ≤ n− 54 n(cid:19) . 3αǫ +2e2 ≤ n−2e2 = O(cid:18) 1 By Theorem 23 the execution of PageRankOfBalancedGraphs fails with probability O(cid:0) 1 O(cid:0) 1 n(cid:1). By Theorem 33 the execution of PageRankLargerDampingFactor fails with probability n2δ(cid:1) = O(cid:18) 1 n2 τ n2 · log 1/ǫ′(cid:19) = O(cid:18) log log log n = O(cid:18) log log log n n(cid:19) . = O(cid:18) 1 n2 (log log n + log 1/ǫ)(cid:19) (log log n + log n)(cid:19) (18) (19) (20) Hence, in total the failure probability of the algorithm is O(1/n). Space complexity. By Theorem 23 the execution of PageRankOfBalancedGraphs(Gc, 1/2, α, δ) requires space O(cid:18) m ln2 n ln ln n (1/2)2α2 + n18 3δ 1/2 n ln2.5 n (1/2)3.5 · α2(cid:19) = O m α2 + n1+o(1) α2 ! . By Theorem 33 the execution of PageRankLargerDampingFactor needs space O(cid:18)m + 1 ǫ′3.5α2 n36τ n ln2.5 n(cid:19) = O(cid:18)m + log7 n ǫ3.5α2 n36τ n ln2.5 n(cid:19) = O m + n1+o(1) ǫ3.5α2 ! . By Lemma 15 the sampling algorithm RandomWalks requires space bounded by O(cid:0)m + Lℓ1+2αn ln n(cid:1) = O(cid:18)m + 1 ǫ2α2 · ℓ1.5n(cid:19) = O(cid:16)m + ǫ3.5α2 (cid:17). α2 + n1+o(1) n ǫ3.5α2(cid:17) . Hence, the final space complexity of the algorithm is O(cid:16) m We can now use Theorem 5 to sample directed random walks and obtain the following result. 37 Theorem 2. Let G be a directed graph. Let D and l be positive integers such that l = o(S)/ log3 n, where S is the available space per machine. There exists an MPC algorithm that samples D independent random walks of length l starting in v for each v in G. The algorithm runs in Let ti be as defined in Lemma 15. Invoke Theorem 5 to obtain a (1 + α)-approximate ǫ- O(log2 log n + log2 l) rounds and uses O(cid:0)m + n1+o(1)l3.5 + Dnl2+o(1)(cid:1) total space and strongly sub- linear space per machine. The algorithm is an imperfect sampler (see Definition 8) that does not fail with probability 1 − O(n−1). Proof. Let α = 1/ log n and ǫ = 1/(4l). PageRank. This invocation can be implemented in O(cid:0)log2 log n + log2 l(cid:1) rounds and the total space of O(cid:0)m + n1+o(1)l3.5(cid:1). Invoke RandomWalks(G, l, t) with C = 20D/(αǫ). By Lemma 15, and given that π(v) ≥ (1 − α)π(v) ≥ (1 − α)ǫ/n, with probability at least 1 − Θ(1/n) this invocation outputs at least C π(v)n ln n ≥ 20D ln n random walks from each vertex v. Let W be the collection of those walks. Also by Lemma 15, W can be obtained in O(log l) rounds by using the total space of O(m + Cl1+2αn) ∈ O(cid:0)m + Dnl2+o(1)(cid:1). The walks in W are PageRank walks. Nevertheless, by Lemma 34 and Chernoff bound, with probability at least 1 − Θ(1/n) for each v there exist D PageRank walks in W that contain no random jump. Those walks are the walks that satisfy the claim of this theorem. 6 PRAM Implementation In this section we discuss PRAM implementation of our algorithms for computing (directed) random walks and hence prove the following. Theorem 6. Let G be a directed graph and 1 ≤ l ≤ n. There exists an NC algorithm that uses O((n + m)1+o(1)) processors and samples one random walk from each vertex of G. All sampled walks are independent. The algorithm is an imperfect sampler (see Definition 8) that fails with probability 1 − O(n−1). 6.1 Storing and Sorting Walks In our MPC implementation of the algorithms described in other sections, we assume that an entire random walk can be stored on one machine. In fact, this is the only reason why our algorithm assume that the length of each walk l satisfies l = o(S). In this section we show a different approach, which would also allow us to increase the upper bound on l. To store each walk w, we allocate l consecutive memory cells, even if w < l. The edges of w occupy the first w cells and the remaining cells are filled with ⊥. Walk identifiers. To each created walk w we assign an integer identifier wid chosen uniformly at random from the interval [1, n10]. With high probability walks have distinct identifiers. Sorting walks. We now explain how to sort the walks with respect to their first vertex. Consider a walk w with the starting vertex v. Then, to i-th cell allocated for w we assign triple (v, wid, i). This labeling can be done in O(log n) time by building a binary tree of processors over the cells allocated for w. A nice feature of this labeling, and also assigning identifiers to random walks, is that after sorting the triples lexicographically, all the cells containing information of w appear consecutively. Sorting walks with respect to their last vertex is done in an analogous way. 38 Stitching two walks. When the algorithm has to stitch two walks w1 and w2, it copies the edges of w2 over the first w2 cells allocated for w1 that have value ⊥. The first cell containing value ⊥ can be found in O(log n) time, e.g., by performing a binary search. After such cell x is found, we copy w2 (that occupies consecutive memory cells) over memory cells x through x + w2 − 1. This again can be done in O(log n) time by building a binary tree over w2. 6.2 Implementation of RandomWalks From our discussion about MPC implementation of RandomWalks, it suffices to show that sorting, computing prefix sums, NumberingSublists and Predecessor can be implemented in O(log n) time. Sorting and computation of prefix sums can be done in O(log n) time in [Col88] and [LF80], respectively. We now describe how to implement Predecessor. Recall that in this primitive we are given an ordered list of tuples L, each element labeled by 0 or 1. This primitive can be implemented as follows. • Assign i to the i-th element of L. This can be done by computing the prefix sum on L with each element having value 1. • Consider the i-th element ei of L. If the label of ei equals 0, assign value/pair (0, ei) to ei. Otherwise, assign value (i, ei) to ei. • The prefix sum approach described in [LF80] can be performed for any associative operation, including max. Compute the prefix sum with operation max over the values/pairs assigned to the elements of L. These prefix sums correspond to the output of Predecessor. As described in Section 4.1, NumberingSublists can be implemented by using prefix sum computation, sorting and Predecessor, each of which can be executed in O(log n) time. 6.3 Implementation of StationaryDistribution In Lemma 22 we described how to implement StationaryDistribution in MPC. That proof relied on primitives NumberingSublists and Predecessor, that we explained how to implement in O(log n) time. The proof also computes maximum over certain subarrays, which can be done in O(log n) time. To conclude the discussion, it remains to comment about implementation of Line 4. This line truncates walks after their first random jump. This again can be done by building a binary tree over each walk w and finding the first edge corresponding to a random jump of w. All the cells allocated to w after that jump are set to ⊥. 6.4 Construction of Stochastic Graphs To construct a stochastic graph with parameters ǫ and σ in MPC, we had to broadcast ǫ and σ to all the machines containing the input graph, copy edge and vertices and properly annotate them. See the description above Observation 24 for more details. In PRAM we perform similar steps. Namely, we build a binary tree over the memory cells that our algorithm uses, copy the corresponding edges and vertices and annotate them by ǫ and σ. 39 6.5 Implementation of TranslateWalk We use several algorithms that translate random walks between different graphs (Algorithms 6, 7 and 9). Their MPC implementation is straightforward as we assume that each walk is stored on one machine. Nevertheless, their PRAM implementation is also almost direct. Each of those methods counts the number of distinct transition a walk has, or marks edges independently of each other, or finds the first edge of a walk that has a specific property (e.g., Line 6 of Algorithm 9). Each of those operations can be performed in O(log n) rounds by building a binary tree over the corresponding walk. 7 Testing Bipartitness We now show how to use our random walk algorithm for testing bipartiteness. In this promise problem, we are given an undirected graph G on n vertices with m edges and a parameter ǫ ∈ (0, 1). We want to distinguish the case that G is bipartite from the case that at least ǫm edges have to be removed to achieve this property. Our parallel algorithm combines techniques developed for previous bipartiteness algorithms [GR99, KKR04] with our simulation of random walks. For simplicity, we assume that vertices of G are not isolated. Our algorithm can be seen as the following procedure consisting of three steps, in which the first two are preprocessing steps: 1. If the graph is dense, we reduce its number of edges to O(n/ǫ) by independently keeping each edge with an appropriate probability. The resulting graph is very likely to be still ǫ/2-far from bipartiteness. 2. If the graph has high degree vertices, we apply the idea of Kaufman, Krivelevich, and Ron [KKR04] to replace all high degree vertices with low degree bipartite expanders. This again preserves the distance from bipartiteness up to a constant factor and allows to assume that the resulting graph has only vertices of small degree. 3. In the resulting graph, we run a small number of short random walks from every vertex. We show that if the graph is far from bipartiteness then random walks from one of the vertices are very likely to discover an odd-length cycle. We present a more formal description of the algorithm as Algorithm 11. Algorithm 11 BipartitenessTester (G, ǫ): An algorithm for testing bipartiteness of an undi- rected graph G = (V, E) on n vertices for a closeness parameter ǫ ∈ (0, 1). 1: Independently keep each edge with probability min(cid:8)1, O(cid:0) n 2: Replace high degree vertices with bipartite expanders (more details in Section 7.2). 3: Using Algorithm 1, generate poly(ǫ−1 log n) random walks of length poly(ǫ−1 log n) from each ǫm(cid:1)(cid:9). vertex. 4: for v ∈ V do 8: 9: return Accept 5: 6: 7: V0 ← vertices reached by the random walks from v in an even number of steps V1 ← vertices reached by the random walks from v in an odd number of steps if V0 ∩ V1 6= ∅ then return Reject 40 7.1 Sampling a Sparse Graph We now prove that the first step of our algorithm (with an appropriate constant selection) preserves the distance to bipartiteness. Lemma 36. Let G be an undirected graph on n vertices with m edges. Let a graph G′ be on the same set of vertices as G created by selecting each edge independently with probability min(cid:8)1, Cn ǫm(cid:9), where C is a sufficiently large positive constant. If G is ǫ-far from bipartiteness, then with probability 1 − 2−Ω(n), G′ is ǫ/2-far from bipartite and has at most O(n/ǫ) edges. Proof. Suppose that G = (V, E) is ǫ-far. The lemma holds trivially if Cn ǫm ≥ 1, because G′ = G is ǫ/2-far and has at most Cn/ǫ edges. We can therefore focus on the case that Cn ǫm < 1. The expected number of edges in this case is Cn/ǫ. By the Chernoff bound, the number of edges in G′ is, with probability 1 − 2−Ω(n), at most 11 10 Cn/ǫ. Now consider any partition of the set V of vertices of G into two sets V1 and V2. Since G is ǫ-far from bipartiteness, the sum of the number of edges in G[V1] and G[V2] is at least ǫm. Otherwise, we could delete them to turn the graph into bipartite. The expected sum of the number of edges in G′[V1] and G′[V2] has then to be at least ǫm· Cn 10 Cn with probability 1− 2−Ω(n), where the constant hidden by the Ω-notation can be made arbitrarily large by making C sufficiently large. By the union bound, the probability that the total number of edges in G′ is more than 11 10 Cn edges can be removed to make the graph bipartite is at most 2−Ω(n) + 2n−1 · 2−Ω(n) = 2−Ω(n). This holds because all constants hidden by the Ω notation can be made arbitrarily small by setting C to be sufficiently large. The distance of G′ from bipartiteness is then at least (cid:0) 9 ǫm = Cn. Again, by the Chernoff bound, the number of them is at least 9 10 Cn/ǫ and that in one of the partitions, fewer than 9 10 Cn(cid:1) /(cid:0) 11 10 Cn/ǫ(cid:1) ≥ ǫ/2. 7.2 Replacing High-Degree Vertices with Expanders We now give more details of Step 2 of Algorithm 11, which reuses the degree reduction method of Kaufman et al. [KKR04]. More specifically, Section 4.1 of their paper shows how to take a graph G = (V, E) and turn into a graph G′ = (V ′, E′) in which the maximum degree equals roughly the average degree of G. Additionally, G′ preserves G's distance to bipartiteness. We start by describing the transformation of the vertex set. Let d = d+ avg(G). We copy every vertex v of G such that deg+(v) ≤ d into G′. Vertices v of higher degree are replaced by bipartite expanders as follows. For each such v, we introduce two sets of vertices of cardinality ⌈deg+(v)/d⌉. We refer to one of them as internal, and the other one as external. If deg+(v) < d2, we create a full bipartite graph between the internal and external vertices with edge multiplicites that make vertices have degree almost d. Otherwise, when deg+(v) ≥ d2, we use any explicit bipartite expander construction of degree d between the two sets [Mar73, LPS86]. Now we describe the transformation of the edge set. For every edge u1, u2 ∈ E, we adjust its endpoints as follows. Let u be one of them. If u was directly copied from G to G′, then we do nothing. Otherwise, we replace it with one of the vertices in the external set created for u. For every vertex u in the original graph that is replaced by a set of vertices, we assign the original edges involving u to the external vertices created for u such that no external vertex is assigned more than d such edges. Kaufman et al. [KKR04] prove the following. Lemma 37 ([KKR04, Theorem 5]). The graph G′ created as above has the following properties: 41 (A) V ′ = Θ(E) and E′ = Θ(E). (B) If G is bipartite, so is G′. (C) If G is ǫ-far from bipartite for some ǫ ∈ (0, 1), then G′ is Ω(ǫ)-far from bipartite.4 (D) d+ max(G′) = O(d+ avg(G)). 7.3 Detecting Odd-Length Cycles in Low-Degree Graphs Lemma 38. Let G be an undirected graph on n vertices with m edges such that d+ max(G) = O(m/(ǫn)). There is an l = poly(ǫ−1 log n) such that two random walks of length l from a ran- dom vertex detect an odd-length cycle with probability at least Ω(n−1poly(ǫ/ log n)) if G is ǫ-far from bipartite, where ǫ ∈ (0, 1). Proof. For G such that d+ max(G) = O(m/(ǫn)), Kaufman et al. [KKR04, Theorem 1] (invoked with ǫ2 in place of ǫ) show that the following algorithm can be used for one-sided testing of bipartiteness: 1. Sample k = Θ(1/ǫ2) vertices v and run t = √n · poly(ǫ−1 log n) independent random walks of length l = poly(ǫ−1 log n) from each of them. 2. If for some v, two of the random walks reach the same vertex, one using an even number of steps and the other using an odd number of steps then reject. Otherwise accept. Let p be the probability of two random walks of length l from a random vertex detecting an odd-length cycle. We use p to upper bound the probability of success of the tester of Kaufman et al. [KKR04] for a graph ǫ-far from bipartite. By the union bound, it cannot succeed with probability 2(cid:1) · p ≤ k · t2 · p. Since it has to succeed with probability at least 2/3, we have 3 , and therefore, p = Ω(1/(k · t2)) = Ω(n−1 · poly(ǫ/ log n)). greater than k ·(cid:0)t k · t2 · p ≥ 2 7.4 Full Bipartiteness Tester Theorem 39. Let α ∈ (0, 1) be a fixed constant. There is an MPC algorithm for testing bipartiteness with a proximity parameter ǫ ∈ (0, 1) in a graph G with n vertices and m edges that with probability at least 1 − 1/poly(n) has the following properties: • The algorithm uses O(nα) space per machine, where α is an arbitrary fixed constant. • The total space is O(m + n · poly(ǫ−1 log n)). • The number of rounds is O(log(ǫ−1 log n)). Proof. We combine the knowledge developed in this section, and show that Algorithm 11 has the desired properties. Let G be an input graph on n vertices, and let G′ be the graph obtained by performing Line 1. By Lemma 36, G′ has O(n/ǫ) edges. Let G′′ = (V ′′, E′′) be obtained by performing Line 2. Then, by Lemma 37 we have V ′′,E′′ = Θ(n/ǫ) (by Property A) and d+ max(G′′) = O(1/ǫ)(by Property D and E(G′) = O(n/ǫ)). Moreover, by Lemma 36 and Property C of Lemma 37, if G is ǫ-far from 4Kaufman et al. in fact switch between two models and slightly different definitions of distance to bipartiteness in this statement, but up to a constant factor, they are equivalent in our setting. 42 bipartite, then G′′ is Ω(ǫ)-far from bipartite. Also, from Property B of Lemma 37 and since G′ is a subgraph of G, we have that if G is bipartite, then G′′ is bipartite as well. Next we apply Lemma 38 on G′′. Let n′′ = V (G′′) = Θ(n/ǫ). Lemma 38 states that to test whether G′′ is ǫ-far from bipartite (and consequently whether G is Θ(ǫ)-far from bipartite) it suffices to perform the following: choose the multiset S of Θ(n′′ · poly(ǫ−1 log n′′)) random vertices of G′′ (chosen with repetition); for each random vertex take two random walks of length l = poly(ǫ−1 log n′′); if the endpoints of any pair of random walks collide, then Reject, and otherwise Accept. Moreover, using that n′′ = Θ(n/ǫ), this test succeed with probability at least 1 − (1 − Ω(n−1poly(ǫ/ log n)))Θ(n·poly(log n/ǫ)) ≥ 1 − poly(1/n) for appropriately chosen constants. Now we show how to use our algorithms from Section 4 to generate the required random walks from G′′. Since vertices in S are chosen independently, by Chernoff bound we have that any vertex v appears O(poly(ǫ−1 log n′′)) times in S with probability 1− 1/poly(n). This implies that from each vertex we need to generate Θ(poly(ǫ−1 log n′′)) pairs of random walks. For that, we use Algorithm 1 with C = poly(ǫ−1 log n′′) to obtain the desired random walks in O(log l) = O(log (ǫ−1 log n)) MPC rounds and the total space of O(n·poly(ǫ−1 log n)) (see Lemma 11), where we used that n′′ = O(n/ǫ). This completes the analysis. 7.5 Additional Application: Finding Cycles in Graphs Far from Cycle-Freeness We also note that our algorithm for bipartiteness testing can be used to find cycles in graphs that are far from being cycle free. Czumaj, Goldreich, Ron, Seshadhri, Shapira, and Sohler [CGR+14] observe that the problem of finding such a cycle can be reduced to the problem of one sided bipartiteness testing by replacing each edge of the graph independently with probability 1/2 with a path of length 2. If the initial graph is far from cycle-freeness, one can show that the modified graph is far from bipartiteness. Our bipartiteness testing algorithm has one-sided error and can be used to find a pair of two short random walks from the same vertex that reveal an odd-length cycle in the modified graph. This cycle can then be mapped to a cycle in the initial graph, by contracting some sub-paths of length 2 back to the corresponding original edge. 8 Testing Expansion In this section we show how to test vertex-expansion of graphs. Our approach (see Algorithm 12) is inspired by the work of Czumaj and Sohler [CS10] and the work of Kale and Seshadhri [KS11]. In [CS10, KS11], the algorithms simulate many, e.g, Θ(√n), random walks from a small number of randomly chosen vertices. If we applied our algorithms for sampling random walks directly, we could bound the total space usage by O(m√n), which is prohibitive. So, instead, we design an approach in which we sample fewer random walks from each vertex (but much more random walks in total). For X, Y ⊆ V , let N (X, Y ) denote the vertex-neighborhood of X within Y . That is, N (X, Y ) {v ∈ Y : ∃u ∈ X such that {u, v} ∈ E}. Definition 40. Let G be an undirected graph and α > 0. We say that G is an α-vertex-expander if for every subset U ⊂ V of size at most V /2 we have N (U, V \ U ) ≥ αU. Definition 41. Let G be a graph of maximum outdegree d and ǫ > 0. We say that G is ǫ-far from an α⋆-vertex-expander if one has to change (add/remove) more than ǫdn edges of G to obtain a α⋆-vertex-expander. def = 43 Algorithm 12 gets α as its input, and returns Accept if G is an α-vertex-expander, or returns Reject if G is far from being such an expander. The idea of the algorithm is as follows. From each vertex, for O(poly log n) many times we run a pair of random walks. The length of these random walks is set in such a way that if G is an α-vertex-expander, then the endpoint of any of these walks is almost uniformly and randomly distributed over V . Hence, the endpoints of a pair of random walks from the same vertex are the same with probability very close to 1/n; if they are the same, we say that these two random walks resulted in a collision. If the number of collisions over all the vertices is significantly larger than 1, then we conclude that G is not an α⋆-vertex-expander, for some α⋆ < α that we set later. Otherwise the algorithm accepts G. Algorithm 12 ExpansionTester (G, α, ǫ): An algorithm that tests whether a given graph G of maximum outdegree d is an α-vertex-expander or G is ǫ-far from any α⋆-expander, for α⋆ = d2 ln (n/ǫ) , where c is a large enough constant. 1: Let G′ be the graph obtained from G by adding 2d − deg+(v) self-loops to each vertex v. 2: T ← 20·log3 n 3: ℓ ← 32d2 ln (n/ǫ) 4: for i ← 1 . . . T do Using Algorithm 1, generate two random walks of length ℓ for each vertex of G′. Let X i otherwise. v = 1 if the two random walks originating at v end at the same vertex, and X i v = 0 α2 cα ǫ6 5: 6: v > T + 10 log2 n ǫ3 then 7: if PT 8: 9: else 10: i=1Pv∈V X i return Reject return Accept In the rest of this section, we prove the following. Theorem 42. Let G = (V, E) be a graph of maximum outdegree d. If G is an α-vertex-expander then Algorithm 12 outputs Accept with high probability. If G is ǫ far from any α⋆-vertex-expander, where = 32d2 ln (n/ǫ) α⋆ = c·α2 . Algorithm 12 can be implemented in O(log ℓ) MPC rounds, using sublinear space per machine and O(mℓ log n) total space. d2 ln (n/ǫ) , then the algorithm outputs Reject also with high probability. Let ℓ α2 def The round and space complexity follows from Lemma 13. The Accept and the Reject cases are proved separately in Lemma 47 and Lemma 49, respectively. Our analysis and the prior work we recall are tailored to regular graphs whose random walks converge to a uniform distribution. Therefore, the algorithm first transform the given graph G into G′ by adding self-loops (see Line 1). Observe that adding self-loops does not affect vertex-cuts, and hence G′ and G have the same vertex-expansion. We will use P l v to denote the distribution of the endpoints of a random walk of length l originating at v. 8.1 Correctness of Acceptance We use the notion of TV distance, that we recall next. Definition 43. Let p1, . . . , pn and q1, . . . , qn be two probability distributions. Then, the total vari- ation distance (TVD) between these distributions is equal to 1/2Pn i=1 pi − qi. 44 In our proof that Algorithm 12 outputs Accept correctly with probability at least 2/3, we use the following results. Lemma 44 ([GR11]). Let Xv be a random variable that equals 1 if 2 random walks of length l starting from vertex v collide, and Xv = 0 otherwise. Let P l v denote the distribution of the endpoints of these random walks. Then, E [Xv] = kP l vk2. Lemma 45 (Proposition 2.8 of [GR11] and discussion thereafter). Let P l v be the distribution of the endpoints a random walk of length l starting from vertex v. Let G′ be the graph as defined on Line 1 of Algorithm 12. If G′ is an α-vertex-expander, then for ℓ as defined on Line 3 of Algorithm 12 the TVD between P l v and the uniform distribution on n vertices is upper-bounded by ǫ/n. We will use the following result to upper-bound the l2 norm of the vector P l v defined in Lemma 45. Lemma 46. Let Y ∈ Rn be a probability distribution vector. If the TVD between Y and the uniform distribution is at most ǫ/n, i.e., 1 i=1 Yi − 1/n ≤ ǫ/n, then 2Pn 1 + 4ǫ2/n . kY k2 ≤ i=1 αi ≤ ǫ/n and Pn Proof. Let yi = 1/n + αi. We have that 1/2Pn Xi=1 Xi=1 2 · 1/n · αi + (1/n + αi)2 = 1/n + kY k2 = α2 n n n n i=1 αi = 0. i = 1/n + α2 i n Xi=1 Xi=1 ≤ 1/n + n Xi=1 αi!2 ≤ 1/n + 4ǫ2/n2 = (1 + 4ǫ2/n)/n We are now ready to provide the main proof of this section. Lemma 47. If G is an α-vertex-expander, then ExpansionTester(G, α, ǫ) returns Accept with probability at least n−2. Proof. As defined on Line 6 of ExpansionTester, let X i iff the two random walks originating at v end at the same vertex. Define X def= PT corresponds to the summation of Line 7 of Algorithm 12. From Lemmas 44 to 46 we have i=1Pv∈V X i v be 0/1 random variable that equals 1 v that for any 4ǫ2T ≤ n. Also, as P ℓ 1/n and hence kP ℓ vk2 ≤ T · (1 + 4ǫ2/n) ≤ T + 1, E [X] = T Xv∈V v is the probability distribution n-dimensional vector, we have kP ℓ E [X] = T Xv∈V vk2 ≥ T = 20·log3 n kP ℓ ǫ6 , (21) vk2 ≥ (22) 45 where we used the definition of T on Line 2 of Algorithm 12. Now we can write P(cid:20)X ≥ T + 10 log2 n ǫ3 (cid:21) from (21) ≤ ≤ 10 log2 n P(cid:20)X ≥ E [X] − 1 + P(cid:20)X ≥(cid:18)1 + (cid:21) ǫ3E [X](cid:19) E [X](cid:21) 9 log2 n ǫ3 (23) From (22) we have that 9 log2 n independent. By applying Chernoff bound (Theorem 7 (C)) on (23) we derive ǫ3E[X] ≤ 1. Observe that across v and i the random variables are X i v P(cid:20)X ≥ T + 10 log2 n ǫ3 (cid:21) ≤ exp(cid:18)− 81 log4 n 3ǫ6E [X](cid:19). From E [X] ≤ T + 1 (see Eq. (21)) and for T = 20·log3 n , as defined on Line 2 of Algorithm 12, the last chain of inequalities is upper-bounded by n−1. Therefore, ExpansionTester outputs Accept with high probability, as desired. ǫ6 8.2 Correctness of Rejection We use the following result to prove that our algorithm reports Reject properly. Lemma 48 (Lemma 4.3 and Lemma 4.7 of [CS10]). Let G′ = (V, E) be a 2d-regular graph such that each vertex has at least d self-loops. Let ℓ be as defined on Line 3 of Algorithm 12, and let α⋆ = If G′ is ǫ-far from every α⋆-expander, for α⋆ ≤ 1/10, then there exists a subset of vertices U such that: d2 ln (n/ǫ) , where c is a large enough constant. cα2 • U ≤ ǫ vk2 • kP ℓ We are now ready to finalize our analysis. 24V ; and, 2 ≥ 1+9ǫ for each v ∈ U . n every α⋆-vertex-expander from Lemma 48 we have vk2 ≥ 1/n. As defined v be 0/1 random variable that equals 1 iff the two random v. Then, if G is ǫ-far from Lemma 49. Let ǫ ∈ (0, 1/5) be a parameter. If G is ǫ far from every α⋆-vertex-expander, then ExpansionTester(G, α, ǫ) returns Reject with probability at least n−2. v is a probability distribution, it holds kP ℓ Proof. For any vertex v ∈ V , as P ℓ on Line 6 of ExpansionTester, let X i walks originating at v end at the same vertex. Define X def= PT i=1Pv∈V X i vk2 vk2 +Xv∈U kP ℓ kP ℓ  n (cid:19) 24(cid:17) 1 n (cid:19) 24(cid:17) 1 3(cid:19) .  Xv∈V \U ≥ T (cid:18)(cid:16)1 − = T (cid:18)(cid:16)1 − ≥ T (cid:18)1 + E [X] = T  ǫ 24 ǫ 24 1 + 9ǫ 1 + 9ǫ ǫ2 + + ǫ ǫ n n 46 By Chernoff bound and the last inequality it holds P  X ≤  6 log n 3(cid:17) T (cid:16)1 + ǫ2   T (cid:18)1 + From the definition of T (Line 2 of Algorithm 12), we have E [X] ! E [X]# ≤ n−2. (24) ǫ2 3(cid:19)  ≤ P"X ≤ 1 −s 6 log n ǫ4 −s240 log3 n ǫ2 log4 n ǫ6 3(cid:19) ≥ T + 6 ≥ T + 6 ≥ T + log3 n ǫ4 − 16 log2 n ǫ3 10 log2 n , ǫ3 1 −vuut   1 −vuut 6 log n T (cid:16)1 + ǫ2 3(cid:17)   T (cid:18)1 + for ǫ ≤ 1/5. This together with Eq. (24) and Line 7 of Algorithm 12 concludes the proof. Acknowledgments We thank Davin Choo and Julian Portmann for valuable discussions. S. Mitrović was supported by the Swiss NSF grant P2ELP2_181772 and MIT-IBM Watson AI Lab. P. Sankowski was supported by the ERC CoG grant TUgbOAT no 772346. A Random Walks in Directed Bounded Degree Graphs In this section we show how to efficiently sample short random walks from directed graphs, provided that the outdegree of each vertex is bounded. Let dist(u, w) be the length of the shortest path from u to w. We define a ball of center v and radius, denoted by B(v, d), to be the set of vertices x of G, such that dist (v, x) ≤ d. In particular, B(v, 1) contains v and all vertices reachable from v by its outedges. Observation 50. Let G be a directed graph and let ∆ be the maximum outdegree in G. Then, for each v ∈ V (G) and any integer d ≥ 0 we have B(v, d) = O(∆d) and G[B(v, d)] = O(∆d+1). Let is first describe the high-level idea. Assume that the goal is to compute a single random walk of length log n. We can compute B(v, d) for all v and d = ǫ log n. In the next step, for each ball B(v, d) we compute G[B(v, d)]. Then, to find a random walk starting from any vertex v, we can compute ǫ log n steps of that random walk in a single round on a single machine that knows G[B(v, d)]. Hence, only O(1/ǫ) steps like this are needed to compute a random walk of length log n. At the same time, if ∆ is a constant, we only need O(n1+ǫ) space to store all graphs G[B(v, d)]. In the remaining part of this section, we describe the details of this approach. 47 B(v, 1) := {v} ∪ {x vx ∈ E} 2: 3: r := ǫ/2 log∆ n 4: r := 2⌊log2 r⌋ 5: for i ← 1 . . . log2 r do for all v ∈ V in parallel do B(v, 2i) :=Sx∈B(v,2i−1) B(x, 2i−1) 8: for v ∈ V do a0 v,v = av 9: 10: for i ← 1 . . . l/r do for all t such that ∃tai−1 Compute G[B(t, r)] for all s such that ai−1 s,t s,t 6= 0 in parallel do 6= 0 in parallel do 6: 7: 11: 12: 13: 14: 15: Algorithm 13 An algorithm for sampling av random walks of length l starting from vertex v (for each v ∈ V ). 1: for all v ∈ V in parallel do ⊲ Round down to a power of two ⊲ For the pseudocode, assume that r divides l Use G[B(t, r)] to compute ai−1 s,t For each random walks computed in the previous step which ends in t′ increase ai length r random walks from t s,t′ Lemma 51. Algorithm 13 is correct. Proof. The first step is to show that the algorithm correctly computes the sets B(v, 2i) for all v and i = 1, . . . , log2 r. This follows directly from the fact that B(v, 2i) :=Sx∈B(v,2i−1) B(x, 2i−1). The random walk themselves are computed by the loop in lines 10-15. Each iteration of the loop extends all random walks by r edges. The algorithm uses variables ai s,t to represent its state, as follows. After the i-th iteration, the algorithm has computed ai s,t random walks of length i · r, which start in s and end in t. For each v ∈ V and i the algorithm maintains the invariant that Pt∈V ai To extend the random walks by r steps, we use the basic fact that a length-r random walk from v is fully contained in G[B(v, r)]. Hence, having G[B(v, r)] is enough to compute r steps of a random walk. It follows easily that the variables ai s,t are updated correctly. Finally, we note that the pseudocode assumes that r divides l, but this assumption can be easily dropped by computing only l mod r steps of random walk in the last iteration of the main loop. v,t = av. Lemma 52. Assume that Pv∈V av = O(n1+ǫ). For any ǫ > 0, Algorithm 13 can be implemented in MPC model to run in O(log log n + l log ∆/(ǫ log n)) rounds, using O(m + n1+ǫ) total space and O(nǫ) space per machine, where ∆ is the maximum degree in the graph and log ∆/ log n = o(1). Proof. Lines 1 -- 9 can be implemented in the MPC model in a straightforward way, so in the proof we focus on the remaining part of the algorithm. Let us first bound the space needed to store G[B(v, r)] for all v. Note that r ≤ ǫ log n/(2 log ∆). By Observation 50 we have G[B(v, r)] = O(∆r+1) = O(nǫ/2+log ∆/ log n) = O(nǫ). Hence, storing G[B(v, r)] for all v ∈ V requires O(n1+ǫ) total space. In the i-th iteration of the algorithm there are ct :=Ps∈V ai−1 s,t random walks that end in t and need to be extended by using G[B(t, r)]. For each such walk that ends in t′ we increase as,t′. In 48 order to make sure that each machine ends up increasing at most O(nǫ) counters as,t′, we use the following batching strategy. Recall that for each vertex t, we need to compute ct random walks In order to do that we use ⌈ct/nǫ⌉ machines, each of which computes G[B(v, r)] starting in t. independently. The total space used by all the machines is then Xt∈V ⌈ct/nǫ⌉O(nǫ) ≤Xt∈V (ct/nǫ + 1)O(nǫ) = O(n1+ǫ) +Xt∈V ct = O(n1+ǫ) +Xv∈V av = O(n1+ǫ) By combining the lemmas from this section we obtain the following. Theorem 53. Let l > 0, G be a directed graph with maximum outdegree bounded by ∆ and let {av}v∈V be a sequence such that Pv∈V av = O(n1+ǫ). There exists an MPC algorithm that for each v ∈ V computes av endpoints of random walks of length l starting from av. The algorithm uses O(log log n + l log ∆/(ǫ log n)) rounds, O(m + n1+ǫ) total space and O(nǫ) space per machine. Note that with l = O(log n) and ∆ = poly log n we get O(log log n) rounds. Moreover, if ∆ = O(1), we can set ǫ = 1/ log log n and use only O(m + n1+o(1)) total space. B Handling Dangling Vertices From theoretical point of view, when dangling vertices are present the transition matrix for the PageRank walks is not stochastic. In particular, the largest eigenvector is no longer equal to 1. Hence, many ways to handle dangling vertices have been proposed, see e.g., [Ber05b]. For example, we can delete them, we can lump them to one vertex and add self-loop, we can add a self-loop to them, each dangling vertex can be linked to an artificial vertex with a self-loop (sink) or we can connect each dangling vertex to every other vertex. The first solution is often mentioned even in the original PageRank paper, however, it is infeasible in our case, as it requires finding strongly connected components first. This last solution seems to be the most accepted and the most widely used one, as it can be interpreted as restarting the random walk from a random state if we reach a dangling vertex. In this paper, we assume that one of the above solutions has been already applied to our graph and, therefore, every vertex has at least one outgoing edge. Still, in this section, we give a novel relation between two most widely applied methods to handle dangling vertices. We have made a through literature study and to the best of our knowledge these relations have not been observed before. Usually, one heuristically argues that these approaches give similar results. We give formal proofs that it is indeed the case. We show that adding self-loops and restarting the walks are equivalent up to a simple transformation. In the case when dangling vertices are present the transition matrix of our graph T = T (G) can be decomposed into the following blocks where the bottom k rows correspond to dangling vertices without any out edges. Adding self-loops gives us the following transition matrix T =(cid:20)T1 0 T2 0(cid:21) , T s =(cid:20)T1 0 I(cid:21) . T2 49 Note that the way we defined transition matrices T and T s means that the entry at row u and column v corresponds to incoming arc to u from v. Hence, a stationary distribution of T is a right eigenvector of T . The PageRank matrix of T s is given by (1 − ǫ)T s + ǫ n J =(cid:20)(1 − ǫ)T1 + ǫ (1 − ǫ)T2 + ǫ n Jn−k,n−k n Jk,n−k ǫ n Jn−k,k (1 − ǫ)I + ǫ n Jk,k(cid:21) , (25) where Ji,j refers to an all 1 matrix of size i× j. We denote by πs =(cid:20)πs 1 πs 2(cid:21) the stationary distribution of the above PageRank matrix. When we consider restarting the walks we obtain the following matrix The PageRank matrix of T r is given by T r =(cid:20)T1 T2 1 n Jk,k (cid:21) . n Jn−k,k 1 (1 − ǫ)T r + ǫ n J =(cid:20)(1 − ǫ)T1 + ǫ (1 − ǫ)T2 + ǫ n Jn−k,n−k n Jk,n−k 1 n Jk,k (cid:21) , n Jn−k,k 1 (26) 1 πr 2(cid:21) being the stationary distribution. In the rest of this section, given a vector x ∈ Rn, with πr =(cid:20)πr we use x to denote that l1 norm of x. Theorem 54. Let πr and πs be the stationary distribution vectors as defined above. Then, it holds and πr 1 = 1 1 + πs ǫ − ǫπs 1 πs 1 πr 2 = 1 1/ǫ − πs 2/ǫ + πs 2 πs 2. Proof. Let us first consider the upper blocks of (25) when used in the stationary equation. We obtain πs 1 = ǫ n ǫ n ǫ n 1 + ǫ (cid:16)(1 − ǫ)T1 + J(cid:17) πs nπs J(cid:17) πs (cid:16)I − (1 − ǫ)T1 − 1 = ǫ 2(cid:16)I − (1 − ǫ)T1 − nπs n J(cid:1)−1 ~1. J(cid:17) πr (cid:16)(1 − ǫ)T1 + (cid:16)I − (1 − ǫ)T1 − 1 nπr J(cid:17) πr 1 = 1 + ǫ n ǫ n 50 1 2~1 = πs ǫ 2~1 nπs ǫ J(cid:17)−1 nπs ~1 = 2g, 2~1 = πr 1. 1 nπr 2~1. where g =(cid:0)I − (1 − ǫ)T1 − ǫ Now, consider the upper blocks of (26). Also from the stationary equation we derive (27) πr 1 = 1 nπr 2(cid:16)I − (1 − ǫ)T1 − ǫ n 1 are parallel to g, and hence πr 1 and πs J(cid:17)−1 1 nπr 2g. ~1 = (28) 1 = xπs 1, for From (27) with (28) we conclude that both πr some x ∈ R. Next we consider lower blocks of (25) and (26). From the lower blocks of (25) we establish (29) (30) 2, for some y ∈ R. We have that πs 1 = 1 − πs 2 and 2 + 1 ǫ 2~1 = πs nπs 2~1 = ǫπs 2. ǫ n 1 + 2g + ǫ n ǫ n (cid:16)(1 − ǫ)T2 + J(cid:17) πs 1 + (1 − ǫ)πs ǫ ǫ (cid:16)(1 − ǫ)T2 + J(cid:17) πs nπs n By plugging the last equality into (27) we get J(cid:17) ǫ (cid:16)(1 − ǫ)T2 + nπs J(cid:17) 1 (cid:16)(1 − ǫ)T2 + nπs 2g + 2(cid:18)(cid:16)(1 − ǫ)T2 + J(cid:17) 1 ǫ πs n (cid:16)(1 − ǫ)T2 + J(cid:17) πr J(cid:17) 1 (cid:16)(1 − ǫ)T2 + nπr 2g + 2(cid:18)(cid:16)(1 − ǫ)T2 + J(cid:17) 1 πr 2 = yπs 2, so from (27) and (28) we obtain Again by (29) and (30) we see that πr 1 = 1 − πr πr Plugging the lest equality into (28) leads to The lower blocks of (26) give 1 + g + g + ǫ n ǫ n ǫ n n n 2 ǫ 2~1 = ǫπs nπs 1 2~1 = πs nπs ~1(cid:19) = πs 1 n 2. 2 1 nπr 2~1 = πr 2. 2 1 2~1 = πr nπr ~1(cid:19) = πr 1 n 2. 1 − πs 2 = which implies ǫ nπs 2g and 1 − πr 2 = 1 nπr 2g, 1 − πs 2 = ǫ nπs 2g and 1 − yπs 2 = 1 n yπs 2g. By solving these two equations for y we obtain Using the same approach to x we get what finishes the proof. y = 1 2/ǫ + πs 1/ǫ − πs 2 . x = 1 1 + πs ǫ − ǫπs 1 , 51 Theorem 54 has a few consequences. First of all, one can easily see that scores of vertices in πr 1 are all higher than scores of vertices in πs 1. More importantly, we can easily obtain πr in O(1) MPC rounds from πs. We note that πs are much easier to compute as obtaining them requires only minor graph modification, i.e., adding self-loops to dangling vertices. Whereas, the scores πr are the most widely accepted ones. References [ABB+19] Sepehr Assadi, MohammadHossein Bateni, Aaron Bernstein, Vahab Mirrokni, and Cliff Stein. Coresets meet EDCS: algorithms for matching and vertex cover on massive graphs. In Proceedings of the Thirtieth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 1616 -- 1635. SIAM, 2019. [ACK19] [ACL06] Sepehr Assadi, Yu Chen, and Sanjeev Khanna. Sublinear algorithms for (∆ + 1) vertex coloring. In Proceedings of the Thirtieth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 767 -- 786. Society for Industrial and Applied Mathematics, 2019. Reid Andersen, Fan R. K. Chung, and Kevin J. Lang. Local graph partitioning using PageRank vectors. In 47th Annual IEEE Symposium on Foundations of Computer Science (FOCS 2006), 21-24 October 2006, Berkeley, California, USA, Proceedings, pages 475 -- 486, 2006. [ALNO07] Konstantin Avrachenkov, Nelly Litvak, Danil Nemirovsky, and Natalia Osipova. Monte Carlo methods in PageRank computation: When one iteration is sufficient. SIAM Journal on Numerical Analysis, 45(2):890 -- 904, 2007. [ANOY14] Alexandr Andoni, Aleksandar Nikolov, Krzysztof Onak, and Grigory Yaroslavtsev. Par- allel algorithms for geometric graph problems. In Proceedings of the 46th ACM Sym- posium on Theory of Computing, STOC 2014, New York, NY, USA, May 31 -- June 3, 2014, pages 574 -- 583, 2014. [ASS+18] Alexandr Andoni, Zhao Song, Clifford Stein, Zhengyu Wang, and Peilin Zhong. Parallel graph connectivity in log diameter rounds. In 2018 IEEE 59th Annual Symposium on Foundations of Computer Science (FOCS), pages 674 -- 685. IEEE, 2018. [ASW19] Sepehr Assadi, Xiaorui Sun, and Omri Weinstein. Massively parallel algorithms for find- ing well-connected components in sparse graphs. In Proceedings of the 2019 ACM Sym- posium on Principles of Distributed Computing, PODC 2019, Toronto, ON, Canada, July 29 - August 2, 2019., pages 461 -- 470, 2019. [BBCT12] Christian Borgs, Michael Brautbar, Jennifer Chayes, and Shang-Hua Teng. A sublinear time algorithm for PageRank computations. In International Workshop on Algorithms and Models for the Web-Graph, pages 41 -- 53. Springer, 2012. [BCX11] Bahman Bahmani, Kaushik Chakrabarti, and Dong Xin. Fast personalized PageRank on MapReduce. In Proceedings of the ACM SIGMOD International Conference on Management of Data, SIGMOD 2011, Athens, Greece, June 12-16, 2011, pages 973 -- 984, 2011. 52 [BDE+19] Soheil Behnezhad, Laxman Dhulipala, Hossein Esfandiari, Jakub Łącki, and Vahab Mirrokni. Near-optimal massively parallel graph connectivity. FOCS, 2019. [Ber05a] Pavel Berkhin. A survey on PageRank computing. Internet Mathematics, 2(1):73 -- 120, 2005. [Ber05b] Pavel Berkhin. A survey on pagerank computing. Internet Math., 2(1):73 -- 120, 2005. [BFU18] Sebastian Brandt, Manuela Fischer, and Jara Uitto. Matching and MIS for uniformly sparse graphs in the low-memory MPC model. arXiv preprint arXiv:1807.05374, 2018. [BHH19] Soheil Behnezhad, MohammadTaghi Hajiaghayi, and David G Harris. Exponentially faster massively parallel maximal matching. FOCS, 2019. [BKS13] [BP98] [BP11] Paul Beame, Paraschos Koutris, and Dan Suciu. Communication steps for parallel query processing. In Proceedings of the 32nd ACM SIGMOD-SIGACT-SIGART Symposium on Principles of Database Systems, PODS 2013, New York, NY, USA, June 22 -- 27, 2013, pages 273 -- 284, 2013. Sergey Brin and Lawrence Page. The anatomy of a large-scale hypertextual web search engine. Computer networks and ISDN systems, 30(1-7):107 -- 117, 1998. Marco Bressan and Luca Pretto. Local computation of PageRank: the ranking side. In Proceedings of the 20th ACM international conference on Information and knowledge management, pages 631 -- 640. ACM, 2011. [BPP18] Marco Bressan, Enoch Peserico, and Luca Pretto. Sublinear algorithms for local graph centrality estimation. In 59th IEEE Annual Symposium on Foundations of Computer Science, FOCS 2018, Paris, France, October 7-9, 2018, pages 709 -- 718, 2018. [Bre02] LA Breyer. Markovian page ranking distributions: some theory and simulations. 2002. [CFSV16] Keren Censor-Hillel, Eldar Fischer, Gregory Schwartzman, and Yadu Vasudev. Fast distributed algorithms for testing graph properties. In Distributed Computing - 30th International Symposium, DISC 2016, Paris, France, September 27-29, 2016. Proceed- ings, pages 43 -- 56, 2016. [CGR+14] Artur Czumaj, Oded Goldreich, Dana Ron, C. Seshadhri, Asaf Shapira, and Chris- tian Sohler. Finding cycles and trees in sublinear time. Random Struct. Algorithms, 45(2):139 -- 184, 2014. [CGS04] Yen-Yu Chen, Qingqing Gan, and Torsten Suel. Local methods for estimating PageRank values. In Proceedings of the thirteenth ACM international conference on Information and knowledge management, pages 381 -- 389. ACM, 2004. [CKK+18] A. Chiplunkar, M. Kapralov, S. Khanna, A. Mousavifar, and Y. Peres. Testing graph clusterability: Algorithms and lower bounds. In 2018 IEEE 59th Annual Symposium on Foundations of Computer Science (FOCS), pages 497 -- 508, Oct 2018. 53 [CŁM+18] Artur Czumaj, Jakub Łącki, Aleksander Mądry, Slobodan Mitrović, Krzysztof Onak, and Piotr Sankowski. Round compression for parallel matching algorithms. In Pro- ceedings of the 50th Annual ACM SIGACT Symposium on Theory of Computing, pages 471 -- 484. ACM, 2018. [CMOS19] Artur Czumaj, Morteza Monemizadeh, Krzysztof Onak, and Christian Sohler. Planar graphs: Random walks and bipartiteness testing. Random Structures & Algorithms, 2019. [Col88] Richard Cole. Parallel merge sort. SIAM Journal on Computing, 17(4):770 -- 785, 1988. [CPS15] Artur Czumaj, Pan Peng, and Christian Sohler. Testing cluster structure of graphs. In Proceedings of the Forty-seventh Annual ACM Symposium on Theory of Computing, STOC '15, pages 723 -- 732, New York, NY, USA, 2015. ACM. [CS10] Artur Czumaj and Christian Sohler. Testing expansion in bounded-degree graphs. Combinatorics, Probability and Computing, 19(5-6):693 -- 709, 2010. [DCGR05] Gianna M. Del Corso, Antonio Gullí, and Francesco Romani. Fast pagerank computa- tion via a sparse linear system. Internet Math., 2(3):251 -- 273, 2005. [DGP11] Atish Das Sarma, Sreenivas Gollapudi, and Rina Panigrahy. Estimating PageRank on graph streams. J. ACM, 58(3):13:1 -- 13:19, 2011. [DMPU15] Atish Das Sarma, Anisur Rahaman Molla, Gopal Pandurangan, and Eli Upfal. Fast distributed PageRank computation. Theor. Comput. Sci., 561(PB):113 -- 121, January 2015. [DNPT13] Atish Das Sarma, Danupon Nanongkai, Gopal Pandurangan, and Prasad Tetali. Dis- tributed random walks. J. ACM, 60(1):2:1 -- 2:31, 2013. [DSB09] Neelam Duhan, AK Sharma, and Komal Kumar Bhatia. Page ranking algorithms: a survey. In 2009 IEEE International Advance Computing Conference, pages 1530 -- 1537. IEEE, 2009. [GGK+18] Mohsen Ghaffari, Themis Gouleakis, Christian Konrad, Slobodan Mitrović, and Ronitt Rubinfeld. Improved massively parallel computation algorithms for MIS, matching, and vertex cover. Proceedings of the 37th ACM Principles of Distributed Computing (PODC 2018), 2018. [GKK13] Ashish Goel, Michael Kapralov, and Sanjeev Khanna. Perfect matchings in O(n log n) time in regular bipartite graphs. SIAM J. Comput., 42(3):1392 -- 1404, 2013. [GKMS18] Buddhima Gamlath, Sagar Kale, Slobodan Mitrović, and Ola Svensson. Weighted matchings via unweighted augmentations. arXiv preprint arXiv:1811.02760, 2018. [GKU19] Mohsen Ghaffari, Fabian Kuhn, and Jara Uitto. Conditional hardness results for mas- sively parallel computation from distributed lower bounds. FOCS, 2019. 54 [GLM19] Mohsen Ghaffari, Silvio Lattanzi, and Slobodan Mitrović. Improved parallel algorithms for density-based network clustering. In International Conference on Machine Learning, pages 2201 -- 2210, 2019. [GR99] [GR11] [GSZ11] [GU19] [HLL18] [HZ96a] [HZ96b] [Jin19] [JS96] Oded Goldreich and Dana Ron. A sublinear bipartiteness tester for bounded degree graphs. Combinatorica, 19(3):335 -- 373, 1999. Oded Goldreich and Dana Ron. On testing expansion in bounded-degree graphs. In Studies in Complexity and Cryptography. Miscellanea on the Interplay between Ran- domness and Computation, pages 68 -- 75. Springer, 2011. Michael T. Goodrich, Nodari Sitchinava, and Qin Zhang. Sorting, searching, and sim- ulation in the MapReduce framework. In International Symposium on Algorithms and Computation, pages 374 -- 383. Springer, 2011. Mohsen Ghaffari and Jara Uitto. Sparsifying distributed algorithms with ramifications in massively parallel computation and centralized local computation. In Proceedings of the Thirtieth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 1636 -- 1653. SIAM, 2019. Nicholas JA Harvey, Christopher Liaw, and Paul Liu. Greedy and local ratio algorithms in the MapReduce model. In Proceedings of the 30th on Symposium on Parallelism in Algorithms and Architectures, pages 43 -- 52. ACM, 2018. Shay Halperin and Uri Zwick. An optimal randomised logarithmic time connectivity algorithm for the EREW PRAM. J. Comput. Syst. Sci., 53(3):395 -- 416, 1996. Shay Halperin and Uri Zwick. Optimal randomized EREW PRAM algorithms for find- ing spanning forests and for other basic graph connectivity problems. In Proceedings of the Seventh Annual ACM-SIAM Symposium on Discrete Algorithms, SODA '96, pages 438 -- 447, Philadelphia, PA, USA, 1996. Society for Industrial and Applied Mathematics. Ce Jin. Simulating random walks on graphs in the streaming model. In 10th Innovations in Theoretical Computer Science Conference, ITCS 2019, January 10-12, 2019, San Diego, California, USA, pages 46:1 -- 46:15, 2019. Mark Jerrum and Alistair Sinclair. The Markov chain Monte Carlo method: an ap- proach to approximate counting and integration. Approximation algorithms for NP-hard problems, pages 482 -- 520, 1996. [KKR04] Tali Kaufman, Michael Krivelevich, and Dana Ron. Tight bounds for testing bipartite- ness in general graphs. SIAM J. Comput., 33(6):1441 -- 1483, 2004. [KM09] Jonathan A. Kelner and Aleksander Mądry. Faster generation of random spanning trees. In 50th Annual IEEE Symposium on Foundations of Computer Science, FOCS 2009, October 25-27, 2009, Atlanta, Georgia, USA, pages 13 -- 21, 2009. [KNP99] David R. Karger, Noam Nisan, and Michal Parnas. Fast connected components algo- rithms for the EREW PRAM. SIAM J. Comput., 28(3):1021 -- 1034, 1999. 55 [KS11] [KSV10] [LF80] [LM04] Satyen Kale and Comandur Seshadhri. An expansion tester for bounded degree graphs. SIAM Journal on Computing, 40(3):709 -- 720, 2011. Howard J. Karloff, Siddharth Suri, and Sergei Vassilvitskii. A model of computation for MapReduce. In Proceedings of the 21st Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2010, Austin, Texas, USA, January 17 -- 19, 2010, pages 938 -- 948, 2010. Richard E Ladner and Michael J Fischer. Parallel prefix computation. Journal of the ACM (JACM), 27(4):831 -- 838, 1980. Amy N Langville and Carl D Meyer. Deeper inside PageRank. Internet Mathematics, 1(3):335 -- 380, 2004. [LMSV11] Silvio Lattanzi, Benjamin Moseley, Siddharth Suri, and Sergei Vassilvitskii. Filtering: a method for solving graph problems in MapReduce. In Proceedings of the twenty-third annual ACM symposium on Parallelism in algorithms and architectures, pages 85 -- 94. ACM, 2011. [LPS86] [Mar73] [NS10] [Ona18] Alexander Lubotzky, Ralph Phillips, and Peter Sarnak. Explicit expanders and the Ramanujan conjectures. In Proceedings of the 18th Annual ACM Symposium on Theory of Computing, May 28-30, 1986, Berkeley, California, USA, pages 240 -- 246, 1986. Gregory A. Margulis. Explicit constructions of expanders. Problemy Peredachi Infor- matsii, 9(4):71 -- 80, 1973. Asaf Nachmias and Asaf Shapira. Testing the expansion of a graph. Inf. Comput., 208(4):309 -- 314, 2010. Krzysztof Onak. Round compression for parallel graph algorithms in strongly sublinear space. arXiv preprint arXiv:1807.08745, 2018. [PBMW99] Lawrence Page, Sergey Brin, Rajeev Motwani, and Terry Winograd. The PageRank ci- tation ranking: Bringing order to the web. Technical Report 1999-66, Stanford InfoLab, November 1999. [Rei85] John H. Reif. An optimal parallel algorithm for integer sorting. In Proceedings of the 26th Annual Symposium on Foundations of Computer Science, SFCS '85, pages 496 -- 504, Washington, DC, USA, 1985. IEEE Computer Society. [RVW18] Tim Roughgarden, Sergei Vassilvitskii, and Joshua R Wang. Shuffles and circuits (on lower bounds for modern parallel computation). Journal of the ACM (JACM), 65(6):41, 2018. 56
1602.08730
5
1602
2017-08-04T23:07:24
Improved bounds and algorithms for graph cuts and network reliability
[ "cs.DS" ]
Karger (SIAM Journal on Computing, 1999) developed the first fully-polynomial approximation scheme to estimate the probability that a graph $G$ becomes disconnected, given that its edges are removed independently with probability $p$. This algorithm runs in $n^{5+o(1)} \epsilon^{-3}$ time to obtain an estimate within relative error $\epsilon$. We improve this run-time through algorithmic and graph-theoretic advances. First, there is a certain key sub-problem encountered by Karger, for which a generic estimation procedure is employed, we show that this has a special structure for which a much more efficient algorithm can be used. Second, we show better bounds on the number of edge cuts which are likely to fail. Here, Karger's analysis uses a variety of bounds for various graph parameters, we show that these bounds cannot be simultaneously tight. We describe a new graph parameter, which simultaneously influences all the bounds used by Karger, and obtain much tighter estimates of the cut structure of $G$. These techniques allow us to improve the runtime to $n^{3+o(1)} \epsilon^{-2}$, our results also rigorously prove certain experimental observations of Karger & Tai (Proc. ACM-SIAM Symposium on Discrete Algorithms, 1997). Our rigorous proofs are motivated by certain non-rigorous differential-equation approximations which, however, provably track the worst-case trajectories of the relevant parameters. A key driver of Karger's approach (and other cut-related results) is a bound on the number of small cuts: we improve these estimates when the min-cut size is "small" and odd, augmenting, in part, a result of Bixby (Bulletin of the AMS, 1974).
cs.DS
cs
IMPROVED BOUNDS AND ALGORITHMS FOR GRAPH CUTS AND NETWORK RELIABILITY1 DAVID G. HARRIS2 AND ARAVIND SRINIVASAN3 7 1 0 2 g u A 4 ] S D . s c [ 5 v 0 3 7 8 0 . 2 0 6 1 : v i X r a Abstract. Karger (SIAM Journal on Computing, 1999) developed the first fully-polynomial approximation scheme to estimate the probability that a graph G becomes disconnected, given that its edges are removed independently with probability p. This algorithm runs in n5+o(1)ǫ−3 time to obtain an estimate within relative error ǫ. We improve this run-time through algorithmic and graph-theoretic advances. First, there is a certain key sub-problem encountered by Karger, for which a generic estimation procedure is employed; we show that this has a special structure for which a much more efficient algorithm can be used. Second, we show better bounds on the number of edge cuts which are likely to fail. Here, Karger's analysis uses a variety of bounds for various graph parameters; we show that these bounds cannot be simultaneously tight. We describe a new graph parameter, which simultaneously influences all the bounds used by Karger, and obtain much tighter estimates of the cut structure of G. These techniques allow us to improve the runtime to n3+o(1)ǫ−2; our results also rigorously prove certain experimental observations of Karger & Tai (Proc. ACM-SIAM Symposium on Discrete Algorithms, 1997). Our rigorous proofs are motivated by certain non- rigorous differential-equation approximations which, however, provably track the worst-case trajectories of the relevant parameters. A key driver of Karger's approach (and other cut-related results) is a bound on the number of small cuts: we improve these estimates when the min-cut size is "small" and odd, augmenting, in part, a result of Bixby (Bulletin of the AMS, 1974). KEYWORDS: Graph reliability, graph cuts, contraction algorithm AMS Classification: 05C31, 05C40, 05C85. 1. Introduction Let G be a connected undirected multi-graph with vertex set V ; as usual, we let V = n. Unless stated otherwise, the graphs we deal with will be multi-graphs with no self-loops, presented in adjacency-matrix for- mat. We define R(p), the reliability polynomial of G, to be the probability that the graph remains connected when edges are removed independently with probability p. One can verify that this is a polynomial in p. This polynomial has various physical applications, for example determining the reliability of a computer network or power grid. Although there is no currently known algorithm for estimating R(p), the complementary probability U (p) = 1 − R(p), which we call the unreliability of the graph, can be estimated in polynomial time. In a breakthrough paper ([8], see also [9]), Karger developed the first fully-polynomial randomized approximation scheme (FPRAS) to estimate U (p) up to relative error ǫ in time polynomial in n and 1/ǫ; even a constant-factor approximation was not known prior to his work. We let exp(x) denote ex; all logarithms are to base e unless indicated otherwise. With an appropri- ate choice of parameters, Karger's algorithm can run in time exp(cid:0)3 log n +qlog n(4 log n + √2 log(1/ǫ)) + o(log n)(cid:1). In particular, if ǫ = Θ(1), this is n5+o(1). (We assume that ǫ ≤ O(1), say ǫ ≤ 1/2, throughout.) Karger's algorithm is based on an algorithm for finding graphs cuts which have close to minimal weight. This algorithm is the Contraction Algorithm, first introduced by [7]. This algorithm has emerged as an important 1 A preliminary version of this work appeared in the Proc. ACM-SIAM Symposium on Discrete Algorithms (SODA), 2014. 2Department of Computer Science, University of Maryland, College Park, MD 20742. Research supported in part by NSF Awards CNS-1010789 and CCF-1422569. Email: [email protected]. 3Department of Computer Science and Institute for Advanced Computer Studies, University of Maryland, College Park, MD 20742. Research supported in part by NSF Awards CNS-1010789 and CCF-1422569, and a research award by Adobe, Inc. Email: [email protected]. 1 building block for many graph algorithms. Just as importantly, it can be viewed as a stochastic process which provides structural results about the graph cuts, for example, a bound on the number of small cuts. In this paper, we provide a more detailed analysis of the Contraction Algorithm and its consequences. This enables us to show a variety of improved bounds and algorithms for graph problems. The focus of this paper is on improving the algorithm for estimating U (p). The following definition will be useful: Definition 1.1. The minimum cut-size in G, also known as the edge-connectivity of G, will be denoted by c. Given α ≥ 1, an "α-cut" in G is a cut with at most αc edges. Our results. The main focus of our analysis is a much faster algorithm for estimate U (p): Theorem 1.2. There is an algorithm to estimate U (p) in time n3+o(1)ǫ−2. Our analysis of the Contraction Algorithm will also allow purely structural bounds on the cut structure of certain graphs: Theorem 1.3. Suppose c is odd and α ≥ 1. Then there are at most O(n2α c optimal, in the sense that there are counter-examples to bounds of the form O(nαx) for any x < 2c c+1 ) α-cuts. This exponent is c+1 . In [12], an algorithm called the Recursive Contraction Algorithm was developed for finding all α-cuts. We obtain a small improvement to this algorithm for the general problem of finding α-cuts. Unlike the previous improvements, this only reduces the logarithmic terms: Theorem 1.4. There is an algorithm that accepts as input a graph G and a real number α ≥ 1. This algorithm succinctly enumerates, with high probability, all α-cuts of G in time O(n2α log n). By contrast, the algorithm of [12] requires time O(n2α log2 n). We note that our algorithm focuses on estimating the parameter U (p), but there are other connectivity measures for which a strategy of enumerating "representative" cuts may be used. [8] gives a similar type of algorithm for estimating multi-way connectivity and [4] discusses an algorithm for estimating parameters related to clustering. Obtaining an FPRAS -- or even a constant-factor approximation -- for R(p) remains a very intriguing open problem. 1.1. Overview of Karger's algorithm, and our improvements. Karger's algorithm for estimating U (p) essentially consists of two separate algorithms, depending on the size of U (p). When U (p) > n−2−δ, where δ is some constant, then Monte Carlo sampling provides an accurate estimate. As the samples are unbiased with relative variance 1/U (p), then after n2+δǫ−2 samples we estimate U (p) accurately. Naively, it might appear to require O(m) time per sample (one must process each edge). A clever sparsification strategy described in Karger [8] reduces this to n1+o(1) time per sample. We will not modify Karger's algorithm for Monte Carlo sampling. When U (p) is small, Monte Carlo sampling no longer can produce an accurate estimate in reasonable time. In the regime U (p) < n−2−δ, Karger develops an alternative algorithm. In this case, Karger shows that the event of graph failure is dominated by the event that a small cut of G has failed. This is done by analyzing the number of cuts of small weight. In particular, there is some α∗ such that U (p) is closely approximated by the probability that an α∗-cut has failed. Karger provides an upper bound on the critical value α∗; for example, when ǫ = Θ(1), we have α∗ ≤ 1 + 2/δ = O(1). This significantly simplifies the problem, because instead of having to consider the exponentially large collection of all cuts of G, we can analyze only the polynomial-size collection of α∗-cuts. Using an algorithm developed in [12], the Recursive Contraction Algorithm, Karger's algorithm can catalogue all such α∗-cuts in time n2α∗+o(1). We refer to this as the cut-enumeration phase of Karger's algorithm. Note that there is a tradeoff between the Monte Carlo phase and cut-enumeration phase, depending on the size of δ. Having catalogued all such small cuts, we need to piece them together to estimate the probability that one of them has failed. For this, Karger uses as a subroutine a statistical procedure developed by Karp, Luby, Madras [14]. This procedure can examine any collection of partially overlapping clauses, to provide an unbiased estimate with relative error O(1) that one such clause is satisfied. By running ǫ−2 iterations of this, we achieve the desired error bounds for U (p). The running time is linear in the size of the collection of clauses. We refer to this as statistical sampling phase of Karger's algorithm. 2 We will improve both the cut-enumeration phase and statistical sampling phase of Karger's algorithm. To improve the cut-enumeration phase, we will show a tighter bound on α∗. In [13], a version of Karger's algorithm was programmed and tested on real graphs. This found experimentally that the average number of cuts needed to accurately estimate the graph failure probability was about n3, not the worst case n5 as predicted by [8]. In this paper, we show this fact rigorously. We will show that the number of small graph cuts in reliable graphs is far smaller than in general graphs. The basic idea is to analyze the dynamics of the Contraction Algorithm, and to show that any small cut C has a large probability of being selected by this algorithm. This analysis is quite difficult technically, because it requires analyzing the three-way interconnections between the number of α-cuts of G, the effectiveness of the Contraction Algorithm, and the value of U (p). The critical parameter that ties these three together is the expected number of failed graph cuts. Our improvement to the statistical sampling phase is more straightforward. The algorithm of [14] is able to handle very general collections of clauses, which can overlap in complicated ways. However, this is unnecessary for our purposes. We will show that the collection of cuts produced by the cut-enumeration phase has a simple distribution, both statistically and computationally. This allows us to use a faster and simpler statistical procedure to piece together the α∗-cuts. As a result, the running time of each sample reduces to about n2; in particular, we do not need to read the entire collection of α∗-cuts for each sample. In total, we reduce the running time of Karger's algorithm to about n3+o(1)ǫ−2. Obtaining faster run- times with Karger's recipe appears to be quite difficult; for if c is the size of the min-cut, then in the regime where pc ≥ n−2+Ω(1), it is not clear how to stop only at "small" cuts, and one appears to need Monte-Carlo sampling -- which requires a runtime that matches ours. We note that another approach to estimating U (p) has been discussed in [17]. This algorithm finds a pair of minimal cuts which are mostly disjoint, and hence there is a negligible probability that both cuts fail simultaneously. By continuing this process, it is found in [17] experimentally that a branching process can efficiently enumerate the probability that some small cut fails. While this algorithm is promising, the analysis of [17] is fully experimental, and it appears that in the worst case this approach might require super-polynomial time. Around the time of our finalizing the published version of this work, a newer algorithm by Karger was developed for estimating U (p), which is not based on cut-enumeration [11]. This algorithm has a run-time of O(n3polylog(n)/ǫ2), which is strictly better than ours. 1.2. Analyzing the trajectory of stochastic processes. The Contraction Algorithm is at the heart of our algorithm, and our main contribution is giving an improved and tighter analysis of it. This is a complex stochastic process, which applies a sequence of random transformations to the graph G. A single step can radically alter the trajectory of this process. In the original paper [12] which introduced this algorithm, very simple and elementary methods were used to bound its behavior. These bounds can be tight for general graphs, but for other types of graphs these bounds are not accurate. However the analysis has not been improved since [12]. To analyze the Contraction Algorithm, we introduce a new methodology for approximating stochastic systems by continuous, deterministic dynamical systems. We believe this method may have applications to other types of systems, and we will describe it here at a high level of generality. Suppose we want to upper-bound E[f (G)], where f is some function of the stochastic process we are interested in (for us, essentially f counts the number of edges found in the graphs produced at intermediate stages of the Contraction Algorithm). We begin by making any number of heuristic guesses as to the behavior of the process. These guesses can be totally unjustified and are often nothing more than wishful thinking. For example, we may assume that any or all random variables are deterministic; we may assume that certain parameters are as large as possible; we replace the discrete time intervals with continuous time. In this way, we develop a dynamical system which we believe should approximate the behavior of E[f (G)]. This dynamical system can be solved to produce some function f (G); we guess (hope) that E[f (G)] ≤ f (G) for all graphs G. So far, our approach mirrors that of [18], which gave general strategies for analyzing stochastic systems. According to [18], the next stage of the solution would be to prove that our assumptions were approximately correct. For example, instead of treating a random variable as deterministic, we may use concentration inequalities to prove that it is centered around its mean (and thus is nearly deterministic). In the case of 3 the Contraction Algorithm, this approach does not seem to work; we are not able to show concentration inequalities for the relevant random variables. The reason is that a single step of the Contraction Algorithm, namely contracting an edge, can change the graph in a far-reaching way; this makes it hard to show the type of "local effect" required for a concentration inequality. By contrast, we will prove that any violation of these heuristic assumptions will only help us; we do not necessarily show that the heuristic assumptions are true or approximately true. We will use induction on G to prove that for any graph G we have E[f (G)] ≤ f (G). To explain how this works, for expository purposes suppose that the function f only depends on the final stage of the stochastic process and that f is a function not of the full graph G but only a single, simple-to- compute parameter φ(G), so that f (G) = g(φ(G)) (for example, φ(G) is the number min-cuts of G). Now, after the initial time-step of the stochastic process, the graph G transforms into the graph H (where now H is a random variable). Thus, we now have E[f (G)] = EH [E[f (H)]]; here we are splitting the expectation into two pieces -- the random choice for the first time-step, and the random choices for the remaining time-steps. We will now use our induction hypothesis applied to the subgraph H; this gives us that E[f (H)] ≤ f (H). Thus, so far we have shown that E[f (G)] ≤ EH[ f (φ(H))]. Now, suppose that the function g(x) happens to be an increasing, concave-down function of x. In this case, we can apply Jensen's inequality to this expression, deriving EH[ f (H)] ≤ g(E[φ(H)]), and hence that E[f (G)] ≤ g(E[φ(H)]). Thus, in order to continue the induction proof, we merely need to show that g(E[φ(H)]) ≤ g(φ(G)) We have thus reduced our trajectory analysis to computing E[φ(H)] (which involves only a single time- step of the stochastic process and the relatively simple function φ) and a simple inequality for a concrete function g. Overall, this process depends very heavily on the concavity and monotonicity properties of the function f . This is very similar to how one can apply Jensen's inequality to interchange the expectation of a function with the function of its expectation. So, in a sense we can view our method as a "generalized Jensen's inequality" for stochastic systems. 1.3. Outline. In Sections 2 and 3, we begin by reviewing some key results and definitions concerning graph cuts. Most of these results are recapitulations of Karger [8]. In Section 4, we describe a new statistical sampling algorithm for the following problem: given a fixed collection A of cuts, what is the probability that at least one cut from A fails? We show that this algorithm has a faster running time, and is just as accurate, compared to the algorithm of [14] used in [8, 9]. Although this sampling algorithm is the final part of our overall algorithm to estimate U (p), we will discuss it first because it is relatively self-contained and because it is less technically challenging than the rest of the paper. In Section 5, we introduce the Contraction Algorithm, an algorithm described by [12]. This algorithm provides an efficient randomized procedure for finding small-weight cuts in G. It also can be viewed as a probabilistic process which can provide purely structural bounds on G. We will be interested in the following question, which is more general than that considered by [12]: suppose we are given a fixed target cut C of G. Under what circumstances does the Contraction Algorithm select C? What can we say about the dynamics of the Contraction Algorithm in those cases in which C will ultimately be selected ? We will prove a series of technical Lemmata which describe these dynamics. Roughly speaking, we "factor out" C to show that the Contraction Algorithm has a uniform behavior regardless of which target cut C (if any) we are interested in. In Section 6 we apply this machinery to analyze the Contraction Algorithm in the case in which the (unweighted) graph G has c an odd number. These results are not necessary for our analysis of Karger's algorithm. We include them here for two reasons. First, the number of small cuts is basically known in the case of even c -- the worst case behavior comes from a cycle graph, in which there are n vertices in a ring with c/2 edges between successive vertices. The case of odd c has been mostly overlooked in the literature. Second, the case of small odd c provides an easier warm-up exercise for the analysis in Section 7. In Section 6, we keep track of the number of min-cuts remaining in G during the evolution of the Contraction Algorithm; in Section 7 we must keep track of the number of cuts of all sizes. Section 7 analyzes how the dynamics of the Contraction Algorithm are affected by the magnitude of U (p). The critical parameter is ¯Z, the expected 4 number of failed cuts in G. We show how ¯Z affects the number of edges which are available in any round of the Contraction Algorithm, and we show how ¯Z itself changes during the execution. The proof method used in Sections 6 and 7 follows the outline of Section 1.2. We give a function f , and prove by induction that the probability of a cut surviving the Contraction Algorithm is at least f . This function f is very complicated and could not have been guessed from first principles. Instead, we first simplify our stochastic process using unwarranted independence and monotonicity assumptions (for example, we assume that the subgraphs produced during the Contraction Algorithm have as few edges as possible subject to the minimum-cut condition), and then translate the stochastic time-steps into a differential equation which can be solved in closed form. This heuristic analysis gives us the mysterious function f , which we then rigorously prove correct. In particular, these "unwarranted independence and monotonicity assumptions" actually correspond to the worst-case behavior of our stochastic process! In Section 8, we apply the analysis of Section 7 to show that α∗, which is the bound of the size of the cuts necessary to approximate U (p), is smaller than the bound given by Karger. We note that while Karger gave a simple bound which could be computed explicitly, our bound depends on the graph parameter ¯Z which we cannot determine easily. However, using this formula, one can determine an upper bound on the total number of iterations of the Contraction Algorithm that are needed to find the α∗-cuts; this bound is irrespective of ¯Z. In Section 9, we analyze the Recursive Contraction Algorithm. This is an algorithm which allows us to run the Contraction Algorithm "in bulk". If we are interested in finding many graph cuts, we must run the Contraction Algorithms multiple times. However, most of the work for processing the graph can be amortized across these multiple runs. In particular, we can essentially reduce the running time for the Contraction Algorithm from n2 (dominated by reading the original graph) to na where a is a small constant. In Section 10, we describe how to combine all the pieces and obtain a full algorithm. This includes deciding when to use Monte Carlo sampling and when to enumerate the small cuts, a detail omitted in Karger [8]. Finally, Section 11 concludes. 2. Preliminaries For a multi-graph G, we define a cut of G to be a partition of the vertices into two classes V = A ⊔ A′, with A, A′ 6= ∅. The sets A, A′ are the shores of the cut. We distinguish this from an edge-cut, which is a subset E′ of the edges of G such that removal of E′ disconnects G. Every cut of G induces an edge-cut of G, namely the edges crossing from A to A′. The weight or size of an edge-cut is the number of edges it contains. We say an edge-cut is minimum if it has the smallest size of all edge-cuts, and we denote by c the size of the smallest edge-cut. We say an edge-cut is minimal if no proper subset is an edge-cut. We will often abuse notation so that a cut C may refer to either the vertex-partition or the edge-cut it induces. Unless stated otherwise, whenever we refer to a cut C, we view C as a set of edges. As mentioned before, for any α ≥ 1 we define an α-cut to be a cut (not necessarily minimal) whose corresponding edge-cut has at most αc edges, and we define a min-cut to be a 1-cut, i.e. a cut of weight c exactly. In this paper, we seek to estimate the probability that the graph becomes disconnected when edges are removed independently with probability p. When edges are removed in this way, we say that an edge-cut fails if and only if all the corresponding edges are removed. In this case, we may concern ourselves solely with cuts. The reason for this is that graph G becomes disconnected if and only if some cut of G fails. This method can be generalized to allow each edge to have its own independent failure probability pe. As described in [8], given a graph G with non-uniform edge failure probabilities, one can transform this to a multi-graph G′ with uniform edge failure probabilities by replacing each edge of G with a bundle of edges, and setting p appropriately. We will assume that the graph G is presented as an adjacency matrix with n2 words. Each word records the number of edges that are present between the indicated vertices. As described in [7], it is possible to transform an arbitrary graph, in which the number of edges may be unbounded, into one with cells of size O(log(1/ǫ) + log n) with similar reliability; hence the arithmetic operations will take polylogarithmic time in any computational model. This transformation may have a running time which is super-polynomial in n, although it is close to linear time as a function of the input data size. We will ignore these issues, and simply assume that we can perform arithmetic operations to precision ǫ and random number generation of an entire word in a single time step. 5 As our algorithm closely parallels Karger's, we use the notation of [8] wherever possible. Recall that c is the size of the smallest edge-cut. As in [8], we let pc = n−2−δ, with δ > 0 being the case of primary interest (the complementary case can be handled by simple Monte-Carlo sampling). We note that δ can be determined in time n2+o(1), simply by finding the size of the minimum cut. Hence we can assume δ is known. Often we will derive estimates assuming δ ≥ δ0; here δ0 can be an arbitrarily small positive constant. This assumption allows us to simplify many of the asymptotic notations, whose constant terms may depend on δ0. In fact, our algorithm is best balanced when δ → 0. It is not hard to see that all of our asymptotic bounds when δ ≥ δ0 can be relaxed to allow δ → 0 sufficiently slowly, for example as δ = 1/ log log log log n. When we analyze α-cuts, we are primarily interested in the case when α is a slow-growing function. (In fact, the case where α = O(1) would be basically sufficient to analyze all of our algorithmic improvements.) We will show how to bound the number of such cuts. The following is a well-known theorem of [6], and indeed, the rest of this section is basically a recapitulation of Karger's work from [6]. Theorem 2.1. ([6]) The number of α-cuts is at most n2α. The following combinatorial principle, which is basically a form of integration by parts, will be used in a variety of contexts. Proposition 2.2. Let F : R → [0,∞) be any increasing function with distributional derivative dF (x) and with the property that, for any α ≥ 1, the number of α-cuts is at most F (α). Let g : R → [0,∞) be any continuous decreasing function. Then g(C/c) ≤ F (α)g(α) +Z ∞ x=α XCuts C of weight C≥αc g(x)dF (x) Proof. Enumerate the weights of all cuts whose weight is at least αc in sorted order as αc ≤ r1 ≤ r2 ≤ ··· ≤ rk. Observe that for any i = 1, . . . , k the definition of F implies that i ≤ F (ri/c). Then XCuts C of weight g(C/c) = C≥αc k Xi=1 ≤ F (rk/c)g(rk/c) + g(ri/c) = kg(rk/c) + k−1 k−1 Xi=1 i(cid:16)g(ri/c) − g(ri+1/c)(cid:17) Xi=1 F (ri/c)(cid:16)g(ri/c) − g(ri+1/c)(cid:17) as i ≤ F (ri/c) and g(ri/c) − g(ri+1/c) ≥ 0 g(ri/c)(cid:16)F (ri/c) − F (ri−1/c)(cid:17) g(ri/c)Z ri/c dF (x)(cid:17) + Xi=2Z ri/c g(r1/c)dF (x) + Xi=2 x=ri−1/c k k k x=α = g(r1/c)F (r1/c) + Xi=2 = g(r1/c)(cid:16)F (α) +Z r1/c = F (α)g(r1/c) +Z r1/c ≤ F (α)g(α) +Z r1/c = F (α)g(α) +Z rk/c x=α x=α x=α dF (x) x=ri−1/c g(ri/c)dF (x) g(x)dF (x) + g(x)dF (x) as g is decreasing k Xi=2Z ri/c x=ri−1/c g(x)dF (x) ≤ F (α)g(α) +Z ∞ x=α g(x)dF (x) (cid:3) Combining Proposition 2.2 and Theorem 2.1, gives a simple proof of the following result from [8]: 6 Corollary 2.3. Let 0 < q < n−2−Ω(1), α ≥ 1. Then XCuts C of weight C≥αc qC/c = O((n2q)α) Proof. Apply Proposition 2.2, using F (x) = n2x and g(x) = qx. We have XCuts C of weight qC/c ≤ qαn2α +Z ∞ x=α C≥αc qx × 2n2x log n dx = (n2q)α − ≤ (n2q)α(cid:16)1 − = O((n2q)α) 2(n2q)α log n log(n2q) = (n2q)α(cid:16)1 − log n2 log(n2n−2−Ω(1))(cid:17) log n2 log(n2q)(cid:17) (cid:3) The following result is as example of this principle; it will later be strengthened in Proposition 8.1. Corollary 2.4. ([8]) Suppose δ ≥ δ0 for some constant δ0 > 0. Then the probability that a cut of weight ≥ αc fails is at most O(n−αδ). Proof. By the union-bound, P(Cut of weight ≥ αc fails) ≤ XCuts C of weight (pc)C/c. C≥αc Now apply Corollary 2.3. (cid:3) This leads to one of the key theorems of Karger's original work: Theorem 2.5. ([8]) Suppose δ ≥ δ0 for some constant δ0 > 0. Then U (p) can be approximated, up to relative error O(ǫ), by the probability that a cut of weight ≤ α∗c fails, where α∗ = 1 + 2/δ − log ǫ δ log n Proof. The absolute error committed by ignoring cuts of weight ≥ α∗c is at most the probability that such a cut fails; by Corollary 2.4 it is at most O(n−α∗δ). The minimum cut of G fails with probability pc = n−2−δ, so U (p) ≥ pc = n−2−δ. Hence the relative error committed by ignoring cuts of weight ≥ α∗c is at most Rel err = O( n−α∗δ n−2−δ ) = O(ǫ) (cid:3) We do not want to get ahead of ourselves, but one of the main goals of this paper will be to improve on the estimate of Theorem 2.5. In proving Theorem 2.5, we used two quite different bounds. These bounds are tight separately, but for very different kinds of graphs. In estimating the absolute error, we bound the number of α-cuts that may appear in G by O(n2α). This is tight for cycle graphs, as discussed in Lemma 3.2, which have a very large number of cuts. On the other hand, when we estimate U (p) ≥ pc, we are assuming that the graph has just a single small cut. As we will show, no graph can have both bounds be simultaneously tight. 7 We define the random variable Z to be the number of cuts of G which fail when edges are removed independently with probability p. The expectation of Z, also known as the partition function is 3. The total number of failed cuts pC. ¯Z = Xcuts C This is an overestimate of the graph failure probability which ignores the overlap between the cuts. The number of failed cuts Z, and its expectation ¯Z, will play crucial roles in our estimates. We take here an approach based on [1], inspired by establishing a connection between the number of failed cuts and an appropriately scaled binomial random variable. Proposition 3.1. Suppose we remove a subset L of edges from G, and the resulting graph H has R connected components. Then L causes exactly 2R−1 − 1 cuts of G to fail. Proof. Any partition of the R components corresponds to a failed cut. (cid:3) Lemma 3.2. Let pc = n−2−δ for δ ≥ δ0 > 0. Suppose we remove edges from G with probability p. Let H denote the resulting graph and let R be its number of connected components. Then for n sufficiently large and r ≥ 1 we have P(R ≥ r) ≤ 1.01n−rδ/2/r! Proof. As shown in [15], [16], [8], the probability that H has ≥ r connected components under edge-failure probability p, is at most the probability that the graph C has ≥ r connected components under edge failure q = pc/2, where C is the cycle graph which contains n vertices and a single edge between successive vertices in the cycle. If r edges fail in C, then the resulting number of distinct components is max(1, r). Hence the probability that C results in r distinct components is the probability that a binomial random variable, with n trials and success probability q, is at least r: P(≥ r connected components) ≤ n Xi=r(cid:18)n i(cid:19)qi(1 − q)n−i ≤ n Xi=r ni(ni(−2−δ)/2/r!) ≤ n(δ/2)(1−r) r!(nδ/2 − 1) As δ > δ0 > 0, then nδ/2 ≥ 1000 for n ≥ Ω(1). Thus nδ/2 − 1 ≥ 0.999nδ/2 and we have P(≥ r connected components) ≤ Thus ¯Z is bounded within a relatively small range: n(δ/2)(1−r) 0.999r!nδ/2 ≤ 1.01n−δr/2/r! (cid:3) Corollary 3.3. For δ ≥ δ0 > 0 and for n sufficiently large, n−2−δ ≤ ¯Z ≤ n−δ Proof. The lower bound ¯Z ≥ n−2−δ follows since the probability that any one min-cut fails is n−2−δ. To show the upper bound, we have ¯Z = E[Z] = E[2R−1 − 1] =Xr≥2 P(R ≥ r)2r−2 2r−2n−rδ/2 r! ≤ 1.01Xr≥2 ≤ 0.26(cid:16)−2n−δ/2 + e2n−δ/2 − 1(cid:17) by Lemma 3.2 For n sufficiently large, the exponent 2n−δ/2 approaches 0. As ex ≤ 1 + x + 0.51x2 for x sufficiently close to 0, it follows that as desired. ¯Z ≤ 0.26(cid:0)−2n−δ/2 + (1 + 2n−δ/2 + 0.51 × 4n−δ) − 1(cid:1) = 0.5304n−δ 8 (cid:3) In light of Corollary 3.3, it is often convenient to write pc = n−2−δ ¯Z = n−2−δ+β Here, δ, β should be thought of as "parameters" of the graph; δ measures the probability that the smallest cut of G fails, while β ∈ [0, 2] counts the number of small cuts. The case β ≈ 0 means there is only a single small cut and the other cuts are very large; the case β ≈ 2 corresponds to the cycle graph. This parametrization will appear many times throughout this paper. We will always assume that δ > δ0 > 0, where δ0 is a constant which may be made arbitrarily small. All of the hidden asymptotic terms may depend on δ0. We will not state this explicitly for the remainder of the paper. We next show that the expected number of failed cuts remains small, even after conditioning on rare events: Proposition 3.4. Let E be an event with probability P(E). Then E[Z E] ≤ O(P(E)− 2 δ log2 n ) Proof. Let q = P(E). If n < O(1), then Z ≤ 2n ≤ O(1) while q− 2 may assume that n is larger than any necessary constant throughout this proof. δ log2 n ≥ 1, and so the result holds. So we Then: E[Z E] = E[2R−1 − 1 E] ≤ ∞ Xr=1 2r−1P(R ≥ r E) ≤ 2r−1 min(1, P(R ≥ r) q ) ∞ Xr=1 ) by Proposition 3.2 2r−1 min(1, 1.01 nrδ/2q ∞ ≤ ⌈x⌉−1 Xr=1 Xr=1 ≤ 2⌈x⌉ + ≤ ≤ 2x+1 + ≤ 2x+1 + ≤ O(2 2r−1 + 1.01 × 2r−1 qnrδ/2 ∞ Xr=⌈x⌉ q(nδ/2 − 2) 1.01 × 2⌈x⌉−1n(δ/2)(1−⌈x⌉) where x = 2 log(1/q) δ log n as 2n−δ/2 < 1 2x+1n(δ/2)(1−x) q(nδ/2 − 2) 2x+1n(δ/2)(1−x) q(nδ/2/2) 2 log(1/q) δ log n ) = O(q− 2 δ log2 n ) for n > 24/δ As an application of Proposition 3.4, we show that ¯Z is nearly equivalent asymptotically to U (p), although (cid:3) the former is much more tractable. Proposition 3.5. For δ ≥ δ0 > 0, we have U (p) = Θ( ¯Z) . Proof. By the union bound, U (p) ≤ ¯Z. Now note that E[Z] = E[Z Z ≥ 1]P(Z ≥ 1). So U (p) = P(Z ≥ 1) = E[Z] E[ZZ≥1] . So it suffices to show that E[Z Z ≥ 1] = O(1). For this we have: E[Z Z ≥ 1] ≤ O(U (p)− 2 δ log2 n ) by Proposition 3.4 ≤ O((n−2−δ)− 2 = O(22+4/δ) ≤ O(22+4/δ0 ) = O(1) δ log2 n ) as U (p) ≥ pc = n−2−δ As in Karger, our strategy will be to use Monte Carlo estimation for U (p) when U (p) is large. The cut-enumeration will be only be performed when U (p) is small. For this, we have the following useful bounds: 9 (cid:3) Proposition 3.6. Let K > 2 be an arbitrary constant. Then for U (p) < n−K and n sufficiently large, we have the following: (1) δ ≥ K − 2 > 0. (2) δ ≥ β + Ω(1). (3) β ∈ [0, 2]. Proof. First, observe that if a min-cut fails, then G fails, so U (p) ≥ pc = n−2−δ. This implies that δ ≥ K− 2. So we may set δ0 = K − 2 > 0, which satisfies (1). Also, by Proposition 3.5, we have U (p) = Θ( ¯Z) = Θ(n−2−δ+β). Hence β ≤ 2 + δ − K + O(1/ log n) ≤ −Ω(1) + δ + O(1/ log n). This implies that for n sufficiently large β ≤ δ − Ω(1). The bound β ∈ [0, 2] is simply a restatement of Proposition 3.3. For the majority of this paper, we will assume that U (p) < n−K for some fixed K > 2, and that n is sufficiently large. Thus, all of the conclusions of Proposition 3.6 hold. We will note this at the beginning of each relevant section; all the results in that section may depend on this assumption and all the resulting asymptotic notations may depend upon K. (cid:3) 4. Estimating the failure probability for a collection of cuts In this section, we address the following statistical problem. Suppose we are given some collection A consisting of N cuts, which includes at least one min-cut. We define the failure probability of A as In this section, we will assume U (p) < n−K for some constant K > 2; thus the conclusions of UA(p) = P(at least one cut from A fails) Proposition 3.6 hold. Our goal here is to estimate UA(p) to within relative error ǫ. This is a key subroutine for Karger's algorithm, and it will also be used for ours. For this, Karger uses an elegant algorithm developed by Karp, Luby, Madras [14]; in this context, that algorithm has a running time of roughly n2N ǫ−2. We will give a new algorithm running in time O(N polylog(N n) + n2ǫ−2). We make some elementary observations first. Let us define the random variable where we use the Iverson notation so that [C fails] is 1 if C fails, and 0 otherwise. [C fails], ZA = XC∈A Then UA(p) = P(ZA ≥ 1). Clearly UA(p) ≤ U (p) and ZA ≤ Z. Also, UA(p) ≥ pc as A contains at least one min-cut. 4.1. Data structures for A. Each cut in A might require Ω(n) space to store explicitly and thus even reading A might require Ω(N n) time. We will give a running time which may be smaller than this, and thus we must store and generate A in a compressed form. Instead of storing the full information about each cut C ∈ A, we will store three smaller pieces of information, each taking just O(log(N n)) words of storage, instead: (1) A unique identifier for C (2) The weight of C (3) A pointer which allows us to fully reconstruct C in time O(n2) In order to assign every cut of A a unique identifier, we may use a simple random hashing scheme. We choose a random function H : V → [2b], where b = φ log N and φ > 0 is some constant. We then define the identifier for a cut C which has shores A, V − A with vertex 1 in A, by H(C) = Pv∈A b(v) where the sum is taken modulo 2b. It is not hard to see that for φ a sufficiently large that with high probability all cuts of A receive distinct identifiers. Because the cuts of C are assigned distinct identifiers, we may sort A and remove any duplicates in time O(N log2(N n)). Thus, we may assume that after an additional pre-processing step, we have that N ≤ 2n. This is a crude bound, but it will be sufficient for many purposes of analyzing our algorithm. Proposition 4.1. Suppose that A has been sorted. Then given any cut C of G, there is an algorithm running in time O(n2) to determine if C ∈ A. 10 Proof. We compute H(C) in time O(n). As all the cuts of A receive distinct identifiers, there is at most one C′ ∈ A with H(C′) = H(C). An index to the cut C′ can be found via binary search in time O(b log N ) ≤ O(log2 N ). Using our crude bound N ≤ 2n, this is at most O(n2). Now, if there is no such C′ ∈ A, then we know that C /∈ A and we are done. Otherwise, C ∈ A if and only if C = C′. To check this, we use the pointer to fully reconstruct C′ from its index; this step takes O(n2). At this stage, both C and C′ are represented explicitly so they can be compared in time O(n). (cid:3) 4.2. The statistical estimation algorithm. We take as our starting point a simpler algorithm, which was presented as a toy or warm-up exercise in Karp, Luby, Madras [14]. We will see how to implement it faster than their alternative, more sophisticated algorithms. PC∈A pC independently with probability p. Let H = G − Q − L. 1. Select a cut Q from A with probability ∝ pQ. 2. Let L be a random subset of the edges in G − Q, in which each such edge is chosen 3. Count how many cuts in A have failed in H; let J denote the number of such cuts. 4. Estimate UA = We can perform step (1) by choosing a random real number in the range [0,P pC] and then performing a binary search; as A explicitly stores the weight of all the cuts, this step can be implemented (with some pre-processing) in time O(log(N n)). The main cost of this algorithm is step (3). If A is an arbitrary collection of edge sets, then seemingly the only way to do this would be to check each member of A to see whether it failed in H. This would require roughly O(mN ) time per execution. This high running time is the main motivation for the more sophisticated algorithm of [14]. . J However, A is a collection of cuts, and we can significantly accelerate step (3) by taking advantage of this fact. We implement step (3) by enumerating all the failed cuts of H, and checking for each if it is present in A. We will show that H typically has a small number of cuts, and so this step is relatively inexpensive. We first show that UA is a good estimator for UA(p), which in turn is a good estimator for U (p). Proposition 4.2. For any cut C ∈ A, the distribution of H in step (2) of this estimation procedure, conditional on Q = C, is the same as the distribution of the graph G′ resulting from edge failures, conditional on the event that C fails. For any cut C ∈ A, the distribution of J conditional on Q = C is the same as the distribution of ZA conditional on the event that C fails. Proof. Because the edge failures are independent, then conditioning on the event that C fails is equivalent to removing the edges of C and letting the remaining edges fail independently. This is exactly the random distribution of graphs selected in step (2) of our estimation algorithm. (cid:3) Proposition 4.3 ([14]). The statistic UA is an unbiased estimator, viz. E[ UA] = UA(p) Proof. The proof is shown originally in [14]; we present a modified proof here for completeness. then we choose one failed cut of A uniformly at random, and mark it. Consider the following random process: we randomly allow edges to fail with probability p. If ZA ≥ 1, Note that some cut of A fails if and only if exactly cut in A is marked. So P (C marked) UA(p) = XC∈A = XC∈A = XC∈A = XC∈A =(cid:0)XC∈A by Proposition 4.2 P (C fails)E[1/ZA C fails] pCE[1/J Q = C] P (Q = C)(cid:0)XC∈A pC(cid:1)E[1/J] = E[ UA] 11 pC(cid:1)E[1/J Q = C] Proposition 4.4. Suppose that C ∈ A. Let H be the graph resulting from removing C and allowing other edges to fail independently. Let Z denote the total number of failed cuts of H. Then Proof. We have that E[Z Q = C] ≤ eO(C/c) (cid:3) E[Z Q = C] = E[Z C fails] ≤ O((pC)− 2 δ log2 n ) by Proposition 4.2 by Proposition 3.4 2(C/c)(2+δ) δ = O(2 = 2O(C/c) ) (cid:3) Proposition 4.5. Suppose that A contains a min-cut. Then E[ U 2 A] ≤ O(E[ UA]2) That is, the statistic UA has relative variance O(1). Proof. We have E[U 2 A Ω(1). ]/E[UA]2 = E[1/J 2]/E[1/J]2 ≤ 1/E[1/J]2. Thus, it will suffices to show E[1/J] ≥ First, we claim that there is some constant x > 1 such that P(Q ≤ xc) ≥ 1/2. For, pc P(Q ≥ xc) = PC∈A,C≥xc pc PC∈A ≤ PC≥xc pC ≤ O(n2+δn−(2+δ)xn2x) < 1/2, n−2−δ as A contains a min-cut by Corollary 2.3 for x sufficiently large constant Now, conditional on the event that Q ≤ xc, by Proposition 4.4 we have that E[Z] ≤ eO(x). As J ≤ Z, this implies that E[1/J] ≥ E[1/J Q ≤ xc]P(Q ≤ xc) ≥ 1/(xc)P (Q ≤ xc) ≥ e−O(x) × 1/2 ≥ (cid:3) Ω(1). Finally, we prove that we can execute this estimation procedure relatively quickly -- much more quickly than by reading in the entire collection A: Proposition 4.6. Suppose that A contains a min-cut. Then, after preprocessing steps, the expected running time of the estimation algorithm is O(n2). Proof. We can enumerate the connected component structure of H in time O(n2). By Proposition 4.1, it requires O(n2) to check whether any cut of H is present in A. Thus, we may compute J in overall running time is O(Zn2). Thus, the expected time for this step is ≤ O(n2)E[Z]. We estimate E[Z] by breaking up the sum in contributions from small cuts (weight is ≤ xc) and big cuts (weight > xc); here x is a parameter we will discuss later. E[Z] = E[Z Q ≤ xc]P(Q ≤ xc) + XC∈A C>xc E[Z Q = C]P(Q = C) = 2O(x) + XC∈A,C>xc ≤ 2O(x) + XC∈A,C>xc E[Z Q = C]P(Q = C) Proposition 4.4 E[Z Q = C] 12 pC pC ′ PC ′∈A E[Z Q = C]pC as A contains a min-cut E[Z C failed]pC Proposition 4.2 ≤ 2O(x) + n2+δ XC∈A,C>xc ≤ 2O(x) + n2+δ XC∈A,C>xc ≤ 2O(x) + n2+δ XC>xc ≤ 2O(x) + n2+δO(n−δx) eO(C/c)pC Proposition 4.4 Corollary 2.3 Now setting x = 1 + 2/δ = O(1), we see that this overall expression is O(1). (cid:3) We summarize our estimation procedure: Proposition 4.7. Let A be a collection of cuts which includes at least one min-cut. Then there is an algorithm for estimating UA(p) to within relative error ǫ with probability > 0.99, and running in time O(N polylog(N n) + n2ǫ−2). Proof. We have pre-preprocessing steps including sorting A and computingPC∈A After this, a single iteration has relative error O(1) and costs O(n2) expected time. We repeat λǫ−2 independent trials of this algorithm. This reduces the relative variance of the resulting unbiased statistic to O(λ−1ǫ−1). By Chebyshev's inequality, for λ sufficiently large, the resulting statistic estimates UA(p) to relative error ǫ with probability > 0.99. (cid:3) pC which can be executed in time O(N polylog(N n)). 5. The Contraction Algorithm We now turn our attention to how to find a representative set of cuts to use to estimate U (p). Key to this is an algorithm of [12] for finding cuts in a graph. This algorithm is called the Contraction Algorithm, and is based on a graph transformation called contraction which will appear throughout this paper. Given a graph G and an edge e = hx, yi of G, then we define the contraction G/e by identifying x and y. More formally, we create a new vertex labeled xy, we delete the vertices x, y and for each edge hx, vi ∈ G we create a new edge hxy, vi; similarly, for each each hy, vi ∈ G we create a new edge hxy, vi. If there are any loops created by this process, we delete them. Suppose that a graph H is derived from G by performing a series of contractions. Then we say that H is a contraction-subgraph of G. Every vertex of H corresponds to a set of vertices in G, any edge of H corresponds to an edge of G, and any cut of H corresponds to a cut of G. Given a cut C of G, we say that C survives in H if C corresponds to some cut of H; equivalently, this holds if every edge of C corresponds to some edge of H. We often abuse notation, so that for any edge e ∈ H we also write e to refer to the corresponding edge of G. For any set of edges L = {e1, . . . , el}, we may also define G/L as follows. We initially set H1 = G and proceed through the edges e ∈ L one by one; if edge ei is present in Hi then Hi+1 = Hi/ei; otherwise, Hi+1 = Hi. We then define G/L = Hl+1. Although this definition depended on the ordering of the edges in L, it is a simple exercise to see that changing this ordering does not change G/L. The Contraction Algorithm takes as input a parameter α, which is roughly speaking the size of the cuts that it is designed to find. We define the Contraction Algorithm with parameter α as follows: 1. Initialize Gn = G. 2. Repeat for i = n, n − 1, . . . ,⌈2α⌉ + 1: 3. Select an edge Fi of Gi uniformly at random. 4. Set Gi−1 ← Gi/Fi selects C) 5. Output a cut C sampled uniformly from G⌈2α⌉. (We say the Contraction Algorithm At each stage i of the Contraction Algorithm, the graph Gi has exactly i vertices. We let Mi denote the number of edges in Gi. We refer to the sequence of edges hFn, Fn−1, . . . , F⌈2α⌉i as the history of the Contraction Algorithm; note that the full sequence of graphs Gi is completely determined by Fn, . . . , F⌈2α⌉+1. 13 1. Initialize Gn = G. 2. Repeat for i = n, n − 1, . . . , 1: 3. If all the edges of Gi are in L, then terminate the loop. 4. Otherwise, select an edge Fi of Gi − L uniformly at random. 5. Set Gi−1 ← Gi/Fi We may also refer to the history of the Contraction Algorithm up to stage i, which we denote by F>i; by this we mean the sequence of edges F>i = hFn, . . . , Fi+1i; these determine Gn, . . . , Gi uniquely. We are only partially interested in the Contraction Algorithm as an algorithm per se. We will often instead view it as a stochastic process which allows us to analyze the number of cuts that are present in the graph. We refer to this stochastic process as CA(G). Thus we may write, for instance ECA(G)[Mi]; this means that we are taking the expected value of the number of edges present in the graph Gi, when we run the Contraction Algorithm starting with graph G. In this type of analysis, we regard C as fixed. We refer to C as the target cut. We will show that, for an arbitrary cut C, the Contraction Algorithm selects C with at least a certain In order probability. for the Contraction Algorithm to find the target cut C, a necessary condition is that C must remain in the final G⌈2α⌉. (This is not a sufficient condition, as we still must randomly select C among the cuts of G⌈2α⌉.) If C remains in G⌈2α⌉, then we say that CA(G) succeeded and we say that C survived. We also say that C survived the Contraction Algorithm. We emphasize that this only for the purposes of analysis; the Contraction Algorithm itself is run without any target in mind. When we run the Contraction Algorithm with parameter α, we say that a cut C survived to stage i if C remains in Gi. Sometimes we may say that C survives to stage i without specifying the parameter α; here we assume that α is any arbitrary real number which is at most i/2. This is acceptable because Gi does not depend on α itself, only whether i ≥ 2α. The contraction process for C. When we fix a target cut C, we may imagine a related stochastic process which we refer to as the Contraction Process. This process may be defined more broadly in terms of any edge-set L, and we denote it by CP(G, L): If this process terminates at stage i (that is, all the edges of Gi are in L), then we say that Gj = ⊥ for j < i. Note that it is possible for some edge of L to become contracted, even though they are not themselves selected, if another edge with the same end-points is selected. This never happens if L is a cut; in the Contraction Process for C, all the edges of C remain present in the resulting contraction-subgraphs. Finally, observe that one may view the Contraction Algorithm as a special case, namely CA = CP(G,∅). For i = 1, . . . , n let Mi denote the number of edges in the graph Gi. We begin with some useful elementary bounds on M . Every vertex of v of the graph Gr defines a cut, namely, v is on one shore and all the other vertices are on the other shore. As the minimum cut size is c, this implies that every vertex must have degree ≥ c, so Mr ≥ rc/2. Thus during the process CP(G, L), as long as L ≤ rc/2 then Gr 6= ⊥. In fact, this bound will always hold in our analysis, so that we will never need to deal with the case of Gr = ⊥. The following proposition shows the connection between the Contraction Algorithm and the Contraction Process for a cut C: Proposition 5.1. Suppose that en, . . . , ei+1 are edges of G but not edges of the cut C and let Mi+1, . . . , Mn denote their edge counts. Then PCA(G)(F>i = hen, . . . , ei+1i) =(cid:16) n Yr=i+1 (1 − C Mr )(cid:17)PCP(G,C)(F>i = hen, . . . , ei+1i) when the Contraction Algorithm is applied with parameter ⌈2α⌉ ≤ i. Proof. We prove this by induction on G. The base case is when G has i vertices; in this case both the LHS and RHS are easily seen to be one. So we now consider the induction step. In the first stage of the Contraction Algorithm, we select some . Conditional on this event, the remaining edge Fn uniformly from G. The probability that Fn = en is stages of the Contraction Algorithm are equivalent to the Contraction Algorithm applied to the graph G/ Fn = G/en. The edge en is not present in C, and so cut C remains a cut of G/en. So we can apply the 1 Mn 14 induction hypothesis to it. PCA(G)(F>i = hen, . . . , ei+1i) = 1 Mn 1 Mr n−1 PCA(G/en)(F>i = hen−1, . . . , ei+1i) Yr=i+1 (1 − C (1 − C (1 − C )(cid:17)PCP(G/en,C)(F>i = hen−1, . . . , ei+1i) )(cid:17) Mn − C )(cid:17)PCP (G,C)(F>i = hen, en−1, . . . , ei+1i) Mr Mr 1 n = Mn(cid:16) =(cid:16) Yr=i+1 =(cid:16) Yr=i+1 n PCP(G/en,C)(F>i = hen−1, . . . , ei+1i) ind. hypothesis and the induction is proved. (cid:3) Corollary 5.2. Let C be any cut. The probability that cut C survives to the ith stage of the Contraction Algorithm (i.e. the probability that cut C is present in the graph Gi), is exactly equal to P(C survives to Gi) = ECP (G,C)h n Yr=i+1 (1 − C Mr )i Proof. We sum over all partial histories up to stage i: PCA(G)(F>i = hen, . . . , ei+1i) all disjoint to C P(C survives to Gi) = Xen,...,ei+1 all disjoint to C(cid:16) = Xen,...,ei+1 = ECP(G,C)h Yr=i+1 n (1 − C Mr n Yr=i+1 (1 − C Mr )(cid:17)PCP (G,C)(F>i = hen, . . . , ei+1i) )i (cid:3) One difficulty with using Proposition 5.1 and Corollary 5.2 is the fact that the expression Qn r=i+1(1 − C/Mr) is a non-linear function of C and Mi+1, . . . , Mn. We often prefer to use a "linearized" potential function Si that approximates it. For any integer i ≥ 0 we define + ··· + Si = c Mn Mi+2 Mi+1 + c c Heuristically, one may think of Si as counting the expected number of times a min-cut is selected during the Contraction Algorithm. We have the following simple bound on Si: Proposition 5.3. For any integer i ∈ [1, n] we have: Proof. We have that: Si ≤ 2 log(n/i) Si = n Xr=i+1 c Mr ≤ n Xr=i+1 c rc/2 ≤Z n r=i 2dr c = 2 log(n/i). (cid:3) The next Lemma shows how the potential function Si gives a good approximation to Proposition 5.2. Lemma 5.4. Let C be a cut of weight αc. For any real number α ≥ 1 and integer i ≥ 2α we have that: 16−αe−αSi ≤ (1 − C Mr ) ≤ e−αSi n Yr=i+1 15 Proof. The upper bound is easy: n (1 − Yr=i+1 To show the lower bound: αc Mr )] ≤ n Yr=i+1 e− αc Mr = e− Pn r=i+1 αc Mr = e−αSi n αc Mr ) ≥ n e− αc αc αc as 1 − x ≥ e−x(1 − x2) for x ∈ [0, 1] α2c2 n n n (1 − Yr=i+1 ≥ e−αSi × as Mr ≥ rc/2 Yr=i+1 = e−αSi × Mr(cid:1)2(cid:1) Mr ×(cid:0)1 −(cid:0) Mr(cid:1)2(cid:1) Yr=i+1(cid:0)1 −(cid:0) Yr=i+1(cid:0)1 − r2c2/4(cid:1) Yr=i+1(cid:0)1 − r2 (cid:1) r=i+1(1 − 4α2 Thus, we need to estimate the expression Qn r2 ). This is an exercise in calculus: 4α2 Xr=i+1 ≥ exp(cid:16)Z ∞ = lim x→∞y→2α+ r2 )(cid:17) r2 )dr(cid:17) as i ≥ 2α 4α2 r r2 ) + 4α tanh−1( 2α r2 ) = exp(cid:16) = e−αSi × r=2α log(1 − exp(cid:16)r log(1 − = exp(−2α log 4) = 16−α Yr=i+1 log(1 − x y(cid:17) (1 − )(cid:12)(cid:12)(cid:12) 4α2 4α2 n 4α2 n which gives us the desired lower bound. (cid:3) This can be applied to obtain a simple bound for the probability of selecting a given cut C: Lemma 5.5. Let C be any cut of weight αc. For α′ ≥ α, the probability that the Contraction Algorithm with parameter α′ selects cut C is at least P(Contraction Algorithm selects cut C) ≥ e−O(α′)ECP (G,C)[e−αS⌈2α⌉] Proof. First, suppose that α′ ≥ n/2. In this case, the Contraction Algorithm simply selects a cut uniformly from G, so that C is selected with probability 2−n−1 = e−O(α′). Also, observe that S⌈2α⌉ ≤ 0 so that ECP(G,C)[e−αS⌈2α⌉] ≤ 1. So the result holds easily in this case. Next, suppose that α′ ≤ n/2. By Lemma 5.5, the probability that the cut C survives to the graph G⌈2α′⌉ is at least 16−α′ Next, note that if C survives to G⌈2α′⌉, then as the Contraction Algorithm selects a cut from this graph Overall, the probability that C is selected is at least e−O(α′)ECP (G,C)[e−αS⌈2α⌉ ] as desired. Note that by Jensen's inequality, uniformly at random, C is selected with probability 21−⌈2α′⌉ ≥ 2−O(α′). ECP (G,C)[e− αc c S⌈2α′⌉ ]. (cid:3) ECP (G,C)[e−αS⌈2α⌉] ≥ exp(−αECP (G,C)[S⌈2α⌉]); thus, to apply Lemma 5.5, it will suffice to compute E[S⌈2α⌉]. Also observe that by combining Proposition 5.3 with Lemma 5.4, we get a simple and well-known lower bound on the probability of retaining C that does not depend on any other properties of G: Corollary 5.6. The probability that the Contraction Algorithm with parameter α selects a given α-cut C is at least P(select C) ≥ e−O(α)(cid:0)n/α(cid:1)−2α 16 . Proof. This holds easily when α ≥ n/2. Otherwise, P(select C) ≥ e−O(α)ECP (G,C)[e−αS⌈2α⌉] ≥ e−O(α)ECP (G,C)[e−α log( n ⌈2α⌉ )] ≥ e−O(α)ECP (G,C)[e−α log( n 2α )] = e−O(α)(cid:0)n/α(cid:1)−2α . (cid:3) The cut C affects the dynamics of the Contraction Process, making it more difficult to analyze than the Contraction Algorithm. The following series of lemmas show how we can "factor out C". We show that the Contraction Process for C can be approximated by the Contraction Algorithm on G/L, where L ⊆ C is a subset of edges from the cut C. Lemma 5.7. Let C be a cut of a connected graph G and let L a subset of the edges of G. Let Mi be the edge counts corresponding to the random process CP(G, C) and let M′i be the edge counts corresponding to the random process CP(G/L, C). Then for r > L the random variable Mr stochastically dominates the random variable L + Mr−L. Note that C is not necessarily a cut of G/L; we interpret C here only as a set of edges in G/L. Proof. As described in [8], there is an alternative description of the contraction process for G, C: we select a random permutation of the edges in G − C. We then process these edges in order, either contracting the edge or ignoring it if it was already contracted. With this in mind, consider the following coupling process: given a permutation ρ of the edges e ∈ G− C, we run respectively the processes CP (G, C) and CP (G/L, C), using the common permutation ρ to order the relevant edges in both cases. Letting Mi, M′i denote the edge counts obtained in the respective processes, we claim that for a fixed ρ, and this will show our claim. Mr ≥ M′r−L + L For a fixed ρ, list the edges of G − C in order of ρ as e1, e2, . . . , em−C. Observe that both Contraction Processes successively select these edges in this order, and contract them if they are still present in the graph (either G or G/L respectively). We say that the process is at stage k if it has processed edges e1, . . . , ek in order. Suppose that when this process is at stage k, then the graph G has reduced to r vertices and contains s edges of L. Then G/L at this stage must have r′ ≥ r − s vertices, as it has at most s additional edges contracted away. Also note that every edge in G/L at stage k also remains in graph G, and in addition G has s edges which are not present for G/L. Hence Mr ≥ Mr′ + s ≥ M′r−s + s Next, note that every time the number of vertices is decreased by one in the process, so too must the number of edges be reduced by at least one. Hence and our claim is proved. (cid:3) M′r−s + s ≥ M′r−s−1 + s + 1 ≥ ··· ≥ M′r−L + L. Corollary 5.8. Let C be any cut of G, and L ⊆ C a subset of the edges of C. Then for any integers j ≥ i ≥ 1 we have ECP(G,C)[Si] ≤ ECP(G/L,C)[Sj] + 2 log(L + j i ) Proof. As Mr ≥ rc/2 for all r, we have ECP(G,C)[Si] ≤ ECP(G,C)[Sj+L] + c rc/2 j+L Xr=i+1 c Mr ] + 2 log(L + j ) i n ≤ Xr=j+L+1 ECP(G,C)[ 17 For each r, the random variable Mr stochastically dominates the random variable L + M′r−L denote the edge counts under CP(G/L, C). This implies that ECP(G,C)[ c ECP(G/L,C)[ ] ≤ ECP(G/L,C)[ ] and so: Mr−L Mr c , where M′i ] ≤ L+Mr−L c ECP(G,C)[Si] ≤ c ] + 2 log(L + j ) i n n−L Mr−L ECP(G/L,C)[ Xr=j+L+1 Xr=j+1 ≤ ECP(G/L,C)[Sj] + 2 log(L + j ECP(G/L,C)[ c Mr = i ] + 2 log(L + j ) i ) (cid:3) To illustrate how we can use these results, suppose we are interested in the contraction process for C, where C contains very few edges. In this case, if we apply Corollary 5.8 with L = C and i = j = ⌈2α⌉, then we would have ECP(G,C)[S⌈2α⌉] ≤ ECP(G/C,C)[S⌈2α⌉] + 2 log(1 + C ⌈2α⌉ ) 2 log(1 + C2α ) ≈ 0. Thus, However, note that CP(G/C, C) is equivalent to CA(G/C). Also, observe that as C is small then ECP(G,C)[S⌈2α⌉] . ECA(G/C)[S⌈2α⌉] We have thus completely factored out C -- we have reduced the analysis of the Contraction Process for C to the behavior of the Contraction Algorithm on a (slightly smaller) graph. We note that the choice of parameters L = C, i = j = ⌈2α⌉ for Corollary 5.8 was only for illustrative purposes, and is not optimal. When we apply this Corollary later, we will choose other parameters which lead to stronger, but more complicated, estimates. 6. Bounds for small, odd c Our ultimate goal for this algorithm is show that the reliability of a graph influences the number of cuts it can have. As a warm-up exercise, we will show that graphs with connectivity c, where c is a small odd number, have noticeably fewer α-cuts than the worst case (where c is even and the graph is a cycle with each edge having multiplicity c/2). This section is not needed for our main algorithm, and can be skipped if desired. We use the following fact about the minimum cuts of G, when c is odd. This is shown in [2], [3]: Proposition 6.1. Suppose G has minimum cut c, for c odd. Then G has at most 2n min-cuts, which are represented by the edges of a spanning tree of G. This is actually the only place we use the fact that c is odd; in fact, our result is true for any graph G which has ≤ 2n min-cuts (or a similar result could be shown for a graph with O(n) min-cuts). Although our goal is to analyze the Contraction Process for a target cut C, it will suffice to analyze the unconditioned Contraction Algorithm. The basic strategy of this proof is use induction on the number of vertices to show a bound on ECA(G)[Si]. We will need to track the behavior of Si not only for the original graph G, but for subgraphs Gr which arise during the evolution of the Contraction Algorithm. The formal induction proof by itself is not very intuitive, because it requires guessing a bound on E[Si] and then proving that this bound is correct. So we will give an intuitive and non-rigorous derivation of the proof. Consider any min-cut C (not the target cut). By Corollary 5.2, it survives to Gi with probability ECP(G,C)[Qn r=i+1(1 − c/Mr)] ≤ ECP(G,C)[e−Si]. Now, suppose that we ignore the distinction between CP(G, C) and CA(G) (the two processes should be almost the same, because C affects only a small part of the graph); in this case, we can approximate that C survives to Gi with probability roughly ECA(G)e−Si. As this is true for any min-cut, the expected number of min-cuts Ki remaining in Gi should be about where we are being deliberately vague about the scope of the expectation. E[Ki] ≈ k exp(−E[Si]) 18 Now the neighborhood of each vertex of Gi defines a cut. As Gi has Ki min-cuts, this implies that at most Ki vertices may have the minimum degree c, while the others must have degree at least c + 1, so that We have a bound on the expected value of the random variable Ki. It will turn out that, given this fixed value of E[Ki], the worst case distribution on Ki is that either Ki = 0 or Ki = i (the latter occurring with probability E[Ki]/i). In this case, Mi ≥ Kic/2 + (i − Ki)(c + 1)/2 E[c/Mi] ≤ E[Ki] c i ic/2 + (1 − E[Ki] i ) c i(c + 1)/2 = 2(ic + E[Ki]) (c + 1)i2 This gives us a recurrence relation in Si: c Mj E[ E[Si−1] =Xj≥i ] = E[Si] + E[ c Mi ] ≈ E[Si] + 2(ic + E[Ki]) (c + 1)i2 ≈ E[Si] + 2(ic + ke−E[Si]) (c + 1)i2 We relax this recurrence relation to a differential equation dE[Si] = − di E[Sn] = 0 2(ke−E[Si] + ci) (c + 1)i2 which can be solved in closed form to obtain E[Si] = logh (i/n) 2 c+1−1(2k + (c − 1)n) − 2k (c − 1)i i This derivation makes a number of unwarranted independence and monotonicity assumptions on the behavior of the random variables, which do not hold in general. However, as we will see, this argument does accurately capture the worst-case behavior for all the random variables. That is, even though the random variables are not independent, any dependency would only give us better bounds. In the following theorem, we carry out the high-level approach discussed in Section 1.2 and prove that our heuristic formula is in fact a correct bound: Theorem 6.2. Let c > 1. Define the function f (i, n, k) = logh (i/n) 2 c+1−1(2k + (c − 1)n) − 2k (c − 1)i i Suppose G is a graph with n vertices and a minimum cut weight of c. Suppose that G has at most k min- cuts, where k is an integer in the range 0 ≤ k ≤ 2n. Then for 3 ≤ i ≤ n we have that ECA(G)[Si] ≤ f (i, n, k). Proof. For simplicity, we will defer some technical analysis of the function f to Appendix A. First, note that by Proposition A.1, the function f is well-defined. We induct on n. When n = i, we have Si = 0 = f (i, n, k). Now suppose n ≥ i + 1, and G has m edges and k ≤ 2n cuts of weight c. In the first step of the Contraction Algorithm, we select an edge of G to contract, arriving at a new graph G′. So ECA(G)[Si] = c/m + EG′ECA(G′)[Si]. We have broken the expectation into two components. First, we randomly select the next subgraph G′; then, we continue the Contraction Algorithm on that subgraph. The graph G′ has n − 1 vertices and has K′ ≤ 2(n − 1) min-cuts, where K′ is a random variable. Each By the inductive hypothesis, min-cut survives to H with probability (1 − c/m), and so E[K′] ≤ k(1 − c/m) ≤ ke−c/m. By Proposition A.2, this is a concave-down increasing function of K′, hence by Jensen's inequality ECA(G′)[Si] ≤ f (i, n − 1, K′) and hence ECA(G′)[Si] ≤ f (i, n − 1, ke−c/m) ECA(G)[Si] ≤ c/m + f (i, n − 1, ke−c/m) 19 k vertices may have the minimum degree c, while the others must have degree at least c + 1. The neighborhood of each vertex of G defines a cut, and for n ≥ 3 these are all distinct. Hence at most First suppose k ≤ n. That implies that m ≥ nc/2 + (n − k)/2 By Proposition A.3, the expression c/m + f (i, n− 1, ke−c/m) is decreasing in m. Then we have the bound ECA(G)[Si] ≤ nc/2 + (n − k)/2 ≤ f (i, n, k) + f (i, n − 1, ke− by Proposition A.4. c nc/2+(n−k)/2 ) Suppose k ≥ n. Then m ≥ nc/2, so we have the bound ECA(G)[Si] ≤ nc/2 + f (i, n − 1, ke− c nc/2 ) c c This completes the induction. (cid:3) ≤ f (i, n, k) by Proposition A.5. the case when c = 1, as it is essentially identical to Theorem 6.2. For that case, we obtain the result: The function f is technically not defined at c = 1. However, it approaches the limit f (i, n, k) = log(cid:0)(n/i)+ (k/i) log(n/i)(cid:1), and this function has similar properties to the case when c > 1. We omit the full analysis of Proposition 6.3. Suppose G is a graph with n vertices and c = 1, and with k ≤ n weight-one cuts (aka bridges). Then for n ≥ i ≥ 1 we have Lemma 6.4. Suppose G has minimum cut c, for c odd. Then for any integers 1 ≤ i ≤ n we have ECA(G)[Si] ≤ logh(n/i) + (k/i) log(n/i)i E[Si] ≤ 2c c + 1 log(n/i) + O(1) Proof. Observe that S1 ≤ S3 + O(1), so it suffices to show this for 3 ≤ i ≤ n. Suppose that the graph G has n vertices and k ≤ 2n cuts of weight c. If c ≥ 3, then by Theorem 6.2 we have ECA(G)[Si] ≤ f (i, n, 2n) c+1 − 4(n/i) ! = log (c + 3)(n/i)2− 2 (c − 1) = (2 − 2c c + 1 2 log(n/i) + O(1) = c + 1 ) log(n/i) + log (c + 3) − 4(i/n)1− 2 c+1 ! (c − 1) A similar proof, using Proposition 6.3, applies when c = 1. (cid:3) We can now estimate the probability of selecting the α-cut C: Theorem 6.5. Suppose c is odd and C is an α-cut. Then the Contraction Algorithm with parameter α selects C with probability Ω(n−2α c Proof. First, suppose n ≥ αc2 (which is the most interesting and difficult case). We then apply Corollary 5.8 with L = C, j = ⌈αc2⌉: c+1 ). ECP(G,C)[S⌈2α⌉] ≤ ECP(G/C,C)[S⌈αc2⌉] + 2 log( ≤ ECA(G/C)[S⌈αc2⌉] + 2 log( αc + ⌈αc2⌉ 2α c(c + 1) ) ) + 1 2 where here we note that CP(G/C, C) = CA(G/C). 20 Let r be the number of vertices in G/C. Applying Lemma 6.4: ECA(G/C)[S⌈αc2⌉] ≤ max(0, 2c c + 1 log( r ⌈αc2⌉ )) + O(1) ≤ 2c c + 1 log( n αc2 ) + O(1) So 2c log( c + 1 ECP(G,C)[S⌈2α⌉] ≤ = n αc2 ) + 2 log( log n − Ω(log α) − c + 1 log n − Ω(log α) + O(1) By Lemma 5.5, the probability of selecting C is bounded by: c + 1 c + 1 2 4c ≤ 2c 2c c(c + 1) ) + O(1) log c + 2 log(cid:0)c(c + 1)(cid:1) + O(1) P(Contraction Algorithm selects C) ≥ exp(−O(α) − αECP(G,C)[S⌈2α⌉]) 2c α log n + Ω(α log α)) ≥ exp(−O(α) − ≥ Ω(n− 2c cut C is selected with probability exactly 21−n ≥ Ω(n−2α c c+1 e−O(α)n− 2α apply Corollary 5.6, which does not take account of the fact that c is odd: c+1 α) c + 1 n To finish the proof, we need to deal with the cases in which n is small. When n ≤ 2α, then observe that c+1 ). Next suppose that 2α < n < αc2. Then we c+1 e−O(α)(αc2)− 2α c+1 α2α P(Select C) ≥ e−O(α)( ≥ n−α 2c ≥ n−α 2c ≥ Ω(n−α 2c c+1 ) ≥ n−α 2c α(cid:1)−2α c+1 e−O(α)(c1/(c+1))−4ααα c+1 α2α ≥ n−α 2c as c ≥ 1 c+1 e−O(α)αα as x−1/(x+1) ≥ Ω(1) for x ≥ 1 (cid:3) (cid:3) The following example shows that we cannot achieve any probability of the form n−αx where x is a constant with x < 2c c+1 : Observation 6.6. Let c be odd, and let α = k c+1 2c with k an integer and α ≤ 2n. Then there is a graph G c+1 α(cid:17) distinct α-cuts. 2α ) whose min-cut has weight c and which has Ω(cid:16)( n Proof. Consider a cycle graph consisting of bundles of (c + 1)/2 edges between each adjacent pair of vertices, except for one edge bundle of (c − 1)/2 edges. This graph has minimum cut c. Suppose we select any k edge-bundles which use the (c + 1)/2 edges to fail. This gives a cut of weight k(c + 1)/2, which is k c+1 2c times the minimum cut as indicated. There are (cid:0)n−1 k (cid:1) such choices, so the total number of such α-cuts is at least 2c (cid:18)n − 1 k (cid:19) =(cid:18)n − 1 c+1 (cid:19) = Ω(cid:16)( 2αc n 2α ) 2c c+1 α(cid:17) 7. The effects of graph reliability on the Contraction Algorithm We now show how the graph reliability affects the behavior of the Contraction Algorithm. Our goal in this section is to obtain a quantitative form of the following simple relationship: a graph which has high reliability will have fewer α-cuts than the cycle graph, for any value of α ≥ 1. The key to this is to draw a connection between ¯Z (the expected number of failed cuts) and the behavior of the Contraction Algorithm. If ¯Z is large (say as large as n2pc), then the graph G could be essentially like the cycle graph, in which case Karger's analysis of the Contraction Algorithm would be tight. However, when ¯Z is small, then the graphs encountered during the Contraction Algorithm have more edges which implies that any target cut C is retained with higher probability. In this section, we will assume U (p) < n−K for some constant K; thus the conclusions of Proposition 3.6 hold. 21 Throughout this section, we recall that pc = n−2−δ ¯Z = n−2−δ+β and that δ ≥ δ0 > 0, where δ0 is an arbitrarily small constant. how this simple proof falls short and how to improve it, at the cost of greater complexity. We begin with a warm-up exercise, which will illustrate some of the ideas in the proof. We then discuss Proposition 7.1. Define h(x) =  2(2 + δ)(log(3 − β + δ) − log(2 − β + δ + x)) 2(2 + δ)(log(3 − β + δ) − log(2 + δ)) + 2(β − x) 2(1 − x) if x ≥ β if x < β ≤ 1 if β ≥ 1 Then for any integer i ∈ [2, n] we have log i Si ≤ h(cid:0) log n(cid:1) log n Here, x should be thought of as a parameter which measures how far along we are in the contraction process: x = 1 is the beginning of the process, while x = o(1) is the end. Before we give the proof, we give a more intuitive description of the somewhat mysterious function h(x). Suppose that we run the Contraction Algorithm starting at the original graph, but terminate it after reaching a subgraph with nx vertices (instead of running it all the way to a graph with 2α vertices). The probability that the cut C survives to Gnx is roughly n−αh(x). So when x = 1, then h(x) = 0 and this makes sense because the cut C survives with probability one. If we assume that α is a small constant, then we terminate the algorithm at x ≈ 0 and so the cut C survives with probability n−αh(0); this is essentially the probability that the cut C is actually selected by the Contraction Algorithm. Proof. Let x = log i log n . For β ≥ 1, this is simply Proposition 5.3. Let us next consider the case β ≤ x ≤ 1. Consider the subgraph Gr during during the Contraction Algorithm for r > i. As r ≥ 3, the neighborhood of each vertex v determines a distinct cut of Gr with weight dv, where dv is the degree of v. As all the cuts of Gr are cuts of G as well, we must have Xv pdv ≤ XC a cut of G pC = ¯Z Now note that rp Pv dv r ≤Pv pdv , hence rp2Mr /r ≤ ¯Z, which in turn implies that r log( ¯Z/r) Mr ≥ 2 log p Hence n Si ≤ 2c log p 2c log p r log( ¯Z/r) ≤Z n Xr=i+1 = 2(2 + δ) log n(log(3 − β + δ) − log(2 − β + δ + x)) = h(x) log n dr = −2c log p(log log(r/ ¯Z))(cid:12)(cid:12)(cid:12) r log( ¯Z/r) r=i n r=nx A similar calculation applies in the case x ≤ β. This simple proof demonstrates the effect of the graph reliability on the behavior of the Contraction Algorithm. In fact, this Proposition 7.1 is already sufficient to obtain a substantially improved run-time compared to Karger's algorithm. We will also need this Proposition 7.1 for technical reasons later in this paper. However, Proposition 7.1 is not tight, because it assumes that the value of ¯Z does not change during the execution of the Contraction Algorithm. But in fact, most of the cuts in the graph are being contracted away, so ¯Z should be decreasing rapidly. We will track this behavior in terms of a parameter which is slightly more general than ¯Z. Suppose we (cid:3) are given a target α-cut C. For any contraction subgraph H, we define the associated graph parameter (1) e−γ(C ′−C)/c AH γ = Xcuts C ′ of H 22 This is the expected number of failed cuts of H, if all the edges in C fail and all the edges outside C fail independently with probability e−γ/c. Be aware that C may not be a cut of the graph H (if some edges of C were contracted); in (1), one should interpret C as a collection of edges which survive in H. Proposition 7.2 shows how the parameter A changes over the course of a Contraction Process. Proposition 7.2. Suppose that C is a cut of G, and L is a subset of the edges of C. Suppose that H is a contraction-subgraph of G with m edges. Let H′ denote the graph obtained from H by one step of the Contraction Process for L (that is, selecting an edge of H − L uniformly at random and contracting it.) Then E[AH′ γ−c/m] ≤ AH γ Proof. Consider some cut C′. In a single iteration of the contraction process, we select an edge of G − L uniformly at random. There are E(H) − L such edges, hence we select an edge of C′ − L with probability C ′−L E(H)−L . So the probability of retaining C′ is P(retain C′) ≤ 1 − C′ − L E(H) − L ≤ 1 − C′ − C m ≤ exp(−C′ − C m ) The contribution of C′ to AH′ over all such C′: γ−c/m is exp(−(γ−c/m)C ′−C c ) if C′ is retained, and is zero otherwise. Summing E[AH′ γ−c/m] ≤XC ′ =XC ′ exp(−(γ − c/m)C′ − C exp(−γC′ − C ) = AH γ c c ) exp(−C′ − C m ) Our strategy here is to guess a formula for E[Si] in terms of various parameters, and then prove it true by an induction. The induction proof is not informative on its own, so we give a heuristic derivation of our formula. This amounts to estimating Mr for the various stages of the Contraction Process for C. In this discussion, we ignore any considerations of the fact that Si is a random variable, and we treat it as essentially deterministic. Suppose that the cuts of G, other than the target cut C, have negligible overlap with C. In this case, = ¯Z. Also, applying Proposition 7.2 multiple times, and ignoring all AG distinctions between expected value and actual values for the variables and all variable dependencies, we have that for the graph Gi: − log(pc) = PC ′ pC ′−C ≈ PC ′ pC ′ (cid:3) AGi − log(pc)−Si = AGi −(log pc)−c/Mi+1−c/Mi+2+···−c/Mn ≤ AG −(log pc) = ¯Z Now suppose that in Gi, each vertex has degree d. Since the neighborhood of each vertex of Gi defines a distinct cut, and these cuts are all assumed to be nearly disjoint from C, Which implies and hence Xv exp(cid:0)(c log p + Si)d/c(cid:1) ≤ AGi − log(pc)+Si = ¯Z c log( ¯Z/i) Si + c log p d ≥ Mi = id/2 ≥ ic/2 log( ¯Z/i) Si + c log p Thus we have a recurrence relation in Si: Si−1 = Si + c/Mi ≤ Si + 2(c log p + Si) i log( ¯Z/i) 23 We relax this to a differential equation 2(Si + c log p) i log(Z/¯i) dSi = − di Sn = 0 which can be solved in closed form to obtain Si = (− log(pc))(cid:16)1 − log2( ¯Z/i) log2( ¯Z/n)(cid:17) This derivation is completely non-rigorous, as it makes a number of unwarranted independence and mono- tonicity assumptions. However, as we will see, all of these assumptions turn out to be the worst-case behavior. Hence the above bound is essentially correct. As in Section 6, we will use this bound as the basis of an induction argument. However, the situation is more complicated because of the way we must transform the contraction process for C into an unconditioned contraction algorithm. In Section 6, we handled this by applying Lemma 5.7 with L = C. This worked because C was small compared to n. We cannot assume this here; instead, we will define L to be a small random subset of the edges of C. This will remove the influence of C from cuts C′ which heavily overlap C. We will show that in fact the worst-case behavior of the contraction process comes about when all other cuts of G have negligible overlap with C; in that case, we can essentially ignore C. Lemma 7.3. There is a subset of the edges L ⊆ C with the following properties: (1) L ≤ ⌈α(2 + δ) log n⌉ (2) AG/L (We can interpret this as follows. The parameter AG/L − log(pc) ≤ ¯Z − log(pc) counts the expected number of failed cuts, given that all edges in L are retained and all edges in C − L are removed and all other edges fail randomly with probability p) Proof. Choose L to be a random subset of C of size exactly x = ⌈α(2 + δ) log n⌉. (If this number is larger than the number of edges in C, we simply set L = C, in which case the lemma is trivially true.) Now consider the contribution of some cut C′ to AG/L − log(pc). If L contains some edge in C ∩ C′, then C′ contributes zero; else it contributes pC ′−C. So, supposing that C ∩ C′ = sc, we have: E[Contribution of cut C′ to AG/L − log(pc)] = pC ′−scP(C′ ∩ L = ∅) ≤ pC ′p−sc(cid:0)αc−sc x (cid:1) (cid:0)αc x(cid:1) = pC ′p−sc (αc − sc)(αc − sc − 1) . . . (αc − sc − (x − 1)) αc − sc ≤ pC ′p−sc( ≤ pC ′ns(2+δ)e− s − log(pc)] ≤PC ′ pC ′ = ¯Z. In particular, there exists some subset (αc)(αc − 1) . . . (αc − (x − 1)) )x = pC ′n(2+δ)s(1 − α α(2+δ) log n = pC ′ s α αc )x (cid:3) Thus, summing over all C′, we have E[AG/L L with AG/L − log(pc) ≤ ¯Z. We are now ready to introduce the main induction argument: Theorem 7.4. Define the function f (i, r, a, γ) =(γ(cid:16)1 − log2(a/i) log2(a/r)(cid:17) if a ∈ (0, 1] 2 log(r/i) if a > 1 Fix a graph G and a target cut C of G, and let H be a contraction-subgraph of G with r vertices. Let γ be a real number in the range [2 log r,∞) and let i, r be integers with 100 ≤ i ≤ r ≤ n. Then ECP(H,C)[Si] ≤ f (i, r, AH γ , γ) 24 We emphasize here that C is not necessarily a cut of H; in the expression CP(H, C) and AH , we view C simply as a subset of the edges of H. Proof. We defer the proof of some technical properties of f to Appendix B, for sake of clarity. follows immediately from Proposition 5.3. We induct on r. When r = i, we have Si = f (i, r, a, γ) = 0. Now suppose r ≥ i + 1, and H has m edges with AH γ = a. We may assume that a ≤ 1, as otherwise this So ECP(H,C)[Si] = c/m + EH′ ECP(H′,C)[Si]. We have broken the expectation into two components: first, we select an edge e of H − C to contract, leading to the graph H′ = H/e; second, we continue the contraction process on the subgraph H′, which has r − 1 vertices. Note that m ≥ rc/2, so γ − c/m ≥ 2 log r − 2/r ≥ 2 log(r − 1). So the induction hypothesis applies to the graph H′ with γ′ = γ − c/m giving By Proposition 7.2, we have EH′ [AH′ ECP(H,C) ≤ c/m + EH′(cid:2)f (i, r − 1, AH′ γ−c/m, γ − c/m)(cid:3). γ−c/m] ≤ a. So by Proposition B.1, ECP(H,C) ≤ c/m + f (i, r − 1, a, γ − c/m). We will now bound the number of edges m of the graph H. For each vertex v ∈ H, let dv be the number of incident edges not including the edges of C. Each vertex then corresponds to a cut which has dv edges outside C, and as r ≥ 3 these cuts are all distinct. So By the arithmetic mean-geometric mean (AM-GM) inequality, exp(−γdj/c) ≤ AH γ = a. Xv∈H Xv∈H This implies that exp(−γdj/c) ≥ r(cid:16)Yv (exp(−γdj/c))(cid:17)1/r = r exp(−γPv dj rc ) ≥ r exp(−γ(m/2) rc ) as m ≥Xv dv/2 and γ > 0 By Proposition B.2, the quantity c/m + f (i, r − 1, a, γ − c/m) is decreasing in m. Hence m ≥ rc log(a/r) −2γ ECP(H,C)[Si] ≤ −2γ r log(a/r) ≤ f (i, r, a, γ) + f (i, r − 1, a, γ + r log(a/r) ) 2γ by Proposition B.3 (cid:3) We use this to estimate the probability ECP(G,C)[Si] for a target cut C. Theorem 7.5. Define the function ¯h : [0, 1] → R+ by ¯h(x) = (δ + 2)(1 − x)(5 − 2β + 2δ + x) (3 − β + δ)2 Let C be an α-cut of G, and let i be an integer in the range i = ⌈2α⌉, . . . , n. Then log i ECP(G,C)[Si] ≤ ¯h(cid:0) log n(cid:1) log n + O(log log n) (The function ¯h has the same interpretation as h, however ¯h(x) is (typically) smaller than h(x) and so it provides a tighter bound on the probability of the cut C surviving (partially) through the Contraction Algorithm.) 25 Proof. Let x = log i log n , so x ∈ [0, 1]. ¯h(x) + 3/δ. This implies that Si ≤ (¯h(x) + 3 If δ ≥ log n, the Proposition 5.3 gives Si ≤ 2 log(n/i) = (2 − 2x) log n. One may verify that (2 − 2x) ≤ So we may assume that δ < log n for the remainder. log n ) log n ≤ ¯h(x) log n + O(1) and we are done.1 H = G/L, and suppose that H has r ≤ n vertices. There are now two cases depending on the size of r, i. j = i + 100: Let L ⊆ C be as given by Lemma 7.3, so that AG/L − log(pc) ≤ ¯Z and L ≤ ⌈α(2 + δ) log n⌉ ≤ O(α log2 n). Let In the first (and most important) case, suppose that r ≥ i + 100. Then we apply Corollary 5.8 with ECP(G,C)[Si] ≤ ECP(H,C)[Sj] + 2 log(L + i + 100 ) i ≤ f (j, r, AH ≤ f (j, r, AH − log(pc),− log(pc)) + 2 log(L + i + 100 i − log(pc),− log(pc)) + O(log log n) as i ≥ 2α,L ≤ ⌈α(2 + δ) log n⌉ ≤ O(α log2 n) Simple inspection shows that f (k, ℓ, a, γ) is a decreasing function of k and an increasing function of ℓ. − log(pc),− log(pc)). Furthermore, using Proposition B.1 and the − log(pc),− log(pc)) ≤ f (i, n, AH − log(pc) ≤ ¯Z ≤ 1, we have that f (i, n, AH − log(pc),− log(pc)) ≤ f (i, n, ¯Z,− log(pc)). So Thus f (j, r, AH fact that AH ) by Theorem 7.4, as r ≥ j ≥ 100 ECP(G,C)[Si] ≤ f (i, n, ¯Z,− log(pc)) + O(log log n) Now substitute i = nx, ¯Z = n−2−δ+β, pc = n−2−δ, and observe that f (i, n, ¯Z,− log(pc)) = ¯h(x) log n. The next case is when r < i + 100. We apply Corollary 5.8 with j = i: ECP(G,C)[Si] ≤ ECP(H,C)[Si] + 2 log(L + i i ) ≤ 2 log(r/i) + 2 log(1 + L/i) i + 100 ) + O(log log n) ≤ 2 log( ≤ O(log log n) ≤ ¯h(x) log n + O(log log n) i as i ≥ 2α,L ≤ ⌈α(2 + δ) log n⌉ ≤ O(α log2 n) (cid:3) Our next result introduces an important parameter ¯h(0). Essentially, ¯h(0) measures the rate of decay of the number of α-cuts. If we make no assumptions about the graph reliability, then the number of α-cuts may be as large as n2α. When we take the reliability of G into account, we show that instead the number of α-cuts is like n¯h(0)α. Crucially, barring some exceptional cases, we have ¯h(0) < 2. Corollary 7.6. For α ∈ [1, n/2] we have ECP(G,C)[S⌈2α⌉] ≤ ¯h(0) log n + O(log log n) − Ω(log α) Proof. We have E[S⌈2α⌉] ≤ ¯h( log⌈2α⌉ log n ) log n + O(log log n) by Theorem 7.5 log⌈2α⌉ log n = ¯h(0) log n + log nZ ≤ ¯h(0) log n − log n × = ¯h(0) log n − Ω(log α) + O(log log n) x=0 ¯h′(x)dx + O(log log n) log⌈2α⌉ log n × Ω(1) + O(log log n) by Proposition D.3 (cid:3) 1Observe that ¯h(x) is a rational function of the parameters β, δ, x, the coefficients of which are rational numbers. Thus, the statement that (2 − 2x) ≤ ¯h(x) + 3/δ for β, δ, x in the appropriate range is equivalent to a first-order sentence in the theory of real-closed fields. A classical result of Tarski is that the theory of real-closed fields is decidable; many symbolic algebra packages have implemented practical algorithms for this. We used the Mathematica function Reduce which implements these algorithms to check that this inequality holds. For the remainder of the paper, whenever we refer to mechanically checking an inequality, we mean that employ the Mathematica software package which proves that it is a validity. 26 Corollary 7.7. The Contraction Algorithm with parameter α outputs any given α-cut with probability at least n−α¯h(0) log−O(α) n. In particular, the number of such cuts is at most nα¯h(0) logO(α) n. Proof. If n ≤ 2α, then C is selected with probability exactly 21−n ≥ Ω(n−α); by Proposition D.1, ¯h(0) ≥ 10/9 so this is ≥ n−α¯h(0). Otherwise, by Lemma 5.5, the probability of selecting any given α-cut C is at least By Corollary 7.6 this is at least exp(−O(α)) exp(Ω(α log α))n−α¯h(0) log−O(α) n ≥ n−α¯h(0) log−O(α) n. P(select C) ≥ exp(−O(α) − αECP(G,C)[S⌈2α⌉]). (cid:3) 8. Bounds on α∗ In this section, we will assume U (p) < n−K for some constant K; thus the conclusions of Proposition 3.6 hold. Recall that the approach of [8] is to show that most unreliability is due to the failure of a small cut. We can use our bound on the number of cuts to estimate this more precisely than Theorem 2.5. Proposition 8.1. Define Uα(p) to be the probability that some cut of weight ≤ αc fails. Then for all α ≥ 1 we have the bounds Proof. We have U (p) − Uα(p) ≤ nα(¯h(0)−2−δ) logO(α) n U (p) − Uα(p) ≤ O(n−αδ) U (p) − Uα(p) = P(Some cut of weight > αc fails and no cut of weight ≤ αc fails) ≤ P(Some cut of weight > αc fails) nα(¯h(0)−2−δ) and we automatically prove the first bound as well. By Corollary 2.4, this is at most O(n−αδ), thus proving the second bound. If ¯h(0) ≥ 2, then n−αδ ≤ So we may suppose that ¯h(0) ≥ 2. Then we estimate this by the union bound P(Some cut of weight > αc fails) ≤ XC>αc pC Proposition 7.7 states that the number of cuts of weight xc is at most F (x) = n¯h(0)x logO(x) n. Hence we may apply Proposition 2.2: this sum is bounded by XC:C>αc pC ≤ F (α)pαc +Z ∞ x=α pxcF ′(x)dx = nh(0)αnα(−2−δ) logO(α) n +Z ∞ ≤ nα(¯h(0)−2−δ) logO(α) n x=α for ¯h(0) ≤ 2 and δ ≥ δ0 > 0 nx(−2−δ)n ¯h(0)x(logO(x) n)(¯h(0) log n + O(log log n))dx (cid:3) As in Karger [8], we estimate U (p) by examining only the smallest cuts. We define α∗ to be the minimal value of α such that The parameter α∗ plays a crucial role in the analysis. We can estimate U (p) to the desired relative error by estimating Uα∗ (p), which we can do by enumerating all the α∗-cuts. This is a relatively small collection, which we can explicitly collect and list. U (p)(1 − ǫ) ≤ Uα∗ (p) ≤ U (p) For the rest of the paper, we define (2) ρ = log(1/ǫ)/ log n. Although in general we allow ρ to increase arbitrarily, we find that these bounds can become confusing because of the interplay between the asymptotic growth of n and ǫ. One can get most of the intuition behind these results by restricting attention to the case ρ = O(1). 27 Using our improved bounds on the Contraction Algorithm, we tighten Theorem 2.5. Lemma 8.2. We have If β ≤ 3/2, then we have α∗ ≤ α∗ ≤ 2 − β + δ + ρ δ + O( 1 log n ) (3 − β + δ)2(2 − β + δ + ρ) (2 − β + δ)2(2 + δ) + O( (1 + ρ) log log n log n ) Proof. The first bound is easier. As shown in Proposition 8.1, the absolute error introduced by ignoring cuts of weight ≥ αc is U (p) − Uα(p) = O(n−αδ). So the relative error is at most n−αδ) Rel Err = O(cid:0) = O(cid:0) ≤ Cn−αδn2+δ−β U (p) (cid:1) ¯Z (cid:1) n−αδ by Proposition 3.5 for some constant C Elementary algebra shows that this is ≤ ǫ for α ≥ log C−log ǫ+(2−β+δ) log n Next let us consider the case when β ≤ 3/2. By Proposition D.1 this implies ¯h(0) ≤ 2. As shown in Proposition 8.1, the absolute error introduced by ignoring cuts of weight ≥ αc is U (p) − Uα(p) = nα(¯h(0)−2−δ) logO(α) n. So the relative error is at most = 2−β+δ+ρ + O( 1 log n ). δ log n δ nα(¯h(0)−2−δ) logO(α) n U (p) nα(¯h(0)−2−δ) logO(α) n ¯Z (cid:1) (cid:1) = nα(¯h(0)−2−δ)n2+δ−β logO(α) n Rel Err = O(cid:0) = O(cid:0) 2+δ−¯h(0) + φ(1+ρ) log log n log n Set α = ρ+2−β+δ δ > δ0 > 0 and ¯h(0) ≤ 2. by Proposition 3.5 , where φ is some constant be specified. Note that α ≤ O(1 + ρ), as Rel Err ≤ n−(ρ+2−β+δ)n φ(1+ρ) log log n(¯h(0)−2−δ) log n (log n)O(α) log n )(log n)O(1+ρ) ≤ n−ρ−Ω( φ(1+ρ) log log n = ǫ(log n)−Ω(φ(1+ρ))(log n)O(1+ρ) ≤ ǫ for φ a sufficiently large constant as δ ≥ β and α ≤ O(1 + ρ) So α∗ ≤ in this case. ρ + 2 − β + δ 2 + δ − ¯h(0) + O( (1 + ρ) log log n log n ) = (3 − β + δ)2(2 − β + δ + ρ) (2 − β + δ)2(2 + δ) + O( (1 + ρ) log log n log n ) If we only want a very crude estimate for α∗ we can use the following, which holds irrespective of the (cid:3) precise value of K, β, δ: Corollary 8.3. We have α∗ ≤ O(1 + ρ) Proof. By Proposition 3.6, δ ≥ K − 2 > 0 and δ ≥ β for n sufficiently large. By Lemma 8.2, α∗ ≤ 2 − β + δ + ρ δ + O( 1 log n ) The restrictions δ ≥ δ0 > 0 and δ ≥ β ensures that this is O(1 + ρ). 28 (cid:3) Remark: In light of Corollary 8.3, it will be convenient to define a term α∗max, which is a computable upper bound of α∗ and which satisfies α∗max ≤ O(1 + ρ). The precise value of the constant term here will not be relevant. It is tempting to simply modify Karger's original algorithm, using this improved estimate for α∗ in place of Karger's estimate. We cannot do this directly, as this estimate depends on the parameter β which we cannot simply compute. One approach would be to estimate α∗ using a worst-case estimate for β. This would give usable and tighter bound than Karger's. For example, suppose that we use Monte Carlo estimation when U (p) ≥ n−2.73 and cut- enumeration when U (p) < n−2.73. Some simple analysis (which we omit here) shows that α∗ ≤ 1.87 + O(ρ) whenever U (p) < n−2.73. using Karger's algorithm for the remainder, this would give us a total runtime of n3.73ǫ−O(1). This is good, but we will take another approach which will allow us to do better. To explain our approach intuitively, consider the following process: We run nα∗¯h(0)(n/ǫ)o(1) independent executions of the Contraction Algorithm with parameter α∗max. This generates a large collection A of cuts, of various sizes. As we show in Proposition 8.4, with high probability A contains all the α∗-cuts. As described in Section 4, we may then use the collection A to estimate U (p). Proposition 8.4. The Contraction Algorithm with parameter α∗max finds any α∗-cut C with probability at least n−α∗¯h(0)(ǫ/n)o(1). Proof. By Corollary 8.3, we have α∗ ≤ α∗max. which is smaller than 21−n for n sufficiently large. So we may assume that α∗ ≤ n/2. e−O(α∗ If α∗ ≥ n/2, then the cut C is found with probability 21−n. By Proposition D.1, n−α∗¯h(0) ≤ n−Θ(n), this cut C is produced by the Contraction Algorithm with probability ≥ max)e−α∗E[S⌈2α∗⌉]. By Lemma 5.5, Note that e−O(α∗ Also by Corollary 7.6, we have E[S⌈2α∗⌉] ≤ ¯h(0) log n + O(log log n). We have that e−α∗E[S⌈2α∗⌉] ≥ max) ≥ e−O(1+ρ). Also observe that eρ = e− log(1/ǫ)/ log n ≥ ǫo(1). So e−O(α∗ max) ≥ ǫo(1). e−α∗(¯h(0) log n+O(log log n)−Ω(log α′)) ≥ e−α∗¯h(0) log n × (log n)−O(α∗) ≥ e−α∗¯h(0)(ǫ/n)o(1). (cid:3) If we use this algorithm directly, then we must run completely separate instances of the Contraction Algorithm for each sample. Each execution of the Contraction Algorithm takes time O(n2) (to process the graph), and so the total work would be roughly nα∗¯h(0)+2. Our goal now will be to reduce the work closer to nα∗¯h(0). In [12], an efficient algorithm called the Recursive Contraction Algorithm (RCA) was introduced for running multiple samples of the Contraction Algorithm simultaneously. This amortizes the work of processing the graph across the multiple iterations, effectively reducing the time for a single execution of the Contraction Algorithm from O(n2) to O(1). In the next section, we will discuss how to combine the Recursive Contraction Algorithm with our improved analysis of the Contraction Algorithm. Unlike in [12], we will not be able to show that a single application of the RCA is as powerful as n2 independent applications of the Contraction Algorithm. We will still show it is powerful enough to substantially reduce the cost of multiple applications of the Contraction Algorithm. The next section will examine the Recursive Contraction Algorithm in detail. We note that we do not need to bound either α∗ or ¯h(0) individually, which would depend on knowing β. It suffices to give an upper bound on the product α∗¯h(0) irrespective of β. 9. The Recursive Contraction Algorithm The basic method of finding the α∗-cuts is to run the Contraction Algorithm for many iterations and collect all the resulting cuts. Each iteration requires O(n2) work (to process the entire graph). As described in [12], this data-processing can be amortized across the multiple iterations. The resulting Recursive Contraction Algorithm, can enumerate all the α-cuts in time O(n2α log2 n). We will run the RCA for a large, fixed number of iterations. This will produce a large collection of cuts A, of various sizes. We will then show that the resulting collection will contain all the α∗-cuts with high probability. Note that we do not know the precise value of α∗ (it may depend on β), so we cannot simply discard cuts of weight > α∗c at this stage. 29 In this section (with the exception of Section 9.6), we will assume U (p) < n−K for some constant K > 2; thus the conclusions of Proposition 3.6 hold. We define the RCA with parameter α as follows:2 1. Randomly contract edges of G until the resulting graph G′ has at most min(n/2,⌈2α⌉) vertices. Run the RCA with parameter α on the subgraph G′. 2. If G′ has ⌈2α⌉ vertices, output a random cut of G. 3. Otherwise, perform 4 independent executions of the RCA on the graph G′. The RCA was introduced in [12], which showed the following bounds on its performance: Theorem 9.1 ([12]). For any graph G, the RCA with parameter α′ executes in time O(n2 log n). For α > 1 + Ω(1), it finds a target α-cut C with probability at least Ω(2−α′ n2−2α). We observe first that the number of α∗-cuts is at most n2α∗ The analysis in [12] does not take into account the graph reliability. We will show a better success probability than n2−2α taking account of this information. Our goal is to show that we can enumerate all the α∗ cuts with high probability using n1+o(1)ǫ−1.99 independent applications of the RCA. As the running time of RCA is n2+o(1), the overall run time will be ≤ n3+o(1)ǫ−1.99. . Thus, suppose we are able to show that any α∗-cut C is found with probability at least n−1−o(1)ǫ1.98 in a single execution of the RCA; then by a standard analysis of the Coupon Collector Problem, this implies that after O(log n2α∗ × n1+o(1)ǫ−1.98) iterations of the RCA that all such α∗-cuts are found, with high probability. Observing that log(n2α∗ ) = (n/ǫ)o(1), the total number of iterations is then bounded by n1+o(1)ǫ−1.98−o(1) ≤ n1+o(1)ǫ−1.99, as desired. This observation means that it suffices to consider a fixed target cut C of weight αc, for α ≤ α∗, and to show that C is found with probability at least n−1−o(1)ǫ1.98. This will be our goal for the remainder of this section. For the remainder of this section, we let C be a fixed target cut and αc its weight. (Note: significantly better exponents than 3, 1.99 can be shown for n, ǫ respectively; but this requires more careful calculations. Improvements in these exponents would not improve the overall run time of our algorithm, so these are omitted.) 9.1. Storing the cuts produced by the RCA. As we have already discussed in Section 4.1, we do not wish to explicitly store all the cuts that will be output by the RCA. Rather, we wish to store them in a compressed format. We briefly discuss how the RCA is to able to output each cut in terms of this compressed representation. First, we must store a unique index for each cut C, which we define by where A is the first shore of C. H(C) = Xv∈A H(v) modulo 2b To compute this, we note that during the intermediate steps of the RCA, every node in the resulting subgraphs Gi corresponds to a set of vertices of G. For each such vertex v ∈ Gi, which corresponds to some H(x) mod 2b. This can be updated at each contraction step. At subset Xv ⊆ V , we define H(v) =Px∈Xv the end of the RCA, we must select a cut of the graph G⌈2α⌉. The cut C′ of the graph G⌈2α⌉ corresponds to a cut C of G and H(C) =Pv∈C ′ H(v). A similar process can be used to count the weight of C. Finally, we must keep track of a pointer which allows us to fully reconstruct any cut in its uncompressed form. To do so, we first store the complete random tape used by applications of the RCA. Then any cut output by the RCA can be reconstructed in terms of its tree-path through the recursive calls to the RCA. These details are discussed more in [8]. 9.2. Handling the easy cases. Our analysis of the RCA will be technically challenging. As a preliminary, we can deal with some of the easy cases first. Proposition 9.2. The RCA enumerates C with probability ≥ n−1−o(1)ǫ1.98, assuming that one of the fol- lowing conditions is satisfied: (1) α ≤ 3/2 2This version is slightly different from that of [12]; the algorithm in that paper uses 2 independent executions to reduce the graph to n/√2 vertices. The only effect of this change is to remove some quantization effects, which would complicate our proof. 30 (2) ρ ≥ 2.1 (3) β ≥ 1 Proof. By Proposition 3.6, we have δ ≥ β + Ω(1) and δ ≥ K − 2 > 0 and β ∈ [0, 2]. We break this proof into a number of cases. Case I: α ≤ 3/2. By Theorem 9.1 the cut C is found with probability at least n2−2α+o(1)2−α∗ Case II: β ≥ 3/2. By Theorem 9.1, C is found with probability at least Ω(2−α∗ n−1−o(1)2−O(1+ρ) ≥ n−1−o(1)ǫ−o(1) as desired. Hence for the remainder of this proof we assume α ≥ 3/2. 2−O(1+ρ)n2−2α∗ ≥ (ǫ/n)o(1)n2−2α∗ found with probability at least (ǫ/n)o(1)n2−4/3−2/3ρ = n−2/3−o(1)ǫ2/3+o(1) as desired. max ≥ max n2−2α) ≥ + O(1/ log n). For β ≥ 3/2 we have α∗ ≤ 4/3 + 2/3ρ. So C is By Lemma 8.2, we have α∗ ≤ 2−β+δ+ρ Thus, for the remainder of the proof, we assume β ≤ 3/2. Case III: ρ > 2.1. In this case, we make the simple observation that a single application of the RCA is at least as powerful as a single application of the Contraction Algorithm (if we simply ignore all but one branch of the RCA). By Proposition 8.4, then C is enumerated with probability at least n−α∗¯h(0)(n/ǫ)−o(1). . δ Assuming that β ≤ 3/2 (otherwise case II holds), then by Lemma 8.2: + O( (2 − β + δ)2(2 + δ) α∗¯h(0) ≤(cid:16) (3 − β + δ)2(2 − β + δ + ρ) (5 − 2β + 2δ)(2 − β + δ + ρ) =(cid:16) 5 − 2β + 2δ 2 − β + δ − o(1)(cid:17) + ρ(cid:16) 5 − 2β + 2δ (2 − β + δ)2 + o(1 + ρ) = (2 − β + δ)2 − o(1)(cid:17) (1 + ρ) log log n log n ))(cid:17)¯h(0) It can be verified mechanically that 5 − 2β + 2δ 2 − β + δ ≤ 5/2 − Ω(1) 5 − 2β + 2δ (2 − β + δ)2 ≤ 5/4 − Ω(1) Hence α∗¯h(0) ≤ 5/2 + 5/4ρ. When ρ > 2.1, this quantity is less than 1 + 1.97ρ. Recalling that ρ = Case IV: 1 ≤ β ≤ 3/2. By Lemma 8.2 log(1/ǫ)/ log n, this means that n−α∗¯h(0) ≥ n−1−o(1)ǫ1.98 as desired. α∗ ≤ (3 − β + δ)2(2 − β + δ + ρ) (2 − β + δ)2(2 + δ) + o(1 + ρ) It can be verified mechanically that this is at most 3/2 + (3/4)ρ for all β ∈ [1, 3/2] and δ ≥ β. So again by Theorem 9.1, then C is found with probability at least n2−2α−o(1) ≥ n−1−o(1)−3/2ρ−o(1)ρ ≥ n−1−o(1)ǫ1.51 (cid:3) Simplifying assumptions. Hence we can make the simplifying assumptions that α ≥ 3/2, ρ ≤ 2.1, β ∈ [0, 1]. As α∗ ≤ α∗max = O(1 + ρ) by Proposition 8.3, this implies that α ≤ O(1) as well. We summarize the following assumptions which we adopt in Sections 9.3, 9.4, 9.5, and which which will not be stated explicitly there: (1) ρ ≤ 2.1 (2) 3/2 ≤ α ≤ α∗ ≤ α∗max ≤ O(1) (3) δ > δ0 > 0 (4) δ ≥ β (5) β ∈ [0, 1] In light of these simplifying assumptions, we can simplify Theorem 9.1. Proposition 9.3. Let H be a contraction-subgraph of G with r ≤ n vertices. Then the RCA with parameter α∗max selects cut C with probability Ω(r2−2α) Proof. We have 2−α∗ max ≥ 2−O(1) = Ω(1) and α ≥ 3/2 > 1 + Ω(1) 31 (cid:3) 9.3. The RCA as a branching process. It is useful to view the sequence of graphs produced by the RCA in terms of a branching tree, in which there is a node in this branching process for each recursive call to the RCA. Every node in this process corresponds to an partial execution of the Contraction Algorithm. We view the root node (depth 0) as corresponding to the original graph G. The leaf nodes correspond to subgraphs which have ≤ ⌈2α⌉ vertices. If our target cut C appears in any of the subgraphs corresponding to a leaf node, it will be output at least once by the RCA. For any node v of this branching process, we let Gv be the corresponding subgraph. For the root node v we have Gv = G. We say that node v succeeds if the cut C remains in Gv. To avoid quantization issues, it will be convenient to assume that n is a power of two. We can always modify our original input graph to achieve this, by adding extra dummy vertices; each dummy vertex is connected to every other vertex (including the other dummy vertices) by infinitely many edges. This modification does not change U (p), and it only changes n by a constant factor. As we aim to give running times which are polynomial in n and do not depend on m, this will not affect our runtime analysis by more than a constant factor. Once we make this assumption, then we can see that, aside from the leaf nodes, the nodes at depth i of the RCA branching process correspond to running the Contraction Algorithm from the original graph G to a graph with exactly n2−i nodes. The overall depth of this tree is H = ⌊log2( )⌋. As α∗max = O(1), we have that log2 n − O(1) ≤ H ≤ log2 n. In the ideal case (if the leaves corresponded to independent executions of the Contraction Algorithm), then the probability of a successful leaf node is nearly equal to the expected number of leaf nodes. Our goal is to calculate the probability that some leaf node succeeds. n ⌈2α∗ max⌉ The analysis of [12] viewed the RCA as a type of percolation process, in which the survival of a target cut C percolated from the root node to the leaf nodes. Starting at any given node at depth i, there is a certain probability that a cut C is retained throughout all the contractions from that node to its children. All the survival events are independent. Our analysis, however, must also keep track of the stochastic evolution of the subgraphs Gi during the Contraction Process. Our improvements have been based on bounding the expected number of edges in these graphs. Thus, we cannot assume that starting at a node v at depth i, the probability that cut C survives in two nodes is the square of the probability that it survives in one; the reason is that these events are both dependent on the random variable Gv. As a result of this, there is a significant correlation between the successes at nearby nodes of the RCA tree. This in turn lowers the overall probability that there is at least one successful leaf node. Dealing with this correlation among nearby nodes will be the major technical challenge for the analysis of the RCA. This correlation becomes more severe at greater depths of the RCA tree. 9.4. Marking nodes. We wish to show that there is a good probability of having at least one successful node. We will do so by using Inclusion-Exclusion (IE): P(At least one successful node) ≥ E[# successful nodes] − E[# pairs of successful nodes] One somewhat paradoxical feature of Inclusion-Exclusion is that sometimes it can give worse estimates when the expected number of successes goes up. For example, suppose we have n independent Bernoulli-q n2−k = Gv. random variables X1, . . . , Xn. By IE, we have P(P Xi ≥ 1) ≥ nq −(cid:0)n 2(cid:1)q2. When q → 0, then this is essentially an accurate estimate, but when q → 1 then the RHS becomes negative -- yielding a completely useless estimate. We will avoid this problem for our analysis as follows. Every node v at depth k of the RCA corresponds to a partial execution of the Contraction Algorithm, up to a subgraph with n2−k vertices. We can define the random variables Si, Mi, Gi, Fi for i = n2−k, . . . , n for this node; we denote them by Sv i , F v i . Observe that Gv i , M v i , Gv Now, if the cut C survives to Gv, then mark the node v with probability min(1, eα(Sv n2−k−B)), where B is a threshold value which we will specify. All such markings are done independently. If the cut C does not survive in Gv, then we do not mark v. Clearly, the probability that some node survives to depth k is at least equal to the probability that there is a marked node at depth k. It is the latter that we will estimate via IE. 32 For any execution of the Contraction Algorithm and any integer k ≥ 0, we define Tk = max(Sn2−k , B) We will show a lower bound on the probability that a depth-k node is marked, and an upper bound on the probability that two depth-k nodes are both simultaneously marked. Proposition 9.4. Let v be a node at depth k of the RCA tree. The probability that node v is marked is at least P(v is marked) ≥ Ω(ECP(G,C)[e−αTk ]) Proof. Let i = n2−k. The partial history F v >i for the node v has a distribution which is simply the Contraction Algorithm up to stage i. In order for the node v to be marked, the edges of that history must all be disjoint to C. So, integrating over such edges, P(v marked) = Xei+1,...,en = Xei+1,...,en disjoint to C disjoint to C PCA(G)(F>i = hen, . . . , ei+1i) × min(1, eα(Si−B)) n PCP(G,C)(F>i = hen, . . . , ei+1i) min(1, eα(Si−B)) (1 − C Mr Yr=i+1 by Proposition 5.1 ) by Lemma 5.4 PCP(G,C)(F>i = hen, . . . , ei+1i) min(1, eα(Si−B))e−αSi PCP(G,C)(F>i = hen, . . . , ei+1i) min(e−αSi, e−αB) PCP(G,C)(F>i = hen, . . . , ei+1i)e−αTk disjoint to C ≥ 16−α Xei+1,...,en ≥ 16−α Xei+1,...,en = 16−α Xei+1,...,en = 16−αECP(G,C)[e−αTk ] disjoint to C disjoint to C Now as α ≤ α∗max ≤ O(1) we have the claimed result. (cid:3) Proposition 9.5. Let v, v′ be two nodes at depth k of the RCA tree, whose nearest common ancestor w is at depth j ≤ k. The probability that v, v′ are both marked satisfies the bounds P(v and v′ marked) ≤ ECP(G,C)[e−αTk ] P(v and v′ marked) ≤ nαh(1− j log2 n )ECP(G,C)[e−2αTk ] Proof. To show the first bound, we simply ignore node v′ completely. In this case, the proof is nearly identical to Proposition 9.4, except we use an upper bound instead of a lower bound. Let us turn our attention to the second bound. Let i = n2−k and t = n2−j. The graph Gw is derived by running the Contraction Algorithm up to j nodes. Conditional on Gw, the nodes v, v′ are independent, and they are derived by running the Contraction Algorithm starting at Gw down to i nodes. We can thus view the joint distribution on the histories at v, v′ in terms of a "double Contraction Algorithm" denoted DCA(G). One can similarly define a "double Contraction Process" denoted DCP(G, C), where at every stage we select an edge uniformly from the edges outside C. For this process, let Fi+1, . . . , Fn be the resulting set of edges for the first leg, and let F ′i+1, . . . , F ′n be the resulting set of edges for the second leg. Both F>i and F ′>i are distributed according to the Contraction Process, but are not independent. Also, we must have Fℓ = F ′ℓ for ℓ = t + 1, . . . , n. Now suppose we are given a sequence of edges fi, . . . , fn, f′i , . . . , f′n, with fℓ = f′ℓ for ℓ = t + 1, . . . , n; we wish to analyze whether they could be produced by double Contraction Algorithm. In the usual way for analyzing the Contraction Algorithm, let the resulting subgraphs by defined by Gn = G′n = G, and Gℓ−1 = Gℓ/fℓ etc. We similarly define Mℓ, M′ℓ, Sℓ, S′ℓ. Finally, we define Tk = max(Si, B) and similarly for 33 T ′k = max(S′i, B). Finally we define H = Gt; this is the graph at which the two legs of the double Contraction Process first diverge. PDCA(G,C)(F>i ~f ∧ F>i = ~f′) = PCA(G)(F>t = hfn, . . . , ft+1i)PCA(H)(F>i = hft, . . . , fi+1i)PCA(H)(F>i = hf′t, . . . , f′i+1i) = PCP(G,C)(F>t = ~f ) )PCA(H)(F>i = hft, . . . , fi+1i) (1 − C (1 − C ) n t Mr Mr Yr=t+1 Yr=i+1 t (1 − C M′r (1 − C ) n Yr=i+1 Yr=t+1 ) t by Proposition 5.1 (1 − C Mr ) i−St) t Yr=i+1 (1 − C M′r ) by Lemma 5.4 × PCA(H)(F>i = hf′t, . . . , f′i+1i) = PDCP(G,C)(F>i = ~f ∧ F ′>i = ~f′) Yr=i+1 ≤ PDCP(G,C)(F>i = ~f ∧ F ′>i = ~f′)e−αSte−α(Si−St)e−α(S′ = PDCP(G,C)(F>i = ~f ∧ F ′>i = ~f′)eαSt e−αSie−αS′ ≤ nαh( log t log n )PDCP(G,C)(F>i = ~f ∧ F ′>i = ~f′)e−αSie−αS′ Mr i i by Proposition 7.1 If we include the probability that both nodes are also marked, we have: P(F v >i = ~f ∧ F v′ >i = ~f′ ∧ v, v′ marked) = PDCA(G,C)(F>i = ~f ∧ F>i = ~f′) ∧ P(v, v′ marked) log n )PDCP(G,C)(F>i = ~f ∧ F ′>i = ~f′)e−αSie−αS′ ≤ nαh( log t i × min(1, eα(Si−B)) min(1, eα(S′ i−B)) ≤ nαh( log t log n )PDCP(G,C)(F>i = ~f ∧ F ′>i = ~f′)e−αTk e−αT ′ k Now, integrating over ~f , ~f′, P(F v >i = ~f ∧ F v′ >i = ~f′ ∧ v, v′ marked) ≤X~f , ~f ′ nαh( log t log n )PDCP(G,C)(F>i = ~f ∧ F ′>i = ~f′)e−αTk e−αT ′ k k∼DCP(G,C)[e−2αTk ]ETk,T ′ k∼DCP(G,C)[e−2αT ′ k ] log n )ETk,T ′ k∼DCP(G,C)[e−αTk e−αT ′ k ] = nαh( log t ≤ nαh( log t by Cauchy-Schwarz log n )qETk,T ′ log n )qETk∼CP(G,C)[e−2αTk ]ET ′ log n )ETk∼CP(G,C)[e−2αTk ] = nαh( log t = nαh( log t k∼CP(G,C)[e−2αT ′ k ] Finally, observe that t = n2−j, giving the final result. (cid:3) 9.5. Inclusion-Exclusion analysis. We now move on to use Inclusion-Exclusion. We will not directly apply it to show that there is a leaf node where C survives -- the correlation among the nodes is too severe for nodes deep in the RCA tree. We will count smaller-depth nodes instead. Proposition 9.6. For any integers j, k with 0 ≤ j ≤ k ≤ H, we have E[ # pairs of marked nodes at depth k] ≤ O(cid:16)ETk∼CP(G,C)h42k−je−αTk + nαh(1− j log2 n )e−2αTki(cid:17) Proof. For each i ≤ k, we count the number of level-k nodes which are marked and have a nearest common ancestor at level i. As every node has four children, the total number of such nodes pairs is 4k × 3 × 4k−i−1. For each such pair, we use Proposition 9.5 to estimate the probability that both nodes are marked; we use the cruder estimate ECP(G,C)[e−αTk ] for i ≥ j and the more refined estimate nαh( log j log n )ECP(G,C)[e−2αTk ] for i < j. 34 Thus, summing over all i = 0, . . . , k, we have k E[ # pairs of marked nodes at depth k] ≤ 4k × 3 × 4k−i−1ECP(G,C)[e−αTk ] Xi=j+1 Xi=0 + j 4k × 3 × 4k−i−1nαh(1− i log2 n )ECP(G,C)[e−2αTk ] ≤ 42k−jECP(G,C)[e−αTk ] + 42kECP(G,C)[e−2αTk ] 4−inαh(1− i log2 n ) j Xi=0 By Proposition D.2 we have that h′(x) ≤ −4/3 − Ω(1) for all x ∈ [0, 1]. Thus, for all x ≥ 1 − j log2 n , we have h(x) ≤ h(1 − j log2 n ) − (4/3 − Ω(1))(x − (1 − j log2 n )). So we estimate log2 n ≤ 4−inαh(1− j log2 n )− α(4/3−Ω(1)) log2 n )2−α(j−i)(4/3−Ω(1)) 4−inαh(1− i log2 n ) ≤ 4−inαh(1− j ≤ 4−inαh(1− j = 4−jnαh(1− j log2 n )2−3/2(j−i)(4/3−Ω(1)) log2 n )(1 − Ω(1))j−i log2 n )(cid:17). This gives us our final estimate So Pj E[ # pairs of marked nodes at depth k] ≤ 42k−jECP(G,C)[e−αTk ]) + O(42k−j nαh(1− j log2 n ) ≤ O(cid:16)4−jnαh(1− j i=0 4−inαh(1− i as α > 3/2 = O(cid:16)ECP(G,C)[42k−je−αTk + nαh(1− j log2 n )e−2αTk ](cid:17) log2 n )ECP(G,C)e−2αTk ) (cid:3) Lemma 9.7. Suppose that j, k are integers in the range 0 ≤ j ≤ k ≤ H. Let ψ > 0 be any sufficiently small constant. Then the RCA with parameter α∗max finds the target cut C with probability at least P(RCA tree includes C) ≥ Ω(cid:16)ECP(C,G)h4αkn2−2αe−αTk − ψ42αk−jn4−4α(cid:0)e−αTk + nαh(1− j log2 n )e−2αTk(cid:1)i(cid:17) Proof. Each marked node at depth k of the RCA tree corresponds to a subgraph with n2−k vertices which contains cut C. Hence, if we execute the remaining stages of the RCA, by Proposition 9.3 it will generate some leaf node containing C with probability Ω((n2−k)2−2α). So each such marked node v has some independent probability qv ≥ φ′(n2−k)2−2α that a leaf node below it contains cut C; here φ′ is some constant. Let φ be any constant such that φ ∈ (0, φ′] and let q = φ(n2−k)2−2α. Now we apply an additional randomization step: we discard v and all its subtree below v with probability qv − q. This is a valid probability as qv ≥ q. Also, it is easy to see now that for any marked node, the probability that there is a non-discarded leaf node containing C is exactly equal to q. Note that we have applied two "attenuation" steps which can only reduce the probability of finding C among the nodes of the RCA-tree. First, some unmarked nodes may have a leaf node containing C, and some marked nodes will contain C but be discarded. If a marked node v at depth k contains some leaf node containing C, and v is not discarded, we say that v is a winner. Each marked node is a winner with probability exactly equal to q. By Proposition 9.4, the expected number of marked leaf nodes is Ω(4kECP(G,C)[e−αTk ]) and so the ex- pected number of winners is Ω(q4kECP(G,C)[e−αTk ]). By Proposition 9.6, the expected number of pairs of marked leaf nodes is O(cid:16)ECP(G,C)h42k−je−αTk + log2 n )e−2αTki(cid:17) and so the expected number of pairs of winners is O(cid:16)q242k−jECP(G,C)he−αTk + log2 n )e−2αTki(cid:17). nαh(1− j nαh(1− j 35 By Inclusion-Exclusion, the probability that there is at least one winner can be lower bounded by: P(RCA tree includes C) ≥ P(There is a winner at depth k) ≥ Ω(cid:16)q4kECP(G,C)[e−αTk ]) − O(cid:16)q242k−jECP(G,C)he−αTk + nαh(1− j = ECP(G,C)hc1φ4αkn2−2αe−αTk − c2φ242αk−j n4−4α(cid:0)e−αTk + nαh(1− j where c1, c2 are constants log2 n )e−2αTki(cid:17)(cid:17) log2 n )e−2αTk(cid:1)i Set φ = min(φ′, ψc1 c2 ) and we lower-bound this expression as Ω(cid:16)ECP(C,G)h4αkn2−2αe−αTk − ψ42αk−jn4−4α(cid:0)e−αTk + nαh(1− j log2 n )e−2αTk(cid:1)i(cid:17) (cid:3) Lemma 9.8. Let y ∈ [0, 1], and define t = max(h(y), ¯h(y/α)). Then the RCA with parameter α∗max finds the target cut C with probability at least Proof. Let x = y/α, so that t = max(h(y), ¯h(x)). We set P(RCA succeeds) ≥ n2−αt−2y−o(1) j = min(cid:0)H,⌊(1 − y) log2 n⌋(cid:1) k = min(cid:0)H,⌊(1 − x) log2 n⌋(cid:1) Clearly j, k are integers and 0 ≤ j ≤ k ≤ H. Also, as H ≥ log2 n− O(1), we have that j− (1− y) log2 n ≤ O(1) and k − (1 − x) log2 n ≤ O(1). We now observe that h(1 − j log2 n ) = h(y ± O(1/ log n)); as the derivative of h is bounded by constants (Proposition D.2), this is at most t + O(1/ log n). Similarly, the derivative of ¯h is bounded by constants, so ¯h(1 − k P(RCA tree includes C) ≥ Ω(cid:16)ECP(G,C)h4αkn2−2αe−αTk − ψ42αk−jn4−4α(cid:0)e−αTk + nαh(1− j log2 n )e−2αTk(cid:1)(cid:3)(cid:17) where ψ is a constant parameter to be determined. Using the fact that α = O(1) and k − (1 − x) log2 n ≤ O(1), we see that the terms can be bounded as log2 n ) ≤ t + O(1/ log n). We now apply Lemma 9.7 to obtain: 4αkn2−2α ≥ Ω(n2−2y) 42αk−j n4−4α ≤ O(n2−2y) nh(1− j log2 n ) ≤ O(nt) So By choosing ψ to be a sufficiently small constant, we obtain: P(RCA tree includes C) ≥ n2−2yΩ(cid:16)ECP(G,C)hΩ(e−αTk ) − ψO(cid:0)e−αTk + nαte−2αTk(cid:1)i(cid:17) P(RCA tree includes C) ≥ n2−2yΩ(cid:16)ECP(G,C)he−αTk − 1 3(cid:0)e−αTk + nαte−2αTk(cid:1)i(cid:17) 2 nαte−αTk )i(cid:17) = n2−2yΩ(cid:16)ECP(G,C)he−αTk (1 − 1 At this point, we are ready to specify the threshold value B = t log n; recall that Tk = max(Sn2−k , B). By definition of Tk we have that nαte−αTk ≤ nαte−αB = 1 and so P(RCA tree includes C) ≥ n2−2yΩ(cid:16)ECP(G,C)[e−αTk (1 − 1 2 )(cid:17) = n2−2yΩ(ECP(G,C)[e−αTk ]) We now claim that (3) which will give us our claimed result. ECP(G,C)[e−αTk ] ≥ n−αt−o(1) 36 Let us write S = Sn2−k , and so Tk = max(S, B). Let r = P(S > B). We show (3) by considering separate cases for the size of r. Case I: r ≤ 1+αt log n 2+αt log n . In this case, ECP(G,C)[e−αTk ] ≥ P(S ≤ B) × ECP(G,C)[e−αTk S ≤ B] = (1 − r)e−αB ≥ (1 − 1 + αt log n 2 + αt log n )e−αB = n−αt 2 + αt log n ≥ n−αt−o(1) as α, t ≤ O(1) Case II: r > 1+αt log n 2+αt log n . Let s = ECP(G,C)[S]. Observe that ECP(G,C)[S S ≥ B] ≤ ECP(G,C)[S]/P (S ≥ B) = s/r. So ECP(G,C)[e−αTk ] ≥ E[e−αTk S > B]P(S > B) = E[e−αS S > B]P(S > B) ≥ e−αE[SS>B]P(S > B) ≥ re−αs/r ≥ 1 2 e−αs× 2+αt log n 1+αt log n S = Tk for S > B by Jensen's inequality We now estimate s using Theorem 7.5 as: s = ECP(G,C)[S] ≤ ¯h( log(n2−k) log n k ) log n + O(log log n) log2 n ≤ ¯h(1 − ) log n + O(log log n) ≤ ¯h(x) log n + O(1) + O(log log n) ≤ t log n + O(log log n) So ECP(G,C)[e−αTk ] ≥ 1 2 exp(−α(cid:0)t log n + O(log log n)(cid:1) × ≥ n−o(1) exp(−αt log n × = n−o(1)e1−αt log n− 2 + αt log n 1 + αt log n 2 2+αt log n ≥ n−o(1)n−αt 2 + αt log n 1 + αt log n ) ) as α = O(1) In either case, we have shown (3). (cid:3) Theorem 9.9. The RCA with parameter α∗max finds any target α∗-cut C with probability at least n−1−o(1)ǫ1.98. Proof. If the simplifying assumptions do not hold, then this is already covered by Proposition 9.2. By Lemma 9.8, C is found with probability at least n2−α max(h(y),¯h(y/α))−2y−o(1) in each iteration of the RCA, for any y ∈ [0, 1]. By Proposition C.3, there is y ∈ [0, 1] so that this at least n2−3−1.5ρ−o(1) = n−1−1.5ρ−o(1). (cid:3) We defer the proof of Proposition C.3 to Appendix C. It is simple conceptually but it is an extremely tedious exercise, based on computer checking of a very large number of cases. 9.6. Further applications of the Recursive Contraction Algorithm. In this Section 9.6, we do not make any assumption on the size of U (p). The Recursive Contraction Algorithm provides a powerful approach to enumerate all the approximately- minimum cuts in a given graph G. Our reliability-estimation algorithm uses it in a very specific way based on bounds for the number of cuts of G. However, we can slightly improve the analysis of the Recursive Contraction Algorithm in other situations. Given a particular value of α and a given graph G (with no 37 information about the cut structure or reliability of G), how to enumerate the α-cuts of G. The Recursive Contraction Algorithm was first introduced in [12] to solve this problem. However, the original description of the RCA was not parametrized in the best way, leading to slightly sub-optimal running time. We improve this here. Theorem 9.10. There is an algorithm to enumerate, with high probability, all α-cuts of G in time O(n2α log n). Proof. First, suppose α < 3/2. Then [10] describes a data structure to represent all the α-cuts in time O(n2) and to enumerate all the α-cuts in time O(n2 log n). Finally, suppose 3/2 ≤ α ≤ √n. We execute the following variant of the Recursive Contraction Algorithm, which we denote RCA2 1. Randomly contract edges of G until the resulting graph G′ has at most min(n−2/5,⌈2α⌉) vertices. 2. If G′ has ⌈2α⌉ vertices, output a random cut of G. 3. Otherwise, perform 2 independent executions of RCA2 on the graph G′. A simple application of the Master Theorem for recurrences along with arguments from [12] shows that this algorithm executes in time O(n5/2). Also using arguments from [12], we can show that for any α-cut C, and any execution of this algorithm, the cut is selected with probability n5/2−2α exp(Ω(α log α)). Thus we can view the process of finding all α-cuts as a Coupon Collector Problem. As there are at most n2α cuts, if we run (2α log n)× n2α−5/2 exp(−α log α) = n2α−5/2 log n independent executions of RCA2, then we find all cuts with high probability. This gives a total run time of O(n2α log n). (cid:3) 10. Putting it all together We may now put all the pieces of the algorithm together. Our basic plan is to use the cut-enumeration if U (p) < n−K, and use Monte-Carlo sampling when U (p) ≥ n−K, where K is some chosen parameter close to 2. How do we determine which of these two methods to apply? At first, it would appear that this decision requires knowing U (p), which is what we are trying to determine in the first place. A simple way to make this decision is to run a preliminary Monte-Carlo sampling for φnK trials, where φ > 1 is constant. If during any of these samples we observe the graph become disconnected, we will use Monte-Carlo sampling to estimate U (p); otherwise we use cut-enumeration. This achieves at least a gross discrimination between the two regimes: Proposition 10.1. Suppose U (p) ≥ n−K. Then the probability of observing the graph become disconnected, is bounded from below by a constant which approaches 1 for φ sufficiently large. Suppose U (p) ≤ φ′n−K, for φ′ a constant. Then the probability of observing the graph become disconnected, is bounded from above by a constant which approaches 0 for φ′ sufficiently small. Proof. In the first case, the number of times the graph becomes disconnected is a binomial random variable, with φnK trials and expected number of successes ≥ φ. By Chernoff's bound, the probability that there are zero successes is ≤ e−φ; this approaches zero for φ sufficiently large. In the second case, the expected number of successes is ≤ φ′. By Markov's inequality, the probability that that there is at least one success is ≤ φ′; this approaches zero for φ′ sufficiently small. (cid:3) Now, when U (p) ≥ n−K, we will choose Monte-Carlo sampling with probability at least 0.99. This is good because the cut-enumeration algorithm may not be well-behaved when U (p) ≥ n−K; most of our theorems completely break down in the regime U (p) ≥ n−2. When U (p) ≤ φ′n−K, we will use cut-enumeration with probability at least 0.99. When φ′n−K < U (p) < n−K, we may use either Monte Carlo sampling or cut-enumeration. In this regime, either of these two algorithms gives good performance. The Monte-Carlo sampling will have relative variance O(n−K ). We have already shown that when U (p) < n−K that cut-enumeration behaves correctly. We now obtain our main result: Proposition 10.2. Let γ > 0 be any constant. Then we can estimate U (p) in time O(n3+γ ǫ−2) with probability ≥ 3/4. 38 Proof. Let K = 2 + γ/2. Suppose that U (p) < n−K and we elect to use the cut-enumeration procedure. We run the RCA for n3+o(1)ǫ−1.99 iterations, and let A denote the resulting set of cuts. By Theorem 9.9, A contains all the α∗-cuts with high probability. In particular, (1 − ǫ)U (p) ≤ Uα∗(p) ≤ UA(p) ≤ U (p) So UA(p) indeed estimates U (p) to within relative error ǫ. We next use the estimation algorithm of Section 4 with this collection. By Proposition 4.7, this estimates UA(p), and hence U (p), to within relative error O(ǫ). The total time for this is O(ApolylogA+n2/ǫ2). As A ≤ n3+o(1)ǫ−1.99, the term ApolylogA is at most n3+o(1)ǫ−2. So the overall running time is indeed n3+o(1)ǫ−2 as desired. Suppose instead that U (p) ≥ φ′n−K, where φ′ is a constant chosen in Proposition 10.1, and we elect to use Monte-Carlo sampling. The straightforward strategy for Monte Carlo sampling would require O(m) time per sample. However, a sparsification method of [8] reduces this is n1+o(1) time per sample. (This sparsification is somewhat involved and we will not modify it; see [8] for a more thorough description). Overall, the time for Monte Carlo sampling O(nK+1ǫ−2 logO(1) n). The total work is O(n3+γ ǫ−2) either way. By Proposition 10.1, with arbitrarily high constant probability, one of these two cases holds. This implies that we find a good estimate with probability > 3/4, which is the goal of our FPRAS. (cid:3) Note that our estimates have been developed under the assumption that δ is uniformly bounded away from 0. This means that for any constant γ > 0, there exists an algorithm with running time O(n3+γ ǫ−2). All of the asymptotic terms may depend arbitrarily on γ. As γ → 0, then δ → 0 as well. In fact one can produce these algorithms in a uniform way. That is, there is a Turing machine M which on input t produces a Turing machine Mt; in turn, Mt produces an estimate for U (p) in time n3+1/tǫ−2. This follows from the fact that all the hidden constants in our proofs can be upper-bounded by computable functions of ⌈ 1 K−2⌉. (This is easy to show, but we have avoided doing so because explicitly tracking all these constant terms would make our analysis more difficult than it already is. This is a very weak property, as computable functions may grow very quickly.) We first show a general condition for uniformization of FPRAS algorithm; we then conclude by applying it to estimating U (p). Lemma 10.3. Suppose that M is a Turing machine with the following behavior: on input t > 0, it produces a Turing machine Mt. Furthermore, Mt has the property that it estimates some statistic X with relative error ǫ with probability > 3/4, and Mt runs in time ≤ ctna+1/tǫ−b. Then there is an FPRAS for X running in time na+o(1)ǫ−b. Proof. First, by repeating any FPRAS for Ω(log n) samples and taking the median, one can increase the success probability from 3/4 to 1 − 1/n2. Let M′t be the FPRAS derived by this amplification; clearly they are also computable and they have running times O(ctna+1/tǫ−b log n). Now, consider the following algorithm: given some input vector ~x of bit-length n, we wish to estimate X(~x). To do so, we dovetail the following computations: we run M (1), . . . , M (log n); as soon as M (i) terminates, we immediately run the resulting M′i (~x). If any computation M′i terminates, we output its answer and terminate. We first claim that with probability ≥ 3/4 this gives a correct answer. For, a necessary condition for this to fail is that one of M′i , . . . , M′log n fails on input ~x; the total probability of this is at most log n× 1/n2 ≤ 1/4. Next, we claim that for any fixed integer s > 0 that this algorithm runs in time ≤ na+1/sǫ−b for n sufficiently large. Let t = 2s. Suppose that M (t) takes time k to compute Mt. Then, for log n ≥ t, our algorithm runs M′t (among other algorithms). It would take time k + ctna+1/tǫ−b log n for algorithm M′t to succeed. We are dovetailing log n separate computations. If the total run-time exceeds (k + ctna+1/tǫ−b log n) log n, then algorithm Mt will receive at least a share of k + ctna+1/tǫ−b log n runtime, and it will terminate with the answer (unless another process has terminated earlier). Thus, the overall run-time of this algorithm is at most (k + ctna+1/tǫ−b log n) log n. This is ≤ na+1/sǫ−b for n sufficiently large as t > s. 39 So, in all, our algorithm runs in time ≤ na+1/tǫ−b for any t > 0 and n sufficiently large. This implies it (cid:3) runs in time na+o(1)ǫ−b. It returns a correct answer with probability ≥ 3/4, as required. Theorem 10.4. There is an algorithm to estimate U (p) in time n3+o(1)ǫ−2. Proof. This follows from Lemma 10.3 and Proposition 10.2. (cid:3) Two natural open questions are to see if a run-time bound such as O(n2/ǫ2) is possible, and to identify other possible applications of differential-equation approximations such as ours. 11. Concluding Remarks It remains an outstanding open question to make progress on the approximability of R(G, p) = R(p), the probability of G remaining connected : as pointed out by Leslie Goldberg to us, even very weak approxi- mations here can be turned into PTAS-type approximations, and a proof of this from [5] is as follows. For example, suppose for some ǫ > 0 that there is a polynomial-time algorithm that given as input any connected graph H with nH vertices, produces a value R(H, p) satisfying (4) note that this is a very weak approximation algorithm. However, it can be turned into essentially an (1± ǫ) -- approximation algorithm as follows. Take the connected input graph G for which we want to well-approximate R(G, p). Choose an arbitrary vertex v of G, and construct a graph H by taking nG copies of G, but by also graph-theoretically "identifying" (i.e., fusing together) the copies of vertex v. Then R(H, p) = R(G, p)nG and nH = n2 (1 − ǫ)√nH R(H, p) ≤ R(H, p) ≤ (1 + ǫ)√nH R(H, p); G; in particular, √nH = nG − 1/2 + o(1). Thus, by (4), G − nG + 1 ∼ n2 (1 − ǫ)√nH R(G, p)nG (1 − ǫ)1−o(1)R(G, p) ≤ ( R(H, p))1/nG ≤ (1 + ǫ)1−o(1)R(G, p); ≤ R(H, p) ≤ (1 + ǫ)√nH R(G, p)nG , i.e., thus, ( R(H, p))1/nG is an excellent approximation to R(G, p). Thus, the approximability of R(G, p) is either excellent, or very poor; determining the truth here is a very intriguing open question. 12. Acknowledgments We thank the SODA 2014 referees for their helpful comments, and Leslie Goldberg for a valuable discussion on R(p). The discussion with Leslie Goldberg that is included in Section 11, as well as part of Aravind Srinivasan's writing, transpired while Srinivasan attended the ICERM Workshop on Stochastic Graph Models in March 2014. We thank the workshop organizers for their kind invitation. Thanks to Thomas Lange and to the anonymous journal reviewers for their many helpful comments and thorough reading of this paper. References [1] Bencz´ur, A., Karger, D.: Approximate s − t min-cuts in O(n2) time. SIAM Journal on Computing 44-2, pp. 290-319 (2015) [2] Bixby, R.: The minimum number of edges and vertices in a graph with edge connectivity n and m n-bonds. Bulletin of the American Mathematical Society 80, 700-704 (1974). [3] Chandran, L., Shankar, L.: On the number of minimum cuts in a graph. SIAM Journal of Discrete Mathematics 18, 177-194 (2004). [4] Gdalyahu, G., Weinshall, D., Weman, M.: Self-organization in vision: stochastic clustering for image segmentation, percep- tual grouping, and image database organization. Pattern Analysis and Machine Intelligence, IEEE Transactions on 23.10, pp. 1053-1074 (2001). [5] Goldberg, L. A., Jerrum, M.: Approximating the Partition Function of the Ferromagnetic Potts Model. Journal of the ACM 59, 25:1 -- 25:31 (2012). [6] Karger, D.: Random Sampling in Graph Optimization Problems. Ph.D. Thesis, Department of Computer Science, Stanford University, 1994. [7] Karger, D.: Global min-cuts in RNC, and other ramifications of a simple min-cut algorithm. Proceedings of the ACM-SIAM Symposium on Discrete Algorithms, 21-30 (1993). [8] Karger, D.: A Randomized Fully Polynomial Time Approximation Scheme for the All Terminal Network Reliability Problem. SIAM Journal on Computing 29-2, 492-514 (1999) [9] Karger, D.: A Randomized Fully Polynomial Time Approximation Scheme for the All Terminal Network Reliability Problem. SIAM Review 43-3, 499-522 (2001) [10] Karger, D.: Minimum Cuts in Near-Linear Time. Journal of the ACM 47 1, 46-76 (2000) [11] Karger, D.: A fast and simpler unbiased estimator for network (un)reliability. Proceedings of the 48th annual Symposium on the Foundations of Computer Science, pp. 635 - 644 (2016) 40 [12] Karger, D., Stein, C.: A new approach to the minimum cut problem. Journal of the ACM 43, 601-640 (1995). [13] Karger, D., Tai, P.: Implementing a Fully Polynomial Time Approximation Scheme for All Terminal Network Reliability. Proceedings of the ACM-SIAM Symposium on Discrete Algorithms, 334-343 (1997). [14] Karp, R. M., Luby, M., Madras, N. Monte-Carlo approximation algorithms for enumeration problems. Journal of Algorithms 10, 429-448 (1989). [15] Lomonosov, M.: Bernoulli scheme with closure. Problems of Information Transmission 10, 73-81. (1974) [16] Lomonosov, M., Polesskii, V. P.: Lower bound of network reliability. Problems of Information Transmission 7, 118-123. (1971) [17] Sharafat, A., Ma'rouzi, O.: All-Terminal network reliability using recursive truncation algorithm. IEEE Transactions on Reliability 58, 338 - 347. (2009) [18] Wormald, N.: The differential equation method for random graph processes and greedy algorithm. Annals of Applied Probability 5-4, pp. 875 - 1240 (1995). Appendix A. Numerical analysis for Section 6 To complete the proof of Theorem 6.2, we must verify certain concavity and monotonicity properties of the function f defined by f (i, n, k) = logh (i/n) 2 c+1−1(2k + (c − 1)n) − 2k i (c − 1)i Proposition A.1. For 1 ≤ i ≤ n, the function f is well-defined. Proof. We need to show that the argument of the logarithm is strictly greater than 0. By Proposition A.2, the argument is strictly increasing in k, so it suffices to show that it is positive at k = 0. When k = 0, it is equal to (i/n) 2 c+1−1((c − 1)n) (c − 1)i which is clearly positive. Proposition A.2. For 1 ≤ i ≤ n and c ≥ 1 the function f (i, n, k) is an increasing, concave-down function of k. (cid:3) Proof. The function f applies the logarithm function to an argument which is a linear function of k. The slope of that linear function is 2n((i/n) 2 c+1 − (i/n)) > 0 (c − 1)i2 for c > 1 and 1 ≤ i ≤ n. Proposition A.3. Suppose c ≥ 3 and i, k, n ≥ 0. Then the expression c/m + f (i, n, ke−c/m) is a decreasing function of m. Proof. Let t = c/m. We wish to show that t + f (i, r, ke−t) is increasing in t. Differentiating with respect to t, it suffices to show that 2k((i/n) − (i/n) 2 2 c+1 ) (i/n) c+1 ((c − 1)net + 2k) − 2(i/n)k + 1 ≥ 0 By differentiating with respect to i (viewing i as a continuous parameter), we see that the left-hand side of the above expression is increasing in i. Hence it suffices to show that this holds when i → 0. In this case, as i → 0, the terms (i/n)2/(c+1) are negligible compared to the linear terms in (i/n), so the above approaches a limit as i → 0 of (cid:3) (cid:3) (c − 1)net (c − 1)net + 2k which is obviously positive. Proposition A.4. For c ≥ 3, n ≥ i + 1 and k ≤ n we have + f (i, n − 1, ke− c nc/2 + (n − k)/2 41 c nc/2+(n−k)/2 ) ≤ f (i, n, k) + f (i, n − 1, ke− c nc/2+(n−k)/2 )(cid:17) − exp(f (i, n, k)) ≤ 0 c−1 c+1(cid:17) − (c − 1)(cid:16)n c+1 2c 2c c+1 − e 2c cn+n (n − 1) 2c c+1(cid:17) ≤ 0 Proof. It suffices to show that c exp(cid:16) nc/2 + (n − k)/2 This expression can be rewritten as −2k(cid:16)n c+1 − (n − 1) c−1 (5) (cid:16)n 2c 2c (c − 1)i The denominator is positive, and the term n1− 2 c+1 − e n c+1(cid:17) can be bounded as: c+1(cid:16)1 − e cn+n (n − 1) c+1 − e cn+n (n − 1) Thus, we verify that (5) holds. c+1 = n 2c 2c 2c 2c 2c 2c c+1 − (n − 1)1− 2 c+1 is positive. Finally, the coefficient n(c+1)(cid:0)1 − 1/n) 2c c+1(cid:17) ≥ n 2c c+1(cid:16)1 − e 2c n(c+1) (e−1/n) 2c c+1(cid:17) = 0 (cid:3) Proposition A.5. For c ≥ 3, k ≥ n ≥ i + 1 we have 2 n + f (i, n − 1, ke− 2 n ) ≤ f (i, n, k) Proof. It suffices to show that This simplifies to showing that (6) −2k(cid:16)n + f (i, n − 1, ke− 2 n exp(cid:16) 2 c+1 − (n − 1) c−1 n )(cid:17) − exp(f (i, n, k)) ≤ 0 c+1(cid:17) c+1 − e2/n(n − 1) 2c 2c ≤ 0 c−1 c+1(cid:17) − (c − 1)(cid:16)n c+1 2c (c − 1)i The denominator of (6) is positive, and the numerator is a decreasing function of k. Hence, as k ≥ n, it suffices to show that this holds at k = n. There, the numerator of (6) is equal to: (7) c+1 + 2n(n − 1) So, we need to show (7) is negative. Here we have: − (c + 1)n 2c c−1 c+1 + (c − 1)e2/n(n − 1) 2c c+1 (7) = n ≤ n 2c 2c c+1(cid:16)−(c + 1) + (1 − 1/n) c+1(cid:16)−(c + 1) + (1 − 1/n) c−1 c−1 c+1 (2 + (c − 1)e2/n(1 − 1/n))(cid:17) c+1 (2 + (c − 1)(1 + 1/n)(cid:17) c−1 as e2x(1 − x) ≤ 1 + x for x ∈ [0, 1] c+1 n )− 2 The derivative of the quantity −(c + 1) + (1 − 1/n) c+1 (2 + (c − 1)(1 + 1/n)) with respect to n is 2(c−1)c( n−1 , which is clearly positive. Also clearly this quantity is negative at n = 1 (it approaches (c+1)n3 −(c + 1)) and approaches 0 as n → ∞. This implies that it is always negative, which in turn implies that (7) is negative as desired. (cid:3) Appendix B. Numerical analysis for Section 7 In this section, we will assume U (p) < n−K for some constant K > 2; thus the conclusions of Proposition 3.6 hold. To complete the proof of Theorem 7.4, we must verify certain concavity and monotonicity properties of the function f defined by f (i, r, a, γ) =(γ(cid:16)1 − log2(a/i) log2(a/r)(cid:17) if a ∈ (0, 1] 2 log(r/i) if a > 1 Proposition B.1. Let r, i be integers with r ≥ i ≥ 100 and let γ, a be real numbers with γ ≥ 2 log r, a ∈ (0, 1). Let A be any random variable with domain (0,∞) satisfying E[A] ≤ a. Then E[f (i, r, A, γ)] ≤ f (i, r, a, γ) 42 Proof. Let us fix i, r, γ and define the function g : [0, 1] → R by g(x) = f (i, r, x, γ) We claim first that g′(x) ≥ 0 and g′′(x) ≤ 0; so g is increasing and concave-down. For, we have that: g′(x) = −2γ log(i/r) log(i/x) x log3(r/x) As r ≥ i ≥ 1 and x ∈ [0, 1], the term log(i/r) is negative, the terms log(i/x), log(r/x) are positive, and γ is positive. So overall g′(x) ≥ 0. The second derivative is given by g′′(x) = −2γ log(r/i)(cid:0)log(r/x) + (log(r/x) − 3) log(i/x)(cid:1) x2 log4(r/x) For r ≥ 21, we have log(r/x) − 3 ≥ 0. The other terms here log(r/i), log(r/x), log(i/x), γ are all clearly positive. So overall g′′(x) ≤ 0. We next claim that g(1) ≥ 2 log(r/i), that is, γ(1 − log2 i log2 r ) ≥ 2 log(r/i) As γ ≥ 2 log r, it suffices to show that 2 log r(1 − The simplifies to showing 2 × log i × (1 − log i log r ) ≥ 0, which is clear. log2 i log2 r ) − 2 log(r/i) ≥ 0 Thus, as g(x) is increasing on x ∈ (0, 1] and g(1) ≥ 2 log(r/i), it follows that g(x) ≤ g(1) for all x ∈ (0,∞). Having shown these concavity properties of the function g(x), we continue to prove the claimed result. Consider the random variable A′ = min(A, 1). Observe that g(A) ≤ g(A′). Also, clearly E[A′] ≤ E[A] ≤ a. By Jensen's inequality E[g(A′)] ≤ g(E[A′]). As g(x) is increasing on x ∈ (0, 1], we have that g(E[A′]) ≤ g(a). This shows that E[g(A)] ≤ g(a) as desired. (cid:3) Proposition B.2. For a ≤ 1 and r ≥ i + 1, the expression is non-increasing in m. Proof. For a ≤ 1, the derivative of this quantity with respect to m is given by c/m + f (i, r − 1, a, γ − c/m) −c log2(cid:0) a i(cid:1) m2 log2(cid:16) a r−1(cid:17) which is clearly ≤ 0. Proposition B.3. For a ∈ [0, 1], γ ≥ 0, and r ≥ 100, we have 2γ −2γ r log(a/r) + f (i, r − 1, a, γ + r log(a/r) (cid:3) ) ≤ f (i, r, a, γ) Proof. We compute the RHS minus the LHS. After collecting terms this is given by: γ log2(cid:0) a i(cid:1)(cid:16)r(2 log a)(1 + r log(1 − 1/r)) − 2r log r + r2(log2(r) − log2(r − 1))(cid:17) r2 log2( a r−1 ) log2( a r ) Removing terms with obvious signs, it suffices to show that and we want to show this is positive. (8) r(2 log a)(1 + r log(1 − 1/r)) − 2r log r + r2(log2(r) − log2(r − 1)) ≥ 0 Simple calculus shows that 1 + x log(1 − 1/x) ≤ 0 for all x ≥ 0; as a ≤ 0 this implies that r(2 log a)(1 + r log(1 − 1/r)) ≥ 0. Thus, in order to show (8) it suffices to show that 43 (9) r2(log2 r − log2(r − 1)) − 2r log r ≥ 0 To show this, we take a second-order Taylor expansion of log x around x = r; this gives us that log(r − 1) ≤ log r − 1 r − 1 2r2 Hence r2(log2 r − log2(r − 1)) − 2r log r ≥ r2(log2 r − (log r − 1/r − 1/(2r2))2) − 2r log r = log r − (1 + Simple calculus shows that this is positive for r ≥ 4. 1 2r )2. (cid:3) Appendix C. Selecting y ∈ [0, 1] for Lemma 9.8 In this section, we will assume U (p) < n−K for some constant K > 2; thus the conclusions of Proposition 3.6 hold. We also suppose throughout that 3/2 ≤ α ≤ α∗ ≤ O(1), ρ ≤ 2.1, β ≤ 1, δ ≥ β. (Other cases are covered already in Proposition 9.2.) For any y ∈ [0, 1], let us define T (y, α) = α max(h(y), ¯h(y/α)) For any y ∈ [0, 1], Lemma 9.8 shows that the success probability of the RCA will be at least n2−2y−T (y,α)−o(1). We claim that it is always possible to select y so that this quantity is at least n−1−o(1)ǫ−1.5−o(1). Thus, it suffices to show that (10) Let us define a = 2y + T (y, α) ≤ 3 + 1.5ρ (3 − β + δ)2(2 − β + δ + ρ) (2 − β + δ)2(2 + δ) We prove (10) in two parts. First, we show that it suffices to bound 2y + T (y, a) -- that is, when we replace α by a quantity which is (approximately) an appropriate upper bound on α∗. Next, we show that 2y + T (y, a) can be regarded as a scalar function depending on only a few real parameters, which can be tested exhaustively. Proposition C.1. For any y ∈ [0, 1] we have T (y, α) ≤ T (y, a) + o(1) Proof. By Lemma 8.2, we have α ≤ α∗ ≤ a + o(1 + ρ). As ρ = O(1), this implies that α ≤ a + o(1). First, suppose that α = a + t, where 0 ≤ t ≤ o(1). By Proposition D.2, the derivatives of h, ¯h are bounded by constants, and so αh(y) ≤ ah(y)+o(1) and similarly α¯h(y/α) ≤ a¯h(y/a)+o(1). So T (y, α) ≤ T (y, a)+o(1) as desired. Next, suppose that α ≤ a. Then αh(y) ≤ ah(y). Also, it can be mechanically verified that x¯h(y/x) is an increasing function of x; thus α¯h(y/α) ≤ a¯h(y/a). This implies that T (y, α) ≤ T (y, a) (cid:3) Next, we bound 2y + T (y, a) by using the crude but effective method of using a ǫ-net and essentially trying every value of β, δ exhaustively. Proposition C.2. There is y ∈ [0, 1] with 2y + T (y, a) ≤ 1 + 1.5ρ + o(1). Proof. First, suppose that δ ≥ 3/2. Then we set y = 1 and obtain that 2y + T (y, a) ≤ 2 + a max(h(1), ¯h(1/a)) β, δ, ρ, and it can be verified mechanically that 2 + a¯h(1/a) ≤ 3 + 1.5ρ. As h(1) = 0, this implies that 2y + T (y, a) ≤ 2 + a¯h(1/a). This can be written as a rational function of We next assume that β ∈ [0, 1], δ ∈ [β, 3/2]. We will show that in this range we can choose y such that 2y + T (y, a) ≤ 2.95 + 1.2ρ We loop over choices of b = 0, s, 2s, . . . , 1−s and d = b−s, b, b+s, b+2d, . . ., 3/2−s and r = 0, s, 2s, . . . , 2.1 where s = 0.001. For each such choice b, d, r we choose some y ∈ [0, 1] and compute an upper bound on 2y + T (y, a) for β, δ, ρ in the range β ∈ [b, b + s], δ ∈ [d, d + s], ρ ∈ [r, r + s]. We denote this interval by Ib,d,r. (Note that the inequality d ≥ b − s comes from the fact that we must have δ ≥ β.) 44 Now, suppose we have fixed some choice of b, d, y and we want to show that in this region (11) 2y + a max(h(y), ¯h(y/a)) ≤ 2.95 + 1.5ρ It can be mechanically verified that in the interval Ib,d,r we have a ≤ amax = (3 − b + d)2 (2 + d)(2 − b + d) + (r + s)(3 − b + d − s)2 (2 + d)(2 − b + d − s)2 As ¯h is an increasing function, a sufficient condition to show (11) is that 2y + amax max(h(y), ¯h(y/amax)) ≤ 2.95 + 1.5r (12) It is easy to compute using standard numerical techniques an upper bound on the quantity (This upper bound is not affected by the value of ρ) For max(h(y), ¯h(y/amax)) over the interval Ib,d,r. example, ¯h(z) is an increasing function of β, δ. Thus, we can compute an upper bound on 2y + amax max(h(y), ¯h(y/amax)) in the interval Ib,d,r; if this upper bound is at most 2.95 + 1.5r, then this shows that (12) and hence (11) holds. We wrote C code (omitted here) to loop over all b, d, r and perform the above calculation. This procedure works for any choice of y. The method we used was to approximately satisfy the constraint h(y) = ¯h(y/amax) at β = b, δ = d. With this choice of y, we satisfy (12) for all intervals.3 (cid:3) Putting these cases together, we have our desired result: Proposition C.3. Suppose 3/2 ≤ α ≤ α∗ and ρ ≤ 2.1 and β ∈ [0, 1]. Then there is y ∈ [0, 1] such that 2y + T (y, α) ≤ 2.95 + 1.5ρ + o(1) Appendix D. Properties of the functions h, ¯h We discuss here some properties of the functions h(x), ¯h(x). We repeat the functions h, ¯h for convenience. In this section, we will assume U (p) < n−K for some constant K > 2; thus the conclusions of Proposition 3.6 hold. h(x) = 2(2 + δ)(log(3 − β + δ) − log(2 − β + δ + x)) 2(2 + δ)(log(3 − β + δ) − log(2 + δ)) + 2(β − x)  2(1 − x) (δ + 2)(1 − x)(5 − 2β + 2δ + x) ¯h(x) = (3 − β + δ)2 if x ≥ β if x ≤ β ≤ 1 if β ≥ 1 Proposition D.1. We have 10/9 ≤ ¯h(0) ≤ 20/9. Furthermore, if β ≤ 3/2 then ¯h(0) ≤ 2. Proof. ¯h(0) is a rational function of β, δ so this fact can be verified mechanically for δ ≥ β, β ∈ [0, 2]. Proposition D.2. We have −2 ≤ h′(x) ≤ −4/3 − Ω(1) Proof. When β ≥ 1 or x ≤ β then h′(x) = −2 and so this is clear. When β ≤ x ≤ 1 we have (cid:3) h′(x) = −2(2 + δ) 2 − β + δ + x As β ≤ 2 + o(1) and δ ≥ δ0, for n sufficiently large this is negative. Hence the maximum value occurs at β = 0, x = 1 yielding h′(x) ≤ −2 + 2 3 + δ ≤ −2 + 2 3 + δ0 ≤ −4/3 − Ω(1) The minimum value of h′(x) occurs at β = x yielding h′(x) ≥ 2. 3Note that the relevant calculations were performed using double-precision floating point (with the default rounding mode), instead of rigorous interval arithmetic. This was done for the sake of easy implementation using standard numerical li- braries. However, in fact, we observed that these constraints were both satisfied with significant slack -- we saw that 2y + amax max(h(y), ¯h(y/amax)) − 2.95 − 1.5r ≤ −0.01. Thus we do not expect that this slight numerical error will affect the validity of the results. (cid:3) 45 Proposition D.3. We have −4 + Ω(1) ≤ ¯h′(x) ≤ −Ω(1). Proof. We compute the derivative of ¯h as: This is clearly a decreasing function of x, so it achieves its minimum value at x = 1. There it is equal to ¯h′(x) = − 2(δ + 2)(−β + δ + x + 2) (−β + δ + 3)2 Similarly, ¯h′(x) achieves its maximum value at x = 0 where we have ¯h′(1) = −2(2 + δ) 3 − β + δ ≥ −2(2 + δ) 1 + δ0 ≥ −4 + Ω(1) 3 − 2 + δ ≥ −2(2 + δ0) 2(δ + 2)(β − δ − 2) (−β + δ + 3)2 ¯h′(0) = One can see that this is U-shaped as a function of β. So its maximum value occurs at either β = 0 or β = 2. At those points respectively we have and ¯h′(0) = −2(2 + δ)2 (3 + δ)2 ≤ −8/9 ¯h′(0) = −2 + 2 (1 + δ)2 ≤ −2 + 2 (1 + δ0)2 ≤ −Ω(1) (cid:3) Proposition D.4. For β ∈ [0, 1] and x ∈ [0, 1] we have ¯h(x) ≤ h(x). Proof. Observe that h(1) = ¯h(1) = 0. So it suffices to show that ¯h′(x) ≥ h′(x) for x ∈ [0, 1]. We have that ¯h′(x) = −2(δ+2)(−β+δ+x+2) . This is a rational function, and so it can be mechanically verified that ¯h′(x) ≥ −2 for x ∈ [0, 1] and β, δ ∈ [0, 1]. As h′(x) = −2 when x ≤ β, this automatically implies that ¯h′(x) ≥ h′(x) for x ≤ β. (−β+δ+3)2 When x ≥ β, we have that h′(x) = −2(2+δ) 2−β+δ+x . So to show that ¯h′(x) ≥ h′(x), we must show that −2(δ + 2)(−β + δ + x + 2) (−β + δ + 3)2 ≥ −2(2 + δ) 2 − β + δ + x ≥ 0 Again, this is a rational function, so it can be mechanically verified that this holds in the indicated (cid:3) range. 46
0908.3574
2
0908
2010-01-20T00:35:00
In-packet Bloom filters: Design and networking applications
[ "cs.DS", "cs.IT", "cs.NI", "cs.PF", "cs.IT" ]
The Bloom filter (BF) is a well-known space-efficient data structure that answers set membership queries with some probability of false positives. In an attempt to solve many of the limitations of current inter-networking architectures, some recent proposals rely on including small BFs in packet headers for routing, security, accountability or other purposes that move application states into the packets themselves. In this paper, we consider the design of such in-packet Bloom filters (iBF). Our main contributions are exploring the design space and the evaluation of a series of extensions (1) to increase the practicality and performance of iBFs, (2) to enable false-negative-free element deletion, and (3) to provide security enhancements. In addition to the theoretical estimates, extensive simulations of the multiple design parameters and implementation alternatives validate the usefulness of the extensions, providing for enhanced and novel iBF networking applications.
cs.DS
cs
In-packet Bloom filters: Design and networking applications Christian Esteve Rothenberg, Carlos A. B. Macapuna, Maur´ıcio F. Magalhaesa, F´abio L. Verdib, Alexander Wiesmaierc aSchool of Electrical and Computer Engineering University of Campinas, Brazil bFederal University of Sao Carlos (UFSCar), Campus Sorocaba , Brazil cDarmstadt University of Technology - CDC, Center for Advanced Security Research Darmstadt, Germany 0 1 0 2 n a J 0 2 ] S D . s c [ 2 v 4 7 5 3 . 8 0 9 0 : v i X r a Abstract The Bloom filter (BF) is a well-known space-efficient data structure that answers set membership queries with some probability of false positives. In an attempt to solve many of the limitations of current inter-networking architectures, some recent proposals rely on including small BFs in packet headers for routing, security, accountability or other purposes that move application states into the packets themselves. In this paper, we consider the design of such in- packet Bloom filters (iBF). Our main contributions are exploring the design space and the evaluation of a series of extensions (1) to increase the practicality and performance of iBFs, (2) to enable false-negative-free element deletion, and (3) to provide security enhancements. In addition to the theoretical estimates, extensive simulations of the multiple design parameters and implementation alternatives validate the usefulness of the extensions, providing for enhanced and novel iBF networking applications. Keywords: Bloom filter, algorithms, distributed systems, packet forwarding, inter-networking 1. Introduction Since the seminal survey work by [1], Bloom fil- ters (BF) [2] have increasingly become a fundamen- tal data aggregation component to address performance and scalability issues of very diverse network applica- tions, including overlay networks [3], data-centric rout- ing [4], traffic monitoring, and so on. In this work, we focus on the subset of distributed networking applica- tions based on packet-header-size Bloom filters to share some state (information set) among network nodes. The specific state carried in the Bloom filter varies from ap- plication to application, ranging from secure creden- tials [5, 6] to IP prefixes [7] and link identifiers [8], with the shared requirement of a fixed-size packet header data structure to efficiently verify set memberships. Considering the constraints faced by the implemen- tation of next generation networks (e.g., Gbps speeds, increasingly complex tasks, larger systems, high-speed memory availability, etc.), recent inter-networking pro- Email addresses: {chesteve, macapuna, magalhaes}@dca.fee.unicamp.br (Christian Esteve Rothenberg, Carlos A. B. Macapuna, Maur´ıcio F. Magalhaes), [email protected] (F´abio L. Verdi), [email protected] (Alexander Wiesmaier) posals [5, 6, 7, 8, 9, 10] chose to include more informa- tion in the packet headers to keep pace with the increas- ing speed and needs of Internet-scale systems. Moving state to the packets themselves helps to alleviate sys- tem bottlenecks (e.g., IP multicast [7], source routing overhead [8]) and enables new in-network applications (e.g., security [5, 6], traceback [9]) or stateless protocol designs [11]. We refer to the BF used in this type of applications as an in-packet Bloom filter (iBF). In a way, iBFs follow a reverse approach compared to traditional standalone BF implementations: iBFs can be issued, queried, and mod- ified by multiple network entities at packet processing time. These specific needs may benefit from additional capabilities like element removals or security enhance- ments. Moreover, careful BF design considerations are required to deal with the potential effects of false pos- itives, as every packet header bit counts and the actual performance of the distributed system is a key goal. In this paper, we address common limitations of naive iBF designs and provide a practical foundation for networking application designs requiring to solve set-membership problems on a packet basis (§ 3). Our main contribution consists of assembling and evaluat- ing a series of practical extensions (i) to increase the Preprint submitted to Computer Networks October 22, 2018 system performance, (ii) to enable false-negative-free element deletion, and (iii) to provide security-enhanced constructs at wire speed (§ 4). Via extensive simula- tion work, we explore the rich design space and provide a thorough evaluation of the observed trade-offs (§ 5). Finally, we relate our contributions to previous work on Bloom filter designs and briefly discuss the applicability of the iBF extensions to existing applications (§ 6). data collector(s). The statistical en-route filtering ap- proach [6] proposes a detection method based on an iBF representation of the report generation (collection of keyed message authentications), that is verified prob- abilistically and dropped en-route in case of incorrect- ness. The iBF-based solution uses 64 bits only and is able to filter out 70% of the injected bogus reports within 5 hops, and up to 90% within 10 hops along the paths to the data sink. 2. Networking applications 2.3. IP traceback iBFs are well suited for applications where one might like to include a list of elements in every packet, but a complete list requires too much space. In these situa- tions, a hash-based lossy representation, like a BF, can dramatically reduce space, maintaining a fixed header size, at the cost of introducing false positives when answering set-membership queries. From its original higher layer applications such as dictionaries, BFs have spanned their application domain down to hardware im- plementations, becoming a daily aid in network applica- tions (e.g., routing table lookups, DPI, etc.) and future information-oriented networking proposals [12]. As a motivation to our work and to get some practical exam- ples of iBF usages, we first briefly survey a series of networking applications with the common theme of us- ing small BFs carried in packets. 2.1. Data path security The credential-based data path architecture intro- duced in [5] proposes novel network router security features. During the connection establishment phase, routers authorize a new traffic flow request and issue a set of credentials (aka capabilities) compactly repre- sented as iBF bit positions. The flow initiator constructs the credentials by including all the router signatures into an iBF. Each router along the path checks on packet ar- rival for presence of its credentials, i.e., the k bits result- ing from hashing the packet 5-tuple IP flow identifier and the routers (secret) identity. Hence, unauthorized traffic and flow security violations can be probabilisti- cally avoided per hop in a stateless fashion. Using 128 bits only, the iBF-based authorization token reduces the probability that attack traffic reaches its destination to a fraction of a percent for typical Internet path lengths. 2.2. Wireless sensor networks A typical attack by compromised sensor nodes con- sists of injecting large quantities of bogus sensing reports, which, if undetected, are forwarded to the 2 The packet-marking IP traceback method proposed in [9] relies on iBFs to trace an attack back to its approx- imate source by analyzing a single packet. On packet arrival, routers insert their mark (IP mask) into the iBF, enabling a receiver to reconstruct probabilistically the packet path(s) by testing for iBF presence of neighbor- ing router addresses. 2.4. Loop prevention In Icarus [10], a small iBF is initialized with 0s and gets filled as forwarding elements includes adding the Bloom masks (size m, k bits set to 1) of the interfaces they pass to the iBF. If the OR operation does not change the iBF, then the packet might be looping and should be dropped. If the Bloom filter changes, the packet is definitely not looping. 2.5. IP multicast Revisiting the case of IP multicast, the authors of [7] propose inserting an iBF above the IP header to rep- resent domain-level paths of multicast packets. After discovering the dissemination tree of a specific multi- cast group, the source border router searches its inter- domain routing table to find the prefixes of the group members. It then builds an 800-bit shim header by in- serting the path labels (AS a : AS b) of the dissemination tree into the iBF. Forwarding routers receiving the iBF check for presence of next hop autonomous systems and forward the packet accordingly. 2.6. Source routing & multicast The LIPSIN [8] forwarding fabric leverages the idea of having interface identifiers in BF-form (m-bit Link ID with only k bits set to 1). A routing iBF can then be constructed by ORing the different Link IDs represent- ing a source route. Forwarding nodes maintain a small Link ID table whose entries are checked for presence in the routing iBF to take the forwarding decision. In addi- tion to stateless multicast capabilities, a series of exten- sions are proposed to have a practical and scalable net- working approach (e.g., virtual links, fast recovery, loop detection, false positive blocking, IP inter-networking, etc.). Using a 256-bit iBF in a typical WAN topology, multicast trees containing around 40 links can be con- structed to reach in a stateless fashion up to 24 users while maintaining the false positive rate (≈ 3%) and the associated forwarding efficiency within reasonable per- formance levels. 3. Basic design The basic notation of an iBF is equivalent to the stan- dard BF, that is an array of length m, k independent hash functions, and number of inserted elements n. For the sake of generality, we refer simply to elements as the objects identified by the iBF and queried by the network processing entities. Depending on the specific iBF net- working application, elements may take different forms such as interface names, IP addresses, certificates, and so on. On insertion, the element is hashed to the k hash val- ues and the corresponding bit positions are set to 1. On element check, if any of the bits determined by the hash outputs is 0, we can be sure that the element was not inserted (no false negative property). If all the k bits are set to 1, we have a probabilistic argument to be- lieve that the element was actually inserted. The case of collisions to bits set by other elements causing a non- inserted element to return "true" is referred to as a false positive. In different networking applications, false pos- itives manifest themselves with different harmful effects such as bandwidth waste, security risks, computational overhead, etc. Hence, a system design goal is to keep false positives to a minimum. 3.1. False positive estimates It is well-known that the a priori false positive esti- mate, f pb, is the expected false positive probability for a given set of parameters (m,n,k) before element addi- tion: (1) 1 − 1 − f pb =  k 1 m!k∗n The number k, that minimizes the false positive proba- bility, can be obtained by setting the partial derivative of f pb with respect to k to 0. This is attained when k = ln(2) ∗ m n , and is rounded to an integer to determine the optimal number of hash functions to be used [1]. While Eq. 1 has been extensively used and experi- mentally validated as a good approximation, for small values of m the actual false positive rate can be much larger. Recently, Bose et al. [13] have shown that f pb 3 is actually only a lower bound, and a more accurate es- timate can be obtained by formulating the problem as a balls-into-bins experiment: pk,n,m = 1 mk(n+1) m Xi=1 iki! m i!( kn i ) (2) which, according to [13, Theorem 4], can be lower- and upper-bounded as follows: k n r lnm − klnp m (3)   pk < pk,n,m < pk 1 + O The difference of the observed false positive rate and the theoretical estimates can be significant for small size BFs, a fact that we (and others) have empirically ob- served (see evaluation in §5.1.2). Hence, iBFs are prone to more false positives than traditional BFs for equiva- lent m/n ratios but larger values of m. Both the definition of Eq. 1 and Eq. 2 do not involve knowing exactly how many bits are actually set to 1. A more accurate estimate can be given once we know the fill factor ρ; that is the fraction of bits that are actually set to 1 after all elements are inserted. We can define the posterior false positive estimate, f pa, as the expected false positive probability after inserting the elements: f pa = ρk (4) Finally, the observed false positive probability is the ac- tual false positive rate ( f pr) that is observed when a number of queries are made: f pr = Observed false positives Tested elements (5) Note that the f pr is an experimental quantity computed via simulation or system measurements and not a theo- retical estimate. Hence, the f pr is the key performance indicator we want to measure in a real system, where every observed false positive will cause some form of degradation. Therefore, practitioners are less interested in the asymptotic bounds of the hash-based data struc- ture and more concerned with the actual false positive rates, especially in the space-constrained scenario of tiny iBFs. 3.2. Naming and operations A nice property of hash-based data structures is that the performance is independent from the form of the in- serted elements. Independently of its size or represen- tation, every element carried in the iBF contributes with at most k bits set to 1. In order to meet the line speed requirements on iBF operations, a design recommenda- tion is to have the elements readily in a pre-computed BF-form (m-bit vector with k bits set to 1), avoiding thereby any hashing at packet processing time. Ele- ment insertion becomes a simple, parallelizable bitwise OR operation. Analogously, an iBF element check can be performed very efficiently in parallel via fast bitwise AND and COMP operations. A BF-ready element name, also commonly referred to as element footprint, can be stored as an m-bit bit vector or, for space efficiency, it can take a sparse rep- resentation including only the indexes of the k bit posi- tions set to 1. In this case, each element entry requires only k ∗ log2(m) bits. 4. Extensions In this section, we describe three useful extensions to basic Bloom filter designs in order to address the fol- lowing practical issues of iBFs: (i) Performance: Element Tags exploit the notion of power of choices in combining hashing-based el- ement names to select the best iBF according to some criteria, for instance, less false positives. (ii) Deletion: Deletable Regions introduce an addi- tional header to code collision-free zones, en- abling thereby safe (false-negative-free) element removals at an affordable packet header bit space. (iii) Security: Secure Constructs use packet-specific information and distributed time-based secrets to provide protection from iBF replay attacks and bit pattern analysis, preventing attackers from misus- ing iBFs or trying to infer the identities of the in- serted elements. 4.1. Element Tags The concept of element Tags (eTags) is based on extending BF-compatible element naming with a set of equivalent footprint candidates. That is, instead of each element being identified with a single footprint, every element is associated with d alternative names, called eTags, uniformly computed by applying some system-wide mapping function (e.g., k ∗ d hash func- tions). That allows us to construct iBFs that can be op- timized in terms of the false positive rate and/or com- pliance with element-specific false positive avoidance strategies. Hence, for each element, there are d differ- ent eTags, where d is a system parameter that can vary depending on the application. As we see later, a practi- cal value of d is in the range of multiples of 2 between 2 and 64. We use the notion of power of choices [14] and take advantage of the random distribution of the bits set to 1 to select the iBF representation among the d candidates that leads to a better performance given a certain opti- mization goal (e.g., lower fill factor, avoidance of spe- cific false positives). This way, we follow a similar ap- proach to the Best-of-N method applied in [15], with the main differences of (1) a distributed application scenario where the d value is carried in the packet header, and (2) the best candidate selection criterion is not limited to the least amount of bits set but includes any system optimization criteria (e.g., § 5.2 bit deletability), includ- ing those that involve counting false positives against a training set (e.g. § 4.1.2 fpr-based selection). The caveats of this extension are, first, it requires more space to store element names, and second, the value d needs to be stored in the packet header as well, consuming bits that could be used for the iBF. However, knowing the d value at element query time is fundamen- tal to avoid checking multiple element representations. Upon packet arrival, the iBF and the corresponding eTag entries can be ANDed in parallel. 4.1.1. Generation of eTags To achieve a near uniform distribution of 1s in the iBF, k independent hash functions per eTag are required. In general, k may be different for each eTag, allowing to adapt better to different fill factors and reducing the false positives of more sensitive elements. Using the double hashing technique [16] to compute the bits set to 1 in the d eTags, only two independent hash functions are required without any increase of the asymptotic false positive probability. That is, we rely on the result of Kirsch and Mitzenmacher [16] on linear combination of hash functions, where two independent hash functions and can be used to simulate i random hash functions of the form: gi(x) = [h1(x) + i ∗ h2(x)] mod m (6) As long as h1(x) and h2(x) are system wide parameters, only sharing i = d ∗ k integers is required to derive the eTags for any set of elements. For space efficiency, an- other optimization for the sparse representation of the candidates consists of defining the d eTags by combina- tions among k + x iBF positions, i.e., d = (cid:16)k+x k (cid:17). 4.1.2. Candidate selection Having "equivalent" iBF candidates enables to de- fine a selection criteria based on some design-specific 4 objectives. To address performance by reducing false positives, we can select the candidate iBF that presents the best posterior false positive estimate (fpa-based se- lection; Eq. 4). If a reference test set is available to count for false positives, the iBF choice can be done based on the lowest observed rate (fpr-based selection; Eq. 5). Another type of selection policy can be specified to favor the candidate presenting less false positives for certain "system-critical" elements (element-avoidance- based selection). 4.1.3. False positive improvement estimate Following the same analysis as in [15], the potential gain in terms of false positive reduction due to selecting the iBF candidate with fewer 1s can be obtained by es- timating the least number of bits set after d independent random variable experiments (see Appendix B for the mathematical details). Fig. 1 shows the expected gains when using the fpa-based selection after generating d candidate iBF for a given element set. With a few dozen candidates, one can expect a factor 2 improvement in the observed f pr when selecting the candidate with fewer ones. Note that the four iBF configurations plotted in Fig. 1 have the same m/n ratio. In line with the argu- ments of [13], smaller bit vectors start with a slightly larger false positive estimate. However, as shown in Fig. 1(b), the f pr improvement factor of smaller iBFs due to the d-eTag extension is larger. Hence, especially for small iBFs, computing d candidates can highly im- prove the false positive behavior, a fact that we have validated experimentally in § 5. 4.2. Deletable Regions Under some circumstances, a desirable property of iBFs is to enable element deletions as the iBF packet is processed along network nodes. For instance, this is the case when some inserted elements are to be pro- cessed only once (e.g., a hop within a source route), or, when bit space to add more elements is required. Un- fortunately, due to its compression nature, bit collisions hamper naive element removals unless we can tolerate introducing false negatives into the system. To over- come this limitation (with high probability), so-called counting Bloom filters (CBF) [17] were proposed to ex- pand each bit position to a cell of c bits. In a CBF, each bit vector cell acts as a counter, increased on element insertion and decreased on element removal. As long as there is no counter overflow, deletions are safe from false negatives. The main caveat is the c times larger space requirements, a very high price for the tiny iBFs under consideration. m=64, n=6 m=128, n=12 m=256, n=24 m=512, n=48 8E-03 7E-03 6E-03 5E-03 4E-03 y t i l i b a b o r p e v i t i s o p e s a f l 0 20 40 60 80 candidates (d) 100 120 (a) A priori false positive estimate of the iBF candidate with the low- est fill factor. 2.8 r o t c a f t n e m e v o r p m i e v i t i s o p e s a l f 2.6 2.4 2.2 2 1.8 1.6 1.4 1.2 1 0 m=64, n=6 m=128, n=12 m=256, n=24 m=512, n=48 20 40 60 80 candidates (d) 100 120 (b) Potential false positive improvement when being able to choose among d iBFs. Figure 1: False positive probability gains of the power of choices ex- tension. The key idea is to keep track of where the collisions occur at element insertion time. By using the property that bits set to 1 by just one element (collision-free bits) are safely deletable, the proposed extension consists of encoding the deletable regions as part of the iBF header. Then, an element can be effectively removed if at least one of its bits can be deleted. Again, this extension should consume a minimum of bits from the allocated iBF space. A straightforward coding scheme is to di- vide the iBF bit vector into r regions of m′/r bits each, where m′ is the original m minus the extension header bits. As shown in Fig. 2, this extension uses r bits to code with 0 a collision-free region and with 1 otherwise (non-deletable region). The probability of element dele- tion i.e. n elements having at least one bit in a collision- free region, can be approximated to (see Appendix A 5 Figure 2: An example of the DlBF with m = 32, k = 3 and r = 4, representing the set x, y, z. The 1s in the first r bits indicate that a collision happen in the corresponding region and bits therein cannot be deleted. Since each element has at least one bit in a collision-free zone, all of them are deletable. for the mathematical details): 100 ) % l ( e b a t e e d l 80 60 40 20 0 n = 32 n = 21 n = 16 n = 13 n = 10 n = 8 8 16 24 32 40 48 56 64 regions (r) (a) Deletability as function of number of regions. (7) 100 ) % ( l e b a t l e e d 80 60 40 20 0 r = 8 r = 16 r = 32 r = 64 5 10 15 20 25 30 elements (n) (b) Deletability as function of inserted elements. Figure 3: Deletability probability (m=256). using keyed hash functions. Our approach does not dif- fer at the core of the solution i.e. obscuring the result- ing bit patterns in the filter by using additional inputs to the hashes. However, our attention is focused to the specifics of distributed, line-speed iBF operations. The main idea to improve the security is to bind the iBF element insertion to (1) an invariant of the packet or flow (e.g., IP 5-tuple, packet payload, etc.), and (2) system-wide time-based secret keys. Basi- cally, the inserted elements become packet- and time- specific. Hence, an iBF gets expirable and meaning- ful only if used with the specific packet (or authorized packet flow), avoiding the risk of an iBF replay attack, where the iBF is placed as a header on a different packet. 4.3.1. Binding to packet contents We strive to provide a lightweight, bit mixing func- tion O = F(K, I) to make an element name K dependent on additional in-packet information I. For this exten- sion, an element name K is an m-bit hash output and 6 pdr = 1 − n 2! k r(m − r)! Plotting pdr against the number of regions r (see Fig. 3(a)) confirms the intuition that increasing r results in a larger proportion of elements being deletable. As more elements are inserted into the iBF, the number of collisions increase and the deletion capabilities (bits in collision-free regions) are reduced (see Fig. 3(b)). As a consequence, the target element deletion probability pdr and the number of regions r establish a practical limitation on the capacity of nmax deletable iBFs. From a performance perspective, enabling deletions comes at the cost of r bits from the iBF bit space. How- ever, removing already processed elements decreases the fill factor and consequently reduces the probability of false positives upfront. Later in § 5.2 we explore the trade-offs between the overhead of coding the deletable regions, the impact on the f pr, and the implications of the candidate selection criteria. 4.3. Secure Constructs The hashing nature of iBFs provides some inherent security properties to obscure the identities of the in- serted elements from an observer or attacker. However, we have identified a series of cases where improved se- curity means are desirable. For instance, an attacker is able to infer, with some probability, whether two pack- ets contain an overlapping set of elements by simple in- specting the bits set to 1 in the iBFs. In another case, an attacker may wait and collect a large sample of iBFs to infer some common patterns of the inserted elements. In any case, if the attacker has knowledge of the com- plete element space (and the eTags generation scheme), he/she can certainly try a dictionary attack by testing for presence of every element and obtain a probabilistic answer to what elements are carried in a given iBF. A similar problem has been studied in [18] to secure stan- dalone BFs representing a summary of documents by Algorithm 1: Secure iBF element set/check algo- rithm. Input: element name K, packet-specific id. I, param. d Output: k bit positions to be set/checked 1.- Let O = k ⊗ I 2.- Divide O into k segments of m/k bits: O1, O2, ..., Ok 3.- Divide each O j into a c ∗ log2(m) bit matrix: m O j1, O j2, ..., O jc where c = ⌈ k∗log2(m)⌉ 4.- foreach O j ∈ [O1, ..., Ok] do Set/check bit position i in the iBF where: i = O j1 ⊗ O j2 ⊗ ... ⊗ O jc i << d end not the eTag representation with only k bits set to 1. The function F should be fast enough to be done at packet processing time over the complete set of elements to be queried by a node processing the iBF. The output O is the k bit positions to be set/checked in the iBF. Using true hash functions (e.g., MD5, SHA1) as F becomes unpractical if we want to avoid multiple (one per ele- ment) cycle-intense hashing per packet. As an example resource-efficient implementation of F, we propose the lightweight Algorithm 1 to mix each element key K with a fixed bit string I. Taking I as an input, the algorithm runs in parallel on each element K and returns the k bit positions in the iBF to be set or checked. After an initial bitwise XOR operation (Step 1), the output O is divided into k segments of m/k bits (Step 2). To build the folding matrix in Step 3, each segment is transformed into a matrix of c∗log2(m) bits.1 For instance, with m = 256 and k = 4, each segment Ok would be a 64-bit bit vector transformed into a 8x8 matrix. Finally, each of the k output values is computed by XORing the rows of each matrix into a log2(m) bit value that returns the bit position to be set/checked (Step 4). The last d-bit shifting operation enables the power of choices capabilities. We are faced with the classic trade-off between se- curity and performance. An heuristic evaluation sug- gests that the proposed F provides a good balance be- tween performance and security. First, F involves only bit shifting and XOR operations that can be done in a 1Note that depending on the values of m and k, some padding bits (e.g., re-used from within the segment) may be required to complete the matrix. 7 few clock cycles in parallel for every K. Second, the k bit positions depend on all the bits, within an m/k bit segment, from the inputs I and K. The security of F de- pends on how well I and K are mixed. For security sen- sitive applications, the XOR operation in Step 1 should be replaced with a more secure transformation P(K, I) i.e., using a lightweight cipher or hash function. In gen- eral, F should take the application specifics into account (e.g., nature of K, computation of I per-packet) and the target security level. 4.3.2. Time-based keyed hashing A more elaborate security extension consists of using a keyed element name construction, and change the se- cret key S (t) regularly. We can S (t) as the output of a pseudo random function S i = F(seed, ti), where seed is the previous seed value and t a time-based input. Then, we can include the current S value in the algorithm for element check/insertion e.g., O = F(K, I, S (t)). Thereby, we have a periodically updated, shared secret between iBF issuers and iBF processing entities, with the benefit that an iBF cannot be re-utilized after a cer- tain period of time or after an explicit re-keying request. Moreover, by accepting S i and S i−1 the system requires only loose synchronization similar to commercial time- coupled token generators. At the cost of initial syn- chronization efforts and computational overhead, this method provides an effective countermeasure to protect the system from compromised iBF attacks (cf., DDoS protection with self-routing capabilities [19]). 4.4. Density factor Another iBF security measure, also proposed in [5], is to limit the percentage of 1s in the iBF to 50-75%. A density factor ρmax can safely be set to k ∗ nmax/m, as each legitimate element contributes with at most k bits. Then, the probability of an attacker guessing a bit combination causing a single false positive can be upper bounded by ρk max. 5. Practical evaluation In this section, we turn our attention to the practi- cal behavior of the iBF in function of the multiple de- sign parameters and carry out extensive simulation work to validate the usefulness of the three extensions under consideration. For these purposes, we use randomly generated bit strings as input elements and the double hashing technique using SHA1 and MD5. The section concludes exploring briefly the potential impact of dif- ferent types of iBF elements (flat labels, IP addresses, dictionary entries) and the hash function implementa- tion choice. 5.1. Element Tags We are interested in evaluating the gains of the power of choices that underpins the element Tag extension (§ 4.1), where any element set can be equivalently rep- resented by d different iBFs, different in their bit distri- bution but equivalent with regard to the carried element identities. We first explore the case where k = 5 and then the impact of using a distribution around 5 for can- didate naming.2 5.1.1. Power of choices (d) We run the simulations varying d from 2 to 64 and updating m accordingly to to reflect the overhead of in- cluding the value d in the packet header. Fig. 4 com- pares the observed f pr for different values of d. We see that by increasing d and choosing the candidate iBF just by observing its fill factor after construction (Fig. 4(a)) leads to better performing iBFs. In the re- gion where the iBF is more filled (30-40 elements), the observed f pr drops between 30% and 50% when 16 or more candidate iBFs are available. Another interpreta- tion is that for a maximal target f pr we can now insert more elements. As expected, the performance gain is more significant if we consider the best performing iBF candidate after testing for false positives. Observing Fig. 4(b), the number of false positives is approximately halved when comparing the best iBF among 16 or more against a standard 256-bit iBF. In general, we note that the observed f pr is slightly larger than the commonly assumed theoretical estimate (Eq. 1), confirming thus the findings by [13] (Eq. 4). This difference is more no- ticeable for small values of m and becomes negligible for values larger than 1024 (see Table 1). 5.1.2. Distribution of the number of hash functions (k) Now, we allow a different number of bits k per can- didate. For instance, with d = 8 the distribution of k among the candidates is [4,4,5,5,6,6,7,7]. Intuitively, this naming scheme adapts better to the total number of elements in the iBF (k closer to kopt = ln(2) ∗ m n ). The fpa-based selection criterion (§ 4.1) is now choos- ing the candidate with the lowest estimate after hash- kd}. Fig. 5(a) shows the distribu- ing: min{ρ0 tion of the selected 256-bit iBFs for the case of d = 16 k0 , . . . , ρd Theor. k=5 no choices 4 choices 16 choices 32 choices 64 choices 5 4 3 2 1 0 10 20 30 40 # elements (a) Best fill rate candidate Theor. k=5 no choices 4 choices 16 choices 32 choices 64 choices 5 4 3 2 1 ) % ( e t a r e v i t i s o p e s a f l ) % ( e t a r e v i t i s o p e s a l f 0 10 20 30 40 # elements (b) Best observed fpr Figure 4: Power of choice gains (m=256, k=5). and k evenly distributed between 4 and 7. The line shows the percentage of times that the selected iBF actu- ally yielded the best performance among the candidates. Disregarding the scenarios with fewer elements, the fpa- based selection criteria succeeded to choose the optimal candidate in about 30% of the times. Fig. 5(b) shows the percentile distribution of the best performing iBF after f pr testing. As expected, in more filled iBFs scenarios, setting less bits per element is beneficial. However, the differences are relatively small. As shown in Table 1, the observed f pr in the case of kconst. = 5 is practically equivalent (if not slightly better) to the case where k is distributed. We can also observe what the theory in § 2 predicts with regard to smaller iBFs and (i) their inferior f pr performance for the same m/n ratio, and (ii) their larger potential to benefit from the power of choices. 2We choose k = 5 to have a probabilistically sufficient footprint space for the eTags (m!/(m−k)! ≈ 1012 with m = 256) when targeting an m/n of about 8 bits per element. 5.1.3. Discussion Based on our experimental evaluation, having more than 32 candidates per element does not seem to bring 8 k=5 k=4 k=7 k=6 best iBF Table 1: Observed f pr for iBFs with 16 eTag choices. ) % ( e t i a d d n a c F B i d e t c e e S l ) % ( e c n a m r o f r e p t s e B 100 80 60 40 20 0 100 80 60 40 20 0 10 14 18 26 22 34 Elements in iBF (#) 30 38 42 46 (a) Best fill rate candidate k=4 k=5 k=6 k=7 10 14 18 26 22 34 Elements in iBF (#) 30 38 42 46 (b) Best observed fpr Figure 5: Distribution of iBF candidates for different number of hash functions k. (d=16, m=256). benefits in terms of performance. If the system design choice is based on selection criteria optimized for the non-presence of specific false positives (i.e. element- avoidance § 4.1), increasing the number of choices d allows complying to a larger set of false positive avoid- ance policies. The practical limitation appears to be solely how much space to store the candidate element representations the application designer is willing to pay. 5.2. Deletion We explore two important aspects of the deletable re- gions extension. First, from a qualitative point of view we examine the actual capabilities to successfully delete elements for different m/n ratios, number of regions r and choices d. Second, we evaluate the quantitative gains in terms of false positive reduction after element bits are deleted. Obviously, both aspects are related and intertwined with the ability to choose among candidate 9 m 128 256 512 n 6 12 18 12 24 36 24 48 72 Std. (%) Th. f pr 0.16 0.04 0.75 1.12 4.39 3.33 0.09 0.04 0.95 0.74 3.31 3.63 0.08 0.04 0.83 0.74 3.29 3.46 fpa-opt. (%) kdst kcte 0.19 0.14 0.88 0.86 3.10 2.80 0.08 0.08 0.71 0.74 2.69 2.75 0.04 0.07 0.64 0.64 2.87 3.05 fpr-opt. (%) kcte kdst 0.05 0.04 0.37 0.32 2.37 2.18 0.03 0.01 0.30 0.26 2.07 2.15 0.01 0.01 0.25 0.22 2.09 2.21 iBF representations to favor the deletion capabilities. Now, the application can choose the iBF candidate with the most number of bits set in collision free-zones, in- creasing thus the bit deletability. Alternatively, one may want to favor the element deletability, recalling that re- moving a single element bit is traduced into a practical deletion of the element. Using our basic coding scheme (§ 4.2), we consume one bit per region to code whether collision happened and deletion is prohibited or not. Thus, the bits available for iBF construction are reduced to m′ = m−log2(d)−r. 5.2.1. Quality We now evaluate how many of the inserted elements can be safely removed in practice. Fig. 6(a) plots the percentage of elements that can be deleted. As ex- pected, partitioning the iBF into more regions results in a larger fraction of elements (bits) becoming deletable. For instance, in the example of a 256-bit iBF with 32 regions (Fig. 6), when 24 elements are inserted, we are able to delete an average of more than 80% of the elements by safely removing around 50% of the bits (Fig. 6(b)). Playing with the candidate choices, we can enhance the bit (Fig. 7(a)) and element (Fig. 7(b)) deletability considerably. Finally, we were able to vali- date experimentally the mathematical model of the ele- ment deletability probability (Eq. 7). 5.2.2. Quantity Next, we explore the f pr gains due to bit deletability. On one hand, we have the potential gains of removing bits from collision-free zones. On the other, the cost of (1) coding the deletable regions (r bits), and (2) having more filled iBFs due to the rarefication of colliding bits. While Fig. 8(a) shows the price of having to code more Theor. R=16 R = 10 R = 14 R = 24 R = 32 Theor. 2 choices 4 choices 8 choices 16 choices 32 choices ) % ( s t n e m e e l l e b a t l e e d 100 90 80 70 60 50 40 30 20 10 0 12 18 24 30 36 # elements (a) Deletability - elements R = 10 R = 14 R = 18 R = 24 R = 28 R = 32 ) % ( s t i b l e b a t l e e d 100 90 80 70 60 50 40 30 20 10 0 12 18 24 30 36 # elements (b) Deletability - bits (d=16) ) % ( s t n e m e e l l e b a t l e e d 100 90 80 70 60 50 40 30 20 10 0 ) % ( s t i b l e b a t l e e d 100 90 80 70 60 50 40 30 20 10 0 12 18 24 30 36 # elements (a) Deletability - elements no choices 2 choices 4 choices 8 choices 16 choices 32 choices 12 18 24 30 36 # elements (b) Deletability - bits Figure 6: Deletability as function of r (m=256). Figure 7: Deletability as f(d). m=256, r=16. regions, Fig. 8(b) illustrates the potential gains of re- moving evert deletable bits are removed. If we average the f pr before and after elements are deleted, the iBF performance appears equivalent to the f pr of a stan- dard non-deletable m-bit iBF. In comparison, a count- ing BF with 2 bits per cell3 would behave like an iBF of size m/2, which would have its element capacity ac- cordingly constrained. Analyzing the power of choices, Fig. 9 confirms the intuition that choosing the best deletable iBF candi- date causes the colliding bits to "thin out" (greater ρ), yielding a higher f pr before deletion (Fig. 9(a)) and a smaller f pr after elements are removed (Fig. 9(b)). 5.2.3. Discussion There is a tussle between having a smaller fill factor ρ, with more collisions at construction time reducing the 3Using the power of choices, we could have with very high proba- bility a candidate that does not exceed the counter value of 3, avoiding false negatives as long as no new additions are considered. f pa, and the deletability extension that benefits from fewer collisions. Deletability may be a key property for some system designs, for instance, whenever an element in the iBF should be processed only once and then be re- moved, or when space is needed to add new elements on the fly. A more detailed evaluation requires taking the specific application dynamics (e.g., frequency of dele- tions/insertions) into consideration. From a f pr performance perspective, the cost of cod- ing the deletable regions is only a slight increase in the f pr due to r being only a fraction of m. However, this practical bit space reduction seems to hinder, on aver- age, the potential f pr gains due to bit deletions up- front. Nevertheless, the deletable regions extension is a far more attractive approach to enable deletions in the space-constrained iBFs than alternative solutions based on counting BFs. An open question is whether we are able to find a more space-efficient coding scheme for the deletable regions. Finally, the power of choices again proved to be a very handy technique to deal with 10 ) % l ( n o i t e e d e r o f e b r p f ) % ( n o i t l e e d r e t f a r p f 5 4 3 2 1 0 5 4 3 2 1 0 R = 10 R = 14 R = 18 R = 24 R = 28 R = 32 12 18 24 30 36 # elements (a) fpr - before deletion R = 10 R = 14 R = 18 R = 24 R = 28 R = 32 12 18 24 30 36 # elements (b) fpr - after deletion ) % l ( n o i t e e d e r o f e b r p f ) % ( n o i t l e e d r e t f a r p f 5 4 3 2 1 0 5 4 3 2 1 0 no choices 2 choices 4 choices 8 choices 16 choices 32 choices 12 18 24 30 36 # elements (a) fpr - before deletion no choices 2 choices 4 choices 8 choices 16 choices 32 choices 12 18 24 30 36 # elements (b) fpr - after deletion Figure 8: False positives in function of r (m=256, d=16). Figure 9: False positives as f(d). (m=256, r=16). the probabilistic nature of hash-based data structures, enabling candidate selection for different criteria (e.g., f pr, element/bit deletability). 5.3. Security Besides fast computation, the main requirements for the security extension are that (i) the random distribu- tion of the iBF bits is conserved, and (ii) given a collec- tion of packets I and the securely constructed iBFs, one cannot easily reveal information about the inserted ele- ments (K). More generally, given a set of (I, iBF) pairs, it must be at best very expensive to retrieve information about the identities of K. We first measured the randomness of the secure iBF construction outputs from Algorithm 1 by fixing a set of 20 elements and changing the per-packet 256-bit ran- domly generated I value on each experiment run. Ta- ble 2 gathers the average results of 100 experiments with 1000 runs per experiment. The observed distri- bution of outputs within an experiment, measured as 11 the Hamming distance between output bit vectors (BV), was very close to the mean value of m/2 bits (128) with a small standard deviation.4 The observed average num- ber of bits set and their distribution were comparable to standard iBF constructs. Additionally, we analyzed whether the 20 most frequent bit positions set in secure iBFs corresponded to bits set in plain iBFs. We defined the correlation factor as the fraction of matches and ob- tained a value of 0, 371, which is close to the probability of randomly guessing bits in a 256-bit iBF with k = 4 and n = 20 elements (Pr ≈ 96/256 ≈ 0, 37). The results indicate that, assuming a random packet identifier I, first, no actual patterns can be inferred from the securely inserted elements, and second, the random bit distribution of an iBF is conserved when using the 4In future work we will hashing techniques domness (http://www.stat.fsu.edu/pub/diehard). such as tests extend these evaluation of Sec. 5.4 with other and the ran- those included in the Diehard suite results proposed algorithm. However, we recognize the limi- tations of Alg. 1. For instance, if provable protection against more elaborated attacks is required, then, a more secure and computationally expensive bit mixing proce- dure (Step 1 in Alg. 1) should be considered, in addition to a time-based shared secret as suggested in § 4.3. Sec. iBF Hamming dist. 127.94 (8.06) # bits set 96.27 (3.20) Correlation 0.371 Plain iBF Random BV 127.95 (8.03) 127.97 (7,97) 96.29 (-) 0 - Table 2: Evaluation of the secure iBF algorithm (m=256, k=4, n=20). Avg. (Stdev) after 1000 runs. 5.4. Hashing technique Finally, we briefly investigate the impacts of the hash function implementation choice and the nature of the input elements in small size iBFs. There are two fac- tors that determine the "quality" of the bit distribution and consequently may impact the observed f pr: 1) the input bit string, and 2) the implementation of the hash function. 5.4.1. Input data sets Instead of considering elements as simple random bit strings, we now explore three types of elements that cover typical inputs of iBF applications: • 32-bit IP addresses: Nearly 9M IP addresses were generated by expanding the subnet values of IP prefixes advertised in the CAIDA database.5 In addition, private IP addresses (10.0.0.0/16, 192.168.0.0/16) were also used in the experiments. • 256-bit random labels: A set of 3M random la- bels was generated constructing each 256-bit label by picking randomly 64 hex characters and check- ing for uniqueness. • Variable-bit dictionary words: A set formed by 98.568 entries of the American dictionary.6 5.4.2. Hash function choice We chose 3 commonly used cryptographic hash func- tions (MD5, SHA1 and SHA256) and 2 general purpose hash functions (CRC32 and BOB).7 The observed f pr (Table 3) imply that, on average, the input type does not affect the iBF performance. Fig- ure 10 plots the observed normalized sample variance for different bit vector sizes (m). For lower m values the variances show a larger difference and start converging for m > 512. CRC presents the best output distribution when dealing with IP addresses as inputs. This may be explained by the 32-bit match of inputs and outputs. In general, the functions exhibit similar behavior, leading to the conclusion that all 5 hash functions can be used in iBF scenarios independently from the nature of the ele- ments. This result experimentally confirms, also in the case small m values, the observation by Mitzenmacher and Vadhal [21] that given a certain degree of random- ness in the input, simple hash functions work well in practice. n DoubleHash IP Random Dict. 16 32 SHA1&MD5 0.340 (0.035) 0.338 (0.032) 0.328 (0.034) CRC32 segm. 0.345 (0.037) 0.349 (0.034) 0.338 (0.034) SHA1&MD5 2.568 (0.436) 2.576 (0.449) 2.519 (0.385) CRC32 segm. 2.541 (0.418) 2.532 (0.403) 2.570 (0.444) Table 3: Observed f pr in 256-bit iBF using double hashing with SHA1 & MD5 and with 8-bit segments of CRC32. Avg. (StdDev); 1000 tests. 5.4.3. Hash segmentation technique We note that for the purposes of iBF construction, there is a waste of hash output bits due to the mod m residual restrictions. Hence, we want to know whether we can divide the output of a hash function into log2(m) segments and use each segment as an independent hash value. We compare the bit distribution and f pr per- formance of iBFs constructed using the double hashing technique with MD5 and SHA1 against iBFs generated with CRC32 segments as hi(x). The differences of the observed f pr (Table 3) are negligible, which suggests that we may indeed use this hashing technique in prac- tice. As a practical consequence, we can reduce the two independent hash function requirement of the double hashing technique to a single hash computation based on e.g., CRC32 or BOB. This result can be applied to iBF networking applications with on-line element hash- ing instead of pre-computed element names. Moreover, the hash segmentation technique may be useful in other multiple-hashing-based data structures (e.g., d-left hash tables) that require hashing on a packet basis. 5ftp.ripe.net/ripe/stats/delegated-ripencc-20090308 6/usr/share/dict/american-english 7Related work has investigated the properties of 25 popular hash functions, pointing to BOB as a fast alternative that yields excellent randomized outputs for network applications [20]. Although MD5 and SHA1 are considered broken due to the recent discovery of colli- sions, they are perfectly valid for our randomness purposes. 12 e c n a i r a V 70000 60000 50000 40000 30000 20000 10000 0 e c n a i r a V 160000 140000 120000 100000 80000 60000 40000 20000 0 MD5 SHA1 SHA256 CRC BOB 64 128 256 512 1024 2048 Bits - Bloom Filter (a) Random labels - 3M # MD5 SHA1 SHA256 CRC BOB 64 128 256 512 1024 2048 Bits - Bloom Filter (b) IP - 8,957,184 # Figure 10: Normalized bit distribution variance for different hash functions. 6. Relevance and related work Although multiple variants of Bloom filter designs and applications have been proposed in the last years (e.g., Bloomier, dynamic, spectral, adaptive, retouched, etc.), to the best of our knowledge, none of the previ- ous work focuses on the particular requirements of dis- tributed networking applications using small Bloom fil- ters in packet headers. Prior work on improved Bloom filters include the Power of Two Choices filter [14] and the Partitioned Hashing [22], which rely on the power of choices at hashing time to improve the performance of BFs. False positives are reduced in [22] by a careful choice of the group of hash functions that are well-matched to the in- put elements. However, this scheme is not practical in distributed, highly dynamic environments. The main idea of [14] is to reduce the number 1s by choosing the "best" set of hash functions. Besides our in-packet- header scope, our approach differs in that we include the 13 information of which group of hash functions was used (d value) in the packet itself, avoiding thereby the caveat of checking multiple sets. On the other hand, we need to stick to one set of hash functions for all elements in the BF, whereas in [14] the optimal group of hash functions can be chosen on an element basis. To our benefit, due to the reduced bit vector scenario, we are able to select an optimal BF after evaluating all d candidates, which leads to improved performance even in very dense BF settings (small m/n ratios). Regarding the notion of choosing the best candidate filter, the Best-of-N method [15] only considers a stan- dalone application where the best BF selection is based on the least dense filter constructed with the optimal number kopt of hash functions is. Our distributed iBF applications consider candidates with different amount of bits set (kdistr) as the maximum set cardinality may be unknown and hashing at packet processing time may not be an option. Moreover, we note that distributed iBF applications may (1) be able to test for presence of elements to be queried upfront and selected the best ob- served f pr candidate, and (2) selection criteria may be beyond reducing f pr, for instance benefiting the dele- tion of elements or avoiding specific false positives. As far as we can say, our scheme for deleting items from a BF based on coding the regions where collisions have happened has not been proposed before. Due to its space efficiency, the false-negative-free characteris- tics, and the high probability of successful deletions, the Deletable Regions extension may have interesting appli- cations beyond the scope of iBFs. The closest BF design innovation to support deletions, other than by counting BFs or d-left fingerprint hash tables, are the Variable- length Signatures (VBF) by Lu et al [23]. While both element deletions are based on resetting at least one bit from an element signature, our scheme introduces no false negatives at the cost of providing only probabilis- tic guarantees for element deletion. Security and privacy preserving extensions for BFs have been previously studied in [18, 24] and our main novelty resides in taking distributed systems and data packets specifics into consideration (e.g., flow- identifier, time-based loose synchronization of dis- tributed secrets). Recently, our work on iBFs has contributed to enable a novel packet forwarding scheme with built-in DDoS protection [19]. The notion of element Tags has its roots in our work on the link identifier based forwarding fab- ric in [8], rendering the system more useful (network policy compliance, loop avoidance, security) and effi- cient ( f pr control, larger multicast groups).Similarly, the d-eTag extensions may be applied to the case of IP multicast [7] to reduce false positives and compliance to inter-domain AS policies in the case of false posi- tives. When applied to the credentials based architecture proposed in [5], multiple candidates may allow iBFs to transverse larger paths before reaching the maximum density. Moreover, the security extension may pro- vide extra protection from an en-route attacker spoof- ing the source IP address and re-using the flow creden- tials for unauthorized traffic. Finally, the hash segmen- tation technique appears useful to lower the burden on networking elements when computing multiple hashes on a packet basis. 7. Conclusions This paper explores an exciting front in the Bloom fil- ter research space, namely the special category of small Bloom filters carried in packet headers. Using iBFs is a promising approach for networking application design- ers choosing to move application state to the packets themselves. At the expense of some false positives, fixed-size iBFs are amenable to hardware and present a way for new networking applications. We studied the design space of iBFs in depth and evaluated new ways to enrich iBF-based networking ap- plications without sacrificing the Bloom filter simplic- ity. First, the power of choices extension shows to be a very powerful and handy technique to deal with the probabilistic nature of hash-based data structures, pro- viding finer control over false positives and enabling compliance to system policies and design optimization goals. Second, the space-efficient element deletion tech- nique provides an important (probabilistic) capability without the overhead of existing solutions like count- ing Bloom filters and avoiding the limitations of false- negative-prone BF extensions. Third, security exten- sions were considered to couple iBFs to time and packet contents, providing a method to secure iBFs against tampering and replay attacks. Finally, we have validated the extensions in a rich simulation set-up, including use- ful recommendations for efficient hashing implementa- tions. We hope that this paper motivates the design of more iBF extensions and new networking applications. Acknowledgments We want to thank the reviewers of earlier versions of this paper. Specially, we appreciate the fruitful discus- sions with Mats Naslund, Pekka Nikander and Andras Zahemszky. The work presented in this paper is sup- ported by Ericsson Research, CNPq and FAPESP. 14 References [1] A. Broder, M. Mitzenmacher, Network applications of Bloom filters: A survey, Internet Mathematics. [2] B. H. Bloom, Space/time trade-offs in hash coding with allow- able errors, Commun. ACM 13 (7) (1970) 422 -- 426. [3] H. Cai, P. Ge, J. Wang, Applications of Bloom filters in peer-to- peer systems: Issues and questions, in: NAS '08: Proceedings of the 2008 International Conference on Networking, Architecture, and Storage, Washington, DC, USA, 2008, pp. 97 -- 103. [4] D. Guo, Y. He, P. Yang, Receiver-oriented design of bloom fil- ters for data-centric routing, Computer Networks. [5] T. Wolf, Data path credentials high-performance capabilities-based networks, in: ANCS '08: Proceedings of the 4th ACM/IEEE Symposium on Architectures for Net- working and Communications Systems, ACM, New York, NY, USA, 2008, pp. 129 -- 130. for [6] F. Ye, H. Luo, S. Lu, L. Zhang, S. Member, Statistical en-route filtering of injected false data in sensor networks, in: INFO- COM, 2004, pp. 839 -- 850. [7] S. Ratnasamy, A. Ermolinskiy, S. Shenker, Revisiting IP multi- cast, in: Proceedings of ACM SIGCOMM'06, Pisa, Italy, 2006. [8] P. Jokela, A. Zahemszky, C. Esteve, S. Arianfar, P. Nikander, LIPSIN: Line speed publish/subscribe inter-networking, in: Pro- ceedings of ACM SIGCOMM'09, Barcelona, Spain, 2009. [9] R. P. Laufer, P. B. Velloso, D. d. O. Cunha, I. M. Moraes, M. D. D. Bicudo, M. D. D. Moreira, O. C. M. B. Duarte, To- wards stateless single-packet IP traceback, in: LCN '07: Pro- ceedings of the 32nd IEEE Conference on Local Computer Net- works, IEEE Computer Society, Washington, DC, USA, 2007, pp. 548 -- 555. [10] A. Whitaker, D. Wetherall, Forwarding without loops in icarus, in: In Proc. of OPENARCH 2002, 2002. [11] T. Aura, P. Nikander, Stateless connections, in: ICICS '97, Springer-Verlag, London, UK, 1997, pp. 87 -- 97. [12] C. Esteve Rothenberg, F. Verdi, M. Magalhaes, Towards a new generation of information-oriented internetworking archi- tectures, in: First Workshop on Re-Architecting the Internet, Madrid, Spain, 2008. [13] P. Bose, H. Guo, E. Kranakis, A. Maheshwari, P. Morin, J. Mor- rison, M. Smid, Y. Tang, On the false-positive rate of Bloom filters, Inf. Process. Lett. 108 (4) (2008) 210 -- 213. [14] S. Lumetta, M. Mitzenmacher, Using the power of two choices to improve Bloom filters, Internet Mathematics 4 (1) (2007) 17 -- 33. [15] M. Jimeno, K. Christensen, A. Roginsk, A power management proxy with a new best-of-n bloom filter design to reduce false positives, in: 21st IEEE International Performance, Computing, and Communications Conference, 2002, pp. 125 -- 133. [16] A. Kirsch, M. Mitzenmacher, Less hashing, same performance: building a better Bloom filter, in: ESA'06., Springer-Verlag, London, UK, 2006, pp. 456 -- 467. [17] F. Bonomi, M. Mitzenmacher, R. Panigrahy, S. Singh, G. Vargh- ese, An improved construction for counting Bloom filters, in: ESA'06: Proceedings of the 14th conference on Annual Eu- ropean Symposium, Springer-Verlag, London, UK, 2006, pp. 684 -- 695. [18] E. Goh, Secure indexes, cryptology eprint archive, in: Report 2003/216, 2003. [19] C. E. Rothenberg, P. Jokela, P. Nikander, M. Sarela, J. Yli- talo, Self-routing denial-of-service resistant capabilities using in-packet bloom filters, in: the 5th European Conference on Computer Network Defense (EC2ND), 2009. [20] C. Henke, C. Schmoll, T. Zseby, Empirical evaluation SIG- for multipoint measurements, of hash functions Appendix B. Mathematical model for d-candidate fpa optimization (adapted from [15]) Given the iBF parameters m, n, k, and letting d be the number of different iBF candidates for the same element set, the probability of setting s bits in an iBF candidate can be formulated as an independent random variable experiment: 1 1 E2 [s] = m 1 − 1 − m !kn +m2 m − 1 σ2 [s] = m m − 1 Defining µ = E[s] and σ = σ[s], the minimum con- m!kn +m (m − 1) m !kn +m2 m − 2 1 − 2 1 − m !kn +m m − 2 m!kn + 1 − m !2kn m!kn 2 (B.2) (B.1) tinuous probability density function is: fmin (s) = 1 2d−1! d er f c s − µ 2σ2 ! (B.3) e −(s−µ) Consequently, the expectation of the least number σ √2!!d−1 σ √2π 1 bits (smin) set by any of d candidates: E (S min) = Z ∞ −∞ s fmin (s) ds (B.4) Finally, the probability of a false positive once the smallest fill ratio has been estimated: pr(cid:2) f alsepositive(cid:3) = E [smin] m k! (B.5) COMM Comput. Commun. Rev. 38 (3) doi:http://doi.acm.org/10.1145/1384609.1384614. (2008) 39 -- 50. [21] M. Mitzenmacher, S. Vadhan, Why simple hash functions work: exploiting the entropy in a data stream, in: SODA '08: Pro- ceedings of the nineteenth annual ACM-SIAM symposium on Discrete algorithms, Society for Industrial and Applied Mathe- matics, Philadelphia, PA, USA, 2008, pp. 746 -- 755. [22] F. Hao, M. Kodialam, T. V. Lakshman, Building high accu- racy bloom filters using partitioned hashing, in: SIGMET- RICS '07, ACM, New York, NY, USA, 2007, pp. 277 -- 288. doi:http://doi.acm.org/10.1145/1254882.1254916. [23] Y. Lu, B. Prabhakar, F. Bonomi, Bloom filters: Design inno- vations and novel applications, in: In Proc. of the Forty-Third Annual Allerton Conference, 2005. [24] R. Nojima, Y. Kadobayashi, Cryptographically secure bloom- filters, in: Transactions on Data Privacy 2, 2009, pp. 131 -- 139. Appendix A. Mathematical Model Deletability Probability for Element Consider a vector of size m, k hash functions and r regions. The bit vector size to construct the actual BF is m′ = m − r and the number of bit cells in each region is equal to ⌈m′/r⌉. The probability of two hash functions setting a given bit cell: p1 = 1 m′! 1 m′! = 1 m′2! (A.1) If we use one hash function per element (i.e. one bit) and insert n elements, the probability of having at least one collision in a given cell is: p2 = n 2! 1 m′2! + n 3! 1 m′3! + ·· · + n n! 1 m′n! = n Xi=2 n i! 1 m′i! (A.2) Considering that each element insertion sets k bits to 1, we compute the probability to: p3 = n 2! b1 m′2! + n 2! b2 m′2! + ·· · + n 2! bk m′2! = n Xi=2 n i! k m′i! (A.3) Equation A.3 considers a collision in a given bit cell. Now, we extend the probability to the m′/r bit cells in a single region: p4 = (1 − p3) m′r =  1 − n Xi=2 n m′i! i! k Replacing m′ with m − r, the probability of an element being deletable, that is of having at least one bit set in a collision-free region is: m′r (A.4) 1 − n Xi=2 n i! pdr =  r ) ( m−r k m − r2! (A.5) Finally, neglecting the contributions of the terms for i > 2 as they tend to zero, we get: pdr ≈ 1 − n 2! ( m−r r ) k m − r2!! (A.6) 15
1806.08283
1
1806
2018-06-21T15:02:58
Cycles to the Rescue! Novel Constraints to Compute Maximum Planar Subgraphs Fast
[ "cs.DS" ]
The NP-hard Maximum Planar Subgraph problem asks for a planar subgraph $H$ of a given graph $G$ such that $H$ has maximum edge cardinality. For more than two decades, the only known non-trivial exact algorithm was based on integer linear programming and Kuratowski's famous planarity criterion. We build upon this approach and present new constraint classes, together with a lifting of the polyhedron, to obtain provably stronger LP-relaxations, and in turn faster algorithms in practice. The new constraints take Euler's polyhedron formula as a starting point and combine it with considering cycles in $G$. This paper discusses both the theoretical as well as the practical sides of this strengthening.
cs.DS
cs
Cycles to the Rescue! Novel Constraints to Compute Maximum Planar Subgraphs Fast Markus Chimani Theoretical Computer Science, Osnabrück University, Germany [email protected] 0000-0002-4681-5550 Tilo Wiedera Theoretical Computer Science, Osnabrück University, Germany [email protected] 0000-0002-5923-4114 Abstract The NP-hard Maximum Planar Subgraph problem asks for a planar subgraph H of a given graph G such that H has maximum edge cardinality. For more than two decades, the only known non-trivial exact algorithm was based on integer linear programming and Kuratowski's famous planarity criterion. We build upon this approach and present new constraint classes- together with a lifting of the polyhedron-to obtain provably stronger LP-relaxations, and in turn faster algorithms in practice. The new constraints take Euler's polyhedron formula as a starting point and combine it with considering cycles in G. This paper discusses both the theoretical as well as the practical sides of this strengthening. 2012 ACM Subject Classification Mathematics of computing → Combinatorial optimization, Mathematics of computing → Graph theory, Theory of computation → Linear programming Keywords and phrases algorithm engineering, graph algorithms, integer linear programming, maximum planar subgraph Digital Object Identifier 10.4230/LIPIcs.ESA.2018.19 Funding Supported by the German Research Foundation (DFG) project CH 897/2-1. 1 Introduction The NP-hard Maximum Planar Subgraph (MPS) problem is an established question in graph theory, already discussed in the classical textbook by Garey and Johnson [14,20]. Given a graph G, we ask for a largest subset F ⊆ E(G) of edges such that F induces a planar graph. By contrast, the closely related maximal planar subgraph problem asks for a set of edges that we cannot extend without violating planarity and is trivially solvable in polynomial time. The inverse measure of MPS that counts the minimum number of edges that must be removed to obtain a planar subgraph, is called the skewness of G and denoted by skew(G). There are several reasons why this problem has received a good deal of attention: Graph theoretically, skewness is a very natural and common measure of non-planarity (like crossing number or genus). Algorithmically, finding a large planar subgraph is central to the planarization method [1,5] that is heavily used in graph drawing: one starts with a large (favorably maximum) planar subgraph and re-inserts the deleted edges, typically to obtain a low number of overall crossings. In fact, this gives an approximation of the crossing number with ratio roughly O(cid:0)∆ · skew(G)(cid:1) [9], where ∆ is the maximum node degree. Furthermore, several graph problems become easier when the input's skewness is small or constant. E.g., © Markus Chimani and Tilo Wiedera; licensed under Creative Commons License CC-BY 26th Annual European Symposium on Algorithms (ESA 2018). Editors: Yossi Azar, Hannah Bast, and Grzegorz Herman; Article No. 19; pp. 19:1–19:14 Leibniz International Proceedings in Informatics Schloss Dagstuhl – Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany 19:2 Cycles to the Rescue! Novel Constraints to Compute MPS Fast we can compute a maximum flow in time O(cid:0)skew(G)3 · V (G) log V (G)(cid:1) [16]1-the same runtime complexity as on planar graphs if the skewness is constant. There are several practical heuristic approaches to tackle the problem [10]. However, MPS is MaxSNP-hard, i.e., there is an upper bound < 1 on the obtainable approximation ratio unless P = NP [2], and there are further limits known for specific algorithmic approaches [3,7]. Already a spanning tree gives an approximation ratio of 1/3, the best known ratio is 4/9 [2], and only recently a practical 13/33-approximation algorithm emerged [3]. Considering exact algorithms, options are scarce. Over two decades ago, an integer linear program based on Kuratowski's characterization of planarity was introduced in [23], which remained the only non-trivial exact algorithm. Only very recently, [8] showed the existence of potentially feasible alternatives to the Kuratowski-based approach, but the former still constitutes the practically by far most efficient (and theoretically most thoroughly explored) model. All known ILP models (including those discussed in this paper) can also directly solve the weighted MPS, i.e., identify the heaviest planar subgraph w.r.t. given edge weights. Contribution. In this paper, we strengthen the Kuratowski model by introducing new constraints and supplementary variables, based on analyzing the cycles occurring in the solutions; see Section 3. In particular, we show in Section 3.2 that starting with the original Kuratowski model and considering cycles of growing lengths yields a natural hierarchy of ever stronger LP-relaxations. In Section 3.3, we establish additional constraint classes using our cycle variables to further strengthen the LP-relaxations, both theoretically and practically. We show the latter property in an experimental evaluation in Section 4. We defer the proofs of some lemmata to the appendix, in which case we mark the lemma with '?'. Preliminaries 2 Graph Notation. Our non-planar input graph is called G. Generally, we consider an undirected graph H, with nodes V (H) and edges E(H), which are cardinality-2 subsets of V (H). We use δH(v) to denote all edges incident to node v in H and define the node degree degH(v) := δH(v). If H is a subgraph of G, we write H ⊆ G. A (sub)graph is a cycle if it is connected and all its nodes have degree 2. The girth γ(H) of H is the length of its smallest cycle. The union of two (non-disjoint) graphs H1, H2 is denoted by H1tH2 := (V (H1)∪V (H2), E(H1)∪E(H2)). For W ⊆ V (H) and F ⊆ E(H) we define node- respectively. We further use H − e := H[E(H) \ {e}]. Given a planar drawing D of some planar graph H, the cyclic adjacency order around each node in D defines an embedding π of H. The disjoint regions bounded by edges in D correspond to the faces of π; the infinite region, bounded only on the inside, is called outer face. The degree deg(f) of any face f is the number of half-edges ("sides" of edges) that occur on the boundary of f; a bridge occurs twice on the same face. and edge-induced subgraphs H[W] := (W,{e ∈ E(H) e ⊆ W}) and H[F] :=(cid:0)S e∈F e, F(cid:1), Linear Programming. A Linear Program (LP) is a vector c ∈ Rd and a set of linear inequalities (constraints) that define a polyhedron P in Rd; we ask for an element x ∈ P (cid:124) that maximizes c x. An Integer Linear Program (ILP) additionally requires the components of x to be integral. For a given problem, one can establish different ILPs, so-called models. To solve an ILP model, one uses branch-and-bound, where dual bounds are obtained from 1 [16] considers the crossing number; the algorithm trivially works also for the stronger parameter skewness. M. Chimani and T. Wiedera 19:3 (fractional) solutions to the LP-relaxation, i.e., the ILP without the integrality requirements. Clearly, strong such LP-bounds are desired. We say a model N is at least as strong as a model M, if N's LP-relaxation gives no worse bounds than M's. We say N is stronger than M if, additionally, there is an instance where N gives a strictly better bound. If, in this case, N arises from M by adding some constraints C, we say C strengthen M. It is often beneficial to consider only a relevant subset of constraints in the solving process, in particular when the class of constraints is (exponentially) large. The procedure is referred to as separation. We employ it on (fractional) LP-solutions for selected constraint classes. Kuratowski Model (ε-Model). The following ILP is due to Mutzel [23]. Jünger and Mutzel showed that both constraint classes below form facets of the planar subgraph polytope [17]. We use solution variables se ∈ {0, 1} (for all e ∈ E(G)) that are 1 if and only if edge e is deleted, i.e., not in the planar subgraph. (In [23], equivalent variables xe := 1 − se are used.) The objective minimizes the skewness-thus maximizes the planar subgraph-and is given by minX MPS problem. For a given subset F ⊆ E(G) of edges, we define s(F) := P s(cid:0)E(G)(cid:1) ≥ E(G) − (3n − 6) + 1G is bipartite(n − 2). Thereby, we may consider edge weights w; they are 1 in case of the traditional unweighted e∈F se as a shorthand. We can always use Euler's bound on the number of edges in planar graphs: w(e) se. e∈E(G) (1) By Kuratowski's theorem [19], a graph is planar if and only if it neither contains a subdivision of a K5 nor of a K3,3. Hence, it suffices to ask for any member of the (exponentially large) set K(G) of all Kuratowski subdivisions that at least one of its edges is deleted: ∀K ∈ K(G). (2) s(cid:0)E(K)(cid:1) ≥ 1 Clearly, (2) are too many constraints to use all explicitly. Instead, we identify a sufficient subset of constraints via a (heuristic) separation procedure: we round the fractional solution and obtain a graph that can be tested for planarity. If it is non-planar, we extract a Kuratowski subdivision. This method does neither guarantee to always find a violated constraint if there is any, nor that the identified subdivision in fact corresponds to a violated Kuratowski constraint. Still, since it has these guarantees on integral solutions, it suffices to obtain an exact algorithm. Over the years, the performance of this approach was improved by strong preprocessing [4], finding multiple Kuratowski subdivision in linear time [11], and strong primal heuristics [10]. We use all these identically in all considered algorithms. The Kuratowski-model forms the basis of our extensions. As such, we denote it, without any of the below extensions, by 'ε-model'. 3 Stronger Constraints Based on Cycles We now present new constraints for the planar subgraph polytope (or a lifted version thereof). All but the first class require the introduction of new variables based on cycles, leading to the cycle model. For each constraint class we first give some motivation and intuition for its feasibility, before discussing its technical details. We then describe-provided the class is large-separation routines that quickly identify violated constraints, and usually show that it strengthens our ILP model. ESA 2018 19:4 Cycles to the Rescue! Novel Constraints to Compute MPS Fast Generalized Euler Constraints. We know from [17] that inequality E(G) ≤ 2V (G) − 4 is facet-defining for complete biconnected graphs. We are interested in a class of similar constraints for dense subgraphs with large girth. The following lemma is folklore: (cid:73) Lemma 1. A planar graph G has at most(cid:0)V (G) − 2(cid:1)γ(G)/(cid:0)γ(G) − 2(cid:1) edges. Proof. Let n := V (G), m := E(G), and π denote an embedding of G. For any face of π we require at least γ(G) half-edges. Thus, the number f of faces in π is bounded by f ≤ 2m/γ(G). Using Euler's formula, we obtain n− m + (2m/γ(G)) ≤ 2, the claimed results (cid:74) follows when solving for m. We can thus derive a feasible generalized Euler constraint for any subgraph H ⊆ G: E(H) − s(cid:0)E(H)(cid:1) ≤(cid:0)V (H) − 2(cid:1)γ(H)/(cid:0)γ(H) − 2(cid:1) 2(cid:0)mod (γ(H) − 2)/2(cid:1) otherwise [13]. However, we did not implement this in our algorithms. We note that this bound can sometimes be improved: for constraints (3) to be satisfied with equality it is necessary that V (H) ≡ 2 (mod γ(H) − 2) if γ(H) is odd and V (H) ≡ ∀H ⊆ G (3) (cid:73) Lemma 2. ? The generalized Euler constraints (3) strengthen the ε-model. Proof sketch. K3,3,1 contains a K3,4 that prohibits the otherwise feasible solution 3/2. (cid:74) We separate constraints (3) heuristically by seeking dense, high-girth subgraphs using two different methods. First, using the current fractional solution, we assign weight 1 − se to each edge e and approximate a maximum cut [22, Section 6.3], obtaining a girth-4 subgraph. If (after postprocessing, see below) this does not yield a violated constraint, we try a second method: We set a target girth µ and iteratively add edges in ascending order of their LP-value to an initially empty graph, while updating the shortest paths between all node pairs. Upon adding an edge e, we check whether e would create a cycle of length < µ, in which case we discard e instead. We may repeat this process for different values of µ. After each of the above attempts, we apply a postprocessing: Let H denote a girth-µ subgraph. The contribution e∈δH(v) se − µ/(µ − 2). We iteratively remove nodes with negative contribution from H. In particular, this will remove all degree-1 nodes. of a node v ∈ V (H) is defined by δH(v) −P 3.1 Cycle Model We now want to bound the number of edges in the planar subgraph by the number of its small faces. Even though compelling from a theoretical standpoint, it is infeasible to generate all potential faces of all planar subgraphs of a given graph (already for bounded length). However, we know that traversing the border of any face of a spanning subgraph H traverses at least one cycle if H is not a tree. We will relate the number of small faces in any planar subgraph of a graph G to the number of small cycles in G. One may also view this as a way to further generalize Euler constraints: many-in particular sparse-graphs have low girth only due to very few cycles of small length. We may assume any (maximal) primal solution to be connected and non-outerplanar as it could be trivially improved otherwise. Also observe that we cannot require faces to uniquely map to cycles in general. Consider for example a cycle graph (two faces with the same cycle) or a non-biconnected graph (each cut-node occurs twice in at least one face; cycles contain nodes at most once) Note that there are biconnected graphs that have no biconnected MPS. (cid:73) Lemma 3. For every connected, planar but non-outerplanar subgraph H of G, there exists an embedding of H such that we can assign a unique cycle α to every face f where all edges of α occur on the boundary of f. M. Chimani and T. Wiedera 19:5 Proof. Let H ⊂ G be as defined in the claim. There exists some biconnected component B? of H that is neither a cycle nor an edge since H is not outerplanar. Choose an embedding of H and pick some face of B? as the outer one. For every biconnected component B that is not just an edge, we iterate over the inner faces of B. Each inner face f of B directly corresponds to a cycle as a biconnected graph contains neither cut-nodes nor bridges. (Observe that an inner face of B might in fact be much larger in H since we ignore other components nested in this face.) Ultimately, we assign the cycle induced by the outer face in H to the (last (cid:74) remaining) outer face. Since B? is not a cycle we do not assign any cycle twice. We denote the number of faces whose degree satisfies some property P by fP. (cid:73) Lemma 4. Given a connected, planar graph H on n nodes and m edges, for each embedding of H with exactly f=d faces of degree d ∈ {3, 4 . . . , 2m}, we have (d − 3)f=d. (4) m = 3n − 6 −X2m d=3 Proof. Every face in any embedding of H has degree at least 3 and at most 2m. For every face f of degree d we can add d − 3 edges that split f into d − 2 triangles without violating planarity. After performing this operation for each face we obtain a planar triangulated graph, i.e., a graph that has exactly 3n − 6 edges. (cid:74) Let Cd(G) denote all cycles of length d in G. We set D ≥ 3 to the maximum cycle length that we want to investigate; this parameter will control the number of additionally generated variables. Let C≤D(G) denote the set of cycles with length at most D. For every cycle α ∈ C≤D(G) we generate a variable cα ∈ {0, 1}.2 We force such a variable to 0 if any edge of the respective cycle is removed and allow at most two cycles per edge in the MPS: X faces (subject to Lemma 3). We discuss its correctness below. Let c(d) :=P Note that constraints (5) resemble the requirement for each edge to appear in at most two cα ≤ 2 (1 − se) α∈C≤D(G): e∈E(α) ∀e ∈ E(G) (5) α∈Cd(G) cα. (cid:73) Lemma 5. For every connected, planar but non-outerplanar subgraph H of G, there exists an embedding π of H and a feasible assignment w.r.t. (5) of cycle variables such that for each d ≤ D the number f=d of faces with degree d in π is bounded from above by f≤d ≤Xd c(k), or equivalently f=d ≤Xd k=3 c(k) − f<d. k=3 Proof. We assign cycle variables following the proof of Lemma 3. Hence, there is a unique cycle variable assigned to each face such that the length of the cycle is at most the degree of its face. The variable assignment is feasible since we pick only edges contained in H and (cid:74) pick at most two cycles incident with any such edge. (cid:73) Theorem 6. For any maximum planar subgraph of a graph G on n nodes and m edges there exists a feasible variable assignment that satisfies (5) and the cycle constraint (D − 1)(cid:0)m − s(E(G))(cid:1) ≤ (D + 1)(n − 2) +XD (D + 1 − d)c(d). (6) d=3 2 Intuitively, we want cα = 1 if and only if α is (part of) a face, see below for details. In terms of correctness, we need not but can actively force these variables to be binary, cf. Section 4. ESA 2018 19:6 Cycles to the Rescue! Novel Constraints to Compute MPS Fast (d − 3)f=d − (D − 2)f>D. Proof. Starting with (4) on any connected, planar subgraph of G that has m − s(E(G)) edges, we relax the equality by using the same coefficient for all faces of large degree as in m − s(E(G)) ≤ 3n − 6 −XD By replacing f>D in Euler's formula, (f>D + f≤D) + n −(cid:0)m − s(E(G))(cid:1) = 2, we obtain (D − 1)(cid:0)m − s(E(G))(cid:1) ≤ (D + 1)(n − 2) +XD (7) The claimed cycle constraint is finally obtained by applying Lemma 5 to iteratively replace f=D0 for D0 = D, D − 1, . . . , 4, 3 by the upper bound (note that f<3 = 0), as sketched below for the (generalized, iteratively re-appearing) rightmost summand of (7): (D + 1 − d)f=d. d=3 d=3 (D0 + 1 − d)f=d ≤XD0−1 (cid:0)(D0 − 1) + 1 − d(cid:1)f=d +XD0 c(d) (cid:74) XD0 d=3 d=3 d=3 d=3 (d − 2)c(d) ≤ 2n − 4. 3.2 Relaxations and D-Hierarchy We now turn our attention to LP-relaxations of the cycle model. We show that there is a hierarchy of gradually stronger LPs induced by the maximum cycle length D. Let the cycle model CMD consist of the ε-model, the cycle variables for cycle lengths up to D, and the corresponding constraints (5),(6). If D = 2 were allowed, CM2 would be exactly the ε-model. (cid:73) Lemma 7. For any solution to the relaxation of CMD, it holds that d=3 c(d) and hence m−s(E(G)) > n−2+PD d=3(d − 2)c(d) > 2n − 4. It follows that PD d=3 dc(d) > d=3 c(d) by the sum of constraints (5). Plugging this bound on the number of edges into the cycle constraint (6), we obtain (cid:74) XD Proof. Assume the contrary, PD 2n−4+2PD PD d=3(d − 2)c(d) < 2n − 4, a contradiction. It is not immediately clear, that decreasing the maximum cycle length maintains LP- feasibility, as some variables are removed and the cycle constraint is replaced. By employing Lemma 7, we can show the following fact. (cid:73) Lemma 8. ? Model CMD+1 is at least as strong as CMD. (cid:73) Lemma 9. Model CMD+1 is stronger than CMD. Proof. Consider the complete graph Kk on k ≥ 5 nodes. Pick any number µ ≥ D + 1. We subdivide every edge of Kk using ξ := bµ/3c additional nodes. The resulting graph K µ has girth at least µ, i.e., it has no cycles of length ≤ D. We observe that skew(K µ n) = skew(Kk) = k(k − 1)/2 − 3k + 6, independent of µ. We show that increasing the maximum cycle length from D to D + 1 cuts off all previously optimal LP solution. k ) − 2)µ/(µ − 2) edges in any planar subgraph. As there are no cycle variables, the cycle constraint (6) approaches this value from above for increasing D. Any feasible solution that tightly satisfies the cycle constraint is an optimal one. The Kuratowski constraints (2) on the other hand are already satisfied by deleting each edge partially with se = 1/(9ξ) ∀e ∈ E(K µ n), since each subdivision requires at least 9ξ edges, still allowing LP-solutions with value k(k − 1)/18. (cid:74) k has girth µ there can be at most (V (K µ Since K µ k Overall, increasing the maximum cycle length strengthens our LP relaxations (leading to fewer LP-computations), but this comes at the cost of increasing the variable space (leading to slower LP-computations). It is imperative to find a good trade-off between these two. M. Chimani and T. Wiedera 19:7 3.3 Strengthening the Cycle Model We now extend the cycle model further by introducing new constraint classes. Only the first such extension requires yet additional variables. Pseudo-Tree Extension. Observe that degree-1 nodes in the solution deteriorate the cycle constraint's bound: given a face f that contains a degree-1 node, we can set the variable of a cycle with length at most deg(f) − 2 to 1. We introduce new variables tv ∈ {0, 1} for all v ∈ V (G) and tvw ∈ {0, 1} for all v, w ∈ V (G) with {v, w} ∈ E(G). They label nodes and directed edges (arcs) as pseudo-trees: any node with at most one unlabeled neighbor (in particular any degree-1 node) is to be labeled. This can be achieved by: tv + degG(v) −X w∈N(v) X twv −X tvw + twv ≤ 1 − s{v,w} tvw ≥ tv svw ≥ 2 w∈N(v) w∈N(v) ∀{v, w} ∈ E ∀v ∈ V (G) ∀v ∈ V (G) (8) (9) (10) Constraints (8) allow at most one tree-arc for any edge and none for deleted edges. We force tree nodes to propagate along one outgoing arc by constraints (9). Finally, constraints (10) label degree-1-nodes and nodes where all (but one) neighbor is labeled. Now, we may subtract v∈V (G) tv nodes (and the same number of edges) from (6) to obtain a stronger bound: P (cid:73) Corollary 10. The extended cycle constraint, given below, is feasible. (D + 1 − d)c(d) − 2X tv (11) v∈V (G) (D − 1)(cid:0)m − s(E(G))(cid:1) ≤ (D + 1)(n − 2) +XD and constraints (10), assumingP w∈N(v) twv = 0. d=3 Alternatively, we may use a less sophisticated approach that does not model propagation but labels only degree-1-nodes. In this case, it suffices to add variables tv ∈ {0, 1}, ∀v ∈ V (G), (cid:73) Lemma 11. ? The pseudo-tree extension, i.e., constraints (8)–(11) together with the t-variables, strengthens CM3. This already holds for the approach without propagation. Proof sketch. We use the graph given in Fig. 1a: any MPS of it has a degree-1 node. (cid:74) All following constraint classes deal with excluding combinations of cycles and paths that either induce non-planarity, or result in cycle-variables not assignable to any face in the planar subgraph (Lemma 5). They are independent of but compatible with the pseudo-tree extension. Cycle-Edge Constraints. Considering integral solutions and constraints (5), a cycle cannot be picked if any of its edges is deleted. W.r.t. fractional solutions we can additionally require se + cα ≤ 1 ∀α ∈ C≤D, e ∈ E(α). (12) Although there are only O(DC≤D) such constraints, preliminary benchmarks showed that adding all of them does not pay off. Instead, we straight-forwardly separate them by iterating over the edges of each cycle that has a non-zero variable. (cid:73) Lemma 12. ? The cycle-edge constraints (12) strengthen CM3. Proof sketch. Use a graph (Fig. 1b) that has 3 edges each incident to only 1 triangle. (cid:74) ESA 2018 19:8 Cycles to the Rescue! Novel Constraints to Compute MPS Fast K8 K7 K8 (a) Pseudo-Tree, Lemma 11 (b) Cycle-Edge, Lemma 12 (c) Two-Cycles-Path, Lemma 14 Figure 1 Graphs in strength proofs. Bold edges in (a) have large weight (or are edge bundles). s(cid:0)E(p)(cid:1) ≥ cα + cβ − 1 Two-Cycles-Path Constraints. Given two cycles α, β, we denote their set of inner nodes by ν(α, β) := {v ∈ V (α) ∩ V (β) δα(v) = δβ(v)}. Let ψ(α, β) denote the set of non-empty paths that connect ν(α, β) to V (α t β) without using any edge in E(α t β). (cid:73) Lemma 13. The two-cycles-path constraints, given below, are feasible. ∀α, β ∈ C≤D; p ∈ ψ(α, β) (13) Proof. Assume an embedding π of α t β where each of α, β corresponds to a face in π. By inserting p into π, we either split face α or face β. Hence, even in a supergraph of α t β t p two such faces cannot exist. Otherwise, if no such π exists, we have 1 ≥ cα + cβ. (cid:74) (cid:73) Lemma 14. ? The two-cycles-path constraints (13) strengthen CM4. Proof sketch. We use the graph of Fig. 1c as input. (cid:74) To identify violated two-cycles-path constraints, we consider each edge e. We collect the set C(e) = {α ∈ C≤D e ∈ E(α) ∧ cα > 0}, and check, for each pair α, β ∈ C(e), whether its sum of LP-values is > 1. If so, we compute the set of inner nodes ν := ν(α, β) and cache the result for future lookup. If ν 6= ∅, we iteratively compute shortest paths following either of two patterns: the combined approach searches for shortest paths from ν to V (α t β) \ ν, whereas the separate one searches for paths from v to V (α t β) \ {v}, separately for each v ∈ ν. Note that the latter variant will always identify a violated constraint, if one exists, whereas the former ignores paths connecting two inner nodes. After identifying a new path p, an edge in E(p) with maximal LP-value is discarded and the search at v starts anew. We point out that there is a natural generalization of this constraint class by using k instead of only 2 cycles. If the k cycles fully enclose a common node v (like any 2 cycles enclose their inner nodes), any other path from v to the same block is forbidden. Cycle-Two-Paths Constraints. We say that two paths p1, p2 are conflicting w.r.t. a cycle α if and only if they each start and end on nodes of V (α) but are otherwise disjoint from α and from one another, and p2 connects the components of α[V (α) \ V (p1)]. (cid:73) Lemma 15. The cycle-two-paths constraints, given below, are feasible. ∀α ∈ C≤D,∀ conflicting paths p1, p2 w.r.t. α (14) s(cid:0)E(p1 t p2)(cid:1) ≥ cα Proof. Given an embedding π of α, we cannot insert both paths p1, p2 into the same face of π. Hence, we must split both faces in π. Consequently, no embedding of any supergraph of α t p1 t p2 exists, where there is a face incident with all of α. (cid:74) While this constraint class may be stronger than the two-cycles-path constraints, we did not implement it: its separation is complex as we ask for two paths depending on each other. M. Chimani and T. Wiedera 19:9 Kuratowski-Cycle Constraints. Starting with a Kuratowski constraint, we can replace parts of its edges by cycles that contain them. (cid:73) Lemma 16. The Kuratowski-cycle constraints, given below, are feasible. s({e ∈ E(K) ∀α ∈ C : e 6∈ E(α)}) ≥X α∈C cα + 1 − C ∀K ∈ K, C ⊆ C≤D (15) Proof. If C = ∅, we simply obtain a Kuratowski constraint. Assuming integrality and C 6= ∅, the right-hand side is 1 if all cycles in C are picked and ≤ 0 otherwise. In the former case, the edges of C, together with the remaining edges of K that are not contained in C (cid:74) contain a Kuratowski subdivision, and we need to remove an edge. (cid:73) Lemma 17. ? The Kuratowski-cycle constraints (15) strengthen CM4. Proof sketch. We use the circulant on 16 nodes with jumps 1, 2, and 8 as input. (cid:74) For separation, we identify a Kuratowski subdivision K as for (2). We collect the set S of cycles with LP-value > 0 incident with K. For each cycle in S, we compute its gain, i.e., the increase in violation (or decrease in slack) when adding that cycle to C. While there are cycles with positive gain, we continue adding a cycle of S with maximal gain to C. Cycle-Clique Constraints. Two cyclic orders π, ¯π on a set X are conflicting if and only if π 6= ¯π and π 6= reverse(¯π). The restriction of π to Y ⊆ X is denoted by πY . A cycle α induces a (up to reversal) unique cyclic order on its nodes V (α). Given two cycles α, β, let πα, πβ be corresponding cyclic orders, and let W := V (α) ∩ V (β) be the common nodes. We say that α and β are conflicting if and only if πW (cid:73) Lemma 18. The cycle-clique constraints, given below, are feasible. β are conflicting. α and πW cα ≤ 1 ∀C ⊆ C≤D s.t. all cycles in C are pairwise conflicting (16) X α∈C Proof. Consider any pair of conflicting cycles α, β ∈ C with πα, πβ, and W defined as above. Since cyclic orders on three elements are unique up to reversal, we have W ≥ 4. By transitivity there exists a set of exactly four common nodes X ⊆ W, such that πX α and πX are conflicting. The graph on X where we add an edge vw if and only if v is adjacent to w β is the K4. Since the K4 is not outerplanar, there can neither be a face in K4 in πX traversing all of X nor such a face in α t β. (cid:74) α or πX β We create the conflict graph HC that contains a node for every cycle with LP-value > 0, cache the conflict information for each pair of cycles, and add constraints for maximal cliques in HC. In a less sophisticated variant, we only add constraints for cliques of size two. 4 Experiments All algorithms are implemented in C++, compiled with GCC 6.3.0, and use the OGDF (snapshot 2017-07-23) [6]. We use SCIP 4.0.1 for solving ILPs with CPLEX 12.7.1 as the underlying LP solver [21]. Each MPS-computation uses a single physical core of a Xeon Gold 6134 CPU (3.2 GHz) with a memory speed of 2666 MHz. We employ a time limit of 20 minutes and a memory limit of 8 GB per computation. Our instances and results, giving runtime and skewness (if solved), are available for download at http://tcs.uos.de/research/mps. ESA 2018 19:10 Cycles to the Rescue! Novel Constraints to Compute MPS Fast Instances and Algorithms. Analogously to the study [8], we consider three established real-world benchmark sets: Rome [12], North [24], and (a subset of) SteinLib [18]. We know from [7,8] that random regular graphs (which are expander graphs with high probability) are especially hard to solve exactly. We use the same such instances as [8], but only consider graphs with ≤ 100 nodes, as no known exact algorithm solves larger instances. There are 20 graphs for each parameterization (V (G), ∆) ∈ {10, 20, 30, 50, 100} × {4, 6, 10, 20, 40}, where ∆ < V (G) is the node-degree. For tuning of ε (e.g., heap size in separation) we rely on the values identified in [15]. We use the notation below to encode algorithmic choices. ε Do not use any extensions but the basic Kuratowski algorithm [23]. e Separate generalized Euler constraints (3). c{r} Add cycle constraints (5), (6), and variables with the minimal value for D such that there are variables for at least 100r cycles. t{01} Use the pseudo-tree extension (8)–(11) with (=t1) or without (=t0) propagation. i Enforce integrality of variables for cycles and pseudo-trees. s w{01} Separate cycle-edge constraints (12). Separate two-cycles-path constraints (13) using combined (=w0) or separate (=w1) approach. Also enables separation on cycle-clique constraints (16) for 2-cliques. Separate Kuratowski-cycle constraints (15). Separate cycle-clique constraints (16). k q Note that instead of providing D explicitly, we specify a minimum number r0 of cycle variables to be generated. We increment D while there are less than r0 cycle variables. Results. Table 1 shows the success rates (percentage of instances solved to proven optimality) and average runtime per instance of our algorithmic variants. For non-solved instances we assume the maximum runtime of 20 minutes-average runtimes are thus comparable only for algorithms that achieve roughly equal success rates. We group the variants by the number of used extensions and highlight variants that dominate their group in bold. The latter informs our choice of which variants to consider in the next group. The separation of generalized Euler constraints is clearly beneficial only on the North graphs, but even there its improvements are marginal when compared to the cycle-based approach. The latter works very well in practice, for all instance sets. In particular (cf. Fig. 2), on Rome it allows us for the first time to compute the skewness of all instances. Using variant c10 t0 i w0, we are able to solve all but grafo10958.98.lgr within the 20 minute time frame; this last instance required 103 minutes. North still contains instances too hard to solve exactly (even when increasing runtime to a few days and memory to 32GB). Nonetheless, we now solve 3/4 of the previously unsolved North graphs within our strict limits. The second group of variants in Table 1 demonstrates that all of our extensions of the cycle model, in particular the pseudo-tree approach, improve upon success rate and runtime on all instance sets when applied to c10. As shown in the lower sections of the table, this does not always apply when comparing models that simultaneously use multiple extensions. Table 2 details the relative improvement for each of the three most promising algorithm configurations over the state-of-the-art ε-model. We provide the success rate for the instances not solved by ε and give the average relative speed-up (i.e., the runtime of ε divided by that of variant X) over the instances solved by both ε and X. This common set is exactly those solved by ε, except for a single ε-solved North-instance not solved by c10. On Rome, the pure cycle model c10 without any further extensions achieves the best speed-up; for the seemingly harder other instance sets, more sophisticated variants are worthwhile. Fig. 2 underlines that the success rate of the algorithms is strongly correlated to the instance's skewness. M. Chimani and T. Wiedera 19:11 Table 1 Overview of performance for algorithmic variants: success rate and avg. runtime. variant Rome North Expanders SteinLib ε e c5 c10 c20 c10 i c10 s c10 t0 c10 t1 c10 w0 c10 w1 c10 k c10 q c10 t0 i c10 t0 s c10 t0 w0 c10 t0 w1 c10 t0 k c10 t0 q c10 t1 i c10 t1 s c10 t1 w0 c10 t1 w1 c10 t1 k c10 t1 q c10 t0 i s c10 t0 s w0 c10 t0 s w1 c10 t0 s k c10 t0 s q c10 t0 i w0 c10 t0 i s w0 succ. [%] 85.71 85.56 98.91 99.14 99.14 99.89 99.79 99.95 99.92 99.79 99.82 99.77 99.73 99.95 99.98 99.98 99.98 99.92 99.95 99.96 99.98 99.98 99.98 99.92 99.92 99.94 99.98 99.98 99.96 99.93 99.99 99.96 time [s] 198.42 199.41 21.60 18.10 19.58 5.52 6.66 3.36 3.74 7.07 6.63 7.26 7.51 3.22 3.08 2.75 2.92 3.57 3.58 3.32 2.75 3.04 3.19 3.65 3.86 3.27 2.43 2.29 3.03 3.22 2.89 2.72 succ. [%] 73.76 77.78 84.40 84.63 83.92 88.89 88.42 92.43 93.14 87.23 86.52 86.52 85.82 93.14 93.62 92.43 92.20 92.67 92.67 92.91 92.43 92.20 91.96 92.20 93.14 92.91 93.85 92.91 93.38 93.62 92.67 94.33 time [s] 325.31 273.29 201.42 195.35 197.86 156.99 165.54 112.82 111.94 165.36 179.48 178.34 185.84 109.61 95.46 112.77 109.37 104.55 109.71 106.39 112.77 114.28 113.03 112.61 113.89 103.17 91.66 101.17 98.06 95.59 105.16 93.99 succ. [%] 34.74 35.00 53.95 54.47 55.00 56.58 58.68 57.37 56.32 55.53 55.00 55.26 55.53 57.37 58.95 57.37 57.11 56.84 57.37 57.11 58.68 56.84 56.84 56.84 56.05 58.95 58.68 58.68 58.68 58.42 57.11 59.47 time [s] 800.38 803.91 567.52 562.81 573.82 538.81 515.13 535.46 539.04 549.94 553.38 552.83 550.55 529.93 509.01 537.61 537.76 535.97 538.19 533.51 537.61 537.97 540.39 538.91 540.23 506.63 508.28 507.99 504.54 510.38 529.95 502.30 succ. [%] 9.52 9.52 31.43 32.38 31.43 31.43 35.24 37.14 37.14 31.43 31.43 33.33 31.43 38.10 39.05 36.19 37.14 38.10 37.14 37.14 37.14 38.10 37.14 37.14 37.14 40.00 39.05 39.05 39.05 38.10 38.10 39.05 time [s] 1 085.94 1 085.93 859.40 853.57 861.47 841.88 821.00 789.26 785.89 837.52 833.81 828.81 841.77 782.72 760.70 808.58 780.83 785.46 789.05 788.52 808.58 786.93 783.09 784.30 788.07 761.47 763.08 756.31 765.08 763.64 798.26 754.46 Table 2 Relative improvement over ε for selected algorithmic variants. We give the the success rate over the instances unsolved by ε, and the avg. runtime ratio over the commonly solved instances. variant Rome North c10 c10 t0 i w0 c10 t0 i s w0 new [%] 93.98 99.92 99.75 speed-up 66.80 60.85 59.58 new [%] 42.34 72.07 78.38 speed-up 21.45 28.59 34.03 Expanders new [%] 30.24 34.27 37.90 speed-up 13.96 12.68 23.21 SteinLib new [%] 25.26 31.58 32.63 speed-up 11.79 6.79 5.42 Table 3 Average number of cycle variables and average values for maximum cycle length D. variant min # var 500 1 000 2 000 c5 c10 c20 Rome North D 9.51 10.51 11.51 # var 627 1 168 2 175 D 7.34 8.01 8.55 # var 689 1 213 2 048 Expanders # var D 2 075 5.43 2 816 5.73 6.47 7 774 SteinLib D 5.80 6.64 7.09 # var 881 3 658 4 785 ESA 2018 19:12 Cycles to the Rescue! Novel Constraints to Compute MPS Fast e t a r s s e c c u s 100 % 50 % 0 % ε c10 c10 t0 i w0 2 4 6 8 10 12 skewness 14 16 18 ≥20 1500 1000 500 0 s e c n a t s n i (a) Solved Rome graphs by skewness. c10 t0 i w0 solves all but 1 skew-22-graph within 20min. e t a r s s e c c u s 100 % 50 % 0 % ε c10 c10 t0 i w0 c10 t0 i s w0 2 4 6 s e c n a t s n i 100 50 0 18 20 ≥23 10 12 8 upper bound on skewness 14 16 (b) Solved North graphs by best upper bound on skewness. Figure 2 Detailed success rates for selected algorithmic variants. Table 3 lists the average number of generated cycle variables and the respective average values for D. We mention that instances with high D values typically generate few cycle variables, close to the lower bound. However, there is a large deviation in the number of generated cycle variables in any fixed instance set: some graphs contain less than the requested number of cycles whereas others already contain roughly 10 000 triangles. Conclusion and Open Questions 5 For over two decades, the strongest ILP model for MPS has not been improved. In this paper we presented novel variables and constraints, based on cycles, to extend this model to finally obtain both a theoretically stronger model, as well as a more efficient algorithm in practice. We proved that there is a hierarchy of ever stronger LP-relaxations, induced by the maximal considered cycle length, and a rich set of further strengthening cycle-based constraint classes. For the first time, we are able to compute the skewness of all Rome graphs, solve 94% of the North graphs (compared to 74% by the ε-model), and solve 40% instead of only 10% of our SteinLib instances. Our extensions also help for the notoriously hard expander graphs. Several of our proofs show the new constraint class's strength w.r.t. a low-D cycle model. We conjecture that most classes remain strengthening for high D, but to prove this, one has to find and argue infinite families of graphs with the LP-properties of our currently hand-crafted proof graphs. Furthermore, it is natural to ask if and which of the new constraint classes form facets in the (lifted) planar subgraph polytope. A problem inherent to our approach arises on inputs of non-homogeneous density: G may have too dense subgraphs to raise D sufficiently, even when every planar subgraph of G contains large regions consisting of high-degree faces. Is there a practical way to generalize the cycle-based approach using an independent maximum cycle length for each edge? M. Chimani and T. Wiedera 19:13 References 1 Carlo Batini, Maurizio Talamo, and Roberto Tamassia. Computer Aided Layout of Entity Relationship Diagrams. J. Syst. Soft., 4(2-3):163–173, 1984. doi:10.1016/0164-1212(84) 90006-2. 2 Gruia Călinescu, Cristina Gomes Fernandes, Ulrich Finkler, and Howard Karloff. A Better Approximation Algorithm for Finding Planar Subgraphs. J. Alg. in Cognition, Informatics and Logic, 27(2):269–302, 1998. doi:10.1006/jagm.1997.0920. Parinya Chalermsook and Andreas Schmid. Finding Triangles for Maximum Planar Subgraphs. In Sheung-Hung Poon, Md. Saidur Rahman, and Hsu-Chun Yen, editors, WALCOM: Algorithms and Computation, 11th International Conference and Workshops, WALCOM 2017, Hsinchu, Taiwan, March 29-31, 2017, Proceedings., volume 10167 of Lecture Notes in Computer Science, pages 373–384. Springer, 2017. doi:10.1007/ 978-3-319-53925-6_29. 4 Markus Chimani and Carsten Gutwenger. Non-planar core reduction of graphs. Discrete 3 Mathematics, 309(7):1838–1855, 2009. doi:10.1016/j.disc.2007.12.078. 5 Markus Chimani and Carsten Gutwenger. Advances in the Planarization Method: Effective Multiple Edge Insertions. J. Graph Algorithms Appl., 13(3):729–757, 2012. doi:10.7155/ jgaa.00264. and Petra Mutzel. 6 Markus Chimani, Carsten Gutwenger, Michael Jünger, Gunnar W. Klau, Karsten The Open Graph Drawing Framework (OGDF). editor, Handbook on Graph Drawing and Visualization, URL: https://crcpress.com/ Klein, In Roberto Tamassia, pages 543–569. Chapman and Hall/CRC, 2013. Handbook-of-Graph-Drawing-and-Visualization/Tamassia/9781584884125. 7 Markus Chimani, Ivo Hedtke, and Tilo Wiedera. Limits of Greedy Approximation Algo- rithms for the Maximum Planar Subgraph Problem. In Veli Mäkinen, Simon J. Puglisi, and Leena Salmela, editors, Combinatorial Algorithms - 27th International Workshop, IWOCA 2016, Helsinki, Finland, August 17-19, 2016, Proceedings, volume 9843 of Lecture Notes in Computer Science, pages 334–346. Springer, 2016. doi:10.1007/978-3-319-44543-4_26. 8 Markus Chimani, Ivo Hedtke, and Tilo Wiedera. Exact Algorithms for the Maximum Planar Subgraph Problem: New Models and Experiments. In 17th International Symposium on Experimental Algorithms, SEA 2018, June 27-29, 2018, L'Aquila, Italy. LIPIcs, 2018. doi:10.4230/LIPIcs.SEA.2018.22. 9 Markus Chimani and Petr Hlinený. A tighter insertion-based approximation of the crossing number. J. Comb. Optim., 33(4):1183–1225, 2017. doi:10.1007/s10878-016-0030-z. 10 Markus Chimani, Karsten Klein, and Tilo Wiedera. A Note on the Practicality of Maximal Planar Subgraph Algorithms. In Yifan Hu and Martin Nöllenburg, editors, Proceedings of the 24th International Symposium on Graph Drawing and Network Visualization (GD 2016), volume abs/1609.02443. CoRR, 2016. doi:10.1007/978-3-319-50106-2_28. 11 Markus Chimani, Petra Mutzel, and Jens M. Schmidt. Efficient Extraction of Multiple Kuratowski Subdivisions. In Seok-Hee Hong, Takao Nishizeki, and Wu Quan, editors, Graph Drawing, 15th International Symposium, GD 2007, Sydney, Australia, September 24-26, 2007. Revised Papers, volume 4875 of Lecture Notes in Computer Science, pages 159–170. Springer, 2007. doi:10.1007/978-3-540-77537-9_17. 12 Giuseppe Di Battista, Ashim Garg, Giuseppe Liotta, Roberto Tamassia, Emanuele Tassi- nari, and Francesco Vargiu. An experimental comparison of four graph drawing algo- rithms. Computational Geometry. Theory and Applications, 7(5-6):303–325, 1997. 11th ACM Symposium on Computational Geometry (Vancouver, BC, 1995). doi:10.1016/ S0925-7721(96)00005-3. 13 Manuel Fernández, Nicholas Sieger, and Michael Tait. Maximal Planar Subgraphs of Fixed Girth in Ramdom Graphs. arXiv:1706.06202. ESA 2018 19:14 Cycles to the Rescue! Novel Constraints to Compute MPS Fast 14 Michael R. Garey and David S. Johnson. Computers and intractability. A guide to the theory of NP-completeness. W. H. Freeman and Co., San Francisco, Calif., 1979. Ivo Hedtke. Minimum Genus and Maximum Planar Subgraph: Exact Algorithms and Gen- eral Limits of Approximation Algorithms. PhD thesis, Osnabrück University, 2017. URL: https://repositorium.ub.uos.de/handle/urn:nbn:de:gbv:700-2017082416212. Jan M. Hochstein and Karsten Weihe. Maximum s-t-flow with k crossings in O(k3n log n) time. SODA '07, pages 843–847, 2007. 17 Michael Jünger and Petra Mutzel. Maximum Planar Subgraphs and Nice Embeddings: Practical Layout Tools. Algorithmica, 16(1):33–59, 1996. doi:10.1007/s004539900036. 18 Thorsten Koch, Alexander Martin, and Stefan Voss. SteinLib: An updated library on steiner tree problems in graphs. Technical Report ZIB-Report 00-37, Konrad-Zuse-Zentrum für Informationstechnik Berlin, Takustr. 7, Berlin, 2000. URL: http://elib.zib.de/ steinlib. 19 Kazimierz Kuratowski. Sur le problème des courbes gauches en topologie. Fundamenta 15 16 20 21 Mathematicae, 15:271–283, 1930. P. C. Liu and R. C. Geldmacher. On the deletion of nonplanar edges of a graph. In Proceedings of the Tenth Southeastern Conference on Combinatorics, Graph Theory and Computing (Florida Atlantic Univ., Boca Raton, Fla., 1979), Congress. Numer., XXIII– XXIV, pages 727–738. Utilitas Math., Winnipeg, Man., 1979. Stephen J. Maher, Tobias Fischer, Tristan Gally, Gerald Gamrath, Ambros Gleixner, Robert Lion Gottwald, Gregor Hendel, Thorsten Koch, Marco E. Lübbecke, Matthias Mil- tenberger, Benjamin Müller, Marc E. Pfetsch, Christian Puchert, Daniel Rehfeldt, Sebas- tian Schenker, Robert Schwarz, Felipe Serrano, Yuji Shinano, Dieter Weninger, Jonas T. Witt, and Jakob Witzig. The SCIP Optimization Suite 4.0. Technical Report 17-12, ZIB, Takustr. 7, 14195 Berlin, 2017. 22 Michael Mitzenmacher and Eli Upfal. Probability and computing - randomized algorithms and probabilistic analysis. Cambridge University Press, 2005. Petra Mutzel. The maximum planar subgraph problem. PhD thesis, Köln University, 1994. Stephen C. North. 5114 directed graphs, 1995. Manuscript. 23 24 M. Chimani and T. Wiedera A Appendix 19:15 The appendix consists mainly of proofs for the strength of certain classes of constraints. Such proofs always proceed in the following manner: First, we describe an integrally edge-weighted graph that is used as input. Note that (integral) edge-weights are naturally obtained by contracting parallel 2-paths in the input and other preprocessing techniques. We restrict ourselves to instances that cannot be reduced by standard techniques [4]. Next, we give an LP-feasible solution with objective value OBJ for the model that does not use the new constraints. In particular, we also show that the solution satisfies all traditional Kuratowski constraints (2). Finally, we show that there is no LP-feasible solution with objective value OBJ when using (a subset of) the new constraints. (cid:73) Lemma 2. The generalized Euler constraints (3) strengthen the ε-model. Proof. Let G denote the K3,3,1 (see Fig. 3). Consider the ε-model on G. We show the fact for OBJ = 3/2. Since γ(G) = 3, the traditional Euler constraint only gives an upper bound of 15 on the number of edges in the planar subgraph, but E(G) = 15. Let v denote the node in the cardinality-1 partition and M denote a perfect matching in G0 := G − v. For any cardinality-2 subset S ⊂ M, the graph G − S is planar (see Fig. 3a). Hence, we satisfy all Kuratowski constraints by setting se = 1/2 for all e ∈ M. It follows that an LP-value of 3/2 is feasible without the generalized Euler constraints. Consider an edge cut F in K3,3,1 that partitions the nodes V (G0) such that E(G0) is fully contained in F, and places v in either of the two partitions. F induces a K3,4-subgraph H with γ(H) = 4 (see Fig. 3b). The generalized Euler constraint on H is s(E(H)) ≥ 2, hence (cid:74) improving the dual bound. F (a) Edges of the maximum matching M in G0 are dashed. (b) The K3,4-subgraph (dashed edges are removed from K3,3,1). Figure 3 The input K3,3,1 for showing the strength of the generalized Euler constraints. (cid:73) Lemma 8. Model CMD+1 is at least as strong as CMD. Proof. Let A := (¯s, ¯c) denote a feasible variable assignment for P 0. By eliminating cycle variables of length D +1 from A we obtain a feasible variable assignment for P with the same objective value: as we do not change the value of ¯s, we respect all Kuratowski constraints. The sum of cycle variables for each edge does not increase, thus, constraints (5) are respected as well. It remains to show that the cycle constraint is satisfied which is obtained in the following way, starting with the trivial identity: XD d=3 D(D + 1 − d)c(d) =XD d=3 D(D + 1 − d)c(d) ESA 2018 19:16 Cycles to the Rescue! Novel Constraints to Compute MPS Fast K8 v1 v1 w1 w1 w3 w2 v2 Figure 4 Input for proving the strength of the pseudo-tree model. Expensive edges are bold. Removing the dashed edges allows to keep all expensive ones. We apply Lemma 7 for D + 1. 2n − 4 +XD D(D + 1 − d)c(d) ≥XD+1 d=3 (D − 1)(D + 2 − d)c(d) d=3 Adding (D2 + D)(n − 2) to both sides and afterwards dividing by D(D − 1) gives the right-hand sides of equation (11), divided by factor D − 1 (resp. D). (cid:18) (D + 1)(n − 2) +XD (cid:18) (D + 2)(n − 2) +XD+1 d=3 d=3 ≥ (cid:19) (cid:19) (D + 1 − d)c(d) · (D − 1)−1 (D + 2 − d)c(d) · D−1 The upper bound on the number of edges due to D is no less than that due to D + 1. (cid:74) (cid:73) Lemma 11. The pseudo-tree extension, i.e., constraints (8)–(11) together with the t- variables, strengthens CM3. This already holds for the approach without propagation. Proof. Consider the following input G: start with two K5's that we each delete an arbitrary edge from and join them by identifying two degree-3 nodes with each other. We call this node w2. The resulting graph has exactly 3 nodes W := {w1, w2, w3} of degree not 4. We denote its edge-set by E5. We add the nodes v1, v2 and connect both to all nodes of W. Let X denote a set of 6 new nodes: we complete a K8-subgraph on X ∪ {w1, v1} and denote its edges by E8. Finally, we assign weight w to the edges: fix a (large) constant M ∈ N; all edges of E5 have weight M, all other edges have weight 1. See Fig. 4 for a schematic depiction of G. Consider CM3 on G. We show the fact for OBJ = 7. We observe that all Kuratowski constraints are satisfied by the following s-variable assignment: se = 0 for all e ∈ E5∪{v2w1}, sv1w2 = sv1w3 = 17/18, sv2w2 = sv2w3 = 1, and se = 1/9 otherwise. This gives an objective value of 7, independent of M. For this objective, the cycle constraint (6) is satisfied if c(3) ≥ 28 which is obtained by setting cα = 1 for 12 triangles α in E5 (corresponding to an actual embedding of the two joined K5-subgraphs) and cα = 8/27 for all(cid:0)8 3 E8 without violating constraints (5). Note that deg(v2) = 1 in the solution. Consider either variant of the pseudo-tree model (8)–(11), assume that the objective value would remain feasible. We observe that for any two edges e, f ∈ δG(v2), the graph G[E5]+e+f is not planar. For any 6 nodes in V (G[E8]) we obtain a K3,3-subdivision. Summing over the respective Kuratowski constraints, it follows that s(E8) ≥ E8/9. Note that no edge (cid:1) triangles α in M. Chimani and T. Wiedera 19:17 v3 T Q w1 v1 w2 v2 Figure 5 Input for proving strength of cycle-edge constraints. The solid edges induce a planar subgraph and show that the same skewness is maintained when inserting w1, w2 into the K7. Quadrangle Q is shaded and the set T of triangles is hatched. All edges incident with exactly one triangle are drawn in bold. in E(G) \ (E5 ∪ E8) is part of a triangle. Let c(F) denote the sum of triangles that use edges of F ⊆ E(G). By the extended cycle constraint (11) we have c(3) ≥ 28 + 2tv2. Since c(3) ≤ c(E5) + c(E8) ≤ 2/3(cid:0)E5 + E8 − s(E8)(cid:1) ≤ 2/3(cid:0)18 + 28 − 28/9(cid:1) = 772/27, we obtain tv2 ≤ 8/27. Constraints (10) imply that s(cid:0)δG(v2)(cid:1) ≤ tv2 + 1 = 35/27. Hence, there exists a pair of edges e, f ∈ δG(v2) such that se + sf ≤ 35/27 · 2/3 = 70/81 and s(E5) ≥ 11/81 follows. By choosing M > (7 · 81)/11 we obtain a contradiction. (cid:74) (cid:73) Lemma 12. The cycle-edge constraints (12) strengthen CM3. Proof. Consider the K7, and pick three nodes v1, v2, v3 ∈ V (K7). We add the new nodes w1, w2 6∈ V (K7) and new edges w1w2, v1w1, v2w2, v3w1, v3w2 to obtain G, see Fig. 5. Note that the edges I := w1w2, v1w1, v2w2 are incident with exactly one triangle (each with a different one, let T denote the set of the three triangles) and a shared quadrangle Q = v1w1w2v2. We observe that skew(G) = skew(K7) = 6. Consider CM3 on G. We show the fact for OBJ = 5. We choose se = 1/8 for all edges e 6∈ E(Q) and set sv1w1 = sv2w2 = 1/2, sv1v2 = sw1w2 = 5/8. Without constraints (12), this allows us to set c(3) = 14 (each edge not in E(Q) being incident with two triangles α, β whose cycle variables are 1 and 3/4, respectively), satisfying the cycle constraints. It is straight-forward to verify the existence of this cycle variable assignment (but manually tedious). Clearly, this bound is no better than the trivial Euler constraint on G. However, when adding the cycle-edge constraints (12), this solution becomes infeasible: for example sv1w1 = 1/2 but cv1w1v3 ≥ 3/4. We show that the objective is larger than 5 by contradiction. To obtain an objective value of 5, we require c(3) ≥ 14. Let E7 denote the edges in the K7-subgraph of G, ¯E7 := E(G) \ E7, and x := s(E7). Recall that s(E(G)) ≥ 5 by Euler and hence s( ¯E7) ≥ 5 − x. Let c(F) denote the sum of triangles where each triangle is weighted by its number of edges in F ⊆ E(G) divided by 3. Already by summing up α∈T cα. For each α ∈ T with cα > 0, we require a certain number of edges in ¯E7 not to be deleted. More precisely, we may assume the largest two cycle variables of T to be incident with 4 different edges of ¯E7 while the smallest one adds just a single edge of ¯E7 that is not used in the other two cycles. Assuming the new constraints to be satisfied on I, we obtain s( ¯E7) ≤ ¯E7 − c( ¯E7)(2/3 · 2 + 1/3). Since K7 constraints (5) over all edges of E7 we have c(E7) ≤ 2/3(cid:0)E7 − x(cid:1) = 14 − 2/3x and hence c( ¯E7) ≥ 2/3x. Note that c( ¯E7) = P ESA 2018 19:18 Cycles to the Rescue! Novel Constraints to Compute MPS Fast K8 v1 v1 w w v3 v3 v2 v2 v1 v1 y v2 x v3 (a) The input G with a schematic depiction of the K8-subgraph. G[V (G) \ X] without the dashed edges is planar. (b) Example of a two-cycles-path constraint: if no bold edge is deleted, the shaded and the (overlapping) hatched quadrangle cannot both occur as part of a face (here, only the hatched one does). Figure 6 Graphs for proving strength of two-cycles-path constraints. contains a Kuratowski-subdivision, it follows that x > 0 and we have the contradiction 5 − x ≤ s( ¯E7) ≤ 5 − 10/9x. (cid:74) (cid:73) Lemma 14. The two-cycles-path constraints (13) strengthen CM4. Proof. We construct our input G in the following manner, see Fig. 6a: consider the K3 and replace each of the three edges by a new K2,3 such that its end nodes become two nodes of the cardinality-3 node partition of K2,3. Let v1, v2, v3 denote the nodes of the cardinality-3 partitions that are not identified with any of V (K3). We add a new node w and the edges wv2, wv3. Finally, we add six new nodes X and a K8-subgraph on X ∪ {w, v1}. Let E8 denote the edge set of this K8-subgraph. Note that w is not incident with any quadrangle outside of E8 and all triangles of G are contained in E8. Consider CM4 on G. We show the fact for OBJ = 6. First, note that the graph G − E8 becomes planar when removing any edge incident with w. In fact, all Kuratowski constraints are satisfied by setting se = 1/9 for all e ∈ E8 and swv2 = swv3 = 1. Let F := E(G) \ for all edges e ∈ F, set cα = 8/27 for all triangles α in E8, and set cα = 77/81 for all 9 quadrangles α in F. It is easy to see that constraints (5) and (6) are satisfied. Hence, an objective value of 6 is feasible unless the new constraints are added. (cid:0)E8 ∪ δG(w)(cid:1). To obtain an LP-feasible c-variable assignment, we additionally set se = 4/81 We now show that this is no longer the case when adding the new two-cycles-path constraints (13). Assume otherwise, i.e., s(E(G)) ≤ 6. We denote the sum over all variables of quadrangles in F that are not incident with any vi (i ∈ {1, 2, 3}) by cout. Similarly, we denote the sum over all variables of quadrangles in F that are incident with some vi (i ∈ {1, 2, 3}), by cin and the sum over all remaining quadrangle variables (each fully contained in E8) by c8(4). The Kuratowski constraints on E8 imply s(E8) ≥ E8/9 and it follows from constraints (5) that 3/2· c(3) + 4/2· c8(4) ≤ E8− s(E8). Hence, c(3) + c8(4) ≤ 448/27. The cycle constraint (6) implies 41 ≤ 2c(3) + c(4). Let us apply the new constraints: for any i ∈ {1, 2, 3}, pick node vi and one of its (two) incident quadrangles Qi that we denote by αin ∈ Qi. There is a unique quadrangle αout not incident with vi but with two vi's F-neighbors. Let x ∈ V (αin) ∩ V (αout) denote the unique node with δαin(x) = δαout(x), i.e., the inner node of αin with αout. We denote the single node contained in V (αout) \ V (αin) by y. We observe that any x-y-path p M. Chimani and T. Wiedera 19:19 (a) Input: circulant graph with jumps 1 (solid straight), 2 (solid bent), and 8 (dashed): adding any single edge of E8 to G[E1 ∪ E2] maintains in a planar graph. (b) This subgraph contains a K3,3-subdivision and consists of eight triangles (hatched) and a 2-8-quadrangle (shaded). (c) K3,3-subdivision that con- sists of 12 edges of E1, one edge of E8 and a disjoint 2-8- quadrangle (shaded). Figure 7 Graphs for showing the strength of Kuratowski-cycle constraints. in G − E8 − E(αout) forms a two-cycle-path constraint with αout and αin, see Fig. 6b. Summing over all such constraints (there are exactly 16 paths for two fixed cycles), we obtain 2s(F) ≥ 2cout + cin − 6. By constraints (5), we have cout + cin ≤ 9 − s(F)/2, an upper bound on s(F). Combining both we obtain 30 ≥ 6cout + 5cin and hence cout + cin ≤ 6. We finally (cid:74) obtain 41 ≤ 2c(3) + c(4) ≤ 2(cid:0)448/27 − c8(4)(cid:1) + c8(4) + cout + cin ≤ 2 · 448/27 + 6 < 40, a contradiction. (cid:73) Lemma 17. The Kuratowski-cycle constraints (15) strengthen CM4. Proof. Let G denote the circulant graph on 16 nodes with jumps 1, 2, and 8 (see Fig. 7a). Consider CM4 on G. We show the fact for OBJ = 14/3. Assume the nodes of G to be labeled as v0, v1, . . . , v15, corresponding to jumps 1. Let Ei ⊆ E(G) denote the edges corresponding to jumps i. We observe that every Kuratowski subdivision needs at least two edges of E8 as (V (G), E1∪E2∪{e}) is planar for all e ∈ E8 (see Fig. 7a). It follows that every Kuratowski constraint is satisfied by se = 1/2 for all e ∈ E8. Without the new constraints, an LP-value of 14/3 is obtainable by se = 1/2 for all e ∈ E8 ∪ {sv1v3}, sv5v7 = 1/6, and se = 0 otherwise; and by picking all 16 triangles and four disjoint quadrangles R, consisting of two edges of E2 \ {v1v3, v5v7} and E8 each, with cycle variable value 1. The solution is cut-off by the new Kuratowski-cycle constraints (15): intuitively, we may pick a quadrangle of R instead of two edges of E8 to obtain a violated Kuratowski- cycle constraint although the sum of any two such edges being 1 prevents any traditional Kuratowski constraints to be violated. We now show that s(E(G)) > 14/3 when adding a certain set of Kuratowski-cycle constraints. An i-j-quadrangle is a quadrangle that uses edges of Ei and Ej. Let qij denote the sum over variables corresponding to i-j-quadrangles. Observe that c(4) = q12 + q18 + q28, since there are no other quadrangles in G. The cycle constraint (6) implies that 3s(E(G)) + 2c(3) + q12 + q18 + q28 ≥ 50. By summing over all constraints (5) that correspond to edges of E1, we obtain c(3) + q12 + q18 + s(E1) ≤ 16. Similarly, using E8 instead of E1, we have q18 + q28 + s(E8) ≤ 8. We describe three types of Kuratowski-cycle constraints (15) in G. Let W denote the nodes of G that have an odd index. We observe that G[W] is a Möbius ladder: it consists ESA 2018 19:20 Cycles to the Rescue! Novel Constraints to Compute MPS Fast of exactly four 2-8-quadrangles and is non-planar. The same construction works for even node indices. We obtain q ≤ 6 by summing over both constraints. Consider a single 2-8-quadrangle α: the indices of all nodes in α have identical parity p. The graph that consists of α and the 8 triangles that use edges of E2 incident with nodes of parity not p, is non-planar, see Fig. 7b. Summing over all corresponding Kuratowski-cycle constraints, we obtain 64 ≥ 4c(3) + q28. Once again, consider a single 2-8-quadrangle α: there are exactly two nodes u, v 6∈ V (α) each incident with two nodes of V (α). Pick any f ∈ E8 ∩ E(α) such that f ∩ {u, v} = ∅. The graph α t G[f ∪ {e ∈ E1 e ∩ {u, v} = ∅}] is non-planar, see Fig. 7c. It consists of a 2-8-quadrangle, another edge of E8, and 12 edges of E1. Summing over all corresponding Kuratowski-cycle constraints, we have 6s(E1) + s(E8) ≥ q28. By the above, we obtain a system of linear inequalities on six non-negative variables: s(E1) + s(E2) + s(E8) ≤ 14/3 3s(E1) + 3s(E2) + 3s(E8) + 2c(3) + q12 + q18 + q28 ≥ 50 c(3) + q12 + q18 + s(E1) ≤ 16 q18 + q28 + s(E8) ≤ 8 q ≤ 6 4c(3) + q28 ≤ 64 6s(E1) + s(E8) ≥ q28 It is straight-forward (although manually tedious) to check that this system has no solution. (cid:74)
1112.0534
1
1112
2011-12-02T18:35:06
The interval ordering problem
[ "cs.DS" ]
For a given set of intervals on the real line, we consider the problem of ordering the intervals with the goal of minimizing an objective function that depends on the exposed interval pieces (that is, the pieces that are not covered by earlier intervals in the ordering). This problem is motivated by an application in molecular biology that concerns the determination of the structure of the backbone of a protein. We present polynomial-time algorithms for several natural special cases of the problem that cover the situation where the interval boundaries are agreeably ordered and the situation where the interval set is laminar. Also the bottleneck variant of the problem is shown to be solvable in polynomial time. Finally we prove that the general problem is NP-hard, and that the existence of a constant-factor-approximation algorithm is unlikely.
cs.DS
cs
The interval ordering problem Christoph Durr∗, Maurice Queyranne†, Frits C.R. Spieksma‡, Fabrice Talla Nobibon§¶, Gerhard J. Woeginger(cid:107) Abstract. For a given set of intervals on the real line, we consider the problem of ordering the intervals with the goal of minimizing an objective function that depends on the exposed interval pieces (that is, the pieces that are not covered by earlier intervals in the ordering). This problem is motivated by an application in molecular biology that concerns the determination of the structure of the backbone of a protein. We present polynomial-time algorithms for several natural special cases of the prob- lem that cover the situation where the interval boundaries are agreeably ordered and the situation where the interval set is laminar. Also the bottleneck variant of the problem is shown to be solvable in polynomial time. Finally we prove that the general problem is NP-hard, and that the existence of a constant-factor-approximation algorithm is unlikely. Keywords: dynamic programming; bottleneck problem; NP-hard; exposed part; agree- able intervals; laminar intervals. Introduction S ⊂ I of the intervals, we define Ij \(cid:83) 1 Let us consider a set I of n intervals Ij = [aj, bj) for j = 1, 2, . . . , n on the real line. The length of interval Ij is denoted by Ij = bj − aj. As usual, the length of a union of disjoint intervals is the sum of the lengths of the individual intervals. For an interval Ij and a subset I∈S I to be that part of interval Ij that is not covered by the union of the intervals in S; throughout this text this uncovered part will be called the exposed part of Ij relative to subset S. Notice that the exposed part depends upon S and in general need not be an interval. (If the intervals in I are pairwise disjoint, then of course the exposed part of any interval I relative to any set S of intervals not containing I is the interval I itself.) We investigate an interval ordering problem that is built around a cost function f that assigns to every interval of length p a corresponding real cost f (p). The cost of a set S of pairwise disjoint intervals is the sum of the costs of the individual intervals in S. The cost of an ordering α =(cid:0)α(1), α(2), . . . , α(n)(cid:1) of all n intervals is the result of summing up in that [email protected] [email protected] ∗CNRS, Universit´e Pierre et Marie Curie, LIP6, F-75252 Paris Cedex 05, France. [email protected] †Sauder School of Business at the University of British Columbia, Vancouver, Canada; and CNRS, France. ‡University of Leuven, Operations Research Group, Naamsestraat 69, B-3000 Leuven, Belgium. §PostDoc researcher for Research Foundation Flanders, Center for Operations Research and Business Statistics (ORSTAT), Faculty of Business and Economics, KULeuven, Leuven, Belgium. E-mail: Fab- [email protected] ¶Scientific collaborator Centre for Quantitative methods and Operations Management (QuantOM), HEC- (cid:107)Technical University of Eindhoven. [email protected] Management School, University of Li`ege, Belgium 1 1 1 0 2 c e D 2 ] S D . s c [ 1 v 4 3 5 0 . 2 1 1 1 : v i X r a order, for every interval, the cost of its exposed part with respect to the previous intervals. Formally, the problem is defined as follows. Definition 1. The Interval Ordering Problem: Given a function f : R → R and n intervals I1, . . . , In over the real line, find an ordering α ∈ Σn such that the cost n(cid:88) f(cid:0)Iα(k) \(cid:91) k−1 j=1 Iα(j)(cid:1), k=1 is minimized, where Σn denotes the set of all the permutations of {1, 2, . . . , n}. Observe that the interval ordering problem becomes trivial, if all intervals are pairwise disjoint (since then all orderings yield the same cost). In the rest of this paper, an instance of the interval ordering problem is represented by(cid:0)I, f(cid:1) where I is the set of intervals and f is the cost function. Example 1. Consider the instance that consists of the five intervals I1 = [0, 1), I2 = [1, 2), I3 = [2, 3), I4 = [3, 6) and I5 = [0, 5), and the cost function f (x) = 2x. An optimal solution for this instance is given by the sequence α = (1, 2, 3, 5, 4) with a total cost of 12. 21 21 I1 I2 I3 I4 I5 21 20 23 21 21 21 I1 I2 I3 I5 I4 22 21 greedy ordering with respect to interval length optimal ordering This example illustrates that in general an optimal solution will not sequence the intervals in order of increasing length (and it can be verified that in Example 1 no such sequence can yield the optimal objective value). The next example illustrates that also the following natural greedy algorithm fails: "Always select the interval with the smallest exposed part relative to the intervals sequenced so far". In fact, the greedy algorithm can be arbitrarily bad, as witnessed by the following example. Example 2. Consider a family of instances, where each instance consists of 2k−1 intervals: A1 = [0, 2k), A2 = [2k − , 4k), A3 = [4k − , 6k),. . . , Ak = [2k(k − 1) − , 2k2), B1 = [k − , 2k2), B2 = [3k − , 2k2), B3 = [5k − , 2k2),. . . , Bk−1 = [2k2 − 3k − , 2k2), for some constants k,  > 0 with the cost function f (x) = 2x. B2 B1 A3 A2 A1 20 22k 20 22k 22k 2k− 2k A1 B1 A2 B2 A3 2k 2k 22k+ greedy ordering with respect to exposed length optimal ordering A greedy sequence is (A1 , A2, . . . , Ak−1, Ak, Bk−1, Bk−2, . . . , B1) and achieves a cost of k22k + k − 1, whereas the optimal solution is (Ak , Bk−1, Ak−1, Bk−2, . . . , A2, B1, A1) and has the cost of 22k+ + (2k− 3)2k + 2k−. The ratio between both costs can be made arbitrarily large, by choosing appropriate k and small  > 0. 2 The contributions of this paper are twofold: on the positive side, we describe polynomial- time algorithms for some natural and fairly general special cases of the problem. On the negative side, we establish the computational complexity (NP-hardness) and the in- approximability of the problem. The paper is organized as follows. In Section 2, we describe the motivating real world application (in molecular biology) that stands behind the interval ordering problem. In Section 3, we formulate and present a number of special cases of the problem that can be solved in polynomial time. In Section 4, we present complexity and in-approximability results. We conclude in Section 5. 2 Motivation The interval ordering problem studied in this paper is motivated by a special case of the so-called distance geometry problem [1 -- 4]. Formally, an instance of the latter consists of an undirected graph G(V, E) with positive edge weights d : E → R+. The goal is to find an embedding of the vertices into some Euclidian space, say p : V → R2, satisfying the requested distances, i.e. for every edge (u, v), we must have p(u) − p(v) = d(u, v). This problem appears in the areas of graph drawing, localizing wireless sensors, and also in protein folding as we now explain. The protein folding problem consists of computing the spatial structure of a protein. To simplify the notations, we restrict the problem to the 2-dimensional space; this does not alter its essence. A protein is a huge molecule consisting of many different atoms linked together. Consider a simplified version of this problem where we only want to determine the structure of the backbone of the protein, that is, we are interested in determining the position of the main string of atoms. The exact sequence of atoms is known, and different approaches are being used in practice to determine their spatial structure. One possibility is to use Nano Magnetic Resonance (NMR) to determine the distances between some pairs of atoms. The goal is then to reconstruct a folding that matches the measured distances. This problem, also called 3-dimensional discretizable molecular distance geometry problem, is NP-hard (see [2]), and different algorithms have been proposed for it; we refer to [3] for a recent overview. Formally in the problem of reconstructing the backbone of a protein, we are given a vertex set V = {1, 2, . . . , m}, enumerating all the atoms of the backbone, together with distances d(i, j) for some pairs i, j ∈ V . It is a common assumption that all d(i, j) with i+1 ≤ j ≤ i+2 are given and d(i, i + 1) − d(i + 1, i + 2) < d(i, i + 2) < d(i, i + 1) + d(i + 1, i + 2) for all i = 1, . . . , m − 2. The first assumption is motivated by the fact that the NMR reveals distances between atoms which are close to each other. The second assumption is motivated by the chemical fact that in general atoms in molecules are not in co-linear positions. We call d(i, j) a short range distance if i + 1 ≤ j ≤ i + 2, and a long range distance otherwise. These assumptions give the problem a combinatorial structure. By translation invariance, without loss of generality we can place vertex 1 in the origin (0, 0). By rotation invariance, without loss of generality we can place vertex 2 in (d(1, 2), 0). Now for vertex 3 there are only two positions respecting the distance d(1, 3), which are the two intersection points of the circle of radius d(1, 3) centered at (0, 0), and the circle of radius d(2, 3) centered at 3 In a similar manner, there are exactly two possible positions of vertex i + 2 (d(1, 2), 0). relative to the segment between vertices i and i + 1. Therefore with fixed positions for vertices 1 and 2, there are exactly 2m−2 embeddings satisfying the short range distances. We could describe each embedding by a binary string x3, x4, . . . , xm, where bit xi is 1 if and only if the triangle formed by vertices i − 2, i − 1, i is oriented clockwise. But in order to circumvent the symmetry inherent to this problem, we describe each embedding by a binary string y3, y4, . . . , ym, where yj = x3 ⊕ x4 ⊕ . . . ⊕ xj. See Figure 1 for illustration. Figure 1: All 8 possible embeddings of a 5 vertex instance. The embedding described by the bit-string 000 is depicted with solid lines. Now every long range distance d(i, j) implies a constraint on the unknown binary string y. It enforces the bits yi+3, yi+4, . . . , yj to those positions that yield an embedding such that atoms i and j are at the right distance. The problem now is to find, as efficiently as possible, values for the bits satisfying all measured distance constraints. Let us now state some notation to arrive at a formal definition of the problem. Notation If a > b then [a, b] is the empty interval. For any a ≤ b by {0, 1}[a,b] we denote the set of all bit strings of length b − a + 1 indexed from a to b. If [a, b] ⊆ [c, d] and y ∈ {0, 1}[c,d] then we denote by y[a, b] the restriction of y to the indices from a to b. We use {0, 1}m as a shortcut notation for {0, 1}[1,m]. Definition 2. The BitString-Reconstruction Problem (BSRP): We are given an in- teger m, and n triplets (ai, bi, Ti) where 1 ≤ ai < bi ≤ m, Ti : {0, 1}[ai,bi] → {0, 1}. The function Ti is an oracle that returns 1 at a single element of the domain. The goal of the BSRP is to find a bit string y ∈ {0, 1}m, such that for all i = 1, . . . , n we have Ti(y[ai, bi]) = 1. The idea is that a triplet in BSRP corresponds to a given distance between atoms i and j with i + 3 ≤ j in the folding problem. Formally, a triplet is defined by (a = i, b = j, T ) where T is the boolean function, that accepts a bit string z if and only if z = y[a, b] for 4 1545345452454534554 every bit string y ∈ {0, 1}m describing an embedding where i and j are at the given distance d(i, j). At this point we assume that there is a unique bit string z with this property. In two dimensions, this is equivalent to fixing the position of the third vertex and in three dimensions this boils down to fixing the fourth vertex as well. Already with this strong simplification, we are facing a non-trivial and interesting algorithmic problem. A straightforward algorithm to solve BSRP employs a brute force approach (see [1] for a similar method called Branch-and-Prune algorithm): by letting ξ be a symbol representing an unspecified bit, the idea of brute-force search is to start with a completely unspecified string y = ξn ∈ {0, 1, ξ}n, and to refine it using the distances between atoms i and j with i − j > 3. More precisely: Algorithm 1 The BruteForce search algorithm Let w = y[ai, bi] and let (cid:96)i be the number of unspecified bits in w Search for z such that Ti[z] = 1, ranging over all 2(cid:96)i different replacements of ξ in w if found then 1: for i = 1, . . . , n do 2: 3: 4: 5: 6: 7: end if 8: 9: end for 10: Return y, replacing all remaining occurrences of ξ by an arbitrary bit exit and announce that there is no solution replace, in y, y[ai, bi] by z else The running time of the BruteForce search algorithm is O(cid:0)(cid:80)n i=1 2(cid:96)i(cid:1) and it depends on the order in which the triplets in the instance are presented to the algorithm. The only remaining question is in which order to process the given distances. In fact, it is our goal to find an order for the triplets in the instance of the BSRP to be passed to the BruteForce search algorithm in order to minimize the running time. This leads to the interval ordering problem that was described in the introduction with the following additional structure: (i) all data are integral, and (ii) the cost function f is given by f (x) = 2x. We should point out here that the protein folding application does not necessarily give rise to instances that display the special structures that we will discuss in Section 3: agreeable intervals, and laminar intervals. 3 Some polynomial time solvable cases In this section, we study some special cases of the interval ordering problem that can be solved in polynomial time. We first consider the case where the intervals are agreeable. We derive an O(n3) dynamic programming algorithm for solving this special case for any cost function f . When the cost function is continuous and convex, we propose a dynamic programming algorithm with time complexity O(n2). Next, we consider the case where the intervals are laminar and describe polynomial-time algorithms for solving the problem when the cost function f is such that the function g(x) = f (x) − f (0) is either super-additive or sub-additive. Finally, we study the bottleneck variant of the interval ordering problem 5 and show that it can be solved in polynomial time when the cost function f is either non- decreasing or non-increasing. 3.1 Agreeable intervals We say that a set I of n intervals Ii = [ai, bi), for i = 1, 2, . . . , n is agreeable if there exists a permutation γ of {1, . . . , n} such that aγ(1) ≤ . . . ≤ aγ(n) and bγ(1) ≤ . . . ≤ bγ(n). In other words, the ordering of the intervals induced by the left endpoints is the same as the ordering induced by the right endpoints. For ease of exposition, we will assume in the rest of this section that γ is the permutation identity: thus we have a1 ≤ . . . ≤ an and b1 ≤ . . . ≤ bn. We can assume that two consecutive intervals Ii and Ii+1 overlap (that is ai+1 < bi) because otherwise this would split the problem into two sub-problems that can be solved independently. In what follows, we first consider the general case with an arbitrary cost function f , followed by a special case where the cost function f is continuous and convex. 3.1.1 Arbitrary cost function In this section, we consider instances(cid:0)I, f(cid:1) of the interval ordering problem with I agree- able and f arbitrary. Observe that in the case of agreeable intervals, after selecting the first interval, the problem decomposes into (at most) two unrelated instances that are each agreeable; we will use this property to derive a dynamic programming algorithm. For a formal definition of the decomposition, consider the set I = {I1, Ii+1 . . . , In} of agreeable intervals. We consider the exposed parts of each of these intervals with respect to {Ij}, 1 ≤ j ≤ n. Since I is agreeable, the exposed parts are again intervals, and we distinguish between those before Ij and those after Ij. Ii Ii+1 Ii+2 Ik Ik−1 Figure 2: The subinstance Ii,k. For convenience define b0 = a1 and an+1 = bn. For any pair of indices 0 ≤ i, k ≤ n + 1 we define the subinstance Ii,k := {Ij ∩ [bi, ak) : i < j < k}. Notice that if bi ≥ ak, then Ii,k consists of k − i − 1 intervals of zero length. Let C(i, k) be the cost of an optimum solution to(cid:0)Ii,k, f(cid:1), with C(i, k) = 0 if Ii,k = ∅. We have the following recursion. 6 Lemma 1. For 0 ≤ i < k ≤ n + 1 we have C(i, k) = 0 in case i + 1 = k, and otherwise C(i, k) = min i<j<k {C(i, j) + f (Ij ∩ [bi, ak)) + C(j, k)} . Proof: The case i + 1 = k follows from Ii,i+1 = {} and the remaining case follows from the fact that (1) some interval Ij has to be selected first, and (2) after selecting that interval the problem decomposes into two unrelated instances, Ii,j and Ij,k, each being agreeable. (cid:3) Theorem 1. The interval ordering problem(cid:0)I, f(cid:1) with I agreeable and f arbitrary, can be solved in O(n3). Proof: Lemma 1 leads to a dynamic programming algorithm with O(n2) variables, each (cid:3) computable in linear time. 3.1.2 Continuous and convex cost function In this subsection, we still assume that the intervals in I are agreeable, but we consider the cost function f to be continuous and convex. Recall that a function f defined on a convex set dom(f ) is convex when f (λx + (1 − λ)y) ≤ λf (x) + (1 − λ)f (y) for all x, y ∈ dom(f ), and 0 ≤ λ ≤ 1. We need the following result, due to Karamata [5] (see also pages 30 -- 32 in Beckenbach and Bellman [6]). Lemma 2. Given 2q + 2 numbers {xk, yk}, k = 0, 1, . . . , q satisfying: • x0 ≥ x1 ≥ . . . ≥ xq, and y0 ≥ y1 ≥ . . . ≥ yq, • for each k = 0, 1, . . . , q − 1: (cid:80)k i=0 xi =(cid:80)q • (cid:80)q i=0 yi, i=0 yi, and then, for any continuous, convex function f we have: i=0 xi ≥(cid:80)k f (xi) ≥ q(cid:88) q(cid:88) i=0 i=0 (1) f (yi). contains n intervals Ii = [ai, bi), i = 1, . . . , n and f is continuous and convex. For a given Let (cid:0)I, f(cid:1) be an instance of the interval ordering problem where I is agreeable and solution to(cid:0)I, f(cid:1) (i.e., a sequence of intervals), we call an interval Ii an E-interval if ai is (cid:0)Ik, f(cid:1). Notice that this definition implies that I = I1. Further, interval Ik is an E-interval in any feasible solution to(cid:0)Ik, f(cid:1). Lemma 3. Let(cid:0)I, f(cid:1) be an instance of the interval ordering problem with I agreeable and If, in an optimal solution to(cid:0)Ik, f(cid:1), interval Ik is the only E-interval, then contained in the exposed part of interval Ii relative to the set of intervals sequenced before Ii (in that solution). Given an integer k, 1 ≤ k ≤ n, let Ik be the set containing the intervals Ii = [ai, bi) for i = k, . . . , n and let Ck be the value of an optimal solution to the instance f continuous and convex; and let Ik defined as above. Ck = f(cid:0)bk − ak (cid:1) + n(cid:88) f(cid:0)bi − bi−1 (cid:1). (2) i=k+1 7 Otherwise, in this optimal solution to(cid:0)Ik, f(cid:1), let Ij with j > k be the first E-interval, i.e., the E-interval with minimal aj. If aj ≤ bk then j = k + 1 and If aj > bk, then Ck = f(cid:0)bk − ak (cid:96)(cid:88) (cid:1) + Ck = f(cid:0)ak+1 − ak f(cid:0)bi − bi−1 (cid:1) + Ck+1. (cid:1) + f(cid:0)aj − b(cid:96) (cid:1) +(cid:0)j − (cid:96) − 1(cid:1)f (0) + Cj, (3) (4) i=k+1 where I(cid:96) is the latest interval in Ik that satisfies b(cid:96) < aj. Proof: We will show that if interval Ik is the only E-interval, then the optimal sequence to (cid:0)Ik, f(cid:1) is simply (k, k + 1, . . . , n). Otherwise, if there is another E-interval Ij, where Ij is the first E-interval with j > k, then the optimal sequence to(cid:0)Ik, f(cid:1) is the sequence of the solution to(cid:0)Ij, f(cid:1) followed by k, k + 1, . . . , j − 1. See Figure 3 for illustration. Ik Ik+1 Ij I(cid:96) Ij−1 Ij+1 In Figure 3: Recurrence relation of Ck. divides into the cost of the intervals between k and j, plus Cj If Ij is the first E-interval after Ik, then the cost optimal sequence to (cid:0)Ik, f(cid:1). The sequence α0 partitions [ak, bn) into n − k + 1 nonempty Case 1: Interval Ik is the only E-interval. We show that α0 = (k, k + 1, . . . , n) is an segments, defined by S0 = [ak, bk), Si = [bk+i−1, bk+i) for i = 1, . . . , n − k (this is true since the intervals are agreeable). Let σ be a permutation of {0, 1, . . . , n − k} such that Sσ(i) ≥ Sσ(i+1) for i = 0, 1, . . . , n − k − 1; the permutation σ orders the segments induced by α0 in non-increasing length. Now, let α be some sequence of intervals (α (cid:54)= α0) which does not feature another E-interval apart from interval Ik. Clearly, α partitions [ak, bn) into less than n − k + 1 nonempty segments, each segment being defined by a pair from the set {ak, bk, bk+1, . . . , bn} (indeed, notice that the only way to have n − k + 1 segments is when α = α0). Let us suppose that α partitions [ak, bn) into p + 1 segments (1 ≤ p ≤ n − k − 1) S(cid:48) 0, . . . , S(cid:48) p. For convenience set S(cid:48) p satisfying S(cid:48) 0 ≥ S(cid:48) 1 ≥ . . . ≥ S(cid:48) p+1 = . . . = S(cid:48) m = {}. 8 Observation: Any segment S(cid:48) given j ∈ {0, 1, . . . , n − k} or is a union of consecutive intervals Sj. This observation follows from the fact that the segments are defined by points in the set {ak bk, bk+1, . . . , bn}. We will use this observation to argue that for each m = 0, 1, . . . , n − k + 1: i (i = 0, 1, . . . , p) is either identical to a segment Sj for a m(cid:88) i ≥ m(cid:88) For any m with p ≤ m ≤ n − k, we have that (cid:80)m step, we assume that(cid:80)m i = [ak, bn) and ∪m S(cid:48) i=0 i=0 i=0 S(cid:48) ∪m i=0S(cid:48) We now show that (5) is also true for m < p, by induction on m. For the base case, note 0 ≥ Sσ(0). For the induction that the the observation above immediately implies that S(cid:48) i=0Sσ(i) ⊆ [ak, bn) and the segments are disjoint. i ≥(cid:80)m i=0 Sσ(i). The question now is whether m+1(cid:88) i ≥ m+1(cid:88) Sσ(i) S(cid:48) Sσ(i). i=0 S(cid:48) i ≥ (cid:80)m (5) i=0 Sσ(i). This is because (6) side of (6), then, using the induction hypothesis (cid:0)(cid:80)m is true. Let us consider Sσ(m+1). i=0 i=0 If each Sσ(r) with r ≤ m is contained in the left-hand i ≥(cid:80)m i=0 Sσ(i)(cid:1), the validity of i=0 S(cid:48) (6) follows. Indeed, if Sσ(m+1) is also contained in the left-hand side of (6), the inequality m+1 ≥ Sσ(m+1). If there exists an Sσ(r) with r ≤ m is certainly valid, else we know that S(cid:48) m+1 ≥ Sσ(r) ≥ Sσ(m+1) (where the first not contained in the left-hand side of (6), then: S(cid:48) inequality holds because the length of a segment Sσ(j) not contained in the left-hand side of (6) is a lower bound for S(cid:48) We now invoke Lemma 2 by setting q := n − k + 1, and for i = 0, 1, . . . , n − k + 1 we i, yi := Si. Clearly, the arguments given above imply that the conditions of set xi := S(cid:48) Lemma 2 are satisfied. Hence, when f is continuous and convex, the cost of α is greater than or equal to the cost of α0. j). This completes the proof of (5). Case 2: There is another E-interval Ij, where Ij is the first E-interval after Ik. For this case, we use the following observation. Let Ip and Iq be two consecutive intervals in a solution, and suppose that they are disjoint. Then it does not matter for the cost of the solution whether Ip or Iq is processed first of the two. Now since Ij is an E-interval, it must be processed before all intervals Ii that contain aj (otherwise Ij is not an E-interval), and it can be processed before all intervals Ii with bi < aj. Thus, we conclude that Ij is processed before intervals indexed by k, k +1, . . . , j−1. Since the intervals are agreeable, the exposed parts (after processing Ij) of the intervals before Ij are disjoint with the intervals with index greater than j. Therefore we can assume that the intervals with index k, . . . , j−1 are processed after the intervals with index j, . . . , n. And of course, the latter intervals are processed optimally by a sequence of the solution to (cid:0)Ij, f(cid:1). Let I(cid:96) with (cid:96) < j be the optimal sequence has a cost of f (bk − ak) +(cid:80)(cid:96) latest interval that does not intersect interval Ij. Notice that by the choice of j, the optimal sequence of the intervals Ik,. . . ,I(cid:96) contains only one E-interval, namely Ik. Hence, that i=k+1 f (bi − bi−1). Finally, we need to take into account the intervals I(cid:96)+1, . . . , Ij−1. Thus, we incur f (aj − b(cid:96)) for the exposed part between b(cid:96) and aj, corresponding to interval I(cid:96)+1, and we incur a cost of f (0) for each of the 9 remaining intervals. Notice that all intervals I(cid:96)+1, . . . , Ij−1 are completely covered in this (cid:3) sequence. This completes the proof of this lemma. Theorem 2. The interval ordering problem(cid:0)I, f(cid:1) with I agreeable and f convex and con- tinuous, can be solved in O(n2). Proof: The O(n2)-time complexity of the dynamic program following from Lemma 3 (see equations (2) and (3)) is explained by the fact that there are n variables and each is a (cid:3) minimization over O(n) values. 3.2 Laminar intervals Let (cid:0)I, f(cid:1) be an instance of the interval ordering problem where I contains n intervals Ii = [ai, bi), for i = 1, 2, . . . , n. We say that the set I of intervals is laminar if for any two intervals Ii and Ij in I, either Ii ∩ Ij = ∅ or one is included in the other. See Figure 4 for an illustration. Figure 4: Illustration of laminar intervals have that i appears before j in α. An ordering α respects the inclusions if for any two intervals Ii and Ij with Ii (cid:40) Ij we Lemma 4. Let(cid:0)I, f(cid:1) be an instance of the interval ordering problem with I laminar. If the any ordering that respects the inclusions is an optimal solution to(cid:0)I, f(cid:1). function g defined by g(x) = f (x) − f (0) is super-additive i.e., g(x + y) ≥ g(x) + g(y) then Proof: Let α be an arbitrary order of optimal cost. We will show that there is another order respecting the inclusions and having a cost not greater than that of α. Suppose that α does not respect the inclusions. Then there is a pair i, j with Ii (cid:40) Ij and j appears before i in α. Let α(cid:48) be the result of placing j right after i in the order α. Let x be the length of the exposed part of Ij in α(cid:48), and y be the length of the exposed part of Ii in α(cid:48). Then x + y is the length of the exposed part of Ij in α. Therefore the contribution of Ii and Ij to the cost of α is f (x + y) + f (0) while their contribution to the cost of α(cid:48) is f (x) + f (y). Since g is super-additive, it follows that f (x + y) + f (0) ≥ f (x) + f (y). We conclude that the cost of α(cid:48) is not more than the cost of α. By repeating the argument, we eventually (cid:3) obtain an inclusion respecting order with optimal cost. An inclusion respecting order can be found simply by sorting the intervals in increasing order of their lengths, breaking ties arbitrarily. 10 Theorem 3. The interval ordering problem(cid:0)I, f(cid:1) with I laminar and f such that the func- tion g(x) = f (x) − f (0) is super-additive, can be solved in O(n log n) time Proof: Immediate. (cid:3) We show in Section 4 that the time complexity of any exact algorithm for solving this problem cannot be better than the time complexity of algorithms for sorting. Thus, when restricting ourselves to comparison-based algorithms, the bound in Theorem 3 is the best possible (see [7]). Remark 4. Notice that the problem (cid:0)I, f(cid:1) with I laminar and f such that the function g(x) = f (x) − f (0) is sub-additive, can also be solved in O(n log n) time by sorting the intervals in decreasing order of their lengths. 3.3 Bottleneck variant of the interval ordering problem O(cid:0)(cid:80)n In this subsection, we consider the bottleneck variant of the interval ordering problem. Re- ferring to the application described in Section 2, instead of looking for the exact complexity i=1 2(cid:96)i(cid:1) of the BruteForce search algorithm, we focus on the maximum power of two that dominates this complexity. Hence, solving the bottleneck variant gives us a solution that is an approximation of the optimal solution to the interval ordering problem. The bottleneck variant is explicitly defined as follows. Definition 3. The Bottleneck Interval Ordering Problem (BIO): Given a function f and a set I = {I1, . . . , In} of intervals over the real line, find an ordering α ∈ Σn that minimizes the value f(cid:0)Iα(k) \(cid:91) k−1 j=1 Iα(j)(cid:1). max k=1,...,n A greedy algorithm for this variant would iteratively select the interval with the smallest exposed part. A formal description is given in Algorithm 2. In the rest of this section we i := Ii be the exposed part of the i-th interval Algorithm 2 Smallest Exposed Part Algorithm 1: for every i = 1, . . . , n, let I(cid:48) 2: Let S = {1, . . . , n} be the set of yet unselected intervals 3: for j = 1, . . . , n do 4: 5: 6: 7: 8: 9: 10: end for 11: Return α Identify i ∈ S such that I(cid:48) α(j) := i S := S\{i} for k ∈ S do update I(cid:48) i is minimal. k := I(cid:48) end for k\I(cid:48) i prove that Algorithm 2 solves instances of BIO when the cost function f is non-decreasing. Our proof is based on the following lemmas. 11 first smallest interval in α, i.e., Iα(i0) ≤ Iα(j) for all j ∈ {1, . . . , n} and Iα(i0) < Iα(j) for Lemma 5. Let(cid:0)I, f(cid:1) be an instance of BIO with a non-decreasing cost-function f . There exists an optimal solution to(cid:0)I, f(cid:1) starting with a smallest interval. Proof: We prove this result by contradiction. Let(cid:0)I, f(cid:1) be an instance of BIO with a non- decreasing cost-function f . Assume that each optimal sequence to(cid:0)I, f(cid:1) does not start with a smallest interval. Consider an optimal sequence α =(cid:0)α(1), . . . , α(i0), . . . , α(n)(cid:1) to(cid:0)I, f(cid:1) with the corresponding optimal value val(α). Clearly, val(α) ≥ f(cid:0)Iα(1)(cid:1). Let Iα(i0) be the all j ∈ {1, . . . , i0 − 1}. Consider now the sequence α(cid:48) = (cid:0)α(i0), α(1), . . . , . . . , α(n)(cid:1) where sequence to(cid:0)I, f(cid:1), which is a contradiction. Given an arbitrary instance(cid:0)I, f(cid:1) of BIO with n intervals and Ii0 ∈ I a smallest interval, we define the Ii0-reduced instance(cid:0)¯Ii0, f(cid:1) with n − 1 intervals as follows. For any interval α(i0) is move to the first position in α. It is clear that this move only affects the intervals that were sequenced before Iα(i0) in α. Further, since f is non-decreasing, and the length of each affected interval cannot have become larger, and Iα(i0) ≤ Iα(1), we conclude that the objective value achieved by α(cid:48) does not exceed val(α). Therefore, α(cid:48) is also an optimal (cid:3) Ij ∈ I, 1. if Ij (cid:54)= Ii0 and Ij ∩ Ii0 = ∅ then Ij ∈ ¯Ii0; 2. if Ij (cid:54)= Ii0 and Ij ∩ Ii0 (cid:54)= ∅ then Ij \ Ii0 ∈ ¯Ii0. Furthermore, the real line is adapted accordingly such that Ij \Ii0 is an interval for all j (cid:54)= i0. Lemma 6. Let (cid:0)I, f(cid:1) be an instance of BIO with a non-decreasing cost-function f . Let Ii0 ∈ I be a smallest interval and αi0 be an optimal sequence to (cid:0)¯Ii0, f(cid:1). Then (cid:0)i0, αi0 (cid:1) is an optimal sequence to(cid:0)I, f(cid:1). Proof: Let val(αi0) be the total cost of the optimal solution αi0 to(cid:0)¯Ii0, f(cid:1). (cid:1) is clearly an optimal sequence to(cid:0)I, f(cid:1) (recall that 1. If f(cid:0)Ii0(cid:1) ≥ val(αi0) then(cid:0)i0, αi0 2. On the other hand, suppose that f(cid:0)Ii0(cid:1) < val(αi0). Lemma 5 implies that there exists an optimal sequence α(cid:48) to(cid:0)I, f(cid:1) starting with Ii0. After selecting Ii0, the instance that remains is(cid:0)¯Ii0, f(cid:1), for which αi0 is optimal. Therefore, (i0, αi0) is an optimal solution to(cid:0)I, f(cid:1). Theorem 5. The Bottleneck Interval Ordering problem(cid:0)I, f(cid:1) with I arbitrary and f non- Ii0 is a smallest interval). (cid:3) decreasing can be solved in O(n2). Proof: This result follows from Lemma 5 and Lemma 6. (cid:3) Remark 6. Notice that if the function f is non-increasing then the instances of BIO with this cost function can be solved with an O(n2)-time algorithm similar to Algorithm 2 where in line 6 instead of taking the interval with the smallest exposed part, we take the interval with the longest exposed part. 12 4 Complexity results This section presents a number of negative results on the computational complexity of the interval ordering problem. Our first result shows that even the easy special cases discussed in Section 3.1 are not completely straightforward, and shows the optimality of the algorithm given in Section 3.2. Theorem 7. The interval ordering problem is at least as hard as the SORTING problem, even if (a) the intervals are agreeable, or if (b) the intervals form a laminar set. Conse- quently, every comparison-based algorithm for these special cases will have a time complexity Ω(n ln n). Proof: Let x1, . . . , xn be an arbitrary sequence of positive real numbers that form an in- stance of the SORTING problem. We construct a corresponding instance of the interval ordering problem that consists of the intervals Ij = [0, xj) for j = 1, . . . , n, together with the cost function f (x) = 2x. Note that this set of intervals is agreeable and laminar. Note that the cost function f (x) is such that g(x) = f (x) − f (0) is super-additive on the positive real numbers. This observation easily yields that the optimal ordering of the intervals must sequence them by increasing right endpoint, and hence induces a solution to (cid:3) the SORTING problem. Next, we will discuss the computational complexity of the interval ordering problem. We will show that there is little hope for finding a polynomial-time algorithm for solving the interval ordering problem in general. The reduction is from the following variant of the NP-hard PARTITION problem [8, problem SP12]. Instance: A finite set {q1, q2, . . . , qn} of n positive integers with sum 2Q; an integer k. Question: Does there exists an index set J ⊆ {1, . . . , n} with J = k, such that(cid:80) (cid:80) 2nQ + k. Then there exists an instance (cid:0)I, f(cid:1) of the interval ordering problem that can be Lemma 7. Let I be an instance of PARTITION and N be an integer such that 2N−1 > j /∈J qj = Q? j∈J qj = built from I in polynomial time and that satisfies the following conditions: (i) If I is a YES-instance of PARTITION, then the total cost of an optimal sequence to (cid:0)I, f(cid:1) is at most 2nQ + n − k. (cid:0)I, f(cid:1) is at least 2N + 2nQ + n − k. (ii) If I is a NO-instance of PARTITION, then the total cost of an optimal sequence to Proof: Consider an arbitrary instance I of PARTITION. We build the instance (cid:0)I, f(cid:1) of interval from 0 to L :=(cid:80)n the interval ordering problem as follows. The cost function f : N → N is defined by f (x) = 0 if x is a power of two, and by f (x) = x otherwise. The set I consists of n + 2 intervals. First, for i = 1, . . . , n there is a so-called element-interval of length (cid:96)i = 2nqi + 1. These element-intervals are pairwise disjoint and put back to back, so that they jointly cover the i=1 (cid:96)i = 2n+1Q + n. Secondly, there is a so-called dummy-interval 13 of length (cid:96)n+1 = 2N − 2nQ − k that goes from L to L + (cid:96)n+1. Thirdly, there is the so-called main-interval that covers all other intervals, and that goes from 0 to L + (cid:96)n+1; hence the length of the main-interval is 2N + 2nQ + n − k. Clearly, this construction of(cid:0)I, f(cid:1) can be done in polynomial time. Next, we prove (i) and (ii). (i) Assume that I is a YES-instance of PARTITION, and let J ⊆ {1, . . . , n} be the corresponding index set. First select the element-intervals that correspond to the qi with i /∈ J, then the main-interval, followed by the remaining element-intervals, and finally the dummy-interval. For the first batch of element-intervals we pay a cost of 2nQ + n − k. The exposed part of the main-interval then has length 2N , which yields a cost of 0. This reduces the exposed part of all remaining intervals down to length 0. The overall total cost is then 2nQ + n − k. (ii) Now assume that I is a NO-instance of PARTITION. We claim that in this case no sequencing can ever turn the length of the exposed part of the main-interval into a power of 2. Then the total cost is proportional to the total length, and hence at least 2N + 2nQ + n − k. It remains to prove the claim. We distinguish two cases. The first case deals with the time before the dummy-interval is sequenced. At such a point in time the length of the exposed part of the main-interval equals the length of the dummy-interval plus the length of the currently unsequenced element-intervals. The length of the dummy-interval is 2N − 2nQ − k > 2N−1. The length of the dummy interval plus the length of all element- intervals is 2N + 2nQ + n − k < 2N +1. Hence the only candidate power of 2 would be 2N . But in this case the subset of the element-intervals would have a total length of 2nQ + n− k, which would correspond to a solution to the PARTITION instance I; a contradiction. The second case deals with the time after the dummy-interval has been sequenced. At such a point in time the length of the exposed part of the main-interval equals the length of the remaining unsequenced element-intervals. But the total length of such a subset can never (cid:3) be a power of 2. Of course, Lemma 7 immediately yields the NP-hardness of the interval ordering problem. We will also derive from it the inapproximability of this problem. Suppose for the sake of contradiction that there is a polynomial-time approximation algorithm with some finite worst-case guarantee θ. Pick an arbitrary instance I of PARTITION, and choose an integer N sufficiently large so that 2N > (cid:0)θ − 1(cid:1)(cid:0)2nQ + n − k(cid:1). (7) of instance I. We construct the instance(cid:0)I, f(cid:1) of the interval ordering problem as indicated Then N is roughly n + log Q + log θ, and hence its length is polynomially bounded in the size in the proof of Lemma 7, and feed it into the approximation algorithm. The answer allows us to decide in polynomial time whether instance I is a YES-instance or a NO-instance of PARTITION. Theorem 8. The interval ordering problem is NP-hard. Furthermore, the interval ordering problem does not possess any polynomial-time approximation algorithm with constant worst- case guarantee, unless P = N P . 14 5 Conclusion This paper studies the problem of ordering a given set of intervals on the real line to minimize the total cost, where the cost incurred for an interval depends on the length of its exposed part when it is processed. We were motivated to consider this problem by an application in molecular biology. Our work proposes polynomial-time algorithms for some special cases of the problem. Furthermore, we prove that the problem is NP-hard and is unlikely to have a constant-factor-approximation algorithm. Some interesting special cases of our problem remain open. For instance, when the cost function is continuous and convex, (and without any assumption on the structure of the intervals), the complexity of the problem is not settled. In particular, the case f (x) = 2x is interesting (note that our NP-hardness construction does not yield anything for this particular cost function). Finally, it would be interesting to see other special cases that can be solved in polynomial time. Acknowledgements We thank an anonymous reviewer, as well as Leo Liberti, for comments on an earlier version of this manuscript. Gerhard Woeginger has been supported by the Netherlands Organization for Scientific Research (NWO), grant 639.033.403, by DIAMANT (an NWO mathematics cluster), and by BSIK grant 03018 (BRICKS: Basic Research in Informatics for Creating the Knowledge Society). Maurice Queyranne's research was supported in part by a Discovery grant from the Natural Sciences Research Council (NSERC) of Canada. References [1] A. Mucherino, C. Lavor, and L. Liberti. The discretizable distance geometry problem. Optimization letters, Online first article, 17 June, 2011. [2] C. Lavor, L. Liberti, N. Maculan, and A. Mucherino. The discretizable molecular distance geometry problem. Computational Optimization and Applications, doi 10.1007/s10589- 011-9402-6, 2011. [3] C. Lavor, L. Liberti, N. Maculan, and A. Mucherino. Recent advances on the discretizable molecular distance geometry problem. European Jorunal of Operational Research, doi 10.1016/j.ejor.2011.11.007, 2011. [4] C. Lavor, J. Lee, A. Lee-St. John L. Liberti, A. Mucherino, and M. Sviridenko. Dicretiza- tion orders for distance geometry problems. Optimization letters, doi 10.1007/s11590- 011-0302-6, 2011. [5] J. Karamata. Sur une in´egalit´e relative aux fonctions convex. Publ. Math. Univ. Belgrade, 1:145 -- 148, 1932. 15 [6] E. F. Beckenbach and R. Bellman. Inequalities. Springer-Verlag, 3rd printing, 1971. [7] T.H. Cormen, C.E. Leiserson, R.L. Rivest, and C. Stein. Introduction to Algorithms. McGraw-Hill, 2nd edition, 2002. [8] M.R. Garey and D.S. Johnson. Computers and intractability: A guide to the theory of NP-completeness. W.H. Freeman and Co., 1979. 16
1511.07529
3
1511
2017-11-03T21:13:59
Calculating the Unrooted Subtree Prune-and-Regraft Distance
[ "cs.DS", "q-bio.PE" ]
The subtree prune-and-regraft (SPR) distance metric is a fundamental way of comparing evolutionary trees. It has wide-ranging applications, such as to study lateral genetic transfer, viral recombination, and Markov chain Monte Carlo phylogenetic inference. Although the rooted version of SPR distance can be computed relatively efficiently between rooted trees using fixed-parameter-tractable maximum agreement forest (MAF) algorithms, no MAF formulation is known for the unrooted case. Correspondingly, previous algorithms are unable to compute unrooted SPR distances larger than 7. In this paper, we substantially advance understanding of and computational algorithms for the unrooted SPR distance. First we identify four properties of optimal SPR paths, each of which suggests that no MAF formulation exists in the unrooted case. Then we introduce the replug distance, a new lower bound on the unrooted SPR distance that is amenable to MAF methods, and give an efficient fixed-parameter algorithm for calculating it. Finally, we develop a "progressive A*" search algorithm using multiple heuristics, including the TBR and replug distances, to exactly compute the unrooted SPR distance. Our algorithm is nearly two orders of magnitude faster than previous methods on small trees, and allows computation of unrooted SPR distances as large as 14 on trees with 50 leaves.
cs.DS
cs
Calculating the Unrooted Subtree Prune-and-Regraft Distance Chris Whidden and Frederick A. Matsen IV 1 7 1 0 2 v o N 3 ] S D . s c [ 3 v 9 2 5 7 0 . 1 1 5 1 : v i X r a Abstract-The subtree prune-and-regraft (SPR) distance metric is a fundamental way of comparing evolutionary trees. It has wide-ranging applications, such as to study lateral genetic transfer, viral recombination, and Markov chain Monte Carlo phylogenetic inference. Although the rooted version of SPR distance can be computed relatively efficiently between rooted trees using fixed-parameter-tractable maximum agreement forest (MAF) algorithms, no MAF formulation is known for the unrooted case. Correspondingly, previous algorithms are unable to compute unrooted SPR distances larger than 7. In this paper, we substantially advance understanding of and computational algorithms for the unrooted SPR distance. First we identify four properties of optimal SPR paths, each of which suggests that no MAF formulation exists in the unrooted case. Then we introduce the replug distance, a new lower bound on the unrooted SPR distance that is amenable to MAF methods, and give an efficient fixed-parameter algorithm for calculating it. Finally, we develop a "progressive A*" search algorithm using multiple heuristics, including the TBR and replug distances, to exactly compute the unrooted SPR distance. Our algorithm is nearly two orders of magnitude faster than previous methods on small trees, and allows computation of unrooted SPR distances as large as 14 on trees with 50 leaves. Index Terms-fixed-parameter tractability, phylogenetics, subtree prune-and-regraft distance, lateral gene transfer, agreement forest. ✦ 1 INTRODUCTION M OLECULAR phylogenetic methods reconstruct evolu- tionary trees (a.k.a phylogenies) from DNA or RNA data and are of fundamental importance to modern bi- ology [1]. Phylogenetic inference has numerous applica- tions including investigating organismal relationships (the "tree of life" [2]), reconstructing virus evolution away from innate and adaptive immune defenses [3], analyzing the immune system response to HIV [4], designing genetically- informed conservation measures [5], and investigating the human microbiome [6]. Although the molecular evolution assumptions may differ for these different settings, the core algorithmic challenges remain the same: reconstruct a tree graph representing the evolutionary history of a collection of evolving units, which are abstracted as a collection of taxa, where each taxon is associated with a DNA, RNA, or amino acid sequence. Phylogenetic study often requires an efficient means of comparing phylogenies in a meaningful way. For example, different inference methods may construct different phylo- genies and it is necessary to determine to what extent they differ and, perhaps more importantly, which specific fea- tures differ between the trees. In addition, the evolutionary history of individual genes does not necessarily follow the overall history of a species due to reticulate evolutionary processes: lateral genetic transfer, recombination, hybridiza- tion, and incomplete lineage sorting [7]. Such processes impact phylogenies by moving a subtree from one location to another, as described below. Thus comparing inferred his- tories of genes to each other, a reference tree, or a proposed species tree may be used to identify reticulate events [8], [9]. Moreover, distance measures between phylogenies provide • C. Whidden and F. Matsen are with the Program in Computational Biology, Fred Hutchinson Cancer Research Center, Seattle, WA, 98109. E-mail: {cwhidden,matsen}@fredhutch.org optimization criteria that can be used to infer summary measures such as supertrees [10], [11], [12], [9]. Numerous distance measures have been proposed for comparing phylogenies. The Robinson-Foulds distance [13] is perhaps the most well known and can be calculated in linear time [14]. However, the Robinson-Foulds distance has no meaningful biological interpretation or relationship to reticulate evolution. Typically, distance metrics are either easy to compute but share this lack of biological relation, such as the quartet distance [15] and geodesic distance [16], or are difficult to compute, such as the hybridization num- ber [17] and maximum parsimony distance [18], [19], [20]. The subtree prune-and-regraft (SPR) distance is widely used due to its biological interpretability despite being difficult to compute [17], [21]. SPR distance is the minimum number of subtree moves required to transform one tree into the other (Figure 1(d)). It provides a lower bound on the number of reticulation events required to reconcile two phylogenies. As such, it has been used to model reticulate evolution [22], [23]. In addition, the SPR distance is a natural measure of distance when analyzing phylogenetic infer- ence methods which typically apply SPR operations to find maximum likelihood trees [24], [25] or estimate Bayesian posterior distributions with SPR-based Metropolis-Hastings random walks [26], [27]. Similar trees can be easily identified using the SPR distance, as random pairs of n-leaf trees differ by by an expected n − Θ(n2/3) SPR moves [28]. This difference approaches the maximum SPR distance of n− 3−(cid:4)(√n − 2 − 1)/2(cid:5) asymptotically [29]. The topology- based SPR distance is especially appropriate in this context as topology changes have been identified as the main lim- iting factor of such methods [30], [31], [32]. Moreover, the SPR distance has close connections to network models of evolution [17], [33], [23]. Although it has these advantages, the SPR distance be- tween both rooted and unrooted trees is NP-hard to com- pute [34], [35], limiting its utility. We recall that rooted trees represent the usual view of evolution, such that the taxa under consideration evolve from a common ancestor in a known direction. Unrooted trees drop this implied direction- ality, and are typically drawn as a graph theoretic tree such that every non-leaf node has degree three (Figure 1(a)). As described below, most phylogenetic algorithms reconstruct unrooted trees. Despite the NP-hardness of computing the SPR distance between rooted phylogenies, recent algorithms can rapidly compare rooted trees with hundreds of leaves and SPR distances of 50 or more in fractions of a second [36], [9]. This has enabled use of the SPR distance for inferring phyloge- netic supertrees and lateral genetic transfer [9], comparing influenza phylogenies to assess reassortment [37], and in- vestigating mixing of Bayesian phylogenetic posteriors [32], [38]. However, most phylogenetic inference packages today use reversible mutation models to infer unrooted trees, motivating SPR calculation for unrooted trees. SPR distances can be computed efficiently in practice for rooted trees for two key reasons. First, they can be computed using a maximum agreement forest (MAF) of the trees [39], [40]. An MAF is a forest (i.e. collection of trees) that can be obtained from both trees by removing a minimum set of edges. Each removed edge corresponds to one SPR operation, and a set of SPR operations transforming one tree into the other can be easily recovered given an MAF. Due to this MAF framework, the development of efficient fixed-parameter and approximation algorithms for SPR distances between rooted trees has become an area of active research [21], [41], [42], [43], [44], [45] (see [43] for a more complete history), including recent extensions to nonbinary trees [46], [47], as well as generalized MAFs of multiple trees [48]. The utility of MAFs motivates defining a variant definition in the unrooted case with analogous properties for unrooted SPR, however, no alternative MAF formulation has yet been developed. A straightforward ex- tension of MAFs to unrooted trees is equivalent to a different metric, the TBR distance [40]. Although TBR rearrange- ments are used in some phylogenetic inference methods, SPR rearrangements are much more common [30] and the TBR distance does not have the other benefits of the SPR distance. The second class of optimizations used by efficient rooted SPR algorithms are preprocessing reduction rules including the subtree reduction rule [40], chain reduction rule [40], and cluster reduction rule [49]. The subtree reduc- tion rule also applies to unrooted trees [40] and we recently showed that the chain reduction rule is applicable to the unrooted case [50], thereby obtaining a linear-size problem kernel for unrooted SPR. However, minimum-length uSPR paths have been shown to break common clusters [35], so the cluster reduction, which partitions the trees into smaller independently solvable subproblems, is not applicable. For all of these reasons, the best previous algorithm for computing the SPR distance between unrooted trees, due to Hickey et al. [35], cannot compute distances larger than 7 or reliably compare trees with more than 30 leaves. In this paper, we substantially advance understanding of and 21 21 21 21 21 3 4 21 3 4 ′ v v u 3 4 4 3 6 5 (a) 5 (b) 5 (c) 6 5 6 5 (d) 2 6 5 Fig. 1. (a) An unrooted X-tree T . (b) T (V ), where V = {1, 2, 5}. (c) TV . (d) An SPR operation transforms T into a new tree by pruning a subtree and regrafting it in an other location. computational algorithms for the unrooted SPR distance. Building on previous work by Hickey et al. [35], Bonet and St. John [51], and our recently introduced "socket agreement forest (SAF)" framework [50], we make the following con- tributions: 1) we identify new properties of minimum-length SPR paths showing that an MAF-like formulation is unlikely to exist, 2) we develop a practical algorithm for enumerating max- imal unrooted AFs, 3) we define a new replug distance, which does admit a MAF-like formulation and gives a lower bound on the uSPR distance; we develop an exact fixed-parameter bounded search tree algorithm for its calculation, and 4) we propose and implement a new incremental heuristic search algorithm called progressive A* that leverages multiple increasingly expensive to compute but more accurate lower bound estimators to compute the uSPR distance in practice for trees with up to 50 leaves and distances as large as 14. Proofs of our lemmas and theorems are in the appendix. 2 PRELIMINARIES Nodes (i.e. vertices) of a tree graph with one neighbor are called leaves and nodes with three neighbors are called internal nodes. An (unrooted binary phylogenetic) X-tree is a tree T whose nodes each have one or three neighbors, and such that the leaves of T are bijectively labeled with the members of a label set X. T (V ) is the unique subtree of T with the fewest nodes that connects all nodes in V . Suppressing a node v of degree 1 or 2 deletes v and its incident edges; if v is of degree 2 with neighbors u and w, u and w are reconnected using a new edge (u, w). The V - tree induced by T is the unique smallest tree TV that can be obtained from T (V ) by suppressing unlabeled nodes with fewer than three neighbors. See Figure 1. A rooted X-tree is defined similarly to an unrooted X- tree, with the exception that one of the internal nodes is called the root and is adjacent to a leaf labeled ρ. Note that this differs from the standard definition of a rooted tree in which the root is a degree two internal node. This ρ node represents the position of the original root in a forest of the trees, as we describe below, and can simply be attached to such a degree two internal node. The parent of a node in an rooted tree is its closest neighbor to the root; the other two neighbors of an internal node are referred to as children. An unrooted X-forest F is a collection of (not necessar- ily binary) trees T1, T2, . . . , Tk with respective label sets X1, X2, . . . , Xk such that Xi and Xj are disjoint, for all 1 ≤ i 6= j ≤ k, and X = X1 ∪ X2 ∪ . . . ∪ Xk. We say F yields the forest with components T1X1, T2X2, . . . , TkXk, in other words, this forest is the smallest forest that can be obtained from F by suppressing unlabeled nodes with less than three neighbors. In the rooted case, each component Ti is rooted at the node that was closest to ρ. Note that only the root of T1 is adjacent to leaf ρ. If T1, T2, . . . , Tk are all binary then the remaining roots have degree 2. For an edge set E, F − E denotes the forest obtained by deleting the edges in E from F and F ÷ E the yielded forest. We say that F ÷ E is a forest of F . For nodes a and b of F , we will say that a can be reached from b, or a ∼F b, when there is a path of edges between a and b in F . The opposite will be denoted a 6∼F b. A subtree-prune-regraft (uSPR) operation on an unrooted X-tree T cuts an edge e = (u, v). This divides T into subtrees Tu and Tv, containing u and v, respectively. Then it introduces a new node v′ into Tv by subdividing an edge of Tv, and adds an edge (u, v′). Finally, v is suppressed (Figure 1(d)). We distinguish between SPR operations on rooted trees and unrooted trees (uSPR operations). SPR operations on rooted trees have the additional requirement that u 6= ρ and that v is u's parent rather than an arbitrary neighbor of u. Note that if the node v′ introduced in the rooted tree is adjacent to ρ then v′ becomes the root. A tree-bisection-reconnection (TBR) operation on an un- rooted tree is defined similarly to a uSPR operation, except that a new node u′ is also introduced into Tu bisecting any edge, the added edge is (u′, v′) rather than (u, v′), and both u and v are suppressed. Note that uSPR operations are a subset of TBR operations, as a TBR operation may reintroduce the same endpoint on one side of the edge. We often consider a sequence of operations applied to a tree T1 that result in a tree T2. These operations can be thought of as "moving" between trees and are also referred to as moves (e.g. an SPR move). A sequence of moves M = m1, m2, . . . , md applied to T1 result in the sequence of trees T1 = t0, t1, t2, . . . , td = T2. We call such sequences of trees a path (e.g. an SPR path). When considering how the tree changes throughout such sequences, it is often helpful to consider how nodes and edges of the tree change. Formally, we construct a mapping ϕi,j that maps nodes and edges of ti to tj. Each mapping ϕi,i+1 between adjacent trees is constructed according to the corresponding move mi+1: nodes and edges of ti that are not modified by mi+1 are mapped to the corresponding nodes and edges of ti+1. The deleted edge (u, v) of ti is mapped to the newly introduced edge of ti+1 (e.g. (u, v′) for an SPR move). Deleted nodes are mapped to ∅. Forward mappings ϕi,j, i < j, are constructed transitively. Reverse mappings ϕj,i, i < j, are constructed analogously by con- sidering the application of moves that construct the reverse sequence td, td−1, . . . , t0. We will use these mappings implicitly to talk about how a tree changes throughout a sequence of moves. With these mappings we can consider SPR and TBR tree moves as changing the endpoints of edges rather than deleting one edge and introducing another. We say that an edge is broken if one of its endpoints is moved by a rearrangement 21 21 54 54 1 2 3 4 5 6 7 3 4 5 6 9 6 9 8 7 3 6 9 8 7 1 4 6 3 7 3 5 9 8 T1 7 8 1 2 (a) 3 2 T2 9 8 (b) Fig. 2. (a) Three unrooted SPR operations transform a tree T1 into another tree T2. The dashed line with an arrow is the edge that will be added in the next step; simultaneously the dotted edge touching the tail end of the arrow will be removed. (b) A MAF of T1 and T2. operation. The relation between SPR and TBR moves can now be summarized by considering that a uSPR operation changes one endpoint of an edge, a rooted tree SPR opera- tion changes the root-most endpoint of an edge, and a TBR operation changes both endpoints. SPR operations give rise to a distance measure dSPR(·,·) between X-trees, defined as the minimum number of SPR operations required to transform one tree into the other. The trees in Figure 2(a), for example, have SPR distance dSPR(T1, T2) = 3. The TBR distance dTBR(·,·) is defined analogously with respect to TBR operations. A minimum- length path of SPR or TBR moves between two trees is an optimal SPR path or optimal TBR path, respectively. The second and third SPR operations applied in Fig- ure 2(a) move both ends of a single edge and can be replaced by a single TBR operation. Thus, in this case dTBR(T1, T2) = 2. Note that the fact that uSPR operations are a subset of TBR operations implies that the TBR distance is a lower bound on the uSPR distance [40]: Lemma 2.1. For two unrooted trees T1 and T2, dTBR(T1, T2) ≤ dSPR(T1, T2). Given trees T1 and T2 and forests F1 of T1 and F2 of T2, a forest F is an agreement forest (AF) of F1 and F2 if it is a forest of both forests. F is a maximum agreement forest (MAF) if it has the smallest possible number of components. We denote this number of components by m(F1, F2). For two unrooted trees T1 and T2, Allen and Steel [40] showed that dTBR(T1, T2) = m(T1, T2) − 1. Figure 2(b) shows an MAF of the trees in Figure 2(a). For two rooted trees T1 and T2, Bordewich and Sem- ple [34] showed dSPR(T1, T2) = m(T1, T2) − 1, by in- troducing the root node augmentation ρ described above. Moreover, nodes are only suppressed in rooted trees if they have fewer than two children, such that unlabeled component roots (the nodes that were connected to the ρ component by an edge before cutting) are not suppressed. In contrast to an MAF, a maximal AF (mAF) F ∗ of two trees T1 and T2 is an AF of T1 and T2 that is not a forest of any other AF of T1 and T2. In other words, no edges can be added to F ∗ to obtain an AF with fewer components. Every MAF is a mAF, but not necessarily vice versa [52]. 3 FOUR STRIKES AGAINST AN AGREEMENT FOR- EST FOR THE USPR DISTANCE right. This is in stark contrast to the trivially solved AF- move-recovery problem for MAF-like problems. 4 There are relatively efficient fixed-parameter algorithms for each distance metric with a maximum (acyclic) agreement forest formulation-the rooted SPR distance [39], unrooted TBR distance [40], and rooted hybridization number [17]. We call these MAF-like problems. For MAF-like problems, the distance can be found from easily determined properties of the maximum agreement forest: typically, its number of components. It is reasonable to ask why there has been no formulation of the uSPR distance as an MAF-like problem. In this section, we identify four properties of the uSPR distance that are contrary to natural MAF assumptions. Specifically, these properties show the uSPR distance isn't easily calculated from properties of a traditionally defined agreement forest. Let S be an optimal sequence of SPR operations trans- forming one unrooted tree T1 to another T2. Consider the set of broken edges E of T1 and T2 whose endpoints are modified by applying S. Then we can naturally define the AF underlying S as T1 ÷ E = T2 ÷ E, that is the maximal forest of edges which are not modified by applying S. Note that this AF is not necessarily maximum. We can similarly define the AF underlying an optimal sequence of TBR moves. Property 3.1. One or both ends of an edge may move An AF with k + 1 components represents a set of k TBR moves, each joining two components with respect to T2. However, SPR moves only move one end of an edge and S may require both ends of a particular edge to move (e.g. the edge initially between 3 and 4 in Figure 2). As such, an optimal SPR path may include one or two rearrangements corresponding to the same broken edge. In fact, as we show in the next property, optimal SPR paths may require three or more moves corresponding to the same broken edge. Property 3.2. The same endpoint of an edge may move twice A useful feature of MAF-like problems is that each optimal move joins two components in the underlying AF. The minimum distance is thus one less than the number of MAF components, and it is easy to recover an optimal sequence of moves from the MAF. However, optimal sequences of uSPR moves with re- spect to a given underlying agreement forest are not guar- anteed to join AF components at each step. Consider, for example, the pair of trees in Figure S3. These trees have only one MAF, but each of their optimal SPR paths begins by applying a move that does not join an underlying AF component. We verified this by computing the SPR distance between the second tree and each neighbor of the first tree. Moreover, we exhaustively tested each optimal SPR path underlain by the MAF and found that each such path moves the same endpoint of some edge twice. In other words, a broken edge may be moved three or more times in an optimal SPR path. Thus, even given the AF underlying an (unknown) optimal sequence of SPRs, it is not clear how to determine the sequence of SPRs or even their number. We call this the AF-move-recovery problem, and suspect that the uSPR version of the problem may be NP-hard in its own Property 3.3. Common clusters are not always maintained A common cluster is a set of taxa L ⊂ X from two X-trees, T1 and T2, such that TiL and Ti(X \ L) are disjoint and connected by a single edge for i = 1, 2. In MAF-like problems, it is never necessary to move taxa from one side of a common cluster edge to the other. In fact, these problems can be decomposed into pairs of common clusters which are solved independently [53], [49]. Such cluster decompositions greatly decrease the computational effort required to solve MAF-like problems, as algorithms to do so scale exponentially with the distance computed within a cluster rather than the total distance [9]. However, as previously shown by Hickey et al. [35], there exist pairs of unrooted trees such that every optimal SPR path violates a common cluster. This lack of indepen- dence between clusters is another sign that uSPR differs from MAF-like problems. Property 3.4. Common paths may be broken In fact, the situation is even worse than identified by Hickey et al. [35]. Consider an optimal sequence M of SPR operations transforming one tree, T1, into another, T2, and the underlying agreement forest F = T1 ÷ E1 = T2 ÷ E2 for some E1 and E2. We say that two paths of edges p1 ∈ T1 and p2 ∈ T2 are common paths with respect to M if they connect the same AF components C1 and C2, that is T1 ÷ (E1 \ p1) = T2 ÷ (E2 \ p2). Not only is it sometimes necessary to move taxa from one side of a cluster edge to another, it may be necessary to break a common path, as shown in Figure S4. This is especially surprising, as a later SPR operation must reform the common path. However, breaking such a common path may free up sets of moves that would be otherwise impossible. This observation implies that every AF underlying an optimal set of SPR operations may be a strict subforest of another AF, that is, every such underlying AF may not be maximal. This is in stark contrast to MAF-like problems where every underlying AF is either maximum or (for rooted hybridization number) maximal. In summary, we believe that these properties make it unlikely that any uSPR MAF formulation is possible. The first two properties show that even if the correct edges are identified that need to be modified, it does not appear straightforward to find the optimal sequence of modifica- tions. The second two properties show that we cannot even assume that edges found in each tree will be preserved in an optimal uSPR path. Thus, we require a different strategy. 4 SOCKET AGREEMENT FORESTS Recently, we proposed a new type of agreement forest, socket agreement forests (SAFs) [50] which we summarize here. Note that SAFs are required only for Observation 5.2 and in Section 6.3, so this section can be skipped on a first read. SPR operations on general trees remove and introduce internal nodes, making it difficult to describe equivalence of sets of moves. SAFs solve this difficulty by including a finite set of predetermined "sockets" which are the only nodes that can be involved in SPR operations and are never deleted or introduced. However, due to this fixed nature, SAFs are unsuitable for determining the SPR distance metric directly. A socket forest is a collection of unrooted trees with special nodes, called sockets. Socket forests have special edges called connections that must be between two sockets. A collection of them is a connection set. Connections are not allowed to connect a socket to itself, although multiple connections to the same socket are allowed. We will also use the following terminology on socket forests. A move is the replacement of one connection in a connection set for another. A replug move is a move that only changes one socket of a given connection. An SPR move for a given connection set is a replug move that does not create cycles. We say that a move breaks the replaced connection. The underlying forest of a socket forest F is the forest F ∗ obtained from F by deleting all connections and suppress- ing all unconnected sockets. A socket forest F permits an unrooted tree T if it is possible to add connections between the sockets of F , resolve any multifurcations in some way, and suppress unconnected sockets to obtain T . We call a connected socket forest with such a connection set a configuration of F (e.g. a T configuration of F ). Moreover, a socket forest F permits an SPR path if each intermediate tree along the path is permitted by F . Given two trees T1 and T2, a socket agreement forest (SAF) is a socket forest that permits both T1 and T2. Note that the underlying forest of an SAF is an AF of T1 and T2. Let M = m1, m2, . . . , mk be a sequence of moves trans- forming tree T1 into tree T2 via an SAF F . We can consider the sequence of trees T1, t1, t2, . . . , tk = T2 induced by these moves, that is the sequence of tree configurations obtained by applying M to a T1 configuration of F that results in a T2 configuration of F . We thus discuss sockets and connections in the trees, as shorthand for the sockets and connections in the corresponding socket forest configurations. Socket forests allow us to be precise concerning how con- nections change during a sequence of moves, because nodes are not deleted or introduced. Each socket can be separately identified (e.g. with a numbering), so any connection can be described irrespective of the other connections in a socket forest. As with moves on general trees, we consider the deletion and insertion of a connection as simply changing the endpoint of the connection. As such, the "new" con- nection maintains the same identifier. Thus, we can identify changes in a connection by the changes in the sockets it con- nects, again irrespective of the other connections in a socket forest. This implies a well defined notion of equivalence of moves: two moves are equivalent if they both attach a given endpoint of the same connection to the same socket. For example, we can uniquely describe a move as changing the second endpoint of connection c to socket v′, regardless of the current state of the socket forest. We say that a move is valid for a socket forest configuration if it can be applied to that configuration. Similarly, a rearranged and/or modified sequence is valid if it is a sequence of valid moves. Given an AF F ′ of two trees T1 and T2, we say that an SPR path between T1 and T2 is optimal with respect to F ′ if there exists no shorter SPR path between T1 and T2 where each intermediate tree along the path is permitted by F ′. Socket agreement forests are a partial analogue of 5 maximum agreement forests: if we can construct a socket agreement forest for T1 and T2, we can be assured of a valid SPR path between T1 and T2 that is optimal with respect to the underlying agreement forest. However, it is not trivial to calculate the length of the SPR path between trees for a given socket agreement forest, and thus they are only a partial analogue of rooted maximum agreement forests. We prove the following lemma in [50]. Lemma 4.1. Let F be a socket agreement forest of two trees T1 and T2. Then there exists an SPR path between T1 and T2 that is permitted by F and optimal with respect to the AF F ∗ underlying F . We can define an optimal replug path with respect to an AF F ′ in an analogous manner. It is then straightforward to apply the proof of Lemma 4.1 to replug moves to obtain the following corollary: Corollary 4.2. Let F be a socket agreement forest of two trees T1 and T2. Then there exists a replug path between T1 and T2 that is permitted by F and optimal with respect to the AF F ∗ underlying F . 5 THE REPLUG DISTANCE AND MAXIMUM END- POINT AGREEMENT FORESTS In this section, we introduce the replug distance, which lies between the TBR distance and SPR distance, and develop an agreement forest variant, called an endpoint agreement forest, for its calculation. This notion of agreement forest records the position of broken edges for unrooted trees, and thus does not have the pathologies of unrooted SPR agreement forests described in the first section. The replug distance on trees is defined in terms of the replug operation, inspired by replug moves on socket forests. A replug operation is an SPR operation that does not neces- sarily result in a tree. That is, a replug operation again cuts an edge e = (u, v) of a tree T , dividing T into Tu and Tv, but the new node v′ attached to u may be chosen from either Tu or Tv. If v′ ∈ Tv then the replug operation is identical to an SPR operation. If, however, v′ ∈ Tu, then adding the edge u, v′ results in a disconnected graph with two components, one of which is cyclic. We further extend this operation to apply to arbitrary partially-labeled graphs, such as the result of a replug operation on a tree (Figure 3(a)). Given two trees, T1 and T2, the replug distance, dR(T1, T2), is the minimum number of replug moves re- quired to transform T1 into T2. By dropping the requirement that each intermediate move result in a tree, we achieve an MAF-like problem that can be computed using a structure we call an endpoint agreement forest (EAF). The replug distance can be used as an approximation and lower bound of the SPR distance which, as we discuss in Section 7, can be used in an incremental heuristic search for the exact SPR distance. We show that it is fixed-parameter tractable in Theorem 6.9, but conjecture: Conjecture 5.1. The replug distance between two trees T1 and T2 is NP-hard to compute. To develop an agreement forest that represents replug operations, we must consider the properties of the unrooted 1 2 1 2 3 φ φ 7 4 5 6 5 6 3 4 φ 7 23 1 6 5 4 9 7 8 T2 9 8 9 8 (b) (c) 3 4 5 6 7 21 9 8 T1 21 3 9 8 (a) 4 5 6 7 Fig. 3. (a) Two replug moves transform a tree T1 into another tree T2. Replug moves modify one end of an edge, like SPR moves, but may create loops and disconnected components. The dashed line with an arrow is the edge that will be added in the next step; simultaneously the dotted edge touching the tail end of the arrow will be removed. (b) A maximum endpoint agreement forest (MEAF) of T1 and T2. The φ nodes indicate endpoints of removed edges that are common to both trees. In this case, as there are two components and two φ-nodes, the TBR and replug distances are both 2. The SPR distance is 3. (c) A MEAF of the trees from Figure 2(a). In this case, the replug distance and SPR distance are both 3, while the TBR distance is 2. SPR distance in Section 3 which make it difficult to solve using agreement forests. Property 3.1 states that one or both ends of an edge may move in an optimal unrooted SPR path. Recall that each SPR operation moves one endpoint of an edge and so any agreement forest formulation must be able to represent which side of an edge remains fixed, as well as the case where both sides of an edge must be moved. The replug distance also has this directional property. However, as replug moves are not required to maintain a tree structure, they do not prevent other replug moves in the way that uSPR moves do. We thus have the following observation: Observation 5.2. Given an SAF, an endpoint of any connection can be attached to any socket with a valid replug move. We can use this observation to show that the replug distance does not have Properties 3.2, 3.3 and 3.4 of the unrooted SPR distance. Lemma 5.3. Let M = m1, m2, . . . , mk be an optimal sequence of replug moves transforming a tree T1 into a tree T2. Then M does not (1) move the same endpoint u of an edge twice, (2) break a common cluster of T1 and T2, or (3) break an edge of a common path of T1 and T2 with respect to M . To account for Property 3.1 and define an agreement forest that represents replug operations, we thus need to represent a fixed endpoint of a moved edge (analogous to component roots of a rooted AF) as well as the case where both endpoints are moved (analogous to an unrooted AF for TBR calculation). We will call this augmented tree structure a (phylogenetic) X-φ-tree, which is a generalization of an X- tree. It has n ≥ X labeled leaves, X of which are uniquely labeled from X, and the remaining q(T ) := n − X leaves 6 are each labeled φ. These φ nodes will be used to indicate an edge endpoint which remains fixed during a set of tree moves. As with X-trees, two X-φ-trees are considered equal if and only if there is an isomorphism between their nodes and edges that maintains node labels. Thus, φ nodes are interchangeable. An X-φ-forest is a forest of X-φ-trees. Consider the three possiblities of an edge e = (u, v) of an X-φ-tree that is modified by one or more replug moves: 1) the v endpoint is moved such that e becomes (u, x) 2) the u endpoint is moved such that e becomes (w, v) 3) both endpoints are moved such that e becomes (y, z). In order to describe such changes as part of a type of agreement forest, we attach φ nodes as follows. In the first case we represent this replug operation by cutting edge e, suppressing node v, then attaching a new leaf labeled φ to node u. The second case is similar: we suppress u then add a φ node to v. Observe that the third case is equivalent to two replug operations or a single TBR operation. We can thus represent the third case by cutting edge e and suppressing nodes u and v, as in general unrooted AFs. To complement the notion of "directional" agreement forest we also need a notion of directional edge set, as follows. We define an endpoint edge Ec of a tree T to be an edge along with a proper subset of its endpoints. This will be denoted e ⊲ p for an edge e = (u, v) where p ( {u, v}. Note that p = ∅ indicates that both endpoints are moved. In the context of a sequence of replug moves, these subsets p are the nodes that remain fixed, which we will call augmented endpoints. An endpoint edge of an X-φ-tree cannot have a φ node as an augmented endpoint. An endpoint edge set E is a set of endpoint edges Ec of T . For an endpoint edge set E, we use F − E to denote the X-φ-forest obtained by deleting the edges in E from F and adding φ node neighbors to each augmented endpoint. We call this "cutting" the endpoint edge set, which is in general a many-to-one mapping. F ÷ E is again the (X-φ) forest yielded by F − E and we say that F ÷ E is an endpoint forest of F . An endpoint agreement forest (EAF) is now naturally de- fined in terms of endpoint forests. Given trees T1 and T2 and forests F1 of T1 and F2 of T2, a forest F is an EAF of F1 and F2 if it is an endpoint forest of both trees. Observe that an EAF is a generalization of an AF, where either no nodes remain fixed (unrooted AF, in which every p = ∅), or every endpoint furthest from the root remains fixed (rooted AF, in which no p = ∅). As such, we can always find an EAF for two trees by constructing an AF. The weight of an EAF F is defined as: ω(F ) = 2 (F − 1) − q(F ), where q(F ) is the number of φ nodes in F . Observe that the weight strictly increases upon cutting an endpoint edge set. We say that an EAF F of two trees T1 and T2 is a maxi- mum endpoint agreement forest (MEAF) of T1 and T2 if it has minimum weight (Figures 3(b) and 3(c)). Use ω(T1, T2) to denote this minimum weight. We can show that dR(T1, T2) is equal to ω(T1, T2), rather than the number of components. Theorem 5.4. Let T1 and T2 be unrooted trees. Then dR(T1, T2) = ω(T1, T2). Our proof of Theorem 5.4 provides an inductive proce- dure for constructing an optimal sequence of replug moves from an MEAF (Fig. S1 in the appendix). Moreover, each step of this procedure can be implemented to require linear time using the tree to AF mappings we construct later with Lemma 6.3. Thus: Corollary 5.5. Let F be an EAF of two unrooted trees T1 and T2. A sequence of ω(F ) replug moves that transform T1 into T2 can be obtained from F in O(nω(F ))-time. The replug distance is a lower bound for the SPR dis- tance, which enables the fast SPR distance algorithm in Section 7. Theorem 5.6. For any pair of trees T1 and T2, dTBR(T1, T2) ≤ dR(T1, T2) ≤ dSPR(T1, T2). 6 A FIXED-PARAMETER REPLUG DISTANCE ALGO- RITHM In this section we develop a fixed-parameter algorithm for computing the replug distance between a pair of binary rooted trees T1 and T2. We apply a two-phase bounded search tree approach to determine whether the replug dis- tance is at most a given value k. The minimum replug distance can be found by repeatedly running this algorithm with increasing parameters k = 1, 2, . . . , dR(T1, T2). Our strategy is to enumerate all possible maximal agree- ment forests (Section 6.1) and then decorate them with φ nodes to enumerate the possible maximal endpoint agree- ment forests (Section 6.2). We then improve the second phase by considering each possible socket assignment as a SAF of F and finding an optimal φ node assignment (Section 6.3). 6.1 Enumerate maximal AFs (TBR distance) The first phase of our search enumerates all maximal (unrooted) AFs. We modify the O(4kn)-time MAF (TBR) distance algorithm of Whidden and Zeh [54] to do so, and adopt some of the improved branching cases from the O(3kn)-time algorithm of Chen et al. [55]. Neither algorithm is capable of enumerating all mAFs in its original form and, furthermore, we can not apply all of the cases from Chen et al. because some of their cases necessarily miss some mAFs. Given two trees T1 and T2 and a parameter k, our algorithm mAF(T1, T2, k) finds each maximal AF that can be obtained by cutting k or fewer edges. If no such mAF exists, then it returns an empty set. If mAFs are found, we apply the next phase of our search to each of these candidate underlying AFs. If we find no mAFs or if none of these mAFs underly a maximum endpoint agreement forest, we increase k and repeat until we find one. This does not increase the running time of the algorithm by more than a constant factor because the running time depends exponentially on k. Our algorithm is recursive, acting on the current forests of T1 and T2 that are obtained by cutting edge sets E1 and E2, respectively, with E1 = E2. These forests maintain a specific structure, F1 = T1 ÷ E1 = { T1} ∪ F0, and F2 = T2 ÷ E2 = F2 ∪ F0, defined as follows: 7 • The tree T1 is obtained from T1 by cutting E1. • The forest F0 has all of the rooted subtrees cut off from T1. The rooting for these subtrees is that given by rooting at the node touching a cut edge. • A set Rt (roots-todo) stores the roots of (not necessarily • The forest F2 has the same label set as T1, and contains the components of F2 that do not yet agree with T1 (i.e. (F2 ÷ E2) \ F0). maximal) subtrees agreeing between T1 and F2. Each invocation of the algorithm works to modify T1 and F2 towards agreement, collecting the needed agreement T1 = forest components in F0. For the top-level invocation, F2 = {T2}, F0 = ∅, and Rt contains all leaves of T1. T1, We say that a pair of nodes a, c ∈ Rt that are siblings in T1 are a sibling pair {a, c}. Such a pair must exist when Rt ≥ 2 just as every tree must have a pair of sibling leaves. T1 For each node x ∈ Rt, ex denotes the unique edge of or F2 that is adjacent to x and extends out of the common subtree rooted at x. We call this the edge adjacent to x. Algorithm mAF(F1, F2, k): 1. (Failure) If k < 0, then return ∅. 2. (Success) If Rt = 1, then F1 = F2. Hence, F2 is an AF 3. (Prune maximal agreeing subtrees) If there is no node of T1 and T2. Return {F2}. r ∈ Rt that is a root in F2, proceed to Step 4. Otherwise choose such a node r ∈ Rt; remove it from Rt and move F2 containing r to F0; cut the edge er the subtree S of separating S in T1 from the rest of T1, which gives S a rooting. Return to Step 2. T1. Let ea and ec be the 4. Choose a sibling pair {a, c} of edges adjacent to a and c in F2. 5. (Grow agreeing subtrees) If a and c are siblings in F2, do the following: remove a and c from Rt; label their mutual neighbor in both forests with (a, c) and add it to Rt; return to Step 2. 6. (Branching) Distinguish two cases depending on whether a ∼F2 c (Figure 4). Note that because a and c are in T1 they are not in F0, so a ∼F2 c is equivalent to a ∼ F2 c. 6.1. If a 6∼F2 c, try cutting off either the subtree rooted at a or that rooted at c, returning: mAF(F1, F2÷{ea}, k−1)∪mAF(F1, F2÷{ec}, k−1). 6.2. If a ∼F2 c, let b1, b2, . . . , bq be the pendant nodes on the path from a to c in T2 and let ebi be the pendant edge adjacent to bi. Try cutting ea or ec, or try cutting off all but one of the subtrees on the path between a and c, returning: mAF(F1, F2 ÷ {ea}, k − 1) ∪ mAF(F1, F2 ÷ {eb2, eb3 , . . . , ebq}, k − (q − 1)) ∪ mAF(F1, F2 ÷ {eb1, eb3 , eb4, . . . , ebq}, k − (q − 1)) . . . ∪ mAF(F1, F2 ÷ {eb1, eb2 , . . . , ebq−1}, k − (q − 1)) ∪ mAF(F1, F2 ÷ {ec}, k − 1). The correctness of our algorithm is proven using a simplification of the proof of Theorem 2 of Whidden and Zeh [54], modified for arbitrary maximal agreement forests. a b1 b2 . . . c b q 8 a c a b1 b2 . . . c b q a b1 b2 . . . c b q a c a c a b1 b2 . . . c b q . . . a b1 . . . b q−1 c b q a c (a) (b) (c) Fig. 4. Branching cases of the maximal AF enumeration algorithm. (a) A sibling pair {a, c} of F1. (b) The branching cases applied to F2 when a 6∼F2 c. (c) The branching cases applied to F2 when a ∼F2 c. Lemma 6.1. mAF(T1, T2, k) returns the set of maximal agree- ment forests of T1 and T2 that can be obtained by cutting k or fewer edges. Theorem 6.2. Given two trees T1 and T2, the set S of maximal agreement forests of T1 and T2: 1) can be enumerated in O(4kn)-time, 2) can be returned in O(4kn + S log S)-time (the log S 3) is of size at most 4k. factor required to avoid duplicate agreement forests), and 6.2 Enumerate maximal EAFs (Replug distance) The second phase of our algorithm enumerates maximal endpoint agreement forests to compute the replug distance. Using mAF(T1, T2, k) we can enumerate each mAF F of two trees T1 and T2 that has k + 1 or fewer components, in other words, the mAFs that correspond to k or fewer TBR operations. However, such an mAF may imply anywhere from k to 2k SPR operations. We assign φ nodes to F to determine the maximal EAF (mEAF) with minimum weight. We require a method to map nodes of the trees to the agreement forest and vice versa. Given an mAF F of trees T1 and T2, we construct a "forward" mapping ψ(x) that maps nodes of T1 and T2 to nodes of F , as well as a "reverse" mapping ψ−1(Ti, x), i ∈ {1, 2}, that maps nodes of F to the trees. Recall that F = T1 ÷ E1 = T2 ÷ E2, where E1 and E2 are the edges cut from T1 and T2, respectively. As F contains fewer nodes than T1 and T2, our forward mapping ψ(x) maps some nodes of T1 and T2 to the empty set. These are exactly the nodes that are contracted when E1 and E2 are cut to obtain F from T1 and T2. We call these the dead nodes of the trees, in contrast to the alive nodes that are mapped to nodes of F . There are potentially many edge sets that can be cut from the trees to obtain the mAF F , but we can quickly obtain one pair of such edge sets and their induced mappings: F can be constructed in linear time, and Lemma 6.3. Let F be an mAF of two trees T1 and T2. Then 1) two sets of edges E1 and E2 such that T1÷E1 = T2÷E2 = 2) a mapping ψ(x) from T1 and T2 nodes to nodes of F and the reverse mappings ψ−1(Ti, x) can be built in O(n)-time; lookups using these mappings take constant time. Now, we develop an algorithm replug(T1, T2, F, d) to enumerate the set of mEAFs of weight d or less with the same components (modulo φ nodes) as a given mAF F of trees T1 and T2. First assume that the edge set E1 to remove from T1 is pre-specified. In this case, each corresponding mEAF F ′ is simply F with a choice of endpoint for each edge e = (u, v) ∈ E1, that is, e⊲{u}, e⊲{v}, or e⊲∅. We have three choices for each edge, and can therefore enumerate these candidate mEAFs in O(3kn) time, where k + 1 is the number of components of F , and keep any of weight d or less. Note that, for each candidate mEAF, we must also check, using O(n)-time, whether it is a forest of T2 (it is guaranteed to be a forest of T1 as we enumerated choices of endpoints for E1). We define the following recursive subprocedure to enumerate the candidate mEAFs that can be obtained from an mAF F with a given set of edges E1. 3. (Branch) Return: Algorithm replug-decorate(T1, T2, F, E1, k): 1. (Failure) If k < 0 then return ∅. 2. (Success) If F contains an unprocessed edge e = (u, v) ∈ E1, then proceed. Otherwise F is a forest of T1 with weight at most double the initial value of k. If F is also a forest of T2, return {F2}. Otherwise, return ∅. replug-decorate(T1, T2, F ÷ e ⊲{u}, E1 \ {e}, k − 1) ∪ replug-decorate(T1, T2, F ÷ e ⊲{v}, E1 \ {e}, k − 1) ∪ replug-decorate(T1, T2, F ÷ e ⊲∅, E1 \ {e}, k − 1). Define a dead tree to be a tree induced by some maximal set of adjacent edges in T1 or T2 that do not map to edges of F . When every dead tree is a single edge, the edge sets E1 and E2 removed to obtain F from T1 and T2 are unique and thus known. However, in general we must enumerate every set of edges E1 such that T1 ÷ E1 = F , because a component C of F that is adjacent to a dead tree with three or more leaves in both T1 and T2 may have nontrivial φ node structures in the mEAF. Given the node mappings and reverse node mappings constructed with Lemma 6.3, we can identify the dead trees in a tree with three preorder traversals. The node mapping construction procedure roots the trees arbitrarily. We use the same roots in our traversals. The first traversal determines the depth from each node of T1 to its arbitrary root. The second traversal identifies the path induced by each edge e = (u, v) of F in T1. To do so, we move towards the root from ψ−1(T1, u) and ψ−1(T1, v), always moving from the more distant node. These paths will cross at the least common ancestor of ψ−1(T1, u) and ψ−1(T1, v) with respect to the root. We mark ψ−1(T1, u) and ψ−1(T1, v) as alive and each other node of the path as a socket. If u or v is a component root of F , then it was not removed by a forced contraction when its adjacent edge was cut. In this case we also mark ψ−1(T1, u) or ψ−1(T1, v), respectively, as a socket. The third and final traversal marks all the remaining nodes as dead and identifies the connected components of dead trees. We will use this assignment of dead nodes and socket nodes at the end of this section to quickly find a single optimal φ node assignment. A dead tree with q leaves has 2q−3 edges. Each such tree can be removed by removing q − 1 edges and contracting the resulting degree two nodes. Thus there are (cid:0)2q−3 q−1 (cid:1) ≤ 4q choices of edges to cut that result in the same dead tree. This implies that there are at most 4k edge sets that result in the same AF. We thereby construct each possible E1 set and test each combination of three choices per edge, as in the unique edge set case. This requires O(4k3kn) = O(12kn) time. In summary, the high-level steps of the algorithm to calculate the replug distance are as follows. Algorithm replug(T1, T2, F, d): 1. Root T1 and T2 arbitrarily at nodes r1 and r2. 2. Construct the mappings ψ and ψ−1 using Lemma 6.3. 3. Compute the distance from each node n in T1 to r1. 4. For each edge e = (u, v) of F , mark ψ−1(T1, u) and ψ−1(T1, v) as alive and the other nodes on the path in T1 from ψ−1(T1, u) to ψ−1(T1, v) as sockets. 5. Mark all unmarked nodes dead. 6. Identify the dead components D1 = {d1, d2, . . . dq1} of 7. Repeat the previous steps for T2, identifying the dead T1. components D2. 8. Let F ← ∅. 9. For each edge set E1 induced by D1, a) Let k ← E1. b) Let F ′ ← replug-decorate(T1, T2, F, E1, k). c) For each forest F ′ ∈ F ′, if F ′ has weight at most d and is consistent with some edge set E2 induced by D2 then add it to F . 10. Return F . In combination with the algorithm mAF(T1, T2, k) from Section 6.1, this implies: Theorem 6.4. Given two trees T1 and T2, the set of mEAFs of T1 and T2 with k + 1 or fewer components can be enumerated in O(48kn)-time and there are at most 48k such mEAFs. This is a fairly loose bound as there are typically far fewer than 4k mAFs [56] and the majority of agreement forests will have few and small dead trees. Although the above procedure requires more effort to enumerate the mEAFs that can be obtained from a single mAF in the worst case than it does to enumerate each of the mAFs, we expect the opposite to be the typical case in practice because closely related trees (such as those compared in phylogenetic analysis) rarely differ in only a single large connected set of bipartitions in both trees which is necessary to induce a single large dead component in both trees. 9 We can improve the φ node assignment step in the case that k is close to the SPR distance. If the SPR distance is d then it never makes sense to consider an mEAF with weight exceeding d for the final phase of our search. In fact, we can exclude any mEAF F ′ with fewer than d − k φ nodes, as their weight (and thus replug distance) is guaranteed to exceed d. We thus define replug-decorate*(T1, T2, F ′, E1, d), a version of replug-decorate which takes this observation into account to enumerate a more limited set of candidate mEAFs. For the definition, initially F ′ = T1 and E1 contains each edge of F , as follows: Algorithm replug-decorate*(T1, T2, F ′, E1, d): 1. (Failure) If d < 0 then return ∅. 2. (Success) If F ′ contains an unprocessed edge e = (u, v) ∈ E1, then proceed. Otherwise F ′ is a forest of T1 with weight less than the initial value of d. If F ′ is also a forest of T2, return {F2}. Otherwise, return ∅. replug-decorate*(T1, T2, F ′ ÷ e ⊲{u}, E1 \ {e}, d − 1) ∪ replug-decorate*(T1, T2, F ′ ÷ e ⊲{v}, E1 \ {e}, d − 1) ∪ replug-decorate*(T1, T2, F ′ ÷ e ⊲∅, E1 \ {e}, d − 2). 3. (Branch) Return: Theorem 6.5. Given two trees T1 and T2, the set of mEAFs of T1 and T2 with weight at most d and k + 1 or fewer components can be enumerated in O(min(4k, 2.42d) · 12kn)-time and there are at most (min(4k, 2.42d) · 12k) such mEAFs. 6.3 Quickly finding a single MEAF (Replug distance) Finally, we discuss how to quickly compute the replug distance in practice. Our goal now is to determine whether the replug distance between two trees is at most d. The minimum distance can again be found by testing increasing values of d starting from 0. We again enumerate the maximal agreement forests that can be obtained by removing at most d edges with mAF(T1, T2, d). For each such mAF F , however, we now wish to find a single optimal φ node assignment, rather than each such optimal assignment. 1 and E ′ To determine such an optimal assignment, we again start by finding an initial set of edges E1 and E2 such that T1 ÷ E1 = T1 ÷ E2 = F . Our first optimization stems from the observation that nontrivial φ node structures are only possible when a component C of an mAF is adjacent to a dead tree in both trees T1 and T2. Call a dead tree uncertain if it is adjacent to such a component in a given tree. When enumerating edge sets E ′ 2 that can be used to obtain F , we only need to enumerate combinations of dead tree edges from dead trees that are uncertain in both T1 and T2. Now, given an AF F of T1 and T2 and edge sets E1 and E2 that can be used to obtain F from the trees, we develop our optimal φ node assignment procedure. The intermediate structures are illustrated in Fig. S2 in the appendix. We first identify the set of candidate agreement forest edges that can be adjacent to a φ-node (candidate φ-nodes). We next identify the set of constraints on EAFs induced by these candidates and show that such sets belong to the monotone class CNF+(≤ 2) [57]. This is the class of satisfiability formulas in conjuctive normal form with no negated literals in which each literal occurs in at most 2 clauses. As such, we reduce the problem of decorating an AF with d − k φ nodes, to that of determining whether a boolean CNF+(≤ 2) formula can be satisfied by an assignment with at least d−k variables set to true. Finally, we briefly describe how this latter problem can be solved in O(k1.5)-time by finding a minimum edge cover in an equivalent clause graph [57]. To identify the candidate φ-nodes, we convert the AF F to an SAF S. Recall that a φ-node indicates an edge endpoint which remains fixed during a set of moves transforming one tree, T1, into another, T2. This implies that one socket remains fixed for each φ-node decorated edge in the T1 and T2 configurations of S. Thus, the sockets of S which are connected to an edge in both T1 and T2 are exactly our set of candidate φ-nodes. To accomplish this SAF conversion, we must thus in- troduce sockets from both T1 and T2 and match sockets which represent nodes from both trees. As described in the replug algorithm, a path of dead nodes in T1 (respectively, T2) between two alive nodes form a set of T1 (T2) sockets. We say that these dead nodes are all on the same edge of F . These sets are ambiguous in the sense that any pair consisting of a T1 and T2 socket that are on the same edge may be a fixed endpoint that can have a φ node. We can identify these ambiguous sets, as well as the dead nodes which are not sockets, in linear time as previously discussed. We must choose a mapping for each such set of h1 T1 sockets and h2 T2 sockets that map to the same alive node edge and that maintains the same orientation. There are thus (cid:0)h1 h2(cid:1) choices for each such set (assuming h1 ≥ h2), for a maximum of at most 4h1 ≤ 4k combinations that must be considered. We further observe that dead tree nodes are not possible choices in such a mapping. Therefore, there are at most 4k SAFs that must be considered, stemming from both choices of E1 and E2 and socket mappings. We expect such situations to be degenerate in practice and that most cases will induce a small number of SAFs based on our experience with rooted agreement forests. Now, for each SAF, we identify the set of constraints induced by the candidate φ-nodes. These constraints nat- urally arise from the fact that we cannot assign two φ-nodes to both endpoints of the same cut edge in E1 of T1 or E2 of T2, as that would imply that the edge remains fixed. Now, suppose, without lack of generality, we have a dead tree D adjacent to nD sockets of F in T1. We say that an assignment of φ-nodes to sockets of S satisfies D if at least one of the nD sockets adjacent to D is not assigned a φ node. By Lemma 6.6, it suffices to find an assignment of φ nodes to S that satisfy each dead component of T1 and T2. Lemma 6.6. Given a socket agreement forest S of two trees T1 and T2, an assignment of φ-nodes to sockets of S is an EAF of T1 and T2 if, and only if, the assignment satisfies every dead tree in T1 and T2 with respect to S. We now show that the full set of such constraints is a boolean monotone CNF+(≤ 2) formula [57]. In particular, determining the maximum number of φ nodes that can be added to an SAF is thus equivalent to determining the minimum number of variables which must be true in such a formula-the minimum cardinality satisfiability problem. Lemma 6.7. The replug distance problem on an SAF S of trees T1 and T2 can be solved by solving the minimum cardinality sat- isfiability problem on a boolean monotone CNF+(≤ 2) formula. 10 This satisfiability problem can be solved efficiently with a polynomial time algorithm. Unlike general CNF satis- fiability, which is NP-hard [57], the minimum cardinality satisfiability problem on monotone CNF+(≤ 2) formulas is equivalent to the edge covering problem on a clause graph. Lemma 6.8. Given an SAF F of two trees T1 and T2, an EAF F ′ of T1 and T2 can be computed in O(k1.5)-time such that F ′ has F as its underlying agreement forest and F ′ contains as many φ-nodes as any such EAF. Finally, we combine the fast φ-node assignment proce- dure of Lemma 6.8 with our general mAF enumeration to solve the replug distance for a pair of trees: Theorem 6.9. Given two trees T1 and T2, an EAF F of T1 and T2 with ω(F ) = dR(T1, T2) and k + 1 components can be found (or determined not to exist) in: 1) O(4k(4kk1.5 + n))-time, or 2) O(4kn + Y k1.5)-time, where Y is the number of candidate SAFs with at most k + 1 components. Repeated applications of the subtree and chain reduction rules reduce the size of the initial trees to a linear function with respect to their SPR distance [50]. We thus achieve: Corollary 6.10. The replug distance for a pair of trees T1 and T2 can be solved in O(16dd1.5)-time, where d = dR(T1, T2). 7 COMPUTING THE USPR DISTANCE WITH A PRO- GRESSIVE A* APPROACH We now present our fixed-parameter algorithm for comput- ing the subtree prune-and-regraft distance between two un- rooted trees, T1 and T2. We first reduce the trees repeatedly by applying the subtree and chain reduction rules. After these reductions, the trees contain at most 28dSPR(T1, T2) leaves [50]. We then apply an incremental heuristic A* search [58] beginning from T1 to find T2. We could simply use standard A* with a replug distance heuristic. However, the replug distance is relatively expensive to compute, and such an algorithm would be very slow. Instead, we use a sequence of increasingly more accurate but expensive to compute heuristics in a method we call progressive A* search. The benefit of our algorithm over a standard A* search lies in the use of multiple heuristic functions, each of which provides a lower bound on its successor and is significantly less expensive to compute. This search focuses on paths that likely lead to the target tree while avoiding expensive computation of the TBR and replug distances on each of the O(n2) neighbors of every visited tree. We maintain a priority queue P of trees that remain to be explored. We also maintain a set V of trees that have already been visited, along with their estimated distances to T2 and what function was used to make that estimate. Initially P = {T1}. Define the priority p(T ) = (dT , hT , eT ). First, dT is the distance already traveled: dT = dSPR(T1, T ). Second, hT is the estimated minimum distance from T1 to T2 that can be achieved by a path that visits tree T . This estimate hT is dT + eT (T, T2), where eT (T, T2) is the estimated minimum distance from T to T2 using the estimation function eT . Third, eT is one of the four estimation functions (i.e., the heuristics) used as follows. The heuristic ONE(T, T2) = 1 for any tree. The heuristic aTBR(T, T2) is the linear-time 3- approximation algorithm for the TBR distance of Whidden and Zeh [54] divided by 3 to guarantee a lower bound estimate of the TBR distance. dTBR(T, T2) and dR(T, T2) are computed with the algorithms in the preceding section. We impose a total order on these heuristics as described below. Our search procedure always considers the next tree from P with smallest priority according to the partial or- dering of these values where for any two trees Ti and Tj, p(Ti) < p(Tj) iff: 1) hTi < hTj , 2) hTi = hTj and eTi < eTj , or 3) hTi = hTj , eTi = eTj , and dTi > dTj . In other words, we prioritize the tree Ti with smallest heuristic distance hTi. We break hT ties using a total or- dering of our heuristics eT : ONE() < aTBR() < dTBR() < dR(). In turn, eT ties are broken by partial distances dT . Each estimator provides a lower bound on each of the successive estimators as well as the target distance dSPR(Ti, T2), which is an important condition to ensure the correctness of our progressive A* search. We break ties by selecting the tree that is most distant from the starting posi- tion and therefore estimated to be closer to the destination tree. Trees with equal hT , eT , and dT values are selected from uniformly at random. Initially, p(T1) = (0, 1, ONE()) when inserting T1 into P . We repeatedly remove the tree T from P with smallest priority p(T ) = (dT , hT , eT ) and apply one of the options: 1) if eT = ONE(), reinsert T with priority (dT , dT + aTBR(T, T2), aTBR()). 2) if eT = aTBR(), reinsert T with priority (dT , dT + dTBR(T, T2), dTBR()). 3) if eT = dTBR(), reinsert T with priority (dT , dT + dR(T, T2), dR()). 4) if eT = dR(), explore each of the O(n2) trees that can be obtained from T by one SPR operation and insert each such tree t /∈ V into P with priority (dT + 1, 1, ONE()) and into V . However, if any of T 's SPR neighbors are T2 then we terminate the program and return the SPR distance of dT + 1. Theorem 7.1. The SPR distance between two unrooted trees T1 and T2 can be computed in O(Y 16dd1.5) time, where Y is the number of trees explored by the heuristic, and d = dSPR(T1, T2). Note that Y = O((28d)!!) after reducing T1 and T2. 8 EXPERIMENTAL EVALUATION We implemented our algorithms in the C++ program uspr [59]. Given two unrooted trees, this software can com- pute their TBR 3-approximation-based lower bound, TBR distance, replug distance, or SPR distance. This program was tested on the prokaryote dataset of [8] which com- pares a phylogenetic supertree constructed by the Matrix Representation with Parsimony method to 22,437 individ- ual gene trees ranging from 4–144 taxa. This dataset has been widely used to test methods for computing rooted SPR distances [21], [54], [36], as well as the sole previous software for computing uSPR distances sprdist by Hickey et al. [35]. (Note that this software is not the identically named software by different authors for computing rooted 5h 1h 1m 1s 1/60s e m i t 11 method sprdist SPR (NR) SPR replug TBR 0 2 4 6 8 10 12 14 16 18 20 22 24 26 distance Fig. 5. The mean time on a log-60 scale required as a function of distance to compute SPR distances using sprdist and SPR, replug, and TBR distances using uspr. The SPR test used all 4 bounding heuristics. The SPR (NR) test used all the bounding heuristics except the replug distance. Means were computed only over computations that succeeded for a given run within the time and memory limits. SPR distances [41], [60].) In the remainder of this paper we refer only to the software of Hickey et al. as sprdist. We computed SPR distances using uspr and sprdist on a computer cluster running Ubuntu 14.04 with the SLURM cluster management software. We allocated one Intel Xeon X5650 CPU per computation and terminated instances which required more than 4096 MB of memory or 5 hours. We tested the 5689 gene trees with 10 or more taxa. We used the standard practice of comparing each gene tree to the subset of the supertree with identical taxa only. 8.1 Running time Our new algorithms allow us to compute much larger SPR distances than were previously possible, as well as compute the same distances with much less time and memory (Fig- ure 5). Note that Figure 5 shows the mean time required by all computations that completed successfully given the time and memory limit, and summarizes different numbers of computations for different methods. We computed SPR distances as large as 14 with uspr, double the maximum distance of 7 computable with sprdist. sprdist also uses a graph exploration strategy, but without efficient heuristics to guide the search it typically reached the memory limit before the time limit was reached. In contrast, uspr explores fewer trees but spends more time per tree and is therefore CPU bound and more scalable than sprdist. Moreover, uspr found 176 instances with an SPR distance of 7 with a mean time of 53.29 seconds, nearly two orders of magnitude faster than the 33 instances with an SPR distance of 7 com- puted by sprdist with a mean time of 1808.96 seconds. We tested our software with and without the replug distance heuristic to determine if the better distance estimate outweighed the extra computation required to compute the heuristic. The replug distance heuristic was necessary to compute SPR distances of 13 or 14. Our software was an average of 5x faster with the replug heuristic, taking a mean time of 20.59s compared to 98.62s with only the TBR heuristic on problem instances which both methods completed given the running time limit. The replug heuristic 2000 d e t e l p m o c 1000 0 method sprdist SPR (NR) SPR replug TBR e c n a t s i d n a e m 6 4 2 0 12 metric SPR replug TBR 10−14 15−19 20−29 30−39 40−49 50−99 100−144 leaves 10 20 30 leaves 40 50 Fig. 6. The number of successfully computed SPR distances using sprdist and SPR, replug, and TBR distances using uspr given a time limit of 5 hours and memory limit of 4096 MB. Results are summarized by ranges of the number of leaves in the tree pairs, with the black lines indicating the total number of tree pairs in the given range. Fig. 7. Mean SPR, replug, and TBR distances of all tree pairs for which the SPR distance was succesfully computed using uspr given a time limit of 5 hours and memory limit of 4096 MB. greatly reduced the number of trees examined, and therefore the memory required, by a factor of about 33 to a mean of 2921.4 with the heuristic compared to 102,498.8 without the heuristic when each approach completed. As expected, our methods can be used to compute much larger replug distances (at most 21) and TBR distances (up to 25) given 5 hours. TBR distance computations are orders of magnitude faster than replug distance computations. As both distances are used repeatedly during our SPR distance progressive A* search, the search time depends primarily on the time required to compute these distances as well as the number of such distances that must be computed. 8.2 Completion Larger trees may have larger distances from a reference tree or supertree so we summarized the number of success- fully computed distances for defined ranges of tree sizes (Figure 6). Our new SPR distance algorithm is practical for trees with up to 50 leaves. We successfully computed distances for 132 of the 170 tree pairs with 40-49 leaves and 5142/5151 of the tree pairs with fewer than 40 leaves. However, we were only able to compute SPR distances for 60 of the 261 tree pairs with 50-99 leaves. This is in stark contrast to sprdist which can not reliably handle trees with more than 30 leaves, as it could only compute distances for 867 of the 1004 pairs of trees with 20-29 leaves, and 127 of the 386 tree pairs with 30-39 leaves. We were able to reliably compute replug distances for trees with up to 65 leaves (114/133 successes in the 50-65 leaf range) and TBR distances for trees with up to 100 leaves (1 failure from the 261 tree pairs in the 50-99 leaf range). 8.3 Mean distance Finally, we compared the mean SPR, replug, and TBR distance values for trees with a given number of leaves (Figure 7). We computed these values only for the tree pairs for which we successfully computed the SPR distance to obtain a fair comparison. We found that the replug distance is an excellent lower bound that closely tracks the SPR distance with a mean difference of 0.047 over 5335 tree pairs. The TBR distance had a mean difference of 0.325 from the SPR distance and 0.278 from the replug distance. In each of our completed tests, the TBR distance was at most 2 less than the replug distance and at most 3 less than the SPR distance, while the SPR distance never exceeded the replug distance by more than 1. 9 CONCLUSIONS We have worked to extend understanding of and methods to calculate the SPR distance between unrooted trees in several directions. We identified four properties of optimal SPR paths between unrooted trees which are atypical of NP-hard tree distance metrics that can be efficiently solved with an MAF formulation: both endpoints of an edge may be moved, the same endpoint of an edge may be moved multiple times, common clusters are not necessarily main- tained, and common paths may be broken. These observa- tions suggest that an MAF formulation is not applicable for computing the SPR distance between unrooted trees. To obtain an efficient search strategy we instead intro- duced a new lower bound on the SPR distance that we call the replug distance. Although the computational complexity of this distance is unknown, our work shows that it is fixed parameter tractable and we conjecture that it is NP-hard to compute. The replug distance captures important properties of the SPR distance while relaxing the requirement that intermediate structures be connected trees. Moreover, we showed that the replug distance can be modeled using an MAF variant that we call a maximum endpoint agreement forest or MEAF. We developed a two-phase fixed-parameter bounded search tree algorithm for the replug distance that runs in time O(16k(k1.5 + n))-time, where k is the SPR distance between the trees and n their number of leaves. This algorithm works by exploring the set of maximal agreement forests of the trees. Experiments suggest that these sets are typically small in practice [56]. Each such forest is then refined to a maximal endpoint agreement forest by solving boolean monotone CNF+(≤ 2) sets of constraints. These formulas naturally arise by considering sets of structures we call dead components in the trees given an mAF, and can be solved in polynomial time when converted to the minimimum edge cover problem of an appropriate constraint graph. Finally, we developed a new incremental heuristic search algorithm that we call progressive A* search. This algorithm expands the search for a given tree outward from the initial tree by applying increasingly expensive but more accurate lower bound estimators. The algorithm is applicable to any search problem that admits such a set of estimators, each of which is a lower bound on the next. Progressive A* search computes the SPR distance d between two unrooted trees in O((28d)!!16dd1.5)-time. Our implementation in the uspr software package uses a TBR approximation, TBR distance, and replug distance as lower bounds. Our results show that uspr is nearly two orders of magnitude faster than the previous best software for computing SPR distances between unrooted trees. In particular, our methods double the maximum SPR distance that can be computed given 5 hours from 7 to 14, and increase the size of trees that can be reliably compared from 30 to 50 leaves. Moreover, our implementation of the replug and TBR distance metrics can handle distances as large as 21 and 25, respectively. The replug and TBR algorithms were able to reliably handle trees with up to 65 and 100 leaves, respectively. The development of initial fixed-parameter bounded search tree algorithms for the SPR distance between rooted trees quickly led to the current state of the art algorithms which can handle distances of 100 or more on trees with hundreds of leaves in only fractions of a second. These im- provements came from a combination of structural insights leading to improved branching rules and new reductions such as the cluster reduction rule which splits the compared trees into independently comparable subtrees. Although unrooted trees are not clusterable with respect to the un- rooted SPR distance, we conjecture that they are clusterable with respect to the replug distance. As faster algorithms for the TBR and replug distance will immediately reduce the time required by our progressive A* search framework, we believe that refining these algorithms represents the best strategy for futher reducing the time required to compute SPR distances between unrooted trees. In addition, tech- niques from the incremental heuristic search literature may also lead to improved algorithms for computing SPR dis- tances. Alternatively, further structural analysis may lead to a direct refinement procedure from MEAFs to unrooted SPR paths, representing another branch of study for future work. Finally, it remains to extend our methods to nonbinary trees or to comparing sets of more than two trees, which are active avenues of research with respect to rooted trees. ACKNOWLEDGMENTS This work was funded by National Science Foundation award 1223057 and 1564137. C. Whidden is a Simons Foun- dation Fellow of the Life Sciences Research Foundation. The research of F. Matsen was supported in part by a Faculty Scholar grant from the Howard Hughes Medical Institute and the Simons Foundation. REFERENCES [1] D. M. Hillis, C. Moritz, and B. K. Mable, Eds., Molecular Systemat- ics. Sinauer Associates, 1996. 13 [2] E. V. Koonin, "The turbulent network dynamics of microbial evo- lution and the statistical tree of life," Journal of molecular evolution, pp. 1–7, 2015. [3] E. Castro-Nallar, M. P´erez-Losada, G. F. Burton, and K. A. Cran- dall, "The evolution of HIV: inferences using phylogenetics," Molecular phylogenetics and evolution, vol. 62, no. 2, pp. 777–792, 2012. [4] B. F. Haynes, G. Kelsoe, S. C. Harrison, and T. B. Kepler, "B-cell- lineage immunogen design in vaccine development with HIV-1 as a case study," Nature biotechnology, vol. 30, no. 5, pp. 423–433, 2012. [5] M. R. Helmus, T. J. Bland, C. K. Williams, and A. R. Ives, "Phy- logenetic measures of biodiversity," The American Naturalist, vol. 169, no. 3, pp. E68–E83, 2007. [6] F. A. Matsen, "Phylogenetics and the human microbiome," Sys- tematic Biology, vol. 64, no. 1, pp. e26–e41, 2015. [7] N. Galtier and V. Daubin, "Dealing with incongruence in phyloge- nomic analyses," Philosophical Transactions of the Royal Society B: Biological Sciences, vol. 363, no. 1512, pp. 4023–4029, 2008. [8] R. G. Beiko, T. J. Harlow, and M. A. Ragan, "Highways of gene sharing in prokaryotes," Proceedings of the National Academy of Sciences of the United States of America, vol. 102, no. 40, pp. 14 332– 14 337, 2005. [9] C. Whidden, N. Zeh, and R. G. Beiko, "Supertrees based on the subtree prune-and-regraft distance," Systematic Biology, vol. 63, no. 4, pp. 566–581, 2014. [10] D. Pisani, J. A. Cotton, and J. O. McInerney, "Supertrees disentan- gle the chimerical origin of eukaryotic genomes," Molecular Biology and Evolution, vol. 24, no. 8, pp. 1752–1760, 2007. [11] M. Steel and A. Rodrigo, "Maximum likelihood supertrees," Systematic Biology, vol. 57, no. 2, pp. 243–250, Apr. 2008. [Online]. Available: http://dx.doi.org/10.1080/10635150802033014 [12] M. S. Bansal, J. G. Burleigh, O. Eulenstein, and D. Fern´andez-Baca, "Robinson-Foulds supertrees." Algorithms for Molecular Biology, vol. 5, no. 18, pp. 1–12, 2010. [13] D. F. Robinson and L. R. Foulds, "Comparison of phylogenetic trees," Mathematical Biosciences, vol. 53, no. 1-2, pp. 131–147, 1981. [14] W. H. E. Day, "Optimal algorithms for comparing trees with labeled leaves," Journal of Classification, vol. 2, no. 1, pp. 7–28, 1985. [15] G. S. Brodal, R. Fagerberg, and C. N. Pedersen, "Computing the quartet distance between evolutionary trees in time O (n log n)," Algorithmica, vol. 38, no. 2, pp. 377–395, 2004. [16] M. Owen and J. S. Provan, "A fast algorithm for computing geodesic distances in tree space," IEEE/ACM Transactions on Com- putational Biology and Bioinformatics (TCBB), vol. 8, no. 1, pp. 2–13, 2011. [17] M. Baroni, S. Gr unewald, V. Moulton, and C. Semple, "Bounding the number of hybridisation events for a consistent evolutionary history," Journal of Mathematical Biology, vol. 51, no. 2, pp. 171–182, 2005. [18] T. C. Bruen and D. Bryant, "Parsimony via consensus," Systematic Biology, vol. 57, no. 2, pp. 251–256, 1 Apr. 2008. [Online]. Available: http://sysbio.oxfordjournals.org/content/57/2/251.abstract [19] S. Kelk and M. Fischer, "On the complexity of computing MP distance between binary phylogenetic trees," arXiv preprint arXiv:1412.4076, 2014. [20] V. Moulton and T. Wu, "A parsimony-based metric for phyloge- netic trees," Advances in Applied Mathematics, vol. 66, pp. 22–45, 2015. [21] R. G. Beiko and N. Hamilton, "Phylogenetic identification of lateral genetic transfer events," BMC Evolutionary Biology, vol. 6, no. 1, p. 15, 2006. [22] W. P. Maddison, "Gene trees in species trees," Systematic Biology, vol. 46, no. 3, pp. 523–536, 1997. [23] L. Nakhleh, T. Warnow, C. R. Lindner, and K. St. John, "Recon- structing reticulate evolution in species-theory and practice," Journal of Computational Biology, vol. 12, no. 6, pp. 796–811, 2005. [24] M. N. Price, P. S. Dehal, and A. P. Arkin, "FastTree 2– approximately maximum-likelihood trees for large alignments," PLoS One, vol. 5, no. 3, p. e9490, 2010. [25] A. Stamatakis, "RAxML-VI-HPC: maximum likelihood-based phylogenetic analyses with thousands of taxa and mixed models," Bioinformatics, vol. 22, no. 21, pp. 2688–2690, 23 Aug. 2006. [26] F. Ronquist, M. Teslenko, P. van der Mark, D. L. Ayres, A. Darling, S. Hohna, B. Larget, L. Liu, M. A. Suchard, and J. P. Huelsenbeck, "MrBayes 3.2: efficient Bayesian phylogenetic inference and model choice across a large model space," Systematic Biology, vol. 61, no. 3, pp. 539–542, 22 Feb. 2012. [Online]. Available: http://dx.doi.org/10.1093/sysbio/sys029 lanta, GA, USA, August 4-6, 2014, Proceedings, vol. 8591. Springer, 2014, p. 381. 14 [49] S. Linz and C. Semple, "A cluster reduction for computing the subtree distance between phylogenies," Annals of Combinatorics, vol. 15, no. 3, pp. 465–484, 2011. [50] C. Whidden and F. A. Matsen IV, "Chain reduction preserves the unrooted subtree prune-and-regraft distance," arXiv preprint arXiv:1611.02351, 2016. [51] M. L. Bonet and K. St John, "On the complexity of uSPR distance," IEEE/ACM Transactions on Computational Biology and Bioinformatics (TCBB), vol. 7, no. 3, pp. 572–576, 2010. [52] F. Shi, J. Chen, Q. Feng, and J. Wang, "Paramaterized algorithms for maximum agreement forest on multiple trees," in Computing and Combinatorics: 19th International Conference, COCOON 2013, Hangzhou, China, June 21-23, 2013. Proceedings, vol. 8591. Springer Berlin Heidelberg, 2013, pp. 567–578. [53] M. Baroni, C. Semple, and M. Steel, "Hybrids in real time," Systematic Biology, vol. 55, no. 1, pp. 46–56, 2006. [54] C. Whidden and N. Zeh, "A unifying view on approximation and FPT of agreement forests," in Proceedings of the 9th International Workshop, WABI 2009, ser. Lecture Notes in Bioinformatics, vol. 5724. Springer-Verlag, 2009, pp. 390–401. [55] J. Chen, J.-H. Fan, and S.-H. Sze, "Parameterized and approxima- tion algorithms for the MAF problem in multifurcating trees," in Graph-Theoretic Concepts in Computer Science. Springer, 2013, pp. 152–164. [56] J. Voorkamp, "Maximal acyclic agreement forests," Journal of Com- putational Biology, vol. 21, no. 10, pp. 723–731, 2014. [57] S. Porschen and E. Speckenmeyer, "Algorithms for variable- weighted 2-SAT and dual problems," in Theory and Applications of Satisfiability Testing–SAT 2007. Springer, 2007, pp. 173–186. [58] P. E. Hart, N. J. Nilsson, and B. Raphael, "A formal basis for the heuristic determination of minimum cost paths," Systems Science and Cybernetics, IEEE Transactions on, vol. 4, no. 2, pp. 100–107, 1968. [59] C. Whidden, "uspr," https://github.com/cwhidden/uspr, 2015. [60] Y. Wu and J. Wang, "Fast computation of the exact hybridization number of two phylogenetic trees," in Bioinformatics Research and Applications. Springer, 2010, pp. 203–214. Freeman, 1979. [61] M. R. Garey and D. S. Johnson, Computers and intractability. W. H. [62] S. Micali and V. V. Vazirani, "An O(√V E) algorithm for finding maximum matching in general graphs," in Foundations of Computer Science, 1980., 21st Annual Symposium on. IEEE Computer Society Press, 1980, pp. 17–27. [27] R. Bouckaert, J. Heled, D. K uhnert, T. Vaughan, C.-H. Wu, D. Xie, M. A. Suchard, A. Rambaut, and A. J. Drummond, "BEAST 2: a software platform for Bayesian evolutionary analysis," PLoS Computational Biology, vol. 10, no. 4, p. e1003537, 2014. "Extremal in C. McDiarmid, operations [28] R. Atkins and subtree preprint for arXiv http://arxiv.org/abs/1509.00669 transfer arXiv:1509.00669, distances trees," [Online]. Available: binary 2015. [29] Y. Ding, S. Gr unewald, and P. J. Humphries, "On agreement forests," Journal of Combinatorial Theory, Series A, vol. 118, no. 7, pp. 2059–2065, Oct. 2011. [30] C. Lakner, P. Van Der Mark, J. P. Huelsenbeck, B. Larget, and F. Ronquist, "Efficiency of Markov chain Monte Carlo tree propos- als in Bayesian phylogenetics," Systematic Biology, vol. 57, no. 1, pp. 86–103, 2008. [31] S. Hohna and A. J. Drummond, "Guided tree topology proposals for Bayesian phylogenetic inference," Systematic Biology, vol. 61, no. 1, pp. 1–11, 2012. [32] C. Whidden and F. A. Matsen IV, "Quantifying MCMC exploration of phylogenetic tree space," Systematic Biology, vol. 64, no. 3, pp. 472–491, 27 Jan. 2015. [Online]. Available: http://dx.doi.org/10.1093/sysbio/syv006 [33] M. Bordewich and C. Semple, "Computing the minimum number of hybridization events for a consistent evolutionary history," Discrete Applied Mathematics, vol. 155, no. 8, pp. 914–928, 2007. [34] --, "On the computational complexity of the rooted subtree prune and regraft distance," Annals of Combinatorics, vol. 8, no. 4, pp. 409–423, 2005. [35] G. Hickey, F. Dehne, A. Rau-Chaplin, and C. Blouin, "SPR dis- tance computation for unrooted trees," Evolutionary Bioinformatics Online, vol. 4, p. 17, 2008. [36] C. Whidden, R. G. Beiko, and N. Zeh, "Fast FPT algorithms for computing rooted agreement forests: theory and experiments," in Experimental algorithms. Springer, 2010, pp. 141–153. [37] G. Dudas, T. Bedford, S. Lycett, and A. Rambaut, "Reassortment between Influenza B lineages and the emergence of a co-adapted PB1-PB2-HA gene complex," Molecular biology and evolution, p. msu287, 2014. [38] C. Whidden and F. A. M. IV, "Ricci-Ollivier curvature of the rooted phylogenetic subtree-prune-regraft graph," proceedings of the Thirteenth Workshop on Analytic Algorithmics and Combinatorics (ANALCO16), 2016. [39] J. Hein, T. Jiang, L. Wang, and K. Zhang, "On the complexity of comparing evolutionary trees," Discrete Applied Mathematics, vol. 71, no. 1-3, pp. 153–169, 1996. [40] B. L. Allen and M. Steel, "Subtree transfer operations and their induced metrics on evolutionary trees," Ann. Comb., vol. 5, no. 1, pp. 1–15, 2001. [41] Y. Wu, "A practical method for exact computation of subtree prune and regraft distance," Bioinformatics, vol. 25, no. 2, pp. 190–196, 2009. [42] M. L. Bonet and K. St. John, "Efficiently calculating evolutionary tree measures using SAT," in Proceedings of the 12th International Conference on Theory and Applications of Satisfiability Testing, ser. Lecture Notes in Computer Science, vol. 5584. Springer-Verlag, 2009, pp. 4–17. [43] C. Whidden, R. G. Beiko, and N. Zeh, "Fixed-Parameter algo- rithms for maximum agreement forests," SIAM J. Comput., vol. 42, no. 4, pp. 1431–1466, 2013. [44] F. Shi, J. You, and Q. Feng, "Improved approximation algorithm for maximum agreement forest of two trees," in Frontiers in Algo- rithmics. Springer, 2014, pp. 205–215. [45] Z.-Z. Chen, Y. Fan, and L. Wang, "Faster exact computation of rSPR distance," Journal of Combinatorial Optimization, vol. 29, no. 3, pp. 605–635, 2013. [46] C. Whidden, R. G. Beiko, and N. Zeh, "Fixed-Parameter and ap- proximation algorithms for maximum agreement forests of multi- furcating trees," Algorithmica, pp. 1–36, 2015, doi: 10.1007/s00453- 015-9983-z. [47] J. Chen, J.-H. Fan, and S.-H. Sze, "Parameterized and approxima- tion algorithms for maximum agreement forest in multifurcating trees," Theoretical Computer Science, vol. 562, pp. 496–512, 2015. [48] F. Shi, J. Chen, Q. Feng, and J. Wang, "Approximation algorithms for maximum agreement forest on multiple trees," in Computing and Combinatorics: 20th International Conference, COCOON 2014, At- 2 2 54 54 a) 3 4 5 6 7 APPENDIX A PROOFS AND SUPPLEMENTAL FIGURES A.1 Additional definitions We first specify some definitions that are only used in the following proofs. A set of four leaves {a, b, c, d} of an unrooted tree T form a quartet abcd when the path from a to b and the path from c to d are vertex-disjoint. A forest contains each of the quartets of its individual component trees. Given a tree T and a forest F , we say a quartet abcd of T is incompatible with F if its leaves do not all belong to the same component of F or define a different quartet in F (e.g. acbd). Whidden and Zeh [54] observed that: Observation A.1. Let T1 and T2 be unrooted X-trees, F a forest of T2 and E a set of edges of F such that F − E yields an agreement forest of T1 and T2. If abcd is a quartet of T1 incompatible with F , then either a 6∼F −E b, a 6∼F −E c, or c 6∼F −E d. A.2 Proofs Lemma 5.3. Let M = m1, m2, . . . , mk be an optimal sequence of replug moves transforming a tree T1 into a tree T2. Then M does not (1) move the same endpoint u of an edge twice, (2) break a common cluster of T1 and T2, or (3) break an edge of a common path of T1 and T2 with respect to M . b) Proof. Consider an SAF F of T1 and T2 that permits M . Assume, for the purpose of obtaining a contradiction, the opposite of the first claim: that two distinct moves mi and mj move the same endpoint u of a connection c of F . We choose i and j such that no move mk moves endpoint u of c, for all i < k < j. Consider the sequence of replug moves M ′ = m1, m2, . . . , mi−1, mi+1, mi+2, . . . , mk. By Observation 5.2 and the fact that no moves of M between mi and mj move endpoint u, this is a valid sequence of replug moves at least through move mj−1. Moreover, mj is then a valid move that results in the same forest as applying mj in sequence M . Therefore applying the remainder of the sequence results in the same tree, which implies that M and M ′ both result in tree T2. The fact that M ′ is a smaller sequence contradicts the optimality of M , proving the claim. The second and third claims follow similarly, by substi- tuting moves that break and reform a common cluster and common path for mi and mj in the above argument. Theorem 5.4. Let T1 and T2 be unrooted trees. Then dR(T1, T2) = ω(T1, T2). Proof. We prove this by induction. We first show that dR(T1, T2) ≥ ω(T1, T2) by induction on dR(T1, T2). To do so, given an optimal sequence of replug moves transforming T1 into T2 (e.g. Fig S1(a)), we iteratively construct an EAF F of T1 and T2 such that ω(F ) = dR(T1, T2) (Fig S1(b)). Because cutting an endpoint edge set strictly increases the weight of a forest, ω(T1, T2) = 0 if and only if T1 = T2 (i.e. dR(T1, T2) = 0). This forms the base case of the induction. Suppose that our claim holds for every pair of trees with a replug distance less than d and that dR(T1, T2) = d. More- over, let m1, m2, . . . , md be a sequence of replug moves that transform T1 into T2. If d = 1 then let T ′ 2 = T1. Otherwise, 3 4 5 6 9 3 4 5 6 5 6 9 9 8 T 7 8 T   2 2 3 4 5 6 7 9 8 T  7 9 8  2  2 3 4 c) 5 6 3 4  7 9 8 EAF,2) 7 8 EAF  ,2) 15 6 9 8 7  5 6 6 9 8 7 3 3 5 6  2 T  2 2  4  7 3 2 T2  2 3 4  7 9 8 8 2) EAF,2) EAF,  9 6 9 8 7  54 3 2 T2 Fig. S1. The conversion processes from Theorem 5.4. (a) The trees from Figure 2(a). (b) An EAF is built iteratively from each replug move by cutting the changed edge and attaching a φ node to the fixed endpoint (tail of the dashed arrow from (a)). If the other endpoint is a φ node then both sides of the edge have moved so the φ node is removed and none added. (c) Given just the EAF, a start tree and an end tree, a minimal replug path can be found by applying replug moves that merge components of the EAF. If there is a φ node we apply a replug move and merge two components. When no φ nodes remain, we merge components by applying TBR moves (i.e. two replug moves). let T ′ 2 be the result of applying the sequence of moves m1, md, . . . , md−1 to T1, so that md transforms T ′ 2 into T2. Thus, by the inductive hypothesis, there exists an EAF F ′ 2 such that ω(F ′) = d − 1. For example, F ′ is of T1 and T ′ labeled EAF(T1, T ′ 2) in Fig S1(b). Let e = (u, v) be the edge moved by md, where u is the endpoint of e that is not moved and v is the endpoint of e that is moved. Now, we wish to cut edge e in F ′ to obtain an EAF of T1 and T2. There are two cases depending on whether e has already been cut in F ′. First, assume that e has been cut. An optimal sequence of replug moves never moves the same endpoint v of an edge e twice by Lemma 5.3. This implies that the replug move in m1, m2, m3, . . . , md−1 which corresponds to cutting edge e must have moved endpoint u rather than endpoint v. Thus, F ′ contains an edge e′ = (v, φ). Moreover, T ′ 2 and T2 differ only in the location of endpoint v of edge e. We remove the ⊲∅}. F ′′ is φ node from e′ to obtain the forest F ′′ = F ′ ÷{e′ an EAF of T1 and T2 with weight d, which proves the claim. For example, F ′′ is labeled EAF(T1,T2) in Fig S1(b). If e has not been cut, then take F = F ′ ÷ {e ⊲{u}}. Because T ′ 2 and T2 differ only in the location of endpoint v of edge e, F is an EAF of T1 and T2. Moreover, F has weight d, so the claim holds. For example, EAF(T1,T ′ 2) in Fig S1(b) can be obtained in this way from the previous EAF of T1 and T ′ 1. that into T2 transform T1 For the other direction, we show that dR(T1, T2) ≤ ω(T1, T2) by constructing a sequence of replug moves m1, m2, . . . , mω(T1,T2) (e.g. Fig S1(a) using Fig S1(c)). If ω(T1, T2) = 0 then T1 = T2 and we construct an empty sequence of replug moves that transform T1 into T2, forming the base case. By induction on ω(T1, T2), suppose that our claim holds for every pair of trees with an MEAF of weight less than ω, and that ω(T1, T2) = ω. Let F be an MEAF of T1 and T2 (labeled EAF(T1,T2) in Fig S1(c)). Let E be an endpoint edge set such that T1 ÷ E = F . There are two cases: either F is an MAF of T1 and T2 (F has no φ nodes), or F is not an MAF of T1 and T2 (F has φ nodes). If F is an MAF, then we can map it to a set of ω/2 TBR operations, and therefore a set of ω replug operations and the claim holds. For example, EAF(T ′ 1,T2) in 1 and T2 and we can transform T ′ Fig S1(c) is an MAF of T ′ 1 into T2 by a single TBR operation. We can then separate that TBR operation into two equivalent replug operations. So, assume that F is not an MAF. Then some component Ci contains a φ node x1. By the definition of an agreement forest, there exists at least one component Cj of F that is "effectively adjacent" to Ci. That is, Ci and Cj are joined by a path P = x1, x2, . . . , xq of nodes in T2 such that x1 ∈ Ci, xq ∈ Cj, and xl /∈ F , for all 1 < l < q. Let e1 be the edge adjacent to x1 in T1. Note that the φ node implies that e1 ⊲{x1} ∈ E. Let yq be the neighbor of xq in Cj such that xq−1 is on the path from yq to xq in T2. We apply a replug move m to connect x1 to the edge adjacent to xq that is closest to yq, resulting in T ′ 1. The node introduced by this replug move is xq−1, which connects Ci and Cj in T ′ 1. Thus, T ′ 1 and T2 with weight ω − 1. By the inductive hypothesis, we can construct a sequence of ω − 1 replug moves M transforming T ′ 1 to T2. Therefore, the sequence of ω replug moves starting with m and then applying the moves in M transforms T1 to T2, 1 ÷ (E \ {e1 ⊲{x1}}) is an MEAF of T ′ 16 and the claim holds. For example, in Fig S1(c) we see that leaves 6 and 9 are adjacent in T2. We apply a replug move to T1 that merges components of EAF(T1,T2) to obtain T ′ 1 and EAF(T ′ 1,T2). Corollary 5.5. Let F be an EAF of two unrooted trees T1 and T2. A sequence of ω(F ) replug moves that transform T1 into T2 can be obtained from F in O(nω(F ))-time. Proof. We will show that we can find, in linear time, a replug move on T1 that results in a tree T ′ such that dR(T ′, T2) = ω(F )− 1. Recursively applying this procedure ω(F ) times proves the claim. The proof of Theorem 5.4 provides a method to find such a move, so we show here that this method can be implemented to take linear time. We can construct mappings ψ and ψ−1 from the trees to the EAF in linear time by Lemma 6.3. The steps of this procedure are to (1) select a compo- nent Ci of F with a φ node if any exist and an arbitrary component otherwise, (2) identify a second component Cj of F that is effectively adjacent to Ci in T2, and (3) apply the corresponding move to attach Ci to Cj . By effectively adjacent, we again mean that we must choose Cj such that Ci and Cj are joined by a path P = x1, x2, . . . , xm of nodes in T2 that does not include any nodes of another component Ck or any nodes of Ci other than x1. We can find a component Ci of F with a φ node x1, if any exist, in linear time by traversing the forest. Otherwise, we can find an arbitrary component Ci in linear time. To find a valid component Cj we first label the nodes of F according to their component numbers, which takes linear time. For each node n of F , we then label the corresponding T2 node ψ−1(T2, n) with n's component number. Finally, we apply a traversal of T2 that starts from ψ−1(T2, x1) and finds such a path by not visiting nodes labeled i and terminating upon finding the first otherwise labeled node xm. We can then apply a replug move that connects xi to xm, resulting in a tree T ′ with an EAF of T ′ and T2 with weight ω(F ) − 1. The steps are similar when no component has a φ node, except that we begin our traversal from an arbitrary node x1 of the chosen Ci that is adjacent to a node x2 of T2 such that ψ(x2) = ∅. Theorem 5.6. For any pair of trees T1 and T2, dTBR(T1, T2) ≤ dR(T1, T2) ≤ dSPR(T1, T2). Proof. We showed in the proof of Theorem 5.4 that the TBR distance is a lower bound for the replug distance. To see that the replug distance is a lower bound for the SPR distance, it suffices to note that every SPR move is also a replug move, that is, every sequence of SPR moves is also a valid sequence of replug moves. Lemma 6.1. mAF(T1, T2, k) returns the set of maximal agree- ment forests of T1 and T2 that can be obtained by cutting k or fewer edges. that observe Proof. We first returned by mAF(T1, T2, k) cannot contain an object that is not an agree- ment forest, as Step 2 will never apply. Now, suppose that the algorithm misses a maximal agreement forest F of T1 and T2 that can be obtained by cutting fewer than k edges. the set Let E be an edge set such that F = T2÷ E. Steps 6.1 and 6.2 are the only steps that modify F2. Thus, every path of recursive invocations terminates in a Step 1 and contains an invocation mAF(F1, F2, k′) that applied Step 6.1 or Step 6.2 such that every cut edge e′ ∈ F2 partitions a pair of leaves that are in the same component of F . So, consider an arbitary path of recursive calls and let mAF(F1, F2, k′) be the first call on this path that applied Step 6.1 or Step 6.2 such that every cut edge e′ ∈ F2 partitions a pair of leaves l1 and l2 that are in the same component of F . In Step 6.1, the fact that a and c are siblings in F1 but a 6∼F2 c implies that either a 6∼F x for all x ∈ (Rt \ {a}), or c 6∼F x for all x ∈ (Rt \ {c}), a contradiction. Observation A.1 implies the same for Step 6.2 with re- spect to at least one of a, b1, bq, or c. We observe that Step 6.2 is the expanded form of the union of four recursive calls: mAF(F1, F2 ÷ {ea}, k − 1) ∪ mAF(F1, F2 ÷ {eb1}, k − 1) ∪ mAF(F1, F2 ÷ {ebq}, k − 1) ∪ mAF(F1, F2 ÷ {ec}, k − 1). To see this, first note that both Step 6.2 and these four calls include calls cutting ea and ec. Thus, both sets of calls will find any mAF that is a forest of F2÷{ea} or F2÷{ec}. Now, observe that an application of the calls cutting eb1 or ebq can not remove the incompatible sibling pair {a, c} (unless q = 2 and both sets of recursive calls are identical). Expanding all possible combinations of repeated applications of these calls results in the cases of Step 6.2. Thus, one of the cut edge sets partitions only leaves which are partitioned in F , also a contradiction. Theorem 6.2. Given two trees T1 and T2, the set S of maximal agreement forests of T1 and T2: 1) can be enumerated in O(4kn)-time, 2) can be returned in O(4kn + S log S)-time (the log S 3) is of size at most 4k. factor required to avoid duplicate agreement forests), and Proof. This proof follows similar arguments to those of Whidden and Zeh [54]. mAF(T1, T2, k) is a bounded search tree algorithm which proceeds to a depth at most k and whose worst case behaviour is fully defined by the branch- ing factor of the recurrence relation of Step 6.2 which is maximized when q = 2 (i.e. 4 single edge cut invocations). Thus, there are at most 4k recursive invocations in total, each of which requires linear time (using the data structures from [54]), excluding the cost of recursion and set union operations. F can be constructed in linear time, and Lemma 6.3. Let F be an mAF of two trees T1 and T2. Then 1) two sets of edges E1 and E2 such that T1÷E1 = T2÷E2 = 2) a mapping ψ(x) from T1 and T2 nodes to nodes of F and the reverse mappings ψ−1(Ti, x) can be built in O(n)-time; lookups using these mappings take constant time. Proof. We adapt the procedure of Lemma 4.3 in [43] to the unrooted case. This procedure constructs, in linear time, a cycle graph structure that is essentially the union of F , E1, E2, and an explicit mapping from nodes of T1 and T2 to F and vice versa. Although written in terms of rooted trees, the fact that the root is a labeled leaf implies that 17 89 7 1 1 2 3 7 4 5 6 21 4 3 7 a) 5 6 1 2 3 7 4 5 6 9 8 T1 2 4 1 3 7 9 8 mAF b) 5 6 4 d) 5 6 1 2 3 7 9 8 2 3 T2 4 c) 5 6 9 8 SAF 4 e) 5 6 φ φ 1 2 3 7 9 8 SAF 9 8 MEAF Fig. S2. The intermediate structures used to find MEAFs. (a) An optimal replug path between a pair of trees, T1 and T2. (b) The single mAF of T1 and T2 can be obtained by cutting any two of the three dotted edges in T1 or T2. The T1 and T2 edge triples are both dead trees. (c) The SAF obtained by adding each of the removed nodes as sockets to the mAF. (d) An SAF with a set of candidate φ-nodes is a subset of the SAF from c). Only sockets that correspond to nodes of both trees can remain fixed during a replug move, constraining our choices of dead tree edges. (e) The mEAF obtained by adding φ nodes is also the MEAF in this case. this procedure also applies to unrooted trees by choosing an arbitrary leaf as the "root". We can obtain E1 and E2 from this structure by (1) iterating through the edges of the cycle graph and (2) applying the respective node mapping to identify the T1 or T2 edge. Theorem 6.4. Given two trees T1 and T2, the set of mEAFs of T1 and T2 with k + 1 or fewer components can be enumerated in O(48kn)-time and there are at most 48k such mEAFs. Proof. We apply mAF(T1, T2, k) to enumerate the set of AFs of T1 and T2 with k + 1 or fewer components. This requires O(4kn)-time, by Theorem 6.2. For each of the at most 4k AFs F , we apply replug(T1, T2, F, k) to enumerate the mEAFs, taking O(4k · 12kn) = O(48kn) time. Theorem 6.5. Given two trees T1 and T2, the set of mEAFs of T1 and T2 with weight at most d and k + 1 or fewer components can be enumerated in O(min(4k, 2.42d) · 12kn)-time and there are at most (min(4k, 2.42d) · 12k) such mEAFs. Proof. Using a standard analysis of the recurrence relation T (d) = 2T (d − 1)T (d − 2) for the number of recursive calls, and the fact that each call requires linear time, barring the cost of recursion, this algorithm takes O(2.42dn)-time to determine whether a given edge set E1 is compatible with an EAF of weight at most d. Each branch of the search will terminate after k recursive calls, so this will never take longer than the original version. Lemma 6.6. Given a socket agreement forest S of two trees T1 and T2, an assignment of φ-nodes to sockets of S is an EAF of T1 and T2 if, and only if, the assignment satisfies every dead tree in T1 and T2 with respect to S. Proof. We first prove that every such assignment A is an EAF. Let A be an assignment of φ-nodes to sockets of S that satisfies every dead tree in T1 and T2 (e.g. Fig S2(e)). Let D be a dead tree of T1 adjacent to a set s of nD sockets of S (Fig S2(a)). The fact that D is adjacent to nD sockets implies that D was induced by removing nD − 1 edges of E1 from T1. Moreover, at least one socket in s does not have a φ node. Each of the φ-nodes assigned to these sockets can be assigned to one of the E1 edges within D. An analogous assignment can be applied to the dead trees of T2. Applying this procedure iteratively to every dead tree of T1 and T2 results in an EAF of T1 and T2. We now prove that every EAF induces such an as- signment A. Let F ′ be an EAF of T1 and T2 obtained by removing edge sets E1 from T1 and E2 from T2 (e.g. Fig S2(b)). Let S be the SAF induced by F ′ (e.g. Fig S2(c)). Let A be the natural assignment of φ-nodes to sockets of S (Fig. S2(e)). A is obtained by adding φ-nodes to some subset of S (e.g. Fig S2(d)). Now, suppose that A assigns a φ node to each of the nD sockets adjacent to some dead component of T1. Then both sides of one of the nD − 1 edges of T1 in D and E1 must have received a φ node, a contradiction. Lemma 6.7. The replug distance problem on an SAF S of trees T1 and T2 can be solved by solving the minimum cardinality sat- isfiability problem on a boolean monotone CNF+(≤ 2) formula. Proof. By Lemma 6.6, it suffices to find an assignment of φ nodes to S that satisfy each dead component of T1 and T2. Now, consider the set of constraints induced by these dead components. We say that such a dead tree is saturated if every endpoint of the dead tree is a candidate φ-node. We only consider constraints from saturated dead trees, as the constraints from unsaturated dead trees are trivially satisfied by excluding a socket that is not a φ- node candidate. Each dead tree implies a constraint of the form (s1 ∪ s2 ∪ . . . ∪ snD ), where the variable si implies that socket si is not assigned a φ node. Moreover, a socket may be adjacent to at most two dead trees (one per tree), so each variable appears in at most 2 constraints. There are at most 2k such constraints, with at most 2k variables. Finally, 18 each variable in a constraint is positive, that is no constraint includes ¬si. Thus, the full set of constraints is a boolean monotone CNF+(≤ 2) formula. Lemma 6.8. Given an SAF F of two trees T1 and T2, an EAF F ′ of T1 and T2 can be computed in O(k1.5)-time such that F ′ has F as its underlying agreement forest and F ′ contains as many φ-nodes as any such EAF. Proof. In the clause graph, each constraint of the formula is represented by a vertex. Two vertices are connected by an edge if they share a variable. A satisfying φ-node assign- ment must include one true variable for each clause, and we wish to determine the minimum number of variables that must be true. In other words, we wish to determine the minimum number of φ-node candidates that do not receive a φ-node. To do so, we can select a set of edges C such that every vertex in the graph is adjacent to an edge in C: in other words, an edge cover. Moreover, we wish to determine the minimum number of edges in any such edge cover-the edge cover problem. The edge cover problem can be solved by finding a maximum matching (set of nonadjacent edges) and greedily adding additional edges [61]. This requires O(√V E)-time [62], for a graph with V vertices and E edges. Our clause graph has at most 2k edges and vertices, and so requires O(k1.5)-time to solve. Observe that we can determine the set of φ nodes from the edge cover and thus also construct the EAF. Theorem 6.9. Given two trees T1 and T2, an EAF F of T1 and T2 with ω(F ) = dR(T1, T2) and k + 1 components can be found (or determined not to exist) in: 1) O(4k(4kk1.5 + n))-time, or 2) O(4kn + Y k1.5)-time, where Y is the number of candidate SAFs with at most k + 1 components. Proof. We iteratively increase k′ = 0, 1, . . . , k until we find an MEAF of T1 and T2. We apply mAF(T1, T2, k) to enu- merate the set of mAFs of T1 and T2 that can be obtained by cutting k or fewer edges. For each such mAF F obtained by cutting k′ edges, we enumerate each of the at most 4k′ SAFs induced by F . We apply the procedure in Lemma 6.8 to each SAF S to determine whether an assignment of φ-nodes to S can be made that results in EAF of T1 and T2 with weight ≤ k. mas 6.1, 6.6, and 6.8. The correctness of this procedure follows from Lem- The running time of the procedure follows from Theo- rem 6.2 and Lemma 6.8. Corollary 6.10. The replug distance for a pair of trees T1 and T2 can be solved in O(16dd1.5)-time, where d = dR(T1, T2). Proof. We first prove the running time bound. Allen and Steel [40] proved that interleaving the subtree and chain reduction rules results in a pair of trees T ′ 2 with at most 28dTBR(T1, T2) leaves. By Theorem 5.6, this is at most 28dR(T1, T2) leaves. Substituting the size of the trees into Theorem 6.9 results in the claimed running time bound. 1 and T ′ To prove that this method is correct, we note that the chain reduction proof of [50] holds whether one consid- ers replug or SPR moves because it relies on finding an 19 alternative set of moves to avoid breaking the common chain. Similarly, the subtree reduction also preserves the replug distance because optimal replug paths do not break common edges. Theorem 7.1. The SPR distance between two unrooted trees T1 and T2 can be computed in O(Y 16dd1.5) time, where Y is the number of trees explored by the heuristic, and d = dSPR(T1, T2). Note that Y = O((28d)!!) after reducing T1 and T2. Proof. This algorithm is guaranteed to find T2, as no tree will ever be inserted into the priority queue twice with a priority determined by the same estimator function. Moreover, each distance estimate is a lower bound on the true SPR distance, by Theorem 5.6. Therefore, as with a standard A* search, the correct distance is guaranteed to be returned. Finally, this method will never compute a replug or TBR distance larger than dSPR(T1, T2) + 1, as we will never expand a tree T 6= T1 with an estimator greater than dSPR(T1, T2). This is an important consideration, as the running time of our TBR and replug distance calculations are exponential with respect to the distance computed. The algorithm explores Y trees, each of which has replug distance at most one greater than dSPR(T1, T2). Therefore the time required to compute estimators for each of these trees is O(16d+1((d + 1)1.5 + n)) by Corollary 6.10. This is O(16dd1.5) for reduced trees with n = O(d). All other operations on each tree can be carried out in time that is asymptotically smaller than the cost of a replug distance computation. Therefore the running time is bounded as claimed. x a9 a8 a7 b1 b2 b3 b4 c1 c2 c3 d1 d2 d3 e1 e2 e3 f1 f2 f3 f4 g1 g2 g3 20 g4 T1 a1 a4 a2 a3 a5 a6 i) b1 b2 b3 b4 c1 c2 c3 d1 d2 d3 e1 e2 e3 f1 f2 f3 f4 x g1 g2 g3 g4 a7 a8 a9 a1 a4 a3 a2 a6 a5 a3 a2 a1 c3 c2 c1 b4 b3 b2 b1 f4 f3 f2 f1 e3 e2 a7 a8 a9 d1 a6 a5 a4 d3 d2 a3 a2 a1 c3 c2 c1 e1 e2 e3 f1 f2 f3 f4 b1 b2 b3 a7 a8 a9 d1 a6 a5 a4 d3 d2 e1 b4 iv) v) x g1 g2 g3 x g1 g2 g3 g4 g4 b3 b2 b1 f4 f3 f2 f1 vi) b4 e3 e3 a3 a2 a1 c3 c2 c1 e1 e2 a7 a8 a9 d1 a6 a5 a4 d3 d2 x g1 g2 g3 g4 T2 e2 e1 c1 c2 c3 a1 a2 a3 x g4 d1 a9 a8 a7 b4 b3 b2 b1 f4 f3 f2 f1 g1 g2 g3 d2 d3 a4 a5 a6 Fig. S3. A portion of an SPR path between two trees T1 and T2 for which every optimal SPR path underlain by the sole MAF moves an endpoint of the same edge twice. The trees have SPR distance 7 and only one MAF with 6 components. The MAF can be obtained by removing the dotted edges. The SPR path shown, for example, moves the endpoint of edge x closest to leaf a7 of the a component twice, in the first and last move. Note that 3 moves are applied to move from i) to iv). c1 f1 i3 i4 i5 i6 T1 i) c2 c3 b1 b2 b3 a1 a2 a3 a4 h1 h2 f2 f3 e1 e2 e3 d1 d2 d3 d4 h3 h4 h6 h5 x g1 g2 g3 i1 i2 21 i3 i4 i5 i6 i2 i1 c1 c2 c3 b1 b2 b3 a1 a2 a3 a4 h1 h2 g3 f1 h6 h5 g1 g2 f2 f3 e1 e2 e3 d1 d2 d3 d4 h3 h4 iii) g3 h2 h1 a4 a3 a2 a1 i3 i4 i6 i2 i1 c1 c2 g2 g1 h5 h6 i5 h4 h3 d4 d3 d2 d1 e3 e2 e1 f3 f2 f1 b1 b2 b3 e3 c3 g3 h1 h2 h3 h4 f3 g1 v) vii) T2 i1 i2 c1 c2 c3 i1 i2 c1 c2 c3 i4 i3 a1 a2 a3 a4 b3 b2 b1 f1 f2 f3 e1 e2 i6 i5 d1 d2 d3 d4 h3 h4 h2 h6 h5 g1 g2 h1 f3 i4 i3 a1 a2 a3 a4 b3 b2 b1 f1 f2 i6 i5 d1 d2 d3 d4 e3 e2 e1 g3 g2 g1 h5 h6 h1 h2 h3 h4 h6 h5 x c1 c2 c3 i1 i2 i4 i3 a1 a2 a3 a4 b3 b2 b1 f1 f2 i6 i5 d1 d2 d3 d4 e3 e2 e1 g3 g2 Fig. S4. Two trees T1 and T2 for which every optimal SPR path breaks a common path. The trees have SPR distance 8 and every optimal SPR path modifies only the dotted edges, corresponding to the sole MAF. The SPR path shown, for example, breaks the common path x between the h and i components in the first move and then reforms this path in the eighth move. Note that each tree other than the second and last is a result of applying two SPR moves.
1802.10347
2
1802
2019-11-04T16:02:38
Decompressing Lempel-Ziv Compressed Text
[ "cs.DS" ]
We consider the problem of decompressing the Lempel--Ziv 77 representation of a string $S$ of length $n$ using a working space as close as possible to the size $z$ of the input. The folklore solution for the problem runs in $O(n)$ time but requires random access to the whole decompressed text. Another folklore solution is to convert LZ77 into a grammar of size $O(z\log(n/z))$ and then stream $S$ in linear time. In this paper, we show that $O(n)$ time and $O(z)$ working space can be achieved for constant-size alphabets. On general alphabets of size $\sigma$, we describe (i) a trade-off achieving $O(n\log^\delta \sigma)$ time and $O(z\log^{1-\delta}\sigma)$ space for any $0\leq \delta\leq 1$, and (ii) a solution achieving $O(n)$ time and $O(z\log\log (n/z))$ space. The latter solution, in particular, dominates both folklore algorithms for the problem. Our solutions can, more generally, extract any specified subsequence of $S$ with little overheads on top of the linear running time and working space. As an immediate corollary, we show that our techniques yield improved results for pattern matching problems on LZ77-compressed text.
cs.DS
cs
Decompressing Lempel-Ziv Compressed Text Philip Bille∗, Mikko Berggren Ettienne∗, Travis Gagie†, Inge Li Gørtz∗, and Nicola Prezza‡ ∗Technical University of Denmark †Dalhousie University 6050 University Ave. ‡University of Pisa Largo Bruno Pontecorvo 3 2800 Kgs. Lyngby Halifax, Canada Pisa, Italy Copenhagen, Denmark {phbi,inge}@dtu.dk , [email protected] [email protected] [email protected] Abstract We consider the problem of decompressing the Lempel -- Ziv 77 representation of a string S of length n using a working space as close as possible to the size z of the input. The folklore solution for the problem runs in O(n) time but requires random access to the whole decompressed text. Another folklore solution is to convert LZ77 into a grammar of size O(z log(n/z)) and then stream S in linear time. In this paper, we show that O(n) time and O(z) working space can be achieved for constant-size alphabets. On general alphabets of size σ, we describe (i) a trade-off achieving O(n logδ σ) time and O(z log1−δ σ) space for any 0 ≤ δ ≤ 1, and (ii) a solution achieving O(n) time and O(z log log(n/z)) space. The latter solution, in particular, dominates both folklore algorithms for the problem. Our solutions can, more generally, extract any specified subsequence of S with little overheads on top of the linear running time and working space. As an immediate corollary, we show that our techniques yield improved results for pattern matching problems on LZ77-compressed text. 1 Introduction In this paper we consider the following problem: given an LZ77 representation of a string S of length n, decompress S and output it as a stream in left-to-right order (without storing it explicitly). Our goal is to solve this problem in as little space as possible, i.e. close to the size z of the compressed input string, and as fast as possible. This problem is fundamental in applications dominated by big repetitive data, where information has to be analyzed on-the-fly due to limitations in storage resources. The folklore solution for the Lempel-Ziv decompression problem achieves linear time, but requires random access to the whole string. A better solution is to convert LZ77 into a straight-line program (i.e. a context-free grammar generating the text) of size O(z log(n/z)). This conversion can be performed in O(z lg(n/z)) space and time [1, 2]. Then, the entire text can be decompressed and streamed in linear time using just the space of the grammar. The problem has also been recently considered in [3] in the context of external-memory algorithms. To the best of our knowledge, the only other work addressing small-space LZ77 decompression is [4], which implements (a practical version of) the ideas described in our paper. In particular, no other theoretical solutions using O(z) space are known. 1.1 Our contributions The main contribution of this paper is to show that LZ77 decompression can be performed in O(z) space and almost linear time (in the length of the extracted string). We provide two space-time trade-offs which enable us to achieve either linear time or linear space or both if the alphabet's size is constant. The first trade-off is particularly appealing on small alphabets, while the second dominates the first on large alphabets and the folklore algorithm based on grammars. Our solution even works for decompressing any specified subsequence of S with little overheads on top of the linear running time (in the extracted substring's length) and working space. As an application, we show that our techniques yield improved results for pattern matching problems on LZ77-compressed text. used on top of the input and the output. Let the quantity l =(cid:80)s We formalize the LZ77 decompression problem as follows. The input consists of an LZ77 representation of a text (we use the version where phrases and sources are not al- lowed to overlap) and a list of text substrings encoded as pairs: (i1, j1), . . . , (is, js). We decompress these substrings and output them (e.g. to a stream or to disk) character- by-character in the order S[i1, j1], . . . , S[is, js]. Since both the input strings and the output can be streamed (for example, from/to disk) we only count the working space k=1(jk−ik +1) denote the total number of characters to be extracted. Our main results are summarized in the following two theorems. Let S be a string of length n from an alphabet of size σ compressed into an LZ77 representation with z phrases. Theorem 1. For any parameter 0 ≤ δ ≤ 1, we can decompress any s substrings of S with total length l in O(l lgδ σ + (s + z) lg(n/z)) time using O(z lg1−δ σ) space. Theorem 2. For any parameter 1 ≤ τ ≤ lg(n/z), we can decompress any s substrings time using O(z lg τ ) space. of S with total length l in O (cid:17) (cid:16) l lg(n/z) τ + (s + z) lg(n/z) Theorems 1 and 2 lead to a series of new and non-trivial bounds on different algorithmic problems on LZ77. For instance, we provide a smooth time-space trade- off for decompressing the whole S in O(n lgδ σ) time using O(z lg1−δ σ) space for any constant 0 ≤ δ ≤ 1. By combining Theorem 2 with τ = lg(n/z) with grammars, we furthermore show how to decompress S in O(n) time using O(z lg lg(n/z)) space. Both bounds are strict improvements over the previous best complexity of O(n) time and O(z lg(n/z)) space. See Section 4 and Corollaries 1 and 2 for details. Our results also imply new trade-offs for the pattern matching and approximate pattern matching problems on LZ77-compressed texts. By showing how our tech- niques can be combined with existing pattern matching results, in Appendix F we show the following: Theorem 3. Let S be a string of length n compressed into an LZ77 representation Z with z phrases, let P be a pattern of length m and let A be an algorithm that can detect an (approximate) occurrence of P in S (with at most k errors) given P and Z in t(z, n, m, k) time and s(z, n, m, k) space. Then, we can solve the same task in O(t(z, zm, m, k) + z lg(n/z)) time and O(s(z, zm, m, k) + z) space. If A reports all occ occurrences using t(z, n, m, k) time and s(z, n, m, k) space, then we can report all occurrences in O(t(z, zm, m, k) + z lg(n/z) + occ) time and O(s(z, zm, m, k) + z + occ) space. Theorem 4. Let A be a streaming algorithm that reports all occ (approximate) oc- currence of a pattern P ∈ [σ]m (with at most k errors) in a stream of length n in t(n, m, k) time and s(n, m, k) space. Then, we can report all occurrences of P in the LZ77 representation of a string S ∈ [σ]n in either: • O(t(zm, m, k) + z lg(n/z)) time and O(s(zm, m, k) + z lg lg(n/z) + occ) space or • O(t(zm, m, k)+z lg(n/z)+zm lgδ σ) time and O(s(zm, m, k)+z lg1−δ σ+occ) space. The best known algorithm for detecting if pattern P occurs in a string S given P and Z uses O(z lg(n/z) + m) time and O(z lg n + m) space [5]. If we plug this into Theorem 3 we obtain O(z lg(n/z) + m) time and O(z lg m + m) space thereby reducing the lg n factor in the space to lg m without increasing the time. We also obtain new trade-offs for reporting all approximate occurrences of P with at most k errors. For example, if we plug in the Landau -- Vishkin and Cole -- Hariharan [6, 7] algorithms, we can solve the problem in O(z lg(n/z) + z min{mk, k4 + m} + occ) time using O(z + m + occ) space for constant-sized alphabets or O(z lg lg(n/z) + m + occ) space for general alphabets. The previous best solution has the same time complexity but uses O(z lg n + m + occ) space [8]. The complete explanation can be found in Appendix F. 1.2 Related work While the LZ77 decompression problem has not been studied much in the literature, the problem of fast LZ77 compression in small working space has lately attracted a lot of research in the field of compressed computation [9, 10, 11, 12, 13]. A closely related problem is the random access problem, where the aim is to build a data structure taking space as close as possible to O(z) words and supporting efficient access queries to single characters. Existing solutions for the random access problem [1, 2, 14] need Ω(z log(n/z)) space to achieve O(log(n/z)) access time. Because these data structures can be built efficiently they also solve the LZ77 decompression problem considered in this paper. In particular they can decompress the entire string S given its LZ77 representation in O(n) time using O(z lg(n/z)) working space. Random access data structures can also decompress any set of s substrings with total length l in O(l +s lg n) time. We provide several new trade-offs for this problem; for instance we can solve it using O(l + (z + s) lg(n/z)) time and O(z) space for constant-sized alphabets or O(z lg lg(n/z)) space for general alphabets. In a recent work [4], Puglisi and Rossi implemented the ideas described in our paper. They showed that, even if an implementation of our algorithms is not practical due to the underlying mergeable dictionary, several optimizations can be introduced that drastically improve performance. Their optimized implementation led to new relevant space-time tradeoffs on several datasets of practical interest. 2 Preliminaries We assume a standard unit-cost RAM model with word size w = Θ(lg n) and that the input is from an integer alphabet Σ = {1, 2, . . . , σ} where σ ≤ nO(1), and we measure space complexity in words unless otherwise specified. A string S of length n = S is a sequence S[1] . . . S[n] of n symbols from an alphabet Σ of size Σ = σ. The string S[i] . . . S[j] denoted S[i, j] is called a substring of S. Let  denote the empty string and let S[i, j] =  when i > j. To ease the notation, let S[i, j] = S[1, j] if i < 1 and S[i, n] if j > n. Let [u] be shorthand for the interval [1; u] = {1, 2, . . . , u} and $ be a special symbol that never occurs in the input. A straight-line program (SLP) is an acyclic grammar in Chomsky normal form where each non-terminal T has exactly one production rule with T as its left-hand side i.e., a grammar where each non-terminal production rule expands to two other rules and generates one string only. Lempel-Ziv 77 Algorithm For simplicity of exposition we use the scheme given by Farach & Thorup [15]. Map Σ into [σ] and assume that S is prefixed by Σ in the negative positions, i.e. S[−c] = c for c ∈ Σ and S[0] = $ /∈ Σ. An LZ77 representation [16, 17] of S is a string Z of the form (s1, l1) . . . (sz, lz) ∈ ([−σ; n] × [n])z. Let u1 = 1 and ui = ui−1 + li−1, for i > 1. For Z to be a valid LZ77 representation of S, we require that si + li ≤ ui and that S[ui, ui + li − 1] = S[si, si + li − 1] for i ∈ [z]. This guarantees that Z represents S and clearly S is uniquely defined in terms of Z. We refer to the substring S[ui, ui + li − 1] as the ith phrase of the representation, the substring S[si, si + li − 1] as the source of the ith phrase and (si, li) as the ith member of Z. We note that the restriction si + li ≤ ui for all i implies that a source and a phrase cannot overlap and thus we do not handle representations that are self-referential. By the given definition, the LZ77 representation of a string is not unique, however a minimal LZ77 representing a text S can be found greedily in O(n) time [18, 19]. Mergeable Dictionary To obtain our results we need mergeable dictionaries with shift operations. The Mergeable Dictionary problem is to maintain a dynamic col- lection G of sets {G1, G2, . . .} of n elements from an ordered universe {1, 2, . . . ,U} starting from n singleton sets under the operations: 1. C ← merge(A, B): Remove A and B from G and insert C = A ∪ B instead. 2. (A, B) ← split(G, x): Split G into two sets A = {y ∈ G y ≤ x} and B = {y ∈ G y > x}. G is removed from G while A and B are inserted. 3. G(cid:48) ← shift(G, x) for some x such that y + x ∈ [U] for each y ∈ G: Create the set G(cid:48) = {y + x y ∈ G}. G is removed from G while G(cid:48) is inserted. 4. makeset(j): Insert a new singleton set G = {j} in G. Bille et al. [20] show how to extend the mergeable dictionary by Iacono & Ozkan [21] to support shifts (Iacono & Ozkan [21] write that their data structure can be extended to support the shift operation but do not provide any details): Figure 1: Example of the τ -context of a string. Dashed parts are truncated parts of the string not shown by the figure, grey parts represent substrings in the τ -context and white parts represent substrings not in the τ -context. The first substring in the negative positions −σ through 0 is always in the τ -context. Recall that li is the length of the ith phrase. In this example, li < τ, li+1 ≤ 2τ and li+2, li+3 > 2τ . Theorem 5 ([20]). There exists a mergeable dictionary with shifts supporting all operations in lg U amortized time using linear space. For a set G, let UG = max(G)− min(G). The 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. 3 LZ77 Induced Context In this section we present the centerpiece of our algorithm. It builds on the funda- mental property of LZ77 compression that any substring of a phrase also occurs in the source of that phrase. Our technique is to store a short substring, which we call context, extracted around phrase borders. The contexts are stored in a compressed form that allows faster substring extraction than that of LZ77. We then take ad- vantage of this property when extracting a substring of S by splitting it into short chunks which in turn are extracted by repeatedly mapping them to the source of the phrase they are part of. Eventually, they will end up as substrings of the contexts from where they can be efficiently extracted. The technique resembles what Farach & Thorup refer to as winding in [15]. We show new applications of the technique and obtain better time complexity by using the mergeable dictionary of Section 2. Recall that we assume S is prefixed by the alphabet in the negative positions, that S[0] = $, and that uk is the starting position in S of the kth phrase. Definition 1. Let τ be a positive integer. The τ -context of a string S (induced by an LZ77 representation Z of S) is the set of positions j where either j ≤ 0 or there is some k such that uk − τ < j < uk + τ . If positions i through j are in the τ -context of S, then we simply say "S[i, j] is in the τ -context of S". Definition 2. Let τ be a positive integer. The τ -context string of S, denoted Sτ , is the subsequence of S that includes S[j] if and only if j is in the τ -context of S. We denote with πτ (j) the unique position in Sτ where such a position j is mapped to (i.e. Sτ [πτ (j)] = S[j]). It is easy to show how to map positions from S to Sτ (see Appendix A for a proof) Lemma 1. Let Z be an LZ77 representation of a string S of length n with z phrases and let τ be a positive integer. Given t = O(z) sorted positions, p1 ≤ . . . ≤ pt ∈ [n] in the τ -context of S we can compute πτ (p1), . . . , πτ (pt) in O(z) time and space. $-σ uiui+1ui+2ui+3ui+4 …u1 …0n We use π as shorthand for πτ whenever τ is clear from context. The following properties follow from the definitions and Lemma 1 but will come in handy later on: Property 1. If a, a(cid:48) are positions in the τ -context of S and a < a(cid:48) then π(a) < π(a(cid:48)). Property 2. If S[a, b] is in the τ -context of S then Sτ [π(a), π(b)] = S[a, b] We now consider the following problem: given a substring S[i, j] of length at most τ , find a pair of integers (i(cid:48), j(cid:48)) such that i(cid:48) ≤ i, S[i, j] = S[i(cid:48), j(cid:48)] and S[i(cid:48), j(cid:48)] is in the τ -context of S. We first give an informal overview of how the algorithm works. Recall that if a substring of S is contained within a phrase in the LZ77 parse of S, then the substring also occurs in the source of that phrase. The idea is to repeat this process of finding an identical substring in the source until the found string is in the τ -context of S, which happens after at most z steps. To do this efficiently for multiple strings, we use the mergeable dictionary structure to maintain the relevant positions. This allows us to process all strings inside a phrase simultaneously because they all need to be moved to the same source. By processing the phrases in right-to-left order we can bound the number of dictionary operations by the number of phrases. The following algorithm gives the details of how to solve the problem for a set of z substrings using O(z) space and O(z lg n) time (which we later improve). Algorithm 1. Let Z be an LZ77 representation of a string S of length n with z phrases and let τ be a positive integer. The input is t = O(z) substrings of S given as pairs of integers denoting start and end positions: (a1, b1), . . . , (at, bt) where bi−ai < τ for all i ∈ [t]. Let G be a mergeable dictionary as given by Lemma 5. For each of the pairs (ai, bi) create a singleton set Gi with element xi at position ai and finally merge all these elements into a single set G. Each element xi has associated its rank i among the input pairs as satellite information. We now consider the members of Z one by one in reverse order. Member (si, li) is processed as follows: 1. If li ≤ τ skip to the next member. 2. Otherwise let (a) (A, B) ← split(G, ui + li − τ ) (b) (A(cid:48), B(cid:48)) ← split(A, ui − 1), (c) B(cid:48)(cid:48) ← shift(B(cid:48), si − ui) (d) G ← merge(A(cid:48), B(cid:48)(cid:48)). In step 1, we skip a phrase if it is no longer than τ because any string of length τ or shorter starting in that phrase is already in the τ -context of S. In step 2a, we split the set such that all strings that start in the last τ positions of the phrase are not shifted, because these already are in the τ -context of S. In 2a-d we split the set Figure 2: Example of the dictionaries created during an iteration. The dashed parts of the string are truncated parts not relevant to the example. The dotted triangles represent the B-sets from earlier iterations. The grey parts show the τ -context of the string inside the ith and i − 1th phrase. Note that the set B(cid:48)(cid:48) is the set B(cid:48) after the shift operation. As exemplified by the elements xj and xj+1, the relative order and position inside the set is unaffected by the shift. Let p and p(cid:48) be the position of xj before and after the shift, respectively. Observe also that S[p, p + (bj − aj) − 1] = S[p(cid:48), p(cid:48) + (bj − aj) − 1], so the shift does not affect the substring represented by xj. An iteration starts from the set G, obtaining A by cutting off B. The new G (not shown in the figure) is then obtained by shifting all elements in the range of B(cid:48), which are all contained in the ith phrase to the same relative position in the source of the phrase. to obtain the set of strings B(cid:48)(cid:48) that starts in the ith phrase excluding those starting in the last τ positions, as they are already in the τ -context of S. These strings are then shifted to the source and will be considered again in later iterations. After processing all members, scan each set in G to retrieve all the elements. Let p(xi) denote the new position in G of element xi. We then output the pairs (p(x1), e1), . . . , (p(xt), et) in order of their rank i where ei = p(xi) + bi − ai. The proof of correctness and the analysis of the time complexity can be found in Appendix B. Bucketing To decrease the running time from O(z lg n) to O(z lg(n/z)), we apply a bucketing argument similar to the one given by Farach & Thorup [15]. The overall idea, described in detail in Appendix B, is to divide the universe of text positions [n] into z buckets of size (cid:100)n/z(cid:101) each, and keep a separate mergeable dictionary for each of the buckets. With a constant additional number of dictionary operations per phrase, we are then able to simulate the dictionary used by Algorithm 1. Since the universe size of each dictionary is now reduced to O(n/z), dictionary operations cost just O(lg(n/z)) time (amortized) and we obtain: Lemma 2. Let Z be an LZ77 representation of a string S of length n with z phrases and let τ be a positive integer. Given t ∈ O(z) substrings of S as pairs of integers (a1, b1), . . . , (at, bt) where bi− ai < τ we can find t pairs of integers (a(cid:48) t, b(cid:48) t) such that S[a(cid:48) i] is in the τ -context of S using O(z) space and O(z lg(n/z)) time. i ≤ ai and S[a(cid:48) 1), . . . , (a(cid:48) 1, b(cid:48) i, b(cid:48) i] = S[ai, bi], a(cid:48) i, b(cid:48) siuinxjxj+1xjxj+1GA'B'BB''A 3.1 LZ77 Compressed Context It is possible to obtain an LZ77 representation Z τ of the string Sτ directly from an LZ77 representation Z of S. Informally, the idea is to split every phrase of Z into two new phrases consisting of respectively the first and last O(τ ) characters of the phrase. In order to find a source for these phrases, we use Algorithm 1 which finds an identical string that also occurs in Sτ . tation Z τ of Sτ given the LZ77 parse Z of S. We now describe the algorithm sketched above that constructs an LZ77 represen- Algorithm 2. First we construct O(z) relevant pairs of integers representing sub- strings of S by considering the members of Z one by one in order. Member (si, li) is processed as follows: 1. If li ≤ τ : Let (ui, ui + li − 1) be a relevant pair. 2. If τ < li < 2τ : Let (ui, ui + τ − 1) and (ui + τ, ui + li − 1) be relevant pairs. 3. Otherwise li ≥ 2τ : Let (ui, ui + τ − 1) and (ui + li − τ + 1, ui + li − 1) be relevant pairs. Each of the relevant pairs represents a prefix or a suffix of a phrase. The concate- nation of these phrase prefixes and suffixes in left-to-right order is exactly the string Sτ . Let (a, b) be a relevant pair created when considering the ith member of Z. Then we say that (a(cid:48), b(cid:48)) = (a − ui + si, b − ui + si) is the related source pair and clearly S[a, b] = S[a(cid:48), b(cid:48)]. Note that the related source pairs might not be in the τ -context. We now use Algorithm 1 to find a pair of integers (a(cid:48)(cid:48), b(cid:48)(cid:48)) for each related source pair (a(cid:48), b(cid:48)) such that S[a(cid:48)(cid:48), b(cid:48)(cid:48)] = S[a(cid:48), b(cid:48)], a(cid:48)(cid:48) ≤ a(cid:48) and S[a(cid:48)(cid:48), b(cid:48)(cid:48)] is in the τ -context of S. We give the pairs in order of creation and this order is preserved by Algorithm 1. If (a(cid:48)(cid:48), b(cid:48)(cid:48)) is the ith output of Algorithm 1 then (πτ (a(cid:48)(cid:48)), l) is the ith member of Z τ where l = b − a + 1 and πτ (a(cid:48)(cid:48)) is computed using Lemma 1. We leave the proof of correctness and the analysis of the time complexity to Appendix D. We obtain the following lemma: Lemma 3. Let Z be an LZ77 representation of a string S of length n with z phrases. We can construct an LZ77 representation Z τ of Sτ with O(z) phrases in O(z lg(n/z)) time and O(z) space. 3.2 Packed and SLP-Compressed Context In this section we consider how to store in two different (packed/compressed) rep- resentations a τ -context string of S. Our representations can be built quickly and support fast random access. Our first solution uses word packing. First, we construct the LZ77 representation of Sτ using Algorithm 2 and decompress it naively. Constructing the representation takes time O(z lg(n/z)) while decompressing it takes linear time in its length, O(zτ ). A string of length zτ can be stored in O(zτ lg σ/ lg n) words using word packing. Lemma 4. Let S be a string S of length n from an alphabet of size σ compressed into an LZ77 representation with z phrases, and let τ be a positive integer. We can build and store Sτ in O(z(lg(n/z) + τ )) time and O(zτ lg σ/ lg n) space. As an alternative solution, we show how to store the context string as an SLP supporting fast random access. The following lemma follows easily from Charikar et al. [2] and Rytter [1] (for a proof, see Appendix E): Lemma 5. Let S be a string of length n compressed into an LZ77 representation with z phrases, and let τ be a positive integer. We can build a balanced SLP of size O(z lg τ ) for Sτ in O(z lg(n/z)) time and O(z lg τ ) space. Furthermore, the SLP supports extraction of any length-(cid:96) substring of Sτ in O((cid:96) + log τ ) time. 4 LZ77 Decompression We now describe how to apply the techniques described in the previous section to extract arbitrary substrings of S. Let S be a string of length n compressed into an LZ77 representation with z phrases and let τ ≤ log(n/z) be a positive integer that we will fix later. We show how to extract s substrings of total length l. Split each substring into consecutive blocks of length τ (except, possibly, the last for each substring), obtaining at most l/τ + s blocks. Process a batch of z blocks at a time in left-to-right order. There are at most O(1 + l/(τ z) + s/z) batches, each containing z blocks. A batch is processed in O(z log(n/z)) time using Lemma 2 thereby finding a substring s(cid:48) in the τ -context of S for every block s in the batch. τ z + s/z)(z lg(n/z) + zτ )) = O((s + z) lg(n/z) + l lg(n/z) Using Lemma 5, we first build the SLP in O(z lg(n/z)) time and O(z lg τ ) space. After that, the z substrings in each batch can be extracted in O(z log τ + zτ ) = O(zτ ) time. Summing up, the time to build the SLP (once) and extract and output all batches is O(z lg(n/z) + (1 + l ). The total space is O(z lg τ ). This proves Theorem 2. If we instead use Lemma 4, we spend O(z(lg(n/z) + τ )) time and O(zτ lg σ/ lg n) space to build Sτ . After that, the z substrings in each batch can be extracted in O(zτ ) time. Summing up, the time to build Sτ (once) and extract and output all batches is O(z(lg(n/z) + τ ) + (1 + τ z + s/z)(z lg(n/z) + zτ )) = O((s + z) lg(n/z) + l lg(n/z) l ) while the space becomes O(zτ lg σ/ lg n) (on top of the input). To prove Theorem 1, we fix τ = lg(n/z)/ lgδ σ for any constant 0 ≤ δ ≤ 1. τ τ Theorems 1 and 2 immediately yield the following two corollaries on the complex- ity of decompressing the entire string S (notice that z lg(n/z) = O(n)): Corollary 1. For any parameter 0 ≤ δ ≤ 1, we can decompress S in O(n lgδ σ) time using O(z lg1−δ σ) space. On large alphabets, we can further improve upon this result by plugging τ = log(n/z) into Theorem 2: Corollary 2. We can decompress S in O(n) time using O(z lg lg(n/z)) space. 5 References [1] W. Rytter, "Application of Lempel-Ziv factorization to the approximation of grammar- based compression," TCS, vol. 302, no. 1-3, pp. 211 -- 222, 2003. [2] M. Charikar, E. Lehman, D. Liu, R. Panigrahy, M. Prabhakaran, A. Sahai, and A. She- lat, "The smallest grammar problem," IEEE Trans. Info. Theory, vol. 51, no. 7, pp. 2554 -- 2576, 2005. [3] D. Belazzougui, J. Karkkainen, D. Kempa, and S. J. Puglisi, "Lempel-Ziv Decoding in External Memory," in Proc. SEA, 2016, pp. 63 -- 74. [4] S. J. Puglisi and M. Rossi, "On Lempel-Ziv Decompression in Small Space," in Proc. DCC, 2019, pp. 221 -- 230. [5] Pawe(cid:32)l Gawrychowski, "Pattern matching in lempel-ziv compressed strings: fast, sim- ple, and deterministic," in European Symposium on Algorithms, 2011, pp. 421 -- 432. [6] Gad M Landau and Uzi Vishkin, "Fast parallel and serial approximate string match- ing," JDA, vol. 10, no. 2, pp. 157 -- 169, 1989. [7] R. Cole and R. Hariharan, "Approximate string matching: A simpler faster algorithm," SIAM JComp., vol. 31, no. 6, pp. 1761 -- 1782, 2002. [8] T. Gagie, P. Gawrychowski, and S. J. Puglisi, "Approximate pattern matching in LZ77-compressed texts," JDA, vol. 32, pp. 64 -- 68, 2015. [9] J. Fischer, T. Gagie, P. Gawrychowski, and T. Kociumaka, "Approximating LZ77 via small-space multiple-pattern matching," in Proc. ESA, 2015, pp. 533 -- 544. [10] J. Fischer, T. I, and D. Koppl, "Lempel Ziv Computation In Small Space (LZ-CISS)," in Proc. CPM, 2015, pp. 172 -- 184. [11] A. Policriti and N. Prezza, "Fast online Lempel-Ziv factorization in compressed space," in Proc. SPIRE, 2015, pp. 13 -- 20. [12] A. Policriti and N. Prezza, "LZ77 computation based on the run-length encoded BWT," Algorithmica, vol. 79, pp. 1 -- 26, 2017. [13] T. Nishimoto, T. I, S. Inenaga, H. Bannai, and M. Takeda, "Dynamic index and lz factorization in compressed space," in Proc. PSC, 2016, pp. 158 -- 170. [14] P. Bille, M. B. Ettienne, I. L. Gørtz, and H. W. Vildhøj, "Time-space trade-offs for lempel-ziv compressed indexing," TCS, vol. 713, pp. 66 -- 77, 2018. [15] M. Farach and M. Thorup, "String Matching in Lempel-Ziv Compressed Strings," Algorithmica, vol. 20, no. 4, pp. 388 -- 404, 1998. [16] A. Lempel and J. Ziv, "On the complexity of finite sequences," IEEE Trans. Info. Theory, vol. 22, no. 1, pp. 75 -- 81, 1976. [17] J. Ziv and A. Lempel, "A universal algorithm for sequential data compression," IEEE Trans. Info. Theory, vol. 23, no. 3, pp. 337 -- 343, May 1977. [18] M. Crochemore, L. Ilie, and W. F. Smyth, "A simple algorithm for computing the Lempel Ziv factorization," in Proc. DCC, 2008, pp. 482 -- 488. [19] J. Karkkainen, D. Kempa, and S. J. Puglisi, "Linear time Lempel-Ziv factorization: Simple, fast, small," in Proc. CPM, 2013, pp. 189 -- 200. [20] Philip Bille, Mikko Berggren Etienne, and Inge Li Gørtz, "Mergeable dictionaries with shifts," arXiv preprint arXiv:1901.00718, 2019. [21] John Iacono and Ozgur Ozkan, "Mergeable dictionaries," in Proc. ICALP, 2010, pp. 164 -- 175. [22] J. Karkkainen and E. Ukkonen, "Lempel-Ziv parsing and sublinear-size index struc- tures for string matching," in Proc. WSP, 1996, pp. 141 -- 155. A Proof of Lemma 1 Proof. Let gapk = max{0, lk − 2τ + 1} be the number of positions inside the k-th LZ77 phrase that are not in the τ -context of S. Let i, k, L be three integers initialized as follows: i = 0, k = 1, and L = 0. We keep the following two invariants: (i) if i > 0, then k is the smallest integer such that pi < uk + lk, i.e. position pi is in the k-th phrase, and (ii) L is the number of positions j < uk such that j is in the τ -context of S (i.e. L is the length of the prefix of Sτ containing characters from S[1..uk − 1]). It is clear that (i) and (ii) hold in the beginning of our procedure. We now show how to iterate through the LZ77 phrases and compute the desired output in one pass. Assume that we have already computed πτ (p1), . . . , πτ (pi) (or none of them if i = 0). To compute πτ (pi+1), we check whether uk ≤ pi+1 < uk + lk, i.e. whether pi+1 is in the k-th phrase. If not, we find the phrase containing pi+1 as follows. We set L ← L + lk − gapk, k ← k + 1 and repeat until we find a value of k that satisfies uk ≤ pi+1 < uk + lk. It is clear that, at each step, L is still the length of the prefix of Sτ containing characters from S[1..uk − 1] (i.e. invariant (ii) is maintained). Once such a k is found, we compute πτ (pi+1) simply adding L to the relative position of pi+1 inside its phrase, and subtract gapk from this quantity if pi+1 is within τ characters from the end of the phrase. In more detail, if pi+1 < uk + τ , then πτ (pi+1) ← L + 1 + (pi+1− uk). Otherwise, πτ (pi+1) ← L + 1 + (pi+1− uk)− gapk. The correctness of this computation is guaranteed by the way we defined L in property (ii). Note that k is again the smallest integer such that pi+1 < uk + lk (invariant (i)), so we can proceed with the same strategy to compute πτ (pi+2), . . . , πτ (pt). Overall, the algorithm runs in O(z) time and space. B Proof and Analysis of Algorithm 1 Correctness Let p(xi) denote the position in G of element xi at any point of the algorithm. We now show that for any element xi, we have S[ai, bi] = S[p(xi), ei] both before and after considering the jth member of Z. Initially, p(xi) = ai so this is trivially true before the first iteration. Assume by induction that this is true before considering member j. If p(xi) > uj + lj − τ or p(xi) < uj, then p(xi) will not be changed when considering member i. Otherwise, uj ≤ p(xi) ≤ uj+lj−τ , and thus S[p(xi), ei] is a substring of S[uj, uj+lj−1] which also occurs at the same relative position in S[sj, sj + lj − 1]. Now xi is shifted such that p(xi) ← p(xi)− uj + sj thereby maintaining the relative position inside the two identical strings and it follows that xi still represents S[ai, bi] after considering member j and thus also before considering member j − 1. We now show that, for any element xi, the string S[p(xi), ei] is in the τ -context of S after considering the last member. Observe that when considering member j, every element positioned in S[uj, uj + lj − τ ] is shifted to a position less than uj, because sj + lj ≤ uj by definition. As we are considering the members in reverse order, this means that every element xi must end in a position such that either there is some k such that uk + lk − τ < p(xi) < uk + lk or p(xi) < 0 which concludes the proof of correctness. Complexity Creating the z singleton elements with positions in the range [n] and merging them to G takes O(z lg n) time. For every member of Z we do O(1) dictio- nary operations. All positions remain in the range [−σ; n] thus this also takes total time O(z lg n). We can easily compute and store u1, . . . , uz in O(z) time and space. Outputting the elements xi in order of their rank i takes linear time as the ranks are consecutive integers thus the total time is O(z lg n). We never store more than the O(z) elements, thus the total space is O(z). C Bucketing i, li − l(cid:48) i) if kF ∈ [ui, ui + li] where l(cid:48) Fix F = (cid:100)n/z(cid:101) and transform the parse Z by splitting any phrase that covers a position kF < n for k = 1, 2, . . ., i.e. replace the element (si, li) by elements (si, l(cid:48) i) i = kF − ui. Clearly, the parse remains and (si + l(cid:48) valid and the number of phrases is at most doubled [15]. We now change the way we merge the sets. Initially, create an array M of length z − 1. Now for each of the pairs (ai, bi) we create the singleton set Gi with element xi at position (ai mod F ) and store a pointer to Gi in position (cid:98)ai/F(cid:99) of M . If the position is occupied by some set Gj merge the sets Gi and Gj and update the position to point at the new set Gi ∪ Gj. Assume that τ ≤ n/z (this will be true later for the values of τ we will use). When considering the members of Z in reverse order we process member (si, li) as follows: 1. If li ≤ τ skip to the next member. 2. Otherwise let (a) (A, B) ← split(M [(cid:98)ui/F(cid:99)], ((ui mod F ) + li − τ )). (b) (A(cid:48), B(cid:48)) ← split(A, ui − 1). (c) Let M [(cid:98)ui/F(cid:99)] point to A(cid:48). (d) B(cid:48)(cid:48) ← shift(B(cid:48), si − ui mod F ). (e) If si − ui < 0 continue with the next member. (f) Otherwise let G(cid:48) ← merge(M [(cid:98)(si − ui)/F(cid:99)], B(cid:48)(cid:48)). (g) Let M [(cid:98)(si − ui)/F(cid:99)] point to G(cid:48). After processing all members, scan each set in G and proceed as originally de- scribed. It is fairly easy to verify that this procedure positions all elements identically to the original procedure. Therefore, the correctness follows from above. There are still O(1) dictionary operations for each of the O(z) members, but the positions of the elements are now in the range [n/z] thus the total time becomes O(z lg(n/z)). To retrieve all the elements, let p(xi) denote the new position in G of element xi. We then output the pairs (p(x1), e1), . . . , (p(xt), et) in order of their rank i where ei = p(xi) + bi − ai. D Proof and Analysis of Algorithm 2 t, b(cid:48) i, b(cid:48) i] and, by Lemma 2, S[a(cid:48)(cid:48) i , b(cid:48)(cid:48) i ] = S[a(cid:48) i, b(cid:48) t , b(cid:48)(cid:48) i , b(cid:48)(cid:48) t , b(cid:48)(cid:48) 1), l1), . . . , (π(a(cid:48)(cid:48) t) be the related source pairs, (a(cid:48)(cid:48) 1, b(cid:48)(cid:48) 1) . . . (a(cid:48)(cid:48) Correctness Let (a1, b1), . . . , (at, bt) be the relevant pairs in order of creation, 1, b(cid:48) (a(cid:48) 1) . . . (a(cid:48) t ) be the output of Al- gorithm 1, and let li = bi − ai + 1. Our goal is to show that Z τ = (π(a(cid:48)(cid:48) t ), lt) is a valid LZ77 represen- tation of Sτ , that is: (i) the concatenation of the phrases of Z τ yields Sτ , (ii) phrases of Z τ are equal to their sources, and (iii) phrases of Z τ do not overlap their sources. Note that Z τ consists of at most 2z phrases (i-ii) It follows directly from Definition 2 that the concatenation of the strings represented by the relevant pairs in order of creation is S[a1, a1]··· S[at, bt] = Sτ . Since S[ai, bi] = S[a(cid:48) i] then we also have that Sτ = S[a(cid:48)(cid:48) i ] are in the τ -context of S then by Property 2 we have S[ai, bi] = Sτ [π(ai), π(bi)] and S[a(cid:48)(cid:48) sented by the pair (ai, bi) is entirely contained in a phrase we must have a(cid:48) and therefore, by Lemma 2, a(cid:48)(cid:48) by Property 1, π(a(cid:48)(cid:48) Complexity For every member of Z we create at most two relevant substrings taking total O(z) time and space. Applying Algorithm 1 takes time O(z lg(n/z)) and O(z) space. We can easily compute and store u1, . . . , uz by computing πτ (a(cid:48)) for every substring reported by Algorithm 1. This takes total O(z) time and space using Lemma 1, thus the total time is O(z lg(n/z)) and the total space is O(z). i , b(cid:48)(cid:48) (iii) By definition of the LZ77 representation of S and since the substring repre- i + li ≤ ai i + li ≤ ai and therefore, t ]. Now, observe that since S[ai, bi] and S[a(cid:48)(cid:48) 1, a(cid:48)(cid:48) i ] = Sτ [π(a(cid:48)(cid:48) 1]··· S[a(cid:48)(cid:48) i ), π(b(cid:48)(cid:48) i + li) ≤ π(ai), i.e. property (iii) holds. i )]. This proves properties (i) and (ii). i. But this means that a(cid:48)(cid:48) i ≤ a(cid:48) E Proof of Lemma 5 Proof. We build the LZ77 representation of Sτ using Lemma 3 and then convert it into an SLP using the procedure described by Charikar et al. and Rytter: Theorem 6 (Charikar et al. [2], Rytter [1]). Let z be the number of phrases in a LZ77 representation of a string S(cid:48) of length n(cid:48). We can build a balanced SLP for S(cid:48) with height O(lg n(cid:48)) in O(z lg(n(cid:48)/z)) space and time. Note that, in our case, n(cid:48) = Sτ ≤ zτ and the SLP's size is O(z lg(n(cid:48)/z)) = O(z lg(zτ /z)) = O(z lg τ ). To reduce the SLP's height to O(log(n(cid:48)/z)) = O(log τ ), we expand the starting nonterminal until obtaining a sequence of t = Θ(z) nonterminals X1, . . . , Xt (which happens at depth Θ(log z), the SLP being balanced). We cut those levels from the SLP and add a new starting nonterminal S(cid:48) → X1 . . . Xt. By navigating the grammar in O(z log τ ) time, we can associate to each nonterminal the length of the text substring it expands to. This is already sufficient to navigate the grammar (by standard techniques) in O(log τ ) time starting from one of the symbols of the expansion of S(cid:48). To get the precise starting symbol, we need one additional predecessor query on the cumulative sizes of the expansions of X1, . . . , Xt, which however can be performed in O(log(n(cid:48)/z)) = O(log τ ) time using, e.g. an Elias-Fano predecessor data structure. To conclude, once reached the leaf (terminal) corresponding to the first character to be extracted, the remaining characters can be retrieved in amortized constant time each by standard techniques, i.e. moving to the next sibling or, if this belongs to a different nonterminal, moving upwards until reaching an ancestor of the next symbol to be extracted, and then descending again to the corresponding leaf. Overall, this procedure visits a sub-tree (of the grammar tree) of size O((cid:96)). F Applications in Pattern Matching In this section we show how our techniques can be applied as a black box in combi- nation with existing pattern matching results. Let S be a string of length n and let P be a pattern of length m. The classical pattern matching problem is to report all starting positions of occurrences of P in S. In the approximate pattern matching problem we are given an error threshold k in addition to P and S. The goal is to find all starting positions of substrings of S that are within distance k of P under some metric, e.g. edit distance where the distance is the number of edit operations required to convert the substring to P . When considering the compressed pattern matching problem, the string S is given in some compressed form. Sometimes, we are only interested in whether or not P occurs in S. Pattern matching on LZ77 compressed texts usually takes advantage of the prop- erty that any substring of a phrase also occurs in the source of the phrase. This means that if an occurrence of P is contained in single phrase, then there must also be an occurrence in the source of that phrase. The implication is that the occurrences of P can be split into two categories: the ones that overlap two or more phrases and the ones that are contained inside a single phrase -- usually referred to as primary and secondary occurrences, respectively [22]. The secondary occurrences can be found from the primary in O(z + occ) time and space [8] where z is the number of phrases in the LZ77 representation of S and occ is the total number of occurrence of P in S. Approximate pattern matching in small space Consider the $-padded m- context string of S denoted S$m obtained by replacing each of the maximal substrings of S that are not in the m-context by a single copy of the symbol $. This string has length O(zm). Observe that all the primary occurrences of P in S are in this string, that any occurrence of P in this string corresponds to a unique primary or secondary occurrence of P in S and that we can map these occurrences to their position in S in O(occ + z lg z) time and O(z) space using the same technique as Lemma 1 but by adding the gap lengths instead of subtracting them. We now prove Theorem 3. Let A be the (approximate) pattern matching algorithm from the theorem using t(z, n, m, k) time and s(z, n, m, k) space. The idea is to run algorithm A on an LZ77 representation of S$m to find all the primary occurrences. Our algorithm works as follows. First create an LZ77 representation Z $m of S$m using Algorithm 2. If two consecutive phrases of Z $m are both induced by the same phrase of Z of length 2m or more we add a phrase between them representing only the symbol $. This is easy to do as part of Algorithm 2 without changing its complexity and the result is exactly an LZ77 representation of S$m with O(z) phrases. The pattern P occurs in S if and only if it occurs in S$m. Thus we can run algorithm A on Z $m to detect an (approximate) occurrence of P in S. Constructing Z $m takes O(z lg(n/z)) time and O(z) space thus the total time becomes O(z lg(n/z) + t(z, zm, m, k)) and the space is O(z + s(z, zm, m, k)). All primary occurrences are found by finding all occurrences of P in S$m, mapping them to their positions in S and filtering out the secondary occurrences. Hereafter, all the secondary occurrences can be found in O(z + occ) time and space [8]. Mapping and filtering also takes O(occ + z) time and space. Thus, if algorithm A reports all (approximate) occurrences of P in S in t(z, n, m, k) time and s(z, n, m, k) space we can report all (approximate) occurrences of P in S in O(z lg(n/z) + t(z, zm, m, k) + occ) time and O(z + s(z, zm, m, k) + occ) space. We now prove Theorem 4. Let A be the streaming algorithm from the theo- rem that reports all (approximate) occurrences of P in a stream of length n using t(n, m, k) time and s(n, m, k) space. The idea is to run algorithm A on the string S$m, which we will stream in chunks to find all the primary occurrences. We use the same technique as above to first filter the primary occurrences and then find all the secondary occurrences in O(z + occ) time and space. We stream the string S$m consisting of O(z) substrings of total length O(zm). We can easily compute when to output a $ during the substring extraction. Thus using Theorems 1 or 2 we can stream S$m in either O(zm) time using O(z lg lg(n/z)) space or O(zm lgδ σ + z lg(n/z)) time using O(z lg1−δ σ) space. The total time is then either: • O(t(zm, m, k) + z log(n/z)) time and O(s(zm, m, k) + z lg lg(n/z) + occ) space or • O(t(zm, m, k) + z lg(n/z) + zm lgδ σ) time and O(s(zm, m, k) + z lg1−δ σ + occ) space. Compressed Existence Gawrychowski [5] shows how to decide if P occurs in S given P and the LZ77 representation of S using O(z lg(n/z) + m) time and space. Applying Theorem 3 we get the following: Corollary 3. We can detect an occurrence of a pattern P of length m given the LZ77 representation of S in O(z lg(n/z) + m) time using O(z lg m + m) space. Approximate Pattern Matching By combining the Landau-Vishkin and Cole-Hariharan [6, 7] algorithms all approx- imate occurrences with at most k errors on a stream of length n can be found in O(min{nk, nk4/m + n}) time using O(m) space. Gagie et al. [8] shows how this algorithm can be used to solve the same problem given an LZ77 representation of S in O(z lg n + z · min{mk, k4 + m} + occ) time and O(z lg n + m + occ) space. Applying Theorem 4 to the combined Landau-Vishkin and Cole-Hariharan algorithm we get the following new trade-offs: Corollary 4. We can report all approximate occurrences of a pattern P of length m with k errors given the LZ77 representation with z phrases of a string S of length n in: • O(z lg(n/z) + z · min{mk, k4 + m} + occ) time using O(z lg lg(n/z) + m + occ) space or • O(z lg(n/z)+z·min{mk, k4 +m}+zm lgδ σ +occ) time using O(z lg1−δ σ +m+occ) space. G Conclusions In this paper we have described the first solution for decompressing Lempel-Ziv 77 in linear time using a space proportional to the input's size on constant alphabets. On general alphabets, we presented a trade-off that allows getting either linear time or linear space. Our solutions can, in general, decompress any subsequence of the text. Our work leaves several open problems. First of all, our solutions for general alphabets cannot achieve both linear time and space. We also note that our running times could be improved by fully exploiting packed computation; while it is definitely possible to slightly improve running times of Theorems 1 and 2 in this sense (at the price of a higher space usage), the (opportunely adjusted) case analysis of Corollaries 1 and 2 would not yield optimal packed extraction times. We therefore suspect that a different technique is needed in order to achieve optimality. Finally, for simplicity of exposition we did not consider self-referential LZ77: allowing overlaps represents a further interesting line of extension of our work.
0910.3503
2
0910
2010-06-07T20:44:36
Searching a bitstream in linear time for the longest substring of any given density
[ "cs.DS" ]
Given an arbitrary bitstream, we consider the problem of finding the longest substring whose ratio of ones to zeroes equals a given value. The central result of this paper is an algorithm that solves this problem in linear time. The method involves (i) reformulating the problem as a constrained walk through a sparse matrix, and then (ii) developing a data structure for this sparse matrix that allows us to perform each step of the walk in amortised constant time. We also give a linear time algorithm to find the longest substring whose ratio of ones to zeroes is bounded below by a given value. Both problems have practical relevance to cryptography and bioinformatics.
cs.DS
cs
Searching a bitstream in linear time for the longest substring of any given density Benjamin A. Burton June 3, 2010 Abstract Given an arbitrary bitstream, we consider the problem of finding the longest substring whose ratio of ones to zeroes equals a given value. The central result of this paper is an algorithm that solves this problem in linear time. The method involves (i) reformulating the problem as a constrained walk through a sparse matrix, and then (ii) developing a data structure for this sparse matrix that allows us to perform each step of the walk in amortised constant time. We also give a linear time algorithm to find the longest substring whose ratio of ones to zeroes is bounded below by a given value. Both problems have practical relevance to cryptography and bioinformatics. 1 Introduction Consider a bitstream of length n, that is, a sequence of bits x1, x2, . . . , xn where each xi is 0 or 1. We define the density of this bitstream to be the proportion of bits that are equal to one (equivalently, P xi/n). The density always lies in the range [0, 1]: a stream of zeroes has density 0, a stream of ones has density 1, and a stream of random bits should have density close to 1 2 . In this paper we are interested in the densities of substrings within a bitstream. By a sub- string, we mean a continuous sequence of bits xa, xa+1, . . . , xb−1, xb, beginning at some arbitrary position a and ending at some arbitrary position b. The length of a substring is the number of bits that it contains (that is, b−a+1), and the density of the substring is likewise the proportion of ones that it contains (that is, Pb In particular, we are interested in the following two problems: i=a xi/(b − a + 1)). Problem 1.1 (Fixed density problem). Suppose we are given a bitstream S of length n and a fixed ratio θ ∈ [0, 1]. What is the longest substring of S whose density is equal to θ? Problem 1.2 (Bounded density problem). Suppose we are given a bitstream S of length n and a fixed ratio θ ∈ [0, 1]. What is the longest substring of S whose density is at least θ? For example, suppose we are given the bitstream S = 010110101100 of length n = 12. Then the longest substring with density equal to θ = 0.6 has length ten (010110101100), and the longest substring with density at least θ = 0.7 has length seven (010110101100). Note that each problem might have many solutions or no solution at all. Both of these problems have important applications for cryptography. Many cryptographic systems are dependent on pseudo-random number generators (PRNGs), and any unwanted predictability or structure in a PRNG becomes a potential attack point for the underlying cryptosystem. For this reason PRNGs are typically subjected to a stringent series of randomness tests, such as those described in [13] or [15]. Bozta¸s et al. have recently designed a new series of randomness tests based on the densities of substrings [3]. To construct these tests, they use the Erdos-R´enyi law of large numbers [1, 7] 1 to compute the limiting distributions for solutions to the fixed density problem, the bounded density problem and related problems. They then compare observed values against these limiting distributions, and they have identified a possible weakness in the Dragon stream cipher [4] as a result. Locating substrings with various density properties also has important applications in bioin- formatics. A sequence of DNA consists of a long string of nucleotides marked G, C, T or A, and subsequences with high proportions of G and C are called GC-rich regions. GC-richness is correlated with factors such as gene density [18], gene length [6], recombination rates [8], codon usage [17], and the increasing complexity of organisms [2, 11]. To identify GC-rich regions we convert a DNA sequence into a bitstream, where each G or C becomes a one bit, and each T or A becomes a zero bit. We then search for high-density substrings in this bitstream, using techniques such as those discussed here. Further applications of density problems in the field of bioinformatics are discussed by Gold- wasser et al. [9] and Lin et al. [14]. In addition, Greenberg [10] signals potential applications in the field of image processing. The focus of this paper is on finding fast algorithms to solve Problems 1.1 and 1.2. Both problems allow simple brute-force algorithms that run in O(n2) time. For the fixed density problem, Bozta¸s et al. improve on this with their SkipMisMatch algorithm [3], which remains O(n2) in the worst case but has an improved average-case time complexity of O(n log n). We outline their contribution in Section 2. Our first contribution in this paper is a series of simple algorithms that solve both the fixed and bounded density problems in O(n log n) time, even in the worst case. These algorithms are easy to implement and effective in practice, and are based upon a central geometric observation. We cover these log-linear algorithms in Section 3. In Section 4 we follow with our main result, which is an algorithm that solves the fixed density problem in O(n) time, again in the worst case. Based on one of the previous log-linear algorithms, this algorithm introduces a specialised data structure that allows us to process each bit of the bitstream in amortised constant time. Broadly speaking, we: • express our bitstream as a sequence of steps through a sparse matrix, where each step requires a localised search and possible insertion into this matrix; • design a specialised data structure that "compresses" this sparse matrix, so that each localised search and insertion can be performed in amortised constant time. The amortised analysis is based on aggregation -- in essence we count the "interesting" steps of the algorithm by associating them with distinct elements of the bitstream, thereby showing the number of such steps to be O(n). Details of the proof are given in Section 4.3. Our final contribution is in Section 5, where we give an O(n) time algorithm for the bounded density problem. In contrast to the fixed density problem, this final algorithm is quite simple, involving just a handful of linear scans. To conclude, we measure the practical performance of our algorithms in Section 6. It is reassuring to find that our linear algorithms are worth the extra difficulty, consistently outper- forming the other algorithms for large bitstream lengths n. In related work, several authors have considered problems of finding maximal density sub- strings in a bitstream subject to a variety of constraints. See in particular work by Lin et al. [14], who place a lower bound on the length of the substring; Goldwasser et al. [9], who improve the prior solution and also place both lower and upper bounds; and Greenberg [10], who studies a variant relating to compressed bitstreams. Hsieh et al. [12] study a series of more general problems, where the bitstream is replaced by a sequence of real numbers, and the density of a substring becomes the average of the corresponding subsequence. In addition to developing algorithms, they show that several such problems -- including the fixed density problem -- have a lower bound of Ω(n log n) time. Our 2 linear algorithm effectively breaks through this lower bound in the case where the input sequence consists entirely of zeroes and ones. Throughout this paper we measure time complexity in "number of operations", where we treat basic arithmetical operations such as + and × as constant-time. 2 Quadratic Algorithms: Bozta¸s et al. In this section we outline the prior work of Bozta¸s et al., including a simple O(n2) brute force algorithm as well as their SkipMisMatch algorithm, which remains O(n2) in the worst case but becomes O(n log n) in the average case. Assumption 2.1. Throughout this paper we assume that the ratio θ is given as a rational θ = α/β, where α and β are integers in the range 0 ≤ α ≤ β ≤ n, and where gcd(α, β) = 1. This assumption is not restrictive in any way. If θ cannot be expressed as above then the fixed density problem has no solution, and for the bounded density problem we can harmlessly replace θ with a nearby rational that satisfies our requirements. A naıve brute force solution runs in O(n3) time: for each possible start point and end point, walk through the substring and count the ones. However, there are several different tricks that can easily convert this into O(n2) by replacing "walk through the substring" with a constant time operation. One such trick is to use a rank table. Definition 2.2 (Rank Table). A rank table is an array r0, r1, . . . , rn, where each entry rk counts the number of ones in the substring x1, . . . , xk. In other words, rk = Pk i=1 xi. It is clear that the complete rank table can be precomputed in O(n) time, and that it supports constant time queries of the form "how many ones appear in the substring xa, . . . , xb?" by simply computing rb − ra−1. For the fixed density problem, the SkipMisMatch algorithm further optimises this O(n2) brute force method by making the following observations: (i) We are searching for the longest substring of density θ. We can therefore reorganise our search to work from the longest substring down to the shortest, allowing us to terminate as soon as we find any substring of density θ. (ii) If we find such a substring, its length must be a multiple of β (where θ = α/β as above). We can therefore restrict our search to substrings of such lengths. (iii) When searching for substrings of length kβ, we need to find precisely kα ones to give a density of θ. If at some point we find kα ± ǫ ones, we must step forward at least ǫ positions in our bitstream before we can "undo the error" and potentially find the kα ones that we seek. Bundling these observations together, we obtain the SkipMisMatch algorithm as illustrated in Figure 1. The worst-case complexity is clearly still O(n2), but for a random bitstream the expected performance can be significantly better. In particular, Bozta¸s et al. prove the following result as a part of [3, Lemma 4]: Lemma 2.3. Suppose we have a random bitstream, where each bit is one with probability ρ or zero with probability 1 − ρ. Then SkipMisMatch has expected time bounded by O(cid:18)θ − ρ−1 × n β log n β(cid:19) . 3 procedure SkipMisMatch(x1, . . . , xn, θ = α/β) Build a rank table r0, r1, . . . , rn for k ← ⌊ n β ⌋ downto 1 do (a, b) ← (1, kβ) while b ≤ n do ǫ ← kα − (rb − ra−1) if ǫ = 0 then Output (a, b) and terminate else ⊲ Search for substrings of length kβ ⊲ Initial start and end for our substring ⊲ Compute the "error" for this substring (a, b) ← (a + ǫ, b + ǫ) ⊲ We can safely skip forward ǫ positions Output "no such substring" and terminate Figure 1: The SkipMisMatch algorithm for the fixed density problem For fixed θ and ρ, this reduces to an expected time of O(n log n), as long as θ 6= ρ. However, if we retain the dependency on θ (and hence its denominator β), we find that SkipMisMatch is rewarded by large denominators β (which enhance the power of optimisation (ii)), and is penalised by values of θ close to ρ (which limit the use of optimisation (iii)). To summarise, the SkipMisMatch algorithm is easy to code and runs significantly faster than brute force, but its performance depends heavily on the given value of θ. In addition, some broader issues might arise -- the expected O(n log n) time is appropriate for random bitstreams (as found in cryptographic applications, for instance), but might not hold for applications such as bioinformatics and image processing where bitstreams become more structured. Moreover, the algorithm does not translate well to the bounded density problem. All of these reasons highlight the need for faster and more robust algorithms, which form the subject of the remainder of this paper. 3 Log-Linear Algorithms: Maps and Sorting In this section we introduce our first truly sub-quadratic algorithms for solving the fixed and bounded density problems. We describe DistMap, a simple algorithm involving a map structure, and DistSort, a variation that replaces this map with a sort and a linear scan. Both of these algorithms run in O(n log n) time, even in the worst case. Although we present even faster algorithms in Sections 4 and 5, both DistMap and DistSort are simple to describe and easy to implement. Moreover, both algorithms play important roles: DistMap is the foundation upon which the linear algorithm of Section 4 is built, and DistSort is a more flexible variant that can solve both the fixed and bounded density problems. 3.1 Graphical Representations Our first step in developing these sub-quadratic algorithms is to find a graphical representation for our bitstreams. Definition 3.1 (Grid Representation). We can plot any bitstream as a walk through an infinite two-dimensional grid as follows.1 We begin at the origin (0, 0), and then step one unit in the x-direction each time we encounter a zero, or one unit in the y-direction each time we encounter a one, as illustrated in Figure 2. We refer to this as the grid representation of the bitstream. All of the new algorithms developed in this paper are based upon the following simple geometric observation: 1This is related to, but not the same as, the walk through the sparse matrix that we use for the linear algorithm in Section 4. 4 PSfrag replacements y End Movements: 0 1 Start (origin) x Figure 2: The grid representation for the bitstream 010110101100 Lemma 3.2. A substring of a bitstream has density θ if and only if the line joining its start and end points in the grid representation has gradient θ 1−θ . To illustrate, Figure 3 builds on the previous example by searching for substrings of density θ = 0.6. Several pairs of points separated by gradient 1−θ = 1.5 are marked (though there are several more such pairs that are not marked). The first two pairs correspond to substrings of length five, and the third pair corresponds to a substring of length ten. θ PSfrag replacements Gradient θ 1−θ = 1.5 Figure 3: Pairs of points that represent substrings of density θ = 0.6 We can find such pairs of points by drawing a line Lθ through the origin with slope 1−θ , and then measuring the distance of each point from this line (where distances are signed, so that points above or below the line have positive or negative distance respectively). This is 1−θ if and illustrated in Figure 4. It is clear that two points are joined by a line of gradient only if their distances from Lθ are the same. θ θ Lθ PSfrag replacements Start (origin) Figure 4: Measuring the distance of each point from the line Lθ Although such distances can be messy to compute, with appropriate rescaling we can convert them into integers as follows. Definition 3.3 (Distance Sequence). Recall from Assumption 2.1 that θ = α/β, where gcd(α, β) = 1. For a given bitstream x1, . . . , xn, we define the distance sequence d0, d1, . . . , dn by the formula di = (β − α) · (number of ones in x1, . . . , xi) − α · (number of zeroes in x1, . . . , xi). In other words, di = (β − α)ri − α(i − ri) = βri − αi, where ri is the corresponding entry in the rank table. 5 With a little thought it can be seen that di is proportional to the distance from Lθ of the point at the end of the ith step of the walk. This empowers the distance sequence with the following critical property: Lemma 3.4. The substring xa, . . . , xb has density equal to θ if and only if da−1 = db. Similarly, the substring xa, . . . , xb has density at least θ if and only if da−1 ≤ db. Proof. Although this follows immediately from the geometric argument above, we can also prove it directly. Using the formula di = βri − αi, we find that da−1 = db if and only if β(rb − ra−1) = α(b − a + 1), or equivalently density of xa, . . . , xb = rb − ra−1 b − a + 1 = α β = θ. The argument for density ≥ θ is similar. 3.2 The DistMap Algorithm With Lemma 3.4 we now have a simple solution to the fixed density problem. We compute the distance sequence d0, . . . , dn as we pass through our bitstream, keeping track of which distances we have seen before and when we first saw them. Whenever we find that a distance has been seen before, we have a substring of density θ and therefore a potential solution. We keep track of previously-seen distances using a key 7→ value map structure with worst- case O(log n) search and insertion, such as a red-black tree [5]. Here the key is a distance D that we have seen before, and the value is the position at which we first saw it (i.e., the smallest i for which di = D). procedure DistMap(x1, . . . , xn, θ = α/β) (a, b) ← (0, 0) δ ← 0 Initialise the empty map m Insert m[0] ← 0 for i ← 1 to n do if xi = 1 then δ ← δ + (β − α) else δ ← δ − α if m has no key δ then Insert m[δ] ← i else ⊲ Best start/end found so far ⊲ Current distance di ⊲ Record the starting point d0 = 0 ⊲ Compute the new distance di ⊲ Have we seen this distance before? ⊲ No, this is the first time if i − m[δ] > b − a + 1 then (a, b) ← (m[δ] + 1, i) ⊲ Yes, back at position m[δ] ⊲ Longest substring found so far Output (a, b) Figure 5: The DistMap algorithm for the fixed density problem The result is the algorithm DistMap, described in Figure 5. Given our choice of map structure, the following result is clear: Lemma 3.5. The algorithm DistMap solves the fixed density problem in O(n log n) time in the worst case. 6 We could of course use a hash table instead of a map structure -- with a judicious choice of hash function this could yield O(n) expected time, though the worst case could potentially be much slower. Because we offer a worst-case O(n) algorithm in Section 4, we do not pursue hashing any further here. 3.3 The DistSort Algorithm We move now to a variant of DistMap that removes any need for a map structure at all. Instead, we replace this map with a simple array that we sort in-place after all n bits of the bitstream have been processed. The new algorithm is named DistSort, and has the following advantages: • Whilst the map structure plays a key role in giving us O(n log n) running time, it also comes with a non-trivial memory overhead. If n is large and memory becomes a problem, the in-place sort used by DistSort may be a more economical choice. • DistMap relies on searching for precise matches da−1 = db within the map structure. This makes it unsuitable for the bounded density problem, which requires only da−1 ≤ db (Lemma 3.4). If we replace our map with an array sorted by distance di, then both problems become easy to solve. Indeed, we find with DistSort that the solutions for the fixed and bounded density problems differ by just one line. The key ideas behind DistSort are as follows: • We walk through the bitstream and compute each distance di as we go, just as we did for DistMap. However, instead of storing distances in a map, we store each pair (di, i) in a simple array z[0..n], so that each array entry z[i] is the pair (di, i). • Once we have finished our walk through the bitstream, we sort the array z[0..n] by distance. This gives us a sequence of (distance, position) pairs (D0, P0) (D1, P1) . . . (Dn, Pn), where D0 ≤ D1 ≤ . . . ≤ Dn and where each Di is the distance after the Pith step. • Finding positions with matching distances is now a simple matter of walking through the array from left to right -- all of the positions with the same distance will be clumped together. In each clump we track the smallest and largest positions pmin and pmax, and these become a candidate substring x(pmin+1), . . . , xpmax with density θ. The longest such substring is then our solution to the fixed density problem. • Solving the bounded density problem is just as easy. The only difference is that we now need our substring x(pmin+1), . . . , xpmax to satisfy dpmin ≤ dpmax , not dpmin = dpmax . To achieve this, we simply change pmin from the smallest position in this clump to the smallest position in all clumps seen so far. The full algorithm is given in Figure 6. The fixed and bounded density algorithms differ by only one line (marked with a comment in bold), where in the bounded case we do not reset pmin upon entering a new clump of pairs with equal distances. Regarding time complexity, we can choose a worst-case O(n log n) sorting algorithm, such as the introsort algorithm of Musser [16]. The subsequent scan through the array runs in linear time, yielding the following overall result: Lemma 3.6. The algorithm DistSort solves both the fixed and bounded density problems in O(n log n) time in the worst case. 7 procedure DistSort(x1, . . . , xn, θ = α/β) Initialise an array z[0..n] of (dist, pos) pairs δ ← 0 z[0] ← (0, 0) for i ← 1 to n do if xi = 1 then δ ← δ + (β − α) else δ ← δ − α z[i] ← (δ, i) ⊲ Current distance di ⊲ Record the starting point d0 = 0 ⊲ Compute the new distance di ⊲ Store the pair (di, i) in our array Sort z[0..n] by distance, giving a sorted sequence of pairs (D0, P0) (D1, P1) . . . (Dn, Pn) (a, b) ← (0, 0) (pmin, pmax) ← (P0, P0) i ← 0 while i ≤ n do pmin ← Pi pmax ← Pi ⊲ Best start/end positions found so far ⊲ Potential start/end positions ⊲ Do this for the fixed density problem ONLY i ← i + 1 while i ≤ n and Di = Di−1 do ⊲ Run through a clump of pairs with the same distance if Pi < pmin then pmin ← Pi if Pi > pmax then pmax ← Pi i ← i + 1 ⊲ A smaller position with this distance ⊲ A larger position with this distance if pmax − pmin > b − a + 1 then (a, b) ← (pmin + 1, pmax) ⊲ Longest substring found so far Output (a, b) Figure 6: The DistSort algorithm for the fixed and bounded density problems 4 Solving the Fixed Density Problem We proceed now to an algorithm for the fixed density problem that runs in O(n) time, even in the worst case. This algorithm uses DistMap as a starting point, but replaces the generic map structure with a specialised data structure for the task at hand. The central observation is the following. As we run the DistMap algorithm, each successive key in our map is always obtained by adding +(β − α) or −α to the previous key. We exploit this constraint to design a data structure that allows us to "jump" from one key to the next without requiring a full search, thereby eliminating the log n factor from our running time. The data structure is fairly detailed, making it difficult to give a simple overview. The following outline summarises the broad ideas involved, but for a clearer picture the reader is referred to the full description in Sections 4.1 and 4.2. The running time of O(n) is established in Section 4.3 using amortised analysis. • We begin by arranging the integers into an infinite two-dimensional lattice (Figure 7), so that +(β − α) represents a single step to the right and −α represents a single step down. 8 This makes moving from one key to the next a local movement within the lattice. This lattice has infinitely many columns but only β − α rows, so a step down from the bottom row wraps back around to the top (but with a shift). ............... ............ ............... ............ ............... ............ • −3 • ............... ............ ............... ............ −8 .......................................................... •3 .......................................................... •6 .......................................................... •9 .......................................................... •0 −6 .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... ............ ............... ............ −11 • .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... ............ ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... ........................................................................................................................................................................... ........................................................................................................................................................................... ........................................................................................................................................................................... ........................................................................................................................................................................... ........................................................................................................................................................................... ........................................................................................................................................................................... ................................................................. ................................................................. ................................................................. ................................................................. ............... ............ −2 ............... ............ −5 .......................................................... ............ ............... −16 • .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... ............ ............ ............... −13 • ............... ............ ............ ............... −10 • ............... ............ ............ ............... −7 ............ ............... −4 ............ ............... −1 ............ ............... 2 • • • • ............... ............ ............... ............ ............... ............ ............... ............ ................................................................. .................. ............ ............... ............ 7 • ............... ............ 4 • ............... ............ 1 • •12 ............... ............ • ............... ............ • ............... ............ • ............... ............ ............... ............ ............... ............ ........................................................................................................................................................................... .................. ............ .................. ............ .................. ............ .................. ............ .................. ............ ............... ............ ............... ............ .................. ............ Figure 7: The two-dimensional lattice of integers for β − α = 3 and α = 5. • We now use this integer lattice as the "domain" of our map, so that keys (the distances di) become points in the lattice, and values (the corresponding positions i) are stored at these points. In this way our data structure becomes a matrix, which is sparse because only n points in the lattice correspond to "real" keys with non-empty values. • The next stage in our design is to "compress" this sparse matrix by storing not individual key 7→ value pairs but rather horizontal runs of consecutive pairs, as illustrated in Figure 8. Storing just the start and end of each run allows us to completely reconstruct the missing keys and values in between. −8 7→ 7 −5 7→ 8 −2 7→ 9 1 7→ 10 4 7→ 11 • .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... • • • • ⇐⇒ −8 7→ 7 4 7→ 11 • ........... ............. ............. ............. ............. ............. ............. ............. ................. ... . • Figure 8: Compressing a horizontal run of consecutive pairs • We finish by developing a linked structure for storing our matrix. The compressed runs in each row are stored as a "horizontal" linked list, with additional "vertical" links between rows for downward steps. We also chain vertical links together, yielding a perfect bal- ance that offers enough information to support fast movement between keys, but enough flexibility to support fast insertion of new key 7→ value pairs. Before presenting the details, it becomes useful to strengthen our base assumptions as follows. Assumption 4.1. Recall from Assumption 2.1 that θ = α/β, where 0 ≤ α ≤ β ≤ n. From here onwards we strengthen this by assuming the stricter bounds 0 < α < β ≤ n. In other words, we explicitly disallow the special cases θ = 0 and θ = 1. Like our earlier assumptions, this is not restrictive in any way. If θ = 0 or θ = 1 then we simply require the longest continuous substring of zeroes or ones, which is trivial to find in linear time. 4.1 The Mapping Matrix We begin the details with a formal definition of the integer lattice depicted in Figure 7. Recall from Assumptions 2.1 and 4.1 that both β−α and α are strictly positive, and that gcd(β−α, α) = 1. Definition 4.2 (Lattice Coordinates). Let z be any integer. The lattice coordinates of z are the unique solutions (r, c) to the equation (β − α)c − αr = z, (1) 9 for which r and c are integers and 0 ≤ r < β − α. We call r and c the row and column of z respectively. For example, consider Figure 7 in which β − α = 3 and α = 5. The following table lists the lattice coordinates of several integers z: Integer z Lattice coordinates of z −3 0 3 6 1 (0, −1) (0, 0) (0, 1) (0, 2) (1, 2) −4 (2, 2) These are precisely the locations at which each integer can be found in Figure 7, where we number the rows and columns so that the integer zero appears at coordinates (0, 0). With a little modular arithmetic it can shown that every integer appears once and only once in our lattice, as expressed formally by the following result. The proof is elementary, and we do not repeat it here. Lemma 4.3. Lattice coordinates are always well-defined, that is, equation (1) has a unique solution for every integer z. Moreover, every pair of integers (r, c) with 0 ≤ r < β − α forms the lattice coordinates of one and only one integer. It is worth reiterating a key feature of this construction, which is that each bit of the bitstream gives rise to a local movement within the lattice: Lemma 4.4. Consider some position i within the bitstream, where 0 ≤ i < n. Suppose that the lattice coordinates of the distance di are (r, c). Then: • If the (i + 1)th bit is a one, the lattice coordinates of the subsequent distance di+1 are (r, c + 1). That is, we take one step to the right. • If the (i + 1)th bit is a zero and r < β − α − 1, then the lattice coordinates of di+1 are (r + 1, c). That is, we take one step down. • If the (i + 1)th bit is a zero and r = β − α − 1 (i.e., we are on the bottom row of the lattice), then the lattice coordinates of di+1 are (0, c − α). That is, we wrap back around to the top with a shift of α columns to the left. This is a straightforward consequence of Definitions 3.3 and 4.2, and again we omit the proof. The various movements described in this result are indicated by the solid lines in Figure 7. Recall that our overall strategy is to build a replacement data structure for the generic key 7→ value map, whose keys are distances di and whose values are the corresponding positions i in the bitstream. Using Lemma 4.3 we can replace each distance di with its lattice coordinates (r, c), thereby replacing the old mapping di 7→ i with the new mapping (r, c) 7→ i. This effectively gives us a matrix with β − α rows and infinitely many columns, which we formalise as follows. Definition 4.5 (Mapping Matrix). We define the mapping matrix to be an infinite matrix with precisely β − α rows (numbered 0, . . . , β − α − 1) and infinitely many columns in both directions (numbered . . . , −1, 0, 1, . . .). Each cell of this matrix may contain an integer, or may contain the symbol ∅ representing an empty cell. The entry in row r and column c of the mapping matrix M is denoted M [ r, c ]. Our algorithm now runs as follows. As we process each bit of the bitstream, we walk through the cells of the mapping matrix as described by Lemma 4.4. If we step into an empty cell, we store the current position in the bitstream. If we step into a previously-occupied cell then we have found a substring of density θ. The full pseudocode is given in Figure 9, under the algorithm name DistMatrix. The algorithm is of course remarkably similar to DistMap (Figure 5), since the key difference is in the underlying data structure. Our focus in Section 4.2 is now to fully describe this data structure, and thereby describe the critical tasks of evaluating and setting the matrix entry M [ r, c ]. 10 procedure DistMatrix(x1, . . . , xn, θ = α/β) (a, b) ← (0, 0) (r, c) ← (0, 0) Initialise the empty mapping matrix M Insert M [ 0, 0 ] ← 0 for i ← 1 to n do if xi = 1 then c ← c + 1 else if r < β − α − 1 then r ← r + 1 else (r, c) ← (0, c − α) if M [ r, c ] = ∅ then Insert M [ r, c ] ← i else ⊲ Best start/end found so far ⊲ Current location in the matrix ⊲ Record the starting point d0 = 0 ⊲ Step right ⊲ Step down ⊲ Step down and wrap around ⊲ Have we been here before? ⊲ No, this is the first time if i − M [ r, c ] > b − a + 1 then (a, b) ← (M [ r, c ] + 1, i) ⊲ Yes, back at position M [ r, c ] ⊲ Longest substring found so far Output (a, b) Figure 9: The DistMatrix algorithm for the fixed density problem 4.2 The Data Structure We cannot afford to store the mapping matrix as a two-dimensional array, because -- even ig- noring the infinitely many columns -- there are O(n2) potential cells that a bitstream of length n might reach.2 However, only n + 1 cells are visited (and hence non-empty) for any particular input bitstream. That is, the mapping matrix is sparse. We therefore aim for a linked structure, where only the cells we visit are stored in memory, and where these cells include pointers to nearby cells to assist with navigation around the matrix. However, before describing this linked structure we introduce a form of compression, where we only need to store the cells involved in downward steps. As we will see in Section 4.3, this compression is critical for stepping through the matrix in amortised constant time. Our compression relies on the observation that a run of k consecutive steps to the right produces a sequence of k consecutive values in the matrix: i i + 1 · · · i + k We can describe such a sequence by storing only the start and end points, without having to store each individual cell in between. This pattern becomes more complicated when new paths through the matrix cross over old paths, but the core idea remains the same -- we look for horizontal runs of consecutive values in the matrix, and record only where they start and end. Figure 10 gives an example, where four different paths from four different sections of the bitstream cross through the same row of the matrix. • Figure 10(a) shows the four paths, which are labelled A, B, C and D in chronological order as they appear in the bitstream. For instance, path A enters the row at cell (8, 1) and position 10 in the bitstream, takes two steps to the right, and exits the row from cell 2This of course depends upon the value of θ. If θ = 1 2 for instance, then there are only 2n + 1 potential cells and a more direct linear algorithm becomes possible. Here we treat the general case 0 < α < β ≤ n. 11 PSfrag replacements D (pos 70) B (pos 30) A (pos 10) C (pos 50) Column: −5 0 5 9 Row: 8 B (pos 33) A (pos 12) C (pos 50) D (pos 84) (a) Several paths that cross through a single matrix row Column: Row: 8 −5 ↓ 70 0 31 32 ↓ 30 71 72 ↓ 10 ↓ 11 12 ↓ 5 79 80 81 ↓ 50 ↓ 83 9 84 ↓ (b) The corresponding values in the mapping matrix Cell Value in this cell Value to start this run (8, −5) (8, −2) (8, 1) (8, 3) (8, 7) (8, 9) 70 30 10 12 50 84 70 30 10 78 82 ∅ (c) Storing these values in memory Figure 10: Compressing a row of the mapping matrix (8, 3) at position 12 in the bitstream. Note that path B subsequently exits from the same cell that A entered, and that path C includes no rightward steps at all. • Figure 10(b) shows the state of the mapping matrix after all four paths have been followed. Note that values from older paths take precedence over values from newer paths, since we always record the first position at which we enter each cell. Vertical arrows are included as reminders of the cells at which paths enter and exit the row. • Figure 10(c) shows how this state can be "compressed" in memory. We only store cells at which paths enter and exit the row, and for each such cell (r, c) we record the following information: -- The value stored directly in that cell, i.e., M [ r, c ]; -- The value that "begins" the horizontal run to the right, i.e., M [ r, c + 1 ] − 1. If the cell (r, c) is itself part of the run (such as (8, −5), (8, −2) and (8, 1) in our example) then both values will be equal. If the cell (r, c) is the exit for an older path (such as (8, 3) or (8, 7) in our example) then these values will be different. If there is no run to the right (as with (8, 9) in our example) then we store the symbol ∅. We collate this information into a full linked data structure as described below in Data Struc- ture 4.6. A detailed example of this linked structure is illustrated in Figure 11. 12 PSfrag replacements Column −∞ Row r Row r + 1 Row r + 2 Column +∞ Entry / exit cell Vertical link Horizontal links Secondary link Figure 11: An illustration of the full linked data structure Data Structure 4.6 (Mapping Matrix). Suppose we have processed the first k bits of our bitstream. To store the current state of the mapping matrix, we keep records in memory for the following cells: • The entry and exit cells in each row, i.e., cells that correspond to positions immediately before or after a zero bit; • The two cells corresponding to the beginning of the bitstream and our current position; • "Sentinel" cells (r, −∞) and (r, +∞) in each row. The record for each such cell (r, c) contains the following information: • The column c; • The values M [ r, c ] and M [ r, c+ 1 ]− 1 as described above, where for the sentinels (r, ±∞) these values are ∅; • Links to the previous and next cells in the same row (called horizontal links). In addition, if we have previously stepped down from this cell then we also store: • A link to the endpoint of this step in the following row (called a vertical link), where this endpoint is (r + 1, c) or (0, c − α) according to whether or not r < β − α − 1; • A link that jumps to the next vertical link in this row, that is, a link to the nearest cell to the right that also stores a vertical link (we call this new link a secondary link). We also insert vertical links between the sentinels at (r, ±∞), running from each row to the next, and join these into the chains of secondary links for each row. To summarise: (i) the "interesting" cells in each row are stored in a horizontal doubly-linked list, (ii) we add vertical links corresponding to previous steps down, and (iii) we chain together the vertical links from each row into a secondary linked list. We return now to fill in the missing parts of the DistMatrix algorithm (Figure 9), namely the evaluation and setting of the matrix entry M [ r, c ]. This can be done as follows. (i) At all times we keep a pointer to the current cell in the matrix (which, according to Data Structure 4.6, always has a record explicitly stored). 13 (ii) Each time we step right or down, we adjust the data structure to reflect the new bit that has been processed, and we move our pointer to reflect the new current cell. (iii) Evaluating and setting M [ r, c ] then becomes a simple matter of dereferencing our pointer. The only step that might not run in constant time is (ii), where we adjust the data structure and move our pointer. The precise work involved varies according to which type of step we take. • Step right (processing a one bit): This is a local operation involving no vertical or secondary links. We might need to extend the endpoint of the current horizontal run or start a new run from the current cell, but these are all simple constant time adjustments involving only the immediate left and right horizontal neighbours. • Step down (processing a zero bit): This is a more complex operation that uses all three link types. Suppose that we begin the step in cell (r, c); for convenience we assume that we step down to (r + 1, c), but the wraparound case r = β − α − 1 is much the same. If there is already a vertical link (r, c) → (r + 1, c) then we simply follow it. Otherwise we do the following: (1) Find where the destination cell (r + 1, c) should be inserted in the horizontal list for row r + 1 (or find the cell itself if it is already explicitly stored). We do this by: -- walking back along row r until we find the nearest vertical link to the left, which we denote L−; -- following the secondary link from L− to the nearest vertical link to the right, which we denote L+; -- following the link L+ down to row r + 1; -- walking back along row r + 1 until we find our insertion point. PSfrag replacements PSfrag replacements (r + 1, c) Row r Row r + 1 L− L+ (r, c) Row r Row r + 1L− (r, c) (r + 1, c) L+ PSfrag replacements (a) The neighbourhood of the source cell (r, c) (b) The path from (r, c) to (r+1, c) Row r Row r + 1 (r, c) L− L0 L+ (r + 1, c) (c) The new vertical and secondary links Figure 12: Stepping down from (r, c) to (r + 1, c) This series of movements is illustrated in Figure 12(b). Note that our sentinels at (r, ±∞) ensure that the vertical links L− and L+ will always exist. (2) If required, insert the cell (r + 1, c) into the horizontal list for row r + 1 and update its immediate horizontal neighbours. 14 (3) Insert the new vertical link (r, c) → (r + 1, c), which we denote L0. (4) Replace the secondary link L− → L+ with two secondary links L− → L0 → L+, as illustrated in Figure 12(c). Operations (2), (3) and (4) are all constant time operations, but operation (1) may involve a lengthy walk through the data structure. The reason for the convoluted path (and indeed the secondary links) is because by walking backwards along each row we can ensure that operation (1) runs in amortised constant time, as shown in the following section. 4.3 Analysis of Running Time Through the discussions of the previous section, we find that -- with the single exception of the walk from (r, c) to (r+1, c) when we step down in the mapping matrix -- each bit of the bitstream can be processed in constant time. The following lemma shows that these exceptional walks can be processed in amortised constant time, giving DistMatrix an overall running time of O(n). As in the previous section, we assume that we step down from (r, c) to (r+1, c); the arguments for the wraparound case r = β − α − 1 are essentially the same. It is also important to remember that the phrases step down and step right refer to the full movement when processing some bit of the bitstream, and not the many different links that we might follow through the data structure in performing such a step. Lemma 4.7. Consider the walk from cell (r, c) to (r + 1, c) in the "step down" phase of the DistMatrix algorithm, as illustrated in Figure 12(b), and define the length of this walk to be the total number of links that we follow. After processing the entire bitstream, the sum of the lengths of all "step down" walks is O(n). In other words, each such walk can be followed in amortised constant time. Proof. We prove this result using aggregate analysis, by "counting" the number of links in each walk using a rough upper bound. The following links are excluded from this count: • all vertical and secondary links; • the leftmost horizontal link on each row of each walk; • any horizontal links that end at the starting point (0, 0); • any horizontal links that end at the current cell (r, c). Figure 13 shows a sample walk where the excluded links are marked with dotted arrows, and the remaining links (all horizontal) are marked with bold solid arrows. It is clear that we exclude O(n) links in total,3 and so if we can show that at most O(n) horizontal links remain then the proof is complete. PSfrag replacements (r, c) L− L+ (r + 1, c) Figure 13: Excluded links in a "step down" walk Within each walk from (r, c) to (r + 1, c), the horizontal links that remain have the following critical properties: 3A horizontal link ending at (0, 0) can occur at most twice per walk (and at most once if β − α > 1). A horizontal link ending at (r, c) can occur at most once per walk, and only in the special case β − α = 1. 15 • The endpoint of each link in row r is also the endpoint of some earlier step down. Moreover, this earlier step down was followed immediately by a succession of steps right that reached at least as far along the row as (r, c). • The endpoint of each link in row r + 1 is also the beginning of some earlier step down. Moreover, this earlier step down was preceded immediately by a succession of steps right that originated at least as far back along the row as (r + 1, c). PSfrag replacements (r, c) (r + 1, c) Figure 14: Earlier successions of steps associated with the remaining links These properties are a consequence of our compression (recall that each non-sentinel cell that we store is either (0, 0), the current cell, a row entry or a row exit), as well as the fact that there are no vertical links between L− and L+ that join row r with row r + 1. Figure 14 illustrates the successions of rightward steps that are described above. We can now associate each remaining link ℓ with a position π(ℓ) in the bitstream: • If the link ℓ is on the "upper" row r, consider the oldest sequence of steps that stepped down to the endpoint of ℓ and then right all the way across to (r, c), as illustrated in Figure 15(a). We define π(ℓ) to be the position in the bitstream that was reached by this sequence when it passed through the cell (r, c). Note that 0 < π(ℓ) ≤ n. • If the link ℓ is on the "lower" row r + 1, consider the oldest sequence of steps that stepped right from (r + 1, c) all the way across to the endpoint of ℓ and then down, as illustrated in Figure 15(b). We define π(ℓ) to be the position in the bitstream that was reached by this sequence when it passed through the cell (r + 1, c), negated so that −n ≤ π(ℓ) < 0. PSfrag replacements PSfrag replacements (r + 1, c) Sequence of steps ℓ (r, c) (r, c) (r + 1, c) ℓ Sequence of steps (a) If ℓ is on the upper row (b) If ℓ is on the lower row Figure 15: The earlier sequence of steps that defines π(ℓ) The key to achieving an O(n) total of walk lengths is to observe that the function π is one-to-one: • A link ℓ1 on the upper row of some walk can never have the same value of π as a link ℓ2 on the lower row of some (possibly different) walk, since π(ℓ2) < 0 < π(ℓ1). • Within a single walk: -- The values π(ℓ) for links ℓ on the upper row r are distinct, because each corresponds to a different historical path through (r, c), with a different initial entry point into row r. 16 -- Likewise, the values π(ℓ) for links ℓ on the lower row r + 1 are distinct, because each corresponds to a different historical path along row r + 1 with a different final exit point from row r + 1. • Between different walks: -- Because we insert a new vertical link after every walk, each walk must have a distinct starting point (r, c). The values π(ℓ) from the upper rows of different walks are therefore distinct because they correspond to positions in the bitstream for distinct cells (r, c). -- Likewise, the values π(ℓ) from the lower rows of different walks are distinct because they correspond to positions in the bitstream for distinct cells (r + 1, c). Therefore π is a one-to-one function. Because π(ℓ) ∈ {−n, −n + 1, . . . , n − 1, n}, it follows that the number of links ℓ in the domain of the function can be at most 2n + 1. Hence there are O(n) horizontal links remaining that we have not excluded from our count, and the proof is complete. Through Lemma 4.7 we now find that each bit of the bitstream can be completely processed in amortised constant time, yielding the following final result: Corollary 4.8. The algorithm DistMatrix solves the fixed density problem in O(n) time in the worst case. 5 Solving the Bounded Density Problem We finish our suite of algorithms with a linear time solution to the bounded density problem, improving upon the log-linear DistSort algorithm of Section 3. Unlike our linear time solution to the fixed density problem, this algorithm is simple to express, uses no sophisticated data structures, and essentially involves just a handful of linear scans. Once again we base our new algorithm on the distance sequence d0, . . . , dn. Recall from Lemma 3.4 that we seek the longest substring xa, . . . , xb in the bitstream for which da−1 ≤ db. We begin with the following simple observation: Lemma 5.1. Suppose that xa, . . . , xb is the longest substring of density ≥ θ in our bitstream. Then there is no i < a − 1 for which di ≤ da−1, and there is no i > b for which di ≥ db. The proof is simple -- if there were such an i, then we could extend our substring to position i and obtain a longer substring with density ≥ θ. This result motivates the following definition: Definition 5.2 (Minimal and Maximal Position). Let k be a position in the bitstream, i.e., some integer in the range 0 ≤ k ≤ n. We call k a minimal position if there is no i < k for which di ≤ dk, and we call k a maximal position if there is no i > k for which di ≥ dk. Figure 5 plots the distance sequence for the bitstream 1001101001011 with target density θ = α/β = 3/5, and marks the minimal and maximal positions on this plot. Minimal and maximal positions have the following important properties: • They are the only positions that we need to consider. That is, the solution to the bounded density problem must be a substring xa, . . . , xb for which a − 1 is a minimal position and b is a maximal position (Lemma 5.1). • They are simple to compute in O(n) time. To find all minimal positions, we simply walk through the distance sequence d0, . . . , dn and collect positions i for which di is smaller than any distance seen before. To find all maximal positions, we walk through the distance sequence in reverse (dn, . . . , d0) and collect positions i for which di is larger than any distance seen before. 17 Distance di 0 2 1 −1 −2 −3 −4 −5 −6 −7 −8 Maximal positions 1 2 3 4 6 7 8 9 10 11 12 13 Position i Minimal positions Figure 16: Minimal and maximal positions for the bitstream 1001101001011 • They are ordered by distance. That is, if the minimal positions are a1, a2, . . . , ap from left to right (a1 < a2 < . . . < ap) then we have da1 > da2 > . . . > dap . Likewise, if the maximal positions are b1, b2, . . . , bq from left to right (b1 < b2 < . . . < bq) then we have db1 > db2 > . . . > dbq . This is an immediate consequence of Definition 5.2. Our algorithm then runs as follows: 1. We compute the distance sequence in O(n) time, by incrementally adding +(β − α) or −α as seen in DistMap and DistSort. 2. We compute the minimal positions a1, a2, . . . , ap and the maximal positions b1, b2, . . . , bq in O(n) time as described above. 3. For each minimal position ai, we find the largest maximal position bj for which dai ≤ dbj . This gives a substring of density ≥ θ and length bj − ai + 1, and we compare this with the longest such substring found so far. The key observation is that, because minimal and maximal positions are ordered by distance, step 3 can also be performed in O(n) time. Specifically, if the minimal position ai is matched with the maximal position bj, then the next minimal position ai+1 will be matched with an equal or later maximal position, i.e., one of bj, bj+1, . . . , bq. We can therefore keep a pointer into the sequence of maximal positions and slowly move it forward as we process each of a1, . . . , ap, giving step 3 an O(n) running time in total. We name this algorithm PositionSweep; see Figure 17 for the pseudocode. Through the discussion above we obtain the following final result: Lemma 5.3. The algorithm PositionSweep solves the bounded density problem in O(n) time in the worst case. 6 Measuring Performance We finish this paper with a practical field test of the different algorithms for the fixed den- sity problem.4 In particular, because the linear DistMatrix algorithm involves a complex data 4We omit the bounded density problem from this field test because the linear algorithm PositionSweep is simple and slick, with neither the complexity nor the potential overhead of DistMatrix. 18 procedure PositionSweep(x1, . . . , xn, θ = α/β) d0 ← 0 for i ← 1 to n do if xi = 1 then di ← di−1 + (β − α) else di ← di−1 − α p ← 1 ; a1 ← 0 for i ← 1 to n do if di < dap then p ← p + 1 ; ap ← i ; q ← 1 for i ← n − 1 downto 0 do b1 ← n if di > dbq then ; q ← q + 1 bq ← i (a, b) ← (0, 0) j ← 1 for i ← 1 to p do while j < q and dai ≤ dbj+1 do j ← j + 1 if bj − ai > b − a + 1 then (a, b) ← (ai + 1, bj) Output (a, b) ⊲ Compute the distance sequence ⊲ Compute minimal positions ⊲ Compute maximal positions ⊲ Best start/end found so far ⊲ Run through minimal positions ⊲ Find best maximal position ⊲ Longest substring found so far Figure 17: The PositionSweep algorithm for the bounded density problem structure with potentially significant overhead, it is useful to compare its practical performance against the log-linear but much simpler algorithms DistMap and DistSort. The tests are designed as follows: • We use bitstreams of length n = 108 for all tests. This value of n was chosen to be large but manageable. We keep n fixed merely to simplify the data presentation -- additional data has been collected for several smaller values of n, and the results show similar characteristics to those described here. • All bitstreams are pseudo-random.5 This is of particular benefit to the SkipMisMatch algorithm, whose expected running time of O(n log n) in a random scenario is significantly better than its worst case time of O(n2). • We run tests with several different values of the target density θ. This includes values close to and far away from 1 2 , as well as values with small and large denominators -- our aim is to identify to what degree the performance of different algorithms depends upon θ. The values of θ that we use are 1 2 , 1 3 , 2 5 , 1 5 , 50 101 , 31 101 and 1 101 . • Each test involves the same 200 pre-generated bitstreams of length n = 108. For each algorithm and each value of θ we measure the mean running time over all 200 bitstreams. All running times are measured as user + system time, running on a single 3 GHz Intel Core 2 CPU with 4GB of RAM. All algorithms are coded in C++ under GNU/Linux. 5Bitstreams were generated using the rand() function from the Linux C Library. 19 Comparison of running times for n = 100,000,000 SkipMisMatch DistMap DistSort DistMatrix ) c e s ( e m i i t g n n n u r n a e M 0 0 0 3 0 0 0 1 0 0 3 0 0 1 0 3 0 1 3 1/2 50/101 2/5 1/3 Theta 31/101 1/5 1/101 Figure 18: Running times of different algorithms for the fixed density problem The results are plotted in Figure 18; note that the time axis uses a log scale, with each horizontal line representing a factor of approximately ×3. Error bars are not included because most standard errors are within ±1%; the only exceptions are for θ = 1 2 , where DistMap has a standard error of ±1.6% and SkipMisMatch has a standard error of ±10%. The values of θ are ordered by distance from 1 2 . Happily, the results are what we hope for. The log-linear algorithms DistMap and Dist- Sort perform significantly better than SkipMisMatch in most cases, and the linear algorithm DistMatrix consistently outperforms all of the others. The dependency of SkipMisMatch upon θ is evident -- performance is best when both θ − 1 2 and the denominator β are large (as expected from Lemma 2.3), bringing it close to the 4 second running time of DistMatrix for the extreme case θ = 1 2 the SkipMisMatch algorithm runs orders of magnitude slower, with a mean running time of over an hour and some individual cases taking up to 10 1 101 . At the other extreme, for θ = 1 2 hours. Amongst the log-linear algorithms6, we find that DistSort performs noticeably better than DistMap. Part of the reason is the memory overhead due to the map structure -- it was found that DistMap often exceeded the available memory on the machine, burdening it with a reliance on virtual memory (which of course is much slower). The linear DistMatrix algorithm also suffers from memory problems to a lesser extent, but Figure 18 shows that that the effectiveness of the algorithm more than compensates for this. Figure 19 plots the peak memory usage for each algorithm, again averaged over all 200 bitstreams. An interesting feature of the running times is that DistMap depends upon θ in an opposite 2 or the denominator β is small, there are manner to SkipMisMatch. This is because when θ ≃ 1 fewer distinct distances amongst d0, . . . , dn, and hence fewer elements stored in the map. 6For DistMap and DistSort, the map and sort are implemented using std::map and std::sort from the C++ Standard Library, as implemented by the GNU C++ compiler version 4.3.2. 20 Peak memory usage for n = 100,000,000 SkipMisMatch DistMap DistSort DistMatrix ) B G ( e g a s u y r o m e m k a e p n a e M 6 5 4 3 2 1 0 1/2 50/101 2/5 1/3 Theta 31/101 1/5 1/101 Figure 19: Peak memory usage of different algorithms for the fixed density problem In conclusion, it is pleasing to note how consistently DistMatrix performs across all of the tested values of θ, with mean running times ranging from 3.2 seconds to 4.2 seconds and stan- dard errors of just 0.1%. The experiments therefore suggest that the added complexity and overhead of DistMatrix are well justified by the efficiency of the algorithm and its underlying data structure. Acknowledgements The author is supported by the Australian Research Council's Discovery Projects funding scheme (project DP1094516). He is grateful to Serdar Bozta¸s, Mathias Hiron and Casey Pfluger for fruitful discussions relating to this work. References [1] R. Arratia, L. Gordon, and M. S. Waterman, The Erdos-R´enyi law in distribution, for coin tossing and sequence matching, Ann. Statist. 18 (1990), no. 2, 539 -- 570. [2] Giorgio Bernardi, Isochores and the evolutionary genomics of vertebrates, Gene 241 (2000), no. 1, 3 -- 17. [3] Serdar Bozta¸s, Simon J. Puglisi, and Andrew Turpin, Testing stream ciphers by finding the longest substring of a given density, Information Security and Privacy, Lecture Notes in Comput. Sci., vol. 5594, Springer, Berlin, 2009, pp. 122 -- 133. [4] Kevin Chen, Matt Henricksen, William Millan, Joanne Fuller, Leonie Simpson, Ed Dawson, Hoon- Jae Lee, and SangJae Moon, Dragon: A fast word based stream cipher, Information Security and Cryptology -- ICISC 2004, Lecture Notes in Comput. Sci., vol. 3506, Springer, Berlin, 2005, pp. 33 -- 50. 21 [5] Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein, Introduction to algorithms, 2nd ed., MIT Press, Cambridge, MA, 2001. [6] Laurent Duret, Dominique Mouchiroud, and Christian Gautier, Statistical analysis of vertebrate sequences reveals that long genes are scarce in GC-rich isochores, J. Mol. Evol. 40 (1995), no. 3, 308 -- 317. [7] Paul Erdos and Alfr´ed R´enyi, On a new law of large numbers, J. Analyse Math. 23 (1970), 103 -- 111. [8] Stephanie M. Fullerton, Antonio Bernardo Carvalho, and Andrew G. Clark, Local rates of recombi- nation are positively correlated with GC content in the human genome, Mol. Biol. Evol. 18 (2001), no. 6, 1139 -- 1142. [9] Michael H. Goldwasser, Ming-Yang Kao, and Hsueh-I Lu, Linear-time algorithms for computing maximum-density sequence segments with bioinformatics applications, J. Comput. System Sci. 70 (2005), no. 2, 128 -- 144. [10] Ronald I. Greenberg, Fast and space-efficient location of heavy or dense segments in run-length en- coded sequences, Computing and Combinatorics, Lecture Notes in Comput. Sci., vol. 2697, Springer, Berlin, 2003, pp. 528 -- 536. [11] Ross Hardison, Dan Krane, David Vandenbergh, Jan-Fang Cheng, James Mansberger, John Taddie, Scott Schwartz, Xiaoqiu Huang, and Webb Miller, Sequence and comparative analysis of the rabbit α-like globin gene cluster reveals a rapid mode of evolution in a G + C-rich region of mammalian genomes, J. Mol. Biol. 222 (1991), no. 2, 233 -- 249. [12] Yong-Hsiang Hsieh, Chih-Chiang Yu, and Biing-Feng Wang, Optimal algorithms for the interval location problem with range constraints on length and average, IEEE/ACM Trans. Comput. Biol. Bioinformatics 5 (2008), no. 2, 281 -- 290. [13] Donald E. Knuth, The art of computer programming, Vol. 2: Seminumerical algorithms, 3rd ed., Addison-Wesley, Reading, MA, 1997. [14] Yaw-Ling Lin, Tao Jiang, and Kun-Mao Chao, Efficient algorithms for locating the length- constrained heaviest segments, with applications to biomolecular sequence analysis, Mathematical Foundations of Computer Science 2002, Lecture Notes in Comput. Sci., vol. 2420, Springer, Berlin, 2002, pp. 459 -- 470. [15] G. Marsaglia, A current view of random number generators, Computer Science and Statistics: The Interface (L. Billard, ed.), Elsevier Science, Amsterdam, 1985, pp. 3 -- 10. [16] David R. Musser, Introspective sorting and selection algorithms, Softw. Pract. Exper. 27 (1997), no. 8, 983 -- 993. [17] Paul M. Sharp, Michalis Averof, Andrew T. Lloyd, Giorgio Matassi, and John F. Peden, DNA sequence evolution: The sounds of silence, Phil. Trans. R. Soc. Lond. B 349 (1995), no. 1329, 241 -- 247. [18] Serguei Zoubak, Oliver Clay, and Giorgio Bernardi, The gene distribution of the human genome, Gene 174 (1996), no. 1, 95 -- 102. Benjamin A. Burton School of Mathematics and Physics, The University of Queensland Brisbane QLD 4072, Australia ([email protected]) 22
1607.08176
1
1607
2016-07-27T16:50:05
Suffix arrays with a twist
[ "cs.DS" ]
The suffix array is a classic full-text index, combining effectiveness with simplicity. We discuss three approaches aiming to improve its efficiency even more: changes to the navigation, data layout and adding extra data. In short, we show that $(i)$ how we search for the right interval boundary impacts significantly the overall search speed, $(ii)$ a B-tree data layout easily wins over the standard one, $(iii)$ the well-known idea of a lookup table for the prefixes of the suffixes can be refined with using compression, $(iv)$ caching prefixes of the suffixes in a helper array can pose a(nother) practical space-time tradeoff.
cs.DS
cs
Suffix arrays with a twist Tomasz Kowalski†, Szymon Grabowski†, Kimmo Fredriksson‡ and Marcin Raniszewski† † Lodz University of Technology, Institute of Applied Computer Science, Al. Politechniki 11, 90 -- 924 L´od´z, Poland {tkowalssgrabowmranisz}@kis.p.lodz.pl ‡ School of Computing, University of Eastern Finland, P.O.B. 1627, FI-70211 Kuopio, Finland, [email protected] Abstract. The suffix array is a classic full-text index, combining ef- fectiveness with simplicity. We discuss three approaches aiming to im- prove its efficiency even more: changes to the navigation, data layout and adding extra data. In short, we show that (i) how we search for the right interval boundary impacts significantly the overall search speed, (ii) a B-tree data layout easily wins over the standard one, (iii) the well-known idea of a lookup table for the prefixes of the suffixes can be refined with using compression, (iv) caching prefixes of the suffixes in a helper array can pose a(nother) practical space-time tradeoff. 1 Introduction Everybody knows the suffix array (SA) [4], a simple full-text index data struc- ture capable of finding the occ occurrences of a pattern P of length m in O(m log n + occ) time, where n is the length of the indexed text. The search mechanism consists in two binary searches, for the left and the right boundary of the interval of text suffixes starting with P , in the array of suffix offsets ar- ranged in the lexicographical order of their text content. The performance of the suffix array can serve as a measuring stick for more advanced (e.g., com- pressed) text indexes [1] and at least for this reason it is important to know how to implement it efficiently and what space-time tradeoffs are possible. The body of research on engineering the suffix array is surprisingly scarce. Although the basic SA idea can be easily grasped even by high-school students, many design choices from the implementor's point of view are not obvious. Let us pose a few questions: (i) Can the binary search strategy be replaced with a faster one, e.g., based on interpolation search? (ii) As occ is usually small, what is practically the best way to find the right interval boundary once the left boundary is known? (iii) Can we change the data layout of suffixes in order to obtain more local memory accesses? (iv) How can we augment the suffix array with a moderate amount of extra data, to initially reduce the search interval and/or speed up string comparisons? The answer to some of them is known, yet in this work we are dealing with the mentioned issues in a more systematic way. 2 Ideas and incarnations The considered ideas are divided into three groups and each of them is described in a separate paragraph. First we discuss non-standard SA traversal strategies. Later we advocate for alternative data layouts, beneficial for the search speed. In the last paragraph some ways to augment the suffix array with extra data, to make the pattern search even faster, are proposed. Navigating over the suffix array. A textbook alternative to binary search is interpolation search, which performs a number of "guesses" concerning the query's location based on the query value and the assumed distribution of keys. It is well-known that interpolation search over constant-size keys achieves O(log log n) expected time not only for the simplest case, i.e., uniformly random distribution [6], yet we are not aware of any published experiments regarding text suffixes. Unfortunately, a straightforward interpretation of string prefixes (which have a lot of duplicates) as integers and standard linear interpolation yielded rather disappointing preliminary results. Another question concerning the navigation over the SA is how the right interval boundary should be found. We examine two methods: a naive one per- forms the binary search over the range lef t . . . n of suffixes, where lef t is the position of the least suffix greater or equal to the pattern, and the doubling (gal- loping) algorithm, which peeks the locations SA[lef t + 2i], i = 0, 1, 2, . . ., until it reaches too far and the search continues in the binary manner over the last considered interval. Note that the time complexity of the right interval boundary search improves in this way from O(m log n) to O(m log occ). Linearized k-ary tree data layout. Binary search over a sorted array is equivalent to walking down a path in a complete binary search tree. Schleger et al. [5] noticed that changing the tree layout from binary to k-ary (k > 2), together with linearization of the search tree, may be more cache-friendly and also convenient for SIMD processing. In their experiments (Intel Core i7) it achieved a speedup of as much as 3 up to 4.5 for 32-bit numbers and 2 to 2.5 for 64-bit numbers, compared to a plain binary search. This data organization can also be called an (implicit) B-tree layout [3]. We apply the presented idea to the suffix array, which, to our knowledge, has not been tried before. Note that setting the B-tree layout for a suffix array cannot be comparably successful as for, e.g., integers, as the accesses to the text are still at "random" areas. Augmenting the suffix array. Manber and Myers in their seminal paper [4] presented a nice trick saving several first steps in the binary search: if we know the SA intervals for all the possible first k symbols of the pattern, we can immediately start the binary search in a corresponding interval. We can set k to logσ n, where σ is the alphabet size, with O(n log n) extra bits of space and constant expected size of the interval. Unfortunately, real texts are far from random, hence in practice, we can use k up to 3 (assuming that text symbols are bytes), which offers a limited (yet, non-negligible) benefit. This idea will be referred in our experiments as using a lookup table, and more specifically we will denote the lookup table on pairs (resp. triples) of symbols with LUT2 (resp. LUT3). In the same spirit, Grabowski and Raniszewski [2] use a hash table to store the intervals for all k-symbol strings occurring in the text. This can significantly reduce the initial interval for real texts with relatively little extra space. In this work we first propose a lookup table with keys being concatenations of Huffman codewords for the starting symbols of the text suffixes (Table 1), truncated to a specified length of b bits. Pattern search translates to finding the first b bits of Huffman encoding of the pattern, which is the LUT key, and then following with binary search over a range of suffixes read from the LUT. A correct implementation of this idea requires a reordering of the suffixes in the SA, to avoid nested LUT ranges (other options, like replacing Huffman with Hu -- Tucker coding, are also possible but we have not tried them out). Note also that the Huffman-based LUT entries store twice more data (both boundaries of the interval) than in the standard LUTs. Table 1. Average binary logarithms of the search interval widths for different LUT variants (first three rows: Huffman encoding with 16 -- 24 bits, next two rows: standard 2-/3-byte LUTs). The averages are over 100K patterns taken randomly from the text. dataset space (MiB) dna200 english200 proteins200 xml200 -- LUT-Huff-15b LUT-Huff-19b LUT-Huff-23b LUT2 LUT3 -- 0.25 4.00 64.00 0.25 64.00 27.644 14.453 11.070 7.790 23.738 21.820 27.644 15.530 13.432 11.630 19.502 16.555 27.644 12.858 9.103 5.617 19.266 15.108 27.644 17.045 15.898 14.985 18.910 16.756 We also propose mixing the LUT or hash table interval narrowing with the B-tree layout, and also augmenting the search tree with prefixes of the suffixes in several top levels of the B-tree. Copying these text snippets into a helper array is beneficial due to more local memory accesses. 3 Experimental results The test machine was equipped with a 4-core Intel i7 4790 3.6 GHz CPU and 32 GB of 1600 MHz DDR3 RAM (9-9-9-24), hosting Windows Server 2012 R2. All codes (https://bitbucket.org/kowallus/sa-search-dev/) were written in C++ and compiled with 64-bit gcc 4.9.3 with -O3. All presented times are averages over 500K patterns taken randomly from the text. The searches were performed over 200 MB datasets from the well-known Pizza & Chili corpus. In the first experiment we show how the count times are affected by two things: using lookup tables, including the introduced Huffman-based ones (on 15 or 23 bits) and choosing a proper interval's right boundary search (Fig. 1). The doubling trick reduces the times usually by 20 -- 30% for the standard and LUT2-boosted suffix array, yet the effect is smaller for short patterns, especially for DNA (where short patterns tend to have thousands of occurrences). This can be explained by the relatively small difference between log n and log occ in those cases. The Huffman-based LUTs are more efficient than their traditional counterparts (when about the same amount of memory is sacrificed). dna200 no-LUT 2B 3B Huff-15b Huff-23b no-LUT-dbl 2B-dbl 3B-dbl Huff-15b-dbl Huff-23b-dbl 10 20 30 m proteins200 40 50 english200 10 20 30 m xml200 40 50 ) s u ( n r e t t a p / e m i t h c r a e s ) s u ( n r e t t a p / e m i t h c r a e s 3.0 2.5 2.0 1.5 1.0 0.5 3.0 2.5 2.0 1.5 1.0 0.5 ) s u ( n r e t t a p / e m i t h c r a e s 4 3 2 1 ) s u ( n r e t t a p / e m i t h c r a e s 3.0 2.5 2.0 1.5 1.0 0.5 10 20 30 m 40 50 10 20 30 m 40 50 Fig. 1. Count times for the standard suffix array and the SA augmented with a lookup table on pairs or triples of bytes, and on 15 or 23 bits of Huffman codewords, using the standard and the doubling search for finding the right interval boundary. Fig. 2 shows the impact of the node size B in the B-tree layout on the count times, with varying pattern length. Even B = 1 results in a much faster search than with a standard SA (by a factor of 1.7 -- 2.0; cf. also Fig. 1) and growing B helps more, up to B = 32 (on all the datasets, B = 64 is slightly slower). Still, the speed gap between B = 1 and B = 32 rarely exceeds 10%. In Fig. 3 we show how augmenting the SA with various structures reducing the initial search interval affects the query times and the used space. The hash ta- ble (HT), based on the xxhash function (https://code.google.com/p/xxhash/), stores 8-grams from the text and was tried with two load factors (LF). LUT2 gives a significant boost in a tiny space, yet it is the hash table (LF=0.9) that excels here, speeding up the baseline variant by a factor of 1.5 -- 2. As our SAs with the B-tree layout can be augmented with prefixes of the suffixes visited in the first steps of the traversal of the tree (i.e., in the top 2.2 2.0 1.8 1.6 1.4 1.2 ) s u ( n r e t t a p / e m i t h c r a e s ) s u ( n r e t t a p / e m i t h c r a e s 1.40 1.38 1.36 1.34 1.32 1.30 1.28 1.26 1.24 english200 dna200 B=1 B=8 B=32 B=64 1.8 1.7 1.6 1.5 1.4 1.3 1.2 ) s u ( n r e t t a p / e m i t h c r a e s 10 20 30 m proteins200 40 50 10 20 40 50 30 m xml200 ) s u ( n r e t t a p / e m i t h c r a e s 1.65 1.60 1.55 1.50 1.45 1.40 10 20 30 m 40 50 10 20 30 m 40 50 Fig. 2. Count times for the SA with the B-tree layout, for selected node sizes B. english200, m = 12 xml200, m = 12 ) s u ( n r e t t a p / e m i t h c r a e s 2.5 2.0 1.5 1.0 0.5 ) s u ( n r e t t a p / e m i t h c r a e s 2.5 2.0 1.5 1.0 0.5 SA-dbl B=1 B=8 B=32 ) s u ( n r e t t a p / e m i t h c r a e s 2.5 2.0 1.5 1.0 0.5 5.0 5.5 6.0 6.5 5.0 5.5 6.0 6.5 index size / text size english200, m = 24 index size / text size xml200, m = 24 ) s u ( n r e t t a p / e m i t h c r a e s 2.5 2.0 1.5 1.0 0.5 5.0 5.5 6.0 index size / text size 6.5 5.0 5.5 6.0 index size / text size 6.5 Fig. 3. Augmenting the suffix array. The right interval boundary in the standard SA variant is found with the doubling technique (-dbl). The five points in each series correspond to: no extra data, LUT2, LUT3, HT with LF=0.9, HT with LF=0.5. english200, m = 24 xml200, m = 24 ) s u ( n r e t t a p / e m i t h c r a e s 1.2 1.1 1.0 0.9 0.8 5.0 B=2, 13 prefix levels B=2, 14 prefix levels B=24, 4 prefix levels B=24, 5 prefix levels 5.2 index size / text size 5.4 5.6 5.8 ) s u ( n r e t t a p / e m i t h c r a e s 1.55 1.50 1.45 1.40 1.35 1.30 1.25 1.20 5.0 5.2 index size / text size 5.4 5.6 5.8 Fig. 4. Index sizes and count times for the SA with the B-tree layout, when several top levels of the tree store the corresponding suffixes' prefixes of length {0, 4, 8, 12, 16}. 2.5 2.0 1.5 1.0 0.5 ) s u ( n r e t t a p / e m i t h c r a e s ) s u ( n r e t t a p / e m i t h c r a e s ) s u ( n r e t t a p / e m i t h c r a e s 2.5 2.0 1.5 1.0 0.5 2.5 2.0 1.5 1.0 0.5 dna200, m = 12 dna200, m = 24 2.5 2.0 1.5 1.0 0.5 ) s u ( n r e t t a p / e m i t h c r a e s 5.0 5.2 5.4 5.6 5.8 6.0 6.2 6.4 5.0 5.2 5.4 5.6 5.8 6.0 6.2 6.4 index size / text size english200, m = 12 SA-dbl & LUT/HT B-tree & LUT/HT B-tree & prefixes B-tree & HT & prefixes 5.0 5.2 5.4 5.6 5.8 6.0 6.2 6.4 index size / text size xml200, m = 12 5.0 5.2 5.4 5.6 5.8 6.0 6.2 6.4 index size / text size ) s u ( n r e t t a p / e m i t h c r a e s ) s u ( n r e t t a p / e m i t h c r a e s 2.5 2.0 1.5 1.0 0.5 2.5 2.0 1.5 1.0 0.5 index size / text size english200, m = 24 5.0 5.2 5.4 5.6 5.8 6.0 6.2 6.4 index size / text size xml200, m = 24 5.0 5.2 5.4 5.6 5.8 6.0 6.2 6.4 index size / text size Fig. 5. Index sizes and count times for several SA variants with different layouts and extra data. Successive points in the series are obtained by changing the LUT or hash table component and/or using the prefix copies on varying number of levels in the tree. levels), we test the impact of the prefix length on the performance and space of the resulting index (Fig. 4). Adding the prefixes gives a noticeable speedup even if they are limited in length to 8 characters and are attached to a few tree levels only, while the space overhead is rather small. Longer prefixes and more levels help less for a much bigger space penalty. Combinations of all ideas presented in the paper are shown in Fig. 5, where the best option is to combine the B-tree layout with LUT/HT (adding prefixes on top of it has a negligible effect). In total, the speed of the standard SA with the standard right interval boundary search was usually improved by a factor exceeding 3 (from 2.6 for xml200 to 3.9 for dna200, for m = 24). Acknowledgment The work was supported by the Polish National Science Centre under the project DEC-2013/09/B/ST6/03117 (the first two and the fourth author). References 1. P. Ferragina, R. Gonz´alez, G. Navarro, and R. Venturini. Compressed text indexes: From theory to practice. ACM Journal of Experimental Algorithmics, 13:article 12, 2009. 30 pages. 2. S. Grabowski and M. Raniszewski. Two simple full-text indexes based on the suffix array. In Proc. PSC, pages 179 -- 191, Czech Technical University in Prague, Czech Republic, 2014. 3. P. Khuong and P. Morin. Array layouts for comparison-based searching. CoRR, abs/1509.05053, 2015. 4. U. Manber and G. Myers. Suffix arrays: a new method for on-line string searches. In Proc. SODA, pages 319 -- 327. SIAM, 1990. 5. B. Schlegel, R. Gemulla, and W. Lehner. K-ary search on modern processors. In Proc. DaMoN, pages 52 -- 60. ACM, 2009. 6. D. E. Willard. Searching unindexed and nonuniformly generated files in log log N time. SIAM J. Comput., 14(4):1013 -- 1029, 1985.
1203.0259
1
1203
2012-03-01T18:21:14
A rearrangement step with potential uses in priority queues
[ "cs.DS" ]
Link-based data structures, such as linked lists and binary search trees, have many well-known rearrangement steps allowing for efficient implementations of insertion, deletion, and other operations. We describe a rearrangement primitive designed for link-based, heap-ordered priority queues in the comparison model, such as those similar to Fibonacci heaps or binomial heaps. In its most basic form, the primitive rearranges a collection of heap-ordered perfect binary trees. Doing so offers a data structure control on the number of trees involved in such a collection, in particular keeping this number logarithmic in the number of elements. The rearrangement step is free from an amortized complexity standpoint (using an appropriate potential function).
cs.DS
cs
A REARRANGEMENT STEP WITH POTENTIAL USES IN PRIORITY QUEUES BORIS ALEXEEV AND M. BRIAN JACOKES Abstract. Link-based data structures, such as linked lists and binary search trees, have many well-known rearrangement steps allowing for efficient implementations of insertion, deletion, and other operations. We describe a rearrangement primitive designed for link-based, heap-ordered priority queues in the comparison model, such as those similar to Fibonacci heaps or binomial heaps. In its most basic form, the primitive rearranges a collection of heap-ordered perfect binary trees. Doing so offers a data structure control on the number of trees involved in such a collection, in particular keeping this number logarithmic in the number of elements. The rearrangement step is free from an amortized complexity standpoint (using an appropriate potential function). 1. Introduction The priority queue, or heap, is perhaps the simplest data structure beyond stacks and FIFO queues. Originally designed as part of the sorting algorithm heapsort [Wil64], heaps are now used in a variety of algorithms, particularly graph-theoretic ones (such as Dijkstra's single-source shortest-paths algorithm). In its most basic form, a heap represents a collection P of elements from a totally-ordered set, together with the operations insert and delete-min; the latter returns the name of the least element after deleting it from P. More useful heap implementations will include the operations decrease-key, meld, delete, and make-queue, which we do not describe in detail here. The importance and utility of heaps stems from fast access to the current minimum element, unlike the fixed access patterns of stacks and queues. Simultaneously, the absence of operations like iteration through P in sorted order allows heaps to answer queries faster than full-fledged binary search trees. Many heap implementations have been developed, including the original binary heap [Wil64], binomial heap [Vui78], and Fibonacci heaps [FT87]. The basic atom of these implementations is the concept of a heap-ordered tree, which is a rooted tree such that each element is no greater than any of its children. In such a tree, clearly the smallest element is the root. Most implementations of heaps in the tradition of binomial heaps maintain a collection of heap-ordered trees represented explicitly, that is, with pointers. (An important exception is binary heaps which maintain a single heap-ordered tree represented implicitly in an array.) In order to perform updates and answer queries efficiently, there are a few primitive operations that rearrange elements in a manner preserving the heap-ordering. Two of the most important are bubble-up (also known as up-heap) and bubble-down (also known as down-heap), which address local inconsistencies in the heap-ordering at a leaf or root, respectively. There are also other primitives, such as the procedure for merging two binomial trees. We introduce a new rearrangement primitive that rearranges a collection of heap-ordered trees. In short, given three perfect heap-ordered binary trees, the rearrangement creates one larger perfect heap-ordered tree and two smaller ones. Date: November 12, 2018. Key words and phrases. Priority queue, heap, rearrangement, perfect binary tree. 1 2. Rearrangement step Recall that a binary tree is perfect (also called full ) if all leaves are at the same depth. Such a tree will necessarily contain a number of nodes one less than a power of two. A rearrangement step is a method of taking three perfect binary trees of the same size (say, of height h) and producing one perfect binary tree of height h + 1 and two perfect binary trees of height h − 1, in constant time. This can be accomplished by comparing the three roots, selecting the smallest one, removing it from its tree (leaving two subtrees), and making it the root of a new larger tree with the other two trees as children. See Figure 1 for visual accompaniment. Figure 1. A rearrangement step: three trees of height h are rearranged to make one tree of height h + 1 and two trees of height h − 1 by selecting the smallest root (shaded) and rearranging children. Suppose a heap is implemented by maintaining a collection of perfect, heap-ordered trees [SS85, BSG03]. Using the rearrangement step iteratively if necessary, the data structure may ensure that no more than two trees of any given height are present in the collection. Because the number of elements in each tree grows exponentially with the height, this ensures that no more than logarithmically-many trees are in the collection overall. Other operations, such as delete-min or meld, are thus easier to implement in logarithmic time. From the point of view of amortized complexity [Tar85], the rearrangement step pays for itself. More specifically, consider a potential function ϕ that is the sum of the heights of the trees in a collection of perfect binary trees. Evidently, this potential function goes down by one every rearrangement step. Therefore, the amortized time complexity tamortized = tactual + ϕ (normalized so that each rearrangement step takes one unit of tactual) does not change when a rearrangement step is performed. Since in any sequence of operations beginning with an empty queue, the initial value of ϕ (namely, zero) is at most the final value of ϕ, the amortized time tamortized is an upper bound on the actual time tactual. Of course, for this analysis to be useful, the other operations must play well with the potential function. In our case, straightforward implementations of the heap operations do not modify ϕ by much. Of course, the rearrangement step need not be limited in its application to perfect binary trees only. However, its implementation in that case is most straightforward so we limit our description to that situation. 2 3. Applications The rearrangement step described in this paper was also discovered by Claus Jensen, independently of these authors. Furthermore, Elmasry, Jensen, and Katajainen have used the step to implement a priority queue that guarantees O(1) worst-case cost per insert and O(log n) worst-case cost per delete, where n is the number of elements stored. [EJK10, EJK12] More specifically, those authors analyze a number system based on powers of two minus one (that is, the size of a perfect heap). A straightforward use of the rearrangement step would then allow each digit to be at most two; the skew binary number system has this property. However, in order to guarantee worst-case times rather than simply amortized times, the authors allow each digit to be at most four. Our writeup complements that of Elmasry, Jensen, and Katajainen by isolating the rearrangement primitive, which is used inline in their paper under the name fix. Thus this rearrangement step, in addition to being a theoretical addition to the basic link mechanisms used in the existing plethora of link-based priority queues, has already found applications. References [BSG03] S. Bansal, S. Sreekanth, and P. Gupta, M-heap: a modified heap data structure, Internat. J. Found. Comput. Sci. 14 (2003), no. 3, 491 -- 502. [EJK10] Amr Elmasry, Claus Jensen, and Jyrki Katajainen, The magic of a number system, Proceedings of the 5th international conference on Fun with algorithms (Berlin, Heidelberg), FUN'10, Springer-Verlag, 2010, pp. 156 -- 165. [EJK12] , Two skew-binary numeral systems and one application, Theory Comput. Syst. 50 (2012), 185 -- 211. [FT87] Michael L. Fredman and Robert Endre Tarjan, Fibonacci heaps and their uses in improved network optimization algorithms, J. Assoc. Comput. Mach. 34 (1987), no. 3, 596 -- 615. [SS85] Thomas Strothotte and Jorg-Rudiger Sack, Heaps in heaps, Proceedings of the sixteenth Southeastern international conference on combinatorics, graph theory and computing (Boca Raton, Fla., 1985), vol. 49, 1985, pp. 223 -- 235. [Tar85] Robert Endre Tarjan, Amortized computational complexity, SIAM J. Algebraic Discrete Methods 6 (1985), no. 2, 306 -- 318. [Vui78] Jean Vuillemin, A data structure for manipulating priority queues, Comm. ACM 21 (1978), no. 4, 309 -- 315. [Wil64] J. W. J. Williams, Algorithm 232: Heapsort, Comm. A.C.M. 7 (1964), no. 6, 347 -- 348. 3
1510.03019
3
1510
2016-03-22T10:11:21
A Shifting Bloom Filter Framework for Set Queries
[ "cs.DS" ]
Set queries are fundamental operations in computer systems and applications.This paper addresses the fundamental problem of designing a probabilistic data structure that can quickly process set queries using a small amount of memory. We propose a Shifting Bloom Filter (ShBF) framework for representing and querying sets. We demonstrate the effectiveness of ShBF using three types of popular set queries: membership, association, and multiplicity queries. The key novelty of ShBF is on encoding the auxiliary information of a set element in a location offset. In contrast, prior BF based set data structures allocate additional memory to store auxiliary information. To evaluate ShBF in comparison with prior art, we conducted experiments using real-world network traces. Results show that ShBF significantly advances the state-of-the-art on all three types of set queries.
cs.DS
cs
A Shifting Bloom Filter Framework for Set Queries Tong Yang Peking University, China [email protected] Yuankun Zhong Nanjing University, China [email protected] Alex X. Liu Michigan State University [email protected] Qiaobin Fu Boston University, USA [email protected] Muhammad Shahzad North Carolina State University [email protected] Zi Li Nanjing University, China [email protected] 6 1 0 2 r a M 2 2 ] S D . s c [ 3 v 9 1 0 3 0 . 0 1 5 1 : v i X r a Gaogang Xie ICT, CAS, China Xiaoming Li Peking University, China This paper will appear in VLDB 2016, see http://www.vldb.org/pvldb/vol9.html ABSTRACT Set queries are fundamental operations in computer systems and applications. This paper addresses the fundamental problem of designing a probabilistic data structure that can quickly process set queries using a small amount of memory. We propose a Shifting Bloom Filter (ShBF) framework for representing and querying sets. We demonstrate the effec- tiveness of ShBF using three types of popular set queries: membership, association, and multiplicity queries. The key novelty of ShBF is on encoding the auxiliary information of a set element in a location offset. In contrast, prior BF based set data structures allocate additional memory to store aux- iliary information. To evaluate ShBF in comparison with prior art, we conducted experiments using real-world net- work traces. Results show that ShBF significantly advances the state-of-the-art on all three types of set queries. 1. 1.1 Motivations INTRODUCTION Set queries, such as membership queries, association queries, and multiplicity queries, are fundamental operations in computer systems and applications. Membership queries check whether an element is a member of a given set. Net- work applications, such as IP lookup, packet classification, and regular expression matching, often involve membership queries. Association queries identify which set(s) among a pair of sets contain a given element. Network architectures such as distributed servers often use association queries. For example, when data is stored distributively on two servers and the popular content is replicated over both servers to achieve load balancing, for any incoming query, the gate- way needs to identify the server(s) that contain the data corresponding to that query. Multiplicity queries check how many times an element appears in a multi-set. A multi-set allows elements to appear more than once. Network mea- surement applications, such as measuring flow sizes, often use multiplicity queries. This paper addresses the fundamental problem of design- ing a probabilistic data structure that can quickly process set queries, such as the above-mentioned membership, as- sociation, and multiplicity queries, using a small amount of memory. Set query processing speed is critical for many sys- tems and applications, especially for networking applications as packets need to be processed at wire speed. Memory con- sumption is also critical because small memory consumption may allow the data structure to be stored in SRAM, which is an order of magnitude faster than DRAM. Widely used set data structures are the standard Bloom Filter (BF) [3] and the counting Bloom Filter (CBF) [11]. Let h1(.),··· , hk(.) be k independent hash functions with uniformly distributed outputs. Given a set S, BF con- structs an array B of m bits, where each bit is initial- ized to 0, and for each element e∈S, BF sets the k bits B[h1(e)%m],··· , B[hk(e)%m] to 1. To process a member- ship query of whether element e is in S, BF returns true if all corresponding k bits are 1 (i.e., returns ∧k i=1B[hi(e)%m]). BF has no false negatives (FNs), i.e., it never says that e /∈S when actually e ∈ S. However, BF has false positives (FPs), i.e., it may say that e ∈ S when actually e /∈ S with a certain probability. Note that BF does not support element dele- tion. CBF overcomes this shortcoming by replacing each bit in BF by a counter. Given a set of elements, CBF first constructs an array C of m counters, where each counter is initialized to 0. For each element e in S, for each 1 (cid:54) i (cid:54) k, CBF increments C[hi(e)%m] by 1. To process a member- ship query of whether element e is in set S, CBF returns true if all corresponding k counters are at least 1 (i.e., re- turns ∧k i=1(C[hi(e)%m] (cid:62) 1)). To delete an element e from S, for each 1 (cid:54) i (cid:54) k, CBF decrements C[hi(e)%m] by 1. 1.2 Proposed Approach In this paper, we propose a Shifting Bloom Filter (ShBF) framework for representing and querying sets. Let h1(.), ··· , hk(.) be k independent hash functions with uniformly dis- tributed outputs. In the construction phase, ShBF first con- structs an array B of m bits, where each bit is initialized to 0. We observe that in general a set data structure needs to store two types of information for each element e: (1) existence in- 1 formation, i.e., whether e is in a set, and (2) auxiliary infor- mation, i.e., some additional information such as e's counter (i.e., multiplicity) or which set that e is in. For each ele- ment e, we encode its existence information in k hash values h1(e)%m,··· , hk(e)%m, and its auxiliary information in an offset o(e). Instead of, or in addition to, setting the k bits at locations h1(e)%m,··· , hk(e)%m to 1, we set the bits at lo- cations (h1(e)+o(e))%m,··· , (hk(e)+o(e))%m to 1. For dif- ferent set queries, the offset has different values. In the query phase, to query an element e, we first calculate the following k locations: h1(e)%m,··· , hk(e)%m. Let c be the maximum value of all offsets. For each 1 (cid:54) i (cid:54) k, we first read the c bits B[hi(e)%m], B[(hi(e)+1)%m],··· , B[(hi(e)+c−1)%m] and then calculate the existence and auxiliary information about e by analyzing where 1s appear in these c bits. To minimize the number of memory accesses, we extend the number of bits in ShBF to m + c; thus, we need k(cid:100) c ber of memory accesses in the worst case, where w is the word size. Figure 1 illustrates our ShBF framework. w(cid:101) num- Figure 1: Shifting Bloom Filter framework. 2 +1(.)%(w − 1) + 1, where h k We demonstrate the effectiveness of ShBF using three types of popular set queries: membership, association, and multiplicity queries. 1.2.1 Membership Queries Such queries only deal with the existence information of each element, which is encoded in k random positions in array B. To leverage our ShBF framework, we treat k/2 positions as the existence information and the other k/2 positions as the auxiliary information, assuming k is an even number for simplicity. Specifically, the offset func- 2 +1(.) is another tion o(.) = h k hash function with uniformly distributed outputs and w is a function of machine word size w. In the construc- for each element e ∈ S, we set both the tion phase, k/2 bits B[h1(e)%m],··· , B[h k (e)%m] and the k/2 bits B[h1(e)%m + o(e)],··· , B[h k In the query phase, for an element e, if all these k bits are 1, then we output e ∈ S; otherwise, we output e /∈ S. In terms of false positive rate (FPR), our analysis shows that ShBF is very close to BF with k hash functions. In terms of perfor- mance, ShBF is about two times faster than BF because of two main reasons. First, ShBF reduces the computational cost by almost half because the number of hash functions that ShBF needs to compute is almost the half of what BF needs to compute. Second, ShBF reduces the number of memory accesses by half because although both ShBF and BF write k bits into the array B, when querying element e, by one memory access, ShBF obtains two bits about e whereas BF obtains only one bit about e. 1.2.2 Association Queries For this type of queries with two sets S1 and S2, for ele- ments in S1 ∪ S2, there are three cases: (1) e ∈ S1 − S2, (2) e ∈ S1 ∩ S2, and (3) e ∈ S2 − S1. For the first (e)%m + o(e)] to 1. 2 2 case, i.e., e ∈ S1 − S2, the offset function o(e) = 0. For i.e., e ∈ S1 ∩ S2, the offset function the second case, o(e) = o1(e) = hk+1(e)%((w − 1)/2) + 1, where hk+1(.) is another hash function with uniformly distributed outputs and w is a function of machine word size w. For the third case, i.e., e ∈ S2 − S1, the offset function o(e) = o2(e) = o1(e) + hk+2(e)%((w − 1)/2) + 1, where hk+2(.) is yet an- other hash function with uniformly distributed outputs. In the construction phase, for each element e ∈ S1 ∪ S2, we set the k bits B[h1(e)%m + o(e)],··· , B[hk(e)%m + o(e)] to 1 using an appropriate value of o(e) as just described for the three cases. In the query phase, given an ele- ment e ∈ S1 ∪ S2 , for each 1 (cid:54) i (cid:54) k, we read the 3 bits B[hi(e)%m], B[hi(e)%m + o1(e)], and B[hi(e)%m + If all the k bits B[h1(e)%m],··· , B[hk(e)%m] are o2(e)]. 1, then e may belong to S1 − S2. If all the k bits B[h1(e)%m + o1(e)],··· , B[hk(e)%m + o1(e)] are 1, then e may belong to S1 ∩ S2. If all the k bits B[h1(e)%m + o2(e)],··· , B[hk(e)%m + o2(e)] are 1, then e may belong to S2 − S1. There are a few other possibilities that we will dis- cuss later in Section 4, that ShBF takes into account when answering the association queries. In comparison, the stan- dard BF based association query scheme, namely iBF, con- structs a BF for each set. In terms of accuracy, iBF is prone to false positives whenever it declares an element e ∈ S1∪S2 in a query to be in S1 ∩ S2, whereas ShBF achieves an FPR of zero. In terms of performance, ShBF is almost twice as fast as iBF because iBF needs 2k hash functions and 2k memory accesses per query, whereas ShBF needs only k + 2 hash functions and k memory accesses per query. 1.2.3 Multiplicity Queries For multiplicity queries, for each element e in a multi- set S, the offset function o(.) = c(e) − 1 where c(e) is e's counter (i.e., the number of occurrences of e in S). In the construction phase, for each element e, we set the k bits B[h1(e)%m+c(e)−1],··· , B[hk(e)%m+c(e)−1] to 1. In the query phase, for an element e, for each 1 (cid:54) i (cid:54) k, we read the c bits B[hi(e)%m], B[hi(e)%m+1],··· , B[hi(e)%m+c− 1], where c is the maximum number of occurrences that an element can appear in S. For these ck bits, for each 1 (cid:54) j (cid:54) c, if all the k bits B[h1(e)%m+j−1],··· , B[hk(e)%m+j−1] are 1, then we output j as one possible value of c(e). Due to false positives, we may output multiple possible values. 1.3 Novelty and Advantages over Prior Art The key novelty of ShBF is on encoding the auxiliary in- formation of a set element in its location by the use of off- sets. In contrast, prior BF based set data structures allocate additional memory to store such auxiliary information. To evaluate our ShBF framework in comparison with prior art, we conducted experiments using real-world net- work traces. Our results show that ShBF significantly ad- vances the state-of-the-art on all three types of set queries: membership, association, and multiplicity. For membership queries, in comparison with the standard BF, ShBF has about the same FPR but is about 2 times faster; in compari- son with 1MemBF [17], which represents the state-of-the-art in membership query BFs, ShBF has 10% ∼ 19% lower FPR and 1.27 ∼ 1.44 times faster query speed. For association queries, in comparison with iBF, ShBF has 1.47 times higher probability of a clear answer, and has 1.4 times faster query speed. For multiplicity queries, in comparison with Spectral BF [8], which represents the state-of-the-art in multiplicity 2 1 1 1 query BFs, ShBF has 1.45 ∼ 1.62 times higher correctness rate and the query speeds are comparable. CM sketch and how our ShBF framework can be applied to CM sketch in Section 5.5. 2. RELATED WORK We now review related work on the three types of set queries: membership, association, and multiplicity queries, which are mostly based on Bloom Filters. Elaborate surveys of the work on Bloom Filters can be found in [5, 14, 18, 19]. 2.1 Membership Queries Prior work on membership queries focuses on optimizing BF in terms of the number of hash operations and the num- ber of memory accesses. Fan et al. proposed the Cuckoo filter and found that it is more efficient in terms of space and time compared to BF [10]. This improvement comes at the cost of non-negligible probability of failing when insert- ing an element. To reduce the number of hash computation, Kirsch et al. proposed to use two hash functions h1(.) and h2(.) to simulate k hash functions (h1(.) + i ∗ h2(.))%m, where (1 (cid:54) i (cid:54) k); but the cost is increased FPR [13]. To re- duce the number of memory accesses, Qiao et al. proposed to confine the output of the k hash functions within cer- tain number of machine words, which reduces the number of memory accesses during membership queries; but the cost again is increased FPR [17]. In contrast, ShBF reduces the number of hash operations and memory access by about half while keeping FPR about the same as BF. 2.2 Association Queries Prior work on association queries focuses on identifying the set, among a group of pair-wise disjoint sets, to which an element belongs. A straightforward solution is iBF, which builds one BF for each set. To query an element, iBF gen- erates a membership query for each set's BF and finds out which set(s) the unknown element is in. This solution is used in the Summary-Cache Enhanced ICP protocol [11]. Other notable solutions include kBF [20], Bloomtree [21], Bloomier [6], Coded BF [16], Combinatorial BF [12], SVBF [15]. A common shortcoming of all existing schemes is that if any pair of sets in the group of sets is not disjoint, these schemes do not function correctly. In contrast, ShBF does not require the sets to be disjoint. 2.3 Multiplicity Queries BF cannot process multiplicity queries because it only tells whether an element is in a set. Spectral BF, which was proposed by Cohen and Matias, represents the state-of-the- art scheme for multiplicity queries [8]. There are three ver- sions of Spectral BF. The first version proposes some mod- ifications to CBF to record the multiplicities of elements. The second version increases only the counter with the min- imum value when inserting an element. This version reduces FPR at the cost of not supporting updates. The third ver- sion minimizes space for counters with a secondary spectral BF and auxiliary tables, which makes querying and updat- ing procedures time consuming and more complex. Aguilar- Saborit et al. proposed Dynamic Count Filters (DCF), which combines the ideas of spectral BF and CBF, for multiplicity queries [2]. DCF uses two filters: the first filter uses fixed size counters and the second filter dynamically adjusts counter sizes. The use of two filters degrades query performance. Another well-known scheme for multiplicity queries is the Count-Min (CM) Sketch [9]. We will describe the details of 3 3. MEMBERSHIP QUERIES In this section, we first present the construction and query phases of ShBF for membership queries. Membership queries are the "traditional" use of a BF. We use ShBFM to denote the ShBF scheme for membership queries. Second, we de- scribe the updating method of ShBFM. Third, we derive the FPR formula of ShBFM. Fourth, we compare the per- formance of ShBFM with that of BF. Last, we present a generalization of ShBFM. Table 1 summarizes the symbols and abbreviations used in this paper. Table 1: Symbols & abbreviations used in the paper Symbol Description m n k kopt S e u hi(s) FP FPR f p(cid:48) BF iBF ShBF ShBFM ShBFA ShBF× Qps multi-set o(.) w w c size of a Bloom Filter # of elements of a Bloom Filter # of hash functions of a Bloom Filter the optimal value of k a set one element of a set one element of a set the i-th hash function false positive false positive rate the FP rate of a Bloom Filter the probability that one bit is still 0 after inserting all elements into BF standard Bloom Filter individual BF: the solution that builds one individual BF per set Shifting Bloom Filters Shifting Bloom Filters for membership qrs. Shifting Bloom Filters for association qrs. Shifting Bloom Filters for multiplicities qrs. queries per second a generalization of the notion of a set in which members can appear more than once offset(.), referring to the offset value for a given input # of bits in a machine word the maximum value of offset(.) for membership query of a single set the maximum number of times an element can occur in a multi-set 2 +1(.) be k 3.1 ShBFM – Construction Phase The construction phase of ShBFM proceeds in three steps. Let h1(.), h2(.),··· , h k 2 + 1 independent hash functions with uniformly distributed outputs. First, we construct an array B of m bits, where each bit is initialized to 0. Second, to store the existence informa- tion of an element e of set S, we calculate k 2 hash val- ues h1(e)%m,h2(e)%m,··· ,h k (e)%m. To leverage our ShBF framework, we also calculate the offset values for the element e of set S as the auxiliary information for each element, 2 +1(e) % (w − 1) + 1. We will later discuss namely o(e) = h k how to choose an appropriate value for w. Third, we set the 2 bits B[h1(e)%m], ··· , B[h k (e)%m] to 1 and the other k k 2 bits B[h1(e)%m + o(e)],··· , B[h k (e)%m + o(e)] to 1. Note 2 2 2 that o(e) (cid:54)= 0 because if o(e) = 0, the two bits B[hi(e)%m] and B[hi(e)%m+o(e)] are the same bits for any value of i in the range 1 (cid:54) i (cid:54) k 2 . For the construction phase, the maxi- mum number of hash operations is k 2 +1. Figure 2 illustrates the construction phase of ShBFM. Figure 2: Illustration of ShBFM construction phase. We now discuss how to choose a proper value for w so that for any 1 (cid:54) i (cid:54) k 2 , we can access both bits B[hi(e)%m] and B[hi(e)%m + o(e)] in one memory access. Note that modern architecture like x86 platform CPU can access data starting at any byte, i.e., can access data aligned on any boundary, not just on word boundaries. Let B[hi(e)%m] be the j-th bits of a byte where 1 (cid:54) j (cid:54) 8. To access bit B[hi(e)%m], we always need to read the j − 1 bits before it. To access both bits B[hi(e)%m] and B[hi(e)%m+o(e)] in one memory access, we need to access j−1+w bits in one memory access. Thus, j − 1 + w (cid:54) w, which means w (cid:54) w + 1 − j. When j = 8, w + 1 − j has the minimum value of w − 7. Thus, we choose w (cid:54) w−7 as it guarantees that we can read both bits B[hi(e)%m] and B[hi(e)%m + o(e)] in one memory access. 3.2 ShBFM – Query Phase Given a query e, we first read the two bits B[h1(e)%m] and B[h1(e)%m+o(e)] in one memory access. If both bits are 1, then we continue to read the next two bits B[h2(e)%m] and B[h2(e)%m + o(e)] in one memory access; otherwise we output that e /∈ S and the query process terminates. If for all 1 (cid:54) i (cid:54) k 2 , B[hi(e)%m] and B[hi(e)%m + o(e)] are 1, then we output e ∈ S. For the query phase, the maximum number of memory accesses is k 2 . 3.3 ShBFM – Updating Just like BF handles updates by replacing each bit by a counter, we can extend ShBFM to handle updates by replacing each bit by a counter. We use CShBFM to de- note this counting version of ShBFM. Let C denote the ar- ray of m counters. To insert an element e, instead of set- ting k bits to 1, we increment each of the corresponding k counters by 1; that is, we increment both C[hi(e)%m] and C[hi(e)%m + o(e)] by 1 for all 1 (cid:54) i (cid:54) k 2 . To delete an element e ∈ S, we decrement both C[hi(e)%m] and C[hi(e)%m + o(e)] by 1 for all 1 (cid:54) i (cid:54) k 2 . In most appli- cations, 4 bits for a counter are enough. Therefore, we can further reduce the number of memory accesses for updating CShBFM. Similar to the analysis above, if we choose w (cid:54) z (cid:99) where z is the number of bits for each counter, we can (cid:98) w−7 guarantee to access both C[hi(e)%m] and C[hi(e)%m+o(e)] in one memory access. Consequently, one update of CShBFM needs only k/2 memory accesses. Due to the replacement of bits by counters, array C in CShBFM uses much more memory than array B in ShBFM. To have the benefits of both fast query processing and small memory consumption, we can maintain both ShBFM and CShBFM, but store array B in fast SRAM and array C in 4 DRAM. Note that SRAM is at least an order of magnitude faster than DRAM. Array B in fast SRAM is for processing queries and array C in slow DRAM is only for updating. After each update, we synchronize array C with array B. The synchronization is quite straightforward: when we insert an element, we insert it to both array C and B; when we delete an element, we first delete it from C, if there is at least one of the k counters becomes 0, we clear the corresponding bit in B to 0. 3.4 ShBFM – Analysis We now calculate the FPR of ShBFM, denoted as fShBFM . Then, we calculate the minimum value of w so that ShBFM can achieve almost the same FPR as BF. Last, we calculate the optimum value of k that minimizes fShBFM . 3.4.1 False Positive Rate We calculate the false positive rate of ShBFM in the fol- lowing theorem. Theorem 1. The FPR of ShBFM for a set of n elements (cid:18) is calculated as follows: fShBFM ≈ (1 − p) k 2 where p = e −nk m . (cid:19) k 2 1 − p + 1 w − 1 p2 (1) Proof. Let p(cid:48) represent the probability that one bit (sup- pose it is at position i) in the filter B is still 0 after in- serting information of all n elements. For an arbitrary ele- ment e, if hi(e)%m does not point to i or i − o(e), where (e)%(w− 1) + 1, then the bit at position i will still o(e) = h k be 0, thus p(cid:48) is given by the following equation. 2 (cid:18) m − 2 (cid:19) kn (cid:18) 2 = 1 − 2 m m (cid:48) p = 2 (cid:19) kn (cid:18) ∞(cid:80)  kn m x (cid:19)−x (2) = e, 1 − 1 x − nk ≈ e m (3) When m is large, we can use the identity to get the following equation for p(cid:48). (cid:18) (cid:48) p = 1 − 2 m (cid:19) kn 2 = (cid:18) (cid:19) m 2 1 − 2 m 2 Let X and Y be the random variables for the event that 2 +1(.) the bit at position hi(.) and the bit at position hi(.)+h k is 1, respectively. Thus, P {X} = 1− p(cid:48). Suppose we look at + 1(cid:105), we want to calculate P {XY }. As a hash pair (cid:104)hi, h k P {XY } = P {X} × P {Y X}, next we calculate P {Y X}. There are w − 1 bits on the left side of position hi. The 1s in these w − 1 bits could be due to the first hash function in a pair and/or due to the second hash function in the pair . In other words, event X happens because a hash pair (cid:104)hj, h k phase. When event X happens, there are two cases: 2 +1(cid:105) sets the position hi to 1 during the construction 1. The event X1 happens, i.e., the position hi is set to 2 +1, i.e., the left w − 1 bits cause hi to be 1 by h k 1, making X and Y independent. Thus, in this case P {Y } = 1 − p(cid:48). 1 1 1 1 1 1 2. The event X2 happens, i.e., the position hi is set to 1 by hj. In this case, As P {X1} + P {X2} =1, thus, P {Y X} = P {Y X, X1} × P {X1} + P {Y X, X2} × P {X2}. 1 Next, we compute P {X1} and P {X2}. (cid:1) = w−1. Probability that are w−1 combinations, i.e.,(cid:0)w−1 P {X1} =(cid:0)w−1 (cid:1) × (1 − p(cid:48)) × 1 As there are w−1 bits on the left side of position hi, there any bit of the w − 1 bits is 1 is 1 − p(cid:48). When one bit in the w−1 bits is 1, probability that this bit sets the bit at location 1 w−1 . Therefore, hi using the hash function h k w−1 = 1 − p(cid:48). Consequently, 2 P {X2} = 1 − P {X1} = p(cid:48). Again there are two cases: X and Y are independent, and thus P {Y } =(cid:0)w−1 1. If the bit which hi(x) points to is set to 1 by the left 1s, (cid:1) × + 1 to 1 is 1 1 (1 − p(cid:48)) × 1 w−1 = 1 − p(cid:48). 2. If the bit which hi(x) points to is not set to 1 by the left 1s, then it must set one bit of the latter w − 1 bits to be 1. This case will cause one bit of the latter w − 1 bits after position hi to be 1. In this case, there are following two situations for the second hashing hi + h k 2 +1: (a) when the second hash points to this bit, the prob- ability is w−1 × 1; 1 (1 − p(cid:48))(w − 2) (b) otherwise, the probability is (1 − 1 w−1 ) × (1 − p(cid:48)). When the second case above happens, P {Y X, X2} is given (cid:18) by the following equation. 1 − w − 2 P {Y X, X2} = w − 1 )(cid:1)(cid:18) 1 − w − 2 w − 1 (4) Integrating the two cases, we can compute P {Y X} as fol- lows. P {Y X} = (1 − p ) +(cid:0)1 − (1 − p )(1 − p (cid:48)(cid:19) w − 1 w − 1 (cid:48)(cid:19) + = p p 1 (cid:48) (cid:48) (cid:48) (5) The probability that all the first hashes point to bits that are 1 is (1 − p(cid:48)) k 2 . The probability that the second hash points to a bit that is 1 is the k 2 -th power of Equation (5). Thus, the overall FPR of ShBFM is given by the following equation. fShBFM =(1 − p (cid:48)(cid:19)(cid:19) k )(1 − p (1 − p ) + p p k 2 ) (cid:48) (cid:48) (cid:48) 2 (cid:48)(cid:18) 1 − w − 2 (cid:19) k w − 1 2 (cid:18) (cid:18) =(1 − p (cid:48) ) k 2 1 − p (cid:48) + 1 w − 1 (cid:48)2 p (6) Note that when w → ∞, this formula becomes the formula of the FPR of BF. Let we represent e 3, p(cid:48) ≈ p. Consequently, we get: m by p. Thus, according to equation − nk (cid:18) (cid:19) k 2 fShBFM ≈ (1 − p) k 2 1 − p + 1 w − 1 p2 Note that the above calculation of FPRs is based on the original Bloom's FPR formula [3]. In 2008, Bose et al. pointed out that Bloom's formula [3] is slightly flawed and 5 gave a new FPR formula [4]. Specifically, Bose et al. ex- plained that the second independence assumption needed to derive fBloom is too strong and does not hold in general, resulting in an underestimation of the FPR. In 2010, Chris- tensen et al. further pointed out that Bose's formula is also slightly flawed and gave another FPR formula [7]. Although Christensen's formula is final, it cannot be used to compute the optimal value of k, which makes the FPR formula prac- tically not much useful. Although Bloom's formula underes- timates the FPR, both studies pointed out that the error of Bloom's formula is negligible. Therefore, our calculation of FPRs is still based on Bloom's formula. 3.4.2 Optimizing System Parameters Minimum Value of w: Recall that we proposed to use w (cid:54) w − 7. According to this inequation, w (cid:54) 25 for 32-bit architectures and w (cid:54) 57 for 64-bit architectures. Next, we investigate the minimum value of w for ShBFM to achieve the same FPR with BF. We plot fShBFM of ShBFM as a function of w in Figures 3(a) and 3(b). Figure 3(a) plots fShBFM vs. w for n = 10000, m = 100000, and k =4, 8, and 12 and Figure 3(b) plots fShBFM vs. w for n = 10000, k = 10, and m = 100000, 110000, and 120000. The horizontal solid lines in these two figures plot the FPR of BF. From these two figures, we observe that when w > 20, the FPR of ShBFM becomes almost equal to the FPR of BF. Therefore, to achieve similar FPR as of BF, w needs to be larger than 20. Thus, by using w = 25 for 32−bit and w = 57 for 64−bit architecture, ShBFM will achieve almost the same FPR as BF. (a) m = 100000, n = 10000 (b) k = 10, n = 10000 Figure 3: FPR vs. w. Optimum Value of k: Now we calculate the value of k that minimizes the FPR calculated in Equation (1). The standard method to obtain the optimal value of k is to dif- ferentiate Equation (1) with respect to k, equate it to 0, i.e., ∂ ∂k fShBFM = 0, and solve this equation for k. Unfor- tunately, this method does not yield a closed form solution for k. Thus, we use standard numerical methods to solve the equation ∂ ∂k fShBFM = 0 to get the optimal value of k for given values of m, n, and w. For w = 57, differentiating Equation (1) with respect to k and solving for k results in the following optimum value of k. kopt = 0.7009 m n Substituting the value of kopt from the equation above into Equation (1), the minimum value of fShBFM is given by the following equation. f min ShBFM = 0.6204 m n (7) 3.5 Comparison of ShBFM FPR with BF FPR Our theoretical comparison of ShBFM and BF shows that the FPR of ShBFM is almost the same as that of BF. Fig- ure 4 plots FPRs of ShBFM and BF using Equations (1) and (8), respectively for m = 100000 and n = 4000, 6000, 8000, 10000, 12000. The dashed lines in the figure correspond to ShBFM whereas the solid lines correspond to BF. We ob- serve from this figure that the sacrificed FPR of ShBFM in comparison with the FPR of BF is negligible, while the num- ber of memory accesses and hash computations of ShBFM are half in comparison with BF. Figure 4: ShBFM FPR vs. BF FPR. Next, we formally arrive at this result. We calculate the minimum FPR of BF as we calculated for ShBFM in Equa- tion (7) and show that the two FPRs are practically equal. For a membership query of an element u that does not be- long to set S, just like ShBFM, BF can also report true with a small probability, which is the FPR of BF and has been well studied in literature [3]. It is given by the following equation. (cid:32) (cid:18) fBF = 1 − 1 − 1 m (cid:19)nk(cid:33)k ≈(cid:16) (cid:17)k 1 − e − nk m (8) For given values of m and n, the value of k that minimizes fBF is = m n . Substituting this value of k into Equation (8), the minimum value of fBF is given by the following equation. n ln 2 = 0.6931 m (cid:19)( m n ln 2) ≈ 0.6185 (cid:18) 1 2 f min BF = m n (9) By comparing Equations (7) and (9), we observe that the FPRs of ShBFM and BF are almost the same. Thus, ShBFM achieves almost the same FPR as BF while reducing the number of hash computations and memory accesses by half. 3.6 Generalization of ShBFM As mentioned earlier, ShBFM reduces k independent hash functions to k/2 + 1 independent hash functions. Conse- quently, it calculates k/2 locations independently and re- maining k/2 locations are correlated through the equation hi(e)+o1(e) (1 (cid:54) i (cid:54) k/2). Carrying this construction strat- egy one step further, one could replace the first k/2 hash functions with k/4 independent hash functions and an off- set o2(e), i.e., hj(e) + o2(e) (1 (cid:54) j (cid:54) k/4). Continuing in this manner, one could eventually arrive at log(k) + 1 hash functions. Unfortunately, it is not trivial to calculate the FPR for this case because log(k) is seldom an integer. In this subsection, we simplify this log method into a linear method by first using a group of functions to calculate k shifting operation t times on these hash locations. t+1 (1 (cid:54) t (cid:54) k − 1) hash t+1 hash locations and then applying k Consider a group of hash function comprising of t + 1 elements, i.e., (cid:104)h1(x), h2(x), . . . , ht+1(x)(cid:105). After complet- ing the construction phase using this group of hash func- w − 2 w − 1 nk t + 1 tions, the probability that any given bit is 0 is w − 1 m = 1− t + 1 m w − t − 1 w − t . . . . To insert n elements, we need such group insertion operations. After com- pleting the insertion, the probability p(cid:48) that one bit is still 0 is given by the following equation. m − w m + (cid:18) (cid:48) p = 1 − t + 1 m (cid:19) kn t + 1 ≈ e − kn m (10) Note that this probability formula is essentially k times product of e− n m . Thus, we can treat our ShBFM as a par- titioned Bloom filter, where the output of each hash func- bits. Setting tion covers a distinct set of consecutive w = m makes this scheme partitioned Bloom filter. The equations below calculate the FPR f for this scheme. t w − 1 where fgroup = 1 t t + 1 × (fgroup) k (cid:48)(cid:1) k f =(cid:0)1 − p ×(cid:0)1 − p (cid:48)(cid:1)2 × (cid:18) 1 − w − 1 − t w − 1 (cid:48) × (1 − p(cid:48))t − (1 − p(cid:48)) − × p + p (11) × p(cid:48)(cid:19)t (cid:19) × p(cid:48) t + 1 (cid:18) 1 − w − 1 − t (cid:18) w − 1 1 − w − 1 − t (cid:48)(cid:19)t w − 1 (cid:19) k (cid:18) k 2 * (12) Due to space limitations, we have moved the derivation of this equation to our extended version at arxiv.org. When t = 1, its false positive rate can be simplified as 1 × p(cid:48)2 1 − p(cid:48) + f = (1 − p(cid:48)) 2 . Similarly, when w goes to infinity, FPR simplifies to f = (1 − p(cid:48))k, which is the formula for FPR of a standard Bloom filter. 3.7 False Positive Derivation w − 1 In our submission, we did not present this subsec- tion due to space limitation. This is the false positive derivation details for interested reviewers. To query a non-existent object, the false positive occurs when the hash function group returns all 1s, assuming the hash function group is (cid:104)hi(x), o1(x), . . . , ot(x)(cid:105) (1 (cid:54) i (cid:54) k t+1 ). 1) If the corresponding bit of hi(x) is not set by the left w − 1 bits, then hi(x) must cause t bits, in the following w − 1 bits, to be set to 1. There are t + 1 situations in to- tal. Note that the r−th (r ∈ [0, t]) situation represents that the corresponding bits of r hash functions out of t are set by hi(x), and another t − r bits are not set by hi(x). Con- sidering the corresponding bits of the hash function subset < o1(x), . . . , ot(x) >, the probability that each of these bits is set by hi(x) is λ1 = t w − 1 (13) 6 n(cid:61)4000n(cid:61)6000n(cid:61)8000n(cid:61)10000n(cid:61)12000051015200.000.020.040.060.080.10kFPrate and the probability that each of these bits is not set by hi(x) is (cid:18) 1 − t (cid:19) ×(cid:0)1 − p (cid:48)(cid:1) λ2 = (14) Therefore, the probability that the r−th situation occurs t × λr . The total probability that the t + 1 situ- 1 × λt−r w − 1 is C r 2 ations occur is t × λr 1 × λt−r r=0C r fI = Σt 2 = (λ1 + λ2)t (15) 2) If the corresponding bit of hi(x) is set by the left w − 1 bits, then the problem can be divided into t situations, where . Note that the l(cid:48)−th each situation has a probability of (l(cid:48) ∈ [0, t − 1]) situation represents that the maximum num- ber of bits in the current subgroup (cid:104)o1(x), . . . , ot(x)(cid:105), which are set to 1 by the previous hash function group causing the corresponding bit of hi(x) to be set to 1. Since our hash function group adopts partitioned Bloom filter, each hash function in the previous hash function group can cause at most 1 bit to be set 1 in current hash function group. When the corresponding bit of hi(x) in the previous hash func- 1 t t bits, then the previous tion group locates at the first hash function group will cause 0 bit to be set 1 in current subgroup (cid:104)o1(x), . . . , ot(x)(cid:105), because there is only one pos- sibility that the last hash function in the previous group causes the bit of current hi(x) to be set to 1. This is the 0−th situation. Similarly, for the l(cid:48)−th situation, if the cor- responding bit of hi(x) in the previous hash function group , w − 1 + (l(cid:48) + 1) × w − 1 locates at , there are at most l(cid:48) bits in the current hash function group set by the previous group, and at least t − l(cid:48) bits in the current hash function group not set by the previous group. Therefore, for the l(cid:48)−th situation, the probability that all the bits in the current hash function group are 1 is (cid:20) w − 1 + l(cid:48) × w − 1 (cid:19) t t w − 1 (16) (cid:48)(cid:1)t−l(cid:48)(cid:17) The total probability that all the t situations happen is fII =Σt−1 l(cid:48)=0fl(cid:48) = Σt−1 l(cid:48)=0 fl(cid:48) = = 1 t 1 t = 1 t + (cid:48)(cid:1)t−l(cid:48) 2 1 t l(cid:48) × λr(cid:48) r(cid:48)=0C r(cid:48) Σl(cid:48) (cid:17) ×(cid:0)1 − p ×(cid:16) 1 × λl(cid:48)−r(cid:48) (cid:48)(cid:1)t−l(cid:48) (λ1 + λ2)l(cid:48) ×(cid:0)1 − p ×(cid:16) (λ1 + λ2)l(cid:48) ×(cid:0)1 − p × ((λ1 + λ2)0 ×(cid:0)1 − p (cid:48)(cid:1)t−0 + . . . (cid:48)(cid:1)t−(t−1)) × (λ1 + λ2)t−1 ×(cid:0)1 − p (cid:16) (λ1 + λ2)l(cid:48) × (1 − p(cid:48))t−l(cid:48)(cid:17) (cid:48)(cid:1)t + (λ1 + λ2)t (cid:48)(cid:1) ×(cid:0)1 − p 1 − p(cid:48) = x −(cid:0)1 − p (1 − p(cid:48))t − (λ1 + λ2)t (1 − p(cid:48)) − (λ1 + λ2) x = 1 t x × λ1 + λ2 By solving equation 18, we obtain the solution Assuming x = Σt l(cid:48)=0 the following equation (17) , we get (18) (19) 7 (cid:18) 1 (cid:19) × p k Probability that 1) happens is C 1 × (1 − p(cid:48)) = (1 − p(cid:48)), so the probability that 2) happens is (1 − (1 − p(cid:48))) = p(cid:48). w−1 × w − 1 Combining 1) and 2), we know that when hi(x) is 1, the probability that all the bits of the current group (cid:104)o1(x), . . . , ot(x)(cid:105) are 1 is fgroup = 1 t (1 − p(cid:48))t − (1 − p(cid:48)) − ×(cid:0)1 − p (cid:18) (cid:48)(cid:1)2 × 1 − w − 1 − t w − 1 (cid:48) × + p (cid:18) 1 − w − 1 − t (cid:18) w − 1 1 − w − 1 − t (cid:48)(cid:19)t w − 1 × p(cid:48)(cid:19)t (cid:19) × p(cid:48) (20) k t + 1 Probability that the corresponding bits of the first hash functions are 1 is (1 − p(cid:48)) positive of the generalized ShBFM is t + 1 . Therefore, the false f =(cid:0)1 − p (cid:48)(cid:1) k t + 1 × (fgroup) k t + 1 (21) Especially, when t = 1, its false positive can be simplified as f = (1 − p(cid:48)) k 2 * (cid:18) (cid:19) k 1 × p(cid:48)2 w − 1 1 − p(cid:48) + 2 . Similarly, when w goes to infin- ity, its false positive is f = (1 − p(cid:48))k, which is the formula for standard Bloom filter. 4. ASSOCIATION QUERIES In this section, we first describe the construction and query phases of ShBF for association queries, which are also called membership test. We use ShBFA to denote the ShBF scheme for association queries. Second, we describe the up- dating methods of ShBFA. Third, we derive the FPR of ShBFA. Last, we analytically compare the performance of ShBFA with that of iBF. 4.1 ShBFA – Construction Phase The construction phase of ShBFA proceeds in three steps. Let h1(.),··· , hk(.) be k independent hash functions with uniformly distributed outputs. Let S1 and S2 be the two given sets. First, ShBFA constructs a hash table T1 for set S1 and a hash table T2 for set S2. Second, it constructs an array B of m bits, where each bit is initialized to 0. Third, for each element e ∈ S1, to store its existence information, ShBFA calculates k hash functions h1(e)%m,··· , hk(e)%m and searches e in T2. If it does not find e in T2, to store its auxiliary information, it sets the offset o(e) = 0. How- ever, if it does find e in T2, to store its auxiliary infor- mation, it calculates the offset o(e) as o(e) = o1(e) = hk+1(e)%((w − 1)/2) + 1, where hk+1(.) is a hash function with uniformly distributed output and w is a function of ma- chine word size w, which we will discuss shortly. Fourth, it sets the k bits B[h1(e)%m + o(e)],··· , B[hk(e)%m + o(e)] to 1. Fifth, for each element e ∈ S2, to store its existence infor- mation, ShBFA calculates the k hash functions and searches it in T1. If it finds e in T1, it does not do anything because its existence as its auxiliary information have already been stored in the array B. However, if it does not find e in T1, to store its auxiliary information, it calculates the offset o(e) as o(e) = o2(e) = o1(e)+hk+2(e)%((w−1)/2)+1, where hk+2(.) is also a hash function with uniformly distributed output. Last, it sets the k bits B[h1(e)%m+o(e)],··· , B[hk(e)%m+ o(e)] to 1. To ensure that ShBFA can read B[hi(e)%m], B[hi(e)%m + o1(e)], and B[hi(e)%m + o2(e)] in a single memory access when querying, we let w (cid:54) w−7. We derived this condition w (cid:54) w − 7 earlier at the end of Section 3.1. As the maximum value of hi(e)%m + o2(e) can be equal to m + w − 2, we append the m-bit array B with w − 2 bits. 4.2 ShBFA – Query Phase We assume that the incoming elements always belong to S1 ∪ S2 in the load balance application1 for convenience. To query an element e ∈ S1 ∪ S2, ShBFA finds out which sets the element e belongs to in the following three steps. First, it computes o1(e), o2(e), and the k hash functions hi(e)%m (1 (cid:54) i (cid:54) k). Second, for each 1 (cid:54) i (cid:54) k, it reads the 3 bits B[hi(e)%m], B[hi(e)%m + o1(e)], and B[hi(e)%m + o2(e)]. Third, for these 3k bits, if all the k bits B[h1(e)%m],··· , B[hk(e)%m] are 1, e may belong to S1 − S2. In this case, ShBFA records (but does not yet de- clare) e ∈ S1 − S2. Similarly, if all the k bits B[h1(e)%m + o1(e)],··· , B[hk(e)%m+o1(e)] are 1, e may belong to S1∩S2 and ShBFA records e ∈ S1 ∩ S2. Finally, if all the k bits B[h1(e)%m + o2(e)],··· , B[hk(e)%m + o2(e)] are 1, e may belong to S2 − S1 and ShBFA records e∈ S2 − S1. Based on what ShBFA recorded after analyzing the 3k bits, there are following 7 outcomes. If ShBFA records that: 1. only e∈ S1 − S2, it declares that e belongs to S1 − S2. 2. only e ∈ S1 ∩ S2, it declares that e belongs to S1 ∩ S2. 3. only e∈ S2 − S1, it declares that e belongs to S2 − S1. 4. both e ∈ S1 − S2 and e ∈ S1 ∩ S2, it declares that e belongs to S1 but is unsure whether or not it belongs to S2. 5. both e ∈ S2 − S1 and e ∈ S1 ∩ S2, it declares that e belongs to S2 but is unsure whether or not it belongs to S1. 6. both e ∈ S1 − S2 and e ∈ S2 − S1, it declares that e belongs to S1 − S2 ∪ S2 − S1. 7. all e ∈ S1 − S2, e ∈ S1 ∩ S2, and e ∈ S2 − S1, it declares that e belongs S1 ∪ S2. Note that for all these seven outcomes, the decisions of ShBFA do not suffer from false positives or false negatives. However, decisions 4 through 6 provide slightly incomplete information and the decision 7 does not provide any infor- mation because it is already given that e belongs to S1 ∪ S2. We will shortly show that the probability that decision of ShBFA is one of the decisions 4 through 7 is very small, which means that with very high probability, it gives a de- cision with clear meaning, and we call it a clear answer. 4.3 ShBFA – Updating Just like BF handles updates by replacing each bit by a counter, we can also extend ShBFA to handle updates by replacing each bit by a counter. We use CShBFA to denote this counting version of ShBFA. Let C denote the array of 1The application is mentioned in the first paragraph of In- troduction Section. m counters. To insert an element e, after querying T1 and T2 and determining whether o(e) = 0, o1(e), or o2(e), instead of setting k bits to 1, we increment each of the correspond- ing k counters by 1; that is, we increment the k counters C[h1(e)%m+o(e)],··· , C[hk(e)%m+o(e)] by 1. To delete an element e, after querying T1 and T2 and determining whether o(e) = 0, o1(e), or o2(e), we decrement C[hi(e)%m + o(e)] by 1 for all 1 (cid:54) i (cid:54) k. To have the benefits of both fast query processing and small memory consumption, we main- tain both ShBFA and CShBFA, but store array B in fast SRAM and array C in slow DRAM. After each update, we synchronize array C with array B. 4.4 ShBFA – Analysis Recall from Section 4.2 that ShBFA may report seven dif- ferent outcomes. Next, we calculate the probability of each outcome. Let Pi denote the probability of the ith outcome. Before proceeding, we show that hi(.) + o(.) and hj(.) + o(.), when i (cid:54)= j, are independent of each other. For this we show that given two random variables X and Y and a number z ∈ R+, where R+ is the set of positive real numbers, if X and Y are independent, then X+z and Y+z are indepen- dent. As X and Y are independent, for any x ∈ R and y ∈ R, we have P (X (cid:54) x, Y (cid:54) y) = P (X (cid:54) x) ∗ P (Y (cid:54) y) (22) Adding z to both sides of all inequality signs in P (X (cid:54) x, Y (cid:54) y), we get P (X + z (cid:54) x + z, Y + z (cid:54) y + z) = P (X (cid:54) x, Y (cid:54) y) = P (X (cid:54) x) ∗ P (Y (cid:54) y) = P (X + z (cid:54) x + z) ∗ P (Y = z (cid:54) y + z) (23) Therefore, X + z and Y + z are independent. Let n(cid:48) be the number of distinct elements in S1 ∪ S2, and let k be the number of hash functions. After inserting all n(cid:48) elements into ShBFA, the probability p(cid:48) that any given bit is still 0 is given by the following equation. (cid:18) (cid:19)kn(cid:48) (cid:48) p = 1 − 1 m This is similar to one minus the false positive probability of a standard BF. When k = ln 2 m n(cid:48) , p(cid:48) ≈ 0.5. Note that the probabilities for outcomes 1, 2, and 3 are the same. Similarly, the probabilities for outcomes 4, 5, and 6 are also the same. Following equations state the expressions for these probabilities. P1 = P2 = P3 = (1 − 0.5k)2 P4 = P5 = P6 = 0.5k ∗ (1 − 0.5k) P7 = (0.5k)2 (24) (25) When the incoming element e actually belongs to one of the three sets: S1 − S2, S1 ∩ S2, and S2 − S1, there is one combination each for S1 − S2 and S2 − S1 and two combinations for S1 ∩ S2. Consequently, the total proba- bility is P1 + P4 ∗ 2 + P7, which equals 1. This validates our derivation of the expressions in Equation 25. As an ex- n(cid:48) ln 2=10. Thus, P1=P2=P3=(1 − 0.510)2 ≈ ample, let k= m 0.998, P4=P5=P6=0.510 ∗ (1 − 0.510) = 9.756 ∗ 10−4, and P7 = (1 − 0.510)2 ≈ 9.54 ∗ 10−7. This example shows that with probability of 0.998, ShBFA gives a clear answer, and with probability of only 9.756∗10−4, ShBFA gives an answer with incomplete information. The probability with which it 8 gives an answer with no information is just 9.54∗10−7, which is negligibly small. 4.5 Comparison between ShBFA with iBF For association queries, a straightfoward solution is to build one individual BF (iBF) for each set. Let n1, n2, and n3 be the number of elements in S1, S2, and S1 ∩ S2, re- spectively. For iBF, let m1 and m2 be the size of the Bloom filter for S1 and S2, respectively. Table 2 presents a com- parison between ShBFA and iBF. We observe from the ta- ble that ShBFA needs less memory, less hash computations, and less memory accesses, and has no false positives. For the iBF, as we use the traffic trace that hits the two sets with the same probability, iBF is optimal when the two BFs use identical values for the optimal system parameters and have the same number of hash functions. Specifically, for iBF, when m1 + m2 = (n1 + n2)k/ ln 2, the probability of 3 (1 − 0.5k). For ShBFA, when answering a clear answer is 2 m = (n1 + n2 − n3)k/ ln 2, the probability of answering a clear answer is(1 − 0.5k)2. 5. MULTIPLICITY QUERIES In this section, we first present the construction and query phases of ShBF for multiplicity queries. Multiplicity queries check how many times an element appears in a multi-set. We use ShBF× to denote the ShBF scheme for multiplic- ity queries. Second, we describe the updating methods of ShBF× . Last, we derive the FPR and correctness rate of ShBF×. 5.1 ShBF× – Construction Phase The construction phase of ShBF× proceeds in three steps. Let h1(.),··· , hk(.) be k independent hash functions with uniformly distributed outputs. First, we construct an array B of m bits, where each bit is initialized to 0. Second, to store the existence information of an element e of multi- set S, we calculate k hash values h1(e)%m,··· , hk(e)%m. To calculate the auxiliary information of e, which in this case is the count c(e) of element e in S, we calculate off- set o(e) as o(e) = c(e) − 1. Third, we set the k bits B[h1(e)%m + o(e)],··· , B[hk(e)%m + o(e)] to 1. To deter- mine the value of c(e) for any element e ∈ S, we store the count of each element in a hash table and use the simplest collision handling method called collision chain. 5.2 ShBF× – Query Phase Given a query e, for each 1 (cid:54) i (cid:54) k, we first read c consec- utive bits B[hi(e)%m], B[hi(e)%m + 1], ··· , B[hi(e)%m + w(cid:101) memory accesses, where c is the maxi- c − 1] mum value of c(e) for any e ∈ S. In these k arrays of c consecutive bits, for each 1 (cid:54) j (cid:54) c, if all the k bits B[h1(e)%m + j − 1],··· , B[hk(e)%m + j − 1] are 1, we list j as a possible candidate of c(e). As the largest candidate of c(e) is always greater than or equal to the actual value of c(e), we report the largest candidate as the multiplicity of e to avoid false negatives. For the query phase, the number of w(cid:101). memory accesses is k(cid:100) c 5.3 ShBF× – Updating 5.3.1 To handle element insertion and deletion, ShBF× main- tains its counting version denoted by CShBF×, which is an array C that consists of m counters, in addition to an ar- ray B of m bits. During the construction phase, ShBF× in- crements the counter C[hi(e)%m + o(e)] (1 (cid:54) i (cid:54) k) by ShBF× – Updating with False Negatives in (cid:100) c one every time it sets B[hi(e)%m + o(e)] to 1. During the update, we need to guarantee that one element with multi- ple multiplicities is always inserted into the filter one time. Specifically, for every new element e to insert into the multi- set S, ShBF× first obtains its multiplicity z from B as ex- plained in Section 5.2. Second, it deletes the z−th multi- plicity (o(e) = z − 1) and inserts the (z + 1)−th multiplic- ity (o(e) = z). For this, it calculates the k hash functions hi(e)%m and decrements the k counters C[hi(e)%m + z − 1] by 1 when the counters are (cid:62) 1. Third, if any of the decre- mented counters becomes 0, it sets the corresponding bit in B to 0. Note that maintaining the array C of counters allows us to reset the right bits in B to 0. Fourth, it incre- ments the k counters C[hi(e)%m + z] by 1 and sets the bits B[hi(e)%m + z] to 1. For deleting element e, ShBF× first obtains its multiplic- ity z from B as explained in Section 5.2. Second, it cal- culates the k hash functions and decrements the counters C[hi(e)%m + z − 1] by 1. Third, if any of the decremented counters becomes 0, it sets the corresponding bit in B as 0. Fourth, it increments the counters C[hi(e)%m + z − 2] by 1 and sets the bits B[hi(e)%m + z − 2] to 1. ShBF× – Updating without False Negatives Note that ShBF× may introduce false negatives because before updating the multiplicity of an element, we first query its current multiplicity from B. If the answer to that query is a false positive, i.e., the actual multiplicity of the element is less than the answer, ShBF× will perform the second step and decrement some counters, which may cause a counter to decrement to 0. Thus, in the third step, it will set the corresponding bit in B to 0, which will cause false negatives. 5.3.2 To eliminate false negatives, in addition to arrays B and C, ShBF× maintains a hash table to store counts of each el- ement. In the hash table, each entry has two fields: element and its counts/multiplicities. When inserting or deleting el- ement e, ShBF× follows four steps shown in Figure 5. First, we obtain e's counts/multiplicities from the hash table in- stead of ShBF×. Second, we delete e's z-th multiplicity from CShBF×. Third, if a counter in CShBF× decreases to 0, we set the corresponding bit in ShBF× to 0. Fourth, when inserting/deleting e, we insert the (z − 1)−th/(z + 1)−th multiplicity into ShBF×. Figure 5: The update process of ShBF×. Note that although the counter array C and the hash table are much larger than the bit array B, we store B in SRAM for processing multiplicity queries and store C and the hash table in DRAM for handling updates. 5.4 ShBF× – Analysis For multiplicity queries a false positive is defined as re- porting the multiplicity of an element that is larger than its 9 Hash TableEach bucket stores an element and its counts/multiplicitiesCounting ShBFXShBFXinsert/delete e1) obtain e's multiplicities z, and update the hash table.2) delete e's zth multiplicity from counting ShBFX. 4) It inserts the z-1th multiplicity into ShBFx when deleting e. It inserts the z+1th multiplicity into ShBFx when inserting e.3) If a counter decreases to 0, set the corresponding bit in ShBFX to 0.On-chipOff-chip Optimal Memory iBF m1+m2=(n1+n2)k/ln2 ShBFA m=(n1+n2-n3)k/ln2 2k k+2 2k k Table 2: Comparison Between ShBFA and iBF. #hash computations #memory accesses Probability of a clear answer 2 3 (1 − 0.5k) (1 − 0.5k)2 false positives YES NO actual multiplicity. For any element e belonging to multi- set Sm, ShBF× only sets k bits in B to 1 regardless of how many times it appears in Sm. This is because every time in- formation about e is updated, ShBF× removes the existing multiplicity information of the element before adding the new information. Let the total number of distinct elements in set Sm be n. The probability that an element is reported to be present j times is given by the following equation. f0 ≈(cid:16) 1 − e − kn m (cid:17)k (26) We define a metric called correctness rate, which is the probability that an element that is present j times in a multi-set is correctly reported to be present j times. When querying an element not belonging to the set, the correctness rate CR is given by the following equation. CR = (1 − f0)c (27) When querying an element with multiplicity j (1 (cid:54) j (cid:54) c) in the set, the correctness rate CR(cid:48) is given by the following equation. (cid:48) = (1 − f0)j−1 CR (28) Note the right hand side of the expression for CR(cid:48) is not multiplied with f0 because when e has j multiplicities, all positions hi(e) + j, where 1 (cid:54) i (cid:54) k, must be 1. 5.5 Shifting Count-min Sketch Besides Spectral BF, count-min sketch (CM sketch) can also be used to record and report the number of multiplic- ities of each element [9]. As shown in Figure 6(a), a CM sketch consists of d vectors, and each vector has r counters. Each vector vi (1 (cid:54) i (cid:54) d) corresponds to a hash function hi(.). When inserting an element e, the CM sketch incre- ments the counters v1[h1(e)]...vd[hd(e)] by 1. When query- ing an element e, the CM sketch reports the minimum value of v1[h1(e)]...vd[hd(e)]. CM sketch is simple and easy to im- plement, but is not memory efficient, as the minimal unit is a counter instead of a bit. (a) CM sketch (b) SCM sketch Figure 6: FPR vs. w. One query on CM sketch needs d hash computations and memory accesses when the length of all counters is smaller than a machine word. In such a case, we can use our shifting framework to halve the number of mem- ory accesses and hash functions. Figure 6(a) shows our 10 shifting version of CM sketch, called shifting count-min (SCM) sketch. SCM sketch consists of d/2 vectors vi (1 (cid:54) i (cid:54) d/2), where each vector has 2r counters. Each vec- tor vi corresponds to a hash function hi(.). When in- serting an element e, first, the SCM sketch increments the counters v1[h1(e)]...vd/2[hd/2(e)] by 1. Second, it in- crements the counters v1[h1(e) + o(e)]...vd/2[hd/2(e) + o(e)] by 1. When querying an element e, the SCM sketch re- ports the minimal value of v1[h1(e)]...vd/2[hd/2(e)] and v1[h1(e) + o(e)]...vd/2[hd/2(e) + o(e)]. To read vi[hi(e)] and vi[hi(e) + o(e)] in one memory accesses, we set o(e) = hd/2+1%(w − 1) + 1, where w (cid:54) (w − 7)/r and w is the number of bits in a machine word. 6. PERFORMANCE EVALUATION In this section, we conduct experiments to evaluate our ShBF schemes and side-by-side comparison with state-of- the-art solutions for the three types of set queries. 6.1 Experimental Setup We give a brief overview of the data we have used for evaluation and describe our experimental setup. Data set: We evaluate the performance of ShBF and state-of-the-art solutions using real-world network traces. Specifically, we deployed our traffic capturing system on a 10Gbps link of a backbone router. To reduce the processing load, our traffic capturing system consists of two parallel sub-systems each of which is equipped with a 10G network card and uses netmap to capture packets. Due to high link speed, capturing entire traffic was infeasible because our de- vice could not access/write to memory at such high speed. Thus, we only captured 5-tuple flow ID of each packet, which consists of source IP, source port, destination IP, destination port, and protocol type. We stored each 5-tuple flow ID as a 13-byte string, which is used as an element of a set during evaluation. We collected a total of 10 million 5-tuple flow IDs, out of which 8 million flow IDs are distinct. To fur- ther evaluate the accuracy of our proposed schemes, we also generated and used synthetic data sets. Hash functions: We collected several hash functions from open source web site [1] and tested them for random- ness. Our criteria for testing randomness is that the prob- ability of seeing 1 at any bit location in the hashed value should be 0.5. To test the randomness of each hash function, we first used that hash function to compute the hash value of the 8 million unique elements in our data set. Then, for each bit location, we calculated the fraction of times 1 appeared in the hash values to empirically calculate the probability of seeing 1 at that bit location. Out of all hash functions, 18 hash functions passed our randomness test, which we used for evaluation of ShBF and state-of-the-art solutions. Implementation: We implemented our query process- ing schemes in C++ using Visual C++ 2012 platform. To compute average query processing speeds, we repeat our ex- periments 1000 times and take the average. Furthermore, we conducted all our experiments for 20 different sets of e3456r21 e34122ro(e)o(e)o(e) (a) Changing n (b) Changing k (c) Changing m Figure 7: Comparison false positive rates of ShBFM and 1MemBF. (a) Changing n (b) Changing k (c) Changing m Figure 8: Comparison of number of memory accesses per query of ShBFM and BF. (a) Changing n (b) Changing k (c) Changing m Figure 9: Comparison of query processing speeds of ShBFM, BF, and 1MemBF. (a) Prob. a clear answer (b) # memory accesses per query (c) Query processing speed Figure 10: Comparison of ShBFA and iBF. (a) Correctness rate (CR) (b) Memory accesses (c) Query processing speed Figure 11: Comparison of ShBF×, Spectral BF, and CM Sketch. 11 100011001200130014000.0000.0010.0020.0030.0040.0050.0060.0070.008 theory of ShBFM (m=22008) simulation of ShBFM (m=22008) 1MemBF (m=22008) 1MemBF (m=22008*1.5) n (k=8) FP rate468101214160.000.010.020.030.040.050.06 1MemBF simulation of ShBFM Theory of ShBFM k (m=22976, n=2000) FP rate320003400036000380004000042000440000.0000.0050.0100.0150.0200.0250.0300.0350.0400.0450.0500.055 1MemBF simulation of ShBFM Theory of ShBFM m (n=4000, k=6) FP rate100011001200130014002.02.53.03.54.04.55.05.56.06.57.0 BF ShBFM n (m=22008, k=8) # memory accesses46810121416123456789 BF ShBFM k (m=33024, n=1000) # memory accesses320003400036000380004000042000440000.00.51.01.52.02.53.03.54.04.55.05.56.06.5 BF ShBFM m (k=6, n=4000) # memory accesses1000120014001600180020004681012141618 BF 1MemBF ShBFM n (m=22008, k=8) Query speed (Mqps)46810121416246810121416182022 BF 1MemBF ShBFM k (m=33024, n=1000) Query speed (Mqps)32000340003600038000400004200044000468101214161820 BF 1MemBF ShBFM m (k=8, n=4000) Query speed (Mqps)46810121416180.550.600.650.700.750.800.850.900.951.00 iBF simulation iBF theory ShBFA simulation ShBFA theory k Prob. a clear answer46810121416180510152025 iBF ShBFA k # memory accesses4681012141618024681012 iBF ShBFA k Query speed (Mqps)89101112131415160.00.20.40.60.81.01.21.41.61.82.02.22.4 theory of ShBFX simulations of ShBFX simulations of Spectral BF simulations of CM Sketch # of hash functions -- k Correctness rate34567891011121314151624681012141618# of memory accesses# of hash functions -- k Spectral BF ShBFX CM sketch3456789101112131415161718246810 Spectral BF ShBFX CM Sketch # of hash functions -- k Query speed (Mqps) parameters. As the results across different parameter sets follow same trends, we will report results for one parameter set only for each of the three types of queries. Computing platform: We did all our experiments on a standard off the shelf desktop computer equipped with an Intel(R) Core i7-3520 CPU @2.90GHz and 8GB RAM running Windows 7. 6.2 ShBFM – Evaluation ShBFM – False Positive Rate In this section, we first validate the false positive rate of ShBFM calculated in Equation (1) using our experimental results. Then we compare ShBFM with BF and 1MemBF [13], which represents the prior scheme for answering mem- bership queries, in terms of FPR, the number of memory accesses, and query processing speed. 6.2.1 Our experimental results show that the FPR of ShBFM calculated in Equation (1) matches with the FPR calculated experimentally. For the experiments reported in this sec- tion, we set k = 8, m = 22008, w = 57, and vary n from 1000 to 1500. We first insert 1000 elements into ShBFM and then repeatedly insert 20 elements until the total number of elements inserted into ShBFM became 1500. On inserting each set of 20 elements, we generated membership queries for 7, 000, 000 elements whose information was not inserted into ShBFM and calculated the false positive rate. Figure 7(a) shows the false positive rate of ShBFM calculated through these simulations as well as through Equation (1). The bars in Figure 7(a) represent the theoretically calculated FPR, whereas the lines represent the FPR observed in our exper- iments. Our results show that the relative error between the FPRs of ShBFM calculated using simulation and theory is less than 3%, which is practically acceptable. Relative error is defined as F P Rs − F P Rt/F P Rt, where F P Rs is the false posi- tive rate calculated using simulation and F P Rt is the false positive rates calculated using theory. The relative error of 3% for ShBFM is the same as relative error for BF calcu- lated using simulation and the theory developed by Bloom et al. [3]. Using same parameters, the FPR of 1MemBF is over 5 ∼ 10 times that of ShBFM. If we increase the space allocated to 1MemBF for storage to 1.5 times of the space used by ShBFM, the FPR of 1MemBF is still a little more than that of ShBFM because hashing k values into one or more words incurs serious unbalance in distributions of 1s and 0s in the memory, which in turn results in higher FPR. Our results also show that the FPR of ShBFM is much smaller than that of 1MemBF when changing k and m. Fig- ure 7(b) and Figure 7(c) show the FPRs of ShBFM and 1MemBF for different values of k and m, respectively. 6.2.2 Our results show that ShBFM answers a membership query using only about half the memory accesses and hash compu- tations and twice as fast compared to BF. Our experiments for evaluating the number of memory accesses per query are similar to that for false positive rate, except that, now we query 2 ∗ n elements, in which n elements belong to the set. Figures 8(a), 8(b), and 8(c) show the number of memory accesses for ShBFM and standard BF for different values of n, k, and m, respectively. We also observed from our exper- iments that standard deviation in the results for ShBFM is also about half of that of standard BF. ShBFM – Memory Accesses ShBFM – Query Processing Speed 6.2.3 Our results show that ShBFM has 1.8 and 1.4 times faster query processing speed compared to BF and 1MemBF, re- spectively. Although 1MemBF only needs one memory ac- cess per query, it needs k + 1 hash functions. BFs are usu- ally small enough to be stored in on-chip memory (such as caches, FPGA block RAM), thus the speed of hash com- putation will be slower than memory accesses. In contrast, our ShBFM reduces both hash computation and memory ac- cesses. In our experiments, using those hashes which passed our randomness test, ShBFM exhibits faster query process- ing speed than that of 1MemBF. It is possible that 1MemBF is faster than ShBFM when using simple hash functions, but this probably incurs larger FPR. Our experiments for eval- uating the query processing speed are similar to that for memory accesses, except that, here we also compare with 1MemBF. Figures 9(a), 9(b), and 9(c) show the query pro- cessing speed for ShBFM , standard BF, and 1MemBF for different values of n, k, and m, respectively. 6.3 ShBFA – Evaluation ShBFA – Probability of Clear Answer In this section, we first validate the probability of a clear answer of ShBFM calculated in Table 2 using our experi- mental results. Then we compare ShBFA with iBF in terms of FPR, memory accesses, and query processing speed. 6.3.1 Our results show that probability of clear answer for ShBFA calculated in Table 2 matches with the probability cal- culated experimentally. We performed experiments for both iBF and ShBFA using two sets with 1 million elements such that their intersection had 0.25 million elements. The query- ing elements hit the three parts with the same probability. While varying the value of k, we also varied the value of m to keep the filter at its optimal. Note that in this case, iBF uses 1/7 times more memory than ShBFA. We observe from Figure 10(a) that the simulation results match the theoreti- cal results, and the average relative error is 0.7% and 0.004% for iBF and ShBFA, respectively, which is negligible. When the value of k reaches 8, the probability of a clear answer reaches 66% and 99% for iBF and ShBFA, respectively. 6.3.2 Our results show that the average number of memory ac- cesses per query of ShBFA is 0.66 times of that of iBF. Fig- ure 10(b) shows the number of memory accesses for different values of k. We observed similar trends for different values of m and n, but have not including the corresponding figures due to space limitation. 6.3.3 Our results show that the average query processing speed of ShBFA is 1.4 times faster than that of iBF. Figure 10(c) plots the the query processing speed of ShBFA and iBF for different values of m. 6.4 ShBF× – Evaluation ShBFA – Memory Accesses ShBFA – Query Processing Speed In this section, we first validate the correctness rate (CR) of ShBF× calculated in Equation (27). Then we compare ShBF× with spectral BF [8] and CM Sketch [9] in terms of CR, number of memory accesses, and query processing speed. The results for CM Sketch and Spectral BF are simi- lar because their methods of recording the counts is similar. 6.4.1 ShBF× – Correctness Rate 12 Our results show that the CR of ShBF× calculated in Equation (27) matches with the CR calculated experimen- tally. Our results also show that on average, the CR of ShBF× is 1.6 times and 1.79 times of that of Spectral BF and CM Sketch, respectively. For the experiments reported in this section, we set c = 57, n = 100, 000, and vary k in the range 8 (cid:54) k (cid:54) 16. For spectral BF and CM sketch, we set use 6 bits for each counter. For each value of k, as ShBF× is more memory efficient, we use 1.5 times the optimal mem- ory (i.e., 1.5 ∗ nk/ln2) for all the three filters. Figure 11(a) shows the results from our experiments for CR. We observe from this figure that the CR calculated through experiments matches with the CR calculated theoretically and the rela- tive error is less than 0.08%, which is negligibly small. 6.4.2 ShBF× – Memory Accesses Our results show that the number of memory accesses of ShBF× is smaller than that of spectral BF and CM Sketch for k (cid:62) 7, and almost equal for k < 7. Figure 11(b) plots the number of memory accesses of ShBF×, CM Sketch, and spectral BF, calculated from the same experiments that we used to plot Figure 11(a) except that k ranges from 3 to 18. 6.4.3 Our results show that ShBF× is faster than spectral BF and CM Sketch when k (cid:62) 11. We evaluate the query pro- cessing speed of ShBF×, CM Sketch, and spectral BF using the same parameters as for Figure 11(b). Figure 11(c) plots the query processing speeds of ShBF× and spectral BF. We observe from this figure that when k > 11, the average query processing speed of ShBF× is over 3 Mqps. 7. CONCLUSION ShBF× – Query Processing Speed The key contribution of this paper is in proposing Shift- ing Bloom Filter, a general framework to answer a vari- ety of set queries. We present how to use ShBF to answer three important set queries, i.e., membership, association, and multiplicity queries. The key technical depth of this pa- per is in the analytical modeling of ShBF for each of the three types queries, calculating optimal system parameters, and finding the minimum FPRs. We validated our analytical models through simulations using real world network traces. Our theoretical analysis and experimental results show that ShBF significantly advances state-of-the-art solutions on all three types of set queries. 8. REFERENCES [1] Hash website [on line]. Available: http://burtleburtle.net/bob/hash/evahash.html. [2] J. Aguilar-Saborit, P. Trancoso, V. Muntes-Mulero, and J.-L. Larriba-Pey. Dynamic count filters. ACM SIGMOD Record, 35(1):26–32, 2006. [3] B. H. Bloom. Space/time trade-offs in hash coding with allowable errors. Communications of the ACM, 13(7):422–426, 1970. [4] P. Bose, H. Guo, E. Kranakis, A. Maheshwari, P. Morin, J. Morrison, M. Smid, and Y. Tang. On the false-positive rate of bloom filters. Information Processing Letters, 108(4):210–213, 2008. [5] A. Broder and M. Mitzenmacher. Network applications of bloom filters: A survey. Internet mathematics, 1(4):485–509, 2004. [6] B. Chazelle, J. Kilian, R. Rubinfeld, and A. Tal. The bloomier filter: an efficient data structure for static support lookup tables. In Proc. ACM-SIAM, 2004. [7] K. Christensen, A. Roginsky, and M. Jimeno. A new analysis of the false positive rate of a bloom filter. Information Processing Letters, 110(21):944–949, 2010. [8] S. Cohen and Y. Matias. Spectral bloom filters. In Proc. ACM SIGMOD, pages 241–252, 2003. [9] G. Cormode and S. Muthukrishnan. An improved data stream summary: the count-min sketch and its applications. Journal of Algorithms, 55(1):58–75, 2005. [10] B. Fan, D. G. Andersen, M. Kaminsky, and M. D. Mitzenmacher. Cuckoo filter: Practically better than bloom. 2009. [11] L. Fan, P. Cao, J. Almeida, and A. Z. Broder. Summary cache: a scalable wide-area web cache sharing protocol. IEEE/ACM Transactions on Networking (TON), 8(3):281–293, 2000. [12] F. Hao, M. Kodialam, T. Lakshman, and H. Song. Fast multiset membership testing using combinatorial bloom filters. In Proc. IEEE INFOCOM, 2009. [13] A. Kirsch and M. Mitzenmacher. Less hashing, same performance: building a better bloom filter. In Algorithms–ESA 2006, pages 456–467. Springer, 2006. [14] A. Kirsch, M. Mitzenmacher, and G. Varghese. Hash-based techniques for high-speed packet processing. In Algorithms for Next Generation Networks, pages 181–218. Springer, 2010. [15] M. Lee, N. Duffield, and R. R. Kompella. Maple: A scalable architecture for maintaining packet latency measurements. In Proc. ACM IMC 2012. [16] Y. Lu, B. Prabhakar, and F. Bonomi. Bloom filters: Design innovations and novel applications. In 43rd Annual Allerton Conference, 2005. [17] Y. Qiao, T. Li, and S. Chen. One memory access bloom filters and their generalization. In Proc. IEEE INFOCOM, pages 1745–1753, 2011. [18] J. Roozenburg. A literature survey on bloom filters. Research Assignment, November, 2005. [19] S. Tarkoma, C. E. Rothenberg, and E. Lagerspetz. Theory and practice of bloom filters for distributed systems. Communications Surveys and Tutorials, IEEE, 14(1):131–155, 2012. [20] S. Xiong, Y. Yao, Q. Cao, and T. He. kBF: a bloom filter for key-value storage with an application on approximate state machines. In Proc. IEEE INFOCOM, 2014. [21] M. K. Yoon, J. Son, and S.-H. Shin. Bloom tree: A search tree based on bloom filters for multiple-set membership testing. In Proc. IEEE INFOCOM, 2014. 13
1101.4068
1
1101
2011-01-21T03:23:57
Linear-Space Data Structures for Range Mode Query in Arrays
[ "cs.DS" ]
A mode of a multiset $S$ is an element $a \in S$ of maximum multiplicity; that is, $a$ occurs at least as frequently as any other element in $S$. Given a list $A[1:n]$ of $n$ items, we consider the problem of constructing a data structure that efficiently answers range mode queries on $A$. Each query consists of an input pair of indices $(i, j)$ for which a mode of $A[i:j]$ must be returned. We present an $O(n^{2-2\epsilon})$-space static data structure that supports range mode queries in $O(n^\epsilon)$ time in the worst case, for any fixed $\epsilon \in [0,1/2]$. When $\epsilon = 1/2$, this corresponds to the first linear-space data structure to guarantee $O(\sqrt{n})$ query time. We then describe three additional linear-space data structures that provide $O(k)$, $O(m)$, and $O(|j-i|)$ query time, respectively, where $k$ denotes the number of distinct elements in $A$ and $m$ denotes the frequency of the mode of $A$. Finally, we examine generalizing our data structures to higher dimensions.
cs.DS
cs
Linear-Space Data Structures for Range Mode Query in Arrays∗ S. Durocher† J. Morrison‡ January 20, 2011 Abstract A mode of a multiset S is an element a ∈ S of maximum multiplicity; that is, a occurs at least as frequently as any other element in S. Given a list A[1 : n] of n items, we consider the problem of constructing a data structure that efficiently answers range mode queries on A. Each query consists of an input pair of indices (i, j) for which a mode of A[i : j] must be returned. We present an O(n2−2)-space static data structure that supports range mode queries in O(n) time in the worst case, for any fixed  ∈ [0, 1/2]. When  = 1/2, this corresponds to the first linear-space data structure to guarantee O( n) query time. We then describe three additional linear-space data structures that provide O(k), O(m), and O(j − i) query time, respectively, where k denotes the number of distinct elements in A and m denotes the frequency of the mode of A. Finally, we examine generalizing our data structures to higher dimensions. √ 1 Introduction Mode and Range Queries. The frequency of an element x in a multiset S, denoted freqS(x), is the number of occurrences (i.e., the multiplicity) of x in S. A mode of S is an element a ∈ S such that for all x ∈ S, freqS(x) ≤ freqS(a). A multiset S may have multiple distinct modes; the frequency of the modes of S, denoted by m, is unique. Along with the mean and median of a multiset, the mode is a fundamental statistic of data analysis for which efficient computation is necessary. Given a sequence of n elements ordered in a list A, a range query seeks to compute the corresponding statistic on the multiset determined by a subinterval of the list: A[i : j]. The objective is to preprocess A to construct a data structure that supports efficient response to one or more subsequent range queries, where the corresponding input parameters (i, j) are provided at query time. We assume the RAM model of computation with word size Θ(log u), where elements are drawn from a universe U = {0, . . . , u − 1}. Although the complete set of possible queries can be precomputed and stored using Θ(n2) space, practical data structures require less storage while still enabling efficient response time. For all i, if i = j, then a range query must report A[i]. Consequently, any range query data structure for a list of n items requires Ω(n) storage space in the worst case [7]. This leads to a natural question: how quickly can an O(n)-space data structure answer range queries? The problem of constructing efficient data structures for range median queries has been analyzed extensively [7, 9, 10, 11, 23, 24, 26, 28, 29, 30, 33, 34]. A range mean query is equivalent to a normalized range sum query (partial sum query), for which a precomputed prefix-sum array provides a linear-space static data structure with constant query time [30]. As expressed recently by Brodal et al. regarding the current status of the range mode query problem: "The problem of finding the most frequent element within a given array range is still rather open." [9, page 2]. See Section 2 for an overview of the current state of the range mode query problem. Our Results. Given an array A[1 : n] of n items, we present an O(n2−2)-space static data structure that supports range mode queries in O(n) time in the worst case, for any fixed  ∈ [0, 1/2]. When  = 1/2, ∗Work supported in part by the Natural Sciences and Engineering Research Council of Canada (NSERC). †University of Manitoba, Winnipeg, Canada, [email protected] ‡University of Manitoba, Winnipeg, Canada, jason [email protected] 1 √ n) query time. Prior to our work, this corresponds to the first linear-space data structure to guarantee O( √ the previous fastest linear-space data structure by Krizanc et al. [30] supported range mode queries in O( n log log n) time; our data structure borrows ideas developed by Krizanc et al. and augments their data structure to eliminate dependence on predecessor queries (see Proposition 4). We describe three additional O(n)-space data structures that provide O(k), O(m), and O(j−i) query time, respectively, where k denotes the number of distinct elements in A. Finally we discuss generalizations of our data structures to d dimensions for any fixed d. To the authors' knowledge, this is the first examination of multidimensional range mode query. 2 Related Work Computing a Mode. The mode of a multiset S of n items can be found in O(n log n) time by sorting S and scanning the sorted list to identify the longest sequence of identical items. Due to the corresponding lower bound on the worst-case time for solving the element uniqueness problem, finding a mode requires Ω(n log n) time in the worst case; that is, the decision problem of determining whether m > 1 requires Ω(n log n) time in the worst case [36]. Better bounds on the worst-case time are obtained by parameterizing in terms of m or k. A worst-case time of O(n log k) is easily achieved by inserting the n elements into a balanced search tree in which each node stores a key and its frequency. Munro and Spira [32] describe an O(n log(n/m))-time algorithm for finding a mode and a corresponding lower bound of Ω(n log(n/m)) on the worst-case time. If distinct elements in S can be mapped efficiently (i.e., in constant time) to distinct integers in the range {1, . . . , k(cid:48)}, for some k(cid:48), then a mode of S can be found in O(n + k(cid:48)) time using O(n + k(cid:48)) space. This is achieved by identifying a maximum element in a frequency table for S of size k(cid:48). This method is analogous to counting sort. A similar algorithm for computing a mode can be implemented using hash tables. We include the following lemma to which we refer in Section 3: Lemma 1 (Krizanc et al. [30]) Let A and B be any multisets. If c is a mode of A ∪ B and c (cid:54)∈ A, then c is a mode of B. √ Range Mode Query. Naturally, a mode of the query interval A[i : j] can be computed directly without preprocessing using any of the methods described in Section 2. Krizanc et al. [30] describe data structures that provide constant-time queries using O(n2 log log n/ log n) space and O(n log n)-time queries using O(n2−2) space, for any fixed  ∈ (0, 1/2]. Petersen and Grabowski [34] improve the first bound to constant time and O(n2 log log n/ log2 n) space and Petersen [33] improves the second bound to O(n)-time queries using O(n2−2) space, for any fixed  ∈ [0, 1/2). When  = 1/2, the data structure of Krizanc et al. [30] requires only n log log n) query time. Although its space requirement is almost linear in n linear space and provides O( as  approaches 1/2, the data structure of Petersen [33] requires ω(n) space. Furthermore, the construction becomes impractical as  approaches 1/2 (the number of levels in a hierarchical set of tables and hash functions approaches ∞ as  → 1/2) and no obvious modification reduces its space requirement to O(n). Greve et al. [25] prove a lower bound of Ω(log n/ log(s · w/n)) query time for any data structure that uses s memory cells of w bits. Bose et al. [7] consider approximate range mode queries, in which the objective is to return an element whose frequency is at least α · m. They give a data structure that requires O(n/(1 − α)) space and answers approximate range mode queries in O(log log1/α n) time for any fixed α ∈ (0, 1), as well as data structures that provide constant-time queries for α ∈ {1/2, 1/3, 1/4}, using space O(n log n), O(n log log n), and O(n), respectively. Greve et al. [25] give a linear-space data structure that supports approximate range mode queries in constant time for α = 1/3, and an O(n· α/(1− α))-space data structure that supports approximate range mode queries in O(log(α/(1 − α))) time for any fixed α ∈ [1/2, 1). Continuous Space versus Array Input. A vast literature studies the problems of geometric range searching in continuous Euclidean space; that is, data points are positioned arbitrarily in Rd. See the survey by Agarwal [1] for an overview of results. The range query problems considered in this paper, however, restrict attention to array input. Although a range query on an array can be viewed as a restricted case of 2 a more general range searching problem (e.g., a point set with regular spacing), the algorithmic techniques differ greatly between the two settings when d ≥ 2. When d = 1, however, a geometric range mode query problem reduces to array range mode query. In particular, the rank of each data point in Euclidean space corresponds to its array index. It suffices to compute the ranks of the respective successor and predecessor of the endpoints of the query interval to identify the indices i and j, and to return the corresponding array range mode query on A[i : j]. In addition to results on the median, mode, and sum range query problems discussed in Sections 1 and 2, other range query problems examined on arrays include semigroups [2, 38, 39], extrema (e.g., range minimum or maximum) [4, 6, 13, 19, 20, 18, 21, 22], selection or quantiles (for which the median is a special case) [23, 24, 28, 29], dominance or rank (counting the number of elements in the query range that exceed a given input threshold) [27, 28], coloured range (counting/enumerating the distinct elements in the query range) [23], and k-frequency (determining whether any element has frequency k) [25]. Recently, range query problems have been examined on multidimensional arrays, including partial sums [12], range minimum [3, 8, 13, 35, 40], median [24], and selection [23]. 3 Sparse Mode Table Method: O(n) Query Time and O(n2−2) Space In the worst case, for every range mode query processed, the data structure of Krizanc et al. [30] makes a se- quence of Θ(n) predecessor queries, each requiring Θ(log log n) time, for a total query time of Θ(n log log n). We build on the data structure of Krizanc et al. and introduce a different technique that avoids predecessor search entirely. Section 3 establishes the following theorem and the corresponding corollary that follows when  = 1/2: Theorem 2 Given an array A[1 : n] of n items, for any  ∈ [0, 1/2] there exists a data structure requiring O(n2−2) storage space that supports range mode queries on A in O(n) time in the worst case. √ Corollary 3 Given an array A[1 : n] of n items, there exists a data structure requiring O(n) storage space that supports range mode queries on A in O( n) time in the worst case. Data Structure Precomputation. Suppose the elements of A[1 : n] are drawn from an ordered bounded universe U . Let D = {a1, . . . , ak} ⊆ U denote the set of distinct elements stored in A. Construct an array B[1 : n] such that for each i, B[i] stores the rank of A[i] in D. Therefore, B[i] ∈ {1, . . . , k}. For any a, i, and j, B[a] is a mode of B[i : j] if and only if A[a] is a mode of A[i : j]. Performing computation on array B instead of array A allows direct array referencing using the values stored in B as indices. For simplicity, we describe our data structures in terms of array B; a table look-up provides a direct bijective mapping from {1, . . . , k} to D. Set D, array B, and the value k are independent of any query range and can be computed in O(n log k) time during preprocessing. Given fixed a and b, array C[1 : k] is a frequency table for B[a : b] if, for each i, C[i] stores the number of occurrences of element i in B[a : b]. For any j > i, if Ci[1 : k] is a frequency table for B[1 : i] and Cj[1 : k] is a frequency table for B[1 : j], then for each x, Cj[x] − Ci[x] is the frequency of B[x] in B[i + 1 : j]. For each a ∈ {1, . . . , k}, let Qa = {b B[b] = a}. That is, Qa is the set of indices b such that B[b] = a. For any a, a range counting query for element a in B[i : j] can be answered by searching for the predecessors of i and j, respectively, in the set Qa; the difference of the indices of the two predecessors is the frequency of a in B[i : j] [30]. As noted above, implementing such a range counting query using an efficient predecessor data structure requires Θ(log log n) time in the worst case. The following related decision problem, however, can be answered in constant time by a linear-space data structure: does B[i : j] contain at least q instances of element B[i]? This question can be answered by a select query that returns the index of the qth instance of B[i] in B[i : n]. For each a ∈ {1, . . . , k}, store the set Qa as an ordered array (also denoted Qa for simplicity). Define a rank array B(cid:48)[1 : n] such that for all b, B(cid:48)[b] denotes the rank of B[b] in B[1 : n] (i.e., the index of b in QB[b]). Given any q, i, and j, to determine 3 Figure 1: Example of the sparse mode table method data structure. The number of list items is n = 24, of which k = 5 are distinct. If  = 3/8, the array is partitioned into t = (cid:100)n/s(cid:101) = 6 blocks of size s = (cid:100)n(cid:101) = 4. The query range is A[i : j] = A[7 : 19], for which the unique mode is 20, occurring with frequency 5. The corresponding mode of B[i : j] is 2. The query range B[7 : 19] is partitioned into the prefix B[7 : 8], the span B[9 : 16], and the suffix B[17 : 19]. The span covers blocks bi = 2 to bj = 3, for which the corresponding mode is S[2, 3] = 2, occurring with frequency S(cid:48)[2, 3] = 4. whether B[i : j] contains at least q instances of B[i] it suffices to check whether QB[i][B(cid:48)[i] + q− 1] ≤ j. Since array QB[i] stores the sequence of indices of instances of element B[i] in B, looking ahead q − 1 positions in QB[i] returns the index of the qth occurrence of element B[i] in B[i : n]; if this index is at most j, then the frequency of B[i] in B[i : j] is at least q. If the index B(cid:48)[i] + q − 1 exceeds the size of the array QB[i], then the query returns a negative answer. This gives the following lemma: Lemma 4 Given an array A[1 : n] of n items, there exists a data structure requiring O(n) storage space that can determine in constant time for any {i, j} ⊆ {1, . . . , n} and any q whether A[i : j] contains at least q instances of element A[i]. Following Krizanc et al. [30], given any  ∈ [0, 1/2] we partition array B into t blocks of size s = (cid:100)n(cid:101), where t = (cid:100)n/s(cid:101) ≤ (cid:100)n1−(cid:101). That is, for each i ∈ {0, . . . , t − 2}, the ith block spans B[i · s + 1 : (i + 1)s] and the last block spans B[(t− 1)· s + 1 : n]. We precompute tables S[0 : t− 1, 0 : t− 1] and S(cid:48)[0 : t− 1, 0 : t− 1], each of size Θ(t2), such that for any {bi, bj} ⊆ {0, . . . , t− 1}, S[bi, bj] stores a mode of B[bi · s + 1 : (bj + 1)s] and S(cid:48)[bi, bj] stores the corresponding frequency. Finally, we need a frequency table C[1 : k] of size k, initialized to zero. The arrays Q1, . . . , Qk can be constructed in O(n) total time in a single scan of array B. The arrays S and S(cid:48) can be constructed in O(n2−) time by scanning array B t times, computing one row of each array S and S(cid:48) per scan. Thus, the total precomputation time required to initialize the data structure is O(n2−). Range Mode Query Algorithm. Given a query range B[i : j], let bi = (cid:100)(i − 1)/s(cid:101) and bj = (cid:98)j/s(cid:99) − 1 denote the respective indices of the first and last blocks completely contained within B[i : j]. We refer to B[bi · s + 1 : (bj + 1)s] as the span of the query range, to B[i : min{bi · s, j}] as its prefix, and to B[max{(bj + 1)s + 1, i} : j] as its suffix. One or more of the prefix, span, and suffix may be empty; in particular, if bi > bj, then the span is empty. See the example in Figure 1. The value c = S[bi, bj] is a mode of the span with corresponding frequency fc = S(cid:48)[bi, bj]. If the span is empty, then let fc = 0. By Lemma 1, either c is a mode of B[i : j] or some element of the prefix or suffix 4 bjbjbibBA30203020404010201040323244121420210133055014405101050B'122044044055044022000000111112222233344455ji012345query range A[7:19]243617115212214972313128518192420001122334455S441224001122334455S'1436672244422222245512355624442232320123456suffix16prefixspan231481011131495121615619181720212322724611Q102Q3Q4Q1Q5i is a mode of B[i : j]. Thus, to identify a mode of B[i : j], we verify for every element in the prefix and suffix whether its frequency in B[i : j] exceeds fc and, if so, we identify this element as a candidate mode and count its additional occurrences in B[i : j]. We present the details of this procedure for the prefix; an analogous procedure is applied to the suffix. We now describe how to compute the frequency of all candidate elements in the prefix over the range B[i : j], storing these values in the frequency table C. Sequentially scan the items in the prefix starting at the leftmost index, i, and let x denote the index of current item. If C[B[x]] > 0, then an instance of element B[x] appears in B[i : x − 1], and its frequency has been counted already; in this case, simply skip B[x] and increment x. If C[B[x]] = 0, check whether QB[x][B(cid:48)[x] + fc − 1] ≤ j (i.e., verify whether B[x] is a candidate). If so, then the frequency of B[x] in B[i : j] is at least fc. The exact frequency of B[x] in B[i : j] can be counted by a linear scan of QB[x], starting at index B(cid:48)[x] + fc − 1 and terminating upon reaching either an index y such that QB[x][y] > j or the end of array QB[x] (i.e., y = QB[x] + 1). That is, QB[x][y] denotes the index of the first instance of element B[x] that lies beyond the query range B[i : j] (or no such element exists). Consequently, the frequency of B[x] in B[i : j] is y − B(cid:48)[x]. Store this value in C[B[x]]. An analogous procedure is repeated for the suffix. Upon completing the scans of the prefix and suffix, we identify a maximum value in array C; its index corresponds to a mode of B[i : j]. Only non-zero entries in C need be examined (and subsequently reset to zero); this is achieved by making a second scan of the prefix and suffix and examining the corresponding elements in array C. Storage Space and Query Time. If the prefix and suffix are empty, then S[bi, bj] is a mode of B[i : j], and this value is returned in constant time. Without loss of generality, suppose the prefix contains at least one item. Consider an arbitrary index x ∈ {i, . . . , bi · s − 1} during the scan of the prefix. If C[B[x]] > 0, then B[x] is processed in constant time. Therefore, suppose C[B[x]] = 0. That is, x corresponds to the index of the first instance of B[x] in the prefix. Consequently, the frequency of B[x] in B[i : j], denoted fx, is equal to its frequency in B[x : j]. By Lemma 4, determining whether fx ≥ fc requires only constant time. Any item B[x] that is not a candidate is processed in constant time. Therefore, suppose B[x] is a candidate. Since the prefix and suffix each have size at most s − 1, fc ≤ fx ≤ 2(s − 1). Item B[x] incurs a cost of O(fx−fc) time for its first occurrence, and O(1) time for subsequent occurrences. Since fc is the frequency of the mode of the span, at least fx − fc instances of B[x] must occur in the prefix or suffix. In other words, instances of element B[x] incur a total cost of O(cx) time, where cx denotes the frequency of B[x] in the prefix and suffix. Since the number of items in the prefix and suffix is at most 2(s − 1), the total cost for processing the prefix is O(s). By an analogous argument, the total cost for processing the suffix is also O(s). Identifying the maximum element in array C and re-initializing C to zero requires O(s) time. Therefore, a range mode query requires O(s) = O(n) time in the worst case. The data structure requires O(n) space to store the arrays A, B, and B(cid:48), O(n) total space to store the arrays Q1, . . . , Qk, and O(t2) = O(n2−2) space to store the tables S and S(cid:48). This gives O(n2−2) total space for O(n) worst-case query time for any  ∈ [0, 1/2], proving Theorem 2. As mentioned earlier, Ω(n) space is required. Therefore, increasing  beyond 1/2 increases query time without decreasing space. 4 Additional Linear-Space Range Mode Query Data Structures We apply results from Section 3 to obtain three additional O(n)-space data structures, giving the following theorem: that supports range mode queries on any A[i : j] in O(min{√ Theorem 5 Given an array A[1 : n] of n items, there exists a data structure requiring O(n) storage space n, k,j − i, m + log log n}) time in the worst case, where k denotes the number of distinct elements in A and m denotes the frequency of the mode of A. 4.1 Sparse Frequency Table Method: O(k) Query Time and O(n) Space We now describe an O(k + s) query time and O(n + n · k/s)-space data structure for any fixed s ∈ [1, n]. When s ∈ Θ(k), our data structure requires O(n) space and supports range mode queries in O(k) time. A 5 Figure 2: Example of the sparse frequency table method data structure. The number of list items is n = 16, of which k = 5 are distinct. The array is partitioned into four blocks of size s = 4. The query range is A[i : j] = A[6 : 15], for which elements 10 and 20 are modes, each occurring with frequency 3. The corresponding modes of B[i : j] are 1 and 2. Thus, C[1] = C[2] = 3 is the maximum value in the frequency array C. value of s ∈ o(k) (respectively, s ∈ ω(k)) results in ω(n) space (ω(k) time) without any reduction in query time (space). Data Structure Precomputation. For each p ∈ {1, . . . , n} such that p mod s = 0, construct a frequency table Cp[1 : k] for the range B[1 : p]. Create one additional array C0[1 : k], initialized to zero. There are (cid:100)n/s(cid:101)+1 such arrays Ci. See Figure 2. The preprocessing time required is O(n+n·k/s) (or O(n log k+n·k/s) time if k or B must be computed). Range Mode Query Algorithm. Array B is partitioned into blocks of size s as in Section 3. Given a query range B[i : j], we refer to the sequence of blocks completely covered by B[i : j] as the span, and to the remaining subarrays as the prefix and suffix, respectively. A query on B[i : j] is performed as follows: 1. Let p = s(cid:98)(i − 1)/s(cid:99) and let p(cid:48) = s(cid:98)j/s(cid:99). That is, p is the largest p ≤ i − 1 such that array Cp is defined. Similarly, p(cid:48) is the largest p(cid:48) ≤ j such that array Cp(cid:48) is defined. 2. Create an array C[1 : k] such that for each x, C[x] ← Cp(cid:48)[x] − Cp[x]. Upon completing this step, C is a frequency table for the span B[p + 1 : p(cid:48)]. 3. For each x ∈ {p + 1, . . . , i − 1}, set C[B[x]] ← C[B[x]] − 1. For each x ∈ {p(cid:48) + 1, . . . , j}, set C[B[x]] ← C[B[x]] + 1. Upon completing this step C is a frequency table for the entire query range B[i : j]. 4. Find a maximum value in C. If x(cid:48) is an index that maximizes C[x(cid:48)], then B[x(cid:48)] is a mode of B[i : j]. Storage Space and Query Time. The data structure consists of arrays A and B, requiring O(n) space, and O(cid:100)n/s(cid:101) + 1 frequency tables of size k. Thus, the total space required by the data structure is O(n + n· k/s). Steps 1 through 4 of the algorithm require O(1), O(k), O(s), and O(k) time, respectively. This gives O(n + n · k/s) total space for O(k + s) query time. 4.2 Low Frequency Mode Method: O(m + log log n) Query Time and O(n) Space Using a combination of ideas from Section 3 and from an approximate range mode query data structure of Greve et al. [25], we briefly describe a range mode data structure parameterized in terms of the frequency 6 p'pi−1C4C8C12C16C0122342314781011131495121615BA62030203020205040401020104023232254412141102021010000011110222114623112345C12331ijsuffixprefixspanquery range A[6:15]0123 √ of the mode, m, with good bounds on space and query time when m is small (e.g., m ∈ O( As in Section 3, the rank array B(cid:48) and the arrays Q1, . . . , Qk are constructed, and array B is partitioned into blocks of size s. For each i ∈ {0, . . . , n} such that i mod s = 0, construct an array Fi[1 : m] such that for each x, Fi[x] stores the largest j ≤ n such that the mode of B[i : j] has frequency at most x; a corresponding mode is also stored. A query range B[i : j] is divided into prefix, span, and suffix subarrays as before. Let p = s(cid:100)i/s(cid:101) denote the index of the first element of the span. Using the technique of Greve et al. [25], a mode of the span and its frequency are computed by finding the successor of j in Fi; this can be achieved in O(log log n) time by an O(n)-space data structure (e.g., a van Emde Boas tree [15, 17, 16] or a y-fast trie [37]). By Lemma 4, determining whether the frequency of an element in the prefix or suffix exceeds that of the mode of the span requires only constant time per element, or O(s) total time. The resulting worst-case query time is O(s + log log n) using O(n + n · m/s) space. Choosing s ∈ Θ(m) gives O(n) space and O(m + log log n) query time. n)). 4.3 Counting Method: O(j − i) Query Time and O(n) Space We briefly describe an O(j − i)-time and O(n)-space data structure. No actual precomputation is necessary other than constructing the array B, finding k, and initializing a frequency table C[1 : k] to zero, all of which can be achieved in O(n log k) precomputation time. This algorithm is similar to counting sort: compute a frequency table for B[i : j] stored in C[1 : k], then identify a maximum element in C[1 : k]. When computing the maximum, the running time is bounded to O(j − i) by only examining indices in C that correspond to elements in B[i : j] (these are exactly the elements of C that have non-zero values). This procedure is repeated after identifying the maximum to reset C[1 : k] to zero. Each step requires Θ(j − i) time and the total space required by the data structure is O(n). 5 Higher Dimensions A natural question is whether our results for one-dimensional range mode query extend to arbitrary dimen- sions. The array B[1 : n] is replaced by a d-dimensional array B[1 : n1, . . . , 1 : nd], containing n elements in total with dimensionality n1, . . . , nd, where n = n1 × ··· × nd. Within Section 5 we refer to a d-dimensional tuple (e.g., (cid:126)i = [i1, . . . , id]) as an array index (e.g., B[(cid:126)i]). We say a tuple (cid:126)i dominates another tuple (cid:126)j if and only if it ≤ jt for all t ∈ {1, . . . , d}. We denote the input array as B[(cid:126)1 : (cid:126)n], where (cid:126)n = [n1, . . . , nd]. A range is defined over a d-dimensional rectangle of indices, uniquely determined by two indices, [(cid:126)i : (cid:126)j], where (cid:126)i ≤ (cid:126)j. A key element of our one-dimensional data structures is the use of frequency tables. In d dimensions, array C[1 : k] is a frequency table for B[(cid:126)a : (cid:126)b] if, for each i ∈ {1, . . . , k}, C[i] stores the number of occurrences of element B[(cid:126)x] = i in B[(cid:126)a : (cid:126)b]. Unlike the one-dimensional case, if C(cid:126)i[1 : k] is a frequency table for B[(cid:126)1 : (cid:126)i] and C(cid:126)j[1 : k] is a frequency table for B[(cid:126)1 : (cid:126)j], then C(cid:126)j[B[(cid:126)x]]− C(cid:126)i[B[(cid:126)x]] is not the frequency of B[(cid:126)x] in B[(cid:126)i : (cid:126)j] in general. In one dimension, (cid:126)i dominates all indices that are to be excluded from the count, whereas this is not the case in higher dimensions. Instead, the 2d corners of the d-rectangle [(cid:126)i : (cid:126)j] can be used to compute the frequency table with typical inclusion-exclusion rules [14]. The result is computed using 2d d-directional range counting queries to determine the frequency of B[(cid:126)x] in B[(cid:126)a : (cid:126)b]. In the range searching literature it is typical to assume d to be a small known constant and for the corresponding factors of d to be omitted from the evaluation of space and time requirements. to the cardinality of the query range [(cid:126)i : (cid:126)j]: O((cid:81)d Counting Method. The counting method described in Section 4.3 does not depend on any properties of one-dimensional data and extends to d-dimensional data and queries. The query time is directly proportional l=1(jl − il + 1)). Precomputation time, query time, and space requirements are analogous to those of the one-dimensional data structure. Sparse Frequency Table Method. We now consider a generalization to d dimensions of the sparse frequency table method described in Section 4.1. As in the one-dimensional data structure, for every (cid:126)t ∈ T we precompute a frequency table C(cid:126)t[1 : k] for the range B[(cid:126)1 : (cid:126)t], where T ⊆ [(cid:126)1 : (cid:126)n] is a fixed subset of indices. 7 If T is a sparse set whose elements are distributed regularly across [(cid:126)1, (cid:126)n], then a frequency table for the span can be computed in O(2dk) time and O(n) space using the inclusion-exclusion principle. The remainder of the query algorithm consists of examining each index (cid:126)w in the enclosing set W = [(cid:126)i : (cid:126)j] \ [(cid:126)bi : (cid:126)bj] (known as the suffix and prefix in the one-dimensional case) and incrementing the corresponding frequency count C[B[ (cid:126)w]]. Finally, the maximum value of the frequency table C determines the frequency of the mode; this maximum is identified in O(k) time. Therefore, the total query time is O(2dk + W). The regular positioning of the indices in T forms a d-dimensional grid that divides B[(cid:126)1 : (cid:126)n] evenly into T cells, each of which is a d-rectangle of cardinality s = n/T. Each frequency table has size k. In order for the space occupied by the frequency tables to remain linear there can be at most O(n/k) such tables (e.g., let T = (cid:100)n/k(cid:101) and s = k). We set the width of each cell in the l dimension to be O(nl(k/n) 1 d ). Observe d = k. Since there are s = k items in a cell, the number of items on the cell's surface that (cid:81)d l=1 nl(k/n) 1 perpendicular to dimension l is (cid:18) k (cid:16) n d(cid:19) (cid:17) 1 O nl k (cid:32) = O k d−1 d d n 1 nl (cid:33) . Observe that W is at most s times the number of cells on the external surfaces of the d-rectangle specified by the query range [(cid:126)i,(cid:126)j]. The total number of items on the external surface perpendicular to some dimension l ∈ {1, . . . , d} is O(n/nl). Thus the number of cells on that external surface is nl k d ) = O(d· n d−1 d−1 d k 1 d 1 d−1 d = O nl n 1 d ), resulting in a total query time of O(2dk + d· n k . Therefore, W ∈ O(d· k(n/k) d ). If k is constant, then the query time can be improved to O(2dk) using O(n · k) space by including a frequency table for every item in B. d−1 d k 1 (cid:18) n O (cid:19) (cid:18)(cid:16) n d (cid:19) (cid:17) d−1 Sparse Mode Table Method. The sparse mode table method described in Section 3 and the sparse frequency table method both specify a subset T of indices positioned at regular intervals for which any pair determines a span within the array B. Instead of storing frequencies for all elements in D, however, the sparse mode table method stores a precomputed mode of the span between any two indices in T . The mode of the query range is then found by searching for elements in the prefix and suffix whose frequency exceeds that of the mode of the span. √ This data structure exemplifies the space-time trade-off. The O( n) query time and O(n) space bounds of the one-dimensional data structure are possible because the cardinality of the prefix and suffix can be kept small while minimizing the time required to measure the frequency of elements in the prefix and suffix. In particular, the one-dimensional data structure supports a constant-time query to determine whether the frequency of a given element exceeds that of the mode of the span. This is achieved by referring to the arrays Q1, . . . , Qk. These arrays, however, do not generalize easily to higher dimensions. A corresponding decision query would be: "Does element B[(cid:126)x] occur at least m times in the block B[(cid:126)i : (cid:126)j]?" Replacing the arrays Q1, . . . , Qk with orthogonal range counting data structures answers the query: "How frequently does element B[(cid:126)x] occur in the block B[(cid:126)i : (cid:126)j]?" A range counting query computed using kd-trees gives a linear-space data structure with O(Q[B[(cid:126)x]]1− 1 d ) query time [31]. Bentley and Mauer [5] describe a linear-space data structure with a faster query time of O(Q[B[(cid:126)x]]) for any fixed  < 1, where the time and space bounds omit constant factors of . As in Section 5, let W denote the enclosing set of indices, (i.e., the indices of the query range not contained in the span). Let DW denote the set of distinct elements contained in W . Thus the range mode query time is1 (cid:41)(cid:33) (cid:16) (cid:110) d ,W(cid:111)(cid:17) d−1 O max Q[u] d−1 d ,W ⊆ O max n . (1) (cid:32) (cid:40) (cid:88) u∈DW 1Our data structure includes kd-trees. In the corresponding analysis of Lee and Wong [31], d is assumed to be constant; consequently, constants dependent upon d do not appear in (1). 8 Maintaining linear space requires that Θ(T) = Θ(s) = Θ( √ in the l dimension to be O( The arrays S and S(cid:48) respectively store a mode and frequency of the span B[(cid:126)bi : (cid:126)bj] for all {(cid:126)bi, (cid:126)bj} ⊆ T . n). We set the number of elements per cell nl). Thus the number of elements on the surface of the cell perpendicular to the l dimension is O((cid:112)n/nl). The total number of elements on the external surface perpendicular to some dimension l ∈ {1, . . . , d} is O(n/nl). Thus the number of cells on the external surface is O((n/nl)(cid:112)nl/n) = O((cid:112)n/nl). Therefore, √ (cid:32) W ∈ O n (cid:33) d(cid:88) l=1 1√ nl . (2) If all values nl are equal, then (2) simplifies to O(d · n1− 1 2d ). 6 Discussion and Directions for Future Research Generalizing Mode. The sparse frequency table and counting methods described in Sections 4.1 and 4.3, respectively, can be generalized to return the xth most frequently occurring element in the query range A[i : j] for any x ∈ {1, . . . , k} by employing a linear-time (O(min{k,j− i}) time) selection algorithm to find the xth largest element in the frequency table for A[i : j]. Due to its dependence on precomputed modes stored in array S, an analogous generalization seems unlikely without a significant increase in space for the sparse mode table method described in Section 3. √ Open Problem 1 Given a list of A[1 : n] of n items, construct an O(n)-space data structure for identifying n) query time, where i, j, and x are the xth most frequently occurring element in the range A[i : j] with O( provided at query time. Dynamic Range Mode Query. Prior discussion has been restricted to static data structures for range mode query. Dynamically updating the list of items is a natural operation: A[i] ← x. Unlike the range median query problem for which dynamic data structures exist [10, 9, 24, 28], none of the previous data structures for range mode query [7, 30, 25, 33, 34] support efficient updates. We briefly discuss some of the challenges of making our data structures dynamic. Both the sparse frequency table and counting methods described in Sections 4.1 and 4.3, respectively, permit straightforward constant-time updates when the set of distinct elements, D, remains unchanged. Updates that modify D, however, require careful consideration. A key issue in defining dynamic data structures analogous to the static data structures described in this paper is to generalize the mapping defined by array B (see Section 3) to support efficient updates. We have preliminary results demonstrating that such updates are possible for implementing a dynamic version of the counting method. As the data structure for the sparse frequency method is currently specified, however, updates that modify D require Θ(n) time in the worst case. The sparse mode table method described in Section 3 does not suggest itself as a good candidate for efficient updates. In particular, the table S requires Θ(n) updates in the worst case, even if D remains unchanged. Also challenging is the problem of updating the arrays Q1, . . . , Qk. Each set Qx is stored as a sorted array to enable direct indexing, resulting in Θ(n) update time in the worst case. Thus, the problem of defining an efficient dynamic range mode query data structure remains open. Open Problem 2 Given an array A[1 : n] of n items, construct a dynamic data structure that supports efficient range mode queries and updates. Geometric Range Mode Query. The range mode problem has a natural definition in Euclidean space: Open Problem 3 Given a multiset P of n points in Rd, construct a data structure to support queries that return a mode of P ∩ R for an arbitrary (orthogonal) query range R ⊆ Rd. What is the time complexity of such a range query for a given space bound? 9 Interpreted differently, an instance of Problem 3 is a set of points P (cid:48) ⊆ Rd, such that each point p ∈ P (cid:48) is assigned a colour. In this case, the mode of R ∩ P (cid:48) is the most frequently occuring colour in the query region. As discussed in Section 2, when d = 1, this problem reduces to range mode query on an array. When d ≥ 2, however, solution techniques tend to differ extensively for range searching problems set in continuous Euclidean space versus those restricted to array input. A range reporting query can be combined with a mode-finding algorithm (e.g., the counting method described in Section 4.3) to identify the multiset of points within the query range and then compute its mode. Such a solution requires enumerating all elements in the query range, possibly resulting in poor query time (e.g., when R ∩ P ∈ Θ(P)). A more ingenious solution might reduce query time by avoiding the use of a range report query. Other than a basic combination approach such as that described above, the range mode query problem in the continuous setting remains open. Lower Bounds. Recently, Greve et al. [25] showed that any data structure that uses s memory cells of w bits requires Ω(log n/ log(s · w/n)) time to answer a range mode query. For linear-space data structures in the RAM model, s · w ∈ Θ(n log n), corresponding to a lower bound of Ω(log n/ log log n) query time. Other than the bound of Greve et al. and the lower bounds on the problem of computing a mode of a multiset (see Section 2), little is known regarding non-trivial lower bounds for the time complexity of the range mode √ query problem. In particular, it is unknown whether there exists a linear-space data structure that supports o( n) query time. Open Problem 4 Identify a function f (n) such that any O(n)-space data structure that supports range mode query on an array of n items requires Ω(f (n)) query time in the worst case, where f (n) ∈ ω(log n/ log log n), or provide an O(n)-space data structure that supports O(log n/ log log n)-time queries. The corresponding question for range selection query was recently solved by Jørgensen and Larsen [29] who showed a lower bound of Ω(log r/ log log n) and a linear-space data structure with O(log r/ log log n + log log n) query time, where r denotes the rank of the selection query. Acknowledgements. The authors thank Peyman Afshani, Timothy Chan, Francisco Claude, Meng He, Ian Munro, Patrick Nicholson, Matthew Skala, and Norbert Zeh for discussing various topics related to range searching. References [1] P. K. Agarwal. Range searching. In J. Goodman and J. O'Rourke, editors, Handbook of Discrete and Computational Geometry, pages 809 -- 837. CRC Press, New York, 2nd edition, 2004. [2] N. Alon and B. Schieber. Optimal preprocessing for answering on-line product queries. Technical Report 71/87, Tel-Aviv University, 1987. [3] A. Amir, J. Fischer, and M. Lewenstein. Two-dimensional range minimum queries. In Proceedings of the Symposium on Combinatorial Pattern Matching (CPM), volume 4580 of Lecture Notes in Computer Science, pages 286 -- 294. Springer, 2007. [4] M. A. Bender and M. Farach-Colton. The LCA problem revisited. In Proceedings of the Latin American Theoretical Informatics Symposium (LATIN), volume 1776 of Lecture Notes in Computer Science, pages 88 -- 94. Springer, 2000. [5] J. L. Bentley and H. A. Maurer. Efficient worst-case data structures for range searching. Acta Infor- matica, 13(2):155 -- 168, 1980. [6] O. Berkman, D. Breslauer, Z. Galil, B. Schieber, and U. Vishkin. Highly parallelizable problems. In Proceedings of the ACM Symposium on the Theory of Computing (STOC), pages 309 -- 319, 1989. 10 [7] P. Bose, E. Kranakis, P. Morin, and Y. Tang. Approximate range mode and range median queries. In Proceedings of the International Symposium on Theoretical Aspects of Computer Science (STACS), volume 3404 of Lecture Notes in Computer Science, pages 377 -- 388. Springer, 2005. [8] G. S. Brodal, P. Davoodi, and S. S. Rao. On space efficient two dimensional range minimum data In Proceedings of the European Symposium on Algorithms (ESA), volume 6346/6347 of structures. Lecture Notes in Computer Science. Springer, 2010. [9] G. S. Brodal, B. Gfeller, A. G. Jørgensen, and P. Sanders. Towards optimal range medians. Theoretical Computer Science, 2011. In press. [10] G. S. Brodal and A. G. Jørgensen. Data structures for range median queries. In Proceedings of the International Symposium on Algorithms and Computation (ISAAC), volume 5878 of Lecture Notes in Computer Science, pages 822 -- 831. Springer, 2009. [11] T. Chan and M. Patra¸scu. Counting inversions, offline orthogonal range counting, and related problems. In Proceedings of the ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 161 -- 173, 2010. [12] B. Chazelle and B. Rosenberg. Computing partial sums in multidimensional arrays. In Proceedings of the ACM Symposium on Computational Geometry (SoCG), pages 131 -- 139, 1989. [13] E. D. Demaine, G. M. Landau, and O. Weimann. On Cartesian trees and range minimum queries. In Proceedings of the International Colloquium on Automata, Languages, and Programming (ICALP), volume 5555 of Lecture Notes in Computer Science, pages 341 -- 353. Springer, 2009. [14] V. Dujmovi´c, J. Howat, and P. Morin. Biased range trees. In Proceedings of the ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 486 -- 495, 2009. [15] P. van Emde Boas. Preserving order in a forest in less than logarithmic time. In Proceedings of the IEEE Symposium on Foundations of Computer Science, pages 75 -- 84, 1975. [16] P. van Emde Boas. Preserving order in a forest in less than logarithmic time and linear space. Infor- mation Processing Letters, 6(3):80 -- 82, 1977. [17] P. van Emde Boas, R. Kaas, and E. Zijlstra. Design and implementation of an efficient priority queue. Mathematical Systems Theory, 10:99 -- 127, 1976. [18] J. Fischer. Optimal succinctness for range minimum queries. In Proceedings of the Latin American Theoretical Informatics Symposium (LATIN), volume 6034 of Lecture Notes in Computer Science, pages 158 -- 169. Springer, 2010. [19] J. Fischer and V. Heun. Theoretical and practical improvements on the RMQ-problem, with applications to LCA and LCE. In Proceedings of the Symposium on Combinatorial Pattern Matching (CPM), volume 4009 of Lecture Notes in Computer Science, pages 36 -- 48. Springer, 2006. [20] J. Fischer and V. Heun. A new succinct representation of RMQ-information and improvements in the enhanced suffix array. In Proceedings of the International Symposium on Combinatorics, Algorithms, Probabilistic and Experimental Methodologies (ESCAPE), volume 4614 of Lecture Notes in Computer Science, pages 459 -- 470. Springer, 2007. [21] J. Fischer and V. Heun. Finding range minima in the middle: Approximations and applications. Mathematics in Computer Science, 3(1):17 -- 30, 2010. [22] H. N. Gabow, J. L. Bentley, and R. E. Tarjan. Scaling and related techniques for geometry problems. In Proceedings of the ACM Symposium on the Theory of Computing (STOC), pages 135 -- 143, 1984. 11 [23] T. Gagie, S. J. Puglisi, and A. Turpin. Range quantile queries: Another virtue of wavelet trees. In Proceedings of the String Processing and Information Retrieval Symposium (SPIRE), volume 5721 of Lecture Notes in Computer Science, pages 1 -- 6. Springer, 2009. [24] B. Gfeller and P. Sanders. Towards optimal range medians. In Proceedings of the International Collo- quium on Automata, Languages, and Programming (ICALP), volume 5555 of Lecture Notes in Computer Science, pages 475 -- 486. Springer, 2009. [25] M. Greve, A. G. Jørgensen, K. D. Larsen, and J. Truelsen. Cell probe lower bounds and approxima- tions for range mode. In Proceedings of the International Colloquium on Automata, Languages, and Programming (ICALP), volume 6198 of Lecture Notes in Computer Science, pages 605 -- 616. Springer, 2010. [26] S. Har-Peled and S. Muthukrishnan. Range medians. In Proceedings of the European Symposium on Algorithms (ESA), volume 5193 of Lecture Notes in Computer Science, pages 503 -- 514. Springer, 2008. [27] J. J´aJ´a, C. W. Mortensen, and Q. Shi. Space-efficient and fast algorithms for multidimensional dom- inance reporting and counting. In Proceedings of the International Symposium on Algorithms and Computation (ISAAC), volume 3341 of Lecture Notes in Computer Science, pages 558 -- 568. Springer, 2004. [28] A. G. Jørgensen. Data Structures: Sequence Problems, Range Queries, and Fault Tolerance. PhD thesis, Aarhus University, 2010. [29] A. G. Jørgensen and K. D. Larsen. Range selection and median: Tight cell probe lower bounds and adaptive data structures. In Proceedings of the ACM-SIAM Symposium on Discrete Algorithms (SODA), 2011. To appear. [30] D. Krizanc, P. Morin, and M. Smid. Range mode and range median queries on lists and trees. Nordic Journal of Computing, 12:1 -- 17, 2005. [31] D. T. Lee and C. K. Wong. Worst-case analysis for region and partial region searches in multidimensional binary search trees and balanced quad trees. Acta Informatica, 9(1):23 -- 29, 1977. [32] J. I. Munro and M. Spira. Sorting and searching in multisets. SIAM Journal on Computing, 5(1):1 -- 8, 1976. [33] H. Petersen. Improved bounds for range mode and range median queries. In Proceedings of the Con- ference on Current Trends in Theory and Practice of Computer Science (SOFSEM), volume 4910 of Lecture Notes in Computer Science, pages 418 -- 423. Springer, 2008. [34] H. Petersen and S. Grabowski. Range mode and range median queries in constant time and sub-quadratic space. Information Processing Letters, 109:225 -- 228, 2009. [35] C. K. Poon. Optimal range max datacub for fixed dimensions. In Proceedings of the International Conference on Database Theory (ICDT), volume 2572 of Lecture Notes in Computer Science, pages 158 -- 172. Springer, 2003. [36] S. Skiena. The Algorithm Design Manual. Springer, 2nd edition, 2008. [37] D. E. Willard. Log-logarithmic worst-case range queries are possible in space Θ(N ). Information Processing Letters, 17:81 -- 84, 1983. [38] A. C. Yao. Space-time tradeoff for answering range queries. In Proceedings of the ACM Symposium on the Theory of Computing (STOC), pages 128 -- 136, 1982. [39] A. C. Yao. On the complexity of maintaining partial sums. SIAM Journal on Computing, 14:277 -- 288, 1985. 12 [40] H. Yuan and M. J. Atallah. Data structures for range minimum queries. In Proceedings of the ACM- SIAM Symposium on Discrete Algorithms (SODA), pages 150 -- 160, 2010. 13
1503.03155
3
1503
2016-12-15T20:03:08
Computing Heat Kernel Pagerank and a Local Clustering Algorithm
[ "cs.DS" ]
Heat kernel pagerank is a variation of Personalized PageRank given in an exponential formulation. In this work, we present a sublinear time algorithm for approximating the heat kernel pagerank of a graph. The algorithm works by simulating random walks of bounded length and runs in time $O\big(\frac{\log(\epsilon^{-1})\log n}{\epsilon^3\log\log(\epsilon^{-1})}\big)$, assuming performing a random walk step and sampling from a distribution with bounded support take constant time. The quantitative ranking of vertices obtained with heat kernel pagerank can be used for local clustering algorithms. We present an efficient local clustering algorithm that finds cuts by performing a sweep over a heat kernel pagerank vector, using the heat kernel pagerank approximation algorithm as a subroutine. Specifically, we show that for a subset $S$ of Cheeger ratio $\phi$, many vertices in $S$ may serve as seeds for a heat kernel pagerank vector which will find a cut of conductance $O(\sqrt{\phi})$.
cs.DS
cs
Computing Heat Kernel Pagerank and a Local Clustering Algorithm(cid:63) Fan Chung and Olivia Simpson University of California, San Diego La Jolla, CA 92093 {fan,_osimpson}@ucsd.edu Abstract. Heat kernel pagerank is a variation of Personalized PageR- ank given in an exponential formulation. In this work, we present a sub- linear time algorithm for approximating the heat kernel pagerank of a graph. The algorithm works by simulating random walks of bounded length and runs in time O( log(−1) log n 3 log log(−1) ), assuming performing a random walk step and sampling from a distribution with bounded support take constant time. The quantitative ranking of vertices obtained with heat kernel pagerank can be used for local clustering algorithms. We present an efficient local clustering algorithm that finds cuts by performing a sweep over a heat kernel pagerank vector, using the heat kernel pagerank approximation algorithm as a subroutine. Specifically, we show that for a subset S of √ Cheeger ratio φ, many vertices in S may serve as seeds for a heat kernel pagerank vector which will find a cut of conductance O( φ). Keywords: Heat kernel pagerank, heat kernel, local algorithms 1 Introduction In large networks, many similar elements can be identified to a single, larger entity by the process of clustering. Increasing granularity in massive networks through clustering eases operations on the network. There is a large literature on the problem of identifying clusters in a graph ([8,37,34,20,28,29]), and the problem has found many applications. However, in a variation of the graph clustering problem we may only be interested in a single cluster near one element in the graph. For this, local clustering algorithms are of greater use. As an example, the problem of finding a local cluster arises in protein net- works. A protein-protein interaction (PPI) network has undirected edges that represent an interaction between two proteins. Given two PPI networks, the goal of the pairwise alignment problem is to identify an optimal mapping between the networks that best represents a conserved biological function. In [27], a local clustering algorithm is applied from a specified protein to identify a group sim- ilar to that protein. Such local alignments are useful for analysis of a particular (cid:63) An extended abstract appeared in [12]. 6 1 0 2 c e D 5 1 ] S D . s c [ 3 v 5 5 1 3 0 . 3 0 5 1 : v i X r a 2 Chung and Simpson component of a biological system (rather than at a systems level which will call for a global alignment). Local clustering is also a common tool for identifying communities in a network. A community is loosely defined as a subset of vertices in a graph which are more strongly connected internally than to vertices outside the subset. Properties of community structure in large, real world networks have been studied in [25], for example, where local clustering algorithms are employed for identifying communities of varying quality. The goal of a local clustering algorithm is to identify a cluster in a graph near a specified vertex. Using only local structure avoids unnecessary computation over the entire graph. An important consequence of this are running times which are often in terms of the size of the small side of the partition, rather than of the entire graph. The best performing local clustering algorithms use probability diffusion processes over the graph to determine clusters (see Section 1.1). In this paper we present a new algorithm which identifies a cut near a specified vertex with simple computations over a heat kernel pagerank vector. The theory behind using heat kernel pagerank for computing local clusters has been considered in previous work. Here we give an efficient approximation algorithm for computing heat kernel pagerank. Note that we use a "relaxed" notion of approximation which allows us to derive a sublinear probabilistic ap- proximation algorithm for heat kernel pagerank, while computing an exact or sharp approximation would require computation complexity of order similar to matrix multiplication. We use this sublinear approximation algorithm for effi- cient local clustering. 1.1 Previous work Heat kernel and approximation of matrix exponentials. Heat kernel pagerank was first introduced in [9] as a variant of personalized PageRank [18]. While PageRank can be viewed as a geometric sum of random walks, the heat kernel pagerank is an exponential sum of random walks. An alternative interpretation of the heat kernel pagerank is related to the heat kernel of a graph as the funda- mental solution to the heat equation. As such, it has connections with diffusion and mixing properties of graphs and has been incorporated into a number of graph algorithmic primitives. Orecchia et al. use a variant of heat kernel random walks in their random- ized algorithm for computing a cut in a graph with prescribed balance con- straints [35]. A key subroutine in the algorithm is a procedure for computing e−Av for a positive semidefinite matrix A and a unit vector v in time O(m) for graphs on n vertices and m edges. They show how this can be done with a small number of computations of the form A−1v and applying the Spielman-Teng linear solver [38]. Their main result is a randomized algorithm that outputs a balanced cut in time O(m polylog n). In a follow up paper, Sachdeva and Vishnoi [36] reduce inversion of positive semidefinite matrices to matrix exponentiation, thus proving that matrix exponentiation and matrix inversion are equivalent to poly- log factors. In particular, the nearly-linear running time of the balanced separator algorithm depends upon the nearly-linear time Spielman-Teng solver. Computing Heat Kernel Pagerank 3 Another method for approximating matrix exponentials is given by Kloster and Gleich in [22]. They use a Gauss-Southwell iteration to approximate the Taylor series expansion of the column vector eP ec for transition probability matrix P and ec a standard basis vector. The algorithm runs in sublinear time assuming the maximum degree of the network is O(log log n). Local clustering. Local clustering algorithms were introduced in [38], where Spiel- man and Teng present a nearly-linear time algorithm for finding local partitions with certain balance constraints. Let Φ(S) denote the cut ratio of a subset S that we will later define as the Cheeger ratio. Then, given a graph and a subset of vertices S such that Φ(S) < φ and vol(S) ≤ vol(G)/2, their algorithm finds a set of vertices T such that vol(T ) ≥ vol(S)/2 and Φ(T ) ≤ O(φ1/3 logO(1) n) in time O(m(log n/φ)O(1)). This seminal work incorporates the ideas of Lov´asz and Simonovitz [30,31] on isoperimetric properties of random walks, and their algorithm works by simulating truncated random walks on the graph. Spielman and Teng later improve their approximation guarantee to O(φ1/2 log3/2 n) in a revised version of the paper [39]. The algorithm of [38,39] improves the spectral methods of [14] and a similar expression in [1] which use an eigenvector of the graph Laplacian to partition the vertices of a graph. However, the local approach of Spielman and Teng allows us to identify focused clusters without investigating the entire graph. For this reason, the running time of this and similar local algorithms are proportional to the size of the small side of the cut, rather than the entire graph. Andersen et al. [3] give an improved local clustering algorithm using approx- imate PageRank vectors. For a vertex subset S with Cheeger ratio φ and volume k, they show that a PageRank vector can be used to find a set with Cheeger ratio O(φ1/2 log1/2 k). Their local clustering algorithm runs in time O(φ−1m log4 m). The analysis of the above process was strengthened in [2] and emphasized that vertices with higher PageRank values will be on the same side of the cut as the starting vertex. Andersen and Peres [4] later simulate a volume-biased evolving set process to find sparse cuts. Although their approximation guarantee is the same as that of [3], their process yields a better ratio between the computational complex- ity of the algorithm on a given run and the volume of the output set. They call this value the work/volume ratio, and their evolving set algorithm achieves an expected ratio of O(φ−1/2 log3/2 n). This result is improved by Gharan and Trevisan in [16] with an algorithm that finds a set of conductance at most O(−1/2φ1/2) and achieves a work/volume ratio of O(ς φ−1/2 log2 n) for tar- get volume ς and target conductance φ. The complexity of their algorithm is achieved by running copies of an evolving set process in parallel. 1.2 Our contributions In this paper, we give a probabilistic approximation algorithm for computing a vector that yields a ranking of vertices close to the heat kernel pagerank vector. 4 Chung and Simpson The approximation algorithm, ApproxHKPRseed, works by simulating random walks and computing contributions of these walks for each vertex in the graph. Assuming access to a constant-time query which returns the destination of a heat kernel random walk starting from a specified vertex, ApproxHKPRseed runs in time O( log(−1) log n 3 log log(−1) ). In the context of this paper, we strictly address heat kernel pagerank with a single vertex as a seed – an analogy to Personalized PageRank with total preference given to a single vertex. Note that heat kernel pagerank with a general preference vector (see Section 2) is a combination of heat kernel pagerank with a single seed vertex. We refer the reader to [13] for this more general case. Using ApproxHKPRseed as a subroutine, we then present a local clustering algorithm that uses a ranking according to an approximate heat kernel pager- ank. Let G be a graph and S a proper vertex subset with volume ς ≤ vol(G)/4 and Cheeger ratio Φ(S) ≤ φ. Then, with probability at least 1 − , our algo- rithm outputs either a cutset T with vol(T ) ≥ vol(S)/2 and ς-local Cheeger √ φ) or a certificate that no such set exists. The algorithm has ratio at most O( work/volume ratio of O(ς−1−3 log n log(−1) log log(−1)). This result is formal- ized in Theorem 4. A summary of previous results and our contributions are given in Table 1. Algorithm Conductance of output set [39] [3] [4] [16] This work O(φ1/2 log3/2 n) O(φ1/2 log1/2 n) O(φ1/2 log1/2 n) O(−1/2φ1/2) O(φ1/2) Work/volume ratio O(φ−2 polylog n) O(φ−1 polylog n) O(φ−1/2 polylog n) O(ς φ−1/2 polylog n) O(ς−1−3 log n log(−1) log log(−1)) Table 1: Summary of local clustering algorithms As a summary of the contributions of this work, (1) We present an algorithm for computing a heat kernel pagerank vector from a single seed vertex with (1+) approximation guarantee with high probability in time O( log(−1) log n 3 log log(−1) ). (2) We present a local clustering algorithm which uses a ranking according to heat kernel pagerank. In our clustering algorithm we use the probabilistic approximation algorithm in (1) as a subroutine, which gives a sublinear-time local clustering algorithm. (3) Using the approximation guarantees of (1) and the analysis for (2), we √ present a local clustering algorithm which with high probability returns a set φ), given a target ratio φ, with work/volume with Cheeger ratio at most O( ratio O(ς−1−3 log n log(−1) log log(−1)) where ς is proportional to the vol- ume of the output set. Computing Heat Kernel Pagerank 5 (4) We validate the performance analysis by implementing our algorithms using several real and synthetic graphs as examples. The clusters that were de- rived in these examples using the local clustering algorithm and heat kernel pagerank approximation have Cheeger ratios as guaranteed in Theorem 4. The theory behind finding local cuts with heat kernel pagerank vectors was first presented in [9,10]. Using some of this analysis as a starting point, we provide the algorithm for computing local clusters, called ClusterHKPR. 1.3 Organization The remainder of the paper is organized as follows. First, we give some definitions and useful facts in Section 2. We give a sublinear-time algorithm for approximat- ing heat kernel pagerank in Section 3. In Section 4 we give the analysis justifying our local clustering algorithm, which we present in Section 4.1. Sections 5 and 6 contain experimental results. In both sections, experiments are performed on real data and on synthetic graphs generated with random graph generators. In Section 5 we demonstrate how the rankings obtained using approximate heat kernel pagerank vectors are compared with rankings obtained using exact heat kernel pagerank vectors. In Section 6 we compute local clusters by implementing the ClusterHKPR algorithm. We compare the volume and Cheeger ratio of these clusters to those output by two existing sweep-based local clustering algorithms. The first is by a sweep of an exact heat kernel pagerank [10] to compare the effects of heat kernel pagerank computation, and the second by a PageRank vector [3]. PageRank has a similar expression as heat kernel pagerank except PageRank is a geometric sum whereas heat kernel pagerank can be viewed as an exponential sum. We expect better convergence rates from heat kernel (see Section 2.2). 2 Preliminaries Let G = (V, E) be an undirected graph on n vertices and m edges. We use u ∼ v to denote {u, v} ∈ E. The degree, dv, of a vertex v is the number of vertices u such that u ∼ v. The volume of a set of vertices S ⊆ V is the total degree of its v∈S dv, and the edge boundary of S is the set of edges with one vertex in S and the other outside of S, ∂(S) = {u ∼ v : u ∈ S, v /∈ S}. When discussing the full vertex set, V , we write S ⊆ G and vol(G) = vol(V ). Let f ∈ Rn be a row vector over the vertices of G. Then the support of f is the set of vertices with nonzero values in f , supp(f ) = {u ∈ V : f (u) (cid:54)= 0}. For vertices, vol(S) =(cid:80) a subset of vertices S, we define f (S) =(cid:80) u∈S f (u). 2.1 A local Cheeger inequality The quality of a cut can be measured by the ratio of the number of edges between the two parts of the cut and the volume of the smaller side of the cut. This is 6 Chung and Simpson called the Cheeger ratio of a set, defined by Φ(S) = ∂(S) min(vol(S), vol(V \ S)) . The Cheeger constant of a graph is the minimal Cheeger ratio, Φ(G) = min S⊂G Φ(S). Finally, for a given subset S of a graph G, the local Cheeger ratio is defined Φ∗(S) = min T⊆S Φ(T ). Our local clustering algorithm is derived from a local version of the usual Cheeger inequalities which relate the Cheeger constant of a graph to an eigen- value associated to the graph. Namely, let the normalized Laplacian of a graph be the matrix (cid:32)L = D−1/2(D−A)D−1/2, where D is the diagonal matrix of vertex degrees and A is the unweighted, symmetric adjacency matrix. Also, let (cid:32)LS be −1/2 determined by a subset S of size S= s and define (cid:32)LS = D S where DS and AS are the restricted matrices of D and A with rows and columns indexed by vertices in S. Then the eigenvalues λS := λS,1 ≤ λS,2 ≤ ··· ≤ λS,s of (cid:32)LS are also known as the Dirichlet eigenvalues of S, and are related to Φ∗(S) by the following local Cheeger inequality [10]: (DS − AS)D −1/2 S (Φ∗(S))2 ≤ λS ≤ Φ∗(S). 1 2 (1) The inequality (1) will be used to derive a relationship between a ranking according to heat kernel pagerank and sets with good Cheeger ratios. Details will be given in Section 4. 2.2 Heat kernel and heat kernel pagerank The heat kernel pagerank vector has entries indexed by the vertices of the graph and involves two parameters; a non-negative real value t, representing the tem- perature, and a preference row vector f : V → R, by the following equation: ρt,f = e−t tk k! f P k (2) ∞(cid:88) k=0 (cid:40) where P is the transition probability matrix (P )uv = 1/du 0 if u ∼ v otherwise. When f is a probability distribution, the heat kernel pagerank can be re- garded as the expected distribution of a random walk according to the transition Computing Heat Kernel Pagerank 7 probability matrix P . A starting distribution we will be particularly concerned with is that with all probability initially on a single vertex u, i.e. f = χu where χu is the indicator vector for vertex u. We will denote the heat kernel pagerank vector over this distribution by ρt,u := ρt,χu and refer to u as the seed vertex. The heat kernel of a graph is defined Ht = e−t∆ where ∆ is the Laplace operator ∆ = I − P . Then an alternative definition for heat kernel pagerank is ρt,f = f Ht, and we have that heat kernel pagerank satisfies the heat differential equation ρt,f = −ρt,f (I − P ). ∂ ∂t (3) We can compare the heat kernel pagerank to the personalized PageRank vector, given by prα,f = α ∞(cid:88) (1 − α)kf P k. (4) k=0 In this definition, α is often called the jumping or reset constant, meaning that at any step the random walk may jump to a vertex taken from f with probability α. When f = χu for some u, i.e. preference is given to a single vertex, the random walk is "reset" to the first vertex of the walk, u, with probability α. We note that, compared to the personalized PageRank vector, which can be viewed as a geometric sum, we can expect better convergence rates from the heat kernel pagerank, defined as an exponential sum. 3 Heat Kernel Pagerank Approximation k! f P k for k ∈ [0,∞]. The vector f P k is the distribution after k We begin our discussion of heat kernel pagerank approximation with an obser- vation. Each term in the infinite series defining heat kernel pagerank in (2) is of the form e−t tk random walk steps with starting distribution f . Then, if we perform k steps of a random walk given by transition probability matrix P from starting distribution f with probability pk = e−t tk k! , the heat kernel pagerank vector can be viewed as the expected distribution of this process. This suggests a natural way to approximate the heat kernel pagerank. That is, we can obtain a close approximation to the expected distribution with sufficiently many samples. Our algorithm operates as follows. We perform r random walks to approximate the infinite sum, choosing r large enough to bound the error. We also use the fact that very long walks are performed with small probability. As such, we limit the lengths of our random walks by a finite number K. Both r, K depend on a predetermined error bound . In our analysis we will use the following definition of an -approximate vector. Definition 1. Let G be a graph on n vertices, and let f : V → R be a vector over the vertices of G. Let ρt,f be the heat kernel pagerank vector according to f and t. Then we say that ν ∈ Rn is an -approximate vector of ρt,f if 8 Chung and Simpson 1. for every vertex v ∈ V in the support of ν, (1 − )ρt,f (v) −  ≤ ν(v) ≤ (1 + )ρt,f (v), 2. for every vertex with ν(v) = 0, it must be that ρt,f (v) ≤ . We note that this is a rather coarse requirement for an approximation, but satisfies our needs for local clustering. In the following algorithm, we approx- imate ρt,u by an -approximate vector which we denote by ρt,u. The running time of the algorithm is O( log(−1) log n 3 log log(−1) ). The method and complexity of the algorithm, ApproxHKPRseed, are similar to the ApproxRow algorithm for per- sonalized PageRank given in [7]. ApproxHKPRseed(G, t, u, ) input: a graph G, t ∈ R+, seed vertex u ∈ V , error parameter 0 <  < 1. output: ρ, an -approximation of ρt,u. initialize a 0-vector ρ of dimension n, where n = V r ← 16 K ← c · log(−1) log log(−1) for some choice of contant c 3 log n for r iterations do Start simulate a P random walk from vertex u where k steps are taken with prob- ability e−t tk k! and k ≤ K let v be the last vertex visited in the walk ρ[v] ← ρ[v] + 1 End end for return 1/r · ρ Theorem 1. Let G be a graph and let u be a vertex of G. Then, the algorithm ApproxHKPRseed(G, t, u, )outputs an -approximate vector ρt,u of the heat ker- nel pagerank ρt,u for 0 <  < 1 with probability at least 1 − . The running time of ApproxHKPRseed is O( log(−1) log n 3 log log(−1) ). 3.1 Analysis of the heat kernel pagerank algorithm Our analysis relies on the usual Chernoff bounds as stated below. Lemma 1 ([7]). Let Xi be independent Bernoulli random variables with X = r(cid:80) i=1 Xi. Then, Computing Heat Kernel Pagerank 9 2 rE(X)). 2 rE(X)) 4 rE(X)) 1. for 0 <  < 1, P(X < (1 − )rE(X)) < exp(− 2 2. for 0 <  < 1, P(X > (1 + )rE(X)) < exp(− 2 3. for c ≥ 1, P(X > (1 + c)rE(X)) < exp(− c Proof (Theorem 1). Consider the random variable which takes on value f P k k! for k ∈ [0,∞). The expectation of this random with probability pk = e−t tk variable is exactly ρt,f . Heat kernel pagerank can be understood as a series of distributions of weighted random walks over the vertices, and the weights are related to the number of steps taken in the walk. The series can be computed by simulating this process, i.e., draw k according to pk and compute f P k with sufficiently many random walks of length k. We approximate the infinite sum by limiting the walks to at most K steps. We will take K to be K = log(−1) log log(−1) . These interrupts risk the loss of contribution to the expected value, but can be upper bounded by e−ttK 2 provided that t > K/log K. This is within the error bound for an approximate heat kernel pagerank. If t ≤ K/log K, the expected length of the random walk is K! ≤  ∞(cid:88) k=0 e−ttk k! · k = t < K/log K. Thus we can ignore walks of length more than K while maintaining ρt,u(v)−  ≤ ρt,u(v) ≤ ρt,u(v) for every vertex v. Next we show how many samples are necessary for our approximation vectors. For k ≤ K, our algorithm simulates k random walk steps with probability e−t tk k! . To be specific, for a fixed u, let X v k be the indicator random variable defined by X v k = 1 if a random walk beginning from vertex u ends at vertex v in k steps. Let X v be the random variable that considers the random walk process ending at vertex v in at most k steps. That is, X v assumes the vector X v k with probability e−t tk k! . Namely, we consider the combined random walk (cid:88) k≤K X v = e−t tk k! X v k . Now, let ρ(k)t,u be the contribution to the heat kernel pagerank vector ρt,u of walks of length at most k. The expectation of each X v is ρ(k)t,u(v). Then, by Lemma 1, P(X v < (1 − )ρ(k)t,u(v) · r) < exp(−ρ(k)t,u(v)r2/2) = exp(−(8/)ρ(k)t,u(v) log n) < n−4 for every component with ρt,u(v) > , since then ρ(k)t,u(v) > /2. Similarly, P(X v > (1 + )ρ(k)t,u(v) · r) < exp(−ρ(k)t,u(v)r2/4) = exp(−(4/)ρ(k)t,u(v) log n) < n−2. 10 Chung and Simpson We conclude the analysis for the support of ρt,u by noting that ρt,u = 1 r X v, and we achieve an -multiplicative error bound for every vertex v with ρt,u(v) >  with probability at least 1 − O(n−2). On the other hand, if ρt,u(v) ≤ , by the third part of Lemma 1, P(ρt,u(v) > 2) ≤ n−8/2 . We may conclude that, with high probability, ρt,u(v) ≤ 2. For the running time, we use the assumptions that performing a random walk step and drawing from a distribution with bounded support require constant time. These are incorporated in the random walk simulation, which dominates the computation. Therefore, for each of the r rounds, at most K steps of the = random walk are simulated, giving a total of rK = O (cid:117)(cid:116) O(1) queries. (cid:16) 16 3 log n · (cid:17) log(−1) log log(−1) Remark 1. This bound on K is not tight. However, it is enough to use cK for some small constant c to cluster vertices with -approximate heat kernel pagerank vectors computed with bounded random walks. Regardless, this value O(K) is independent of the size of the graph and never affects the running time. See Section 5 for a futher discussion. Remark 2. We note that the algorithm works for any t, but a good choice of t will be related to the size of the local cluster S and a desirable convergence rate. In particular, the constraints put on t are necessary for our local clustering results, presented in Section 4. The algorithm for efficient heat kernel pagerank computation has promise for a variety of applications. It has been shown in [11] how to apply heat ker- nel pagerank in solving symmetric diagonally dominant linear systems with a boundary condition, for example. 4 Finding Good Local Cuts The premise of the local clustering algorithm is to find a good cut near a specified vertex by performing a sweep over a vector associated to that vertex, which we will specify. Let p : V → R be a probability distribution vector over the vertices of the graph of support size Np = supp(p). Then, consider a probability-per-degree ordering of the vertices where p(v1)/dv1 ≥ p(v2)/dv2 ≥ ··· ≥ p(vNp )/dvNp . Let Si be the set of the first i vertices per the ordering. We call each Si a segment. Then the process of investigating the cuts induced by the segments to find an optimal cut is called performing a sweep over p. In this section we will show how a sweep over a single heat kernel pagerank vector finds local cuts. Specifically, we show that for a subset S with vol(S) ≤ vol(G)/4 and Φ(S) ≤ φ, and for a large number of vertices u ∈ S, performing a √ sweep over the vector ρt,u, where ρt,u is an -approximation of ρt,u, will find a set with Cheeger ratio at most O( φ). Remark 3. Though all the vertices in the support of the vector are sorted to build segments, in practice the sweep will be aborted after the volume of the current Computing Heat Kernel Pagerank 11 segment is larger than the target size. This is the locality of the algorithm, and ensures that the amount of work performed is proportional to the volume of the output set. The ς-local Cheeger ratio of a sweep over a vector ν is the minimum Cheeger ratio over segments Si with volume 0 ≤ vol(Si) ≤ 2ς. Let Φς (ν) the ς-local Cheeger ratio of cuts over a sweep of ν that separates sets of volume between 0 and 2ς. We will use the following bounds for heat kernel pagerank in terms of local Cheeger ratios and sweep cuts to reason that many vertices u can serve as good seeds for performing a sweep. Lemma 2. Let G be a graph and S a subset of vertices of volume ς ≤ vol(G)/4. Then the set of u ∈ S satisfying e−tΦ∗(S) ≤ ρt,u(S) ≤ √ ςe−tΦς (ρt,fS )2/4 1 2 has volume at least ς/2. To proof Lemma 2, we begin with some bounds for heat kernel pagerank in terms of local Cheeger ratios and sweep cuts. For a subset S, define fS to be the following distribution over the vertices, (cid:40) fS(u) = du/vol(S) 0 if u ∈ S otherwise. Then the expected value of ρt,u(S) over u in S is given by: E(ρt,u(S)) = = du vol(S) du ρt,u(S) (χuHt)(S) (cid:88) (cid:88) u∈S vol(S) u∈S = fSHt(S) = ρt,fS (S). (5) We will make use of the following result, given here without proof (see [10]), which bounds the expected value of ρt,u(S) given by (5) in terms of local Cheeger ratios. Lemma 3 ([10]). In a graph G, and for a subset S, the following holds: 1 2 e−tΦ∗(S) ≤ 1 2 e−tλS ≤ ρt,fS (S). Next, we use an upper bound on the amount of probability remaining in S after sufficient mixing. This is an extension of a theorem given in [10]. 12 Chung and Simpson Theorem 2. Let G be a graph and S a subset of vertices with volume ς ≤ vol(G)/4. Then, ρt,fS (S) ≤ √ ςe−tΦς (ρt,fS )2/4. To prove Theorem 2, we define the following for an arbitrary function f : V → R and any integer x with 0 ≤ x ≤ vol(G)/2, f (x) = max T⊆V ×V,T=x f (u, v), f (u, v) = The above definition can be extended to all real values of x, αuvf (u, v), αuv ≤ 1 if u ∼ v, f (x) = max T⊆V ×V,T=x (u,v)∈T (cid:88) u∼v αuv = x. Claim. Let Si be a segment according to a vector f : V → R such that x = vol(Si) and f (v) > 0 for every v ∈ Si. Then Proof. We are considering the maximum over a subset of vertex pairs T of size vol(Si). Since we are only adding values over vertex pairs which are edges in G, this maximum is achieved when (cid:40) f (u)/du, if u ∼ v, 0, otherwise. (cid:88) (u,v)∈T (cid:88) (cid:88) u∈Si (cid:88) (cid:88) u∈Si u∈Si f (x) = f (u) = f (Si). (cid:88) v∼u f (u)/du (cid:88) v∼u f (u) 1/du f (x) = = = f (Si). (cid:117)(cid:116) Proof (Theorem 2). Let Z be the lazy random walk Z = 1/2(I + P ). Then, f Z(S) = 1/2 f (S) + f (u, v) (cid:88) u∼v∈S (cid:17) (cid:88) (cid:17) f (u, v) + = 1/2 ≤ 1/2(f (vol(S) + ∂(S)) + f (vol(S) − ∂(S))) u∨v∈S u∧v∈S f (u, v) = 1/2 f (vol(S)(1 + Φ(S))) + f (vol(S)(1 − Φ(S))) (cid:17) . (cid:16) (cid:16) (cid:88) (cid:16) Let ft = ρt,fS , and let x satisfy 0 ≤ x ≤ 2ς ≤ vol(G)/2 and represent a volume of some set Si. Then taking cue from the above inequality, we can Computing Heat Kernel Pagerank 13 associate S to Si, vol(S) to vol(Si) = x and Φ(S) to the minimum Cheeger ratio of a set Si satisfying vol(Si) = x ≤ 2ς, or Φς (ρt,fS ). Then using Claim 4, ftZ(x) ≤ 1/2(ft(x(1 + Φς (ρt,fS ))) + ft(x(1 − Φς (ρt,fS )))). Now consider the following differential inequality, ft(x) = −ρt,fS (I − W )(x) = −2ρt,fS (I − Z)(x) = −2ft(x) + 2ftZ(x) ≤ −2ft(x) + ft(x(1 + Φς (ρt,fS ))) ∂ ∂t + ft(x(1 − Φς (ρt,fS ))) ≤ 0. (6) (7) (8) (9) Line (6) follows from (3), and line (8) follows from the concavity of f . √ xe−tΦς (ρt,fS )2/4. Then, Consider gt(x) to be gt(x) = (cid:113) (cid:113) − 2gt(x) + gt(x(1 + Φς (ρt,fS ))) + gt(x(1 − Φς (ρt,fS ))) (cid:113) = −2gt(x) + = (−2 + ≤ −Φς (ρt,fS )2 1 − Φς (ρt,fS ))gt(x) 1 + Φς (ρt,fS )gt(x) + 1 + Φς (ρt,fS ) + (cid:113) 1 − Φς (ρt,fS )gt(x) gt(x) 4 = gt(x), ∂ ∂t √ where we use the fact that −2 + ∂t ft(x)t=0≤ ∂ (9). Now, since ft(0) = gt(0) and ∂ 1 + y + √ ∂t gt(x)t=0, 1 − y ≤ −y2/4 for y ∈ (0, 1] in line − 2ft(x) + ft(x(1 + Φς (ρt,fS ))) + ft(x(1 − Φς (ρt,fS ))) < −2gt(x) + gt(x(1 + Φς (ρt,fS ))) + gt(x(1 − Φς (ρt,fS ))), and in particular, ∂ ∂t ft(x) ≤ ∂ ∂t gt(x). Since f0(x) ≤ g0(x), we may conclude that ft(x) ≤ gt(x) = √ xe−tΦς (ρt,fS )2/4. (cid:117)(cid:116) Using Lemma 3 and Theorem 2, we arrive at the following useful inequalities. Corollary 1. Let G be a graph and S a subset with volume ς ≤ vol(G)/4. Then, e−tΦ∗(S) ≤ ρt,fS (S) ≤ √ ςe−tΦς (ρt,fS )2/4. 1 2 We are now prepared to prove Lemma 2. 14 Chung and Simpson Proof (Lemma 2). Let F be the set of seeds F = {u ∈ S : ρt,u(S) ≤ 2ρt,fS (S)}. Then, by (5), F = {u ∈ S : ρt,u(S) ≤ 2E(ρt,u(S))}. Now we consider the set of vertices not included in F , E(ρt,u(S) u /∈ F ) ≥(cid:88) du 2E(ρt,u(S)) vol(S) u /∈F ≥ vol(S \ F ) vol(S) (cid:88) u /∈F 2 E(ρt,u(S)). Which implies vol(S) 2 > vol(S \ F ) or, vol(F ) > ς/2. (cid:117)(cid:116) We can use Lemma 2 to reason that many vertices u satisfy the above in- equalities, and thus can serve as good seeds for performing a sweep. 4.1 A local graph clustering algorithm √ It follows from Lemma 2 that the ranking induced by a heat kernel pagerank vector with appropriate seed vertex can be used to find a cut with approximation guarantee O( φ) by choosing the appropriate t. To obtain a sublinear time local clustering algorithm for massive graphs, we use ApproxHKPRseed to efficiently compute an -approximate heat kernel pagerank vector, ρt,u, to rank vertices. The ranking induced by ρt,u is not very different from that of a true vector ρt,u in the support of ρt,u (for an experimental analysis, see Section 5). Namely, using the bounds of Lemma 3, we have ρt,u(S) ≥ (1 − )ρt,u(S) − s, where s = S. In particular, (1 − )e−tΦ∗(S) − s ≤ ρt,u(S) ≤ √ ςe−tΦς ( ρt,u)2/4 1 2 (10) for a set of vertices u of volume at least ς/2. Theorem 3. Let G be a graph and S ⊂ G a subset with vol(S)= ς ≤vol(G)/4, S= s, and Cheeger ratio Φ(S) ≤ φ. Let ρt,u be an -approximate of ρt,u for some vertex u ∈ S. Then there is a subset St ⊂ S with vol(St)≥ ς/2 for which a sweep over ρt,u for any vertex u ∈ St with √ 1. t = φ−1 log( 2 1− + 2s) and 2. Φς (ρt,u)2 ≤ 4/t log(2) ς finds a set with ς-local Cheeger ratio at most √ 8φ. Computing Heat Kernel Pagerank 15 Proof. Let u be a vertex in St as described in the theorem statement. Using the inequalities (10), we can bound the local Cheeger ratio by a sweep over ρt,u: e−tΦ∗(S) ≤ 2 1 −  ( √ ςe−tΦς ( ρt,u)2/4 + s) which implies e−tΦ∗(S) ≤ e−tΦς ( ρt,u)2/4(cid:16) 2 √ ς 1 −  + setΦς ( ρt,u)2/4(cid:17) , and by the assumption 2, we have e−tΦ∗(S) ≤ e−tΦς ( ρt,u)2/4(cid:16) 2 Φ∗(S) ≥ Φς (ρt,u)2 4 Let x = log( 2 √ 1− + 2s). Then, ς √ ς 1 −  √ − log( 2 1− + 2s) + 2s ς t (cid:17) . Φς (ρt,fS )2 ≤ 4Φ∗(S) + 4x/t. Since Φ∗(S) ≤ Φ(S) ≤ φ and t = φ−1x, it follows that Φς (ρt,u) ≤ √ √ particular, a sweep over ρt,u finds a cut with Cheeger ratio O( is contained in St. 8φ. In φ) as long as u (cid:117)(cid:116) We are now prepared to give our algorithm for finding cuts locally with heat kernel pagerank. The algorithm takes as input a starting vertex u, a desired volume ς for the cut set, and a target Cheeger ratio φ for the cut set. Then, to find a set achieving a minimum ς-local Cheeger ratio, we perform a sweep over an approximate heat kernel pagerank vector with the starting vertex as a seed. 16 Chung and Simpson ς √ 1− + 2s) ClusterHKPR(G, u, s, ς, φ, ) input: a graph G, a vertex u, target cluster size s, target cluster volume ς ≤ vol(G)/4, output: a set T with ς/2 ≤ vol(T ) ≤ 2ς, Φ(T ) ≤ √ target Cheeger ratio φ, error parameter . 1: t ← φ−1 log( 2 2: ρ ← ApproxHKPRseed(G, t, u, ) 3: sort the vertices of G in the support of ρ according to the ranking ρ[v]/dv 4: for j ∈ [1, n] do 5: i≤j vi 6: 7: 8: 9: 10: 11: 12: 13: end for Sj =(cid:83) else if ς/2 ≤ vol(Sj) ≤ 2ς and Φ(Sj) ≤ √ output NO CUT FOUND, break output NO CUT FOUND if vol(Sj) > 2ς then output Sj else end if 8φ. 8φ then Theorem 4. Let G be a graph which contains a subset S of volume at most vol(G)/4 and Cheeger ratio bounded by φ. Further, assume that u is contained in the set St ⊆ S as defined in Theorem 3. Then ClusterHKPR(G, u, s, ς, φ, )outputs a cutset T with ς-local Cheeger ratio at most 8φ. The running time is the same as that of ApproxHKPRseed. √ Proof. Since it is given that u ∈ St for t = φ−1 log( 2 1− + 2s), and by the assumptions on G and S, Theorem 3 states that a sweep over the approximate √ heat kernel pagerank vector ρ will find a set with ς-local Cheeger ratio at most 8φ. The checks performed in line 8 of the algorithm discover such a set. √ ς The computational work reduces to the main procedures of computing the heat kernel pagerank vector in line 2 and performing a sweep over the vec- tor in line 4. Performing a sweep involves sorting the support of the vector (line 3) and calculating the conductance of segments. From the guarantees of an -approximate heat kernel pagerank vector, any vertex with average probabil- ity less than  will be excluded from the support. Then the volume of a vector ρ output in line 2 is O(−1), and performing a sweep over ρ can be done in O(−1 log(−1)) time. The algorithm is therefore dominated by the time to com- pute a heat kernel pagerank vector, and the total running time is O( log(−1) log n 3 log log(−1) ).(cid:117)(cid:116) 5 Ranking Vertices with Approximate Heat Kernel Pagerank The backbone procedure of the local clustering algorithm is the sweep: ranking the vertices of the graph according to their approximate heat kernel pagerank Computing Heat Kernel Pagerank 17 values, and then testing the quality of the cluster obtained by adding vertices one at a time in the order of this ranking. To this end, in this section we compare the rankings of vertices obtained using exact heat kernel pagerank vectors with approximate heat kernel pagerank vectors. Specifically, we consider how accuracy changes as the upper bound of random walk lengths, K, vary. In the following experiments, we approximate heat kernel pagerank vectors by sampling random walks of length min{k, K}, where k is chosen with probability pk = e−t tk k! . We test the values computed with different values of K. Since the expected value of a random walk length k chosen with probability pk = e−t tk k! is t, we set K to range from 1 to approximately t for a specified value of t. In each trial, for a given graph, seed vertex, and value of t, we compute an exact heat kernel pagerank vector ρt,u and an approximate heat kernel pagerank vector ρt,u using ApproxHKPRseed but limiting the length of random walks to K for various K as described above. We then measure how similar the vectors are in two ways. First, we compare the vector values computed. Second, we compare the rankings obtained with each vector. The following are the measures used: 1. Comparing vector values. We measure the error of the approximate vector ρt,u by examining the values computed for each vertex and comparing to an exact vector ρt,u. We use the following measures: – Average L1 error: The average absolute error over all vertices of the graph, average L1 error := 1 n n(cid:88) i=1 ρt,u(vi) − ρt,u(vi). (11) – -error: The accumulated error in excess of an -approximation (see Definition 1), -error := (cid:88) (cid:88) v∈V, ρt,u(v)>0 + v∈V, ρt,u(v)=0 max{ρt,u(v) − ρt,u(v)−ρt,u(v), 0} max{ρt,u(v) − , 0}. (12) 2. Comparing vector rankings. To measure the similarity of vertex rankings we use the intersection difference (see [6,15] among others). For a ranked list of vertices A, let Ai be the set of items with the top i rankings. Then we use the following measures: – Intersection difference: Given two ranked lists of vertices, A and B, each of length n, the intersection difference is intersection difference := dist(A, B) = 1 n n(cid:88) Ai ⊕ Bi 2i i=1 , (13) where Ai ⊕ Bi denotes the symmetric difference (Ai \ Bi) ∪ (Bi \ Ai). 18 Chung and Simpson – Top-k intersection difference: The intersection difference among the top k elements in each ranking, top-k intersection difference := distk(A, B) = k(cid:88) i=1 1 k Ai ⊕ Bi 2i . (14) Intersection difference values lie in the range [0, 1], where a difference of 0 is achieved for identical rankings, and 1 for totally disjoint lists. In these experiments, A is the list of vertices ranked according to an exact heat kernel pagerank vector ρt,u, and B is the list of vertices ranked according to an -approximate heat kernel pagerank vector ρt,u. √ In every trial we choose t = φ−1 log( 2 1− + 2s) as specified in the local clus- tering algorithm stated in Section 4.1. This value depends on several parameters, including desired Cheeger ratio, cluster size, and cluster volume. Specifics are provided for each set of trials. ς 5.1 Synthetic graphs Random graph models In this series of trials we use three different models of random graph generation provided in the NetworkX [17] Python package, which we describe presently. The first is the Watts-Strogatz small world model [41], generated with the command connected_watts_strogatz in NetworkX. In this model, a ring of n vertices is created and then each vertex is connected to its d nearest neightbors. Then, with probability p, each edge (u, v) in the original construction is replaced by the edge (u, w) for a random existing vertex w. The model takes parameters n, d, p as input. The second is the preferential attachment (Barab´asi-Albert) model [5]. Graphs in this model are created by adding n vertices one at a time, where each new vertex is adjoined to d edges where each edge is chosen with probability pro- portional to the degree of the neighboring vertex. This is generated with the barabasi_albert_graph generator in NetworkX. The model takes parameters n, d as input. The third NetworkX generator is powerlaw_cluster_graph, which uses the Holme and Kim algorithm for generating graphs with powerlaw degree distribu- tion and approximate average clustering [19]. It is essentially the Barab´asi-Albert model, but each random edge forms a triangle with another neighbor with prob- ability p. The model takes parameters n, d, p as input. Table 2 lists the random graph models used and their parameters. Procedure For every value of K that we test, we generate ten random graphs using each of the three random graph models. For each graph we choose a random seed vertex u with probability proportional to degree, and we choose t as t = √ φ−1 log( 2 1− + 2s) according to the values in Table 3. Then for each graph we ς Computing Heat Kernel Pagerank 19 Model Source Parameters small world Watts-Stragatz[41] n, the size of the vertex set, d, the number of neighbors each vertex is assigned, p, the probability of switching an edge. preferential Barab´asi-Albert[5] n, the size of the vertex set, attachment powerlaw Holme and Kim [19] n, the size of the vertex set, cluster d, the number of neighbors each vertex is assigned d, the number of neighbors each vertex is assigned, p, the probability of forming a triangle Table 2: Random graph models used. compare an exact heat kernel pagerank vector ρt,u and the average of two - approximate heat kernel pagerank vectors ρt,u. The results we present are the average over all trials for each K and each type of graph. We use d = 5 and p = 0.1 in every trial, and n = 100 for the first set of trials (Figure 1) and n = 500 for the second (Figure 2). These parameters are outlined in Table 3. Model V d p  Target Target Target t Cheeger ratio cluster size cluster volume small world 100 5 500 5 100 5 500 5 100 5 500 5 0.1 0.1 - - 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 84.9 84.9 84.9 preferential 84.9 attachment 84.9 powerlaw 84.9 cluster Table 3: Parameters used for random graph generation and to compute t for vector computations. φ = 0.05 φ = 0.05 φ = 0.05 φ = 0.05 φ = 0.05 φ = 0.05 s = 100 s = 100 s = 100 s = 100 s = 100 s = 100 ς = 500 ς = 500 ς = 500 ς = 500 ς = 500 ς = 500 Discussion For each graph and value of K, we measure the -error, the average L1 error, the intersection difference and the top-10 intersection difference of an approximate heat kernel pagerank vector as compared to an exact heat kernel pagerank vector. Figure 1 plots the above measures for graphs over n = 100 vertices, while Figure 2 plots these measures for graphs over n = 500 vertices. In both Figures 1 and 2, each subplot charts a different notion of error (from top left, clockwise: -error, average L1 error, intersection difference and top-10 intersection difference) on the y-axis against K on the x-axis. In both sets of plots and for every measure of error, we see that in the pref- erential attachment and powerlaw graphs the error is minimized after limiting random walks to only length K = 10, regardless of the size. We observe a shal- lower decline in -error, average L1 error, and intsersection differance for the small world graphs. In particular, we note that the intersection difference drops 20 Chung and Simpson Trials on 100-vertex random graphs. Fig. 1: Different measures of error for random graphs on 100 vertices when ap- proximating heat kernel pagerank with varying random walk lengths. Computing Heat Kernel Pagerank 21 Trials on 500-vertex random graphs. Fig. 2: Different measures of error for random graphs on 500 when approximating heat kernel pagerank with varying random walk lengths. 22 Chung and Simpson significantly after 10 random walk steps for all random graphs on both 100 and 500 vertices. For  = 0.1, K = 4 · the rankings for the purpose of local clustering. log(−1) log log(−1) ≈ 11.04 is enough to approximate 5.2 Real graphs Network data For the experiments in this section, and later in Section 6, we use the following graphs compiled from real data. The network data is summarized in Table 4. 1. (dolphins) A dolphin social network consisting of two families [32]. The seed vertex is chosen to be a prominent member of one of the families. 2. (polbooks) A network of books about US politics published around the time of the 2004 Presidential election and sold on Amazon [23]. Edges represent frequent copurchases. 3. (power) The topology of the US Western States Power Grid [40]. 4. (facebook) A combined collection of Facebook ego-networks, including the ego vertices themselves [26]. 5. (enron) An Enron email communication network [21], in which vertices represent email addresses and an edge (i, j) exists if an address i sent at least one email to address j. Network dolphins polbooks power facebook enron Source E Average degree V 159 62 Dolphins social network [32] 441 105 Copurchases of political books [23] 4941 6594 Power grid topology [40] Facebook ego-networks [26] 4039 88234 Enron communication network [21] 36692 183831 5 8.8 2.7 43.7 10 Table 4: Graphs compiled from real data. The network data for graphs 1, 2, and 3 were taken from Mark Newman's network data collection [33]. The network data for graphs 4 and 5 are from the SNAP Large Network Dataset Collection [24]. ς Procedure In this series of experiments, the seed vertex u was chosen to be a known member of a cluster. As before, t was chosen according to t = √ φ−1 log( 2 1− + 2s) with the values in Table 5. For each graph and for each value of K we compare an exact heat kernel pagerank vector ρt,u with an -approximate heat kernel pagerank vector ρt,u. Specifically, we consider the average L1 distance (11) and the intersection difference (13). We again choose K to range from 1 to t. Computing Heat Kernel Pagerank 23  Target Target Target t Cheeger ratio cluster size cluster volume 0.1 φ = 0.05 s = 100 ς = 1000 95.6 Table 5: Parameters used to compute t for vector computations. Discussion Figure 3 plots the average L1 error on the y-axis against different values of K on the x-axis for each of the dolphins, polbooks, and power graphs. Figure 4 plots the intersection difference on the y-axis against K on the x-axis. Fig. 3: Average error in each component for -approximate heat kernel pagerank vectors when allowing varying random walk lengths. First we discuss the average L1 error. The dolphins and the polbooks graphs exihibit properties of both the small world graphs and the preferential attach- ment graphs of the previous section (Figures 1 and 2). Like the preferential attachment models, there is a significant drop in average L1 error after K = 5, and like the small world model the error continues to drop for larger values of K, approaching a minimum error of ≈ 0.003. The average L1 error in the power graph, on the other hand, is small for all values of K. We remark that, represent- ing a power grid, the graph has very small average vertex degree, so few random walk steps are enough to approximate the stationary distribution. As for the intersection difference, we observe a smaller variance in values for the three graphs. Regardless of the size or structure of the graph, the intersection difference drops sharply from K = 1 to K = 5. For values larger than K = 10 < log(−1) 4· log log(−1) , where  = 0.1, the intersection difference decreases only marginally. The purpose of these experiments was to evaluate how error and differences of ranking change in heat kernel pagerank approximation when varying K, the 24 Chung and Simpson Fig. 4: Intersersection difference of the ranked lists of vertices computed by exact and -approximate heat kernel pagerank vectors when allowing varying random walk lengths. upper bound on number of steps taken in random walks. We found that setting log(−1) an upper bound for random walk lengths to K = 10 < 4· log log(−1) with  = 0.1 according to Theorem 1 yields approximations which satisfy the prescribed error bounds. This value is independent of the size of the graph and t, and depends only on . Namely, we observed that choosing K this way results in a significant decrease in both average L1 error and intersection difference as compared to smaller values of K, and only slight decrease in average L1 error and intersection difference for larger values of K as demonstrated in Figures 1, 2, 3, and 4. Further, we tested graphs of various size, random graphs generated from various models (see Section 5.1), and graphs from real data representing social networks, copurchasing networks, and topological grids (see Section 5.2). We found this choice of K was optimal for every graph regardless of size or structure. That is, the cutoff for random walk lengths does not depend on the size of the graph. It is also worth mentioning that the most striking outlier among the subject graphs is the small world graph, or expander graphs. This is due to the fact that the graph consists of a single cluster, which makes local cluster detection ineffective. 6 An Assessment of Cheeger Ratios Obtained with Local Clustering Algorithms The goal of this section is to analyze the quality of local clusters computed with a sweep over an approximate heat kernel pagerank vector (see Section 4 for details on sweeps). We consider two objectives for analysis. Computing Heat Kernel Pagerank 25 The first objective is to validate the statement of Theorem 4. To do this, we show that the Cheeger ratios of local clusters computed with sweeps over ap- proximate heat kernel pagerank vectors are within the approximation guarantees of Theorem 4. We use a slightly modified version of ClusterHKPR to compute these clusters. We call this modified algorithm HKPR, and it is described in the list below. The second objective is to compare clusters computed with sweeps over dif- ferent vectors. Namely, for a given graph and seed vertex, we compare the local clusters computed using the following sweep algorithms: 1. (HKPR) A sweep over an -approximate heat kernel pagerank vector is performed. The segment S with volume vol(S) ≤ vol(G)/2 of minimal Cheeger ratio is output. This is the ClusterHKPR algorithm with the follow- ing modification: we allow segments of volume up to vol(G)/2 rather than limiting the search to segments of volume < 2ς, twice the target volume. 2. (HKPR) A sweep over an exact heat kernel pagerank vector is performed. The segment S with volume vol(S) ≤ vol(G)/2 of minimal Cheeger ratio is output. This algorithm was outlined, but not stated explicitely, in [10]. 3. (PR) A sweep over a Personalized PageRank vector (4) is performed. The segment S with volume vol(S) ≤ vol(G)/2 of minimal Cheeger ratio is out- put. This is an adaptation of the algorithm PageRank-Nibble[3] with the following modifications: (i) rather than performing a sweep over an approx- imate PageRank vector, perform a sweep over an exact PageRank vector, and (ii) allow segments only as large as vol(G)/2. We summarize the algorithms and parameters below in Table 6. Algorithm Sweep vector Algorithm parameters Sweep vector parameters √ ς 1− + 2s) HKPR ρt,u HKPR PR ρt,u prα,u φ, target Cheeger ratio t = φ−1 log( 2 s, target cluster size u, seed vertex ς, target cluster volume , approximation parameter φ, target Cheeger ratio t = 2φ−1 log s s, target cluster size u, seed vertex φ, target Cheeger ratio α = φ2/255 ln(100 √ m) Table 6: Algorithms used for comparing local clusters. u, seed vertex Each trial will resemble Procedure 1, as stated below. 26 Chung and Simpson Procedure 1 Compare Clusters Let G be a graph and u a seed vertex Choose parameters φ, s, ς,  Let SA be a local cluster computed using the algorithm HKPR Let SB be a local cluster computed using the algorithm HKPR Let SC be a local cluster computed using the algorithm PR Compare SA, SB, SC . The following sections describe the experiments in more detail. 6.1 Synthetic graphs In this section, we use graphs generated with three random graph models: Watts- Strogatz small world, Barab´asi-Albert preferential attachment, and Holme and Kim's powerlaw cluster as described in Section 5.1. Procedure We perform twenty-five trials of Procedure 1 and take the averages of Cheeger ratios and cluster volumes computed. Specifically, we fix a model and algorithm parameters. Then, generate a random graph according to the model and parameters. For each random graph, pick a random seed vertex with probability proportional to degree. Then, for each seed vertex compute local clusters SA, SB, SC using the algorithms HKPR, HKPR, and PR, respectively. We then use the average Cheeger ratio and cluster volume of the SA, SB, SC for comparison. In Table 7 we summarize the parameters used for each random graph model. Model V d p  Target Target Target Cheeger ratio cluster size cluster volume small world preferential attachment powerlaw cluster - - - 100 500 500 500 100 500 500 100 500 500 Table 7: Algorithm parameters used to compare local clusters. 100 5 0.1 0.1 500 5 0.1 0.1 800 5 0.1 0.1 1000 5 0.1 0.1 0.1 100 5 0.1 500 5 800 0.1 5 5 0.1 0.1 100 5 0.1 0.1 500 800 5 0.1 0.1 20 100 100 100 20 100 100 20 100 100 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 Computing Heat Kernel Pagerank 27 Discussion We address the first analytic objective listed in the introduction of this section by discussing the clusters output by HKPR. Namely, we compare the clusters computed with HKPR to the guarantees of Theorem 4. The results for each graph are given in Table 8. The first three columns indicate the ran- dom graph model and algorithm parameters used for each instance. The last two columns demonstrate how the (average) Cheeger ratio of clusters computed by HKPR compare to the approximation guarantee of Theorem 4. Namely, The- 8φ with high probability. In every case the Cheeger ratio is well within the approximation bounds. orem 4 states that the cluster output will have Cheeger ratio ≤ √ Model small world preferential attachment powerlaw cluster V 100 500 800 1000 100 500 800 100 500 800 Synthetic graphs φ, Target Cheeger ratio output by √ 8φ Cheeger ratio 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 HKPR 0.173557 0.47316 0.510597 0.519399 0.523929 0.503542 0.491046 0.517521 0.500312 0.494145 0.894427 0.894427 0.894427 0.894427 0.894427 0.894427 0.894427 0.894427 0.894427 0.894427 Table 8: Cheeger ratios of cluster output by HKPR. The second objective is to compare clusters computed with the three dif- ferent local clustering algorithms HKPR, HKPR, and PR. Table 9 is a col- lection of cluster statistics for the trials. For each graph instance we list the average Cheeger ratio and cluster volume of local clusters computed using the PR, HKPR, and HKPR algorithms, respectively. We remark that for each graph there is little variation in Cheeger ratio and volume of clusters computed by the three different algorithms. We also note that there is no obvious trend as graphs get larger. The small world graphs demonstrate the greatest variation in cluster quality. However, as mentioned in Section 5, expander graphs, such as small world graphs, consist of one large cluster. It is worth noting that in some trials the output volume is significantly greater than twice the target volume. While this may seem like a contradiction, it is a consequence of our implementation. During a sweep one may choose to output a cluster of minimal Cheeger ratio, or one that satisfies volume constraints, or both. We are interested in comparing Cheeger ratios and so allow the sweep to continue checking clusters that are well beyond twice the target volume. 28 Chung and Simpson Model small world preferential attachment powerlaw cluster V 100 500 800 Synthetic graphs PR 0.235159 HKPR 0.087723 HKPR 0.173557 (volume = 52.52) (volume = 171.28) (volume = 142) 0.244261 0.062263 0.47316 (volume = 190.16) (volume = 943.68) (volume = 206.64) 0.246564 0.064599 0.510597 (volume = 162.68) (volume = 1413.6) (volume = 209.6) 1000 0.245612 0.064716 0.519399 100 500 800 100 500 800 (volume = 584.56) (volume = 1907.4) (volume = 225.2) 0.430071 0.512819 0.523929 (volume = 471.2) (volume = 467.16) (volume = 468.16) 0.508305 0.51018 0.503542 (volume = 2461.96) (volume = 2459.4) (volume = 2463.28) 0.491046 0.496369 0.491046 (volume = 3964.17) (volume = 3971.17) (volume = 3951.83) 0.426828 0.505277 0.517521 (volume = 463.4) (volume = 465.44) (volume = 464.88) 0.487341 0.507328 0.500312 (volume = 2447.12) (volume = 2460.44) (volume = 2446.28) 0.522281 0.513365 0.494145 (volume = 3947) (volume = 3966) (volume = 3947) Table 9: Cheeger ratios of clusters output by different local clustering algorithms on synthetic data. Computing Heat Kernel Pagerank 29 6.2 Real graphs For these trials we use graphs generated from real data summarized in Sec- tion 5.2. Procedure We compare clusters computed by each of the three algorithms as outlined in Procedure 1. In these trials we fix the seed vertex to be a member of a cluster with good Cheeger ratio. Using this seed vertex, we compare the clusters computed using the HKPR, HKPR, PR algorithms. For each trial we use the parameters listed in Table 10. We note that in each case the target cluster volume is computed to be roughly the target cluster size times the average vertex degree, and here we use  = 0.1. Network V E Average degree  Target Target Target Cheeger ratio cluster size cluster volume dolphins polbooks power facebook enron Table 10: Graph and algorithm parameters used to compare local clusters. 62 159 105 441 4941 6594 4039 88234 36692 183831 100 270 600 2800 1000 20 30 200 200 100 5 8.8 2.7 43.7 10 0.1 0.1 0.1 0.1 0.1 0.08 0.05 0.05 0.05 0.05 Discussion Table 11 lists ratios output by HKPR compared with the approxi- mation guarantees of Theorem 4. In each case, the Cheeger ratios are well within the approximation bounds of Theorem 4. Network φ, Target Cheeger ratio output by Real graphs Cheeger ratio √ 8φ 0.8 dolphins polbooks power facebook enron 0.632456 0.632456 0.632456 0.632456 Table 11: Cheeger ratios of cluster output ClusterHKPR. 0.08 0.05 0.05 0.05 0.05 HKPR 0.083333 0.052133 0.346667 0.056939 0.036602 The complete numerical data obtained from the set of the trials are given in Table 12. For each graph we list the Cheeger ratio, cluster volume, and addi- tionally the cluster size of local clusters computed using each of the algorithms PR, HKPR, and HKPR, respectively. 30 Chung and Simpson Network dolphins PR 0.226415 HKPR 0.163636 HKPR 0.083333 Real graphs polbooks power facebook (volume = 106) (volume = 110) (volume = 96) (size = 23) 0.079518 (size = 24) 0.245657 (size = 20) 0.052133 (volume = 415) (volume = 403) (volume = 422) (size = 48) 0.375 (size = 49) 0.002764 (size = 50) 0.346668 (volume = 16) (volume = 4342) (volume = 300) (size = 6) 0.418993 (size = 1564) 0.001277 (size = 85) 0.056939 (volume = 88140) (volume = 67326) (volume = 35266) (size = 3063) (size = 1094) (size = 258) enron 0.48797 (volume = 183612) - - 0.036602 (volume = 3579) Table 12: Cheeger ratios of cluster output by different local clustering algorithms. For each graph, the local cluster computed using HKPR has smaller Cheeger ratio than the local cluster computed using PR. For the power graph, we ob- serve that the cluster of minimal Cheeger ratio was computed using the HKPR algorithm, but it is nearly a third the size of the entire network. The algorithms HKPR and PR, on the other hand, each return smaller clusters. We remark that for real graphs, the clusters computed using sweeps over different vectors have more variation than for random graphs. At this point we remark about our choice of parameters for the trials. At this point the sensitivity of the algorithm to the choice of , φ, s, and ς has not been fully explored. In particular, it is worth studying the effect of φ on the output cluster in future work. To conclude, we include visualizations of clusters computed in the facebook ego-network to illustrate the differences in local cluster detection. Figure 5 colors the vertices in a local cluster computed using the HKPR algorithm, as described in Table 12. Figure 6 colors the vertices in a local cluster compted using the PR algorithm. The numerical data of the last two sections validate the effectiveness and efficiency of local cluster detection using sweeps over -approximate heat kernel pagerank. The experiments of Section 5 demonstrate that sampling a number of random walks of at most K steps yield a ranking of vertices within the error bounds of Theorem 1. This ranking in turn is used to compute a local cluster. What is more, this value K does not depend on parameters other than . Specif- ically, it does not depend on the size of the graph or the desired cluster volume, size, or Cheeger ratio. Finally, the data of Section 6 validate the statements of Theorem 4. That is, perfoming a sweep over an approximate heat kernel pager- ank vector detects clusters of Cheeger ratio at most 8φ for a desired Cheeger √ Computing Heat Kernel Pagerank 31 Fig. 5: Local cluster in facebook ego network computed using the HKPR algo- rithm. 32 Chung and Simpson Fig. 6: Local cluster in facebook ego network computed using the PR algorithm. Computing Heat Kernel Pagerank 33 ratio φ. The total cost of computing this cluster is O( log(−1) log n the size of the graph. 3 log log(−1) ), sublinear in References 1. Noga Alon and Vitali D. Milman, λ1, isoperimetric inequalities for graphs, and superconductors, Journal of Combinatorial Theory, Series B 38 (1985), no. 1, 73– 88. 2. Reid Andersen and Fan Chung, Detecting sharp drops in pagerank and a simplified local partitioning algorithm, Proceedings of Theory and Applications of Models of Computation, Springer, 2007, pp. 1–12. 3. Reid Andersen, Fan Chung, and Kevin Lang, Local graph partitioning using pager- ank vectors, IEEE 47th Annual Symposium on Foundations of Computer Science, IEEE, 2006, pp. 475–486. 4. Reid Andersen and Yuval Peres, Finding sparse cuts locally using evolving sets, Proceedings of the 41st Annual Symposium on Theory of Computing, ACM, 2009, pp. 235–244. 5. Albert-L´aszl´o Barab´asi and R´eka Albert, Emergence of scaling in random networks, Science 286 (1999), no. 5439, 509–512. 6. Michele Benzi and Christine Klymko, Total communicability as a centrality mea- sure, Journal of Complex Networks 1 (2013), no. 2, 124–149. 7. Christian Borgs, Michael Brautbar, Jennifer T. Chayes, and Shang-Hua Teng, A sublinear time algorithm for pagerank computations, WAW, 2012, pp. 41–53. 8. Pak K. Chan, Martine D.F. Schlag, and Jason Y. Zien, Spectral k-way ratio-cut partitioning and clustering, IEEE Transactions on Computer-Aided Design of In- tegrated Circuits and Systems 13 (1994), no. 9, 1088–1096. 9. Fan Chung, The heat kernel as the pagerank of a graph, Proceedings of the National Academy of Sciences 104 (2007), no. 50, 19735–19740. 10. , A local graph partitioning algorithm using heat kernel pagerank, Internet Mathematics 6 (2009), no. 3, 315–330. 11. Fan Chung and Olivia Simpson, Solving linear systems with boundary conditions using heat kernel pagerank, Workshop on Algorithms and Models for the Web Graph, 2013, pp. 203 – 219. 12. 13. , Computing heat kernel pagerank and a local clustering algorithm, Com- binatorial Algorithms: 25th International Workshop, IWOCA 2014, Duluth, MN, USA, October 15-17, 2014, Revised Selected Papers, Springer, 2014, pp. 110–121. , Solving local linear systems with boundary conditions using heat kernel pagrank, Internet Mathematics 11 (2015), no. 4-5, 449–471. 14. William E. Donath and Alan J. Hoffman, Algorithms for partitioning of graphs and computer logic based on eigenvectors of connection matrices, IBM Technical Disclosure Bulletin 15 (1972), no. 3, 938–944. 15. Ronald Fagin, Ravi Kumar, and D. Sivakumar, Comparing top k lists, SIAM Jour- nal on Discrete Mathematics 17 (2003), no. 1, 134–160. 16. Shayan Oveis Gharan and Luca Trevisan, Approximating the expansion profile and almost optimal local graph clustering, IEEE 53rd Annual Symposium on Founda- tions of Computer Science, IEEE, 2012, pp. 187–196. 17. Aric A. Hagberg, Daniel A. Schult, and Pieter J. Swart, Exploring network struc- ture, synamics, and function using NetworkX, Proceedings of the 7th Python in Science Conference (SciPy2008) (Pasadena, CA USA), August 2008, pp. 11–15. 34 Chung and Simpson 18. Taher H Haveliwala, Topic-sensitive pagerank, Proceedings of the 11th interna- tional conference on World Wide Web, ACM, 2002, pp. 517–526. 19. Petter Holme and Beom Jun Kim, Growing scale-free networks with tunable clus- tering, Physical Review E 65 (2002), no. 2, 026107. 20. Ravi Kannan, Santosh Vempala, and Adrian Vetta, On clusterings: Good, bad and spectral, Journal of the ACM (JACM) 51 (2004), no. 3, 497–515. 21. Bryan Klimt and Yiming Yang, Introducing the enron corpus., CEAS, 2004. 22. Kyle Kloster and David F. Gleich, A nearly-sublinear method for approximating a column of the matrix exponential for matrices from large, sparse networks, Algo- rithms and Models for the Web Graph, 2013, pp. 68–79. 23. Valdis Krebs, New political patterns, http://www.orgnet.com/divided, 2008. 24. Jure Leskovec and Andrej Krevl, SNAP Datasets: Stanford large network dataset collection, http://snap.stanford.edu/data, June 2014. 25. Jure Leskovec, Kevin J. Lang, Anirban Dasgupta, and Michael W. Mahoney, Sta- tistical properties of community structure in large social and information networks, Proceedings of the 17th International Conference on World Wide Web, ACM, 2008, pp. 695–704. 26. Jure Leskovec and Julian J Mcauley, Learning to discover social circles in ego networks, Advances in Neural Information Processing Systems, 2012, pp. 539–547. 27. Chung-Shou Liao, Kanghao Lu, Michael Baym, Rohit Singh, and Bonnie Berger, Isorankn: Spectral methods for global alignment of multiple protein networks, Bioin- formatics 25 (2009), no. 12, i253–i258. 28. Frank Lin and William W. Cohen, Power iteration clustering, Proceedings of the 27th International Conference on Machine Learning(ICML10), 2010, pp. 655–662. , A very fast method for clustering big text datasets, Proceedings of the 19th 29. European Conference on Artificial Intelligence, 2010, pp. 303–308. 30. L´aszl´o Lov´asz and Mikl´os Simonovits, The mixing rate of markov chains, an isoperimetric inequality, and computing the volume, Proceedings of the 31st Annual Symposium on Foundations of Computer Science, IEEE, 1990, pp. 346–354. 31. , Random walks in a convex body and an improved volume algorithm, Ran- dom Structures & Algorithms 4 (1993), no. 4, 359–412. 32. D. Lusseau, K. Schneider, O.J Boisseau, P. Haase, E. Slooten, and S.M. Dawson, The bottlenose dolphin community of doubtful sound features a large proportion of long-lasting associations, Behavioral Ecology and Sociobioloy 54 (2003), 396–405. http://www-_personal.umich.edu/~mejn/ 33. Mark Newman, Network data, netdata/, 2013. 34. Andrew Y Ng, Michael I Jordan, Yair Weiss, et al., On spectral clustering: Analysis and an algorithm, Advances in neural information processing systems 2 (2002), 849–856. 35. Lorenzo Orecchia, Sushant Sachdeva, and Nisheeth K. Vishnoi, Approximating the exponential, the lanczos method and an O(m)-time spectral algorithm for balanced separator, Proceedings of the 44th Symposium on Theory of Computing, ACM, 2012, pp. 1141–1160. 36. Sushant Sachdeva and Nisheeth K. Vishnoi, Matrix inversion is as easy as expo- nentiation, arXiv preprint arXiv:1305.0526 (2013). 37. Jianbo Shi and Jitendra Malik, Normalized cuts and image segmentation, IEEE Transaction on Pattern Analysis and Machine Intelligence 22 (2000), no. 8, 888– 905. 38. Daniel A. Spielman and Shang-Hua Teng, Nearly-linear time algorithms for graph partitioning, graph sparsification, and solving linear systems, Proceedings of the Computing Heat Kernel Pagerank 35 thirty-sixth annual ACM symposium on Theory of Computing, ACM, 2004, pp. 81– 90. 39. , A local clustering algorithm for massive graphs and its application to nearly-linear time graph partitioning, CoRR abs/0809.3232 (2008). 40. Duncan J. Watts and Steven H. Strogatz, Collective dynamics of 'small-world' networks, Nature 393 (1998), no. 6684, 440–442. 41. , Collective dynamics of small-world networks, Nature 393 (1998), no. 6684, 440–442.
1908.09135
1
1908
2019-08-24T13:27:38
Subadditive Load Balancing
[ "cs.DS" ]
Set function optimization is essential in AI and machine learning. We focus on a subadditive set function that generalizes submodularity, and examine the subadditivity of non-submodular functions. We also deal with a minimax subadditive load balancing problem, and present a modularization-minimization algorithm that theoretically guarantees a worst-case approximation factor. In addition, we give a lower bound computation technique for the problem. We apply these methods to the multi-robot routing problem for an empirical performance evaluation.
cs.DS
cs
Subadditive Load Balancing Kiyohito Nagano Gunma University [email protected] Akihiro Kishimoto IBM Research, Ireland [email protected] August 27, 2019 Abstract Set function optimization is essential in AI and machine learning. We focus on a subadditive set function that generalizes submodularity, and examine the subadditivity of non-submodular functions. We also deal with a minimax subadditive load balancing problem, and present a modularization-minimization algorithm that theoretically guarantees a worst-case approximation factor. In addition, we give a lower bound computation technique for the problem. We apply these methods to the multi-robot routing problem for an empirical performance evaluation. 1 Introduction A set function is regarded as a discrete function on the vertices of n-dimensional hypercube {0, 1}n. Many combinatorial problems arising in machine learning are reduced to set function optimization. In particular, submodular set functions are a fundamental tool. For example, submodular optimization has been used to perform clustering [31, 29], image segmentation [33, 18] and feature selection [1], and applied to influence maximization [19], sensor placement [14], and text summarization [27]. A set function f is a real-valued function defined on subsets of a finite set V = {1, . . . , n}. The domain of f is the power set of V , denoted by 2V = {S : S ⊆ V }. A set function f : 2V → R is submodular if f (S) + f (T ) ≥ f (S ∪ T ) + f (S ∩ T ) for all S, T ⊆ V . The submodular set function is known to be a discrete counterpart of the convex function [28]. Similarly to convex functions, submodular functions can be exactly minimized in polynomial time [13, 32, 15]. However, in many practical settings, submodular function minimization becomes a very difficult task even when only one simple additional constraint is introduced [35, 16]. Minimax submodular load balancing (SMLB) is NP-hard. Svitkina and Fleischer [35] presented a sampling-based O(√n ln n)-approximation algorithm. Wei et al. [38] tackled submodular partitioning problems, including minimax SMLB, and presented a majorization-minimization algorithm that ensures a theoretical worst-case approximation factor. Their analysis heavily relies on the curvatures of the submodular functions [37, 17, 34]. A set function g : 2V → R is subadditive if g(S) + g(T ) ≥ g(S ∪ T ) for all S, T ⊆ V . Nonnegative submodularity immediately leads to nonnegative subadditivity whose optimization is important in machine learning [4]. A fractionally subadditive (or XOS) set function, which is a special case of a subadditive set function and a generalization of a submodular set function, is well studied in the context of combinatorial auction [6] and learnability and sketchability of set functions [3, 2, 9]. Despite a simple generalization of submodularity, to the best of our knowledge, little work exists on general subadditive optimization [8]. Therefore, theoretical properties and potential applications of such general subadditive set optimization problems have not been revealed yet. We, therefore, first examine the subadditivity of fundamental non-submodular functions, including the facility location function [11] and the minimum spanning tree (MST) function. We show that a subadditive set function simplifies computing interpolation of a submodular set function with unknown function values. The interpolation is related to submodular function approximation [10], but our approach is different, since the algorithm of Goemans et al. [10] is not always easy to implement. 1 We then consider the minimax subadditive load balancing (SALB) problem as an important general- ization of SMLB. As a variant of the majorization-minimization algorithm [38] for SMLB, we present the modularization-minimization algorithm that ensures a theoretical worst-case approximation factor. Our analysis reveals the difference and similarity between submodular and subadditive set functions in terms of tractability. While the approximability of SALB implies a tractable aspect of subadditivity, we prove intractability of curvature computation of a subadditive set function. Thus, we introduce a concept of a pseudo-curvature that is relatively tractable. In addition, we present a method for computing a lower bound for SALB in some special cases, including SMLB. Finally, we discuss that the SALB problem with the MST functions is related to multi-robot routing (MRR) problem with the minimax team objective [23], and perform an empirical evaluation of our approach. Besides, the iterative procedure in the modularization-minimization algorithm attempts to improve a solution found so far. We empirically evaluate the effectiveness of the iterative procedure starting with different initial solutions computed by other existing algorithms for MRR. 2 Subadditive functions and subadditive load balancing We first give basic definitions, and then define the subadditive load balancing problem. 2.1 Set functions, and subadditive functions Let V = [n] := {1, . . . , n} be a given set of n elements, and g : 2V → R be a real-valued function defined on all the subset of V . Such a function g is called a set function with a ground set V . A set function g : 2V → R is called subadditive if g(S) + g(T ) ≥ g(S ∪ T ), ∀S, T ⊆ V . A set function g : 2V → R is called submodular if g(S) + g(T ) ≥ g(S ∪ T ) + g(S ∩ T ), ∀S, T ⊆ V , and is called modular if g(S) + g(T ) = g(S∪T )+ g(S∩T ), ∀S, T ⊆ V . A set function is called nonnegative if 0 ≤ g(S) for any S ⊆ V , nondecreasing if g(S) ≤ g(T ) for any S, T ⊆ V with S ⊆ T , and normalized if g(∅) = 0. Trivially, a nonnegative submodular function is a nonnegative subadditive function. Thus subadditivity generalizes submodularity in a simple manner. For an n-dimensional vector z = (zi)i∈V ∈ Rn and S ⊆ V , we denote z(S) = Pi∈S zi. A set function z : 2V → R corresponding to the vector z ∈ Rn is a modular function with z(∅) = 0. In the rest of the paper, we basically denote a subadditive set function as g, and a submodular set function as f . 2.2 Examples of subadditive set functions We examine the subadditivity of some non-submodular functions. The minimum spanning tree function plays an important role in multi-robot routing problems in §5. Another example, a subadditive interpolation of a submodular set function, is given in §2.2.2. 2.2.1 Examples in combinatorial optimization Minimum spanning tree function. The minimum spanning tree function is a canonical example of the subadditive set function. Let r be a root node and V = {1, . . . , n} be a set of other nodes. We are given a distance d(i, j) ≥ 0 for any i, j ∈ eV := {r} ∪ V . Suppose that d : eV × eV → R is symmetric and satisfies triangle inequalities. For any subset S ⊆ V , a minimum spanning tree (MST) w.r.t. eS := {r} ∪ S is a spanning tree w.r.t. eS that minimizes the sum of edge distances. For any S ⊆ V , let M ST (S) be a sum of edge distances of MST w.r.t. eS. We call M ST : 2V → R a minimum spanning tree function on V with root r. Lemma 1. A minimum spanning tree function M ST : 2V → R is nonnegative and subadditive. The function M ST : 2V → R is not always nondecreasing and/or submodular. For the function M ST in Figure 1 (a), M ST ({1, 3}) = 10 and M ST ({1, 2, 3}) = 9. Thus, M ST is not nondecreasing. For the function M ST in Figure 1 (b), M ST ({1}) = 5, M ST ({1, 2}) = M ST ({1, 3}) = 6, and M ST ({1, 2, 3}) = 9. Thus, M ST is not submodular. 2 r 3 5 1 3 5 5 2 3 3 (a) r 3 3 2 5 3 3 (b) 3 3 1 Figure 1: Minimum spanning tree functions Let us consider an MST function with nonnegative node weights. Given an MST function M ST : 2V → R and a nonnegative uniform node weight β ≥ 0, the function M ST β : 2V → R defined by M ST β(S) = M ST (S) + βS (∀S ⊆ V ) (1) is also subadditive. The functions M ST and M ST β will be used in the computational experiments on multi-robot routing problems in Section 6. Facility location function. The facility location function [11] is another example. Given a finite set V = {1, 2, . . . , n} of customers and a finite set F of possible locations for the facilities, a certain service is provided by connecting customers to opened facilities. Opening facility j ∈ F incurs a fixed cost oj ≥ 0, and connecting customer i ∈ V to facility j ∈ F incurs a fixed cost cij ≥ 0. For any subset S ⊆ V of the customers, let F L(S) be the minimum cost of providing the service only to S. We call F L : 2V → R a facility location function. Let us see an example of F L in Figure 2 with F = {a, b} and V = {1, 2, 3}. We have, e.g., F L({2}) = oa + c2a = 2, F L({1, 2}) = oa + c1a + c2a = 3, and F L({1, 2, 3}) = oa + c1a + c2a + ob + c3b = 5. Lemma 2. A facility location function F L : 2V → R is nondecreasing and subadditive. As pointed out in [11], F L : 2V → R is not necessarily submodular. In the case of Figure 2, we have F L({1, 2}) + F L({2, 3}) < F L({1, 2, 3}) + F L({2}). oa = 1 a ob = 1 b 1 1 3 1 2 1 3 1 3 Figure 2: Facility location function 2.2.2 Interpolation of a submodular set function Let f : 2V → R be a nondecreasing submodular set function with f (∅) = 0. Assume that we have only a part of the function values of f . That is, for a given collection C = {C1, C2, . . . , Cm} ⊆ 2V , the function values f (Ci) = fi are known for each i = 1, . . . , m and the value f (S) are unknown for any S ∈ 2V \ C. The objective here is to build a set function g : 2V → R that approximates f . We introduce a general, simple method to construct a subadditive interpolating set function gC, which is computationally tractable. We utilize the ideas of the polymatroid [7] and the Lov´asz extension [28]. In some applications, evaluating function values of f is computationally expensive (see, e.g., [26]). By appropriately setting the collection C, our interpolation method transforms a complicated submodular opti- mization problem into a simple subadditive optimization problem. Lov´asz extension. The polymatroid P(f ) = {z ∈ Rn : z(S) ≤ f (S) (∀S ⊆ V )} ∩ Rn polyhedron, where R≥0 is the set of nonnegative real values. The Lov´asz extension bf : Rn by bf (x) = maxz∈P(f )hx, zi (∀x ∈ Rn extension of f since bf (I S) = f (S) holds, ∀S ⊆ V , where I S ∈ {0, 1}n is the characteristic vector of S. ≥0), where hx, zi =Pi∈V xizi. The function bf is a natural continuous ≥0 is a bounded ≥0 → R is defined 3 Construction of the interpolating function. For an imitated polymatroid PC(f ) = {z ∈ Rn : z(Ci) ≤ f (Ci) (∀i = 1, . . . , m)} ∩ Rn ≥0, and an imitated Lov´asz extension bfC(x) = maxz∈PC(f )hx, zi 2V → R as gC(S) = bfC(I S) (∀S ⊆ V ). The following lemma guarantees that gC is a natural subadditive Lemma 3. The set function gC : 2V → R satisfies extension of f and gC is computationally tractable. ≥0), we define the set function gC : (∀x ∈ Rn (i) (ii) (iii) (iv) gC(S) ≥ f (S), ∀S ⊆ V , gC(Ci) = f (Ci), ∀i = 1, . . . , m, gC is a nondecreasing subadditive set function, and the value gC(S) can be computed in polynomial time in n and m for any given S ⊆ V . Proof. Proof of (i). By definition, we have P(f ) ⊆ PC(f ). Therefore, f (S) = bf (I S) = max z∈P(f )hI S, zi ≤ max z∈PC(f )hI S, zi = bfC(I S) = gC(S), for all S ⊆ V . Proof of (ii). By Lemma 3 (i), we have f (Ci) ≤ gC(Ci), ∀i = 1, . . . , m. By the definition of gC and PC(f ), we have gC(Ci) = max z∈PC(f )hI Ci, zi = max z∈PC(f ) z(Ci) ≤ f (Ci), for all i = 1, . . . , m. Thus, we obtain f (Ci) = gC(Ci), for all i = 1, . . . , m. Proof of (iii). The nondecreasing property of gC follows from PC(f ) ⊆ Rn ≥0. We have gC(S ∪ T ) = maxz∈PC(f )hI S∪T , zi ≤ maxz∈PC(f )hI S + I T , zi ≤ maxz∈PC(f )hI S, zi + maxz∈PC(f )hI T , zi = g(S) + g(T ), for any S, T ⊆ V . Thus, gC is subadditive. Proof of (iv). The polyhedron PC(f ) is bounded and it is determined by n + m linear inequalities. Thus, the linear programming problem max z∈PC(f )hI S, zi can be solved in polynomial time in n and m. The function gC is not necessarily submodular. Consider the case where V = {1, 2, 3}, f (S) = (7 − S)S (∀S ⊆ V ), and C = 2V \ V . We have gC({1}) = 6, gC({1, 2}) = gC({1, 3}) = 10, and gC({1, 2, 3}) = 15. Therefore, gC is not submodular. Figure 3 illustrates a polymatroid P(f ) and an imitated polymatroid PC(f ) in the case of this example. x3 6 x3 6 (5, 5, 5) O P ( f ) 6 x1 x2 6 x2 6 O PC ( f ) x1 6 Figure 3: Polymatroid P(f ) and imitated polymatroid PC(f ) 2.3 Subadditive load balancing We define the submodular load balancing (SMLB) and the subadditive load balancing (SALB) problems. S = (S1, . . . , Sm) is an m-partition of V = {1, . . . , n} if S1∪···∪Sm = V and Sj∩Sj′ = ∅ for 1 ≤ j < j′ ≤ m (some Sj can be empty). Suppose that set functions f1, . . . , fm : 2V → R are normalized, nonnegative, and 4 submodular, and set functions g1, . . . , gm : 2V → R are normalized, nonnegative, and subadditive. The SMLB problem is defined as max j=1,..., m fj(Sj) min s. t. S = (S1, . . . , Sm) is an m-partition of V. (2) We say that SMLB is nondecreasing if f1, . . . , fm are nondecreasing. Approximation algorithms and heuris- tics are proposed for the nondecreasing SMLB [35, 38]. On the other hand, we mainly deal with SALB which has not been performed in-depth analysis before. SALB has a slightly different objective function: max j=1,..., m gj(Sj) min s. t. S = (S1, . . . , Sm) is an m-partition of V. (3) SALB is nondecreasing for nondecreasing g1, . . . , gm. 3 Algorithms for SALB SALB is NP-hard due to the hardness of SMLB. We, therefore, consider some approaches to find approximate solutions of SALB, and begin with the greedy method. Algorithm Greedy(g1, . . . , gm) 0: Set Sj := ∅, ∀j ∈ [m], and U := V . 1: While U 6= ∅ do i∈R Choose ij ∈ arg min Choose j∗ ∈ arg min Set Sj∗ := Sj∗ ∪ {ij∗} and U := U \ {ij∗} gj(Sj ∪ {i}), ∀j ∈ [m] gj(Sj ∪ {ij}) j∈[m] 2: Output S = (S1, . . . , Sm). Greedy is straightforward but does not empirically yield solutions of good quality (see Section 5). We introduce a nontrivial approach and give new theoretical analyses. We say that an algorithm A for the minimization problem (P) achieves an approximation factor of γ ≥ 1 or A is a γ-approximation algorithm if (OP T ≤) AP P ≤ γ · OP T is satisfied for any instance of the problem (P), where OP T is the optimal value of the problem and AP P is the objective function value of the approximate solution obtained by A. It is known to be difficult to give a theoretically good approximation algorithm for SALB in a sense. There is no polynomial-time approximation algorithm for the nondecreasing SMLB (and SALB) with an approximation factor of o(pn/ ln n) [35]. Therefore, it is important to see the tractability of load balancing problems by using measures different from n = V . As a nontrivial approach to SMLB, Wei et al. [38] proposed a majorization-minimization algorithm and gave a worst-case approximation factor for the nondecreasing submodular case. Its approximation factor depends on the curvatures of the submodular set functions. We replace f1, . . . , fm in the majorization-minimization algorithm of [38] with g1, . . . , gm, which we call the modularization-minimization algorithm MMin (see §3.1). This replacement leads to the following notable differences and similarities described in this and next sections: • Unlike SMLB, a majorizing approximation modular set function for SALB cannot be constructed due to the non-submodular structure. • As is the case for SMLB, our analysis uses the curvatures of the subadditive set functions. The worst- case approximation factor of MMin for the nondecreasing SALB in §3.2 is a generalization of the result of [38] for the nondecreasing SMLB. • Unlike for a submodular set function, the curvature computation is not easy for a subadditive set function (see §4). Note that the curvature computation is not necessarily required because the algorithm does not use its value. 5 The approximation guarantee including the curvatures of set functions may be unstable or useless, due to its difficulty of computing the actual value of the approximation factor. In order to resolve this issue, we present a method to compute a lower bound of the optimal solution for some important cases (see §3.3). 3.1 The modularization minimization algorithm We describe the modularization-minimization algorithm MMin for SALB. Framework of the algorithm. MMin iteratively updates the m-partition S. Given a tentative m- partition S′ = (S′ m) for SALB, the update operation of each iteration constructs modular ap- proximation function Mj : 2V → R of gj at S′ j for each j = 1, . . . , m, and obtains a modified m-partition 1 , . . . , S′′ S′′ = (S′′ m). S′′ is an optimal solution to the following modular load balancing (M-LB) problem: 1, . . . , S′ max j=1,..., m Mj(Sj) min s. t. S = (S1, . . . , Sm) is an m-partition of V. (4) Construction of approximation functions. Given a subadditive set function g : 2V → R and a subset S′ ⊆ V , we have to construct a modular approximation set function M of g at S′ in order to deal with the problem (4). If g is submodular, a majorization set function M satisfying g(S) ≤ M (S), ∀S and g(S′) = M (S′) can be constructed in a simple way [38].1 In contrast, in the subadditive case, it would be difficult to construct a majorization set function. Thus, for example, we use an intuitively natural modular set function M defined by M (S) = g(S′) + Pi∈S\S ′ g(i S′) − Pi∈S ′\S g(i S′ \ {i}) (S ⊆ V ), (5) where g(i S) = g(S ∪ {i}) − g(S) for S ⊆ V and i /∈ S. If g is nondecreasing, the marginal cost g(i S) is nonnegative for all S ⊆ V and i /∈ S. In computing lower bounds (see § 3.3), we will give an alternative way of constructing the approximation modular set function M which is a minorization set function. The minorization set function M approximating the function g around the subset S′ satisfies We use an approximate minorization set function for some important special cases. g(S) ≥ M (S), ∀S and g(S′) = M (S′). Algorithm description. MMin is described below. Algorithm MMin(g1, . . . , gm) 1 , . . . , S(0) 0: Find an initial m-partition S(0) = (S(0) 1: Construct a modular approximation function M (k) 2: Let S(k) = (S(k) 3: If S(k) = S(k−1) 1 , . . . , S(k) j then output S := S(k), else set k := k + 1 and go to Step 1. , ∀j ∈ [m] = {1, . . . , m}. M (k) j (Sj). m ) of V . Set k := 1. of gj at S(k−1) j m ) be an m-partition S that minimizes max j=1,..., m MMin needs to find an initial partition in Step 0, and solve the M-LB problem (4) in Step 2. We describe the methods to do so in the following part. In addition, we give a simple approximation bound of MMin for SALB with a mild assumption. 1 In the submodular case [38], the functions M 1 and M 2 defined by, for all S ⊆ V , M 1(S) = g(S′) + P g(i S′) − i∈S\S ′ P g(i V \ {i}), M 2(S) = g(S′) + P g(i ∅) − P g(i S′ \ {i}) are both majorization set functions. These functions i∈S ′\S are not necessarily majorizing in the subadditive case. i∈S\S ′ i∈S ′\S 6 Finding an initial partition. MMin can start with an arbitrary m-partition of V . In order to obtain an approximation factor for SALB, we consider the M-LB problem M (0) j (Sj ) j=1,..., m min max s. t. S = (S1, . . . , Sm) is an m-partition of V, where M (0) gj({i}) (S ⊆ V ), (S) =Xi∈S j (6) and let S(0) be an optimal (or approximately optimal) partition of problem (6). Solving the modular load balancing. Each modular set function Mj in problem (4) is represented as Mj(S) = bj +Pi∈S cij (S ⊆ V ). Therefore, by using a standard MIP (mixed integer programming) formulation technique, problem (4) becomes min y xij = 1, ∀i ∈ V, s. t. Xj∈[m] bj +Xi∈S xij ∈ {0, 1},∀i ∈ V, ∀j ∈ [m], y ∈ R. cij xij ≤ y, ∀j ∈ [m], (7) An optimal solution to problem (7) can be found via MIP solvers such as IBM ILOG CPLEX. An LP-based 2-approximation algorithm of [25] for the unrelated parallel machines scheduling problem can also be used for problem (7). However, with the algorithm of Lenstra et al., the approximation factor of 2 can be preserved only when bj ≥ 0 (∀j ∈ [m]) and cij ≥ 0 (∀i ∈ V, ∀j ∈ [m]). A simple bound of the algorithm. For g : 2V → R, we say that g satisfies a singleton-minimal (SMinimal) property if g({i}) ≤ g(S ∪ {i}), for all i ∈ V and S ⊆ V \ {i}. Any nondecreasing set function and the MST function in §2.2, which is not necessarily nondecreasing, satisfy the SMinimal property. We give a simple approximation bound of MMin for SALB. Proposition 4. The algorithm MMin for SALB achieves an approximation factor of 2 · (maxj∈[m] S∗ each gj satisfies the singleton minimal property, where S∗ = (S∗ m) is an optimal partition. 1 , . . . , S∗ j ) if A proof of Proposition 4 uses the definition of the initial partition S(0), the following simple relation (S∗ j ), and the approximation factor of 2 of the algorithm for (7). The M (0) initial partition of MMin already attains the approximation bound. j ) = Pi∈S ∗ gj({i}) ≤ S∗ j gj(S∗ j j 3.2 Analysis of the approximation algorithm for nondecreasing SALB For nondecreasing SALB, the bound of Proposition 4 can be improved by using the curvatures. We give a worst-case approximation factor of the algorithm MMin for the nondecreasing SALB. The following result is a generalization of the result of [38] for the nondecreasing SMLB. Theorem 5. The algorithm MMin for the nondecreasing subadditive load balancing achieves an approxi- mation factor of 2 · (maxj∈[m] m) is an optimal partition, and κgj (S) is the curvature of gj at S ⊆ V . We give a proof of Theorem 5 with the aid of the curvatures of a subadditive set function. j )) ), where S∗ = (S∗ 1 , . . . , S∗ j −1)(1−κg(S ∗ 1+(S ∗ S ∗ j Curvatures and modular approximation functions. As with the submodular case [37, 17], we consider the curvatures of subadditive functions. Suppose that g is a normalized nondecreasing subadditive set function with g({i}) > 0 for all i ∈ V . Define the curvature κg(S) of g at S ⊆ V as κg(S) = 1 − min A⊆S, i∈A g(i A \ {i}) g({i}) . 7 Denote the total curvature κg(V ) by κg. By the definition of the curvatures, for all S′ ⊆ S ⊆ V and i ∈ S′, we have g(i S ′\{i}) g({i}) ≥ 1 − κg(S) and thus g(i S′ \ {i}) ≥ (1 − κg(S))g({i}). (8) A set function bg : 2V → R is an γ-approximation of g if g(S) ≤ bg(S) ≤ γg(S) for all S ⊆ V . The following lemma evaluates to what extent the modular function M (S) =Xi∈S g({i}) (S ⊆ V ) closely approximates g. Lemma 6. If 0 < κg < 1, it holds that g(S) ≤Xi∈S g({i}) ≤ 1 1 − κg g(S) (S ⊆ V ). Proof. The first inequality directly follows from the subadditivity. Suppose S = h and S = {i1, . . . , ih}. Let Sk = {i1, . . . , ik} for each k = 1, . . . , h. Then, by using the inequality (8), we have g(S) = hXk=1 g(ik Sk \ {ik}) ≥ (1 − κg)Xi∈S g({i}), which shows the second inequality. By a more detailed non-uniform analysis, we can obtain a non-uniform version of Lemma 6. Lemma 7. For each S ⊆ V , if 0 < κg(S) < 1, it holds that g(S) ≤Xi∈S g({i}) ≤ S 1 + (S − 1)(1 − κg(S)) g(S). Proof. Let S ⊆ V be a subset with S = m. Fix an element i ∈ S. Then, we let S = {j1, j2, . . . , jm} with j1 = i, and set S0 = ∅, Sk = {j1, . . . , jk} (k = 1, . . . , m). By using the inequality (A1), we have g(S) − g({i}) = mXk=2 g(jkSk−1) ≥ (1 − κg(S)) Xj∈S\{i} g({j}). By summing up these inequalities for all i ∈ S, we have Sg(S) −Xi∈S g({i}) ≥ (1 − κg(S))(S − 1)Xi∈S =⇒ Sg(S) ≥ (1 + (1 − κg(S))(S − 1))Xi∈S =⇒ g({i}). g(S) ≥Xi∈S 1 + (S − 1)(1 − κg(S)) S g({i}), g({i}), 8 Analysis of the approximation factor. Here we assume that g1, . . . , gm are nondecreasing, and gj({i}) > 0 for all i ∈ V and j ∈ [m]. In addition, we use a γMLB-approximation algorithm for problem (6) in Step 0 of the algorithm MMin. Notice that the polynomial-time algorithm of [25] for problem (6) achieves an approximation factor of 2, that is, γMLB = 2. To prove Theorem 5, we show that the initial partition S(0) of the algorithm MMin attains the approxi- mation factor. Thus, it suffices to show the following lemma. Lemma 8. Let S(0) = (S(0) an optimal partition of the nondecreasing SALB. Then, S(0) is a (maxj∈[m] m ) be an optimal partition of problem (6), and let S∗ = (S∗ 1 , . . . , S(0) j −1)(1−κg(S ∗ 1 , . . . , S∗ m) be j )) )-approximation 1+(S ∗ S ∗ j solution of the nondecreasing SALB. S ∗ j j = 1+(S ∗ Proof. Let γ∗ for each j ∈ [m]. Therefore, we have max j −1)(1−κg(S ∗ j )) for each j ∈ [m]. In view of Lemma 7, we havePi∈S ∗ j∈[m] Xi∈S ∗ gj({i}) ≤ ( max γ∗ j ) · ( max gj(S∗ j )). j∈[m] j∈[m] j j By the subadditivity and the optimality of S(0), we have ) ≤ max j∈[m] Xi∈S(0) j gj({i}) ≤ max j∈[m] Xi∈S ∗ j max j∈[m] gj(S(0) j gj({i}). gj({i}) ≤ γ∗ j gj(S∗ j ) (9) (10) Combining (9) and (10), we can see that the partition S(0) is a (maxj∈[m] γ∗ nondecreasing SALB. j )-approximation solution of the 3.3 Lower bound computation In order to evaluate the quality of the obtained approximation solution, a lower bound of the optimal value of SALB gives an estimate about how close the solution is to the optimal one. We introduce a method to compute a lower bound, which employs the idea behind one iteration of MMin. 1, . . . , S′ 3.3.1 A general framework Given an m-partition S′ = (S′ can construct a modular set function Mj : 2V → R satisfying αgj(S) ≥ Mj(S), ∀S ⊆ V and gj(S′ (we call such Mj an α-approximate minorization set function of gj at S′ S′′ = (S′′ SALB. Let S∗ = (S∗ Mj satisfies Mj(S∗ have maxj Mj(S′′ m) for SALB, and let α ≥ 1. Suppose that, for each j = 1, . . . , m, we j) = Mj(S′ j) j). Then, an optimal solution m) to the M-LB (4) with M1, . . . , Mm provides a lower bound of the optimal value of the m) be an optimal partition to the SALB. For each j = 1, . . . , m, the function j ). By the definition of S′′, we j ). Thus, we have maxj Mj(S∗ j ) ≤ α maxj gj(S∗ j ). Combining these inequalities, we obtain 1 , . . . , S∗ j ) ≤ αgj(S∗ j ) ≤ maxj Mj(S∗ 1 , . . . , S′′ max j=1, ... ,m gj(S∗ j ) ≥ 1 α max j=1, ... ,m Mj(S′′ j ). Therefore, LB = 1 α max j=1, ... ,m Mj(S′′ j ) (11) is a lower bound of the optimal value of the SALB. The question is how to construct α-approximate minorization set functions with small α (≥ 1). In the remaining part, we deal with the SALB with minimum spanning tree functions (§2.2) and the nondecreasing SMLB. 9 3.3.2 Lower bound for SALB with MST functions Given a minimum spanning tree function M ST : 2V → R on the node set V with root r and a subset S′ ⊆ V , we consider a construction of an αT-approximate minorization set function MT of M ST at S′ for some αT ≥ 1. To construct MT, we use the cost-sharing method for the minimum spanning tree game [5]. Let Tr be a minimum spanning tree w.r.t. V ∪ {r}. For each i ∈ V , let pi be the (unique) parent node of i such that i and pi are directly connected on the (unique) path from i to r in Tr. The algorithm of Bird [5] sets the weight wi of i ∈ V as the distance from i to pi. It holds that M ST (S) ≥ Pi∈S wi (∀S ⊆ V ) and Pi∈V wi = M ST (V ) since the weight vector w = (wi)i∈V ∈ Rn is a core of the minimum spanning tree game. We set αT := M ST (S′)/Pi∈S ′ wi (≥ 1), and define the modular set function MT : 2V → R as MT(S) = αTPi∈S wi (S ⊆ V ). Then, we have αTM ST (S) ≥ MT(S) (∀S ⊆ V ) and M ST (S′) = MT(S′). partition S′ = (S′ Now we establish a lower bound for the SALB with MST functions M ST1, . . . , M STm. Given an m- Therefore, the function MT is an αT-approximate minorization set function of M ST at S′. m), we compute weight vector w(j) for each M STj, and we define 1, . . . , S′ αmax = max j=1,...,m αj, (12) where αj = M STj(S′ quality of LB is empirically evaluated in Section 6. i j j)/Pi∈S ′ w(j) . Then, we can obtain the lower bound LB in (11) with α = αmax. The MST case with uniform node weights. M ST1, . . . , M STm with M ST β this case, the lower bound for SALB can be computed in the same way as the MST case. We let Given a uniform node weight β ≥ 0, we can replace j (S) = M STj(S) + βS (∀S ⊆ V ). Also in m, where M ST β 1 , . . . , M ST β αβ max = max j=1,...,m αβ j , (13) where αβ j = M ST β j (S′ j)/Pi∈S ′ j (w(j) i + β). Then, we can obtain LB in (11) with α = αβ max. 3.3.3 Lower bound for nondecreasing SMLB Given a normalized nondecreasing submodular set function f : 2V → R and a subset S′ ⊆ V , we show a way of constructing an α-approximate minorization set function Mf of f at S′ with α = 1. Let w = (wi)i∈V ∈ Rn be an optimal solution to the linear optimization problem maxz∈P(f )hI S ′, zi over ≥0 , where I S ′ ∈ {0, 1}n is the characteristic the polymatroid P(f ) = {z ∈ Rn : z(S) ≤ f (S) (∀S ⊆ V )} ∩ Rn vector of S′. The vector w can be computed efficiently via the greedy algorithm of Edmonds [7]. Define the modular set function Mf : 2V → R as Mf (S) =Pi∈S wi (S ⊆ V ). Then, the definition of the polymatroid implies that f (S) ≥ Mf (S), ∀S ⊆ V , and the correctness of the greedy algorithm of [7] implies that f (S′) = Mf (S′). Therefore, the function Mf is an exact minorization set function of f at S′. The greedy algorithm of Edmonds. To make the paper self-contained, we describe the greedy algo- rithm of Edmonds [7] in detail. For a nonnegative coefficient vector a = (ai)i∈V ∈ Rn, we deal with the linear optimization problem maxz∈P(f )ha, zi over the polymatroid P(f ). Let L = (v1, v2, . . . , vn) be a total order of V = {1, . . . , n} such that av1 ≥ av2 ≥ ··· ≥ avn . Define L(0) = ∅, L(1) = {v1}, L(2) = {v1, v2}, . . . , and L(n) = {v1, . . . , vn}. The greedy algorithm of Edmonds [7] sets wvh := f (L(h)) − f (L(h − 1)) for each vh ∈ V . Then, the vector w = (wi)i∈V ∈ Rn is known to be optimal to maxz∈P(f )ha, zi. In addition, it holds that f (L(h)) = w(L(h)) for each h = 0, 1, . . . , n. In the case of the problem maxz∈P(f )hI S ′ , zi, we fix any total order L = (v1, . . . , vk, vk+1, . . . , vn) of V = {1, . . . , n} such that S′ = {v1, . . . , vk}, where k = S′. 4 Intractability of subadditivity, and countermeasures Theorem 5 in §3.2 shows a tractable aspect of subadditivity. This section provides some intractable aspects of subadditivity. In addition, as an alternative to the curvature of a subadditive set function, we introduce a concept of a pseudo-curvature. 10 Intractability of subadditivity 4.1 Unconstrained minimization. For submodular set function f : 2V → R with V = [n], the unconstrained minimization problem minS⊆V f (S) is exactly solved in polynomial time [13, 32, 15]. On the other hand, we prove that the unconstrained subadditive minimization is not tractable. We derive the intractability from the NP-hardness of the prize-collecting Steiner tree (PCST) problem of Goemans and Williamson [12]. Theorem 9. For subadditive set function g : 2V → R, the problem minS⊆V g(S) is NP-hard. Proof. Given an n-dimensional nonnegative prize vector p = (pi)i∈V ∈ Rn and a minimum spanning tree function M ST : 2V → R defined in §2.2, let us consider a set function P CST : 2V → R defined by P CST (S) = M ST (S) + p(V \ S) (S ⊆ V ). The PCST of Goemans and Williamson [12], which is NP-hard, coincides with the minimization problem minS⊆V P CST (S). In addition, owing to the subadditivity of M ST (S) and the nonnegative modularity of p(V \ S), P CST is subadditive. Therefore, the PCST is a special case of the unconstrained subadditive minimization problem. Thus, the subadditive function minimization is NP-hard. Curvature computation. For a submodular set function, it is easy to calculate curvatures [37, 17]. On the other hand, we prove that the curvature computation is not a trivial task in the subadditive case. We derive the intractability from the NP-hardness of the maximization problem of a nondecreasing submodular set function, which is a well-known NP-hard problem. Theorem 10. For a subadditive set function g : 2V → R and S ⊆ V , the computation of curvature κg(S) = 1 − min Proof. Let i∗ = n be a fixed element of V = [n], and let U = V \ {i∗} = [n − 1]. In view of the definition of the curvature, it suffices to show the NP-hardness of the minimization problem minA⊆U (g(A∪{i∗})− g(A)). To prove the NP-hardness, we construct a subadditive function g using a nonnegative submodular function. Let ef : 2U → R be a general nonnegative submodular function. Then, we define a set function g : 2V → R with the ground set V = U ∪ {i∗} as is NP-hard. g(A)−g(A\{i}) A⊆S, i∈A g({i}) g(A) =(cid:26) ef (A) 0 (A ⊆ U = V \ {i∗}), (i∗ ∈ A ⊆ V ). Trivially, g is nonnegative. Moreover, we can see that g always satisfies the subadditive inequality g(A) + g(B) ≥ g(A∪ B) for all A, B ⊆ V . ((i) If i∗ ∈ A∪ B, we have g(A∪ B) = 0 ≤ g(A) + g(B). (ii) If i∗ /∈ A∪ B, the nonnegative submodularity of ef gives the subadditive inequality of g.) Now, the minimization problem minA⊆U (g(A ∪{i∗})− g(A)) is equivalent to the submodular maximization problem maxA⊆U ef (A), which is known to be NP-hard. Therefore, the curvature computation is NP-hard for a subadditive set function. 4.2 Pseudo-curvatures As a countermeasure to the difficulty of the curvature calculation of a subadditive set fuction (Theorem 10), we introduce a concept of a pseudo-curvature. Given a nonnegative subadditive set function g : 2V → R, we suppose that g can be decomposed as follows: where g+ is subadditive and approximately or exactly nondecreasing, and f+ is nonnegative and submodular (or nonnegative and modular). If g+ is exactly nondecreasing, the total curvature κg of g can be bounded as follows: g(S) = g+(S) + f+(S) (∀S ⊆ V ), A⊆V, i∈A κg = 1 − min ≤ 1 − min = 1 − min i∈V A⊆V, i∈A f+(i V \{i}) . g+(i A\{i})+f+(i A\{i}) g({i}) f+(i A\{i}) g({i}) g({i}) 11 Target MST Table 1: Quality of RTC for MST and MMin MMin + MST Initial MMin size 50 100 120 RTC 4220 5484 5886 Time (s) 0.00024 0.0016 0.0042 RTC 4735 6626 7147 Time (s) 0.78 15.50 81.48 RTC 3827 5111 5474 Time (s) 1.32 16.43 82.54 RTC 3628 4797 5189 Time (s) 0.52 0.73 0.87 RTC 1914 3064 3422 Lower bound Time (s) 193.26 13.32 7.17 αmax 1.66 1.42 1.38 pseudo-curvature. An appropriate decomposition g = g+ + f+ would make the value bκg := 1 − mini∈V reasonable alternative to the total curvature κg even if g+ is approximately nondecreasing. We call bκg a Let us consider the case where g(S) = M ST β(S) = M ST (S) + βS defined in (1). The function M ST is nonnegative and subadditive (Lemma 1). Although M ST is not strictly nondecreasing, it can be regarded as an approximately nondecreasing set function. In addition, the term of βS(= f+(S)) is modular and nonnegative. Therefore, the pseudo-curvature bκM ST β is given by βV −βV \{i} g({i}) a f+(V )−f+(V \{i}) bκM ST β = 1 − min = 1 − min i∈V i∈V M ST β ({i}) β d(r,i)+β . (14) The relationship between the performance of the proposed algorithm and the pseudo-curvature will be discussed in Section 6. 5 Application to multi-robot routing This section explains an application of the subadditive load balancing (SALB) to the multi-robot routing (MRR) problem with the minimax team objective. For a set of robots R = {r1, . . . , rm}, a set of targets, T = {t1, . . . , tn}, and any i, j ∈ R ∪ T , a nonnegative cost (distance) d(i, j) ≥ 0 is determined. The cost function d : (R ∪ T ) × (R ∪ T ) → R is symmetric and satisfies triangle inequalities. We consider an allocation of targets to robots. Let Sj ⊆ T be a target subset allocated to robot rj ∈ R. MRR with the minimax team objective asks for finding an m-partition S = (S1, . . . , Sm) of T and a path Pj for each robot rj ∈ R that visits all targets in Sj so that a team objective is optimized [23] as follows: Minimax : min S max j∈R RP Cj(Sj) or min S max j∈R RT Cj(Sj), where RP Cj(Sj) is the minimum value of the robot path cost (RPC) for robot rj ∈ R to visit all targets in Sj, and RT Cj(Sj) is the minimum value of the robot tree cost (RTC) for robot rj ∈ R, i.e., RT Cj(Sj) is the sum of edge cost of an MST on {rj} ∪ Sj. The RPC is intractable due to the NP-hardness of the traveling salesperson problem, but the RTC is tractable. An MST on {rj} ∪ Sj can be converted to a robot path on {rj} ∪ Sj whose cost is within 1.5 · RP Cj(Sj) (see, e.g., [36]). Approximation algorithms especially based on sequential single-item auctions have been extensively stud- ied to solve MRR [21]. Our approach based on SALB provides a new, different way of tackling MRR with the minimax team objective. Because RT Cj(Sj ) is an MST function (see §2.2), it is an example of the subadditive set function. In addition, the lower bound analysis of §3.3 can be utilized. We can also deal with the processing time of targets. Let β ≥ 0 be a (uniform) waiting time it takes each robot to process each target. Then, each RT Cj becomes an MST function with a uniform node weight, which is defined in (1). Furthermore, even in this case, we can use the lower bound analysis of §3.3, and the pseudo-curvatures can be computed in view of (14). 6 Experimental results We performed empirical evaluation in the MRR domain on a machine with four Intel CPU cores (i5-6300U at 2.40GHz, only one core in use) and 7.4 GB of RAM. Our C++ implementation of the modularization- minimization algorithm denoted by MMin, runs IBM ILOG CPLEX to optimally solve each LP problem 12 Table 2: Quality of RTC for MST and MMin with 120 targets and 5 robots. Waiting Time 10 30 60 MST Time (s) 0.0032 0.0027 0.0025 RTC 6095 6656 7476 RTC 7195 7668 8314 Initial Time (s) 70.77 21.33 32.68 MMin Time (s) 72.11 22.80 34.49 RTC 5617 6100 6790 MMin + MST Pseudo RTC 5393 5907 6661 Time (s) Curvature 1.17 1.35 1.77 0.997 0.991 0.983 Table 3: Quality of RPC for each method Target size MMin MMin + MST MST Path 50 100 120 5233 7255 7756 4979 6900 7484 5011 7182 7870 4767 6827 7446 generated by MMin. MMin terminates if the value of the LP problem in the current iteration agrees with one in a previous iteration. We also implemented the following well-known MRR algorithms: • MST [23] is a standard algorithm presented in Algorithm Greedy, which is very similar to GreedMin of Wei et al. [38]. When MST calculates the RPC value, each robot's MST needs to be converted to a path. We used short-cutting [24], commonly used in MRR [23, 20]. • Path [23] is a standard auction algorithm in the literature [21]. Starting with a null path, each robot greedily extends its path with the insertion heuristic [24]. The robot with the smallest RPC wins an unassigned target in each round. This step is repeated until all targets are assigned. In calculating the RPC value for MMin, our approach generated a path based on the insertion heuristic with a partition calculated by MMin (i.e., the assignment optimized for RTC). We prepared a road map of the Hakodate area in Japan and precomputed distances between locations. That is, the distance was immediately retrieved when necessary. This is a common experimental setting for MRR, e.g., [22, 39]. In practice, when the map only contains a small city, all distance information fits into memory e.g., [30]. The precomputed distances correspond to driving times in second. We always set the robot size to five, but prepared three cases for the target size (50, 100 and 120). Each case consisted of 100 instances by randomly placing agents and targets. Table 1 shows average RTC values and average runtimes. We excluded Path here, since it does not optimize for RTC. The values in "Initial" indicate the RTC values and runtimes for finding initial m- partitions of MMin. The iterative procedure of MMin is regarded as a step to further refine an initial solution. Therefore, another initial solution can be passed to this iteration, although the worst-case theoretical analysis of the solution quality remains future work. We prepared MMin + MST that performs the MMin iterations but starts with an initial m-partition calculated by MST. MMin generated 9%, 7%, and 7% smaller RTC values than MST with 50, 100 and 120 targets, respectively. While the RTC values of the initial partitions generated by solving the first LP problems were inferior to those of MST, MMin's iterative steps successfully improved the initial partitions. In case of 50 targets, MMin performed 19 iterations on average, ranging between 4 and 76 iterations. In case of 120 targets, the number of iterations was 22 on average, ranging between 6 and 92 iterations. Among these iterations, MMin typically spent 59-99 % of the runtime in finding an initial partition. The formulation of the initial LP problem is slightly different from those in the remaining iterations, which we hypothesize as a cause of the difficulty. Finding the initial partition tended to be harder with a larger target size. In solving the most difficult instance with 50 targets, MMin needed 13.27 seconds to find an initial partition and only 0.75 seconds for the remaining iterations. There was one instance with 120 targets which took MMin 7317 seconds to find an initial partition. MMin + MST performed best in terms of the RTC quality and runtime. It bypassed the significant overhead of the initial partition computation, and started with a better initial RTC value than standard MMin. This indicates that such a hybrid approach is important in practice. The results shown in [23] seem to indicate that the worst-case solutions of auction-based algorithms are bounded by O(m). However, MMin is a centralized approach, and a question remains open as future work regarding whether MMin + MST theoretically guarantees a better approximation factor in general or not. We calculated an average lower bound and αmax defined in (12) for each target size (see Table 1) with the method presented in §3.3 and with the partition returned by MMin + MST. These lower bounds indicate that 13 on average the approximation factors of MMin + MST were empirically better than 1.90, and 1.57 and 1.52 for 50, 100, and 120 targets, respectively. We observed that there were many instances whose larger lower bounds were returned if different partitions (e.g., a partition that is better than in the previous iterations) were used for the lower bound computation. Therefore, in fact, MMin + MST must yield solutions closer to optimal than those potential approximation factors. The average runtime to compute a lower bound increased when the target size decreased, which was counter-intuitive. However, the potential approximation factors and the αmax values increased with a de- crease of the target size. Therefore, we hypothesize that the LP problem for lower bound calculation tends to be more difficult if the lower bound is farther than the optimal solution. Next, let us see the performance of the algorithms with waiting time β ≥ 0. Table 2 shows the cases where waiting times are varied from 10 -- 60 seconds with 5 robots and 120 targets. The waiting time corresponds to the time necessary for a robot to collect and drop off a target. We observed similar tendencies, even when waiting times were introduced. MMin returns better RTC values than MST, but suffers from the computational overhead for solving the initial LP problem. MMin+MST bypasses this overhead as well as yields the best RTC values. The values of the pseudo-curvaturebκM ST β determined in (14) close to 1 indicate a difficulty of performing theoretical analysis, even with waiting times. When the waiting time β was set to 60, the value of αβ max defined in (13) was 1.32, which was smaller than that without waiting time (i.e., αmax = 1.38 as shown in Table 1, and the pseudo-curvature is 1). This result implies the relative tractability of the problem with β = 60. Table 3 shows RPC values of each method. Since our approach does not optimize for the RPC, algorithms that obtain better RTC values do not always yield better RPC values in theory. However, in practice, MMin + MST performed best of all methods. While Path and MST guarantee the same theoretical approximation factor to optimal RPC values in MRR, there has been consensus that Path tends to perform better than MST [23], as is the case in our experiment. However, our results are important in the sense that they indicate that approaches that optimize solutions for the RTC metric (i.e., the MST function) and then convert to a path have a potential to become a better approach than Path, which would open up further research opportunities. 7 Concluding remarks We presented the modularization-minimization algorithm for the subadditive load balancing, and gave an approximation guarantee for the nondecreasing subadditive case. We also presented a lower bound com- putation technique for the problem. In addition, we evaluated the performance of our algorithm in the multi-robot routing domain. The application of subadditive optimization to AI are new, and subadditive approaches may open up a new field of AI and machine learning. An example of future work is to elucidate the theoretical and empirical behaviors of the modularization-minimization algorithm with respect to the initial solutions. Our results about giving the MMin iteration procedure an initial partition calculated by an MST-based greedy algorithm show the importance of the choice of the initial solutions. On other other hand, the question whether or not the iterative procedure currently contributes to improving the worst-case approximation factor remains unanswered. References [1] F. Bach. Learning with submodular functions: A convex optimization perspective. Foundations and Trends in Machine Learning, 6(2 -- 3):145 -- 373, 2013. [2] A. Badanidiyuru, S. Dobzinski, H. Fu, R. Kleinberg, N. Nisan, and T. Roughgarden. Sketching valuation functions. In SODA '12, pages 1025 -- 1035, 2012. [3] M.-F. Balcan and N. Harvey. Submodular functions: Learnability, structure, and optimization. SIAM Journal on Computing, 47:703 -- 754, 2018. [4] A. A. Bian, J. M. Buhmann, A. Krause, and S. Tschiatschek. Guarantees for greedy maximization of non- submodular functions with applications. In ICML, pages 498 -- 507, 2017. [5] C. G. Bird. On cost allocation for a spanning tree: A game theoretic approach. Networks, 6:335 -- 350, 1976. 14 [6] S. Dobzinski, N. Nisan, and M. Schapira. Approximation algorithms for combinatorial auctions with complement- free bidders. Mathematics of Operations Research, 35:1 -- 13, 2010. [7] J. Edmonds. Submodular functions, matroids, and certain polyhedra. In Combinatorial Structures and Their Applications (R. Guy, H. Hanani, N. Sauer, J. Schonheim, eds.), pages 69 -- 87. Gordon and Breach, 1970. [8] U. Feige. On maximizing welfare when utility functions are subadditive. SIAM J. Comput., 39(1):122 -- 142, 2009. [9] V. Feldman and J. Vondr´ak. Optimal bounds on approximation of submodular and xos functions by juntas. SIAM Journal on Computing, 45:1129 -- 1170, 2016. [10] M. X. Goemans, N. Harvey, S. Iwata, and V. Mirrokni. Approximating submodular functions everywhere. In SODA '09, pages 535 -- 544, 2009. [11] M. X. Goemans and M. Skutella. Cooperative facility location games. Journal of Algorithms, 50:194 -- 214, 2004. [12] M. X. Goemans and D. P. Williamson. A general approximation technique for constrained forest problems. SIAM Journal on Computing, 24:296 -- 317, 1995. [13] M. Grotschel, L. Lov´asz, and A. Schrijver. Geometric Algorithms and Combinatorial Optimization. Springer, 1988. [14] C. Guestrin, A. Krause, and A.P. Singh. Near-optimal sensor placements in gaussian processes. In ICML, pages 265 -- 272, 2005. [15] S. Iwata, L. Fleischer, and S. Fujishige. A combinatorial strongly polynomial algorithm for minimizing submod- ular functions. Journal of the ACM, 48:761 -- 777, 2001. [16] S. Iwata and K. Nagano. Submodular function minimization under covering constraints. In FOCS'09, pages 671 -- 680, 2009. [17] R. K. Iyer, S. Jegelka, and J. Bilmes. Curvature and optimal algorithms for learning and minimizing submodular functions. In NIPS, pages 2742 -- 2750, 2013. [18] S. Jegelka and J. Bilmes. Submodularity beyond submodular energies: coupling edges in graph cuts. In CVPR'11, pages 1897 -- 1904, 2011. [19] D. Kempe, J. Kleinberg, and E. Tardos. Maximizing the spread of influence through a social network. In KDD'03, pages 137 -- 146, 2003. [20] A. Kishimoto and N. Sturtevant. Optimized algorithms for multi-agent routing. In AAMAS, pages 1585 -- 1588, 2008. [21] S. Koenig, P. Keskinocak, and C. Tovey. Progress on agent coordination with cooperative auctions. In AAAI, pages 1713 -- 1717, 2010. [22] S. Koenig, C. Tovey, X. Zheng, and I. Sungur. Sequential bundle-bid single-sale auction algorithms for decen- tralized control. In IJCAI, pages 1359 -- 1365, 2007. [23] M. G. Lagoudakis, E. Markakis, D. Kempe, P. Keskinocak, A. Kleywegt, S. Koenig, C. Tovey, A. Meyerson, and S. Jain. Auction-based multi-robot routing. In Proc. of Robotics: Science and Systems, 2005. [24] E. L. Lawler, J. K. Lenstra, A. H. G. R. Kan, and D. B. Shmoys. The Traveling Salesman Problem: A Guided Tour of Combinatorial Optimization. Wiley Series in Discrete Mathematics and Optimization, 1985. [25] J. K. Lenstra, D. B. Shmoys, and E. Tardos. Approximation algorithms for scheduling unrelated parallel machines. Math. Program., 46:259 -- 271, 1990. [26] J. Leskovec, A. Krause, C. Guestrin, C. Faloutsos, J. VanBriesen, and N. Glance. Cost-effective outbreak detection in networks. In KDD '07, pages 420 -- 429, 2007. [27] H. Lin and J. Bilmes. Multi-document summarization via budgeted maximization of submodular functions. In HLT'10, pages 912 -- 920, 2010. [28] L. Lov´asz. Submodular functions and convexity. In A. Bachem, M. Grotschel, and B. Korte, editors, Mathematical Programming -- The State of the Art, pages 235 -- 257. Springer-Verlag, 1983. [29] K. Nagano, Y. Kawahara, and S. Iwata. Minimum average cost clustering. In NIPS, pages 1759 -- 1767, 2010. [30] H. Nakashima, S. Sano, K. Hirata, Y. Shiraishi, H. Matsubara, R. Kanamori, H. Koshiba, and Itsuki Noda. One cycle of smart access vehicle service development. In Proc. of the 2nd International Conf. on Serviceology, pages 152 -- 157, 2014. [31] M. Narasimhan, N. Jojic, and J. Bilmes. Q-clustering. In NIPS, pages 979 -- 986, 2005. 15 [32] A. Schrijver. A combinatorial algorithm minimizing submodular functions in strongly polynomial time. Journal of Combinatorial Theory (B), 80:346 -- 355, 2000. [33] P. Stobbe and A. Krause. Efficient minimization of decomposable submodular functions. In NIPS, pages 2208 -- 2216, 2010. [34] M. Sviridenko, J. Vondr´ak, and J. Ward. Optimal approximation for submodular and supermodular optimization with bounded curvature. In SODA'15, pages 1134 -- 1148, 2015. [35] Z. Svitkina and L. Fleischer. Submodular approximation: sampling-based algorithms and lower bounds. In FOCS'08, pages 697 -- 706, 2008. [36] Vijay V. Vazirani. Approximation Algorithms. Springer-Verlag New York, Inc., 2001. [37] Jan Vondrak. Submodularity and curvature: the optimal algorithm. In RIMS Kokyuroku Bessatsu, volume B23, volume B23, pages 253 -- 266, 2010. [38] K. Wei, R. K. Iyer, S. Wang, W. Bai, and J. A. Bilmes. Mixed robust/average submodular partitioning: Fast algorithms, guarantees, and applications. In NIPS, pages 2233 -- 2241, 2015. [39] X. Zheng, S. Koenig, and C. Tovey. Improving sequential single-item auctions. In IROS, pages 2238 -- 2244, 2006. Supplementary Material A.1 Proofs of Subadditivity We show the subadditivity of the minimum spanning tree function M ST and the facility location function F L defined in §2.2. A.1.1 Subadditivity of minimum spanning tree function In the field of game theory, the subadditivity of the minimum spanning tree function is recognized in relation to the minimum spanning tree game (Bird [5]). Here, we describe the proof of Lemma 1 to make the paper self-contained. Lemma 1 (§2.2.1). A minimum spanning tree function M ST : 2V → R is nonnegative and subadditive. Proof. By definition, nonnegativity is trivial. For subsets S, T ⊆ V , let ES be the edge set of MST w.r.t. eS and let ET be the edge set of MST w.r.t. eT . The graph (S∪T ∪{r}, ES ∪ET ) with a node set S∪T ∪{r} and an edge set ES ∪ ET are connected. Thus we have M ST (S) + M ST (T ) =Pe∈ES ∪ET d(e) ≥ M ST (S ∪ T ), which shows the subadditivity of M ST . A.1.2 Subadditivity of facility location function We show the subadditivity of the facility location function. Lemma 2 (§2.2.1). A facility location function F L : 2V → R is nondecreasing and subadditive. Proof. We are given a set V = {1, . . . , n} of customers and a finite set F of possible locations for the facilities with opening costs oj ≥ 0 (∀j ∈ F ) and connecting costs cij ≥ 0 (∀(i, j) ∈ V × F ). For each edge subset E ⊆ V × F , let N (E) be a set of all endpoints of E, and we denote V (E) := V ∩ N (E) and F (E) := F ∩ N (E). For S ⊆ V , F ′ ⊆ F , and E ⊆ V × F , we say that a triple T = (S, F ′,E) is feasible if S ⊆ V (E) and F (E) ⊆ F ′. For any feasible triple T = (S, F ′,E), we define cost(T ) := Pj∈F ′ oj +P(i,j)∈E cij, and we have F L(S) ≤ cost(T ). In addition, for each S ⊆ V , there exists a feasible triple T ∗ = (S, F ∗,E ∗) such that F L(S) = cost(T ∗). Suppose that S′ ⊆ S ⊆ V . Let T ∗ = (S, F ∗,E ∗) be a feasible triple satisfying F L(S) = cost(T ∗). Then, T ′ = (S′, F ∗,E ∗) is also a feasible triple. Therefore, F L(S′) ≤ cost(T ′) = cost(T ∗) = F L(S), which implies the nondecreasing property of F L. k ) be a feasible triple such that 2 ) is feasible, we have F L(S1 ∪ S2) ≤ Suppose that S1, S2 ⊆ V . For each k ∈ {1, 2}, let T ∗ 1 ∪ F ∗ 2 = (S1 ∪ S2, F ∗ 2 ) = F L(S1) + F L(S2), which implies the subadditivity of F L. k ). Since T ∗ k = (Sk, F ∗ 2 ,E ∗ 1 ∪ E ∗ k ,E ∗ F L(Sk) = cost(T ∗ cost(T ∗ 1 ∪ T ∗ 2 ) ≤ cost(T ∗ 1 ∪ T ∗ 1 ) + cost(T ∗ 16 A.2 Supplementary Explanation for §3.1 Let us see that it would be difficult to construct a majorization set function in the subadditive case. Given a subadditive set function g : 2V → R and a subset S′ ⊆ V , define the functions M 1 and M 2 as, for all S ⊆ V , M 1(S) = g(S′)+ Pi∈S\S ′ M 2(S) = g(S′)+ Pi∈S\S ′ g(i S′)− Pi∈S ′\S g(i ∅)− Pi∈S ′\S g(i V \ {i}), g(i S′ \ {i}). Both M 1 and M 2 are majorization set functions of g at S′ if g is submodular (Wei et al. [38]). But these functions are not necessarily majorizing functions in the subadditive case. Let g : 2{1,2,3} → R be the minimum spanning tree function in Figure 1 (b), which is nondecreasing, subadditive, and non-submodular. The function M 1 with S′ = {1} becomes M 1(S) = 2 +Pi∈S ai (S ⊆ {1, 2, 3}), where a1 = 3, a2 = a3 = 1. M 1 does not majorize g since g({1, 2, 3}) = 9 and M 1({1, 2, 3}) = 7. The function M 2 with S′ = {1, 2, 3} becomes M 2(S) =Pi∈S bi (S ⊆ {1, 2, 3}), where b1 = b2 = b3 = 3. M 2 does not majorize g since g({1}) = 5 and M 2({1}) = 3. 17
1011.2571
1
1011
2010-11-11T06:07:18
Recursive Sketching For Frequency Moments
[ "cs.DS" ]
In a ground-breaking paper, Indyk and Woodruff (STOC 05) showed how to compute $F_k$ (for $k>2$) in space complexity $O(\mbox{\em poly-log}(n,m)\cdot n^{1-\frac2k})$, which is optimal up to (large) poly-logarithmic factors in $n$ and $m$, where $m$ is the length of the stream and $n$ is the upper bound on the number of distinct elements in a stream. The best known lower bound for large moments is $\Omega(\log(n)n^{1-\frac2k})$. A follow-up work of Bhuvanagiri, Ganguly, Kesh and Saha (SODA 2006) reduced the poly-logarithmic factors of Indyk and Woodruff to $O(\log^2(m)\cdot (\log n+ \log m)\cdot n^{1-{2\over k}})$. Further reduction of poly-log factors has been an elusive goal since 2006, when Indyk and Woodruff method seemed to hit a natural "barrier." Using our simple recursive sketch, we provide a different yet simple approach to obtain a $O(\log(m)\log(nm)\cdot (\log\log n)^4\cdot n^{1-{2\over k}})$ algorithm for constant $\epsilon$ (our bound is, in fact, somewhat stronger, where the $(\log\log n)$ term can be replaced by any constant number of $\log $ iterations instead of just two or three, thus approaching $log^*n$. Our bound also works for non-constant $\epsilon$ (for details see the body of the paper). Further, our algorithm requires only $4$-wise independence, in contrast to existing methods that use pseudo-random generators for computing large frequency moments.
cs.DS
cs
Recursive Sketching For Frequency Moments Vladimir Braverman, Rafail Ostrovsky University of California, Los Angeles {vova, rafail}@cs.ucla.edu May 31, 2021 Abstract 2 In a ground-breaking paper, Indyk and Woodruff (STOC 05) showed how to compute Fk (for k > 2) in space complexity O(poly-log(n, m) · n1− k ), which is optimal up to (large) poly-logarithmic factors in n and m, where m is the length of the stream and n is the upper bound on the number of distinct elements k ). A follow-up work of in a stream. The best known lower bound for large moments is Ω(log(n)n1− Bhuvanagiri, Ganguly, Kesh and Saha (SODA 2006) reduced the poly-logarithmic factors of Indyk and Woodruff to O(log2(m)·(log n+log m)·n1− k ). Further reduction of poly-log factors has been an elusive goal since 2006, when Indyk and Woodruff method seemed to hit a natural "barrier." Using our simple recursive sketch, we provide a different yet simple approach to obtain a O(log(m) log(nm) · (log log n)4 · k ) algorithm for constant ǫ (our bound is, in fact, somewhat stronger, where the (log log n) term can n1− be replaced by any constant number of log iterations instead of just two or three, thus approaching log ∗n. Our bound also works for non-constant ǫ (for details see the body of the paper). Further, our algorithm requires only 4-wise independence, in contrast to existing methods that use pseudo-random generators for computing large frequency moments. 2 2 2 0 1 0 2 v o N 1 1 ] S D . s c [ 1 v 1 7 5 2 . 1 1 0 1 : v i X r a 1 Introduction The celebrated paper of Alon, Matias and Szegedy [1] defined the following streaming model: Definition 1.1. Let m, n be positive integers. A stream D = D(n, m) is a sequence of size m of integers p1, . . . , pm, where pi ∈ {1, . . . , n}. A frequency vector is a vector of dimensionality n with non-negative entries fi, i ∈ [n] defined as: fi = {j : 1 ≤ j ≤ m, pj = i}. Definition 1.2. A k-th frequency moment of D is defined by Fk(D) =Pi∈[n] f k Alon, Matias and Szegedy [1] initiated the study of approximating frequency moments with sublinear mem- ory. Their surprising and fundamental results imply that for k ≤ 2 it is possible to approximate Fk with polylogarithmic space; and that polynomial space is necessary for k > 2. Today, research on frequency mo- ments is one of the central directions for streaming; many important discoveries have been made since [1]. The incomplete list of relevant work includes [18, 15, 2, 10, 3, 12, 13, 14, 16, 17, 25, 23, 24, 28, 30, 4, 9, 20]. i . Also F∞ = maxi∈[n] fi. For small k ≤ 2, a long line of papers culminated in the recent optimal results: • k = 0: In their award-winning paper, Kane, Nelson and Woodruff [24] gave optimal-space solution. • 0 < k < 2: Kane, Nelson, and Woodruff [23], and later Kane, Nelson, Porat and Woodruff [22], gave optimal-space solutions. • k = 2: The famous sketch of Alon, Matias and Szegedy [1] is, in fact, optimal. For large k > 2, after years of tremendous effort by the theory community, with important intermediate results, the state of the art is as follows: Jayram, Kumar and Sivakumar [2], and Chakrabarti, Khot and Sun [10]. Recently, the lower bound of • k > 2 [Lower bounds:] The lower bound of Ω(cid:16)n1− 2 Ω(cid:16)(log n) · n1− 2 k(cid:17) on space complexity was shown by Bar-Yossef, k(cid:17) was announced by Jayram and Woodruff (see the last page of [26] Monemizadeh and Woodruff SODA 2010 presentation of [27]). • k > 2 [Upper bounds:] Indyk and Woodruff in their ground-breaking paper [19] first presented a ǫ12 · (log2 n)(log6 m) · n1− 2 k(cid:17) and then shown how k(cid:17) space com- their two-pass algorithm can be converted to one-pass algorithm with additional poly-log multiplicative factors. The method of Indyk and Woodruff [19] was subsequently improved in 2006 by Bhuvanagiri, two-pass algorithm with space complexity of O(cid:16) 1 Ganguly, Kesh and Saha [5] to achieve: O(cid:16) k2 plexity with one pass. To the best of our knowledge, this bound is the best know until today. ǫ2+4/k · (log2 m) · (log n + log m) · n1− 2 Main Technical Challenge: No progress was made on the problem of large frequency moments since the 2006 work of [5] described above due to the following "barrier": The large frequency moments represent the case of implicit vectors that cannot be sketched, at least directly. That is, no linear computation is known (unlike the case for the small sketches) that would give a good approximation for the entire vector. In fact, every algorithm that achieves O(n1−2/k) memory bits boils down to the Indyk and Woodruff approach. More- over, this is also true for algorithms for other implicit objects [6, 21]. Thus, it might be necessary to not only improve the existing bounds, but also to come up with new methods for computing estimates of implicit vectors. 1 Our Results: This is exactly what we do in this paper. We give a new, recursive method of computa- tions of implicit vectors that also improves the upper bounds for large frequency moments. We improve the bound of Bhuvanagiri, Ganguly, Kesh and Saha [5] from O(k2ǫ−2−(4/k) log2(m) log(nm)n1− 2 k ) to at least O(k2ǫ−2−(4/k)(log log(n))4 log(m) log(nm)n1− 2 k ). In fact, we give an even better bound. For any constant t we achieve: gt(n) log(m) log(nm)n1− 2 k(cid:19) space complexity, where: and O(cid:18) k2 ǫ2+(4/k) g0(n) = n gt(n) = log(gt−1(n)). For constant t and ǫ, we can further improve our bound to O(cid:0)log(n) log(n log(m)) · gt(n) · n1−2/k(cid:1). (Thus, this is a nearly quadratic improvement of the possible ratio between upper and lower bounds compared to the recently announced Ω(log(n)n1−2/k) lower bound of Jayram and Woodruff.) Our reduction requires only pairwise independence in contrast to the full independence that previous approaches need. Eliminating the need for total randomness is an important challenge for streaming; see, e.g., [23]. We obtain an algorithm that needs only 4-wise independence and thus does not need Nisan's pseudorandom generators [29]. Finally, we note that our proofs are elementary, along the lines of AMS-type proofs. An Alternative Perspective of Our Results: Many fundamental problems in streaming can be seen as com- puting L1 approximation of implicit vectors. For instance, the frequency moment Fk can be seen as an L1 norm of a vector with entries f k i . Except for small moments (i.e., k ≤ 2), no sketching (i.e., linear transforma- tion) algorithms were known in the past. That is, all previous methods for computing Fk for k > 2 resorted to non-linear computations, such as medians to boost the probability that heavy hitters will contribute. We give a recursive sketching algorithm for estimating within (1 ± ǫ) the L1 norm of an implicit n- dimensional vector of non-negative values, where the algorithm is not given such a vector explicitly, but is only allowed access through a "heavy hitters" oracle. Unlike all previous methods, our recursive sketching algorithm is a linear transformation (to heavy hitters) and requires O(log n) calls to a heavy hitters oracle and yields a (1 ± ǫ) approximation to L1 with constant probability. We note that our algorithm can be viewed as a random linear transformation on an implicit vector to heavy hitters, and thus gives a new dimension reduction method. Note that our dimension reduction does not contradict the impossibility result of Brinkman and Charikar [8], since our dimension reduction method preserves only the norm of the implicit vector and not pairwise distances between vectors. Yet, our method is sufficient for multiple streaming applications where we typically care about the norm of a single implicit vector. Thus, we believe that our method might be useful beyond approximating large frequency moments. In particular, it can be applied to other functions and implicit objects such as matrices, e.g., in [6, 21, 7]. Informal Ideas: Let us describe, very informally, the fundamental approach of Indyk and Woodruff [19]. They split the frequency vector into "layers," where each layer contains all entries with frequencies between, e.g., γi and γi+1 for a carefully chosen γ > 1. Then they approximate the contribution of each layer by sampling the stream and by finding the heavy elements that contribute to the layer. Their elegant analysis shows that such a procedure ensures a good approximation with high probability. We also use the connection between frequency moments and heavy hitters discovered by Indyk and Woodruff. However, we do not use the layers method; we employ recursion instead. For streaming appli- cations, recursion can be helpful if it is possible to reduce computations to a single instance of a smaller 2 2 n. problem. This is the approach that we take. More specifically, we show that, given an algorithm for "heavy hitters," it is possible to reduce such a problem on a vector of size n to a single computation of a random vector of size approximately 1 This simple observation follows from elementary arguments such as Chebychev or Hoeffding inequality. We then employ this observation recursively and show that log(n) recursive calls can give an algorithm that already matches the bounds from [5]. Further, it is possible to reduce the number of recursive calls log(n) to log log(n) by applying the same argument, but stopping after O(log log(n)) steps. At the depth O(log log(n)) of the recursion, the number of positive frequencies in a corresponding vector is polylogarithmically smaller then n, with constant probability. Thus, any algorithm that works in polylog(n, m)n1−2/k space will approx- imate such a vector "for free." Employing such an algorithm at the bottom of log log(n) recursion reduces the log(n) factor to a poly(log log(n)) factor. Further, the same idea may be repeated at least constant num- ber of times; this is how we achieve our final bound. That is, we show that approximating the L1 norm of implicit vectors is practically equivalent to finding heavy hitters. Our method is quite general and works for any implicit vector. Further, the simplest variant of the argument requires only pairwise independence, giving an algorithm that requires only 4-wise independence, in contrast to existing methods that use pseudorandom generators. We gave a simple analysis that uses Chebyshev inequality. Better bounds are possible. For instance, as- suming total randomness of H we can apply tail bounds such as the Hoeffding bound or Bernstein inequality. For our purposes, even Chebyshev-like bounds are sufficient, thus we present only these bounds here. Also, pairwise independence allows us to simplify algorithms by avoiding pseudorandom generators. 1.1 Roadmap In Section 2 we introduce the basic argument and extend it to a special case, stuitable for streaming applica- tions, case in Section 3. In Section 4 we describe a generic algorithm for recursive computations. In Section 5 we use our method to obtain a better upper bound for the problem of frequency moments. 2 Recursive Sketches In this paper we denote by V the L1 norm of V , i.e., V =Pj∈[n] vj. Definition 2.1. Major elements Let V be a vector of dimensionality n with non-negative entries vi ≥ 0. Let 0 < α ≤ 1. An element vi is a α-major with respect to V if: vi ≥ αV . A set S ⊆ [n] is a α-core w.r.t. V if i ∈ S for any α-major vi. Lemma 2.2. Let V ∈ R[n] be a fixed vector and let S be an α-core w.r.t. V . Let H be a random vector with uniform zero-one entries hi, i ∈ [n] that are pairwise-independent. Define Then P (X − V ≥ ǫV ) ≤ α ǫ2 . X =Xi∈S vi + 2Xi /∈S hivi. Proof. Clearly, E(X) = V . By the properties of variance, by pairwise independence of hi and by the definition of α-core: v2 i ≤ αV 2. Thus, by Chebyshev inequality: V ar(X) = 4Xi /∈S v2 i V ar(hi) =Xi /∈S α ǫ2 . P (X − V ≥ ǫV ) ≤ 3 Corollary 2.3. Let V ∈ R[n] be a random vector and let S be an α-core w.r.t. V . Let H be a random vector independent of V and S with uniform zero-one entries hi, i ∈ [n] that are pairwise-independent. Define Then X =Xi∈S vi + 2Xi /∈S hivi. P (X − V ≥ ǫV ) ≤ α ǫ2 . Proof. For any fixed V and S the main claim is true since H is independent of V and S and by Lemma 2.2. Thus, the corollary follows. 2.0.1 Recursive Computations Let φ be a parameter. Let H1, . . . , Hφ be i.i.d. random vectors with zero-one entries that are uniformly distributed and pairwise independent. For two vectors of dimensionality n define Had(V, U ) to be their Hadamard product; i.e., Had(V, U ) is a vector of dimensionality n with entries viui. Define: V0 = V, and Vj = Had(Vj−1, Hj) for j = 1, . . . , φ. Denote by vj such that Sj is an α-core of Vj. Define the sequence i and hj i the i-th entry of Vj and Hj respectfully. Let S0, . . . , Sφ be a sequence of subsets of [n] and Xφ = Vφ. Fact 2.4. Xj = Xi∈Sj vj i + 2Xi /∈Sj hj+1 i vj i , j = 0, . . . , φ − 1, φ P ( [j=0 (Xj − Vj ≥ ǫVj)) ≤ (φ + 1)α ǫ2 . Proof. Consider fixed j < k. It follows from the definitions that Hj+1 is independent of Vj and Sj. Applying Corollary 2.3 and the union bound we obtain the proof. Consider the following recursive definition: Yφ = Xφ, Yj = 2Yj+1 + Xi∈Sj (1 − 2hj+1 i )vj i . Lemma 2.5. For any φ, γ, vector V and α = Ω( γ2 φ3 ): P (Y0 − V ≥ γV ) ≤ 0.2. Proof. Denote Err1 j = Vj − Xj and Err2 j = Vj − Yj. We can rewrite Xj = 2Vj+1 + Xi∈Sj (1 − 2hj+1 i )vj i . Thus Xj − Yj = 2(Vj+1 − Yj+1) = 2Err2 j+1 and Err2 j = Yj − Vj ≤ Xj − Vj + Xj − Yj = Err1 j + 2Err2 j+1. 4 By definition Err1 φ = Err2 φ = 0. Thus we can rewrite: Err2 0 ≤ Err1 0 + 2Err2 1 ≤ · · · ≤ Choose ǫ = γ 10(φ+1) ; we have by Fact 2.4: 2jErr1 j . φ Xj=0 φ P (Y0 − V ≥ γV ) = P (Err2 2jErr1 j ≥ γV ) ≤ P   φ  Xj=0  2jErr1 φ 0 ≥ γV ) ≤ P ( Xj=0  + P  j < ǫVj(cid:1)  ∩ j ≥ γV  \j=0(cid:0)Err1     2jVj ≥ 10(φ + 1)V  P  Xj=0  +  i! . ht ǫ2 φ Vj = Xi∈[n] vi j Yt=1 (φ + 1)α . φ [j=0 (Xj − Vj ≥ ǫVj)  ≤ For j > 0 we note that Vj is a random variable defined as: Since all Hj are mutually independent, we conclude that φ E( Xj=0 2jVj) = φ Xj=0 2j Xi∈[n] vi j Yt=1 E(ht i)!  = φ Xj=0 2j Xi∈[n] vi2−j  = (φ + 1)V . Thus, and by Markov inequality, we have φ P ( Xj=0 2jVj ≥ 10(φ + 1)V ) ≤ 0.1. Also, (φ+1)α ǫ2 ≤ 0.1 for sufficiently large α = Ω( γ2 φ3 ). Thus, P (Y0 − V ≥ γV ) ≤ 0.2. 3 An Extension: Approximate and Random Cores There are many ways to extend our basic result. We will explore one direction, when the cores are random and contain approximations of heavy hitters with high probability1. We consider vectors from a finite domain [m]n. 1In this section we limit our discussion to finite sets and discrete distributions. This limitation is artificial but sufficient for our applications; on the other hand it simplifies the presentation. 5 Definition 3.1. Let Ω be a finite set of real numbers. Define P airst to be a set of all sets of pairs of the form: {(i1, w1), . . . , (it, wt)}, 1 ≤ i1 < i2 < . . . it ≤ n, ij ∈ N, wj ∈ Ω. Further define P airs = ∅ ∪ n [t=1 P airst! . Definition 3.2. A non-empty set Q ∈ P airst, i.e., Q = {(i1, w1), . . . , (it, wt)} for some t ∈ [n], is (α, ǫ)- cover w.r.t. vector V ∈ [M ]n if the following is true: 1. ∀j ∈ [t](1 − ǫ)vij ≤ wj ≤ (1 + ǫ)vij . 2. ∀i ∈ [n] if vi is α-major then ∃j ∈ [t] such that ij = i. Definition 3.3. Let D be a probability distribution on P airs. Let V ∈ [m]n be a fixed vector. We say that D is δ-good w.r.t. V if for a random element Q of Pairs with distribution D the following is true: P (Q is (α, ǫ)-cover of V ) ≥ 1 − δ. Definition 3.4. Let g be a mapping from [M ]n to a set of all distributions on P airs. We say that g is δ-good if for any fixed V ∈ [M ]n the distribution g(V ) is δ-good w.r.t. V . Intuitively, g represents an output of an algorithm that finds heavy hitters (and their approximations) of input vector V w.p. 1 − δ. Definition 3.5. For non-empty Q ∈ P airs define Ind(Q) to be the set of indexes of Q. Formally, for Q ∈ P airs, denote Ind(Q) = {i : ∃j < t such that for j-th pair (ij, wj) of Q it is true that ij = i}. For i ∈ Ind(Q) denote by wQ(i) the corresponding approximation, i.e. if i = ij then wQ(i) = wj. (Note that since ij < ij+1 this is a valid definition.) For completeness, denote wQ(i) = 0 for i /∈ Ind(Q) and Ind(∅) = ∅. Now we are ready to repeat the arguments from the previous section. Corollary 3.6. Let V ∈ R[n] be a random vector. Let g be a δ-good mapping and let Q be a random element of P airs that is chosen according to a distribution g(V ). Let H be a random vector independent of V and Q with uniform zero-one entries hi, i ∈ [n] that are pairwise-independent. Define Then X ′ = Xi∈Ind(Q) vi + 2 Xi /∈Ind(Q) hivi. P (X ′ − V ≥ ǫV ) ≤ ǫ α2 + δ. Proof. Consider a fixed vector V0 and an event that V = V0. Conditioned on this event, the distribution g(V ) is fixed and δ-good w.r.t. V0. Consider the event that Q = Q0, where Q0 is an (α, ǫ)-cover w.r.t. V0. Conditioned on this event, Ind(Q) is an α-cover w.r.t. V0. Since H is independent of Q the claim is true for any such V0 by Lemma 2.2 and by union bound. Thus, the corollary follows. 6 3.0.2 Recursive Computations Let φ be a parameter. Let H1, . . . , Hφ be i.i.d. distributed and pairwise independent. Define: random vectors with zero-one entries that are uniformly V0 = V, and Vj = Had(Vj−1, Hj) for j = 1, . . . , φ. Denote by vj random element of Pairs with distribution g(Vi). Define wj(i) = wQj (i). Define the sequence: i the i-th entry of Vj and Hj respectfully. Let g be a δ-good mapping and let Qi be a i and hj X ′ j = Xi∈Ind(Qj ) vj i + 2 Xi /∈Ind(Qj) hj+1 i vj i , j = 0, . . . , φ − 1, and X ′ φ = Vφ. From Corollary 3.6 and by repeating the arguments from Fact 2.4 we obtain Fact 3.7. φ P ( [j=0(cid:0)X ′ j − Vj ≥ ǫVj(cid:1)) ≤ (φ + 1)( α ǫ2 + δ). Consider the following recursive definition. Let Y ′ vector Vφ and such that for any fixed Vφ: φ = Y ′ φ(Vφ) be a random variable that depends on random Also, define for j = 0, . . . , φ − 1: P (Y ′ φ − Vφ ≥ ǫVφ) ≤ δ. Y ′ j = 2Y ′ j+1 + Xi∈Ind(Qj) (1 − 2hj+1 i )wj i . Lemma 3.8. For any φ, γ, vector V ; for α = Ω( γ2 φ3 ) and δ = Ω( 1 φ): P (Y ′ 0 − V ≥ γV ) ≤ 0.2. Proof. Denote Err1 j = Vj − X ′ j, Err2 j = Vj − Y ′ j and Err3 i . We can rewrite j =Pi∈Ind(Qj ) wj(i) − vj (1 − 2hj+1 i )vj i . X ′ j = 2Vj+1 + Xi∈Ind(Qj) Thus X ′ j − Y ′ j ≤ 2Err2 j+1 + Err3 j and Err2 j = Y ′ j − Vj ≤ X ′ j − Vj + X ′ j − Y ′ j ≤ Err1 j + Err3 j + 2Err2 j+1. Thus we can rewrite: φ Err2 0 ≤ Err1 0 + Err3 0 + 2Err2 1 ≤ · · · ≤ 2kErr2 φ + 2jErr1 j + Choose ǫ = γ 30(φ+1) and denote Z = 2kErr2 j=0 2jErr1 j=0 2jErr3 j . Then P (Y ′ 0 − V ≥ γV ) = P (Err2 0 ≥ γV ) ≤ P (Z ≥ γV ) ≤ 2jErr3 j . φ Xj=0 Xj=0 j +Pφ φ +Pφ 7 φ φ P  (Z ≥ γV ) ∩ j < ǫVj(cid:1) \j=0(cid:0)Err1   φ ≥ ǫVφ(cid:1) + P  [j=0(cid:0)Err1 P (cid:0)Err2  ∩ j < ǫVj(cid:1) \j=0(cid:0)Err3    + P  j ≥ ǫVj(cid:1) [j=0(cid:0)Err3  φ < ǫVφ(cid:1) ∩(cid:0)Err2  + j ≥ ǫVj(cid:1)  . φ φ φ, we have P (Err2 φ ≥ ǫVφ) ≤ δ. Also, by the definition of Qj and union Note that by the definition of Y ′ bound, Thus and by Fact 3.7: P ( φ [j=0 (Err3 j ≥ ǫVj)) ≤ (φ + 1)δ. P (Y ′ φ 0 − V ≥ γV ) ≤ P  Xj=0  2jVj ≥ 10(φ + 1)V  α ǫ2 + 2δ).  + (φ + 2)( The lemma follows by repeating the concluding arguments from Lemma 2.5. 4 A Generic Algorithm Let D be a stream as in Definition 1.1. For a function H : [n] 7→ {0, 1}, define DH to be a sub-stream of D that contains only elements p ∈ D such that H(p) = 1. Let V = V (D) be an implicit vector of dimensionality n defined by a stream, e.g., a frequency moment vector from Definition 1.1. We say that a vector V is separable if for any H, we have Had(V (D), H) = V (DH ). Let HH(D, α, ǫ, δ) be an algorithm that produces (α, ǫ)-cover w.r.t. V (D) w.p. 1 − δ, i.e., produces δ-good distribution w.r.t. V (D) for some suitable finite set of Pairs, as defined in Definition 3.1. Algorithm 4.1. Recursive Sum[0](D, ǫ) 1. Generate φ = O(log(n)) pairwise independent zero-one vectors H1, . . . , Hφ. Denote Dj to be a stream DH1H2...Hj . 2. Compute, in parallel, random cores Qj = HH(Dj, φ3 ǫ2 , ǫ, 1 φ) 3. If F0(Vφ) > 1010 then output 0 and stop. Otherwise compute precisely Yφ = Vφ. 4. For each j = φ − 1, . . . , 0, compute Yj = 2Yj+1 −Pi∈Ind(Qj)(1 − 2hj 5. Output Y0. i )wQj (i). Theorem 4.2. Algorithm 4.1 computes (1 ± ǫ)-approximation of V and errs w.p. at most 0.3. The algorithm log(n) )) memory bits, where µ is the space required by the above algorithm uses O(log(n)µ(n, HH. ǫ2 log3(n) , ǫ, 1 1 Proof. The correctness follows directly from the description of the algorithm and Lemma 3.8 and Markov inequality. The memory bounds follows from the direct computations. 8 5 Approximating Large Frequency Moments on Streams We apply the developed above technique to the problem of frequency moments. Fact 5.1. Let V be a vector of dimensionality n with non-negative entries and let n0 be a number of non-zero entries in V . Let 0 < α < 1 and let vi be such that vk 2 k −1 2 k n j . Then v2 i ≥ 0.5α i ≥ αPj∈[n] vk j . 0 Pj6=i v2 (cid:16)Pj6=i vk j(cid:17) 2 k ≤ Proof. If n0 = 0 the fact is trivial. Otherwise, by Holder's inequality, Pj6=i v2 1− 2 0 α− 2 k k v2 i . n j ≤ n 1− 2 k 0 The famous Count-Sketch [11] algorithm finds all α-heavy elements. In particular, the following is a corollary from [11]. Theorem 5.2. (from [11]) Let at be the frequency of the t-th most frequent element. There exists an algorithm that w.p. 1 − δ outputs t pairs (i, f ′ i ≤ (1 + ǫ)fi and such that all elements with Pi∈[n],fi<at fi ≥ (1 − ǫ)at appear in the list. The algorithm uses O((t + ) log(m/δ) log(m)) memory bits. i ) such that (1 − ǫ)fi ≤ f ′ f 2 i (ǫat)2 Combining with Fact 5.1 we obtain Corollary 5.3. There exists an algorithm that w.p. 1 − δ outputs O(α−1) pairs (i, f ′k f ′k i ≤ (1 + ǫ)f k O((α−1 + k2 i and such that all elements with f k ǫ2 α−2/kn1−2/k) log(m/δ) log(m)) memory bits. i ≥ αPj∈[n] f k i ≤ j appear in the list. The algorithm uses i ) such that (1 − ǫ)f k The algorithm from Corollary 5.3 defines a δ-good distribution w.r.t. to the input vector V (D) over some finite set2 from Definition 3.1. Denote the algorithm from Corollary 5.3 by CS(D, α, ǫ, δ). Thus, combining with Algorithm 4.1 if gives an algorithm errs w.p. δ, outputs (1 ± ǫ)-approximation of Fk and log(mn) log(m) log1+6/k(n) log(1/δ)) memory bits, nearly matching the bound in [5]. uses O( Denote this algorithm by A0(D, ǫ, δ). We can improve the bound further recursively: ǫ2+4/k n1−2/k k2 0 Algorithm 5.4. Recursive Fk[1](D, ǫ) 1. Generate φ = O(log log(n)) pairwise independent zero-one vectors H1, . . . , Hφ. Denote Dj to be a stream DH1H2...Hφ. 2. Compute, in parallel, Qj = CS(Dj, ǫ2 φ3 , ǫ, 1 100φ ) 3. Compute Yφ = A0(Dφ, ǫ, 0.1). 4. For each j = φ − 1, . . . , 0, compute Yj = 2Yj+1 −Pi∈Ind(Qj)(1 − 2hj 5. Output Y0. i )wQj (i). F0(Dφ) ≤ n log10(n) . Thus, executing A0 for n′ = There exists a constant c such that for φ = c log log(n), except with a small constant probability, we obtain an approximation of Fk(Dφ) using k2 ǫ2+4/k n1−2/k log(mn) log(m)) memory bits. Since φ = O(log log(n)), the complexity of the new algo- k2 ǫ2+4/k n1−2/k log(mn) log(m)(log log(n))4). Repeating this argument a constant number log10(n) n O( rithm becomes O( of times we arrive at: 2Indeed, we can define the finite set Ω from Definition 3.1 as a set of all possible outputs of Count-Sketch executed over all vectors on [m]n. This is a finite set (for finite n, m) and thus we can define Pairs accordingly. 9 Theorem 5.5. Define g1(n) = log(n) and gt(n) = log(gt−1(n)). For any constant t there ex- 1 3 and uses ist an algorithm computes a (1 ± ǫ)-approximation of Fk(D), errs w.p. O(ctk2ǫ−2−(4/k)n1− 2 k gt(n) log(m) log(nm)) memory bits, where ct is a constant that depends on t. at most We note also that it is possible to reduce the complexity to O(n1− 2 k gt(n) log(n)(log(n) + log log(m))), at least for constant ǫ, using, instead of CountSketch, the variant of the AMS sketch and the ideas from [7]. References [1] Noga Alon, Yossi Matias, and Mario Szegedy. The space complexity of approximating the frequency moments. J. Comput. Syst. Sci., 58(1):137 -- 147, 1999. [2] Ziv Bar-Yossef, T. S. Jayram, Ravi Kumar, and D. Sivakumar. An information statistics approach to data stream and communication complexity. J. Comput. Syst. Sci., 68(4):702 -- 732, 2004. [3] Ziv Bar-Yossef, T. S. Jayram, Ravi Kumar, D. Sivakumar, and Luca Trevisan. Counting distinct elements in a data stream. In RANDOM '02: Proceedings of the 6th International Workshop on Randomization and Approximation Techniques, pages 1 -- 10, London, UK, 2002. Springer-Verlag. [4] Paul Beame, T. S. Jayram, and Atri Rudra. Lower bounds for randomized read/write stream algorithms. In STOC '07: Proceedings of the thirty-ninth annual ACM symposium on Theory of computing, pages 689 -- 698, New York, NY, USA, 2007. ACM. [5] Lakshminath Bhuvanagiri, Sumit Ganguly, Deepanjan Kesh, and Chandan Saha. Simpler algorithm for estimating frequency moments of data streams. In SODA, pages 708 -- 713, 2006. [6] Vladimir Braverman and Rafail Ostrovsky. Measuring independence of datasets. In STOC '10: Pro- ceedings of the 42nd ACM symposium on Theory of computing, pages 271 -- 280, New York, NY, USA, 2010. ACM. [7] Vladimir Braverman and Rafail Ostrovsky. Zero-one frequency laws. In STOC '10: Proceedings of the 42nd ACM symposium on Theory of computing, pages 281 -- 290, New York, NY, USA, 2010. ACM. [8] Bo Brinkman and Moses Charikar. On the impossibility of dimension reduction in l1. J. ACM, 52(5):766 -- 788, 2005. [9] Amit Chakrabarti, Graham Cormode, and Andrew McGregor. Robust lower bounds for communication and stream computation. In STOC '08: Proceedings of the 40th annual ACM symposium on Theory of computing, pages 641 -- 650, New York, NY, USA, 2008. ACM. [10] Amit Chakrabarti, Subhash Khot, and Xiaodong Sun. Near-optimal lower bounds on the multi-party In IEEE Conference on Computational Complexity, communication complexity of set disjointness. pages 107 -- 117, 2003. [11] Moses Charikar, Kevin Chen, and Martin Farach-Colton. Finding frequent items in data streams. In ICALP '02: Proceedings of the 29th International Colloquium on Automata, Languages and Program- ming, pages 693 -- 703, London, UK, 2002. Springer-Verlag. [12] Don Coppersmith and Ravi Kumar. An improved data stream algorithm for frequency moments. In SODA, pages 151 -- 156, 2004. [13] Graham Cormode, Mayur Datar, Piotr Indyk, and S. Muthukrishnan. Comparing data streams using hamming norms (how to zero in). IEEE Trans. on Knowl. and Data Eng., 15(3):529 -- 540, 2003. 10 [14] Joan Feigenbaum, Sampath Kannan, Martin Strauss, and Mahesh Viswanathan. An approximate l1- difference algorithm for massive data streams. In FOCS '99: Proceedings of the 40th Annual Symposium on Foundations of Computer Science, page 501, Washington, DC, USA, 1999. IEEE Computer Society. [15] Philippe Flajolet and G. Nigel Martin. Probabilistic counting algorithms for data base applications. J. Comput. Syst. Sci., 31(2):182 -- 209, 1985. [16] Sumit Ganguly. Estimating frequency moments of data streams using random linear combinations. In APPROX-RANDOM, pages 369 -- 380, 2004. [17] Sumit Ganguly and Graham Cormode. On estimating frequency moments of data streams. In APPROX '07/RANDOM '07: Proceedings of the 10th International Workshop on Approximation and the 11th In- ternational Workshop on Randomization, and Combinatorial Optimization. Algorithms and Techniques, pages 479 -- 493, Berlin, Heidelberg, 2007. Springer-Verlag. [18] Piotr Indyk. Stable distributions, pseudorandom generators, embeddings, and data stream computation. J. ACM, 53(3):307 -- 323, 2006. [19] Piotr Indyk and David Woodruff. Optimal approximations of the frequency moments of data streams. In STOC '05: Proceedings of the thirty-seventh annual ACM symposium on Theory of computing, pages 202 -- 208, New York, NY, USA, 2005. ACM. [20] T. S. Jayram, Andrew McGregor, S. Muthukrishnan, and Erik Vee. Estimating statistical aggregates on probabilistic data streams. In PODS '07: Proceedings of the twenty-sixth ACM SIGMOD-SIGACT- SIGART symposium on Principles of database systems, pages 243 -- 252, New York, NY, USA, 2007. ACM. [21] T. S. Jayram and David P. Woodruff. The data stream space complexity of cascaded norms. In FOCS '09: Proceedings of the 2009 50th Annual IEEE Symposium on Foundations of Computer Science, pages 765 -- 774, Washington, DC, USA, 2009. IEEE Computer Society. [22] Daniel M. Kane, Jelani Nelson, Ely Porat, and David P. Woodruff. Fast moment estimation in data streams in optimal space. CoRR, abs/1007.4191, 2010. [23] Daniel M. Kane, Jelani Nelson, and David P. Woodruff. On the exact space complexity of sketching In Proceedings of the 21st Annual ACM-SIAM Symposium on Discrete and streaming small norms. Algorithms (SODA 2010), 2010. [24] Daniel M. Kane, Jelani Nelson, and David P. Woodruff. An optimal algorithm for the distinct elements problem. In PODS '10: Proceedings of the twenty-ninth ACM SIGMOD-SIGACT-SIGART symposium on Principles of database systems of data, pages 41 -- 52, New York, NY, USA, 2010. ACM. [25] Ping Li. Compressed counting. In SODA '09: Proceedings of the Nineteenth Annual ACM -SIAM Symposium on Discrete Algorithms, pages 412 -- 421, Philadelphia, PA, USA, 2009. Society for Industrial and Applied Mathematics. [26] Morteza Monemizadeh and David P. Woodruff. http://www.almaden.ibm.com/cs/people/dpwoodru/soda10.ppt. [27] Morteza Monemizadeh and David P. Woodruff. 1-pass relative-error lp-sampling with applications. In SODA, pages 1143 -- 1160, 2010. [28] Jelani Nelson and David P. Woodruff. Fast manhattan sketches in data streams. In PODS '10: Proceed- ings of the twenty-ninth ACM SIGMOD-SIGACT-SIGART symposium on Principles of database systems of data, pages 99 -- 110, New York, NY, USA, 2010. ACM. 11 [29] Noam Nisan. Pseudorandom generators for space-bounded computation. Combinatorica, 12:449 -- 461, 1992. 10.1007/BF01305237. [30] David Woodruff. Optimal space lower bounds for all frequency moments. In SODA '04: Proceedings of the fifteenth annual ACM-SIAM symposium on Discrete algorithms, pages 167 -- 175, 2004. 12
1507.02268
3
1507
2016-03-02T12:58:32
Optimal approximate matrix product in terms of stable rank
[ "cs.DS", "cs.LG", "stat.ML" ]
We prove, using the subspace embedding guarantee in a black box way, that one can achieve the spectral norm guarantee for approximate matrix multiplication with a dimensionality-reducing map having $m = O(\tilde{r}/\varepsilon^2)$ rows. Here $\tilde{r}$ is the maximum stable rank, i.e. squared ratio of Frobenius and operator norms, of the two matrices being multiplied. This is a quantitative improvement over previous work of [MZ11, KVZ14], and is also optimal for any oblivious dimensionality-reducing map. Furthermore, due to the black box reliance on the subspace embedding property in our proofs, our theorem can be applied to a much more general class of sketching matrices than what was known before, in addition to achieving better bounds. For example, one can apply our theorem to efficient subspace embeddings such as the Subsampled Randomized Hadamard Transform or sparse subspace embeddings, or even with subspace embedding constructions that may be developed in the future. Our main theorem, via connections with spectral error matrix multiplication shown in prior work, implies quantitative improvements for approximate least squares regression and low rank approximation. Our main result has also already been applied to improve dimensionality reduction guarantees for $k$-means clustering [CEMMP14], and implies new results for nonparametric regression [YPW15]. We also separately point out that the proof of the "BSS" deterministic row-sampling result of [BSS12] can be modified to show that for any matrices $A, B$ of stable rank at most $\tilde{r}$, one can achieve the spectral norm guarantee for approximate matrix multiplication of $A^T B$ by deterministically sampling $O(\tilde{r}/\varepsilon^2)$ rows that can be found in polynomial time. The original result of [BSS12] was for rank instead of stable rank. Our observation leads to a stronger version of a main theorem of [KMST10].
cs.DS
cs
Optimal approximate matrix product in terms of stable rank Michael B. Cohen∗ Jelani Nelson† David P. Woodruff‡ Abstract We give two different characterizations of the type of dimensionality-reducing map Π that can be used for spectral error approximate matrix multiplication (AMM). Both imply a random data-oblivious Π with m = O(r/ε2) rows suffices, where r is the maximum stable rank, i.e. squared ratio of Frobenius and operator norms, of the matrices being multiplied. This answers the main open question of [MZ11, KVZ14], and is optimal for any random oblivious map. Both characterizations apply to a general class of random Π, and one even to deterministic Π. Recall an (ε, δ, d)-oblivious subspace embedding (OSE) distribution D over matrices Π ∈ Rm×n is such that for any d-dimensional linear subspace E of Rn, P(k(ΠU )T (ΠU )− Ik > ε) < δ, where the columns of U form an orthonormal basis for E. In one characterization, we show if this tail bound was established via the moment method, then to obtain AMM it suffices that D be an (ε, δ, 2r)-OSE. That is, we show being an OSE for dimension (i.e. rank) k implies black box AMM for matrices of stable rank k. Once this is shown, our main result is then just a simple corollary of the fact that subgaussian maps with m = Ω((d + log(1/δ))/ε2) rows are (ε, δ, d)-OSE's. Also, for all known OSE's, the best analyses indeed are via the moment method (or tools such as matrix Chernoff, which themselves also imply moment bounds). Thus our theorem can be applied to a much more general class of sketching matrices than just the subgaussian sketches in [MZ11, KVZ14], in addition to achieving better bounds. This includes fast subspace embeddings such as the Subsampled Randomized Hadamard Transform [Sar06, LWM+07] or sparse subspace embeddings [CW13, MM13, NN13, Coh16], or even constructions that may be developed in the future, to show that rank bounds in their analyses in previous work can automatically be replaced with stable rank. Our second characterization identifies certain deterministic conditions which if satisfied imply the AMM guarantee. We show these conditions are sufficiently precise to yield optimal results for subgaussian maps and even a deterministic Π such as the truncated SVD. Our main theorem, via connections with spectral error matrix multiplication proven in pre- vious work, implies quantitative improvements for approximate least squares regression and low rank approximation [Sar06], and implies faster low rank approximation for popular kernels in machine learning such as the gaussian and Sobolev kernels. Our main result has also already been applied to improve dimensionality reduction guarantees for k-means clustering [CEM+15], and also implies new results for nonparametric regression when combined with results in [YPW15]. Lastly, we point out a minor but interesting observation that the proof of the "BSS" deter- ministic row-sampling result of [BSS12] can be modified to show that for any matrices A, B of stable rank at most r, one can achieve the spectral norm guarantee for approximate matrix mul- tiplication of AT B using a deterministic sampling matrix with O(r/ε2) non-zero entries which can be found in polynomial time. The original result of [BSS12] was for rank instead of stable rank. Our observation leads to a stronger version of a main theorem of [KMST10]. ∗MIT. [email protected]. Supported by Akamai Presidential Fellowship and NSF grant CCF-1111109. †Harvard. [email protected]. Supported by NSF grant IIS-1447471 and CAREER CCF-1350670, ONR grant N00014-14-1-0632 and Young Investigator N00014-15-1-2388, and a Google Faculty Research Award. ‡IBM Almaden. [email protected]. Supported by XDATA program of the Defense Advanced Research Projects Agency (DARPA), administered through Air Force Research Laboratory FA8750-12-C-0323. 1 Introduction Much recent work has successfully utilized randomized dimensionality reduction techniques to speed up solutions to linear algebra problems, with applications in machine learning, statistics, optimiza- tion, and several other domains; see the recent monographs [HMT11, Mah11, Woo14] for more details. In our work here, we give new spectral norm guarantees for approximate matrix multipli- cation (AMM). Aside from AMM being interesting in its own right, it has become a useful primitive in the literature for analyzing algorithms for other large-scale linear algebra problems as well. We show applications of our new guarantees to speeding up standard algorithms for generalized regres- sion and low-rank approximation problems. We also describe applications of our results to k-means clustering (discovered in [CEM+15]) and nonparametric regression [YPW15]. In AMM we are given A, B each with a large number of rows n, and the goal is to compute some matrix C such that kC − AT BkX is "small", for some norm k · kX . Furthermore, we would like to compute C much faster than the usual time required to exactly compute AT B. Work on randomized methods for AMM began with [DKM06], which focused on k·kX = k·kF , i.e., Frobenius norm error. They showed by picking an appropriate sampling matrix Π ∈ Rm×n, k(ΠA)T (ΠB) − AT BkF ≤ εkAkFkBkF (1) with good probability, if m = Ω(1/ε2). By a sampling matrix, we mean the rows of Π are indepen- dent, and each row is all zero except for a 1 in a random location according to some appropriate distribution. If A ∈ Rn×d and B ∈ Rn×p, note (ΠA)T (ΠB) can be computed in O(mdp) time once ΠA and ΠB are formed, as opposed to the straightforward O(ndp) time to compute AT B. The Frobenius norm error guarantee of Eq. (1) was also later achieved in [Sar06, Lemma 6] via a different approach, with some later optimizations to the parameters in [KN14, Theorem 6.2]. The approach of Sarl´os was not via sampling, but rather to use a matrix Π drawn from a distribution satisfying an "oblivious Johnson-Lindenstrauss (JL)" guarantee, i.e. a distribution D over Rm×n satisfying the following condition for some ε, δ ∈ (0, 1/2): 2 − kxk2 ∀x ∈ Rn, P (2) Π∼D(cid:0)kΠxk2 2 > εkxk2 2(cid:1) < δ. Such a matrix Π can be taken with m = O(ε−2 log(1/δ)) [JL84]. Furthermore, one can take Π to be a Fast JL transform [AC09] (or any of the follow-up improvements [AL13, KW11, NPW14, Bou14, HR16]) or a sparse JL transform [DKS10, KN14] to speed up the computation of ΠA and ΠB. One could also use the Thorup-Zhang sketch [TZ12] combined with a certain technique of [LBKW14] (see [Woo14, Theorem 2.10] for details) to efficiently boost success probability. Other than Frobenius norm error, the main other error guarantee investigated in previous work is spectral error. That is, we would like kC − AT Bk to be small, where kMk denotes the largest singular value of M . If one is interested in applying AT B to some set of input vectors then this type of error is the most meaningful, since kC − AT Bk being small is equivalent to kCxk ≈ kAT Bxk for any x. The first work along these lines was again by [DKM06], who gave a procedure based on entry-wise sampling of the entries of A and B. The works [DMM06, SS11] showed that row-sampling according to leverage scores also provides the desired guarantee with few samples. Then [Sar06], combined with a quantitative improvement in [CW13], showed that one can take a Π drawn from an oblivious JL distribution with δ = 2−Θ(r) where r(·) denotes rank and r = r(A) + r(B). Then for Π with m = O((r + log(1/δ))/ε2), with probability at least 1− δ over Π, (3) k(ΠA)T (ΠB) − AT Bk ≤ εkAkkBk. 1 As we shall see shortly via a very simple lemma (Lemma 1), a sufficient deterministic condition implying Eq. (3) is that Π is an O(ε)-subspace embedding for the r-dimensional subspace spanned by the columns of A, B. The notion of a subspace embedding was introduced by [Sar06]. Definition 1. Π is an ε-subspace embedding for U ∈ Rn×r, U T U = I, if Π satisfies Eq. (3) with A = B = U , i.e. k(ΠU )T (ΠU ) − Ik ≤ ε. This is equivalent to ∀x ∈ Rr, (1 − ε)kxk2 2 ≤ (1 + ε)kxk2 2, i.e. Π preserves norms of all vectors in the subspace spanned by the columns U . An (ε, δ, r)-oblivious subspace embedding (OSE) is a distribution D over Rm×n such that 2 ≤ kΠU xk2 ∀U ∈ Rn×r, U T U = I, P Π∼D (k(ΠU )T (ΠU ) − Ik > ε) < δ. Fast subspace embeddings Π, i.e. such that the products ΠA and ΠB can be computed quickly, are known using variants on the Fast JL transform such as the Subsampled Randomized Hadamard Transform (SRHT) [Sar06, LWM+07, Tro11, LDFU13] (also see a slightly improved analysis of the SRHT in Section A.2) or via sparse subspace embeddings [CW13, MM13, NN13, LMP13, CLM+15, Coh16]. In most applications it is important to have a fast subspace embedding to shrink the time it takes to transform the input data to a lower-dimensional form. The SRHT is a construction of a Π such that ΠA can be computed in time O(nd log n) (see Section A.2 for details of the construction). The sparse subspace embedding constructions have some parameter m rows and exactly s non-zero entries per column, so that ΠA can be computed in time O(s· nnz(A)), where nnz(·) is the number of non-zero entries, and there is a tradeoff in the upper bounds between m and s. An issue addressed by the work of [MZ11] is that of robustness. As stated above, achieving Eq. (3) requires Π be a subspace embedding for an r-dimensional subspace. However, consider the case when A (and similarly for B) is of high rank but can be expressed as the sum of a low-rank matrix plus high-rank noise of small magnitude, i.e., A = A + EA for A of rank r( A) ≪ r, and where kEAk is very small but EA has high (even full) rank. One would hope the noise could be ignored, but standard results require Π to have a number of rows at least as large as r, regardless of how small the magnitude of the noise is. Another case of interest (as we will see in Section 3) is when A and B are each of high rank, but their singular values decay at some appropriate rate. As discussed in Section 3, in several applications where AMM is not the final goal but rather is used as a primitive in analyzing an algorithm for some other problem (such as k-means clustering or nonparametric regression), the matrices that arise do indeed have such decaying singular values. The work [MZ11] remedied this by considering the stable ranks r(A), r(B) of A and B. Define r(A) = kAk2 F /kAk2. Note r(A) ≤ r(A) always, but can be much less if A has a small tail of singular values. Let r denote r(A) + r(B). Among other results, [MZ11] showed that to achieve Eq. (3) with good probability, one can take Π to be a random (scaled) sign matrix with either m = Ω(r/ε4) or m = Ω(r log(d + p)/ε2) rows. As noted in follow-up work [KVZ14], both the 1/ε4 dependence and the log(d + p) factor are undesirable. In their data-driven low dimensional embedding application, they wanted a dimension m independent of the original dimensions, which are assumed much larger than the stable rank, and also wanted lower dependence on 1/ε. To this end, [KVZ14] defined the nuclear rank as nr(A) = kAk∗/kAk and showed m = Ω( nr/ε2) rows suffice for nr = nr(A) + nr(B). Here kAk∗ is the nuclear norm, i.e., sum of singular values of A. Since kAk2 F is the sum of squared singular values, it is straightforward to see that nr(A) ≥ r(A) always. Thus there is a tradeoff: the stable rank guarantee is worsened to nuclear rank, but dependence on 1/ε is improved to quadratic. We show switching to the weaker nr guarantee is unnecessary by showing quadratic dependence on 1/ε holds even with stable rank. This answers the main open question of [MZ11, KVZ14]. 2 To state our results in a more natural way, we rephrase our main result to say that we achieve k(ΠA)T (ΠB) − AT Bk ≤ εs(cid:18)kAk2 + kAk2 F k (cid:19)(cid:18)kBk2 + kBk2 k (cid:19). F (4) for an arbitrary k ≥ 1, and we do so by using subspace embeddings for O(k)-dimensional subspaces in a certain black box way (which will be made precise soon) regardless of the ranks of A, B. Remark 1. Note that our previously stated main contribution is equivalent, since one could set k = r(A) + r(B) to arrive at the conclusion that subspace embeddings for O(r)-dimensional subspaces yield the guarantee in Eq. (3). Alternatively one could obtain the Eq. (4) guarantee via Eq. (3) with error parameter ε′ = Θ(ε · min{1,p(r(A) · r(B))/k}). Henceforth, we use the following definition. Definition 2. For conforming matrices AT , B, we say Π satisfies the (k, ε)-approximate spectral norm matrix multiplication property ((k, ε)-AMM) for A, B if Eq. (4) holds. If Π is random and satisfies (k, ε)-AMM with probability 1−δ for any fixed A, B, then we say Π satisfies (k, ε, δ)-AMM. Our main contribution: We give two different characterizations for Π supporting (k, ε)-AMM, both of which imply (k, ε, δ)-AMM Π having m = O((k + log(1/δ))/ε2) rows. The first char- acterization applies to any OSE distribution for which a moment bound has been proven for k(ΠU )T (ΠU ) − Ik (which is true for the best analyses of all known OSE's). In this case, we show a black box theorem: any (ε, δ, 2k)-OSE provides (k, ε, δ)-AMM. Since matrices with subgaussian entries and m = Ω((k + log(1/δ))/ε2) are (ε, δ, 2k)-OSE's, our originally stated main result follows. This result is optimal, since [NN14] shows any randomized distribution over Π with m rows having the (k, ε, δ)-AMM property must have m = Ω((k + log(1/δ))/ε2) (the hard instance there is when A = B = U has orthonormal columns, and thus rank and stable rank are equal). Our second characterization identifies certain deterministic conditions which, if satisfied by Π, imply the desired (k, ε)-AMM property. These conditions are of the form: (1) Π should preserve a certain set of O(log(1/ε)) different subspaces of varying dimensions (all depending on k, ε and not on the ranks of A, B) with varying distortions, and (2) for a certain two matrices in our analysis, left-multiplication by Π should not increase their operator norms by more than an O(1) factor. These conditions are chosen carefully so that matrices with subgaussian entries and m = Ω(k/ε2) satisfy all conditions simultaneously with high probability, again thus proving our main result while also suggesting that the conditions we have identified are the "right" ones. Due to the black box reliance on the subspace embedding primitive in our proofs, Π need not only be a subgaussian map. Thus not only do we improve on m compared with previous work, but also in terms of the general class of Π our result applies to. For example given our first characterization, not only does it suffice to use a random sign matrix with Ω(k/ε2) rows, but in fact one can apply our theorem to more efficient subspace embeddings such as the SRHT or sparse subspace embeddings, or even constructions discovered in the future. That is, one can automatically transfer bounds proven for the subspace embedding property to the (k, ε)-AMM property. Thus, for example, the best known SRHT analysis (in our appendix, see Theorem 9) implies (k, ε, δ)-AMM for m = Ω((k + log(1/(εδ)) log(k/δ))/ε2) rows. For sparse subspace embeddings, the analysis in [Coh16] implies m = Ω(k log(k/δ)/ε2) suffices with s = O(log(k/δ)/ε) non-zeroes per column of Π. The only reason for the log k loss in m for these particular distributions is not due to our theorems, 3 but rather due to the best analyses for the simpler subspace embedding property in previous work already incurring the extra log k factor (note being a subspace embedding for a k-dimensional subspace is simply a special case of (k, ε)-AMM where A = B = U has k orthonormal columns). In the case of the SRHT, this extra log k factor is actually necessary [Tro11]; for sparse subspace embeddings, it is conjectured that the log k factor can be removed and that m = Ω((k+log(1/δ))/ε2) actually suffices to obtain an OSE [NN13, Conjecture 14]. We also discuss in Remark 3 that one can set Π to be Π1 · Π2 where Π1 has subgaussian entries with O(k/ε2) rows, and Π2 is some other fast OSE (such as the SRHT or sparse subspace embedding), and thus one could obtain the best of both worlds: (1) Π has O(k/ε2) rows, and (2) can be applied to any A ∈ Rn×d in time T + O(km′d/ε2), where T is the (fast) time to apply Π2 to A, and m′ is the number of rows of Π2. For example, by appropriate composition as discussed in Remark 3, Π can have O(k/ε2) rows and support multiplying ΠA for A ∈ Rn×d in time O(nnz(A)) + O(ε−O(1)(k3 + k2d)). We also observe the proof of the main result of [BSS12] can be modified to show that given any A, B each with n rows, and given any ε ∈ (0, 1/2), there exists a diagonal matrix Π ∈ Rn×n with O(k/ε2) non-zero entries, and that can be computed by a deterministic polynomial time algorithm, achieving (k, ε)-AMM. The original work of [BSS12] achieved Eq. (3) with m = O(r/ε2) for r being the sum of ranks of A, B. The work [BSS12] stated their result for the case A = B, but the general case of potentially unequal matrices reduces to this case; see Section 4. Our observation also turns out to yield a stronger form of [KMST10, Theorem 3.3]; also see Section 4. As mentioned, aside from AMM being interesting on its own, it is a useful primitive widely used in analyses of algorithms for several other problems, including k-means clustering [BZMD15, CEM+15], nonparametric regression [YPW15], linear least squares regression and low-rank ap- proximation [Sar06], approximating leverage scores [DMMW12], and several other problems (see [Woo14] for a recent summary). For all these, analyses of correctness for algorithms based on dimensionality reduction via some Π rely on Π satisfying AMM for certain matrices in the analysis. After making certain quantitative improvements to connections between AMM and applications, and combining them with our main result, in Section 3 we obtain the following new results. 1. Generalized regression: Given A ∈ Rn×d and B ∈ Rn×p, consider the problem of comput- ing X∗ = argminX∈Rd×p kAX − Bk. It is standard that X∗ = (AT A)+AT B where (·)+ is the Moore-Penrose pseudoinverse. The bottleneck here is computing AT A, taking O(nd2) time. A popular approach is to instead compute X = ((ΠA)T (ΠA))+(ΠA)T ΠB, i.e., the minimizer of kΠAX − ΠBk. Note that computing (ΠA)T (ΠA) (given ΠA) only takes a smaller O(md2) amount of time. We show that if Π satisfies (k, O(√ε))-AMM for UA, P ¯AB, and is also an O(1)-subspace embedding for a certain r(A)-dimensional subspace (see Theorem 3), then kA X − Bk2 ≤ (1 + ε)kPAB − Bk2 + (ε/k)kPAB − Bk2 F where PA is the orthogonal projection onto the column space of A, P ¯A = I − PA, and UA has orthonormal columns forming a basis for the column space of A. The punchline is that if the regression error P ¯AB has high actual rank but stable rank only on the order of r(A), then we obtain multiplicative spectral norm error with Π having fewer rows. Generalized regression is a natural extension of the case when B is a vector, and arises for example in Regularized Least Squares Classification, where one has multiple (non-binary) labels, and for each label one creates a column of B; see e.g. [CLL+10] for this and variations. 4 2. Low-rank approximation: We are given A ∈ Rn×d and integer k ≥ 1, and we want to compute Ak = argminr(X)≤k kA− Xk. The Eckart-Young theorem implies Ak is obtained by truncating the SVD of A to the top k singular vectors. The standard way to use dimensionality reduction for speedup, introduced in [Sar06], is to let S = ΠA then compute A = APS. Then return Ak, the best rank-k approximation of A, instead of Ak (it is known Ak can be computed more efficiently than Ak; see [CW09, Lemma 4.3]). We show if Π satisfies (k, O(√ε))-AMM for Uk and A − Ak, and is a (1/2)-subspace embedding for the column space of Ak, then k Ak − Ak2 ≤ (1 + ε)kA − Akk2 + (ε/k)kA − Akk2 F . The punchline is that if the stable rank of the tail A − Ak is on the same order as the rank parameter k, then standard algorithms from previous work for Frobenius multiplicative error actually in fact also provide spectral multiplicative error. This property indeed holds for any k for popular kernel matrices in machine learning such as the gaussian and Sobolev kernels (see [RHV11] and Examples 2 and 3 of [YPW15]), and low-rank approximation of kernel matrices has been applied to several machine learning problems; see [GM13] for a discussion. We also explain in Section 3 how our result has already been applied in recent work on dimen- sionality reduction for k-means clustering [CLM+15], and how it generalizes results in [YPW15] on dimensionality reduction for nonparametric regression to use a larger class of embeddings Π. 1.1 Preliminaries and notation We frequently use the singular value decomposition (SVD). For a matrix A ∈ Rn×d of rank r, consider the compact SVD A = UAΣAV T A where UA ∈ Rn×r and VA ∈ Rd×r each have orthonormal columns, and ΣA is diagonal with strictly positive diagonal entries (the singular values of A). We assume (ΣA)i,i ≥ (ΣA)j,j for i < j. We let PA = UAU T A denote the orthogonal projection operator onto the column space of A. We use span(A) to refer to the subspace spanned by A's columns. Often for a matrix A we write Ak as the best rank-k approximation to A under Frobenius or spectral error (obtained by writing the SVD of A then setting all (ΣA)i,i to 0 for i > k). We often denote A− Ak as A¯k. For matrices with orthonormal columns, such as UA, (UA)k denotes the n× k matrix formed by removing all but the first k columns of U . When A is understood from context, we often write U ΣV T instead of UAΣAV T A , and Uk to denote (UA)k (and Σk for (ΣA)k, etc.). 2 Analysis of matrix multiplication for stable rank First we record a simple lemma relating subspace embeddings and AMM. Lemma 1. Let E = span{A, B}, and let Π be an ε-subspace embedding for E. Then Eq. (3) holds. Proof. First, without loss of generality we may assume kAk = kBk = 1 since we can divide both sides of Eq. (3) by kAk · kBk. Let U be a matrix whose columns form an orthonormal basis for E. Then note for any x, y we can write Ax = U w, By = U z where kwk ≤ kxk,kzk ≤ kyk. Then k(ΠA)T (ΠB) − AT Bk = sup = sup kxk=kyk=1hΠAx, ΠByi − hAx, Byi kwk,kzk≤1hΠU z, ΠU wi − hU z, U wi 5 = k(ΠU )T (ΠU ) − Ik < ε (cid:4) Lemma 1 implies that if A, B each have rank at most r, it suffices for Π to have Ω(r/ε2) rows. In the following two subsections, we give two different characterizations for Π to provide (k, ε)- AMM, both only requiring Π to have Ω(k/ε2) rows, independent of r. 2.1 Characterization for (k, ε, δ)-AMM via a moment property Here we provide a way to obtain (k, ε)-AMM for any Π whose subspace embedding property has been established using the moment method, e.g. sparse subspace embeddings [MM13, NN13, Coh16], dense subgaussian matrices as analyzed in Section A.1, or even the SRHT as analyzed in Section A.2. Our approach in this subsection is inspired by the introduction of the "JL-moment property" in [KN14] to analyze approximate matrix multiplication with Frobenius error. The following is a generalization of [KN14, Definition 6.1], which was only concerned with d = 1. Definition 3. A distribution D over Rm×n has (ε, δ, d, ℓ)-OSE moments if for all matrices U ∈ Rn×d with orthonormal columns, E Π∼D(cid:13)(cid:13)(ΠU )T (ΠU ) − I(cid:13)(cid:13) ℓ < εℓ · δ Note that this is just a special case of bounding the expectation of an arbitrary function of k(ΠU )T (ΠU ) − Ik. The arguments below will actually apply to any nonnegative, convex, increas- ing function of k(ΠU )T (ΠU ) − Ik2, but we restrict to moments for simplicity of presentation. The acronym "OSE" refers to oblivious subspace embedding, a term coined in [NN13] to refer to dis- tributions over Π yielding a subspace embedding for any fixed subspace of a particular bounded dimension with high probability. We start with a simple lemma. Lemma 2. Suppose D satisfies the (ε, δ, 2d, ℓ)-OSE moment property and A, B are matrices with (1) the same number of rows, and (2) sum of ranks at most 2d. Then E Π∼D(cid:13)(cid:13)(ΠA)T (ΠB) − AT B(cid:13)(cid:13) ℓ < εℓkAkℓkBkℓ · δ Proof. First, we apply Lemma 1 to A and B, where U forms an orthonormal basis for the subspace span{columns(A), columns(B)}, showing that Therefore (cid:13)(cid:13)(ΠA)T (ΠB) − AT B(cid:13)(cid:13) ≤(cid:13)(cid:13)(ΠU )T (ΠU ) − I(cid:13)(cid:13)kAkkBk. E Π∼D(cid:13)(cid:13)(ΠA)T (ΠB) − AT B(cid:13)(cid:13) ℓ ≤ E Π∼D(cid:13)(cid:13)(ΠU )T (ΠU ) − I(cid:13)(cid:13) ℓ kAkℓkBkℓ < εℓkAkℓkBkℓ · δ (cid:4) Then, just as [KN14, Theorem 6.2] showed that having OSE moments with d = 1 implies approximate matrix multiplication with Frobenius norm error, here we show that having OSE moments for larger d implies approximate matrix multiplication with operator norm error. 6 Theorem 1. Given k, ε, δ ∈ (0, 1/2), let D be any distribution over matrices with n columns with the (ε, δ, 2k, ℓ)-OSE moment property for some ℓ ≥ 2. Then, for any A, B, P Π∼D(cid:18)k(ΠA)T (ΠB) − AT Bk > εq(kAk2 + kAk2 F /k)(kBk2 + kBk2 F /k)(cid:19) < δ (5) Proof. We can assume A, B each have orthogonal columns. This is since, via the full SVD, there exist orthogonal matrices RA, RB such that ARA and BRB each have orthogonal columns. Since neither left nor right multiplication by an orthogonal matrix changes operator norm, k(ΠA)T (ΠB) − AT Bk = k(ΠARA)T (ΠBRB) − (ARA)T BRBk. Thus, we replace A by ARA and similarly for B. We may also assume the columns a1, a2, . . . of A are sorted so that kaik2 ≥ kai+1k2 for all i. Henceforth we assume A has orthogonal columns in this sorted order (and similarly for B, with columns bi). Now, treat A as a block matrix in which the columns are blocked into groups of size k, and similarly for B (if the number of columns of either A or B is not divisible by k, then pad them with all-zero columns until they are, which does not affect the claim). Let the spectral norm of the ith block of A be si = ka(i−1)·k+1k2, and for B denote the spectral norm of the ith block as ti = kb(i−1)·k+1k2. These equalities for A, B hold since their columns are orthogonal and sorted by norm. We claimPi s2 F /k (and similarly for Pi t2 1 = kA′1k ≤ kAk. i ≤ kAk2 +kAk2 i ). To see this, let the blocks of A be A′1, . . . , A′q where si = kA′ik. Note s2 Also, for i > 1 we have s2 i = ka(i−1)·k+1k2 2 ≤ Thus kajk2 2 = 1 kkA′i−1k2 F . 1 k X(i−2)·k+1≤j≤(i−1)·k Xi>1 s2 i ≤ kAk2 F /k. Define C = (ΠA)T (ΠB) − AT B. Let v{i} denote the ith block of a vector v (the k-dimensional vector whose entries consist of entries (i − 1) · k + 1 to i · k of v), and C{i},{j} the (i, j)th block of C, a k × k matrix (the entries in C contained in the ith block of rows and jth block of columns). Now, kCk = supkxk=kyk=1 xT Cy. For any such vectors x and y, we define new vectors x′ and y′ whose coordinates correspond to entire blocks: we let x′i = kx{i}k, with y′ defined analogously. We similarly define C′ with entries corresponding to blocks of C, where C′i,j = kC{i},{j}k. Then xT Cy ≤ x′T C′y′, simply by bounding the contribution of each block. Thus it suffices to upper bound kC′k, which we bound by its Frobenius norm kC′kF . Now, recalling for a random variable X that kXkℓ denotes (EXℓ)1/ℓ and using Minkowski's inequality (that k · kℓ is a norm for ℓ ≥ 1), kkC′k2 k(ΠA′i)T (ΠB′j) − A′T Fkℓ/2 =(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13) Xi,j ≤Xi,j kk(ΠA′i)T (ΠB′j) − A′T ≤Xi,j ε2s2 j · δ2/ℓ (Lemma 2) i t2 i B′jk2(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)(cid:13)ℓ/2 i B′jk2kℓ/2 7 s2 i! · = ε2 Xi Xj ≤(cid:18)εq(kAk2 + kAk2 t2 j  δ2/ℓ F /k)(kBk2 + kBk2 F /k)δ1/ℓ(cid:19)2 Fkℓ/2 Now, EkC′kℓ F = kkC′k2 P kC′k > εr(kAk2 + kAk2 ℓ/2, implying )(kBk2 + kBk2 k k F F )! ≤ P kC′kF > εr(kAk2 + kAk2 k F )(kBk2 + kBk2 k F )! F < EkC′kℓ (cid:18)εq(kAk2 + kAk2 ≤ δ. k F )(kBk2 + kBk2 k F )(cid:19)ℓ (cid:4) We now discuss the implications of applying Theorem 1 to specific OSE's. In Section A.1 we show that if Π has independent subgaussian entries and Subgaussian maps: m = Ω((k+log(1/δ))/ε2) rows, then it satisfies the (ε, δ, 2k, Θ(k+log(1/δ))) OSE moment property. Thus Theorem 1 applies to show that such Π will satisfy (k, ε, δ)-AMM. SRHT: The SRHT is the matrix product Π = SHD where D ∈ Rn×n is n × n diagonal with independent ±1 entries on the diagonal, H is a "bounded orthonormal system" (i.e. an orthogonal matrix in Rn×n with maxi,j Hi,j = O(1/√n)), and the m rows of S are independent and each samples a uniformly random element of [n]. Bounded orthonormal systems include the discrete Fourier matrix and the Hadamard matrix; thus such Π exist supporting matrix-vector multiplication in O(n log n) time. Thus when computing ΠA for some n× d matrix A, this takes time O(nd log n) (by applying Π to A column by column). In Theorem 9 we show that the SRHT with m = Ω((k + log(1/(εδ)) log(k/δ))/ε2) satisfies the (ε, δ, 2k, log(k/δ))-OSE moment property, and thus provides (k, ε, δ)-AMM. Interestingly our analysis of the SRHT in Section A.2 seems to be asymptotically tighter than any other analyses in previous work even for the basic subspace embedding property, and even slightly improves the by now standard analysis of the Fast JL transform given in [AC09]. Sparse subspace embeddings: The sparse embedding distribution with parameters m, s is as follows [CW13, NN13, KN14]. The matrix Π has m rows and n columns. The columns are indepen- dent, and for each column exactly s uniformly random entries are chosen without replacement and set to ±1/√s independently; other entries in that column are set to zero. Alternatively, one could use the CountSketch [CCF04]: the m rows are equipartitioned into s sets of size m/s each. The columns are independent, and in each column we pick exactly one row from each of the s partitions and set the corresponding entry in that column to ±1/√s uniformly; the rest of the entries in the column are set to 0. Note ΠA can be multiplied in time O(s· nnz(A)), and thus small s is desirable. It was shown in [MM13, NN13], slightly improving [CW13], that either of the above distributions satisfies the (ε, δ, k, 2)-OSE moment property for m = Ω(k2/(ε2δ)), s = 1, and hence (k, ε, δ)-AMM 8 It was also shown (though this particular conclusion follows easily from [KN14, Theorem 6.2]). in [Coh16], improving upon [NN13], that they satisfy the (ε, δ, k, log(k/δ))-OSE moment property, and hence also (k, ε, δ)-AMM, for m = Ω(Bk log(k/δ)/ε2), s = Ω(logB(k/δ)/ε) for any B > 2. It is conjectured that for B = O(1), m = Ω((k + log(1/δ))/ε2) should suffice [NN13, Conjecture 14]. Remark 2. The work [Coh16] does not explicitly discuss the OSE moment property for sparse subspace embeddings. Rather, [Coh16] bounds E eE2ℓ/ε = O(k) for E = k(ΠU )T (ΠU ) − Ik and ℓ = log(k/δ). Note though for x ≥ 0 and integer ℓ ≥ 1, xℓ ≤ ℓ! · ex ≤ ℓℓ · ex by Taylor expansion of the exponential. Setting x = 2ℓE/ε, [Coh16] thus implies E(2ℓE/ε)ℓ ≤ ℓℓ · E eE2ℓ/ε = O(k). Thus E Eℓ = O(k) · (ε/2)ℓ < δ by choice of ℓ, which is the (ε, δ, k, log(k/δ))-OSE moment property. Remark 3. Currently there appears to be a tradeoff: one can either use Π such that ΠA can be computed quickly, such as sparse subspace embeddings or the SRHT, but then the number of rows m is at least k log k. Alternatively one could achieve the optimal m = O(k/ε2) using subgaussian Π, but then multiplying by Π is slower: O(mnd) time for A ∈ Rn×d. However, settling for a tradeoff is unnecessary. One can actually obtain the "best of both worlds" by composition, i.e. the multiplication Π = Π1 · Π2 of two matrices both supporting AMM. Thus Π2 could be a fast matrix providing AMM to low (but suboptimal) dimension, and Π1 a "slow" (e.g. subgaussian) matrix with the optimal O(k/ε2) number of rows. In fact one can even set Π = Π1Π2Π3 where Π3 is the sparse subspace embedding with O(k2/ε2) rows and s = 1, Π2 is the SRHT, and Π1 is a subgaussian matrix. Then ΠA will have the desired O(k/ε2) rows and can be computed in time O(nnz(A)) + O(ε−O(1)(k3 + k2d)); see Section A.3 for justification. 2.2 Characterization for (k, ε, )-AMM via deterministic events Here we provide a different characterization for achieving (k, ε)-AMM. Without loss of generality we assume max{kAk2,kAk2 F ≤ k). Let w, w′ each be minimal such that kA ¯wk,kB ¯w′k ≤ ε/C′ for some sufficiently large constant C′ (which will be set in the proof of Theorem 2). It was shown that w, w′ = O(k/ε2) in the proof of Theorem 3.2 (i.b) in [MZ11]. Write the SVDs Aw = UAw ΣAwV T F /k} = 1 (so kAk2,kBk2 ≤ 1 and kAk2 F /k} = max{kBk2,kBk2 Aw , Bw′ = UBw′ ΣBw′ V T F ,kBk2 Bw′ . For 0 ≤ i ≤ log2(1/ε2) define D′i as set of all columns of UAw , UBw′ whose corresponding squared singular values (from ΣAw, ΣBw′ ) are at least 1/2i. Let DAw be the set of min{k, w} largest singular vectors from UAw , and define DBw′ similarly. Define Di = D′i ∪ DAw ∪ DBw′ . Let si denote the dimension of span(Di), and note the si are non-decreasing. Let si be si after rounding up to the nearest power of 2. Group all i with the same value of si into groups G1, G2, . . . , Glog2(1/ε2). For example if for i = 0, 1, 2, 3 the si are 3, 4, 15, 16 then the si are 4, 4, 16, 16 and G1 = {0, 1}, G2 = {2, 3}. Let vj be the common value of si for i in Gj. Lemma 3. Pi si/2i ≤ 8k. Proof. Define s = DAw ∪ DBw′ ≤ 2k and let s′i denote the dimension of span(D′i). Then the above summation is at mostPi(s/2i + s′i/2i) ≤ 4k +Pi s′i/2i. It thus suffices to bound the second summand by 4k. Note that we can find a basis for D′i among the columns of UAw , UBw′ with corresponding squared singular value at least 1/2i, so let ai + bi = s′i, where ai is the number of columns of UAw in the basis and bi the number of columns of UBw′ in the basis. Then by averaging, if the inequality of the lemma statement does not hold then eitherPi ai/2i > 2k orPi bi/2i > 2k. Without loss of generality assume the former. 9 Consider an arbitrary column of UAw , and suppose it has squared singular value in the range Its contribution to Pi ai/2i is therefore [1/2i, 1/2i−1). Then it is in span(D′j) for all j ≥ i. 1/2i + 1/2i+1 + . . . which is at most 2/2i = 1/2i−1. It follows thatPi ai/2i ≤ 2k, since the squared Frobenius norm of Aw is at most k. This is a contradiction to Pi ai/2i > 2k. Now we prove the main theorem of this subsection. (cid:4) Theorem 2. Suppose that the following conditions hold: (1) If w + w′ ≤ k, then Π is an ε/C-subspace embedding for the subspace spanned by the columns of Aw, Bw′. Otherwise if w + w′ > k, then for each 0 ≤ i ≤ log2(1/ε2), Π is an εi/C-subspace embedding for span(Di′) with εi = min(cid:26) 1 2 , εr vj k(cid:27) where i′ is the largest i with si in Gj. (2) kΠA ¯wk,kΠB ¯w′k ≤ ε/C. Then Eq. (4) holds as long as C is smaller than some fixed universal constant. Proof. We would like to bound k(ΠA)T (ΠB) − AT Bk ≤ k(ΠAw)T ΠBw′ − AT α + k(ΠA ¯w)T ΠB ¯w′k } {z {z ∆ β +k(ΠA ¯w)T ΠBw′k +k(ΠAw)T ΠB ¯w′k wBw′k } } } {z +kAT +kAT ¯wB ¯w′k ¯wBw′k } {z } {z {z +kAT wB ¯w′k } {z Θ γ η ζ (6) Using kXY k ≤ kXk · kY k for any conforming matrices X, Y , we see ∆ ≤ ε2/C 2 by condition (2). Furthermore by the definition of w, w′ we know kA ¯wk,kB ¯w′k ≤ ε/C′, and thus ζ + η + Θ ≤ 2ε/C′ + (ε/C′)2. Note condition (1) implies that Π is a (1/2)-subspace embedding for the subspace spanned by columns of Aw, Bw′ (by taking i maximal). Thus by both conditions we have β, γ ≤ (ε/C)(1 + 1/2). Thus assume w + w′ > k. Then we have k(ΠAw)T ΠBw′ − AT It only remains to bound α. If w + w′ ≤ k, then we are done by condition (1) and Lemma 1. Let x, y be any unit norm vectors. Write x = x1 + x2 + . . . + xb for b = log2(1/ε2), where xi is the restriction of x to coordinates for which the corresponding squared singular values kxk=kyk=1(cid:12)(cid:12)(cid:10)ΠUAw ΣAw x, ΠUBw′ ΣBw′ y(cid:11) −(cid:10)UAw ΣAw x, UBw′ ΣBw′ y(cid:11)(cid:12)(cid:12) in ΣAw are in (1/2i, 1/2i−1]. Similarly define y1, . . . , yb. Then (cid:10)ΠUAw ΣAw x, ΠUBw′ ΣBw′ y(cid:11) − (cid:10)UAw ΣAw x, UBw′ ΣBw′ y(cid:11) equals wBw′k = sup b (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) Xi=1 b Xj=1(cid:10)ΠUAw ΣAw xi, ΠUBw′ ΣBw′ yj(cid:11) −(cid:10)UAw ΣAw xi, UBw′ ΣBw′ yj(cid:11)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) yj+ −*UAw ΣAw xi,Xj≤i Xi=1 *ΠUAw ΣAw xi, ΠUBw′ ΣBw′Xj≤i ≤ b (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) 10 UBw′ ΣBw′ yj+(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) + b Xj=1 *ΠUAw ΣAwXi≤j xi, ΠUBw′ ΣBw′ yj+ −*Xi≤j (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) (7) xi, yj+(cid:12)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) yj+(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) Di. Therefore by property (1) and Lemma 1, We bound the first sum, as bounding the second is similar. Note UAw ΣAw xi, UBw′ ΣBw′Pj≤i yj ∈ (cid:12)(cid:12)(cid:12)(cid:12)(cid:12) *ΠUAw ΣAw xi, ΠUBw′ ΣBw′Xj≤i C2(i−1)/2 · kxik · kyk yj+ −*UAw ΣAwxi, UBw′ ΣBw′Xj≤i ≤ εi (8) ε C2(i−1)/2 ·r 2si k · kxik ≤ where Eq. (8) used that the corresponding v value in property (1) is at most 2si. Returning to Eq. (7) and applying Cauchy-Schwarz and Lemma 3, *ΠUAw ΣAw xi, ΠUBw′ ΣBw′Xj≤i b Xi=1(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) b UBw′ ΣBw′ yj+(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) yj+ −*UAw ΣAwxi,Xj≤i Xi=1 ≤ kxik2!1/2 2i!1/2 C√k · b · b Xi=1 Xi=1 2√8ε C ≤ ≤ 2ε si ε C2(i−1)/2 ·r 2si k · kxik We thus finally have that Eq. (6) is at most (2√8 + 3)ε/C + +(ε/C)2 + 2ε/C′ + (ε/C′)2, which is at most ε for C, C′ sufficiently large constants. (cid:4) Now we discuss some implications of Theorem 2 for specific Π. Example 1: Let Π have O(k/ε2) rows forming an orthonormal basis for the span of the columns of Aw, Bw′. Property (1) is satisfied for every i in fact with εi = 0. Property (2) is also satisfied since kΠA ¯wk ≤ kΠk · kA ¯wk ≤ ε, and similarly for bounding kΠB ¯w′k. Example 2: Let Π be a random m×n matrix with independent entries that are subgaussian with variance 1/m. For example, the entries of Π may be N (0, 1/m), or uniform in {−1/√m, 1/√m}. Let m be Θ((k + log(1/δ))/ε2). As mentioned in Section A.1, such Π is an ε-subspace embedding for a k-dimensional subspace with failure probability δ. For property (1) of Theorem 2, if w+w′ ≤ k then we would like Π to be an ε-subspace embedding for a subspace of dimension at most k, which holds with failure probability δ. If w + w′ > k then we would like Π to be an εi-subspace embedding for span(Di′) for all 1 ≤ i ≤ log2(1/ε2) simultaneously. Note maxj vj ≤ 2(w + w′) = O(k/ε2), and thus maxj vj ≤ m. Thus for a subspace under consideration Di′ for i′ ∈ Gj, we have failure probability δvj /k for our choice of m. By construction every vj is at least k, and the vj increase at least geometrically. Thus our total failure probability is, by a union bound,Pj δvj /k ≤Pj δ2j−1 = O(δ). Property (2) of Theorem 2 is satisfied with failure probability δ by [RV13, Theorem 3.2]. 11 3 Applications Spectral norm approximate matrix multiplication with dimension bounds depending on stable rank has immediate applications for the analysis of generalized regression and low-rank approximation problems. We also point out to the reader recent applications of this result to kernelized ridge regression [YPW15] and k-means clustering [CEM+15]. 3.1 Generalized regression Here we consider generalized regression: attempting to approximate a matrix B as AX, with A of rank at most k. Let PA be the orthogonal projection operator to the column space of A, with P ¯A = I − P ; then the natural best approximation will satisfy AX = PAB. This minimizes both the Frobenius and spectral norms of AX − B. A standard approximation algorithm for this is to replace A and B with sketches ΠA and ΠB, then solve the reduced problem exactly (see e.g. [CW09], Theorem 3.1). This will produce X = ((ΠA)T ΠA)−1(ΠA)T ΠB A X = A((ΠA)T ΠA)−1(ΠA)T ΠB = UA((ΠUA)T ΠUA)−1(ΠUA)T ΠB. Below we give a lemma on the guarantees of the sketched solution in terms of properties of Π. Theorem 3. If Π 1. satisfies the (k,pε/8)-approximate spectral norm matrix multiplication property for UA, P ¯AB 2. is a (1/2)-subspace embedding for the column space of A (which is implied by Π satisfying the spectral norm approximate matrix multiplication property for UA with itself ) then kA X − Bk2 ≤ (1 + ε)kPAB − Bk2 + (ε/k) · kPAB − Bk2 F . (9) Proof. We may write: kA X − Bk2 2 = kUA((ΠUA)T ΠUA)−1(ΠUA)T ΠB − Bk2 = kUA((ΠUA)T ΠUA)−1(ΠUA)T Π(PAB + P ¯AB) − PAB − P ¯ABk2 = kPAB + UA((ΠUA)T ΠUA)−1(ΠUA)T ΠP ¯AB − PAB − P ¯ABk2 = kUA((ΠUA)T ΠUA)−1(ΠUA)T ΠP ¯AB − P ¯ABk2. So far, we have shown that the error depends only on P ¯AB and not PAB (with the third line following from the fact that the sketched regression is exact on PAB). Now, in the last line, we can see that the two terms lie in orthogonal column spaces (the first in the span of A, the second orthogonal to it). For matrices X and Y with orthogonal column spans, kX + Y k2 ≤ kXk2 +kY k2, so this is at most kUA((ΠUA)T ΠUA)−1(ΠUA)T ΠP ¯ABk2 + kP ¯ABk2. 12 Spectral submultiplicativity then implies the first term is at most (kUAk · k((ΠUA)T ΠUA)−1k · k(ΠUA)T ΠP ¯ABk)2. kUAk is 1, since UA is orthonormal. ((ΠUA)T ΠUA)−1 is at most 2, since Π is a subspace embedding for UA. Finally, k(ΠUA)T ΠP ¯ABk is at most pε/8·q(kUAk2 + kUAk2 F /k) =p(ε/8) · 2 · (kPAB − Bk2 + kPAB − Bk2/k). Multiplying these together, squaring, and adding the remaining kP ¯ABk2 term gives a bound of F /k)(kP ¯ABk2 + kP ¯ABk2 (1 + ε)kPAB − Bk2 + (ε/k) · kPAB − Bk2 F as desired. (cid:4) 3.2 Low-rank approximation Now we apply the generalized regression result from Section 3.1 to obtain a result on low-rank k , where Uk has only k columns approximation: approximating a matrix A in the form Uk Σk V T and both Uk and Vk have orthonormal columns. Here, we consider a previous approach (see e.g. [Sar06]): 1. Let S = ΠA. 2. Let PS be the orthogonal projection operator to the row space of S. Let A = APS. 3. Compute a singular value decomposition of A, and keep only the top k singular vectors. Return the resulting low rank approximation Ak of A. It turns out computing Ak can be done much more quickly than computing Ak; see details in [CW09, Lemma 4.3]. Let Ak be the exact k-truncated SVD approximation of A (and thus the best rank-k approx- imation, in the spectral and Frobenius norms), and let Uk be the top k column singular vectors, and A¯k = A − Ak be the tail. Theorem 4. If Π 1. satisfies the (k,pε/8)-approximate spectral norm matrix multiplication property for Uk, A¯k 2. is a (1/2)-subspace embedding for the column space of Uk then kA − Akk2 ≤ (1 + ε)kA − Akk2 + (ε/k)kA − Akk2 F (10) Proof. Note that this procedure chooses the best possible (in the spectral norm) rank-k approxi- mation to A subject to the constraint of lying in the row space of S. Thus, the spectral norm error can be no worse than the error of a specific such matrix we exhibit. We simply choose the matrix obtained by running our generalized regression algorithm from A onto Uk, with Π: Uk((ΠUk)T ΠUk)−1(ΠUk)T ΠA This is rank-k by construction, since it is multiplied by Uk, and it lies in the row space of S = ΠA since that is the rightmost factor. On the other hand, it is an application of the regression algorithm to A where the optimum output is Ak (since that is the projection of A onto the space of Uk). Plugging this into Eq. (9) gives the desired result. (cid:4) 13 3.3 Kernelized ridge regression In nonparametric regression one is given data yi = f∗(xi) + wi for i = 1, . . . , n, and the goal is to recover a good estimate for the function f∗. Here the yi are scalars, the xi are vectors, and the wi are independent noise, often assumed to be distributed as mean-zero gaussian with some variance σ2. Unlike linear regression where f∗(xi) is assumed to take the form hβ, xi for some vector β, in nonparametric regression we allow f∗ to be an arbitrary function from some function space. Naturally the goal then is to recover some f from the data so that, as n grows, the probability that f is "close" to f∗ increases at some good rate. The recent work [YPW15] considers the well studied problem of obtaining f so that k f − f∗k2 is small with high probability over the noise w, where one uses the definition n kf − gk2 n = 1 n n Xi=1 (f (xi) − g(xi))2. The work [YPW15] considers the case where f∗ comes from a Hilbert space H of functions f such that f is guaranteed to be square integrable, and the map x 7→ f (x) is a bounded linear functional. The function f is then defined to be the optimal solution to the Kernel Ridge Regression (KRR) problem of computing f LS = argmin f∈H ( 1 2n n H) Xi=1 (yi − f (xi))2 + λn · kfk2 (11) for some parameter λn. It is known that any H as above can be written as the closure of the set of all functions g(·) = αik(·, zi), (12) N Xi=1 over all α ∈ RN and vectors z1, . . . , zN for some positive semidefinite kernel function k. Further- more, the optimal solution to Eq. (11) can be expressed as f LS =Pn · k(·, xi) for some choice of weight vector αLS, and it is known that kf LS − f∗kn will be small with high probability, over the randomness in w, if λn is chosen appropriately (see [YPW15] for background references and precise statements). i=1 αLS i After rewriting Eq. (11) using Eq. (12) and defining a matrix K with Ki,j = k(xi, xj), one arrives at a reformulation for KRR of computing αLS = argmin α∈Rn (cid:26) 1 2n αT K 2α − 1 n αT Ky + λnαT Kα(cid:27) =(cid:18) 1 n K 2 + 2λnK(cid:19)−1 1 n · Ky, which can be computed in O(n3) time. The work [YPW15] then focuses on speeding this up, by instead computing a solution to the lower-dimensional problem αLS = argmin α∈Rm (cid:26) 1 2n αT ΠK 2ΠT α − 1 n αT ΠKy + λnαT ΠKΠT α(cid:27) =(cid:18) 1 n ΠK 2ΠT + 2λnΠKΠT(cid:19)−1 1 n · ΠKy and then returning as f the function specified by the weight vector α = ΠT αLS . Note that once various matrix products are formed (where the running time complexity depends on the Π being used), one only needs to invert an m × m matrix thus taking O(m3) time. They then prove that k f − f∗kn is small with high probability as long as Π satisfies two deterministic conditions (see the proof of Lemma 2 [YPW15, Section 4.1.2], specifically equation (26) in that work): 14 • Π is a (1/2)-subspace embedding for a particular low-dimensional subspace • kΠBk = O(kBk) for a particular matrix B of low stable rank (B is U D2 in [YPW15]). Note kΠBk = k(ΠB)T ΠBk1/2 ≤(cid:0)k(ΠB)T ΠB − BT Bk + kBT Bk(cid:1)1/2 ≤ k(ΠB)T ΠB−BT Bk1/2+kBk, and thus it suffices for Π to provide the approximate matrix multiplication property for the product BT B, where B has low stable rank. The first bullet simply requires a subspace embedding in the standard sense, and for the second bullet [YPW15] avoided AMM by obtaining a bound on kΠBk directly by their own analyses for gaussian Π and the SRHT (in the gaussian case, it also follows from [RV13, Theorem 3.2]). Our result thus provides a unifying analysis which works for a larger and general class of Π, including for example sparse subspace embeddings. 3.4 k-means clustering In the works [BZMD15, CEM+15], the authors considered dimensionality reduction methods for k-means clustering. Recall in k-means clustering one is given n points x1, . . . , xn ∈ Rd, as well as an integer k ≥ 1, and the goal is to find k points y1, . . . , yk ∈ Rd minimizing k j=1 kxi − yjk2 2. min n Xi=1 That is, the n points can be partitioned arbitrarily into k clusters, then a "cluster center" should be assigned to each cluster so as to minimize sums of squared Euclidean distances of each of the n points to their cluster centers. It is a standard fact that once a partition P = {P1, . . . , Pk} of the n points into clusters is fixed, the optimal cluster centers to choose are the centroids of the points in each of the k partitions, i.e. yj = (1/Pj) ·Pi∈Pj One key observation common to both of the works [BZMD15, CEM+15] is that k-means cluster- ing is closely related to the problem of low-rank approximation. More specifically, given a partition P = {P1, . . . , Pk}, define the n × k matrix XP by 1√Pj xi. , if i ∈ Pj otherwise (XP )i,j =  0, Let A ∈ Rn×d have rows x1, . . . , xn. Then the k-means problem can be rewritten as computing argminPkA − XP X T P Ak2 F where P ranges over all partitions of {1, . . . , n} into k sets. It is easy to verify that the non-zero columns of XP are orthonormal, so XP X T P is the orthogonal projection onto the column space of XP . Thus if one defines S as the set of all rank at most k orthogonal projections obtained as XP X T P for some k-partition P, then the above can be rewritten as the constrained rank-k projection problem of computing (13) argminP∈Sk(I − P )Ak2 F . 15 P is the centroid of the points in i's partition in P. One can verify this by hand, since the rows of A are the points xi, and the ith row of P A for P = XP X T The work [CEM+15] showed that if S is any subset of projections of rank at most k (henceforth rank-k projections) and Π ∈ Rm×d satisfies certain technical conditions to be divulged soon, then if P ∈ S satisfies (14) k(I − P )AΠTk2 then k(I − P )Ak2 F ≤ F ≤ γ · minP∈Sk(I − P )AΠTk2 F , (1 + ε) (1 − ε) · γ · minP∈Sk(I − P )Ak2 F . (15) (16) (17) One set of sufficient conditions for Π is as follows (see [CEM+15, Lemma 10]). Let Ak denote the best rank-k approximation to A and let A¯k = A − Ak. Define Z ∈ Rd×r for r = 2k by Z = Vr, i.e. the top r right singular vectors of A are the columns of Z. Define B1 = Z T and √k kA¯kkF · (A− AZZ T ). Define B ∈ R(n+r)×d as having B1 as its first r rows and B2 as its lower B2 = n rows. Then [CEM+15, Lemma 10] states that Eq. (14) implies Eq. (15) as long as k(ΠBT )T (ΠBT ) − BBTk < ε, and (cid:12)(cid:12)kΠB2k2 F − kB2k2 F(cid:12)(cid:12) ≤ εk One can easily check kBk2 = 1 and kBk2 F ≤ 3k, so the stable rank r(B) is at most 3k. Thus Eq. (16) is implied by the (3k, ε/2)-AMM property for BT , BT , and our results apply to show that Π can be taken to have m = O((k +log(1/δ))/ε2) rows to have success probability 1−δ for Eq. (16). Obtaining Eq. (17) is much simpler and can be derived from the JL moment property (see the proof of [KN14, Theorem 6.2]). Without our results on stable-rank AMM provided in this current work, [CEM+15] gave a different analysis, avoiding [CEM+15, Lemma 10], which required Π to have m = Θ(k· log(1/δ)/ε2) rows (note the product between k and log(1/δ) instead of the sum). 4 Stable rank and row selection As well as random projections, approximate matrix multiplication (and subspace embeddings) by row selection are also common in algorithms. This corresponds to setting Π to a diagonal matrix S with relatively few nonzero entries. Unlike random projections, there are no oblivious distributions of such matrices S with universal guarantees. Instead, S must be determined (either randomly or deterministically) from the matrices being embedded. There are two particularly algorithmically useful methods for obtaining such S. The first is importance sampling: independent random sampling of the rows, but with nonuniform sam- pling probabilities. This is analyzed using matrix Chernoff bounds [AW02], and for the case of k-dimensional subspace embedding or approximate matrix multiplication of rank-k matrices, it can produce O(k(log k)/ε2) samples [SS11]. The second method is the deterministic selection method given in [BSS12], often called "BSS", choosing only O(k/ε2) rows. This still runs in polynomial time, but originally required many relatively expensive linear algebra steps and thus was slower in general; see [LS15] for runtime improvements. The matrix Chernoff methods can be extended to the stable-rank case, making even the log factor depend only on the stable rank, using "intrinsic dimension" variants of the bounds as pre- sented in Chapter 7 of [Tro15]. Specifically, Theorem 6.3.1 of that work can be applied with each 16 n summands each equal to 1 the probability of choosing a particular row i equal to i bi − AT B(cid:17), where ai is the ith row of A, and i is random with aT n(cid:16) 1 pi We here give an extension of BSS that covers low stable rank matrices as well. pi = kaik2 + kbik2 Pj kajk2 + kbjk2 Theorem 5. Given an n by d matrix A such that kAk2 ≤ 1 and kAk2 there exists a diagonal matrix S with O(k/ε2) nonzero entries such that F ≤ k, and an ε ∈ (0, 1), k(SA)T (SA) − AT Ak ≤ ε Such an S can be computed by a polynomial-time algorithm. When AT A is the identity, this is just the original BSS result. It is also stronger than Theorem 3.3 of [KMST10], implying it when A is the combination of the rowspN/T · vi from that theorem statement with an extra column containing the costs, and a constant ǫ. The techniques in that paper, on the other hand, can prove a result comparable to Theorem 5, but with the row count scaling as k/ε3 rather than k/ε2. Proof. The proof closely follows the original proof of BSS. However, for simplicity, and because the tight constants are not needed for most applications, we do not include [BSS12, Claim 3.6] and careful parameter-setting. At each step, the algorithm will maintain a partial approximation Z = (SA)T (SA) (the matrix "A" in [BSS12]), with S beginning as 0. Additionally, we keep track of upper and lower "walls" Xu and Xl; in the original BSS these are just multiples of the identity. The final S will be returned by the algorithm (rescaled by a constant so that the average of the upper and lower walls is AT A). We will maintain the invariants tr(A(Xu − Z)−1AT ) ≤ 1 tr(A(Z − Xl)−1AT ) ≤ 1. (18) (19) These are the so-called upper and lower potentials from BSS. We also require Xu ≺ Z ≺ Xl; recall M ≺ M′ means that M′ − M is positive definite. Note that unlike [BSS12], here we do not apply a change of variables making AT A the identity (to avoid confusion, since that would change the Frobenius norm). This is the reason for the slightly more complicated form of the potentials. In the original BSS, Xu and Xl were always scalar multiples of the identity (here, without the change of variables, that would correspond to always being multiples of AT A). [BSS12] thus simply represented them with scalars. Like BSS, we will increase Xu and Xl by multiples of AT A–however, the key difference from BSS is that they are initialized to multiples of the identity, rather than AT A. In particular, we may initialize Xu to kI and Xl to −kI. This is still good enough to get the spectral norm bounds we require here (as opposed to the stronger multiplicative approximation guaranteed by BSS). We will have two scalar values, δu and δl, depending only on ε; they will be set later. One step consists of 1. Choose a row ai from A and a positive scalar t, and add taiaT i to Z (via increasing the i component of S). 17 2. Add δuAT A to Xu and δlAT A to Xl. We will show that with suitable values of δu and δl, for any Z obeying the invariants there always exists a choice of i and t such that the invariants will still be true after the step is complete. This corresponds to Lemmas 3.3 through 3.5 of BSS. For convenience, we define, at a given step, the matrix functions of y Mu(y) = ((Xu + yAT A) − Z)−1 Ml(y) = (Z − (Xl + yAT A))−1. The upper barrier value, after making a step of taiaT i and increasing Xu, is tr(A((Xu + δuAT A) − (Z + taiaT i ))−1AT ). Applying the Sherman-Morrison formula, and cyclicity of trace, to the rank-1 update taiaT can be rewritten as i , this tr(AMu(δu)AT ) + taT i Mu(δu)AT AMu(δu)ai 1 − taT i Mu(δu)ai . Since the function f (y) = tr(AMu(y)AT ) is a convex function of y with derivative f′(y) = − tr(AMu(y)AT AMu(y)AT ), we have f (δu) − f (0) ≤ −δu tr(AMu(δu)AT AMu(δu)AT ). Then the difference between the barrier before and after the step is at most taT i Mu(δu)AT AMu(δu)ai 1 − taT i Mu(δu)ai − δu tr(AMu(δu)AT AMu(δu)AT ). Constraining this to be no greater than zero, rewriting in terms of 1 t and pulling it out gives 1 t ≥ aT i Mu(δu)AT AMu(δu)ai δu tr(AMu(δu)AT AMu(δu)AT ) + aT i Mu(δu)ai. Furthermore, as long as 1 infinity as t approaches the smallest value passing Xu. t is at least this, Z will remain below Xu, since the barrier must approach For the lower barrier value after the step, we get Again, applying Sherman-Morrison rewrites it as tr(A((Z + taiaT i ) − (Xl + δlAT A))−1AT ). tr(AMl(δl)AT ) − taT i Ml(δl)AT AMl(δl)ai 1 + taT i Ml(δl)ai . Again, due to convexity the increase in the barrier from raising Xl is at most δl times the local derivative. The difference in the barrier after the step is then at most taT i Ml(δl)AT AMl(δl)ai 1 + taT i Ml(δl)ai − + δl tr(AMl(δl)AT AMl(δl)AT ). 18 This is not greater than zero as long as 1 t ≤ aT i Ml(δl)AT AMl(δl)ai δl tr(AMl(δl)AT AMl(δl)AT ) − aT i Ml(δl)ai. There is some value of t that works for ai as long as the lower bound for 1 t is no larger than the upper bound. To show that there is at least one choice of i for which this holds, we look at the sum of all the lower bounds and compare to the sum of all the upper bounds. Summing the former over all i gets tr(AMu(δu)AT AMu(δu)AT ) δu tr(AMu(δu)AT AMu(δu)AT ) + tr(AMu(δu)AT ) and the latter gets Finally, note that tr(AMl(δl)AT AMl(δl)AT ) δl tr(AMl(δl)AT AMl(δl)AT ) − tr(AMl(δl)AT ). tr(AMu(δu)AT ) = tr(A((Xu + δuAT A) − Z)−1AT ) ≤ tr(A(Xu − Z)−1AT ) ≤ 1 and the lower barrier implies Z − Xl ≻ AT A, implying that as long as δl ≤ 1 2 , tr(AMl(δl)AT ) = tr(A(Z − (Xl + δlAT A))−1AT ) ≤ 2 tr(A(Z − Xl)−1AT ) ≤ 2. Thus, we can always make a step as long as δu and δl are set so that and δl ≤ 1 2 . This is satisfied by 1 δu + 1 ≤ 1 δl − 2 δu = ε + 2ε2 δl = ε − 2ε2. Before the first step, Xu and Xl can be initialized as kI and −kI, respectively. If the algorithm is then run for k ε2 steps, we have: AT A + 2kAT A + kI AT A + 3kI Xu = (cid:22) Xl = k ε k ε k ε k ε AT A − 2kAT A − kI AT A − 3kI. k Xl both end up within 3εI of AT A, so ε (cid:23) ε k Xu and ε k S) satisfies the requirements of the output for 3ε (one can simply apply this argument for ε/3). Furthermore, all the computa- tions required to verify the preservation of invariants and compute explicit ts can be performed in polynomial time. (cid:4) k Z (from p ε This obtains more general AMM as a corollary: 19 Corollary 1. Given two matrices A and B, each with n rows, and an ε ∈ (0, 1), there exists a diagonal matrix S with O(k/ε2) nonzero entries satisfying the (k, ε)-AMM property for A, B. Such an S can be computed by a polynomial-time algorithm. Proof. Apply Theorem 5 to a matrix X consisting of the columns of A √2 max(kAk2,kAkF /√k) appended to the columns of , and use the resulting S. B √2 max(kBk2,kBkF /√k) Note that X satisfies the conditions of that theorem, since concatenating the sets of columns at most adds the squares of their spectral and Frobenius norms. (SA)T (SB)− AT B is a submatrix of 2 max(kAk2,kAkF /√k) max(kBk2,kBkF /√k)((SX)T (SX) − X T X), so its spectral norm is upper bounded by the spectral norm of that matrix, which in turn is bounded by the guarantee of Theorem 5. (cid:4) Acknowledgments We thank Jaros law B lasiok for pointing out the connection between low stable rank approximate matrix multiplication and the analyses in [YPW15]. References [AC09] [AL13] [AW02] [Bou14] [BSS12] Nir Ailon and Bernard Chazelle. The fast Johnson-Lindenstrauss transform and ap- proximate nearest neighbors. SIAM J. Comput., 39(1):302–322, 2009. Nir Ailon and Edo Liberty. An almost optimal unrestricted fast Johnson-Lindenstrauss transform. ACM Transactions on Algorithms, 9(3):21, 2013. Rudolf Ahlswede and Andreas J. Winter. Strong converse for identification via quan- tum channels. IEEE Transactions on Information Theory, 48(3):569–579, 2002. Jean Bourgain. An improved estimate in the restricted isometry problem. Geometric Aspects of Functional Analysis, 2116:65–70, 2014. Joshua D. Batson, Daniel A. Spielman, and Nikhil Srivastava. Twice-Ramanujan sparsifiers. SIAM J. Comput., 41(6):1704–1721, 2012. [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, 2015. [CCF04] Moses Charikar, Kevin C. Chen, and Martin Farach-Colton. Finding frequent items in data streams. Theor. Comput. Sci., 312(1):3–15, 2004. [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 ACM Symposium on Theory of Computing (STOC), 2015. Full version at http://arxiv.org/abs/1410.6801v3. 20 [CLL+10] Pei-Chun Chen, Kuang-Yao Lee, Tsung-Ju Lee, Yuh-Jye Lee, and Su-Yun Huang. Multiclass support vector classification via coding and regression. Neurocomputing, 73(7-9):1501–1512, 2010. [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 Annual Conference on Innovations in Theoretical Computer Science (ITCS), pages 181–190, 2015. [Coh16] [CW09] [CW13] [DKM06] [DKS10] [DMM06] Michael B. Cohen. Simpler and tighter analysis of sparse oblivious subspace em- beddings. In Proceedings of the 27th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), to appear, 2016. linear algebra in Kenneth L. Clarkson and David P. Woodruff. the 41st Annual ACM Symposium the streaming model. on Theory of Computing (STOC), pages 205–214, 2009. Full version at http://researcher.watson.ibm.com/researcher/files/us-dpwoodru/cw09.pdf. In Proceedings of Numerical Kenneth L. Clarkson and David P. Woodruff. regression in input sparsity time. sium on Theory of Computing (STOC), pages 81–90, 2013. http://arxiv.org/abs/1207.6365v4. In Proceedings of Low rank approximation and the 45th ACM Sympo- Full version at Petros Drineas, Ravi Kannan, and Michael W. Mahoney. Fast Monte Carlo algorithms for matrices I: approximating matrix multiplication. SIAM J. Comput., 36(1):132–157, 2006. Anirban Dasgupta, Ravi Kumar, and Tam´as Sarl´os. A sparse Johnson-Lindenstrauss transform. In Proceedings of the 42nd ACM Symposium on Theory of Computing (STOC), pages 341–350, 2010. Petros Drineas, Michael W. Mahoney, and S. Muthukrishnan. Sampling algorithms for ℓ2 regression and applications. In Proceedings of the Seventeenth Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1127–1136, 2006. [DMMW12] Petros Drineas, Malik Magdon-Ismail, Michael W. Mahoney, and David P. Woodruff. Fast approximation of matrix coherence and statistical leverage. Journal of Machine Learning Research, 13:3475–3506, 2012. [FR13] [GM13] Simon Foucart and Holger Rauhut. A Mathematical Introduction to Compressive Sensing. Applied and Numerical Harmonic Analysis. Birkhauser, 2013. Alex Gittens and Michael W. 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. [HMT11] Nathan Halko, Per-Gunnar Martinsson, and Joel A. Tropp. Finding structure with randomness: Probabilistic algorithms for constructing approximate matrix decompo- sitions. SIAM Review, 53(2):217–288, 2011. 21 [HR16] [HW71] [JL84] [KMN11] Ishay Haviv and Oded Regev. The restricted isometry property of subsampled Fourier matrices. In Proceedings of the 27th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), to appear, 2016. David Lee Hanson and Farroll Tim Wright. A bound on tail probabilities for quadratic forms in independent random variables. Ann. Math. Statist., 42(3):1079–1083, 1971. William B. Johnson and Joram Lindenstrauss. Extensions of Lipschitz mappings into a Hilbert space. Contemporary Mathematics, 26:189–206, 1984. Daniel M. Kane, Raghu Meka, and Jelani Nelson. Almost optimal explicit johnson- lindenstrauss families. In Proceedings of the 14th International Workshop on Random- ization and Computation (RANDOM), pages 628–639, 2011. [KMST10] Alexandra Kolla, Yury Makarychev, Amin Saberi, and Shang-Hua Teng. Subgraph sparsification and nearly optimal ultrasparsifiers. In Proceedings of the Forty-second ACM Symposium on Theory of Computing, STOC '10, pages 57–66, New York, NY, USA, 2010. ACM. [KN14] [KVZ14] [KW11] Daniel M. Kane and Jelani Nelson. Sparser Johnson-Lindenstrauss transforms. J. ACM, 61(1):4, 2014. Anastasios T. Kyrillidis, Michail Vlachos, and Anastasios Zouzias. Approximate ma- trix multiplication with application to linear embeddings. CoRR, abs/1403.7683, 2014. Felix Krahmer and Rachel Ward. New and improved Johnson-Lindenstrauss embed- dings via the Restricted Isometry Property. SIAM J. Math. Anal., 43(3):1269–1281, 2011. [LBKW14] Yingyu Liang, Maria-Florina Balcan, Vandana Kanchanapally, and David P. Woodruff. In Proceedings of the 27th Annual Conference on Advances in Neural Information Processing Systems (NIPS), pages 3113–3121, 2014. Improved distributed principal component analysis. [LDFU13] Yichao Lu, Paramveer Dhillon, Dean Foster, and Lyle Ungar. Faster ridge regression via the subsampled randomized Hadamard transform. In Proceedings of the 26th Annual Conference on Advances in Neural Information Processing Systems (NIPS), 2013. [LMP13] [LP86] [LPP91] Mu Li, Gary L. Miller, and Richard Peng. In Proceedings of the 54th Annual IEEE Symposium on Foundations of Computer Science (FOCS), pages 127–136, 2013. Iterative row sampling. Fran¸cois Lust-Piquard. In´egalit´es de Khintchine dans Cp (1 < p < ∞). C. R. Math. Acad. Sci. Paris, 303(7):289–292, 1986. Fran¸cois Lust-Piquard and Gilles Pisier. Noncommutative Khintchine and Paley in- equalities. Ark. Mat., 29(2):241–260, 1991. 22 [LS15] Yin Tat Lee and He Sun. Constructing linear sized spectral sparsification in almost linear time. In Proceedings of the 56th Annual IEEE Symposium on Foundations of Computer Science (FOCS), pages 250–269, 2015. [LWM+07] Edo Liberty, Franco Woolfe, Per-Gunnar Martinsson, Vladimir Rokhlin, and Mark Tygert. Randomized algorithms for the low-rank approximation of matrices. Proceed- ings of the National Academy of Sciences, 104(51):20167–20172, 2007. [Mah11] [MM13] [MZ11] [NN13] [NN14] [NPW14] [RHV11] [RV13] [Sar06] [SS11] [Tro11] [Tro15] Michael W. Mahoney. Randomized algorithms for matrices and data. Foundations and Trends in Machine Learning, 3(2):123–224, 2011. Xiangrui Meng and Michael W. Mahoney. Low-distortion subspace embeddings in input-sparsity time and applications to robust linear regression. In Proceedings of the 45th ACM Symposium on Theory of Computing (STOC), pages 91–100, 2013. Avner Magen and Anastasios Zouzias. Low rank matrix-valued Chernoff bounds and approximate matrix multiplication. In Proceedings of the 22nd Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1422–1436, 2011. 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. Jelani Nelson and Huy L. Nguyen. Lower bounds for oblivious subspace embeddings. In Proceedings of the 41st International Colloquium on Automata, Languages, and Programming (ICALP), pages 883–894, 2014. Jelani Nelson, Eric Price, and Mary Wootters. New constructions of RIP matrices with fast multiplication and fewer rows. In Proceedings of the 25th Annual ACM- SIAM Symposium on Discrete Algorithms (SODA), 2014. Nima Reyhani, Hideitsu Hino, and Ricardo Vig´ario. New probabilistic bounds on eigenvalues and eigenvectors of random kernel matrices. In Proceedings of the Twenty- Seventh Conference on Uncertainty in Artificial Intelligence (UAI), pages 627–634, 2011. Mark Rudelson and Roman Vershynin. Hanson-Wright inequality and sub-gaussian concentration. Electronic Communications in Probability, 18:1–9, 2013. Tam´as Sarl´os. Improved approximation algorithms for large matrices via random projections. In Proceedings of the 47th Annual IEEE Symposium on Foundations of Computer Science (FOCS), pages 143–152, 2006. Daniel A. Spielman and Nikhil Srivastava. Graph sparsification by effective resistances. SIAM J. Comput., 40(6):1913–1926, 2011. Joel A. Tropp. Improved analysis of the subsampled randomized Hadamard transform. Adv. Adapt. Data Anal., 3(1–2):115–126, 2011. Joel A Tropp. An introduction to matrix concentration inequalities. arXiv preprint arXiv:1501.01571, 2015. 23 [TZ12] Mikkel Thorup and Yin Zhang. Tabulation-based 5-independent hashing with applica- tions to linear probing and second moment estimation. SIAM J. Comput., 41(2):293– 331, 2012. [Woo14] David P. Woodruff. Sketching as a tool for numerical linear algebra. Foundations and Trends in Theoretical Computer Science, 10(1-2):1–157, 2014. [YPW15] Yun Yang, Mert Pilanci, and Martin J. Wainwright. Randomized sketches for kernels: Fast and optimal non-parametric regression. CoRR, abs/1501.06195, 2015. Appendix A OSE moment property In the following two subsections we show the OSE moment property for both subgaussian matrices and the SRHT. A.1 Subgaussian matrices In this section, we show the OSE moment property for distributions satisfying a JL condition, namely the JL moment property. This includes matrices with i.i.d. entries that are mean zero and subgaussian with variance 1/m. Definition 4. [KMN11] Let D be a distribution over Rm×n. We say D has the (ε, δ, p)-JL moment property if for all x ∈ Rn of unit norm, E Π∼D kΠxk2 − 1p < εp · δ. The following theorem follows from the proof of Lemma 8 in the full version of [CW13]. We give a different proof here inspired by the proof of [FR13, Theorem 9.9], which is slightly shorter and more self-contained. A weaker version appears in [Sar06, Lemma 10], where the size bound on X is (Cd/ε)d for a constant C ≥ 1 instead of simply C d. Theorem 6. Let U ∈ Rn×d with orthonormal columns be arbitrary. Then there exists a set X ⊂ Rn, X ≤ 9d, each of norm at most 1 such that k(ΠU )T (ΠU ) − Ik ≤ 2 · sup x∈X kΠxk2 − 1 Proof. We will show that if supx∈X kΠxk2 − 1 < ε/2 then k(ΠU )T (ΠU ) − Ik < ε, where ε > 0 is some positive real. Define A = (ΠU )T (ΠU ) − I. Since A is symmetric, kAk = sup kxk=1xT Ax = sup kxk=1hAx, xi Let Tγ be a finite γ-net of ℓd 2 and for every x ∈ Rd of unit norm there exists a y ∈ Tγ such that kx − yk2 ≤ γ. As we will see soon, there exists such a Tγ of size at most (1 + 2/γ)d. We will show that if Π satisfies the JL condition on T ′ = {U y : y ∈ T1/4} with error ε/2, then kAk < ε; that is, (1 − ε/2)kxk2 2 ≤ (1 + ε/2)kxk2 2 for all x ∈ T ′. 2, i.e. Tγ ⊂ ℓd 2 ≤ kΠxk2 24 Let x be a unit norm vector that achieves the sup above, i.e. kAk = hAx, xi. Then, letting y be the closest element of Tγ to x, kAk = hAx, xi = hAy, yi + hA(x + y), x − yi + kAk · kx + yk · kx − yk ≤ ≤ + 2γkAk. ε 2 ε 2 Rearranging gives kAk ≤ ε/(2(1 − 2γ)), which is ε for γ = 1/4. Now we must show that we can take Tγ ≤ (1 + 2/γ)d. The following is a standard cover- ing/packing argument for bounding metric entropy. Imagine packing as many radius-(γ/2) ℓ2 balls as possible into Rd, centered at points with at most unit norm and such that these balls do not intersect each other. Then these balls all fit into a radius-(1 + γ/2) ℓ2 ball centered at the origin, and thus the number of balls we have packed is at most the ratio of the volume of a (1 + γ/2) ball to the volume of a γ/2 ball, which is ((1 + γ/2)/(γ/2))d = (1 + 2/γ)d. Now, take those maximally packed radius-(γ/2) balls and double each of their radii to be radius γ. Then every point in the unit ball is contained in at least one of these balls by the triangle inequality, which is exactly the property we wanted from Tγ (Tγ is just the centers of these balls). To see why every point is in at least one such ball, if some x ∈ Rd of unit norm is not contained in any doubled ball then a γ/2-ball about x would be disjoint from our maximally packed γ/2 balls, a contradiction. (cid:4) Lemma 4. If D satisfies the (ε, δ, p)-JL moment property, then D satisfies the (2ε, 9dδ, d, p)-OSE moment property Proof. By Theorem 6, there exists a subset X ⊂ Rn of at most 9d points such that Ek(ΠU )T (ΠU ) − Ikp ≤ 2p · E sup ≤ 2p ·Xx∈X ≤ 2p · 9d · εp · δ = (2ε)p · 9dδ. x∈X kΠxk2 − 1p EkΠxk2 − 1p (cid:4) It is known that if D is a distribution over Rm×n with m = Ω(log(1/δ)/ε2) and for Π ∼ D, the entries of Π are independent subgaussians with mean zero and variance 1/m, then D has the (ε/2, δ, Θ(log(1/δ)))-JL moment property [KMN11]. Thus such a matrix has the (ε, δ, d, Θ(d + log(1/δ)))-OSE moment property for δ < 2−d by Lemma 4. A.2 Subsampled Randomized Hadamard Transform (SRHT) Recall the SRHT is the m× n matrix Π = (1/√m)· SHD for n a power of 2 where D has diagonal entries α1, . . . , αn that are independent and uniform in {−1, 1}, H is the unnormalized Hadamard transform with Hi,j = (−1)hi,ji (treating i, j as elements of the vector space F ), and S is a sampling matrix. That is, the rows of S are independent, and each row has a 1 in a uniformly log2 n 2 25 random location and zeroes elsewhere. A similar construction is where S is an n × n diagonal matrix with Si,i = ηi being independent Bernoulli random variables each of expectation m/n (so that, in expectation, S selects m rows from HD). We will here show the moment property for this latter variant since it makes the notation a tad cleaner, though the analysis we present holds essentially unmodified for the former variant as well. Our analysis below implies that the SRHT provides an ε-subspace embedding for d-dimensional subspaces with failure probability δ for m = O(ε−2(d + log(1/(εδ))) log(d/δ)). This is an improve- ment over analyses we have found in previous works. The analysis in [Tro11] only considers constant ε and δ = O(1/d) and for these settings achieves m = O((d+log n) log d), which is still slightly worse than our bound for this setting of ε, δ (our bound removes the log n and achieves any 1/ poly(d) failure probability with the same m). The analysis in [LDFU13] only allows failure probabilities greater than n/ed. They show failure probability δ + n/ed is achieved for m = O(d log(d/δ)/ε2), which is also implied by our result if m ≤ n (which is certainly the case in applications for the SRHT to be useful, since otherwise one could use the n × n identity matrix as a subspace embed- ding). The reason for these differences is that previous works operate by showing HDU has small row norms with high probability over D; since there are n rows, some logarithmic dependence on n shows up in a union bound. After this conditioning, one then shows that S works. Our analysis does not do any such conditioning at all. Interestingly, such a lossy conditioning approach was done even for the case d = 1 [AC09]. As we see below, these analyses can be improved (essentially the log n terms that appear from the conditioning approach can be very slightly improved to log m). Our main motivation in re-analyzing the SRHT was not to improve the bounds, but simply to clearly demonstrate that the SRHT satisfies the OSE moment property. The fact that our moment based analysis below (very slightly) improved m was a fortunate accident. Before we present our proof of the OSE moment property for the SRHT, we state a theorem we will use. For a random matrix M , we henceforth use kMkp to denote (EkMkp )1/p where kMkSp is the Schatten-p norm, i.e. the ℓp norm of the singular values of M . Sp Theorem 7 (Non-commutative Khintchine inequality [LP86, LPP91]). Let X1, . . . , Xn be fixed real matrices and σ1, . . . , σn be independent Rademachers. Then ∀p ≥ 1, kXi σiXikp . √p · max(k(Xi XiX T i )1/2kSp,k(Xi X T i Xi)1/2kSp) . We will also make use of the Hanson-Wright inequality. Theorem 8 (Hanson-Wright [HW71]). For (σi) independent Rademachers and A symmetric, ∀p ≥ 1, kσT Aσ − E σT Aσkp . √p · kAkF + p · kAk. We now present our main analysis of this subsection. Theorem 9. The SRHT satisfies the (ε, δ, d, p)-moment property for p = log(d/δ) as long as m & ε−2(d log(d/δ) + log(d/δ) log(m/δ)) ≃ ε−2(d + log(1/(εδ)) log(d/δ)). Proof. For a fixed U ∈ Rn×d with orthonormal columns, we would like to bound 1 m E α,η k (SHDU )T (SHDU ) − Ikp. 26 Since p ≥ log d we have 1 m k (SHDU )T (SHDU ) − Ik ≃ k 1 m (SHDU )T (SHDU ) − IkSp by Holder's inequality. Also, let z1, . . . , zn be the rows of HDU , as column vectors, so that 1 m (SHDU )T (SHDU ) = 1 m n Xi=1 ηizizT i . (20) (21) over η, of the right hand side of Eq. (21) for any D. Thus we are left wanting to bound i = (HDU )T HDU = n · I for any D, so the identity matrix is the expectation, Note also Pi zizT k 1 mXi ηizizT i − E η′ 1 mXi η′izizT i kp where the η′i are identically distributed as the ηi but independent of them. Below we use kf (X)kLp(X) to denote (EX f (X)p)1/p. Also we assume p is an integer multiple of 4, so that kAkSp for real sym- metric A equals (tr(Ap))1/p and kAkSp/2 = (tr(Ap/2))2/p. Thus for (σi) independent Rademachers, mXi η′izizT ηizizT i kp (22) k 1 1 1 i −Ikp = k 1 η′izizT i kLp(η)kLp(α) i kLp(η,η′)kLp(α) (Jensen's inequality) (kMkp Sp = tr(M p)) i )p/2)2)1/2p (Cauchy-Schwarz) i )p))1/2p (Cauchy-Schwarz) (23) (since d1/p ≤ 2) σi(ηi − η′i)zizT i kp (equal in distribution) η′ i − E 1 mXi mXi η′izizT η′ i − E i −Xi (ηi − η′i)zizT i kp 1 1 2 = = ≤ ≤ ηizizT ηizizT ηizizT mXi mXi = kk 1 mkkXi m · kXi m · kXi m · kXi √p m · k(Xi ηikzik2 √p m · E (max √p m · k max √p m · k max √p m · k max σiηizizT ≤ ≤ ≤ . . i ηikzik2 ηikzik2 ηikzik2 i i i i kp (triangle inequality) ηikzikp ηizizT i )1/2kp (Theorem 7) 2 · zizT i )p/2)!1/p 2) · tr((Xi · (E tr((Xi 2k1/2 · (d · E tr((Xi · kXi i k1/2 2k1/2 2k1/2 ηizizT ηizizT ηizizT p p p p 27 ≤r p m · k max i ηikzik2 2k1/2 p · (d1/p + k 1 mXi ηizizT i − Ik1/2 p ) (triangle inequality) (24) i i , then tr(M p/2)2 = )2, and the rank of M , and hence the number of summands βi, is at most d. Letting Eq. (23) follows since if βi are the singular values of M = Pi ηizizT (Pi βp/2 mPi ηizizT Q = k 1 and R =pp/m · k maxi ηikzik2 , combining Eq. (22) and Eq. (24) i − Ik1/2 2k1/2 p p Q2 . R + RQ implying that for some fixed constant C > 0, we have Q2 − CRQ− CR ≤ 0. This implies that Q is at most the larger root of the associated quadratic equation, i.e. Q . max{√R, R}, or equivalently k 1 mXi ηizizT i − Ikp . max{R, R2} It only remains to bound R, which in turn amounts to bounding k maxi ηikzik2 2k1/2 p (25) . Define (26) i α,η i E α,η max k max ηikzik2 ηq i (kzik2 ηq i (kzik2 ηq i (kzik2 q = max{p, log m}, and note k · kp ≤ k · kq. Then 2)q(cid:19)1/q 2)q!1/q 2)q!1/q 2)q(cid:19)1/q ηq i (kzik2 ηq (kzik2 i ) · (E 2)q)(cid:19)1/q 2kq =(cid:18) E ≤ E α,ηXi = Xi ≤(cid:18)n · max =(cid:18)n · max =(cid:18)m · max ≤ 2 · max = 2 · max = 2 · max i αkq (d + kαT Ui U T i kkzik2 i kαT Ui U T E α,η (E η E α i i α i 2)q)(cid:19)1/q (α, η independent) i (kzik2 2kq (m1/q ≤ 2 by choice of q) i α − E αT Ui U T i αkq) (triangle inequality) where Ui is the matrix with ( Ui)k,j = Hi,k · Uk,j. Of particular importance for us is the identity U T i Ui = I. Then by Eq. (26) and Theorem 8, k max i ηikzik2 i kF + q · k Ui U T i k 2kq . d + √q · k Ui U T = d +pqd + q 28 so that which when combined with Eq. (25) gives 3 ≤ 2 · (d + q) (AM-GM inequality) R .r p m ·pd + q, k 1 mXi ηizizT i − Ikp .r p m · (d + q) + p m · (d + q). Thus the OSE moment property is satisfied by our choices of m, p in the theorem statement. (cid:4) A.3 Composing dimensionality reducing maps supporting AMM As discussed in Remark 3, to obtain both a good number of rows for Π as well as fast multiplication for ΠA, ΠB, one may wish to set Π as the composition Π = Π1Π2, where Π1 has the correct number m1 = O(k/ε2) of rows (e.g. a matrix of subgaussian entries), whereas Π2 maps to a small but suboptimal number m2 of rows (e.g. the SRHT) but supports fast embedding to compute Π2A. We show here that composing maps each supporting AMM yields a final map also giving AMM. As discussed in Corollary 1, without loss of generality we can assume A = B. Also, as discussed in Remark 1, we can focus on achieving Eq. (3) where the number of rows of Π should depend on the stable rank r and not rank r of A. The key is to note the following simple triangle inequality: k(ΠA)T (ΠA) − AT Ak ≤ k(Π1Π2A)T (Π1Π2A) − (Π2A)T (Π2A)k } {z α The results of this work show that to achieve the desired β ≤ εkAk2, it suffices that the number of rows of Π2 need only depend on r and not r, as desired. The trouble is that for α, the number of rows of Π1 will need to depend on the stable rank r′ of Π2A and not r. Furthermore, the error will be α ≤ εkΠ2Ak2 and not α ≤ εkAk2. Thus, we must obtain good bounds on both r′ and kΠ2Ak. To achieve this, note +k(Π2A)T (Π2A) − AT Ak } {z β . (27) kΠ2Ak = k(Π2A)T (Π2A)k1/2 = kAk ± k(Π2A)T (Π2A) − AT Ak1/2 (28) and kΠ2AkF = tr((Π2A)T (Π2A))1/2 = kAkF ± k(Π2A)T (Π2A) − AT AkF (29) Thus, if we condition on β = k(Π2A)T (Π2A) − AT Ak ≤ εkAk2 (which we already discussed above), then indeed we have kΠ2Ak = Θ(kAk) by Eq. (28). Also, [KN14, Theorem 6.2] implies k(Π2A)T (Π2A) − AT AkF ≤ εkAk2 F with probability 1 − δ as long as Π comes from a distribution satisfying the (O(ε), δ, ℓ)-JL moment property for some ℓ ≥ 2 (which is just the (O(ε), δ, 1, ℓ)-OSE If this holds, then kΠ2AkF = Θ(kAkF ) by moment property in the terminology of this work). Eq. (29), and thus r′ = Θ(r), as desired. Then overall, we have that the left hand side of Eq. (27) is at most ε · kΠ2Ak2 + ε · kAk2 = O(ε) · kAk2 as desired, in which both Π1 and Π2 need only provide AMM with error ε for matrices both of stable rank O(r). 29 Remark 4. An even slicker argument that works in the case when Π1, Π2 are both drawn from distributions satisfying the (ε, δ, k, ℓ)-OSE moment property is to observe that the distribution of the product Π1Π2 itself satisfies the OSE moment property. Indeed, letting kZkp denote (EZp)1/p for a scalar random variable Z, and letting U ∈ Rn×k denote a matrix with orthonormal columns, kk(Π1Π2U )T Π1Π2U − Ikkℓ < εδ1/ℓkkΠ2Uk2kℓ (Lemma 2) = εδ1/ℓkk(Π2U )T Π2Ukkℓ ≤ εδ1/ℓ(1 + kk(Π2U )T Π2U − Ikkℓ) (triangle inequality) ≤ εδ1/ℓ(1 + εδ1/ℓ) In the first line we used that when A = B in Lemma 2, Π1 need only satisfy the OSE moment property with parameter k instead of 2k (since then the span of the columns of both A and B has dimension at most k). Thus the distribution of the product Π1Π2 satisfies the (O(ε), O(δ), k, ℓ)-OSE moment property. 30
1603.08819
2
1603
2016-09-26T12:43:55
The SCJ small parsimony problem for weighted gene adjacencies (Extended version)
[ "cs.DS", "q-bio.GN" ]
Reconstructing ancestral gene orders in a given phylogeny is a classical problem in comparative genomics. Most existing methods compare conserved features in extant genomes in the phylogeny to define potential ancestral gene adjacencies, and either try to reconstruct all ancestral genomes under a global evolutionary parsimony criterion, or, focusing on a single ancestral genome, use a scaffolding approach to select a subset of ancestral gene adjacencies, generally aiming at reducing the fragmentation of the reconstructed ancestral genome. In this paper, we describe an exact algorithm for the Small Parsimony Problem that combines both approaches. We consider that gene adjacencies at internal nodes of the species phylogeny are weighted, and we introduce an objective function defined as a convex combination of these weights and the evolutionary cost under the Single-Cut-or-Join (SCJ) model. The weights of ancestral gene adjacencies can e.g. be obtained through the recent availability of ancient DNA sequencing data, which provide a direct hint at the genome structure of the considered ancestor, or through probabilistic analysis of gene adjacencies evolution. We show the NP-hardness of our problem variant and propose a Fixed-Parameter Tractable algorithm based on the Sankoff-Rousseau dynamic programming algorithm that also allows to sample co-optimal solutions. We apply our approach to mammalian and bacterial data providing different degrees of complexity. We show that including adjacency weights in the objective has a significant impact in reducing the fragmentation of the reconstructed ancestral gene orders.
cs.DS
cs
The SCJ Small Parsimony Problem for Weighted Gene Adjacencies Nina Luhmann, Manuel Lafond, Annelyse Th´evenin, Aıda Ouangraoua, Roland Wittler and Cedric Chauve 1 Abstract-Reconstructing ancestral gene orders in a given phylogeny is a classical problem in comparative genomics. Most existing methods compare conserved features in extant genomes in the phylogeny to define potential ancestral gene adjacencies, and either try to reconstruct all ancestral genomes under a global evolutionary parsimony criterion, or, focusing on a single ancestral genome, use a scaffolding approach to select a subset of ancestral gene adjacencies, generally aiming at reducing the fragmentation of the reconstructed ancestral genome. In this paper, we describe an exact algorithm for the Small Parsimony Problem that combines both approaches. We consider that gene adjacencies at internal nodes of the species phylogeny are weighted, and we introduce an objective function defined as a convex combination of these weights and the evolutionary cost under the Single-Cut-or-Join (SCJ) model. The weights of ancestral gene adjacencies can e. g. be obtained through the recent availability of ancient DNA sequencing data, which provide a direct hint at the genome structure of the considered ancestor, or through probabilistic analysis of gene adjacencies evolution. We show the NP-hardness of our problem variant and propose a Fixed-Parameter Tractable algorithm based on the Sankoff-Rousseau dynamic programming algorithm that also allows to sample co-optimal solutions. We apply our approach to mammalian and bacterial data providing different degrees of complexity. We show that including adjacency weights in the objective has a significant impact in reducing the fragmentation of the reconstructed ancestral gene orders. An implementation is available at http://github.com/nluhmann/PhySca. ! 1 INTRODUCTION Reconstructing ancestral gene orders is a long-standing computational biology problem with important applica- tions, as shown in several recent large-scale projects [15], [28], [29]. Informally, the problem can be defined as follows: Given a phylogenetic tree representing the speciation his- tory leading to a set of extant genomes, we want to recon- struct the structure of the ancestral genomes corresponding to the internal nodes of the tree. Existing ancestral genome reconstruction methods con- centrate on two main strategies. Local approaches consider the reconstruction of one specific ancestor at a time inde- pendently from the other ancestors of the tree. Usually, they do not consider an evolutionary model and proceed in two stages: (1) comparing gene orders of ingroup and outgroup species to define potential ancestral gene adjacencies, and (2) selecting a conflict-free subset of ancestral gene adjacencies – where a conflict is defined as an ancestral gene extremity belonging to more than two potential adjacencies, e. g. due to convergent evolution –, to obtain a set of Contiguous Ancestral Regions (CARs) [7], [13], [24]. The second stage of this approach is often defined as a combinatorial opti- mization problem aiming to minimize the number of dis- • N. Luhmann and R. Wittler are with the International Research Training Group "Computational Methods for the Analysis of the Diversity and Dynamics of Genomes", Bielefeld University, Germany. • N. Luhmann, R. Wittler and A. Th´evenin are with the Genome Informatics group, Faculty of Technology and Center for Biotechnology, Bielefeld University, Germany. • M. Lafond is with the Department of Computer Science and Operational • A. Ouangraoua is with the Department of Computer Science, Universit´e • C. Chauve is with the Department of Mathematics, Simon Fraser Univer- Research, Universit´e de Montr´eal, Montr´eal, Canada. de Sherbrooke, Sherbrooke, Canada. sity, Burnaby (BC), Canada. carded ancestral adjacencies, thus maximizing the number of selected adjacencies [7], [24], [26]. This stage follows principles common in scaffolding methods used to obtain gene orders for extant genomes from sequencing data [10], [25]. This approach was recently used to scaffold an an- cestral pathogen genome for which ancient DNA (aDNA) sequencing data could be obtained [30]. Global approaches on the other hand simultaneously reconstruct ancestral gene orders at all internal nodes of the considered phylogeny, generally based on a parsimony criterion within an evolu- tionary model. This so called Small Parsimony Problem has been studied with several underlying genome rearrange- ment models, such as the breakpoint distance or the Double- Cut-and-Join (DCJ) distance [2], [21], [37]. While rearrange- ment scenarios based on complex rearrangement models can give insights into underlying evolutionary mechanisms, from a computational point of view, the Small Parsimony Problem is NP-hard for most rearrangement distances [34]. One exception is the Single-Cut-or-Join (SCJ) distance, for which linear/circular ancestral gene orders can be found in polynomial time [17], however constraints required to ensure algorithmic tractability yield fragmented ancestral gene orders. The two approaches outlined above optimize somewhat orthogonal criteria. For example, the underlying goal of the local approach is to maximize the agreement between the resulting ancestral gene order and the set of potential ancestral adjacencies, independently of the other ancestral gene orders. Would it be applied independently to all an- cestral nodes, potential ancestral adjacencies exhibiting a mixed profile of presence/absence in the extant genomes might then lead to a set of non-parsimonious ancestral gene orders. The global approach aims only at minimizing the 6 1 0 2 p e S 6 2 ] S D . s c [ 2 v 9 1 8 8 0 . 3 0 6 1 : v i X r a evolutionary cost in the phylogeny and can result in more fragmented ancestral gene orders. Nevertheless, there is little ground to claim that one approach or the other is more accurate or to be preferred, and the work we present is an attempt to reconcile both approaches. We introduce a variant of the Small Parsimony Problem based on an optimality criterion that accounts for both an evolutionary distance and the difference between the initial set of potential ancestral adjacencies and the final consistent subset of adjacencies conserved at each ancestral node. More precisely we consider that each potential ancestral gene adjacency can be provided with a (prior) non-negative weight at every internal node. The contribution of the discarded adjacencies to the objective function is then the sum of their weights. These adjacency weights can e. g. be obtained as probabilities computed by sampling scenarios for each potential adjacency independently [12] or can be based on ancient DNA (aDNA) sequencing data providing direct prior information assigned to certain ancestral nodes. It follows that the phylogenetic framework we present can then also assist in scaffolding fragmented assemblies of aDNA sequencing data [22], [30]. We prove NP-hardness of the problem variant we intro- duce and describe an exact exponential time algorithm for reconstructing consistent ancestral genomes under this op- timality criterion, based on a mixed Dynamic Programming / Integer Linear Programming approach. We show that this Small Parsimony Problem variant is Fixed-Parameter Tractable (FPT), with a parameter linked to the amount of conflict in the data. Moreover, this also allows us to provide an FPT sampling algorithm for co-optimal solutions, – a problem recently addressed in [27] using a MCMC ap- proach. We evaluate our method on a simulated dataset and compare our results to several other methods reconstructing ancestral genomes. Further, we apply our method to two real data sets: mammalian genomes spanning roughly one million years of evolution, and bacterial genomes (pathogen Yersinia) spanning 20, 000 years of evolution and for which some aDNA sequencing data is available. We show that we can reduce the fragmentation of ancestral gene orders in both datasets by integrating adjacency weights while reconstructing robust ancestral genomes. This paper is an extended version of the work previously presented in [23], particularly including new results on simulated datasets and a hardness proof of the defined problem. 2 BACKGROUND AND PROBLEM STATEMENT 2.1 Genomes and adjacencies Genomes consist of chromosomes and plasmids. Each such component can be represented as a linear or circular se- quence of oriented markers over a marker alphabet. Markers correspond to homologous sequences between genomes, e. g. genes or synteny blocks. We assume that each marker appears exactly once in each genome, so our model does not consider duplications or deletions. To account for its orientation, each marker x is encoded as a pair of marker extremities (xh, xt) or (xt, xh). An adjacency is an unordered pair of marker extremities, e. g. {xt, yh}. The order of markers in a genome can be 2 encoded by a set of adjacencies. Two distinct adjacencies are said to be conflicting if they share a common marker extremity. If a set of adjacencies contains conflicting adjacen- cies, it is not consistent with a mixed linear/circular genome model. We assume that the set of adjacencies for an extant assembled genome is consistent. The set of adjacencies for one genome naturally defines an adjacency graph, where nodes represent marker extremities and edges represent adjacencies. Conflicting adjacencies can be identified as branching nodes in this graph. 2.2 The Small Parsimony Problem and rearrangement distances In a global phylogenetic approach, we are given a phylogenetic tree with extant genomes at its leaves and internal nodes representing ancestral genomes. We denote by A the set of all adjacencies present in at least one extant genome and assume that every ancestral adjacency belongs to A. Then the goal is to find a labeling of the internal nodes by consistent subsets of A minimizing a chosen genomic distance over the tree. This is known as the Parsimonious Labeling Problem. Definition 1 (Parsimonious Labeling Problem). Let T = (V, E) be a tree with each leaf l labeled with a consistent set of adjacencies Al ⊆ A, and d a distance between consistent sets of adjacencies. A labeling λ : V → P(A) with λ(l) = Al for each leaf is parsimonious for d if none of the internal nodes v ∈ V contains a conflict and it minimizes the sum W (λ, T ) of the distances along the branches of T : (cid:88) d(cid:0)λ(u), λ(v)(cid:1). W (λ, T ) = (u,v)∈E This problem is NP-hard for most rearrangement dis- tances taken as evolutionary models. The only known exception is the set-theoretic Single-Cut-or-Join (SCJ) dis- tance [17]. It defines a rearrangement distance by two op- erations: the cut and join of adjacencies. Given two genomes defined by consistent sets of adjacencies A and B, the SCJ distance between these genomes is dSCJ (A, B) = A − B + B − A . The Small Parsimony Problem under the SCJ model can be solved by computing a parsimonious gain/loss history for each adjacency separately with the dynamic programming Fitch algorithm [18], [19] in polynomial time. Consistent labelings can be ensured with the additional constraint that in case of ambiguity at the root of the tree, the absence of the adjacency is chosen [17]. As each adjacency is treated independently, this constraint might automatically exclude all adjacencies being part of a conflict to ensure consistency. This results in an unnecessarily sparse recon- struction in terms of reconstructed adjacencies and thus more fragmented genomes higher up in the tree. 2.3 Generalization by weighting adjacencies When considering an internal node v, we define node u as its parent node in T . We assume that a specific adjacency graph is associated to each ancestral node v, whose edges are annotated by a weight wv,a ∈ [0, 1] representing a confi- dence measure for the presence of adjacency a in species v. Then in a global reconstruction, cutting an adjacency of a higher weight has higher impact in terms of the optimiza- tion criterion than cutting an adjacency of lower weight. Formally, we define two additional variables for each adjacency a ∈ A at each internal node v ∈ V : The presence (or absence) of a at node v is represented by pv,a ∈ {0, 1}, while cv,a ∈ {0, 1} indicates a change for the status of an adjacency along an edge (u, v), i.e., pu,a (cid:54)= pv,a. We consider the problem of optimizing the following objective function, where α ∈ [0, 1] is a convex combination factor. Definition 2 (Weighted SCJ Labeling Problem). Let T = (V, E) be a tree with each leaf l labeled with a consistent set of adjacencies Al ⊆ A and each adjacency a ∈ A is assigned a given weight wv,a ∈ [0, 1] for each node v ∈ V . A labeling λ of the internal nodes of T with λ(l) = Al for each leaf is an optimal weighted SCJ labeling if none of the internal nodes v ∈ V contains a conflict and it minimizes the criterion (cid:88) D(λ, T ) = α(1 − pv,a)wv,a + (1 − α)cv,a v,a Further, we can state the corresponding co-optimal sampling problem. A sampling method is important to examine different scenarios that can explain evolution toward the structure of extant genomes. rearrangement co-optimal Definition 3 (Weighted SCJ Sampling Problem). Given the setting of the Weighted SCJ Labeling Problem, sample uniformly from all labelings λ of the internal nodes of T that are solutions to the Weighted SCJ Labeling Problem. 2.4 Problem complexity Aside of the many heuristics for the Small Parsimony Problem for non-SCJ rearrangement models (see for exam- ple [21], [36], [37] for the DCJ distance), there exist a few positive results for the Weighted SCJ Labeling Problem with specific values of α. If α = 0, the objective function corresponds to the Small Parsimony Problem under the SCJ distance and hence a solution can be found in polynomial time [17]. A generaliza- tion towards multifurcating, edge-weighted trees including prior information on adjacencies at exactly one internal node of the tree is given in [22]. Recently, Mikl´os and Smith [27] proposed a Gibbs sampler for sampling optimal labelings under the SCJ model with equal branch lengths. It starts from an optimal labeling obtained as in [17], and then explores the space of co-optimal labelings through repeated constrained parsimonious modifications of a single adjacency evolutionary scenario. This method addresses the issue of the high fragmentation of internal node labelings, but convergence is not proven, and so there is no bound on the computation time. If α = 1, i.e., we do not take evolution in terms of SCJ distance along the branches of the tree into account, we can solve the problem by applying independently a 3 maximum-weight matching algorithm at each internal node [26]. So the extreme cases of the problem are tractable, and while we assume that the general problem is hard, we will now prove it for a small range of α. Theorem 1. The Weighted SCJ Labeling Problem is NP-hard for any α > 33/34. We show the hardness by reduction from the Maximum Intersection Matching Problem, which is defined as follows. Let G1 and G2 be two graphs on the same vertex set. Find a perfect matching in G1 and G2 such that the number of edges common to both matchings is maximized. We prove NP-hardness of this problem by reduction from 3-Balanced-Max-2-SAT (see appendix for details). Theorem 2. The Maximum Intersection Matching Problem is NP-complete. The relation of the Weighted SCJ Labeling Problem and the Maximum Intersection Matching Problem can be sketched as follows. For a given instance of the Maximum Intersection Matching Problem, G1 and G2, we construct a tree that contains the edges of both graphs as potential adjacencies. For α > 33/34, an optimal labeling of two internal nodes then corresponds to perfect matchings in G1 and G2. Maximizing the number of common edges of the matching then minimizes the SCJ distance between the nodes. A detailed proof is given in the appendix. 3 METHODS In order to find a solution to the Weighted SCJ Labeling Problem, we first show that we can decompose the prob- lem into smaller independent subproblems. Then, for each subproblem containing conflicting adjacencies, we show that, if it contains a moderate level of conflict, it can be solved using the Sankoff-Rousseau algorithm [32] with a complexity parameterized by the size of the subproblem. For a highly conflicting subproblem, we show that it can be solved by an Integer Linear Program (ILP). 3.1 Decomposition into independent subproblems We first introduce a graph that encodes all adjacencies present in at least one internal node of the considered phylogeny (Def. 4 and Supplementary Fig. 7). As introduced previously, we consider a tree T = (V, E) where each node is augmented with an adjacency graph. Definition 4 (Global adjacency graph). The set of vertices VAG of the global adjacency graph AG consists of all marker extremities present in at least one of the adjacency graphs. There is an edge between two vertices a, b ∈ VAG that are not extremities of a same marker, if there is an internal node in the tree T whose adjacency graph contains the adjacency {a, b}. The edge is labeled with the list of all internal nodes that contain this adjacency. the set of marker extremities equal Each connected component C of the global adjacency the species graph defines a subproblem composed of phylogeny, to the vertex set of C, and the set of adjacencies equal to the edge set of C. According to the following lemma, whose proof is straightforward, it is sufficient to solve each such subproblem independently. Lemma 1. The set of all optimal solutions of the Weighted SCJ Labeling Problem is the set-theoretic Cartesian product of the sets of optimal solutions of the instances defined by the connected components of the global adjacency graph. To solve the problem defined by a connected compo- nent C of the global adjacency graph containing conflicts, we rely on an adaptation of the Sankoff-Rousseau algorithm with exponential time complexity, parameterized by the size and nature of conflicts of C, and thus can solve subproblems with moderate amount of conflict. 3.2 Overview of the Sankoff-Rousseau algorithm The algo- Sankoff-Rousseau dynamic programming rithm [32] solves the general Small Parsimony Problem for discrete characters. Let L be the set of all possible labels of a node in the phylogeny. Then for each node u in the tree, the cost c(a, u) of assigning a label a ∈ L to this node is defined recursively as follows: (cid:88) (cid:0)c(b, v) + d(a, b)(cid:1) c(a, u) = min b∈L v child of u where in our case d(a, b) is defined as in Definition 2. This equation defines a dynamic programming algorithm whose base case is when u is a leaf in which case c(a, u) = 0 if λ(u) = a and c(a, u) = ∞ otherwise. Afterwards, choosing a label with the minimum cost at the root node and back- tracking in a top-down traversal of the tree results in a most parsimonious labeling. We refer to [14] for a review on the Sankoff-Rousseau algorithm. 3.3 Application to the Weighted SCJ Labeling Problem In order to use the Sankoff-Rousseau algorithm to solve the problem defined by a connected component C of the global adjacency graph, we define a label of an internal node of the phylogeny as the assignment of at most one adjacency to each marker extremity. More precisely, let x be a marker extremity in C, v an internal node of T , and e1, . . . , edx be all edges in the global adjacency graph that are incident to x and whose label contains v (i.e., represent adjacencies in the adjacency graph of node v). We define the set of possible labels of v as Lx,v = {∅, e1, . . . , edx}. The set of potential labels Lv of node v is then the Cartesian product of the label sets Lx,v for all x ∈ V (C) resulting in a set of discrete labels x∈V (C)(1 + dx). Note that not all of these joint labelings are valid as they can assign an adjacency a = (x, y) to x but not to y, or adjacency a = (x, y) to x and b = (x, z) to z thus creating a conflict (see Supplementary Fig. 8 for an example). for v of size(cid:81) 4 For an edge (u, v) in the tree, we can then define a cost matrix that is indexed by pairs of labels of Lu and Lv, respectively. The cost is infinite if one of the labels is not valid, and defined by the objective function otherwise. We can then apply the Sankoff-Rousseau approach to find an optimal labeling of all internal nodes of the tree for connected component C. Note that, if C is a connected component with no con- flict, it is composed of two vertices and a single edge, and can be solved in space O(n) and time O(n). 3.4 Complexity analysis The time and space complexity of the algorithm is obvi- ously exponential in the size of C. Indeed, the time (resp. space) complexity of the Sankoff-Rousseau algorithm for an instance with a tree having n leaves and r possible labels for each node is O(nr2) (resp. O(nr)) [14]. In our algorithm, assuming n leaves in T (i.e. n extant species), mC vertices in the global adjacency graph of C and a maximum degree dC for vertices (marker extremities) in this graph, (1 + dC)mC is an upper bound for the size of the label set Lv for a node v. Moreover, computing the distance between two labels of Lv and Lu, where (u, v) is an edge of T , can trivially be done in time and space O(mC): If both labels are valid, it suffices to check how many common adjacencies are present in both labels, while deciding if a label is not valid can be done by a one-pass examination of the label. Combining this with the Sankoff-Rousseau complexity yields a time complexity in O(nmC(1 + dC)2mC ) and a space complexity in O(nmC(1 + dC)mC ). Given a general instance, i.e., an instance not limited to a single connected component of the global adjacency graph, we can consider each connected component independently (Lemma 1). For a set of N markers and c connected components in the global adjacency graph defining a conflicting instance, we define D as the maximum degree of a vertex and M as the maximum number of vertices in all such components. Then, the complexity analysis above shows that the problem is Fixed-Parameter Tractable (FPT). Theorem 3. The Weighted SCJ Labeling Problem can be solved in worst-case time O(nN (1 + D)2M ) and space O(nN (1 + D)M ). In practice, the exponential complexity of our algo- rithm depends on the structure of the conflicting connected components of the global adjacency graph. The dynamic programming algorithm will be effective on instances with either small conflicting connected components or small de- grees within such components, and will break down with a single component with a large number of vertices of high degree. For such components, the time complexity is provably high and we propose an ILP to solve them. 3.5 An Integer Linear Program We can formulate the optimization problem as a simple ILP. We consider two variables for any adjacency a and node v, pv,a ∈ {0, 1} and cv,a ∈ {0, 1}, defined as in Section 2. (cid:88) v,a Minimize α(1 − pv,a)wv,a + (1 − α)cv,a subject to pv,a + pu,a − pp,a ≥ 0 for (p, u), (p, v) ∈ E(T ) pv,a + pu,a − pp,a ≤ 1 for (p, u), (p, v) ∈ E(T ) pv,a + pu,a + cv,a ≤ 2 for (u, v) ∈ E(T ) pv,a + pu,a − cv,a ≥ 0 for (u, v) ∈ E(T ) pv,a − pu,a + cv,a ≥ 0 for (u, v) ∈ E(T ) (cid:88) − pv,a + pu,a + cv,a ≥ 0 for (u, v) ∈ E(T ) (cid:88) pv,a ≤ 1 and pv,a ≤ 1 a=(xt,y) a=(xh,y) for any marker x and node v (c1) (c2) (c3) (c4) (c5) (c6) (c7) The constraints ensure parsimony (c1 and c2), consis- tency of the solution (c7) and define the correct value for cv,a dependent on the value of pa along an edge (u, v) (c3−6). This ILP has obviously a size that is polynomial in the size of the problem. 3.6 Sampling co-optimal labelings The Sankoff-Rousseau DP algorithm can easily be modified to sample uniformly from the space of all optimal solutions to the Weighted SCJ labeling Problem in a forward- backward fashion. The principle is to proceed in two stages: first, for any pair (v, a) we compute the number of optimal solutions under this label for the subtree rooted at v. Then, when computing an optimal solution, if a DP equation has several optimal choices, one is randomly picked according to the distribution of optimal solutions induced by each choice (see Appendix for more details). This classical dynamic programming approach leads to the following result. Theorem 4. The Weighted SCJ Sampling Problem can be solved in worst-case time O(nN (1 + D)2M ) and space O(nN (1 + D)M ). For subproblems that are too large for being handled by the Sankoff-Rousseau algorithm, the SCJ Small Parsimony Gibbs sampler recently introduced [27] can easily be modi- fied to incorporate prior weights, although there is currently no proven property regarding its convergence. 3.7 Weighting ancestral adjacencies A first approach to assign weights to ancestral adjacencies consist in considering evolutionary scenarios for an adja- cency independently of the other adjacencies. An evolution- ary scenario for an adjacency is a labeling of the internal nodes of the species phylogeny T by the presence or absence of the adjacency, and the parsimony score of a scenario is the number of gains/losses of the adjacency along the branch of T , i. e. the SCJ score for this single adjacency. For a scenario σ, we denote by p(σ) its parsimony score. Its Boltzmann score is then defined as B(σ) = e− p(σ) kT , where kT is a given constant. If we denote the set of all possible evolutionary scenarios for the adjacency {x, y} by S(x, y), the partition function of the adjacency and its Boltzmann probability are defined as 5 (cid:88) B(σ), P r(σ) = B(σ) Z(x, y) . Z(x, y) = σ∈S(x,y) The weight of the adjacency at internal node v is then the sum of the Boltzmann probabilities of all scenarios where the adjacency is present at node v. All such quantities can be computed in polynomial time [12]. Parameter kT is useful to skew the Boltzmann proba- bility distribution: If kT tends to zero, parsimonious sce- narios are heavily favored and the Boltzmann probability distribution tends to the uniform distribution over opti- mal scenarios, while when kT tends to ∞, the Boltzmann distribution tends toward the uniform distribution over the whole solution space. In our experiments, we chose a value of kT = 0.1 that favors parsimonious scenarios but considers also slightly suboptimal scenarios. When aDNA sequence data is available for one or sev- eral ancestral genomes, markers identified in extant species can be related to assembled contigs of the ancestral genome, as in [30] for example. For an ancestral adjacency in a species for which aDNA reads are available, it is then possible to associate a sequence-based weight to the adjacency – either through gap filling methods (see Section 4, where we use the probabilistic model of GAML [11]), or scaffolding methods such as BESST [31] for example. In comparison to the weighting approach described above, these weights are then not directly based on the underlying phylogeny, but provide an external signal for the confidence of adjacencies at the respective internal node. 4 RESULTS We evaluated our algorithm on a simulated dataset and compared its sensitivity and precision to several other re- construction methods. Further, we applied our method to two real datasets: mammalian and Yersinia genomes. The mammalian dataset was used in the studies [13] and [27]. It contains six mammalian species and two outgroups, spanning over 100 million years of evolution, and five different marker sets of varying resolution (minimal marker length). Our experimental results consider issues related to the complexity of our algorithm, the use of a pure SCJ reconstruction (obtained when the α parameter equals 0) and the relative impact of the value of α on both the total evolutionary cost and the ancestral gene orders fragmenta- tion. Our second dataset contains eleven Yersinia genomes, an important human pathogen. This dataset contains contigs from the recently sequenced extinct agent of the Black Death pandemic [9] that occurred roughly 650 years ago. We refer to Supplementary Fig. 9 and 10 for the species phylogenies of these two datasets. 4.1 Simulations We created simulated datasets as described in [16]: with a birth-rate of 0.001 and a death rate of 0, we simulated 20 binary trees with 6 leaves and scaled the branch lengths such that the tree has a diameter D = 2n, where n is the number of markers in each unichromosomal genome. 6 ues of α, the influence of the weighting becomes apparent: for kT = 0.1, the precision only decreases for α = 1, while for kT = 1, the precision decreases also for lower values of α, however leading to more complete reconstructions. In comparison, both DCJ-based methods RINGO and MGRA produce less fragmented solutions by recovering more true adjacencies under the jeopardy of also reconstructing more false adjacencies. The sensitivity and precision of Fitch-SCJ, ROCOCO and ANGES are comparable to our method for low to medium values of α. The F1 score assesses the relation of sensitivity and pre- cision with equal importance. RINGO achieves a better F1 score than all other methods. The F0.5 score emphasizes the precision of a method over its sensitivity. With this measure, our method with kT = 1 and α = 0.5 outperforms the other tools, while ROCOCO and ANGES also reach similarly good scores. In general, it can be seen that the equal contribution of global evolution and local adjacency weights in the objective function provides a reliable reconstruction and further a useful tool to explore the solution space under different values of α. Fig. 1. Average precision and sensitivity (top), and F1 and F0.5 (bottom) of reconstructions on 20 simulated datasets. Adjacency weights have been obtained with parameters kT = 0.1 (left) and kT = 1 (right). The root genome with n = 500 markers is then evolved along the branches of the tree by applying inversions and translocations with a probability of 0.9 and 0.1 respectively. The number of rearrangements at each branch corresponds to the simulated branch length, the total number of re- arrangements ranges from 1242 to 2296 in the simulated trees. We compare results of our implementation PHYSCA for different values of α ∈ {0, 0.3, 0.5, 0.8, 1} with the tools RINGO [16], MGRA [4], Fitch-SCJ [8], ROCOCO [33], [35] (dense approach for signed adjacencies) and ANGES [20] (adjacencies only). We computed adjacency weights as de- scribed in subsection 3.7 with the software DeClone [12] and parameter kT ∈ {0.1, 1}. The methods RINGO and MGRA are global approaches minimizing the DCJ-distance in the tree, while ANGES reconstructs specific ancestors locally in the tree and is applied for each node separately. For α = 0, our objective is finding a consistent, most parsimonious solution and equals the objectives of Fitch-SCJ and ROCOCO, where Fitch-SCJ always finds the most fragmented solution whereas RO- COCO and our method aim at reporting least fragmented reconstructions. We measured sensitivity and precision of the recon- structions based on the comparison of simulated and re- constructed adjacencies by the different methods. A high sensitivity indicates the ability to recover the true marker order of ancestors in the phylogeny, while a high precision denotes few wrongly reconstructed adjacencies. As shown in Figure 1, our method reaches a high precision of 0.99 for all values of α ≥ 0.5, while increasing the sensitivity in comparison to the pure Fitch-SCJ solution by reducing the fragmentation of the reconstructed scaffolds. For higher val- 4.2 Mammalian dataset We used the markers computed in [13] from whole-genome alignments. The extant species contain a diverse number of chromosomes ranging from 9 chromosomes in opossum to 39 chromosomes in pig. Unique and universal markers were computed as synteny blocks with different resolution in terms of minumum marker length. Note that all rearrange- ment breakpoints are therefore located outside of marker coordinates. It results in five different datasets varying from 2, 185 markers for a resolution of 100 kb to 629 markers for a resolution of 500 kb. We considered all adjacencies present in at least one ex- tant genome as potentially ancestral. To weight an adjacency at all internal nodes of the tree, we relied on evolutionary scenarios for each single adjacency, in terms of gain/loss, independently of the other adjacencies (i. e. without con- sidering consistency of ancestral marker orders). We obtain these weights using the software DeClone [12], and we refer to them as DeClone weights. We considered two values of the DeClone parameter kT , 0.1 and 1, the former ensuring that only adjacencies appearing in at least one optimal adjacency scenario have a significant DeClone weight, while the latter samples adjacencies outside of optimal scenarios. For the analysis of the ancestral marker orders obtained with our algorithm, we considered the data set at 500 kb resolution and sampled 500 ancestral marker orders for all ancestral species under different values of α. Complexity The complexity of our algorithm is dependent on the size of the largest connected component of the global adjacency graph. In order to restrict the complexity, we kept only adjacencies whose weights are above a given threshold x. Figure 2 shows the expected decrease in computational complexity correlated to threshold x for the five differ- ent minimal marker lengths. In most cases, all connected components are small enough to be handled by our exact lllll0.50.60.70.80.91.00.40.50.60.70.8kT = 0.1PrecisionSensitivitylllll0.50.60.70.80.91.00.40.50.60.70.8kT = 1PrecisionSensitivitylllll0.50.60.70.80.91.00.40.50.60.70.8F1 scoreF0.5 scorelllll0.50.60.70.80.91.00.40.50.60.70.8F1 scoreF0.5 scoreMGRARINGOSCJANGESPHYSCA α 00.30.50.81ROCOCO Frequency of adjacencies in 500 samples with α = 0 as percentage of optimal labelings they appear in. TABLE 1 7 Ancestor Frequency f f = 100% 100% > f > 50% f < 50% Boreoeutheria Euarchontoglires Ferungulates Primates Rodentia Theria root node 94.66 95.42 96.53 98.82 99.49 97.67 92.23 1.07 0.88 0.55 0.34 0.34 0.89 1.23 4.27 3.79 2.92 0.84 0.17 1.43 6.53 The optimal SCJ distance in the tree for α = 0 is 1, 674, while the related DCJ distance in the sampled reconstruc- tions varies between 873 and 904 (Figure 4). In comparison, we obtained a DCJ distance of 829 with GASTS [36], a small parsimony solver directly aiming at minimizing the DCJ distance. More precisely, over all ancestral nodes, 70 adjacencies found by GASTS do not belong to our prede- fined set of potential ancestral adjacencies and another 147 appear in the 500 samples with a frequency below 50%. This illustrates both a lack of robustness of the pure SCJ optimal labelings, and some significant difference between the SCJ and DCJ distances. Finally, we compared the Boltzmann probabilities of ancestral adjacencies (DeClone weights) with the frequency observed in the 500 samples. There is a very strong agree- ment for DeClone weights obtained with kT = 0.1 as only 14 ancestral adjacency have a DeClone weight that differs more than 10% from the observed frequency in the samples. This shows that, despite the fact that the DeClone approach disregards the notion of conflict, it provides a good approximation of the optimal solutions of the SCJ Small Parsimony Problem. Ancestral reconstruction with DeClone weights and varying values of α. For α > 0, our method minimizes a combination of the SCJ distance with the DeClone weights of the adjacencies discarded to ensure valid ancestral gene orders. Again, we sampled 500 solutions each for different values of α with the 500 kb data set. We distinguish between DeClone parameter kT = 0.1 and kT = 1. Figures 4 and 5 show the respective observed results in terms of evolutionary distance and fragmentation. For kT = 0.1, the optimal SCJ and DCJ distance over the whole tree hardly depends on α. Including the DeClone weights in the objective actually results in the same solution, independent of α > 0. In fact, while applying a low weight threshold of x = 0.2, the set of potential adjacencies is already consistent at all internal nodes except for a few conflicts at the root that are solved unambiguously for all values of α. This indicates that building DeClone weights on the basis of mostly optimal adjacency scenarios (low kT ) results in a weighting scheme that agrees with the evolution along the tree for this dataset. More importantly, Figures 4 and 5 show that the combination of DeClone weights followed by our algorithm, leads to a robust set of ancestral gene orders. Fig. 2. Number of different labels for the largest connected component in each of the mammalian datasets. This statistic provides an upper bound for the actual complexity of our reconstruction algorithm. Fig. 3. Number of reconstructed CARs at each internal node in 500 samples for the mammalian dataset with 500 kb resolution, x = 0.2 and α = 0. algorithm in reasonable time except for very large compo- nents in the marker sets with higher resolution under a low threshold x. For the 500 kb dataset with x = 0.2 and kT = 1, the computation of one solution takes on average 200 s on a 2.6 GHz i5 with 8 GB of RAM. It can be reduced to 30 s when DeClone weights are based on kT = 0.1. This illustrates that our algorithm, despite an exponential worst-case time complexity, can process realistic datasets in practice. Optimal SCJ labelings Next, we analyzed the 500 optimal SCJ labelings obtained for α = 0, i. e. aiming only at minimizing the SCJ distance, and considered the fragmentation of the ancestral gene orders (number of CARs) and the total evolutionary dis- tance. Note that, unlike the Fitch algorithm used in [17], our algorithm does not favor fragmented assemblies by design but rather considers all optimal labelings. Sampling of co- optimal solutions shows that the pure SCJ criterion leads to some significant variation in terms of number of CARs (Figure 3). In contrast, Table 1 shows that most observed ancestral adjacencies are present in all sampled scenarios. About 5% of adjacencies, mostly located at nodes higher up in the phylogeny, are only present in a fraction of all sampled scenarios, indicating that there is a small number of conflicts between potential adjacencies that can be solved ambiguously at the same parsimony cost. 0.20.30.40.50.60.70.81e+031e+071e+11threshold xnumber of labels (log scale)1111122222333334444455555marker length100200300400500llllllllllllllllllBoreo.Euarcho.Ferun.Primat.Rodent.Theria405060708090100ancestornumber of CARs 8 Fig. 4. SCJ distance (upper half) and DCJ (lower half) distance in the whole tree for all samples and selected values of α in the mammalian dataset. Fig. 6. Reconstructed number of CARs in the yersinia dataset with aDNA weights at the BD node and 0 otherwise, for four ancestral nodes. the Black Death agent, considered as ancestral to several extant strains [9]. We refer to this augmented ancestral node as the Black Death (BD) node. The marker sequences for all extant genomes were computed as described in [30], restricting the set of markers to be unique and universal. We obtained a total of 2, 207 markers in all extant genomes and 2, 232 different extant adjacencies, thus showing a relatively low level of syntenic conflict compared to the number of markers, although it implies a highly dynamic rearrange- ment history over the short period of evolution [30]. As for the mammalian dataset, we considered as po- tentially ancestral any adjacency that appears in at least one extant genome. However for this dataset, reducing the complexity by applying a weight threshold x was not necessary. For the BD node, adjacency weights can be based on the given aDNA reads for a given potential ancestral adjacency as follows. First, we used FPSAC [30] to compute DNA sequences filling the gaps between any two adjacent marker extremities (obtained by aligning the gap sequences of the corresponding conserved extant adjacencies and re- constructing a consensus ancestral sequence using the Fitch algorithm). Then we computed the weights as a likelihood of this putative gap sequence given the aDNA reads, us- ing the GAML probabilistic model described in [11]. Each adjacency together with its template gap sequence details a proposition for an assembly A as a piece of the real ancestral sequence, and given the aDNA read set R, the model r∈R P r(rA) for observing the reads R given that A is the correct assembly. The probability P r(rA) can be computed by aligning r to the assembly A while the alignment is evaluated under an appropriate sequencing error model. We refer to [11] for details. then defines a probability P r(RA) = (cid:81) Ancestral reconstruction with aDNA weights Again we sampled 500 solutions for this dataset. We com- puted the weights at the BD node based on the aDNA data, while adjacencies at all other nodes were given weight 0. Hence we can investigate the influence of including the aDNA sequencing data in the reconstruction while for the rest of the tree, the weights do not impact the objective function. Moreover, this weighting scheme addresses the issue of potential BD adjacencies with a low weight due to the difficulty of sequencing ancient DNA. Fig. 5. Number of CARs in the mammalian dataset in all samples at selected internal nodes for different values of α reconstructed with DeClone weights under kT = 0.1. While the number of CARs differs in the case of α = 0 where the adjacency weights are not considered, the fragmentation stays constant for the other values of α. In comparison, for kT = 1, we see an increase in SCJ and DCJ distance for higher α, while the number of CARs at in- ternal nodes decreases, together with a loss of the robustness of the sampled optimal results when α gets close to 1. It can be explained by the observation that the weight distribution of ancestral adjacencies obtained with DeClone and kT = 1 is more balanced than with kT = 0.1 as it considers sub- optimal scenarios of adjacencies with a higher probability. It further illustrates that, when the global evolutionary cost of a solution has less weight in the objective function, the algorithm favors the inclusion of an adjacency of moderate weight that joins two CARs while implying a moderate number of evolutionary events (for example an adjacency shared by only a subset of extant genomes). From that point of view, our algorithm – being efficient enough to be run on several values of α – provides a useful tool to evaluate the relation between global evolution and prior confidence for adjacencies whose pattern of presence/absence in extant genomes is mixed. 4.3 Yersinia pestis dataset We started from fully assembled DNA sequences of seven Yersinia pestis and four Yersinia pseudotuberculosis genomes. In addition, we included aDNA single-end reads and 2 134 contigs of length > 500bp assembled from these reads for lllllalphadistance00.30.50.81900100017001800SCJ, kT 0.1SCJ, kT 1DCJ, kT 0.1DCJ, kT 1llllllll00.30.50.8100.30.50.8100.30.50.814050607080number of CARsalphaEuarchonto.PrimatesTherialllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll00.30.50.800.30.50.800.30.50.800.30.50.82468101214number of CARsalphaBDnode1node5node6 As shown in Figure 6, for selected internal nodes of the phylogeny, the pure SCJ solutions at α = 0 result in the highest fragmentation, while the number of CARs decreases as we increase the importance of the adjacency weights in the objective of our method. For the BD node, when including the aDNA weights, the fragmentation is decreasing while the reconstructions for each α > 0 are robust. At the other nodes, the applied sequencing weights also reduce the fragmentation except for node6 which is located in the pseudotuberculosis subtree and hence more distant to the BD node. This shows that the aDNA weights not only influence the reconstructed adjacencies at the BD node, but also other nodes of the tree. 5 CONCLUSION Our main contributions are the introduction of the Small Parsimony Problem under the SCJ model with adjacency weights, together with an exact parameterized algorithm for the optimization and sampling versions of the problem. The motivation for this problem is twofold: incorporating sequence signal from aDNA data when it is available, and recent works showing that the reconstruction of ancestral genomes through the independent analysis of adjacencies is an interesting approach [5], [12], [17], [27]. Regarding the latter motivation, we address a general issue of these approaches that either ancestral gene orders are not consistent or are quite fragmented if the methods are constrained to ensure consistency. The main idea we intro- duce is to take advantage of sampling approaches recently introduced in [12] to weight potential ancestral adjacencies and thus direct, through an appropriate objective function, the reconstruction of ancestral gene orders. Our results on the mammalian dataset suggest that this approach leads to a robust ancestral genome structure. However, we can observe a significant difference with a DCJ-based ancestral reconstruction, a phenomenon that deserves to be explored further. Our algorithm, which is based on the Sankoff- Rousseau algorithm similarly to several recent ancestral reconstruction algorithms [5], [12], [27], is a parameterized algorithm that can handle real instances containing a mod- erate level of syntenic conflict. Our experimental results on both the mammalian and bacterial datasets suggest that introducing prior weights on adjacencies in the objective function has a significant impact in reducing the fragmen- tation of ancestral gene orders, even with an objective func- tion with balanced contributions of the SCJ evolution and adjacency weights. For highly conflicting instances, it can be discussed if a reconstruction through small parsimony is the right approach to solve these conflicts or if these should be addressed differently. Our sampling algorithm improves on the Gibbs sampler introduced in [27] in terms of computational complexity and provides a useful tool to study ancestral genome reconstruc- tion from a Bayesian perspective. Moreover, our algorithm is flexible regarding the potential ancestral gene adjacencies provided as input and could easily be associated with other ideas, such as intermediate genomes for example [16]. There are several research avenues opened by our work. From a theoretical point of view, we know the problem we introduced is tractable for α = 0 and α = 1, and 9 we show it is hard for α > 33/34, but it remains to see whether it is hard otherwise. Further, given that the considered objective is a combination of two objectives to be optimized simultaneously, Pareto optimization is an interesting aspect that should be considered. Our model could also be extended towards other syntenic characters than adjacencies, i. e. groups of more than two markers, following the ancient gene clusters reconstruction approach introduced in [33]. As ancestral gene orders are defined by consistent sets of adjacencies, the principle of our dynamic programming algorithm could be conserved and it would only be a matter of integrating gene clusters into the ob- jective function. From a more applied point of view, one would like to incorporate duplicated and deleted markers into our Small Parsimony Problem. There exist efficient algorithms for the case of a single adjacency [5], [12] that can provide adjacency weights, and natural extensions of the SCJ model to incorporate duplicated genes. However it remains to effectively combine these ideas. Finally, again due to the flexibility and simplicity of the Sankoff-Rousseau dynamic programming algorithm, one could easily extend our method towards the inference of extant adjacencies if some extant genomes are provided in partially assembled form following the general approach described in [1], [3]. This would pave the way towards a fully integrated phy- logenetic scaffolding method that combines evolution and sequencing data for selected extant and ancestral genomes. Acknowledgements NL and RW are funded by the International DFG Research Training Group GRK 1906/1. CC is funded by NSERC grant RGPIN-249834. REFERENCES [1] Aganezov Jr., S., Sitdykova, N., Alekseyev, M.: Scaffold assembly based on genome rearrangement analysis. Comput. Biol. and Chemistry 57, 46–53 (2015) [2] Alekseyev, M., Pevzner, P.A.: Breakpoint graphs and ancestral genome reconstructions. Genome Res. 19, 943–957 (2009) [3] Anselmetti, Y., Berry, V., pthers: Ancestral gene synteny recon- struction improves extant species scaffolding. BMC Genomics 16(Suppl 10), S11 (2015) [4] Avdeyev, P., Jiang, S., Aganezov, S., Hu, F., Alekseyev, M.A.: Reconstruction of ancestral genomes in presence of gene gain and loss. Journal of Computational Biology 23(3), 150–164 (2016) [5] B´erard, S., Gallien, C., et al.: Evolution of gene neighborhoods within reconciled phylogenies. Bioinformatics 28, 382–388 (2012) [6] Berman, P., Karpinski, M.: On some tighter inapproximability results. In: International Colloquium on Automata, Languages, and Programming. pp. 200–209. Springer (1999) [7] Bertrand, D., Gagnon, Y., et al.: Reconstruction of ancestral genome subject to whole genome duplication, speciation, rearrangement and loss. In: WABI 2010, LNCS, vol. 6293, pp. 78–89. Springer (2010) [8] Biller, P., Feijao, P., Meidanis, J.: Rearrangement-based phylogeny using the single-cut-or-join operation. IEEE/ACM TCBB 10(1), 122–134 (2013) [9] Bos, K.I., Schuenemann, V., et al.: A draft genome of yersinia pestis from victims of the black death. Nature 478, 506–510 (2011) [10] Bosi, E., Donati, B., et al.: Medusa: a multi-draft based scaffolder. Bioinformatics 31(15), 2443–2451 (2015) [11] Boza, V., Brejov´a, B., Vinar, T.: GAML: Genome Assembly by Maximum Likelihood. Algorithms Mol. Biol. 10, 18 (2015) [12] Chauve, C., Ponty, Y., Zanetti, J.: Evolution of genes neighbor- hood within reconciled phylogenies: An ensemble approach. BMC Bioinformatics 16(Suppl. 19), S6 (2015) 10 [13] Chauve, C., Tannier, E.: A methodological framework for the reconstruction of contiguous regions of ancestral genomes and its application to mammalian genomes. PLoS Comput. Biol. 4, e1000234 (2008) [14] Csuros, M.: How to infer ancestral genome features by parsimony: Dynamic programming over an evolutionary tree. In: Models and Algorithms for Genome Evolution, pp. 29–45. Springer (2013) [15] Denoeud, F., Carretero-Paulet, L., et al.: The coffee genome pro- vides insight into the convergent evolution of caffeine biosynthe- sis. Science 345, 125527 (2013) [16] Feijao, P.: Reconstruction of ancestral gene orders using interme- diate genomes. BMC Bioinformatics 16(Suppl. 14), S3 (2015) [17] Feijao, P., Meidanis, J.: SCJ: a breakpoint-like distance that simpli- fies several rearrangement problems. IEEE/ACM TCBB 8, 1318– 1329 (2011) [18] Fitch, W.: Toward defining the course of evolution: minimum change for a specific tree topology. Syst. Biol. 20, 406–416 (1971) [19] Hartigan, J.A.: Minimum mutation fits to a given tree. Biometrics 29(1), 53–65 (1973) [20] Jones, B.R., Rajaraman, A., Tannier, E., Chauve, C.: Anges: recon- structing ancestral genomes maps. Bioinformatics 28(18), 2388– 2390 (2012) [21] Kov´ac, J., Brejov´a, B., Vinar, T.: A practical algorithm for ancestral rearrangement reconstruction. In: WABI 2011, LNCS, vol. 6833, pp. 163–174. Springer (2011) [22] Luhmann, N., Chauve, C., et al.: Scaffolding of ancient contigs and ancestral reconstruction in a phylogenetic framework. In: BSB 2014, LNCS, vol. 8826, pp. 135–143. Springer (2014) [23] Luhmann, N., Th´evenin, A., Ouangraoua, A., Wittler, R., Chauve, C.: The scj small parsimony problem for weighted gene adjacen- cies. In: International Symposium on Bioinformatics Research and Applications. pp. 200–210. Springer (2016) [24] Ma, J., Zhang, L., et al.: Reconstructing contiguous regions of an ancestral genome. Genome Res. 16, 1557–1565 (2006) [25] Mandric, I., Zelikovsky, A.: Scaffmatch: scaffolding algorithm based on maximum weight matching. Bioinformatics 31(16), 2632– 2638 (2015) [26] Ma nuch, J., Patterson, M., et al.: Linearization of ancestral mul- tichromosomal genomes. BMC Bioinformatics 13(Suppl 19), S11 (2012) [27] Mikl´os, I., Smith, H.: Sampling and counting genome rearrange- ment scenarios. BMC Bioinformatics 16(Suppl 14), S6 (2015) [28] Ming, R., Van Buren, R., et al.: The pineapple genome and the evolution of CAM photosynthesis. Nature Genetics (2015), in press [29] Neafsey, D.E., Waterhouse, R.M., et al.: Highly evolvable malaria vectors: The genome of 16 Anopheles mosquitoes. Science 347, 1258522 (2015) [30] Rajaraman, A., Tannier, E., Chauve, C.: FPSAC: fast phylogenetic scaffolding of ancient contigs. Bioinformatics 29, 2987–2994 (2013) [31] Sahlin, K., Vezzi, F., et al.: BESST - efficient scaffolding of large fragmented assemblies. BMC Bioinformatics 15, 281 (2014) [32] Sankoff, D., Rousseau, P.: Locating the vertices of a steiner tree in an arbitrary metric space. Math. Programming 9, 240–246 (1975) [33] Stoye, J., Wittler, R.: A unified approach for reconstructing ancient gene clusters. IEEE/ACM TCBB 6(3), 387–400 (2009) [34] Tannier, E., Zheng, C., Sankoff, D.: Multichromosomal median and halving problems under different genomic distances. BMC Bioinformatics 10(1), 120 (2009) [35] Wittler, R.: Phylogeny-based Analysis of Gene Clusters. Ph.D. Thesis, Faculty of Technology, Bielefeld University (2010) [36] Xu, A., Moret, B.: GASTS: parsimony scoring under rearrange- ments. In: WABI 2011, LNCS, vol. 6833, pp. 351–363. Springer (2011) [37] Zheng, C., Sankoff, D.: On the pathgroups approach to rapid small phylogeny. BMC Bioinformatics 12(Suppl 1), S4 (2011) APPENDIX Methods: supplementary material Results: supplementary material 11 Fig. 7. Simplified example of a connected component in the global adjacency graph. All internal nodes of the tree are augmented with adjacency graphs. At node v, the graph contains adjacency {xt, yh}, at node u, the graph contains adjacency {xt, zt}. Along the edge {u, v}, one adjacency has been cut, the other has been joined. In the global adjacency graph, we see a connected component that contains two edges incident to xt. This component does not contain a conflict, just a rearrangement. See Fig. 8 below for a C that contains a conflict. Fig. 9. Underlying phylogeny of the considered genomes for the mam- malian dataset used in the evaluation. Fig. 10. Underlying phylogeny of Yersinia dataset used in the evaluation. the considered genomes for the Fig. 8. Example for a given connected component C. At each node v of the tree, possible assignments are defined by the connected compo- nent containing all edges annotated with v. Possible assignments for a marker extremity, e. g. bt, are defined by the incident adjacency edges, hence in this example we can e. g. assign a1,a2 or ∅ to bt. Here two valid joint labeling for v are shown, while the third one assigns different adjacencies for bt and ch and is therefore invalid. A DP sampling algorithm. In the bottom-up traversal, in addition to the minimal cost induced by labeling a node v with a specific label a ∈ L, we can also store the number of optimal solutions under this label for the subtree rooted at v. Let x and y be the children of v, and Lx and Ly the sets of labels that induced the minimum value for a at v (which means a label out of these sets is assigned in the backtracking phase if v is labeled with a). Then  C(y, l) (cid:88) l∈Lx (cid:88) l∈Ly C(v, a) = C(x, l) for all optimal root labels: C(root) = (cid:80) gives the number of optimal solutions for the subproblem rooted at v. At the root, we might have the choice between different labels with minimum cost. Let Lroot be the set of these labels, then the number of overall possible co-optimal solutions is simply the sum of the number of solutions C(root, l). Subsequently in the top-down traversal, choose a label l ∈ Lroot with probability C(root,l) C(root) . If at an internal node more than one label in a child node induced the minimum value, choose one of these labels analogously. l∈Lroot Fig. 11. Yersinia dataset: Reconstructed number of CARs with DeClone weights at kT = 1. Fig. 12. Yersinia dataset: Reconstructed number of CARs with DeClone weights at kT = 0.1. vwvxtyhztw{xt, yh}{xt, zt}chdhetfha1a2a3a4a5vvwv,wv,wCbtbtchetfha1a2a1a4a2a4a5a5(bt,a1), (ch,a1), (et,a5), (fh,a5)valid:(bt, ), (ch,a4), (et,a4), (fh, )invalid:(bt,a1), (ch,a4), (et,a5), (fh,a5)chetfha1a2a4a5vvvvCvbtFerungulatesEuarchontogliresRodentiaPrimatesBoreoeutheriaTheriaCowPigHumanMacacaMouseRatOpossumChickenYersinia pestis AntiquaYersinia pestis C092Yersinia pestis Z176003Yersinia pestis Nepal516Yersinia pestis KIM10Yersinia pestis biovar MicrotusYersinia pestis Pestoides FYersinia pseudotuberculosis IP31758Yersinia pseudotuberculosis YPIIIYersinia pseudotuberculosis PB1Yersinia pseudotuberculosis IP32953Black Death aDNA36781245llllllllllllll00.30.50.8100.30.50.8100.30.50.8100.30.50.812468101214number of CARsalphaBDnode1node5node600.30.50.8100.30.50.8100.30.50.8100.30.50.812468101214number of CARsalphaBDnode1node5node6 NP-Hardness for high values of α In this section we show that Weighted SCJ labeling is NP- hard for 33/34 < α < 1. The Maximum Intersection Matching Problem Maximum Intersection Matching Problem (MIMP) Input: two graphs G1 and G2 with V (G1) = V (G2), and an integer r. Question: does there exist a perfect matching M1 in G1 and a perfect matching M2 in G2 such that E(M1) ∩ E(M2) ≥ r? We now introduce the problem used for showing the hardness of MIMP. The 3-Balanced-Max-2-SAT problem is, given n boolean variables x1, . . . , xn and a set of m clauses C = {C1, . . . , Cm}, each with exactly two literals (e.g. (x ∨ y)), such that each variable appears in the clauses 3 times positively and 3 times negatively, to find an assignment to the n variables such that a maximum of clauses are satisfied. Note that m = 3n since each variable appears in 6 clauses and each clause has 2 variables. This problem is NP-hard by a reduction from Max-Cut on 3-regular graphs [6]. We reduce 3-Balanced-Max-2-SAT to MIMP, and we begin by describing how we transform a given 3-Balanced-Max-2- SAT instance into a MIMP instance. Figure 13 illustrates the main ideas behind the reduction. Let x1, . . . , xn be the set of n variables and C = {C1, . . . , Cm} be the set of clauses of the given 3-Balanced- Max-2-SAT instance. In our construction the graph G1 cor- responds to the variables and G2 to the clauses. 17 in cyclic order. Call the edges vi 1, . . . , vi 13 positive, and the edges vi The graph G1 is the disjoint union of n cycles X1, . . . , Xn each of length 18, one for each variable xi. For each 1 ≤ i ≤ n, the cycle Xi corresponding to xi has vertices 6vi 0, vi vi 7 and 16 nega- 12vi vi tive. Note that Xi has exactly two perfect matchings: one containing all the positive edges, and one containing all the negative edges. Since G1 has n such cycles, G1 has 2n perfect matchings, which are in bijection with the possible xi assignments. Also note that no two positive or negative edges share a vertex. 0vi 10 and vi 1, vi 15vi 4, vi 3vi 9vi 1 , C +i 2 , C +i Some additional notations are needed before we can construct G2. Let C +i 3 be the 3 clauses containing variable xi positively. Map each of the 3 positive edges of 1 to C +i 0vi Xi to a distinct clause arbitrarily (e.g. we map vi 1 , 2 , C−i 3 ). Similarly let C−i 1 , C−i vi 6vi 3 be the clauses in which xi appears negatively, and map each negative edge of Xi to one of these clauses in a distinct manner. 13 to C +i 2 and vi 7 to C +i 12vi Now, G2 has the same vertex set as G1, and is the union of m cycles Z1, . . . , Zm of length 6, one for each clause in C. Let xj and xk be the two variables contained in a avj clause Ci. Let vj a+1 be the edge of the cycle Xj mapped to Ci, and vk b vk b+1 be the edge of the cycle Xk mapped to Ci. Then the cycle Zi corresponding to Ci is, in cyclic order, vj a, where addition is to be taken modulo 18. Thus Zi contains exactly two edges in common with G1: vj b+1 is from Xk. Importantly, Zi has 2 possible perfect matchings: one contains vj a+1 is from Xj and vk a+1 and the other has vk a+1vj a+5vk b+1vk b+5vj b vk b vk avj avj avj b+1. b vk 12 Fig. 13. Illustration of a clause gadget used for the MIMP reduction. The cycles X1 and X2 are the cycles of G1 corresponding to variables x1 and x2. The '+' edges are positive, and the '-' edges are negative., The cycle Z1 (dashed edges) corresponds to the clause C1 = (x1 ∨ x2), where here the edges v1 4 are hypothetically mapped to C1. 1 and v2 Other clause cycles are not shown. 3v2 0v1 Intuitively speaking, if an edge e is in both G1 and G2, say on the cycles Xi of G1 and Zj of G2, then e corresponds to the fact that xi appears in clause Cj. If e is positive, setting xi = T rue satisfies Cj, and if e is negative, setting xi = F alse satisfies Cj. We first prove some structural properties of G1 and G2 which will be of use later on. We denote by G the complement of a graph G. Lemma 2. The graphs G1 and G2 satisfy the following conditions: V (G1) = V (G2) are even; 1) 2) G1 is the disjoint union of cycles of length at most 18; 3) G2 is the disjoint union of cycles of length at most 6; 4) G1 and G2 have a perfect matching in common, i.e. there is a set E ⊆ E(G1)∩ E(G2) such that E forms a perfect matching in both G1 and G2. a is on the Zi cycle. Otherwise, vj Proof: Conditions 1) and 2) are immediate from our construction. For 3), we need to show that the m cycles of G2 are disjoint. We argue that each vertex of G2 appears in exactly one cycle. First, each vertex vj a gets included in at least one cycle Zi: if vj a is an endpoint of a positive or a negative edge e, then e is mapped to some clause Ci, and so vj a is not on a positive or negative edge, and thus we have a ∈ {2, 5, 8, 11, 14, 17}. Therefore a − 5 ∈ {15, 0, 3, 6, 9, 12} (modulo 18). In this case, vj a−5 is on a positive or negative edge, and one can check that vj a−5. To see that no vertex gets included in two cycles, observe that V (G2) = V (G1) = 18n = 18(m/3) = 6m. Thus G2 has m cycles of length 6 spanning 6m vertices, which is only possible if no two cycles of G2 intersect. For condition 4), there are many choices, and we exhibit one. Let 1 ≤ j ≤ n and 1 ≤ a ≤ 18. One can check that in both G1 and G2, vj a is not a neighbor a+2 : 1 ≤ j ≤ n, 0 ≤ a ≤ 17} of vj (addition modulo 18) is a perfect matching of G1 and G2. a+2. Thus the set E = {vj a is in the same cycle Zi as vj avj Observe that since G2 is a disjoint union of cycles, it has 2m perfect matchings since each cycle has 2 possible perfect matchings. We are now ready to prove the hardness of MIMP. 01234567891011121314151617+-++--01234567891011121314151617+-++--X1X2Z1C1 = (x1 V x2) avj Proof of Theorem 2: It is easy to see that MIMP is in NP, since checking that two given matchings are perfect and share r edges in the two graphs can be done in polynomial time. Also, G1 and G2 can obviously be constructed in polynomial time. To prove NP-hardness, we claim that, using the construction described above, at least r clauses of C are satisfiable if and only if G1 and G2 admit a perfect matching with at least r edges in common. (⇒) Let A be an assignment of x1, . . . , xn satisfying r clauses of C. In G1, for each Xi cycle, take the positive perfect matching of Xi if xi is positive in A, and the negative perfect matching otherwise. The result is a perfect matching M1 of G1. To construct a perfect matching M2 of G2, let Ci be a clause satisfied by the value of a variable xj in A. Then, take in M2 the perfect matching of Zi that contains the edge vj a+1 of Xj mapped to Ci. This edge is shared by both our choices in G1 and G2. We apply this choice of Zi perfect matching for each clause Ci satisfied by A (and pick the matching of Zi(cid:48) arbitrarily for an unsatisfied clause Ci(cid:48)). Since r clauses are satisfied, there must be r common edges in M1 and M2. (⇐) Let M1 and M2 be the perfect matchings of G1 and G2 with common edges F = E(M1) ∩ E(M2), F ≥ r. Observe that each edge of F must be either positive or negative in G1. We claim that the following assignment A satisfies at least r clauses: set xi = T rue if F has a positive edge in Xi, set xi = F alse if F has a negative edge in Xi, and set xi arbitrarily if F has no positive or negative edge in Xi. No xi can be assigned two values since F ⊆ M1 and M1 is in a perfect matching of G1 (and thus cannot contain both positive and negative edges from the same cycle Xi). Let Z = {Zi1, Zi2, . . . , Zik} be the clause cycles of G2 containing an edge of F . For each Zi in G2, there can only be one edge of Zi in F (recall that each possible perfect matching of Zi has exactly one edge in common with G1). Hence since F ≥ r, there must be at least r clause cycles in Z, and thus at least r satisfied clauses. Hardness of Weighted-SCJ-labeling Given an MIMP instance G1 and G2 that satisfies the con- ditions of Lemma 2, we construct a Weighted-SCJ-labeling instance consisting of a phylogeny T , consistent extant adjacencies on the leaves of T and weighted ancestral adja- cencies on its internal nodes. Let 2n = V (G1) = V (G2). The Weighted-SCJ-labeling instance has n markers, and the phylogeny is a tree T with 4 leaves A, B, C, D and 3 internal nodes X, Y and Z. The node X is the parent of A and B, the node Y is the parent of C and D and the node Z is the parent of X and Y . Let E ⊆ E(G1) ∩ E(G2) such that E forms a perfect matching in both G1 and G2. The marker extremities are V (G1) = V (G2) and the marker head-tail pairs are given by E (i.e. if xy ∈ E, then x and y are the two extremities of a marker). Since G1 is a union of disjoint cycles of even length, its edges can be partitioned into two disjoint perfect match- ings M1,1 and M1,2. More precisely, let M1,1 be a perfect matching of G1. By removing the set of edges M1,1 from G1, we obtain another perfect matching M1,2. The extant adjacencies for the leaf A are given by M1,1, and those of B by M1,2. Similarly, G2 can be split into two disjoint perfect 13 matchings M2,1 and M2,2. The extant adjacencies of leaf C are given by M2,1 and those of leaf D by M2,2. The set of adjacencies under consideration is A := E(G1)∪ E(G2). In X (respectively Y ), all adjacencies corre- sponding to an edge of G1 (respectively G2) have weight 1. All other adjacencies, including all adjacencies in Z, have weight 0. Note that in this construction, any ancestral adjacency a with non-zero weight can be found in some leaf of T , which corresponds to the initialization in our method. Also note that no adjacency connects two extremities from the same marker. Indeed, all adjacencies on T , extant or ancestral, are taken from either G1 or G2, whereas marker extremities are defined by E, which is taken from the com- plement of G1 and G2. Thus there is no marker/adjacency inconsistency. We show that if α > 33/34, Weighted SCJ labeling is NP-hard. This is mainly because we are "forced" to assign a perfect matching to X and Y , as we show in the next Lemma. We then need to choose these matchings so as to maximize their intersection, since this minimizes the SCJ distance on the XZ and Y Z branches. Lemma 3. Let α > 33/34. Let λ be any labeling for the instance T constructed from G1 and G2 as above. Then there is a labeling λ(cid:48) such that the edges corresponding to λ(cid:48)(X) (respectively λ(cid:48)(Y )) form a perfect matching of G1 (respectively G2), and D(λ(cid:48), T ) ≤ D(λ, T ). Proof: Call a cycle C of G1 (resp. G2) covered by λ if λ(X) (resp. λ(Y )) has exactly V (C)/2 edges of C, i.e. λ(X) (resp. λ(Y )) contains a perfect matching of C. If every cycle of G1 and every cycle of G2 is covered by λ, then the Lemma holds. Otherwise, we show that if there is an uncovered cycle C, it is advantageous to modify λ in order to make C covered. Thus let C be a cycle of either G1 or G2 that is not covered by λ, and denote c := V (C). We have c ≤ 18. Let W = X if C is in G1, and W = Y if C is in G2 instead. Let M be the edges of C that correspond to an adjacency labeled by λ(W ). Let d be the number of vertices of C that do not belong to an edge of M (i.e. vertices of C that do not belong to any adjacency of λ(W ), or that belong to an adjacency that does not correspond to an edge of C). Since C is not covered we assume that d ≥ 1. Now, M has (c − d)/2 edges. As c is even, this implies d ≥ 2 as it must also be even. Obtain λ(cid:48) from λ by first removing all adjacencies of λ(W ) including a vertex of C, then adding to λ(W ) the perfect matching of C that has the most edges common to M, observing that we retain at least M/2 edges of M (and hence remove at most M/2). Then the number of adjacencies in λ but not in λ(cid:48) is at most d + M/2 = d + (c−d)/2 . On the other hand at most c/2 − M/2 = c/2 − (c − d)/4 = 4 ≤ 18+d adjacencies are assigned by λ(cid:48) but not by λ. As c+d X and Y have 3 incident edges, the increase in the SCJ cost incurred by changing from λ to λ(cid:48) is at most (1 − α) · 3(d + ) = (1 − α)(3d + 27). On the other hand, the 18−d 4 + 18+d cost of adjacency weights is decreased by αd/2, since in C, M = (c − d)/2 edges of weight 1 are removed, and c/2 edges of weight 1 are added, and so d/2 new adjacencies of weight 1 are gained. The total difference in cost from λ to λ(cid:48) is at most (1 − α)(3d + 27) − αd/2. One can check that for d >= 2 and α ≥ 33/34, this total difference is no more 4 ≤ d + 18−d = d + c−d 2 4 4 4 14 than 0. Therefore, we can modify λ to cover C at an equal or better cost. By applying this idea on every cycle of G1 and G2, we get a labeling λ(cid:48) such that λ(cid:48)(X) is a perfect matching of G1 and λ(cid:48)(Y ) is a perfect matching of G2. We can finally show the hardness of Weighted-SCJ- labeling. Proof of Theorem 1: To prove NP-hardness of Weighted-SCJ-labeling, we use the construction described above, which can easily be seen to be feasible in polynomial time. We show that G1 and G2 admit a perfect matching with k common edges if and only if T as constructed above admits a labeling total cost at most (1− α)(6n− 2k) + α· 2n if α > 33/34. (⇒) Let M1 and M2 be perfect matchings of G1 and G2, respectively, that share edge set I = E(M1) ∩ E(M2), with I ≥ k. We label the internal node X of T with the adjacencies corresponding to M1, the internal node Y with the adjacencies corresponding to M2, and internal node Z with the adjacencies corresponding to I. Now, each of the n adjacencies in λ(X) is found in either λ(A) or λ(B) (but not both). Thus λ(X) \ λ(A) + λ(X) \ λ(B) = n. Conversely λ(A)\λ(X)+λ(B)\λ(X) = n because half of λ(A)∪λ(B) is in λ(X). Thus the AX and BX branches, together, induce an SCJ cost of 2n. Similarly, the CY and DY branches induce an SCJ cost of 2n. There are n − k adjacencies of λ(X) not in λ(Z) and all adjacencies of λ(Z) are in λ(X), and so the XZ branch has SCJ cost n− k. Likewise, Y Z has SCJ cost n − k. The total SCJ cost is 6n − 2k. As for the cost of adjacency weights, X has 2n adjacen- cies of weight 1, and n of them are used by λ(X). The same holds for Y . Thus X and Y , together, induce an ancestral adjacency cost of 4n − 2n = 2n. The total weighted cost is (1 − α)(6n − 2k) + α · 2n as desired. (⇐) Suppose that G1 and G2 is a "no" instance, i. e. no pair of perfect matching have k edges in common. We show that any labeling has cost strictly greater than (1 − α)(6n − 2k) + α · 2n. As per Lemma 3, there is an optimal labeling λ for T such that λ(X) is a perfect matching of G1 and λ(Y ) is a perfect matching of G2. Choose such an optimal λ that labels Z with a minimum number of adjacencies. By the same argument as above, the branches AX, BX, CY and DY incur, together, an SCJ cost of 4n. As for XZ and Y Z, let a be an adjacency in λ(Z), and recall that a has weight 0 in Z. Then a must be in one of λ(X) or λ(Y ), since if a is in neither of λ(X) nor λ(Y ), then it should be removed as λ is suboptimal. If a is in λ(X) but not in λ(Y ), presence or absence of a in λ(Z) has the same cost, and thus a (cid:54)∈ λ(Z) by our choice of λ. Thus λ(Z) ⊆ λ(X) ∩ λ(Y ). Since G1 and G2 form a "no" instance and X and Y are labeled by a perfect matching, we must have λ(X) ∩ λ(Y ) < k, and therefore λ(Z) < k. The cost incurred by the XZ and Y Z branches is 2n − 2λ(Z) > 2n − 2k. We get that the total SCJ cost incurred by λ is strictly greater than 6n − 2k. Exactly 2n of the 4n putative ancestral adjacencies for X and Y are taken by λ, and so the ancestral adjacency cost is 2n. In total, the cost of the labeling λ is strictly higher than (1 − α)(6n − 2k) + α(2n), and T is also a "no" instance. The above analysis, in particular Lemma 3, can certainly be improved in order to yield better bounds for α. Never- theless, the question of whether Weighted SCJ labeling is NP-hard for every 0 < α < 1 is wide open.
1102.3813
2
1102
2011-02-22T12:43:56
Efficient Algorithms for Dualizing Large-Scale Hypergraphs
[ "cs.DS" ]
A hypergraph ${\cal F}$ is a set family defined on vertex set $V$. The dual of ${\cal F}$ is the set of minimal subsets $H$ of $V$ such that $F\cap H \ne \emptyset$ for any $F\in {\cal F}$. The computation of the dual is equivalent to many problems, such as minimal hitting set enumeration of a subset family, minimal set cover enumeration, and the enumeration of hypergraph transversals. Although many algorithms have been proposed for solving the problem, to the best of our knowledge, none of them can work on large-scale input with a large number of output minimal hitting sets. This paper focuses on developing time- and space-efficient algorithms for solving the problem. We propose two new algorithms with new search methods, new pruning methods, and fast techniques for the minimality check. The computational experiments show that our algorithms are quite fast even for large-scale input for which existing algorithms do not terminate in a practical time.
cs.DS
cs
Efficient Algorithms for Dualizing Large-Scale Hypergraphs Keisuke Murakami1 and Takeaki Uno1 National Institute of Informatics, 2-1-2 Hitotsubashi, Chiyoda-ku, Tokyo 101-8430, JAPAN, e-mail: {murakami,uno}@nii.ac.jp Abstract. A hypergraph F is a set family defined on vertex set V . The dual of F is the set of minimal subsets H of V such that F ∩H 6= ∅ for any F ∈ F. The computation of the dual is equivalent to many problems, such as minimal hitting set enumeration of a subset family, minimal set cover enumeration, and the enumeration of hypergraph transversals. Although many algorithms have been proposed for solving the problem, to the best of our knowledge, none of them can work on large-scale input with a large number of output minimal hitting sets. This paper focuses on developing time- and space-efficient algorithms for solving the problem. We propose two new algorithms with new search methods, new pruning methods, and fast techniques for the minimality check. The computational experiments show that our algorithms are quite fast even for large-scale input for which existing algorithms do not terminate in a practical time. 1 Introduction A hypergraph F is a subset family defined on a vertex set V , that is, each element (called hyperedge) F of F is a subset of V . The hypergraph is a generalization of a graph so that edges can have more than two vertices. A hitting set is a subset H of V such that H ∩ F 6= ∅ for any hyperedge F ∈ F . A hitting set is called minimal if it includes no other hitting set. The dual of a hypergraph is the set of all minimal hitting sets. The dualization of a hypergraph is to construct the dual of a given hypergraph. Dualization is a fundamental problem in computer science, especially in ma- chine learning, data mining, and optimization, etc. It is equivalent to (1) the minimal hitting set enumeration of given subset family, (2) minimal set cover enumeration of given set family, (3) enumeration of hypergraph transversal, (4) enumeration of minimal subsets that are not included in any of the given set family, etc. One of the research goals is to clarify the existence of a polynomial time algorithm for solving the problem. The size of dual can be exponential in the input hypergraph, thus the polynomial time algorithm for dualization usu- ally means an algorithm running in time polynomial to the input size and the output size. Although Kachian et al.[6] developed a quasi-polynomial time algo- rithm which runs in O(N log N ) time, where N is the input size plus output size, the existence of a polynomial time algorithm is still an open question. From the importance of dualization in its application areas, a lot of research has aimed at algorithms that terminate in a short time on real world data. The size of the dual can be exponential, but in practice, it is huge but not intractable. Thus, practically efficient algorithms aim to take a short time for each minimal hitting set. Reduction of the search space was studied as a way to cope with this problem [4, 6 -- 8, 12, 15]. Finding a minimal hitting set is easy; one removes vertices one by one unless each has an empty intersection with some hyperedges. However, finding exactly all minimal hitting sets is not easy; we have to check a great many vertex subsets that can be minimal hitting sets. The past studies have succeeded in reducing the search space, but the computational cost was substantial, hence the current algorithms may take a long time when the size of the dual is large. In this paper, we focus on developing an efficient computation for the case of large-scale input data with a large number of minimal hitting sets. We looked at the disadvantages of the existing methods and devised new algorithms to eliminate them. -- breadth-first search: A popular search method for dualization is hill climbing such that the algorithm starts from the emptyset, and recursively adds ver- tices one by one until it reaches minimal hitting sets. The minimal hitting sets already found are stored in memory and used to check the minimality. This minimality check is popular, but its memory usage is so inefficient so that we cannot solve a problem with many minimal hitting sets. We alleviate this disadvantage by using a depth-first search algorithm with the use of the new minimality check algorithm explained below. The algorithm proposed in [8, 9] uses a depth-first search, but its minimality check takes a long time on large hypergraphs. -- minimality check: The time for the minimality check in a breadth-first search is short when the hitting sets to be checked are small on average, but will be long for larger hitting sets (such as size 20 or larger). We alleviate this disadvantage by using a new algorithm that does not need the hitting sets that have already been found. We introduce a new concept, called the crit- ical hyperedge, that characterizes the minimality of hitting sets. Computing and updating critical hyperedges can be done in a short time, thus we can efficiently check the minimality in a short time. -- pruning: Several algorithms use pruning methods to reduce the search space, but our experiments show that these pruning methods are not sufficient. We propose a simple but efficient pruning method. We introduce a lexicographic depth-first search, and thereby remove vertices that can never be used and prune branches without necessary vertices. The pruning drastically reduces the computation time. -- sophisticated use of simple data structures: Not many studies have mentioned the data structures or how to use them efficiently, despite this being a very important consideration to reduce the computation time. We use both the adjacency matrix (characteristic vectors of hyperedges) and doubly linked lists to speed up the operations of taking intersections and set differences. This accelerates the computation time in extremely sparse, extremely dense (use complement as input), non-small minimal hitting sets (over 10 vertices) cases. The paper is organized as follows. In the following subsections, we explain the related work and related problems. Section 2 is for preliminaries, and Section 3 describes the existing algorithms. We describe our new algorithms in Section 4 and show the results of computational experiments in Section 5. We conclude the paper in Section 6. 1.1 Related Work There have been several studies on the dualization problem, of which we shall briefly review the DL, BMR, KS and HBC algorithms. These algorithms are classified into two types according to their structure; improved versions of the Berge algorithm[2], and hill-climbing algorithms. The Berge algorithm updates the set of minimal hitting sets iteratively, by adding hyperedges one by one to the current partial hypergraph. DL, BMR and KS are the algorithms of this type, and HBC is the hill-climbing type. The candidates for minimal hitting sets are generated by gathering vertices one-by-one until a minimality condition is violated. When a candidate becomes a hitting set, it is a minimal hitting set. The HBC algorithm does this operation in a breadth-first manner. The DL algorithm, proposed by Dong and Li [4], is a border-differential algorithm for data mining. The main difference from the Berge algorithm is that it avoids generating non-minimal hitting sets by increasing the problem size incrementally. The DL algorithm starts from an empty hypergraph and adds a hyperedge iteratively while updating the set of minimal hitting sets. The sizes of the intermediate sets of minimal hitting sets are likely smaller than that of the original hypergraph, thus we can expect that there will be no combinatorial explosion. Experiments on two small UCI datasets [14] have shown that the DL algorithm is much faster than their previous algorithm and the level-wise hill climbing algorithm. In general, the Berge algorithm and DL algorithm are very useful when the hypergraph has few hyperedges, but for large hypergraphs, it may take a long time because of many updates. The BMR algorithm, proposed by Bailey et al. [5], starts from a hypergraph with few vertices with hyperedges restricted to the vertex set (the vertices not in the current vertex set are removed from the hy- peredges). The hyperedges grow as the vertex set increases. The BMR algorithm first uses the Berge algorithm to solve the problem of the initial hypergraph, and then it updates the minimal hitting sets. Note that Hagen tested a version of the DL algorithm instead of the Berge algorithm [11]. Kavvadias and Stavropoulos's algorithm (KS algorithm) [8, 9] embodies two ideas; unifying the nodes contained in the same hyperedges and depth-first search. These ideas help to reduce the number of intermediate hitting sets and memory usage. To perform a depth-first search, they use a minimality check al- gorithm that does not need other hitting sets; check whether the removal of each vertex results a hitting set or not. The KS algorithm uses an efficient algorithm for this task. Hebert et al. proposed a level-wise algorithm (HBC algorithm) [7]. Their algorithm is a hill climbing algorithm which starts from the empty set and adds vertices one by one. It searches the vertex subsets satisfying a necessary condition to be a minimal hitting set, called a "Galois connection". A vertex subset satisfies the Galois connection if the removal of any of its vertexes decreases the number of hyperedges intersecting with it. The sets satisfying the Galois connection form a set system satisfying the monotone property (independent set system), thus we can perform a breadth-first search in the usual way. 1.2 Related Problems Dualization has many equivalent problems. We show some of them below. (1) minimal set cover enumeration For a subset family F defined on a set E, a set cover S is a subset of F such that the union of the members of S is equal to E, i.e., E = SX∈S X. A set cover is called minimal if it is included in no other set cover. We consider F to be a vertex set, and F (v) to be a hyperedge where F (v) is the set of F ∈ F that include v. Then, for the hyperedge set (set family) F = {F (v)v ∈ E}, a hitting set of F is a set cover of F , and vice versa. Thus, enumerating minimal set covers is equivalent to dualization. (2) minimal uncovered set enumeration For a subset family F defined on a set E, an uncovered set S is a subset of E such that S is not included in any member of F . Let ¯F be the complement of F , which is the set of the complement of members in F , i.e., ¯F = {E \ XX ∈ F}. S is not included in X ∈ F if and only if S and E \ X have a non-empty in- tersection. An uncovered set of F is a hitting set of ¯F , and vice versa, thus the minimal uncovered set enumeration is equivalent to the minimal hitting set enumeration. (3) circuit enumeration for independent system A subset family F defined on E is called an independent system if for each member X of F , any of its subsets is also a member of F . A subset of E is called independent if it is a member of F , and dependent otherwise. A circuit is a minimal dependent set, i.e., a dependent set which properly contains no other dependent set. When an independent system is given by the set of maximal in- dependent sets of F , then the enumeration of circuits of F is equivalent to the enumeration of uncovered sets of F . (4) Computing negative border from positive border A function is called Boolean if it maps subsets in 2V to {0, 1}. A Boolean function B is called monotone (resp., anti-monotone) if it for any set X with B(X) = 0 (resp., B(X) = 1), any subset X ′ of X satisfies B(X ′) = 0 (resp., B(X ′) = 1). For a monotone function B, a subset X is called a positive border if B(X) = 0 and no its proper superset Y satisfies B(Y ) = 0 , and is called a negative border if B(X) = 1 and no its proper subset Y satisfies B(Y ) = 1. When we are given a Boolean function by the set of positive borders, the problem is to enumerate all of its negative borders. This problem is equivalent to dualization, since the problem is equivalent to uncovered set enumeration. (5) DNF to CNS transformation DNF is a formula whose clauses are composed of literals connected by "or" and whose clauses are connected by "and". CNF is a formula whose clauses are composed of literals connected by "and", and whose clauses are connected by "or". Any formula can be represented as a DNF formula and a CNF formula. Let D be a DNF formula composed of variables x1, ..., xn and clauses C1, ..., Cm. A DNF/CNF is called monotone if no clause contains a literal with "not". Then, S is a hitting set of the clauses of D if and only if the assignment obtained by setting the literals in S to true gives a true assignment of D. Let H be a minimal CNF formula equivalent to D. H has to include any minimal hitting set of D as its clause, since any clause of H has to contain at least one literal of any clause of D. Thus, a minimal CNF equivalent to D has to include all minimal hitting sets of D. For the same reason, computing the minimal DNF from a CNF is equivalent to dualization. 2 Preliminaries A hypergraph F is a subset family {F1, . . . , Fm} defined on a vertex set V , that is, each element (called hyperedge) F of F is a subset of V . The hypergraph is a generalization of a graph so that edges can contain more than two vertices. A subset H of V is called a vertex subset. A hitting set is a vertex subset H such that H ∩ F 6= ∅ for any hyperedge F ∈ F . A hitting set is called minimal if it includes no other hitting set. The dual of a hypergraph is the hypergraph whose hyperedge set is the set of all minimal hitting sets, and it is denoted by dual(F ). For example, when V = {1, 2, 3, 4}, F = {{1, 2}, {1, 3}, {2, 3, 4}}, {1, 3, 4} is a hitting set but not minimal, and {2, 3} is a minimal hitting set. dual(F ) is {{1, 2}, {1, 3}, {1, 4}, {2, 3}}. It is known that F = dual(dual(F )) if no F, F ′ ∈ F satisfy F ⊂ F ′. The dualization of a hypergraph is to construct the dual of the given hypergraph. F denotes the number of hyperedges in F , that is m, and F denotes the sum of the sizes of hyperedges in F , respectively. In particular, F is called the size of F . Fi denotes the hypergraph composed of hyperedges {F1, . . . , Fi}. For v ∈ V , let F (v) be the set of hyperedges in F that includes v, i.e., F (v) = {F F ∈ F , v ∈ F }. For vertex subset S and vertex v, we respectively denote S ∪ {v} and S \ {e} by S ∪ v and S \ e. We introduce the new concept critical hyperedge in the following. For a vertex subset S ⊆ V , uncov(S) denotes the set of hyperedges that do not intersect with S, i.e., uncov(S) = {F F ∈ F , F ∩ S = ∅}. S is a hitting set if and only if uncov(S) = ∅. For a vertex v ∈ S, a hyperedge F ∈ F is said to be critical for v if S ∩ F = {v}. We denote the set of all critical hyperedges for v by crit(v, S), i.e., crit(v, S) = {F F ∈ F , S ∩ F = {v}}. Suppose that S is a hitting set. If v has no critical hyperedge, every F ∈ F includes a vertex in S other than v, thus S \ v is also a hitting set. Therefore, we have the following property. Property 1. S is a minimal hitting set if and only if uncov(S) = ∅, and crit(v, S) 6= ∅ holds for any v ∈ S. If crit(v, S) 6= ∅ for any v ∈ S, we say that S satisfies the minimality condi- tion. Our algorithm updates crit to check the minimality condition quickly, by utilizing the following lemmas. Let us consider an example of crit. Suppose that F = {{1, 2}, {1, 3}, {2, 3, 4}}, and the hitting set S is {1, 3, 4}. We can see that crit(1, S) = {{1, 2}}, crit(3, S) = ∅, crit(4, S) = ∅, thus S is not minimal, and we can remove either 3 or 4. For S′ = {1, 3}, crit(1, S′) = {{1, 2}}, crit(3, S′) = {{2, 3, 4}}, thus S′ is a minimal hitting set. The following lemmas are the keys to our algorithms. Lemma 1. For any vertex subset S, v ∈ S and v′ crit(v, S) \ F (v′). Particularly, crit(v, S ∪ v′) ⊆ crit(v, S) holds. 6∈ S, crit(v, S ∪ v′) = Proof. For any F ∈ crit(v, S), (S ∪ v′) ∩ F = {v} holds if F is not in F (v′), and thus it is included in crit(v, S ∪ v′) \ F (v). Conversely, (S ∪ v′) ∩ F = {v} holds for any F ∈ crit(v, S ∪ v′). This means that S ∩ F = {v}, and F ∈ crit(v, S). ⊓⊔ Lemma 2. For any vertex subset S and v′ 6∈ S, crit(v′, S ∪ v′) = uncov(S) ∩ F (v′). Proof. Since any hyperedge not in uncov(S) has a non-empty intersection with S, F can never be a critical hyperedge for v′. Any critical hyperedge for v′ includes v′ thus, we can see that crit(v′, S) ⊆ uncov(S) ∩ F (v′). Conversely, for any hyperedge F included in uncov(S) ∩ F (v′), F ∩ (S ∪ v′) = {v′}, thereby uncov(S) ∩ F (v′) ⊆ crit(v′, S). Hence, the lemma holds. ⊓⊔ The next two lemmas follow directly from the above. Lemma 3. [7] If a vertex subset S satisfies the minimality condition, any of its subsets also satisfy the minimality condition, i.e., the minimality condition satisfies the monotone property. Lemma 4. [7] If a vertex subset S does not satisfy the minimality condition, S is not included in any minimal hitting set. In particular, any minimal hitting set S is maximal in the set system composed of vertex subsets satisfying the minimality condition. Lemma 5. For any vertex subset S, Pv∈S crit(v, S) ≤ F. Proof. From the definition of the critical hyperedge, any hyperedge F ∈ F can ⊓⊔ be critical for at most one vertex. Thus, the lemma holds. 3 Existing Algorithms This section is devoted to explaining the framework of the existing algorithms related to our algorithms: DL algorithm, KS algorithm, and HBC algorithm. The DL algorithm starts by computing dual(F1) and then iteratively computes dual(Fi) from dual(Fi−1). For any S ∈ dual(Fi), either S ∈ dual(Fi−1) holds, or S \ v ∈ dual(Fi−1) holds for {v} = S ∩ Fi. Note that when S ∈ dual(Fi) is not in dual(Fi−1), S ∩ Fi is composed of exactly one vertex, since crit(v, S) must be {Fi}. However, for any S ∈ dual(Fi−1), S ∈ dual(Fi) if S ∩ Fi 6= ∅. When S ∩ Fi = ∅, S ∪ v with v ∈ Fi may be in dual(Fi). The algorithm is as follows. for each S ∈ Di−1 do ALGORITHM DL (F = {F1, . . . , Fm}) 1. D0 := {∅} 2. for i := 1 to m 3. Di := ∅ 4. 5. 6. 7. 8. 9. end for 10. end for if S ∩ Fi 6= ∅ then insert S to Di else for each v ∈ Fi do if no S′ ∈ Di−1 satisfies S′ 6= S and S′ ⊆ S ∪ v then insert S ∪ v to Di end for After the computation, Dm is dual(F ). Line 7 is for checking whether S ∪ v is in Di or not by looking for a hitting set included in S ∪ v. This needs basically O(P Di−1) time and is a bottleneck computation of the algorithm. This part requires all of Di memory, thus we need to perform a breadth-first search. Kavadias and Stavropoulos[8, 9] proposed a depth-first version of this algorithm. According to the hitting sets generation rule, each hitting set in Fi is uniquely generated from a hitting set of Fi−1. Thus, starting from each hitting set in F1, we perform this generation rule in a depth-first manner, and visit all the minimal hitting sets of all Fi. The algorithm does not store each Di in memory, and it checks for the minimality of S ∪ v by checking whether S ∪ v \ f is a hitting set or not for each f ∈ S. The algorithm is as follows. ALGORITHM KS (S, i) 1. if i = m then output S; return 2. if S ∩ Fi 6= ∅ then call KS(S, i + 1) 3. else for each v ∈ Fi do 4. 5. 6. end for 7. call KS(S ∪ v, i + 1) 8. end for for each u ∈ S do if S ∪ v \ u is a hitting set then go to 8. The bottleneck is also the minimality check on line 5 that basically needs to access all hyperedges in Fi−1. The number hitting sets that are added a vertex is Sm i=1 Di \ dual(F ) = O( Sm i=1 Di). The algorithms perform the minimality check for each addition, thus roughly speaking, the number of minimality checks in both algorithms is O( Sm i=1 Di × f ) where f is the average size of hyperedges. For S ∈ Di and v ∈ S, crit(v, S) is non-empty, since v always has a critical hyperedge in Fi. It implies that any subset S explored by the algorithm satisfies the minimality condition. The minimality check is usually one of the time-consuming parts of dualiza- tion algorithms. The check whether the current vertex subset is a hitting set or not is also a time consuming part, but it can be done by updating uncov, thus for almost all vertex subsets to be operated on, its cost is much smaller than the minimality check. Therefore, the number of minimality checks would be a good measure of the efficiency of the search strategy. Here, we define the search space of an algorithm by the set of vertex subsets that are checked the minimality. The size of the search space is equal to the number of executed minimality checks. The cost for the minimality check increases with Di, for the DL algorithm, and with S and F for the KS algorithm. Thus, the DL algorithm will be faster when the dual(F ) is small, whereas the KS algorithm will be faster when F is small and S is small on average. The HBC algorithm is a kind of branch and bound algorithm. It starts from the emptyset, and chooses elements one by one. For each element v, it generates two recursive calls concerned with a choice; add v to the current vertex subset, and do not add it. When the current vertex subset becomes a hitting set, it checks the minimality, and outputs it if minimal. To speed up the computation, the algorithm prunes branches through the use of the so called Galois condition. The Galois condition for S and v 6∈ S is uncov(S) = uncov(S ∪ v), and when it holds, S ∪ v is never included in a minimal hitting set, thus we can terminate the recursive call with respect to S ∪ v. The Galois condition is equivalent to our minimality condition, since it is equivalent to crit(v, S ∪ v) = ∅1. The algorithm is written as follows. for each S ∈ Di do ALGORITHM HBC (F = {F1, . . . , Fm}) 1. D0 := {∅} ; i = 0 2. while Di 6= ∅ 3. 4. 5. 6. 7. 8. end for 9. end while end for if uncov(S) = ∅ then output S for each v larger than maximum vertex in S do if S ∪ v satisfies the Galois condition then insert S to Di 1 the Galois condition is proposed in 2007[7], while crit is proposed in 2003[12, 15]. The term "minimality condition" first appears in [7]. If the pruning method is only the Galois condition, the vertex subsets to be explored by the algorithm is all the non-hitting sets satisfying the minimality condition. Thus, the size of search space of HBC algorithm is no less than that of DL algorithm. On contrary, DL and KS algorithms has to update the minimal hitting sets even if they do not change, thus the HBC algorithm has an advantage in this point. 4 New Search Algorithms and Minimality Check We propose two depth-first search (branch and bound) algorithms for dualization problem. The main differences from the existing algorithms are to use crit for the minimality condition check, and pruning methods to avoid searching hopeless branches. The algorithms keep lists crit[u] and uncov representing crit(u, S) and uncov(S). When the algorithm adds a vertex v to S and generates a recursive call, it updates crit[] and uncov by the following algorithm. Update crit uncov (v, crit[], uncov) 1. for each F ∈ F (v) do 2. 3. 4. end for if F ∈ crit[u] for a vertex u ∈ S then remove F from crit[u] if F ∈ uncov then uncov := uncov \ F ; crit[e] := crit[e] ∪ {F } After execution, crit[u] becomes crit(u, S ∪v). Since each hyperedge F can be critical hyperedge for at most one vertex, we put F on the vertex as a mark and perform step 2 in a constant time. Thus, the time complexity of this algorithm is O(F (v)). Even though this algorithm is simple, we can reduce the time complexity of an iteration of the KS algorithm from O(V × F) to O(F). 4.1 Reverse Search Algorithm One of our algorithms is based on the reverse search [1], and it can be regarded as an improved version of the KS algorithm. Let S = Sm i=1 Fi, that is the set of vertex subsets that are operated by KS algorithm. Let us denote the minimum i such that Fi ∈ crit(v, S) by min crit(v, S), and the minimum i such that Fi ∈ uncov(S) by min uncov(S). min crit(v, S) (resp., min uncov(S)) is defined as m + 1 if crit(v, S) (resp., uncov(S)) is empty. Using these terms, we give a characterization of S. Lemma 6. S 6= ∅ belongs to S if and only if min crit(v, S) < min uncov(S) holds for any v ∈ S. Proof. Suppose that S ∈ S, thus S ∈ Fi for some i. We can see that min uncov(S) > i, crit(v, S) includes a hyperedge Fj ∈ F with i < j, and thus min crit(v, S) < i for any v. Thus, min crit(v, S) < min uncov(S) holds for any v ∈ S. Conversely, suppose that min crit(v, S) < min uncov(S) holds for any v ∈ S. Then, we can see that crit(v, S) 6= ∅ for any v ∈ S because min crit(v, S) < m + 1. Let i = min uncov(S) − 1. Note that i ≤ m. We can then see that S is a hitting set of Fi and min crit(v, S) ≤ i. This in turn implies that S is a minimal hitting set in Fi, and thus, it belongs to S. ⊓⊔ For S ∈ S, min crit(S) is the minimum index i such that S is a minimal hitting set of Fi, i.e., min crit(S) = maxv∈S{min crit(v, S)}. We define the parent P (S) of S by S \ v, where v is the vertex such that min crit(v, S) = min crit(S). Since any Fi is critical for at most one vertex, min crit(S) and the parent are uniquely defined. The parent-child relation given by this definition is acyclic, thus forms a tree spanning all the vertex subsets in S and rooted at the emptyset. Our algorithm performs a depth-first search on this tree starting from the emptyset. This kind of search strategy is called reverse search[1]. This search strategy is essentially equivalent to KS algorithm if we skip all redundant iteration in which we add no vertex to the current vertex subset. In a straightforward implementation of KS algorithm, we have to iteratively compute the intersection of Fi and the current vertex subset S until we meet the Fi that does not intersect with S. When uncov(S) is not so large, it takes long time. Particularly, when uncov(S) = ∅, we may spend Θ(F) time. On contrary, in our strategy, we have only to maintain uncov(S), that is much lighter. The depth-first search starts from the emptyset. When it visits a vertex subset S, it finds all children of S iteratively and generates a recursive call for each child. In this way, we can perform a depth-first search only by finding children of the current vertex subset. The way to find the children is shown in the following lemma. Lemma 7. Let S ∈ S and i = min uncov(S). A vertex subset S′ is a child of S if and only if (1) i < m + 1 (2) S′ = S ∪ v for some v ∈ Fi, and (3) min crit(v′, S′) < i holds for any v′ ∈ S. Proof. Suppose that S′ is a child of S. We can see that uncov(S) is not empty, and thus (1) holds. From the definition of the parent, S is obtained from S′ by removing a vertex v from S′. From min crit(S′) < min uncov(S′) and uncov(S) = uncov(S′) ∪ crit(v, S′), we obtain min crit(v, S′) = min crit(S′) = min uncov(S). This means that Fi ∈ crit(v, S′), and thus (2) holds. This equa- tion also implies that (3) holds. Suppose that S′ is a vertex subset satisfying (1), (2) and (3). From (2), we see that min crit(v, S′) = i. Since uncov(S′) > i, this together with (3) implies that S′ satisfies the conditions in Lemma 6 and thereby is included in S. min crit(v, S′) = i and (3) leads to min crit(S′) = i and P (S′) = S′ \ v = S. Note that condition (1) guarantees the existence of Fi given condition (2), thus ⊓⊔ it is implicitly used in the proof. From Lemma 7, we can find all children of S by adding each vertex v ∈ Fi to S, and checking (3). This can be done in a short time by updating crit. The algorithm is as follows. global variable: crit[], uncov ALGORITHM RS (S) 1. if uncov = ∅ then output S; return 2. i := min{jFj ∈ uncov} 3. for each v ∈ Fi do 4. 5. 6. 7. end for call Update crit uncov (v, crit[], uncov) if min{tFt ∈ crit[f ]} < i for each f ∈ S then call RS(S′) recover the change to crit[] and uncov done in 4 Theorem 1. Algorithm RS enumerates all minimal hitting sets in O(F×S) time and O(F) space. Proof. Since the parent-child relationship induces a rooted tree spanning all vertex subsets in S, the algorithm certainly enumerates all vertex subsets in S. Since any minimal hitting set is included in S, all minimal hitting sets are found by the algorithm. The update of crit[] and uncov is done in O(F (v)) time, thus an iteration of the algorithm takes O(F) time. In total, the algorithm takes O(F × S) time. The algorithm requires extra memory for storing crit[] and uncov and for memorizing the hyperedges removed in step 4. Since crit[] and uncov are pairwise disjoint, the total memory for crit and uncov is O(m). If a hyperedge is removed from a list, it will not be removed again in the deeper levels of the recursion, from the monotonicity of crit. Thus, it also needs O(m) memory. The most memory is for F (v) of each v, and takes O(F) space. ⊓⊔ pruning method Suppose that in an iteration we are operating on a vertex subset S, and have confirmed that S∪v does not satisfy the minimality condition. From Lemma 3, we observe that S′ ∪ v does not satisfy the minimality condition if S ⊆ S′. This means that in the recursive call generated by the iteration with respect to S, we do not have to care about the addition of v, thus we remove v from the candidate list for addition during the recursive call. This condition also holds when S ∪ v is a minimal hitting set, since no superset of a minimal hitting set satisfies the minimality condition. We call the vertex v satisfying one of these conditions violating. We can apply this pruning method to the RS algorithm by finding all violat- ing vertices before step 3 and can output all minimal hitting sets S ∪ v found in the process. We then execute the loop from step 3 to step 7 only for non-violating vertices, so that we can avoid unnecessary recursive calls. 4.2 Depth-first Search Algorithm This subsection described a simple hill-climbing depth-first search algorithm, whose search space is contained in that of the HBC algorithm. We start from S = ∅, and add vertices to S recursively unless the minimality condition is violated. To avoid the duplication, we use a list of vertices CAN D that represents the vertices that can be added in the iteration. The vertices not included in CAN D will not be added, even if the addition satisfies the minimality condition, i.e., the iteration given S and CAN D enumerates all minimal hitting sets including S and included in S ∪ CAN D by recursively generating calls. Suppose that an iteration is given S and CAN D, and without loss of general- ity CAN D = {v1, . . . , vk}. For the first vertex v1, we make a recursive call with respect to S ∪ v1, with CAN D = CAN D \ v1, to enumerate all minimal hitting sets including S ∪ v1. After the termination of the recursive call, we generate a recursive call for S ∪ v2. To avoid finding the minimal hitting sets including v1, we give CAN D \ {v1, v2} to the recursive call. In this way, for each vertex vi, we generate a recursive call with S ∪ vi and CAN D = {vi+1, . . . , vk}. This search strategy is common to many algorithms for enumerating members in a mono- tone set system, for example clique enumeration [13]. That is, its correctness has already been proved. Next, let us describe a pruning method coming from the necessary condition to be a hitting set. Suppose that an iteration is given S and CAN D, and let F be a hyperedge in uncov(S). We can see that any minimal hitting set including S has to include at least one vertex in S. Thus, we have to generate recursive calls with respect to vertices in CAN D ∩ F , but do not have to do so for vertices in CAN D \ F . In the RS algorithm, we have to find all violating vertices before generat- ing recursive calls. In contrast, we can omit this step from our DFS algorithm. Suppose that an iteration is given S and CAN D, and is going to generate re- cursive calls with respect to vertices in v1, . . . , vk ∈ F ∩ CAN D. Then, we first set CAN D to CAN D \ {v1, . . . , vk}. If vk is not a violating vertex, we generate a recursive call for S ∪ vk, and add vk to CAN D. If vk is a violating vertex, we do not add vk to CAN D. In this way, when we generate a recursive call with respect to S ∪ vh, all violating vertices vj , j > h have already been found, thus there is no need to find all them at the beginning. The algorithm is described as follows. global variable: crit[], uncov, CAN D ALGORITHM DFS (S) 1. if uncov = ∅ then output S ; return 2. choose a hyperedge F from uncov; 3. C := CAN D ∩ F ; CAN D := CAN D \ C 4. for each v ∈ C do 5. 6. 7. 8. end for call Update crit uncov (v, crit[], uncov) if crit(f, S′) 6= ∅ for each f ∈ S then call DFS(S ∪ v); CAN D := CAN D ∪ v recover the change to crit[] and uncov done in 5 Similar to the case of the RS algorithm, the computation time of an iteration is bounded by O(F). 4.3 Implementation Issues This section is devoted to the computational techniques for improving efficiency. Our data structure for representing hyperedges and F (v) is an array list in which the IDs of vertices or hyperedges are stored. Using array list fastens the set operations with respect to F (v) and list vertices in a hyperedge. The data structure for crit and uncov is a doubly linked list. In each iteration, we remove some hyperedge IDs from these lists and reinsert them after the termination of a recursive call. A doubly linked list is a good data structure for these operations, as it preserves the order of IDs in the list. 4.4 Using the Adjacency Matrix for Set Operations When two subsets S and S′ are represented by lists of their including elements, the set operations such as intersection and set difference need O(S + S′) time. However, when we have the characteristic vectors of S and S′, we can do better. The characteristic vector of S is a vector whose ith element is one if and only if i is included in S. To take the intersection, we scan S (or S′) with the smaller size, and choose the elements included in S′ (or S). This check can be done in O(1) time with using the characteristic vector of S′, thus the computation time is reduced to O(min{S, S′}). For computing S \ S′, we remove their intersection from S, thus the computation time is also the same. Our algorithms take intersection of (crit and uncov) and F (v). Updating the characteristic vectors of (crit and uncov) uses O(F) memory and does not increase the time complexity. The characteristic vectors of F (v) for each v requires a lot of memory to store, thus we use it only when F is larger than n × F/64, i.e., F is dense. Note that in our experiments, all instances satisfied this condition. 4.5 Choosing the Smallest Hyperedge In the DFS algorithm, we can choose arbitrary hyperedge in uncov as F , for re- stricting the vertices to be added. We choose a hyperedge including the smallest number of vertices which have not been pruned, so that the number of recur- sive calls generated will be small. Counting such vertices in each hyperedge in uncov may take time longer than the case just choosing one arbitrary, but our preliminary experiments showed that it reduced the computation time almost in half. 4.6 Pruning Only a Restricted Set of Items The pruning method described above can be applied to any vertex. However, applying it to all possible vertices may take a long time compared with other parts of an iteration. Sometimes it occurs that pruning takes a long time but only few branches are pruned. Thus, to make the computation time stable, we prune only the vertices in CAN D ∩ F , which are the vertices to be added to the current solution. This takes a time proportional to the time spent by an iteration, thus it never needs a long time. 4.7 Inputting the Complement of the Hypergraph In some instances, F is quite dense, e.g., over 95% of vertices are included in many F ∈ F . This occurs when the data has no clear structure and has many minimal hitting sets. We can often find such instances in practice, such as in minimal infrequent vertex subset mining from maximal frequent vertex subsets. In such cases, the instance itself takes up a lot of memory, and needs a long time to be operated on. Here, we can reduce the computation time by using the complement. The complement version of our algorithm inputs the complement of each F ∈ F . The operations of each iteration change so that the vertices to be added are vertices not in F , and taking difference in the crit update changes to taking the intersection. This substantially reduces the computation time, since we have to access only a small number of vertices/hyperedges. In our experiments, we found that this idea works well for very dense datasets. 5 Computational Experiments In this section, we show the results of our computational experiments comparing our algorithms with the existing algorithms. 5.1 Codes and Environments Our algorithms are implemented in C, without any sophisticated library such as binary tree. Existing algorithms are implemented in C++ by using the vector class in STL. KS algorithm and Fredman Khachiyan algorithm (BEGK[3, 16]) are given by the authors. All tests were performed on a 3.2 GHz Core i7-960 with a Linux operating system with 24GB of RAM memory. Note that none of the implementations used multi-cores. The codes and the instances are available at the author's Web cite (http://research.nii.ac.jp/ uno/dualization.html). 5.2 Problem Instances We prepared several instances of problems in several categories as follows. The first category consists of randomly generated instances. Each hyperedge includes a vertex i with probability p. The sizes and the probabilities are listed below. The instances in the second category were generated by the dataset "connect- 4" taken from the UCI Machine Learning Repository [14]. Connect-4 is a board game, and each row of the dataset corresponds to a minimal winning/losing stage of the first player, and a minimal hitting set of a set of winning stages is a minimal way to disturb wining/losing plays of the first player. From the dataset of winning/losing stages, we took the first m rows to make problem instances of different sizes. The third instances are generated from the frequent itemset (pattern) mining problem. An itemset is a hyperedge in our terminology. For a set family F and a support threshold σ, an itemset is called frequent if it is included in at least σ hyperedges, and infrequent otherwise. A frequent itemset included in no other frequent itemset is called a maximal frequent itemset, and an infrequent itemset including no other infrequent itemset is called a minimal infrequent itemset. A minimal infrequent itemset is a minimal itemset included in no maximal frequent itemset, and any subset of it is included in at least one maximal frequent itemset. Thus, the dual of the set of the complements of maximal frequent itemsets is the set of minimal infrequent itemsets. The problem instances are generated by enumerating all maximal frequent sets from the datasets "BMS-WebView-2" and "accidents", taken from the FIMI repository [10]. The profiles of the datasets are listed below. The fourth instances are used in previous studies [9, 3]. • Matching graph (M(n)): a hypergraph with n vertices (n is even) and n/2 hy- peredges forming a perfect matching, that is, hyperedge Fi is {2i − 1, 2i}. This instance has few hyperedges but a large number of minimal hitting sets 2n/2. • Dual Matching graph (DM(n)): it is dual(M(n)). It has 2n/2 hyperedges on n nodes. This instance has a large number of hyperedges but a small number of minimal hitting sets n/2. • Threshold graph (TH(n)): a hypergraph with n vertices (n is even) and hy- peredge set {{i, j} : 1 ≤ i < j ≤ n, j is even}. This instance has a small number of hyperedges n2/4 and a small number of minimal hitting sets n/2 + 1. • Self-Dual Threshold graph (SDTH(n)): The hyperedge set of SDTH(n) is given as {{n − 1, n}} ∪ {{n − 1} ∪ E E ∈TH(n − 2)} ∪ {{n} ∪ E E ∈ dual(TH(n − 2))}. SDTH(n) has the same number of minimal hitting sets as its hyperedges, (n − 2)2/4 + n/2 + 1. • Self-Dual Fano-Plane graph (SDFP(n)): A hypergraph with n vertices and (k− 2)2/4+k/2+1 hyperedges, where k = (n−2)/7. The construction starts with the set of lines in a Fano plane H0 = {{1, 2, 3}, {1, 5, 6}, {1, 7, 4}, {2, 4, 5}, {2, 6, 7}, {3, 4, 6}, {3, 5, 7}}. Then we set H = H1 ∪ H2 ∪ · · · ∪ Hk, where H1, H2, ..., Hk are k disjoint copies of H0. The dual of H is the hypergraph of all 7k unions obtained by taking one hyperedge from each of k copies of H0(H1, H2, · · · , Hk). We finally obtain SDFP(n), which is a hypergraph of 1 + 7k + 7k hyperedges. 5.3 Differences Before showing the results, we discuss the difference between the algorithms from the viewpoint of algorithmic structures. Basically, the search space of DL, KS, and our RS algorithms are the same. However, DL and KS check the same hitting sets many times, while RS operates by one hitting set at most once. In addition, our RS has a pruning method, thus the number of hitting sets generated may be decreased. The search spaces of the HBC and DFS algorithms are basically the same, but DFS reduces it by using pruning methods. For the minimality check, DL, BMR, and HBC algorithms access basically all members in Di. Basically, this takes O(min{2S log F, D) time. Some heuristics can reduce the time, but the reduction ratio would be limited. In contrast, KS takes O(S × F) time, and RS takes O(F (v)) time. Thus, we can expect that -- DL, BMR, and HBC are faster when there are only a few minimal hitting sets , -- HBC is faster if the search space of DL is larger than the set of vertex subsets satisfying the minimality condition, for example, in the case that the sizes of minimal hitting sets are quite small -- KS, RS, and DFS are faster when F is small, -- RS is faster than KS when the sizes of minimal hitting sets are not small, and vertex unification (done by KS) does not work. 5.4 Results Table 1 - 10 compare the computation times. In these tables, F represents the number of hyperedges, F ∗ represents the average size of hyperedges, dual(F ) represents the number of minimal hitting sets and S∗ represents the average size of minimal hitting sets. The computation time is in seconds. Furthermore, "-" means that the computation time was more than 1000 seconds, and "fail" implies that the computation did not terminate normally because of a shortage of memory or some error. Table 1. Computation time on the dataset of winning stage in Connect-4 BEGK w 100 1.2 200 5.2 0.005 0.061 400 46 DL 1.6 BMR 0.006 0.044 0.52 - HBC KS 1.1 RS DFS F F ∗ 200 8 400 8 100 8 33 dual(F) S∗ 800 3200 6400 12800 1600 430 180 17 - 73 0.41 0.27 800 1600 8 55 6.2 0.67 - - 3.2 0.021 0.14 0.001 0.005 0.032 0.078 0.001 0.006 0.021 0.056 - - - - - 83 48 12800 8 287 1145 6069 11675 71840 459502 1277933 11614885 20.54 - - - - - 20 11 6400 8 - - 710 - 860 4.7 2.6 3200 8 10.70 11.95 14.15 14.84 16.46 17.69 18.67 8 The computation time of algorithms which store minimum hitting sets, such as DL and BMR, depends on dual(F ) and S∗. On the other hand, the com- putation time of the depth-first algorithms, such as KS, RS and DFS, depends Table 2. Computation time on the dataset of losing stage in Connect-4 l 200 BEGK 400 800 1600 3200 6400 12800 100 51 4.7 6.4 DL 0.11 2.2 BMR 0.047 - 110 HBC 0.057 KS 2.6 0.009 0.052 RS 0.006 0.044 DFS F 200 F ∗ 8 - - - - - 420 180 12800 8 dual(F) 2341 22760 33087 79632 212761 2396735 4707877 16405082 19.09 - - - - - 15 12 3200 8 - - - - - 98 40 6400 8 - - 130 - 97 1.6 0.94 1600 8 340 210 16 - 20 0.41 0.28 800 8 110 44 5.1 - 4.6 0.14 0.09 400 8 11.19 12.43 13.59 14.62 100 8 15.73 17.06 17.41 S∗ Table 3. Computation time on matching graphs Table 4. Computation time on dual matching graphs M 20 37 24 2.4 0.17 32 4.4 28 1.1 BEGK 0.045 0.72 36 40 36 fail 0.003 0.012 0.04 0.21 0.89 3.9 DL BMR 0.003 0.016 0.045 0.19 1.2 5.3 HBC - 0 0.003 0.01 0.044 0.2 0.87 KS 0 0.004 0.013 0.059 0.25 1.1 RS DFS 0.002 0.006 0.023 0.06 0.26 1.1 F 20 F ∗ 2 216 218 220 16 20 14 2 214 14 10 2 210 10 12 2 212 12 18 2 16 2 S∗ 520 18 - dual(F) DM BEGK 57 900 20 1.4 DL BMR 0.038 HBC 0.21 KS RS DFS F F ∗ 0.4 4.2 49 540 3.3 - 24 28 32 36 40 3.1 8.9 67 fail fail 0.01 0.054 0.25 1.2 7.1 70 - - 0.012 0.071 0.56 5.6 60 780 - 0.007 0.054 0.5 4.8 50 0.014 0.075 0.64 6.8 73 - 212 214 216 218 220 14 16 18 20 12 14 16 18 20 12 2 2 210 10 10 2 dual(F) S∗ 2 2 2 Table 5. Computation time on threshold graphs Table 6. Computation time on self-dual threshold graphs BEGK - 80 DL T H 160 200 40 0.28 0.84 7.5 0.24 2.6 - 11 120 2.7 0.004 0.027 0.091 0.6 - 2.5 19 0.52 6.6 BMR 0.009 0.15 - HBC - 0.021 0.34 KS 35 0.001 0.003 0.016 0.019 0.048 RS 0 0.003 0.01 0.026 0.037 DFS F 6400 10000 F ∗ 2 101 29.05 59.02 89.02 119.01 149.01 400 1600 3600 2 61 2 41 2 81 2 21 S∗ dual(F) SDT H BEGK 202 42 0.53 82 3.3 0.008 0.052 162 122 27 110 0.2 0.56 2.7 - 25 DL BMR 0.012 0.19 0.87 HBC - KS 6.3 RS DFS F F ∗ 310 1.3 7.2 - - 0.057 74 0.002 0.01 0.017 0.049 0.065 0.001 0.01 0.025 0.041 0.068 422 1642 3662 6482 10102 4.34 4.42 4.45 4.46 4.47 422 1642 3662 6482 10102 4.34 4.42 4.45 4.46 4.47 - 1 dual(F) S∗ Table 7. Computation time on self-dual Fano-plane graphs Table 8. Computation time on randomly generated instances 9 23 16 1.3 SDF P BEGK 0.043 27 DL 0 0.004 0.22 BMR 0.001 0.003 0.11 HBC 3.2 KS RS DFS F F ∗ 30 590 22 3.4 0 0.023 540 0 0.002 0.032 0.64 0 0.001 0.022 0.39 0 0 0.014 0.42 15 - - 260 - 26 16 20 365 2430 16843 3.87 6.27 9.63 12.89 15.97 365 2430 16843 3.87 6.27 9.63 12.89 15.97 dual(F) S∗ 64 64 15 37 p 0.9 0.8 0.7 0.6 BEGK DL BMR HBC KS RS DFS cRS cDFS 64 20 1.8 0.078 3.1 0.12 0.093 0.13 0.087 1000 510 210 20 1.9 37 0.87 0.84 2.6 1.8 1000 45.056 39.898 - - - 680 - 52 52 300 250 1000 29.953 dual(F) 30429 364902 2509943 16809231 7.31 - - 320 33 290 6.4 6.1 29 21 1000 35.024 F F ∗ 5.94 3.75 4.88 S∗ Table 9. Computation time on all maximal frequent set from "accidents" ac BEGK 90 fail fail fail 50 30 200 0.54 130 8.7 150 3.2 110 22 DL 0.004 0.042 0.28 0.98 BMR 0.008 0.041 0.074 0.17 0.004 0.018 0.064 0.16 HBC KS fail 0.001 0.011 0.02 0.052 RS 0.002 0.013 0.034 0.05 DFS 0 0.007 0.027 0.05 cRS cDFS 0.001 0.005 0.019 0.051 990 2000 - 87 - 4.8 140 2.3 170 0.95 fail fail 32 0.26 28 0.23 230 0.23 170 0.18 4322 10968 32207 135439 57.48 56.34 72.85 72.23 326.66 326.08 325.31 430.39 7617 17486 47137 185218 5.09 7.32 70 430 31 5.7 3.4 fail 0.78 0.76 1.4 0.95 253 1039 1916 3547 2.57 3.77 4.25 4.73 - 270 21 19 fail 3.3 3.2 12 8.4 F F ∗ 6.46 5.70 447 81 dual(F) S∗ Table 10. Computation time on all maximal frequent set from "BMS-WebView2" bms2 BEGK DL BMR HBC KS RS DFS cRS cDFS F F ∗ dual(F) S∗ 800 500 400 200 100 50 30 20 10 - 5.4 20 0.31 fail 0.15 0.15 0.015 0.012 237 - 3.9 18 0.2 fail 0.12 0.089 0.009 0.007 152 - 0.87 4.7 0.066 fail 0.039 0.048 0.004 0.003 62 - - - 87 fail - - 47 62 74262 3338.68 3261.89 3338.18 3337.39 3336.36 3335.91 3335.23 3334.97 3334.19 89448 438867 1289303 2297560 3064937 4582209 2.15 - - - 23 fail 340 400 4 4.4 17315 - - - 37 fail 800 950 10 12 30405 - 94 110 1.1 fail 0.87 1.1 0.056 0.053 823 - - 1000 8.8 fail 71 92 1 1.1 6946 - - 380 3.5 fail 9.2 13 0.25 0.25 2591 4616 1.29 16991 1.88 15993 1.82 1.99 2.01 2.02 2.04 2.07 on F and F ∗. In particular, RS and DFS are much faster than any other algo- rithm in almost all instances, up to 10,000 times in some cases. The exceptions are matching graphs and dual matching graphs; both are extreme cases of only few small minimal hitting sets that can be easily found, and of few small hyper- edges. Straightforward algorithms are fast for these cases. Also, HBC, cRS and cDFS are faster when the hypergraph is dense. BEGK is the slowest in most in- stances; algorithms with smaller complexity are not always faster. KS algorithm embodies an idea to unify the isomorphic vertices into one to reduce the number of iterations, but it seems that this is not so much efficient in our experiments. In our extra experiments, such isomorphic vertices exist in only a few iterations, thus the improvement brought about by unifying them would be limited. Note that in instance M , DL is not slow even though dual(F ) is very large. This reason would be that for any S ∩ Fi = ∅ for all i and the minimality check would not be required at all. In several instances, BMR is slower than DL, even though it is an improved version. The reason would be that BMR uses up a lot of time in preprocessing. The following Table 11 lists the average ratios of computation times relative to the case without pruning. The value is the average over all instances in the categories, and smaller values mean more improvement. In some cases the ratio is slightly larger than 1.0, however basically the pruning works well especially for RS. The reason that the pruning is not so efficient for DFS is that DFS already has a pruning method, thus the improvement is limited. We also evaluated the total memory usage of each algorithm. The memory usage mainly depends on the number of minimal hitting sets, thus we display two extreme cases; dual matching graphs DM and the randomly generated in- stances p. In the results, all algorithms use a lot of memory when F is large. Table 11. Reduction ratio of computation time by pruning method l M DM T H SDT H SDF P p w instance RS (all) 0.37 0.44 0.73 0.16 1.00 DFS (all) 0.98 1.09 1.08 1.03 0.86 RS (large) 0.19 0.19 0.96 0.11 0.77 DFS (large) 0.96 0.95 1.01 1.00 0.83 ac bms2 0.30 0.33 0.34 0.56 0.46 0.94 0.73 1.01 0.15 0.29 0.17 0.33 0.68 0.94 0.44 1.00 0.20 1.03 0.12 1.19 In particular, DL, BMR and HBC use more memory, since STL library uses a much memory for the sake of making variable operations more efficient. Our al- gorithm and KS algorithm are quite stable to increasing the number of minimal hitting sets, while the others are quite sensitive. KS uses 2.3 megabytes of mem- ory while ours use 12 megabytes. However, 12 megabytes are used by standard library (libc), thus basically the difference can be ignored. Table 12. Total memory requirement for dual matching graphs (megabytes) Table 13. Total memory requirement for randomly generated instances (megabytes) 32 36 65 fail DM 20 24 28 BEGK 51 51 58 40 fail 43 45 51 160 580 2300 - 21 24 41 110 610 25 76 710 7900 - - 25 94 300 8 1.9 - 24 66 13 13 15 - 24 66 13 13 15 220 216 218 210 212 214 10 12 14 16 18 20 dual(F) 10 12 14 20 16 18 2 2 2 DL BMR HBC KS RS DFS F F ∗ S∗ 2 3 2 2 p 0.9 0.8 0.7 0.6 BEGK DL BMR HBC KS RS DFS cRS cDFS 51 49 30 23 2.3 12 12 12 12 1000 130 120 100 63 2.3 12 12 12 12 1000 45.056 39.898 - - - 13000 - 12 12 12 12 1000 29.953 dual(F) 30429 364902 2509943 16809231 7.31 - - 660 850 2.3 12 12 12 12 1000 35.024 F F ∗ 5.94 3.75 4.88 S∗ 6 Conclusion We proposed efficient algorithms for solving the dualization problem. The new depth-first search type algorithms are based on reverse search and branch and bound with a restricted search space. We also proposed an efficient minimality condition check method that exploits a new concept called "critical hyperedges". Computational experiments showed that our algorithms outperform the existing ones in almost all cases, while using less memory even for very large-scale prob- lems with up to millions of hyperedges. In some cases, though, our algorithms take a long time for the minimality check. Shortening this time will be one of the future tasks. More efficient pruning methods are also an interesting topic of future work. Acknowledgments Part of this research is supported by the Funding Program for World-Leading Innovative R&D on Science and Technology, Japan. We thank Khaled Elbas- sion and Elias C. Stavropoulos for providing us with the programs used in our experiments. References 1. D. Avis and K. Fukuda, "Reverse Search for Enumeration," Discrete Applied Math- ematics, vol. 65, pp. 21-46 (1996). 2. C. Berge, "Hypergraphs," volume 45 of North-Holland Mathematical Library, (1989). 3. E. Boros, K. Elbassioni, V. Gurvich, and L. Khachiyan, "An Efficient Implementa- tion of a Quasi-Polynomial Algorithm for Generating Hypergraph Transversals," In Proc. of the 11th European Symposium on Algorithms (ESA 2003), 2432, pp. 556- 567, Springer (2003). 4. G. Dong and J. Li, "Mining Border Descriptions of Emerging Patterns from Dataset Pairs ," Knowledge and Information Systems, vol. 8, pp. 178-202 (2005). 5. J. Bailey, T. Manoukian, and K. Ramamohanarao, "A Fast Algorithm for Com- puting Hypergraph Transversals and its Application in Mining Emerging Patterns ," In Proc. of the 3rd IEEE International Conference on Mining (ICDM 2003), , pp. 485-488, IEEE Computer Society, December (2003). 6. M. L. Fredman and L. Khachiyan, "On The Complexity of Dualization of Monotone Disjunctive Normal Forms," Journal of Algorithms, vol. 21, pp. 618-628 (1996). 7. C. H´ebert, A. Bretto and B. Cr´emilleux, "A Data Mining Formalization to Improve Hypergraph Minimal Transversal Computation", Fundamental Informaticae 80, pp. 415-433 (2007). 8. D. J. Kavvadias and E. C. Stavropoulos, "Evaluation of an Algorithm for the Transversal Hypergraph Problem," Algorithm Engineering, pp. 72-84 (1999). 9. D. J. Kavvadias and E. C. Stavropoulos, "An efficient algorithm for the transversal hypergraph generation," Journal of Graph Algorithms and Applications, vol. 9, pp. 239-264 (2005). 10. Frequent Itemset Mining Dataset Repository, http://fimi.cs.helsinki.fi/data/ 11. M. Hagen, "Algorithmic and Computational Complexity Issues of MONET," Ph.D. Thesis, Friedrich-Schiller-Universitat Jena, December (2008). 12. K. Satoh, T. Uno, "Enumerating Maximal Frequent Sets Using Irredundant Dual- ization", Lecture Notes in Artificial Intelligence 2843, pp. 256-268 (2003). 13. E. Tomita, A. Tanaka, H. Takahashi, "The Worst-case Time Complexity for Gen- erating all Maximal Cliques and Computational Experiments", Theoretical Com- puter Science 363, pp. 28-42 (2006). 14. UCI machine learning repository, http://archive.ics.uci.edu/ml/ 15. T. Uno, K. Satoh, "Detailed Description of an Algorithm for Enumeration of Max- imal Frequent Sets with Irredundant Dualization", ICDM 2003 Workshop on Fre- quent Itemset Mining Implementations, CEUR Workshop Proceedings 90 CEUR- WS.org, (2003). 16. L. Khachiyan, E. Boros, K. Elbassioni and V. Gurvich, "An efficient implementa- tion of a quasi-polynomial algorithm for generating hypergraph transversals and its application in joint generation", Discrete Applied Mathematics 154, pp. 2350-2372 (2006).
1811.05808
2
1811
2019-06-26T00:53:21
Robustness of spectral methods for community detection
[ "cs.DS", "math.PR" ]
The present work is concerned with community detection. Specifically, we consider a random graph drawn according to the stochastic block model~: its vertex set is partitioned into blocks, or communities, and edges are placed randomly and independently of each other with probability depending only on the communities of their two endpoints. In this context, our aim is to recover the community labels better than by random guess, based only on the observation of the graph. In the sparse case, where edge probabilities are in $O(1/n)$, we introduce a new spectral method based on the distance matrix $D^{(l)}$, where $D^{(l)}_{ij} = 1$ iff the graph distance between $i$ and $j$, noted $d(i, j)$ is equal to $\ell$. We show that when $\ell \sim c\log(n)$ for carefully chosen $c$, the eigenvectors associated to the largest eigenvalues of $D^{(l)}$ provide enough information to perform non-trivial community recovery with high probability, provided we are above the so-called Kesten-Stigum threshold. This yields an efficient algorithm for community detection, since computation of the matrix $D^{(l)}$ can be done in $O(n^{1+\kappa})$ operations for a small constant $\kappa$. We then study the sensitivity of the eigendecomposition of $D^{(l)}$ when we allow an adversarial perturbation of the edges of $G$. We show that when the considered perturbation does not affect more than $O(n^\varepsilon)$ vertices for some small $\varepsilon > 0$, the highest eigenvalues and their corresponding eigenvectors incur negligible perturbations, which allows us to still perform efficient recovery.
cs.DS
cs
Proceedings of Machine Learning Research vol 99:1 -- 30, 2019 32nd Annual Conference on Learning Theory Robustness of spectral methods for community detection Ludovic Stephan Inria, École Normale Supérieure, PSL Research University [email protected] Laurent Massoulié Inria, École Normale Supérieure, PSL Research University, Microsoft Research-Inria Joint Centre [email protected] Editors: Alina Beygelzimer and Daniel Hsu Abstract The present work is concerned with community detection. Specifically, we consider a random graph drawn according to the stochastic block model: its vertex set is partitioned into blocks, or communities, and edges are placed randomly and independently of each other with probability depending only on the communities of their two endpoints. In this context, our aim is to recover the community labels better than by random guess, based only on the observation of the graph. In the sparse case, where edge probabilities are in O(1/n), we introduce a new spectral method based on the distance matrix D(ℓ), where D(ℓ) ij = 1 iff the graph distance between i and j, noted d(i, j) is equal to ℓ. We show that when ℓ ∼ c log(n) for carefully chosen c, the eigenvectors associated to the largest eigenvalues of D(ℓ) provide enough information to perform non-trivial community recovery with high probability, provided we are above the so-called Kesten-Stigum threshold. This yields an efficient algorithm for community detection, since computation of the matrix D(ℓ) can be done in O(n1+κ) operations for a small constant κ. We then study the sensitivity of the eigendecomposition of D(ℓ) when we allow an adversarial perturbation of the edges of G. We show that when the considered perturbation does not affect more than O(nε) vertices for some small ε > 0, the highest eigenvalues and their corresponding eigenvectors incur negligible perturbations, which allows us to still perform efficient recovery. Our proposed spectral method therefore: i) is robust to larger perturbations than prior spectral methods, while semi-definite programming (or SDP) methods can tolerate yet larger perturbations; ii) achieves non-trivial detection down to the KS threshold, which is conjectured to be optimal and is beyond reach of existing SDP approaches; iii) is faster than SDP approaches. 9 1 0 2 n u J 6 2 ] S D . s c [ 2 v 8 0 8 5 0 . 1 1 8 1 : v i X r a c(cid:13) 2019 L. Stephan & L. Massoulié. ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION 1. Introduction 1.1. Background Community detection is the task of finding large groups of similar items inside a large relationship graph, where it is expected that related items are (in the assortative case) more likely to be linked together. The Stochastic Block Model (abbreviated in SBM) has been designed by Holland et al. (1983) to analyze the performance of algorithms for this task; it consists in a random graph G whose edge probabilities depend only on the community membership of their endpoints. Since then, a large number of articles have been devoted to the study of this model; a survey of these results can be found in Abbe (2017), or in Fortunato (2010) for a more general view on community detection. The sparse case, when edge probabilities are in O(1/n), is known to be much harder to study than denser models; the existence of a positive portion of isolated vertices makes complete re- construction impossible, and studies usually focus on partial recovery of the community structure. Insights on this topic often stem from statistical physics; in the two-community case, Decelle et al. (2011) conjectured the existence of a threshold for reconstruction, as well as its exact value; this con- jecture was then proved in Mossel et al. (2015) for the first part, Massoulié (2014) and Mossel et al. (2013) for the converse part. Similarly, in the general case, a method was first presented in Krzakala et al. (2013) and then proven to work in Bordenave et al. (2015) -- bar a technical condition -- and Abbe and Sandon (2016). The main issue in the sparse setting is that the usual method relying on the eigenvectors of the adjacency matrix of G fails due to the lack of separation of the eigenvalues. Consequently, a wide array of alternative spectral methods have been designed, relying on the spectrum of a matrix associated to G. More precisely, the eigenvectors associated to the highest eigenvalues of those matrices will often carry some information about the community structure of G, enough for partial reconstruction. Examples include the path expansion matrix used in Massoulié (2014), or the non- backtracking matrix in Krzakala et al. (2013). Additionally, other types of methods can be used in this setting: for example, the semi-definite programming (or SDP) algorithm relaxes the problem into a convex optimization one, which can then be approximately solved (see for example Montanari and Sen (2016)). An important feature of real-life networks that is missing from the SBM is the existence of small-scale regions of higher density, that arise from phenomena unrelated to the community struc- ture. For this reason, a common variant of the SBM is the addition of small cliques to the gen- erated random graph. Commonly-used spectral methods, for example those relying on the non- backtracking matrix in Bordenave et al. (2015), are known to fail in this setting, due to the appari- tion of localized eigenvectors, with no ties to the community structure, and corresponding to large eigenvalues -- see Zhang (2016) for a comparison of those methods, as well as a proposed heuristic to deal with those localized vectors by lowering their associated eigenvalues. SDP methods are the most studied for this problem, due to their natural stability; in particular, Makarychev et al. (2016) show a reconstruction algorithm that is robust to the adversarial addition of o(n) edges, in the case of an arbitrary number of communities; this was also shown independently by Moitra et al. (2016). However, all the SDP methods mentioned here fail to reach the KS threshold by at least a large constant, with only Montanari and Sen (2016) approaching it as the average degree increases. After completing this work we became aware of the article of Abbe et al. (2018). It establishes results akin to ours on robustness (although with a different definition thereof) of spectral meth- 2 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION ods for detection in SBM. We use however a slightly different matrix, and our results apply to an arbitrary number of blocks, whereas they only consider SBM with two blocks. 1.2. Summary of main results This article focuses on the Stochastic Block Model, as defined in Holland et al. (1983); we recall here a succinct definition: Definition 1 Let r ∈ N be fixed, W be a r × r symmetric matrix with nonnegative entries, and π a probability vector on [r]. A random graph G = (V, E) with V = n is said to be distributed according to the Stochastic Block Model (or SBM) with r blocks and parameters (W, π) if: (i) each vertex v ∈ V is assigned a type σ(v) sampled independently from π, (ii) any two vertices u, v in V are joined with an edge randomly and independently from every other edge, with probability min( Wσ(u),σ(v) n , 1). Given a random graph G sampled according to the above model (with the types of each vertex hidden), the aim is to estimate the type assignment σ from the observation of G only. However, since there is a positive proportion of isolated vertices, perfect reconstruction is theoretically im- possible; we will thus only focus on retrieving only a positive proportion of the types. Our metric for reconstruction will be the following: Definition 2 Let σ be the true type estimation, and σ a type estimate of σ; the empirical overlap between σ and σ is defined as: ov(σ, σ) = max τ ∈Sr 1 n nXv=1 1σ(v)=τ (σ(v)) − max k∈[r] πk, (1) where Sr is the set of permutations of [r]. For a given algorithm leading to estimates σ for all n, we say that this algorithm achieves partial reconstruction if lim inf n→∞ ov(σ, σ) > 0 w.h.p. (2) Spectral methods in denser settings (with average degrees of about log(n)) usually consist in clustering the eigenvectors of the adjacency matrix of G; however those methods are known to fail in sparser graphs (see Abbe (2017). As a result, different (and more complex) matrices are needed: Definition 3 Let G be any graph, and ℓ be a positive integer. We define two matrices associated with G: (i) the path expansion matrix B(ℓ) (studied in Massoulié (2014)), whose (i, j) coefficient counts the number of self-avoiding paths (that is, paths that do not go through the same vertex twice) of length ℓ between i and j, (ii) the distance matrix D(ℓ), defined by D(ℓ) ij = 1 if d(i, j) = ℓ and 0 otherwise, where d denotes the usual graph distance. 3 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION We are now ready to state our first result: Theorem 4 Assume that π ≡ 1/r, W is a stochastic positive regular matrix, and that the two highest eigenvalues µ1, µ2 of W satisfy the condition: µ2 2 > µ1. Then there exists an algorithm, based only on an eigenvector of B(ℓ) associated with its second highest eigenvalue, that achieves partial reconstruction whenever ℓ ∼ δ log(n) for small enough δ. The same algorithm also achieves partial reconstruction when applied to D(ℓ) instead of B(ℓ), with the same conditions on ℓ. Regardless of the change of matrices, this is already an improvement on Bordenave et al. (2015); indeed, we managed to remove a technical asymmetry condition on W (namely, the existence of a simple eigenvector associated with a high eigenvalue). We now move on to study the stability of our algorithm; as opposed to most papers that classify the difficulty of an adversary according to the number of altered edges, ours considers the number of affected vertices. Definition 5 Let γ := γ(n) be a positive integer, and G any graph on n vertices. The adversary of strength γ is allowed to arbitrarily add and remove edges at will, as long as the number of vertices affected (i.e. vertices that are endpoints of altered edges) is at most γ. Our main result on stability is then the following: Theorem 6 Under the same assumptions as Theorem 4, let G a graph generated via SBM, and Gγ a graph obtained when perturbed by an adversary of strength γ. Then, assuming γ = o (µ2 2/µ1)ℓ/2 log(n) ! , the algorithm of Theorem 4 still achieves partial reconstruction on Gγ. The above result on γ is the best possible, up to a factor of log(n). Compared to the spectral algorithm in Bordenave et al. (2015), this is a substantial improve- ment: their algorithm is known (see e.g. Zhang (2016)) to be highly unstable w.r.t edge addition. In contrast, the above result reaches a perturbation of size a small power of n (since ℓ is of order log(n)). This is sharp, and thus still far from the o(n) bound achieved by various SDP methods (notably Makarychev et al. (2016); Montanari and Sen (2016)); this discrepancy is likely a result of delicate graph properties involved in spectral algorithms that make them more sensitive to perturba- tions. However, our result still has several advantages compared to the other cited methods, namely: (i) the threshold for partial reconstruction in our method is exactly the KS threshold, whereas SDP-based methods require a slightly stronger condition, especially when the mean degree of G is low. (ii) as will be proved later, the running time of our algorithm is at most O(n13/12), which is much faster that the usual methods for SDP algorithms. (iii) Finally, all the SDP methods mentioned throughout this paper only consider the symmetric case even in the case of multiple communities. 4 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION 1.3. Detailed setting and results STOCHASTIC BLOCK MODEL Consider the SBM as defined above; following Bordenave et al. (2015), we introduce Π = diag(π1, . . . , πr) and define the mean progeny matrix M = ΠW ; the eigenvalues of M are the same as those of the symmetric matrix S = Π1/2W Π1/2 and in particular are real. We denote them by µ1 ≥ µ2 ≥ . . . ≥ µr. We shall make the following regularity assumptions: first, µ1 > 1 and M is positive regular, (3) i.e. the coefficients of M t are all positive for some t. Secondly, each type of vertex has the same asymptotic average degree, that is Mij = rXi=1 rXi=1 πiWij = α for all j ∈ [r]. In this case, the matrix M ∗ = M/α is a stochastic matrix and therefore µ1 = α > 1. (4) (5) Since M = Π−1/2SΠ1/2, M is diagonalizable; let (φ1, . . . , φr) be a basis of normed left eigen- vectors for M , that is Condition (4) implies that φ1 = 1/√r, where 1 is the all-ones vector. φ⊤ i M = µiφ⊤ i for all i ∈ [r]. (6) It has been shown in Bordenave et al. (2015) and Abbe and Sandon (2016) that polynomial-time algorithms achieve partial reconstruction when the following condition, called the Kesten-Stigum threshold, is verified: The quantity τ is commonly referred to as the signal-to-noise ratio. Alternatively, we define r0 such that τ := µ2 2/µ1 > 1. µ2 r0+1 ≤ µ1 < µ2 r0. (7) (8) Therefore, the condition (7) is equivalent to r0 > 1. In the two-community case, the above condition is equivalent to the possibility of reconstruc- tion (see Massoulié (2014), Mossel et al. (2015)). However, in the general setting (r > 4), non- polynomial algorithms can achieve partial reconstruction even below this threshold. This was orig- inally conjectured in Decelle et al. (2011), and more recently proven in Abbe and Sandon (2016). 5 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION PATH EXPANSION MATRIX In Massoulié (2014), an algorithm for partial reconstruction in the two-community case makes use of the path expansion matrix B(ℓ). Our first aim is to extend the result from this paper to the general case; we first define for all k ∈ [r] the vectors χk and ϕk by χk(v) = φk(σ(v)) and ϕk = B(ℓ)χk kB(ℓ)χkk . (9) Let λ1(B(ℓ)) ≥ λ2(B(ℓ)) ≥ λn(B(ℓ)) be the eigenvalues of B(ℓ) ordered by absolute value; our first theorem is an extension of Theorem 2.1 in Massoulié (2014): Theorem 7 Consider a graph G generated as above, and let ℓ ∼ κ logα(n), with κ < 1/12. Then, with probability going to 1 as n goes to +∞: (i) λk(B(ℓ)) = Θ(µℓ k) for k ∈ [r0], (ii) For k > r0, λk(B(ℓ)) = O(log(n)c αℓ/2) for some constant c > 0. Furthermore, consider µ such that µ2 > α and µ is an eigenvalue of multiplicity d of M. Let φ(1), . . . , φ(d) be an orthonormal basis of eigenvectors of M associated to µ, and ϕ(1), . . . , ϕ(d) the vectors defined as in (9). There exist orthogonal vectors ξ(1), . . . , ξ(d) in Rn such that the following holds: (i) for all i, ξ(i) is an eigenvector of B(ℓ), with associated eigenvalue Θ(µℓ) (ii) there exists an orthogonal matrix Q ∈ O(d) such that kϕQ − ξk2 = O(cid:16)αℓ/2µ−ℓ(cid:17) , where ϕ (resp. ξ) is the n × d matrix whose columns are the ϕ(i) (resp. the ξ(i)). The above theorem does not yield immediately an algorithm for community reconstruction; however, adapting the one found in Bordenave et al. (2015), we designed the following: Algorithm 8 Let ξ be an eigenvector of B(ℓ) associated to the eigenvalue λ2(B(ℓ)), normalized such that kξk2 = n, and K an arbitrary large constant. First, partition V in two sets (I +, I −) via the following procedure: put v in I + with probability P(v ∈ I + ξ) = 1 2 + 1 2K ξ(v) 1 ξ(v)≤K Then, assign the label 1 to every vertex in I + and label 2 to every vertex in I −. We then have the following theorem: Theorem 9 Assume that π ≡ 1/r, and that r0 > 1, i.e. that we are above the Kesten-Stigum threshold. Then Algorithm 8 yields an asymptotically positive overlap when n → ∞ for some choice of K. 6 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION Note that we don't need the asymmetry condition from Bordenave et al. (2015) anymore; our algorithm can deal with multiple eigenvalues as well. Additionally, an explicit value for K is derived in the appendix, which makes our algorithm easy to implement and eliminates the need for "magic" constants, such as the ones in Zhang (2016) or Abbe and Sandon (2016). A crucial feature of this algorithm is that it depends only on the second eigenvalue of B(ℓ); for any perturbation that leaves the r0 highest eigenvalues -- or even the second highest -- unchanged, the result from Theorem 9 will hold. THE DISTANCE MATRIX We introduce now the distance matrix D(ℓ), defined by D(ℓ) ij = 1 if and only if d(i, j) = ℓ, where d is the distance in G. This matrix, while sparser than B(ℓ), retains much of the desired spectral properties. In particular, we have the following theorem: Theorem 10 Assume that condition (7) holds, and set ℓ such that ℓ ∼ κ logα(n), where κ is a constant such that κ < 1/12. Then the results of Theorem 7 hold with the matrix B(ℓ) replaced by D(ℓ). As a result, Algorithm 8 will still succeed when applied to the matrix D(ℓ). GRAPH PERTURBATION As mentioned in the introduction, community detection algorithms have to be resilient to the pres- ence of small cliques (or denser subgraphs) to be useful in practice, since this kind of pattern is often present in real-life networks. We chose to focus here on adversarial perturbations, as defined in the summary, whereas other papers (mainly Abbe et al. (2018)) focus instead on other random graph models, more prone to small loops and cliques. As shown in Zhang (2016), the usual spectral methods do not fare well against adversarial (or even random) perturbation, especially when the added subgraph contains several cliques. This is especially the case for the non-backtracking matrix in Bordenave et al. (2015), but also the path expansion matrix in Massoulié (2014). However, the distance matrix is more stable to clique addition, since it does not count the number of paths between two vertices -- which is affected significantly by small perturbations. We can therefore allow a perturbation of size up to a small power of n, as stated in the following theorem: 2/µ1 > 1 is the signal-to-noise ratio. Theorem 11 Let G be an SBM as above, with πi ≡ 1/r. Assume that r0 > 1, and recall that τ = µ2 Then, if γ = o(τ ℓ/ log(n)), then Algorithm 8 based on the distance matrix recovers the original communities with asymptotically positive overlap, even after a perturbation affecting at most γ vertices. The controls in the above theorem can be shown to be sharp, up to a factor of log(n): Theorem 12 With the same assumptions as above, let D(ℓ) be the distance matrix of G and D(ℓ) the one of the graph after the adversarial perturbation. If γ = Ω(τ ℓ), then there exists a perturbation of size at most γ such that D(ℓ) has an eigenvalue 2), with associated eigenvector asymptotically perpendicular to the first r0 ones of D(ℓ). of size Ω(µℓ 7 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION Therefore, we cannot guarantee the stability of the eigenvectors of D(ℓ) when the perturbation affects too many vertices. This means that the best bound we can get on the size of allowed pertur- bations of the matrix D(ℓ) is τ ℓ, which we can rewrite as τ ℓ = nκ logα(τ ). The spectral method on the distance matrix is thus robust to perturbations of size at most nε, with ε = κ logα(τ ) going to zero as we approach the KS threshold. 1.4. Notations and outline of the paper Throughout this paper, we will make use of the following notation: for two functions f, g, we say that f = eO(g) if there exists a constant c such that f = O (log(n)c · g). We similarly define the notations eΘ andeΩ. The next Section is devoted to the study of the spectral structure of B(ℓ); we also state there an important theorem on spectral perturbation that will be useful for the study of matrix D(ℓ) as well. In Section 3, we study the distance matrix D(ℓ) and introduce a method to deal with perturbations of this matrix. We then leverage this method to obtain bounds on the size of allowed perturbations. 2. Spectral structure of B(ℓ) 2.1. A theorem on eigenspace perturbation In the following, we'll need a way to link the operator norm of a matrix perturbation to the conse- quent perturbation of its eigenvectors. This is provided by the following variant of the Davis-Kahan sin θ theorem (Yu et al. (2015), Theorem 2): Theorem 13 Let Σ, Σ be symmetric n × n matrices, with eigenvalues λ1 ≥ . . . ≥ λn and λ1 ≥ . . . ≥ λn respectively. Fix 1 ≤ r ≤ s ≤ n and assume that min(λr−1 − λr, λs − λs+1) > 0, where we define λ0 = +∞ and λn+1 = −∞. Let d = s − r + 1, and let V = (vr, . . . , vs) and V = (vr, . . . , vs) have orthonormal columns satisfying Σvj = λjvj and Σvj = λj vj for j ∈ {r, . . . , s}. Then there exists an orthogonal matrix Q ∈ O(d) such that 2√2dk Σ − Σkop (10) kV Q − V kF ≤ min(λr−1 − λr, λs − λs+1)· 2.2. Strategy of proof We present here the main ideas of the proof, and defer its full version to the appendix. The first step is an adaptation of Proposition 19 from Bordenave et al. (2015): Proposition 14 Let ℓ ∼ κ logα(n) with κ < 1/12. Define, for k ∈ [r], θk = kB(ℓ)ϕkk and ζk = B(ℓ)ϕk θk , (11) with ϕk as in (9). Then, with high probability, we have the following estimations for every γ < 1/2: 8 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION (i) θk = Θ(µℓ k) for k ∈ [r0], (ii) hϕj , ϕki = eO(α3ℓ/2n−γ/2) for j 6= k ∈ [r0], (iii) hζj, ϕki = eO(α2ℓn−γ/2) for j 6= k ∈ [r0]. r0Xk=1 D = θkzkz⊤ k . Now, let (z1, . . . , zr0 ) be the Gram-Schmidt orthonormalization of (ϕ1, . . . , ϕr0 ), and define The non-zero eigenvalues of D are thus the θk, with corresponding eigenvectors zk. Then, using the asymptotic orthogonality properties of Proposition 14, we prove the following: Proposition 15 For all k ∈ [r0], zk is asymptotically parallel to ϕk. Furthermore, (12) Theorem 7 then results from a simple application of the Weyl inequality (Weyl (1912)) and Theo- rem 13: Proof (of Theorem 7): let θk = 0 for k > r0; the eigenvalues of D are then exactly the θi for i ≤ n. By Weyl's inequality, we have for all i ∈ [n] kB(ℓ) − Dkop = eO(αℓ/2). λi(B(ℓ)) − θi = eO(αℓ/2). kzQ − ξk = O(cid:16)αℓ/2µ−ℓ(cid:17) , Since θk = Θ(µℓ k) for k ∈ [r0], this implies the statements (i) and (ii) of the Theorem. We now define z(1), . . . , z(d) as the zi associated to ϕ(1), . . . , ϕ(d), and z as in Theorem 7. Applying inequality (10) to B(ℓ) and D yields the existence of an orthogonal matrix Q ∈ O(d) such that and the proof of Proposition 15 shows that kz(i) − ϕ(i)k = O(cid:0)αℓ/2µ−ℓ(cid:1) for all i. Using the triangular inequality (and the fact that Q preserves the norm) completes the proof of Theorem 7. 2.3. A new reconstruction algorithm We now sketch the proof for Theorem 9; it hinges on one key lemma, whose proof (adapted from Bordenave et al. (2015)) is in the appendix: Lemma 16 Let ξ be as in Algorithm 8. For all i ∈ [r], there exists a random variable Xi such that for every K > 0 that is a continuity point of Xi, in probability, 1 nXv∈V 1σ(v)=i ξ(v)1ξ(v)≤K → π(i) E[Xi1Xi≤K], where the convergence is independent from ξ. 9 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION Furthermore, we have E[Xi] = 0 Xi∈[r] and Xi∈[r] E[Xi]2 > c (13) for some absolute constant c > 0, and for all ε > 0 there exists a choice of M (independent from the chosen eigenvector ξ) such that In particular, Lemma 16 implies that there exist i and j such that E[Xi] − E[Xj] > √c. We then use a concentration bound to show that for all i, in probability, (14) (15) (cid:12)(cid:12)E[Xi1Xi≤K] − E[Xi](cid:12)(cid:12) < ε v∈I + → π(i)(cid:18) E[Xi1 Xi≤K] 2K + 1/2(cid:19) := π(i)pi 1 nXv∈V 1 σ(v)=i 1 where the convergence is independent from ξ. Assume now that π ≡ 1/r; from Lemma 16, for a large enough M there exists a δ > 0 such that pi > pj + δ. Assign label 1 to I + and 2 to I −, and let τ be a permutation such that τ (i) = 1 and τ (j) = 2. The overlap achieved by τ is thus 1 nXv∈V 1 σ(v)=i 1 v∈I + + 1 nXv∈V 1 σ(v)=j 1 v∈I − − 1 r = 1 r (pi + 1 − pj) − 1 r > δ r , (16) which completes the proof of Theorem 9. 3. Study of the matrix D(ℓ) 3.1. From B(ℓ) to D(ℓ) The first aim of this section is to prove Theorem 10, i.e. that we can replace matrix B(ℓ) by D(ℓ) in the algorithm from Theorem 9. Directly proving this theorem is hard, because of the lack of a decomposition such as the one in Lemma 25 for D(ℓ). However, in view of the proof of Theorem 7 above, it is sufficient to prove the following proposition: Proposition 17 Let G be a SBM as above, and ℓ ∼ κ logα(n) with κ < 1/12. Let B(ℓ) be the path expansion matrix of G, and D(ℓ) its distance matrix. Then, with high probability: where ρ is the spectral radius of a matrix. ρ(B(ℓ) − D(ℓ)) = eO(αℓ/2), For ease of notation, let ∆(ℓ) = B(ℓ) − D(ℓ); we first notice that ∆(ℓ) is a 0 − 1 matrix: Lemma 18 Let ℓ ∼ κ logα(n) with κ < 1/12. For all vertices i, j ∈ {1, . . . , n}, Furthermore, if ∆(ℓ) ij = 1, then there exists a cycle C such that: 0 ≤ ∆(ℓ) ij ≤ 1. d(i,C) + d(j,C) ≤ ℓ. 10 (17) (18) (19) ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION Define now a matrix P (ℓ) by P (ℓ) the previous lemma, we have ∆(ℓ) ij ≤ P (ℓ) ij ij = 1 if there is a cycle C such that d(i,C) + d(j,C) ≤ ℓ. By for all (i, j), and the Perron-Frobenius theorem implies: ρ(∆(ℓ)) ≤ ρ(P (ℓ)). (20) It remains then to bound the spectral radius of P (ℓ); the key lemma is the following: Lemma 19 For a given cycle C, let P (ℓ) and VC the set of vertices such that d(i,C) ≤ ℓ. Then: C be the matrix defined by P (ℓ) C,ij = 1 if d(i,C) + d(j,C) ≤ ℓ, (i) P (ℓ) C is zero outside of VC × VC, (ii) ρ(P (ℓ)) = maxC ρ(P (ℓ) C ). By part (ii) of the above lemma, it is sufficient to bound ρ(P (ℓ) C ) for a given cycle C in G; using part (i) of the above lemma, we can restrict our study to the subspace spanned by the vertices in VC. C ; as the co- C only depends on the distance of i and j to C, we likewise group the coefficients Let v be a normed vector of size VC corresponding to the highest eigenvalue of P (ℓ) efficient (i, j) of P (ℓ) of v by their distance t to C, and write v = (vtj ) 0≤t≤ℓ . 1≤j≤St(C) We then have: v⊤PCv = Xt+u≤ℓXi,j vti vuj = Xt+u≤ℓ Xi vti!Xj vuj. coefficients vti are necessarily equal; otherwise, we could increaseP vti while leavingP v2 By the Perron-Frobenius theorem, the coefficients of v are non-negative. For a given t, the ti fixed, C v while keeping kvk2 constant: this contradicts the definition of v. which leads to increasing v⊤P (ℓ) Writing vti = vt for all 1 ≤ i ≤ St(C); we get: St(C)Su(C)vtvu v⊤PCv = Xt+u≤ℓ and kvk2 =Xt St(C)v2 t . (21) Let w be the size ℓ vector defined by wt =pSt(C)vt. Rewriting the above expression in terms of w yields and kvk2 = kwk2, (22) v⊤PCv = Xt+u≤ℓpStSuwtwu where we omit the dependency of St in C. As a result, the spectral radius of PC is equal to that of the ℓ × ℓ matrix QC defined by: QC = √S0S1 S0 ... S1 ... √S0S1 pS0Sℓ−1 pS1Sℓ−1 √S0Sℓ 0  . . . ··· ··· 11 ··· pS0Sℓ−1 √S0Sℓ ··· pS1Sℓ−1 .  0 ... 0 0 ... 0 0 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION We now finally use the row sum bound to get: ρ(P (ℓ) C ) = ρ(QC) ≤ max t Xu≤ℓ−tpStSu t Xu≤ℓ−t ≤ max = O(log(n)αℓ/2). log(n)α t+u 2 via lemma 36 Combining the above inequality with Lemma 19 and inequality (20) eventually leads to which completes the proof of Proposition 17. ρ(∆(ℓ)) = eO(αℓ/2), 3.2. Stability to graph perturbation In this subsection, we sketch the proofs for Theorems 11 and 12. (23) (24) (25) (26) In the original algorithm, the computation of B(ℓ) in A note about computational complexity polynomial time relies on the almost tree-like, tangle-free structure of the random graph G; this structure may be lost when we add cliques, and increase the algorithm complexity. As we want to devise polynomial algorithms in every case, this may be a hindrance. Conversely, the computation of the distance matrix D(ℓ) can be done in polynomial time (for example breadth-first search of the ℓ-neighbourhood of each vertex in G yields an algorithm in O(n1+κ) = O(n13/12) in the case of SBM, O(n2) in general) for any graph, which makes it all the more adapted to the problem at hand. In order to prove Theorem 11, we need a less restrictive version of Proposition 17; indeed, bounding the spectral radius of the perturbation by O(αℓ/2) not only preserves the highest eigen- values, but also bounds the remaining eigenvalues of D(ℓ) bypλ1(D(ℓ)). This bound is commonly referred to as a Ramanujan-like property of G. This property, although interesting on its own, is not specifically needed for the reconstruction algorithm to work; rather, we only need one eigenvector associated to the second highest eigenvalue µ2 to remain unchanged. We'll therefore only need the following proposition: Proposition 20 We consider the same setting as Theorem 11. Let D(ℓ) be the distance matrix of G, and G and eD(ℓ) be the perturbed versions (after adding adversarial noise) of G and D(ℓ), respectively. Then The proof relies on a bound similar to the one in Theorem 10, replacing matrices PC and QC by matrices PK and QK also depending only on the distance to the perturbed vertex set K. The details can be found in the appendix. ρ(eD(ℓ) − D(ℓ)) = o(µℓ 2). (27) 12 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION References E. Abbe and C. Sandon. Detection in the stochastic block model with multiple clusters: proof of the achievability conjectures, acyclic bp, and the information-computation gap. In NIPS'16, 2016. Emmanuel Abbe. Community detection and stochastic block models: recent developments. CoRR, abs/1703.10146, 2017. URL http://arxiv.org/abs/1703.10146. Emmanuel Abbe, Enric Boix, Peter Ralli, and Colin Sandon. Graph powering and spectral robust- ness. CoRR, abs/1809.04818, 2018. URL http://arxiv.org/abs/1809.04818. Charles Bordenave, Marc Lelarge, and Laurent Massoulié. Non-backtracking spectrum of ran- In IEEE 56th An- dom graphs: Community detection and non-regular ramanujan graphs. nual Symposium on Foundations of Computer Science, FOCS 2015, Berkeley, CA, USA, 17-20 October, 2015, pages 1347 -- 1357, 2015. URL https://doi.org/10.1109/FOCS.2015.86. 10.1109/FOCS.2015.86. doi: Aurelien Decelle, Florent Krzakala, Cristopher Moore, and Lenka Zdeborová. Asymptotic analysis of the stochastic block model for modular networks and its algorithmic applications. Phys. Rev. E, 84:066106 (1 -- 19), Dec 2011. doi: 10.1103/PhysRevE.84.066106. Santo Fortunato. Community detection in graphs. 2010. http://www.sciencedirect.com/science/article/pii/S0370157309002841. https://doi.org/10.1016/j.physrep.2009.11.002. ISSN 0370-1573. doi: Physics Reports, 486(3):75 -- 174, URL P. W. Holland, K. B. Laskey, and S. Leinhardt. Stochastic blockmodels: First steps. Social Networks, 5(2):109 -- 137, 1983. Florent Krzakala, Cristopher Moore, Elchanan Mossel, Joe Neeman, Allan Sly, Lenka Zdeborová, and Pan Zhang. Spectral redemption: clustering sparse networks. CoRR, abs/1306.5550, 2013. URL http://arxiv.org/abs/1306.5550. Konstantin Makarychev, Yury Makarychev, and Aravindan Vijayaraghavan. Learning com- In Proceedings of the 29th Conference on Learning munities in the presence of errors. Theory, COLT 2016, New York, USA, June 23-26, 2016, pages 1258 -- 1291, 2016. URL http://jmlr.org/proceedings/papers/v49/makarychev16.html. Laurent Massoulié. Community detection thresholds and the weak ramanujan property. In Pro- ceedings of the Forty-sixth Annual ACM Symposium on Theory of Computing, STOC '14, pages 694 -- 703, New York, NY, USA, 2014. ACM. ISBN 978-1-4503-2710-7. doi: 10.1145/2591796. 2591857. URL http://doi.acm.org/10.1145/2591796.2591857. Ankur Moitra, William Perry, and Alexander S. Wein. How robust are reconstruction thresholds for community detection? In Proceedings of the 48th Annual ACM SIGACT Symposium on Theory of Computing, STOC 2016, Cambridge, MA, USA, June 18-21, 2016, pages 828 -- 841, 2016. doi: 10.1145/2897518.2897573. URL https://doi.org/10.1145/2897518.2897573. A. Montanari and S. Sen. Semidefinite programs on sparse random graphs and their application to community detection. In STOC'16 Proceedings of the forty-eighth annual ACM symposium on Theory of Computing, 2016. 13 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION E. Mossel, J. Neeman, and A. Sly. A proof of the block model threshold conjecture. arxiv:1311.4115, 2013. Elchanan Mossel, Joe Neeman, and Allan Sly. Reconstruction and estimation in the planted partition model. Probability Theory and Related Fields, 162(3-4):431 -- 461, 2015. ISSN 0178-8051. Hermann Weyl. Das asymptotische Verteilungsgesetz der Eigenwerte linearer partieller Dif- ferentialgleichungen (mit einer Anwendung auf die Theorie der Hohlraumstrahlung). Math. Ann., 71(4):441 -- 479, 1912. URL https://doi.org/10.1007/BF01456804. 10.1007/BF01456804. ISSN 0025-5831. doi: Y. Yu, T. Wang, and R. J. Samworth. A useful variant of the Davis-Kahan theorem for statisti- cians. Biometrika, 102(2):315 -- 323, 2015. ISSN 0006-3444. doi: 10.1093/biomet/asv008. URL https://doi.org/10.1093/biomet/asv008. P. Zhang. Robust spectral detection of global structures in the data by learning a regularization. In NIPS'16, 2016. 14 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION Appendix A. Proof or Propositions 14 and 15 A.1. Outline of the proof and similarities with Bordenave et al. (2015) The main arguments of the proof rely on the study of three quantities: (i) a multi-type branching process Zt, (ii) a similar process based on exploring the neighbourhood of a vertex v in G, named Yt(v), (iii) the actual vectors we're aiming to study, B(ℓ)χk. When the ℓ-neighbourhood of v is cycle-free, we have that B(ℓ)χk = hφk, Yt(v)i for k ∈ [r0]; and there is a coupling between the laws of Zt and Yt(v) for almost every v, which allows us to translate results on Zt to results on B(ℓ)χk. The proof in Bordenave et al. (2015) studies the matrix Bℓ, where B is the non-backtracking matrix; Bℓ ij therefore counts the number of non-backtracking walks between i and j. When the ℓ-neighbourhood of i is tree-like, (B(ℓ)χk)i = (Bℓ ¯χk)i, where ¯χk is a similarly defined vector; most of the results from Bordenave et al. (2015) can therefore be applied to this setting without further work. We will simply lay out the main steps of the proof, highlighting the main differences with Bordenave et al. (2015) when necessary. A.2. Local structure of G For an integer t ≥ 0, we introduce the vector Yt(v) = (Yt(v)(i))i∈[r], where Yt(v)(i) = {w ∈ V d(v, w) = t, σ(w) = i} . The proof of our first proposition, although quite lengthy, is completely identical to its equivalent in Bordenave et al. (2015); we therefore omit it. Proposition 21 Let ℓ ∼ κ logα(n) with κ < 1/8; then, for all γ < 1/2: (i) for any k ∈ [r0], there exists ρk > 0 such that in probability, (ii) for any j 6= k ∈ [r], 1 (iii) for any j 6= k ∈ [r], = O(cid:16)α5ℓ/2n−γ/2(log(n))5/2(cid:17) . = O(cid:16)α7ℓ/2n−γ/2(log(n))5/2(cid:17) . hφk, Yℓ(v)i2 µ2ℓ k → ρk. 1 nXv∈V hφj, Yℓ(v)ihφk, Yℓ(v)i(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) hφj, Y2ℓ(v)ihφk, Yℓ(v)i(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) 15 nXv∈V E(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) E(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) nXv∈V 1 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION For t ≥ 0, define Yt(v) = {w ∈ V d(v, w) = t}; for k ∈ [r], we set Pk,ℓ(v) = ℓ−1Xt=0 Xw∈Yt(v) Lk(w), where Lk(w) = X (x,y)∈Y1(w)\Yt(v),x6=y hφk, Yt(x)i Sℓ−t−1(y), Yt(x) is the equivalent of Yt(x) when all vertices in (G, v)t (i.e. vertices at distance at most t from v) are removed and Sℓ−t−1(y) = k Yℓ−t−1(y)k1. It can be seen from Bordenave et al. (2015) that when (G, v)2ℓ is a tree, then (B(ℓ)B(ℓ)χk)v = Pk,ℓ(v) + χk(v)Sℓ(v) + hφk, Y2ℓ(v)i. One main difference with the proof in Bordenave et al. (2015) is the presence of the last term in the above sum, as well as the fact that dealing with B(ℓ)B(ℓ)χk is a little more difficult. The next proposition is an adaptation of Proposition 38 from Bordenave et al. (2015), with an identical -- and thus omitted -- proof: Proposition 22 Let ℓ ∼ κ logα(n) with κ < 1/10. Then, for all γ < 1/2: (i) for all k ∈ [r0], there exists ρ′ nXv∈V 1 k such that w.h.p (Pk,ℓ(v) + hφk, Y2ℓ(v)i)2 µ4ℓ k → ρ′ k. (ii) for any j 6= k ∈ [r], for some c > 0: 1 nXv∈V Pk,ℓ(v)hφj , Yℓ(v)i = O(cid:16)α7ℓ/2n−γ/2(log(n))c(cid:17) . A.3. From local neighbourhoods to the matrix B(ℓ) For ease of notation, we define Nk,ℓ(v) = hφk, Yℓ(v)i; using the same methods as in Bordenave et al. (2015), we have the following estimates: Proposition 23 Let ℓ ∼ κ logα(n) with κ < 1/4. Then w.h.p: kB(ℓ)χk − Nk,lk = o(αℓ/2√n) and kB(ℓ)B(ℓ)χk − Pk,ℓ − Nk,2ℓk = O(αℓ√n). It then remains to follow the proof of Proposition 19 from Bordenave et al. (2015); we simply highlight the proof for estimation (iii) of Proposition 14, since it is the only difference: Proof (Proposition 14-(iii)): We have by definition hϕj, ζki = hB(ℓ)χj, B(ℓ)B(ℓ)χki kB(ℓ)χjkkB(ℓ)B(ℓ)χkk . 16 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION But kB(ℓ)χjk = Θ(√nµℓ k), kB(ℓ)B(ℓ)χkk = kB(ℓ)χkkθk = Θ(√nµ2ℓ k ) and: (cid:12)(cid:12)(cid:12)hB(ℓ)χj, B(ℓ)B(ℓ)χki − hNj,ℓ, Pk,ℓ + Nk,2ℓi(cid:12)(cid:12)(cid:12) ≤ kNj,ℓkkB(ℓ)B(ℓ)χk − Pk,ℓ − Nk,2ℓk + kB(ℓ)B(ℓ)χkkkB(ℓ)χj − Nj,ℓk Furthermore, from Propositions 21 and 22, we get = eO(α4ℓ√n). hNj,ℓ, Pk,ℓ + Nk,2ℓi = eO(α7ℓ/2n1−γ/2). This gives the desired result. A.4. Ramanujan property of B(ℓ) In order to complete the proof of Theorem 7, we need a control on the other eigenvalues of B(ℓ). This is covered by the following proposition: Proposition 24 Let H = hϕ1, . . . , ϕr0i, and ℓ ∼ κ logα(n) with κ < 1/12. Then with high probability sup x∈H ⊥,kxk=1 kB(ℓ)xk = eO(αℓ/2). (28) The proof of this result relies on the following decomposition of B(ℓ), whose proof can be found in Massoulié (2014): Lemma 25 Matrix B(ℓ) verifies the identity B(ℓ) = ∆(ℓ) + ℓXm=1 ∆(ℓ−m) ¯AB(m−1) − Γℓ,m, ℓXm=0 for matrices ∆(j), Γℓ,m such that for ℓ = O(log(n)) and with high probability, for all ε > 0, ρ(Γℓ,m) = nε−1α(ℓ+m)/2, m = 1, . . . , ℓ. ρ(∆(j)) = eO(αj), j = 1, . . . , ℓ, (29) (30) (31) Here, ¯A refers to the expected value of the adjacency matrix A of G. The next step is therefore to control B(m−1)x for x ∈ H ⊥; in what follows γ will be any constant below 1/2. We begin with the following proposition from Bordenave et al. (2015): Proposition 26 Let ℓ ∼ κ logα(n) with κ < γ/2. There exists a subset B ⊂ V , constants C and c such that w.h.p the following holds: (i) for all i ∈ V \ B, 0 ≤ m ≤ ℓ, (B(m)χk)i − µt−ℓ k (B(ℓ)χk)i ≤ C log(n)cαm/2 (B(m)χk)i ≤ C log(n)cαm/2 if k ∈ [r0], if k ∈ [r] \ [r0]. 17 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION (ii) for all i ∈ B, 0 ≤ m ≤ ℓ and k ∈ [r], (B(ℓ)χk)i ≤ C log(n)cαm. (iii) B = eO(αℓn1−γ). From this, we get the following corollary: Corollary 27 Let ℓ ∼ κ logα(n) with κ < γ/2; then, with high probability, for 0 ≤ m ≤ ℓ − 1 and k ∈ [r0]: sup x⊥B(ℓ)χk,kxk=1hB(m)χk, xi = eO(√n αm/2). Additionally, for k ∈ [r] \ [r0], Proof Write Using the Cauchy-Schwarz inequality, the first sum is bounded by kB(m)χkk = eO(√nαm/2). xi(B(m)χk)i +Xi /∈B xi(B(m)χk)i = s1 + s2. hB(m)χk, xi =Xi∈B s1 ≤ log(n)cαmpB ≤ log(n)dαmαℓ/2n(1−γ)/2 = o(√nαm/2), k Xi∈B (B(ℓ)χk)i s2 ≤ µt−ℓ ≤ log(n)cαt−ℓαℓαℓ/2n(1−γ)/2 + log(n)c√nαt/2 = eO(√n αm/2), xi(B(ℓ)χk)i +Xi /∈B xi(B(m)χk)i − µt−ℓ k while the second can be treated using Proposition 26 and the fact that hB(ℓ)χk, xi = 0: where we used again the Cauchy-Schwarz inequality as before. Let now k ∈ [r] \ [r0]; as before, we write kB(m)χkk2 =Xi∈B (B(m)χk)2 (B(m)χk)2 i i +Xi /∈B ≤ B log(n)cα2m + n log(n)cαm = n log(n)c(αl+2mn−γ + αm) = eO(nαm), and the result follows. We are now ready to prove Proposition 24: 18 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION Proof Let x ∈ H ⊥ such that kxk = 1 and the supremum in (28) is reached; using the decomposition from Lemma 25, we have kB(ℓ)xk ≤ ρ(∆(ℓ)) + ℓXm=1 ρ(∆(ℓ−m))k ¯AB(m−1)xk + ρ(Γℓ,m). ℓXm=1 the matrix P by The first and third terms are bounded by eO(αℓ/2). For the second term, we notice that defining P = 1 n µkχkχ⊤ k , rXk=1 we have ¯A = P − diag(P ) since W =P µkφkφ⊤ k ¯AB(m−1)xk =(cid:13)(cid:13)(cid:13)(cid:13)(cid:13) Therefore, for fixed 1 ≤ m ≤ ℓ, we have: rXk=1 k B(m−1)x − diag(P )B(m−1)x(cid:13)(cid:13)(cid:13)(cid:13)(cid:13) kB(m−1)xk + Xk∈[r0] µk n kχkχ⊤ µkχkχ⊤ supi Wii ≤ n k . k B(m−1)xk + Xk∈[r]\[r0] µk n kχkχ⊤ k B(m−1)xk = I + J + K. Notice first that B(ℓ) we have ij ≤ 2 for all i, j by the tangle-free property, so I = O(1). Now, for k ∈ [r0], [r0] Therefore, J = eO(αm/2); finally, using the Cauchy-Schwarz inequality, we have for k ∈ [r] \ kχkχ⊤ k B(m−1)xk = kχkkhB(m−1)χk, xi ≤ eO(√n × √nαm/2). kχkχ⊤ k B(m−1)xk ≤ kχkkkB(m−1)χkkkxk = eO(√n × √nαm/2 × 1). Putting this all together, we find that for 1 ≤ m ≤ ℓ k ¯AB(m−1)xk = eO(αm/2). Since ρ(∆(ℓ−m)) = eO(α(ℓ−m)/2), we get kB(ℓ)xk = eO(αℓ/2), which proves the desired result. A.5. Proof of Proposition 15 Using Proposition 24, we are now able to prove our last result. Note that if κ < 1/12, there exists a γ < 1/2 such that κ < γ/6. 19 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION Let zk be the Gram-Schmidt orthonormalization of ϕk; using Lemma 9 from Bordenave et al. (2015), we know that and thus zk is asymptotically parallel to ϕk. We only need a final lemma to complete our proof: kϕk − zkk = eO(α3ℓ/2n−γ/2), Lemma 28 Assume that ℓ ∼ κ logα(n) with κ < γ/6. Then Proof Write k αℓ/2). kζk − zkk = eO(θ−1 ζk = Xj∈[r0] hζk, zjizj + x, where x ∈ H ⊥. We have, for j 6= k, hζk, zji = eO(α2ℓn−γ/2) by the above bound of kϕj − zjk; furthermore, kxk2 = hζk, xi since κ < γ/6. Then, which yields the desired result. kzk − ζkk2 = 2(1 − hζk, zki) = eO(θ−2 k αℓ), Proof (of Proposition 15): We first bound kB(ℓ)zk − Dzkk for k ∈ [r0]. Notice that Dzk = θkzk; this gives kB(ℓ)zk − Dzkk ≤ kB(ℓ)zk − B(ℓ)ϕkk + kB(ℓ)ϕk − θkzkk ≤ ρ(B(ℓ))kzk − ϕkk + θkkζk − zkk = O(αℓ) × eO(α3ℓ/2n−γ/2) + eO(αℓ/2) = eO(αℓ/2). Consider now x ∈ RV such that kxk = 1. Decomposing x asP xkzk + x′ where x′ ∈ H ⊥, we have: 20 Therefore, we can write k αℓ/2) × kxk. = θ−1 k hB(ℓ)ϕk, xi ≤ θ−1 k kB(ℓ)xk = eO(θ−1 1 = kζkk2 = hζk, zki2 +Xj6=k hζk, zji2 + kxk2 = hζk, zki2 + eO(α2ℓn−γ/2) + eO(θ−2 = hζk, zki2 + eO(θ−2 k αℓ), k αℓ) ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION xkkB(ℓ)zk − Dzkk + kB(ℓ)x′ − Dx′k kB(ℓ)x − Dxk ≤ Xk∈[r0] ≤ eO(αℓ/2) + kB(ℓ)x′k = eO(αℓ/2), which completes the proof. Appendix B. Proofs for Theorem 9 B.1. Proof of Lemma 16 We first recall a result from Kesten and Stigum: consider a multitype Galton-Watson process, where the type of the root node is distributed according to arbitrary probability vector ν, and a particle of type j ∈ [r] has a Poi(Mij) number of children of type i. Let Zt be the vector of population at time t, and Ft the natural filtration associated to Zt; we have the following statement: Lemma 29 For each µ eigenvalue of M such that µ2 > α, and each eigenvector φ associated to µ, t 7→ X(φ, ν, t) = µ−t k hφk, Zti (32) is an Ft-martingale converging a.s. and in L2 to a random variable with finite variance and ex- pected value hφk, νi. Let µ 6= α be an eigenvalue of M of multiplicity d such that µ2 > α, and φ(1), . . . , φ(d) an orthonormal basis of eigenvectors associated to d. We define for all i ∈ [d], j ∈ [r], X (i) the limit variable of martingale (32), applied to φ = φ(i) and ν = δj . Similarly to previous notations, let φ(i) (resp. X (i)) be the vector(cid:16)φ(i) ), and φ (resp. X) the (random) matrix whose columns are the φ(i) (resp. the X (i)). Recall that from Lemma 29, the expected value of X (i) j is φ(i) j j (cid:17)j∈[r] (resp.(cid:16)X (i) j (cid:17)j∈[r] for all i, j. j Now, let ξ be an eigenvector of B(ℓ), normalized so that kξk2 = n, with associated eigenvalue Θ(µℓ); as shown in the proof of Theorem 7, there exists a vector u ∈ Rd such that We let kξ − (hφu, Yℓ(v)i)v∈V k = o(1). φ(ξ) = φu and X (ξ) = Xu. From Proposition 21, u has norm Θ(1), and since µ−thφ, Zti (with ν = δj ) converges to X (i) j in L1, µ−thφ(ξ), Zti converges to X (ξ) j in L1 independently of ξ. Using proposition 36 from Bordenave et al. (2015), we have the following: 21 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION Lemma 30 For all i ∈ [r], we have the following convergence in L1: 1σ(v)=i ξ(v)1ξ(v)≤K → π(i)EhX (ξ)1 nXv∈V 1 X (ξ)≤Ki, for all K that is a continuity point of the distribution of Xi, and independently of ξ. Proof We first recall the aforementioned proposition from Bordenave et al. (2015): we say that a function τ that takes a graph and a distinguished vertex as an argument is ℓ-local if τ (G, v) depends only on the ℓ-neighbourhood of v in G. Denote by T the multitype Galton-Watson tree discussed earlier, rooted at o, where o has the distribution δι and ι has distribution π. Lemma 31 Assume that τ, ψ are two ℓ-local functions such that τ ≤ ψ and ψ is non-decreasing by the addition of edges. Then, if ℓ ∼ κ logα(n) with κ < 1/2, we have, for γ < 1/2: E"(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) 1 nXv∈V ≤ c τ (G, v) − E[τ (T, o)](cid:12)(cid:12)(cid:12)(cid:12)(cid:12) # (cid:18)E[max αℓ/2plog(n) nγ/2 v∈V ψ4(G, v)](cid:19)1/4 σ(v)=i hφ(ξ), Yℓ(v)i1 ∨(cid:0)E(cid:2)ψ2(T, o)(cid:3)(cid:1)1/2! We now apply this lemma with τ (G, v) = 1 in Proposition 21. We can set ψ(G, v) = K, and by Lemma 29 and the subsequent analysis, we have hφ(ξ) ,Yℓ(v)i≤K where Yℓ is defined E[τ (T, o)] → π(i) EhX (ξ) i 1 X (ξ) i ≤Ki independently of ξ. Now, by definition, we have kξ −(cid:0)hφ(ξ), Yℓ(v)i(cid:1)v∈V k = o(1) (again independently of ξ). By the Cauchy-Schwarz inequality, we deduce that 1 nXv∈V(cid:12)(cid:12)(cid:12)ξ(v) − hφ(ξ), Yℓ(v)i(cid:12)(cid:12)(cid:12) = o(1) as well, and the lemma follows if K is a continuity point of X (ξ) . i It now remains to prove the desired properties of the X (ξ) i orthogonal to the all-one vector and as such ; first, since µ 6= α, then φ(ξ) is Xi∈[r] E[Xi] =Xi∈[r] φ(ξ) i = 0 Moreover, kφ(ξ)k2 = kuk2 = Θ(1), which proves the second assertion. Finally, let η > 0; since the X (i) j all have finite variance, there exists a constant K > 0 such that P(X (i) j ≤ K ′) ≥ 1 − η for all i, j and thus P(cid:0)kXk∞ ≤ K ′(cid:1) ≥ 1 − drη. 22 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION Using the equivalence of norms, we find 2 ≤ rkuk2 which implies (since X (ξ) = Xu) P(cid:16)∀i, kX (i)k2 2 ≤ rK ′2(cid:17) ≥ 1 − drη P(cid:16)kX (ξ)k2 2K ′2(cid:17) ≥ 1 − drη. Using again norm equivalence yields finally, for K = √rkukK ′, P(cid:16)kX (ξ)k∞ ≤ K(cid:17) ≥ 1 − drη. ](cid:12)(cid:12)(cid:12) = EhX (ξ)i 1 ] − E[X (ξ) ≤rEh(X (ξ) ≤rEh(X (ξ) (cid:12)(cid:12)(cid:12)E[X (ξ) Now, we have, for all i, X (ξ) X (ξ) ≤K 1 i i i i i i >Ki )2iP(cid:16)X (ξ) )2i ·pdrη i (33) ≥ K(cid:17) But by Doob's Theorem, Eh(X (ξ) ity of Lemma 16. i )2i is finite so choosing η accordingly yields the last inequal- B.2. Proof of limit (15) For each v ∈ V , we define Iv to be the random variable equal to 1 if v is assigned to I +, and 0 otherwise. Conditionnally to ξ, it is straightforward to see that Iv ∼ Ber(qv) with 1 2K Now, let Pi = ({v ∈ I + σ(v) = i}) /n; by definition, 1σ(v)=i Iv Pi = qv = 1 2 + 1 nXv∈V ξ(v)1 ξ(v)≤K . We therefore have E[Pi ξ] = 1 nXv∈V 1σ(v)=i (cid:18) 1 2 + 1 2K ξ(v)1ξ(v)≤M(cid:19) , Var(Pi) ≤ 1 4n and thus with high probability, independently of ξ, Pi = E[Pi ξ] + n−1/3 → π(i)(cid:18) 1 1 2K + 2 E[X (ξ) i ](cid:19) = π(i) pi ≤M (34) (35) 1 X (ξ) i where the convergence speed is independent from ξ. 23 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION B.3. Explicit bounds on K In this section, the goal is to perform a more precise analysis of the limit variables X (ξ) , and to leverage this analysis to obtain an explicit value for K in Algorithm 8. For simplicity, we will assume that π ≡ 1/r throughout this section, although most of the results hold for general π. We begin with a small lemma: Lemma 32 Let φ be a normed eigenvector of M associated to an eigenvalue α > µ > √α, and denote by X (φ) the limit random variables of Lemma 29. Let c(φ),j (resp. m(φ),j) the vector of the j-th cumulants (resp. moments) of the X (φ) . We then have the following relation, for all j ∈ N: i i i c(φ),j = M µj m(φ),j By definition, we have c(φ),1 = m(φ),1 = φ, and we have the following corollary for c(φ),2 and m(φ),2: Corollary 33 We denote by φ2 the vector whose coordinates are the φ2 i . Then c(φ),2 =(cid:18)I − M µ2(cid:19)−1 M µ2 φ2 and m(φ),2 =(cid:18)I − M µ2(cid:19)−1 φ2. As a result, we have Var(X (φ) i ) = Xi∈[r] 1 τ − 1 and Xi∈[r] E[(X (φ) i )2] = τ τ − 1 , 2/α. where τ = µ2 Proof (of Corollary 33). The first part is an easy calculation, observing that c(φ),2 = m(φ),2 − φ2. For the second part, since the all-one vector e is an eigenvector of M associated to the eigenvalue α, we have: i Var(X (φ) ) = he, c(φ),2i µ2(cid:19)−1 M = e⊤(cid:18)I − µ2 φ2 1 − α/µ2 e⊤ φ2 τ − 1 and a similar calculation yields the second identity. α/µ2 M 1 Xi∈[r] = = , It now remains to prove Lemma 32: 24 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION Proof (of Lemma 32). Using the Galton-Watson tree definition (and going one step down into the tree), we have the following characterization for the variables X (φ) : i X (φ) i = 1 µ Xj∈[r] Poi(Mij)Xk=1 X (φ) j,k , j,k are independent copies of X (φ) j for all k. Applying the Laplace transform (denoted where the X (φ) by ψ(φ) i ) and taking the logarithm on both sides, we find that for all t ∈ R, log(ψ(φ) i (t)) = Xj∈[r] Mij(cid:18)ψ(φ) j (cid:18) t µ(cid:19) − 1(cid:19) Now, the k-th Taylor coefficient of the LHS is c(φ),k i /k!, and the one on the RHS is Mij j m(φ),k k! µk = Xj∈[r] 1 µk k!hM m(φ),kii , which completes the proof. We now can prove our first result on the vector u defined before: Lemma 34 Let µ, ξ and u be defined as in the proof of Lemma 16. Then we have kuk2 = r(τ − 1) + o(1) Proof From Lemma 21, we know that for each i ∈ [d], 2 (cid:13)(cid:13)(cid:13)(cid:16)hφ(i), Yℓ(v)i(cid:17)v∈V(cid:13)(cid:13)(cid:13) = n(ρ(i) + o(1)) where ρ(i) =Xi∈[r] π(i)Eh(X (i))2i But since π ≡ 1/r, we know from Corollary 33 that 1 ρ(i) = ρ := r(τ − 1) But the vectors(cid:0)hφ(i), Yℓ(v)i(cid:1)v∈V are asymptotically orthogonal, and thus n = kξk2 = (kvk2 + o(1)) · n · (ρ + o(1)), which yields the desired result. Now, we are ready to prove some bounds for K; the main step is the following Markov bound on (X (i))2: Lemma 35 Let η > 0; then, for all i ∈ [d], j ∈ [r], P(cid:18)X (i) j ≤r τ η(τ − 1)(cid:19) ≥ 1 − η 25 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION Proof For all C > 0, we have by Markov's inequality P(cid:16)X (i) j ≥ C(cid:17) ≤ E[(X (i) j )2] C 2 ≤ τ C 2(τ − 1) , where we bounded E[(X (i) j )2] by the sum of all E[(X (i) k )2]. The lemma then follows easily. Now, we have to unravel the calculations done in the proof for Lemma 16; let ε < 0. By the same bound as above (as well as the fact that the φ(i) are orthogonal), we have Eh(X (ξ) i )2i ≤ kuk2 τ τ − 1 = rτ + o(1) Therefore, an asymptotically good choice of η is which yields a value for K ′ of η = ε2 r2 d τ , K ′ =r τ η(τ − 1) = r τ ε r d τ − 1 Finally, the bound for K becomes K = √rkukK ′ = r τ ε √r d τ We thus need to find a sufficient value for ǫ; recall that = kuk2 = r(τ − 1) + o(1) and therefore there exists some values for i, j such that Xi∈[r] i i2 EhX (ξ) (cid:12)(cid:12)(cid:12)(cid:12)EhX (ξ) i i2 i i = 0, − EhX (ξ) EhX (ξ) and Xi∈[r] j i2(cid:12)(cid:12)(cid:12)(cid:12) ≥pr(τ − 1) + o(1). √r d τ = r τrd τ − 1 τ A sufficient choice of ε is thuspr(τ − 1)/4, which yields an explicit value for K: K = r τ ε Appendix C. Proof of Lemma 18 We first recall some results about the neighbourhoods of vertices, whose proofs can be found in Bordenave et al. (2015): 26 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION Lemma 36 For a vertex i, define St(i) as the number of vertices at distance t of i. Then there exist constants C and ε > 0 such that with probability 1 − O(n−ε), for all i ∈ {1, . . . n} and ℓ = O(log(n)): St(i) ≤ C · log(n) · αt, t ∈ {1, . . . , ℓ}. On the other hand, with high probability, when ℓ = κ logα(n) with κ < 1/2: Sℓ(i)2 = Θ(nα2ℓ). nXi=1 Additionnally, a result about the almost tree-like structure of vertex neighbourhoods: (36) (37) Lemma 37 Assume ℓ = κ log(n), with κ log(α) < 1/4. Then with high probability no node i has more than one edge cycle in its ℓ-neighbourhood; we say that G is ℓ-tangle-free. Using those results, we are now able to prove Lemma 18: Proof From Lemma 37, we can deduce that if d(i, j) ≤ ℓ, there are at most two distinct paths between i and j. Therefore, B(ℓ) Additionally, if D(ℓ) ij = 1, then there is a self-avoiding path of length ℓ between i and j, and thus ij ≤ 2 for all i, j. B(ℓ) ij = 1, so ∆(ℓ) ij ≥ 0 for all i, j. Finally, assume that there exists a pair i, j such that D(ℓ) ij = 2; then there are two paths of length ℓ between i and j and d(i, j) < ℓ so there is also a path of length less than ℓ. This contradicts Lemma 37. ij = 0 and B(ℓ) ij = 1, there are two possibilities: Consider now two vertices i and j such that ∆(ℓ) (i) D(ℓ) ij = 0 and B(ℓ) ij > 0: then d(i, j) < ℓ and there is a path of length < ℓ and at least a path of length ℓ between i and j. (ii) D(ℓ) ij = 1 and B(ℓ) ij > 1: then there are at least two paths of length ℓ between i and j. In both cases, there are at least two paths of length at most ℓ connecting i and j, which implies the statement of the lemma. Appendix D. Proof of Lemma 19 Proof (i) is obvious since d(i,C) + d(j,C) ≤ ℓ implies d(i,C) ≤ ℓ. the ℓ-neighbourhood of i, which contradicts Lemma 37. For (ii), note first that VC and VC ′ are disjoint for C 6= C′: if i ∈ VC ∩ VC ′, then C and C′ are in Let πC be the projection on VC for all C; the πC are mutually orthogonal and for a vector v, we have: v⊤P (ℓ)v =XC v⊤πCP (ℓ)πCv =XC ≤XC (πCv)⊤P (ℓ) C (πCv) ρ(P (ℓ) C ) · kπCvk2 C ) ·XC ρ(P (ℓ) kπCvk2. ≤ max C 27 (38) (39) (40) ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION On the other hand, kvk2 ≥XC Combining inequalities (40) and (41) yields ρ(P (ℓ)) ≤ maxC ρ(P (ℓ) comes from the decomposition P (ℓ) =P P (ℓ) kπCvk2. C . (41) C ); the reverse inequality Appendix E. Proof of Proposition 20 In the same vein as Lemma 36, for a vertex set X , define St(X ) as the number of vertices at distance t of X . By taking the union on all vertices of X , we easily get the following corollary: Corollary 38 For the same constants C and ε as above, with probability 1 − O(n−ε), we have for all vertex subsets X ∈ P({1, . . . , n}) and ℓ = O(log(n)): St(X ) ≤ C · X log(n) · αt, t ∈ {1, . . . , ℓ}. We are now able to prove Proposition 20: Proof Let K be the modified vertex set, and consider vertices i and j such that D(ℓ) ij we have one of four possibilities: (i) d(i, j) = ℓ and d(i, j) < ℓ (ii) d(i, j) > ℓ and d(i, j) = ℓ (iii) d(i, j) = ℓ and d(i, j) > ℓ (iv) d(i, j) < ℓ and d(i, j) = ℓ ij . Then 6= eD(ℓ) In cases (i) and (ii), there is a path between i and j in G through K of length at most ℓ, and in cases (iii) and (iv) there is a path between i and j in G through K. Therefore, in all cases, we have that d(i,K) + d(j,K) ≤ ℓ. ij , and PK for the matrix such that PK,ij = 1{d(i,K) + d(j,K) ≤ ℓ}; the previous analysis and the Perron-Frobenius theorem imply that (42) Write eD(ℓ) − D(ℓ) for the matrix whose (i, j) coefficient is eD(ℓ) ρ(eD(ℓ) − D(ℓ)) ≤ ρ(eD(ℓ) − D(ℓ)) ≤ ρ(PK). We can then perform the same analysis as in the proof of Proposition 17 to find that the spectral ij − D(ℓ) radius of PK is the same as that of QK = √S0S1 S0 ... S1 ... √S0S1 pS0Sℓ−1 pS1Sℓ−1 √S0Sℓ 0  28 . . . ··· ··· ... 0 0 ··· pS0Sℓ−1 √S0Sℓ ··· pS1Sℓ−1 ,  0 ... 0 0 ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION where we write St instead of St(K) for ease of notation. Corollary 38 then gives St(K) = O(αt log(n)K) = o(αtτ ℓ/2), and the same calculation as in Proposition 17 yields: ρ(QK) = o(αℓ/2τ ℓ/2) = o(µℓ 2), (43) and the theorem follows. Appendix F. Proof of Theorem 12 In order to prove Theorem 12, we need to show that the controls in the proof of Theorem 11 are ac- tually sharp. We begin with the following lemma, which comes from the fact that ℓ-neighbourhoods of the vertices of G are roughly of the same size: Lemma 39 Assume that γ = Θ(τ ℓ/2). Then there exists a set of vertices K of size γ such that: Sℓ(K) = Ω(αℓ · γ). (44) Proof Let ε > 0 to be determined later, S be the set consisting of the n1−ε vertices i with the largest values Sℓ(i); we first show that, for all i ∈ S Sℓ(i) = Θ(αℓ). Indeed, from Lemma 36, we have the folowing inequalities: Knα2ℓ ≤ nXi=1 Sℓ(i)2 ≤ n min i∈S Sl(i)2 + S(C log(n)αℓ)2, and the second term is negligible before the two others, which implies (45). (45) (46) We then build a set K of size γ as follows: begin with any member of S, and at each step add a vertex x such that d(x,K) > 2ℓ. This is possible as long as the 2ℓ-neighbourhood of K does not cover S, i.e. as long as: (47) γ · C log(n)α2ℓ < n1−ε. But the LHS of this inequality is bounded by C log(n)n3/4, so this condition is satisfied as long as ε < 1/4. equation (39) we have: By this construction, the vertices of K have ℓ-neighbourhoods that are pairwise disjoint, so by (48) Sℓ(K) = Ω(αℓ × γ). Consider now the vector v such that: vi = γ−1/2 Sℓ(K)−1/2 0 if i ∈ K if d(i,K) = ℓ otherwise . 29 (49) ROBUSTNESS OF SPECTRAL METHODS FOR COMMUNITY DETECTION The aim is to show the following equalities: v⊤D(ℓ)v kvk2 = Ω(µℓ 2) and hv, B(ℓ)χki = o(kvkkB(ℓ)χkk) ∀k ∈ [r0] (50) Indeed, Theorem 12 will then follow from a simple application of Courant-Fisher's Theorem. Proof (of Eq. (50). We notice that kvk2 = 2; furthermore: v⊤D(ℓ)v =Xi,j viD(ℓ) ij vj vivj ≥ 2 Xi∈Sℓ(K)Xj∈K = 2γSℓ(K)γ−1/2Sℓ(K)−1/2 = 2pγSℓ(K) = Ω(µℓ 2), which proves the first inequality. It remains then to prove that v is asymptotically orthogonal to B(ℓ)χk for k ∈ [r0]: noticing that vi ≤ 1 for all i and kvk0 = γ + Sℓ(K), we find, using Corollary 38: hv, B(ℓ)χki ≤ (γ + Sℓ(K)) · kB(ℓ)χkk∞ ≤ (γ + Sℓ(K)) · eO(αℓ) = eO(γα2ℓ) = o(√nµℓ k) = o(kvkkB(ℓ)χkk), where we used part (ii) of proposition 26 to bound kB(ℓ)χkk∞. since κ < 1/4 30
1309.3458
3
1309
2016-05-17T12:25:56
A Parallel Data Distribution Management Algorithm
[ "cs.DS", "cs.DC" ]
Identifying intersections among a set of d-dimensional rectangular regions (d-rectangles) is a common problem in many simulation and modeling applications. Since algorithms for computing intersections over a large number of regions can be computationally demanding, an obvious solution is to take advantage of the multiprocessing capabilities of modern multicore processors. Unfortunately, many solutions employed for the Data Distribution Management service of the High Level Architecture are either inefficient, or can only partially be parallelized. In this paper we propose the Interval Tree Matching (ITM) algorithm for computing intersections among d-rectangles. ITM is based on a simple Interval Tree data structure, and exhibits an embarrassingly parallel structure. We implement the ITM algorithm, and compare its sequential performance with two widely used solutions (brute force and sort-based matching). We also analyze the scalability of ITM on shared-memory multicore processors. The results show that the sequential implementation of ITM is competitive with sort-based matching; moreover, the parallel implementation provides good speedup on multicore processors.
cs.DS
cs
A Parallel Data Distribution Management Algorithm Moreno Marzolla, Gabriele D'Angelo Dept. of Computer Science and Engineering University of Bologna, Italy Email: [email protected], [email protected] Marco Mandrioli Email: [email protected] 6 1 0 2 y a M 7 1 ] S D . s c [ 3 v 8 5 4 3 . 9 0 3 1 : v i X r a Abstract -- Identifying intersections among a set of d- dimensional rectangular regions (d-rectangles) is a common problem in many simulation and modeling applications. Since algorithms for computing intersections over a large number of regions can be computationally demanding, an obvious solution is to take advantage of the multiprocessing capabilities of modern multicore processors. Unfortunately, many solutions employed for the Data Distribution Management service of the High Level Architecture are either inefficient, or can only par- tially be parallelized. In this paper we propose the Interval Tree Matching (ITM) algorithm for computing intersections among d-rectangles. ITM is based on a simple Interval Tree data structure, and exhibits an embarrassingly parallel structure. We implement the ITM algorithm, and compare its sequential performance with two widely used solutions (brute force and sort-based matching). We also analyze the scalability of ITM on shared-memory multicore processors. The results show that the sequential implementation of ITM is competitive with sort-based matching; moreover, the parallel implementation provides good speedup on multicore processors. Keywords-Data Distribution Management; High Level Archi- tecture; Parallel Algorithms; Interval Tree I. INTRODUCTION The High Level Architecture (HLA) specification [1] de- fines several Data Distribution Management (DDM) services to forward events generated on update regions to a set of subscription regions. For example, consider a simulation of vehicles moving on a two-dimensional terrain. Each vehicle may be interested in events happening inside its area of interest (e.g., its field of view) that might be approximated with a rectangular region centered at the vehicle position. This kind of problem also arises in the context of Massively Multiplayer Online Games, where the game engine must send updates only to players that might be affected by game events, in order to reduce computation cost and network traffic. In this paper we assume that a region corresponds to a single extent in DDM terminology), that is, a d-dimensional rectangle (d-rectangle) in a d-dimensional routing space. Spatial data structures that can solve the region intersec- tion problem have been developed over the years; examples 0The version of this publisher available at as: Moreno http://dx.doi.org/10.1109/DS-RT.2013.23. Please Marzolla, Gabriele D'Angelo, Marco Mandrioli. A Parallel Data Distribution Management Algorithm. Proceedings of the 2013 IEEE/ACM 17th International Symposium on Distributed Simulation and Real Time Applications (DS-RT 2013). ISBN, 978-0-7695-5138-8. is cite paper include the k-d tree [2] and R-tree [3]. However, it turns out that simpler, less efficient solutions are actually preferred in practice and widely deployed in DDM implementations. The reason is that efficient spatial data structures tend to be complex to implement, and therefore their theoretical performance is affected by high constant factors. The increasingly large size of computer simulations em- ploying DDM techniques is posing a challenge to the existing solutions. As the number of regions increases, so does the execution time of the DDM service. Given the current trend in microprocessor design where a single CPU contains multiple independent execution units, significant improvements could be achieved if the existing DDM match- ing algorithms were capable of taking advantage of the computational power provided by multi-core processors. There are two opportunities for parallelizing DDM algo- rithms. The first is based on the observation that the problem of identifying whether two d-rectangles intersect can be reduced to d independent intersection problems among one- dimensional segments (details will be given in Section III). Therefore, given an algorithm that can identify intersections among two sets of segments, we can execute d instances in parallel, each computing the intersections among the projections of the extents along each dimension. The extent intersections can be easily computed from the segments overlap information. The idea above can be regarded as the "low hanging fruit" which is easy to get, but does not solve the problem in the long run. In fact, the number of cores in modern processors is often larger than the number of dimensions of most routing spaces; this gap is likely to increase (e.g., the Tilera TILE-Gx8072 processor [4] offers 72 general- purpose cores on the same chip, connected through an on- chip mesh network). Here comes the second parallelization opportunity: distribute the regions to the available cores so that each core can work on a smaller problem. This is quite difficult to achieve on the existing DDM algorithms, since they are either inefficient (and therefore there is little incentive in splitting the workload), or inherently sequential (and therefore there is no easy way to achieve parallelism over the set of extents). In this paper we describe the Interval Tree Matching (ITM) algorithm for solving the one-dimensional segment intersection problem. The algorithm uses a simple imple- mentation of the Interval Tree data structure based on an augmented balanced search tree. Experimental performance measures indicate that the sequential version of ITM is com- petitive in the sequential case with the best algorithm used for DDM, namely sort-based matching. We also observed good scalability of the parallel implementation of ITM on shared-memory architectures. An important feature of ITM is that it can be used to efficiently update overlap information in a dynamic setting, that is, in case extents can be moved or resized dynamically. This paper is organized as follows. In Section II we briefly review the state of the art and compare ITM with existing solutions to the DDM matching problem. In Section III we describe three commonly used algorithms for DDM: brute force, grid-based and sort-based matching. In Section IV we describe ITM and analyze its computational cost. In Section V we experimentally evaluate the performance of the sequential version of ITM compared with brute force and sort-based matching; additionally, we study the scalability of a parallel implementation of ITM on a multicore processor. Finally, conclusions and future works will be discussed in Section VI. II. RELATED WORK DDM matching can be considered as an instance of the more general problem of identifying intersecting pairs of (hyper-)rectangles in a multidimensional metric space. Well known space-partitioning data structures such as k-d trees [2] and R-trees [3] can be used to efficiently store volumetric objects and identify intersections with a query object. However, spatial data structures are quite complex to implement and, although asymptotically efficient, they can be slower than less efficient but simpler solutions in many real-world situations [5]. In [6] the authors describe a rectangle-intersection algorithm in two-dimensional space that uses only simple data structures (arrays), and can enu- merate all k intersections among n rectangles O(n log n+k) time and O(n) space. The usage of Interval Trees for DDM was first proposed in [5] where the authors used a different and more complex data structure than the one proposed here (see Section IV). In their case, the performance evaluation on very small instances shows mixed results. Sort-Based Matching (SBM) [7] is a widely used algo- rithm for enumerating all intersections among subscription and update extents, with particular emphasis on distributed simulation applications based on the High Level Architec- ture (HLA) specification. SBM first sorts the endpoints, and then scans the sorted set (details will be given in Section III-D). SBM is extended in [8] to work efficiently on a dynamic scenario where extents can be moved or resized dynamically. Despite its simplicity and efficiency, SBM has the draw- back that its sequential scan step is intrinsically serial and can not be easily parallelized. This can be a serious limitation when dealing with a large number of extents on multicore processors. In [9] the authors propose a binary partition-based match- ing algorithm that has good performances in some settings, but suffers from a worst case cost of O(N 2 log N ) where N is the total number of subscription and update regions. Moreover, the extension of this algorithm to the dynamic scenario seems impractical. Layer et al. [10] describe the Binary Interval Search (BITS) algorithm. BITS can be used to efficiently count the number of intersections between two sets A and B of intervals in time O ((A + B) log B). To do so, BITS performs a preprocessing phase in which two sorted arrays BS and BE are created in time O(B log B). BS contains the starting points of all intervals in B, while BE contains the ending points. The number of intervals in B that intersect a given query interval q = [q.low, q.high] can be computed by subtracting from B the number of intervals which do not intersect q. BITS uses two binary searches in BS and BE to compute the number of intervals in B whose ending point precedes q.low, and those whose starting point follows q.high. While BITS can be easily parallelized by executing the binary searches in parallel, it must be observed that the problem of enumerating all intersections can not be easily handled by BITS without substantial modifications which significantly increase its computational cost. III. DDM MATCHING ALGORITHMS In this section we define the DDM problem and describe three well known solution algorithms that have been thor- oughly investigated. Let S = {S1, . . . , Sn} and U = {U1, . . . , Um} be two sets of rectangular regions in d-dimensional space (d- rectangles, also called extents). S is the set of subscription extents, while U is the set of update extents. Each extent T has an integer attribute T.id representing its index in the set it belongs to, e.g., Si.id = i and Uj.id = j. The goal of a DDM matching algorithm is to identify all intersections between a subscription and an update extent, that is, enumerating the content of the subset of S × U defined as {Si ∈ S, Uj ∈ U Si ∩ Uj 6= ∅} Figure 1 shows an example in d = 2 dimensions with three subscription extents {S1, S2, S3} and two update ex- tents {U1, U2}. We observe that U1 overlaps with S1 and S3, while U2 overlaps with S2 and S3. The preferred way of storing the intersections uses a n×m binary matrix M, where each element Mij = 1 if and only Algorithm 2 Brute Force Matching (BF) function BRUTEFORCE-1D(S, U) n ← S, m ← U Let M be an n × m intersection matrix for all i ← 1, n do for all j ← 1, m do Mij ← INTERSECT-1D(Si, Uj) return M Figure 1. Data Distribution Management example in d = 2 dimensions Algorithm 1 Segment intersection test function INTERSECT-1D(x, y) return x.low < y.high ∧ y.low < x.high if Si intersects Uj. In the case of Figure 1 we have M =   1 0 1 0 1 1   Since the number of intersections is generally much smaller than n × m, matrix M tends to be sparse and can be stored in compressed form to reduce the memory requirement. It is important to observe that any DDM algorithm that enumerates all K intersections requires time at least Ω(K); we say that the time complexity of DDM matching algo- rithms is output-sensitive, since it depends on the size of the output as well as on the size of the input. Since K ≤ nm, in the worst case we have that any algorithm has a worst- case complexity of O(nm). Every algorithm that stores the result into an uncompressed intersection matrix requires time O(nm) to initialize the matrix, regardless of the number of intersections. Despite this, it makes sense to try to improve the efficiency of overlap identification, since in practice this is the slower step of the DDM problem. A. Testing Intersection Testing whether two d-rectangles intersect is a key opera- tion. When d = 1 the problem is reduced to testing whether two segments x = [x.low, x.high], y = [y.low, y.high] intersect, that can be done in time O(1) using Algorithm 1. For the general case d > 1 we observe that two d- dimensional extents Si and Uj intersect if and only if all their projections along each dimension intersect. Looking again at Figure 1, we see that the projections of S1 and U2 intersect along dimension 1 but not along dimension 2; therefore, S1 and U2 cannot intersect. On the other hand, the Figure 2. Grid-based DDM in d = 2 dimensions. projections of S2 and U2 intersect along both dimensions, and in fact these rectangular regions intersect in the plane. Since dealing with segments is easier than dealing with d- rectangles, it is common practice in the DDM research com- munity to define efficient algorithms for the one-dimensional case, and use them to solve the general higher dimensional case. According to the discussion above, an algorithm that enumerates all intersections among two sets of n and m segments in time O (f (n, m)) can be immediately extended to an O (d × f (n, m)) algorithm for d-rectangles. For this reason in the rest of this paper we will consider the case d = 1 only. B. Region-Based Matching The most direct approach for solving the segment inter- section problem is Region-Based matching, also called Brute Force (BF) approach shown in Algorithm 2. The BF algo- rithm tests all n × m subscription-update pairs, and records intersection information in matrix M. The BF algorithm requires time O(nm), and is therefore not very efficient; despite this, it is appealing due to its simplicity. Furthermore, BF can be trivially parallelized since all iterations are independent (it is an example of em- barrassingly parallel computation). When p processors are available, the amount of work performed by each processor is O (nm/p). C. Grid-Based Matching The Grid Based (GB) matching algorithm proposed by Boukerche and Dzermajko [11] is an improved solution to the d-rectangle intersection problem. It works by partitioning the routing space into a grid of d-dimensional cells. Each extent is mapped to the grid cells it overlaps with. The events produced by an update extent Uj are sent to all subscriptions that share at least one cell in common with Uj. The GB approach is more scalable than BF; furthermore, its performance can be tuned by choosing a suitable cell size. Unfortunately, it has some drawbacks: GB matching may report spurious overlaps, that is, may deliver events to subscribers which should not receive them. This situation is illustrated in Figure 2: the extent U1 and S2 share the dashed cell but do not overlap; therefore, S2 will receive spurious notifications from U1 that will need to be filtered out at the receiving side. The problem of spurious events can be mitigated by applying the brute force algorithm to each grid cell. If the routing space is partitioned into G cells and all extents are evenly distributed over the grid, each cell will have n/G subscription extents and m/G update extents. Therefore, the brute force approach applied to each cell requires O(nm/G2) operations; since there are G cells, the overall complexity becomes O(nm/G). In conclusion, in the ideal case the GB matching can reduce the workload by a factor G with respect to BF. Unfortunately, when cells are small (and therefore G is large) each extent is mapped to a larger number of cells, which increases the computation time. D. Sort-Based Matching The Sort-Based Matching algorithm proposed by Raczy et al. [7] is a simple and very efficient solution to the DDM matching problem. In its basic version, SBM is illustrated in Algorithm 3. Given a set S of n subscription intervals, and a set U of m update intervals, the algorithm sorts the endpoints in nonde- creasing order in the array L. Then, the algorithm performs a scan of the sorted vector; two sets SubscriptionSet and UpdateSet are used to keep track of the active subscription and update intervals at every point p. Each time the upper bound of an interval T is encountered, the intersection matrix M is updated appropriately, depending on whether T is a subscription or update extent. As can be seen, SBM uses only simple data structures. If we ignore the time needed to initialize the matrix M, Algorithm 3 requires time O ((n + m) log(n + m)) to sort the vector L, then time O(n + m) to scan the sorted vector. During the scan phase, total time O(nm) is spent to transfer the information from the sets SubscriptionSet and UpdateSet to the intersection matrix M, assuming that the sets above are implemented as bitmaps [7]. The overall computational cost is O ((n + m) log(n + m) + nm), and therefore asymptotically not better than BF; however, the term O(nm) comes from simple operations on bitmaps, hence SBM is very efficient in practice [7]. While SBM is very fast, it has the drawback of not being easily parallelizable. In fact, while parallel algorithms Algorithm 3 Sort-Based Matching (SBM) function SORT-BASED-MATCHING-1D(S, U) n ← S, m ← U Let M be an n × m intersection matrix Let L be a vector with 2(n + m) elements for all extents x ∈ S ∪ U do Insert x.lower and x.upper in L Sort L in nondecreasing order SubscriptionSet ← UpdateSet ← ∅ for all points p ∈ L in nondecreasing order do if p belongs to subscription extent T then if p is the lower bound of T then SubscriptionSet ← SubscriptionSet ∪ {T } else SubscriptionSet ← SubscriptionSet \ {T } ⊲ extents in UpdateSet overlap T i ← T.id for all x ∈ UpdateSet do j ← x.id Mij ← 1 else ⊲ T is an update extent if p is the lower bound of T then UpdateSet ← UpdateSet ∪ {T } else UpdateSet ← UpdateSet \ {T } ⊲ extents in SubscriptionSet overlap T j ← T.id for all x ∈ SubscriptionSet do i ← x.id Mij ← 1 return M for sorting the array L are known [12], the scan step is affected by loop-carried dependencies, since the content of SubscriptionSet and UpdateSet depend on their values at the previous iteration. This dependency can not be easily removed. Given the widespread availability of multi- and many-core processors, this limitation can not be ignored. In the next section we introduce the Interval Tree Match- ing algorithm for computing intersections among two sets of intervals. ITM uses an augmented AVL tree data structure to store the intervals. The performance of ITM depends on the number of intersections; however we will show that ITM is faster than SBM in the scenarios considered in the literature. Furthermore, ITM can be trivially parallelized, hence further performance improvements can be obtained on shared-memory multi-core processors. IV. INTERVAL TREE MATCHING ITM is a DDM matching algorithm for one dimensional segments based on the Interval Tree data structure. An Interval Tree stores a dynamic set of n intervals, and Algorithm 4 Returns the list of intervals intersecting q function INTERVAL-QUERY(x, q, M) if x = null or x.maxupper < q.lower or x.minlower > q.upper then return INTERVAL-QUERY(x.left, q, M) if INTERSECT-1D(x.in, q) then i ← x.in.id, j ← q.id Mij ← 1 if q.upper > x.in.lower then INTERVAL-QUERY(x.right, q, M) Algorithm 5 Interval Tree Matching Algorithm function INTTREE-MATCHING-1D(S, U) n ← S, m ← U Let M be an n × m intersection matrix T ← INTERVAL-TREE-CREATE(S) for all j ← 1, m do INTERVAL-QUERY(T.root, Uj, M) return M the difference being that at each node x both the x.minlower and x.maxupper fields are used to drive the exploration of the tree; also, the search might proceed on both the left and right child of node x. Algorithm 4 can identify all k intersections between q and all n intervals stored in the tree T in time O (min{n, (k + 1) log n}). The complete ITM matching procedure can now be easily described in Algorithm 5. First, an Interval Tree T is created from the subscription extents in S. Then, for each update extent Uj ∈ U, function INTERVAL-QUERY is invoked to identify all subscriptions that intersect Uj. Asymptotic Running Time: If there are n subscription and m update extents, the Interval Tree of subscriptions can be created in time O(n log n) and requires space O(n); the total query time is O (min{mn, (K + 1) log n}), K ≤ nm being the number of intersections involving all subscription and all update intervals. Note that we can assume without loss of generality that n ≤ m (if this is not the case, we can switch the role of S and U). Parallelizing ITM: Algorithm 5 can be trivially par- allelized, since all m queries on T are independent. Note that function INTERVAL-QUERY modifies the intersection matrix M passed as parameter; however, each invocation of INTERVAL-QUERY modifies a different column of M, therefore no conflicts arise. In Section V we will illustrate the results of experimental investigations on the scalability of the parallel implementation of ITM. Dynamic interval management: Another interesting feature of ITM is that it can easily cope with dynamic inter- vals. In most applications, extents can move and grow/shrink dynamically; if an update extent, say Uj, changes its position Figure 3. Interval Tree representation of a set of intervals supports insertions, deletions, and queries to get the list of segments intersecting with a given interval q. Different implementations of the Interval Tree are possi- ble. Priority search trees [13] support insertions and dele- tions in time O(log n), and can report all k intersections with a given query interval in time O(k + log n). For the experimental evaluation described in Section V we implemented the simpler but less efficient variant based on augmented AVL trees [14], described in [15, Chapter 14.3]. We did so in order to trade a slight decrease in asymptotic efficiency for a simpler and more familiar data structure. It should be observed that ITM is not tied to any specific implementation of Interval Tree, therefore any data structure can be used as a drop-in replacement inside the algorithm. Each node x of the AVL tree holds an interval x.in; intervals are sorted according to their lower bounds, and ties are broken by comparing upper bounds. Node x includes two additional fields x.maxupper and x.minlower, representing the maximum value of the upper bound and minimum value of the lower bound, respectively, of all intervals stored in the subtree rooted at x. We have chosen AVL trees over other balanced search trees, such as red-black trees [16], because AVL trees are more rigidly balanced and therefore allow faster queries. Figure 3 shows an example of Interval Tree with n = 7 intervals. Insertions and deletions are handled with the usual rules of AVL trees, with the additional requirement to propagate updates of the maxupper and minlower attributes up to the root. Since the height of an AVL tree is O(log n), insertions and deletions in the augmented data structure still require O(log n) time in the worst case. The storage requirement is O(n). Function INTERVAL-QUERY(x, q, M), described in Al- gorithm 4, is used to update matrix M with all intersec- tions of the update extent q with the segments stored in the subtree rooted at node x. The function is invoked as INTERVAL-QUERY(T.root, q, M). The basic idea is very similar to a conventional item lookup in a binary search tree, DDM ALGORITHMS CONSIDERED IN THE EXPERIMENTAL EVALUATION Table I Algorithm Computational Cost Additional Space Brute Force Sort-Based Interval Tree O (min{mn, (K + 1) log n}) O(nm) O ((n + m) log(n + m) + nm) O(n + m) none O(n) or size, then it is necessary to recompute column j of matrix M. The brute force approach applied to Uj alone gives an O(n) algorithm, since it is only necessary to identify overlaps between Uj and all n subscription segments. An extension of SBM capable of updating intersection informa- tion efficiently has been proposed [8], with an asymptotic cost that depends on various factors (e.g., upper bound of the dimension, maximum bound shift in a region modification). On the other hand, we can use two Interval Trees TU and TS, holding the set of update and subscription extents, respectively, to recompute the intersections efficiently. If an update extent Uj is modified, we can identify the subscrip- tions overlapping Uj in time O (min{n, (k + 1) log n}) by performing a query on TS. Similarly, if a subscription extent Si changes, the list of intersections can be recomputed in time O (min{m, (k + 1) log m}) using TU . Maintenance of both TU and TS does not affect the asymptotic cost of ITM. V. EXPERIMENTAL EVALUATION The performance of a DDM service can be influenced by many different factors, including: (i) the computational cost of the DDM matching algorithm; (ii) the memory footprint; (iii) the communication overhead of the parallel/distributed architecture where the simulation is executed and (iv) the cost of sending and discarding irrelevant events at the destination, if any. The communication overhead depends on the hardware platform over which the simulation model is executed, and also on the implementation details of the communication protocol used by the simulation middleware. Therefore, fac- tor (iii) above is likely to equally affect any DDM algorithm in the same way. The cost of discarding irrelevant notifications applies only to approximate matching algorithms, such as GB match- ing, that can report spurious intersections (unless spurious intersections are cleaned up at the sender side). The BF, SBM and ITM algorithms do not suffer from this problem since they never return spurious intersections. Besides, in [7] and [9] the authors show that for relevant cases the SBM algorithm has better performance than GB matching. There- fore, in the performance evaluation study we focused on the exact matching algorithms above, where only factors (i) and (ii) should be considered. Table I summarizes the computational and memory re- quirements of the DDM algorithms considered in the exper- imental evaluation. All costs are expressed in term of the number of subscription extents n, update extents m, and total number of intersections K. The "Additional Space" column specifies the additional memory required by each algorithm, excluding the space needed to maintain the lists of intervals, and excluding also the space required by the intersection matrix. As discussed in the previous sections, an extra O(nm) space is required by all algorithms to store the full intersection matrix. It is important to observe that the asymptotic costs re- ported in Table I may have little significance when eval- uating the actual performance of the algorithms, since in practice the constants hidden in the asymptotic notation may play a major role and should not be ignored. For example, as already explained in Section III, the weight of the term nm in the cost of SBM is likely very low since it is originated from simple operations on bit vectors. For these reasons, we performed a set of experimental evaluations whose outcome will be illustrated in this section. For better comparability of our results with those reported by other research papers, we considered d = 1 dimen- sions, and used the methodology and parameters employed in [7]. The first parameter is the total number of extents N . We considered a total number of extents in the range [50 × 103, 500 × 103]. In all cases, n = N/2 are subscription extents and m = N/2 are update extents. All extents are randomly placed on a segment of total length L = 1 × 106. All extents have the same length l that is computed in order to obtain the desired overlapping degree α, defined as: α = P area of extents area of the routing space = N × l L Therefore, for a given value of α and N , the length l of each segment can be computed as l = αL/N . The overlapping degree is an indirect measure of the total number of intersections among subscription and update extents. While the cost of BF and SBM is not affected by the number of intersections, this is not the case for ITM. We considered the same values for α as in [7], namely α ∈ {0.01, 1, 100}. The experimental evaluation has been performed on an Intel(R) Core(TM) i7-2600 3.40 GHz CPU with 4 phys- ical cores with Hyper-Threading (HT) technology [17]. The system has 16 GB of RAM and runs Ubuntu 11.04 (x86 64 GNU/Linux, 2.6.38-16-generic #67-Ubuntu SMP). HT works by duplicating some parts of the processor except the main execution units. From the point of view of the Operating System, each physical processor core corresponds to two logical processors. Many studies from Intel and others have shown that when HT is available, many multi- threaded applications can have a performance boost in the range from 16 to 28% [17]. The algorithms have been implemented in C and compiled with gcc version 4.5.2 using the -O3 flag. The SBM algorithm has been implemented according to the improved version described in [7, Section 4.2], which is more efficient than the basic version shown in Algorithm 3. The parallel versions of BF and ITM have been obtained from the sequential implementation by enabling OpenMP [18] directives in the code. The performance metric of interest is the total (wall clock) execution time needed to compute the intersection matrix; this time always includes any preprocessing (e.g., the time required by ITM to build the Interval Tree or the time needed by SBM to sort the vector of endpoints). Each measure is the average of 30 independent executions, in order to get statistically valid results. To foster the reproducibility of our experiments, all the source code used in this performance evaluation, and the raw data obtained in the experiments execution, are freely available on the research group web- site [19] with a Free Software license. Sequential implementation: We start by comparing the performance of the sequential implementations of BF, SBM and ITM. Figure 4 shows the total execution time of each algorithm as a function of the number of extents N , with low, medium and high overlapping degrees α. The vertical scale has been set to allow an easier com- parison of SBM and ITM; since Brute Force is the slower algorithm, its execution time goes quickly out of scale. We see that ITM is faster than SBM, but the gap between them tend to close as the overlapping degree α grows. We also observe that the execution time of SBM is unaffected by the value of α, which is expected by observing in Table I that its cost does not depend on K. Parallel implementation: We now study the perfor- mance of a parallel implementation of ITM. As stated in Section IV, ITM can be trivially parallelized using a multi- thread implementation in which each thread is assigned a subset of the queries. Parallel versions of ITM and BF have been obtained by enabling OpenMP directives in the source code. To the best of our knowledge no parallel versions of SBM have been proposed, and as explained in Section III the sequential step of SBM is affected by a loop-carried dependency which can not be easily avoided. Figure 5 shows the execution time of the sequential SBM with three configurations of ITM in which a different number of concurrent threads is used. We consider the case in which α = 100, corresponding the the scenario depicted in Figure 4(c). As expected, the parallel ITM can exploit multiple processor cores to increase the gap from SBM. The practical effect is that ITM remains competitive for larger number of intersections. To understand the scalability of the parallel version of ITM we compute the speedup Sp as a function of the number p of execution threads, where Sp is defined as the ratio of the execution time of the sequential implementation and the execution time with p threads. Figure 6 shows the speedup of parallel BF and paral- lel ITM. Despite its inefficiency in terms of wall-clock time, BF has been considered here because it is so easily paral- ) . c e s ( e m i t n o i t u c e x E 8 7 6 5 4 3 2 1 0 Scalability evaluation, α=100 SBM (sequential) parallel ITM, 2 threads parallel ITM, 4 threads parallel ITM, 8 threads 50 100 150 250 200 350 Number of extents x 103 300 400 450 500 Figure 5. Execution time of SBM (sequential) and ITM (parallel), α = 100, lower is better p u d e e p S 8 7 6 5 4 3 2 1 Speedup, α=100, 500 x 103 extents linear speedup parallel BF parallel ITM 2 4 6 8 Number of threads 10 12 Figure 6. extents, α = 100, higher is better Speedup of parallel BF and parallel ITM, N = 500 × 103 lelizable that it provides baseline values for the speedup. Interestingly, ITM scales better than BF; this is probably due to the improved locality achieved by the Interval Tree, since the intervals stored by the nodes near the root are likely kept in cache. Figure 6 shows also the effect of HT: when the number of threads p is the in the range 1, . . . , 4 each execution thread is allocated on a dedicated physical core. When the number of threads exceeds the number of physical cores, then multiple threads are allocated to the same core. As said before, HT does provide a performance boost, but unfortunately not comparable to that provided by an actual physical core with independent execution units. The speedup drops when the number of threads exceeds the number of logical cores. Finally, Figure 7 summarizes the execution time of paral- lel ITM over a range of overlapping degrees (0 < α ≤ 100) and for an increasing number of extents (from 50 × 103 to 500 × 103). The plot supports the fact that the running time ) . c e s ( e m i t n o i t u c e x E 8 7 6 5 4 3 2 1 0 50 100 150 BF SBM ITM 400 450 500 ) . c e s ( e m i t n o i t u c e x E 8 7 6 5 4 3 2 1 0 50 100 150 BF SBM ITM 400 450 500 ) . c e s ( e m i t n o i t u c e x E 8 7 6 5 4 3 2 1 0 50 100 150 250 200 350 Number of extents x 103 300 BF SBM ITM 400 450 500 250 200 350 Number of extents x 103 300 250 200 350 Number of extents x 103 300 (a) α = 0.01 (b) α = 1 (c) α = 100 Figure 4. Execution time in seconds as a function of the number N of extents (lower is better). The vertical linear scale, as opposed to logarithmic scale, has been defined to allow easier comparison between SBM and ITM ) ) . . c c e e s s ( ( e e m m i i t t n n o o i i t t u u c c e e x x E E 0.5 0.45 0.4 0.35 0.3 0.25 0.2 0.15 0.1 0.05 0 0 10 20 30 40 50 60 70 80 90 100 α 50 450 350 250 Number of extents x 103 150 Figure 7. Execution time of parallel ITM, 8 execution threads, lower is better of ITM depends on both the number of matches K and the input size N ; in our experiments the value of K is directly correlated with the overlap factor α, hence the shape of the graph. VI. CONCLUSIONS AND FUTURE WORKS In this paper we described ITM, a parallel algorithm based on Interval Trees that can be used to solve the d-rectangle intersection problem for DDM. ITM uses an augmented AVL tree data structure to store a set of intervals, allowing fast intersection queries. ITM is of practical interest since it can be implemented quite easily; a prototype has been built and is available at [19]. Both the sequential and the parallel implementation of ITM has been evaluated experi- mentally; the results show that the sequential implementation of ITM compares favorably with Sort-Based Matching, the current best solution to the DDM matching problem. The parallel version of ITM shows good scalability, achieving a 5 speedup on a four core, hyperthreaded Intel i7 processor. We are currently extending the ITM prototype as de- scribed in Section IV to solve the dynamic DDM matching problem, where extents can be moved or resized dynami- cally. Furthermore, we are including support for ITM in the GAIA/ART`IS parallel simulation middleware [20]. This will allow us to test ITM in real simulation models, to further assess its performance. ACKNOWLEDGMENT The authors would like to thank Piero Fariselli for kindly providing the server on which the experimental evaluation described in Section V has been done. NOTATION Subscription set S = {S1, . . . , Sn} S := U := Update set U = {U1, . . . , Um} n := Number of subscription extents m := Number of update extents N := Total number of subscription and update extents M := K := Number of intersections, K ≤ nm α := Overlapping degree n × m intersection matrix REFERENCES [1] "IEEE Standard for Modeling and Simulation (M&S) High Level Architecture (HLA) -- Framework and Rules," IEEE Std 1516-2010 (Rev. of IEEE Std 1516-2000), pp. 1 -- 38, 2010. [2] J. Rosenberg, "Geographical data structures compared: A study of data structures supporting region queries," Computer- Aided Design of Integrated Circuits and Systems, IEEE Trans- actions on, vol. 4, no. 1, pp. 53 -- 67, 1985. [3] A. Guttman, "R-trees: a dynamic index structure for spatial searching," SIGMOD Rec., vol. 14, no. 2, pp. 47 -- 57, Jun. 1984. [4] TILERA: Family, http://www.tilera.com/products/processors/TILE-Gx Family, 2013. Processor TILE-Gx [5] M. Petty and A. Mukherjee, "Experimental comparison of d-rectangle intersection algorithms applied to HLA data dis- tribution," in Proceedings of the 1997 Distributed Simulation Symposium, 1997, pp. 13 -- 26. [6] F. Devai and L. Neumann, "A rectangle-intersection algorithm with limited resource requirements," in Proc. 10th IEEE Int. Conf. on Computer and Information Technology, ser. CIT '10. Washington, DC, USA: IEEE Computer Society, 2010, pp. 2335 -- 2340. [7] C. Raczy, G. Tan, and J. Yu, "A sort-based DDM matching algorithm for HLA," ACM Trans. Model. Comput. Simul., vol. 15, no. 1, pp. 14 -- 38, Jan. 2005. [8] K. Pan, S. J. Turner, W. Cai, and Z. Li, "A dynamic sort-based DDM matching algorithm for HLA applications," ACM Trans. Model. Comput. Simul., vol. 21, no. 3, pp. 17:1 -- 17:17, Feb. 2011. [9] J. Ahn, C. Sung, and T. G. Kim, "A binary partition- based matching algorithm for data distribution management," in Simulation Conference (WSC), Proceedings of the 2011 Winter, 2011, pp. 2723 -- 2734. [10] R. M. Layer, K. Skadron, G. Robins, I. M. Hall, and A. R. Quinlan, "Binary interval search (BITS): A scalable algorithm for counting interval intersections," Bioinformatics, 2012. [11] A. Boukerche and C. Dzermajko, "Performance comparison of data distribution management strategies," in Proc. 5th IEEE Int. Workshop on Distributed Simulation and Real-Time Applications, ser. DS-RT '01. Washington, DC, USA: IEEE Computer Society, 2001, pp. 67 -- . [12] R. Cole, "Parallel merge sort," SIAM Journal on Computing, vol. 17, no. 4, pp. 770 -- 785, 1988. [13] E. M. McCreight, "Priority search trees," SIAM J. Comput., vol. 14, no. 2, pp. 257 -- 276, 1985. [14] G. Adelson-Velskii and E. M. Landis, "An Algorithm for the Organization of Information," Doklady Akademii Nauk USSR, vol. 146, no. 2, pp. 263 -- 266, 1962. [15] T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein, Introduction to Algorithms (3. ed.). MIT Press, 2009. [16] L. J. Guibas and R. Sedgewick, "A dichromatic framework for balanced trees," in Foundations of Computer Science, 1978., 19th Annual Symposium on, 1978, pp. 8 -- 21. [17] D. T. Marr, F. Binns, D. L. Hill, G. Hinton, D. A. Koufaty, A. J. Miller, and M. Upton, "Hyper-Threading Technology Architecture and Microarchitecture," Intel Technology Jour- nal, vol. 6, no. 1, Feb. 2002. [18] L. Dagum and R. Menon, "OpenMP: An industry-standard [API for shared-memory programming," IEEE Comput. Sci. Eng., vol. 5, pp. 46 -- 55, January 1998. [19] "Parallel And Distributed Simulation (PADS) research group," http://pads.cs.unibo.it, 2013. [20] L. Bononi, M. Bracuto, G. D'Angelo, and L. Donatiello, "A new adaptive middleware for parallel and distributed simulation of dynamically interacting systems," in Proc. 8th IEEE Int. Symp. on Distributed Simulation and Real-Time Applications. Washington, DC, USA: IEEE Computer Society, 2004, pp. 178 -- 187.
1502.00911
3
1502
2016-11-23T11:20:47
Multicuts in Planar and Bounded-Genus Graphs with Bounded Number of Terminals
[ "cs.DS", "cs.CG" ]
Given an undirected, edge-weighted graph G together with pairs of vertices, called pairs of terminals, the minimum multicut problem asks for a minimum-weight set of edges such that, after deleting these edges, the two terminals of each pair belong to different connected components of the graph. Relying on topological techniques, we provide a polynomial-time algorithm for this problem in the case where G is embedded on a fixed surface of genus g (e.g., when G is planar) and has a fixed number t of terminals. The running time is a polynomial of degree O(sqrt{g^2+gt}) in the input size. In the planar case, our result corrects an error in an extended abstract by Bentz [Int. Workshop on Parameterized and Exact Computation, 109-119, 2012]. The minimum multicut problem is also a generalization of the multiway cut problem, a.k.a. multiterminal cut problem; even for this special case, no dedicated algorithm was known for graphs embedded on surfaces.
cs.DS
cs
Multicuts in Planar and Bounded-Genus Graphs with Bounded Number of Terminals∗ ´Eric Colin de Verdi`ere† July 29, 2018 Abstract 6 1 0 2 v o N 3 2 ] S D . s c [ 3 v 1 1 9 0 0 . 2 0 5 1 : v i X r a Given an undirected, edge-weighted graph G together with pairs of vertices, called pairs of terminals, the minimum multicut problem asks for a minimum-weight set of edges such that, after deleting these edges, the two terminals of each pair belong to different connected components of the graph. Relying on topological techniques, we provide a polynomial-time algorithm for this problem in the case where G is embedded on a fixed surface of genus g (e.g., when G is planar) and has a fixed number t of terminals. The running time is a polynomial of degree O(cid:0)(cid:112)g2 + gt(cid:1) in the input size. In the planar case, our result corrects an error in an extended abstract by Bentz [Int. Workshop on Parameterized and Exact Computation, 109 -- 119, 2012]. The minimum multicut problem is also a generalization of the multiway cut problem, a.k.a. multiterminal cut problem; even for this special case, no dedicated algorithm was known for graphs embedded on surfaces. 1 Introduction The minimum cut problem is one of the most fundamental problems in combinatorial optimization (see Schrijver [34] for a fascinating historical account), originally introduced in relation to railway transshipment problems during the cold war [22]. In this context, the railway network is modeled by a planar graph, each edge having a weight (its capacity), and the goal is to compute the minimum-weight set of edges that need to be removed to disconnect two given vertices of the network, the source and destination for a given commodity. While countless generalizations of this problem have been studied, we are interested here in two natural extensions: 1. What if there are several commodities, corresponding to different source and destination pairs? In other words, we are studying an instance of the minimum multicut problem: Given several pairs of source and destination vertices, how to find a minimum-weight set of edges to disconnect every destination vertex from its corresponding source? 2. What if the network is not planar, but includes a few tunnels and bridges? In other words, what happens if the graph is embedded, not in the plane, but on some fixed surface? More formally, let G = (V, E) be an undirected graph. Furthermore, let T be a subset of vertices of G, called terminals, and let R be a set of unordered pairs of vertices in T , called terminal pairs. A subset E(cid:48) of E is a multicut (with respect to (T, R)) if for every terminal pair {t1, t2} ∈ R, the vertices t1 and t2 are in different connected components of the graph (V, E \ E(cid:48)). In the minimum multicut problem (also known as the minimum multiterminal cut problem), we assume in addition that G is positively edge-weighted, and the goal is to find a multicut of minimum weight. We prove that this problem is polynomial-time solvable if G is embedded on a fixed surface and the number t of terminals is fixed. More precisely: ∗Work supported by the French ANR Blanc project ANR-12-BS02-005 (RDAM). †CNRS, Laboratoire d'Informatique Gaspard Monge, Marne-la-Vall´ee, France. [email protected]. Part of this work was done while the author was at CNRS, D´epartement d'informatique, ´Ecole normale sup´erieure, Paris, France. 1 √ Theorem 1.1. Assume that G is cellularly embedded on a surface (orientable or not) of Euler genus g. g2+gt) time, where t = T is Then the minimum multicut problem can be solved in (g + t)O(g+t)nO( the number of terminals and n is the number of edges of G. This is the first polynomial-time algorithm for this purpose, even when specialized to either the t) dependence multiway cut problem (see below for details) or the planar version. Moreover, the nO( in the number of terminals is unavoidable, assuming the Exponential Time Hypothesis [30], even in these two special cases. √ Comparison with Former Work Many instances of the minimum multicut problem are hard, even in very restricted cases. In particular, it is NP-hard in unweighted binary trees [7] and unweighted stars [20, Theorem 3.1], and even APX-hard in the latter case. In the case where the number of pairs of terminals is fixed and at least three, Dahlhaus et al. [14] have proved that the problem is APX-hard in general graphs; nonetheless, it becomes polynomial-time solvable for bounded-treewidth graphs, as proved by Bentz [2, Theorem 1], and fixed parameter tractable in the size of the solution for unweighted graphs [6]. The problem is even harder for directed graphs [2]. In the case where the graph is planar, the number of terminals is fixed, and they all lie on the outer face, Bentz [3] has given a polynomial-time algorithm for the minimum multicut problem. More recently [4], he has announced an algorithm for the same case, but removing the condition that the terminals lie on the outer face. Unfortunately, his proof has several flaws, leaving little hope for repair (see Appendix A). We give a faster algorithm that also works for graphs on arbitrary surfaces. A special case that is somewhat more tractable is the multiway cut problem (a.k.a. the multi- terminal cut problem); this is the case where the set of pairs of terminals comprises all possible pairs of distinct vertices in the set of terminals T ⊂ V . In the planar case, Dahlhaus et al. [14] have proved that it is still NP-hard, but Bateni et al. [1] have given a polynomial-time approximation scheme. Again in the planar case, the problem is also polynomial-time solvable if the number of terminals is fixed, as proved in the early 1990s [14, 23]. In stark contrast, the complexity of the multicut problem has remained open until now, although it is a very natural generalization of the multiway cut problem (the multicut problem is "dual" to the multicommodity flow problem, largely studied [33, Chapters 70 -- 76]). More recently, Klein and Marx have shown that the planar multiway cut problem can be solved in 2O(t)nO( t)- dependence is the best one could hope for, assuming the Exponential Time Hypothesis (ETH) [30]. Our algorithm is more general since it deals with multicut, not multiway cut, and works on arbitrary surfaces; its running time, for fixed genus, is tO(t)nO( t); while the tO(t) factor is slightly worse than the 2O(t) of Klein and Marx, the second factor is the same, and optimal unless ETH is false. Since approximability in the planar case is very different for multicut and multiway cut, our result is surprising, since it shows that, as far as exact computation is concerned, both are (essentially) equally hard. t) time (where n is the complexity of the graph) [26]; Marx has proved that the nO( √ √ √ As a side note, it is easy to see that, to solve the multicut problem, it suffices to guess the partition of the terminals into connected components, and to solve a multiway cut problem in a higher genus surface. However, this reduction is not useful here, since we would get a worse dependence in t if we were to prove the result for multiway cut on surfaces and use this reduction. On the other hand, graph algorithms dedicated to graphs embedded on a fixed surface have flourished during the last decade. One reason is that many graphs arising in geometric settings are naturally embedded on a surface; another one is that the family of graphs embeddable on a fixed surface is closed under minor, and such studies can be seen as a first step towards efficient algorithms for minor-closed families. This line of research is also justified by the fact that testing whether a graph of complexity n embeds on a surface of genus g can be done efficiently in the complexity of the graph, namely, in 2O(g)n time [31]. However, the history of flow and cut problems for graphs embedded on surfaces is rather short. Chambers et al. [9] have given an algorithm to compute a minimum cut in a graph embedded on an orientable surface of genus g that runs in gO(g)n log n time; a very different algorithm by Erickson and Nayyeri [17] runs in 2O(g)n log n time. Thus, the minimum cut problem is solvable in near-linear time on graphs embeddable on a fixed orientable surface. Algorithms 2 are also available for computing global minimum cuts [16] and maximum flows [10] for graphs on surfaces. To our knowledge, we present here the first algorithm for the minimum multicut problem (or even the multiway cut problem) for surface-embedded graphs. The main tool for flows and cuts on surfaces [9, 10, 16, 17] is homology, which is the appropriate algebraic formalism for dealing with graphs separating two given vertices, but it appears to be insufficient in the multicommodity case. Overview and Discussion of Proof Techniques The strategy for proving Theorem 1.1 is the following. In Section 3, we first show that a multicut corresponds, in a dual sense, to a graph drawn on S that separates all pairs of terminals; such a graph will be called a multicut dual. Moreover, if the multicut is minimum, then this multicut dual is as short as possible, when distances on S are measured using the cross-metric: namely, the sum of the weights of the edges of G crossed by the multicut dual is minimum. The topological structure of the multicut dual can be described suitably after we cut the surface open into a disk with all terminals on its boundary (Section 4). We then show that this structure is constrained (Section 5), that we can enumerate its various possibilities (Section 6), and (roughly) that, for each of these topologies, we can compute a shortest multicut dual with that topology efficiently (Section 7). At a high level, our approach follows a similar pattern to Klein and Marx [26], since they also rely on enumerating the various candidate topologies for the dual solution and find the optimum solution for each topology separately. This strategy is also present in Dahlhaus et al. [14] and, in a different context, in Chambers et al. [8], which was our initial source of inspiration. The details are, however, rather different. Indeed, Klein and Marx [26] need a reduction to the biconnected case [26, Section 3], which is shortcut in our approach. Also, the structural properties that we develop for the minimum multicut problem are more involved than the known ones for the multiway cut problem; indeed, the solution, viewed in the dual graph, has less structure in the multicut problem than in the multiway cut problem: in the multiway cut case, it has as many faces as terminals, and thus many cycles, whereas for the minimum multicut problem, the possible topologies are more diverse (e.g., an optimal solution could be a single dual cycle). Chambers et al. [8] have developed related techniques for computing a shortest splitting cycle, which have been subsequently reused for other topological and computational problems in planar or surface cases [9, 18, 19]. A key difference, however, is that we extend the method to work with graphs instead of paths or cycles, which makes the arguments more complicated. We need to encode precisely the locations of the vertices and edges of the multicut dual with respect to the cut graph; the cross-metric setting is very convenient for this purpose, since it avoids successive transformations of the input dual graph to mimic cutting along another graph, as done by Klein and Marx [26]. Moreover, our approach also relies on other techniques from computational topology, in particular, homology techniques developed for the single commodity minimum cut problem [9], homotopy techniques for shortest homotopic paths [13, 27], and treewidth techniques for the surface case [15]. Finally, we remark that we are not aware of any significantly simpler proof for the planar case: The construction of Section 4 can be simplified, and Lemma 7.2 is standard in that case, but the overall strategy would be the same. 2 Preliminaries We recall here standard definitions on the topology of surfaces. For general background on topology, see for example Stillwell [35] or Hatcher [24]. For more specific background on the topology of surfaces in our context, see recent articles and surveys on the same topic [12, 13]. In this article, S is a compact, connected surface without boundary; g denotes its Euler genus. Thus, if S is orientable, g ≥ 0 is even, and S is (homeomorphic to) a sphere with g/2 handles attached; if S is non-orientable, S is a sphere with g ≥ 1 disjoint disks replaced by Mobius strips. We consider paths drawn on S. A path p is a continuous map from [0, 1] to S; a loop is a path p such that its two endpoints coincide: p(0) = p(1). A path is simple if it is one-to-one (except, of course, that its endpoints p(0) and p(1) may coincide). We thus emphasize that, contrary to the 3 standard terminology in graph theory, paths may self-intersect. A simple loop is two-sided if it has a neighborhood homeomorphic to an annulus; otherwise, it has a neighborhood homeomorphic to a Mobius strip (which implies that the surface is non-orientable), and is one-sided . All the graphs considered in this article may have loops and multiple edges. A drawing of a graph G on S maps the vertices of G to points on S and the edges of G to paths on S whose endpoints are the images of the incident vertices. An embedding of G is a "crossing-free" drawing: The images of the vertices are pairwise distinct, and the image of each edge is a simple path intersecting the image of no other vertex or edge, except possibly at its endpoints. We will mostly consider graph embeddings on S. A face of an embedding of G on S is a connected component of S minus (the image of) G. A graph is cellularly embedded on S if every face of the graph is an open disk. A cut graph of S is a graph G embedded on S whose unique face is a disk. (In particular, a cut graph has no isolated vertex, unless it is reduced to a single vertex and S is a sphere -- this case does not occur in this paper.) Euler's formula states that, if G is a graph cellularly embedded on S with v vertices, e edges, and f faces, then v − e + f = 2 − g. Algorithmically, we can store graphs cellularly embedded on S by their combinatorial map, which essentially records the cyclic ordering of the edges around each vertex; there are efficient data structures for this purpose [15, 28]. 3 The Cross-Metric Setting In this section, we prove that a minimum multicut corresponds, in an appropriate sense, to a shortest graph satisfying certain properties. We say that a graph H embedded on S is in general position with respect to our input graph G if there are finitely many intersection points between G and H, and each such point corresponds to a crossing between an edge of G and an edge of H. The length of H is the sum, over all crossing points between G and H, of the weight of the corresponding edge of G. Note that an edge of H can cross an edge of G several times, and in such cases, the length of the edge of H is computed by taking into account the multiplicity of intersections. In other words, G is now seen as a graph that provides a discrete (or cross-metric) distance function on S [13]. Algorithmically, we can store a graph H in general position with respect to G by recording the combinatorial map of the overlay of G and H, obtained by adding vertices at each intersection point between G and H and subdividing edges of G and H. In the following, unless noted otherwise, all graphs drawn on S will be in general position with respect to G. Moreover, whenever we consider distances between two points in S (not lying on G) or lengths of paths in S, we implicitly consider them in the above cross-metric sense. In some clearly mentioned cases below (see Proposition 4.1), we will need to consider paths p that are in general position with respect to G, except that some of their endpoints may lie on G. In such cases, the endpoints of p are not taken into account for determining the length of p. A multicut dual is a graph C embedded on S such that, for every pair {t1, t2} ∈ R, the vertices t1 and t2 are in different faces of C. As the terminology suggests, we have the following proposition, which will guide our approach. Proposition 3.1. Let C be a shortest multicut dual. Then the set E(cid:48) of edges of G crossed at least once by C is a minimum multicut. Proof. E(cid:48) is a multicut, because any path in G connecting a pair of terminals {t1, t2} ∈ R must cross the multicut dual, and thus use one edge in E(cid:48). Moreover, the weight of E(cid:48) is at most the length of C. To prove that E(cid:48) is a multicut of minimum weight, it suffices to prove that, for every multicut E(cid:48)(cid:48) with weight w, there exists a multicut dual of length w. Consider the dual graph G∗ that has one vertex inside each face of G and one edge e∗ crossing each edge e of G. The subgraph of G∗ with edge set {e∗ e ∈ E(cid:48)(cid:48)} forms a multicut dual whose length is w. As a side remark, it follows that the minimum multicut problem can be seen as a discrete version of the following topological problem: Given a metric surface S with boundary, and a set R of pairs of 4 boundary components, compute a shortest graph on S that separates every pair of boundaries in R. We are exactly solving this problem in the realm of cross-metric surfaces. 4 Planarization Our algorithm starts by computing a cut graph K of S passing through all the terminals. We will also need some structural properties for K, detailed in the following proposition. If S is the sphere (equivalently, if G is planar), we could take for K a shortest spanning tree of T (with respect to the cross-metric setting), which can be obtained using a simple modification of any algorithm for computing minimum spanning trees in graphs. For the general case, we use a known construction, a so-called greedy system of arcs [8]. The following proposition summarizes the properties that we will use. Proposition 4.1. In O(n log n + (g + t)n) time, we can compute a cut graph K on S, whose O(g + t) vertices contain T , and with O(g + t) edges, each of which is a shortest path on S. Some vertices of K may lie on G (either on vertices or on edges). Proof. We temporarily remove a small disk containing each terminal, the boundary of which crosses each edge of G incident to that terminal exactly once, and crossing no other edge of G. This yields a surface with boundary S(cid:48) that is naturally a cross-metric surface, because the intersection of the image of the graph G with S(cid:48) is also a graph G(cid:48) embedded on S(cid:48). On that surface, we compute a system of arcs [8, Section 5.1], namely, a set of disjoint, simple paths with endpoints on the boundary of S(cid:48) that cut S(cid:48) into a topological disk. Moreover, there are O(g + t) paths (by Euler's formula), and the aforementioned construction guarantees that each path is roughly the "concatenation" of (at most) two shortest paths. More precisely, each path can be split into two shortest paths by inserting a degree-two vertex on an intersection point between e and some edge of G(cid:48). (It is actually a shortest system of arcs [11, Conclusion].) Putting back the disks containing the terminals, and extending the arcs slightly inside these disks to the terminals, we obtain a cut graph K satisfying the desired properties. The number of edges of K is still O(g + t), and the running time is O(n log n + (g + t)n) [8]. At a high level, the algorithm consists in (1) enumerating all possible "topologies" of the multicut dual with respect to K, (2) for each of these possible topologies, computing a shortest multicut dual with that topology, and (3) returning the overall shortest multicut dual. 5 Structural Properties of a Shortest Multicut Dual In this section, we prove some structural properties of a shortest multicut dual. Consider all shortest multicut duals in general position with respect to K ∪ G. Among all these, let C0 be one that crosses K a minimum number of times. We can, without loss of generality, assume that C0 is inclusionwise minimal, in the sense that no edge can be removed from C0 without violating the fact that it is a multicut dual. Of course, we can assume that C0 has no isolated vertex. If C0 has a degree-one vertex, we can "prune" it, by removing it together with its incident edge. If C0 has a degree-two vertex that is not a loop, we can "dissolve" it, by removing it and identifying the two incident edges. Thus, we can assume that C0 has minimum degree at least two, and that every degree-two vertex is the vertex of a connected component that is a loop. 5.1 Crossing Bound We start with an easy consequence of Euler's formula. Lemma 5.1. C0 has O(g + t) vertices and edges. Proof. We first note that each face of C0 contains at least one terminal: Otherwise, let e be an edge incident to a face not containing a terminal; we could remove e without violating the multicut dual 5 (a) (b) (c) (d) (e) p Figure 1: (a): The part of the multicut dual C0 close to e (depicted as a horizontal line). (b): its modified version C(cid:48) 0 obtained by pushing all crossings with e to a single point p. The black lines are the loops in L, the grey ones are the other edges of C(cid:48) 0. (c): The configuration corresponding to a monogon. The disk is shaded. (d): The new configuration to replace (c). (e): This configuration is not a monogon, because of the presence of an obstacle (shown as a star). property (because it would not change which pairs of terminals are separated), contradicting the minimality of C0. Thus, C0 has at most t faces. Let us first assume that every face of C0 is a disk. If C0 contains a degree-two vertex, this means that some connected component of C0 is a loop (cid:96). Since each face of C0 is a disk and S is connected, the graph C0 must be connected, so it equals (cid:96), and the statement of the lemma holds. So we can assume that C0 has minimum degree at least three. Let v, e, and f be the numbers of vertices, edges, and faces of C0; we deduce that 3v ≤ 2e. Combining this with Euler's formula v − e + f = 2 − g and the fact that f ≤ t, we obtain that e = O(g + t), and thus also v = O(g + t), as desired. If some faces of C0 are not disks, we can iteratively extend C0 by adding edges between existing vertices of C0 so that no new face is created but each face is cut into a disk (see, e.g., Chambers et al. [8, proof of Lemma 2.1]; the proof in that article extends verbatim to non-orientable surfaces). Applying the reasoning of the previous paragraph to this new graph yields that it has O(g + t) vertices and edges; this is also true for C0. The main structural property of C0 is isolated in the following lemma: Lemma 5.2. There are O(g + t) crossings between C0 and each edge of K. As in algorithms for other problems using the same approach [8, 9, 18, 19, 26], the proof of this lemma consists of an exchange argument: If C0 crosses an edge of K too many times, we can replace C0 with a no longer multicut dual that crosses K fewer times, contradicting the choice of C0. The proof ultimately boils down to topological considerations. Let us also mention that the only property that we are using on the edges of K is that they are disjoint shortest paths (except possibly at their endpoints). Proof of Lemma 5.2. We focus on a specific edge e of K crossed by C0, forgetting about the others. It is convenient to put an obstacle close to each of the two endpoints of e (since e is a shortest path, its endpoints are distinct). It is also convenient to temporarily look at the situation differently, by forgetting about G and by modifying C0 in the vicinity of e by pushing all crossings of C0 with e to a single point p on e (Figure 1(a, b)). This transforms C0 into another graph C(cid:48) 0 that has p as a new vertex. To prove the lemma, it suffices to prove that the degree of p in C(cid:48) 0 is O(g + t). Moreover, every non-loop edge of C(cid:48) 0 corresponds to one of the two endpoints of an edge of C0, and there are O(g + t) of these by Lemma 5.1. Hence, if we let L be the one-vertex subgraph of C(cid:48) 0 made of the loops of C(cid:48) 0 based at p, it suffices to prove that the number of loops in L is O(g + t). A monogon, resp. a bigon, is a face of L that is, topologically, an open disk with one, resp. two, copies of p on its boundary and containing in its interior no obstacle, no vertex of C0, and no terminal. We first claim that no face of L can be a monogon. Otherwise (Figure 1(c)), some edge e(cid:48) of C0 crosses e twice consecutively, at points x and y say, such that the pieces of e and e(cid:48) between x and y bound a disk containing in its interior no obstacle, no vertex of C0, and no terminal. Since the disk contains no obstacle, the boundary of the disk lies entirely on one side of e, as in Figure 1(c), and other cases such as the one shown in Figure 1(e) cannot occur. Since the disk contains no vertex of C0, it 6 (a) (b) (c) (d) (e) Figure 2: The exchange argument in the two-sided case. The horizontal segment represents edge e of K. The strips are shaded; they represent disks with no terminal, no obstacle, and no piece of C0 in their interior. If the sides of the strips are all on the same side of e, there is a single case (a). Replacing the top configuration of C0 with the bottom configuration (creating two new vertices) still yields a multicut dual (as all pairs of faces that were separated in the top configuration are still separated in the bottom configuration, except possibly for the strips, but these contain no terminal), which is no longer than the original (because e is a shortest path) and has less crossings with K. This is a contradiction with the choice of C0. If the sides of the strips are on different sides of e, we need to distinguish according to four cases (b -- e), depending on how the sides of the strips overlap. In all cases, the same argument shows that we could find a no longer multicut dual with fewer crossings with K, a contradiction. (We could also remark that case (e) is impossible because it involves closed curves in C0 without vertex.) contains no piece of C0 in its interior. We can thus replace the piece of e(cid:48) between x and y with a path that runs along e (Figure 1(d)). This operation does not make e(cid:48) longer, since e is a shortest path; it removes the two intersection points with e and does not introduce other crossings with K. Moreover, since the disk contains no terminal in its interior, the resulting graph is also a multicut dual. This contradiction with the choice of C0 proves the claim. We will prove below that no loop in L can be incident to two bigons. Taking this fact for granted for now, whenever one face of L is a bigon, we remove one of the two incident loops, and iterate until there is no bigon any more. The previous fact implies that these iterations remove at most half of the loops: If L(cid:48) is the remaining set of loops, we have L ≤ 2L(cid:48). Furthermore, L(cid:48) has no monogon or bigon. This latter fact, together with arguments based on Euler's formula, implies that the number of loops in L(cid:48) is O(g + t) [8, Lemma 2.1], because S has Euler genus g, and the total number of obstacles, vertices of C0, and terminals (which are the points that prevent a face that is a disk of degree one or two to be a monogon or bigon) is O(g + t) (Lemma 5.1). (That article considers the orientable case only, but the lemma [8, Lemma 2.1] and its proof extend directly to the non-orientable case.) This implies that L = O(g + t), which proves the lemma. So there only remains to prove that no loop in L can be incident to two bigons. Assume that such a loop exists. On the original surface S, this corresponds to two "strips" glued together, see Figure 2, top: Each strip is bounded by two pieces of e and two pieces of edges of C0, and these two strips share a common piece of edge of C0. Since a bigon contains no obstacle, the sides of the strips contain none of the endpoints of e. Since the interiors of these strips contain no vertex of C0, they contain no piece of C0. If S is assumed to be orientable, there are five possible cases up to symmetry, see Figure 2, top: (a) is the case where each strip has its two sides on the same side of e, (b -- e) are the various cases where each strip has its two sides on opposite sides of e. In each case, we change C0 by modifying some edges and possibly by adding vertices (see Figure 2, bottom). Since e is a shortest path and the new pieces 7 (a) (b) (c) (d) (e) Figure 3: The exchange argument in the one-sided case. The argument is the same as in Figure 2; the sole difference is that the strips are drawn with a "twist". "run along" e, one can check that the resulting graph is no longer than C0; moreover, it crosses K fewer times. Also, each replacement may split some faces of the original graph and attach each of the strips to some of the resulting faces, but pairs of terminals that were initially separated by C0 are still separated by the new graph, which is thus also a multicut dual. This contradicts the choice of C0. If S is non-orientable, there are five other cases, because the loops in L may be one-sided. However, an entirely similar argument as in the previous paragraph (Figure 3) allows to conclude. 5.2 Some Shortest Multicut Dual is Good We now give a more precise description of the intersection pattern between C0 and K, using the properties proved in the previous section. Cutting the surface S along K yields a topological disk D. The boundary ∂D of D corresponds to copies of vertices and edges of K; there are O(g + t) of these. The copies of the vertices of K on ∂D are called the corners of D, while the copies of the edges of K are called the sides of D. The sides of D can be reglued pairwise to obtain S. Let C be a graph on S in general position with respect to K ∪ G. In particular, C0 is such a graph. Cutting S along K transforms the overlay of K and C into a graph U drawn in D (Figure 4(a)): Each edge of that graph corresponds to a piece of an edge of K or of C; each vertex of that graph corresponds to a vertex of K, a vertex of C, or a (four-valent) intersection point between an edge of K and an edge of C. We denote by ¯C the subgraph of U made of the edges corresponding to pieces of edges of C (thus, ¯C lies in the interior of D except possibly for some of its leaves), and by ¯K the subgraph of U made of the edges corresponding to pieces of edges of K (thus, the image of ¯K is the boundary of D). Definition 5.3. We say that C is good if ¯C is the disjoint union of (see Figure 4(a)): • trees with at least one vertex of degree at least two, with all their leaves on ∂D, and • arcs, namely, edges with both endpoints on ∂D, on different sides of ∂D, and, moreover: • there are O(g + t) intersection points between C and each side of ∂D, and • the total number of edges of the trees is O(g + t). Finally, Section 5 can be summarized as follows: Proposition 5.4. Some shortest multicut dual is good. 8 e e a d (a) a d b b c c (b) 1 1 1 3 (c) 1 1 3 1 Figure 4: (a): The surface S, and a (good) graph C, viewed after cutting S along the cut graph K, resulting in a disk D. The trees of ¯C are in thick lines, the arcs being in thin lines. (b) and (c) are used to illustrate the proof of Proposition 6.2: (b) shows the disk D, with vertices on the boundary corresponding to the corners and the leaves of trees of ¯C; arcs connecting the same pair of edges of this polygon are represented by a single arc with an integer indicating their number; (c) represents the dual polygon (compared from (b), every vertex on the boundary is replaced with an edge, and every edge is replaced with a vertex); the arcs correspond to the internal or boundary edges of this dual polygon in thick lines; these edges can be augmented arbitrarily to a weighted triangulation of the dual polygon (the weights of the edges are zero unless noted otherwise). Proof. We prove that C0 is indeed good. If some connected component of ¯C0 contains a cycle, that cycle bounds a disk on S containing no terminal (since the terminals are vertices of K), so we can remove any edge of that cycle without affecting the fact that C0 is a multicut dual; this contradicts the choice of C0. Therefore, ¯C0 is a forest. Since C0 has no degree-zero or degree-one vertex, ¯C0 has no isolated vertex, and any degree-one vertex of ¯C0 lies on ∂D. Any component of ¯C0 that is a single path must have its endpoints on different sides of ¯K; otherwise, we could take an innermost such path and "push it across" the side of ¯C0 its endpoints lie in, using the same argument as in Figure 1(a, b): This would not make C0 longer, and would decrease its number of crossings with K, contradicting the choice of C0. This proves that C0 satisfies the first two points of Definition 5.3. The third and fourth points trivially follow from Lemmas 5.2 and 5.1, respectively. 6 Enumerating Topologies Let C be a good graph on S; recall that the union of ¯K and ¯C forms a connected planar graph U . The topology of C is the data of the combinatorial map of U , where the outer face is distinguished, and the sides are paired. Intuitively, it describes combinatorially the relative positions of C and K. More generally, a topology is the combinatorial map of a connected, planar graph with a distinguished outer face and a pairing of the sides (these are the subpaths of the outer cycle connecting consecutive degree-two vertices). Lemma 6.1. Given a topology, we can determine whether it is the topology of a good graph that is a multicut dual in O((g + t)2) time. Proof. First, we can assume that the topology has complexity O((g + t)2), since otherwise it is not the topology of a good graph. We first check that the outer boundary is a cycle. Then we glue the sides of the outer face according to the pairing. This results in the combinatorial map, on S, of the overlay of C (corresponding to the interior edges of the topology) and K (corresponding to the edges on the outer face -- we can check that the combinatorial map indeed is the same as that of K). All of this takes O((g + t)2) time. Deciding whether C is good is easy in time linear in the size of the topology. Deciding whether C is a multicut dual can also be done in that amount of time: We can determine which elements of T fall 9 into which face of C, since each terminal is a vertex of K, and whether each pair of terminals in R lies in different faces of C. This also implies that whether C is a multicut dual or not is completely determined by its topology. Hence the following terminology: A topology is valid if it is the topology of a good graph that is a multicut dual. The result of this section can now be stated as follows. Proposition 6.2. The number of valid topologies is (g + t)O(g+t); these topologies can be enumerated within the same time bound. Proof of Proposition 6.2. It suffices to prove that there are (g + t)O(g+t) possible topologies for a good graph, and that we can enumerate them within the same time bound, because we can afterwards select the ones that correspond to multicut duals by Lemma 6.1. We first focus on enumerating all the possibilities for the trees of ¯C, forgetting about the arcs. We know that the total number of edges of the forest is O(g + t). Any such forest can be obtained by: • starting with a tree τ with O(g + t) edges where all internal vertices have degree three, • contracting an arbitrary number of edges of that tree, • removing an arbitrary number of edges of that tree. Moreover, to specify exactly the topology for the trees of ¯C, we need to specify the cyclic ordering of the edges around each vertex of τ , and to specify to which side of ¯K each leaf of τ belongs. There are 2O(g+t) possibilities for the choice of the initial tree τ together with the cyclic ordering of the edges around each vertex of τ (this is essentially a Catalan number, counting the number of binary trees). Once this is determined, there are (g + t)O(g+t) possibilities to determine to which side of ¯K each leaf of τ belongs (actually, 2O(g+t), but this refinement is useless here). There remains to choose which of the O(g + t) edges to contract or delete, and to specify to which of the O(g + t) sides of ¯K each leaf of τ belongs. To conclude, there are (g + t)O(g+t) possible choices for the combinatorial map for the union of the trees, which can be enumerated also in (g + t)O(g+t) time. Given such a possibility for the trees, we bound the number of possibilities for choosing the arcs. The O(g + t) leaves of the trees and the corners cut ∂D into O(g + t) intervals. The arcs connect distinct intervals (by definition of a good graph); moreover, the arcs are pairwise disjoint. Consider the dual polygon having one vertex per interval, such that each edge connects two consecutive intervals along ¯K (Figure 4(b, c)). Connect two vertices of the dual polygon by an internal edge of the dual polygon whenever there exists at least one arc connecting the corresponding pair of intervals. Since the arcs are non-crossing, the internal edges do not cross, and form a subset of a triangulation of the dual polygon. There are 2O(g+t) possible triangulations, since the dual polygon has O(g + t) vertices (this is again a Catalan number). To conclude, the number of possibilities for inserting the arcs, assuming the trees have already been chosen, is bounded from above by the number of weighted triangulations of the dual polygon, namely, triangulations where each (internal or boundary) edge bears a non-negative number that encodes the number of arcs of the corresponding type, which is thus O(g + t). This number is (g + t)O(g+t). Moreover, enumerating all these possibilities can be done in the same amount of time. 7 Dealing With Each Valid Topology The strategy for our algorithm is roughly as follows: For each valid topology, we compute a shortest graph C with that topology; then we return the set of edges of G crossed by the overall shortest graph C. Actually, we do not exactly compute an embedding of a shortest graph C; instead, we compute a shortest drawing (possibly with crossings) of the same graph, with some homotopy constraints; in particular, that drawing is no longer than the shortest embedding, and we prove that this also corresponds to a minimum multicut. To get an efficient algorithm, we use dynamic programming on small treewidth graphs [5]. The key proposition is the following. 10 Proposition 7.1. Given a valid topology, we can compute, in nO( weight is at most the length of each multicut dual with that topology. g2+gt) time, some multicut whose √ The following lemma allows to use treewidth techniques for surface-embedded graphs; it seems to be folklore, and is standard in the planar case. √ Lemma 7.2. Given a graph H with p vertices, edges, and faces embedded on a surface of genus g, one can compute in O(p √ p) time a path decomposition of the graph with width O( gp). Proof. We start by removing loops and multiple edges, in time O(p). Note that the resulting graph (still denoted by H) is, as the original one, not necessarily cellularly embedded on the surface S of genus g. However, the combinatorial map given by H defines a cellular embedding of H on the surface S(cid:48) obtained by pasting a disk to each facial walk of H (this idea is recurrent, e.g., in Mohar and Thomassen [32]). The genus g(cid:48) of S(cid:48) is at most that of S. (Indeed, H could be augmented to a graph H(cid:48) cellularly embedded on S by adding edges, without increasing the number of vertices and faces; the cellular embeddings H(cid:48) on S and H on S(cid:48) have the same number of vertices and faces, but the first one has more edges; so S has genus larger than S(cid:48), by Euler's formula.) Let h be the number of vertices of H. Given the embedding of H on S(cid:48), one can compute in O(h) √ time a small, balanced, planar separator A for H: a set of O( gh) vertices whose removal leaves a planar graph with no connected component with more than 2h/3 vertices [15, Theorem 5.1]. (That theorem states only the existence of the separator, but the proof immediately gives a linear-time algorithm, as mentioned in the remark right after its proof.) √ We then compute a path decomposition of the planar graph H(cid:48) := H − A of width O( h(cid:48)) in O(h(cid:48)√ h(cid:48)) time, where h(cid:48) is the number of vertices of H(cid:48), using standard techniques. For example, one can compute a small, balanced, planar separator B for H(cid:48) made of at most c1 h(cid:48) vertices, for some constant c1 [29]; by induction, we can assume that each component of H(cid:48) − B has a path decomposition of width at most 2c2h(cid:48)/3, for some constant c2 to be chosen later; concatenating these paths arbitrarily and adding B to all the nodes of the resulting path gives a path decomposition of H(cid:48) of width at most h(cid:48), which is at most 2c2h(cid:48) if c2 is chosen large enough. By induction, it takes O(h(cid:48)√ 2c2h(cid:48)/3 + c1 h(cid:48)) time to compute this path decomposition explicitly. (Using more advanced techniques [21], and if one is willing to accept an implicit representation of the path decomposition, one can achieve the same result in linear time, but we do not care about this, since this will not improve the running time of the overall algorithm.) Finally, adding A to each node of the path decomposition of H(cid:48) = H − A gives a path decomposition √ of H of width O( √ √ √ gp) in O(p p) time. Let C be a good graph. The crossing sequence of an edge e of C (directed arbitrarily) is the ordered sequence of edges in K crossed by e when walking along e, together with the indication of the orientation of each crossing (more precisely, on which side of the edge of K lies the part of e before the crossing, and on which side lies the part of e after the crossing). Given the topology of C, one can determine the crossing sequence of every edge of C. We say that a drawing C(cid:48) of the (abstract) graph C has the same topology as C if each edge of C(cid:48) has the same crossing sequence as the corresponding edge of C. Lemma 7.3. Let C(cid:48) be a drawing of a multicut dual C with the same topology as C. Then, the set of edges of G crossed by C(cid:48) is a multicut. Proof. Let {t1, t2} ∈ R be a pair of terminals, and let f be the face of C containing t1. The set of edges of C that are incident exactly once to the face of C containing t1 forms an even subgraph C1 of C, in which every vertex has even degree. Moreover, C1 separates t1 from t2. Let C(cid:48) 1 be the drawing of the same subgraph in C(cid:48). To prove our result, it suffices to prove that C(cid:48) 1 also separates t1 from t2, using the fact that the crossing sequences are the same in C1 and C(cid:48) 1. Although intuitive, this fact is non-trivial, and its proof relies on two results involving homology. We will use these results as a black box; in particular, no knowledge of homology is required here. We can assume that C(cid:48) has a finite number of self-intersection points, each of which is a crossing. Therefore, C(cid:48) 1 can be seen as an even graph embedded on S (by adding a new vertex at each crossing 11 between two edges of C(cid:48) 1). Our lemma is implied by two results by Chambers et al. [9], reformulated here in our setting (that paper only considers orientable surfaces, but the two results we use extend immediately to non-orientable surfaces): • if, for every edge e of K, the even graphs C1 and C(cid:48) 1 cross e with the same parity, then they are homologous (over Z/2Z) [9, Lemma 3.4]. In our case, since the crossing sequences are equal, C1 and C(cid:48) 1 are homologous; • an even graph separates t1 from t2 if and only if it is homologous, on the surface S \ {t1, t2}, to a small circle around t1 [9, Lemma 3.1]. Thus, since C1 separates t1 from t2, it is also the case for C(cid:48) 1. Proof of Proposition 7.1. Lemma 7.3 implies that it suffices to compute (the set of edges of G crossed by) a shortest drawing with the given topology. Let us first explain how to achieve this, assuming that the locations of the vertices are prescribed. Let C be any multicut dual with that topology and these vertex locations; we do not know C, but know the crossing sequence of its edges (they are determined by the topology) and the vertex locations (they are prescribed). To achieve our goal, it suffices, for each edge e of C, to compute a shortest path with the same crossing sequence as e and the same endpoints. We remark that algorithms for computing a shortest homotopic path in S minus the vertex set of K precisely achieve this goal [13]: In short, we glue copies of the disk D according to the specified crossing sequence, in such a way that edge e "lifts" to that space Se; then we compute a shortest path in Se connecting the same endpoints as that lift, and "project" back to S. (We can assign infinitesimal crossing weights to the edges of K to ensure that the crossing sequences of e and e(cid:48) are the same.) The complexity of D (with its internal structure defined by the edges of G) is O((g + t)n), and the crossing sequences have total length O((g + t)2), so the total complexity of the spaces Se is O((g + t)3n). Since Se is planar, and since shortest paths can be computed in linear time in planar graphs [25], this is also the complexity of computing (the set of edges of G crossed by) a shortest graph drawing with a given topology and specified vertex locations. To compute a shortest drawing with the given topology, over all choices of vertex locations, we can naıvely enumerate all possible locations of the O(g + t) vertices. Note that it is only relevant to consider which face of the overlay of G and K each vertex belongs to, and there are O((g + t)n) such faces. This yields an nO(g+t)-time algorithm. To get a better running time, we use treewidth techniques, also used by Klein and Marx in the planar multiway cut case [26]. The (abstract) graph C defined by the specified topology has O(g + t) vertices and is embedded on a surface with genus g. Lemma 7.2 gives us, in (g + t)O(1) time, a path decomposition of C of width O((cid:112)g2 + gt). We use standard dynamic programming on the path decomposition (rooted, e.g., at one of its endpoints). More precisely, at each node N of the path, we have a table that indicates, for every choice of the locations of the vertices in N , the length of the shortest drawing of the subgraph of C induced by the vertices in N and its descendents, among those that respect the crossing sequence constraints. We can fill in the tables by a bottom-up traversal of the path decomposition. Since each node contains O((cid:112)g2 + gt) vertices, the running time of the algorithm is nO( g2+gt). √ We can now conclude the proof of Theorem 1.1: Proof of Theorem 1.1. We compute the cut graph K in O(n log n+(g +t)n) time (Proposition 4.1), and √ enumerate all valid topologies in (g + t)O(g+t) time (Proposition 6.2). For each valid topology, we apply the algorithm of Proposition 7.1 in nO( g2+gt) time, and return a shortest multicut found. Therefore, the overall running time is O((g + t)O(g+t)nO( g2+gt). The correctness is easy: By Proposition 3.1, it suffices to compute a multicut whose weight is at most the length of any multicut dual. By Proposition 5.4, some shortest multicut dual has a valid topology; when this topology is chosen in the course of the algorithm, Proposition 7.1 guarantees that we have computed a shortest multicut. √ 12 Acknowledgments Many thanks to C´edric Bentz for several helpful discussions on his manuscript [4]. Thanks also to Claire Mathieu for an inspiring discussion in the preliminary stage of this paper, to Arnaud de Mesmay for a useful remark, and to the anonymous referees for their detailed reports, one of them suggesting that an improvement might be possible with the treewidth technique of Klein and Marx [26]. References [1] MohammadHossein Bateni, MohammadTaghi Hajiaghayi, Philip N. Klein, and Claire Mathieu. A polynomial-time approximation scheme for planar multiway cut. In Proceedings of the 23rd Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 639 -- 655, 2012. [2] C´edric Bentz. On the complexity of the multicut problem in bounded tree-width graphs and digraphs. Discrete Applied Mathematics, 156(10):1908 -- 1917, 2008. [3] C´edric Bentz. A simple algorithm for multicuts in planar graphs with outer terminals. Discrete Applied Mathematics, 157:1959 -- 1964, 2009. [4] C´edric Bentz. A polynomial-time algorithm for planar multicuts with few source-sink pairs. In International Workshop on Parameterized and Exact Computation, pages 109 -- 119, 2012. Also in arXiv:1206.3999. [5] Hans Bodlaender. Dynamic programming on graphs with bounded treewidth. In Proceedings of the 15th International Colloquium on Automata, Languages and Programming (ICALP), 1988. [6] Nicolas Bousquet, Jean Daligault, and St´ephan Thomass´e. Multicut is FPT. In Proceedings of the 43rd Annual ACM Symposium on Theory of Computing (STOC), pages 459 -- 468, 2011. [7] Gruia Calinescu, Cristina G. Fernandes, and Bruce Reed. Multicuts in unweighted graphs and digraphs with bounded degree and bounded tree-width. Journal of Algorithms, 48:333 -- 359, 2003. [8] Erin W. Chambers, ´Eric Colin de Verdi`ere, Jeff Erickson, Francis Lazarus, and Kim Whittlesey. Splitting (complicated) surfaces is hard. Computational Geometry: Theory and Applications, 41(1 -- 2):94 -- 110, 2008. [9] Erin W. Chambers, Jeff Erickson, and Amir Nayyeri. Minimum cuts and shortest homologous cycles. In Proceedings of the 25th Annual Symposium on Computational Geometry (SOCG), pages 377 -- 385. ACM, 2009. [10] Erin W. Chambers, Jeff Erickson, and Amir Nayyeri. Homology flows, cohomology cuts. SIAM Journal on Computing, 41(6):1605 -- 1634, 2012. [11] ´Eric Colin de Verdi`ere. Shortest cut graph of a surface with prescribed vertex set. In Proceedings of the 18th European Symposium on Algorithms (ESA), part 2, number 6347 in Lecture Notes in Computer Science, pages 100 -- 111, 2010. [12] ´Eric Colin de Verdi`ere. Topological algorithms for graphs on surfaces. Habilitation thesis, ´Ecole normale sup´erieure, 2012. Available at http://monge.univ-mlv.fr/~colinde/pub/12hdr.pdf. [13] ´Eric Colin de Verdi`ere and Jeff Erickson. Tightening nonsimple paths and cycles on surfaces. SIAM Journal on Computing, 39(8):3784 -- 3813, 2010. [14] Elias Dahlhaus, David S. Johnson, Christos H. Papadimitriou, Paul D. Seymour, and Mihalis Yannakakis. The complexity of multiterminal cuts. SIAM Journal on Computing, 23(4):864 -- 894, 1994. [15] David Eppstein. Dynamic generators of topologically embedded graphs. In Proceedings of the 14th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 599 -- 608, 2003. 13 [16] Jeff Erickson, Kyle Fox, and Amir Nayyeri. Global minimum cuts in surface embedded graphs. In Proceedings of the 23rd Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1309 -- 1318, 2012. [17] Jeff Erickson and Amir Nayyeri. Minimum cuts and shortest non-separating cycles via homology covers. In Proceedings of the 22nd Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1166 -- 1176, 2011. [18] Jeff Erickson and Amir Nayyeri. Shortest non-crossing walks in the plane. In Proceedings of the 22nd Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 297 -- 308, 2011. [19] Kyle Fox. Shortest non-trivial cycles in directed and undirected surface graphs. In Proceedings of the 24th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 352 -- 364, 2013. [20] Naveen Garg, Vijay V. Vazirani, and Mihalis Yannakakis. Primal-dual approximation algorithms for integral flow and multicut in trees. Algorithmica, 18:3 -- 20, 1997. [21] Michael T. Goodrich. Planar separators and parallel polygon triangulation. Journal of Computer and System Sciences, 51(3):374 -- 389, 1995. [22] T. E. Harris and F. S. Ross. Fundamentals of a method for evaluating rail net capacities. Technical Report Research Memorandum RM-1573, The RAND Corporation, Santa Monica, California, 1955. [23] David Hartvigsen. The planar multiterminal cut problem. Discrete Applied Mathematics, 85:203 -- 222, 1998. [24] Allen Hatcher. Algebraic topology. Cambridge University Press, 2002. Available at http: //www.math.cornell.edu/~hatcher/. [25] Monika R. Henzinger, Philip Klein, Satish Rao, and Sairam Subramanian. Faster shortest-path algorithms for planar graphs. Journal of Computer and System Sciences, 55(1, part 1):3 -- 23, 1997. [26] Philip N. Klein and D´aniel Marx. Solving planar k-terminal cut in O(nc In Proceedings of the 39th International Colloquium on Automata, Languages and Programming (ICALP) volume 1, pages 569 -- 580, 2012. √ k) time. [27] Martin Kutz. Computing shortest non-trivial cycles on orientable surfaces of bounded genus in almost linear time. In Proceedings of the 22nd Annual Symposium on Computational Geometry (SOCG), pages 430 -- 438. ACM, 2006. [28] S´ostenes Lins. Graph-encoded maps. Journal of Combinatorial Theory, Series B, 32:171 -- 181, 1982. [29] Richard J. Lipton and Robert Endre Tarjan. A separator theorem for planar graphs. SIAM Journal on Applied Mathematics, 36(2):177 -- 189, 1979. [30] D´aniel Marx. A tight lower bound for planar multiway cut with fixed number of terminals. In Proceedings of the 39th International Colloquium on Automata, Languages and Programming (ICALP) volume 1, pages 677 -- 688, 2012. [31] Bojan Mohar. A linear time algorithm for embedding graphs in an arbitrary surface. SIAM Journal on Discrete Mathematics, 12(1):6 -- 26, 1999. [32] Bojan Mohar and Carsten Thomassen. Graphs on surfaces. Johns Hopkins Studies in the Mathematical Sciences. Johns Hopkins University Press, 2001. [33] Alexander Schrijver. Combinatorial optimization. Polyhedra and efficiency, volume 24 of Algorithms and Combinatorics. Springer-Verlag, Berlin, 2003. 14 [34] Alexander Schrijver. On the history of combinatorial optimization (till 1960). In Handbook of Discrete Optimization, pages 1 -- 68. Elsevier, 2005. [35] John Stillwell. Classical topology and combinatorial group theory. Springer-Verlag, New York, second edition, 1993. A Problems with Bentz' Approach in the Planar Case Here, we show several flaws in Bentz' approach [4] for the planar version of the problem, which leaves little hope for repair. Bentz starts by guessing the clusters, namely, the partition of the terminals induced by the faces of the optimal multicut dual, and enumerates all possibilities for the locations of the vertices of the multicut dual that have degree at least three. (He does so in the dual graph, while we do it in the cross-metric setting to keep track of the crossings between the multicut dual and the cut graph, but this is the same idea.) Then, his strategy is to consider all the possible homotopy classes of the closed walks Ci that bound a face of the multicut dual containing the terminals of a given cluster i. Unfortunately, it is dubious that this strategy could work; at least, the enumeration of the homotopy classes has to be substantially more complicated than described in his article, and one would need to consider the homotopy classes of the edges of the multicut dual, not only of the closed walks Ci. In more detail: • In Lemma 3, it is claimed that two cycles are homotopic in the plane minus a set of terminals if and only if they enclose the same terminals in their interior. This is not the case (see Figure 5). In particular, as soon as there is more than two terminals, the number of homotopy classes is infinite; • Lemma 5 claims the following: Assume that Ci passes through vertices ω1, . . . , ωqi of the multicut dual. Then we still have a multicut dual if we replace Ci with any cycle C(cid:48) i going through ω1, . . . , ωqi that encloses the same set of terminals as Ci. This is not the case, as Figure 6 demonstrates. (Actually, Lemma 5 makes a slightly stronger claim, which is also contradicted by that figure.) For the same reason, Corollary 1 does not hold. These counterexamples show that it is not sufficient to determine whether cycles are valid (can be part of a multicut dual) based only on which terminals they enclose (although this would indeed be very nice, since the number of such possibilities is nO(t)). We really need to consider the homotopy classes of the paths, and to bound their number. This is exactly the purpose of Lemma 5.2 in our technique. Figure 5: Two non-homotopic cycles enclosing the same set of terminals. 15 Figure 6: In a multicut dual, replacing a cycle (in thick lines) with another cycle passing through the same vertices and enclosing the same terminals does not always give a multicut dual. 16
1012.0259
1
1012
2010-12-01T18:00:01
(\alpha, \beta) Fibonacci Search
[ "cs.DS" ]
Knuth [12, Page 417] states that "the (program of the) Fibonaccian search technique looks very mysterious at first glance" and that "it seems to work by magic". In this work, we show that there is even more magic in Fibonaccian (or else Fibonacci) search. We present a generalized Fibonacci procedure that follows perfectly the implicit optimal decision tree for search problems where the cost of each comparison depends on its outcome.
cs.DS
cs
(α, β) Fibonacci Search Pavlos S. Efraimidis Department of Electrical and Computer Engineering, Democritus University of Thrace, Building A University Campus, 67100 Xanthi, Greece [email protected] Abstract. Knuth [12, Page 417] states that "the (program of the) Fi- bonaccian search technique looks very mysterious at first glance" and that "it seems to work by magic". In this work, we show that there is even more magic in Fibonaccian (or else Fibonacci) search. We present a generalized Fibonacci procedure that follows perfectly the implicit opti- mal decision tree for search problems where the cost of each comparison depends on its outcome. 1 Introduction Binary search is the most common algorithm for comparison-based search in sorted arrays in which random access is permitted. The worst-case complexity is logarithmic on the length n of the sequence. A general information-theoretic lower bound based on decision trees shows that any comparison-based search algorithm needs in the worst-case at least logarithmic steps to locate an item in a sorted array. In the analysis of binary search, the cost of each comparison step is usually some fixed constant. However, there are natural problems where the cost of a comparison depends on its outcome. For example, during the search an over- estimation of the unknown value may cost more than an underestimation or the opposite. An interesting example is provided by TCP (Transmission Control Protocol) flows that transmit data over the Internet. Each TCP flow has a pa- rameter called the congestion window, which is used to regulate its transmission rate. A small congestion window will cause the flow to use less than the available bandwidth whereas a large congestion window will cause delays and packet losses in case of overflows. Most TCP flows use the AIMD (Additive Increase Multi- plicative Decrease) algorithm to adjust their congestion window to the current network conditions [11,6]. The cost induced to a TCP flow for underestimating the optimal congestion window differs from the cost of overestimating it. We consider the following toy-example of asymmetric cost binary search. As- sume that we want to experimentally estimate the minimum speed at which the airbags of a particular car will deploy. Assuming that all other parameters of the experiment are held constant (ceteris paribus assumption), we want to identify the minimum speed with one decimal digit precision, at which the airbags de- ploy. We are given the information that the requested minimum speed is in the closed interval 10-20 km/h (interval of uncertainty). Finally, there is asymmetry in the cost of each comparison (crash test). The damage caused by a crash test in the interval of uncertainty is 500e if the airbags do not deploy and 1500e if the airbags open. What is the minimum worst-case cost to identify the requested speed? The solution of this example is given in Section 7. A similar example is the leaky shower problem described in [10]. An amusing example of a closely related search problem is given in the lecture notes of [15]. Given two absolutely identical eggs, how many times do we have to drop an egg to identify how strong the eggs are? In this problem, the unknown value has to be found with at most two overestimates. The cracking eggs problem is an example of asymmetric cost binary search where there is a fixed bound on the number of the outcomes of one type, usually the overestimates. Binary search with a bounded number of overestimates is discussed in [3,16], where it is shown that it is related to binomial trees. In this work, we consider the problem of searching in a sorted array when the cost of each comparison depends on its outcome. For example, in the binary case, each comparison with outcome "≤" has a fixed cost α and each comparison with outcome ">" a fixed cost β. We assume that α and β are integers or rational multiples of each other, such that α ≥ 1 and β ≥ 1. We then generalize the results to the case of searching with more than two outcomes. A problem related to the (binary) search procedure is the construction of (binary) search trees. An O(n) time algorithm to construct a binary search tree for (α, β) binary search is presented in [5]. The results of [5] are based on an interesting relation of the search tree structure to the Pascal's triangle and are valid for any positive numbers β ≥ α > 0. The case of (1, 2) binary search trees is further discussed in [14] where the relation of the (1, 2) binary search problem to the original Fibonacci sequence is identified. Binary trees with choosable edge lengths are discussed in [13]. A general treatment of binary search with asymmetric costs is given in [10]. The costs of binary search in [10] can be real numbers, but the search procedure proposed is only near optimal. The same problem is studied in [9] with tools from dynamic programming. Tree structures for searching with asymmetric costs when the number of outcomes of each comparison may be larger than two is discussed in [4] where optimal lopsided trees are analyzed. The focus of this work is on a lightweight search algorithm for asymmetric cost search and not on the explicit construction of the corresponding search tree. As such, the main contribution of this work is an optimal lightweight search procedure for (α, β) binary search without the explicit construction of the binary search tree. Furthermore, we show that the results of this work are valid for search trees of higher degrees. The generalization of the Fibonacci sequences used in this work seems to naturally fit the search problem and gives simple, optimal results. Even though the problem has been studied in the past, no algorithm that is both optimal with respect to its running time and the cost of the generated solution has been presented. Interestingly, there is an early search algorithm called Fibonacci search or Fibonaccian search [7,12], which uses the classic Fibonacci sequence to lead the item selection procedure in the sorted array1. Fibonacci search is a variation of binary search that avoids the division operations required in binary search to select the middle item. At that early days of computer science a division by two or even a simple shift operation could be an undesirably expensive operation for a computer program. Knuth [12, Page 417] states that "the (program of the) Fibonaccian search technique looks very mysterious at first glance" and that "it seems to work by magic". In this work, we show that there is even more magic in Fibonaccian (or else Fibonacci) search. The generalized Fibonacci procedure of this work follows perfectly the implicit optimal decision tree for search problems where the cost of each comparison depends on its outcome. Contribution. We present (α, β) Fibonacci search, an optimal lightweight search procedure for searching with asymmetric costs. The algorithm is simple and intuitive and the first, to our knowledge, optimal algorithm for a classic problem when the comparison costs are fixed integers or rationally multiples of each other. We define Fibonacci decision trees and use them to prove the information theoretic lower bounds of the search problem. Even though this structure exists implicitly in more general works like [4], its significance for search and decision problems has not been sufficiently stressed so far. Moreover, we present and solve an interesting guessing game with h outcomes per comparison and discuss applications of it in prefix codes. Finally, we present an abstract class definition and an implementation of the search algorithm. The rest of this work is organized as follows: The asymmetric cost search problem is defined in Section 2. In Section 3, Fibonacci-like sequences are de- fined. The lower bound on the worst-case cost is presented in Section 4. The (α, β) Fibonacci search algorithm is described in Section 5. Applications of (α, β) Fibonacci search are presented in Section 6 and a final discussion is given in Sec- tion 7. 2 (α, β) Binary Search The formal definition of the asymmetric binary search problem follows. Definition 1. The (α, β) binary search problem. An array V of n items sorted in increasing order is given. Each item of the array can be accessed in time O(1). For any value x and any item vk of V the cost of the comparison x ≤ vk is cost of (x ≤ vk) = (cid:26) α, β, if the outcome if true, if the outcome is false. Parameters α and β are strictly positive integers. The cost of a search is equal to the sum of the costs of all comparison operations x ≤ vk performed during the search. 1 The term Fibonacci search is also used in the literature for a technique that locates the minimum of a unimodal function in a given interval. See for example [2]. This interpretation of the term Fibonacci search is not related to our work. We assume that the searched item x is in the array V. The results of this work can be extended to searches for items that may not belong to V by comparing at the end of the search the requested item with the item found. Cost and complexity. The cost metric in the search procedure can be used to model diverse criteria. For example in [14] the cost corresponds to computa- tional complexity; underestimation costs one processor operation and overesti- mation two processor operations. The cost can also correspond to other metrics like the budget in the airbags example or some efficiency criterion in the TCP flow example. 3 Sequences In the analysis of the lower bound and the search algorithm for the (α, β) search problem we will use a generalization of Fibonacci sequences. In this Section we provide the necessary definitions of the sequences that we will use. We start with the well-known Fibonacci sequence. Definition 2. The Fibonacci sequence is given by the recurrence relation f (k) = f (k − 1) + f (k − 2) , (1) with initial values f (k) = 0, for k ≤ 0, and f (1) = 1. We define the following generalization of the Fibonacci sequence where each term is the sum of two preceding terms, which however may not be the immediately preceding terms. Definition 3. The (α, β) Fibonacci sequence. Given integers α ≥ 1 and β ≥ 1, the (α, β) Fibonacci sequence is given by the recurrence relation g(k) = g(k − α) + g(k − β) , (2) with initial values, unless otherwise specified, g(k) = 0, for k < 0, and g(0) = 1. The (α, β) Fibonacci sequence is actually a family of generalized Fibonacci se- quences. Some well known sequences that are related to members of the (α, β) Fibonacci family are: • The classic Fibonacci sequence for {α, β} = {1, 2} and initial values f (0) = 0 and f (1) = 1. • The Padovan sequence and the Perrin sequence for {α, β} = {2, 3} and initial values f (0) = f (1) = f (2) = 1 and f (0) = 3, f (1) = 0, f (2) = 2, respectively. Given the parameters α and β of an (α, β) Fibonacci sequence, let ℓ = min{α, β} and u = max{α, β} . (3) In the analysis of the (α, β) binary search problem we will encounter the following sequence, in which the term k of the sequence is equal to the sum of the last ℓ terms of the corresponding (α, β) Fibonacci sequence. Definition 4. Given integers α ≥ 1 and β ≥ 1, let ℓ = min{α, β}. Then let G(k) = ℓ Xi=1 g(k + 1 − i) , (4) where g(k) is the (α, β) Fibonacci sequence. It turns out that the G(k) sequence is also an (α, β) Fibonacci sequence but with its own initial values. Proposition 1. G(k) is an (α, β) Fibonacci sequence. Proof. G(k) = ℓ Xi=1 g(k − i + 1) = ℓ Xi=1 g(k − i + 1 − α) + ℓ Xi=1 g(k − i + 1 − β) (5) ⇒ G(k) = G(k − α) + G(k − β) . (6) The appropriate initial values for G(k) are G(k) = 0 for k < 0 and G(k) = 1 for 0 ≤ k < u. Note that if ℓ = 1 then, as expected, the sequences G(k) and g(k) coincide (for the same parameters α and β). Closed form expressions are known for example for the terms of the classic Fibonacci sequence, the Padovan sequence and the Perrin sequence. Since every member of the (α, β) Fibonacci sequences is defined by a linear recurrence, there exists a closed-form solution for each sequence. However, we are not aware of a general closed form expression for the complete (α, β) Fibonacci family. Closed form estimations of terms of generalized Fibonacci sequences are given for ex- ample in [4,19,9,10]. The following Proposition follows directly from Lemma 1 of [9] and provides upper and lower bounds on the terms of the G(k) Fibonacci sequence. Proposition 2. For strictly positive integers α and β it holds k+1−u u ≤ G(k) ≤ 2 2 k+2−u ℓ . (7) 4 The Lower Bound We present an information-theoretic lower bound on the worst-case cost of the (α, β) binary search problem. Like the known lower bounds for binary search, the approach is based on decision trees. To handle the asymmetry of the comparison costs we define a special type of decision tree. Definition 5. The (α, β) decision tree. The root node of the tree has level 0. Let v be a node at level dv of the tree. Then node v(cid:26) is either a leaf of the tree, or it has a left child at level (dv + α) and a right child at level (dv + β). Note that the term level is used to represent the weighted depth of the tree nodes. Each level of the tree corresponds to a particular cost value. Definition 6. The level of an (α, β) decision tree is the maximum level of any of its nodes. The depth of a node is the common depth of tree nodes, i.e., the number of links from the root to the node. The depth of an (α, β) decision tree is the maximum depth of any of its nodes. The distinguishing property of (α, β) decision trees is that nodes which have the same parent may be located at different tree levels. The general form of an (α, β) decision tree is shown in Figure 1a. Two instances of (α, β) decision trees are presented in Figure 2. 0 α β 0 γ α β (a) An (α, β) decision tree. (b) An h-decision tree for h=3. Fig. 1: Two instances of asymmetric cost decision trees. Proposition 3. The number of nodes at level k of a complete (α, β) decision tree is the value of term g(k) of corresponding (α, β) Fibonacci sequence of Equa- tion 3. Proof. The number of nodes at level k is equal to the sum of the number of nodes at levels (k − α) and (k − β). Furthermore, there is one node at level 0, the root node. Proposition 4. The number of leaf nodes of a complete (α, β) decision tree of level k is G(k), where G(k) is the (α, β) Fibonacci sequence of Equation 4. Proof. The nodes of level k are of course leaf nodes of the tree. Additionally, any node with level in (k − 1), (k − 2), . . . , (k + 1 − ℓ) must also be a leaf node since the node cannot have any descendants with level at most k. Proposition 5. The wort-case cost for an (α, β) binary search problem with n items is at least k, where k is the minimum index such that G(k) ≥ n. Proof. Any search procedure for an (α, β) binary search problem can be rep- resented with a corresponding (α, β) decision tree. The level of the decision tree corresponds to the worst-case cost of the respective search procedure. From Proposition 4 we know that any (α, β) decision tree with level up to k − 1 can have at most G(k − 1) leaves. Hence any search procedure will have worst-case cost at least k, where k is such that G(k) ≥ n. 5 (α, β) Fibonacci Search We propose (α, β) Fibonacci search, an algorithm for the (α, β) binary search problem. The proposed algorithm is a dichotomic search algorithm like binary search but uses the G(k) sequence numbers to dichotomize the item sets and to select the items to be examined. The algorithm is a generalization of Fibonacci search [7] to (α, β) Fibonacci sequences. 5.1 The Algorithm (short version) Algorithm (α, β) Fibonacci search Input: A sorted array V with n items and a requested item x in V . The items in V are indexed from 0 to n − 1. Step 0: (α, β) Fibonacci numbers. Prepare the (α, β) Fibonacci numbers up to index k such that G(k) ≥ n. Step 1: Initializations. Let z = k − α, lef t = 0, right = n − 1. Step 2: Search Loop. While (lef t < right) (a) index = lef t + G(z); if (index > right) then {index = right}; (b) value = v[index] (c) Compare (x ≤ value) true: right = index; z = z − α; false: lef t = index + 1; z = z − β; Step 3: Check if (V [index] == x). This step is only necessary if the requested item x may not belong to V. First the algorithm prepares the sequence of G(k) numbers up to the first term G(k) of the sequence such that G(k) ≥ n. Then, the algorithm enters the search loop. In each round, the algorithm selects either the left subtree or the right subtree of the implicit (α, β) decision tree. If the current subtree has G(z) leaves then the number of leaves of the left tree is G(z − α) and of the right subtree G(z − β). If the current subtree has less than G(z) leaves (if n is not an (α, β) Fibonacci number), then the right subtree will also have less than G(z − β) leaves. 5.2 Complexity and Cost From the description of the (α, β) Fibonacci search algorithm and the lower bound of Section 4, it follows that the worst-case cost of the algorithm is optimal. Proposition 6. The worst-case cost of the (α, β) Fibonacci search algorithm for the (α, β) binary search problem is optimal. Proof. The decision tree of the search algorithm is the (α, β) decision tree used in the proof of the lower bound in Section 4. Hence, the worst-case performance matches the lower bound.        (a) The complete (3, 1) decision tree with level 10. The maximum number of leaves of a (3, 1) decision tree with level 10 is equal to the number of nodes at level 10 of the depicted tree.            ! (b) The complete (3, 2) decision tree with level 10. The maximum number of leaves of a (3, 2) decision tree with level 10 is equal to the number of nodes at levels 9 and 10 of the depicted tree. Fig. 2: Two instances of (α, β) Fibonacci trees with level 10. The dark nodes are the nodes at which the (α, β) Fibonacci search algorithm terminates. We will show that the computational complexity of the (α, β) Fibonacci search algorithm is logarithmic on the number n of the items. Proposition 7. Given an (α, β) binary search problem, the level of the implicit (α, β) decision tree of algorithm (α, β) Fibonacci search is at most u · ⌈log2 n⌉. Proof. (Sketch.) Recall that u = max{α, β}. The worst-case complexity of binary search for the (α, β) binary search problem is ⌈log2 n⌉ = O(log n). Hence, the worst-case cost of binary search is at most u · ⌈log2 n⌉. The worst-case cost of (α, β) Fibonacci search is optimal and thus not larger that u · ⌈log2 n⌉. Corollary 1. The depth of the (α, β) decision tree is not larger than ⌈u/ℓ⌉⌈log2 n⌉. Proof. Follows from Proposition 7 since every round of the search procedure increases the level (cost) of the search by at least ℓ. A slightly weaker result follows from Proposition 2. Proposition 8. The complexity of the (α, β) Fibonacci search algorithm is at most logarithmic on the number of items n. Proof. The algorithm first prepares the (α, β) Fibonacci sequence up to the first k, such that G(k) ≥ n. From Proposition 7, the level of the corresponding decision tree is bounded by u · ⌈log2 n⌉, and, thus, by O(log n), assuming u is a constant. From Corollary 1 we obtain that k ≤ ⌈u/ℓ⌉ · ⌈log2 n⌉ = O(log n). The main phase of the algorithm is the search loop. The loop is executed not more than ⌈u/ℓ⌉ · ⌈log2 n⌉ times, since in each loop the depth of the remaining tree is reduced by at least one. Thus, the overall complexity is O(⌈u/ℓ⌉ · ⌈log2 n⌉) = O(log n). Note that a factor u is hidden in the preparation time of the algorithm (calculation of the terms of G(k)) and a factor u/ℓ in the complexity of each item search. 5.3 The Algorithm (full version) We present now the full version of the (α, β) Fibonacci search algorithm which is also average-case optimal, assuming that all items of the population are equiprob- able. When n = V is an (α, β) Fibonacci number, then the lowest layer of the corresponding search tree is complete and the short version of Section 5.1 is op- timal in the average case too. If, however, n is not an (α, β) Fibonacci number, then some nodes of the lowest layer of the complete search tree are not used. To make the search optimal in the average case, the surplus nodes have to be assigned to highest cost nodes of the search tree. Let k be the level of the cor- responding search tree. Then the number of surplus nodes cannot exceed g(k) because else the lowest of the tree could be avoided. We assume that all surplus nodes are assigned to the lowest layer from right to left. The full version of (α, β) Fibonacci search traverses the implicit decision tree down to the corresponding leaf. During its descendance, it simply keeps track how many surplus nodes cor- respond to its current subtree. The code of the algorithm becomes a little more involved, but its asymptotic complexity remains the same. Due to lack space, we omit the detailed description of the algorithm. 6 Applications Fibonacci sequences can be generalized to sequences of higher order. For exam- ple, the common Fibonacci sequence of order three is the Tribonacci sequence. Further members in increasing order are the Tetranacci, Pentanacci and Hex- anacci sequences [18]. Since (α, β) Fibonacci search fits perfectly the decision tree of the (α, β) binary search problem we are tempted to examine what happens if we turn to higher order Fibonacci sequences. 6.1 A Guessing Game The generalization of the asymmetric cost binary search problem to searching with more outcomes per comparison gives the following guessing game. Definition 7. The h-outcomes guessing game. An array V with n items sorted in increasing order and access time O(1) for each item, is given. To search in an interval I, the following comparison operation is supported: The interval I has to be partitioned into a partition P of h consecutive intervals defined with h-1 values v1 ≤ v2 ≤ . . . ≤ vh−1. For any value x and any partition P, the cost of finding in which of the intervals of P item x belongs, is cost of (in which interval of P is x) = wi, if the searched item is in interval i, for i = 0, 1, . . . , h − 1, where the weights or costs wi, for i = 0, 1, . . . , h−1, are strictly positive integers. The cost of a search is equal to the sum of the costs of all comparison operations performed during the search. As in the binary search case, the requested item x is assumed to belong to the array V, else the requested item has to be compared at the end of the search with the item found. The results of Section 4 on the lower bound of the two outcomes (α, β) binary search can be extended to obtain h-decision trees this search problem with h outcomes. Similarly, it is straightforward to generalize the (α, β) Fibonacci search algorithm of Section 5 to the h-Fibonacci search algorithm that optimally solves the h-outcomes search problem. Due to lack space, we omit the detailed description and proofs of these results. 6.2 Coding with Unequal Letter Costs The problem of searching with asymmetric costs is strongly related to optimal prefix codes [17,8]. The encoding of letters that may have different lengths but occur with the same probability is known as the Varn coding problem and can be solved in polynomial time. The results of this work, provide simple strict lower bounds on the worst-case cost of Varn codes with lengths that are integers or rational multiples of each other. In particular, an implicit description of an optimal Varn encoding or an optimal Varn encoding with the alphabetic property (the additional constraint that the encoding of the words must preserve their alphabetical order) can be calculated in logarithmic time. The h-Fibonacci decision tree provides a tight lower bound on the worst case cost for the encoded form and the h-Fibonacci search algorithm gives an optimal coding of the letters that matches the lower bound. Then, the encoding of any particular word can also be calculated in logarithmic time. This might be useful if the domain (the item set to be encoded) is very large, for example exponential on some problem parameter. In this case we may generate an implicit encoding, given any specific (possibly implicit) ordering of all words and then generate only the words that are actually used. 7 Discussion We consider the (α, β) Fibonacci search algorithm and its generalization, the h-Fibonacci search algorithm, fundamental tools that can be used within the solutions of other computational problems. For this reason, we developed a pro- totype implementation of the two algorithms within a standard Java class library that can be found at [1]. Back to the airbag example of Section 1, the interval of uncertainty con- tains 101 distinct values (10.0, 10.1, . . . , 20.0). We use the implemented (α, β) Fibonacci search algorithm with α = 1 and β = 3 to find that the level of the corresponding (α, β) decision tree is 14 (since G(13) = 88 and G(14) = 129, for α = 1 and β = 3). Thus, the worst-case cost is 500·14 = 7000e. The correspond- ing tree generated by normal binary search has worst-case depth ⌈log2 101⌉ = 7 and thus, the cost of the binary search solution can be up to 7 · 1500 =10500e. Since the lowest layer of the binary search tree is not complete, this cost can be reduced to 6 · 1500 + 1 · 500 = 9500e by using the 101 leftmost leaves (because in this case the right branches have the higher cost). The difference between the costs 7000 and 9500, albeit not colossal, is without doubt significant. Preliminary experiments indicate the, rather expected, result, that the benefits of using (α, β) Fibonacci search increase as the ratio u/ℓ in- creases. The experiments also indicate that the benefits in the average case cost of the search problem if (α, β) Fibonacci search is used, are still significant, albeit smaller than with the worst-case criterion. A further interesting question is if the results of this work can be generalized to support real positives α and β, possibly with the use of the Pascal's triangle like in [5] or techniques from [4]. References 1. abFib. A Java class implementation for (α, β) Fibonacci search, 2010. http://utopia.duth.gr/∼pefraimi/projects/abFib/. 2. Mordecai Avriel. Nonlinear Programming: Analysis and Methods. Dover Publica- tions, September 2003. 3. Jon Louis Bentley and Donna J. Brown. A general class of resource tradeoffs. Journal of Computer and System Sciences, 25(2):214 – 238, 1982. 4. Vicky Siu-Ngan Choi and Mordecai J. Golin. Lopsided trees, i: Analyses. Algo- rithmica, 31(3):240–290, 2001. 5. David M. Choy and C. K. Wong. Bounds for optimal α − β binary trees. BIT Numerical Mathematics, 17:1–15, 1977. 6. P.S. Efraimidis and L. Tsavlidis. Window-games between TCP flows. In Lecture Notes in Computer Science (SAGT 2008), volume 4997, pages 95–108, Springer- Verlag Berlin Heidelberg, 2008. 7. David E. Ferguson. Fibonaccian searching. Commun. ACM, 3(12):648, 1960. 8. Mordecai J. Golin, Claire Kenyon, and Neal E. Young. Huffman coding with unequal letter costs. In STOC '02: Proceedings of the thiry-fourth annual ACM symposium on Theory of computing, pages 785–791, New York, NY, USA, 2002. ACM. 9. K. Hinderer. On dichotomous search with direction-dependent costs for a uniformly hidden object. Optimization, 21:215–229, 1990. 10. Sanjiv Kapoor and Edward M. Reingold. Optimum lopsided binary trees. J. ACM, 36(3):573–590, 1989. 11. R. Karp, E. Koutsoupias, C. Papadimitriou, and S. Shenker. Optimization prob- lems in congestion control. In Proceedings of FOCS '00, page 66, Washington, DC, USA, 2000. IEEE Computer Society. 12. D.E. Knuth. The Art of Computer Programming, volume 2 : Seminumerical Algo- rithms. Addison-Wesley Publishing Company, second edition, 1981. 13. Jens Massberg and Dieter Rautenbach. Binary trees with choosable edge lengths. Inf. Process. Lett., 109(18):1087–1092, 2009. 14. Thomas Ottmann, Arnold L. Rosenberg, Hans-Werner Six, and Derick Wood. Bi- nary search trees with binary comparison cost. International Journal of Parallel Programming, 13(2):77–101, 1984. 15. Satish Rao. Cracking eggs (or asymmetric cost binary search). CS270 Lecture Notes, Lecture 25, 2001. http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.23.72. 16. J. van Leeuwen, N. Santoro, J. Urrutia, and S. Zaks. Guessing games and dis- tributed computations in synchronous networks. In 14th International Colloquium on Automata, languages and programming, pages 347–356, London, UK, 1987. Springer-Verlag. 17. Ben Varn. Optimal variable length codes (arbitrary symbol cost and equal code word probability). Information and Control, 19(4):289 – 301, 1971. 18. Wikipedia. Generalizations of fibonacci numbers - Wikipedia, the free encyclo- pedia, 2010. [Online; accessed 26-Febrouary-2010]. 19. D.A. Wolfram. Solving generalized fibonacci recurrences. The Fibonacci Quarterly, 36(2):129–145, 1998.
1106.3126
1
1106
2011-06-16T01:21:34
Testing List H-Homomorphisms
[ "cs.DS" ]
Let $H$ be an undirected graph. In the List $H$-Homomorphism Problem, given an undirected graph $G$ with a list constraint $L(v) \subseteq V(H)$ for each variable $v \in V(G)$, the objective is to find a list $H$-homomorphism $f:V(G) \to V(H)$, that is, $f(v) \in L(v)$ for every $v \in V(G)$ and $(f(u),f(v)) \in E(H)$ whenever $(u,v) \in E(G)$. We consider the following problem: given a map $f:V(G) \to V(H)$ as an oracle access, the objective is to decide with high probability whether $f$ is a list $H$-homomorphism or \textit{far} from any list $H$-homomorphisms. The efficiency of an algorithm is measured by the number of accesses to $f$. In this paper, we classify graphs $H$ with respect to the query complexity for testing list $H$-homomorphisms and show the following trichotomy holds: (i) List $H$-homomorphisms are testable with a constant number of queries if and only if $H$ is a reflexive complete graph or an irreflexive complete bipartite graph. (ii) List $H$-homomorphisms are testable with a sublinear number of queries if and only if $H$ is a bi-arc graph. (iii) Testing list $H$-homomorphisms requires a linear number of queries if $H$ is not a bi-arc graph.
cs.DS
cs
Testing List H-Homomorphisms Yuichi Yoshida∗ School of Informatics, Kyoto University, and Preferred Infrastructure, Inc. [email protected] November 13, 2018 Abstract Let H be an undirected graph. In the List H-Homomorphism Problem, given an undirected graph G with a list constraint L(v) ⊆ V (H) for each variable v ∈ V (G), the objective is to find a list H-homomorphism f : V (G) → V (H), that is, f (v) ∈ L(v) for every v ∈ V (G) and (f (u), f (v)) ∈ E(H) whenever (u, v) ∈ E(G). We consider the following problem: given a map f : V (G) → V (H) as an oracle access, the objective is to decide with high probability whether f is a list H-homomorphism or far from any list H-homomorphisms. The efficiency of an algorithm is measured by the number of accesses to f . In this paper, we classify graphs H with respect to the query complexity for testing list H-homomorphisms and show the following trichotomy holds: (i) List H-homomorphisms are testable with a constant number of queries if and only if H is a reflexive complete graph or an irreflexive complete bipartite graph. (ii) List H-homomorphisms are testable with a sublinear number of queries if and only if H is a bi-arc graph. (iii) Testing list H-homomorphisms requires a linear number of queries if H is not a bi-arc graph. 1 1 0 2 n u J 6 1 ] S D . s c [ 1 v 6 2 1 3 . 6 0 1 1 : v i X r a ∗Supported by MSRA Fellowship 2010. 0 1 Introduction For two graphs G = (V (G), E(G)) and H = (V (H), E(H)), a map f : V (G) → V (H) is called a ho- momorphism from G to H if (f (u), f (v)) ∈ E(H) whenever (u, v) ∈ E(G). In the H-Homomorphism Problem (HOM(H) for short), given an undirected graph G, the objective is to decide whether there exists a homomorphism from G to H. It is well known that HOM(H) is in P if H is a bipartite graph and in NP-Complete if H is not a bipartite graph [3, 8, 21]. List H-Homomorphism Problem (LHOM(H) for short) is a variant of H-Homomorphism Problem, in which we are also given a list L(v) ⊆ V (H) for each vertex v in G. A map f : V (G) → V (H) is called a list-homomorphism from G to H if f is a homomorphism from G to H and f (v) ∈ L(v) for every v ∈ V (G). The objective is to decide whether there exists a list-homomorphism f from G to H. There are many results on the relationship between the graph H and the computational complexity of LHOM(H) [11, 12, 13, 14]. In particular, LHOM(H) is in P iff H is a bi-arc graph [14]. In this paper, we consider testing list-homomorphisms. See [17, 27] for surveys on property testing. In our setting, a map f is given as an oracle access, i.e., the oracle returns f (v) if we specify a vertex v ∈ V (G). A map f is called ǫ-far from list-homomorphisms if we must modify at least an ǫ-fraction of f to make f a list-homomorphism. An algorithm is called a tester for LHOM(H) if it accepts with probability at least 2/3 if f is a list-homomorphism from G to H and rejects with probability at least 2/3 if f is ǫ-far from list-homomorphisms. The efficiency of an algorithm is measured by the number of accesses to the oracle f . When we say that a query complexity is constant/sublinear/linear, it always means constant/sublinear/linear in V (G), i.e., the domain size of f . We can assume that there exists a list-homomorphism from G to H. If otherwise, we can reject immediately without any query. In this paper, we completely classify graphs H with respect to the query complexity for testing LHOM(H). Our result consists of the following two theorems. Theorem 1.1. LHOM(H) is testable with a constant number of queries iff H is an irreflexive complete bipartite graph or a reflexive complete graph. Theorem 1.2. LHOM(H) is testable with a sublinear number of queries iff H is a bi-arc graph. The central question in the area of property testing is to classify properties into the following three categories: properties testable with a constant/sublinear/linear number of queries. Our result first establishes such a classification for a natural and general combinatorial problem. We note that, from Theorem 1.2 and results given by [14], LHOM(H) is testable with a sublinear number of queries iff LHOM(H) is in P. However, it is not clear whether there is a computational class corresponding to properties testable with a constant number of queries. To obtain our results, we exploit universal algebra, which is now a common tool to study computational complexity of constraint satisfaction problems (see, e.g., [24]). Another contribution of this paper is showing that universal algebraic approach is quite useful in the setting of property testing. It is rare that we succeed to obtain characterizations of properties testable Related works: with a constant/sublinear number of queries. The only such a characterization we are aware of is one for graph properties in the dense model [18]. In this model, it is revealed that Szemer´edi's regularity lemma [28] plays a crucial role [1]. Roughly speaking, the regularity lemma gives the constant-size sketch of a graph. It turns out that a property is testable in the dense model with a 1 constant number of queries iff the property is well-approximated by the union of constant number of sketches [1]. However, no characterization is known for properties testable with a sublinear number of queries. Similarly, for properties on Boolean functions, several partial classifications on constant-time testability are known [5, 25]. Let B be a relational structure (see Section 2 for the definition). In Constraint Satisfaction Problem over B (CSP(B) for short), given another relational structure A, the objective is to find a homomorphism from A to B. There have been a lot of research on classifying B with respect to the computational complexity of CSP(B) (see, e.g., [10, 22]). We can see that HOM(H) and LHOM(H) are special cases of CSP, and there are also many results classifying H with respect to the computational complexity of HOM(H) and LHOM(H) (see, e.g., [20, 22]). Testing homomorphisms on k-SAT is already studied [4, 16]. In k-SAT, given a CNF formula for which each clause consists of k literals, the objective is to find an assignment to variables so as to satisfy all the clauses. The problem k-SAT coincides with CSP(B) for some appropriate relational structure B. Testing homomorphisms for k-SAT can be restated as follows: Given an assignment, test whether the assignment is a satisfying assignment or far from any satisfying assignments. It is known that 2SAT is testable with O(√n) queries [16] and testing 3SAT requires Ω(n) queries [4], where n is the number of variables in an input CNF formula. We can see that our result extends those results to a large family of CSPs. Given a relational structure B, it is also natural to ask whether a relational structure A has a homomorphism to B or far from having homomorphisms. Here, A is given as an oracle access. There are two major models in this setting, i.e., the dense model and the bounded-degree model. In the dense model, it is known that any CSP is testable in constant time [2]. In the bounded-degree model, it is known that Horn-SAT is testable in constant time [30, 29] and the number of queries needed to test 2SAT is eΘ(√n) [19] where n is the number of variables in an input structure A. In Section 2, we introduce definitions used throughout this paper. Sections 3 Organizations: and 4 shows "if" and "only if" part of Theorem 1.1, respectively. Similarly, Sections 5 and 6 shows "if" and "only if" part of Theorem 1.2, respectively. 2 Preliminaries Let w : A → R be a weight function such that Pa∈V w(a) = 1. Then, by a ∼ w, we mean that we pick an element a ∈ A with probability w(a). For a function f : A → B and A′ ⊆ A, we define fA′ : A′ → A as the function whose domain is restricted to A′. We also define wA′ : A′ → R as wA′(a) = w(a)/Pa′∈A′ w(a′). Note that wA′ satisfiesPa′∈A′ wA′(a′) = 1. Relational structures, polymorphisms and algebras: A vocabulary τ is a finite set of rela- tional symbols; each symbol has an associated arity. A (finite) relational structure A with vocab- ulary τ consists of a finite set A, its universe, and for every relational symbol R ∈ τ of arity n, an n-ary relation RA on A, the interpretation of R by A. A homomorphism of a structure A to a structure B with the same vocabulary τ is a mapping ϕ : A → B from the universe of A to the universe of B such that for each (n-ary) relational symbol R ∈ τ and any tuple (a1, . . . , an) ∈ RA the tuple (ϕ(a1), . . . , ϕ(an)) ∈ RB. For relational structure B, we define HOM(B) as the problem in which, given another relational structure A, the objective is to find a homomorphism from A to B. We denote by A the size of universe of A and denote by kAk the number of tuples in its 2 relations. For brevity, we use a capital letter to denote the universe of the corresponding relational structure (e.g., A denotes the universe of A). Let R be a relation on a set A, An (n-ary) operation f on the same set is said to be a poly- morphism of R if for any tuples a1, . . . , an ∈ R, the tuple f (a1, . . . , an) obtained by applying f component-wise also belongs to R. The relation R is called an invariant of f . An operation f is a polymorphism of a relational structure A if it is a polymorphism of each relation of the structure. The set of all polymorphism of A is denoted by Pol(A). From a collection C of operations Inv(C) denotes the set of invariants of all operations from C. An algebra is a pair A = (A; F ) consisting of a set A, the universe of A, and a set F of operations, the basic operations of A. Operations that can be obtained from the basic operations of A and the projection operations on A, that is operations of the form f (x1, . . . , xn) = xi, by means of compositions are called term operations of A. Term(A) denotes the set of all term operations of A. Any relational structure A can be associated with an algebra Alg(A) = (A; Pol(A)). Conversely, any algebra A = (A; F ) corresponds to a class of relational structures Str(A) that includes all the structures A with universe A and Term(A) ⊆ Pol(A). An operation f is called idempotent if f (x1, . . . , xk) ∈ {x1, . . . , xk} for any x1, . . . , xk where k is the arity of f . An algebra A is called idempotent if any basic operation (thus, term operation) is idempotent. Graph homomorphisms: We often identify a graph H = (V (H), E(H)) with a relational struc- ture H consisting of a universe V (H) and a binary relation E(H). In particular, H = V (H) and kHk = E(H). Note that problem HOM(H) defined with graph terminologies and HOM(H) defined with relational structures coincide. Similarly, LHOM(H) can be restated with relational structures. Let H be the relational structure associated with H and define HL as the relational structure obtained from H by adding all unary relations SH ⊆ V (H). Then, LHOM(H) coincides with HOM(HL). Let G be a graph with list constraints {L(v)}v∈V (G). Let G be the relational struc- ture corresponding to G. Then, we can define another relational structure GL obtained from G by adding unary relations SG ⊆ V (G). Here, for each (unary) tuple (v) ∈ SG, there is a corresponding constraint L(v) = SH. Finally, we define HL = Alg(HL) for a graph H. Note that the algebra HL is idempotent since HL contains unary relations Sv = {(v)} for every v ∈ V (H), and an operation that has {Sv}v∈V (H) as invariants must be idempotent. Testing homomorphisms: Let A and B be relational structures and w : A → R be a weight function with Pa∈A w(a) = 1. The distance between two functions f, f ′ : A → B is defined as [f (a) 6= f ′(a)]. For a function f : A → B, we define distB(f ) = minf ′ dist(f, f ′) dist(f, f ′) = Pr a∼w where f ′ is a homomorphism from A to B. We call a map f ǫ-far if distB(f ) ≥ ǫ. For subset A′ ⊆ A, we define distB(fA′) similarly using the weight function wA′. We consider testing homomorphisms to a relational structure B. An input is (A, w, f ) where A is a relational structure, w : A → R is a weight function withPa∈A w(a) = 1, and f : A → B is a map. The map f is given as an oracle access. Thus, by specifying a ∈ A, the oracle returns the value of f (a). Definition 2.1. An algorithm is called a tester for HOM(B) if, given an input (A, w, f ), it accepts with probability at least 2/3 when f is a homomorphism from A to B, and rejects with probability at least 2/3 when f is ǫ-far from homomorphisms. 3 A tester is called a one-sided error tester if it always accepts an input (A, w, f ) if f is a homo- morphism. An algorithm is called having query complexity q(n, m, ǫ) if, given an input (A, w, f ), it queries at most q(A,kAk, ǫ) times. We always assume that q(n, m, ǫ) is an increasing function on n, m and a decreasing function on ǫ. We can similarly define testers and testability for HOM(H) and LHOM(H) for a graph H since they have equivalent formalizations using relational structures. For convenience, we write an input for HOM(H) and LHOM(H) as (G, w, f ) and (G, L, w, f ), respectively, where G is a graph, {L(v)}v∈V (G) is a set of list constraints, w is a weight function, and f is a map given as an oracle access. We finally define bi-arc graphs for reference though we do not use the definition in our proof. Let C be a circle with two specified points p and q. A bi-arc is a pair of arcs (N, S) such that N contains p but not q and S contains q but not p. A graph H = (V, E) is a bi-arc graph if there is a family of bi-arcs {(Nx, Sx) x ∈ V } such that, for every x, y ∈ V , the following holds: (i) if x and y are adjacent, then neither Nx intersects Sy nor Ny intersects Sx, and (ii) if x is not adjacent to y then both Nx intersects Sy and Ny intersects Sx. An undirected graph is called reflexive if every vertex has a loop and irreflexive if no vertex has loop. It is known that a reflexive graph is bi-arc iff it is an interval graph, and that an irreflexive graph is bi-arc iff it is bipartite and its complement is an circular-arc graph [14]. 3 Graphs Testable with a Constant Number of Queries In this section, we show the following lemma, which is the "if" part of Theorem 1.1. Lemma 3.1. When H is an irreflexive complete bipartite graph or a reflexive complete graph, then there exists a one-sided error tester for LHOM(H) with query complexity O(1/ǫ2). Let (G, L, w, f ) be an input for LHOM(H). For a vertex v ∈ V (G), let C(v) be the connected component containing v. Proposition 3.2. Let (G, L, w, f ) be an input for LHOM(H). Suppose that distH (f ) ≥ ǫ. Then, E v∼w [distH(fC(v))] ≥ ǫ. v∼w v∼w It is clear that [distH (fC(v))] = E Proof. Let f be a list-homomorphism closest to f and ǫv = dist(fC(v), fC(v)). [ǫv] ≥ ǫ. ǫv = distH(fC(v)). Since distH(f ) ≥ ǫ, we have E Corollary 3.3. Suppose that there exists a one-sided error tester A for LHOM(H) with query complexity q(ǫ) if an input graph is restricted to be connected. Then, there exists a one-sided error tester A′ for LHOM(H) with query complexity q(ǫ)/ǫ for any input graph. Proof. Let (G, L, w, f ) be an input. Our algorithm A′ is as follows: Let S be a set of Θ(1/ǫ) vertices chosen from G according to w. For each vertex v ∈ S, we run A with an error parameter ǫ on the input whose domain is restricted to C(v). We reject if A rejects for some v ∈ S. We accept otherwise. It is easy to see that the above algorithm always accepts when f is a list-homomorphism, and the query complexity is at most q(ǫ)/ǫ. 4 [distH(fC(v))] ≥ ǫ. Thus, Suppose that distH(f ) ≥ ǫ. From Proposition 3.2, we have E [distH(fC(v)) ≥ ǫ] ≥ ǫ holds. For a vertex v with distH(fC(v)) ≥ ǫ, the algorithm A rejects with Pr v∼w probability at least 2/3. Thus, A′ rejects with probability at least 1 − (1 − 2/3 · ǫ)Θ(1/ǫ) ≥ 2/3. Lemma 3.4. Suppose that there exists a one-sided error tester A for LHOM(H) with query com- plexity q(ǫ) if an input map is restricted to satisfy list constraints. Then, there also exists a one-sided error tester A′ for LHOM(H) with query complexity O(1/ǫ) + q(ǫ/2) for any input. Proof. Let (G, L, w, f ) be an input. We define f ′ : G → H as v∼w f ′(v) =(f (v) any element in L(v) if f (v) ∈ L(v) otherwise Note that we can compute f ′(v) by querying f once, i.e., f (v). Our algorithm A′ is as follows: Let S be a set of Θ(1/ǫ) vertices chosen from G according to w. We reject if f (v) 6∈ L(v) for some v ∈ S. If otherwise, we simply return the output by A running on f ′ with an error parameter ǫ/2. It is easy to see that the above test always accepts when f is a list-homomorphism, and the query complexity is at most O(1/ǫ) + q(ǫ/2). Suppose that distH (f ) ≥ ǫ. If dist(f, f ′) ≥ ǫ/2, then A′ rejects with probability at least If dist(f, f ′) < ǫ/2, from the 1 − (1 − ǫ/2)Θ(1/ǫ) ≥ 2/3 when checking f (v) ∈ L(v) for v ∈ S. triangle inequality, we have distH (f ′) ≥ ǫ/2. Thus, A′ rejects with probability at least 2/3. Lemma 3.5. Let H be a reflexive complete graph. Then, there exists a one-sided error tester for LHOM(H) with query complexity O(1/ǫ). Proof. Let (G, L, w, f ) be an input and assume that f satisfies list constraints. Then, we can always accept since any map is a list-homomorphism to H. The lemma follows from Lemma 3.4. Lemma 3.6. Let K2 be an irreflexive complete graph with two vertices. There exists a one-sided error tester A for LHOM(K2) with query complexity O(1/ǫ2). Proof. Let (G, L, w, f ) be an input and assume that G is connected and f satisfies list constraints. Note that G must be bipartite in order to have a homomorphism to H, and let V1 ∪ V2 be the bipartition of G. Let a, b be two vertices in K2. Then, we have two homomorphisms, i.e., f 1 and f 2 where f 1V1 ≡ a, f 1V2 ≡ b, and f 2V1 ≡ b, f 2V2 ≡ a. Our algorithm A is as follows: Let S1 (resp., S2) be a set of Θ(1/ǫ) vertices chosen from V1 (resp., V2) according to wV1 (resp., wV2). Then, we check f (u) = f (v) for every u, v ∈ S1, f (u) = f (v) for every u, v ∈ S2, and f (u) 6= f (v) for every u ∈ S1, v ∈ S2. We reject if any of them do not hold. We accept otherwise. It is easy to see that the above test always accepts when f is a list-homomorphism, and the query complexity is O(1/ǫ). Suppose that distH (f ) ≥ ǫ. Note that f 1 or f 2 must satisfy list constraints. We assume below that both f 1 and f 2 satisfy list constraints. The analysis is similar when either of them does not satisfy list constraints. Since f is ǫ-far from f 1, we havePv∈V1,f (v)=b w(v) ≥ ǫ/2 orPv∈V2,f (v)=a w(v) ≥ ǫ/2. Similarly, we havePv∈V1,f (v)=a w(v) ≥ ǫ/2 orPv∈V2,f (v)=b w(v) ≥ ǫ/2. In any case, the probability that we reject is at least 1 − 2(1 − ǫ/2)Θ(1/ǫ) ≥ 2/3. 5 From Corollary 3.3 and Lemma 3.4, LHOM(K2) is testable with O(1/ǫ2) queries. Now, we show that any complete bipartite graph is testable with a constant number of queries. For two graphs G and H, we call a map f : V (G) → V (H) a full-homomorphism if (u, v) ∈ E(G) iff (f (u), f (v)) ∈ E(H). The difference from a homomorphism is that we must have (f (u), f (v)) 6∈ E(H) when (u, v) 6∈ E(G). Proposition 3.7. Let h be a full-homomorphism from H to H ′. For a graph G and a homomor- phism f ′ from G to H ′, let f : V (G) → V (H) be a map such that f (v) is any element in h−1(f ′(v)). Then, f is also a homomorphism from G to H. Proof. Suppose that f is not a homomorphism. Then, there exist u, v ∈ V (G) such that (u, v) ∈ E(G) while (f (u), f (v)) 6∈ E(H). Then, we have (f ′(u), f ′(v)) = (h(f (u)), h(f (v))) 6∈ E(H ′) since h is a full-homomorphism, which is contradicting the fact that f ′ is a homomorphism. Lemma 3.8. Let H be a graph and suppose that there exists a full-homomorphism h from H to H ′. If there exists a one-sided error tester for LHOM(H ′) with query complexity q(ǫ), then there exists a one-sided error tester for LHOM(H) with query complexity O(1/ǫ) + q(ǫ/2). Proof. Let (G, L, w, f ) be an input and assume that f satisfies list constraints. We define L′ = h◦L and f ′ = h ◦ f . Then, we run the tester for LHOM(H ′) on an input (G, L′, w, f ′) with an error parameter ǫ. If f is a list-homomorphism, then f ′ is also a list-homomorphism, and the tester always accepts. Suppose that distH (f ) ≥ ǫ and let f ′ be the list-homomorphism closest to f ′. We define ef : V (G) → V (H) as follows. ef (v) =(f (v) any element in L(v) ∩ h−1(f ′(v)) if f ′(v) = f ′(v), otherwise. Note that, in the latter case, L(v) ∩ h−1(f ′(v)) is not empty since f ′(v) ∈ L′(v) = h(L(v)). Thus, ef is well-defined. We can easily see that ef satisfies list constraints from the construction. When f ′(v) = f ′(v), we have f (v) ∈ h−1(f ′(v)). Thus, ef is a list-homomorphism from Proposition 3.7. It means that dist(f ′, f ′) ≥ dist(f,ef ) ≥ distH(f ) ≥ ǫ. Thus, the tester rejects with probability at We have shown that LHOM(H) is testable with q(ǫ) queries when an input is restricted to satisfy least 2/3. list constraints. The lemma follows from Lemma 3.4. Lemma 3.9. Let H be an irreflexive complete bipartite graph. Then, there exists a one-sided error tester for LHOM(H) with query complexity O(1/ǫ2). Proof. Since there exists a full-homomorphism from H to K2, LHOM(H) is testable with O(1/ǫ2) queries from Lemmas 3.6 and 3.8. Proof of Lemma 3.1. The claim immediately follows from Lemmas 3.5 and 3.9. 6 4 Graphs Not Testable with a Constant Number of Queries In this section, we show the following lemma, which is the "only if" part of Theorem 1.1. Lemma 4.1. If H is neither an irreflexive complete bipartite graph nor a reflexive complete graph, testing LHOM(H) requires Ω( log n log log n ) queries. The following is immediate since we can freely restrict the range of a map by list constraints. Proposition 4.2. Let H be a graph and H ′ be an induced subgraph of H. If testing LHOM(H ′) requires q queries, then testing LHOM(H) also requires q queries. The following lemma is implicitly stated in [16] when showing lower bounds for testing 2SAT. Lemma 4.3 ([16]). Let H be a graph and G be a graph with list constraints {L(v)}v∈V (G). For vertices u, v ∈ V (G) with u 6= v, let R = {(f (u), f (v)) f is a list-homomorphism from G to H}. If R = {(a, c), (b, c), (b, d)} for vertices a, b, c, d ∈ H, a 6= b, c 6= d, then testing LHOM(H) requires Ω( log n log log n ) queries. We also use the following lemma, which is a special case of Lemma 6.1 (see Section 6). Lemma 4.4. Let K3 be an irreflexive complete graph with three vertices. Then, testing LHOM(K3) requires Ω(n) queries. Note that K3 is not a bi-arc graph. The following two lemmas deal with reflexive graphs and irreflexive graphs, respectively. log log n ) queries. Lemma 4.5. Let H be a reflexive graph. If H is not a complete graph, testing LHOM(H) requires Ω( log n Proof. Let P = ({a, b, c};{(a, a), (b, b), (c, c), (a, b), (b, c)}) be a reflexive path of length 2 and G = ({u, v};{(u, v)}) be an irreflexive edge with list constraints L(u) = {a, b} and L(v) = {b, c}. It is It follows that easy to see that the relation R in Lemma 4.3 becomes R = {(a, b), (b, b), (b, c)}. testing LHOM(P ) requires Ω( log n log log n ) queries. From Proposition 4.2, if LHOM(H) is testable with a constant number of queries, H must have a diameter 1, implying that H is a reflexive complete graph. log log n ) queries. If H is not a complete bipartite graph, testing Lemma 4.6. Let H be an irreflexive graph. LHOM(H) requires Ω( log n Proof. Let P = ({a, b, c, d};{(a, b), (b, c), (c, d)}) be an irreflexive path of length 3 and G = ({u, v};{(u, v)}) be an irreflexive edge with list constraints L(u) = {a, c} and L(v) = {b, d}. It is easy to see that the relation R in Lemma 4.3 becomes R = {(a, b), (c, b), (c, d)}. It follows that testing LHOM(P ) requires Ω( log n log log n ) queries. Also, for an irreflexive triangle T , testing LHOM(T ) requires Ω(n) queries from Lemma 4.4. Thus, if LHOM(H) is testable with a constant number of queries, H must not have a path of length 3 or a triangle as induced subgraphs from Proposition 4.2. Thus, H must be a complete bipartite graph. Proof of Lemma 4.1. Let P = ({a, b};{(a, b), (b, b)}) be an edge with a loop and G = ({u, v};{(u, v)}) be an irreflexive edge with list constraints L(u) = L(v) = {a, b}. Then, the relation R in Lemma 4.3 becomes {(a, b), (b, b), (b, a)}, and it follows that testing LHOM(P ) requires Ω( log n log log n ) queries. Thus, if LHOM(H) is testable with a constant number of queries, H must be reflexive or irreflexive from Proposition 4.2. Then, the lemma follows from Lemmas 4.5 and 4.6. 7 5 Graphs Testable with a Sublinear Number of Queries In this section, we show the following lemma, which is the "if" part of Theorem 1.2. Lemma 5.1. Let H be a bi-arc graph. Then, there exists a one-sided error tester for LHOM(H) with query complexity O(pn/ǫ). We first describe a propagation algorithm to solve CSPs. Let A and B be two relational struc- tures. To check whether there exists a homomorphism f from A to B, we can use the following algorithm. Let k, ℓ be integers with k ≤ ℓ. For each subset U ⊆ A,U ≤ ℓ, we keep track of a set SU of tuples corresponding to maps from AU to B. First, we initialize SU to the set of solutions to the partial instance AU . Then, for each subsets U, U ′ ⊆ A with U ∩ U ′ ≤ k, we eliminate tuples a in SU if aU ′ is not contained in SU ′U . We continue this process until no update occurs. This propagation algorithm is called (k, ℓ)-Minimality [9]. If SU becomes empty for some U ⊆ A, we can conclude that A has no homomorphism to B. Even if no SU is empty when propagation stops, A may not have a homomorphism to B. If A has a homomorphism to B in such a case, then B is called having width (k, ℓ). A ternary operation f : B3 → B is called a majority if f (x, x, y) = f (x, y, x) = f (y, x, x) = x for x, y ∈ B. It is known that a relational structure B such that the associated algebra Alg(B) admits a majority operation has width (2, 3) [24]. We say a map f : A → B ∪ {⊥} is extendable to a homomorphism if there exists a homomorphism f ′ : A → B such that f ′(v) = f (v) whenever f (v) ∈ B. We call a vertex v a violating vertex if f (v) 6∈ S{v} and a pair of vertices (v, u) a violating pair if (f (v), f (u)) 6∈ S{v,u}. It is known that the majority operation implies the following property. Lemma 5.2 (2-Helly property, [15]). Let B be a relational structure such that Alg(B) admits a majority operation. For a relational structure A and U ⊆ A,U ≤ 3, let SU be the set of tuples obtained by (2, 3)-Minimality running on A. If a map f : A → B ∪ {⊥} is not extendable to a homomorphism, then there is a violating vertex v or a violating pair (v, u) for some u, v ∈ f −1(B). Lemma 5.3 ([11]). Let H be a bi-arc graph. Then, HL admits a majority operation. Proof of Lemma 5.1. Let (G, L, w, f ) be an input for LHOM(H). From Lemmas 5.2 and 5.3, we can assume the 2-Helly property. Our algorithm is described below. Algorithm 1 LHOM(H) tester for a bi-arc graph H 1: Run (2, 3)-Minimality and let SU be the set of tuples obtained for U ⊆ V (G),U ≤ 3. 2: Let X be a set of Θ(1/ǫ) vertices chosen according to w 3: if ∃v ∈ X such that f (v) 6∈ S{v} then 4: Reject the input. 5: Let Y1, Y2 be sets of Θ(pn/ǫ) vertices chosen according to w. 6: if ∃v ∈ Y1, u ∈ Y2 such that (f (v), f (u)) 6∈ S{v,u} then 7: 8: Accept the input. Reject the input. Note that (2, 3)-Minimality updates SU using not only the graph G but also the list constraint L. The query complexity is clearly O(pn/ǫ). It is clear that the tester always accepts when f is a list-homomorphism. 8 Suppose that distH(f ) ≥ ǫ. Let U be a subset of V (G) with maximum weight such that the partial homomorphism fU is extendable to a list-homomorphism. Clearly, we have w(U ) + ǫ ≤ 1. Let v be a vertex in V (G) \ U . From the maximality of U , we cannot extend fU ∪{v} to a list- homomorphism. Thus, from the 2-Helly property, v is a violating vertex or (v, u) is a violating pair for some u ∈ U . Let A be the set of violating vertices in V (G) \ U , and B = V (G) \ (U ∪ A). Note that for any v ∈ B, a pair (v, u) is a violating pair for some u ∈ U . Since A ∪ B = V (G) \ U , we have w(A) + w(B) ≥ 1 − w(U ) ≥ ǫ. When w(A) ≥ ǫ/2, we reject at Line 4 with probability at least 1 − (1 − ǫ/2)Θ(1/ǫ) ≥ 2/3. Suppose that w(B) ≥ ǫ/2. For a subset B′ ⊆ B, we define N (B′) = {u ∈ U ∃v ∈ B′, (v, u) is a violating pair}. Note that fU ′ is extendable to a list-homomorphism where U ′ = (U \ N (B′)) ∪ B′. Thus, we must have w(B′) ≤ w(N (B′)) from the maximality of U . Let q = Y1 = Y2 and c > 0 be a parameter. Let B′ = Y1 ∩ B and F1 be the event that w(B′) ≤ ǫq 10 from Chernoff's bound. Note that w(N (B′)) ≥ w(B′) ≥ ǫq cn . Let F2 be the event that no violated edge is detected. Then, 3 by choosing the hidden constant in q = Θ(pn/ǫ) 10 + (1− ǫq Pr[F2] ≤ Pr[F1] + Pr[F2 F1] ≤ 1 large enough. cn . By choosing c large enough, we have Pr[F1] ≤ 1 cn )q ≤ 1 Note that we only use the fact that HL admits a majority operation. Thus, our algorithm can be also used to testing homomorphisms to other CSPs admitting majority operations, e.g., 2SAT. 6 Graphs Not Testable with a Sublinear Number of Queries In this section, we prove the following, which is "only if" part of Theorem 1.2. Lemma 6.1. If a graph H is not a bi-arc graph, then testing LHOM(H) requires Ω(n) queries. To prove Lemma 6.1, we make use of a sequence of reductions. First, we define reductions used in this section. Definition 6.2. Let A and B be relational structures. We say that there is a (randomized) gap- preserving local reduction from B to A if there exist functions t1(n, m), t2(n, m) and constants c1, c2 satisfying the following: there exists a (randomized) construction such that given an input (J , wJ , fJ ) for HOM(B), it generates an input (I, wI , fI ) for HOM(A) such that 1. I ≤ t1(J ,kJ k), 2. kIk ≤ t2(J ,kJ k), 3. if fJ is a homomorphism, then fI is also a homomorphism, 4. if distB(fJ ) ≥ ǫ, then Pr[distA(fI) ≥ c1ǫ] ≥ 9/10, and 5. we can compute fI (v) for any v ∈ I by querying fJ at most c2 times. Lemma 6.3. Let A be a relational structure such that there exists a tester for HOM(A) with query complexity q(n, m, ǫ). If there exists a gap-preserving local reduction from a relational structure B to A, there exists a tester for HOM(B) with query complexity O(q(t1(n, m), t2(n, m), O(ǫ))). Proof. Let (J , wJ , fJ ) be an input for HOM(B). Let (I, wI , fI ) be the (random) input for HOM(A) given by the reduction. 9 We run A with an error parameter c1ǫ. If fJ is a homomorphism, then A accepts with probability at least 2/3. If fJ is ǫ-far from homomorphisms, then A rejects with probability at least 9/10·2/3 = 3/5. In both cases, we can increase the probability by running A a constant number of times and take the majority of outputs. Since we can compute the value of fI (v) by querying fJ at most c2 times, the number of queries to fJ is at most O(c2q(t1(n, m), t2(n, m), c1ǫ)). For an algebra A, we say that HOM(A) is testable with q(n, m, ǫ) queries if, for any relational structure A ∈ Str(A), HOM(A) is testable with q(n, m, ǫ) queries. Lemma 6.4. Let A be a relational structure such that HOM(A) is testable with q(n, m, ǫ) queries. Then, HOM(A) is also testable with O(1/ǫ + q(O(n + m), O(m), O(ǫ))) queries. Proof. Let B be a relational structure in Str(A). Then, each relation of B is obtained from relations of A in finitely many steps by using the following constructions [6, 7]: 1. removing a relation, 2. adding a relation obtained by permuting the variables of a relation, 3. adding the intersection of two relations of the same arity, 4. adding the product of two relations, 5. adding the equality relation, and 6. adding a relation obtained by projecting an n-ary relation to its first n − 1 variables. It thus suffices to prove that B is testable if B is obtained by any of those constructions from A. To this end, we will give gap-preserving local reductions from B to A with t1(n, m) ≤ n + m, t2(n, m) ≤ 2m, c1 = c2 = O(1). (For Case 5, we need reprocessing that costs O(1/ǫ) queries.) Let (J , wJ , fJ ) be an input of HOM(B). Then, we construct another input (I, wI , fI ) of HOM(A) so that the construction satisfies conditions of gap-preserving local reductions. Since checking conditions (1),(2), (3) and (5) are straightforward, we will only check the condition (4). For any case below, we define f I : I → A as the homomorphism closest to fI . Then, we will construct a homomorphism efJ : J → B using f I and show that dist(fI , f I ) must be large using the fact that dist(fJ ,efJ ) ≥ ǫ. Then, the lemma follows by iteratively applying Lemma 6.3. Case 1: Let us suppose first that B is obtained from A by removing a relation of A. Let I be the relational structure obtained from J by supplementing the relations of J by an empty relation corresponding to the relation removed from A. We set wI = wJ and fI = fJ . Then, we define holds. efJ = f I . It is clear that efJ is a homomorphism from J to B. Thus, dist(fI , f I ) = dist(fJ ,efJ ) ≥ ǫ Case 2: Let us suppose that B is obtained from A by adding a relation S obtained from a relation R of A by permuting the variables according to a permutation π. Let I be the relational structure obtained from J by deleting SJ and replacing RJ by RI = RJ ∪ SJ π is obtained by permuting the variables of SJ according to π−1. We set wI = wJ and fI = fJ . Then, we define efJ = f I . It is clear that efJ is a homomorphism from J to B. Thus, dist(fI , f I ) = dist(fJ ,efJ ) ≥ ǫ π where SJ holds. 10 2 where T J Case 3: Let R and S be two relations of the same arity of A. Let T denote the intersection of R and S. Let us suppose that B is obtained from A by adding the relation T . Let I be the relational structure obtained from J by deleting T J and replacing RJ by RI = RJ ∪ T J and SJ by SI = SJ ∪ T J . We set wI = wJ and fI = fJ . Then, we define efJ = f I . It is clear that efJ is a homomorphism from J to B. Thus, dist(fI, f I ) = dist(fJ ,efJ ) ≥ ǫ holds. Case 4: Let R and S be two relations of A. Let T denote the product of R and S, and let B be obtained from A by adding the relation T . Let I be the relational structure obtained from J by deleting T J and replacing RJ by RI = RJ ∪ T J 1 (resp., T J 1 and SJ by SI = SJ ∪ T J 2 ) is the projection of T J onto the variables of the R-part (resp., S-part) of T J . We set wI = wJ and fI = fJ . Then, we define efJ = f I . It is clear that efJ is a homomorphism from J to B. Thus, dist(fI , f I ) = dist(fJ ,efJ ) ≥ ǫ holds. Case 5: Let us suppose that B is obtained from A by adding the equality relation. Let θ be the reflexive, symmetric, transitive closure of θ′ where θ′ is the relation of J corresponding to equality in B. Clearly, θ is an equivalent relation on J. For a variable v ∈ J, we define v/θ as the corresponding θ-block. For a θ-block u, we define wJ (u, b) = Pv∈u:fJ (v)=b wJ (v), wJ (u) = Pb∈B Θ(1/ǫ) variables according to w and check whether those variables obey θ. Let bfJ : J → B be the map such that bfJ (v) = f maj (v/θ). Note that bfJ is the map closest to fJ obeying θ. It is easy to see Suppose that dist(fJ ,bfJ ) ≥ ǫ/20. This indicatesPu:θ-block(wJ (u) − w hard to show that, in such a case, the algorithm above rejects bfJ with probability at least 2/3. Thus, we assume that dist(fJ ,bfJ ) =Pu:θ-block(wJ (u) − w Now, we define the input (I, wI , fI ) for HOM(A). We define a structure I so that its base set is the set of θ-blocks, and its relations are defined as follows: For each relation RJ of J distinct from θ′, we define a relation RI on the θ-blocks by stipulating that that the above algorithm always accepts when fJ is a homomorphism from J to B and the query complexity is O(1/ǫ). (u)) ≥ ǫ/20. It is not wJ (u, b), w Before we reduce the problem to HOM(A), we run the following algorithm first: Pick a set of (u)) < ǫ/20 in what follows. wJ (u, b), and f maj (u) = argmax wJ (u, b). maj J (u) = max b∈B maj J J b∈B J maj J (u1, . . . , ur) ∈ RI iff ∃v1 ∈ u1, . . . ,∃vr ∈ ur such that (v1, . . . , vr) ∈ RJ . Also, we set wI (u) = wJ (u). We define fI(u) = fJ (v) where v is a variable in u randomly chosen according to wJu, i.e., v is chosen with probability wJ (v)/wJ (u). wJ (v). For a θ-block u, we define distu(fJ , fI ) = We define dist(fJ , fI ) = Pu:θ-block Pv∈u:fI (u)6=fJ (v) wJ (u) . It is clear that dist(fJ , fI) = Pu:θ-block Pv∈u:fI (u)6=fJ (v) wJ (v) wJ (u)distu(fJ , fI ). 11 We have E[distu(fJ , fI )] = Xb∈B wJ (u, b) wJ (u, b) wJ (u) (cid:18)1 − wJ (u) 1 − wJ (u) (cid:19) wJ (u) ! + 1 − maj J maj J (u) (u) w w ≤ ≤ 2 1 − w (u) maj J wJ (u) ! . w (u) maj J wJ (u) ! · 1 Thus, E[dist(fJ , fI )] = E[ Xu:θ-block wJ (u)distu(fJ , fI)] ≤ Xu:θ-block 2(wJ (u) − w maj J (u)) < ǫ 10 . Also, we have Var[distu(fJ , fI )] w w (u) maj J maj J = E[(distu(fJ , fI ) − E[distu(fJ , fI )])2] ≤ wJ (u) 1 − wJ (u) !2 wJ (u) − E[distu(fJ , fI)]!2 wJ (u) ! ≤ 2 1 − + 1 − + 1 − wJ (u) ! . = 1 − maj J maj J maj J (u) (u) (u) (u) w w w w (u) maj J wJ (u) ! · 1 Thus, wJ (u)distu(fJ , fI )] ≤ Xu:θ-block Thus, from Chebyshev's inequality, Pr[dist(fJ , fI ) ≥ ǫ/2] ≤ 1/16. Var[dist(fJ , fI )] = Var[ Xu:θ-block We check the condition (4). We define efJ as efJ (v) = f I (v/θ). It is clear that efJ is a homo- morphism from J to B. Since we have dist(fJ , fI ) + dist(fI , f I ) ≥ dist(fJ ,efJ ) ≥ ǫ, it follows that Pr[dist(fI, f I ) ≥ ǫ/2] ≥ 15/16. 2(wJ (u) − w (u)) ≤ ǫ 10 maj J . Case 6: Let us suppose that B is obtained from A by adding the projection S of an r-ary relation R of A to its first r − 1 variables. Let I be the relational structure with the base set J extended by a new element for each (r − 1)-tuple in SJ . The relations of I are those of J , except that SJ is removed and RJ is replaced by RI = RJ ∪ SJ r−1 is obtained from SJ by extending every (r − 1)-tuple of SI with the corresponding new element in the base set of I. Note that I ≤ J +kJ k and kIk = kJ k. We set wI (v) = wJ (v) for a variable v ∈ J is and wI (v) = 0 for a variable v corresponding to (r − 1)-tuple in SJ . We define fI as follows: We set fI (v) = fJ (v) for v ∈ J and arbitrary value for a variable v corresponding to an (r − 1)-tuple in SJ . (Indeed, we do not have to care about those values since there weights are zero.) Then, we define efJ (v) = f I (v) for v ∈ J. It is easy to check that efJ is a homomorphism, and dist(fI , f I ) ≥ dist(f,efJ ) ≥ ǫ. r−1 where SJ 12 We introduce some notions related to algebras. Let A = (A; F ) be an algebra. A set B ⊆ A is a subuniverse of A if for every basic operation f ∈ F restricted to B has all the results in B. For a nonempty subuniverse B of an algebra A, fB is the restriction of f to B. The algebra B = (B, FB) where FB = {fB f ∈ F} is a subalgebra of A. Algebras A, B are of the same type if they have the same number of basic operations and corresponding operations have equal arities. Given algebras A, B of the same type, a product A× B is the algebra with the same type as A and B with universe A × B and basic operations computed coordinate-wise. An equivalence relation θ on A is called a congruence of an algebra A if θ is a subalgebra of A × A. Given a congruence θ on A, we can form the homomorphic image A/θ, whose elements are the equivalence classes of A and the basic operations are defined so that the natural projection mapping is a homomorphism A → A/θ. If A is idempotent, θ-classes are subuniverses of A. It is known that a relational structure A is in Str(A) if each relation in A is a subuniverse of a finite power of A. A variety is a class of algebras of the same type closed under formation of subalgebras, ho- momorphic images and finite products. For any algebra A, there is a smallest variety containing A, denoted by V(A) and called the variety generated by A. It is well known that any variety is generated by an algebra and that any member of V(A) is a homomorphic image of a subalgebra of a power of A. Lemma 6.5. Let A be an algebra such that HOM(A) is testable with q(n, m, ǫ) queries. Then, for any finite algebra B ∈ V(A), HOM(B) is also testable with O(q(O(n), O(m), O(ǫ))) queries. Proof. It suffices to show that every subalgebra, homomorphic image and finite power of A is testable with O(q(O(n), O(m), O(ǫ))) queries. Let B be a subalgebra, a homomorphic image, or a finite power of A and let B be a relational structure on B such that the relations of B are subalgebras of finite powers of B. From Lemma 6.3, it suffices to show a gap-preserving local reduction from B to A. We follow the approach similar to the proof of Lemma 6.4. Given an input (J , wJ , fJ ) for HOM(B), we define another structure (I, wI , fI ) for HOM(A). Then, we show that the construction satisfies the conditions of gap-preserving local reductions. Since checking conditions (1), (2), (3), and (5) are straightforward, we will only check the condition (4). For any case below, we define f I : I → A as a homomorphism closest to fI. Then, we will construct a homomorphism efJ : J → B from f I and show that dist(fI , f I ) must be large by using the fact that dist(fJ ,efJ ) ≥ ǫ. Suppose first that B is a subalgebra of A. Let A be the relational structure whose base set is A and whose relations are all the relations of B and B as a unary relation. Notice that the relations of A are subalgebras of finite powers of A, and A ∈ Str(A). We take I to be J with all of its relations adding B as a unary relation. In particular, I = J. Then, we define wI = wJ and fI = fJ . Due to the unary relations, f I(v) ∈ B must hold for every v ∈ I. Thus, f I is also a homomorphism from J to B. Thus, distA(f ) = dist(fI , f I ) ≥ ǫ. Secondly, suppose that B is a homomorphic image of A under the homomorphism h : A → B. This time, let A be the relational structure whose base set is A and whose relations are the preimages under the homomorphism h of all the relations of B. Notice that the relations of A are subalgebras of finite powers of A, and A ∈ Str(A). We take I to be the relational structure whose base set is J and whose relations are the preimages under the homomorphism h of all the relations of I. We define wI = wJ and fI : I → A so that fI (v) is any element in h−1(fJ (v)). Note that h ◦ f I is a homomorphism from I to B. From the construction, we have dist(fI, f I ) ≥ dist(h ◦ fI, h ◦ f I ) = dist(fJ , h ◦ f I ) ≥ ǫ. Finally, suppose that B = Ak. Let A be the relational structure with the following relations: If R is an s-ary relation of B, define R0 to be the sk-ary relation such that, if (b1, . . . , bs) ∈ R 13 with bi = (a1,i, . . . , ak,i), we put the sk-tuple (a1,1, . . . , a1,s, . . . , ak,1, . . . , ak,s) in R0. Note that the sk-ary relations obtained in this way are subalgebras of finite powers of A, and A ∈ Str(A). We take I to be the union of k disjoint copies of J with one sk-ary relation for each s-ary relation of J . An sk-tuple in the new relation on I is formed by the k copies of an s-tuple in the old relation on J , that is, if (x1, . . . , xs) is in the old relation on J and xi,j is the i-th copy of xj in J, then (x1,1, . . . , x1,s, . . . , xk,1, . . . , xk,s) is in the new relation. We define wI (xi) = wJ (x)/k if xi is a copy of x. For a map fJ : J → B, we define fI : I → A as follows: If xi,j is the i-th copy of xj, we define fI (xi,j) as the i-th element of fJ (xj). We make efJ : J → B from f I by efJ (xj) = (f I (x1,j), . . . , f I (xn,j)). Clearly, efJ is a homomorphism. Thus, dist(fI , f I ) ≥ dist(fJ ,efJ )/k ≥ ǫ/k. We define 3LIN = ({0, 1};{(0, 0, 0), (0, 1, 1), (1, 0, 1), (1, 1, 0)}, {(0, 0, 1), (0, 1, 0), (1, 0, 0), (1, 1, 1)}) as the relational structure expressing a system of linear equations over F2 such that each equation has arity three. Lemma 6.6 ([4]). Testing HOM(3LIN) requires Ω(n) queries even if m = O(n). We introduce the notion of type set of an algebra and of a variety. Roughly speaking, the type set of a finite algebra is a subset of the set 1, 2, 3, 4, 5 whose elements are called types and correspond to certain classes of algebras: 1 to unary algebras, 2 to vector spaces over finite fields, 3 to Boolean algebras, 4 to distributive lattices and 5 to semilattices. See [23] for details. If V is a variety, the type set of V is the union of the type sets of the finite algebras in V. We say that an algebra or variety admits (omits) type i when i is (is not) in its type set. Lemma 6.7 ([26]). Let A be an idempotent algebra such that V(A) admits type 1. There exists an algebra B ∈ V(A) such that 3LIN ∈ Str(B). Lemma 6.8 ([14]). Let H be a non bi-arc graph. Then, V(HL) admits type 1. Proof of Lemma 6.1. Assume that LHOM(H) is testable with o(n) queries when m = O(n). Then, from Lemma 6.4, HOM(HL) is testable with o(n) queries. Then, from Lemma 6.5, HOM(H′) is testable with o(n) queries for any H′ ∈ V(HL). However, HL is idempotent and V(HL) admits type 1 from Lemma 6.8. Thus, 3LIN ∈ V(HL) from Lemmas 6.7, and testing 3LIN requires Ω(n) queries from Lemma 6.6. Contradiction. References [1] N. Alon, E. Fischer, I. Newman, and A. Shapira. A combinatorial characterization of the testable graph properties: it's all about regularity. In Proc. 38th ACM symposium on Theory of computing, pages 251 -- 260, 2006. [2] N. Alon and A. Shapira. Testing satisfiability. Journal of Algorithms, 47:87 -- 103, 2003. [3] L. Barto and M. Kozik. Cyclic terms in algebraic approach to CSP. In Proc. 25th IEEE Symposium on Logic in Computer Science, volume 1, 2010. [4] E. Ben-Sasson, P. Harsha, and S. Raskhodnikova. Some 3cnf properties are hard to test. SIAM Journal on Computing, 35(1):1 -- 21, 2006. 14 [5] A. Bhattacharyya, E. Grigorescu, and A. Shapira. A unified framework for testing linear- invariant properties. In Proc. 51st IEEE Symposium on Foundations of Computer Science, pages 478 -- 487, 2010. [6] V. G. Bodnarchuk, L. A. Kaluzhnin, V. N. Kotov, and B. A. Romov. Galois theory for post algebras. i. Cybernetics and Systems Analysis, 5(3):243 -- 252, 1969. [7] V. G. Bodnarchuk, L. A. Kaluzhnin, V. N. Kotov, and B. A. Romov. Galois theory for post algebras. ii. Cybernetics and Systems Analysis, 5(5):531 -- 539, 1969. [8] A. Bulatov. H-coloring dichotomy revisited. Theoretical Computer Science, 349(1):31 -- 39, 2005. [9] A. Bulatov. Combinatorial problems raised from 2-semilattices. Journal of Algebra, 298(2):321 -- 339, 2006. [10] A. Bulatov and M. Valeriote. Recent results on the algebraic approach to the CSP. Complexity of Constraints, pages 68 -- 92, 2008. [11] L. Egri, A. Krokhin, B. Larose, and P. Tesson. The complexity of the list homomorphism problem for graphs. In Proc. 27th International Symposium on Theoretical Aspects of Computer Science, volume 5, pages 335 -- 346, 2010. [12] T. Feder and P. Hell. List homomorphisms to reflexive graphs. Journal of Combinatorial Theory, Series B, 72(2):236 -- 250, 1998. [13] T. Feder, P. Hell, and J. Huang. List homomorphisms and circular arc graphs. Combinatorica, 19(4):487 -- 505, 1999. [14] T. Feder, P. Hell, and J. Huang. Bi-arc graphs and the complexity of list homomorphisms. Journal of Graph Theory, 42(1):61 -- 80, 2003. [15] T. Feder and M.Y. Vardi. The computational structure of monotone monadic snp and con- straint satisfaction: A study through datalog and group theory. SIAM Journal of Computing, 28(1):57 -- 104, 1998. [16] E. Fischer, E. Lehman, I. Newman, S. Raskhodnikova, R. Rubinfeld, and A. Samorodnitsky. Monotonicity testing over general poset domains. In Proc. 34th ACM symposium on Theory of computing, pages 474 -- 483, 2002. [17] O. Goldreich. Introduction to testing graph properties, 2010. [18] O. Goldreich, S. Goldwasser, and D. Ron. Property testing and its connection to learning and approximation. Journal of the ACM, 45(4):653 -- 750, 1998. [19] O. Goldreich and D. Ron. A sublinear bipartiteness tester for bounded degree graphs. Com- binatorica, 19(3):335 -- 373, 1999. [20] P. Hell. Algorithmic aspects of graph homomorphisms. Surveys in Combinatorics, 307:239 -- 276, 2003. [21] P. Hell and J. Nesetril. On the complexity of h-coloring. Journal of Combinatorial Theory, Series B, 48(1):92 -- 110, 1990. 15 [22] P. Hell and J. Nesetril. Colouring, constraint satisfaction, and complexity. Computer Science Review, 2(3):143 -- 163, 2008. [23] D.C. Hobby, R. McKenzie, and American Mathematical Society. The structure of finite alge- bras. American Mathematical Society, 1988. [24] P. Jeavons, D. Cohen, and M. Gyssens. Closure properties of constraints. Journal of the ACM, 44(4):527 -- 548, 1997. [25] T. Kaufman and M. Sudan. Algebraic property testing: the role of invariance. In Proc. 40th ACM symposium on Theory of computing, pages 403 -- 412, 2008. [26] A. Krokhin, A. Bulatov, and P. Jeavons. The complexity of constraint satisfaction: an algebraic approach. Structural theory of automata, semigroups, and universal algebra, pages 181 -- 213, 2005. [27] D. Ron. Algorithmic and analysis techniques in property testing, 2009. [28] E. Szemer´edi. Regular partitions of graphs. Probl`emes combinatoires et th´eorie des graphes, 260:399 -- 401, 1975. [29] Y. Yoshida. Optimal constant-time approximation algorithms and (unconditional) inapprox- imability results for every bounded-degree CSP. In Proc. 43rd ACM symposium on Theory of computing, pages 665 -- 674, 2011. [30] Y. Yoshida and Y. Kobayashi. Testing (s, t)-disconnectivity of graphs and digraphs, 2011. manuscript. 16
1401.0119
1
1401
2013-12-31T09:41:59
Expected time complexity of the auction algorithm and the push relabel algorithm for maximal bipartite matching on random graphs
[ "cs.DS" ]
In this paper we analyze the expected time complexity of the auction algorithm for the matching problem on random bipartite graphs. We prove that the expected time complexity of the auction algorithm for bipartite matching is $O\left(\frac{N\log^2(N)}{\log\left(Np\right)}\right)$ on sequential machines. This is equivalent to other augmenting path algorithms such as the HK algorithm. Furthermore, we show that the algorithm can be implemented on parallel machines with $O(\log(N))$ processors and shared memory with an expected time complexity of $O(N\log(N))$.
cs.DS
cs
Expected time complexity of the auction algorithm and the push relabel algorithm for maximal bipartite matching on random graphs Oshri Naparstek and Amir Leshem January 3, 2014 Abstract In this paper we analyze the expected time complexity of the auction al- (cid:16) N log2 (N ) (cid:17) gorithm for the matching problem on random bipartite graphs. We prove that the expected time complexity of the auction algorithm for bipartite matching is O on sequential machines. This is equivalent to other aug- log(N p) menting path algorithms such as the HK algorithm. Furthermore, we show that the algorithm can be implemented on parallel machines with O(log(N )) processors and shared memory with an expected time complexity of O(N log(N )). 1 Introduction One of the most extensively studied problems in combinatorial optimization in the last 50 years known as the Bipartite Maximum Cardinality Matching (BMCM). The main goal of the BMCM problem is to find an assignment where the maxi- mal number of vertices are matched on bipartite graphs, thus making it a special case of the max-flow problem as well as the max-sum assignment problem. Hence, any algorithm that solves one of these problems also solves the BMCM problem. (cid:16)√ (cid:17) Most of the algorithms that solve the BMCM problem are augmenting paths algo- rithms.The Hopcroft-Karp (HK) algorithm [HK73] is one of the most well-studied of these. The HK algorithm has a worst case time complexity of O where N m (cid:16) √ (cid:17) N is the number of vertices in the bipartie graph and m is the number of edges in the graph. The HK algorithm was revisited more recently by Feder and Mot- wani [FM91] and was proven to have a worst case time complexity of O . N m log(N ) Another well known augmenting path algorithm that solves the BMCM problem is Dinic’s algorithm [Din70]. Motwani [Mot94] proved that Dinic’s algorithm 1 (cid:16) m log(N ) (cid:17) achieves perfect matching on random bipartite graphs with an expected running (cid:17) (cid:16) √ time of O where ∆ is the expected number of neighbours per vertex. log ∆ It was later shown by Bast et al. [BMST06] that algorithms that use the shortest . Recently it augmenting paths, have an expected time complexity of O N m log(N ) was shown by Frize et al. [CF+10] that maximum cardinality matching can be found on sparse random graphs with an expected time complexity of O (m) using a combination of the Karp-Sipser heuristic and an augmenting path. Goel et al. [GKK10] presented an algorithm with an expected time of N log(N ) iterations on regular bipartite graphs. Other solutions to the BMCM problem that do not use the augmenting path method include the auction algorithm [Ber79] and the push relabel (PR) algorithm [GT88]. The main difference between the augmenting path algorithms described above and these algorithms is that in augmenting path algorithms, an augmenting path is first found and then augmented. By contrast, in the auction and PR algo- rithms, only two edges are augmented on each iteration according to some update rule. It was shown by both Goldberg [GK95] and Bertsekas [BC92] that the push relabel algorithm and the auction algorithm are equivalent. Since these algorithms are equivalent we will refer only to the auction algorithm from now on. The av- erage time complexity of the auction algorithm is not known and the problem of calculating it has remained unresolved more than 30 years. However, in many cases it has been shown that the auction algorithm converges faster than other methods in solving the assignment problem [BoTLfIS90]. Furthermore, several experimental studies [Set93, S+96, CGM+98, KLMU12] showed that in practice, auction algo- rithms outperforms augmenting paths based algorithms on many real life scenarios for the solution of the BMCM problem. Bertsekas [BCT91] conjectured that the average running time of the auction algorithm would be O (m log(N )) on bipartite graphs with uniformly distributed weights where m is the number of edges in the bipartite graph and N is the number of vertices on each side of the graph. In this paper we analyze the average time complexity of the auction algorithm (cid:16) N log2 (N ) (cid:17) for the BMCM problem. We prove that the expected time complexity of the auction algorithm for random bipartite graphs where each edge is independently selected (cid:17) (cid:16) c log N with probability p ≥ 2 log(N ) is O on sequential machines. We show (cid:16) N log2 (N ) (cid:17) N log(N p) that by reducing the density of the graph such that p = O N ity reduces to O . We then present a parallel implementation of the log(log(N )) algorithm for parallel machines with O (log(N )) processors and a shared mem- ory. We prove that the expected time complexity of the parallel implementation is O(N log(N )). the complex- 2 2 Notation and problem formulation Definition 1 Let G = (V , E ) be a graph with a vertex set V and an edge set E . The neighbor set of vertex v ∈ V is given by nv = {u ∈ V : {u, v} ∈ E } (1) Definition 2 Let G = (U, V , E ) be bipartite graph with vertex sets U = V = N and an edge set E . Let M ⊆ E and let G( U , V , M ) be a bipartite subgraph of G with vertex sets U , V = N and an edge set M . We say that M is a matching on G if nv = 1 max v∈U ∪V Definition 3 Let G = (U, V , E ) be bipartite graph with vertex sets U = V = N and an edge set E . If M is a matching and M = N then we say M is a perfect matching. Definition 4 Let G = (U, V , E ) be bipartite graph with vertex sets U = V = N and an edge set E . Let M ⊆ E and let G(U, V , M ) be a bipartite subgraph of G with vertex sets U , V = N and an edge set M . We say that a vertex v ∈ U ∪ V is free if nv = 0 otherwise we say it is not free. (2) Definition 5 Let G = (V , E ) be a graph with vertex set V and an edge set E . A path P of length l is an ordered set with l + 1 vertices {v1 , v2 , .., vl+1} such that vi ∈ V , ∀i = 1..l + 1 and (vi , vi+1 ) ∈ E , ∀i = 1..l. Definition 6 Let G = (U, V , E ) be bipartite graph with vertex sets U = V = N and an edge set E . Let M be a non-maximal matching on G. An alternating path P on G given partial matching M is a path where (vi , vi+1 ) ∈ M if i is even and (vi , vi+1 ) /∈ M if i is odd. An illustration of an alternating path is shown in Fig 1. Definition 7 Let G = (U, V , E ) be a bipartite graph with vertex sets U = V = N and an edge set E . Let M be a non-maximal matching. An augmenting path of M is an alternating path on G that starts at a free vertex in U and ends at a free vertex in V . The BMCM problem is defined as follows: Let G = (U, V , E ) be a bipartite graph with vertex set U ∪ V and an edge set E . Find an assignment M with maximal number of edges. 3 Figure 1: Alternating path 1 3 The auction algorithm The auction algorithm [Ber79] is an intuitive method for solving the assignment problem. In many cases it has been shown to converge faster than other methods for this case [BoTLfIS90]. Auctions in which unassigned people raise their prices and bid for objects simultaneously was the original inspiration for the auction al- gorithm. Similarly, the auction algorithm has two stages, the bidding stage and the assignment stage. In the bidding stage each unassigned individual raises the price of the object he wishes to acquire by the difference between the most profitable ob- ject and the second most profitable object plus some constant . In the assignment stage every object is assigned to the highest bidder. The two stages are repeated until all bidders are assigned an object. More specifically, let R be the matrix of the initial rewards. Let B be a matrix of the bids. ρ is the price vector where ρk is given by: ρk = max n Let η = [η1 , η2 , ..., ηN ] be an assignment (permutation) vector where ηn is the object that is assigned to the n’th person; i.e., the matching {(Un , Vηn ) : n = 1..N } is a perfect matching. (Un , Vηn ) ∈ M (4) B(n, k) (3) Definition 8 An object k is said to be assigned to person n by η if ηn = k . The reward of the n’th person on assignment η is denoted by R(n, ηn ) and the price that the n’th person pays on assignment η is denoted by ρηn . Given a pos- itive scalar , an assignment η and a price ρηn , a person n is termed happy with 4 UV12341234 Table 1: The Auction algorithm (Bertsekas 79) Select  > 0, set all the people as unassigned and set ρk = 0, n = 1..N Repeat until all the people are assigned 1. Choose an unassigned person n 2. Calculate his maximum profit γn = maxk (R(n, k) − ρk ) 3. Calculate the second maximum profit k = arg maxk (R(n, k) − ρk ) ωn = maxk (cid:54)=k (R(n, k) − ρk ) 4. Assign object k to person n. If this object has been assigned to another person, make this person unassigned (and as a result unassigned). 5. Set person n as assigned 6. Update the price of object k to be ρk = ρk + γn − ωn +  end assignment η if the profit (i.e., reward minus price) is within  of the maximal profit achievable by person n. This condition is called -Complementary slackness (-CS). (R(n, k) − ρk ) −  R(n, ηn ) − ρηn ≥ max k When all the people are assigned and happy, the algorithm stops. It was shown in [Ber79] that the algorithm terminates in finite time. The algorithm is within N  of being optimal at termination [Ber79]. Also, if the initial prices are all zeros and N ≤ K the algorithm still converges in finite time and with the same bounds on optimality. The original Bertsekas auction algorithm is depicted in Table 1. (5) 4 A simplified auction algorithm for maximal bipartite matching The BMCM problem is a special case of the assignment problem where the values in the reward matrix are either 0 or 1. Furthermore, since the reward matrix is integer valued, the choice of  = 1 N is sufficient for obtaining an optimal solution [Ber79]. The cardinality of a matching is the number of vertices that were assigned to edges with weight 1. Here we simplify the auction algorithm and assume that on each iteration an unassigned person is picked and raises the price of his most 5 desirable object by exactly . Under this assumption, the price ρk = hk N where hk is the number of times that the price of the k’th object was raised. We further simplify the algorithm and assume that a person would only bid on objects with positive rewards. Under this assumption the -CS condition 5 for an object with a positive reward becomes: (6) 1 − hηn N ≥ max k (1 − hk N ) − 1 N . (7) (8) Multiplying both sides by N and rearranging yields a simplified -CS condition for the BMCM problem hηn − 1 ≤ min (hk ). k Using the simplified -CS condition we can derive a simplified version of the auc- tion algorithm for the BMCM problem. On each iteration an unassigned person is chosen, the person is assigned to the k’th channel with minimal hk and raises it by 1. The description of the algorithm using graph theory terminology is as follows: Let G = (U, V , E ) be a bipartite graph with vertex sets U, V where U = V = N and an edge set E . Let h = [h1 , h2 , ..., hN ] be the value assigned to the vertices in V . On each iteration a free vertex u ∈ U is assigned to a vertex v ∈ V with minimal value hk . If another vertex was previously assigned to that vertex it be- comes free. The algorithm stops after a perfect matching is found or the number of iterations is larger than N 2 + N . The algorithm is depicted in Table 4. Note that the simplified auction algorithm is equivalent to the push relabel algorithm with double push [GK95]. 5 The average number of iterations of the simplified auc- tion algorithm for the BMCM problem In this section we analyze the expected time complexity of the simplified auction algorithm for the BMCM problem. Observation 1 Let T be the number of iterations until the algorithm terminates and let hv be the value of vertex v at termination, then N(cid:88) v=1 T = (9) hv 6 Table 2: Simplified auction algorithm for maximal matching in bipartite graphs 2. While M < N and (cid:80)N 1. Initialize hv = 0, ∀v ∈ V and set M = ∅ k=1 hk < N (N − 1) do (a) Choose a free vertex u ∈ U (b) j = arg minv∈nu hv (c) M = M ∪ (u, j ) (d) uold = {u ∈ U : (u, j ) ∈ M } (e) M = M \ (uold , j ) (f) hj = hj + 1 3. Return Proof: The proof is trivial since on every iteration the value of exactly one (cid:3) vertex is increased by 1. Lemma 1 Let G = (U, V , E ) be a bipartite graph with vertex sets U = V = N and an edge set E . Let M (i) ⊆ E be a non maximal matching obtained by the algorithm in the i’th iteration. Let hv (i) be the value of vertex v in the i’th iteration of the algorithm. Let Dl (i) be a subset of V defined by: Dl (i) = {v ∈ V : hv (i) ≥ l} . If v0 ∈ Dl (i) and (u, v0 ) ∈ M (i) then nu ⊆ Dl−1 (i) Proof: If v0 ∈ Dl (i) and (u, v0 ) ∈ M (i) it implies that v0 = arg min v∈nu for some k < i and hv (k) (10) (11) hv0 (k + 1) = hv0 (k) + 1 = l. This implies that for every vertex v ∈ nu in the (k + 1)’th iteration hv (k + 1) ≥ hv (k + 1) − 1 = hv (k) = l − 1. This implies that in the k’th iteration nu ⊆ Dl−1 (k). (12) (13) (14) 7 Since hv (n) is a non-decreasing function of n (prices never go down) nu ⊆ Dl−1 (k) ⊆ Dl−1 (i). An illustration of lemma 1 is given in Figure 2. (15) (cid:3) Figure 2: An illustration of lemma 1 Claim 2 Let G = (U, V , E ) be bipartite graph with vertex sets U = V = N and an edge set E . Let M (i) be a non maximal matching obtained by the algorithm in the i’th iteration. Let u0 ∈ U be a free vertex such that in the i’th iteration of the algorithm nu0 ⊆ Dl (i). Let u1 ∈ U be the end point of an alternating path P with P = 2 starting from u0 then v (cid:54)∈ Dl−2 (i) \ Dl−1 (i) ∀v ∈ nu1 (16) Proof: We first observe that if nu0 ⊆ Dl (i), then by definition for every vertex v ∈ nu0 v (cid:54)∈ Dl−1 (i) \ Dl (i). (17) By the definition of an alternating path, if nu0 ⊆ Dl (i) there exists a vertex j ∈ nu1 ∩ nu0 such that (u1 , j ) ∈ M (i), (u0 , j )(cid:54)∈M (i) and j ∈ Dl (i). Hence, by lemma 1 it implies that nu1 ⊆ Dl−1 (i). (18) 8 Reapplying the lemma implies that for every vertex v ∈ nu1 v (cid:54)∈ Dl−2 (i) \ Dl−1 (i). (19) (cid:3) Lemma 3 Let G = (U, V , E ) be bipartite graph with vertex sets U = V = N and an edge set E . Let M (i) be a non maximal matching obtained by the algorithm in the i’th iteration and let u0 ∈ U be a free vertex such that in the i’th iteration of the algorithm nu0 ⊆ Dl (i); then every augmenting path of G on M (i) starting from u0 is at least of length 2l + 1. Proof: Let um ∈ U be the end point of an alternating path P with P = 2m starting from u0 . By recursively applying claim 2 we get that for every vertex v ∈ num v (cid:54)∈ Dl−m−1 (i) \ Dl−m (i). (20) The last vertex in an augmenting path is a free vertex. Note that a vertex v ∈ V is free only if v ∈ D0 (i) \ D1 (i). However, from equation 20 if nu0 ⊆ Dl (i) then for all v ∈ num , m ≤ l, v (cid:54)∈ D0 (i) \ D1 (i). This means that if P is an augmenting path that starts from u0 there are at least l odd elements on P . This implies that any augmenting path that starts from u0 has (cid:3) at least 2l + 1 elements. A well-known theorem by Berge [Ber57] states that if a bipartite graph G contains a perfect matching there exists an augmenting path in G with respect to any non maximal matching M . Theorem 4 [Ber57] Let G = (U, V , E ) be a bipartite graph with vertex sets U = V = N and an edge set E . If G contains a perfect matching there exists an augmenting path in G for any partial matching M . (22) (21) We will now use the above theorem and lemma 3 to prove the following lemma: Lemma 5 Let G = (U, V , E ) be a bipartite graph with vertex sets U = V = N and an edge set E . If G contains a perfect matching and for any non-perfect matching M ⊆ E there exists an augmenting path of length at most 2l + 1, then for each free vertex u ∈ U and a partial matching M (i) obtained by the algorithm in the ith iteration there exists at least one neighbor j ∈ nu such that hj (i) ≤ l on each iteration of the algorithm. 9 Proof: Assume towards contradiction that G contains a perfect matching and for any non-perfect matching M ⊆ E there exists an augmenting path of length at most 2l + 1 but on the i’th iteration there exists a free vertex u with respect to M (i) such that if j ∈ Nu then hj (i) > l. This means that nu ⊆ Dl+1 (i). By lemma 3 each augmenting path that begins at u is of length of at least 2l + 3. However, our assumption is that for any non maximal matching M of G there exists at least one augmenting path of length 2l + 1 or less. This implies that u is not the starting vertex of any augmenting path of G on M (i). This also implies that u is not the starting vertex of any augmenting path of G on M (j ) for any j ≥ i. This is true since we know from lemma 1 that Dm (i) ⊆ Dm (j ), ∀m, ∀j ≥ i Hence, u is not the starting vertex of an augmenting path of G on M (j ) where M (j ) = N − 1. This implies that there is no augmenting path of length at most 2l + 1 to M (j ). This can occur in two situations: (23) 1. No augmenting path exists to G on M (j ). Theorem 4 implies that no per- fect matching exists for G in contradiction to the assumption that a perfect matching exists. 2. There exists an augmenting to G on M (j ) but with length at least 2l + 3. This is a contradiction to our assumption that every non maximal matching contains an augmenting path of length at most 2l + 1 (cid:3) Lemma 6 Let G = (U, V , E ) be a bipartite graph with vertex sets U = V = N and an edge set E . If G contains a perfect matching and for any non-perfect matching M ⊆ E there exists an augmenting path of length at most 2l + 1, then for every v ∈ V at each iteration of the algorithm until the algorithm terminates hv (i) ≤ l + 1, ∀i, v ∈ V (24) Proof: On each iteration i, the free vertex from U select a vertex j such that j = arg minv∈nu hv (i) and set hj (i + 1) = hj (i) + 1. However, we assume that G contains a perfect matching and for any non-perfect matching M ⊆ E there exists an augmenting path of length at most 2l + 1. Hence, by lemma 5 to any free vertex at the i’th iteration with respect to a partial matching M (i) there exists a vertex v0 such that hv0 (i) ≤ l. This means min v∈nu hv (i) ≤ l, ∀i. (25) 10 As a result, if there exists vertex v0 ∈ V where hv0 (i) = l + 1 then hv (i) (cid:54)= v0 . arg min v∈nu This implies that if hv0 (i) = l + 1 its value never rises and as a result hv (i) ≤ l + 1, ∀i, v ∈ V . (26) (27) (cid:3) Lemma 7 Let G = (U, V , E ) be a bipartite graph with vertex sets U = V = N and an edge set E . If G contains a perfect matching then T ≤ N (N − 1) (28) Proof: G contains 2N vertices. Hence, every path is of length at most 2N − 1 and in particular every augmenting path is of length at most 2N − 1 for any non maximal matching. By lemma 6 we get that hv (i) ≤ N − 1, ∀i, v ∈ V N(cid:88) v=1 hv ≤ N (N − 1) Using lemma 1 we get: (29) (30) T = (cid:3) Definition 9 Let G = (U, V , E ) be bipartite graph with vertex sets U = V = N and an edge set E . If G is a random graph where each edge occurs with probability p we say that G ∈ B (N , p). Definition 10 G ∈ B (N , p) if G ∈ B (N , p) and for any non-maximal matching M there exists an augmenting path for M of length at most 2L + 1 where L = c log(N ) log(N p) and c > 0 is some constant. Observation 2 Let G ∈ B (N , p) and let and let T be the number of iterations until the algorithm terminates then T ≤ N (L + 1). (31) where L = c log(N ) log(N p) . 11 Proof: G ∈ B (N , p); hence, for any non maximal matching M there exists an augmenting path of length at most 2L + 1. let L = c log(N ) log(N p) , then by lemma 6 we get that hv (i) ≤ L + 1, ∀i, v ∈ V . (32) Using lemma 1 we get: N(cid:88) v=1 T = hv ≤ N (L + 1) = N c log(N ) log(N p) + N . (33) (cid:3) The following theorem was proven in [Mot94]: Theorem 8 Let G ∈ B (N , p) where p ≥ (1+) log(N ) exists Nγ such that for every N ≥ Nγ N Pr(G ∈ B (N , p)) ≥ 1 − N −γ . then for every γ > 0 there (34) The following theorem was proven in [ER66]: Theorem 9 Let G = (U, V , E ) ∈ B (N , p) and p = c log(N ) N , c > 2 then N →∞ Pr (G contains a perfect matching) = e−2N 1−c lim We now prove the main theorem of the paper: Theorem 10 Let G ∈ B (N , p) be a random bipartite graph with N > Nγ vertices on each side and p = c log(N ) N , c > 2. Then the expected number of iterations until (cid:18) N log(N ) (cid:19) the algorithm terminates is: log(N p) E (T ) ≤ O (36) . (35) Proof: Let A = {G ∈ B (N , p) : G does not contains a perfect matching} and let B = {G ∈ B (N , p) \ B (N , p)}. From Theorem 8 we know that there exists Nγ such that for every N > Nγ Pr (B ) ≤ N −γ . (37) (38) (39) 12 From theorem 9 we know that if (G ∈ B (N , p)), p > c log(N ) N exists N1 such that for every N > N1 N c−1 ≤ 2 Pr (A) ≤ 2 N . let γ ≥ 1 and let N be N = max(Nγ , N1 ) and c > 2, there (40) (41) (42) (43) (44) (45) (46) (47) (cid:3) Pr let B (N , p) be B (N , p) = {G : G contains a perfect matching} ∩ B (N , p). (cid:17) (cid:16) Using the union bound, = 1 − Pr (A ∪ B ) ≥ 1 − Pr(A) − Pr(B ) G ∈ B (N , p) If N ≥ N , p = c log(N ) (cid:17) ≥ 1 − 3 (cid:16) , c > 2 then n G ∈ B (N , p) Pr N (cid:40) From lemma 7 and Lemma 2 we know that: N (N − 1), G (cid:54)∈ B (N , p) T ≤ log(N p) + N , G ∈ B (N , p) N c log(N ) (cid:19) (cid:19) (cid:18) N c log(N ) (cid:18) this implies that if N ≥ N , p = c log(N ) , c > 2 then n (cid:18) N log(N ) (cid:19) 1 − 3 E (T ) ≤ N log(N p) log(N p) (N 2 − N ) = 3 N + N + = O . . , If p = c log(N ) N (cid:18) N log(N ) the number of iterations is log(log(N )) O (cid:19) . 13 6 Expected time complexity (cid:16) N log2 (N ) (cid:17) In this section we use the results from the previous section to analyze the expected time complexity of the algorithm in sequential and parallel implementations. We first prove that the expected running time of the algorithm is O on log(N p) sequential machines. We point out that if the graph is dense it is advantageous to take a random sparse subgraph of the original graph and perform the algorithm on the sparse subgraph. Then, we introduce a parallel implementation of the algorithm for machines with Q processors and a shared memory. We prove that if Q = O(log(N )) the expected time complexity is O (N log(N )). 6.1 Sequential implementation (cid:16) N log(N ) (cid:17) We now analyze the expected time complexity of the algorithm for random bipartite graphs from B (N , p) on sequential machines. From Theorem 10 we know that the (cid:17) (cid:16) N log2 (N ) . Hence we need to expected number of iterations is bounded by O log(N p) show that the expected numbed of operations per iteration is O (log(N )). The next time theorem shows that the algorithm can be implemented with O log(N p) complexity on sequential machines. Theorem 11 Let G = (U, V , E ) ∈ B (N , p) be a random bipartite graph with (cid:17) (cid:16) N log2 (N ) p ≥ c log(N ) N ,c > 2 then the algorithm finds a maximal matching on a sequential machine with one processor with the expected time bounded by O log(N p) Proof: (cid:18) N log(N ) (cid:19) In section 5 we proved that the expected number of iterations until convergence is bounded by log(N p) where T is the number of iterations until convergence. Define Tinner to be the number of operations needed in each iteration and Ttotal to be the total number of operations preformed by the algorithm. All of the operations in each iterations are O(1) except for the operation of finding a vertex with minimal value for the chosen vertex u which requires O(nu ) operations where nu is the number of neighbours of vertex u. Since the number (cid:19) (cid:18) pN 2 log(N ) of neighbors of each vertex is an independent random variable and E (nu ) = N p then log(N p) E (Ttotal ) = E (T ) E (Tinner ) = O E (T ) ≤ O (48) (49) 14 If E (nu ) = O (log(N )) then (cid:18) N log2 (N ) (cid:19) (50) E (Ttotal ) = O log log(N ) (cid:3) time complexity of O (cid:0)N 2 log(N )(cid:1) which is not particularly good. To improve the When the graph is dense; i.e., E (nu ) = O(N ) the algorithm converges with a expected running time performance, we can obtain a sparse random graph from the dense graph by randomly choosing d edges from the original dense graph where d is binomially distributed as ) (51) d ∼ B in(E , c log(N ) N p Let G be the sparse graph obtained from G by randomly selecting d edges of G. on G with O (cid:0)N 2(cid:1) iterations. Hence, the expected time complexity even for dense If G contains a perfect matching, a solution for the MCM problem for G is also a solution for G. If G doest not contain a perfect matching the algorithm is applied (cid:18) (cid:19) (cid:18) N log2 (N ) (cid:19) O (cid:0)N 2 log(N )(cid:1) = graphs remains: (cid:18) N log2 (N ) (cid:19) 1 − 2 E (Ttotal ) ≤ N log log(N ) log log(N ) (52) O + 2 N = O 6.2 Parallel Implementation We now analyze a parallel implementation of the algorithm on a machine with Q (cid:16) N log(N ) (cid:17) processors and a shared memory. We show that if Q = O (log(N )) the expected time complexity of the algorithm is O (N log(N )). As in the sequential case, the (cid:16) N log(N ) (cid:17) expected number of outer iterations is T = O . This implies that for log(N p) p = c log(N ) . In the parallel implementation we keep a sorted T = O N log(log(N )) tree for each vertex of u ∈ U . If G is a random graph with p = c log(N ) then N E (nu ) = c log(N ), ∀u ∈ U E (nv ) = c log(N ), ∀v ∈ V This implies that on each iteration we need to maintain O (log(N )) sorted trees with an expected number of O (log(N )) elements per tree. The maintenance of each sorted tree can be done in parallel over Q processors with O (log (log(N ))) (53) 15 operations per processor. Hence, the expected time complexity for the parallel (cid:18) N log2 (N ) (cid:19) implementation is given by: Q E (Ttotal ) = E (T )E (Tinner ) = O (54) and if Q = O(log(N )) the expected time becomes E (Ttotal ) = O (N log(N )) (55) Note that if G is not sparse we can obtain a sparse graph from the dense graph and use the same arguments as in the sequential implementation to get E (Ttotal ) = O (N log(N )) (56) 7 Conclusion In this paper we analyzed the expected time complexity of the auction algorithm for the matching problem on random bipartite graphs. We proved that the ex- pected time complexity of the auction algorithm for bipartite matching is just as good as other augmenting path algorithms such as the HK algorithm. Further- more, we showed that the algorithm can be implemented on parallel machines with O(log(N )) processors and a shared memory with an expected time complexity of O(N log(N )). References [BC92] [BCT91] [Ber57] [Ber79] D.P. Bertsekas and D.A. Casta non, A forward/reverse auction al- gorithm for asymmetric assignment problems, Computational Opti- mization and Applications 1 (1992), no. 3, 277–297. D.P. Bertsekas, D.A. Castanon, and H. Tsaknakis, Reverse auction and the solution of inequality constrained assignment problems, Un- published Report (1991). C. Berge, Two theorems in graph theory, Proceedings of the National Academy of Sciences of the United States of America 43 (1957), no. 9, 842. D.P. Bertsekas, A distributed algorithm for the assignment problem, Lab. for Information and Decision Systems Working Paper, MIT (1979). 16 [BMST06] Holger Bast, Kurt Mehlhorn, Guido Schafer, and Hisao Tamaki, Matching algorithms are fast in sparse random graphs, Theory of Computing Systems 39 (2006), no. 1, 3–14. [BoTLfIS90] D.P. Bertsekas, Massachusetts Institute of Technology. Labora- tory for Information, and Decision Systems, An auction algorithm for shortest paths, Massachusetts Institute of Technology, Labora- tory for Information and Decision Systems, 1990. [CF+10] Prasad Chebolu, Alan Frieze, et al., Finding a maximum matching in a sparse random graph in o (n) expected time, Journal of the ACM (JACM) 57 (2010), no. 4, 24. [CGM+98] Boris V Cherkassky, Andrew V Goldberg, Paul Martin, Jo ao C Se- tubal, and Jorge Stolfi, Augment or push: a computational study of bipartite matching and unit-capacity flow algorithms, Journal of Ex- perimental Algorithmics (JEA) 3 (1998), 8. [Din70] [ER66] [FM91] [GK95] [GKK10] Efim A Dinic, Algorithm for solution of a problem of maximum flow in networks with power estimation, Soviet Math. Dokl, vol. 11, 1970, pp. 1277–1280. P. Erd os and A. R ´enyi, On the existence of a factor of degree one of a connected random graph, Acta Mathematica Hungarica 17 (1966), no. 3, 359–368. Tom ´as Feder and Rajeev Motwani, Clique partitions, graph com- pression and speeding-up algorithms, Proceedings of the twenty- third annual ACM symposium on Theory of computing, ACM, 1991, pp. 123–133. Andrew V Goldberg and Robert Kennedy, An efficient cost scaling algorithm for the assignment problem, Mathematical Programming 71 (1995), no. 2, 153–177. Ashish Goel, Michael Kapralov, and Sanjeev Khanna, Perfect matchings in o (n log n) time in regular bipartite graphs, Proceed- ings of the 42nd ACM symposium on Theory of computing, ACM, 2010, pp. 39–46. [GT88] Andrew V Goldberg and Robert E Tarjan, A new approach to the maximum-flow problem, Journal of the ACM (JACM) 35 (1988), no. 4, 921–940. 17 [HK73] John E Hopcroft and Richard M Karp, An n5/2 algorithm for maxi- mum matchings in bipartite graphs, SIAM Journal on Computing 2 (1973), no. 4, 225–231. [KLMU12] Kamer Kaya, Johannes Langguth, Fredrik Manne, and Bora Uc¸ ar, Push-relabel based algorithms for the maximum transversal prob- lem, Computers & Operations Research (2012), 1266–1275. [Mot94] [S+96] [Set93] R. Motwani, Average-case analysis of algorithms for matchings and related problems, Journal of the ACM (JACM) 41 (1994), no. 6, 1329–1356. Jo ao C Setubal et al., Sequential and parallel experimental results with bipartite matching algorithms, University of Campinas, Tech. Rep. IC-96-09 (1996). Jo ao C Setubal, New experimental results for bipartite matching, Proceedings of netflow93 (1993), 211–216. 18
1112.2930
2
1112
2011-12-14T14:35:31
Multiple Traveling Salesmen in Asymmetric Metrics
[ "cs.DS" ]
We consider some generalizations of the Asymmetric Traveling Salesman Path problem. Suppose we have an asymmetric metric G = (V,A) with two distinguished nodes s,t. We are also given a positive integer k. The goal is to find k paths of minimum total cost from s to t whose union spans all nodes. We call this the k-Person Asymmetric Traveling Salesmen Path problem (k-ATSPP). Our main result for k-ATSPP is a bicriteria approximation that, for some parameter b >= 1 we may choose, finds between k and k + k/b paths of total length O(b log |V|) times the optimum value of an LP relaxation based on the Held-Karp relaxation for the Traveling Salesman problem. On one extreme this is an O(log |V|)-approximation that uses up to 2k paths and on the other it is an O(k log |V|)-approximation that uses exactly k paths. Next, we consider the case where we have k pairs of nodes (s_1,t_1), ..., (s_k,t_k). The goal is to find an s_i-t_i path for every pair such that each node of G lies on at least one of these paths. Simple approximation algorithms are presented for the special cases where the metric is symmetric or where s_i = t_i for each i. We also show that the problem can be approximated within a factor O(log n) when k=2. On the other hand, we demonstrate that the general problem cannot be approximated within any bounded ratio unless P = NP.
cs.DS
cs
Multiple Traveling Salesmen in Asymmetric Metrics Zachary Friggstad∗ Department of Combinatorics and Optimization University of Waterloo [email protected] June 15, 2018 Abstract We consider some generalizations of the Asymmetric Traveling Salesman Path problem. Suppose we have an asymmetric metric G = (V, A) with two distinguished nodes s, t ∈ V . We are also given a positive integer k. The goal is to find k paths of minimum total cost from s to t whose union spans all nodes. We call this the k-Person Asymmetric Traveling Salesmen Path problem (k-ATSPP). Our main result for k-ATSPP is a bicriteria approximation that, for some parameter b ≥ 1 we may choose, finds between k and k + k b paths of total length O(b log V ) times the optimum value of an LP relaxation based on the Held-Karp relaxation for the Traveling Salesman problem. On one extreme this is an O(log V )-approximation that uses up to 2k paths and on the other it is an O(k log V )-approximation that uses exactly k paths. i=1. The goal is to find an si − ti path for every pair such that each node of G lies on at least one of these paths. Simple approximation algorithms are presented for the special cases where the metric is symmetric or where si = ti for each i. We also show that the problem can be approximated within a factor O(log n) when k = 2. On the other hand, we demonstrate that the general problem cannot be approximated within any bounded ratio unless P = NP. Next, we consider the case where we have k pairs of nodes {(si, ti)}k 1 1 0 2 c e D 4 1 ] S D . s c [ 2 v 0 3 9 2 . 2 1 1 1 : v i X r a ∗Research supported by an iCORE ICT/AITF award while studying at the University of Alberta. s t Figure 1: The pictured arcs all have cost 0 and the missing arcs have cost 1. The gap between optimum solutions for k = 1 and k = 2 is unbounded. 1 Introduction We consider generalizations of the metric Traveling Salesman problem. In most of our settings we are given a complete directed graph G = (V, A) with n nodes. There are nonnegative arc costs duv, uv ∈ A satisfying the directed triangle inequality duv ≤ duw + dwv for any distinct u, v, w ∈ V . In general, duv 6= dvu for u, v ∈ V so we call such graphs asymmetric metrics. Some well-studied Traveling Salesman variants in asymmetric metrics are to find the minimum cost Hamiltonian cycle or minimum cost Hamiltonian path where some of the endpoints of the path may be specified in advance. All of these problems are NP-hard to approximate within small constant factors [27]. We will mainly study problems concerning finding multiple paths in asymmetric metrics whose union covers all nodes while minimizing the total cost of these paths. This generalizes the Asym- metric Traveling Salesman Path problem (ATSPP). Formally, define k-ATSPP to be the following problem. Given an asymmetric metric G = (V, A) with arc costs duv and two distinct nodes s, t ∈ V , we want to find k paths from s to t in G such that every node v ∈ V lies on at at least one of these paths. Finally, we define General k-ATSPP to be the following generalization of k-ATSPP. We are given k pairs of nodes (si, ti), . . . , (sk, tk) in an asymmetric metric G and we are to find an si − ti path for each i so each v ∈ V lies on at least one of these paths. Again, the goal is find such paths of minimum total cost. One thing that makes k-ATSPP an attractive variant of ATSPP is that the gap between op- timum solutions for different values of k in an asymmetric metric may be arbitrarily large. For example, the instance in Figure 1 has a solution of cost 0 using 2 paths but any single path has cost at least 1. One way to think about this is that it might be efficient to hire additional salesmen to cover the locations in an asymmetric metric. On the other hand, we do not have this large gap in symmetric metrics (i.e. when duv = dvu for all u, v ∈ V ) because a single salesman can cover all paths by traveling back and forth between s and t and cover all locations with no greater cost (if k is even then one final step from s to t makes it an s − t path while adding an extra OP T /k to the cost). 1.1 Related Work In the well-studied Traveling Salesman problem (TSP), the goal is to find a Hamiltonian cycle of minimum total edge cost in a symmetric metric. A classic result of Christofides [9] is a polynomial- time algorithm for TSP that finds a Hamiltonian cycle with cost at most 3 2 times the cost of the optimum solution. Hoogeveen [18] adapted this algorithm to the problem of finding minimum cost Hamiltonian paths. He obtains a 3 2 -approximation if at most one endpoint is fixed in advance and a 5 3 -approximation if both endpoints are fixed in advance. Recently, An, Kleinberg, and Shmoys have improved the approximability of the case when both endpoints are fixed to 1+√5 2 < 1.6181 [2]. 1 In asymmetric metrics, Frieze, Galbiati, and Maffioli [12] gave the first approximation algorithm for ATSP with an approximation ratio of log2 n where n = V . A series of papers improved on this ratio by constant factors [5, 20, 10] with the last being 2 3 log2 n. Finally, Asadpour et al. [3] produced an asymptotically better approximation algorithm for ATSP with ratio O(log n/ log log n). The variant of finding Hamiltonian paths in asymmetric metrics, namely ATSPP, has only recently been studied from the perspective of approximation algorithms. The first approximation algorithm was an O(√n)-approximation by Lam and Newman [22]. Following this, Chekuri and Pal [8] brought the ratio down to O(log n). Finally, Feige and Singh [10] proved that an α-approximation for ATSP implies a (2 + ǫ)α-approximation for ATSPP for any constant ǫ > 0. Combining their result with the recent ATSP algorithm in [3] yields an O(log n/ log log n)-approximation for ATSPP. There is a linear programming (LP) relaxation for each of these problems based on the Held- Karp relaxation for TSP [17]. For TSP, this relaxation is: minimize : Puv∈E duvxuv such that : x(δ(v)) = 2 x(δ(S)) ≥ 2 ∀ v ∈ V ∀ ∅ ( S ( V xuv ∈ [0, 1] ∀ uv ∈ E Many of the approximation algorithms mentioned above also bound the integrality gap of the respec- tive Held-Karp LP relaxation. For TSP, Wolsey [32] proved the solutions found by Christofides' al- gorithm [9] are within 3/2 of the optimal solution to the above LP relaxation. For ATSP, Williamson [31] proved that the algorithm of Frieze et al. [12] bounds the integrality gap of its respective LP by log2 n. The improved O(log n/ log log n)-approximation for ATSP in [3] improved the bound on gap to the same ratio. For TSP paths, An, Kleinberg and Shmoys [2] first showed that Hoogeveen's algorithm bounds the integrality gap of a Held-Karp type relaxation for TSP paths by 5 3 in cases where both endpoints are fixed. In the same paper they argue that their 1+√5 -approximation for this case also bounds the integrality gap by the same factor. Nagarajan and Ravi [26] first showed that the integrality gap of an LP relaxation for ATSPP, which is the same as LP (1) in this paper when k = 1, was O(√n). Later Friggstad, Salavatipour, and Svitkina [13] showed a bound of O(log n) in the integrality gap of this LP relaxation which is currently the best bound. We note that the result of Feige and Singh in [10] that relates the approximability of ATSP and ATSPP does not extend to their integrality gaps in any obvious way. In the full version of [13], the authors studied extensions of their O(log n)-approximation for ATSPP to k-ATSPP. They demonstrated that k-ATSPP can be approximated within O(k2 log n) and that this bounds the integrality gap of LP (1) by the same factor. Though not stated explicitly, their techniques can also be used to devise a bicriteria approximation for k-ATSPP that uses O(k log n) paths of total cost at most O(k log n) times the value of LP (1) in a manner similar to the algorithm in the proof of Theorem 1.3 in [13]. As far as we know, no results are known for General k-ATSPP even for the case k = 2. 2 One other problem related to one we consider is the following. We are given 2k distinct nodes S = {s1, . . . , sk} and T = {t1, . . . , tk} in a symmetric metric. We want to find k paths whose union spans all nodes. This should be such that each node in S is the start node of exacly one path and each node in T is the end node of exactly one path. Matroid intersection techniques used by Rathinam and Sengupta [28] can be easily adapted to approximate this problem within a factor 2. 1.2 Our Results By the directed triangle inequality, it is easy to see that there is an optimum solution for an instance of k-ATSPP where each node in V − {s, t} lies on precisely one of the k paths. Such an optimum 2 solution corresponds to an integer point in LP (1) of the same cost. So the optimum value of LP (1), say OP TLP , is a lower bound for the minimum cost k-ATSPP solution. Our main result for k-ATSPP is the following. Theorem 1.1 For any integer b ≥ 1, there is an efficient algorithm for k-ATSPP that finds between k and k + k b paths of total cost at most O(b log n) · OP TLP . This is an O(k log n)-approximation using precisely k paths when b = k + 1 and an O(log n)- approximation using at most 2k paths when b = 1. The algorithm is also easy to implement with the most complicated subroutine being that of finding a minimum weight perfect matching in a bipartite graph. Its running time can easily be seen to be O(M (n + k − 2)b log n) where M (N ) is the time it takes to compute such a matching in a complete bipartite graph with N nodes on each side. We then proceed to study variants of k-ATSPP that vary how the start and/or end locations are specified. Examples are when the start locations are not fixed or when we have a set of k start nodes S and a set of k end nodes T and the start and end locations of the paths should establish a bijection between S and T . We extend our approximation algorithm for k-ATSPP to these variants. Finally, we study General k-ATSPP. Our first result is an O(log n) for General 2-ATSPP. We also have a 3-approximation for General k-ATSPP in symmetric metrics and an O(log n)-approximation for General k-ATSPP when si = ti for all i. However, we have the following hardness result for General k-ATSPP with no further restrictions. Theorem 1.2 It is NP-hard to distinguish between instances of General k-ATSPP whose optimum solution has cost 0 and instances whose optimum solution has cost at least 1. This implies the problem cannot be efficiently approximated within any bounded ratio unless P = NP. While the reduction uses k = n/4, modifications can be made to prove hardness results (under stronger assumptions) for values of k being as small as polylogarithmic in n. To summarize, Section 2 presents the algorithm for k-ATSPP, proves Theorem 1.1, and discusses some variations of k-ATSPP on how the start and/or end locations are specified. In Section 3 we demonstrate an O(log n)-approximation for General 2-ATSPP, discuss approximation algorithms for other restrictions of General k-ATSPP, and prove Theorem 1.2. Section 4 then concludes this paper by identifying some directions for future work and mentioning some basic results for the alternative goal of minimizing the cost of the most expensive path in either k-ATSPP or General k-ATSPP. 2 A Bicriteria Approximation for k-ATSPP In this section, we will develop a bicriteria approximation algorithm that finds approximately k paths from s to t in an asymmetric metric G = (V, A) whose total cost is within some bounded ratio of the optimum value of LP relaxation (1). The algorithm is parameterized by a positive integer b; different bicriteria approximation guarantees result from different choices of b. 2.1 Preliminaries If X is a flow between two nodes or a circulation then we let Xuv denote the value that X assignes to arc uv ∈ A. For S ⊆ V we let X(δ+(S)) = Pu∈S,v∈V −S Xuv and X(δ−(S)) = Pv∈V −S,u∈S Xvu. For brevity, we let X(δ+(v)) := X(δ+({v})) and X(δ−(v)) := X(δ−({v})) for v ∈ V . We say X is 3 integral if Xuv is an integer for each arc uv ∈ A. The cost of X is Puv∈A duv · Xuv. All flows and circulations X in this paper will have Xuv ≥ 0 for each arc uv ∈ A. covers from [22] and [13]. Our starting point will be to use structures similar to cycle covers from [12] and path/cycle Definition 2.1 A k-path/cycle cover from s to t is an integral flow F such that F (δ+(v)) = F (δ−(v)) = 1 for each v ∈ V − {s, t}, F (δ+(s)) = F (δ−(t)) = k, and F (δ−(s)) = F (δ+(t)) = 0. Note that in a k-path/cycle cover F the flow Fuv across any arc uv ∈ A − {st} is either 0 or 1 and Fst ≤ k. If we regard F as a multiset of arcs, then F may be decomposed into k paths from s to t and a collection of cycles where every v ∈ V − {s, t} lies on exacly one path or exactly one cycle. We can efficiently find a minimum-cost k-path/cycle cover using a standard reduction to minimum weight perfect matching in a bipartite graph with n + k − 2 nodes on each side. ATSPP considered in [26] and [13]. LP (1) is the LP relaxation for k-ATSPP we consider. It is similar to the LP relaxation for minimize : subject to : duvxuv Xe∈A x(δ+(v)) = x(δ−(v) = 1 x(δ+(s)) = x(δ−(t)) = k x(δ−(s)) = x(δ+(t)) = 0 x(δ+(S)) ≥ 1 xuv ≥ 0 (1) (2) ∀v ∈ V − {s, t} ∀{s} ⊆ S ( V ∀ uv ∈ A We will break the presentation of the algorithm into two parts. The first is a loop that runs for Θ(b log n) iterations. Each iteration will find the cheapest k-path/cycle cover on the remaining nodes and discards some nodes from the cycles or, more generally, circulations formed by taking the union of the current k-path/cycle cover and paths from previous iterations. These discarded nodes can be added to the final solution by using the circulations to "graft" them into the paths. It is similar to the main loop in the algorithm for ATSPP in [13]. After this first phase we will have Θ(bk log n) paths of cost from s to t whose union is acyclic and covers all remaining nodes. However, our goal is to use at most k + k b paths. The second part of the algorithm will assemble only k + k b paths that cover all remaining nodes using arcs from the Θ(bk log n) paths. This will be possible because we will carefully select which nodes to discard in each iteration so that each remaining node lies in almost a 1 k -fraction of the Θ(bk log n) paths after the main loop. So, if we regard our Θ(bk log n) paths as a flow then each node supports almost a 1 k -fraction of this flow. If we scale the flow by Θ(b log n) then we have a flow sending Θ(k) units from s to t where every other remaining node supports Ω(1) units of this flow. We will show how to round this flow to obtain an acyclic integral flow of roughly the same cost that sends between k and k + k b units of flow from s to t so that each remaining node supports exactly 1 unit of this flow. Then a path decomposition of this acyclic integral flow yields the required paths. Finally, we graft the nodes that were discarded in the first phase to these paths using the circulations that were removed in the first phase. 2.2 The Algorithm Let b ≥ 1 be an integer, this is the b in the statement of Theorem 1.1. For notational convenience, we will let L be (b + 1)⌊log2 n⌋ for the remainder of this section. Algorithm 1 is the k-ATSPP bicriteria approximation. 4 ⊲ W is the set of nodes that have not been discarded yet ⊲ Used to decide which nodes to discard from a circulation ⊲ F will be an acyclic s − t flow using only nodes in W ⊲ C will be a circulation on the nodes in V − W Algorithm 1 The Bicriteria Approximation for k-ATSPP. 1: Let W ← V 2: Let lv = 0,∀v ∈ V 3: Let Fuv ← 0,∀u, v ∈ V 4: Let Cuv ← 0,∀uv ∈ V 5: L ← (b + 1)⌊log2 n⌋ 6: for L iterations do 7: Find a minimum-cost k-path/cycle cover F ′ on W F ← F + F ′ Subtract a circulation H from F so F is acyclic again for each connected component A in the support of H do Shortcut the flow in F over w so F (δ+(w)) = 0 A (u)) Let vA ← arg minu∈A lu + H(δ+ for each node w ∈ A − {vA} do end for W ← W − (A − {vA}) lvA ← lvA + H(δ+ A (vA)) 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: ⊲ breaking ties arbitrarily ⊲ F remains acyclic ⊲ The nodes in A − {vA} will be reintroduced in step 22 end for C ← C + H cost at most the cost of F . Let P be the s − t flow of value k′ defined by these paths. 18: 19: end for 20: Use Corollary 2.10 to find k′ ∈ [k, k + k 21: Let B be the simple t − s flow with Bts = k′ and Buv = 0 for every other arc. 22: Let C′ ← P + C + B 23: Find an Eulerian circuit K using each arc uv eactly C′uv times. 24: Shortcut K so it visits each node in V − {s, t} exactly once. 25: Delete the k′ edges ts from K to obtain k′ paths P1, . . . , Pk′. 26: Return P1, . . . , Pk′. b ] s− t paths whose union covers all nodes in W of total ⊲ See Lemma 2.2 The proof of the following lemma is simple and is found in Appendix A.1. Lemma 2.2 In Step 22, C′ is an integral circulation whose support is strongly connected in G(V, A). We assume, for now, that Step 20 works as stated. If so, we can prove the following combinatorial analog of Theorem 1.1 that compares the cost of the solution to the optimum k-ATSPP cost OP T solution rather than the value of LP (1). Theorem 2.3 Each node v ∈ V − {s, t} lies on exactly one of the s − t paths P1, . . . , Pk′ returned by Algorithm 1 and the total cost of these paths is at most L · OP T . Proof. Since C′ is a circulation whose support is strongly connected in G(V, A), then every node in V is visited by the Eulerian circuit. Since the shortcutting did not bypass around either s or t, then the ts arc still appear exactly k′ times in K and there are no vs or tv arcs in K for any v ∈ V − {s, t}. So, after removing the k′ occurences of the t − s arc from K, we have a collection of precisely k′ paths from s to t whose union visits all nodes. All that is left is to bound the final cost by L · OP T . We prove, by induction on i, that the cost of F + C after iteration i is at most i · OP T . For i = 0 (before the first iteration) this is clear 5 and we now assume that i > 0 and that the cost of F + C just before the i'th iteration is at most (i − 1) · OP T . Let Wi be the subset of nodes W in the i'th iteration. We can obtain a feasible k-path/cycle cover on Wi of cost at most OP T by shortcutting an optimum k-ATSPP solution on V around nodes in V − Wi. Thus, the minimum cost k-path/cycle cover F ′ on Wi has cost at most OP T . After adding F ′ to F we have that the cost of F + C is, by induction, at most i · OP T . The rest of the body of the loop simply moves flow between F and C and shortcuts some flow so the cost of F + C is still bound by i · OP T at the end of the i'th iteration. The cost of the circulation C′ in Step 22 is then at most L·OP T plus the cost of B. Shortcutting past nodes in the Eulerian circuit K yields an circuit whose total cost is still at most L · OP T plus the cost of B. The paths P1, . . . , Pk′ are formed by removing the k′ arcs from t to s which have cost exactly the cost of B. Thus, the cost of the returned paths is at most L · OP T . (cid:3) 2.3 Finding the Flow P in Step 20 Consider the acyclic integral flow F after the main loop terminates. It is possible to argue that our choice of vA in Step 11 implies each v ∈ W has F (δ+(v)) > 0 so a path decomposition of F yields a collection of paths whose union covers all nodes. However, the number of paths is kL which is much larger than our desired value k + k b . The fact that we can find fewer paths is essentially due to the fact that every v ∈ W − {s, t} supports a lot of flow in F . The main object of concern in this step is the following polytope P(D) where D ∈ R. In P(D), we have a variable zuv for every arc uv in the subgraph induced by W . The full description of P(D) is: z(δ+(w)) = z(δ−(w)) = 1 z(δ+(s)) = z(δ−(t)) = D z(δ−(s)) = z(δ+(t)) = 0 ∀w ∈ W − {s, t} 0 ≤ zuv ≤ Fuv ∀ ordered pairs u, v ∈ V (3) (4) (5) (6) Since the support of F is acyclic and the support of z is required to be a subset of the support of F , then any integral point z ∈ P(D) corresponds to a flow P of the form required in Step 20 with k′ = D. Notice that Constraints (6) imply that the cost of z would be at most the cost of F . Thus, our goal is to find a value D ∈ [k, k + k b ] for which P(D) has an integer point. The proof of the following property is standard (eg. [29]). Lemma 2.4 Every basic point in polytope P(D) is integral when D is an integer. So, to prove P(D) has an integer point for a given integer D it suffices to prove that P(D) contains any point. That is, for D ∈ Z if there is some point z ∈ P(D) with, perhaps, rational coordinates, then there is certainly a point z′ with integer coordinates since P(D) is integral. The following lemmas are proven in essentially the same way as Lemmas 2.3 and 2.5 in the extended abstract of [13], so we omit their proofs. Lemma 2.5 Throughout the course of the algorithm, lv ≤ ⌊log2 n⌋ for every v ∈ W . Lemma 2.6 When the main loop terminates, F (δ+(v)) = L − lv for each v ∈ W − {s, t}. We will require that all node in W −{s, t} support the same amount of flow in F . The following lemma shows how to construct such a flow through simple modifications of F . 6 Lemma 2.7 For some 0 ≤ γ ≤ ⌊log2 n⌋ there is an acyclic integral flow F ′ sending kL units of flow from s to t where every v ∈ W − {s, t} has F ′(δ+(v)) = L − γ. Furthermore, the cost of F ′ is at most the cost of F . Let γ = maxw∈W−{s,t} lw and recall that γ ≤ ⌊log2 n⌋ by Lemma 2.5. While some Proof. w ∈ W − {s, t} has F (δ+(v)) > L − γ (cf. Lemma 2.6), shortcut F past w as follows. Choose any two arcs uw, wv with Fuw, Fwv > 0. Then subtract 1 from both Fuw and Fwv and add 1 to Fuv. Note that F remains integral and acyclic after such an operation and that the cost of F does not increase by the triangle inequality. We let F ′ be this flow F once all w ∈ W − {s, t} have F (δ+(v)) = L − γ. From now on, we will assume that F (δ+(v)) = L − γ for every v ∈ W − {s, t} where γ is some integer at most log2 n. The following lemma is the first step to finding a good integer D for which P(D) 6= ∅. The value kL Lemma 2.8 P (cid:16) kL L−γ may be fractional, but we will deal with that problem later. L−γ(cid:17) 6= ∅ for some 0 ≤ γ ≤ ⌊log2 n⌋. (cid:3) Let D = kL The main problem is that the kL L−γ and define a point z by zuv = Fuv L−γ . It is easy to verify z ∈ P(D) after Proof. noting that γ ≤ ⌊log2 n⌋ and b ≥ 1 implies L − γ ≥ 1. L−γ may not be an integer. The following lemma fixes this by mapping a point in P(D) to a point in P(⌊D⌋) be modifying flow along "sawtooth" s − t paths that alternate between following arcs in the support of z in the forward and reverse directions. This can be used to decrease both z(δ+(s)) and z(δ−(t)) while preserving z(δ+(v)) = z(δ−(v)) = 1 at all other nodes. The fact that such a sawtooth path always exists if D is not an integer is a consequence of the fact that the total flow through all nodes in W − {s, t} is integral. The full proof appears in Appendix A.2. (cid:3) Lemma 2.9 If P(D) 6= ∅, then P(⌊D⌋) 6= ∅. Corollary 2.10 There is an integer k′ ∈ [k, k + k between k and k + k these paths is at most the cost of the flow F after the main loop of Algorithm 1. b ] such that P(k′) 6= ∅. That is, we we can find b paths from s to t whose union spans all nodes in W . Furthermore, the cost of since Proof. Lemmas 2.8 and 2.9 show P (cid:16)j kL L − γ(cid:23) ≤ k ≤ (cid:22) kL L−γk(cid:17) 6= ∅ for some 0 ≤ γ ≤ ⌊log2⌋n. The result follows k(b + 1)⌊log2 n⌋ b⌊log2 n⌋ = k + k b . (cid:3) In the next section, we complete the proof of Theorem 1.1 by showing the cost is actually at most O(b log n) times the value of LP relaxation (1). 2.4 Bounding the Integrality Gap For a subset W ⊆ V containing both s and t, let LP (W ) denote LP relaxation (1) on the asymmetric metric induced by W . Consider the LP obtained by removing Constraints (2) from LP (W ). The resulting LP is integral [29] whose integer points correspond to k-path/cycle covers of W . The following holds because removing the constraints from a minimizaton LP does not increase its value. 7 Lemma 2.11 For any subset W ⊆ V containing s and t, the minimum cost of a k-path/cycle cover of W is at most the value of LP (W ). The proof of the next lemma is the same as the proof for the case k = 1 in [13]. It uses splitting off techniques developed by Frank [11] and Jackson [19] for Eulerian graphs. The idea is that we obtain an Eulerian graph by multiplying an optimum basic (thus fractional) point in LP (1) by a large enough integer and identifying s and t. Since we are only concerned with preserving cuts for subsets S of W that include s, then using splitting off techniques to bypass nodes in V − {s, t} in this Eulerian graph and then scaling back to a fractional point x′ will preserve x′(δ+(S)) ≥ 1 in the graph induced by W while not increasing the cost. Lemma 2.12 For any subset W of V containing s and t, the value of LP (W ) is at most the value OP TLP of LP (V ). Now we can complete the proof of Theorem 1.1. Proof of Theorem 1.1. By Lemmas 2.11 and 2.12, the cost of each k-path/cycle cover found in Step (7) is at most OP TLP . The proof of Theorem 2.3 shows that the final cost of the paths is at most the sum of the costs of each k-path/cycle cover found. So, the total cost of the k + k b paths found is at most L · OP TLP = O(b log n) · OP TLP . (cid:3) 2.5 Varying the Endpoints Consider the following ways to specify the start locations of the paths: each path may start at any node (No Source), all paths start at a common node s (Common Source), or there are nodes s1, . . . , sk where each must be the start of some path (Multiple Source). We can also consider anal- ogous ways to specify the end locations of the paths. In Multiple Source/Multiple Sink instances, we only require each path start at some si and end at some tj. It may be that some paths start and end at locations with different indices. The following theorems are easy to verify and the proofs are only briefly sketched. We let OP T be the cost of the optimum solution using exactly k paths for the k-ATSPP variant in question. Theorem 2.13 For any integer b ≥ 1, there is an approximation algorithm for the No Source/Single Sink variant of k-ATSPP that finds at most k + k b paths of total cost at most O(b log n) · OP T . Proof. the approximation algorithm from Theorem 1.1. Simply add a new start node s and set sv = 0 and vs = ∞ for every v ∈ V . Then use (cid:3) Theorem 2.14 For any integer b ≥ 1, there is an approximation algorithm for the Multiple Source/Single Sink variant of k-ATSPP that finds at most k + k b paths of total cost at most O(b log(n + k)) · OP T . Proof. Let s1, . . . , sk be the multiple sources. Create a start node s and k other new nodes s′1, . . . , s′k. Add cost 0 arcs from s to s′i and from s′i to si for each i. Add a cost ∞ arc from v to s for every v ∈ V . Use Theorem 1.1 on the shortest paths metric of this graph. The intermediate nodes s′i are to ensure that each si is the start location of some path. (cid:3) Combining the constructions in Theorems 2.13 and 2.14 can also be used to combine different start and end location specifications (e.g. No Source/Multiple Sink). 8 3 General k-ATSPP Recall that in General k-ATSPP, we are given k pairs of nodes (s1, t1), . . . , (sk, tk). The goal is to find an si − ti path for each 1 ≤ i ≤ k so that every v ∈ V lies on at least one such path. This differs from the Multiple Source/Multiple Sink variant described in Section 2.5 since the path at si must end at ti, rather than merely requiring that the start and end nodes of the paths establish a bijection between {s1, . . . , sk} and {t1, . . . , tk}. 3.1 Approximating General 2-ATSPP Let (s1, t1) and (s2, t2) be pairs of nodes we are to connect. Furthermore, suppose all four of these endpoints are distinct (by creating multiple copies of locations if necessary). This means there is an optimum General 2-ATSPP solution where the two paths are vertex disjoint. Notice that the optimum Multiple Source/Multiple Sink 2-ATSPP solution for the case with sources {s1, s2} and sinks {t1, t2} is a lower bound for OP T . The first step of the algorithm is to run an α-approximation for this variant of 2-ATSPP. This gives us two paths P1, P2 starting at s1, s2, respectively. If P1 ends at t1 (equivalently, P2 ends at t2), then these paths form a valid solution for the General 2-ATSPP problem with cost at most α · OP T . Otherwise, we have s1 − t2 and s2 − t1 paths. We use the following lemma which is proven in Appendix A.3. It gives us a relatively cheap way to adjust these paths to get s1 − t1 and s2 − t2 paths. Lemma 3.1 There are nodes u1, v2 on P1 and v1, u2 on P2 such that the following hold: a) u1 = v2 or u1v2 is an arc on P1, b) v1 = u2 or v1u2 is an arc on P2 and c) du1u2 + dv1v2 ≤ OP T . The rest of the General 2-ATSPP algorithm proceeds as follows. Try all O(n2) guesses for u1, u2, v1, v2 where either u1 = v2 or u1v2 is an arc on P1 and either v1 = u2 or v1u2 is an arc on P2. For each guess, construct a path Q1 by traveling along P1 from s1 to u1, then using the u1u2 arc in G, and then traveling along P2 from u2 to t1. Construct Q2 in a similar manner by traveling from s2 to v1 on P2, then using the v1v2 arc in G, and then traveling along P1 from v2 to t2. It is easy to see that Q1 and Q2 form a feasible solution for this General 2-ATSPP instance. Since each arc on P1 and P2 is traversed at most once by Q1 and Q2, then the total cost of Q1 and Q2 is at most α · OP T + du1u2 + dv1v2. Output the cheapest solution found over these guesses. When the algorithm guesses nodes u1, u2, v1, v2 from Lemma 3.1 we have du1u2 + dv1v2 ≤ OP T . It is straightforward to verify that each arc in P1 and P2 is used at most once between Q1 and Q2. So the final cost of Q1 and Q2 is at most (α + 1) · OP T . To summarize: Theorem 3.2 If there is an α-approximation for the Multiple Source/Multiple Sink variant of 2-ATSPP then there is an (α + 1)-approximation for General 2-ATSPP. By setting b = 3 and using Theorem 2.14 composed with an analogous result for Multiple Sink instances, Theorem 3.2 gives us the following. Corollary 3.3 There is an O(log n)-approximation for General 2-ATSPP. 3.2 Approximating Other Restrictions of General k-ATSPP We breifly mention a couple of variants of General k-ATSPP that can be approximated well. We leave their full descriptions to Appendix A.4 since they are simple variants of known algorithms for some TSP variants. 9 U a b X 1 X 2 X 3 X 4 a b c d e f a b f e W c d V i) ii) Figure 2: i) An instance of tripartite triangle packing with n = 2. ii) The corresponding graph H. The first variant is when the metric is symmetric. In this case, there is a simple 3-approximation using a tree doubling approach. Next, if si = ti for each 1 ≤ i ≤ k, then the problem is to find a cycle cover where each cycle contains some root node si where we allow cost 0 loops on the nodes si (corresponding to the salesman at si going directly to ti). This version can be approximated within ⌊log2(n − k)⌋ + 1 using a modification of the ATSP algorithm by Frieze et al. [12]. 3.3 Hardness of General k-ATSPP We will use the following NP-complete. Definition 3.4 In the Tripartite Triangle Packing problem, we are given a tripartite graph G = (U ∪ V ∪ W, E) with U = V = W = n where no edge in E has both endpoints in a common partition U, V , or W . A triangle is a subset of 3 nodes for which any two are adjacent in G. The problem is to determine if it is possible to find n vertex-disjoint triangles in G. NP-completeness of this problem is essentially shown in [14]. Technically, only related problems are proven to be NP-complete in this book. However, consider the 3D Matching problem that is proven to be NP-complete in Theorem 3.2 on page 50. If each triple M = {u, v, w} is replaced with edges uv, vw, wu then we obtain an instance of Tripartite Triangle Packing. Careful inspection of the proof of Theorem 3.2 of [14] shows that the only triangles {uv, vw, wu} that can be formed must have come from some triple M = {u, v, w} in the 3D Matching reduction. Thus, the Tripartite Triangle Packing problem is also NP-complete. For our reduction to General k-ATSPP, let G = (U ∪ V ∪ W, E) be an instance of Tripartite Triangle Packing with U = V = W = n. Create a directed graph H with four layers of nodes X1, X2, X3, X4 where X1 and X4 are disjoint copies of U , X2 is a copy of V , and X3 is a copy of W . For every edge e in G, there is a unique index 1 ≤ i ≤ 3 such that the endpoints of e lie in Xi and Xi+1. Add this arc to H, direct it from Xi to Xi+1, and set its cost to 0. This is illustrated in Figure 2. Set k := n and consider the General k-ATSPP instance on H′ obtained from the shortest paths metric H where we set the cost of a uv arc to be 1 if there is no u − v path in H. For each u ∈ U , we have a source/sink pair from the copy of u in X1 to the copy of u in X4. The details of the following claim are simple and can be found in Appendix A.5. The proof of Theorem 1.2 immediately follows. 10 Claim 3.5 There is a Tripartite Triangle Packing solution in G if and only if the optimum General k-ATSPP solution in H′ solution has cost 0. Note that the value k is n/4 in the above reduction. Similar hardness results for smaller values of k (as a function of n) are established in Appendix A.6 down to k being polylogarithmic in n. The complexity of approximating the case when k is a constant at least 3 remains open. 4 Future Directions Our best approximation for k-ATSPP that uses exactly k paths has an approximation guarantee of O(k log n). Can the dependence on k in the approximation ratio be reduced? Perhaps there is an O(polylog(n, k))-approximation for k-ATSPP that uses only k paths. On the other hand, the problem might be hard to approximate much better than k. Also, as far as we know the integrality gap of LP (1) could be Ω(k). For General k-ATSPP, the case k = 1 is simply ATSPP and we proved an O(log n)-approximation for k = 2. Is there a more general O(f (k) · log n)-approximation for General k-ATSPP whose run- ning time is polynomial when k is a constant? Finally, rather than minimizing the total cost of all paths we might want to minimize the cost of the most expensive path. This can be thought of as minimizing the total time it takes for agents moving simultaneously to visit all locations. From Theorem 1.1 and the observation that the total cost of k paths is at most k times the cost of the most expensive path, we get an O(bk log n)-approximation for this variant that uses at most k + k b paths. Also, Theorems A.5 and A.6 (Appendix A.7) show that approximation algorithms for Directed Orienteering and Directed k-Stroll can be used to obtain other bicriteria approximation algorithms. The current best approximation algorithms for Directed Orienteering [7, 25] and Directed k-Stroll [4] imply the following: Corollary 4.1 There is an efficient algorithm that finds O(k log3 n) paths from s to t of maximum cost OP T whose union covers all nodes in V . Corollary 4.2 There is an O(log3 n)-approximation uses at most O(k log n) paths. We leave it as an open problem to improve these bounds. In particular, is it possible to obtain a polylogarithmic approximation that uses only O(k) paths? We also note that the hardness results for General k-ATSPP proven in this paper also hold for the the variant where we want to minimize the maximum cost of the si − ti paths. 5 Acknowledgements The author would like to thank Anupam Gupta, Mohammad R. Salavatipour, and Zoya Svitkina for insightful discussions on these problems. References [1] H.-C. An and D. Shmoys. LP-based approximation algorithms for traveling salesman path problems. arXiv manuscript number 1105.2391. [2] H.-C. An, R. Kleinberg, and D. Shmoys. Improving Christofides' Algorithm for the s− t Path TSP. arXiv manuscript number 1110.4604. 11 [3] A. Asadpour, M. X. Goemans, A. Madry, S. Oveis Gharan, and A. Saberi. An O(log n/ log log n)-approximation algorithm for the asymmetric traveling salesman problem. In Proc. 21st ACM Symp. on Discrete Algorithms, 2010. [4] M. Bateni and J. Chuzhoy. Approximation algorithms for the directed k-tour and k-stroll problems. In Proc. 13th APPROX, 2010. [5] M. Blaser. A new approximation algorithm for the asymmetric TSP with triangle inequality. In Proc. 13th ACM Symp. on Discrete Algorithms, 2002. [6] M. Charikar, M. X. Goemans, and H. Karloff. On the integrality ratio for asymmetric TSP. In Proc. 45th IEEE Symp. on Foundations of Computer Science, 2004. [7] C. Chekuri, N. Korula, and M. Pal. Improved algorithms for orienteering and related problems. In Proc. 19th ACM Symp. on Discrete Algorithms, 2008. [8] C. Chekuri and M. Pal. An O(log n) approximation ratio for the asymmetric traveling salesman path problem. Theory of Computing, 3(1):197 -- 209, 2007. [9] N. Christofides. Worst-case analysis of a new heuristic for the traveling salesman problem. Technical report, Graduate School of Industrial Administration, Carnegie-Mellon University, Pittsburgh, PA, 1976. [10] U. Feige and M. Singh. Improved approximation ratios for traveling salesperson tours and paths in directed graphs. In Proc. 10th APPROX, 2007. [11] A. Frank. On connectivity properties of Eulerian digraphs. Ann. Discrete Math., 41:179 -- 194, 1989. [12] A. Frieze, G. Galbiati, and F. Maffioli. On the worst-case performance of some algorithms for the asymmetric traveling salesman problem. Networks, 12:23 -- 39, 1982. [13] Z. Friggstad, M.R. Salavatipour, and Z. Svitkina, Asymmetric traveling salesman path and directed latency problems. Proc. SODA, 2010. Additional results appear in arXiv, manuscript number 0907.0726v1. [14] M.R. Garey and D.S. Johnson, Computers and Intractability: A Guide to the Theory of NP-Completeness. W. H. Freeman& Co., New York, 1979. [15] M. C. Golumbic. Algorithmic Graph Theory and Perfect Graphs (Annals of Discrete Mathe- matics, Vol 57). North-Holland Publishing Co., Amsterdam, The Netherlands, second edition, 2004. [16] G. Gutin and A. P. Punnen, editors. Traveling Salesman Problem and Its Variations. Springer, Berlin, 2002. [17] M. Held and R. Karp. The traveling salesman problem and minimum spanning trees. Opera- tions Research, 18:1138 -- 1162, 1970. [18] J. A. Hoogeveen. Some paths are more difficult than cycles. Oper. Res. Lett., 10:291 -- 295, 1991. [19] B. Jackson. Some remarks on arc-connectivity, vertex splitting, and orientation in digraphs. Journal of Graph Theory, 12(3):429 -- 436, 1988. 12 [20] H. Kaplan, M. Lewenstein, N. Shafrir, and M. Sviridenko. Approximation algorithms for asymmetric TSP by decomposing directed regular multigraphs. J. ACM, 52(4):602 -- 626, 2005. [21] J. Kleinberg and D. P. Williamson. Unpublished note, 1998. [22] F. Lam and A. Newman. Traveling salesman path problems. Math. Program., 113(1):39 -- 59, 2008. [23] E. Lawler, J. K. Lenstra, A. H. G. Rinnooy Kan, and D. Shmoys, editors. The Traveling Salesman Problem: A guided tour of combinatorial optimization. John Wiley & Sons Ltd., 1985. [24] V. Nagarajan. On the LP relaxation of the asymmetric traveling salesman path problem. Theory of Computing, 4(1):191 -- 193, 2008. [25] V. Nagarajan and R. Ravi. Poly-logarithmic approximation algorithms for directed vehicle routing problems. In Proc. 10th APPROX, pages 257 -- 270, 2007. [26] V. Nagarajan and R. Ravi. The directed minimum latency problem. In Proc. 11th APPROX, pages 193 -- 206, 2008. [27] C. H. Papadimitriou and S. Vempala. On the approximability of the traveling salesman prob- lem. Combinatorica, 26(1):101 -- 120, 2006. [28] S. Rathinam and R. Sengupta. Matroid intersection and its applications to multiple depot, multiple TSP. Technical report, University of California, Berkely, 2006. [29] A. Schrijver. Combinatorial Optimization - Polyhedra and Efficiency. Springer-Verlag, New York, 2005. [30] D. Shmoys and D. P. Williamson. Analyzing the Held-Karp TSP bound: a monotonicity property with application. Inf. Process. Lett., 35(6):281 -- 285, 1990. [31] D. P. Williamson. Analysis of the Held-Karp heuristic for the traveling salesman problem. M.S. Thesis, MIT, 1990. [32] L. A. Wolsey. Heuristic analysis, linear programming and branch and bound. Mathematical Programming Study, 13:121 -- 134, 1980. A Appendix A.1 Proof of Lemma 2.2 We see that C′ is an integral circulation since it is the sum of an integral circulation C, an integral s − t flow P of value k′, and an integral t − s flow B of value k′. To prove its support is strongly connected in G(V, A) it suffices to show that there is a v − t path in the support of C′ for every v ∈ V . Suppose Wi is the set of remaining nodes W just after the i'th iteration of the loop (and W0 = V ). We prove by induction on L − i that every node in Wi has a path to v. Consider the base case i = L. Since P only uses arcs in the support of F , since F is acyclic (from Step 9), and since F (δ+(v)) > 0 for v ∈ W −{s, t} (Lemmas 2.5 and 2.6) then any walk from any v ∈ WL in the support of P of maximal length must end at t. 13 Now suppose i < L and that every node in Wi+1 has a path to t in the support of C′. Let v ∈ Wi, if v ∈ Wi+1 then, by induction, v has a path to t. Otherwise, v must have been removed in Step 15 of the current iteration for some circulation A. But then vA, the representative of circulation A that was chosen to remain in W , is in Wi+1, so it has a path to t by induction. Finally, v also has a path to t in the support of C′ since it can travel first to vA in A and then, by induction, to t. (cid:3) A.2 Proof of Lemma 2.9 Suppose D is not an integer, otherwise we are already done. Let z be any point in P(D). Form an undirected and weighted bipartite graph H = (WL ∪ WR, E′) where both WL and WR are disjoint copies of W . We identify an arc uv of G with an edge uv in H with u ∈ WL and v ∈ WR. That is, for each arc uv add an edge from u ∈ WL to v ∈ WR with weight zuv. By constraints (3), (4) and (5), we have that z(δ(v)) (the total z-value of all edges in E′ incident to v) is an integer for every v ∈ WL ∪ WR except for s ∈ WL and t ∈ WR. We claim there is a path from s ∈ WL to t ∈ WR in H that only uses edges uv with zuv > 0. Note that these paths are allowed to take a step from WR to WL since H is undirected. Such a step corresponds to following an arc uv in the reverse direction in the original directed graph G. Suppose, for the sake of contradiction, that there is no path from s ∈ WL to t ∈ WR using only edges uv with zuv > 0. Let S be the collection of all nodes in H that can be reached from s ∈ WL using only edges with positive z-value; our assumptions means the copy of t in WR is not in S. Let z(E(S)) denote the total z-value of edges with both endpoints in S. On one hand, since every node v ∈ WR − {t} has z(δ(v)) = 1 and since t 6∈ S, then z(E(S)) = Xv∈WR∩S z(δ(v)) = WR ∩ S. On the other hand, since every node v ∈ WL − {s} has z(δ(v)) = 1 and since s ∈ S, then z(E(S)) = Xv∈WL∩S z(δ(v)) = (WL − {s}) ∩ S + z(δ(s)) = (WL − {s}) ∩ S + D. But R ∩ S = (WL − {s}) ∩ S + D contradicts our assumption that D is not an integer. So, it must be that there is a path from s ∈ WL to t ∈ WR in H using only edges e with ze > 0. Suppose that such a path followed a sequence of edges e1, e2, . . . , ec. Since H is bipartite and s ∈ WL, t ∈ WR are on different sides, then c must be odd. Let δ = min(cid:26)D − ⌊D⌋, min 1≤i≤c: i odd zei(cid:27) be the minimum z-value of the edges that are followed from WL to WR when walking along this path (or the difference between D and ⌊D⌋ if this is smaller). Update the z values of the edges on this path by: zei ← (cid:26) zei − δ zei + δ i odd i even We will now argue that the resulting z-values fit in the polytope P(D − δ). First, notice that both z(δ(s)), s ∈ WL and z(δ(t)), t ∈ WR, which were originally D, decrease by exactly δ. Any other node v not on this path does not have the z-value of any incident edge changed. Finally, if v is an internal node on this path then the z-value of one incident edge decreases by δ and the 14 z-value of another incident edge increases by δ. Therefore, we have z(δ(v)) = 1 after this update for every internal node v on this path. By our choice of δ, we maintain ze ≥ 0 for every edge e. Now, if the path was a single edge st then no edge had its z-value increased so the bounds ze ≤ Fe continue to hold for every edge e. Otherwise, every edge e = uv on this path has either z(δ(u)) = 1 or z(δ(v)) = 1 so ze ≤ 1 must hold after this update. Since the only ze values that are increased are those in the support of the integral flow F , then ze ≤ 1 ≤ Fe. The above process maps a point from P(D) to a point in P(D − δ) when D is not an integer. If δ was chosen to be D − ⌊D⌋ > 0, then z(δ(s)) = z(δ(t)) = ⌊D⌋ after this process and we are done. Otherwise, we can repeat the process to map a point from P(D − δ) to P(D − δ′) for some δ′ > δ with D − δ′ ≥ ⌊D⌋ and so on. Each such step that does not result in a point in the polytope P(⌊D⌋) has us remove at least one edge from the support of z. Since no edges are introduced to the support of z, then this process will terminate in finitely many iterations with a point in P(⌊D⌋). (cid:3) A.3 Proof of Lemma 3.1 Let P ′1 be the s1 − t1 path and P ′2 be the s2 − t2 path in some fixed optimum solution. Also, for nodes u, v ∈ V we use u ≺ v to indicate that both u and v appear on the same path in our optimum solution P ′1, P ′2 and that u appears sometime before v on this path. Let a, b be such that ab is the first arc on P1 with a ∈ P ′1 and b ∈ P ′2. Such an arc exists because P1 starts with a node in P ′1 and ends in a node in P ′2. Let x be the first node along P2 such that a ≺ x. We know such a node exists because a ≺ t1 and t1 ∈ P2. Now, let y be the furthest node along P2 but still before x such that either y ∈ P ′1 or y ∈ P ′2 and y ≺ b. Again, such a node exists because s2 ∈ P ′2 and s2 ≺ b. Suppose y ∈ P ′2 with y ≺ b. If y is immediately followed by x on P2 then we let u1 = a, u2 = x, v1 = y, v2 = b. Otherwise, say w is the immediate successor of y on P2. By our choice of y we have w ∈ P ′2 and b ≺ w. In this case, we set u1 = b, u2 = w, v1 = y, v2 = b. This case is illustrated in Figure 3. Next, suppose y ∈ P ′1. Let z be the first node on P2 that lies on P ′1. Note that z occurs no later than y on P2 (it may be equal to y). Now, by our choice of a on P1, every node between s1 and a on P1 also lies on P ′1. We also have that s1 appears before z on P ′1 (since s1 is the start of P1) and, by our choice of x and the fact that z appears before x on P2, we have that z appears before a on P ′1. So, there must be some arc cd on the subpath of P1 starting at s1 and ending at a such that c appears before z on P ′1 and d appears after z on P ′1. We let u1 = c, u2 = z, v1 = z, v2 = d in this case. In all cases, we can easily verify that condition a) and b) in the statement of the lemma are satisfied. Also, in any case we have that one of the following is true: 1. u1 ≺ u2 and v1 ≺ v2 with u1 and v1 appearing on different paths in P ′1, P ′2 2. v1 ≺ v2 = u1 ≺ u2 3. u1 ≺ u2 = v1 ≺ v2 In each case, the triangle inequality implies du1u2 + dv1v2 is a lower bound on the total cost of P ′1 and P ′2. That is, du1u2 + dv1v2 ≤ OP T . (cid:3) A.4 Restricted Instances of General k-ATSPP Theorem A.1 There is a 3-approximation for General k-ATSPP in symmetric metrics. 15 P 1 P 2 Q 1 Q 2 s 1 s 2 s 1 s 2 a a ... ... y ... ... y w i) w ii) b b ... x ... ... x ... t 2 t 1 t 2 t 1 i) An illustration of the case y ∈ P ′2 with immediate successor w 6= x on P2. The white Figure 3: nodes lie on P ′1 and the gray nodes lie on P ′2. A dashed arc v → v′ indicates v ≺ v′ on P ′1 and a gray arc v → v′ indicates v ≺ v′ on P ′2. ii) The s1 − t1 and s2 − t2 paths Q1, Q2 formed in the proof of Theorem 3.2 for this case. Proof. First, we may assume that the 2k start and end locations are all distinct by duplicating locations that appear multiple times among s1, . . . , sk, t1, . . . , tk. Let X = {s1, . . . , sk}∪{t1, . . . , tk}. Compute the minimum weight forest F of G where every component contains exactly one node in X. Such forests correspond to spanning trees of G/X, the graph obtained by contracting all nodes in X and keeping parallel edges. Now, add the set of edges M = {siti, 1 ≤ i ≤ k} to F . This results in a forest where each component contains both si and ti from some 1 ≤ i ≤ k pair. In each such component Fi, double all edges except siti and find an Eulerian walk from si to ti. Follow such a walk and shortcut past repeated nodes to get a path Pi that visits all nodes in the component Fi. Before adding M , the cost of F was at most OP T because a forest where each component contains exactly one node in X can be obtained by deleting one edge from every si − ti path in the optimum solution. Also, since the optimum solution consists of si − ti paths for each 1 ≤ i ≤ k and since the single edge siti is the shortest si − ti path, then the cost of M is also at most OP T . Finally, since we only doubled the edges from F and shortcutting does not increase the cost of a path, then the final cost is at most twice the cost of F plus the cost of M which, in turn, is at most 3 · OP T . (cid:3) Theorem A.2 There is a (⌊log2(n− k)⌋ + 1)-approximation for instances of General k-ATSPP in asymmetric metrics when si = ti for all 1 ≤ i ≤ k. Proof. Let ri denote the common start and end location for salesman i. Recall that we are allowing a salesman to travel directly from si to ti which corresponds to a loop of cost 0 at ri. Like Frieze et al. [12], we consider cycle covers except that we also allow a loop at a root ri to be a cycle in the cycle cover. We do not allow loops at any node in V − {r1, . . . , rk}. A minimum cost cycle cover that allows loops at root nodes can be computed efficiently in a manner similar to computing 16 minimum cost cycle covers without loops. Initialize the set of "remaining nodes" W := V . While W 6= {r1, . . . , rk}, we compute a minimum cost cycle cover C. Note that the cost of C is at most OP T because shortcutting an optimum solution past nodes in V − W yields a feasible cycle cover on W of cost at most OP T . If any cycle in C contains more than one root, then shortcut C past all but one of these roots. The roots that are removed from the cycle are then said to be covered by a loop of cost 0. For each cycle Ci in C, if there is a root r in Ci then we remove all of Ci − {r} from W . Otherwise, we only remove all but any one arbitrarily chosen node in Ci from W . When W is finally reduced to R, the union of all cycles found over all iterations will have each component being an Eulerian graph containing exactly one root. So, shortcutting an Eulerian circuit in each component yields the desired cycles. At each step before the final iteration, at least half of the non-root nodes are removed so the number of iterations is at most ⌊log2(n − k)⌋ + 1. The total cost of these cycles is at most the total cost of all cycles covers each of which has cost at most OP T , so the total cost is (⌊log2(n − k)⌋ + 1) · OP T . (cid:3) A.5 Proof of Claim 3.5 Suppose T = {(ui, vi, wi)}n i=1 is a collection of n vertex-disjoint triangles with ui ∈ U, vi ∈ V and wi ∈ W . For each such triangle (ui, vi, wi), we have the salesman starting at ui ∈ X1 to travel first to vi ∈ X2, then to wi ∈ X3, and finally to ui ∈ X4. Every node in H′ is visited since every node is included in some triangle in T . By construction, every step taken by a salesman traverses an arc of cost 0 so the total cost is 0. Conversely, suppose there is a k-ATSPP solution that avoids using any arc of positive cost. Then each of the arcs followed by the salesmen must be in increasing order of the levels Xi. Since there are only n salesmen and since each salesman can visit only two nodes in addition to their endpoints, then each salesman visits every layer Xi. Since no arcs of positive cost were used then every salesman only uses arcs corresponding to edges in G. Thus, the nodes visited by each salesman correspond to a triangle in G and these triangles partition the nodes of G. (cid:3) A.6 Hardness of General k-ATSPP for Smaller k There is a very simple modification to the proof of Theorem 1.2 that proves hardness for smaller values of k. It is reminiscent of some "padding" arguments in complexity theory. Theorem A.3 For any constant ǫ > 0, instances of general k-ATSPP with k = Ω(nǫ) cannot be approximated within any bounded ratio unless P = N P . Simply attach a path P of length Θ(n ǫ ) to the end of the copy of u1 ∈ X4 Proof (sketch). in H in the reduction from Theorem 1.2. Set the cost of all arcs in this path is 0. All start and end locations of the salesmen are the same, except that the first salesman ends at the end of the path P rather than at u1 ∈ X4. Now, k = Θ(N ǫ) where N is the number of nodes in this modified version of H. (cid:3) In fact, under the Exponential Time Hypothesis we can push the value of k down to polyloga- 1 rithmic in the hardness reduction. Theorem A.4 There is a constant c such that for any δ > 0, no polynomial-time algorithm for δ N ) can discern between instances with instances of General k-ATSPP on N nodes with k = Ω(log optimum value 0 and instances with optimum value at least 1 unless 3SAT has can be decided in time 2O(nδ) where n is the number of variables. c 17 δ Say the reduction from 3SAT to Tripartite Triangle Packing produces instances of size Proof. at most nc for large enough n where c is a constant and n is the number of variables in the 3SAT instance. Let k denote the size of a partition in the Tripartite Triangle Packing instance and note k ≤ nc. As in the proof of Theorem A.3, append a path to some u1 ∈ X4 except make its length 2k c is the number of nodes in this General k-ATSPP instance. c − 4k. Note that k = (log2 N ) Suppose there is a polynomial-time algorithm for General k-ATSPP instances on N nodes that can distinguish between instances with optimum value 0 and instances with optimum value at least 1 when k ≥ (log2 N ) δ . Use this algorithm on the instance constructed in the previous paragraph to distinguish between "yes" and "no" instances of 3SAT. δ where N = 2k c c δ The running time of the reduction of 3SAT to General k-ATSPP is polynomial in 2k Running the polynomial-time algorithm for General k-ATSPP on the instance with N = 2k δ c ≤ 2nδ . c nodes δ yields an algorithm for 3SAT whose running time is 2 O(cid:16)k δ c (cid:17) which is at most 2O(nδ). (cid:3) A.7 Minimizing the Salesmen's Makespan Here we consider the variant of k-ATSPP where the goal is to minimize the cost of the most expensive path rather than the total cost of all paths. Let OP T denote the minimum value for which there are k paths from s to t of maximum length OP T whose union spans all nodes. We first recall that in the Directed Orienteering problem, we have an asymmetric metric G = (V, A) with arc weights, a budget B, and a fixed start node s. The goal is to visit the maximum number of nodes with a path starting at s of cost at most B. Theorem A.5 If there is an α-approximation for Directed Orienteering, then we can efficiently find O(kα log n) paths from s to t, each of length 2· OP T , whose union spans all nodes. If we have an α-approximation for the variant of Directed Orienteering when both start and end location are specified, then we can find O(kα log n) paths of length at most OP T . Proof. We will describe an algorithm that is supplied with a value B. If B ≥ OP T , then it will succeed in finding O(kα log n) paths of length at most B + OP T whose union covers all nodes. So, by binary searching for B and keeping the smallest value for which the algorithm succeeds, we find O(kα log n) paths of length at most 2 · OP T . The algorithm is simple. Initialize W = V − {s, t}. Then, for Θ(kα log n) iterations use the Directed Orienteering approximation on W ∪ {s} starting from node s to find a path P of length at most B that covers some nodes. Append t to the end of this path P . Remove the nodes of P −{s, t} from W and repeat. Note that each path has length at most B + OP T because the final step to t has length at most OP T . If W = ∅ after all iterations, then we say that the algorithm succeeded. Otherwise, we say the algorithm failed. We claim that the algorithm will succeed if B ≥ OP T . In each iteration we have, from short- cutting the paths in an optimum solution around nodes in V − W , that there is a path of length OP T ≤ B that covers at least W/k nodes in W . So, the Directed Orienteering algorithm with budget B will cover at least W/kα of these nodes and the size of W drops by a (cid:0)1 − 1 kα(cid:1)-fraction. After Θ(kα log n) iterations all nodes should be covered. Finally, we note that we can use essentially the same algorithm to find paths of length OP T if we have a α-approximation for Directed Orienteering when we can specify both start and end locations. That is, we don't have to extend the paths found by the Directed Orienteering approximation to end at t since they already end at t. (cid:3) 18 In the Directed k-Stroll problem, we have an asymmetric metric G = (V, A), an integer k, and two nodes s, t. The goal is to find an s − t path of minimum weight that visits at least k other nodes. We can also use approximation algorithms for this problem to approximate the variant of k-ATSPP whose goal is to minimize the cost of the most expensive path. Theorem A.6 If there is an α-approximation for the Directed k-Stroll problem, then we can find O(k log n) paths of length at most α · OP T each. Initialize W to V −{s, t} and iterate the following proceduce. Use the Directed ⌈W/k⌉- Proof. Stroll approximation on W ∪{s, t} to find an s− t path P that visits at least W/k locations in W . By shortcutting an optimum solution, we see that there is such a path on the subgraph induced by W of length at most OP T so the length of P will be at most α · OP T . Remove the nodes in P − {s, t} from W and repeat. After O(k log n) iterations, all nodes will be covered by paths of length at most α · OP T . (cid:3) 19
1406.3058
2
1406
2015-07-17T13:03:08
Multilevel polynomial partitions and simplified range searching
[ "cs.DS", "math.AG" ]
The polynomial partitioning method of Guth and Katz [arXiv:1011.4105] has numerous applications in discrete and computational geometry. It partitions a given $n$-point set $P\subset\mathbb{R}^d$ using the zero set $Z(f)$ of a suitable $d$-variate polynomial $f$. Applications of this result are often complicated by the problem, what should be done with the points of $P$ lying within $Z(f)$? A natural approach is to partition these points with another polynomial and continue further in a similar manner. So far it has been pursued with limited success---several authors managed to construct and apply a second partitioning polynomial, but further progress has been prevented by technical obstacles. We provide a polynomial partitioning method with up to $d$ polynomials in dimension $d$, which allows for a complete decomposition of the given point set. We apply it to obtain a new algorithm for the semialgebraic range searching problem. Our algorithm has running time bounds similar to a recent algorithm by Agarwal, Sharir, and the first author [SIAM~J.~Comput. 42(2013) 2039--2062], but it is simpler both conceptually and technically. While this paper has been in preparation, Basu and Sombra, as well as Fox, Pach, Sheffer, Suk, and Zahl, obtained results concerning polynomial partitions which overlap with ours to some extent.
cs.DS
cs
Multilevel polynomial partitions and simplified range searching∗ Jir´ı Matousek Zuzana Pat´akov´a† Department of Applied Mathematics Charles University, Malostransk´e n´am. 25 118 00 Praha 1, Czech Republic, and Department of Computer Science ETH Zurich, 8092 Zurich, Switzerland Department of Applied Mathematics and Computer Science Institute Charles University, Malostransk´e n´am. 25 118 00 Praha 1, Czech Republic Abstract The polynomial partitioning method of Guth and Katz [arXiv:1011.4105] has numerous It partitions a given n-point set applications in discrete and computational geometry. P ⊂ Rd using the zero set Z(f ) of a suitable d-variate polynomial f . Applications of this result are often complicated by the problem, what should be done with the points of P lying within Z(f )? A natural approach is to partition these points with another polynomial and continue further in a similar manner. So far it has been pursued with limited success-several authors managed to construct and apply a second partitioning polynomial, but further progress has been prevented by technical obstacles. We provide a polynomial partitioning method with up to d polynomials in dimension d, which allows for a complete decomposition of the given point set. We apply it to obtain a new algorithm for the semialgebraic range searching problem. Our algorithm has running time bounds similar to a recent algorithm by Agarwal, Sharir, and the first author [SIAM J. Comput. 42: 2039–2062, 2013], but it is simpler both conceptually and technically. While this paper has been in preparation, Basu and Sombra, as well as Fox, Pach, Sheffer, Suk, and Zahl, obtained results concerning polynomial partitions which overlap with ours to some extent. 1 Introduction Polynomial partitions. Since the late 1980s, numerous problems in discrete and computa- tional geometry have been solved by geometric divide-and-conquer method, where a suitable partition of space is used to subdivide a geometric problem into simpler subproblems. The earliest, and most widely applied, kinds of such partitions are cuttings, based mainly on ideas of Clarkson (e.g., [Cla87]) and Haussler and Welzl [HW87]. See, e.g., [Cha05] for a survey of cuttings and their applications. Using cuttings as the main tool, another kind of space partition, called simplicial parti- tions, was introduced in [Mat92] (and further improved by Chan [Cha12]). Given an n-point set P ⊂ Rd and a parameter r > 1, a simplicial 1 r -partition is a collection of simplices (of di- mensions 0 through d), such that each of them contains at most n/r points of P and together they cover P . In Chan's version, they can also be assumed to be pairwise disjoint. ∗Research supported by the ERC Advanced Grant No. 267165. †Partially supported by the project CE-ITI (GACR P202/12/G061) of the Czech Science Foundation and by the Charles University Grants SVV-2014-260103 and GAUK 690214. 1 Let us introduce the following convenient terminology: a set A crosses a set B if A inter- sects B but does not contain it. The main parameter of a simplicial partition is the maximum number of simplices of the partition that can be simultaneously crossed by a hyperplane (or, equivalently, by a halfspace). One can construct simplicial partitions where this number is bounded by O(r1−1/d) [Mat92, Cha12], which is asymptotically optimal in the worst case (throughout this paper, we consider the space dimension d as a constant, and the implicit constants in asymptotic notation may depend on it, unless explicitly stated otherwise). Simplicial partitions work mostly fine for problems involving points and hyperplanes in Rd. However, they are much less useful if hyperplanes are replaced by lower-dimensional objects-such as lines-or curved objects-such as spheres-or other hypersurfaces. Guth and Katz [GK15] invented a new kind of partitions, called polynomial partitions, which overcome these drawbacks to some extent. The most striking application of polynomial partitions so far is probably still the original one in [GK15] in a solution of Erdos' problem of distinct distances (also see Guth [Gut15] for a simplified but weaker version of the main result of [GK15]), but a fair number of other applications have been found since then: see Solymosi and Tao [ST12], Zahl [Zah13], Kaplan et al. [KMS12], Kaplan et al. [KMSS12], Zahl [Zah12], Wang et al. [WYZ13], Agarwal et al. [AMS13], Sharir, Sheffer, Zahl [SSZ12], and Sharir and Solomon [SS14] (our list is most likely incomplete and we apologize for omissions). Given an n-point set P ⊂ Rd and a parameter r > 1, we say that a nonzero polynomial r -partitioning polynomial for P if none of the connected components of f ∈ R[x1, . . . , xd] is a 1 Rd \ Z(f ) contains more than n/r points of P . Guth and Katz [GK15] proved that, for every P and every r > 1, there exists a 1 r - partitioning polynomial of degree O(r1/d). From the results of real algebraic geometry on the complexity of arrangements of zero sets of polynomials (see [BPR03]) it follows that any hyperplane h intersects at most O(r1−1/d) components of Rd \ Z(f ), and hence any halfspace crosses at most O(r1−1/d) components of Rd \ Z(f ). Moreover, using a more recent result of Barone and Basu [BB12] discussed below, one obtains that an algebraic variety X of dimension k defined by polynomials of constant-bounded degrees crosses at most O(rk/d) components of Rd \ Z(f ). In this respect, polynomial partitions match the performance of simplicial partitions concerning hyperplanes and give a crucial advantage for other varieties. However, they still leave an important issue open: namely, what should be done with the exceptional set P ∗ := P ∩ Z(f ) that ends up lying within the zero set of the partitioning polynomial. Multilevel polynomial partitions. At first sight, it may seem that this issue can be remedied, say, by a suitable perturbation of the polynomial f . However, if all of P lies on a line in Rd, say, then a degree-D polynomial can partition it into at most D + 1 pieces, and so if we want all of P to be partitioned into pieces of size n/r, then we will need degree about r, as opposed to r1/d in the Guth–Katz polynomial partition theorem. A natural idea is to partition the exceptional set P ∗ further by another polynomial g such that Z(f, g) := Z(f ) ∩ Z(g) has dimension at most d − 2. If Z(f, g) again contains many points of P ∗, we would like to partition them further by a third polynomial h with dim Z(f, g, h) ≤ d − 3, and so on. This program encounters several technical difficulties, and so far it has been realized only up to the second partitioning polynomial g in [Zah13] and [KMSS12] (also see [Zah12]). Our main result is the following multilevel partition theorem. 2 Theorem 1.1. For every integer d > 1 there is a constant K such that the following hold. Given an n-point set P ⊂ Rd and a parameter r > 1, there are numbers r1, r2, . . . , rd ∈ [r, rK ], positive integers t1, t2, . . . , td, a partition P = P ∗ ∪ d ti [ i=1 [ j=1 Pij of P into disjoint subsets, and for every i, j, a connected set Sij ⊆ Rd containing Pij, such that Pij ≤ n/ri for all i, j, P ∗ ≤ rK, and the following hold: (i) If h ∈ R[x1, . . . , xd] is a polynomial of degree bounded by a constant D0, and X = Z(h) is its zero set, then, for every i = 1, 2, . . . , d, the number of the Sij crossed by X is at most O (cid:16)r1−1/d (cid:17), with the implicit constant also depending on D0. i (ii) If X is an algebraic variety in Rd of dimension at most k ≤ d − 2 defined by polynomials of degree bounded by a constant D0, then, for every i = 1, 2, . . . , d, the number of the Sij crossed by X is bounded by O (cid:16)r1−1/(k+1) (cid:17). i We will need only part (i), while part (ii) is stated for possible future use, since it can be handled with very little extra work. Related work. The problem concerning the exceptional set P ∗ in a single-level polynomial partition has been addressed in various ways in the literature. In one of the theorems in Agarwal et al. [AMS13], P ∗ is forced to be at most of a constant size, by an infinitesimal perturbation of P . However, this strategy cannot be used in incidence problems, for example, where a perturbation destroys the structure of interest. Moreover, for algorithmic purposes, known methods of infinitesimal perturbation are applicable with a reasonable overhead only for constant values of r. Solymosi and Tao [ST12] handle the exceptional set essentially by projecting it to a hyper- plane. This yields a (d − 1)-dimensional problem, which is handled recursively. Their method allows them to deal only with constant values of r, and consequently it yields bounds that are suboptimal by factors of nε (where ε > 0 is arbitrarily small but fixed number). Another variant of the strategy of projecting P ∗ to a hyperplane was used in [AMS13]; there r could be chosen as a small but fixed power of n, leading to only polylogarithmic extra factors, as opposed to nε with constant r. However, the resulting algorithm and proof are complicated, since one has to keep track of several parameters and solve a tricky recursion. Our proof of Theorem 1.1 also involves a projection trick, but the projection is encapsu- lated in the proof and simple to analyze, and in applying the theorem we can work in the original space all the time. In this paper we apply an algorithmic enhancement of Theorem 1.1, stated below, to recover the main result of Agarwal et al. [AMS13] in a way that is simpler both conceptually and technically. While this paper was in preparation, two groups of researchers announced results concern- ing multilevel polynomial partitions, which partially overlap with ours. Fox, Pach, Sheffer, Suk, and Zahl [FPS+14] as well as Basu and Sombra [BS14], obtained results similar to our key lemma (Lemma 3.1), but with different proofs. However, the Basu–Sombra result works just for varieties of codimension two and hence it cannot be used for our range searching algorithm. On the other hand, Fox et al. have no restriction on the dimension of the variety, 3 but they have to assume the variety is irreducible. The important feature of our method is that we are able to avoid computing irreducible components which is crucial from algorithmic point of view. For more details we refer to the discussion in Section 7. Range searching with semialgebraic sets. Here we consider a basic and long-studied question in computational geometry. Let P be a set of n points in Rd and let Γ be a family of geometric "regions," called ranges, in Rd. For example, Γ can be the set of all axis-parallel boxes, balls, simplices, or cylinders, or the set of all intersections of pairs of ellipsoids. In the Γ-range searching problem, we want to preprocess P into a data structure so that the number of points of P lying in a query range γ ∈ Γ can be counted efficiently. More generally, we may be given a weight function on the points in P and we ask for the cumulative weight of the points in P ∩ γ (our result applies in this more general setting as well). We consider the low-storage variant of Γ-range searching, where the data structure is allowed to use only linear or near-linear storage, and the goal is to make the query time as small as possible. We study semialgebraic range searching, where Γ is a set of constant-complexity semialge- braic sets. We recall that a semialgebraic set is a subset of Rd obtained from a finite number of sets of the form {x ∈ Rd g(x) ≥ 0}, where g is a d-variate polynomial with integer co- efficients, by Boolean operations (unions, intersections, and complementations). Specifically, let Γd,D,s denote the family of all semialgebraic sets in Rd defined by at most s polynomial inequalities of degree at most D each. By semialgebraic range searching we mean Γd,D,s-range searching for some parameters d, D, s. This problem and various special cases of it have been studied in many papers. We refer to [AE98, Mat95] for background on range searching and to [AMS13] for a more detailed discussion of the problem setting and previous work. The main result of [AMS13] is as follows. Theorem 1.2. Let d, D0, s, and ε > 0 be constants. Then the Γd,D0,s-range searching prob- lem for an arbitrary n-point set in Rd can be solved with O(n) storage, O (cid:0)n1+ε(cid:1) expected preprocessing time, and O (cid:0)n1−1/d logB n(cid:1) query time, where B is a constant depending on d, D0, s and ε. As announced, here we provide a new and simpler proof. Basically we apply Theorem 1.1, but for the algorithmic application, we need to amend it with an algorithmic part, essentially asserting that the construction in Theorem 1.1 can be executed in time depending polyno- mially on r and linearly on n (we again stress that d is taken as a constant). Moreover, we need that the Sij can be handled algorithmically-they are semialgebraic sets of controlled complexity. We will use the real RAM model of computation where we can compute exactly with arbitrary real numbers and each arithmetic operation is executed in unit time. A precise statement is as follows. Theorem 1.3 (Algorithmic enhancement of Theorem 1.1). Given P ⊂ Rd and r as in Theorem 1.1, one can compute the sets P ∗, Pij, and Sij in time O (cid:0)nrC(cid:1), where C = C(d) is a constant. Moreover, for every i, the number ti of the Pij is ti = O (cid:0)rC(cid:1), and each Sij is a semialgebraic set defined by at most O (cid:0)rC(cid:1) polynomial inequalities of maximum degree (cid:17) of the O (cid:0)rC(cid:1). For every i = 1, 2, . . . , d, every range γ ∈ Γd,D0,s crosses at most O (cid:16)r1−1/d Sij, with the constant of proportionality depending on d, D0, s. i 4 2 Algebraic preliminaries Throughout the paper we assume that we are working in the Real RAM model of computation, where arithmetic operations with arbitrary real numbers can be performed exactly and in unit time. This is the most usual model in computational geometry. We could also consider the bit model (a.k.a. Turing machine model), assuming the input points rational or, say, algebraic. Then the analysis would be more complicated, but we believe that, with sufficient care, bounds analogous to those we obtain in the Real RAM model can be derived as well, with an extra multiplicative term polynomial in the bit size of the input numbers. For example, the algorithms of real algebraic geometry we use are also analyzed in the bit model in [BPR03], and the polynomiality claims we rely on still hold. However, at present we do not consider this issue sufficiently important to warrant the additional complication of the paper. Notions and tools from algebraic geometry over C. A real algebraic variety V is a subset of some Rd that can be expressed as V = Z(f1, . . . , fm), i.e., the set of common zeros of finitely many polynomials f1, . . . , fm ∈ R[x1, . . . , xd]. For a complex algebraic variety, R is replaced with C (the complex numbers).1 As in the introduction, we will use Z(f ) for the real zeros of a (real) polynomial f ∈ R[x1, . . . , xd], while ZC(f ) is the set of all zeros of a complex or real polynomial in Cd. For a real polynomial f we have Z(f ) = ZC(f ) ∩ Rd. A nonempty complex variety V is called irreducible if it cannot be written as the union of two proper complex subvarieties, and similarly for real varieties. The empty set is not considered to be irreducible. Note that Z(f ) can be irreducible over R even if ZC(f ) is reducible over C. An easy example is the variety V (x2 + y2). It is well known that every nonempty variety can be uniquely decomposed into a finite number of irreducible components, none containing another. For a complex variety V , we will use the notions of dimension dim V and degree deg V . These can be defined in several equivalent ways. We refer to the literature such as [CLO07, Har92, Har77], for rigorous treatment. Here we just recall a rather intuitive definition and state the properties we will actually use. The dimension of V ⊆ Cd can be defined as the largest k such that a generic (d − k)- dimensional complex affine subspace F of Cd intersects V in finitely many points, and the degree is the number of intersections (which is the same for all generic F ). To explain the meaning of "generic", let us consider only the subspaces F = F (a) that can be expressed by d−k j=0 ∈ Ck(d−k+1). The F (a) being generic means that the point a does not lie in the zero set of a certain nonzero polynomial (depending on V ). In particular, almost all subspaces F in the sense of measure are generic. We note that the dimension of Cd is d and its degree is 1. the equations xi+d−k = ai0 + Pd−k j=1 aijxj, i = 1, . . . , k, for some a = (aij)k i=1 If V = ZC(f ) is the zero set of a single squarefree polynomial, then deg V = deg f . We will always assume that the polynomials we deal with are squarefree. For a real algebraic variety V , the definition with a generic affine subspace does not quite make sense, and in real algebraic geometry, the dimension is usually defined, for the more general class of semialgebraic sets, as the largest k such that V contains the image 1More precisely, these are affine algebraic varieties, while other kinds of algebraic varieties, such as projective or quasiprojective ones, are often considered in the literature. Here, with a single exception, we suffice with the affine case. 5 of a k-dimensional open cube under an injective semialgebraic map; see [BCR98, BPR03]. An equivalent way of defining the dimension of a real algebraic variety V uses the Krull dimension2 of the coordinate ring R[x1, . . . , xd]/I(V ), where I(V ) is the ideal of all real polynomials vanishing on V ; see [BCR98, Cor. 2.8.9] for this equivalence. For complex case the dimension defined via generic affine subspaces coincides with the Krull dimension of the coordinate ring C[x1, . . . , xd]/IC(V ); see [Har92, Chapter 11]. We will need the following fact, which is apparently standard (for example, it is mentioned without proof as Remark 13 in [BB13]), although so far we have not been able to locate an explicit reference (Whitney [Whi57, Lemma 8] proves a similar statement, but he uses definitions that are not standard in the current literature). Lemma 2.1. Let V ⊆ Cd be a complex variety. Then V ∩ Rd is a real variety and dim(V ∩ Rd) ≤ dim V . This is perhaps not as obvious as it may seem, because if we identify Cd with R2d in the usual way, then topologically, a k-dimensional complex variety V has (real) dimension 2k. Sketch of proof. If V = ZC(f1, . . . , fm) for f1, . . . , fm ∈ C[x1, . . . , xd], then V ∩ Rd = Z(f1f 1, . . . , fmf m), where the bar denotes complex conjugation. Each fif i is a real polynomial, and so V ∩ Rd is a real variety. The inequality for the dimensions can be checked, for example, by employing the defi- nition of the dimensions via the Hilbert function (see, e.g., [CLO07]), which is well known Indeed, if f ∈ C[x1, . . . , xd] is a com- to be equivalent to the Krull dimension definition. plex polynomial of degree at most D vanishing on V , we can write f = f1 + if2, where f1, f2 ∈ R[x1, . . . , xd] correspond to the real and complex parts of coefficients of f , respec- tively. Then deg f1 and deg f2 are at most D and both f1 and f2 vanish on V ∩ Rd. Therefore, if (g1, . . . , gm) is a basis of the real vector space of all real polynomials of degree at most D vanishing on V ∩ Rd, then the g1, . . . , gm, regarded as complex polynomials, generate the complex vector space of all complex polynomials of degree at most D vanishing on V . It follows that the Hilbert function of the complex variety V is at least as large as the Hilbert function of the real variety V ∩ Rd. Lemma 2.2 (A generalized B´ezout inequality). Let V ⊆ Cd be an irreducible variety, let f ∈ C[x1, . . . , xd] be a polynomial that does not vanish identically on V , and let W1, . . . , Wk be the irreducible components of V ∩ ZC(f ). Then all of the Wi have dimension dim(V ) − 1, and their degrees satisfy k X i=1 deg Wi ≤ deg(V ) deg(f ). Proof. We may assume that f is irreducible (if not, we decompose it into irreducible factors, use the lemma for each factor separately, and add up the degrees). The first part about dimension of every irreducible component is exactly [Har77, Exer- cise I.1.8] (also see [Har77, Prop. I.7.1]). 2The Krull dimension of a ring R is the largest n such that there exists a chain I0 ( I1 ( · · · ( In of nested prime ideals in R. 6 As for the statement with degrees, we let V ⊆ PCd be the projective closure of V , and similarly for ZC(f ). Let Y1, . . . , Ym be the irreducible components of V ∩ ZC(f ). By [Har77, Thm. I.7.7], we have Pm i=1 deg Yi ≤ deg(V ) deg(ZC(f )) = deg(V ) deg(f ). For every Wi, the projective closure W i is irreducible, and so it equals a unique Yj(i), and deg Wi ≤ deg Yj(i). The lemma follows. Also see [Hei83, Thm. 1] for a similar statement. We will need to apply the lemma to a variety that is not necessarily irreducible. We if V1, . . . , Vk are the irreducible will use that the degree is additive in the following sense: components of a variety V , with dim Vi = dim V for all i, then deg V = Pk We also need the property that a variety of degree ∆ can be defined by polynomials of i=1 deg Vi. degree at most ∆. Theorem 2.3 (Prop. 3 in [Hei83]). Let V be an irreducible affine variety in Cd. Then there exist d + 1 polynomials f1, . . . , fd+1 ∈ C[x1, . . . , xd] of degree at most deg V such that V = ZC(f1, . . . , fd+1). Ideals and Grobner bases. For polynomials f1, . . . , fm ∈ C[x1, . . . , xd], the ideal I gener- ated by f1, . . . , fm is the set of all polynomials of the form h1f1 + · · · + hmfm, h1, . . . , hm ∈ C[x1, . . . , xd]. Every such ideal has a Grobner basis, which is a set of polynomials that also generates I and has certain favorable properties; see, e.g., [CLO07] for an introduction. Each Grobner basis is associated with a certain monomial ordering. We will use only Grobner bases with respect to a lexicographic ordering, where monomials in the variables x1, . . . , xd are first ordered according to the powers of xd, then those with the same power of xd are ordered according to powers of xd−1, etc. In other words, we consider lexicographic ordering w.r.t. xd > xd−1 > · · · > x1. We will need the following theorem: Theorem 2.4. Assuming d fixed and given polynomials f1, . . . , fm ∈ C[x1, . . . , xd] with deg fi ≥ 1, a Grobner basis of the ideal generated by the fi can be computed in time polynomial in Pm i=1 deg fi. We have not found an explicit reference in the literature that would provide Theorem 2.4. In particular, for the usual Buchberger algorithm and variations of it, only much worse bounds seem to be known. However, Theorem 2.4 follows by inspecting the method of Kuhnle and Mayr [KM96] for finding a Grobner basis in exponential space. (Also see [MR11] for a newer algorithm.) Before providing the details, we need one definition: For any polynomial h ∈ C[x1, . . . , xd], the normal form NF(h) w.r.t. I ⊆ C[x1, . . . , xd] is the unique irreducible 3 polynomial w.r.t. I in the coset4 h + I. Recall that we have fixed lexicographic ordering.5 We note that Kuhnle and Mayr work over the field Q, however, the theoretical background works also for C. Let I ⊆ C[x1, . . . , xd] be an ideal whose Grobner basis we want to compute and assume it is generated by m polynomials of degree bounded by D. 3A polynomial h is reducible w.r.t. I if supp(h) ∩ hℓm(I)i 6= ∅, where the support of h is a set of all monomials occurring in h (i.e., having nonzero coefficient) and hℓm(I)i = hℓm(f ) : f ∈ Ii is an ideal of all leading monomials of I, where leading monomial ℓm(f ) is the largest monomial occurring in f . 4h + I = {h + f : f ∈ I}. 5We note that the algorithm by [KM96] requires the monomial ordering given by rational weight matrix. The weight matrix of lexicographic ordering consists just of zero's and one's, and hence it is rational. See [KM96] for details. 7 (i) First important lemma [KM96, Section 5],[MR11, Lemma 3] is that the reduced Grobner basis is always equal to the set of all the polynomials h − NF(h), where h is a monomial minimally reducible 6 w.r.t. I. (ii) Let h ∈ C[x1, . . . , xd] be arbitrary but fixed. Our next goal is to compute NF(h) w.r.t. I. Since h − NF(h) ∈ I, there is a representation h − NF(h) = m X i=1 cifi with c1, . . . , cm ∈ C[x1, . . . , xd]. (1) The next step is to rewrite the polynomial equation (1) to a system of linear equations. Recall that h and fi's are fixed and NF(h) and ci's are unknowns. Let us assume that deg ci ≤ E for all i and some E. Expanding all the polynomials h, fi, ci and also the polynomial r := NF(h) to sums of monomials and comparing the coefficients of left and right side in (1), we get one linear equation for every term. If deg NF(h) ≤ N for some N , it can be shown that there are at most (max(N, D + E))d equations in no more than N d + mEd unknowns. It follows that all these linear equations can be rewritten into a single matrix equation and the size of the matrix is bounded by N d + m(D + E)d. For more details we refer to [KM96, Section 3]. Note that it can happen that there are more unknowns than equations. Fortunately, since we are interested in a solution with minimal r (w.r.t. lexicographic ordering), we can always decrease the number of unknowns by putting the coefficient corresponding to the largest monomial of r to be zero. For more details (and also example) we again refer to [KM96, Section 3]. (iii) Now we want to bound degrees of ci's and also the degree of NF(h). By Hermann [Her26, MM82], the degrees of ci's are bounded by E := deg(h − NF(h)) + (mD)2d . Dub´e [Dub90] showed the existence of a Grobner basis G for I where the degrees of all polynomials in G are bounded by M := 2(D2/2 + D)2d−1 . Using this bound, Kuhnle and Mayr [KM96, Section 2] showed that the degree of the normal form of h w.r.t. I can be always bounded by N := ((M + 1)d deg(h))d+1. (iv) It follows that to compute reduced Grobner basis of I it is enough to enumerate all monomials up to Dub´e's bound and calculate their normal forms and normal forms of all its direct divisors. This can be done by solving the system of linear equations described in (ii). In order to turn the described method into an algorithm, we have to be able to efficiently solve a system of linear equations. Kuhnle and Mayr used Turing machines, that is why they need to work over Q. Since we work with the Real RAM model of computation which allows arithmetic operations with arbitrary real numbers (in unit time), we can use the described algorithm over C as well. Now we are ready to prove Theorem 2.4. every i. i=1 deg fi and m ≤ Pm Proof of Theorem 2.4. Clearly D ≤ Pm polynomial time in Pm i=1 deg fi, since deg fi ≥ 1 for It follows from (i)–(iv) that, for d fixed, the Grobner basis can be computed in i=1 deg fi. Indeed, by (ii) and (iii), the normal form of a polynomial 6A monomial h is minimally reducible w.r.t. I if it is reducible w.r.t. I but none of its proper divisors is reducible w.r.t. I. 8 of degree bounded by O(D) can be computed in time polynomial in D, and hence also in i=1 deg fi. According to (iv), the step (ii) is repeated polynomially many times; the claim Pm follows. Tools from real algebraic geometry. Let F ⊂ R[x1, . . . , xd] be a finite set of polynomials. The arrangement of (the zero sets of) F is the partition of Rd into maximal relatively open connected subsets, called cells, such that for each cell C there is a subset FC ⊆ F such that C ⊆ Z(f ) for all f ∈ FC and C ∩ Z(f ) = ∅ for all f ∈ F \ FC. Similar to [AMS13], a crucial tool for us is the following theorem of Barone and Basu. Theorem 2.5 (Barone and Basu [BB12]). Let V be a k-dimensional algebraic variety in Rd defined by a finite set F of d-variate real polynomials, each of degree at most D, and let G be a set of s polynomials of degree at most E ≥ D. Then the number of those cells of the arrangement of the zero sets of F ∪ G that are contained in V is bounded by O(1)dDd−k(sE)k. We will be using the theorem only for d a constant and G = {g} consisting of a single polynomial to get an upper bound of O(Dd−kEk) on the number of connected components of V \ Z(g). For the range searching algorithm, we also need the following algorithmic result on the construction of arrangements. Theorem 2.6 (Basu, Pollack and Roy [BPR03, Thm. 16.18]). Let F = {f1, . . . , fm} be a set of m real d-variate polynomials, each of degree at most D. Then the arrangement of the zero sets of F in Rd has at most (mD)O(d) cells, and it can be computed in time at most T = md+1DO(d4). Each cell is described as a semialgebraic set using at most T polynomials of degree bounded by DO(d3). Moreover, the algorithm supplies adjacency information for the cells, indicating which cells are contained in the boundary of each cell, and it also supplies an explicitly given point in each cell. 3 A key lemma: Partitioning Polynomial that does not vanish on a variety In this section we establish the following lemma, which will allow us to deal with the excep- tional sets and iterate the construction of a partitioning polynomial. Although we are dealing with a problem in Rd, it will be more convenient to work with complex varieties. This is because algebraic varieties over an algebraically closed field have some nice properties that fail for real varieties in general. Lemma 3.1 (Key lemma). Let V ⊆ Cd be a complex algebraic variety of dimension k ≥ 1, such that all of its irreducible components Vj have dimension k as well. Let Q ⊂ V ∩ Rd be a finite point set, and let r > 1 be a parameter. Then there exists a real 1 r -partitioning polynomial g for Q of degree at most D = O(r1/k) that does not vanish identically on any of the irreducible components Vj of V . Note that the bound on deg g in the key lemma cannot be improved to O (cid:16)(cid:0) r where ∆ is the degree of V , unless there are some restrictive conditions on r. We thank to the anonymous referee, who pointed it out. The example is as follows: let us assume that all points of Q lie on a k-flat F . Since F is isomorphic to Rk, partitioning of Q corresponds to ∆(cid:1)1/k(cid:17), 9 a partititioning in Rk. It is clear that if V is formed by a union of F and many other k-flats ∆(cid:1)1/k(cid:17) cannot parallel to F , then (cid:0) r serve as a degree bound for a partitioning polynomial. ∆(cid:1)1/k can be made arbitrarily close to zero and hence O (cid:16)(cid:0) r However, we believe that, for an irreducible variety, one can hope for a better bound and we propose the following conjecture: Conjecture 3.2. Let V ⊆ Cd be an irreducible complex algebraic variety of dimension k ≥ 1 and degree ∆. Let Q ⊂ V ∩ Rd be a finite point set, and let r ≥ ∆k+1, r > 1 be a parameter. ∆(cid:1)1/k(cid:17) Then there exists a real 1 that does not vanish identically on V . r -partitioning polynomial g for Q of degree at most D = O (cid:16)(cid:0) r Note that for k = d the affirmative answer follows from the partitioning theorem by Guth and Katz [GK15], and for k = d − 1 from the theorem by Kaplan et al. [KMSS12] (for d = 3) and also by Zahl [Zah13]. We also note that Basu and Sombra propose similar conjecture, see [BS14, Conj. 3.4]. Even if the conjecture is true, we cannot use it for our range searching application unless we know how to effectively decompose a variety into irreducibles. Before proving the key lemma, we first sketch the idea. The proof is based on a projec- tion trick. Let us consider the standard projection πd : Cd → Cd−1 given by (a1, . . . , ad) 7→ (a1, . . . , ad−1), i.e., forgetting the last coordinate. The standard projection of an affine variety need not be a variety in general (consider, e.g., the projection of the hyperbola Z(xy − 1) on the x-axis). However, for every variety of dimension at most d − 1, there is a simple linear change of coordinates in Cd (Lemma 3.4) after which the image of V under the standard pro- jection is a variety in Cd−1 (Theorem 3.3). Moreover, this projection preserves the dimension of the variety (Theorem 3.3). The idea of the proof of the key lemma is to project the given k-dimensional complex variety V onto Ck, by iterating the standard projection, and, if necessary, coordinate changes in such a way that the image of V is all of Ck (Corollary 3.5). Then we find a 1 r -partitioning polynomial for the projection of the given point set Q by the Guth–Katz method, and we pull it back to a 1 r -partitioning polynomial in Rd. We now present this approach in more detail. We begin with a well-known sufficient condition guaranteeing that the standard projection of a variety is a variety of the same dimension. Theorem 3.3 (Projection theorem). Let I ⊂ C[x1, . . . , xd] be an ideal, d ≥ 2, and let J := I ∩ C[x1, . . . , xd−1] be the ideal consisting of all polynomials in I that do not contain the variable xd. Suppose that I contains a nonconstant polynomial f , with D = deg f ≥ 1, in which the monomial xD d appears with a nonzero coefficient. Let V = V (I) be a complex variety defined as the zero locus of all polynomials in I. Then the image πd(V ) under the standard projection πd : Cd → Cd−1 is the variety ZC(J) ⊆ Cd−1, and dim πd(V ) = dim V . Proof. Theorem 1.68 in [DP13] contains everything in the theorem except for the claim dim πd(V ) = dim V . For this claim, which is also standard, we first observe that, for every point a ∈ πd(V ), the xd-coordinates of these preimages are roots of the nonzero univariate polynomial fa(xd) := f (a1, . . . , ad−1, xd). In other words the extension C[x1, . . . , xd−1]/J ⊆ 10 C[x1, . . . , xd]/I is integral.7 By [HS06, Thm. 2.2.5], integral extension preserves the (Krull) dimension. The next standard lemma (a simple form of the Noether normalization for infinite fields) implies that the condition in the projection theorem can always be achieved by a suitable change of coordinates. See, e.g., [DP13, Lemma 1.69]. Lemma 3.4. Let f ∈ C[x1, . . . , xd] be a polynomial of degree D ≥ 1. Then there are coeffi- cients λ1, . . . , λd−1 such that f ′(x1, . . . , xd) := f (x1 + λ1xd, . . . , xd−1 + λd−1xd, xd) is a polynomial of degree D in which the monomial xD d has a nonzero coefficient. This holds for a generic choice of the λi, meaning that there is a nonzero polynomial g ∈ C[y1, . . . , yd−1] such that f ′ satisfies the condition above whenever g(λ1, . . . , λd−1) 6= 0. Consequently, the condition on f ′ holds for almost all choices of a real vector (λ1, . . . , λd−1). By combining the projection theorem with Lemma 3.4 and iterating, we obtain the fol- lowing consequence: Corollary 3.5. Let V ⊂ Cd be a complex variety of dimension k, 1 ≤ k ≤ d − 1, for which all irreducible components also have dimension k. Then there is a linear map π : Cd → Ck, whose matrix w.r.t. the standard bases is real, such that π(Vj) = Ck for every irreducible component Vj of V . Proof. We construct π iteratively by composing standard projections and appropriate coordi- nate changes. First we choose a nonzero polynomial f vanishing on V , and we fix a change of coordinates as in Lemma 3.4 so that the corresponding polynomial f ′ is as in the projection d : Cd → Cd−1 be the composition of the standard projection πd with this theorem. Letting π′ coordinate change, we get that π′ d(V ) is a variety and dim π′ d(V ) = k. Let Vj be an irreducible component of V . Then f vanishes on Vj as well, and applying d(Vj) is a k-dimensional variety in the projection theorem with Vj instead of V , we get that π′ Cd−1 as well. We define π′ i : Ci → Ci−1, i = d − 1, d − 2, . . . , k + 1, analogously; to get π′ nonzero polynomial f that vanishes on the k-dimensional variety π′ desired projection π is the composition π := π′ k+1 ◦ · · · ◦ π′ d. i+1 ◦ · · · ◦ π′ i, we use some d(V ). The We get that π(V ) is a k-dimensional variety in Ck, and so is π(Vj) for every irreducible component Vj of V . But the only k-dimensional variety in Ck is Ck, and the corollary follows. Now we are ready to prove the key lemma. Proof of Lemma 3.1. Given the k-dimensional complex variety V and the n-point set Q ⊂ Rd as in the key lemma, we consider a projection π : Cd → Ck as in Corollary 3.5. Since the matrix of π is real, we can regard ¯Q := π(Q) as a subset of Rk. More precisely, ¯Q is a multiset in general, since π may send several points to the same point. (It would be easy to avoid such coincidences in the choice of π, but we do not have to bother with that.) 7A ring S is an integral extension of a subring R ⊆ S if all elements of S are roots of monic polynomials in R[x]. 11 1 We apply the original Guth–Katz polynomial partition theorem to ¯Q, which yields a r -partitioning polynomial ¯g ∈ R[y1, . . . , yk] for ¯Q of degree D = O(r1/k). We note that the Guth–Katz method works for multisets without any change (because the ham-sandwich theorem used in the proof applies to arbitrary measures and thus, in particular, to multisets). We define a polynomial g ∈ R[x1, . . . , xd] as the pullback of ¯g, i.e., g(x) := ¯g(π(x)). We have deg g = deg ¯g since π is linear and surjective. Moreover, g is a 1 r -partitioning polynomial for Q, since if π(q) and π(q′) lie in different components of Rk \ Z(¯g), then q and q′ lie in different components of Rd \ Z(g) (indeed, if not, a path γ connecting q to q′ and avoiding Z(g) would project to a path ¯γ connecting π(q) to π(q′) and avoiding Z(¯g)). Finally, since ¯g does not vanish identically on Ck and π(Vj) = Ck for every j, the polyno- mial g does not vanish identically on any of the irreducible components Vj. The key lemma is proved. 4 Proof of Theorem 1.1 Here we use the key lemma to construct the multilevel partition in Theorem 1.1. Thus, we are given an n-point set P ⊂ Rd and a parameter r > 1. We proceed in d steps. The parameters r1, r2, . . . , rd are set as follows: r1 := r, ri+1 := rc i , i = 1, 2, . . . , d − 1, where c is a sufficiently large constant (depending on d). This will allow us to consider quantities depending polynomially on ri as very small compared to ri+1. We will also have auxiliary degree parameters D1, D2, . . . , Dd, where Di = O (cid:16)r1/(d−i+1) i (cid:17) . At the beginning of the ith step, i = 1, 2, . . . , d, we will have the following objects: • A complex variety Vi−1, which may be reducible, but such that all irreducible compo- nents have dimension d − i + 1. Initially, for i = 1, V0 = Cd. • A set Qi−1 ⊆ P ∩ Vi−1, the current "exceptional set" that still needs to be partitioned. For i = 1, Q0 = P . We also have deg Vi−1 ≤ ∆i−1 := D1D2 · · · Di−1. i In the ith step, we apply the key lemma to Vi−1 and Qi−1 with r = ri (and k = d − i + 1). This yields a real (1/ri)-partitioning polynomial gi for Qi−1 of degree at most Di = (cid:17) that does not vanish identically on any of the irreducible components of Vi−1. O (cid:16)r1/(d−i+1) (For i = 1, this is just an application of the original Guth–Katz polynomial partition theorem.) Let Si1, . . . , Siti be the connected components of (Vi−1∩Rd)\Z(gi), and let Pij := Sij∩Qi−1 (these are the sets as in Theorem 1.1). For every j we have Pij ≤ Qi−1/ri ≤ n/ri since gi is a (1/ri)-partitioning polynomial. We also have the new exceptional set Qi := Qi−1 ∩ Z(gi). 12 Finally, we set Vi := Vi−1 ∩ ZC(gi). Since gi does not vanish identically on any of the irreducible components of Vi−1, all irreducible components of Vi are (d − i)-dimensional by Lemma 2.2, and the sum of their degrees, which equals deg Vi, is at most deg(Vi−1) deg(gi) ≤ ∆i−1Di ≤ D1D2 · · · Di = ∆i as needed for the next inductive step. This finishes the ith partitioning step. After the dth step, we end up with a 0-dimensional variety Vd, whose irreducible compo- nents are points, and their number is deg Vd ≤ ∆d, a quantity polynomially bounded in r. The set Qd is the exceptional set P ∗ in Theorem 1.1, and Qd ≤ Vd = deg Vd ≤ ∆d. The crossing number. crossed by X as in parts (i) and (ii) of the theorem. It remains to prove the bounds on the number of the sets Sij First let X = Z(h) be a hypersurface of degree D0 = O(1) as in (i). For i = 1, we actually get that X intersects at most O (cid:16)r1−1/d (cid:17) of the S1j, because the number of the S1j intersected by X is no larger than the number of connected components of X \ Z(g1). By the Barone–Basu theorem (Theorem 2.5), the number of these components is bounded by O((deg h)(deg g1)d−1) = O (cid:16)D0Dd−1 1 (cid:17) = O (cid:16)r1−1/d (cid:17) as claimed. 1 1 Now let i ≥ 2. We want to bound the number of the sets Sij crossed by X. Let U1, . . . , Ub be the irreducible components of Vi−1 whose real points are not completely contained in X; that is, satisfying Uℓ ∩ Rd 6⊆ X. We have b ≤ deg Vi−1 ≤ ∆i−1. For every j such that X crosses Sij, let us fix a point yj ∈ Sij \ X and another point zj ∈ Sij ∩ X (they exist by the definition of crossing). Since Sij is path-connected, there is also a path γj ⊆ Sij connecting yj to zj. Let z∗ j be the first point of X on γj when we go from yj towards zj. We observe that z∗ j lies in some Uℓ. Indeed, points on γj just before z∗ j lie in Vi−1 (since Sij ⊆ Vi−1) but not in X, hence they lie in some Uℓ, and Uℓ, being an algebraic variety, is closed in the Euclidean topology. For any given Uℓ, a connected component of (Uℓ ∩ Rd ∩ X) \ Z(gi) may contain at most j (since the Sij are separated by Z(gi)). Therefore, the number of the Sij crossed one of the z∗ by X is no more than b X ℓ=1 #(Wℓ \ Z(gi)), where Wℓ := Uℓ ∩ Rd ∩ X, and # denotes the number of connected components. Since Uℓ is irreducible and X does not contain all of its real points, the polynomial h defining X does not vanish on Uℓ, and thus Uℓ∩ZC(h) is a proper subvariety of Uℓ of (complex) dimension dim Uℓ − 1 = d − i. Hence, by Lemma 2.1, the real variety Wℓ = (Uℓ ∩ ZC(h)) ∩ Rd also has (real) dimension at most d − i. By Theorem 2.3, we have Uℓ = ZC(f1, . . . , fm) for some, generally complex, polynomials of degree at most deg Uℓ ≤ ∆i−1. Thus Wℓ is the real zero set of the real polynomials h, f1f 1, . . . , fmf m. These polynomials have degrees bounded by max(D0, 2∆i−1) = O(∆i−1). By the Barone–Basu theorem again, the number of components of Wℓ \ Z(gi) is at most O(∆d−dim Wℓ i−1 Ddim Wℓ i ) = O(∆d i−1Dd−i i ) = O (cid:16)∆d i−1r1−1/(d−i+1) i (cid:17) . The total number of the Sij crossed by X is then bounded by ∆i−1 times the last quantity, i.e., by O (cid:16)∆d+1 i−1, we can (cid:17) = O (cid:16)(D1D2 · · · Di−1)d+1r1−1/(d−i+1) (cid:17). Since ri = rc i−1 r1−1/(d−i+1) i i 13 make (D1D2 · · · Di−1)d+1 smaller than any fixed power of ri, and hence we can bound the last (cid:17) (recall that i ≥ 2), which finishes the proof of part (i) of the theorem. estimate by O (cid:16)r1−1/d For part (ii), the argument requires only minor modifications. Now X is a variety of i dimension k ≤ d − 2 defined by real polynomials of degree at most D0 = O(1). We have dim Vi−1 = d − i + 1, and for dim X = k ≤ d − i we simply count the components of X \ Z(gi), as we did for part (i) in the case i = 1. This time we obtain the bound O (cid:16)Dd−dim X (cid:17) = O (cid:0)Dk d−i+1 increases with i, and thus it is the largest for d − i = k, in which case (cid:17). (This is the critical case; for all of the other i we get a better i (cid:1) = O (cid:16)rk/(d−i+1) The exponent Ddim X (cid:17). k 0 i i the bound is O (cid:16)r1−1/(k+1) bound.) i For k ≥ d − i + 1, we argue as in part (i): letting U1, . . . , Ub be the irreducible components of Vi−1 with Uℓ ∩ Rd 6⊆ X and Wℓ := Uℓ ∩ Rd ∩ X, the number of the Sij crossed by X is bounded by Pb ℓ=1 #(Wℓ\Z(gi)), and each Wℓ has (real) dimension at most dim Vi−1−1 = d−i. The number of components of Wℓ \ Z(gi) is again bounded, by the Barone–Basu theorem, (cid:17). For every fixed by O (cid:16)∆d δ > 0, we can choose the constant c in the inductive definition of the ri so large that ∆d+1 i−1 ≤ rδ i , and so the previous bound is no more than O (cid:16)r1−1/(d−i+1)+δ (cid:17), and the sum over all Wℓ is O (cid:16)∆d+1 i−1 r1−1/(d−i+1) i−1r1−1/(d−i+1) (cid:17). i i i The exponent 1 − 1 O (cid:16)r1−1/k+δ proof of Theorem 1.1. (cid:17). By letting δ := 1 i d−i+1 is maximum for d − i + 1 = k, in which case our bound is (cid:17). This concludes the k+1, we bound this by O (cid:16)r1−1/(k+1) k − 1 i 5 Algorithmic aspects of Theorem 1.1 The goal of this section is to prove Theorem 1.3. In order to make the proof of Theorem 1.1 algorithmic, we need to compute both with real and complex varieties. A variety V , both in the real and complex cases, is represented by a finite list f1, . . . , fm of polynomials such that V = Z(f1, . . . , fm). The size of such a representation is measured as m + Pm i=1 deg fi. It would perhaps be more adequate to use (cid:0)deg fi+d (cid:1), the number of monomials in a general d-variate polynomial of degree deg fi, instead of just deg fi, but since we consider d constant, both quantities are polynomially equivalent. d If we want to pass from a complex V defined by generally complex polynomials f1, . . . , fm to the real variety V ∩ Rd, we use the trick already mentioned: V ∩ Rd is defined by the real polynomials f1f 1, . . . , fmf m. To make the construction in Theorem 1.1 algorithmic, besides some obvious steps (such as testing the membership of a point in a variety, which is done by substituting the point coordinates into the defining polynomials), we need to implement the following operations: (A) Given a variety V in Cd of dimension k, 1 ≤ k ≤ d − 1, such that all irreducible compo- nents of V have dimension k, compute a real projection π : Cd → Ck as in Corollary 3.5, i.e., such that π(Vj) = Ck for all irreducible components Vj of V . (B) Given a point (multi)set Q ⊂ Rk, k ≤ d, construct a 1 r -partitioning polynomial of degree O (cid:0)r1/k(cid:1) (as in the proof of the key lemma). 14 (C) Given a complex variety V and a polynomial g, compute V ∩ ZC(g). d, where π′ For (A), we follow the proof of Corollary 3.5, i.e., we compute π as the composition i : Ci → Ci−1 sends (x1, . . . , xi) to (x1 + λi,1xi, . . . , xi−1 + λi,i−1xi), k+1 ◦ · · · ◦ π′ π′ with the λij chosen independently at random from the uniform distribution on [0, 1], say (or, if we do not want to assume the capability of generating such random reals, we can still choose them as random integers in a sufficiently large range). The composed π will work almost surely (or, if we use large random integers, with high probability-this can be checked using the Schwartz–Zippel lemma). In order to verify that a particular π works, we verify the condition in the projection i separately. To this end, we compute the projected varieties theorem (Theorem 3.3) for each π′ Vi := π′ i+1 ◦ · · · ◦ π′ d(V ) in Ci; initially Vd = V . The projections can be computed in a standard way using Grobner bases w.r.t. the lex- icographic ordering; see [CLO07]. Namely, we suppose that Vi has already been computed. j := xj + λijxi, where the λij are those used in π(i) and λii = 0; We make the substitution x′ this transforms the list of polynomials defining Vi into another list of polynomials in the new variables x′ i. Since 1 ≤ dim Vi ≤ d − 1, it follows that all the polynomials in the list have degree at least one. Thus, by Theorem 2.4, we compute a Grobner basis Gi of the ideal generated by these new polynomials, with respect to the lexicographic ordering, where the ordering puts the variable xi first. 1, . . . , x′ If Gi contains no polynomial whose leading term is a power of xi (as in the projection theorem), then we discard πi, generate a new one, and repeat the test. If Gi does contain such a polynomial, then we take all polynomials in Gi that do not contain xi, and these define the i(Vi) in Ci−1. Indeed, recall that by [CLO07, Thm. 3.1.2], if G is a Grobner variety Vi−1 = π′ basis of I ⊆ C[x1, . . . , xd] then G ∩ C[x1, . . . , xd−1] is a Grobner basis of I ∩ C[x1, . . . , xd−1]. The claim now follows from the projection theorem. Thus, the computation of π takes a constant number of Grobner basis computations and (In practice, the coordinate projection the expected number of repetitions is a constant. forgetting the last d − k coordinates will probably work most of the time; then only one Grobner basis computation is needed to verify that it works.) For operation (B), constructing a partitioning polynomial for points in Rk, we use a (randomized) algorithm from [AMS13, Thm. 1.1], which runs in expected time O (cid:0)Qr + r3(cid:1) for fixed k. It also works for multisets, as can easily be checked. Since each point of the original input set P participates in no more than d of these operations, and the value of r in each of these cases is bounded by a polynomial function of the original parameter r in the theorem, the total time spent in all of the operations (B) in the construction is bounded by O(nrC) for a constant C. Operation (C), intersecting a complex variety with Z(g), is trivial in our representation, since we just add g to the list of the defining polynomials of V . This finishes the implementation of the operations, and now we need to substantiate the claims about the number and form of the sets Sij. We recall that each Sij is obtained as a cell in the arrangement of Z(gi) within Vi−1. The degrees of gi and of the polynomials defining Vi−1 are bounded by a polynomial in r. Then by Theorem 2.6, we get that each Sij is defined by at most rC polynomials of degree at most rC, and is computed in rC time. The number of the Sij is polynomially bounded in r as well. Finally, we need to consider a range γ ∈ Γd,D0,s. By definition, γ is a Boolean combination of γ1, . . . , γs, where γℓ = {x ∈ Rd : hℓ(x) ≥ 0}, with a polynomial hℓ of degree at most D0, and 15 moreover, if γ crosses a path-connected set A, then at least one of the varieties Xℓ = Z(hℓ) crosses A. It follows that the crossing number for γ is no more than s-times the bound in Theorem 1.1(i). This concludes the proof of Theorem 1.3. 6 The range searching result The derivation of the range searching result, Theorem 1.2, from Theorem 1.3, is by a standard construction of a partition tree as in [Mat92, AMS13], and here we give it for completeness (and also to illustrate its simplicity). Proof of Theorem 1.2. Given d, D0, s, ε > 0 and a set P ⊂ Rd, we choose a sufficiently large n0 = n0(d, D0, s, ε) and a sufficiently small parameter η = η(d, D0, s, ε) > 0, and we construct a partition tree T for P recursively as follows: If P ≤ n0, T consists of a single node storing a list of the points of P and their weights. For P > n0, we choose r := nη and we construct P ∗, the Pij, and the Sij as in Theo- rem 1.1. The root of T stores (the formulas defining) the Sij, the total weight of each Pij, and the points of P ∗ together with their weight. For each i and j, we make a subtree of the root node, which is a partition tree for Pij constructed recursively by the same method. By Theorem 1.3, the construction of the root node of T takes expected time O (cid:0)nrC(cid:1) = O (cid:0)n1+Cη(cid:1). The total preprocessing time T (n) for an n-point P obeys the recursion, for n > n0, T (n) ≤ O (cid:0)n1+Cη(cid:1) +Pi,j T (nij), with Pi,j nij ≤ n and nij ≤ n/r = n1−η, whose solution is T (n) ≤ O (cid:0)n1+Cη(cid:1). A similar simple analysis shows that the total storage requirement is O(n). Let us consider answering a query with a query range γ ∈ Γd,D0,s. We start at the root of T and maintain a global counter which is initially set to 0. We test the points of the exceptional set P ∗ for membership in γ one by one and increment the counter accordingly in rO(1) time. Then, for each i, j, we distinguish three possibilities: (i) If Sij ∩ γ = ∅, we do nothing. (ii) If Sij ⊆ γ, we add the total weight of the points of Pij to the global counter. (iii) Otherwise, we recurse in the subtree corresponding to Pij, which increments the counter by the total weight of the points of Pij ∩ γ. The three possibilities above can be distinguished, for given Sij, by constructing the arrangement of the zero sets of the polynomials defining Sij plus the polynomials defining γ, according to Theorem 2.6. The total time, for all i, j together, is rO(1). Since, by Theorem 1.3, γ together crosses at most O (cid:16)r1−1/d (cid:17) of the Sij, possibility (iii) (cid:17) values of j. We thus obtain the following recursion i occurs, for given i, for at most O (cid:16)r1−1/d for the query time Q(n), with the initial condition Q(n) = O(1) for n ≤ n0: i Q(n) ≤ nC ′η + d X i=1 O (cid:16)r1−1/d i (cid:17) Q (n/ri) , nη ≤ ri ≤ nKη, where C ′ and K are constants independent of η. A simple induction on n verifies that this implies, for η ≤ (1 − 1/d)/C ′, Q(n) = O (cid:0)n1−1/d logB n(cid:1) as claimed. 16 7 Remark: On (not) computing irreducible components For the algorithmic part, it is important that we do not need to compute the irreducible components of the varieties Vi (although we use the irreducible components in the proof of our multilevel partition theorem). There are several algorithms in the literature for computing irreducible components of a given complex variety (e.g., [EM99]). However, these algorithms need factorization of multivariate polynomials over C as a subroutine (after all, factoring a polynomial corresponds to computing irreducible components of a hypersurface). Polynomial factorization is a well-studied topic, with many impressive results; see, e.g., [Kal92] for a survey. In particular, there are algorithms that work in polynomial time, assum- ing the dimension fixed, but only in the Turing machine model. Adapting these algorithms to the Real RAM model, which is common in computational geometry and which we use, encounters some nontrivial obstacles-we are grateful to Erich Kaltofen for explaining this issue to us. It may perhaps be possible to overcome these obstacles by techniques used in real algebraic geometry for computing in abstract real-closed fields (see [BPR03]), but this would need to be worked out carefully. Then one could probably obtain rigorous complexity bounds on computing irreducible components of a complex variety, hopefully polynomial in fixed dimension; we find this question of independent interest. Acknowledgment We would like to thank Josh Zahl for pointing out mistakes in an earlier version of this paper, Saugata Basu for providing a draft of his recent work with Sombra and useful advice, Erich Kaltofen for kindly answering our questions concerning polynomial factorization, and Pavel Pat´ak, Edgardo Rold´an Pensado, Mart´ın Sombra, and Martin Tancer for enlightening discussions. References [AE98] P. K. Agarwal and J. Erickson. Geometric range searching and its relatives. In B. Chazelle, J. E. Goodman, and R. Pollack, editors, Discrete and Computational Geometry: Ten Years Later, pages 1–56. American Mathematical Society, Provi- dence, 1998. [AMS13] P. K. Agarwal, J. Matousek, and M. Sharir. On range searching with semialgebraic sets II. SIAM J. Comput., 42(6):2039–2062, 2013. [BB12] [BB13] S. Barone and S. Basu. Refined bounds on the number of connected components of sign conditions on a variety. Discrete Comput. Geom., 47(3):577–597, 2012. S. Barone and S. Basu. On a real analogue of Bezout inequality and the number of connected components of sign conditions. Preprint, arXiv:1303.1577v2, 2013. [BCR98] J. Bochnak, M. Coste, and M.-F. Roy. Real Algebraic Geometry. Springer, Berlin etc., 1998. Transl. from the French, revised and updated edition. 17 [BPR03] S. Basu, R. Pollack, and M.-F. Roy. Algorithms in real algebraic geometry. Algo- rithms and Computation in Mathematics 10. Springer, Berlin, 2003. [BS14] S. Basu and M. Sombra. Polynomial partitioning on varieties of codimension two and point-hypersurface incidences in four dimensions. Preprint, arXiv:1406.2144, 2014. [Cha05] B. Chazelle. Cuttings. In Handbook of data structures and applications (D. P. Mehta and S. Sahni, editors). Chapman & Hall/CRC, Boca Raton, FL, 2005. [Cha12] T. M. Chan. Optimal partition trees. Discrete Comput. Geom., 47(4):661–690, 2012. [Cla87] K. L. Clarkson. New applications of random sampling in computational geometry. Discrete Comput. Geom., 2:195–222, 1987. [CLO07] D. Cox, J. Little, and D. O'Shea. Ideals, varieties, and algorithms. Undergraduate Texts in Mathematics. Springer, New York, third edition, 2007. [DP13] W. Decker and G. Pfister. A first course in computational algebraic geometry. African Institute of Mathematics (AIMS) Library Series. Cambridge University Press, Cambridge, 2013. [Dub90] T. W. Dub´e. The structure of polynomial ideals and Grobner bases. SIAM J. Comput., 19(4):750–775, 1990. [EM99] M. Elkadi and B. Mourrain. A new algorithm for the geometric decomposition of a variety. In Proceedings of the 1999 International Symposium on Symbolic and Algebraic Computation, pages 9–16, New York, NY, USA, 1999. ACM. [FPS+14] J. Fox, J. Pach, A. Sheffer, A. Suk, and J. Zahl. A semi-algebraic version of Zarankiewicz's problem. Preprint, arXiv:1407.5705, 2014. [GK15] L. Guth and N. H. Katz. On the Erdos distinct distances problem in the plane. Annals of Mathematics, 181:155–190, 2015. [Gut15] L. Guth. Distinct distance estimates and low degree polynomial partitioning. Discrete Comput. Geom., 53(2):428–444, 2015. [Har77] R. Hartshorne. Algebraic geometry. Springer, New York, 1977. [Har92] J. Harris. Algebraic Geometry (A First Course). Springer-Verlag, Berlin, 1992. [Hei83] [Her26] [HS06] J. Heintz. Definability and fast quantifier elimination in algebraically closed fields. Theoret. Comput. Sci., 24(3):239–277, 1983. Corrigendum ibid. 39,1983: 2–3. G. Hermann. Die Frage der endlich vielen Schritte in der Theorie der Polynomide- ale. Math. Ann., 95(1):736–788, 1926. C. Huneke and I. Swanson. Integral Closure of Ideals, Rings, and Modules, volume 336 of London Mathematical Society Lecture Note Series. Cambridge University Press, Cambridge, 2006. 18 [HW87] D. Haussler and E. Welzl. Epsilon-nets and simplex range queries. Discrete Com- put. Geom., 2:127–151, 1987. [Kal92] [KM96] E. Kaltofen. Polynomial factorization 1987–1991. In LATIN '92 (Sao Paulo, 1992), volume 583 of Lecture Notes in Comput. Sci., pages 294–313. Springer, Berlin, 1992. K. Kuhnle and E. W. Mayr. Exponential space computation of Grobner bases. In Proceedings of the 1996 international symposium on symbolic and algebraic computation, ISSAC '96, Zurich, Switzerland, July 24–26, 1996, pages 62–71. ACM, New York, NY, USA, 1996. [KMS12] H. Kaplan, J. Matousek, and M. Sharir. Simple proofs of classical theorems in discrete geometry via the Guth-Katz polynomial partitioning technique. Discrete Comput. Geom., 48(3):499–517, 2012. [KMSS12] H. Kaplan, J. Matousek, Z. Safernov´a, and M. Sharir. Unit distances in three dimensions. Combin. Probab. Comput., 21(4):597–610, 2012. [Mat92] J. Matousek. Efficient partition trees. Discrete Comput. Geom., 8:315–334, 1992. [Mat95] J. Matousek. Geometric range searching. ACM Comput. Surveys, 26:421–461, 1995. [MM82] E. W. Mayr and A. R. Meyer. The complexity of the word problems for commu- tative semigroups and polynomial ideals. Adv. in Math., 46(3):305–329, 1982. [MR11] E. W. Mayr and S. Ritscher. Space-efficient Grobner basis computation without degree bounds. In Proceedings of the 36th International Symposium on Symbolic and Algebraic Computation, pages 257–264. ACM, New York, NY, USA, 2011. [SS14] M. Sharir and N. Solomon. Incidences between points and lines in four dimensions. In Proc. 30th ACM Sympos. on Computational Geometry, 2014. [SSZ12] M. Sharir, A. Sheffer, and J. Zahl. Improved bounds for incidences between points and circles. Preprint arXiv:1208.0053, 2012. [ST12] J. Solymosi and T. Tao. An incidence theorem in higher dimensions. Discrete Comput. Geom., 48(2):255–280, 2012. [Whi57] H. Whitney. Elementary structure of real algebraic varieties. Ann. of Math. (2), 66:545–556, 1957. [WYZ13] H. Wang, B. Yang, and R. Zhang. Bounds of incidences between points and algebraic curves. Preprint, arXiv:1308.0861, 2013. [Zah12] J. Zahl. A Szemeredi–Trotter type theorem in R4. Preprint arXiv:1203.4600, 2012. [Zah13] J. Zahl. An improved bound on the number of point-surface incidences in three dimensions. Contrib. Discrete Math., 8(1):100–121, 2013. 19
1808.06411
2
1808
2018-10-11T13:14:42
Scalable Edge Partitioning
[ "cs.DS", "cs.DC", "cs.DM" ]
Edge-centric distributed computations have appeared as a recent technique to improve the shortcomings of think-like-a-vertex algorithms on large scale-free networks. In order to increase parallelism on this model, edge partitioning - partitioning edges into roughly equally sized blocks - has emerged as an alternative to traditional (node-based) graph partitioning. In this work, we give a distributed memory parallel algorithm to compute high-quality edge partitions in a scalable way. Our algorithm scales to networks with billions of edges, and runs efficiently on thousands of PEs. Our technique is based on a fast parallelization of split graph construction and a use of advanced node partitioning algorithms. Our extensive experiments show that our algorithm has high quality on large real-world networks and large hyperbolic random graphs, which have a power law degree distribution and are therefore specifically targeted by edge partitioning
cs.DS
cs
Scalable Edge Partitioning∗ Christian Schulz‡ Daniel Seemaier§ Darren Strash¶ Sebastian Schlag† Abstract Edge-centric distributed computations have appeared as a recent technique to improve the shortcomings of think- like-a-vertex algorithms on large scale-free networks. In order to increase parallelism on this model, edge parti- tioning -- partitioning edges into roughly equally sized blocks -- has emerged as an alternative to traditional (node-based) graph partitioning. In this work, we give a distributed memory parallel algorithm to compute high- quality edge partitions in a scalable way. Our algorithm scales to networks with billions of edges, and runs effi- ciently on thousands of PEs. Our technique is based on a fast parallelization of split graph construction and a use of advanced node partitioning algorithms. Our ex- tensive experiments show that our algorithm has high quality on large real-world networks and large hyper- bolic random graphs -- which have a power law degree distribution and are therefore specifically targeted by edge partitioning. 8 1 0 2 t c O 1 1 ] S D . s c [ 2 v 1 1 4 6 0 . 8 0 8 1 : v i X r a ∗Partially supported by DFG grant SA 933/10-2. The research leading to these results has received funding from the European Research Council under the European Union's Seventh Frame- work Programme (FP/2007-2013) / ERC Grant Agreement no. 340506. †Institute for Theoretical Informatics, Karlsruhe Institute of ‡Faculty of Computer Science, University of Vienna, Vienna, Technology, Karlsruhe, Germany. Technology, Karlsruhe, Germany. §Institute for Theoretical Informatics, Karlsruhe Institute of ¶Department of Computer Science, Hamilton College, Clinton, Austria. NY, USA. 1 Introduction 1 With the recent stagnation of Moore's law, the primary method for gaining computing power is to increase the number of available cores, processors, or networked ma- chines (all of which are generally referred to as pro- cessing elements (PEs)) and exploit parallel computa- tion. One increasingly useful method to take advantage of parallelism is found in graph partitioning [6, 8, 44], which attempts to partition the vertices of a graph into roughly equal disjoint sets (called blocks), while minimizing some objective function -- for example min- imizing the number of edges crossing between blocks. Graph partitioning is highly effective, for instance, for distributing data to PEs in order to minimize commu- nication volume [18], and to minimize the overall run- ning time of jobs with dependencies between computa- tion steps [45]. Similar to (node-based) graph partitioning, the quality of the edge partitioning can have a dramatic ef- fect on parallelization [32]. Noting that edge partition- ing can be solved directly with hypergraph partitioners, such as hMETIS [26, 27] and PaToH [9], Li et al. [32] showed that these techniques give the highest qual- ity partitionings; however, they are also slow. There- fore, a balance of solution quality and speed must be taken into consideration. This balance is struck well for the split-and-connect (SPAC) method introduced by This traditional (node-based) graph partitioning has also been essential for making efficient distributed graph algorithms in the Think Like a Vertex (TLAV) model of computation [35]. In this model, node- centric operations are performed in parallel, by mapping nodes to PEs and executing node computations in parallel. Nearly all algorithms in this model require information to be communicated between neighbors -- which results in network communication if stored on different PEs -- and therefore high-quality graph partitioning directly translates into less communication and faster overall running time. As a result, graph partitioning techniques are included in popular TLAV platforms such as Pregel [34] and GraphLab [33]. However, node-centric computations have serious shortcomings on power law graphs -- which have a skewed degree distribution. In such networks, the over- all running time is negatively affected by very high- degree nodes, which can result in more communication steps. To combat these effects, Gonzalez et al. [17] in- troduced edge-centric computations, which duplicates node-centric computations across edges to reduce com- munication overhead. In this model, edge partitioning -- partitioning edges into roughly equally sized blocks -- must be used to reduce the overall running time. This variant of partitioning is also NP-hard [7]. Li et al. [32]. In the SPAC method, vertices are dupli- cated and weighted so that a (typically fast) standard node-based graph partitioner can be used to compute an edge partitioning; however, this method was only studied in the sequential setting. While this is a great initial step, the graphs that benefit the most from edge partitioning are massive -- and therefore do not fit on a single machine [22]. However, distributed algorithms for the problem fare far worse [7, 17]. While adding much computational power with many processing elements (PEs), edge parti- tioners such as PowerGraph [17] and Ja-Be-Ja-VC [39], produce partitionings of significantly worse quality than those produced with hypergraph partitioners or SPAC. Thus, there is no clear winning algorithm that gives high quality while executing quickly in a distributed setting. 1.1 Our Results. In this paper, we give the first high-quality distributed memory parallel edge parti- tioner. Our algorithm scales to networks with billions of edges, and runs efficiently on thousands of PEs. Our technique is based on a fast parallelization of split graph construction and a use of advanced node partitioning al- gorithms. Our experiments show that while hypergraph partitioners outperform SPAC-based graph partitioners in the sequential setting regarding both solution qual- ity and running time, our new algorithms compute sig- nificantly better solutions than the distributed memory hypergraph partitioner Zoltan [14] in shorter time. For large random hyperbolic graphs, which have a power law degree distribution and are therefore specifically tar- geted by edge partitioning, our algorithms compute so- lutions that are more than a factor of two better. More- over, our techniques scale well to 2 560 PEs, allowing for efficient partitioning of graphs with billions of edges within seconds. E. We extend c and ω to sets, i.e., c(V (cid:48)) :=(cid:80) and ω(E(cid:48)) := (cid:80) 2 Preliminaries 2.1 Basic Concepts. Let G = (V = {0, . . . , n − 1}, E, c, ω) be an undirected graph with edge weights ω : E → R>0, node weights c : V → R≥0, n = V , and m = v∈V (cid:48) c(v) e∈E(cid:48) ω(e). N (v) := {u : {v, u} ∈ E} denotes the neighbors of v and E(v) := {e : v ∈ e} de- notes the edges incident to v. A node v ∈ Vi that has a neighbor w ∈ Vj, i (cid:54)= j, is a boundary node. We are look- ing for blocks of nodes V1,. . . ,Vk that partition V , i.e., V1 ∪···∪ Vk = V and Vi ∩ Vj = ∅ for i (cid:54)= j. The balance constraint demands that ∀i ∈ {1..k} : c(Vi) ≤ Lmax := k (cid:101) for some imbalance parameter ε. The ob- (1 + ε)(cid:100) c(V ) i<j w(Eij) where := {{u, v} ∈ E : u ∈ Vi, v ∈ Vj}. Similar to the Eij node partitioning problem, the edge partitioning prob- jective is to minimize the total cut (cid:80) 2 k (cid:109) cut (cid:80) lem asks for blocks of edges E1, . . . , Ek that partition (cid:108) ω(E) E, i.e. E1∪···∪ Ek = E and Ei∩ Ej = ∅ for i (cid:54)= j. The balance constraint demands that ∀i ∈ {1..k} : ω(Ei) ≤ . The objective is to minimize the vertex (1 + ε) v∈V I(v) − 1 where I(v) := {i : E(v) ∩ Ei (cid:54)= ∅}. Intuitively, the objective expresses the number of re- quired replicas of nodes: if a node v has to be copied to each edge partition that has edges incident to v, the number of required replicas of that node is I(v) − 1. A clustering is also a partition of the nodes. How- ever, k is usually not given in advance and the bal- ance constraint is removed. A size-constrained cluster- ing constrains the size of the blocks of a clustering by a given upper bound U such that c(Vi) ≤ U. Note that by adjusting the upper bound one can somewhat control the number of blocks of a feasible clustering. blocks Π = {V1, . . . , Vk} such that(cid:83)k 2.2 Hypergraphs. An undirected hypergraph H = (V, E, c, ω) is defined as a set of n vertices V and a set of m hyperedges/nets E with vertex weights c : V → R>0 and net weights ω : E → R>0, where each net is a subset of the vertex set V (i.e., e ⊆ V ). The vertices of a net are called pins. As before, c and ω are extended to work on sets. A vertex v is incident to a net e if v ∈ e. The size e of a net e is the number of its pins. A k-way partition of a hypergraph H is a partition of its vertex set into k i=1 Vi = V , Vi (cid:54)= ∅ for 1 ≤ i ≤ k and Vi∩Vj = ∅ for i (cid:54)= j. A k-way partition Π is called ε-balanced if each block Vi ∈ Π satisfies k (cid:101) the balance constraint: c(Vi) ≤ Lmax := (1 + ε)(cid:100) c(V ) for some parameter ε. Given a k-way partition Π, the number of pins of a net e in block Vi is defined as Φ(e, Vi) := {v ∈ Vi v ∈ e}. For each net e, Λ(e) := {Vi Φ(e, Vi) > 0} denotes the connectivity set of e. The connectivity of a net e is the cardinality of its connectivity set: λ(e) := Λ(e). A net is called cut net if λ(e) > 1. The k-way hypergraph partitioning problem is to find an ε-balanced k-way partition Π of a hypergraph H that minimizes an objective function over the cut nets for some ε. The most commonly used cost functions e∈E(cid:48) ω(e) and the e∈E(cid:48)(λ(e)− 1) ω(e), where E(cid:48) is the set of all cut nets [13, 15]. Optimizing both objective functions is known to be NP-hard [30]. are the cut-net metric cut(Π) := (cid:80) connectivity metric (λ− 1)(Π) :=(cid:80) 2.3 The Split-and-Connect (SPAC) Method. If the input graph fits into memory, edge partitioning can be solved by forming a hypergraph with a node for each edge in E, and a hyperedge for each node, consisting of the edges to which it is incident. Thus, hypergraph partitioners optimizing the connectivity metric can be applied to this problem [32]; however, they are more 3 (a) (b) Figure 1: (a) The input graph. (b) The resulting split graph. Each node v is replaced by a set Sv of split nodes that form a cycle (if Sv ≥ 3). Auxiliary edges are drawn thin, dominant edges are drawn thick. powerful than necessary, as this conversion has mostly small hyperedges. The problem can also be solved with node- based graph partitioning by creating a new graph G(cid:48) with the split-and-connect transformation (SPAC) of Li et al. [32]. More precisely, given an undirected, un- weighted graph G = (V, E), they construct the split graph G(cid:48) = (V (cid:48), E(cid:48), c(cid:48), ω(cid:48)) as follows: for each node v ∈ V , create a set of split nodes Sv := {v(cid:48) d(v)} that are connected to a cycle by auxiliary edges with edge- weight one, i.e. edges {v(cid:48) i+1} for i = 1, . . . , d(v) − 1 and {v(cid:48) In the connect phase, split nodes are connected by edges, i.e. for each edge e = {u, v} in G, a corresponding dominant edge {u(cid:48), v(cid:48)} in G(cid:48) is cre- ated. This is done such that overall both u(cid:48) ∈ Su and v(cid:48) ∈ Sv are connected to one and only one dominant edge. Those dominant edges get assigned edge weight infinity. Figure 1 gives an example. 1}. d(v), v(cid:48) 1, . . . , v(cid:48) i, v(cid:48) Note that the original version of the SPAC method connects the split nodes of the same split set to an induced path rather than a cycle. Exchanging them for cycles simplifies implementation and does not change the theoretical approximation bound [32]. To partition the edges of G, a node-based parti- tioning algorithm is run on G(cid:48). Since dominant edges have edge weight infinity, it is infeasible to cut dominant edges for the node-based partitioning algorithm. Thus, both endpoints of a dominant edge are put into the same partition. To obtain an edge partition of the in- put graph, one transfers the block numbers of those end- points to the edge in G that induced the dominant edge. Each distinct node partition occurring in a split node set cuts at least one auxiliary edge, unless the set is fully contained in a single partition. Hence, the number of node replicas is at most the number of edge cuts. Since the vertex cut is always smaller than or equal to the edge cut, a good node partition of the split graph intuitively leads to a good edge partition of the input graph. Note that the node-based partitioning algorithm is a parameter of the algorithm. Overall, their approach is shown to be up to orders of magnitude faster than the uvwxSvSuSwSx hypergraph partitioning approaches using hMETIS [24] and PaToH [10] and considered competitive in terms of the number of replicas [32]. 3 Related Work There has been a huge amount of research on graph and hypergraph partitioning so that we refer the reader to existing literature [6, 8, 37, 44] for most of the material. Here, we focus on issues closely related to our main contributions. Since both graph partitioning algorithms using the method by Li et al. [32] and hypergraph partitioning algorithms are useful to solve the edge partitioning problem, we start this section with reviewing literature for those problems and then finish with edge partitioning algorithms. 3.1 Node Partitioning. All general-purpose meth- ods that are able to obtain high-quality node partitions for large real-world graphs are based on the multilevel In the multilevel graph partitioning (MGP) method. method, the input graph is recursively contracted to achieve smaller graphs which should reflect the same basic structure as the input graph. After applying an initial partitioning algorithm to the smallest graph, the contraction is undone and, at each level, a local search method is used to improve the partitioning induced by the coarser level. Well-known software packages based on this approach include KaHIP [41], Jostle [50], METIS [25] and Scotch [11]. Most probably the fastest available parallel code is the parallel version of METIS, ParMETIS [23]. This parallelization has difficulty maintaining the balance of the partitions since at any particular time, it is difficult to say how many nodes are assigned to a particular block. PT-Scotch [11], the parallel version of Scotch, is based on recursive bipartitioning. Within this work, we use sequential and distributed memory parallel algorithms of the open source multi- level graph partitioning framework KaHIP [41] (Karl- sruhe High Quality Partitioning). This framework tack- les the node partitioning problem using the edge cut as objective. ParHIP [36] is a distributed memory parallel node partitioning algorithm. The algorithm is based on parallelizing and adapting the label propagation tech- nique originally developed for graph clustering [38]. By introducing size constraints, label propagation becomes applicable for both the coarsening and the refinement phase of multilevel graph partitioning. The resulting system is more scalable and achieves higher quality than state-of-the-art systems like ParMETIS and PT-Scotch. 3.2 Hypergraph Partitioning. HGP has evolved into a broad research area since the 1990s. Well-known 4 multilevel HGP software packages with certain distin- guishing characteristics include PaToH [9] (originating from scientific computing), hMETIS [26, 27] (originat- ing from VLSI design), KaHyPar [1, 19, 42] (general purpose, n-level), Mondriaan [48] (sparse matrix parti- tioning), MLPart [3] (circuit partitioning), Zoltan [14], and SHP [22] (distributed), UMPa [47] (directed hyper- graph model, multi-objective), and kPaToH (multiple constraints, fixed vertices) [4]. 3.3 Edge Partitioning. While hypergraph parti- tioning and the SPAC method are effective for com- puting an edge partitioning of small graphs, different techniques are used for graphs that do not fit in the memory of a single computer. Gonzalez et al. [17] study the streaming case, where edges are assigned to par- titions in a single pass over the graph. They investi- gate randomly assigning edges to partitions, as well as a greedy strategy. Using their greedy method, the aver- age number of replicas is around 5 for power-law graphs. Bourse et al. [7] later improved the replication factor by performing a similar process, but weighting each vertex by its degree. With Ja-Be-Ja-VC, Rahimian et al. [39] present a distributed parallel algorithm for edge-based partitioning of large graphs which is essentially a local search algorithm that iteratively improves upon an ini- tial random assignment of edges to partitions. 4 Engineering a Parallel Edge Partitioner We now present our algorithm to quickly compute high quality edge partitions in the distributed memory setting. Roughly speaking, we engineer a distributed version of the SPAC algorithm (dSPAC) and then use a distributed memory parallel node-based graph partitioning to partition the model. We start this section by giving a description of the data structures that we use and then explain the parallelization of the SPAC algorithm. 4.1 Graph Data Structure. We start with details of the parallel graph data structure and the implemen- tation of the methods that handle communication. First of all, each PE gets a subgraph, i.e. a contiguous range of nodes a..b, of the whole graph as its input, such that the subgraphs combined correspond to the input graph. Each subgraph consists of the nodes with IDs from the interval I := a..b and the edges incident to at least one node in this interval, and includes vertices not in I that are adjacent to vertices in I. These vertices are referred to as ghost nodes (also referred to elsewhere in the liter- ature as halo nodes). Note that each PE may have edges it shares with another PE and the number of edges as- signed to the PEs may therefore vary significantly. The subgraphs are stored using a standard adjacency array representation -- we have one array to store edges and one array for nodes, which stores head pointers into the edge array. However, for the parallel setting, the node array is divided into two parts: the first part stores lo- cal nodes and the second part stores ghost nodes. The method used to keep local node IDs and ghost node IDs consistent is explained next. Instead of using the node IDs provided by the input graph (i.e., the global IDs), each PE p maps those IDs to the range 0 .. np − 1, where np is the number of distinct nodes of the subgraph on that PE. Note that this number includes the number of ghost nodes stored on PE p. The number of local nodes is denoted by (cid:96)p. Each global ID i ∈ a .. b is mapped to a local node ID i − a. The IDs of the ghost nodes are mapped to the remaining np−(b−a+1) local IDs in the order in which they appeared during the construction of the graph data structure. Transforming a local node ID to a global ID or vice versa, can be done by adding or subtracting a. We store the global ID of the ghost nodes in an extra array and use a (local) hash table to transform global IDs of ghost nodes to their corresponding local IDs. Additionally, we store for each ghost node the ID of its corresponding PE, using an array PE for O(1) lookups. We call a node an interface node if it is adjacent to at least one ghost node. The PE associated with the ghost node is called an adjacent PE. Similar to node IDs, directed edges are mapped to the range 0 .. mp−1 of local edge IDs, where mp denotes the number of local directed edges of the subgraph on PE p. Edges that start from node v ∈ V (G) have consecutive edge IDs ev .. ev+d(v)−1. A roughly equal distribution of nodes to PEs is suboptimal for the SPAC algorithm since the size of the split graph mostly depends on the number of edges. Hence, we improve load imbalance by distributing the graph such that the number of edges is roughly the same on each PE. 4.2 Distributed Split Graph Construction. We use G to denote the input graph with np nodes and mp edges on PE p and construct the split graph G(cid:48) with p nodes and m(cid:48) n(cid:48) p edges on the same PE. A pseudocode description of our distributed SPAC algorithm (dSPAC) is given in Algorithm 1. First, recall that the split graph contains a set Sv of d(v) split nodes for each node v ∈ V (G). For a node v, we create the nodes of the split graph on the PE that owns v. Thus, the number of local split graph nodes on PE p is equal to the number of local edges of the input graph on PE p, i.e. n(cid:48) p = mp. Since the edges incident to the same node have consecutive IDs, we can use edge IDs from G as local node IDs in the split graph Algorithm 1: Our dSPAC algorithm on PE p Input: Graph G with np nodes, mp edges on PE p Input: Empty split graph G(cid:48) n(cid:48) p := mp mglobal for i := 0; i < n(cid:48) // one split node per local edge p(cid:48)=0 mp // create split nodes ... // ... with global IDs := prefixSum(mp) p; ++i do G(cid:48).insertNode(mglobal // i.e.,(cid:80)p−1 + i) p p values for all interface nodes // i.e., u ∈ 0 .. lp − 1 // i.e., e ∈ eu .. eu+d(u)−1 // compute E(cid:48) foreach u ∈ V (G) do p p(cid:48) := −1 foreach e ∈ E(u) do v := edgeTarget(e) if PE[v] (cid:54)= p(cid:48) then p(cid:48) := PE[v] Ep(cid:48)(a + u) := mglobal p + e // exchange E(cid:48) foreach PE p(cid:48) (cid:54)= p do p values with adjacent PEs send Ep(cid:48) values to PE p(cid:48) receive Ep values from PE p(cid:48) // insert auxiliary and dominant edges foreach u ∈ V (G) do // i.e., u ∈ 0 .. lp − 1 // i.e., e ∈ eu .. eu+d(u)−1 foreach e ∈ E(u) do v := edgeTarget(e) v(cid:48) := globalID(v) u(cid:48) := e + mglobal // insert dominant edge with edge-weight ∞ G(cid:48).insertEdge(u(cid:48),Ep(v(cid:48)),∞) Ep(v(cid:48)) := Ep(v(cid:48)) + 1 if d(u) > 1 then // global ID of split node u(cid:48) // insert auxiliary edges p // compute target nodes for aux. edge uprev := e − eu − 1 mod d(u) unext := e − eu + 1 mod d(u) // local → global ID for target node v(cid:48) := eu + mglobal + unext G(cid:48).insertEdge(u(cid:48), v(cid:48), 1) if uprev (cid:54)= unext then // local → global ID for target node v(cid:48) := eu + mglobal + uprev G(cid:48).insertEdge(u(cid:48), v(cid:48), 1) p p Output: distributed split graph G(cid:48) G(cid:48). To transform those local node IDs to global ones, we need the overall number of edges on PEs that have a smaller PE ID than p. This can be easily computed in parallel by computing a prefix sum over the number of local edges mp of each PE p. This takes O(log p) time and linear work [28]. Afterwards, the SPAC transformation requires us to connect split nodes by auxiliary edges and domi- 5 Figure 2: A node v ∈ V (G) on PE A with neighbors on PEs A, B and C. Neighbors are traversed in the order of the edges. PEs are ordered A < B < C. nant edges. Auxiliary edges with edge-weight one are inserted between split nodes v ∈ Sv to connect them to an induced cycle. Since Sv is fully contained on a single PE, we can create the auxiliary edges indepen- dently on each PE. Recall that dominant edges are induced by undi- rected edges {u, v} in G. These edges connect split nodes, i.e. nodes from the sets Su and Sv, such that each split node is incident to precisely one (undirected) dominant edge. To construct dominant edges, global coordination is required: say that u has neighbors on two different PEs. Both neighbors do not know about each other, since u is only available as ghost node on those PEs, i.e. without information about its adja- cency. Yet, both neighbors must choose a unique split node from the set Su. Our algorithm solves this problem as follows. First, the adjacency lists of each node are ordered by their global node ID. We assume that this is already the case for the input network, otherwise one can simply run a sorting algorithm on the neighborhood of each vertex. Since nodes are assigned consecutively among the processors, this implies that the adjacency list of each interface node in the input graph is ordered by the target processor, i.e. the processor that owns the target of the edge. Figure 2 gives an example. For an interface node u ∈ V (G) on PE p, let Ep(cid:48)(u) be the global ID of the first edge {u, v} with v ∈ V (G) on PE p(cid:48). In the split graph G(cid:48) this ID corresponds to the global ID of the first split node in Su that will be adjacent to a split node of Sv on PE p(cid:48). Due to the order of the vertices, these values can be easily computed for all adjacent PEs by scanning the neighborhood of that vertex. We send the corresponding value to PE p(cid:48). Using this information, we will be able to construct dominant edges in the desired way. To avoid startup overheads, we first compute all Ep(cid:48)(vI ) values for all adjacent interface nodes vI and then send a single message from p to p(cid:48) that contains all values. Hence, the total message size for PE p is O(np I is the number of interface nodes on PE p and P p A is the number of PEs adjacent to PE p. A) where np I P p We now create dominant edges by using the just computed values as follows. First of all, each processor traverses its nodes in the order of their IDs. Let u ∈ V (G) be a node on PE p with its ordered neighbors being v1, . . . , vd(v). For each edge {u, vi}, we create a dominant edge from u's i-th split node to Ep(vi), i.e. we create the dominant edge {u(cid:48) i,Ep(vi)}. Note that the value E was initially sent from the PE that contains vi. Afterwards, we increment Ep(vi) by one, so that the next neighbor of vi that is on PE p connects a dominant edge to vi's next split node. Lemma 4.1. Our parallel SPAC algorithm creates a valid split graph. i Proof. First note that, by the process above, we create precisely one dominant edge for each split node. Hence, it is sufficient to show that the resulting split graph is undirected. Consider a pair of adjacent nodes u, v ∈ V (G) where u is owned by PE p and v is owned by PE p(cid:48). We show that both vertices pick the correct split node -- hence, forming an undirected (dominant) edge. is u's i-th split node and v(cid:48) Roughly speaking, by the order in which the nodes and their incident edges are traversed it is ensured that the values E used for the creation of the edges point to the correct split node. More precisely, let u ∈ V (G) be a node of the input graph and its ordered neighbors be v1, . . . , vd(u). We consider {u, vi} and argue that its induced dominant edge is indeed undirected. For this purpose, let u be owned by PE p and vi be owned by PE p(cid:48). On PE p, we create a directed edge (u(cid:48) i, v(cid:48)), where u(cid:48) is some split node of v defined by the process above. We argue that PE p(cid:48), creates an edge (v(cid:48), u(cid:48) i) which makes the graph It is sufficient to argue that both edges undirected. include u(cid:48) i, since we can use the same argument with u and vi reversed to imply that the other endpoint is correct too. Node u chooses u(cid:48) i for the dominant edge from Su to Svi, because it traverses its neighbors in order and vi is its i-th neighbor. In the other direction, vi chooses the split node of u based on Ep(cid:48)(u). We claim that it chooses u(cid:48) i. Let vj be the first neighbor of u on PE p(cid:48). Since the neighborhood is ordered as described above, vj, . . . , vi are all on PE p(cid:48) and moreover, they are traversed in the same order on PE p(cid:48) (thus construct their dominant edges in the same order). Thus, vi connects the dominant edge to Ep(cid:48)(u) + (i − j), since that is the total increment of Ep(cid:48)(u) at the time when vi constructs its dominant edges. But by the definition of Ep(cid:48)(u), we have that Ep(cid:48)(u) is the global split node ID of j. Thus, vi connects to u's j + (i− j) = i-th split node. u(cid:48) Assuming that the adjacency list of the nodes are al- ready sorted by global ID, our algorithm performs a lin- 6 BACe2e3e4ve1 (cid:31) A A B EA(2) = 5 EA(3) = 7 C EA(4) = 9 C EC (0) = 3 EC (3) = 8 B EB (0) = 1 EB (1) = 5 EB (4) = 10 (b) (a) (c) Figure 3: (a) The input graph, distributed across three PEs (indicated by the dashed delimiters). IDs of directed edges are drawn next to their sources. (b) The Ep(·) messages each PE sends to other PEs: the messages in the i-th row and j-th column are sent from PE i to PE j. (c) The constructed split graph. Auxiliary edges are drawn thin, dominant edges are drawn thick. ear amount of work. Thus split graph construction takes O(m/p + log p) time, if edges are distributed evenly. parallel node-partitioning After computing the split graph, we use the distributed algorithms ParHIP [36] and ParMETIS [23] to partition it. To obtain an edge partition of the input graph, we transfer the block numbers of those endpoints to the edge in G that induced the dominant edge. 5 Experimental Evaluation In this section we evaluate the performance of the pro- posed algorithm. We start by presenting our methodol- ogy and setup, the system used for the evaluation and the benchmark set that we used. We then look at solu- tion quality, running time, and scalability of (d)SPAC- based GP as well as HGP, and compare our algorithm to those systems. 5.1 Methodology and Setup. We implemented the distributed split graph construction algorithm described in Section 4 in the ParHIP graph partitioning frame- work [36]. In the following, we use SPAC when referring to sequential split graph construction and use dSPAC to denote our algorithm in the distributed setting. The code is written in C++, compiled with g++ 7.3.0, and uses OpenMPI 1.10 as well as KaHIP v2.0. In order to establish the state-of-the-art regarding edge partitioning, we perform a large number of ex- periments using several partitioning tools including se- quential and distributed graph and hypergraph parti- tioners. More precisely, our experimental comparisons use the KaHIP [40] and METIS [25] sequential graph partitioners as well as their respective distributed ver- sions ParHIP [36] and ParMETIS [23]. Furthermore we use the k-way (hMETIS-K) and the recursive bisec- tion variant (hMETIS-R) of hMETIS 2.0 (p1) [26, 27], PaToH [9], and KaHyPar-MF [20]. These hypergraph partitioners were chosen because they provide the best solution quality for sequential hypergraph partition- ing [20]. To evaluate distributed hypergraph partition- ing approaches, we include Zoltan [14]. We also tried to use Parkway [46], but were not able work with the current version provided online1, because the code has deadlocks and hangs on many instances. Since there is no implementation of the Ja-Be-Ja-VC algorithm [39] publicly available, we include our own implementation. Judging from the results presented in [39], both imple- mentations provide comparable solution quality. How- ever, since Ja-Be-Ja-VC performed significantly worse than all other partitioning approaches in our experi- ments, we only consider it in a sequential setting. Fur- thermore we do not report running times, because all other systems are highly engineered, while our Ja-Be- Ja-VC implementation is a prototype. For partitioning, we use ε = 0.03 as imbalance factor for all tools except h-METIS-R, which treats the imbalance parameter dif- ferently. We therefore use an adjusted imbalance value as described in [43]. For each algorithm, we perform five repetitions with different seeds and use the arithmetic mean to average solution quality and running time of the different runs. When averaging over different instances, we use the ge- ometric mean in order to give every instance a compa- rable influence on the final result. We furthermore use performance plots [42] to com- pare the best solutions of competing algorithms on a per-instance basis. For each algorithm, these plots re- late the smallest vertex cut of all algorithms to the cor- responding vertex cut produced by the algorithm on a per-instance basis. A point close to one indicates that the partition produced by the corresponding algorithm was considerably worse than the partition produced by the best algorithm. A value of zero therefore indicates that the corresponding algorithm produced the best so- lution. Thus an algorithm is considered to outperform another algorithm if its corresponding ratio values are below those of the other algorithm. 1https://github.com/parkway-partitioner/parkway 7 ABC012340123456789101130124576891011CAB 5.2 System and Instances. We use the ForHLR II cluster (Forschungshochleistungsrechner) for our experi- mental evaluation. The cluster has 1152 compute nodes, each of which is equipped with 64 GB main memory and two Intel Xeon E5-2660 Deca-Core v3 processors (Haswell) clocked at 2.6 GHz. A single Deca-Core pro- cessor has 25 MB L3-Cache, and every core has 256 KB L2-Cache and 64 KB L1-Cache. All cluster nodes are connected by an InfiniBand 4X EDR interconnect. We evaluate the algorithms on the graphs listed in Table 1. Random geometric rggX graphs have 2X nodes and were generated using code from [21]. Random hyperbolic rhgX graphs are generated using [16] with power law exponent 2.2 and average degree 8. SPMV graphs are bipartite locality graphs for sparse matrix vector multiplication (SPMV), which were also used to evaluate the sequential SPAC algorithm in [32]. Given a n×n matrix M (in our case the adjacency matrix of the corresponding graph), an SPMV graph corresponding to an SPMV computation M x = y consists of 2n vertices representing the xi and yi vector entries and contains an edge (xi, yj) if xi contributes to the computation of yj, i.e. if Mij (cid:54)= 0. To evaluate the hypergraph approaches, we trans- form the graphs into hypergraphs. As described in Sec- tion 2.3, a hypergraph instance contains one hypernode for each undirected edge in the graph and a hyperedge for each graph node that contains the hypernodes cor- responding to its incident edges. 5.3 Solution Quality of SPAC+X and HGP. We start by exploring the solution quality provided by the different sequential algorithmic approaches to the edge partitioning problem, i.e., we consider the vertex cut that is obtained by applying the partition of the SPAC or hypergraph model to the input graph. We restrict the benchmark set to the Walshaw graphs, SPMV graphs with up to 1M nodes2 and rhg10 -- rhg18, since the running times for hypergraph partitioners were too high for larger instances. We run all partitioners on one PE, i.e., one core of a single node. Each instance is partitioned into k blocks for k ∈ {2, 4, 8, 16, 32, 64, 128}. In the experiments of Li et al. [32], the SPAC approach combined with METIS as graph partitioner was significantly faster than the hypergraph partitioners hMetis and PaToH, while achieving comparable solution quality. Since this comparison was restricted to five graphs, we first compare a larger number of high quality graph and hypergraph partitioners on a larger benchmark set. 2scircuit_spmv, cant_spmv and mc2depi_spmv Graph n m Type Ref. add20 data 3elt uk add32 bcsstk33 whitaker3 crack wing_nodal fe_4elt2 vibrobox bcsstk29 4elt fe_sphere cti memplus cs4 bcsstk30 bcsstk31 fe_pwt bcsstk32 fe_body t60k wing brack2 finan512 fe_tooth fe_rotor 598a fe_ocean 144 wave m14b auto rhgX cant_spmv scircuit_spmv mc2depi_spmv in-2004_spmv circuit5M_spmv amazon eu-2005 youtube in-2004 packing channel road_central hugebubble-10 uk-2002 nlpkkt240 europe_osm rhgX Walshaw Graph Archive ≈ 2.3K ≈ 2.8K ≈ 4.7K ≈ 4.8K ≈ 4.9K ≈ 8.7K ≈ 9.8K ≈ 10K ≈ 10K ≈ 11K ≈ 12K ≈ 13K ≈ 15K ≈ 16K ≈ 16K ≈ 17K ≈ 22K ≈ 28K ≈ 35K ≈ 36K ≈ 44K ≈ 45K ≈ 60K ≈ 62K ≈ 62K ≈ 74K ≈ 78K ≈ 99K ≈ 110K ≈ 143K ≈ 144K ≈ 156K ≈ 214K ≈ 448K 210 -- 218 ≈ 3.6K -- 976K ≈ 7.4K M [49] ≈ 15K M [49] ≈ 13.7K M [49] ≈ 6.8K M [49] ≈ 9.4K M [49] ≈ 291K M [49] ≈ 289K M [49] ≈ 30K M [49] ≈ 75K M [49] ≈ 32K M [49] ≈ 165K M [49] ≈ 302K M [49] ≈ 45K M [49] ≈ 49K M [49] ≈ 48K M [49] ≈ 54K M [49] ≈ 43K M [49] ≈ 1M M [49] ≈ 572K M [49] ≈ 144K M [49] ≈ 985K M [49] ≈ 163K M [49] ≈ 89K M [49] ≈ 121K M [49] ≈ 366K M [49] ≈ 261K M [49] ≈ 452K M [49] ≈ 662K M [49] ≈ 741K M [49] ≈ 409K M [49] ≈ 1M M [49] ≈ 1M M [49] ≈ 1.6M M [49] ≈ 3.3M M [49] [16] S SPMV Graphs ≈ 125K ≈ 350K ≈ 1M ≈ 2.5M ≈ 11M ≈ 2M SP ≈ 100K SP ≈ 2.1M SP ≈ 17M SP ≈ 60M SP [51] [12] [51] [29] [12] Large Graphs ≈ 407K ≈ 862K ≈ 1.1M ≈ 1.4M ≈ 2.1M ≈ 4.8M ≈ 14M ≈ 18.3M ≈ 18.5M ≈ 27.9M ≈ 51M 220 -- 226 ≈ 2.3M [31] S ≈ 16.1M [5] S ≈ 2.9M [31] S ≈ 27M [5] S ≈ 17.4M M [5] ≈ 42.6M M [5] ≈ 34M R [5] ≈ 27.5M M [5] ≈ 262M [29] S ≈ 373M M [12] ≈ 108M R [5] [16] S ≈ 4M -- 280M rggX 225 -- 228 ≈ 550M -- 5G M [21] Huge Graphs Table 1: Our benchmark set. Type 'S' stands for social or web graphs, 'M' is used for mesh type networks, 'R' is used for road networks, SP(MV) is used for graphs for sparse matrix-vector multiplication. 8 pergraph partitioners in terms of solution quality. Com- pared to hMETIS and PaToH, its solutions are 18% and 19% better on average. In a sequential edge par- titioning setting with a reasonable number k of blocks, we therefore conclude that hypergraph partitioning per- forms better than SPAC+X regarding both solution quality (using KaHyPar-MF) and running time (using PaToH). Finally we note that the distributed edge par- titioner Ja-Be-Ja-VC can not compete with high quality graph or hypergraph partitioning systems. Since its so- lutions are more than an order of magnitude worse, we do not consider it in the following comparisons. 5.4 Solution Quality of dSPAC+X and dHGP. We now investigate state-of-the-art methods for com- puting edge partitions in the distributed memory set- ting. Here, we use the large graphs from Table 1 in- cluding rhg20 -- rhg26, as well as the large two SPMV graphs in-2004_spmv and circuit5M_smpv. Since Ja- Be-Ja-VC [39] already produced low quality solutions on small graphs, we restrict the following comparison to distributed memory hypergraph partitioning with Zoltan and distributed graph partitioning using our dis- tributed split graph construction (dSPAC) in combina- tion with both ParMETIS and ParHIP. All instances are again partitioned into k ∈ {2, 4, 8, 16, 32, 64, 128} blocks. This time, we run all algorithms on 32 cluster nodes (i.e., with 640 PEs in total). As can be seen in Table 3 and Figure 5, dSPAC- based graph partitioning outperforms the hypergraph partitioning approach using Zoltan in both solution quality and running time. While dSPAC+ParMETIS is the fastest configuration, dSPAC+ParHIP-Eco provides the best solution quality. On irregular social networks and web graphs (type S), the solutions of ParHIP- Fast and ParMETIS are on average 15% and 18% worse, respectively, while the vertex cuts produced by Zoltan are worse by more than a factor of two. Furthermore dSPAC+X also performs better than HGP with Zoltan for meshes, road networks and SPMV graphs. Since dSPAC+X outperforms HGP with Zoltan in a distributed setting regarding both solution quality and running time, we thus conclude that is is currently the best approach for computing edge partitions of large graphs, in particular if the graphs do not fit into the memory of a single machine. and Solution Quality of 5.5 Scalability dSPAC+X. Finally, we look at the scaling be- havior of distributed SPAC graph construction and partitioning using ParMetis and ParHIP-Fast. To simplify the evaluation, we restrict the experiments in this section to partitioning the eight largest graphs 9 Figure 4: Performance plot comparing SPAC+X, sev- eral HGP systems, and Ja-Be-Ja-VC on small graphs. Type Algorithm KaHyPar-MF hMETIS-R hMETIS-K PaToH Zoltan KaHIP-Strong METIS Ja-Be-Ja-VC S (rhgX) VC Time 433 510.61 s 625 17.19 s 14.81 s 524 0.46 s 508 943 0.66 s 84.33 s 517 0.63 s 595 6 336 -- M & SP Time VC 20.75 s 1 350 66.64 s 1 684 43.44 s 1 587 0.51 s 1 679 1.31 s 1 962 1 638 191.36 s 1.92 s 1 829 18 441 -- Table 2: Mean vertex cuts and running times for rhg10 -- rhg18 (left) and Walshaw graphs and SPMV graphs with up to 1M nodes (right). As can be seen in Figure 4 and Table 2, partition- ing the hypergraph model with KaHyPar-MF overall re- sults in the lowest vertex cuts. Moreover we see that all hypergraph partitioners except Zoltan on average per- form better than SPAC+METIS, with PaToH even be- ing faster. This is true not only for meshes and SPMV graphs, but also for rhgX graphs with power law de- gree distribution. This effect could be explained by the choice of k -- the number of blocks used for partitioning. While we use standard values for (node-based) graph partitioning benchmarks [49], Li et al. [32] choose k such that each block contains approximately 10 240 edges. Thus some instances are partitioned into up to 1 692 and 5 952 blocks, which might be too large for current partitioning tools. the Looking at solution quality of different SPAC+X approaches, we see that KaHIP performs bet- ter than METIS when using its strong configuration and even outperforms all hypergraph partitioners ex- cept KaHyPar-MF. However on Walshaw and SPMV graphs, it is also the slowest partitioning approach. As can be seen in the additional performance plots in Appendix B, KaHyPar-MF dominates all other hy- 0.000.010.050.100.200.400.600.801.001102550100250Instances1-(Best/Algorithm)AlgorithmJaBeJa-VCKaHIP-StrongKaHyPar-MFMETISPaToHhMETIS-KhMETIS-R Type Algorithm ParHIP-Fast ParHIP-Eco ParMETIS Zoltan S Time VC 22 321 17.92 s 18 952 65.91 s 23 221 3.01 s 50 780 51.82 s M & R & SP Time VC 8 380 9.54 s 7 255 37.30 s 9 432 1.66 s 13 516 51.80 s Table 3: Mean vertex cuts and running times for large social graphs (left), as well as meshes, road networks, and SPMV graphs (right). Figure 5: Solution quality for distributed approaches on large social graphs, meshes, road networks, and SPMV Instances3 where Zoltan required too much graphs. memory were set to 1. (including rgg25 - rgg28) into k = 2 blocks on an increasing number of PEs. We start with a single PE on a single node and then go up to all 20 PEs of a single node. From there on we double the number of nodes in each step, until we arrive at 128 nodes with a total of 2 560 PEs. The results are shown in Figure 6. Results for the remaining large graphs can be found in Figure 8 in Appendix C. The running times of dSPAC+X are dominated by the running times of the distributed graph partitioners. While dSPAC+ParMetis is faster than dSPAC+ParHIP-Fast, the latter scales slightly better than the former. Regarding solution quality, Table 5 in Appendix C shows that for large numbers of PEs, ParHIP-Fast computes better solutions than ParMETIS. By combining our distributed split graph construction algorithm with high quality distributed graph partitioning algorithm, we are now able to compute edge partitions of huge graphs that were previously not solvable on one a single PE, or even a small number of PEs. 3nlpkkt240 with k ∈ {2, 4, 8, 16, 32, 64, 128}. 10 (a) Running time for distributed split graph construction. (b) Running time for dSPAC+ParHIP-Fast. (c) Running time for dSPAC+ParMETIS. Figure 6: Comparing the running times of distributed split graph construction (a), dSPAC+ParHIP-Fast (b), and dSPAC+ParMETIS (c) for the eight largest graphs of our benchmark set on an increasing number of PEs. 6 Conclusion and Future Work We presented an efficient distributed memory parallel edge partitioning algorithm that computes solutions of very high quality. By efficiently parallelizing the split graph construction, our dSPAC+X algorithm scales to graphs with billions of edges and runs efficiently on up to 2560 PEs. Our extensive experiments furthermore show that in a sequential setting hypergraph partitioners still outperform node-based graph partitioning based on the SPAC approach regarding both solution quality and running time. Hence, we believe that fast high-quality hypergraph partitioners yet have to be developed in order to narrow the gap between dSPAC+X and dHGP. In the future, we would like to run a working 0.000.010.050.100.200.400.600.801.001102550100Instances1-(Best/Algorithm)AlgorithmParHIP-EcoParHIP-FastParMETISZoltan0.31.03.010.08016032064012802560NumberofPEsTime(s)Graphnlpkkt240rgg25rgg26rgg27rgg28rhg25rhg26uk-200230501008016032064012802560NumberofPEsTime(s)Graphnlpkkt240rgg25rgg26rgg27rgg28rhg25rhg26uk-2002310308016032064012802560NumberofPEsTime(s)Graphnlpkkt240rgg25rgg26rgg27rgg28rhg25rhg26uk-2002 implementation of Parkway in order to get a complete overview regarding the state-of-the-art in distributed HGP. Furthermore it would be interesting to combine ParHIP with the the shared memory parallel MT- KaHIP [2] partitioner in order to get a partitioner that uses shared memory parallelism within a cluster node, while cluster nodes themselves still work in a distributed memory fashion. Lastly, we plan to release our algorithm. Acknowledgments. This work was performed on the computational resource ForHLR II funded by the Ministry of Science, Research and the Arts Baden- Württemberg and DFG ("Deutsche Forschungsgemein- schaft"). References [1] Y. Akhremtsev, T. Heuer, P. Sanders, and S. Schlag. Engineering a direct k-way hypergraph partitioning algorithm. In 19th Workshop on Algo- rithm Engineering and Experiments, (ALENEX), pages 28 -- 42, 2017. [2] Y. Akhremtsev, P. Sanders, and C. Schulz. High-Quality Shared-Memory Graph Partitioning. ArXiv e-prints, Oct. 2017. [3] C. J. Alpert, J.-H. Huang, and A. B. Kahng. Multilevel Circuit Partitioning. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, 17(8):655 -- 667, 1998. [4] C. Aykanat, B. B. Cambazoglu, and B. Uçar. Multi-level Direct K-way Hypergraph Partition- ing with Multiple Constraints and Fixed Vertices. Journal of Parallel and Distributed Computing, 68 (5):609 -- 625, 2008. ISSN 0743-7315. [5] D. Bader, A. Kappes, H. Meyerhenke, P. Sanders, C. Schulz, and D. Wagner. Benchmarking for In Ency- Graph Clustering and Partitioning. clopedia of Social Network Analysis and Mining. Springer, 2014. [6] C. Bichot and P. Siarry, editors. Graph Partition- ing. Wiley, 2011. [7] F. Bourse, M. Lelarge, and M. Vojnovic. Bal- anced Graph Edge Partition. In Proc. 20th ACM SIGKDD International Conf. on Knowledge Dis- covery and Data Mining, KDD '14, pages 1456 -- 1465. ACM, 2014. In Algorithm Engineering - Selected Results and Surveys, pages 117 -- 158. Springer, 2016. [9] Ü. V. Catalyürek and C. Aykanat. Hypergraph- Partitioning-Based Decomposition for Parallel Sparse-Matrix Vector Multiplication. IEEE Trans- actions on Parallel and Distributed Systems, 10(7): 673 -- 693, Jul 1999. ISSN 1045-9219. [10] Ü. V. Catalyürek and C. Aykanat. PaToH: Parti- tioning Tool for Hypergraphs. http://bmi.osu. edu/umit/PaToH/manual.pdf, 1999. [11] C. Chevalier and F. Pellegrini. PT-Scotch. Parallel Computing, 34(6-8):318 -- 331, 2008. [12] T. Davis. The University of Florida Sparse Matrix Collection, http://www.cise.ufl.edu/ research/sparse/matrices, 2008. [13] M. Deveci, K. Kaya, B. Uçar, and Ü. V. Çatalyürek. Hypergraph partitioning for multiple communication cost metrics: Model and methods. Journal of Parallel and Distributed Computing, 77: 69 -- 83, 2015. [14] K. D. Devine, E. G. Boman, R. T. Heaphy, R. H. Bisseling, and Ü. V. Catalyürek. Parallel Hyper- graph Partitioning for Scientific Computing. In 20th International Conference on Parallel and Dis- tributed Processing (IPDPS), pages 124 -- 124. IEEE, 2006. [15] W. Donath. Logic partitioning. Physical Design Automation of VLSI Systems, pages 65 -- 86, 1988. [16] D. Funke, S. Lamm, P. Sanders, C. Schulz, D. Strash, and M. von Looz. Communication-free In IEEE massively distributed graph generation. International Parallel and Distributed Processing Symposium, IPDPS, 2018. [17] J. E. Gonzalez, Y. Low, H. Gu, D. Bickson, and C. Guestrin. PowerGraph: Distributed Graph- Parallel Computation on Natural Graphs. In Pre- sented as part of the 10th USENIX Symposium on Operating Systems Design and Implementation (OSDI 12), pages 17 -- 30. USENIX, 2012. ISBN 978- 1-931971-96-6. [18] B. Hendrickson and T. G. Kolda. Graph Parti- tioning Models for Parallel Computing. Parallel Computing, 26(12):1519 -- 1534, 2000. [8] A. Buluç, H. Meyerhenke, I. Safro, P. Sanders, and C. Schulz. Recent Advances in Graph Partitioning. [19] T. Heuer and S. Schlag. Improving Coarsening Schemes for Hypergraph Partitioning by Exploiting 11 Community Structure. In 16th International Sym- posium on Experimental Algorithms, (SEA), pages 21:1 -- 21:19, 2017. [31] J. Lescovec. Stanford Network Analysis Pack- age (SNAP). http://snap.stanford.edu/index. html. [20] T. Heuer, P. Sanders, and S. Schlag. Network Flow-Based Refinement for Multilevel Hypergraph Partitioning. In 17th International Symposium on Experimental Algorithms (SEA), volume 103, pages 1:1 -- 1:19, 2018. [32] L. Li, R. Geda, A. B. Hayes, Y. Chen, P. Chaud- hari, E. Z. Zhang, and M. Szegedy. A simple yet effective balanced edge partition model for parallel computing. SIGMETRICS Perform. Eval. Rev., 45 (1):6 -- 6, June 2017. [21] M. Holtgrewe, P. Sanders, and C. Schulz. Engi- neering a Scalable High Quality Graph Partitioner. Proceedings of the 24th IEEE International Paral- lal and Distributed Processing Symposium, pages 1 -- 12, 2010. [22] I. Kabiljo, B. Karrer, M. Pundir, S. Pupyrev, A. Shalita, A. Presta, and Y. Akhremtsev. So- cial Hash Partitioner: A scalable distributed hy- pergraph partitioner. Proceedings VLDB Endow., 10(11):1418 -- 1429, August 2017. [23] G. Karypis and V. Kumar. Parallel Multilevel k-way Partitioning Scheme for Irregular Graphs. In Proceedings of the ACM/IEEE Conference on Supercomputing'96, 1996. [24] G. Karypis and V. Kumar. hmetis: A hypergraph partitioning package, version 1.5. 3. user manual, 23, 1998. [33] Y. Low, J. Gonzalez, A. Kyrola, D. Bickson, C. Guestrin, and J. M. Hellerstein. GraphLab: A new parallel framework for machine learning. In P. Grünwald and P. Spirtes, editors, Proc. 26th Conf. on Uncertainty in Artificial Intelligence (UAI), pages 340 -- 349. AUAI Press, 2010. [34] G. Malewicz, M. H. Austern, A. J. Bik, J. C. Dehn- ert, I. Horn, N. Leiser, and G. Czajkowski. Pregel: A System for Large-scale Graph Processing. In Proc. 2010 ACM SIGMOD International Conf. on Management of Data, SIGMOD '10, pages 135 -- 146. ACM, 2010. [35] R. R. McCune, T. Weninger, and G. Madey. Think- ing Like a Vertex: A Survey of Vertex-Centric Frameworks for Large-Scale Distributed Graph Processing. ACM Comput. Surv., 48(2):25:1 -- 25:39, Oct. 2015. [25] G. Karypis and V. Kumar. A Fast and High Quality Multilevel Scheme for Partitioning Irreg- ular Graphs. SIAM Journal on Scientific Comput- ing, 20(1):359 -- 392, 1998. [36] H. Meyerhenke, P. Sanders, and C. Schulz. Parallel graph partitioning for complex networks. In 2015 IEEE International Parallel and Distributed Pro- cessing Symposium, pages 1055 -- 1064, May 2015. [26] G. Karypis and V. Kumar. Multilevel K-way In Proceedings of the Hypergraph Partitioning. 36th ACM/IEEE Design Automation Conference, pages 343 -- 348. ACM, 1999. ISBN 1-58113-109-7. [27] G. Karypis, R. Aggarwal, V. Kumar, and S. Shekhar. Multilevel Hypergraph Partitioning: Applications in VLSI Domain. IEEE Transactions on Very Large Scale Integration VLSI Systems, 7 (1):69 -- 79, 1999. ISSN 1063-8210. [28] V. Kumar, A. Grama, A. Gupta, and G. Karypis. design and Ben- Introduction to parallel computing: analysis of algorithms, jamin/Cummings Redwood City, 1994. volume 400. [29] U. o. M. Laboratory of Web Algorithms. Datasets, http://law.dsi.unimi.it/datasets.php. [30] T. Lengauer. Combinatorial Algorithms for Inte- grated Circuit Layout. John Wiley & Sons, Inc., 1990. ISBN 0-471-92838-0. 12 [37] D. A. Papa and I. L. Markov. Hypergraph Parti- tioning and Clustering. In T. F. Gonzalez, editor, Handbook of Approximation Algorithms and Meta- heuristics. Chapman and Hall/CRC, 2007. [38] U. N. Raghavan, R. Albert, and S. Kumara. Near Linear Time Algorithm to Detect Commu- nity Structures in Large-Scale Networks. Physical Review E, 76(3), 2007. [39] F. Rahimian, A. H. Payberah, S. Girdzijauskas, and S. Haridi. Distributed vertex-cut partition- ing. In K. Magoutis and P. Pietzuch, editors, Dis- tributed Applications and Interoperable Systems, pages 186 -- 200, Berlin, Heidelberg, 2014. [40] P. Sanders and C. Schulz. Engineering Multilevel In Proceedings Graph Partitioning Algorithms. of the 19th European Symposium on Algorithms, volume 6942 of LNCS, pages 469 -- 480. Springer, 2011. ISBN 978-3-642-23718-8. [41] P. Sanders and C. Schulz. Think Locally, Act Globally: Highly Balanced Graph Partitioning. In Proceedings of the 12th International Symposium on Experimental Algorithms (SEA'12), LNCS. Springer, 2013. [50] C. Walshaw and M. Cross. JOSTLE: Parallel Mul- tilevel Graph-Partitioning Software -- An Overview. In Mesh Partitioning Techniques and Domain De- composition Techniques, pages 27 -- 58. Civil-Comp Ltd., 2007. [51] S. Williams, L. Oliker, R. Vuduc, J. Shalf, K. Yelick, and J. Demmel. Optimization of sparse matrix-vector multiplication on emerging multicore platforms. Parallel Computing, 35(3):178 -- 194, 2009. Revolutionary Technologies for Acceleration of Emerging Petascale Applications. [42] S. Schlag, V. Henne, T. Heuer, H. Meyerhenke, P. Sanders, and C. Schulz. k-way Hypergraph Par- titioning via n-Level Recursive Bisection. In 18th Workshop on Algorithm Engineering and Experi- ments (ALENEX), pages 53 -- 67, 2016. [43] S. Schlag, V. Henne, T. Heuer, H. Meyerhenke, P. Sanders, and C. Schulz. k-way Hypergraph Par- titioning via n-Level Recursive Bisection. In 18th Workshop on Algorithm Engineering and Experi- ments (ALENEX), pages 53 -- 67, 2016. [44] K. Schloegel, G. Karypis, and V. Kumar. Graph Partitioning for High Performance Scientific Simu- lations. In The Sourcebook of Parallel Computing, pages 491 -- 541, 2003. [45] C. Schulz and D. Strash. Graph Partitioning -- Formulations and Applications to Big Data. In Encyclopedia on Big Data Technologies, 2018, to appear. [46] A. Trifunovic and W. J. Knottenbelt. Parkway 2.0: A Parallel Multilevel Hypergraph Partitioning In Computer and Information Sciences - Tool. ISCIS 2004, volume 3280, pages 789 -- 800. Springer, 2004. ISBN 978-3-540-23526-2. [47] Ü. V. Çatalyürek and M. Deveci and K. Kaya and B. Uçar. UMPa: A multi-objective, multi- level partitioner for communication minimization. In D. A. Bader, H. Meyerhenke, P. Sanders, and D. Wagner, editors, Graph Partitioning and Graph Clustering - 10th DIMACS Implementation Chal- lenge Workshop, Georgia Institute of Technology, Atlanta, GA, USA, February 13-14, 2012. Proceed- ings, volume 588 of Contemporary Mathematics, pages 53 -- 66. AMS, 2012. [48] B. Vastenhouw and R. H. Bisseling. A Two- Dimensional Data Distribution Method for Paral- lel Sparse Matrix-Vector Multiplication. SIAM Re- view, 47(1):67 -- 95, 2005. ISSN 0036-1445. [49] C. Walshaw and M. Cross. Mesh Partitioning: A Multilevel Balancing and Refinement Algorithm. SIAM Journal on Scientific Computing, 22(1):63 -- 80, 2000. 13 A Full Experimental Data Algorithm KaHyPar-MF hMETIS-K hMETIS-R PaToH Zoltan (1) Zoltan (20) KaHIP-Fast KaHIP-Eco KaHIP-Strong METIS ParHIP-Fast (20) ParHIP-Eco (20) ParMETIS (20) Ja-Be-Ja-VC VC (avg) 1 283 1 518 1 617 1 604 1 875 1 967 1 869 1 663 1 572 1 750 1 947 1 737 1 970 15 077 (a) Walshaw graphs. Algorithm KaHyPar-MF hMETIS-K hMETIS-R PaToH Zoltan (1) Zoltan (20) KaHIP-Fast KaHIP-Eco KaHIP-Strong METIS ParHIP-Fast (20) ParHIP-Eco (20) ParMETIS (20) Ja-Be-Ja-VC VC (avg) 433 524 625 508 1 301 1 481 658 580 517 595 613 538 676 6 336 Runtime 17.30 s 35.06 s 51.85 s 0.42 s 1.06 s 0.25 s 1.66 s 7.76 s 160.02 s 1.55 s 0.66 s 108.26 s 0.08 s -- Runtime 510.75 s 14.81 s 17.19 s 0.46 s 0.36 s 0.19 s 1.04 s 4.50 s 84.33 s 0.63 s 0.52 s 106.20 s 0.06 s -- Algorithm KaHyPar-MF hMETIS-K hMETIS-R PaToH Zoltan (1) Zoltan (20) KaHIP-Fast KaHIP-Eco KaHIP-Strong METIS ParHIP-Fast (20) ParHIP-Eco (20) ParMETIS (20) Ja-Be-Ja-VC VC (avg) 1 283 2 620 2 664 2 813 3 289 3 874 3 120 2 754 2 598 3 014 4 039 3 289 3 403 180 762 Runtime 162.84 s 493.26 s 1 144.71 s 4.69 s 14.39 s 3.40 s 11.21 s 52.53 s 1 428.63 s 20.60 s 12.77 s 146.06 s 0.63 s -- (b) SPMV graphs with up to 1M edges. Algorithm KaHyPar-MF hMETIS-K hMETIS-R PaToH Zoltan (1) Zoltan (20) KaHIP-Fast KaHIP-Eco KaHIP-Strong METIS ParHIP-Fast (20) ParHIP-Eco (20) ParMETIS (20) Ja-Be-Ja-VC VC (avg) 1 091 1 321 1 443 1 342 1 846 1 979 1 593 1 412 1 317 1 480 1 651 1 459 1 679 15 774 Runtime 43.58 s 37.99 s 55.00 s 0.54 s 1.06 s 0.30 s 1.81 s 8.43 s 173.79 s 1.64 s 0.80 s 110.39 s 0.08 s -- (c) Small random hyperbolic graphs, rhg10 -- rhg18. (d) All small graphs. Table 4: Full comparison of Walshaw, SPMV graphs with up to 1M nodes and rhg10 -- rhg18. The results for Zoltan are reported for one PE, Zoltan (1), and 20 PEs, Zoltan (20). For ParHIP and ParMETIS, only results on 20 PEs are shown. All algorithms were executed on a single node. 14 B Additional Performance Plots The following performance plots are based on the Walshaw graphs, SPMV graphs with up to 1M nodes and the random hyperbolic graphs rhg10 -- rhg18. (a) Performance comparison of all hypergraph partitioners. (b) Performance comparison of SPAC+X with different se- quential graph partitioners. (c) Performance comparison of dSPAC+X with different distributed graph partitioners and Zoltan. (d) Comparing the best sequential SPAC+X (KaHIP- Strong) and HGP (KaHyPar-MF) approaches with the best dSPAC+X implementation (dSPAC+ParHIP-Eco). Figure 7: Additional performance plots comparing hypergraph partitioning algorithms (a), sequential SPAC+X approaches (b), dSPAC+X and dHGP approaches (c), as well as the best algorithm of each category (d). 15 0.000.010.050.100.200.400.600.801.001102550100250Instances1-(Best/Algorithm)AlgorithmKaHyPar-MFPaToHZoltanhMETIS-KhMETIS-R0.000.010.050.100.200.400.600.801102550100250Instances1-(Best/Algorithm)AlgorithmKaHIP-EcoKaHIP-FastKaHIP-StrongMETIS0.000.010.050.100.200.400.600.801.001102550100250Instances1-(Best/Algorithm)AlgorithmParHIP-EcoParHIP-FastParMETISZoltan0.000.010.050.100.200.400.601102550100250Instances1-(Best/Algorithm)AlgorithmKaHIP-StrongKaHyPar-MFParHIP-Eco C Additional Experimental Results for dSPAC+X (a) Running time for dSPAC+ParHIP-Fast. (b) Running time for dSPAC+ParHIP-Fast. (c) Running time for dSPAC+ParMETIS. (d) Running time for dSPAC+ParMETIS. (e) Running time for distributed split graph construction. (f) Running time for distributed split graph construction. Figure 8: Running times for dSPAC+ParHIP-Fast (a, b), dSPAC+ParMETIS (c, d) and the time it takes to compute the distributed split graph (e, f) on increasing numbers of PE. 16 31030100300120408016032064012802560NumberofPEsTime(s)Graphrhg20rhg21rhg22rhg23rhg24rhg25rhg26101001000120408016032064012802560NumberofPEsTime(s)Graphamazonchannelcircuit5M_spmveu-2005europe_osmhugebubble-10in-2004in-2004_spmvpackingroad_centralyoutube110100120408016032064012802560NumberofPEsTime(s)Graphrhg20rhg21rhg22rhg23rhg24rhg25rhg26110100120408016032064012802560NumberofPEsTime(s)Graphamazonchannelcircuit5M_spmveu-2005europe_osmhugebubble-10in-2004in-2004_spmvpackingroad_centralyoutube0.11.010.0120408016032064012802560NumberofPEsTime(s)Graphrhg20rhg21rhg22rhg23rhg24rhg25rhg260.11.010.0120408016032064012802560NumberofPEsTime(s)Graphamazonchannelcircuit5M_spmveu-2005europe_osmhugebubble-10in-2004in-2004_spmvpackingroad_centralyoutube Graph in-2004_spmv circuit5M_spmv amazon eu-2005 youtube in-2004 packing channel road_central hugebubble-10 uk-2002 nlpkkt240 europe_osm rhg20 rhg21 rhg22 rhg23 rhg24 rhg25 rhg26 rgg27 rgg25 rgg26 rgg28 in-2004_spmv circuit5M_spmv amazon eu-2005 youtube in-2004 packing channel road_central hugebubble-10 uk-2002 nlpkkt240 europe_osm rhg20 rhg21 rhg22 rhg23 rhg24 rhg25 rhg26 rgg27 rgg25 rgg26 rgg28 1 20 Vertex cut on different numbers of PEs 640 160 320 40 80 1 280 2 560 ParHIP-Fast 1 478 1 600 232 -- 366 -- 307 1 526 235 1 529 22 740 23 501 25 432 23 537 1 658 1 662 60 838 63 129 72 033 63 284 472 3 282 -- 14 575 16 551 26 542 125 1 798 333 3 324 394 3 179 412 3 137 118 1 699 -- -- -- 567 850 1 215 -- -- -- -- -- -- -- -- 137 1 934 -- -- 196 890 1 361 1 809 1 960 -- -- -- -- -- -- -- 131 1 836 -- -- 194 700 1 077 1 478 2 061 2 822 -- -- -- -- -- -- 189 1 426 24 493 1 489 67 324 248 3 494 14 779 132 1 760 202 1 544 22 987 1 533 63 018 417 3 335 21 975 128 1 783 195 1 363 23 577 1 562 65 684 359 3 193 19 212 126 1 773 194 1 316 23 364 1 560 63 535 264 3 423 14 996 125 1 770 185 1 475 22 788 1 435 66 867 263 4 272 15 233 122 1 752 -- 130 548 110 529 126 918 115 485 135 790 -- 187 071 181 478 178 162 181 843 -- 192 201 756 590 759 1 037 965 1 269 1 394 1 465 2 795 1 726 2 324 3 186 3 036 -- 21 810 -- 7 777 -- -- 12 581 17 846 -- 205 581 821 1 020 1 304 1 907 2 380 3 281 22 547 8 058 13 140 17 897 199 637 878 1 044 1 399 2 131 2 535 3 741 -- 9 611 16 041 -- 195 580 846 1 011 1 480 2 056 2 811 3 416 24 213 8 804 13 133 -- 195 657 924 1 126 1 503 2 688 3 014 -- -- 10 710 -- -- ParMETIS 2 339 2 696 400 -- 588 -- 509 1 346 787 3 472 804 3 567 566 1 314 19 219 22 114 21 619 21 010 2 453 2 405 56 207 62 012 61 790 61 342 753 586 2 962 3 602 10 995 12 057 12 185 12 147 221 1 779 -- -- 240 633 889 1 217 1 554 2 294 2 876 -- -- -- -- -- 222 1 831 -- -- 257 649 934 1 116 1 625 2 249 -- -- -- -- -- -- 223 1 773 -- -- 257 652 839 1 175 1 598 -- -- -- -- -- -- -- 240 1 710 -- -- -- 475 646 761 1 297 -- -- -- -- -- -- -- 558 1 445 20 417 2 455 61 200 774 3 469 12 209 210 1 775 72 346 239 647 868 1 094 1 666 2 277 2 942 -- -- 8 832 -- -- 494 1 453 20 338 2 554 61 007 687 3 268 12 145 234 1 718 71 689 513 1 374 20 358 2 855 61 151 733 3 323 12 418 201 1 746 71 476 516 1 390 20 269 2 618 60 899 740 3 327 12 247 224 1 729 71 084 513 1 563 20 174 2 756 61 249 707 3 169 12 054 229 1 713 72 477 -- 143 048 141 947 142 466 141 491 233 583 809 1 035 1 459 2 001 2 755 3 669 20 208 8 725 12 880 29 742 246 582 777 1 106 1 545 2 144 2 693 3 785 19 672 8 782 13 097 29 864 248 619 816 1 062 1 598 2 112 2 746 3 902 20 141 8 999 13 405 -- 241 647 856 1 086 1 705 2 252 2 952 3 923 -- 8 882 13 373 -- Table 5: Solution quality of dSPAC+X for the largest graphs on an increasing number of PEs. 17
1702.08443
1
1702
2017-02-26T07:12:46
Elementary Yet Precise Worst-case Analysis of MergeSort, A short version (SV)
[ "cs.DS", "cs.CC", "cs.DM" ]
This paper offers two elementary yet precise derivations of an exact formula \[ W(n) = \sum_{i=1} ^{n} \lceil \lg i \rceil = n \lceil \lg n \rceil - 2^{\lceil \lg n \rceil} + 1 \] for the maximum number $ W(n) $ of comparisons of keys performed by $ {\tt MergeSort} $ on an $ n $-element array. The first of the two, due to its structural regularity, is well worth carefully studying in its own right. Close smooth bounds on $ W(n) $ are derived. It seems interesting that $ W(n) $ is linear between the points $ n = 2^{\lfloor \lg n \rfloor} $ and it linearly interpolates its own lower bound $ n \lg n - n + 1 $ between these points.
cs.DS
cs
Elementary Yet Precise Worst-case Analysis of MergeSort A short version (SV) of a manuscript intended for future publication $ MAREK A. SUCHENEK California State University Dominguez Hills, Department of Computer Science, 1000 E. Victoria St., Carson, CA 90747, USA, [email protected] Abstract The full version of this paper offers two elementary yet precise derivations of an exact formula n(cid:88) W (n) = (cid:100)lg i(cid:101) = n(cid:100)lg n(cid:101) − 2(cid:100)lg n(cid:101) + 1 i=1 for the maximum number W (n) of comparisons of keys performed by MergeSort on an n-element array. The first of the two, due to its struc- tural regularity, is well worth carefully studying in its own right. Close smooth bounds on W (n) are derived. It seems interesting that W (n) is linear between the points n = 2(cid:98)lg n(cid:99) and it linearly interpolates its own lower bound n lg n − n + 1 between these points. The manuscript (MS) of the full version of this paper, dated January 20, 2017, can be found at: http://csc.csudh.edu/suchenek/Papers/Analysis_of_MergeSort.pdf Keywords: MergeSort, sorting, worst case. 2010 MSC: 68W40 Analysis of algorithms $ c(cid:13)2017 Marek A. Suchenek. Preprint submitted to arXiv.org for the record as a manuscript. September 22, 2018 Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV) 2 ACM Computing Classification Theory of computation: Design and analysis of algorithms: Data structures design and analysis: Sorting and searching Mathematics of computing: Discrete mathematics: Graph theory: Trees Mathematics of computing: Continuous mathematics: Calculus ACM classes: F.2.2; G.2.0; G.2.1; G.2.2 Contents 1 Introduction 2 Some Math prerequisites 3 MergeSort and its worst-case behavior W (n) 4 An easy yet precise derivation of W (n) 5 Close smooth bounds on W (n) 6 Other properties of the recursion tree Tn 3 4 5 7 9 13 7 A derivation of W (n) without references to the recursion tree 16 8 Other work 9 Best-case analysis of MergeSort Appendix A A Java code of MergeSort Appendix B Generating worst-case arrays for MergeSort 16 19 20 20 Appendix C Notes from my Analysis of Algorithms lecture 22 Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV) 3 1. Introduction MergeSort is one of the fundamental sorting algorithms that is being taught in undergraduate Computer Science curricula across the U.S. and elsewhere. Its worst-case performance, measured by the number of com- parisons of keys performed while sorting them, is optimal for the class of algorithms that sort inductively1 by comparisons of keys.2 Historically, it3 was the first sorting algorithm to run in O(n lg n) time4. So it seems only fitting to provide an exact formula for MergeSort's worst- case performance and derive it precisely. Unfortunately, many otherwise decent texts offer unnecessarily imprecise5 variants of it, and some with quite convoluted, incomplete, or incorrect proofs. Due to these imperfections, the fact that the worst-case performance of MergeSort is the same as that of another benchmark sorting algorithm, the binary insertion sort of [5], has remained unnoticed6. In this paper, I present two outlines7 of elementary yet precise and com- plete derivations of an exact formula n(cid:88) W (n) = (cid:100)lg i(cid:101) = n(cid:100)lg n(cid:101) − 2(cid:100)lg n(cid:101) + 1 i=1 for the maximum number W (n) 8 of comparisons of keys performed by MergeSort on an n-element array. The first of the two, due to its struc- tural regularity, is well worth carefully studying in its own right. 1Inductive sorting of n keys sorts a set of n − 1 of those keys first, and then "sorts-in" the remaining n-th key. 2In its standard form analyzed in this paper, MergeSort is not an inductive sorting algorithm. However, its worst-case performance, measured by the number of comparisons of keys performed while sorting them, is equal to the worst-case performance of the binary insertion sort first described by Steinhaus in [5] that is worst-case optimal in the class of inductive sorting algorithms that sort by comparisons of keys; see [3] page 186. 3A bottom-up version of it, invented by John Neumann. 4In the worst case. 5Notable exceptions in this category are [2] and [4] that derive almost exact formulas, but see Section 8 page 16 for a brief critique of the results and their proofs offered there. 6Even in [3]. 7The detailed derivations can be found in [9]. 8Elementary derivation of an exact formula for the best-case performance B(n) of MergeSort, measured by the number of comparisons of keys performed while sorting them, has been done in [8]; see Section 9 page 19 of this paper. Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV) 4 Unlike some other basic sorting algorithms9 that run in O(n lg n) time, MergeSort exhibits a remarkably regular10 worst-case behavior, the elegant simplicity of which has been mostly lost on its rough analyses. In particular, W (n) is linear11 between the points n = 2(cid:98)lg n(cid:99) and it linearly interpolates its own lower bound n lg n − n + 1 12 between these points. What follows is a short version (SV) of a manuscript dated January 20, 2017, of the full version version [9] of this paper that has been posted at: http://csc.csudh.edu/suchenek/Papers/Analysis_of_MergeSort.pdf The derivation of the worst case of MergeSort presented here is roughly the same13 as the one I have been doing in my undergraduate Analysis of Algorithms class. Appendix C shows sample class notes from one of my lectures. 2. Some Math prerequisites tion of a well-known14 closed-form formula for(cid:80)n A manuscript of the full version [9] of this paper contains a clever deriva- i=1(cid:100)lg i(cid:101). It proves insightful in my worst-case analysis of MergeSort as its right-hand side will occur on page 8 in the fundamental equality (5) and serve as an instrument to derive the respective exact formula for MergeSort's worst-case behavior. Lemma 2.1. For every integer n ≥ 1, (1) (cid:50) n(cid:88) (cid:100)lg n(cid:101)−1(cid:88) (cid:100)lg i(cid:101) = (n − 2y). i=1 y=0 Proof in [9]. From this one can easily conclude that: 9For instance, Heapsort; see [7] for a complete analysis of its worst-case behavior. 10As revealed by Theorem 5.2, page 10. 11See Figure 4 page 11. 12Given by the left-hand side of the inequality (12) page 11. 13Except for the present proof of Lemma 2.1 which I haven't been using in my class. 14See [3]. Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV) 5 Corollary 2.2. For every integer n ≥ 1, n(cid:88) (cid:100)lg i(cid:101) = n(cid:100)lg n(cid:101) − 2(cid:100)lg n(cid:101) + 1. (2) i=1 3. MergeSort and its worst-case behavior W (n) A call to MergeSort inherits an n-element array A of integers and sorts it non-decreasingly, following the steps described below. Algorithm MergeSort 3.1. To sort an n-element array A do: 1. If n ≤ 1 then return A to the caller, 2. If n ≥ 2 then 2(cid:99) elements of A to a recursive call to MergeSort, (a) pass the first (cid:98) n 2(cid:101) elements of A to another recursive call to MergeSort, (b) pass the last (cid:100) n (c) linearly merge, by means of a call to Merge, the non-decreasingly sorted arrays that were returned from those calls onto one non- decreasingly sorted array A(cid:48), (d) return A(cid:48) to the caller. A Java code of Merge is shown on the Figure 1.15 A typical measure of the running time of MergeSort is the number of comparisons of keys, which for brevity I call comps, that it performs while sorting array A. Definition 3.2. The worst-case running time W (n) of MergeSort is defined as the maximum number of comps it performs while sorting an array of n distinct16 elements. 15A Java code of MergeSort is shown in Appendix A Figure A.6 page 20. 16This assumption is superfluous for the purpose of worst-case analysis as the mere presence of duplicates does not force MergeSort to perform more comps. Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV) 6 Figure 1: A Java code of Merge, based on a pseudo-code from [1]. Calls to Boolean method Bcnt.incr() count the number of comps for the purpose of experimental verification of the worst-case analysis of MergeSort. Clearly, if n = 0 then W (n) = 0. From this point on, I am going to assume that n ≥ 1.17 Since no comps are performed outside Merge, W (n) can be computed as the sum of numbers of comps performed by all calls to Merge during the execution of MergeSort. The following classic results will be useful in my analysis. Theorem 3.3. The maximum number of comps performed by Merge on two sorted list of total number n of elements is n − 1. Proof (constructive, with Java code that generates worst cases shown in the Appendix B) in [9]. (cid:50) Moreover, if the difference between the lengths of merged list is not larger than 1 then no algorithm that merges sorted lists by means of comps beats Merge in the worst case, that is, has a lower than n − 1 maximum number of comps.18 This fact makes MergeSort optimal in the intersection of the class of sorting algorithms that sort by merging two sorted lists of lengths' 17This assumption turns out handy while using expression lg n. 18Proof in [3], Sec. 5.3.2 page 198; the worst-case optimality of Merge (n − 1 comps) was generalized in [6] over lists of lengths k and m, with k ≤ m, that satisfy 3k ≥ 2m− 2. Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV) 7 difference not larger than 1 19 with the class of sorting algorithms that sort by comps. 4. An easy yet precise derivation of W (n) MergeSort is a recursive algorithm. If n ≥ 2 then it spurs a cascade of two or more recursive calls to itself. A rudimentary analysis of the respective recursion tree Tn, shown on Figure 2, yields a neat derivation of the exact formula for the maximum number W (n) of comps that MergeSort performs on an n-element array. Figure 2: A sketch of the recursion 2-tree Tn for MergeSort for a sufficiently large n, with level numbers shown on the left and the numbers of nodes in the respective level shown on the right. The nodes correspond to calls to MergeSort and show sizes of (sub)arrays passed to those calls. The last non-empty level is h. The empty levels (all those numbered > h) are not shown. The root corresponds to the original call to MergeSort. If a call that is represented by a node p executes further recursive calls to MergeSort then these calls are represented by the children of p; otherwise p is a leaf. The wavy line (cid:58)(cid:58)(cid:58)(cid:58) represents a path in Tn. 19Or, by virtue of the above-quoted result from [6], with the difference not larger than the half of the length of the shorter list plus 1. Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV) 8 The idea behind the derivation is strikingly simple. It is based on the observation20 that for every k ∈ N, the maximum number Ck of comps performed at each level21 k of Tn is given by this neat formula:22 Ck = max{n − 2k, 0}. (3) Since n − 2k > 0 if, and only if, (cid:100)lg n(cid:101) − 1 ≥ k, (4) the Corollary 2.2 will allow me to conclude from (3) and (4) the main result of this paper23: (cid:100)lg n(cid:101)−1(cid:88) (cid:88) k∈N W (n) = Ck = (n − 2k) = n(cid:100)lg n(cid:101) − 2(cid:100)lg n(cid:101) + 1 = (cid:100)lg i(cid:101). (5) k=0 i=1 n(cid:88) n(cid:88) The missing details24 in the above sketch are in [9]. Naturally, their only purpose is to prove the equality (3) for all k ∈ N, as the rest, shown in (5), easily follows from it. In particular, we get: The Main Theorem 4.1. The number W (n) of comparisons of keys that MergeSort performs in the worst case while sorting an n-element array is W (n) = (cid:100)lg i(cid:101) = n(cid:100)lg n(cid:101) − 2(cid:100)lg n(cid:101) + 1. Proof in [9]. i=1 From that we can conclude a usual rough characterization of W (n): W (n) ≤ n(lg n + 1) − 2lg n + 1 = n lg n + n − n + 1 = n lg n + 1 and W (n) ≥ n lg n − 2lg n+1 + 1 = n lg n − 2n + 1. (6) (cid:50) 20Which I prove in [9] as Theorem 4.6, page 14. 21Empty or not. 22It is a simplification of formulas used in derivation presented in [2] and discussed in Section 8 page 16; in particular, it does not refer to the depth h of the decision tree Tn. 23This is how I have been deriving it in my undergraduate Analysis of Algorithms class for some 15 years or so, now. 24Which I did not show in my Analysis of Algorithms class. Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV) 9 Therefore, The occurrence of(cid:80)n W (n) ∈ Θ(n log n). i=1(cid:100)lg i(cid:101) in (6) allows to conclude that W (n) is ex- actly equal25 to the number of comparisons of keys that the binary insertion sort, considered by H. Steinhaus in [5] and analyzed in [3], performs in the worst case. Since the binary insertion sort is known to be worst-case opti- mal26 in the class of algorithms that perform incremental sorting, MergeSort is worst-case optimal in that class27, too. From this and from the observation at the end of Section 3, page 6, I conclude that no algorithm that sorts by merging two sorted lists and only by means of comps is worst-case optimal in the class of algorithms that sort by means of comps as it must perform 8 comps in the worst case while sorting 5 elements28, while one can sort 5 elements by means of comps with no more than 7 comps. 5. Close smooth bounds on W (n) Our formula for W (n) contains a function ceiling that is harder to analyze than arithmetic functions and their inverses. In this Section, I outline a derivation of close lower and upper bounds on W (n) that are expressible by simple arithmetic formulas. I show that these bounds are the closest to W (n) in the class of functions of the form n lg n + cn + 1, where c is a real constant. The detailed derivation and missing proofs can be found in [9]. Using the function ε (analyzed briefly in [3] and [7]), a form of which is shown on Figure 3, given by: ε = 1 + θ − 2θ and θ = (cid:100)lg n(cid:101) − lg n, one can conclude29 that, for every n > 0, n(cid:100)lg n(cid:101) − 2(cid:100)lg n(cid:101) = n(lg n + ε − 1), (7) (8) 25[3] contains no mention of that fact. 26With respect to the number of comparisons of keys performed. 27Although it is not a member of that class. 28They can be split in two: 1 plus 4, and follow the binary insertion sort, or 2 plus 3, and follow MergeSort. 29See [7], Thm. 12.2 p. 94 for a proof. Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV)10 which yields W (n) = n(lg n + ε − 1) + 1 = n lg n + (ε − 1)n + 1. (9) Figure 3: Graph of ε − 1 as a function of lg n. Property 5.1. Function ε given by (7) is a continuous function of n on the set of reals > 0. It assumes the minimum 0 for every n = 2(cid:98)lg n(cid:99) and the maximum δ = 1 − lg e + lg lg e ≈ 0.0860713320559342, 30 (10) for every (11) and only such n. The function ε restricted to integers never reaches the value δ. However, δ is the supremum of ε restricted to integers. n = 2(cid:98)ln n+lg lg e(cid:99) ln 2 Proof in [9]. Characterization (9) and Property 5.1 yield close smooth bounds of W (n). They are both of the form n lg n + cn + 1 and they sandwich tightly W (n) If one sees W (n) as an infinite polygon31, its lower between each other. bound circumscribes it and its upper bound inscribes it. (cid:50) 30The constant 1 − lg e + lg lg e has been known as the Erdös constant δ. Erdös used it around 1955 in order to establish an asymptotic upper bound for the number M (k) of different numbers in a multiplication table of size k × k by means of the following limit: lim k→∞ 31Which it is. ln k×k M (k) ln ln(k × k) = δ. 00.47123411.471232-1-0.913928 Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV)11 Theorem 5.2. W (n) is a continuous concave function, linear between the points n = 2(cid:98)lg n(cid:99), that for every n > 0 satisfies this inequality: n lg n − n + 1 ≤ W (n) ≤ n lg n − (1 − δ)n + 1 < n lg n − 0.913n + 1, (12) with the left ≤ becoming = for every n = 2(cid:98)lg n(cid:99) and the right ≤ becoming = for every n = 2(cid:98)lg n+lg lg e(cid:99) ln 2, and only for such n. Moreover, the graph of W (n) is tangent to the graph of n lg n−(1−δ)n+1 at the points n = 2(cid:98)lg n+lg lg e(cid:99) ln 2, and only at such points. Proof in [9]. (cid:50) Figure 4: W (n) = n(cid:100)lg n(cid:101) − 2(cid:100)lg n(cid:101) + 1 (the middle line) and its bounds n lg n − n + 1 and n lg n − (1 − δ)n + 1 ≈ n lg n − 0.913n + 1, all three treated as functions of a positive real variable n, plotted for n ∈ [1, 6]. W (n) is linear between the points n = 2(cid:98)lg n(cid:99) and it linearly interpolates its lower bound n lg n − n + 1 between these points. Its upper bound n lg n − (1 − δ)n + 1 inscribes it and is tangent to it at the points n = 2(cid:98)lg n+lg lg e(cid:99) ln 2. The bounds given by (12) are really close32 to the exact value of W (n), as it is shown on Figure 4 page 11. The exact value n(cid:100)lg n(cid:101) − 2(cid:100)lg n(cid:101) + 1 is a continuous function (if n is interpreted as a real variable) despite that it incorporates discontinuous function ceiling. 32The distance between them is less than δn ≈ 0.0860713320559342n for any positive integer n. 1.3862922.7725945.545180.38629412.5451859.63553 Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV)12 Note 5.3. It seems interesting that W (n) = n(cid:100)lg n(cid:101) − 2(cid:100)lg n(cid:101) + 1 (whether n is interpreted as a real variable or an integer variable) is linear between points n = 2(cid:98)lg n(cid:99) and linearly interpolates its own lower bound n lg n − n + 1 between these points. For n restricted to positive integers, the inequality (12) can be slightly enhanced by replacing the ≤ symbol with <, with the following result. Theorem 5.4. 1 − δ is the greatest constant c such that for every integer n ≥ 1, W (n) < n lg n − cn + 1. (13) Proof in [9]. Theorem 5.4 can be reformulated as follows. Corollary 5.5. (cid:50) inf{c ∈ R ∀n ∈ N \ {0}, W (n) < n lg n − cn + 1} = 1 − δ. (14) Proof in [9]. (cid:50) No upper bound of W (n) that has a form n lg n − cn + 1 can coincide with W (n) at any integer n, as the following fact ascertains. Corollary 5.6. There is no constant c such that for every integer n ≥ 1, W (n) ≤ n lg n − cn + 1 and for some integer n ≥ 1, W (n) = lg n − cn + 1. Proof in [9]. In particular33, (15) (16) (cid:50) inf{c ∈ R ∀n ∈ N \ {0}, W (n) ≤ n lg n − cn + 1} = 1 − δ. (17) Moreover, we can conclude from Theorem 5.4 the following fact. 33Note the ≤ symbol in (17). Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV)13 Corollary 5.7. 1 − δ is the greatest constant c such that for every integer n ≥ 1, W (n) ≤ (cid:100)n lg n − cn(cid:101). (18) (19) Proof in [9]. (cid:50) Since for any integer n ≥ 1, W (n) is integer, the lower bound given by (12) yields (cid:100)n lg n(cid:101) − n + 1 ≤ W (n) ≤ (cid:100)n lg n − 0.913n(cid:101). By virtue of Corollary 5.7, for some integers n ≥ 1,34 W (n) > (cid:100)n lg n − 0.914n(cid:101). (20) Although the bounds given by (19) 35 are tighter than those given by (12), they nevertheless involve the discontinuous ceiling function, so that they may not be as easy to visualize or analyze as some differentiable functions, thus losing their advantage over the precise formula W (n) = n(cid:100)lg n(cid:101) − 2(cid:100)lg n(cid:101) + 1. Therefore, the bounds given by (12) appear to have an analytic advantage over those given by (19). 6. Other properties of the recursion tree Tn This sections contains some well-known auxiliary facts that I didn't need for the derivation of the exact formula for W (n) but am going to derive from the Main Lemma 4.1 of [9] for the sake of a thoroughness of my analysis of the decision tree Tn. Theorem 6.1. The depth h of the recursion tree Tn is h = (cid:100)lg n(cid:101). (21) Proof in [9]. (cid:50) Note 6.2. Theorem 6.1 allows for quick derivation of fairly close upper bound on the number of comps performed by MergeSort on an n-element array. Since at each level of Tn less than n comparisons are performed by Merge and at level h no comps are performed, and there are h = (cid:100)lg n(cid:101) levels below level h, the total number of comps is not larger than (n − 1)h = (n − 1)((cid:100)lg n(cid:101)) < (n − 1)(lg n + 1) ∈ O(n log n). (22) 34For instance, for n = 11. 35Almost the same bounds were given in [2]; see Section 8 for more details on this. Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV)14 A cut of a tree Tn is a set Γ of nodes of T such that every branch36 in Tn has exactly one element in Γ. Theorem 6.3. The sum of values shown at the elements of any cut of Tn is n. Theorem 6.4. The number of leaves in the recursion tree Tn is n. Proof in [9]. The following corollary provides some statistics about recursive calls to (cid:50) (cid:50) Proof in [9]. MergeSort. Corollary 6.5. For every integer n > 0, (i) Tn has 2n − 1 nodes. (ii) The number or recursive calls spurred by MergeSort on any n-element array is 2(n − 1). (iii) The sum Sn of all values shown in the recursion tree Tn on Figure 2 is equal to: Sn = n(cid:100)lg n(cid:101) − 2(cid:100)lg n(cid:101) + 2n = n(lg n + ε + 1). (23) (iv) The average size An of array passed to any recursive call to MergeSort while sorting an n-element array is: An = 1 2 (1 + 1 n − 1 )(lg n + ε) ≈ 1 2 (lg n + ε). (24) Proof in [9]. (cid:50) Here is a very insightful property. It states that MergeSort is splitting its input array fairly evenly37 so that at any level of the recursive tree, the difference between the lengths of the longest sub-array and the shortest sub- array is ≤ 1. This fact is the root cause of good worst-case performance of MergeSort. 36A maximal path. 37The sizes of the sub-arrays passed to recursive calls at any non-empty level k of the decision tree Tn above the last non-empty level h are the same as the sizes of the elements of the maximally even partition of an n-element set onto 2k subsets. Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV)15 Property 6.6. The difference between values shown by any two nodes in the same level of of the recursion tree Tn is ≤ 1. Proof in [9]. (cid:50) Property 6.6 has this important consequence that Merge is, by virtue of the observation on page 6 after the Theorem 3.3 page 6, worst-case comparison- optimal while merging any two sub-arrays of the same level of the recursion tree. Thus the worst-case of MergeSort cannot be improved just by replacing Merge with some tricky merging X as long as X merges by means of compar- isons of keys. Corollary 6.7. Replacing Merge with any other method that merges sorted arrays by means of comps will not improve the worst-case performance of MergeSort measured with the number of comps while sorting an array. Proof. Proof follows from the above observation. Since a parent must show a larger value than any of its children, the Property 6.6 has also the following consequence. Corollary 6.8. The leaves in the recursion tree Tn can only reside at the last two non-empty levels of Tn. Proof. Proof follows from the Property 6.6 as the above observation indicates. As a result, one can conclude38 that the recursion tree Tn has the miminum internal and external path lengths among all binary trees on 2n − 1 nodes. Since all nodes at the level h of the recursion tree Tn are leaves and show value 1, no node at level h− 1 can show a value > 2. Indeed, level h− 1 may only contain leaves, that show value 1, and parents of nodes of level h that show value 1 + 1 = 2. This observation and the previous result allow for easy characterization of contents of the last two non-empty levels of tree Tn. Corollary 6.9. For every n ≥ 2: (i) there are 2h − n leaves, all showing value 1, at the level h − 1, 38Cf. [3], Sec. 5.3.1 Ex. 20 page 195. Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV)16 and (ii) there are n − 2h−1 non-leaves, all showing value 2, at the level h − 1, (iii) there are 2n − 2h 39 nodes, all leaves showing value 1, at the level h of the recursion tree Tn, where h is the depth40 of Tn. Proof in [9]. (cid:50) (25) 7. A derivation of W (n) without references to the recursion tree In order to formally prove Theorem 4.1 without any reference to the recursion tree, I use here the well-known41 recurrence relation (cid:101)) + n − 1 if n ≥ 2 W (n) = W ((cid:98) n 2 (cid:99)) + W ((cid:100) n 2 (26) that easily follows from the description (Algorithm 3.1 page 5) of MergeSort, steps 2a, 2c and Theorem 3.3. I am going to prove, by direct inspection, that the function W (n) defined by (6) satisfies equations (25) and (26). W (1) = 0 The details of the proof are in [9]. 8. Other work Although some variants of parts of the formula (6) appear to have been known for quite some time now, even otherwise precise texts offer derivations that leave room for improvement. For instance, the recurrence relation for MergeSort analyzed in [4] asserts that the least number of comparisons of keys performed outside the recursive calls, if any, that suffice to sort an array of size n is n rather than n − 1. This seemingly inconsequential variation i=1 ((cid:98)lg i(cid:99)+2) 42 on page 2, Exercise 1.4, rather i=1(cid:100)lg i(cid:101) derived in this paper. (Also, results in a solution W (n) =(cid:80)n−1 than the correct formula (5) W (n) =(cid:80)n 39This value shows in the lower right corner of Figure 2 page 7 of a sketch of the recursion tree Tn; it was not need needed for the derivation of the main result (6) page 8, included for the sake of completeness only. 40The level number of the last non-empty level of Tn. 41For instance, derived in [1] and [2]. 42I saw W (n) =(cid:80)n−1 i=1 (cid:98)lg i(cid:99) on slides that accompany [4]. Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV)17 the relevant derivations presented in [4], although quite clever, are not nearly as precise and elementary as those presented in this paper.) As a result, the fact that MergeSort performs exactly the same number of comparisons of keys as does another classic, binary insertion sort, considered by H. Steinhaus and analyzed in [3], remains unnoticed. Pages 176 -- 177 of [2] contain an early sketch of proof of W (n) = nh − 2h + 1, (27) where h is the depth of the recursion tree Tn, with remarkably close43 bounds given by (28) page 18. It is similar44 to a simpler derivation based on the equality (3), presented in this paper in Section 4 and outlined in (5) page 8 i=1(cid:100)lg i(cid:101) part), which it predates by several years. (except for the(cid:80)n The [2]'s version of the decision tree Tn (Figure 4.14 page 177 of [2], shown here on Figure 5) was a re-use of a decision tree for the special case of n = 2(cid:98)lg n(cid:99), with an ambiguous, if at all correct45, comment in the caption that "[w]henever a node size parameter is odd, the left child size parameter is rounded up46 and the right child size is rounded down47." The proof of the fact, needed for the derivation in [2], that Tn had no leaves outside its last two levels (Corollary 6.8 page 15, not needed for the derivation presented in Section 4) was waved with a claim "[w]e can48 determine that [...]" 43Although not 100 percent correct. 44The idea behind the sketch of the derivation in [2] was based on an observation that h−2(cid:88) i=0 W (n) = (n − 2i) + n − B 2 , where B was the number of leaves at the level h − 1 of the decision tree Tn; it was sketchily derived from the recursion tree shown on Figure 5 and properties stated in the Corollary 6.9 page 15 (with only a sketch of proof in [2]) not needed for the derivation presented in Section 4. 45It may be interpreted as to imply that for any level k, all the left-child sizes at level k are the same and all the right-child sizes at level k are the same, neither of which is a valid statement. 46Should be: down, according to (25) page 16. 47Should be: up, according to (25) page 16. 48This I do not doubt. Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV)18 Figure 5: A snapshot from [2], page 177, showing a decision tree for MergeSort. Note: This picture is copyrighted by Addison Wesley Longman (2000). It was reproduced here from [2] for criticism and comment purposes only, and not for any other purpose, as prescribed by U.S. Code Tittle 17 Chapter 1 para 107 that established the "fair use" exception of copyrighted material. Although h was claimed in [2] to be equal to (cid:100)lg(n+1)(cid:101) 49 (and not to the correct (cid:100)lg n(cid:101) given by the equality (21) page 13, a fact not needed for the derivation presented in Section 4), somehow the mostly correct conclusion50 was inferred from it, however, with no details offered - except for a mention that a function α that satisfies h = lg n + lg α, similar to function ε shown on Figure 3 page 10, was used. It stated that (Theorem 4.6, page 177, in [2]): (cid:100)n lg n − n + 1(cid:101) ≤ W (n) ≤ (cid:100)n lg n − 0.914n(cid:101). (28) It follows from (20) page 13 that the constant 0.914 that appears in (28) is incorrect. It was a rounding error51, I suppose, that produced a false upper bound52. for W (n) and precluded concluding the neat characterization W (n) =(cid:80)n 49Which claim must have produced an incorrect formula n(cid:100)lg(n + 1)(cid:101) − 2(cid:100)lg(n+1)(cid:101) + 1 50Almost identical with (19) page 13, except for the constant 0.914. 51Of 1 − δ, where δ is given by (10) page 10. 52For instance, if n = 11 then MergeSort performs 29 comparisons of keys while the i=1(cid:100)lg i(cid:101). Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV)19 9. Best-case analysis of MergeSort It turns out that derivation of minimum number B(n) of comps performed by MergeSort on an n-element array is a bit more tricky. A formula (cid:98)lg n(cid:99)(cid:88) k=0 ((cid:98)lg n(cid:99) + 1) − n 2 2kZigzag ( n 2k+1 ), (29) where Zigzag(x) = min(x − (cid:98)x(cid:99),(cid:100)x(cid:101) − x), has been derived and thoroughly analyzed in [8]. It has been also demon- strated in [8] that there is no closed-form formula for B(n). Incidentally, as it was pointed out in [8] , B(n) is equal to the sum A(n, 2) of bits in binary representations of all integers < n. value of the upper bound (cid:100)n lg n − .914n(cid:101) given in [2], Theorem 4.6. p. 177, is 28; this is a significant error as 28 or less comps while sorting any 11-element array beats the binary insertion sort that requires(cid:80)11 i=1(cid:100)lg i(cid:101) = 29 comps in the worst case. Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV)20 Appendix A. A Java code of MergeSort Figure A.6 shows a Java code of MergeSort. Figure A.6: A Java code of MergeSort. A code of Merge is shown on Figure 1. Appendix B. Generating worst-case arrays for MergeSort Figure B.7 shows a self-explanatory Java code of recursive method unSort that given a sorted array A reshuffles it, in a way resembling InsertionSort53, onto a worst-case array for MergeSort. For instance, it produced this array of integers between 1 and 500: 1, 500, 2, 3, 4, 7, 5, 6, 8, 15, 9, 10, 11, 14, 12, 13, 16, 31, 17, 18, 19, 22, 20, 21, 23, 30, 24, 25, 26, 29, 27, 28, 32, 62, 33, 34, 35, 38, 36, 37, 39, 46, 40, 41, 42, 45, 43, 44, 47, 61, 48, 49, 50, 53, 51, 52, 54, 60, 55, 56, 57, 59, 58, 63, 124, 64, 65, 66, 69, 67, 68, 70, 77, 71, 72, 73, 76, 74, 75, 78, 92, 79, 80, 81, 84, 82, 83, 85, 91, 86, 87, 88, 90, 89, 93, 123, 94, 95, 96, 99, 97, 98, 100, 107, 101, 102, 103, 106, 104, 105, 108, 122, 109, 110, 111, 114, 112, 113, 115, 121, 116, 117, 118, 120, 119, 125, 249, 126, 127, 128, 131, 129, 130, 132, 139, 133, 134, 135, 138, 136, 137, 140, 155, 141, 142, 143, 146, 144, 145, 147, 154, 148, 149, 150, 153, 151, 152, 156, 186, 157, 158, 159, 162, 160, 161, 163, 170, 164, 53Although not with InsertionSort's sluggishness; the number of moves of keys it performs is only slightly more than the minimum number (29) of comps performed by MergeSort on any n-element array. Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV)21 Figure B.7: A Java code of unSort that, given a sorted array A, reshuffles it onto a worst- case array for MergeSort. Its structure mimics the Java code of MergeSort shown on Figure A.6. 165, 166, 169, 167, 168, 171, 185, 172, 173, 174, 177, 175, 176, 178, 184, 179, 180, 181, 183, 182, 187, 248, 188, 189, 190, 193, 191, 192, 194, 201, 195, 196, 197, 200, 198, 199, 202, 216, 203, 204, 205, 208, 206, 207, 209, 215, 210, 211, 212, 214, 213, 217, 247, 218, 219, 220, 223, 221, 222, 224, 231, 225, 226, 227, 230, 228, 229, 232, 246, 233, 234, 235, 238, 236, 237, 239, 245, 240, 241, 242, 244, 243, 250, 499, 251, 252, 253, 256, 254, 255, 257, 264, 258, 259, 260, 263, 261, 262, 265, 280, 266, 267, 268, 271, 269, 270, 272, 279, 273, 274, 275, 278, 276, 277, 281, 311, 282, 283, 284, 287, 285, 286, 288, 295, 289, 290, 291, 294, 292, 293, 296, 310, 297, 298, 299, 302, 300, 301, 303, 309, 304, 305, 306, 308, 307, 312, 373, 313, 314, 315, 318, 316, 317, 319, 326, 320, 321, 322, 325, 323, 324, 327, 341, 328, 329, 330, 333, 331, 332, 334, 340, 335, 336, 337, 339, 338, 342, 372, 343, 344, 345, 348, 346, 347, 349, 356, 350, 351, 352, 355, 353, 354, 357, 371, 358, 359, 360, 363, 361, 362, 364, 370, 365, 366, 367, 369, 368, 374, 498, 375, 376, 377, 380, 378, 379, 381, 388, 382, 383, 384, 387, 385, 386, 389, 404, 390, 391, 392, 395, 393, 394, 396, 403, 397, 398, 399, 402, 400, 401, 405, 435, 406, 407, 408, 411, 409, 410, 412, 419, 413, 414, 415, 418, 416, 417, 420, 434, 421, 422, 423, 426, 424, 425, 427, 433, 428, 429, 430, 432, 431, 436, 497, 437, 438, 439, 442, 440, 441, 443, 450, 444, 445, 446, 449, 447, 448, 451, 465, 452, 453, 454, 457, 455, 456, 458, 464, 459, 460, 461, 463, 462, 466, 496, 467, 468, 469, 472, 470, 471, 473, 480, 474, 475, 476, 479, 477, 478, 481, 495, 482, 483, 484, 487, 485, 486, 488, 494, 489, 490, 491, 493, 492. Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV)22 It took my MergeSort 3,989 comps to sort it. Of course, 500(cid:100)lg 500(cid:101) − 2(cid:100)lg 500(cid:101) + 1 = 4, 500 − 512 + 1 = 3, 989. Appendix C. Notes from my Analysis of Algorithms lecture Below are some of the class digital notes I wrote while lecturing Analysis of Algorithms in Spring 2012, with some comments added after class. Fig- ure 4.14 (decision tree) is from the course textbook [2], page 177, showing a decision tree for MergeSort. Note: This figure is copyrighted by Ad- dison Wesley Longman (2000). I used it transformatively in my class for nonprofit education, criticism, and comment purposes only, and not for any other purpose, as prescribed by U.S. Code Tittle 17 Chapter 1 para 107 that established the "fair use" exception of copyrighted material. Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV)23 Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV)24 Below is the improved recursion tree (of the Figure 4.14 page page 177 of [2]) that I used in class in Spring 2012. In Spring 2010 and before, I was deriving the equality (3) on page 8 during my lectures directly from the recurrence relation (25), (26) on page 16. References [1] S. Baase, Computer Algorithms: Introduction to Design and Analysis, Addison-Wesley Publishing, 2nd ed., 1991. Suchenek: Elementary Yet Precise Worst-case Analysis of MergeSort (SV)25 [2] S. Baase and A. V. Gelder, Computer Algorithms; Introduction to Design & Analysis, Asddison Wesley, 3rd ed., 2000. [3] D. E. Knuth, The Art of Computer Programming, vol. 3, Addison- Wesley Publishing, 2nd ed., 1997. [4] R. Sedgewick and P. Flajolet, An Introduction to the Analysis of Algorithms, Pearson, 2013. [5] H. Steinhaus, Mathematical Snapshots, Oxford University Press, 1950. [6] P. K. Stockmeyer and F. F. Yao, On the optimality of linear merge, SIAM Journal on Computing, 9 (1980), p. 85 -- 90. [7] M. A. Suchenek, A complete verifcation heapsort with http://arxiv.org/abs/1504.01459, (2015). experimental worst-case of its analysis results of (MS), [8] [9] , Best-case analysis of MergeSort with an application to the sum of digits problem (MS), http://arxiv.org/abs/1607.04604, (2016). , Elementary yet precise worst-case analysis of MergeSort (MS), http://csc.csudh.edu/suchenek/Papers/Analysis_of_MergeSort.pdf, (2017). c(cid:13)2017 Marek A. Suchenek. All rights reserved by the author. A non-exclusive license to distribute this article is granted to arXiv.org.
1006.1231
3
1006
2013-10-10T18:58:29
On the Insertion Time of Cuckoo Hashing
[ "cs.DS" ]
Cuckoo hashing is an efficient technique for creating large hash tables with high space utilization and guaranteed constant access times. There, each item can be placed in a location given by any one out of k different hash functions. In this paper we investigate further the random walk heuristic for inserting in an online fashion new items into the hash table. Provided that k > 2 and that the number of items in the table is below (but arbitrarily close) to the theoretically achievable load threshold, we show a polylogarithmic bound for the maximum insertion time that holds with high probability.
cs.DS
cs
On the Insertion Time of Cuckoo Hashing ∗ Nikolaos Fountoulakis University of Birmingham, School of Mathematics Edgbaston, B15 2TT, United Kingdom [email protected] Konstantinos Panagiotou Ludwig-Maximilians-Universitat, Mathematics Institute Theresienstr. 39, 80333 Munchen, Germany [email protected] Angelika Steger Institute of Theoretical Computer Science ETH, 8092 Zurich, Switzerland [email protected] May 29, 2018 Abstract Cuckoo hashing is an efficient technique for creating large hash tables with high space utilization and guaranteed constant access times. There, each item can be placed in a location given by any one out of k different hash functions. In this paper we investigate the random walk heuristic for inserting in an online fashion new items into the hash table. Provided that k ≥ 3 and that the number of items in the table is below (but arbitrarily close) to the theoretically achievable load threshold, we show a polylogarithmic bound for the maximum insertion time that holds with probability 1 − o(1) as the size of the table grows large. 1 Introduction Hash tables are widely used in applications that need efficient data structures supporting the insertion, deletion, and lookup of elements. A key issue in the use of hash-tables is the handling of collisions. One particular technique that has attracted quite a bit of attention is the so-called cuckoo hashing, which is based upon the paradigm of the power of many choices [1, 20]. The term cuckoo hashing was coined by Pagh and Rodler in [22]. In this work we consider a generalization of it, as it was described by Fotakis, Pagh, Sanders and Spirakis in [11]. We are given a table T with n locations, and we assume that each location can hold one item. Further settings where two or more items can be stored in each location have also been ∗This paper was written while the first two authors were affiliated with Max-Planck-Institute for Informatics, and while the third author was on sabbatical leave at the Max-Planck-Institute for Informatics. It has been accepted for publication in the SIAM Journal on Computing. 1 studied, see e.g. [2, 7, 10, 14], but we will not treat those cases here. Moreover, we are given k ≥ 2 hash functions h1, . . . , hk that map any element from a universe U of items to k (not necessarily distinct) positions in the table T . Each given item can be stored at any position dictated by one out of those k functions. As in many previous works, we also assume that h1, . . . , hk are independent and uniformly random functions hi : U → T ; this assumption, though not being satisfactory from a practical point of view, is necessary in several of our arguments. In his survey [19] Mitzenmacher outlined a number of open problems that remain to be solved in order to improve our understanding of the power of cuckoo hashing from a theoretical point of view. Among these is the issue of space utilization and the search for good upper bounds for the time needed to insert new elements. The first point was recently solved independently by the first two authors [12, 13] as well as Frieze and Melsted [15]. The aim of this paper is to address the second point. Before we present our results we first need to outline the results from [12, 13, 15] in more detail. Load Thresholds A natural question in cuckoo hashing is the following. Let us denote by I ⊂ U the set of available items. As I increases, it becomes more and more unlikely that all items can be inserted into the table so that each item i is assigned to one of the k locations h1(i), . . . , hk(i). In other words, if I is "small" compared to n = T, then with high probability1, there is an assignment to the locations of the table that respects the k choices of each item. On the other hand, if I becomes "large", then such an assignment does not exist with high probability (trivially, this happens at the latest when n + 1 items are available). The important question is whether there is a critical size for I where the probability for the existence of a valid assignment drops abruptly in the limit as n → ∞ from 1 to 0, i.e., whether there is a load threshold for cuckoo hashing. More precisely, we say that a value c∗k is the load threshold for cuckoo hashing with k choices for each element if P(cid:18) there is an assignment of ⌊cn⌋ items to a table with n locations that respects the choices of all items (cid:19) n→∞→ (1, 0, if c < c∗k, if c > c∗k . (1.1) In the case k = 2 there is a natural connection with random graphs. Indeed, we may think of the n locations of T as the vertices of the graph, and of the items as edges that encode the two choices. If I = m we obtain the classical Erdos-R´enyi random (multi-)graph G∗n,m. The properties of this random graph are essentially those of the random graph Gn,m on n vertices and m distinct uniform random edges. Moreover, it easy to see by applying Hall's Theorem that Gn,m has no subgraph with more edges than vertices if and only if all items can be assigned to one of their preferred locations such that no location is assigned more than one item. It is well-known that the property "Gn,m has a subgraph with more edges than vertices" coincides with the emergence of a giant connected component that contains a linear fraction of the vertices, see e.g. [17]. As the latter is known to happen when m crosses n/2, we readily obtain that the load threshold for cuckoo hashing and k = 2 is at c∗2 = 1/2. In other words, at most half of the table can be filled in a way that respects the choices of all items. The cases k ≥ 3 are very different from k = 2. Tight results were obtained independently by the first two authors [12, 13], as well as by Frieze and Melsted [15]. Moreover, Dietzfelbinger 1i.e., with probability 1 − o(1) as n → ∞ 2 k = ξ∗(1 − e−ξ∗ 1 − e−ξ∗ − ξ∗e−ξ∗ . ) (1.2) et al. [6] related the load threshold for cuckoo hashing to the satisfiability threshold of the k-XORSAT problem. Theorem 1.1. For any integer k ≥ 3 let ξ∗ be the unique solution of the equation ξ∗ Then c∗k = In particular, if there are ⌊cn⌋ items, then the following hold with high probability. k(1−e−ξ∗ )k−1 is the load threshold for cuckoo hashing with k choices per element. 1. If c < c∗k, then there is an assignment of the items to a table with n locations that respects the choices of all items. 2. If c > c∗k, then such an assignment does not exist. . = 0.917, c∗4 Numerically we obtain for example that c∗3 . =" indicates that the values are truncated to the last digit shown. Moreover, a simple calculation reveals that c∗k = 1 − e−k + o(e−k) for k → ∞. Fast Insertion Note that Theorem 1.1 is non-algorithmic: it states that whenever the load of the hash-table is below the load threshold, then there exists with high probability an assignment such that each item is allocated to one of the k positions given by the hash functions. The theorem does not, however, address the question whether such an assignment can actually be found efficiently. This is the problem that we address in this paper. . = 0.992, where " . = 0.976 and c∗5 More specifically, we study the distribution of the time that is needed to add an item into the table, assuming that some number of given items have already been allocated. We consider the following natural randomized insertion procedure, which is also known as the "random-walk insertion heuristic". When we want to add a new item i to the table, we first choose randomly one location among h1(i), . . . , hk(i). If that location is free, i can be placed immediately and the algorithm terminates. If not, the item occupying the chosen location has to be displaced and is moved to a random location among its remaining k− 1 choices to make room for i. This item in turn may need to displace another item, and so on. Consequently, inserting an item will require a sequence of moves, each maintaining the property that every item remains in one of its k potential locations, until no further displacements are needed. The algorithm is described formally in the next section. The random-walk insertion heuristic was introduced and simulated in [11] as a randomized counterpart of the deterministic breadth-first search for a free location to insert the new item. We refer the reader to that paper for a detailed discussion about the origins of the method and many references to related work. Note that the random-walk insertion heuristic may fail in several different ways. In particular, if it is not possible to add the new item to the table, it will get stuck in an infinite sequence of displacements of items. Moreover, since the heuristic acts only 'locally', there is no way of detecting such an undesirable situation. On the other hand, Frieze, Melsted and Mitzenmacher [16] studied this algorithm and showed that such 'bad' situations occur only very rarely. In particular, they showed that the running time, i.e., the number of displaced items, is polylogarithmic with high probability provided k ≥ 8 and the load of the hash-table is not too close to the threshold c∗k. The main theorem of our paper states that the random-walk insertion heuristic actually succeeds in polylogarithmic time with high probability for any number of inserted items arbitrarily close to the load threshold and for all k ≥ 3. 3 Theorem 1.2. For any ζ > 0 the following is true. Let 0 < ε < 1, and for k ≥ 3 set c = k+log(k−1) (k−1) log(k−1) . For any set of m = ⌊(1 − ε)c∗kn⌋ items of the universe U , if the hash functions h1, . . . , hk are independent and uniformly distributed over a table with n locations, then with probability 1 − o(1) each of the items will be inserted into the table in time O(log2+c+ζ n). Observe that c . = 2.66 for k = 3, c simple calculation shows that c = 1 running time thus also improves upon that from [16], which is greater than 2 + 2c. log k + O( 1 . = 1.54 for k = 4 and c . = 1.15 for k = 5. Moreover, a k ) as k grows. Our exponent in the bound of the As a last remark, note that for k = 2 the random-walk insertion heuristic is a deterministic algorithm. The total running time to insert a given number of elements was studied in the papers by Devroye and Morin [5] and in great detail by Drmota and Kutzelnigg [8]. In particular, these papers show that the running time is linear in the number of inserted elements. We conjecture that for k ≥ 3 this should also be the case. Outline Our proof of Theorem 1.2 develops further some ideas from [16] and combines them with several new structural properties of random hypergraphs. In Section 2 we introduce some basic facts and relate cuckoo hashing to random hypergraphs and orientations of their edge sets. A general outline of the argument can be found there. In particular, it turns out that a crucial property needed in the analysis is that such a random hypergraph has no "dense spots", i.e., no subgraphs that have a density (fraction of edges to vertices) that is much larger than the density of the whole graph, c.f. Theorem 2.2. In Section 3, which is formulated entirely in random graph jargon, we prove Theorem 2.2. Finally, in Section 4 we prove some additional auxiliary properties of random hypergraphs. 2 The Insertion Algorithm and its Analysis 2.1 Random-Walk Insertion & Random Hypergraphs We begin with a formal description of the random-walk insertion heuristic. We assume that there are k ≥ 3 hash functions h1, . . . , hk that map a universe U to the n locations of a hash table T . We denote by T (i) the contents of the ith location of T , and we write T (i) = ∅ if the ith location is empty. Also, if e is an item that has been inserted into the table, we denote by I(e) the index of the hash function that e currently uses, i.e., T (hI(e)(e)) = e. With these definitions at hand we are able to present in the following table a formal description of the insertion algorithm exposed in the introduction. Our analysis of this algorithm begins with describing the allocation of elements in terms of certain operations on hypergraphs. More specifically, the hash table of size n corresponds to a set of n vertices, and the k locations h1(i), . . . , hk(i) of an item i correspond to a hyperedge of size (at most) k. As we assume that the hash functions are truly random, a set of m elements gives rise to a k-uniform random multi-hypergraph H∗n,m,k with vertex set Vn = {1, . . . , n} and m edges, each one chosen independently and uniformly at random with replacement among all k-multisubsets of the vertex set. Note that in this definition of H∗n,m,k we actually interpret the word "multi" in two ways: (i) an edge has size k, but may contain a particular vertex several times, and (ii) the edge set of H∗n,m,k may be a multiset, i.e., a particular edge may occur multiple times. With slight abuse of terminology, we say that a multi-hypergraph H = H(V, E) with vertex set V and edge set E is a k-graph if it is k-bounded, that is, every hyperedge is a subset 4 algorithm Insert(T , I, e) – Insert e into T using the random-walk heuristic SUC ← FALSE; j ← 0; repeat Choose uniformly at random i ∈ {1, . . . , k} \ {j}; I(e) ← i; if T (hi(e)) 6= ∅ then 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 until SUC = TRUE e′ ← T (hi(e)); j ← I(e′); T (hi(e)) ← e; e ← e′; T (hi(e)) ← e; SUC ← TRUE; else endif of V with at most k vertices. Observe, that the random hypergraph H∗n,m,k corresponds in a natural way to a k-graph, by projecting each ordered k-tuple of vertices that forms an edge in H∗n,m,k to the set of vertices contained in this k-tuple. In what follows, we will be using the symbol H∗n,m,k to denote both objects; each time the interpretation should be clear from the context. Notation Let H = H(V, E) be a multi-hypergraph. In the rest of the paper we will use the following notation. The density of H is the ratio E/V . Moreover, for any V ′ ⊆ V we write H[V ′] for the subgraph of H induced by V ′, i.e., H[V ′] has vertex set V ′ and its edges are those edges in E that contain vertices only from V ′. We will also write EH (V ′) for the edge set of H[V ′] and eH (V ′) = EH(V ′). We will omit the subscript if the graph we refer to is clear from the context. Finally, slightly abusing notation, we will say that the density of V ′ is eH(V ′)/V ′, again if the reference to H is clear from the context. 2.2 Orientations and the o-neighborhood of a Vertex For a k-graph H = H(V, E) with E ≤ V an injective mapping o : E → V such that o(e) ∈ e for all e ∈ E is called an orientation. For e ∈ E and v ∈ e we will say that e is oriented to v if o(e) = v. Observe that in the setting of cuckoo hashing an orientation corresponds to a proper assignment of the items to locations in the hash table, i.e., such that each location contains at most one item, and each item is assigned to a location that is prescribed by one of the k hash functions. Similarly, the random-walk insertion heuristic can be viewed as a random walk on the vertex set of the corresponding k-uniform hypergraph. If we want to stress that the random walk starts with a particular assignment that corresponds to an orientation o, we also speak of an o-random walk on the vertex set of the hypergraph H. Before we proceed with the proof of Theorem 1.2 in the next section we need to collect some basic properties of orientations and fix some necessary notation. Given an orientation o of a hypergraph H, we denote by Fo(H) the set of free vertices, that is, vertices to which no edge is oriented to. We call the remaining vertices occupied. Furthermore, we will define certain 5 quantities that describe how 'far' a given vertex is from Fo(H). Formally, for any v ∈ V let the first o-neighborhood N o,1(v; H) be the set of vertices in the edge oriented to v, excluding v itself, i.e, N o,1(v; H) = {u ∈ e : o(e) = v and u 6= v}. More generally, the tth o-neighborhood of v contains all vertices in any edge that is ori- ented to some vertex of the (t − 1)st o-neighborhood of v, excluding all vertices in previous neighborhoods. Formally, we have N o,t(v; H) =(cid:8)u ∈ e : o(e) ∈ N o,t−1(v; H)(cid:9) \ t−1[j=1 N o,j(v; H). We also define the 0th o-neighborhood of v to be v itself. Moreover, we write No,t(v; H) = ∪t j=0N o,j(v; H) and No,t(v; H) = No,t(v; H). We will omit the reference to H if the hyper- graph that we refer to is clear from the context. Finally, if v is a vertex of H and S ⊆ V , then the o-distance of S from v is defined by do(v, S; H) = min{t : No,t(v) ∩ S 6= ∅}, i.e., it is the smallest t such that No,t(v) contains some vertex is S. Note that the o-distance provides a way to measure the complexity, i.e., the number of items that have to be displaced, of an o-random walk. Indeed, if do(v, Fo) = d, then inserting a new item at location v requires (deterministically) the displacement of at least d items. Note also that for t ≥ 1 the definition implies that the tth neighborhood of any vertex can contain at most (k − 1)t vertices. Thus, by summing up a geometric series we get the bound (2.1) No,t(v) ≤ (k − 1)t+1. 2.3 Proof of Theorem 1.2: Analysis of the Insertion Algorithm Before we proceed with the actual proof details, let us give a rough sketch of the main argument. Assume that 0 ≤ m ≤ ⌊(1 − ε)c∗kn⌋ items I1, . . . , Im ∈ U are given, together with the values of the k hash functions. Then the above discussion implies that the corresponding hypergraph is distributed like H∗n,m,k, where the m items correspond to the m edges. Let us fix the realization of H∗n,m,k that we denote by H for brevity. We will bound the insertion time under the assumption that the hypergraph satisfies some properties holding with high probability that we will state explicitly. In particular, these properties will guarantee that H and (thus) all of its subgraphs have an orientation. Let Hj = Hj(Vn, Ej) be the subgraph of H on the same vertex set, which includes only the edges that correspond to the first j items I1, . . . , Ij, and let oj : Ej → Vn be any orientation of Hj. Subsequently, we will argue that if H has this set of desired properties, then with probability at least 1 − O(n−1−ζ/2) the oj-random walk will displace at most O(log2+c+ζ n) items before inserting Ij+1 successfully. This implies the statement of the theorem. Suppose that the edge corresponding to Ij+1 is initially allocated to v ∈ Vn, and assume that v is occupied; otherwise there is nothing to show. Following the arguments in [16] we will consider a decomposition of the vertex set Vn into two sets according to the oj-distance of Foj from each vertex. In particular, for some C > 0, we let S ⊆ Vn be the set of vertices v ∈ Vn such that doj (v, Foj ) ≤ C and let B = Vn\ S. In the work of Frieze et al. [16] the parameter C 6 was of order log log n. In contrast, for our analysis, it is sufficient that doj (v, Foj ) is bounded, and this has also the additional benefit that it allows us to shave off some logarithmic factors from the resulting running time. We show that C can be chosen such that S covers almost all of the hypergraph. Note that if v ∈ S, then the definition of S implies that there is at least one free vertex within oj-distance C from v, and the oj-random walk will thus hit a free vertex with proba- bility at least 1/(k − 1)C within the next C steps. In order to treat the case v 6∈ S we will first show that certain expansion properties of H (that hold with high probability for H∗n,m,k) guarantee that the oj-neighborhood up to oj-distance roughly logk−1 n from v grows almost like a (k − 1)-regular hypertree. This, in turn, will then allow us to show that for vertices v 6∈ S the oj-random walk will hit S with reasonably high probability after a logarithmic number of steps. In the next two subsections we define two properties of k-graphs, a density and an expansion property, and show that a random hypergraph H∗n,m,k has these properties with high probability. We also show that the density property implies that the set S is large, and that the expansion property implies that a random walk starting in a vertex not in S will hit S within a logarithmic number of steps with high probability. In Section 2.3.3 we then show how these two properties conclude the proof of Theorem 1.2. Our plan for the proof of Theorem 1.2 is thus as follows. 2.3.1 Density Properties Assume that H = H(V, E) is a k-graph. We define the following property. Property Dδ: For all ∅ 6= V ′ ⊆ V we have e(V ′) < (1 − δ)V ′. Note that if a k-graph has property Dδ for some δ > 0, then there exists an orientation as well; this follows immediately from Hall's theorem. The next proposition states that for any such orientation o, most of the vertices are such that the set of free vertices Fo is within bounded o-distance from them. This will be an important ingredient in the proof of Theorem 1.2, since for such vertices, the probability that the random-walk insertion heuristic finds the shortest sequence of displacements to some free vertex is bounded from below by a constant. Proposition 2.1. Let H = H(V, E) be a k-graph that has Property Dδ for some δ > 0. Let o : E → V be any orientation. Then, for all α > 0, there exists C = C(α, δ) > 0 and a set S ⊆ V with S ≥ (1 − α)V such that for every v ∈ S we have do(v, Fo) ≤ C. We defer the proof to Section 2.4. The next theorem states that H∗n,m,k has Property Dδ with high probability for some suitable δ > 0. Theorem 2.2. Let 0 < ε < 1, k ≥ 3 and suppose that m = ⌊(1 − ε)c∗kn⌋. There exists a δ = δ(ε, k) > 0 such that H∗n,m,k has property Dδ with probability 1 − o(1). We prove this theorem in Section 3. Together with Proposition 2.1 this gives us a statement about the typical structure of H∗n,m,k. Corollary 2.3. Let ε > 0, α > 0 and assume that m = ⌊(1 − ε)c∗kn⌋. Then there is a C = C(α, ε) > 0 such that every subgraph H = H(Vn, E) of H∗n,m,k has the following property with high probability. For any orientation o of H there exists a set S ⊆ Vn such that S ≥ (1− α)n and every v ∈ S satisfies do(v, Fo; H) ≤ C. 7 2.3.2 Expansion Properties The density properties described in the previous section will allow us to deal in the proof of Theorem 1.2 with insertions of new items at vertices that are at bounded o-distance from the set of free vertices. In order to deal with insertions at any other vertex we will consider a different set of structural properties of hypergraphs. For a set of edges E′ of a hypergraph H = H(V, E), we denote by V (E′) the set of vertices contained in edges of E′. We say that a k-graph H = H(V, E) has expansion property E, if it satisfies the following two conditions. Property E: 1. For all E′ ⊆ E with log log V < E′ < V /k we have V (E′) ≥ (k − 1 − xE ′)E′, where xs = logk((k−1)ek) logk(V /s)−1 . 2. For all E′ ⊆ E with E′ ≤ log log V we have V (E′) ≥ (k − 1)E′. Note that for any E′ ⊆ E we have V (E′) ≤ kE′, and moreover, if the graph with edge set E′ is connected, then even V (E′) ≤ (k− 1)E′. Property E thus guarantees that V (E′) is 'close' to this upper bound for all E′ ⊆ E, i.e., the graph around any given vertex expands rapidly. Certainly, the choice of the parameters in the definition of E is somehow arbitrary and not best possible. Nevertheless, they suffice for our arguments. In Section 4 we show the following statement. Proposition 2.4. If m ≤ c∗kn, then H∗n,m,k has Property E with high probability. Note also that if H has Property E, then all its subgraphs have also this property. Given an orientation o of a hypergraph and a vertex v, recall that No,t(v) is the number of vertices within o-distance at most t from v. In Section 4 we show the following statement, which quantifies how fast No,t grows as a function of t, if the given graph has Property E. Lemma 2.5. Let ζ > 0, k ≥ 3 and c = c(k) be as in Theorem 1.2. Then, for any β > 0 sufficiently small and for any n sufficiently large the following is true. Let H = H(V, E) be a k-graph with n vertices that has Property E, and let o : E → V be any orientation. If v ∈ V is such that there is no free vertex Set T = logk−1 n + (c + ζ) logk−1 logk−1 n. within o-distance T from v, then No,T (v) > βn. The proof can be found in Section 4. In other words, this lemma states that number of vertices with o-distance T from a given vertex v is Ω(n), provided that there is no free vertex within this o-distance. Intuitively, placing a new item at such a vertex v dominates the running time of the random-walk insertion heuristic, since in this case it is forced to displace (in the best case) at least T items. In order to show a similar statement about No,t for vertices that are 'close' to the set of free vertices we perform a simple technical modification. Given a hypergraph H = H(V, E) and an orientation o of its edges, we define an auxiliary hypergraph H′ = H′(V ′, E′) by replacing every free vertex of H by a (k − 1)-regular hypertree of depth T (on a new set of vertices) 8 rooted at this vertex. We extend o to an orientation o′ of the edges of H′ by orienting each new edge towards the root of its tree. Thus, the union of the leaves of each such tree are the free vertices of H′. Corollary 2.6. With the same assumptions as in Lemma 2.5 and H′ as in the previous paragraph we obtain for all v ∈ V that No′,T (v; H′) > βn. 2.3.3 Proof of Theorem 1.2 In this section we combine the statements of Corollary 2.3 and Corollary 2.6 to derive a high probability bound for the running time of the random-walk insertion heuristic. Assume that m = ⌊(1 − ε)c∗kn⌋. From Theorem 2.2 we know that there exists a δ = δ(ε, k) > 0 such that H∗n,m,k satisfies Property Dδ with high probability. In particular, H∗n,m,k has an orientation with high probability, and so do all of its subgraphs. From Proposition 2.4 we also know that H∗n,m,k satisfies Property E with high probability; similarly, all its subgraphs have Property E. We thus may assume that we begin with a certain realization of H∗n,m,k that has both properties, which, for convenience, we abbreviate by H. Let H = H(Vn, E) be any subgraph of H on the same vertex set. Fix any orientation o of its edges, and any ζ > 0. Thereafter, choose α small enough so that Corollary 2.6 can be applied (to H) with β = 2α and set C = C(α, ε) > 0 as in Corollary 2.3. Note that this also specifies the set S, i.e., S ⊆ Vn is such that S ≥ (1 − α)n and every v ∈ S satisfies do(v, Fo; H) ≤ C. Lemma 2.7. Assume that α, ζ, C and H, H, o are specified as above. Let T and c be defined as in Corollary 2.6 and Theorem 1.2. Then the probability that a o-random walk on H starting at a vertex v0 hits a free vertex within T + C steps is at least α (k − 1)−C (logk−1 n)−c−ζ. Proof. Let us consider the following stopping rule. Starting from v0, we walk either for T steps or until we hit a free vertex, whatever occurs earlier. If the latter is not the case, then we walk for C additional steps or until we hit a free vertex. We consider the same o-random walk on H′, that is, the o-random walk that starts at v0 and makes the same random choices as the one in H, and possibly new ones, if the random walk on H stopped at a free vertex. Let u be the vertex that has been reached after T steps. The growth property guaranteed by Corollary 2.6 implies that there are at least βn − αn ≥ αn vertices within o′-distance T from v0 in H′ that either belong to S or to one of the trees we added to H. The probability of hitting such a vertex after T steps is at least αn (k − 1)−T . If u 6∈ S, then u belongs to one of the trees that we added to H, and we conclude that the o-random walk on H has stopped before making T steps. If u ∈ S, then we stop the o-random walk in H′ but we continue it in H for another C steps or until a free vertex is found. The probability that we end up at a free vertex is at least (k − 1)−C , since the assumption that u belongs to S implies that there is at least one free vertex within o-distance C from u. Thus the probability of success is at least αn (k − 1)−T−C , and the proof is completed. To conclude the proof of Theorem 1.2, we split the o-random walk into phases, where a phase is either a window of duration T + C or until a free vertex was hit. We repeatedly use the above lemma to bound the number of unsuccessful phases, since it applies to any subgraph of H∗n,m,k and any orientation of it. More precisely, suppose that we are given any orientation o of some subgraph H of H∗n,m,k, and we want to extend o to the graph H plus some edge e that is in H∗n,m,k but not in H. (In the cuckoo hashing setting, this amounts 9 to the situation that we have already inserted a specific number of items in the table, and we want to add another item.) Suppose that we set o(e) = v0 ∈ e; v0 is chosen randomly among the vertices in e, but this is not important. If the first phase is unsuccessful, then the above statement applies with the starting vertex being the vertex in which the previous phase ended, say v1, and with a new orientation o1 of the hypergraph H with e and without the edge that was oriented to v1 before the last step of the o-random walk. The above arguments imply that for any ζ > 0 the probability that at least logc+1+2ζ n phases are unsuccessful given that a new item is inserted in v0 is O(1/n1+ζ ). As each phase lasts for T + C = O(log n) steps, we deduce that with probability 1− O(1/n1+ζ), the random walk inserts the new item within O(log2+c+2ζ n) steps. As the total number of inserted elements is O(n) this concludes the proof of Theorem 1.2. k−1 Remark Note that the same argument yields the bound O(log1+c+2ζ n) for the expected total number of steps performed by one o-random walk, since the number of unsuccessful phases is dominated by a geometric distribution. 2.4 Proof of Proposition 2.1: o-neighborhoods and the Density of a Hy- pergraph The main idea of the proof is as follows. As H has Property Dδ we know that Fo = V − E > δV . Suppose that we remove all free vertices and all edges that contain a free vertex. As the removal of any edge e that contains a free vertex generates a new free vertex, namely o(e), this process generates a subhypergraph of H, which is induced by V \ Fo, with a new set of free vertices. For this subhypergraph we can again use Property Dδ to deduce that the number of free vertices is at least a δ-fraction of the number of vertices. We repeat this stripping until we are left with less than αV vertices – and show that a constant number of rounds suffice. More formally, let F0 := Fo and L0 := V . Define inductively Li+1 = Li \ Fi and let Fi+1 be the set of free vertices in the hypergraph induced by Li+1. Since H has Property Dδ, it follows that F0 > δV = δL0. We claim that for all i ≥ 0 we have Fi+1 ≥ δLi+1 as well. The two crucial observations are: (i) Li+1 = e(Li), as Li+1 contains exactly the vertices that are the images (under o) of the edges in the hypergraph induced by Li. (ii) Fi+1 = e(Li) − e(Li+1), as every edge that belongs to the hypergraph induced by Li but not to the one induced by Li+1 generates exactly one free vertex in Fi+1. As H has Property Dδ we also know that e(Li+1) < (1 − δ)Li+1. Hence, Fi+1 Thus (ii) = e(Li) − e(Li+1) > e(Li) − (1 − δ)Li+1 = δLi+1. (i) Li+1 = Li − Fi < (1 − δ)Li for all i ≥ 0. To conclude the proof observe that this implies that for all t ≥ 1 Lt < (1 − δ)tL0 = (1 − δ)tV . Thereby, choosing t = ⌈log1−δ α⌉ we deduce that Lt < αV . Thus, we may take S := V \ Lt and C(α, δ) = ⌈log1−δ α⌉. 10 3 Proof of Theorem 2.2: the Subgraph Density of H∗n,m,k Towards the proof of Theorem 2.2 we begin with showing a lemma that will enable us to restrict our arguments to a specific subgraph of H∗n,m,k. In particular, we will consider the so-called core, which is the unique maximum subhypergraph of a given hypergraph H with minimum degree at least two. Of course, the core of H might contain no vertex. We will denote the core of H by C(H). The core is a well-studied object in the literature of random graphs and it has several applications in the analysis of algorithms, for example in the context of load balancing and hashing [2, 10, 12] or graph coloring [3]. In particular, the distribution of the number of vertices and edges in C(H∗n,m,k) is well-known, see e.g. [23, 4, 21, 18], and we will make extensive use of these results. A standard algorithm that reveals the core of a given hypergraph is the so-called stripping process and works as follows. We repeatedly choose an arbitrary vertex of degree at most one and we remove it from the graph, together with the single edge that it contains (if any). This process stops when there are no more available vertices of degree at most one; what remains is either an empty hypergraph with no vertices (if the core is empty), or, otherwise, the core itself. Lemma 3.1. Let H = H(V, E) be a k-graph where every edge contains at least two distinct vertices such that 1. C(H) has Property Dδ for some 0 < δ < 1/4 and 2. H has Property E. Then there exists ζ > 0 such that H itself has Property Dζδ. Proof. Let S ⊆ V . We set vS = S and we write eS for the number of edges in H[S]. Moreover, we write dS = eS/vS for the density of H[S]. We will show that for any S ⊆ V we have dS < 1− ζδ for some ζ > 0. Towards this goal we will make a case distinction depending on the number of edges eS. The first part of Property E implies that for all β ∈ (0, 1) there exists a 0 < γ < 1/k such that for all E′ ⊆ E with log log V < E′ ≤ γV we have V (E′) ≥ (k − 1 − β)E′. Setting β = 1/2, let γ = γ(1/2) be as above. Let us start with the case eS ≤ γV . The bound on the density of S can be deduced right away from Property E. Indeed, by using the first part of Property E, if eS > log log V , then vS ≥ (k − 1 − 1/2)eS , yielding dS = eS vS ≤ 1 k − 1 − 1/2 (k≥3) ≤ 2 3 . (3.1) Using the second part of Property E, if eS ≤ log log V , then vS ≥ (k−1)eS . A rearrangement yields dS = eS vS ≤ (k≥3) ≤ 1 2 . (3.2) Suppose now that eS > γV . We will make a further case distinction depending on the number of edges that belong to the core of H[S]. First, let us assume that there are at 1 k − 1 11 least γV /2 edges of H[S] that do not belong to the core of H[S]. To avoid unnecessary complications we will assume that H[S] is connected; clearly it is sufficient to argue about connected sets. Consider the stripping process on H[S]. This induces an ordering of the set of vertices of H[S] not belonging to the core; it is the ordering according to which these vertices are deleted from H[S]. Let v1, . . . , vt be this ordering for an integer t ≤ vS. Note that whenever we delete a vertex of degree one during the stripping process, this is accompanied by an edge that is deleted too, that is, the (single) edge that this vertex is contained in. Each one of the remaining k − 1 vertices of this edge either belongs to the core of H[S] or it appears in some position after the deleted vertex in the specified ordering. Let us now consider the ordering in reverse and let i be the minimum index such that the number of edges that contain vi, . . . , vt in the graph induced by vi, . . . , vt and the vertex set of C(H[S]) is ⌊γV /2⌋; there are s := t − i + 1 vertices there. Assuming that among them there are x vertices that were isolated at the point in time they were removed by the stripping process, we have s = ⌊γV /2⌋ + x. The first part of Property E implies that the number of vertices that are contained in these edges is at least (k − 1 − β)⌊γV /2⌋. Among these vertices at least (k − 1 − β)⌊γV /2⌋ − s = (k − 2 − β)⌊γV /2⌋ − x vertices must belong to the core of H[S]. Let S0 denote these vertices and let S1 denote the remaining vertices of the core of H[S]. In other words, S0 ≥ (k − 2− β)⌊γV /2⌋ − x. As the core of H[S] is a subgraph of the core of H, Property Dδ implies that the core of H[S] contains at most (1− δ)(S0 +S1) edges. Now we can write an upper bound on the density of S. We have dS = eS vS ≤ t − x + (1 − δ)(S0 + S1) t + S0 + S1 = 1 − x t + S0 + S1 − δ S0 + S1 t + S0 + S1 . x Using that t + S0 + S1 ≤ V we infer that eS vS ≤ 1 − V − δ So, ⌊γV /2⌋ ≥ γV /4 implies that V − δS0 V ≤ 1 − x (k − 2 − β)⌊γV /2⌋ − x V ≤ 1 − δ (k − 2 − β)⌊γV /2⌋ V . eS vS ≤ 1 − δ (k − 2 − β)γV 4V = 1 − δ(k − 2 − β)γ/4. (3.3) Finally, assume that less than γV /2 edges of H[S] do not belong to the core of H[S]. With eC(S) and vC(S) denoting the number of edges and vertices of the core of H[S], respec- tively, Property Dδ of the core of H implies that (1 − δ)vC(S) > eC(S) ≥ γV /2. (3.4) Since additionally t + eC(S) ≤ V we infer that eS vS ≤ t + eC(S) t + vC(S) ≤ t + (1 − δ)vC(S) = 1 − δ t + vC(S) vC(S) t + vC(S) (3.4) ≤ 1 − δ γV 2(1 − δ)V = 1 − δ γ 2(1 − δ) . Together with (3.1)–(3.3) the above inequality determines the value of ζ. Taking suffices. ζ := min(cid:26) 1 2 , γ 2(1 − δ) , (k − 2 − 1/2)γ 4 (cid:27) 12 The main ingredient in our proof is statement about the subgraphs of the core itself. Theorem 3.2. Let ε > 0 and suppose that m = ⌊(1−ε)c∗k n⌋, where c∗k is given in Theorem 1.1. Then, for sufficiently small ε, the core of H∗n,m,k has Property Dε3/2 with probability 1− o(1). The above theorem together with Proposition 2.4 and Lemma 3.1 yield Theorem 2.2. In the remainder of this section we prove Theorem 3.2. 3.1 Models of Random Hypergraphs Theorem 3.2 is stated for the H∗n,m,k model, where multiple edges are allowed, and also each edge can contain a vertex more than once. We start by arguing that it suffices to consider a slightly different random graph model. Let Hn,m,k denote a random hypergraph that is created by selecting m edges with k distinct vertices in each edge without replacement. Then the following is true. Proposition 3.3. Let k ≥ 3 and ε > 0 be sufficiently small. Assume that m = ⌊cn⌋, for some c > 0. If P(Hn,m,k has property Dε3) = 1 − o(1), then P(H∗n,m,k has property Dε3/2) = 1 − o(1) as well. Proof. First of all, recall that Proposition 2.4 implies that H∗n,m,k has Property E with prob- ability 1 − o(1). Therefore, sets of size at most γn, for some sufficiently small γ > 0, do not violate Property Dε3/2. So it is sufficient to argue only about sets with at least γn vertices. Let us call an edge in H∗n,m,k bad if it either has repeated vertices or if there is another edge that contains exactly the same vertices. For each of these edges we resample new edges until the resulting hypergraph contains m different edges with k distinct vertices in each. Note that this process yields Hn,m,k. A trivial calculation reveals that with probability 1 − o(1) the random hypergraph H∗n,m,k has at most log n bad edges. In the above process, sets with at least γn vertices may change their number of edges by at most log n. Thus, for n large enough, if Hn,m,k has the property Dε3 and there are at most log n bad edges, then H∗n,m,k must have property Dε3/2. The statement of the proposition follows. Thus, proving Theorem 3.2 for Hn,m,k (where we use ε3 instead of ε3/2) is sufficient. Our remaining proof strategy is inspired by the ideas in [12, 13], where it was shown that the core of Hn,m,k has property D0. Particularly, we develop further and adapt the arguments in that papers in order to show the stronger statement claimed in Theorem 3.2. We will use the following auxiliary statements about binomial coefficients. Proposition 3.4. Let H(x) = −x log x−(1−x) log(1−x) denote the entropy function. Then, for any 0 < α < 1 and δ < 1, as n → ∞ (cid:18) n αn(cid:19) = enH(α) 1 + o(1) p2πα(1 − α)n and (cid:18) n αn + δn(cid:19) ≤(cid:18) n αn(cid:19)enδ log(max{1/α,1/(1−α)}). Proof. The first statement is well-known and follows immediately from Stirling's approxima- tion of the factorial function; we omit the details. To see the second statement, let us first consider the case δ ≥ 0. We can assume that α + δ ≤ 1, as otherwise the statement holds trivially. Then (cid:0) n αn+δn(cid:1) αn(cid:1) = (cid:0) n δnYi=1 n − αn − i + 1 αn + i ≤(cid:18) (1 − α)n αn (cid:19)δn ≤ enδ log(1/α). 13 Similarly, for the case δ < 0 we obtain (cid:0) n αn−δn(cid:1) (cid:0) n αn(cid:1) = δn−1Yi=0 αn − i n − αn + i + 1 ≤(cid:18) αn (1 − α)n(cid:19)δn ≤ enδ log(1/(1−α)). For the sake of convenience we will carry out our calculations in the Hn,p,k model of ran- dom k-graphs. This is the "higher-dimensional" analogue of the well-studied Gn,p model, where, given n ≥ k vertices, we include each k-tuple of vertices with probability p, indepen- dently of every other k-tuple. Standard arguments show that if we adjust p suitably, then the Hn,p,k is essentially equivalent to Hn,cn,k. The following proposition makes this statement precise. Then Proposition 3.5. Let P be any property of hypergraphs, and let p = ck/(cid:0)n−1 Proof. Let N =(cid:0)n P (Hn,cn,k 6∈ P) ≤ O(√n) · P (Hn,p,k 6∈ P) . cn(cid:19)pcn(1 − p)N−cn (Prop. 3.4) k(cid:1), and note that pN = cn. Hence, P (Hn,p,k has cn edges) =(cid:18)N k−1(cid:1), where c > 0. = Θ(n−1/2). The claim then follows from P (Hn,cn,k 6∈ P) = P (Hn,p,k 6∈ P Hn,p,k has cn edges) ≤ P (Hn,p,k 6∈ P) P (Hn,p,k has cn edges) . In order to prove Theorem 3.2 it is therefore sufficient to show that the core of Hn,p,k has Property Dε3 with probability 1 − o(n−1/2). This is accomplished in the next sections. 3.2 Working on the Core of Hn,p,k: the Cloning Model Recall that the core of a hypergraph is the unique maximum subgraph that has minimum degree (at least) two. Note that studying properties of the core of a random hypergraph directly is a very difficult task, since the restriction on the minimum degree introduces several dependencies among the edges. At this point we introduce the main tool for our analysis, which provides an accurate description of the core of random hypergraphs. The cloning model with parameters (N, D, k), where N ≥ 1 and D ≥ 0 are random variables taking integral values, is defined as follows. We generate a graph in three stages. 1. We expose the value of N . 2. We expose the degrees d = (d1, . . . , dN ), where the di's are independent identically distributed as D. 3. For each 1 ≤ v ≤ N we generate dv copies, which we call v-clones or simply clones. Then we choose uniformly at random a matching from all perfect k-matchings on the set of all clones. Note that such a matching may not exist – in this case we choose a random matching that leaves less than k clones unmatched. Finally, we construct the graph Hd,k by contracting the clones to vertices, i.e., by projecting the clones of v onto v itself for every 1 ≤ v ≤ N . 14 Note that the last stage in the above procedure is equivalent to the configuration model Hd,k for random hypergraphs with degree sequence d = (d1, . . . , dn). In other words, Hd,k is a random multigraph where the ith vertex has degree di. We will consider a special case of the above model. The so-called Poisson cloning by Kim [18]. There, we choose N = n with probability 1, and the distribution D is the Pois- model eHn,p,k for k-graphs with n vertices and parameter p ∈ [0, 1], which was introduced k−1(cid:1). Note that here D is essentially the vertex degree son distribution with parameter λ := p(cid:0)n−1 distribution in the binomial random graph Hn,p,k, so we would expect that the two models behave similarly. The following statement confirms this, and is implied by Theorem 1.1 in [18]. Theorem 3.6. Let k ≥ 2 and suppose that p = Θ(n−k+1). Then there is a C > 0 such that for any property P of k-graphs P (Hn,p,k 6∈ P) ≤ C P(cid:16)eHn,p,k 6∈ P(cid:17)1/k + e−n. In other words, in order to prove Theorem 3.2 it is sufficient to show that the core of eHn,p,k has Property Dε3 with probability 1−o(n−k/2). Before we do so, let us collect some important properties of the Poisson cloning model. One big advantage of the Poisson cloning model is that it provides a very precise descrip- tion of the core. In particular, Theorem 6.2 in [18] implies the following statement, where we write "x ± y" for the interval of numbers (x − y, x + y). k−1(cid:1) > λk. Theorem 3.7. Let λk := minx>0 Moreover, let ¯x be the largest solution of the equation x = (1 − e−xck)k−1, and set ξ := ¯xck. Then the following is true with probability 1 − n−ω(1). If N2 denotes the number of vertices in the core of eHn,p,k, then Furthermore, the core itself is distributed like the cloning model ( N2, Po≥2(Λc,k), k), where Po≥2(Λc,k) denotes a Poisson random variable conditioned on being at least 2 and parame- ter Λc,k, where Λc,k = ξ + β, for some β ≤ δ. (1−e−x)k−1 , 0 < δ < 1, and c be such that ck = p(cid:0)n−1 N2 = (1 − e−ξ − ξe−ξ)n ± δn. x We shall say that a random variable is a 2-truncated Poisson variable, if it is distributed like a Poisson variable, conditioned on being at least 2. The next statement is taken from [13, Corollary 3.4]. Corollary 3.8. Let δ > 0. Let N2 and M2 denote the number of vertices and edges in the core of eHn,p,k, where p = ck/(cid:0)n−1 with probability 1 − n−ω(1), k−1(cid:1) and ck > λk, where λk is defined in Theorem 3.7. Then, N2 = (1 − e−ξ − ξe−ξ)n ± δn and M2 = ξ(1 − e−ξ) k(1 − e−ξ − ξe−ξ) N2 ± δn, In the following we will collect a few basic properties of the relation of the number of where ξ = ¯xck and ¯x is the largest solution of the equation x = (1 − e−xck)k−1. vertices and edges in the core of eHn,p,k. We define the functions x(1 − e−x) and g(x) = f (x) = x k(1 − e−x − xe−x) k(1 − e−x)k−1 15 and recall that c∗k and ξ∗ in Theorem 1.1 and also Theorem 3.2 are given by the solution of the system 1 = f (ξ∗) and c∗k = g(ξ∗). (3.5) An easy calculation shows that f (x) is an increasing function of x and infinitely differentiable over R+, and that g(x) has a unique minimum, which is obtained at x = xg. Moreover, g(xg) = λk/k, where λk is defined in Theorem 3.7. We shall need the following technical claim. Claim 3.9. xg < ξ∗. Proof. A simple calculation reveals that g′(x) = 1 − e−x − (k − 1)xe−x . k(1 − e−x)k (k−1)2 − 2 log(k−1) Let x0 = 2 log(k − 1). The numerator of g′(x0) is 1 − 1 to be greater than zero for all k ≥ 3. Hence g′(x0) > 0 and thus xg ≤ x0. In the remainder we argue that ξ∗ ≥ k/2, which settles the claim with x0 < k/2. Note that the monotonicity of f guarantees that it is enough to show that f (k/2) ≤ 1. Using the estimate ex ≥ 1 + x + x2/2, which is valid for all x ≥ 0 we obtain , which is easily seen k−1 2(cid:19) = f(cid:18) k 1 2 · ek/2 − 1 ek/2 − 1 − k/2 = 1 2(cid:18)1 + k 2(ek/2 − 1 − k/2)(cid:19) ≤ 1 2(cid:18)1 + 4 k(cid:19) . Note that for k ≥ 4 this expression is at most 1, thus concluding the proof in these cases. Finally, if k = 3, then numerical calculations imply that ξ∗ > 2.14 > 2 log 2. k−1(cid:1), where c = (1− ε)c∗k > λk/k, and set ξ = ¯xck, where ¯x is Let us assume that p = ck/(cid:0)n−1 the largest solution of the equation x = (1−e−xck)k−1. So, ξ is the largest solution of c = g(ξ), implying with the above claim that ξ < ξ∗. Therefore, we have f (ξ) < 1, and Corollary 3.8 guarantees that with probability 1 − n−ω(1) the density of the core of Hn,p,k is less than 1. This argument can be extended to obtain the following finer statement. Corollary 3.10. Let δ > 0 be sufficiently small and choose c > λk/k such that the largest solution ξ of the equation c = g(ξ) satisfies ξ = ξ∗ − δ, where ξ∗ is as in Theorem 1.1. Then there is an ε > 0 such that ε = Θ(δ) and c = (1 − ε)c∗k. Moreover, there is a constant ek > 0 such with probability 1 − n−ω(1) M2 = N2(1 − ekδ + Θ(δ2)). Proof. We first show that there is an ε > 0 with the claimed properties. Note that ξ is defined through the equation c = g(ξ) and ξ∗ through c∗k = g(ξ∗). Let xg be the minimizer of g, i.e., g(xg) = λk/k, and note that whenever x > xg we have g′(x) > 0. Applying Taylor's Theorem and using (3.5) we infer that there is a µ ∈ [ξ, ξ∗] such that c = g(ξ) = g(ξ∗) + g′(µ)(ξ − ξ∗) = c∗k − g′(µ)δ. So c = (1 − ε)c∗k, where ε = g′(µ) whenever δ is sufficiently small. c∗ k δ, and note that g′(µ) remains bounded for µ ∈ [ξ, ξ∗], 16 To see the claim for M2, note that Corollary 3.8 (where we use δ2 for δ) guarantees that with probability 1 − n−ω(1) we may assume that M2 = (f (ξ) ± δ2) N2. Moreover, Taylor's Theorem, this time applied to f , implies that f (ξ) = f (ξ∗) + f′(ξ∗)(ξ − ξ∗) + O((ξ − ξ∗)2) = 1 − f′(ξ∗)δ + O(δ2), thus concluding the proof with ek = f′(ξ∗) and the fact that f is increasing. We immediately obtain the following corollary. Corollary 3.11. Let k ≥ 3. Let ε > 0 be sufficiently small and suppose that p = (1 − ε)c∗kk/(cid:0)n−1 k−1(cid:1). Then, with probability 1 − n−ω(1) M2 ≤ (1 − ε2) N2. 3.3 Subgraphs of the 2-Core In order to obtain a sufficient bound for the probability that the core of eHn,p,k has property Dε3 we will exploit the following statement. Recall that for a hypergraph H = H(V, E) and S ⊆ V we denote by H[S] the subgraph induced by S, and we abbreviate eS = EH(S) for the number of edges in H[S]. Proposition 3.12. Let γ > 0 and let H = H(V, E) be a k-graph such that E < ⌊(1−γ)V ⌋. Moreover, let U be an inclusion maximal subset of V such that eU ≥ (1 − γ)U. Then eU = ⌈(1 − γ)U⌉ and all edges e ∈ E satisfy e ∩ U 6= k − 1. Proof. If eU > ⌈(1− γ)U⌉, then eU ≥ (1− γ)U + 1. Let U′ = U ∪{v}, where v is any vertex in V \ U . Note that such a vertex exists, as U 6= V . Moreover, denote by d the degree of v in U , i.e., the number of edges in H that contain v and all other vertices only from U . Then eU ′ = eU + d ≥ eU ≥ (1 − γ)U + 1. Note that U′ = U + 1. Hence, the above inequality implies that eU ′ ≥ (1 − γ)(U + 1) − (1 − γ) + 1 ≥ (1 − γ)U′, which contradicts the maximality of U . Similarly, if there was an edge e such that e ∩ U = k− 1, then we could construct a larger subset of VH that also satisfies the density requirement by adding the vertex in e \ U to U . Let γ > 0. The following lemma bounds the probability that a given subset of the vertices of the core is maximal and has density ≥ 1 − γ, assuming that the degree sequence has been exposed. That is, the randomness is that of the 3rd stage of the exposure process in the Poisson cloning model. A similar statement was shown in [12] for the special case γ = 0. Lemma 3.13. Let k ≥ 2, d = (d1, . . . , dN ) be a degree sequence and U ⊆ {1, . . . , N} such that Let 0 < γ < 1/4 and assume that 3N/4 < M < (1 − γ)N . If B(β, q; γ) denotes the event that U is an inclusion maximal set of Hd,k such that eU ≥ (1 − γ)U, then U = ⌊βN⌋, where 1/2 < β ≤ 1. Moreover, set M = k−1PN Pd,k(B(β, q; γ)) ≤ max(cid:26)1,(cid:18) M i=1 di and q = (kM )−1Pi∈U di. ⌊βN⌋(cid:19)(cid:27) · (2k − k − 1)M−βN · e−kM·H(q) · eO(γ log(1/γ)N ), where H(x) = −x ln x − (1 − x) ln(1 − x) denotes the entropy function, and Pd,k denotes the probability measure on the space of Stage 3, given the outcomes of the first two stages. 17 Proof. The graph Hd,k is obtained by creating di clones for each 1 ≤ i ≤ N and, thereafter, by choosing uniformly at random a perfect k-matching on this set of clones. Note that this is the same as throwing kM balls into M bins, with the condition that every obtains exactly k balls. We use this analogy to prove the claim as follows. Assume that we color the kqM clones of the vertices in U red, and the remaining k(1− q)M clones blue. So, by applying Proposition 3.12 we are interested in the probability of the event that there are exactly ⌈(1− γ)U⌉ bins with k red balls and no bin that contains exactly one blue ball. We estimate the probability for this event as follows. We start by putting into each bin k black balls, labeled with the numbers 1, . . . , k. Let K = {1, . . . , k}, and let X1, . . . , XM be independent random sets such that for 1 ≤ i ≤ M ∀K′ ⊆ K : P(cid:0)Xi = K′(cid:1) = qK′(1 − q)k−K′. Note that Xi is distributed like Bin(k, q). We then recolor the balls in the ith bin that are in Xi with red, and all others with blue. We infer that the total number of red balls is X =PM i=1 Xi. Set Z = P (X = kqM ) . Note that E (X) = kqM , and that X is distributed like Bin(kM, q). By applying Proposi- tion 3.4 we infer that Z = P (X = E (X)) = (1 + o(1))(2πq(1 − q)kM )−1/2. Let Rj be the number of Xi's that contain j elements, and set P = P (X = kqM ∧ Rk = ⌈(1 − γ)U⌉ ∧ Rk−1 = 0) . Let eU = ⌈(1 − γ)U⌉. By using the above notation we may estimate P (B(β, q; γ)) = P Z ≤ √2M · P (X = kqM ∧ Rk = eU ∧ Rk−1 = 0) . (3.6) Let pj = P (Xi = j) =(cid:0)k A = Then (b0, . . . , bk−2) ∈ Nk−1 : . k−2Xj=0 bj = M − eU and k−2Xj=0 b0, . . . , bk−2, 0, eU(cid:19) · P = X(b0,...,bk−2)∈A(cid:18) k−2Yj=0 (cid:18)M eU(cid:19)qkqM (1 − q)k(1−q)M ·(cid:18) M − eU j(cid:1)qj(1 − q)k−j. Moreover, define the set of integer sequences jbj = kqM − keU j  · peU b0, . . . , bk−2(cid:19) k−2Yj=0(cid:18)k j(cid:19)bj b0, . . . , bk−2(cid:19) k−2Yj=0(cid:18)k j(cid:19)bj X(b0,...,bk−2)∈A(cid:18) M − eU ≤ (2k − 1 − k)M−eU . pbj k . . M 18 By applying the multinomial theorem we obtain the bound Observe that the summand can be rewritten as Thus, from (3.6) we infer that for large M P (B(β, q; γ)) ≤ 2√M(cid:18)M The proof is completed by estimating(cid:0)M Then γ < 1/4 guarantees that eU(cid:19)qkqM (1 − q)k(1−q)M (2k − k − 1)M−eU . eU(cid:1). More specifically, assume first that U ≥ (1−γ)M . (cid:18)M eU(cid:19) ≤(cid:18) M 2γM(cid:19) ≤(cid:18) eM 2γM(cid:19)2γM = eO(γ log(1/γ)·N ). Otherwise, let us write U = ⌊βN⌋ = ηM , for some appropriate η ≤ 1− γ. Note that β > 1/2 and M < (1 − γ)N guarantee that η > 1/2. By applying Proposition 3.4 we obtain (cid:18)M eU(cid:19) =(cid:18) M (1 − γ)ηM(cid:19) ≤(cid:18) M ηM(cid:19)eM γη log(max{1/η,1/(1−η)}) =(cid:18) M U(cid:19)eO(γ log(1/γ)N ). With the above lemma at hand we are ready to estimate the number of subsets of vertices in the core of eHn,p,k that have density at least 1− ε3. Suppose that the degree sequence of the core C is given by d = (d1, . . . , dN2 ). Then, the number of edges in C is M2 = k−1PN2 i=1 di. For q, β ∈ [0, 1] let Xq,β = Xq,β(C) = Xq,β(d) denote the number of subsets of C with ⌊β N2⌋ vertices and total degree ⌊q· k M2⌋. (We will omit writing "⌊.⌋" from now on.) Note that Xq,β is a random variable that depends only on the outcomes of the first two stages of the exposure of the core. Let also Yq,β denote the number of these sets that are inclusion maximal and have density at least 1 − ε3. k−1(cid:1) be such that the largest solution ξ of the equa- Let δ > 0. Moreover, let p = ck/(cid:0)n−1 tion g(ξ) = c satisfies ξ = ξ∗ − δ, where g(ξ∗) = c∗k. By applying Corollary 3.10 we infer that there is a ε = Θ(δ) such that c = (1 − ε)c∗k. Moreover, Theorem 3.7 (where we use δ3 for δ) guarantees that with probability 1 − n−ω(1) N2 = n(1 − e−ξ − ξe−ξ) ± δ3n and Λc,k = ξ ± δ3, where ξ = ξ∗ − δ. Set n2 = (1 − e−ξ − ξe−ξ)n and m2 = and let A be the event ξ(1 − e−ξ) k(1 − e−ξ − ξe−ξ) n2 A : N2 = n2 ± δ3n and M2 = m2 ± δ3n. (3.7) Corollary 3.8 implies that P (A) = 1 − n−ω(1). Moreover, Corollary 3.10 guarantees the existence of a ek > 0 such that m2 = (1 − ekδ + Θ(δ2))n2. (3.8) We shall assume all the above facts in the remainder. We are ready to prove the main result of this section, which deals with sets with more than 0.7N2 vertices. Smaller sets are treated at the end of this section. 19 Lemma 3.14. With the notation above, let β ∈ [0.7, 1−ekδ/2] and let β ≤ q ≤ 1−2(1 − β)/k. Then, for sufficiently small δ > 0 P (Yq,β > 0) = n−ω(1). Moreover, when q < β or q > 1 − 2(1 − β)/k, the above probability is 0. Proof. The proof follows the arguments in [13], see Lemma 4.5 – Claim 4.11 there. We describe here all necessary steps and refer each time we need a statement from [13] at the appropriate position in that paper. Firstly, suppose that we have exposed the degree sequence d of the core. Markov's inequality implies that (3.9) where B(β, q; ε3) is as in Lemma 3.13. Note that for sufficiently small δ > 0, (3.8), the upper bound on β, and Proposition 3.4 imply P (Yq,β > 0 d) ≤ Xq,β(d)Pd,k(B(β, q; ε3)), (cid:18) m2 ± δ3n β(n2 ± δ3n)(cid:19) ≤(cid:18) n2 β(n2 ± δ3n)(cid:19) ≤(cid:18) n2 βn2(cid:19) · eO(δ3 log(1/δ)n2). By conditioning on A, taking expectations on both sides of (3.9), and applying Lemma 3.13 (see Lemma 4.5 in [12]) we infer that for δ > 0 sufficiently small P (Yq,β > 0) ≤ E (Xq,β A) ·(cid:18) n2 βn2(cid:19) · (2k − k − 1)m2−βn2 · e−km2·H(q)+O(δ2n2) + P(cid:0)A(cid:1) . (3.10) The expectation of Xq,β, conditioned on the event A, is determined by calculating the prob- ability that a specific set with β N2 vertices has total degree qk M2. This task was performed in [13], see Lemma 4.8 there. It follows that where E (Xq,β A) = exp(cid:18)n2H(β) − n2(1 − β)I(cid:18) k(1 − q) I(z) =(z (ln Tz − ln ξ) − ln(cid:0)eTz − Tz − 1(cid:1) + ln(cid:0)eξ − ξ − 1(cid:1) , 1 − β (cid:19) (1 + o(1)) + O(n2δ2)(cid:19) , if z > 2 if z = 2 , ln 2 − 2 ln ξ + ln(eξ − ξ − 1), and Tz is the unique solution of z = Tz(1−e−Tz ) 1−e−Tz−Tze−Tz . Let By using (3.10) and (3.8) we infer that 1 − β (cid:19) . f (β, q) := 2 H(β) + (1 − β) ln(2k − k − 1) − kH (q) − (1 − β)I(cid:18) k(1 − q) P (Yq,β > 0) ≤ expnn2(cid:16)f (β, q) + ekδ(cid:0)kH (q) − ln(2k − k − 1)(cid:1) + O(δ2)(cid:17)o + n−ω(1). In [13] the following was shown, see Claim 4.11 there. Claim 3.15. There exists a C > 0 such that for any small enough ν > 0 the following is true. Let 0.7 ≤ β ≤ 1 − ν and β ≤ q ≤ 1 − 2(1 − β)/k. Then f (β, q) ≤ −Cν + O(δ2). 20 We distinguish between the following cases. First, note that if 0.7 ≤ β ≤ 1−√δ, then the above claim yields for sufficiently small δ > 0 P (Yq,β > 0) ≤ en2(−C√δ+O(δ)) + n−ω(1) = n−ω(1). Finally, if 1 − √δ ≤ β ≤ 1 − ekδ/2, then the above claim implies that there is a C′ > 0 such that f (β, q) < C′δ2. Moreover, by the monotonicity of the entropy function and q ≥ β we have for sufficiently small δ > 0 kH (q) − ln(2k − k − 1) ≤ kH(0.99) − ln(2k − k − 1). A simple calculation and the fact H(0.99) < 0.06 show that the above expression is negative for all k ≥ 3. This completes the proof of Theorem 3.2 for the case 0.7 ≤ β ≤ 1 − ekδ/2. Now if β ≥ 1 − ekδ/2, then (3.7) together with (3.8) imply that for small δ all larger subsets have density smaller than 1 − ε3. In order to cover the remaining cases for β we use straightforward first moment arguments. For technical reasons we state our results for the uniform model Hn,m,k. We begin with the case k ≥ 5. Lemma 3.16. Let k ≥ 5, c < 1 and 0 < γ < 0.001. Then Hn,cn,k contains no subset with less than 0.7n vertices and density at least 1 − γ with probability at least 1 − n−(1−γ)k2+2k+1. Proof. The probability that an edge of Hn,cn,k is contained completely in a subset U of the vertex set is (cid:0)Uk(cid:1)/(cid:0)n k(cid:1) ≤ (Un )k. Let k n ≤ u ≤ 0.7. Then the probability that there is a set (cid:18) n un(cid:19) ·(cid:18) (1 − γ)un(cid:19)uk·(1−γ)un ≤ en(H(u)+H((1−γ)u)+(1−γ)ku ln u), with un vertices and density at least 1 − γ is at most cn where H(x) = −x ln x−(1−x) ln x denotes the entropy function. It can easily be seen that the exponent has a unique minimum with respect to u in [0, 0.7], implying that it is maximized either at u = k/n or at u = 0.7. Note that H(0.7)+H((1−γ)0.7)+(1−γ)k 0.7 ln(0.7) ≤ H(0.7)+H((1−γ)0.7)+(1−γ)5·0.7 ln(0.7) ≤ −0.01 and that H(cid:18) k n(cid:19) + H(cid:18)(1 − γ) k n(cid:19) + (1 − γ) k2 n ln(cid:18) k n(cid:19) = − ((1 − γ)k2 − (2 − γ)k) ln n n + O(cid:18) 1 n(cid:19) . So, the maximum is obtained at u = k/n, and for large n we conclude that the probability that there is a subset with at most 0.7n vertices and density at least 1 − γ is at most Xk/n≤u≤0.7 n−(1−γ)k2+2k ≤ n−(1−γ)k2+2k+1. The cases k ∈ {3, 4} need a separate treatment. There we will exploit Proposition 3.12. 21 Lemma 3.17. Let 0 < γ < 0.001. Let H be a k-graph, where k ∈ {3, 4} and call a set U ⊂ VH bad if eU = ⌈(1 − γ)U⌉ and ∀e ∈ EH : e ∩ U 6= k − 1. Then, for any c ≤ 0.95 and sufficiently large n P (Hn,cn,3 contains a bad subset U with ≤ n/2 vertices) = o(1). and for any c ≤ 0.98 and sufficiently large n P (Hn,cn,4 contains a bad subset U with ≤ 3n/4 vertices) = o(1). The proof is essentially the same as the proof of Lemma 4.3 in [13], and thus omitted. it suffices to show that the core C = C(VC, EC) of eHn,p,k, where p = ck/(cid:0)n−1 Proof of Theorem 3.2. First of all, let k ≥ 5. By applying Lemma 3.16 we obtain that with high probability, Hn,m,k does not contain a subset of less than 0.7n vertices with density at least 1− ε3. By Proposition 3.3 this is also true for H∗n,m,k, and in particular also for the core of H∗n,m,k. Concerning larger subsets of the core of H∗n,m,k, by Proposition 3.5 and Theorem 3.6 k−1(cid:1) and m = cn, contains no subset with more than 0.7VC vertices and density at least 1− ε3 with probability at least 1 − o(n−k/2). This follows from Lemma 3.14, and the proof is completed for k ≥ 5. The cases k = 3, 4 require slightly more work. We begin with k = 3. Lemma 3.17 and the fact c∗3 < 0.95 guarantee that with high probability the core of Hn,m,k has no subset S with ≤ n/2 vertices such that eS = ⌈(1 − ε3)S⌉, and there is no edge that contains precisely two vertices in that set. By Proposition 3.3 this is also true for H∗n,m,k. In particular, by using Proposition 3.12 we infer that with high probaility the core of H∗n,m,k does not contain a inclusion maximal subset with at most n/2 vertices and density at least 1 − ε3. Concerning larger subsets of the core of H∗n,m,k, again by Proposition 3.5 and Theorem 3.6 k−1(cid:1) and m = cn, contains no subset with more than n/2 vertices and density at least 1− ε3 with probability at least 1−o(n−k/2). However, by Corollary 3.8 we know that with probability at least 1−n−ω(1) it suffices to show that the core C = C(VC, EC) of eHn,p,k, where p = ck/(cid:0)n−1 VC = (1 − e−ξ − ξe−ξ ± O(ε))n, where ξ = 3c(1 − e−ξ)2. Numerical calculations imply that VC ≥ 0.63n for any ε > 0 that is small enough. So, C does not contain any inclusion maximal subset with less than n/2 ≤ VC/(2 · 0.63) ≤ 0.77 N2 vertices an density at least 1 − ε3. This completes together with Lemma 3.14 the proof for k = 3; the case k = 4 follows similarly by using the second part of the conclusion of Lemma 3.17, and the fact that c∗4 < 0.98. 4 Spanning properties of H∗n,m,k 4.1 Proof of Proposition 2.4 The proof is similar to that of Lemma 8 in [16], but suitably adjusted to our parameters. For ease of notation we write t = (k − 1)s − δ; later we will set δ = xss and δ = 1, respectively. 22 The expected number of sets in H∗n,m,k containing s edges that span at most t vertices is bounded from above by (cid:18)m s(cid:19)(cid:18)n nk(cid:19)s t(cid:19)(cid:18) tk s (cid:19)s(cid:16) ne t (cid:17)t(cid:18) t n(cid:19)ks ≤(cid:18) c∗kne ≤ n−δeks(c∗ks−1)s((k − 1)s)s(ks)δ =(cid:18) ks Let ξ > 0 be such that (1 + ξ)c∗k = 1. To deduce the first claim we observe that for δ = xss the assumption xs = logk((k − 1)ek)/(logk(n/s) − 1) implies that n(cid:19)δ(cid:16)c∗k(k − 1)ek(cid:17)s = n−δeks−δ(c∗ks−1)sts+δ (4.1) . (cid:18) ks n(cid:19)δ(cid:16)c∗k(k − 1)ek(cid:17)s =(cid:20)(cid:18) ks n(cid:19)xs(cid:16)c∗k(k − 1)ek(cid:17)(cid:21)s = (1 + ξ)−s. By taking the sum over all log log n < s ≤ n/k we deduce that the probability that there exists a set of s edges of that spans at most (k− 1− xs)s vertices is O(cid:0)(1 + ξ)−log log n(cid:1) = o(1). The proof of the second part follows along the same lines, except that we use slightly cruder upper bounds. In particular, we bound c∗k ≤ 1. Setting δ = 1, we deduce from (4.1) that the expected number of sets with s ≤ log log n edges that span at most t = (k − 1)s − 1 vertices is at most k log log n ·(cid:16)kek(cid:17)log log n = o(1). n 4.2 Proof of Lemma 2.5 We will use the following auxiliary fact. Proposition 4.1. For any constants a, b > 0 we have that whenever D = D(a, b) is suffi- ciently large then jYi=1(cid:18)1 − a ib + D(cid:19) ≥ j−a/b · (bD)−a/b · e−a2/bD for all j ≥ 2/b. Proof. Assume that D ≥ 2 is large enough so that we thus obtain jYi=1(cid:18)1 − a ib + D(cid:19) ≥ exp − jXi=1 Further, we have a b+D ≤ 0.5. As 1 − x ≥ e−x−x2 ib + D(cid:19)2! . jXi=1(cid:18) a a ib + D − for x ≤ 0.5 (4.2) a ib + D ≤ aZ j 0 jXi=1 Similarly, 1 bx + D dx = a b · (log(bj + D) − log(D)) ≤ a b · log(bj + D). jXi=1(cid:18) a ib + D(cid:19)2 ≤ a2Z j 0 1 (bx + D)2 dx = 23 a2 b ·(cid:18) 1 D − 1 bj + D(cid:19) ≤ a2 bD . Now observe that for j ≥ 2/b we have bj + D ≤ bjD and thus log(bj + D) ≤ log(bj) + log(D). The substitution of these two bounds into (4.2) thus yields jYi=1(cid:18)1 − a ib + D(cid:19) ≥ j−a/b · (bD)−a/b · e−a2/bD. Let H = H(V, E) be a k-graph on n vertices having Property E. We also fix a vertex v ∈ V and an orientation o of the edges, and for all i ≥ 0 we let si be the number of vertices that are within o-distance at most i from v. Note that si = No,i(v), but we shall be using this symbol throughout this section to avoid an unnecessary notational burden. If all vertices within o-distance at most i from v are occupied, then Property E implies that si+1 ≥((k − 1 − xsi)si, (k − 1)si, if si > log log n if si ≤ log log n. . (4.3) Claim 4.2. Let i0 := min{i : si > log log n}. Then i0 ≤ logk−1 log log n + 1. Proof. Observe that for all 2 ≤ i < i0, we have si ≥ (k−1)si−1 ≥ . . . ≥ (k−1)i−1s1 = (k−1)i, and the claim follows. Claim 4.3. Let tε := ⌊(1− ε) logk−1 n⌋. Then there exists a dk > 0 such that whenever ε > 0 is sufficiently small and n is sufficiently large we have stε ≥ n1−ε · e−dk/ε. Proof. Observe that by (2.1) we have stε ≤ (k − 1)tε+1 ≤ (k − 1)n1−ε. Let i0 be defined as in the previous claim. Hence, we have for all i0 ≤ i ≤ tε for any sufficiently large n that xsi ≤ logk((k − 1)ek) ε logk n − logk(k − 1) − 1 ≤ 2 log((k − 1)ek) ε log n . Thus, for all such i the first part of (4.3) yields si+1 ≥ (k − 1 − xsi)si ≥ (k − 1)(cid:16)1 − (k − 1)ε log n (cid:17)si. 2 log((k − 1)ek) Set φ = φ(ε, k, n) = 1 − 2 log((k−1)ek) Claim 4.2 we obtain (k−1)ε log n . By applying the above estimate repeatedly and using stε ≥ (k − 1)tε−i0φtε−i0si0 ≥ (k − 1)tε−logk−1 log log nφlogk−1 n · log log n ≥ Note that φlogk−1 n ≥ exp(cid:26)− 2 log((k − 1)ek) ε(k − 1) log n logk−1 n + o(1)(cid:27) = exp(cid:26)− 2 log((k − 1)ek) ε(k − 1) log(k − 1) Since log((k−1)ek) (k−1) log(k−1) > 0 for any k ≥ 3, the claim follows whenever ε is sufficiently small. 24 n1−ε k − 1 · φlogk−1 n. + o(1)(cid:27) . Claim 4.4. Let t ≥ i0, where i0 is as defined in Claim 4.2. For every ε > 0 sufficiently small, if st ≤ εn, then for all 0 ≤ i ≤ t − i0, we have xst−i ≤ logk((k − 1)ek) i logk(k − 1 − γ) + logk(1/ε) − 1 ≤ γ, where γ = logk((k−1)ek) logk(1/ε)−1 . Proof. We will show the statement by induction on i. For i = 0 this is obtained directly from the definition of xst: xst = logk((k − 1)ek) logk(n/st) − 1 ≤ logk((k − 1)ek) logk(1/ε) − 1 = γ. Using (4.3), for the induction step we have st−(i+1) ≤ st−i k − 1 − xst−(i+1) ≤ st−i k − 1 − γ ≤ st (k − 1 − γ)i+1 ≤ εn (k − 1 − γ)i+1 . Thus the definition of xst−(i+1) yields xst−(i+1) = logk((k − 1)ek) logk(n/st−(i+1)) − 1 ≤ logk((k − 1)ek) (i + 1) logk(k − 1 − γ) + logk(1/ε) − 1 < γ. The next claim finishes the proof of Lemma 2.5. Claim 4.5. For every k ≥ 3 and ζ > 0 there exists ε0 = ε0(ζ, k) > 0 such that for all 0 < ε < ε0 and n sufficiently large the following is true. If all vertices within o-distance T := logk−1 n +(cid:16) k+log(k−1) (k−1) log(k−1) + ζ(cid:17) logk−1 logk−1 n from v are occupied, then sT > εn. Proof. We prove the claim by contradiction. Assume that sT ≤ εn. Claim 4.4 implies that xsT −i ≤ i logk(k − 1 − γ) + logk(1/ε) − 1 for all 0 ≤ i ≤ T − i0 and the first part of (4.3) thus implies that 1 εn εn logk((k − 1)ek) sT−j ≤ i=1(cid:0)k − 1 − xsT −i(cid:1) ≤ Qj (k − 1)j i=1(cid:16)1 − logk((k−1)ek)/(k−1) Qj i logk(k−1−γ)+logk(1/ε)−1(cid:17) . for all 0 ≤ j ≤ T − i0. We now apply Proposition 4.1 for a = logk((k − 1)ek)/(k − 1) and b = logk(k − 1 − γ). Then Proposition 4.1 implies such that whenever ε is sufficiently small (such that logk(1/ε) − 1 ≥ D, where D = D(a, b) is as defined in Proposition 4.1), then (4.4) jYi=1(cid:18)1 − logk((k − 1)ek)/(k − 1) i logk(k − 1 − γ) + logk(1/ε) − 1(cid:19) ≥ j− logk ((k−1)ek ) (k−1) logk (k−1−γ) · 1 Cε,k , (4.5) 25 where Cε,k is an appropriately defined constant depending only on ε and k. Then substituting the lower bound from (4.5) into (4.4) we obtain that for all j ≤ logk−1 n we have sT−j ≤ εn (k − 1)j (logk−1 n) logk ((k−1)ek ) (k−1) logk (k−1−γ) Cε,k. (4.6) If we now set Rε,k := Cε,k · edk/ε, where dk is the constant from Claim 4.3, we deduce that for j := ε logk−1 n + logk((k−1)ek) (k−1) logk(k−1−γ) logk−1 logk−1 n + logk−1 Rε,k we have sT−j ≤ εe−dk/εn1−ε. (4.7) If ε is small enough, then in turn γ is small enough so that for n sufficiently large T − j ≥ ⌊(1 − ε) logk−1 n⌋; this, however, contradicts the lower bound from Claim 4.3. 4.3 Proof of Corollary 2.6 The hypergraph H′ still has Property E with n instead of N = V (H′). Using this, the proof of Corollary 2.6 follows exactly along the lines of the proof of Lemma 2.5. References [1] Y. Azar, A. Broder, A. Karlin, and E. Upfal. Balanced allocations. SIAM Journal on Computing, 29(1):180–200, 1999. [2] J. A. Cain, P. Sanders, and N. Wormald. The random graph threshold for k-orientiability and a fast algorithm for optimal multiple-choice allocation. In Proceedings of SODA '07, pp. 469–476, 2007. [3] A. Coja-Oghlan and A. Taraz. Exact and approximative algorithms for coloring G(n, p). Random Strucures & Algorithms, 24(3):259–278, 2004. [4] C. Cooper. The cores of random hypergraphs with a given degree sequence. Random Structures & Algorithms, 25(4):353–375, 2004. [5] L. Devroye and P. Morin. Cuckoo hashing: Further analysis. Information Processing Letters, 86(4):215–219, 2003. [6] M. Dietzfelbinger, A. Goerdt, M. Mitzenmacher, A. Montanari, R. Pagh, and M. Rink. Tight thresholds for cuckoo hashing via XORSAT. In Proceedings of ICALP '10, pp. 213–225, 2010. [7] M. Dietzfelbinger and C. Weidling. Balanced allocation and dictionaries with tightly packed constant size bins. Theoretical Computer Science, 380(1-2): 47 – 68, 2007. [8] M. Drmota and R. Kutzelnigg. A precise analysis of Cuckoo hashing. ACM Transactions on Algorithms, 8(2): Article 11, 2012. [9] R. S. Ellis. Entropy, large deviations, and statistical mechanics. Classics in Mathematics. Springer-Verlag, Berlin, 2006. Reprint of the 1985 original. 26 [10] D. Fernholz and V. Ramachandran. The k-orientability thresholds for Gn,p. In Proceed- ings of SODA '07, pp. 459–468, 2007. [11] D. Fotakis, R. Pagh, P. Sanders, and P. Spirakis. Space efficient hash tables with worst case constant access time. In Proceedings of STACS '03, pp. 271–282, 2003. [12] N. Fountoulakis and K. Panagiotou. Orientability of random hypergaphs and the power of multiple choices. In Proceedings of ICALP '10, pp. 348–359, 2010. [13] N. Fountoulakis and K. Panagiotou. Sharp load thresholds for cuckoo hashing. Random Structures & Algorithms, 41(3): 306–333, 2012. [14] N. Fountoulakis, M. Khosla and K. Panagiotou. The multiple-orientability thresholds for random hypergraphs. In Proceedings of SODA '11, pp. 1222–1236, 2011. [15] A. Frieze and P. Melsted. Maximum matchings in random bipartite graphs and the space utilization of cuckoo hashtables. Random Structures & Algorithms, 41(3): 334–364, 2012. [16] A. M. Frieze, P. Melsted and M. Mitzenmacher. An analysis of random-walk cuckoo hashing. SIAM Journal on Computing, 40(2):291–308, 2011. [17] S. Janson, T. Luczak, and A. Ruci´nski. Random graphs. Wiley-Interscience Series in Discrete Mathematics and Optimization. Wiley-Interscience, New York, 2000. [18] J. H. Kim. Poisson cloning model for random graphs. Manuscript, 2006. [19] M. Mitzenmacher. Some open questions related to cuckoo hashing. In Proceedings of ESA '09, pp. 1–10, 2009. [20] M. Mitzenmacher, A.W. Richa, and R. Sitaraman. The power of two random choices: a survey of techniques and results. In: Handbook of Randomized Computing, pp. 255–312, 2000. [21] M. Molloy. Cores in random hypergraphs and boolean formulas. Random Structures & Algorithms, 27(1):124–135, 2005. [22] R. Pagh and F. Rodler. Cuckoo hashing. In Proceedings of ESA '01, pp. 121–133, 2001. [23] B. Pittel, J. Spencer and N. Wormald. Sudden emergence of a giant k-core in a random graph. Journal of Combinatorial Theory, Series B, 67(1):111–151, 1996. 27
1704.02183
3
1704
2018-03-12T12:42:32
Proportional Approval Voting, Harmonic k-median, and Negative Association
[ "cs.DS", "cs.GT" ]
We study a generic framework that provides a unified view on two important classes of problems: (i) extensions of the k-median problem where clients are interested in having multiple facilities in their vicinity (e.g., due to the fact that, with some small probability, the closest facility might be malfunctioning and so might not be available for using), and (ii) finding winners according to some appealing multiwinner election rules, i.e., election system aimed for choosing representatives bodies, such as parliaments, based on preferences of a population of voters over individual candidates. Each problem in our framework is associated with a vector of weights: we show that the approximability of the problem depends on structural properties of these vectors. We specifically focus on the harmonic sequence of weights for which the objective function interpreted in a multiwinner election setup reflects to the well-known Proportional Approval Voting (PAV) rule. Our main result is that, due to the specific (harmonic) structure of weights, the problem allows constant factor approximation. This is surprising since the problem can be interpreted as a variant of the k-median problem where we do not assume that the connection costs satisfy the triangle inequality. The algorithm we propose is based on dependent rounding [Srinivasan, FOCS'01] applied to the solution of a natural LP-relaxation of the problem. The rounding process is well known to produce distributions over integral solutions satisfying Negative Correlation (NC), which is usually sufficient for the analysis of approximation guarantees offered by rounding procedures. In our analysis, however, we need to use the fact that the carefully implemented rounding process satisfies a stronger property, called Negative Association (NA), which allows us to apply standard concentration bounds for conditional random variables.
cs.DS
cs
Proportional Approval Voting, Harmonic k-median, and Negative Association Jaros(cid:32)law Byrka∗ Piotr Skowron† Krzysztof Sornat‡ Abstract We study a generic framework that provides a unified view on two important classes of problems: (i) extensions of the k-median problem where clients are interested in having multiple facilities in their vicinity (e.g., due to the fact that, with some small probability, the closest facility might be malfunctioning and so might not be available for using), and (ii) finding winners according to some appealing multiwinner election rules, i.e., election system aimed for choosing representatives bodies, such as parliaments, based on preferences of a population of voters over individual candidates. Each problem in our framework is associated with a vector of weights: we show that the approximability of the problem depends on structural properties of these vectors. We specifically focus on the harmonic sequence of weights, since it results in particularly appealing properties of the considered problem. In particular, the objective function interpreted in a multiwinner election setup reflects to the well-known Proportional Approval Voting (PAV) rule. Our main result is that, due to the specific (harmonic) structure of weights, the problem allows constant factor approximation. This is surprising since the problem can be interpreted as a variant of the k-median problem where we do not assume that the connection costs satisfy the triangle inequality. To the best of our knowledge this is the first constant factor approximation algorithm for a variant of k-median that does not require this assumption. The algorithm we propose is based on dependent rounding [Srinivasan, FOCS'01] applied to the solution of a natural LP-relaxation of the problem. The rounding process is well known to produce distributions over integral solutions satisfying Negative Correlation (NC), which is usually sufficient for the analysis of approximation guarantees offered by rounding procedures. In our analysis, however, we need to use the fact that the carefully implemented rounding process satisfies a stronger property, called Negative Association (NA), which allows us to apply standard concentration bounds for conditional random variables. 8 1 0 2 r a M 2 1 ] S D . s c [ 3 v 3 8 1 2 0 . 4 0 7 1 : v i X r a ∗University of Wroc(cid:32)law, Wroc(cid:32)law, Poland, [email protected]. †University of Warsaw, Warsaw, Poland, [email protected]. ‡University of Wroc(cid:32)law, Wroc(cid:32)law, Poland, [email protected]. 1 1 Introduction This paper considers a general unified framework for two classes of problems: (i) extensions of the k-median problem where clients care about having multiple facilities in their vicinity, and (ii) finding winning committees according to a number of well-known, but hard-to-compute multiwinner election systems1. Let us first formalize our framework; we will discuss motivation and explain the relation to k-median and to multiwinner elections later on. For a natural number t ∈ N, by [t] we denote the set {1, . . . , t}. Let F = {F1, . . . , Fm} be the set of m facilities and let D = {D1, . . . , Dn} be the set of n clients (demands). The goal is to pick a set of k facilities that altogether are most satisfying for the clients. Different clients can have different preferences over individual facilities-by ci,j we denote the cost that client Dj suffers when using facility Fi (this can be, e.g., the communication cost of client Dj to facility Fi, or a value quantifying the level of personal dissatisfaction of Dj from Fi). Following Yager [37], we use ordered weighted average (OWA) operators to define the cost of a client for a bundle of k facilities C. Formally, let w = (cid:0)w1, . . . , wk define the w-cost of a client Dj for a size-k set of facilities C as w(C, j) =(cid:80)k (cid:1) be a non-increasing vector of k weights. We (cid:0)(cid:8)ci,j : Fi ∈ C(cid:9)(cid:1) is a non-decreasing permutation of c→(C, j) = (c→ the costs of client Dj for the facilities from C. Informally speaking, the highest weight is applied to the lowest cost, the second highest weight to the second lowest cost, etc. In this paper we study the following computational problem. Definition 1 (OWA k-median). In OWA k-median we are given a set D = {D1, . . . , Dn} of i∈[m],j∈[n], a positive clients, a set F = {F1, . . . , Fm} of facilities, a collection of clients' costs(cid:0)ci,j (cid:1) integer k (k ≤ m), and a vector of k non-increasing weights w = (cid:0)w1, . . . , wk (cid:1). The task is to 1 (C, j), . . . , c→ k (C, j)) = sortASC compute a subset C of F that minimizes the value i=1 wic→ i (C, j), where n(cid:88) n(cid:88) k(cid:88) w(C) = w(C, j) = → i (C, j). wic j=1 j=1 i=1 Note that OWA k-median with weights (1, 0, 0, . . . , 0) is the k-median problem. Sometimes the costs represent distances between clients and facilities. Formally, this means that there exists a metric space M with a distance function d : M × M → R≥0, where each client and each facility can be associated with a point in M so that for each Fi ∈ F and each Dj ∈ D we have d(i, j) = ci,j. When this is the case, we say that the costs satisfy the triangle inequality, and use the terms "costs" and "distance" interchangeably. Then, we use the prefix Metric for the names of our problems. E.g., by Metric OWA k-median we denote the variant of OWA k-median where the costs satisfy the triangle inequality. (1) harmonic: whar = (cid:0)1, 1/2, 1/3, . . . , 1/k(cid:1). By Harmonic k-median we denote the OWA k- (2) p-geometric: wgeom =(cid:0)1, p, p2, . . . , pk−1(cid:1), for some p < 1. We are specifically interested in the following two sequences of weights: median problem with the harmonic vector of weights. The two aforementioned sequences of weights, whar and wgeom, have their natural interpretations, which we discuss later on (for instance, see Examples 3 and 4). 1We note that multiwinner election rules have many applications beyond the political domain-such applications include finding a set of results a search engine should display [14], recommending a set of products a company should offer to its customers [28, 29], allocating shared resources among agents [32, 31], solving variants of segmentation problems [26], or even improving genetic algorithms [17]. 2 Figure 1: The relation between the considered models. OWA k-median is the most general model. Proportional Approval Voting and Harmonic k-median due to the use of harmonic weights can be viewed as natural extensions of the well known and commonly used D'Hondt method of apportionment [5]. 1.1 Motivation In this subsection we discuss the applicability of the studied model in two settings. Multiwinner Elections Different variants of the OWA k-median problem are very closely related to the preference aggregation methods and multiwinner election rules studied in the computational social choice, in particular, and in AI, in general-we summarize this relation in Table 1 and in Figure 1. In particular, one can observe that each "median" problem is associated with a corresponding "winner" problem. Specifically, the k-median problem is known in computational social choice as the Chamberlin–Courant rule. Let us now explain the differences between the winner ("election") and the median ("facility location") problems: 1. The election problems are usually formulated as maximization problems, where instead of (negative) costs we have (positive) utilities. The two variants, the minimization (with costs) and the maximization (with utilities) have the same optimal solutions. Yet, there is a substantial difference in their approximability. Approximating the minimization variant is usually much harder. For instance, consider the Chamberlin–Courant (CC) rule which is defined by using the sequence of weights (1, 0, 0, . . . , 0). In the maximization variant standard arguments can be used to prove that a greedy procedure yields the approximation ratio of (1− 1/e). This stands in a sharp contrast to the case when the same rule is expressed as the minimization one; in such a case we cannot hope for virtually any approximation [33] (we will extend this result in Theorem 21). Approximating the minimization variant is also more desired. E.g., a 1/2-approximation algorithm for (maximization) CC can effectively ignore half of the population of clients, whereas it was argued [33] that a 2-approximation algorithm for the minimization (if existed) would be more powerful. In this paper we study the harder minimization variant, and give the first constant-factor approximation algorithm for the minimization OWA-Winner with the harmonic weights. 2. In facility location problems it is usually assumed that the costs satisfy the triangle inequality. This relates to the previous point: since the problem cannot be well approximated in the general setting, one needs to make additional assumptions. One of our main results is showing that there is a k-median problem (OWA k-median with harmonic weights) that admits a constant-factor approximation without assuming that the costs satisfy the triangle inequality; this is the first known result of this kind. 3 OWAmedianHarmonicmedian(harmonicweights)ProportionalApprovalVoting(0-1costs)dHondtmethodapprovalsforasingleparty) k-median problem election rule comment OWA k-median OWA-Winner [32] Finding winners according to OWA-Winner rules is the maximization variant of OWA k-median (utilities instead of costs). Thiele methods [36] Thiele methods are OWA-Winner rules for 0/1 costs. Harmonic k-median PAV [36] k-median Chamberlin–Courant [9] In PAV we assume the 0/1 costs. So far, only the maxi- mization variant was considered in the literature. In CC, usually some specific form of utilities is assumed- different utilities have been considered, but always in the maximization variant (utilities instead of costs). Table 1: The relation between the k-median problems and the corresponding problems studied in AI, in particular in the computational social choice community. The special case of Harmonic k-median where each cost belongs to the binary set {0, 1} is equivalent to finding winners according to Proportional Approval Voting. The harmonic sequence whar = (1, 1/2, 1/3, . . . , 1/k) is in a way exceptional: indeed, PAV can be viewed as an extension of the well known D'Hondt method of apportionment (used for electing parliaments in many contemporary democracies) to the case where the voters can vote for individual candidates rather than for political parties [5]. Further, PAV satisfies several other appealing properties, such as extended justified representation [4]. This is one of the reasons why we are specifically interested in the harmonic weights. For more discussion on PAV and other approval-based rules, we refer the reader to the survey of Kilgour [25]. OWA k-median as an Extension of k-median Intuitively, our general formulation extends k-median to scenarios where the clients not only use their most preferred facilities, but when there exists a more complex relation of "using the facilities" by the clients. Similar intuition is captured by the Fault Tolerant version of the k-median problem introduced by Swamy and Shmoys [35] and recently studied by Hajiaghayi et al. [20]. There, the idea is that the facilities can be malfunctioning, and to increase the resilience to their failures each client needs to be connected to several of them. Definition 2 (Fault Tolerant k-median). In Fault Tolerant k-median problem we are given the same input as in k-median, and additionally, for each client Dj we are given a natural number rj ≥ 1, called the connectivity requirement. The cost of a client Dj is the sum of its costs for the rj closest open facilities. Similarly as in k-median, we aim at choosing at most k facilities so that the sum of the costs is minimized. When the values (cid:0)rj (cid:1) j∈[n] are all the same, i.e., if rj = r for all j, then Fault Tolerant k-median is called r-Fault Tolerant k-median and it can be expressed as OWA k-median for the weight vector w with r ones followed by k − r zeros. Yet, in the typical setting of k-median problems one additionally assumes that the costs between clients and facilities behave like distances, i.e., that they satisfy the triangle inequality. Indeed, the (2.675 + )-approximation algorithm for k-median [6], the 93-approximation algorithm for Fault Tolerant k-median [20], the 2- approximation algorithm for k-center [21], and the 6.357-approximation algorithm for k-means [1], 4 they all use triangle inequalities. Moreover it can be shown by straightforward reductions from the Set Cover problem that there are no constant factor approximation algorithms for all these settings with general (non-metric) connection costs unless P = NP. Using harmonic or geometric OWA weights is also well-justified in case of facility location problems, as illustrated by the following examples. Example 3 (Harmonic weights: proportionality). Assume there are (cid:96) ≤ k cities, and for i ∈ [(cid:96)] let Ni denote the set of clients who live in the i-th city. For the sake of simplicity, let us assume that k · Ni is divisible by n. Further, assume that the cost of traveling between any two points within a single city is negligible (equal to zero), and that the cost of traveling between different cities is equal to one. Our goal is to decide in which cities the k facilities should be opened; naturally, we set the cost of a client for a facility opened in the same city to zero, and-in another city-to one. Let us consider OWA k-median with the harmonic sequence of weights whar. Let ni denote the number of facilities opened in the i-th city in the optimal solution. We will show that for each i we have ni = kNi n , i.e., that the number of facilities opened in each city is proportional to its population. Towards a contradiction assume there are two cities, i and j, with ni ≥ kNi n − 1. By closing one facility in the i-th city and opening one in the j-th city, we decrease the total cost by at least: n + 1 and nj ≤ kNj Nj · wnj +1 − Ni · wni = Ni nj + 1 − Ni ni > Njn kNj − Nin kNi = 0. Since, we decreased the cost of the clients, this could not be an optimal solution. As a result we see that indeed for each i we have ni = kNi n . Example 4 (Geometric weights: probabilities of failures). Assume that we want to select k facilities and that each client will be using his or her favorite facility only. Yet, when a client wants to use a facility, it can be malfunctioning with some probability p; in such a case the client goes to her second most preferred facility; if the second facility is not working properly, the client goes to the third one, etc. Thus, a client uses her most preferred facility with probability 1 − p, her second most preferred facility with probability p(1 − p), the third one with probability p2(1 − p), etc. As a result, the expected cost of a client Dj for the bundle of k facilities C is equal to w(C, j) for the weight vector w =(cid:0)1 − p, (1 − p)p, . . . , (1 − p)pk−1(cid:1). Finding a set of facilities, that minimize the expected cost of all clients is equivalent to solving OWA k-median for the p-geometric sequence of weights (in fact, the sequence that we use is a p-geometric sequence multiplied by (1 − p), yet multiplication of the weight vector by a constant does not influence the structure of the optimal solutions). 1.2 Our Results and Techniques Our main result is showing, that there exists a 2.3589-approximation algorithm for Harmonic k-median for general connection costs (not assuming triangle inequalities). This is in contrast to the innaproximability of most clustering settings with general connection costs. Our algorithm is based on dependent rounding of a solution to a natural linear program (LP) relaxation of the problem. We use the dependent rounding (DR) studied by Srinivasan et al. [34, 18], which transforms in a randomized way a fractional vector into an integral one. The sum-preservation property of DR ensures that exactly k facilities are opened. DR satisfies, what is well known as negative correlation (NC)-intuitively, this implies that the sums of subsets of random variables describing the outcome are more centered around their expected values than if the fractional variables were rounded independently. More precisely, negative correlation allows one to use standard concentration bounds such as the Chernoff-Hoeffding bound. 5 Yet, interestingly, we find out that NC is not sufficient for our analysis in which we need a conditional variant of the concentration bound. The property that is sufficient for conditional bounds is negative association (NA) [23]. In fact its special case that we call binary negative association (BNA), is sufficient for our analysis. It captures the capability of reasoning about conditional probabilities. Thus, our work demonstrates how to apply the (B)NA property in the analysis of approximation algorithms based on DR. To the best of our knowledge, Harmonic k-median is the first natural computational problem, where it is essential to use BNA in the analysis of the algorithm. We additionally show that the 93-approximation algorithm of Hajiaghayi et al. [20] can be extended to OWA k-median (our technique is summarized in Section 3)-this time we additionally need to assume that the costs satisfy the triangle inequality. Indeed, without this assumption the problem is hard to approximate for a large class of weight vectors; for instance, for p-geometric sequences with p < 1/e (Theorem 22 and Corollary 23) or for sequences where there exists λ ∈ (0, 1) such that clients care only about the λ-fraction of opened facilities (Theorem 21). Due to space constraints the formulation and the discussion on these hardness results are redelegated to Appendix E. For the paper to be self-contained, in Appendix A we discuss in detail the process of dependent rounding (including a few illustrative examples); in particular, we provide an alternative proof that DR satisfies binary negative association. Our proof is more direct and shorter than the proofs known in the literature [27]. 2 Harmonic k-median and Proportional Approval Voting: a 2.3589-approximation Algorithm In this section we demonstrate how to use the Binary Negative Association (BNA) property of Dependent Rounding (DR) to derive our main result-a randomized constant-factor approximation algorithm for Harmonic k-median. In Appendix A we provide a detailed discussion on DR and BNA, including a proof that DR satisfies BNA, and several examples. Theorem 5. There exists a polynomial time randomized algorithm for Harmonic k-median that gives 2.3589-approximation in expectation. Corollary 6. There exists a polynomial time randomized algorithm for the minimization Propor- tional Approval Voting that gives 2.3589-approximation in expectation. In the remainder of this section we will prove the statement of Theorem 5. Consider the following linear program (1–5) that is a relaxation of a natural ILP for Harmonic k-median. min w(cid:96) · x(cid:96) ij · cij j=1 i=1 n(cid:88) k(cid:88) m(cid:88) m(cid:88) (cid:96)=1 i=1 yi = k k(cid:88) m(cid:88) (cid:96)=1 i=1 (1) (2) x(cid:96) ij ≤ yi ∀i ∈ [m], j ∈ [n] x(cid:96) ij ≥ 1 ∀j ∈ [n], (cid:96) ∈ [k] ∀i ∈ [m], j ∈ [n], (cid:96) ∈ [k] (3) (4) (5) yi, x(cid:96) ij ∈ [0, 1] The intuitive meaning of the variables and constraints of the above LP is as follows. Variable yi denotes how much facility Fi is opened. Integral values 1 and 0 correspond to, respectively, opening and not opening the i-th facility. Constraint (2) encodes opening exactly k facilities. Each client Dj ∈ D has to be assigned to each among k opened facilities with different weights. For that we copy each client k times: the (cid:96)-th copy of a client Dj is assigned to the (cid:96)-th closest to Dj open 6 facility. Variable x(cid:96) ij denotes how much the (cid:96)-th copy of Dj is assigned to facility Fi. In an integral solution we have x(cid:96) ij ∈ {0, 1}, which means that the (cid:96)-th copy of a client can be either assigned or not to the respective facility. The objective function (1) encodes the cost of assigning all copies of all clients to the opened facilities, applying proper weights. Constraint (3) prevents an assignment of a copy of a client to a not-opened part of a facility. In an integer solution it also forces assigning different copies of a client to different facilities. Observe that, due to non-increasing weights w(cid:96), the objective (1) is smaller if an (cid:96)(cid:48)-th copy of a client is assigned to a closer facility than an (cid:96)(cid:48)(cid:48)-th copy, whenever (cid:96)(cid:48) < (cid:96)(cid:48)(cid:48). Constraint (4) ensures that each copy of a client is served by some facility. Just like in most facility location settings it is crucial to select the facilities to open, and the later assignment of clients to facilities can be done optimally by a simple greedy procedure. We propose to select the set of facilities in a randomized way by applying the DR procedure to the y vector from an optimal fractional solution to linear program (1–5). This turns out to be a surprisingly effective methodology for Harmonic k-median. 2.1 Analysis of the Algorithm Let OPTLP be the value of an optimal solution (x∗, y∗) to the linear program (1–5). Let OPT be the value of an optimal solution (xOPT, yOPT) for Harmonic k-median. Easily we can see that (xOPT, yOPT) is a feasible solution to the linear program (1–5), so OPTLP ≤ OPT. Let Y = (Y1, . . . , Ym) be the random solution obtained by applying the DR procedure described in Appendix A to the vector y∗. Recall that DR preserves the sum of entries (see Appendix A), hence we have exactly k facilities opened. It is straightforward to assign clients to the open facilities, so the variables X = (X (cid:96) ij)j∈[n],i∈[m],(cid:96)∈[k] are easily determined. j We will show that E[cost(Y )] ≤ 2.3589 · OPTLP. In fact, we will show that E[costj(Y )] ≤ 2.3589 · OPTLP , where the subindex j extracts the cost of assigning client Dj to the facilities in the solution returned by the algorithm. In our analysis we focus on a single client Dj ∈ D. Next, we reorder the facilities {F1, F2, . . . , Fm} in the non-decreasing order of their connection costs to Dj (i.e., in the non-decreasing order of cij). Thus, from now on, facility Fi is the i-th closest facility to client Dj; ties are resolved in an arbitrary but fixed way. The ordering of the facilities is depicted in Figure 2, which also includes information about the fractional opening of facilities in y∗, i.e., facility Fi is represented by an interval of length y∗ i . The total length of all intervals equals k. Next, we subdivide each interval into a set of (small) -size pieces (called -subintervals);  is selected so that 1/, and y∗ i/ for each i, are integers. Note that the values y∗ i , which originate from the solution returned by an LP solver, are rational numbers. The subdivision of [0, k] into -subintervals is shown in Figure 2 on the "(Zr)r∈{1,2,...,k/}" level. The idea behind introducing the -subintervals is the following. Although computationally the algorithm applies DR to the y∗ variables, for the sake of the analysis we may think that the DR process is actually rounding z variables corresponding to -subinterval under the additional assumption that rounding within individual facilities is done before rounding between facilities. Formally, we replace the vector Y = (Y1, Y2, . . . , Ym) by an equivalent vector of random variables Z = (Z1, Z2, . . . , Zk/). Random variable Zr represents the r-th -subinterval. We will use the following notation to describe the bundles of -subintervals that correspond to particular facilities: submax(0) = 0 and submax(i) = submax(i − 1) + sub(i) = {submax(i − 1) + 1, . . . , submax(i)}. y∗ i  , (6) (7) Intuitively, sub(i) is the set of indexes r such that Zr represents an interval belonging to the i-th facility. Examples for both definitions are shown in Figure 2 in the upper level. Formally, the 7 Figure 2: Ordering of the facilities by ci,j for the chosen client Dj. Definitions of the variables Yi, Zr and of the indices sub(i) and submax(i). random variables Zr are defined so that: (cid:88) Yi = r∈sub(i) Zr and Yi = 1 =⇒ ∃! r ∈ sub(i) Zr = 1. For each r ∈ {1, 2, . . . , k/} we can write that: Pr[Zr = 1] = Pr[Zr = 1 and Pr[Zr = 0] = 1 − , hence E[Zr] = . Also we have: (cid:12)(cid:12)Ysub−1(r) = 1] · Pr[Ysub−1(r) = 1] =  =  (cid:88)  = Pr  (cid:95) Zr = 1 Zr = 1 r∈sub(i) r∈sub(i)  y∗ sub−1(r) · y (cid:88) r∈sub(i) ∗ sub−1(r) =  Pr [Yi = 1] = Pr Pr [Zr = 1] . (8) (9) (10) When Yi = 1 its representative is chosen randomly among (Zr)r∈sub(i) independently of the choices of representatives of other facilities. Therefore ∀i∈[m] ∀r∈sub(i) E [f (Y ) Yi = 1] = E [f (Y ) Yi = 1 ∧ Zr = 1] , (11) for any function f on vector Y = (Y1, Y2, . . . , Ym). Now we are ready to analyze the expected cost for any client Dj ∈ D. (cid:32) (cid:34) E m(cid:88) i=1 1 +(cid:80)i−1 cij i(cid:48)=1 Yi(cid:48) (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)Yi = 1 (cid:35) (cid:33) · Pr [Yi = 1] E[costj(Y )] ≤ 8 clientDjorderedfacilitiesc;jc2;jc3;jc4;jcm;jyy2y3y4ym12k0Zr)r2f;2;:::;k=gYi)i2f;2;:::;mgnon-decreasingdistancesFF2F3F4Fmsubmax3)=13sub2)=f7;8;9g12345611112141516171819221k=78913 i=1 i=1 m(cid:88) m(cid:88) m(cid:88) m(cid:88) m(cid:88) i=1 i=1 i=1 (10) = = (11) = (8),(9) = (8) =   · Pr [Zr = 1] · Pr [Zr = 1] r∈sub(i) 1 i(cid:48)=1 Yi(cid:48) 1 i(cid:48)=1 Yi(cid:48) 1 i(cid:48)=1 Yi(cid:48) E r∈sub(i) E r∈sub(i) cij · E (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)Yi = 1 (cid:35) (cid:34) (cid:88) 1 +(cid:80)i−1 cij · (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)Yi = 1 (cid:35) (cid:34) (cid:88) 1 +(cid:80)i−1 cij · (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)Yi = 1 ∧ Zr = 1 (cid:35) (cid:34) (cid:88) 1 +(cid:80)i−1  · cij · (cid:35) (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)Zr = 1 (cid:34) (cid:88) 1 +(cid:80)submax(i−1) (cid:35)  · cij · (cid:12)(cid:12)(cid:12)(cid:12)(cid:12)Zr = 1 (cid:34) (cid:88) 1 +(cid:80)r−1 (cid:34) (cid:35) (cid:12)(cid:12)(cid:12)(cid:12)Zr = 1 k/(cid:88) 1 +(cid:80)r−1 1 r(cid:48)=1 Zr(cid:48) 1 r(cid:48)=1 Zr(cid:48) r∈sub(i) r∈sub(i) E E r(cid:48)=1 Zr(cid:48) 1 E[costj(Y )] OPTLP j (7),(12) r=1 ≤  · csub−1(r),j · E k/(cid:88)  · csub−1(r),j · 1(cid:100)r(cid:101) r=1  · Pr [Zr = 1] (12) W.l.o.g., assume that OPTLP j > 0. Hence the approximation ratio for any client Dj is = ≤ −1(r) is an index of a facility that contains Zr. Now we convert the sum over facilities note that sub into a sum over unit intervals. A unit interval is represented as a sum of 1/ many -subintervals: k(cid:88) (cid:96)/(cid:88) (cid:96)=1 = r=((cid:96)−1)/+1 csub−1(r),j · E (cid:96)/(cid:88) k(cid:88) (cid:34) 1 +(cid:80)r−1 1 r(cid:48)=1 Zr(cid:48) (cid:35) (cid:12)(cid:12)(cid:12)(cid:12)Zr = 1 W.l.o.g., we can assume that first interval has non-zero costs: (cid:80)1/ r=((cid:96)−1)/+1 (cid:96)=1 csub−1(r),j · 1 (cid:96) r=1 csub−1(r),j > 0, otherwise the LP pays 0 and our algorithm pays 0 in expectation on intervals from non-empty prefix of (1, 2, . . . , k). With this assumption we can take maximum over intervals: (cid:96)/(cid:88)  (cid:34) 1 +(cid:80)r−1 1 r(cid:48)=1 Zr(cid:48) (cid:35) (cid:12)(cid:12)(cid:12)(cid:12)Zr = 1 csub−1(r),j · E (cid:96)/(cid:88) r=((cid:96)−1)/+1 csub−1(r),j · 1 (cid:96)  ≤ Lemma 17 ≤ max (cid:96)∈[k] r=((cid:96)−1)/+1 Costs csub−1(r),j can be general and they could be hard to analyze. Therefore we would like to remove costs from the analysis. We will use Lemma 18 for which the technique of splitting variables 9 Yi into Zr was needed. We are using the fact that the variables Zr have the same expected values; i , i.e., not monotonic. Thus otherwise the coefficient in front of the expected value would be cij · y∗ Consider the expected value in the above expression for a fixed r ∈ {((cid:96)−1)/ + 1, . . . , (cid:96)/}: (cid:35) . (cid:12)(cid:12)(cid:12)(cid:12)Zr = 1  = (cid:12)(cid:12)(cid:12)(cid:12)Zr = 1  . (cid:12)(cid:12)(cid:12)(cid:12)Zr = 1 Zr(cid:48) = t − 1 (13) (14) Lemma 18 ≤ max (cid:96)∈[k] (cid:34) 1 +(cid:80)r−1  r−1(cid:88) (cid:96)(cid:88) Pr 1 t r(cid:48)=1 t=1 1 r(cid:48)=1 Zr(cid:48) = Zr(cid:48) = t − 1 Er = E Pr Zr(cid:48) = t − 1 (cid:34) 1 r(cid:48)=1 Zr(cid:48) r(cid:48)=1 1 +(cid:80)r−1  r−1(cid:88) k(cid:88)  r−1(cid:88)  , (cid:12)(cid:12)(cid:12)(cid:12)Zr = 1  = (cid:12)(cid:12)(cid:12)(cid:12)Zr = 1 r(cid:48)=1 1 t Pr t=(cid:96)+1 E = t=1 1 t r=((cid:96)−1)/+1 (cid:96)/(cid:88)  · (cid:96) · (cid:35) (cid:12)(cid:12)(cid:12)(cid:12)Zr = 1 k(cid:88)  + (cid:12)(cid:12)(cid:12)(cid:12)Zr = 1  r−1(cid:88)  r−1(cid:88) k(cid:88) r(cid:48)=1 r(cid:48)=1 k(cid:88) k(cid:88) 1 t t=(cid:96)+1 (cid:96)(cid:88) 1 t For t ∈ {1, 2, . . . , (cid:96)} we consider the conditional probability in the above expression, denote it by pr(t − 1), and analyze the corresponding cumulative distribution function Hr(t − 1): pr(t − 1) = Pr Zr(cid:48) = t − 1 Hr(t − 1) = Pr Zr(cid:48) ≤ t − 1 (cid:48) pr(t ), (15) (16) t−1(cid:88) t(cid:48)=0 We continue the analysis of Er: Er (14),(15) = pr(t − 1) + t=(cid:96)+1 1 t pr(t − 1) (cid:96)(cid:88) (cid:96)(cid:88) t=2 t=2 1 t 1 t (cid:96)(cid:88) t=1 1 t t=1 (cid:96)(cid:88) (cid:96)−1(cid:88) (cid:96)−1(cid:88) (cid:96)−1(cid:88) t=1 t=1 1 t (cid:18) 1 (16) = Hr(0) + (Hr(t − 1) − Hr(t − 2)) + pr(t − 1) = = = ≤ = Hr(0) + Hr(t − 1) − 1 t Hr(t − 1) − (cid:96)−1(cid:88) (cid:96)−1(cid:88) t=1 t=1 (cid:19) t + 1 1 1 Hr(t − 1) − t + 1 1 t + 1 t − Hr(t − 1) + 1 t pr(t − 1) t=(cid:96)+1 t=2 1 t t=(cid:96)+1 Hr(t − 2) + Hr(t − 1) + Hr(t − 1) + k(cid:88) Hr((cid:96) − 1) + Hr((cid:96) − 1) + k(cid:88) 1 (cid:96) 1 (cid:96) t=(cid:96)+1 pr(t − 1) k(cid:88) t=l+1 Hr((cid:96) − 1) + 1 t pr(t − 1)  k(cid:88) t=(cid:96)+1 pr(t − 1)  pr(t − 1) 1 Hr(t − 1) + 1 (cid:96) t(t + 1) t=1 10 (cid:96)−1(cid:88) t=1 ≤ 1 t(t + 1) Hr(t − 1) + 1 (cid:96) . (17) Lemma 7. For any (cid:96) ∈ [k], t ∈ [(cid:96) − 1] and r ∈ {((cid:96)−1)/ + 1, ((cid:96)−1)/ + 2, . . . , (cid:96)/} we have (cid:16) e · r ·  (cid:17)t . Hr(t − 1) ≤ e −r· · t The proof of Lemma 7 combines the use of the BNA property of variables {Z1, Z2, . . . , Zk/} with applications of Chernoff-Hoeffding bounds. Due to the space constraints, the proof is moved to the Appendix C. In the end, we get the following bound on the approximation ratio. Lemma 8. For any j ∈ [n] we have E[costj(Y )] OPTLP j ≤ 2.3589. A proof uses inequalities (13), (17) as well as Lemma 7 with an upper bound derived by an integral of the function ft(x) = e−x. We made numerical calculation for (cid:96) ∈ {1, 2, . . . , 88} and for other case we used Stirling formula and Taylor series for e(cid:96) to derive analytical upper bound. Full proof, including a plot of numericaly obtained values, is presented in the Appendix C. 3 OWA k-median with Costs Satisfying the Triangle Inequality In this section we construct an algorithm for OWA k-median with costs satisfying the triangle inequality. Thus, the problem we address in this section is more general than Harmonic k-median (i.e., the problem we have considered in the previous section) in a sense that we allow for arbitrary non-increasing sequences of weights. On the other hand, it is less general in a sense that we require the costs to form a specific structure (a metric). In our approach we first adapt the algorithm of Hajiaghayi et al. [20] for Fault Tolerant k-median so that it applies to the following, slightly more general setting: for each client Dj we introduce its multiplicity mj ∈ N-intuitively, this corresponds to cloning Dj and co-locating all such clones in the same location as Dj. However, this will require a modification of the original algorithm for Fault Tolerant k-median, since we want to allow the multiplicities {mj}Dj∈D to be exponential with respect to the size of the instance (otherwise, we could simply copy each client a sufficient number of times, and use the original algorithm of Hajiaghayi et al.). Next, we provide a reduction from OWA k-median to such a generalization of Fault Tolerant k-median. The resulting Fault Tolerant k-median with Clients Multiplicities problem can be cast as the following integer program: min n(cid:88) j=1 m(cid:88) m(cid:88) i=1 i=1 mj · xij · cij yi = k m(cid:88) xij = rj i=1 yi, xij ∈ {0, 1} xij ≤ yi mj ∈ N 11 ∀j ∈ [n] ∀i ∈ [m], j ∈ [n] ∀i ∈ [m] ∀j ∈ [n] Reduction. Let us take an instance I of OWA k-median(cid:0) Dj,1, Dj,2, . . . , Dj,k with requirements 1, 2, . . . , k, respectively. For Q =(cid:81)k , i ∈ [k] are rational numbers in the canonical form. We construct an instance I(cid:48) of wi = pi qi Fault Tolerant k-median with Clients Multiplicities with the same set of facilities and the same number of facilities to open, k. Each client Dj ∈ D is replaced with clients r=1 qr, the multiples of the clients are defined as follows: D,F, k, w,{cij}Fi∈F ,Dj∈D(cid:1) where • mj,(cid:96) = (w(cid:96) − w(cid:96)+1) · Q, for each (cid:96) ∈ [k − 1], and • mj,k = wk · Q. Figure 3: Reduction from OWA k-median to Fault Tolerant k-median with Clients Multiplicities. Theorem 9. There is a polynomial-time 93-approximation algorithm for Metric Fault Tolerant k-median with Clients Multiplicities. Proof can be found in the Appendix D. Consider reduction from OWA k-median to Fault Tolerant k-median with Clients Multiplicities depicted on Figure 3. Lemma 10. Let I be an instance of OWA k-median, and let I(cid:48) be an instance of Fault Tolerant k-median with Clients Multiplicities constructed from I through reduction from Figure 3. An α-approximate solution to I(cid:48) is also an α-approximate solution to I. Proof can be found in the Appendix D. Corollary 11. There exists a 93-approximation algorithm for Metric OWA k-median that runs in polynomial time. 4 Concluding Remarks and Open Questions We have introduced a new family of k-median problems, called OWA k-median, and we have shown that our problem with the harmonic sequence of weights allows for a constant factor approximation even for general (non-metric) costs. This algorithm applies to Proportional Approval Voting. In the analysis of our approximation algorithm for Harmonic k-median, we used the fact that the dependent rounding procedure satisfies Binary Negative Association. We showed that any Metric OWA k-median can be approximated within a factor of 93 via a reduction to Fault Tolerant k-median with Clients Multiplicities. We also obtained that OWA k-median with p-geometric weights with p < 1/e cannot be approximated without the assumption of the costs being metric. The status of the non-metric problem with p-geometric weights with p > 1/e remains an intriguing open problem. Using approximation and randomized algorithms for finding winners of elections requires some comment. First, the multiwinner election rules such as PAV have many applications in the voting theory, recommendation systems and in resource allocation. Using (randomized) approximation algorithms in such scenarios is clearly justified. However, even for other high-stake domains, such as 12 political elections, the use of approximation algorithms is a promising direction. One approach is to view an approximation algorithm as a new, full-fledged voting rule (for more discussion on this, see the works of Caragiannis et al. [7, 8], Skowron et al. [33], and Elkind et al. [15]). In fact, the use of randomized algorithms in this context has been advocated in the literature as well-e.g., one can arrange an election where each participant is allowed to suggest a winning committee, and the best out of the suggested committees is selected; in such case the approximation guaranty of the algorithm corresponds to the quality of the outcome of elections (for a more detailed discussion see [33]) 2. Nonetheless, we think that it would be beneficial to learn whether our algorithm can be efficiently derandomized. Acknowledgments. We thank Ola Svensson and Aravind Srinivasan for their helpful and insightful comments. J. Byrka was supported by the National Science Centre, Poland, grant number 2015/18/E/ST6/00456. P. Skowron was supported by a Humboldt Research Fellowship for Postdoctoral Researchers. K. Sornat was supported by the National Science Centre, Poland, grant number 2015/17/N/ST6/03684. References [1] S. Ahmadian, A. Norouzi-Fard, O. Svensson, and J. Ward. Better guarantees for k-means and euclidean k-median by primal-dual algorithms. In Proceedings of the 58th IEEE Symposium on Foundations of Computer Science, pages 61–72, 2017. [2] N. Ailon, M. Charikar, and A. Newman. Aggregating inconsistent information: Ranking and clustering. Journal of the ACM, 55(5):23:1–23:27, 2008. [3] A. Auger and B. Doerr. Theory of randomized search heuristics: Foundations and recent developments. World Scientific Publishing, 2011. [4] H. Aziz, M. Brill, V. Conitzer, E. Elkind, R. Freeman, and T. Walsh. Justified representation in approval-based committee voting. Social Choice and Welfare, 48(2):461–485, 2017. [5] M. Brill, J-F. Laslier, and P. Skowron. Multiwinner approval rules as apportionment methods. In Proceedings of the 31st AAAI Conference on Artificial Intelligence, pages 414–420, 2017. [6] J. Byrka, T. Pensyl, B. Rybicki, A. Srinivasan, and K. Trinh. An improved approximation for k -median and positive correlation in budgeted optimization. ACM Transactions on Algorithms, 13(2):23:1–23:31, 2017. [7] I. Caragiannis, J. A. Covey, M. Feldman, C. M. Homan, C. Kaklamanis, N. Karanikolas, A. D. Procaccia, and J. S. Rosenschein. On the approximability of Dodgson and Young elections. Artificial Intelligence, 187:31–51, 2012. 2Indeed, approximation algorithms for many election rules have been extensively studied in the literature. In the world of single-winner rules, there are already very good approximation algorithms known for the Kemeny's rule [2, 10, 24] and for the Dodgson's rule [30, 22, 7, 16, 8]. A hardness of approximation has been proven for the Young's rule [7]. For the multiwinner case we know good (randomized) approximation algorithms for Minimax Approval Voting [11], Chamberlin–Courant rule [33], Monroe rule [33], or maximization variant of PAV [32]. 13 [8] I. Caragiannis, C. Kaklamanis, N. Karanikolas, and A. D. Procaccia. Socially desirable approximations for Dodgson's voting rule. ACM Transactions on Algorithms, 10(2):6:1–6:28, 2014. [9] B. Chamberlin and P. Courant. Representative deliberations and representative decisions: Proportional representation and the Borda rule. American Political Science Review, 77(3):718– 733, 1983. [10] D. Coppersmith, L. Fleischer, and A. Rudra. Ordering by weighted number of wins gives a good ranking for weighted tournaments. ACM Transactions on Algorithms, 6(3):55:1–55:13, 2010. [11] M. Cygan, (cid:32)L. Kowalik, A. Soca(cid:32)la, and K. Sornat. Approximation and parameterized com- plexity of minimax approval voting. In Proceedings of the 31st AAAI Conference on Artificial Intelligence, pages 459–465, 2017. [12] I. Dinur and D. Steurer. Analytical approach to parallel repetition. In Proceedings of the 46th ACM Symposium on Theory of Computing, pages 624–633, 2014. [13] D. P. Dubhashi, J.Jonasson, and D. Ranjan. Positive influence and negative dependence. Combinatorics, Probability and Computing, 16(1):29–41, 2007. [14] C. Dwork, R. Kumar, M. Naor, and D. Sivakumar. Rank aggregation methods for the web. In Proceedings of the 10th International World Wide Web Conference, pages 613–622, 2001. [15] E. Elkind, P. Faliszewski, P. Skowron, and A.i Slinko. Properties of multiwinner voting rules. Social Choice and Welfare, 48(3):599–632, 2017. [16] P. Faliszewski, E. Hemaspaandra, and L. A. Hemaspaandra. Multimode control attacks on elections. Journal of Artificial Intelligence Research, 40:305–351, 2011. [17] P. Faliszewski, J. Sawicki, R. Schaefer, and M. Smolka. Multiwinner voting in genetic algorithms for solving ill-posed global optimization problems. In Proceedings of the 19th International Conference on the Applications of Evolutionary Computation, pages 409–424, 2016. [18] R. Gandhi, S. Khuller, S. Parthasarathy, and A. Srinivasan. Dependent rounding and its applications to approximation algorithms. Journal of the ACM, 53(3):324–360, 2006. [19] M. R. Garey and D. S. Johnson. Computers and Intractability: A Guide to the Theory of NP-Completeness. W. H. Freeman, 1979. [20] M. T. Hajiaghayi, W. Hu, J. Li, S. Li, and B. Saha. A constant factor approximation algorithm for fault-tolerant k -median. ACM Transactions on Algorithms, 12(3):36:1–36:19, 2016. [21] D.S. Hochbaum and D.B. Shmoys. A best possible heuristic for the k -center problem. Mathe- matics of Operations Research, 10(2):180–184, 1985. [22] C. M. Homan and L. A. Hemaspaandra. Guarantees for the success frequency of an algorithm for finding Dodgson-election winners. Journal of Heuristics, 15(4):403–423, 2009. [23] K. Joag-Dev and F. Proschan. Negative association of random variables with applications. The Annals of Statistics, 11(1):286–295, 1983. 14 [24] C. Kenyon-Mathieu and W. Schudy. How to rank with few errors. In Proceedings of the 39th ACM Symposium on Theory of Computing, pages 95–103, 2007. [25] D. Kilgour. Approval balloting for multi-winner elections. In J. Laslier and R. Sanver, editors, Handbook on Approval Voting, pages 105–124. Springer, 2010. [26] J. M. Kleinberg, C. H. Papadimitriou, and P. Raghavan. Segmentation problems. Journal of the ACM, 51(2):263–280, 2004. [27] J. B. Kramer, J. Cutler, and A. J. Radcliffe. Negative dependence and Srinivasan's sampling process. Combinatorics, Probability and Computing, 20(3):347–361, 2011. [28] T. Lu and C. Boutilier. Budgeted social choice: From consensus to personalized decision making. In Proceedings of the 22nd International Joint Conference on Artificial Intelligence, pages 280–286, 2011. [29] T. Lu and C. Boutilier. Value-directed compression of large-scale assignment problems. In Proceedings of the 29th AAAI Conference on Artificial Intelligence, pages 1182–1190, 2015. [30] J. C. McCabe-Dansted, G. Pritchard, and A. M. Slinko. Approximability of dodgson's rule. Social Choice and Welfare, 31(2):311–330, 2008. [31] B. Monroe. Fully proportional representation. American Political Science Review, 89(4):925–940, 1995. [32] P. Skowron, P. Faliszewski, and J. Lang. Finding a collective set of items: From proportional multirepresentation to group recommendation. Artificial Intelligence, 241:191–216, 2016. [33] P. Skowron, P. Faliszewski, and A. M. Slinko. Achieving fully proportional representation: Approximability results. Artificial Intelligence, 222:67–103, 2015. [34] A. Srinivasan. Distributions on level-sets with applications to approximation algorithms. In Proceedings of the 42nd IEEE Symposium on Foundations of Computer Science, pages 588–597, 2001. [35] C. Swamy and D.B. Shmoys. Fault-tolerant facility location. ACM Transactions on Algorithms, 4(4):51:1–51:27, 2008. [36] T. N. Thiele. Om flerfoldsvalg. In Oversigt over det Kongelige Danske Videnskabernes Selskabs Forhandlinger, pages 415–441. 1895. [37] R. R. Yager. On ordered weighted averaging aggregation operators in multicriteria decision- making. IEEE Trans. Systems, Man, and Cybernetics, 18(1):183–190, 1988. A Dependent Rounding and Negative Association Consider a vector of m variables (yi)i∈[m], and let y∗ For simplicity we will assume that 0 ≤ y∗ i denote the initial value of the variable yi. i is an integer. A rounding procedure takes this vector of (fractional) variables as an input, and transforms it into a vector of 0/1 integers. We focus on a specific rounding procedure studied by Srinivasan [34] which we refer to as dependent rounding (DR). i ≤ 1 for each i, and that k =(cid:80) i∈[m] y∗ 15 i + y(cid:48) i and y(cid:48) j so that y(cid:48) j = yi + yj, and so that y(cid:48) DR works in steps: in each step it selects two fractional variables, say yi and yj, and changes the values of these variables to y(cid:48) j is an integer. Thus, after each iteration at least one additional variable becomes an integer. The rounding procedure stops, when all variables are integers. In each step the randomization is involved: with some probability p variable yi is rounded to an integer value, and with probability 1 − p variable yj becomes an integer. The value of the probability p is selected so as to preserve the expected value of each individual entry yi. Clearly, if yi + yj ≥ 1, then one of the variables is rounded to 1; otherwise, one of the variables is rounded to 0. For example, if yi = 0.4 and yj = 0.8, then with probability 0.25 the values of the variables yi and yj change to, respectively, 1 and 0.2; and with probability 0.75 they change to, respectively, 0.2 and 1. If yi = 0.3 and yj = 0.2, then with probability 0.4 the values of the two variables change to, respectively, 0 and 0.5; and with probability 0.6, to, respectively, 0.5 and 0. i or y(cid:48) Let Yi denote the random variable which returns one if yi is rounded to one after the whole rounding procedure, and zero, otherwise. It was shown [34] that the DR generates distributions of Yi which satisfy the following three properties: Marginals. Pr[Yi = 1] = y∗ i , Sum Preservation. Pr[(cid:80) Negative Correlation. For each S ⊆ [m] it holds that Pr[(cid:86) (cid:81) i Yi = k] = 1, Pr[(cid:86) i∈S Pr[Yi = 0]. i∈S(Yi = 0)] ≤ (cid:81) i∈S(Yi = 1)] ≤ i∈S Pr[Yi = 1], and These three properties are often used in the analysis of approximation algorithms based on dependent rounding for various optimization problems-see, e.g., [18]. In fact, DR satisfies an even stronger property than NC, called conditional negative association (CNA) [27], yet, to the best of our knowledge, this property has never been used before for analyzing algorithms based on the DR procedure. For two random variables, X and Y , by cov[X, Y ] we denote the covariance between X and Y . Recall that cov[X, Y ] = E[XY ] − E[X] · E[Y ]. Negative Association [23]. For each S, Q ⊆ [m] with S ∩ Q = ∅, s = S, and q = Q, and each two nondecreasing functions, f : [0, 1]s → R and g : [0, 1]q → R, it holds that: cov(cid:2)f (Yi : i ∈ S), g(Yi : i ∈ Q)(cid:3) ≤ 0. Conditional Negative Association. We say that the sequence of random variables (Yi)i∈[m] satisfies the CNA property if the conditional variables (Y[m]\SYS = a) satisfy NA for any S ⊆ [m] and any a = (ai)i∈S. For S = ∅, CNA is equivalent to NA. It was shown by Dubhashi et al. [13] that if one rounds the variables according to a predefined linear order over the variables (cid:31) (i.e., if one always chooses for rounding the two fractional variables which are earliest in (cid:31)), then the resulting distribution satisfies CNA. Yet, the requirement of following a predefined linear order of variables is too restrictive for our needs. Then, Kramer et al. [27] showed that DR following a predefined order on pairs of variables that implements a tournament tree returns a distribution satisfying CNA. In our analysis we will use a simpler version of the NA property, which nevertheless is expressive enough for our needs. We introduce the following property. 16 Binary Negative Association (BNA). For each S, Q ⊆ [m] with S ∩ Q = ∅, s = S, and q = Q, and each two nondecreasing functions, f : {0, 1}s → {0, 1} and g : {0, 1}q → {0, 1}, we have: cov(cid:2)f (Yi : i ∈ S), g(Yi : i ∈ Q)(cid:3) ≤ 0. From the definitions it is easy to see that CNA =⇒ NA =⇒ BNA. A.1 BNA is Strictly Stronger than NC We now argue that BNA is a strictly stronger property than NC. First we show a straightforward inductive argument that BNA implies NC. Next we provide an example of a distribution that satisfies NC but not BNA. In fact, this distribution is generated by a not-careful-enough implementation of DR. Lemma 12. For two binary random variables X, and Y , X, Y ∈ {0, 1}, the condition cov[X, Y ] ≤ 0 is equivalent to Pr[X = 1 ∧ Y = 1] ≤ Pr[X = 1] · Pr[Y = 1]. Proof. Observe that for binary variables, X and Y , it holds that E[X] = Pr[X = 1], E[Y ] = Pr[Y = 1], and E[XY ] = Pr[X = 1 ∧ Y = 1]. Lemma 13. Binary Negative Association of (Yi)i∈[m] implies their Negative Correlation. Proof. We will prove the NC property by induction on S. Clearly, the property holds for S = 1. i∈S/{j}(Yi = 1) and g(Yj) = (Yj = 1) for any j ∈ S. For an inductive step, we define two non-decreasing functions f (Yi : i ∈ S/{j}) =(cid:86)   · Pr [Yj = 1] (Yi = 1) ∧ Yj = 1 (cid:34)(cid:94) BNA, Lemma 12 (Yi = 1) (Yi = 1) i∈S/{j} (cid:35) i∈S ≤ Pr Pr =  (cid:94)  (cid:94) (cid:89) Pr i∈S/{j} i∈S(Yi = 0) we define two other non-decreasing functions inductive assum. ≤ i∈S Pr[Yi = 1]. i∈S/{j}(Yi > 0) and g(Yj) = (Yj > 0) for any j ∈ S. In order to bound the probability of(cid:86) f (Yi : i ∈ S/{j}) =(cid:87) (cid:35) (cid:34)(cid:95) Pr(cid:2)(cid:86)  (cid:95)  + Pr [Yj > 0] − Pr  (cid:95)  − Pr [Yj > 0] + Pr i∈S(Yi = 0)(cid:3) = 1 − Pr  (cid:95) Pr  (cid:94) = 1 − (Yi = 0) (Yi > 0) (Yi > 0) i∈S/{j} i∈S/{j} = Pr i∈S i∈S/{j} (Yi > 0) ∧ Yj > 0  (Yi > 0) ∧ Yj > 0 i∈S/{j}  17 Figure 4: An illustration of Example 14. BNA, Lemma 12 ≤ (Yi = 0) i∈S/{j} Pr  (cid:94)  (cid:94)  (cid:94) i∈S/{j} i∈S/{j} (Yi = 0) (Yi = 0)  − Pr [Yj > 0] + Pr  (cid:95)  − Pr [Yj > 0] · Pr  (cid:94)  · Pr [Yj = 0] (cid:89) inductive assum. i∈S/{j} ≤ i∈S = Pr = Pr  · Pr [Yj > 0] (Yi > 0) i∈S/{j} (Yi = 0)  Pr[Yi = 0]. Note that the general formulation of DR does not specify how the pairs of fractional variables are selected. The proof in [34] that DR satisfies NC is independent of the method in which these pairs of fractional variables are selected. We will now show that, if these pairs are selected by an adaptive adversary who may take into account the way in which the previous pairs were rounded, then the BNA property may not hold (so, also neither NA nor CNA). Consider the following example. Example 14. Consider m = 8, k = 4, and the vector of variables (yi)i∈[8], all with the same initial value 1/2. Let S = {2, 3, 4}, Q = {5}, and: f (Y2, Y3, Y4) = if Y2 + Y3 + Y4 ≥ 2 otherwise g(Y5) = Y5. (cid:40) 1 0 Let α and β denote the events that Y2 + Y3 + Y4 ≥ 2 and that Y5 = 1, respectively. BNA would require that Pr[α ∧ β] ≤ Pr[α] · Pr[β]. Consider DR procedure as depicted in the following diagram (the paired variables are enclosed in rounded rectangles). First, we pair variables y1 with y5 and y2 with y6. The way in which the remaining variables are paired depends on the result of rounding within pairs (y1, y5) and (y2, y6). If y1 and y2 are both rounded to the same integer, then we pair y3 with y7 and y4 with y8. Otherwise, we pair y3 with y4 and y7 with y8. 18 y1y2y3y41/21/21/21/2y5y6y7y81/21/21/21/2y1y2y3y4111/21/2y5y6y7y8001/21/2y1y2y3y4101/21/2y5y6y7y8011/21/2y1y2y3y4011/21/2y5y6y7y8101/21/2y1y2y3y4001/21/2y5y6y7y8111/21/2Pr[α]=3/4Pr[α]=0Pr[α]=1Pr[α]=1/4β¬β ⊥ y1 = 0.2 y6 = 0.8 y1 = 0.2 ⊥ y5 = 0.2 y6 = 0.6 y1 = 0.7 y2 = 0.5 y3 = 0.5 y4 = 0.5 Figure 5: An example run of DR using a tournament tree structure. In this example the result is: y2, y3, y6 = 1, and y1, y4, y5 = 0. Note that according to DR each rounding decision is taken with the same probability (e.g., when we pair variables y1 with y5, then the probabilities of y1 and y5 rounded to one is the same). Thus, we observe that Pr[α] = 1/2, Pr[β] = 1/2, but Pr[α ∧ β] = 1/4 + 1/16. Example 14 is simpler than the one given by Kramer et al. [27]. Both examples show that NA is a strictly stronger property than NC. Kramer et al. use the set of 7 variables with initial values equal to 3/7, k = 4, and a predefined order on pairs of variables. Our example uses an adaptive adversary who decides which pair of variables should be rounded in each step of the rounding procedure. Our example cannot be implemented by fixing an order on pairs of variables (hence it also cannot be implemented by fixing a tournament tree). Our 8 variables have marginal probabilities equal to 1/2, thus the example can be easily understood, and one does not need to calculate probabilities of choosing all(cid:0)7 (cid:1) 4-element sets. 4 A.2 Fixed Tournament Pairings Ensure BNA The method in which fractional elements are paired together can be thought of as a subset of rules of a sports tournament, in which losers drop out of the game, but winners remain and are being paired up for the following games. The above example shows that an awkward adaptive pairing of remaining players may influence the value of certain functions on the subsets of players. We will show that if the competition is organized by a standard fixed upfront tournament tree, then such manipulations are not possible, which allows to prove BNA for the outcome of the DR process following such tree. Intuitively, the way in which the variables are paired should be, in some sense, independent of the result of previous roundings. We consider a fixed binary tree with m leaves-each leaf containing one variable yi with value y∗ i , so that each variable is put in exactly one leaf; the other nodes are temporarily empty. In each step, the algorithm selects two nonempty nodes, say n1 and n2, with a common empty parent, and applies the basic step of the DR procedure to the two variables in nodes n1 and n2. As a result at least one of the variables becomes an integer. If one of the variables is still fractional, we promote this variable with its new value to the parent node. If both variables become integers (which happens when their sum is equal to one), we promote a fake variable ⊥ to the parent node. When we compare any variable v with ⊥, we always promote v with its current value to the parent node. An example run of such implementation of the DR procedure is depicted in Figure 5. 19 Hereinafter we assume that the DR procedure uses a fixed tournament tree structure, as described above. Theorem 15. The DR algorithm using a tournament tree structure guarantees BNA. The proof follows from Theorem 5 in [27]. The theorem says that DR using a tournament tree structure produces distributions satisfying the NA property; clearly, NA implies BNA. However, to make the paper self-contained, we provide our inductive proof of Theorem 15 in the remainder of the section. Our proof uses induction on the number of fractional variables; Kramer et al. [27] use induction on the number of leaves in the tournament tree. While the two proofs use similar ideas and are of a similar difficulty, our proof is slightly more direct and shorter. Proof of Theorem 15. Recall that Yi is a random variable that indicates whether or not the described DR procedure rounds yi to 1. Let S, Q ⊆ [m] with S ∩ Q = ∅, s = S, and q = Q, and let f : {0, 1}s → {0, 1} and g : {0, 1}q → {0, 1} be two nondecreasing functions. Let α and β denote the events that f (Yi : i ∈ S) = 1 and g(Yi : i ∈ Q) = 1, respectively. For a vector y of m values, which represents the values of the variables (yi)i∈[m] that appear during our rounding procedure by Pr [Ey] we denote the probability that an event E occurs under the condition that we have reached the point of the rounding algorithm where the variables (yi)i∈[m] have values indicated by y. By Lemma 12 it is sufficient to show that the following inequality holds for each y: Pr [α ∧ βy] ≤ Pr [αy] · Pr [βy] . (18) We will prove this statement by induction on the number of fractional variables in y. If y contains only integer variables, then it is clear that Inequality (18) is satisfied. Now assume that Inequality (18) is satisfied whenever y contains at most (cid:96) fractional values. We will show that Inequality (18) is also satisfied when y contains (cid:96) + 1 fractional values. Let y be such vector. Consider a single step of our algorithm, where the two variables yi and yj are paired. Let Ei and Ej denote the events that, respectively, yi and yj, is increased. Similarly, let y(i) and y(j) denote the vectors of the values of the variables (yi)i∈[m] when, respectively, yi and yj is increased. We have: α ∧ βy(i) By our inductive assumption, it holds that: Pr [α ∧ βy] = Pr (cid:104) (cid:105) (cid:104) (cid:104) (cid:105) (cid:105) · Pr [Ei] + Pr α ∧ βy(j) · Pr [Ej] . (cid:104) (cid:104) (cid:105) (cid:105) (cid:104) (cid:105) (19) βy(i) αy(i) αy(j) · Pr βy(j) · Pr [Ej] . · Pr [Ei] + Pr Pr [α ∧ βy] ≤ Pr · Pr Now, we consider the following cases: Case 1: i, j /∈ S. Observe that either the fake variable ⊥ is promoted to the parent node or one of the variables: yi and yj. Observe that irrespectively of which of the two variables is promoted to the parent, the promoted variable will always hold the same new value. Further, observe that the subsequent rounding steps do not depend on which variable has been promoted to the parent node, but only on the value of the promoted variable. Thus, the rounding within the pair of variables, yi and yj, affects only the probability of events including Yi or Yj (here we use the assumption that the tournament tree is fixed; the way in which the variables are paired does not depend on the result of rounding within the pair (yi, yj)). In particular, = Pr [αy]. We can rewrite Inequality (19) as follows: Pr = Pr [αy] and Pr αy(j) αy(i) (cid:105) (cid:104) (cid:104) (cid:104) (cid:105) Pr [α ∧ βy] ≤ Pr [αy] · Pr βy(i) · Pr [Ei] + Pr [αy] · Pr βy(j) · Pr [Ej] (cid:105) (cid:104) (cid:105) 20 (cid:16) (cid:104) (cid:105) (cid:105) (cid:104) βy(j) · Pr [Ej] (cid:17) · Pr [Ei] + Pr Pr = Pr [αy] βy(i) = Pr [αy] · Pr [βy] . Case 2: i, j /∈ Q. The same reasoning but applied to β rather than to α, leads to the same conclusion. Case 3: i ∈ S and j ∈ Q (the case when i ∈ Q and j ∈ S is symmetric). As a result of round- ing, one of the variables, yi and yj, increases, and the other one decreases. Let us analyze what happens when yi increases and yj decreases, i.e., when event Ei occurs. By the same reasoning as in Case 1, we infer that the fact that yi is increased does not influence the further process of rounding other variables than yi and yj. At the same time when yi is increased, it becomes more likely that this variable will eventually become one, in comparison to the case when yj is increased: (i) If yi + yj ≥ 1, then yi being increased means that yi becomes one right away. (ii) Otherwise, i.e., if yi + yj < 1: if yi is increased, it is still positive so it is still possible that it will eventually become one. On the other hand, if yj is increased, then yi is rounded down to zero, which makes it impossible for yi to become one. Since the function f is nondecreasing we infer that Pr ≤ Pr reasoning allows us to conclude that Pr following claim: βy(i) αy(i) βy(j) ≥ Pr αy(j) . The same . This is summarized in the (cid:104) (cid:105) (cid:104) (cid:104) (cid:104) (cid:105) (cid:105) (cid:105) (cid:105) (cid:105) Claim 1. Pr αy(i) ≥ Pr αy(j) βy(i) ≤ Pr βy(j) . (cid:104) (cid:105) (cid:105) (cid:104) (cid:104) (cid:105) (cid:105) At the same time: Pr βy(i) · Pr [Ei] + Pr (cid:104) (cid:104) Claim 2. It holds that: (i) Pr (ii) Pr βy(i) βy(j) Pr [Ei] ≤ Pr [βy] Pr [Ei], and Pr [Ej] ≥ Pr [βy] Pr [Ej]. (cid:104) (cid:105) (cid:104) and Pr (cid:105) βy(j) (cid:104) (cid:104) (cid:105) · Pr [Ej] = Pr [βy] = Pr [βy](cid:0)Pr [Ei] + Pr [Ej](cid:1). (20) (cid:105) (cid:104) get that also Pr Proof of Claim 2. For the sake of contradiction, let us assume that one of these inequalities Pr [Ei] > Pr [βy] Pr [Ei]. By Equality (20) we is not satisfied, say assume that Pr Pr [Ej] < Pr [βy] Pr [Ej]. In these two conditions we can reduce > Pr [βy] and > the factors Pr [Ei] and Pr [Ej], respectively, and obtain that Pr < Pr [βy]. By combining these two inequalities, we get that Pr , which contradicts Claim 1. βy(j) βy(i) βy(i) βy(i) Pr Pr (cid:104) (cid:104) (cid:105) (cid:105) (cid:104) (cid:105) (cid:104) (cid:105) βy(j) βy(j) Now, we continue the proof of Theorem 15. We will apply Lemma 19 with: (cid:104) (cid:105) (cid:104) (i) a1 = Pr αy(i) , a2 = Pr αy(j) (cid:105) , 21 (cid:104) (cid:104) (cid:104) (cid:105) (cid:105) (cid:105) (cid:104) (cid:105) (cid:104) (cid:104) (cid:104) (cid:105) (cid:105) βy(i) Pr [Ei], b2 = Pr (ii) b1 = Pr (iii) c1 = Pr [βy] Pr [Ei], and c2 = Pr [βy] Pr [Ej]. (a1 ≥ a2 by Claim 1; c1 ≥ b1 and b2 ≥ c2, by Claim 2; b1 + b2 = c1 + c2 by Equality (20)). We get that: βy(j) Pr [Ej], (cid:105) (cid:104) (cid:105) (cid:104) (cid:105) Pr Pr αy(i) αy(i) · Pr [Ei] + Pr βy(i) · Pr · Pr [βy] · Pr [Ei] + Pr αy(j) · Pr βy(j) · Pr [Ej] ≤ αy(j) · Pr [βy] · Pr [Ej] . Combining the above inequality with Inequality (19), we infer that: Pr [α ∧ βy] ≤ Pr (cid:16) (cid:104) (cid:105) αy(i) Pr · Pr [βy] · Pr [Ei] + Pr αy(i) · Pr [Ei] + Pr αy(j) αy(j) (cid:17) · Pr [βy] · Pr [Ej] · Pr [Ej] = Pr [βy] = Pr [βy] · Pr [αy] (cid:104) (cid:104) (cid:105) (cid:105) This proves the inductive step and completes the proof. B Useful Lemmas variables. Let X =(cid:80)n Theorem 16 (Theorem 1.16 from [3]). Let X1, X2, . . . , Xn be negatively correlated binary random i=1 Xi. Then X satisfies the Chernoff-Hoeffding bounds for δ ∈ [0, 1]: Pr [X ≤ (1 − δ)E[X]] ≤ (cid:18) e−δ (1 − δ)(1−δ) (cid:19)µ . Lemma 17. For any sequence (ai)i∈[n] and (bi)i∈[n], bi > 0, it holds: i∈{1,2,...,n} (cid:80)n i=1 ai(cid:80)n i=1 bi ≤ max n(cid:88) bj(cid:80)n (cid:19) n(cid:88) i=1 bi ≤ bj(cid:80)n aj bj · j=1 i=1 bi j=1 = ai bi = max i∈{1,2,...,n} ai bi . ai bi . n(cid:88) j=1 (cid:18) max i∈{1,2,...,n} (cid:19) ai bi bj(cid:80)n i=1 bi = Proof. (cid:80)n i=1 ai(cid:80)n i=1 bi aj(cid:80)n i=1 bi n(cid:88) (cid:18) j=1 max i∈{1,2,...,n} = = Lemma 18. For any non-decreasing sequence (ci)i∈{1,2,...,n}, ci > 0 and any non-increasing sequence (ai)i∈{1,2,...,n} it holds: (cid:80)n (cid:80)n i=1 aici i=1 ci ≤ n(cid:88) i=1 1 n ai. 22 Proof. We prove that by induction. Clearly, we have equality for n = 1. We assume that (cid:33) . (21) ci (cid:80)n−1 (cid:80)n−1 i=1 aici i=1 ci ≤ n−1(cid:88) n(cid:88) aici ≤ i=1 n · i=1 aici ≤ n−1(cid:88) i=1 − (n − 1) · i=1 ai. n−1(cid:88) (cid:33) (cid:32)n−1(cid:88) (cid:33) (cid:32) n(cid:88) i=1 · ci . i=1 1 n − 1 ai · ai i=1 (cid:32)n−1(cid:88) (cid:33) (cid:32) n(cid:88) n−1(cid:88) (cid:35) (cid:35) aici i=1 i=1 n−1(cid:88) n−1(cid:88) i=1 + n−1(cid:88) n−1(cid:88) i=1 ci + an · ci + cn · ai + an · cn − n · n−1(cid:88) i=1 aici − n · an · cn, (an · ci + cn · ai − an · cn − ai · ci) , (ai − an) (cn − ci) . It is equivalent to We would like to show that (n − 1) · We have the following equivalent inequalities: ai (cid:32)n−1(cid:88) (cid:34)(cid:32)n−1(cid:88) (cid:34)(cid:32)n−1(cid:88) i=1 i=1 · (cid:33) (cid:33) (cid:33) ai ai (cid:32)n−1(cid:88) (cid:32)n−1(cid:88) (cid:32)n−1(cid:88) i=1 i=1 · (cid:33) (cid:33) (cid:33) ci 0 ≤ 0 ≤ 0 ≤ · ci − (n − 1) · aici + i=1 i=1 i=1 i=1 Using the inductive assumption (21) and monotonicity of sequences, i.e., 0 ≤ ai − an, 0 ≤ cn − ci we finish the proof. Lemma 19. Let a1, a2, b1, b2, c1, c2 ∈ R be such that a1 ≥ a2, c1 ≥ b1, b2 ≥ c2, and b1 + b2 = c1 + c2. It holds that: a1c1 + a2c2 ≥ a1b1 + a2b2. Proof. We have that b2−c2 = c1−b1 ≥ 0, and so a2(b2−c2) ≤ a1(c1−b1), which can be reformulated as a1(c1 − b1) + a2(c2 − b2) ≥ 0. Thus: a1c1 + a2c2 = a1b1 + a2b2 + a1(c1 − b1) + a2(c2 − b2) ≥ a1b1 + a2b2. C Omitted Proofs from Section 2 Lemma 20. Distribution of {Z1, Z2, . . . , Zk/} satisfies Binary Negative Association. Proof sketch. Note that DR procedure on (Yi)i∈[m] and then independent choice of (Zr)r∈sub(i) for each i ∈ [m] is equivalent to the following implementation of DR on (Zr)r∈{1,2,...,k/}. First, for each i ∈ [m] (Zr)r∈sub(i) are processed until obtaining a single non-zero variable that is equivalent to yi. Then, in the second phase the rounding proceeds as if it had started from the yi variables. Since this process altogether is an implementation of a single DR procedure with fixed tournament tree starting from (Zr)r∈{1,2,...,k/} variables, we can simply apply Theorem 15 and get the statement of the lemma. At this point we note that the result of Dubhashi et al. [13] is not sufficient for proving our lemma. They have proved that DR following a predefined order of variables (which can be viewed 23 ∈ S), g(Zr(cid:48) : r (cid:48) 0 ≥ cov(cid:2)f (Zr(cid:48) : r  k/(cid:88) Pr r(cid:48)=r+1 Therefore, Hr(t − 1) (22) ≤ Pr Pr = (23) ≤ Pr  k/(cid:88)  k/(cid:88)  k/(cid:88) r(cid:48)=r+1 Zr(cid:48) ≥ k − t  , Zr  .  · Pr [Zr = 1] . r(cid:48)=r i=1 ai ≥ k − t  k/(cid:88)  = Pr (cid:12)(cid:12)(cid:12)(cid:12) Zr = 1  . (cid:12)(cid:12)(cid:12)(cid:12) Zr = 1 (cid:111) (cid:110)(cid:80)S  k/(cid:88) 1 ∈ Q)(cid:3) = cov  k/(cid:88)  ≤ Pr  (cid:12)(cid:12)(cid:12)(cid:12) Zr = 1 Zr(cid:48) ≥ k − t r(cid:48)=r+1 r(cid:48)=r+1 (cid:48) r(cid:48)=r+1 Zr(cid:48) ≥ k − t ∧ Zr = 1 Pr [Zr = 1]  = Pr Zr(cid:48) ≥ k − t r(cid:48)=r+1 Zr(cid:48) ≤ t  r(cid:48)=1  r(cid:88)  r(cid:88) r(cid:48)=1  .  , (22) (23) (24) as a linear tournament tree) returns distributions satisfying the CNA property. Here, however, we need to have at least a "two-stage" linear tournament: the first linear tournament on variables (Zr)r∈sub(i) and the second tournament on winning variables from the first tournament. Proof of Lemma 7. Let us fix (cid:96) ∈ [k], t ∈ [(cid:96) − 1] and r ∈ {((cid:96)−1)/ + 1, ((cid:96)−1)/ + 2, . . . , (cid:96)/}. We have  = (cid:12)(cid:12)(cid:12)(cid:12) Zr = 1 Zr(cid:48) ≥ k − (t − 1) Hr(t − 1) (16) = Pr = Pr  r−1(cid:88)  k/(cid:88) r(cid:48)=1 r(cid:48)=r+1 Zr(cid:48) ≤ t − 1 Zr(cid:48) ≥ k − t We now exploit Binary Negative Association of variables Zi (Lemma 20). By setting S = {r + 1, r + 2, . . . , k/}, Q = {r}, f (a1, a2, . . . as) = 1 and g(a) = a we obtain: Since f, g are binary and non-decreasing we can use Lemma 12 to obtain an equivalent inequality: Zr(cid:48) ≥ k − t ∧ Zr = 1 Zr(cid:48) ≥ k − t Using Lemma 20 and Lemma 13 we know that (Zr)r∈{1,2,...,k/} are negatively correlated. What is more, t is smaller than the expected value of the sum t ≤ (cid:96) − 1 = ((cid:96) − 1 + ) −  ≤ r ·  −  < r ·  (9) = E Zr(cid:48) Therefore, we can use Chernoff-Hoeffding bounds as follows (24) Hr(t − 1) ≤ Pr Zr(cid:48) ≤ t  r(cid:88) r(cid:48)=1  24 = Theorem 16 ≤ = Proof of Lemma 8. E[costj(Y )] OPTLP j (13),(14),(17) ≤ = max (cid:96)∈[k] 1 + max (cid:96)∈[k] Lemma 7 ≤ 1 + max (cid:96)∈[k] = 1 + max (cid:96)∈[k] (cid:96) · = 1 + max (cid:96)∈[k] (cid:96) · (cid:19)(cid:19) t r ·  1 − 1 − et−r· · (r · )t (cid:18) t . t e tt Pr (cid:18) = (cid:17)t Zr(cid:48) < r ·  · r(cid:48)=1 r·−1 r·  r(cid:88)  e r· (cid:1) t (cid:0) t (cid:16) e · r ·  r· −r· ·  (cid:96)−1(cid:88)  (cid:96)−1(cid:88)  (cid:96)−1(cid:88)  (cid:96)/(cid:88)  (cid:96)/−1(cid:88) (cid:96)/(cid:88) (cid:96)/(cid:88) (cid:96)/(cid:88) (cid:18) 1 (cid:96)−1(cid:88) (cid:96)−1(cid:88) t(t + 1) · r=((cid:96)−1)/+1 r=((cid:96)−1)/+1 r=((cid:96)−1)/+1 et tt · t=1 1 1 t=1 t=1 t=1 1 t(t + 1) · et tt ·  · (cid:96) ·  · (cid:96) ·  · (cid:96) · t=1 t(t + 1) · Hr(t − 1) t(t + 1) · Hr(t − 1) 1 t(t + 1) · e −r· · (cid:19) + 1 (cid:96)  (cid:16) e · r ·  t (cid:17)t     · e −r· · (r · )t (cid:90) r· e −r· · (r · )t dx r·−  ≤ r=((cid:96)−1)/+1 r=((cid:96)−1)/+1 we now use an upper bound on the most interior sum by an integral of the function ft(x) = e−x · xt. t(x) = e−x · xt−1 · (t − x) ≤ 0 for 1 ≤ t ≤ (cid:96) − 1 ≤ x, so the function f is non-increasing. Note that f(cid:48) Therefore ≤ 1 + max (cid:96)∈[k] (cid:96) · 1 t(t + 1) · et tt · e (cid:96)−1 . (25) To bound the above expression we first numerically evaluate it for (cid:96) ∈ {1, 2, . . . , 88} and obtain 1 + max (cid:96)∈{1,2,...,88} (cid:96) · 1 t(t + 1) · et tt · < 2.3589. It remains to bound the expression for (cid:96) ∈ {89, 90, . . . , k}, which we do by the following estimation: (cid:18)(cid:90) (cid:96) (cid:19) 1 + (cid:96) · 1 t(t + 1) · et tt · e −x · xtdx (cid:96)−1 (cid:96)−1(cid:88) t=1 (cid:96)−1(cid:88) t=1 (cid:96)−1(cid:88) t=1 (cid:18)(cid:90) (cid:96) (cid:18)(cid:90) (cid:96) (cid:19) −x · xtdx (cid:19) (cid:96)−1 e −x · xtdx (cid:96)−1(cid:88) (cid:96)−1(cid:88) t(t + 1) · t=1 1 1 t(t + 1) · t=1 ≤ 1 + (cid:96) · Stirling ≤ 1 + (cid:96) · 25 −((cid:96)−1) · (cid:96)t et tt · e √2πt · e t! 1 12t −((cid:96)−1) · (cid:96)t · e 1 13 12 · e 12 · e ≤ 1 + √2π · e ≤ 1 + √2π · e ≤ 1 + 3√2π · e −((cid:96)−1) · −(cid:96) · −(cid:96) · 12 · e 1 + 3√2π · e 12 · e 1 √(cid:96) 12 · ≤ = 1 + 3√2π · e 13 13 13 Taylor series for e(cid:96) (cid:96)t+1 (t + 1)! · √(cid:96) √t (cid:96)−1(cid:88) t=1 1 √(cid:96) · (cid:96)−1(cid:88) (cid:96)−1(cid:88) t=1 1 √(cid:96) · (cid:96)t+1 (t + 1)! · (cid:96) t (cid:96)t+1 (t + 1)! · (cid:96) t + 2 1 √(cid:96) · −(cid:96) · t=1 1 √(cid:96) · e(cid:96) < 2.3551 < 2.3589. The maximum is obtained for (cid:96) = 4 (see Figure 6). (cid:96) 1 2 3 4 5 6 7 8 9 10 11 12 ratio 1 1.90 2.32 2.3589 2.26 2.11 1.98 1.86 1.78 1.70 1.65 1.60 Figure 6: The numerical and the analytical upper bound on the approximation ratio on intervals ((cid:96) − 1, (cid:96)), for each (cid:96) ∈ [k]. D Omitted Proofs from Section 3 Proof of Theorem 9. We reduce an instance of Fault Tolerant k-median with Clients Mul- tiplicities to an instance of Fault Tolerant k-median by replacing the multiple mj of a client Dj with mj clients in the same location and with the same connectivity requirement (we will call such clients clones of Dj). Observe that there exists an optimal solution in which each clone of the same client is connected to the same set of open facilities. Next, we run the 93-approximation algorithm of Hajiaghayi et al. [20] on such a constructed instance with clones. It is apparent that the solution that we obtain by following this procedure approximates the original instance with 26 1.01.52.02.53.03.54.0lapprox. ratio110203040506070809010042.3589 −− achieved approx. ratioanalytical upper boundnumerical calculation the ratio of 93. However, the issue is that mj can be exponential in the number of clients in the original instance, and so the most straightforward implementation of our reduction does not run in polynomial-time. To deal with that we will efficiently encode the reduced instance, and we will show that the algorithm of Hajiaghayi et al. can be adapted to run on such encoded instances. We proceed as follows. (cid:80)m First, we solve the LP part of the original algorithm [20] with the additional multiplicative factors {mj}Dj∈D added to the objective function. From the solution to the LP, (yi)i∈[m] with i=1 yi = k, we construct an optimal assignment of the clients to the facilities. We encode such an assignment efficiently by grouping all clones of the same client into a single cluster and storing an assignment for a single client for each cluster only (we call such a client the representative of the cluster). In particular, note that all clones in the same cluster have the same assignments and so, they all have the same average and maximal assignment costs. We use this property in the next step of the original algorithm: creating bundles of volume 1 [20, Algorithm 1]. By a careful analysis of this algorithm we can observe that no new bundles are created for a cloned client (lines 5 and 6 of [20, Algorithm 1]) and so that the cloned clients can be considered in bunches. Next, as in the original algorithm, we divide the clients into safe and dangerous by the criterion on the ratio of the maximal and the average cost in the assignment vector. Intuitively, if the maximum is much higher than the average then the client is marked as dangerous (for a formal definition see [20, Section 2.2]), otherwise it is considered safe. Hence, the clones of the same client are either all safe or all dangerous. In the latter case they are also in conflict: they are close and they have the same connectivity requirements (for a definition also see [20, Section 2.2]). Thus, in the filtering phase [20, Algorithm 2] either all the dangerous clones of the same client are filtered out or exactly one of them survives; without loss of generality we can assume that the representative of the cluster survives. In fact, this is the main reason why we can quite easy adapt the algorithm. The next step, that is building a laminar family [20, Algorithm 3], is independent on clients that were filtered out, and so it can be performed on our efficiently encoded instance. The safe clients are not used later on by the algorithm (they are only the side effect of creating bundles and later on they only appear in the algorithm's analysis). Finally, the rounding process of the algorithm ([20, Section 2.3]) depends on the set of constructed bundles and on the set of filtered dangerous clients (and the induced laminar family), and as we discussed it is possible to construct each of the two families with efficient encoding. This completes the proof. Proof of Lemma 10. Let C be an α-approximate solution to I(cid:48). By FT-k-med-multi(C, j) we denote be the total cost of the clients Dj,1, Dj,2, . . . , Dj,k constructed through reduction from Figure 3. Similarly, let OWA-k-med(C, j) be the cost of the client Dj for C in I. For each client Dj we have: → i (C, j) c → mj,r · c i (C, j) → mj,r · c i (C, j) = → mj,r · c i (C, j) r(cid:88) i=1 = (cid:33) k(cid:88) (cid:33) i=1 k(cid:88) k(cid:88) r=1 r=i (cid:32) r(cid:88) i=1 mj,r · r(cid:88) (cid:32) i=1 k(cid:88) r=i → i (C, j) · c mj,r r=1 k(cid:88) k(cid:88) k(cid:88) k(cid:88) r=1 i=1 i=1 FT-k-med-multi(C, j) = = = = → i (C, j) · wi · Q = Q · OWA-k-med(C, j). c 27 Let C∗ I and C∗ I(cid:48) be optimal solutions for I and I(cid:48), respectively. By the same reasoning, we have that: FT-k-med-multi(C ∗ I , j) = Q · OWA-k-med(C ∗ I , j). (cid:88) 1 Q Dj∈D ∗ I(cid:48), j) ≤ α 1 Q (cid:88) Dj∈D FT-k-med-multi(C ∗ I , j) OWA-k-med(C, j) = FT-k-med-multi(C, j) And, thus, that:(cid:88) Dj∈D 1 Q ≤ α (cid:88) (cid:88) Dj∈D Dj∈D FT-k-med-multi(C = α OWA-k-med(C ∗ I , j). This completes the proof. E Hardness of approximation In the main text we have shown that the OWA k-median problem with the harmonic sequence of weights admits very good approximations. In this section we show that for many other natural sequences of weights, the considered problem is hard to approximate, unless we introduce additional assumptions, such as the assumptions that the costs satisfy the triangle inequality. Our hardness results hold already for 0/1 costs. Let us start by considering the OWA k-median problem for a certain specific class of weights. (cid:1) be a sequence of weights used in OWA k-median. Fix For each k ∈ N, let w(k) =(cid:0)w λ ∈ (0, 1). We say that the clients care only about the λ-fraction of facilities if for each k it holds (k) that w i = 0 whenever i > λk. For instance, we say that the clients care only about 90% of facilities if the cost of each client from a set C does not depend on the 10% of worst facilities in C. (k) 1 , . . . , w (k) k First, we prove a simple result which says that if there exists λ such that the clients care only about the λ-fraction of facilities, and if the costs of clients from facilities can be arbitrary, in particular if they cannot be represented as distances satisfying the triangle inequality, then the problem does not admit any approximation. Theorem 21. Fix λ ∈ (0, 1) and consider the problem OWA k-median where clients care only about the λ-fraction of facilities. For any positive computable function α, there exists no polynomial-time α-approximation algorithm for OWA k-median, unless P = NP. Proof. Let us fix a function α and for the sake of contradiction, let us assume that there exists a polynomial time α-approximation algorithm A for OWA k-median. We will show that A can be used to find exact solutions to the exact set cover problem, X3C. This will stay in contradiction with the fact that X3C is NP-hard [19]. Let I be an instance of X3C, where we are given a set of 3n elements E = {e1, . . . , e3n}, and a collection S of subsets of E such that each set in S contains exactly 3 elements from E. We ask if there exists a subcollection C of n subsets from S such that each element from E belongs to exactly one set from C. From I we construct an instance of OWA k-median in the following way. First, we set the size . Let p be the index of the last positive weight in the sequence w(k). of the committee k = Since clients care only about the λ-fraction of facilities, we know that k − p > k − λk ≥ n. Our set of facilities consists of three groups F = S ∪ H ∪ H(cid:48), i.e., we have facilities which correspond to (cid:108) n (cid:109) 1−λ 28 subsets from S and two groups of dummy facilities. We set H = p − 1 and H(cid:48) = k − n − p + 1. Our set of clients consist of two groups D = E ∪ G, where G is the set of dummy clients with G = H(cid:48) . Let us now describe the preferences of clients over facilities. For each client j ∈ F and each dummy facility i ∈ H we set ci,j = 0. Further, for each non-dummy client j ∈ E and a non-dummy facility i ∈ S we set ci,j = 0 if and only if j ∈ i. Finally, we match dummy clients from G with dummy facilities from H(cid:48) so that each client is matched to exactly one facility and each facility to exactly one client, and set ci,j = 0 whenever i and j are matched. For all remaining pairs (i, j) we set ci,j = 1. Let C∗ be an optimal set of facilities. We will show that the total cost of clients from C∗ is 0 if and only if there exists an exact cover for our initial instance I. ( =⇒ ) Assume there exists an exact cover in I-let C denote the collection of n subsets covering all the elements. If we set C∗ = C ∪ H ∪ H(cid:48), then each client has exactly p facilities with distance 0. Note that C∗ = n + p − 1 + k − n − p + 1 = k. For the remaining k − p facilities the weights are equal to zero. Thus, the total cost of clients from C∗ is equal to 0. ( ⇐= ) Assume the total cost of clients from C∗ is equal to 0. In particular, the clients from G need to have cost equal to 0, so H ∪ H(cid:48) must be the part of a winning committee. Similarly, the If there exists a winning committee with the total cost of clients equal to 0, then algorithm A remaining n facilities must correspond to the cover of E. would find such committee. This completes the proof. Hence any approximation for OWA k-median can recognize whether the instance is YES-instance. Next, we prove a more specific hardness result for the p-geometric sequence of weights. Theorem 22. Consider the OWA k-median problem for the p-geometric sequence of weights. For each c < 1, there exists no polynomial-time (n−c ln(p)−1)-approximation algorithm for the problem unless P = NP. Proof. Let us fix c < c(cid:48) < 1. For the sake of contradiction, let us assume that there exists a polynomial-time (n−c ln(p)−1)-approximation algorithm A for our problem. We will show that this algorithm can be used as an c(cid:48) ln(n)-approximation algorithm for the Set Cover problem, which, unless P = NP, will stay in contradiction with the approximation threshold established by Dinur et al. [12]. Let us take an instance I of the Set Cover problem. In I we are given a set of n elements E, a collection S of subsets of E. We ask about minimal k such that there is a subcollection C From I we construct an instance I(cid:48) of OWA k-median as follows. We set P =(cid:80)k of k subsets from S such that each element from E belongs to some set from C. Without loss of generality we can assume that n is big enough to satisfy c ln(n) + 1 < c(cid:48) ln(n). i=1 pi−1 and x = (cid:100)c ln(n) + 1(cid:101), thus c ln(n) + 1 ≤ x ≤ c(cid:48) ln(n). For each element e ∈ E we introduce one client. Further, for each set S ∈ S we introduce x facilities S1, . . . , Sx. The cost of a client e for a facility Si is equal to 0 if and only if e ∈ S; otherwise, it is equal to one. Finally, we guess the optimal solution k to I, and set the size of the desired set of facilities to kfac = k · x. Let us assume that there exist a set cover C of size k for the original instance I. What is the cost of the clients in the optimal solution for I(cid:48)? Let us consider the set of kfac facilities C(cid:48) constructed in the following way: for each set from the cover S ∈ C we take all x facilities that correspond to S and add them to C(cid:48). Observe that each client has cost equal to zero from at least x facilities from C(cid:48). Thus, the total cost of clients from C(cid:48) is at most equal to (recall that P =(cid:80)K i=1 pi−1): wdis(C (cid:48) ) = (cid:48) wdis(C n(cid:88) j=1 , j) ≤ n(cid:0)px + px+1 + . . . + pK−1(cid:1) ≤ 29 ≤ n(cid:0)pc ln(n)+1 + pc ln(n)+2 + . . . + pK−1(cid:1) < npc ln(n) · P = = n · eln(p)·c·ln(n) · P = n · nc ln(p) · P = P nc ln(p)+1. Now, let us take the set of kfac facilities C(cid:48)(cid:48) such that some client has cost equal to one from each facility from C(cid:48)(cid:48). Then, wdis(C(cid:48)(cid:48)) ≥ P . Thus, an (n−c ln(p)−1)-approximation algorithm for OWA k-median with the p-geometric sequence of weights needs to return a solution where each client has cost equal to zero from at least one facility. From such solution, however, we can extract at most kfac sets which form a cover of the original instance. Thus, our algorithm A can be used to find x-approximation solutions for the Set Cover problem (recall that x < c(cid:48) ln(n)), which is impossible under the standard complexity theory assumptions [12]. This completes the proof. Using that we obtain Corollary 23. There is no polynomial-time constant-factor approximation algorithm for the OWA k-median problem for the p-geometric sequence of weights when p < 1/e. 30
1606.06566
1
1606
2016-06-21T13:40:01
Faster Computation of Path-Width
[ "cs.DS" ]
Tree-width and path-width are widely successful concepts. Many NP-hard problems have efficient solutions when restricted to graphs of bounded tree-width. Many efficient algorithms are based on a tree decomposition. Sometimes the more restricted path decomposition is required. The bottleneck for such algorithms is often the computation of the width and a corresponding tree or path decomposition. For graphs with $n$ vertices and tree-width or path-width $k$, the standard linear time algorithm to compute these decompositions dates back to 1996. Its running time is linear in $n$ and exponential in $k^3$ and not usable in practice. Here we present a more efficient algorithm to compute the path-width and provide a path decomposition. Its running time is $2^{O(k^2)} n$. In the classical algorithm of Bodlaender and Kloks, the path decomposition is computed from a tree decomposition. Here, an optimal path decomposition is computed from a path decomposition of about twice the width. The latter is computed from a constant factor smaller graph.
cs.DS
cs
Faster Computation of Path-Width Martin Furer⋆ 1 Department of Computer Science and Engineering Pennsylvania State University University Park, PA 16802, USA 2 Visiting Theoretical Computer Science ETH Zurich Zurich Switzerland [email protected] Abstract. Tree-width and path-width are widely successful concepts. Many NP-hard problems have efficient solutions when restricted to graphs of bounded tree-width. Many efficient algorithms are based on a tree decomposition. Sometimes the more restricted path decomposition is re- quired. The bottleneck for such algorithms is often the computation of the width and a corresponding tree or path decomposition. For graphs with n vertices and tree-width or path-width k, the standard linear time algorithm to compute these decompositions dates back to 1996. Its run- ning time is linear in n and exponential in k3 and not usable in practice. Here we present a more efficient algorithm to compute the path-width and provide a path decomposition. Its running time is 2O(k2)n. In the classical algorithm of Bodlaender and Kloks, the path decomposition is computed from a tree decomposition. Here, an optimal path decomposi- tion is computed from a path decomposition of about twice the width. The latter is computed from a constant factor smaller graph. Keywords: Path-width, tree-width, Bodlaender's algorithm, path de- composition, FPT. ⋆ Research supported in part by NSF Grant CCF-1320814. 6 1 0 2 n u J 1 2 ] S D . s c [ 1 v 6 6 5 6 0 . 6 0 6 1 : v i X r a 2 1 Martin Furer Introduction Tree-width and tree decompositions have been defined by Roberson and Seymour [15]. Independently, Arnborg and Proskurowski [2] introduced the equivalent concept of partial k-trees, as subgraphs of the previously known, simply structured k-trees. Many NP-hard graph problems have very efficient solutions when the graph is given with a tree decomposition of small width. Indeed, Courcelle's meta-theorem [6] says that all prob- lems expressible in monadic second order logic have a linear time solution for graphs of bounded tree-width. Here, the dependence of the running time on the tree-width is allowed to be really bad. Theoretically this con- cept is captured by fixed parameter tractability (FPT). A parameterized problem is in FPT, if it can be solved by an algorithm with a running time of the form O(f (k)nc) for an arbitrary computable function f (k) and some constant c, where n is the problem size and k is the parameter. Many faster solutions have been designed for specific problems. The goal is always to have efficient solutions for instances with small values of the parameter. For more background information on fixed parameter tractability, see e.g. [7,9,11,8]. Tree-width is an important parameter for enabling fast algorithms for interesting classes of graphs. But for some algorithms, the more restricted path-width parameter is of interest. (The Pathwidth entry on Wikipedia lists such applications in VLSI design, graph drawing, and computational linguistics.) The path-width is defined with tree-decompositions where the tree is a path. Unfortunately, for graphs of small tree-width or path-width, it is not easy to find a corresponding tree decomposition of minimal width. Com- puting the tree-width is NP-hard [1]. For constant tree-width, a tree de- composition of minimal width can be computed in polynomial time [15]. The problem is even solvable by an FPT-algorithm [16]. But the only known linear time algorithms are variations of Bodlaender's algorithm [3]. Their running time is 2Θ(k3)n. This is too slow to be used in practice. Heuristic algorithms are used instead. Throughout this paper n = V is the number of vertices of the graph in question, and k is a width param- eter. For the related notion of tree-depth [10], initially Bodlaender's algo- rithm provided the most efficient way to compute its value and to produce a corresponding tree decompositon. Recently, the exponent in the running time has been decreased from O(k3) to O(k2) [14]. We want to produce Faster Computation of Path-Width 3 the same improvement for path-width, even though it seems to require a different method. There have been many efforts to find better approximation algorithms for the tree-width. The main goal has been to achieve a small constant factor approximation with a running time f (k)g(n), where f (k) is 2O(k) and g(n) is polynomial, preferably linear. This combined goal has been achieved by the recent paper of Bodlaender et al. [4] producing a 5- approximation in time O(ckn). The authors write, "it would be very interesting to have an exact algorithm for testing if the treewidth of a given graph is at most k in 2o(k3)nO(1) time." Downey and Fellows [7] re- mark that Bodlaender's Theorem, based on the algorithm of Bodlaender and Kloks is impractically exponential in k, namely 2ck3 where c ≈ 32, and they write, "It would be very interesting if this could be reduced to an exponential with exponent linear in k." We cannot get a linear ex- ponent, but the improvement from O(k3) to O(k2) in the exponent for path-width is significant. We will use some key ingredients of Bodlaender and Kloks [5] and its improved version of Perkovi´c and Reed [12]. First of all, it is the idea that a given tree decomposition is useful for the solution of all kinds of graph problems based on bottom-up dynamic programming. Even the problems of computing tree decompositions or path decompostions themselves are graph problems that can be solved this way. This makes sense, if one wants to compute a tree decomposition of width k, when one has available a tree decomposition of width linear in k. To obtain the needed constant factor approximation, one can use a top-down construction based on the re- peated use of small vertex separators [16,13]. But such an FPT-algorithm runs in O(n log n) or even quadratic time. Recently, a the 5-approximation has been obtained by Bodlaender et al. [4] running in time O(ckn). For a theoretical result, this approximation would be sufficient, but the high approximation ratio makes the final step very expensive. Therefore, in order to have a chance of a practical algorithm, we show how to mod- ify the Bodlaender and Kloks [5] method working with 2-approximations. Finally, we do the critical last step improving the constant factor approx- imation to an exact solution in time 2O(k2) instead of the previous 2O(k3) for graphs of path-width k. Here, the starting approximation ratio affects the constant factor in the exponent hidden by the O-notation. The main idea of Bodlaender and Kloks [5] is the following. If a graph has a large matching, then a significantly smaller graph with the same or smaller tree-width is obtained by collapsing matched pairs of vertices into one. The smaller problem can be solved recursively, and expanding 4 Martin Furer the collapsed pairs again results in a 2-approximation for the width and a corresponding tree decomposition of the original graph. On the other hand, if there is no large matching, then one can add more edges to the graph without increasing the tree-width. This in turn will create simplicial vertices, i.e., vertices whose neighborhood induces a clique. Simplicial vertices are easy to handle. For computing the tree-width, these methods did not result in a prac- tical algorithm, because of the cubic exponent and large constant factors. For path-width, with a quadratic exponent and much smaller constant factors, we could have a chance. We use the standard notions of tree decomposition and a special no- tion of nice path decomposition. Definition 1. A tree decomposition of a graph G = (V, E) is a pair ({Bp : p ∈ I}, T ), where T is a tree, I is the node set of T , and the subsets Bp ⊆ V have the following properties. (The set of vertices Bp associated with p ∈ I is called the bag of p.) 1. Sp∈I Bp = V , i.e., each vertex belongs to at least one bag. 2. For all edges e = {u, v} ∈ E there is at least one p ∈ I with {u, v} ⊆ 3. For every vertex v ∈ V , the set of indices p of bags containing v Bp, i.e., each edge is represented by at least one bag. induces a subtree of T (i.e., a connected subgraph). The tree-width of G is the smallest k such that G has a tree decomposition with largest bag size k + 1. A rooted tree decomposition is a tree decomposition where T is a rooted tree. We assume all tree edges are oriented towards the root. Definition 2. A nice tree decomposition is a rooted tree decomposition with the following four types of nodes. Leaf node: p has no children, and Bp = 1. Introduce node: p has one child q with Bp = Bq ∪ {v} for some vertex Forget node: p has one child q with Bp ∪ {v} = Bq for some vertex Join node: p has 2 children q and q′ with Bp = Bq = Bq′. v 6∈ Bq. v 6∈ Bp. Furthermore, the root is a forget node with an empty bag. As an important concept, tree-width has several other equivalent def- initions. A graph has tree-width at most k, if and only if it is a partial k-tree [2]. Faster Computation of Path-Width 5 2 Path Decompositions One can define a path decomposition of a graph G = (V, E) to be a tree decomposing ({Bp : p ∈ I}, T ) where the tree T = (I, F ) is a path. A rooted path decomposition is a rooted tree decomposition where the root is an endpoint of the path. We find it more convenient, to describe a nice path decomposition by the sequence of introduce and forget operations. Reminiscent of the traditional definition, we refer to the indices of the sequence as nodes. Every vertex has its introduce node before its forget node. The first node is the leaf, the last node is the root. It is a forget node. We consider the leaf node to be an introduce node too. Definition 3. A path decomposition of a graph G = (V, E) with V = n is a sequence of triples P = ((p1, t1, w1), . . . , (p2n, t2n, w2n)) with the following properties. -- Every vertex v ∈ V occurs exactly twice in the sequence (p1, . . . , p2n), first, pj = v with tj = +1 indicating j being the introduce node for v, then, pj ′ = v with tj ′ = −1 indicating j ′ with j ′ > j being the forget node for v. -- The sequence (w1, . . . , w2n) is defined by wj =   0 wj−1 + 1 wj−1 − 1 if j = 1 if 1 < j ≤ 2n and tj = +1 (introduce node) if 1 < j ≤ 2n and tj = −1 (forget node). Bags have the traditional meaning and can easily be defined recursively. Bj =   if j = 1 {p1} Bj−1 ∪ {pj} if 1 < j ≤ 2n and tj = +1 (introduce node) Bj−1 \ {pj} if 1 < j ≤ 2n and tj = −1 (forget node). The width of a node j is defined to be 1 less than the number of vertices in its bag Bj. Thus, wj is the width of the node j. Definition 4. The width of a path decomposition is the maximum width of any of its nodes. The path-width of a graph is the minimum width of any of its path de- compositions. We use the double factorial (2n − 1)!! = (2n − 1)(2n − 3) . . . 3 1 = (2n)!/(n!2n). We count the number of path decompositions. 6 Martin Furer Proposition 1. The number of path decompositions of an n-vertex graph is n!(2n − 1)!! = (2n)! 2n ∼ √πn(cid:16) n e(cid:17)2n 2n+1. Proof. Induction on n shows that the number of path decompositions for n vertices which are forgotten in a fixed order is (2n − 1)!!, as there are 2n − 1 places to introduce the last forgotten vertex. Considering all n! permutations of the forgetting order of the vertices proves the result. ⊓⊔ Finally Stirling's approximation is used. We now assume, we are given a path decomposition of width ℓ, and we want to produce a path decomposition of width k < ℓ or conclude that no such decomposition exists. Definition 5. The full skeleton QP (U ) induced by a non-empty subset U ⊆ V of a path decomposition P = ((p1, t1, w1), . . . , (p2n, t2n, w2n)) of G = (V, E) is obtained from P by replacing all pj ∈ V \ U by 0. Definition 6. The skeleton Q induced by a non-empty subset U ⊆ V of a path decomposition P = ((p1, t1, w1), . . . , (p2n, t2n, w2n)) of G = (V, E) is obtained from QP (U ) by repeatedly deleting maximal length intervals of the form ((pj+1, tj+1, wj+1, . . . , (pj ′−1, tj ′−1, wj ′−1)) with pj+1 = pj+2 = ··· = pj ′−1 = 0 and min{wj, wj ′} ≤ wj ′′ ≤ max{wj, wj ′} for all j ′′ with j < j ′′ < j ′. We refer to this step as simplifying. Note that every deleted node has a width between the width of the remaining node immediately before it and the width of the remaining node immediately after it. wj is the width of the jth node. Thus, if the jth node is an introduce node for vertex v, then wj is the width just after the insertion of vertex v, and if the jth node is a forget node for vertex v, then wj is the width just after the deletion of vertex v. Definition 7. The width of a skeleton is its maximum wj entry. Proposition 2. The width of a path decomposition is equal to the width of any of its skeletons. Proof. Sequences of deleted nodes are always next to a node whose width ⊓⊔ is at least equal to the width of any node in the deleted sequence. Faster Computation of Path-Width 7 3 Overview The fastest published linear time algorithm to decide whether the path- width of a graph G is at most k, and to produce a width k path decomposi- tion is obtained in two steps. The first step uses a version of Bodlaender's algorithm [3] to compute a tree decomposition of width ℓ = O(k) (or show that none exists). The second step uses the method of Bodlaender and Kloks [5] to produce a path decomposition of width k (or show that none exists) from the tree decomposition of width ℓ. Also the first step uses the method of Bodlaender and Kloks in recursive calls, to compute tree decompositions of smaller width from tree decompositions of roughly twice the width for smaller graphs. The improved version of Bodlaender's algorithm by Perkovi´c and Reed [12] computes the small width tree de- composition much faster, but like the original version, its running time has an exponent of order k3. A theoretical alternative would be to start with the recent 5-approximation algorithm [4], but if an exact solution is desired, the second step would be significantly more expensive due to the higher approximation factor. We propose a linear time path-width and path decomposition algo- rithm which recurses on path decompositions rather than the more costly tree decompositions. The exponent is only quadratic in k, and there are no large hidden constants. Note that we concentrate on the worst case in terms of the path-width. It is possible that the tree-width is significantly smaller than the path-width (by a factor of up to log n). In this special case, the traditional approach can be faster. 4 The Efficient Algorithm The crucial step of producing our faster path decomposition is to produce a small width path decomposition from one with a constant factor bigger width. We are given a path decomposition P . Let B ∗ j = j [ i=1 Bi. Let Gj = G[B ∗ j ] be the subgraph of G induced by B ∗ j . We want to construct a minimum width path decomposition P ′ of G. As for most efficient algorithms based on small tree-width, our path 8 Martin Furer decomposition algorithm uses a bottom-up dynamic programming ap- proach. Any optimal path decomposition P ′ of G contains a path decom- position P ′ j of the subgraph Gj of G. It is sufficient to try for all small k whether there is a path decom- position of width k, and pick one in the affirmative case. For simplicity, we just describe the decision algorithm, because a solution can be found by standard back tracing of the dynamic programming solution. The ba- sic idea of the algorithm is to produce the skeleton Qj of an optimal P ′ j induced by Bj for j = 1, . . . , 2n. Then the path-width of Q2n is the path-width of G. Naturally, the problem with this basic idea is that the optimal path de- composition P ′ is unknown. A pessimistic approach would be to compute all skeletons obtained from all possible path decompositions of G. Fortu- nately, a good compromise is possible. Instead of computing all skeletons Qj, we compute a set Qj of skeletons, with the assurance that Qj contains at least one skeleton Qj of an optimal path decomposition. Theorem 1. Given a graph G, a number k, and a path decomposition P of G of width ℓ = 2O(k), one can decide whether the path-width of G is at most k in time 2O(ℓk)n. A corresponding path decomposition can be computed with the same time bound. Proof. Assume G and its path decomposition P of width ℓ is given. Each bag Bj is a set of vertices of G with Bj ≤ ℓ + 1. We define Aj to be the set of all path decompositions of Gj = G[B ∗ We will now define an algorithm that visits the nodes of G in the order given by P . For more details see Fig. 1. The algorithm will have the following property. j ] of width at most k. Claim. During the visit of node j, the algorithm computes a set of skele- tons Qj of Aj, induced by Bj. This set Qj includes at least one of minimal width. Each set of skeletons is computed from the previously computed set of skeletons of the predecessor j− 1 in P . We will show that if Gj has a path decomposition P ′ j of width at most k′ ≤ k, then Qj contains at least one skeleton of Gj (induced by Bj) of width at most k′. The algorithm Decrease Path-Width depends on the type of node j in the path decomposition P . For every type of node, we now describe the action of the algorithm and prove the claim inductively. Faster Computation of Path-Width 9 Algorithm Decrease Path-Width: Input: A graph G, widths ℓ and k, and a path decomposition P = ((p1, t1, w1), . . . , (p2n, t2n, w2n)) of G of width ℓ. Task: Decide whether G has path-width at most k. Comment: Will be used with ℓ = 2k + 1. Comment: Compute a sequence of sets of skeletons Qj of path decompositions of Gj = G[B ∗ Comment: For some optimal path decomposition P ′ of G, each Qj contains a skele- ton of P ′[Qj ], the restriction of P ′ to B ∗ j . j ] induced by the bag Bj of node j, for j = 1, . . . , 2n. // Start Node w′ for j = 2 to 2n do 1 = 0; w′ 2))} 2 = −1; Q1 = {((p1, +1, w′ 1), (p1, −1, w′ // Introduce Node if tj = +1 then for each skeleton Q in Qj−1 create skeletons for Qj by i + 1) in Q after any position i, i′ − 1) in Q after any position i′ with i′ > i, and inserting (pj, +1, w′ inserting (pj, −1, w′ incrementing w′ i′′ for all positions i′′ in-between, as long as it does not increase the width above k, i is before the forget node in Q of any neighbor u of v, and i′ is after the introduce node in Q of any neighbor u of v. (Positions include position 0 meaning insertion to the left of Q.) if Qj = ∅ then Return("tree-width > k"). // Forget Node if tj = −1 then for each skeleton Q in Qj−1 create a skeleton for Qj by replacing pj both times by 0, and simplifying as specified in Def. 6. // Success Return(min{width of Q : Q ∈ Q2n}) Fig. 1. The algorithm Decrease path-width Leaf node 1: The bag of the leaf node 1 contains just one vertex v = p1, the only skeleton in Q1 is a two node skeleton Q = (v, +1, 0), (v,−1,−1) (v is introduced and then forgotten). The leaf node 1 has bag B1 = {v}, the root node 2 has bag B2 = ∅. The claim is satisfied, because there is only one path decomposition P ′ of the one vertex graph G1. Thus Q is the skeleton of the minimal path decomposition P ′. Introduce node j: If j is an introduce node, then the bag Bj of node j of P contains a new vertex v not in the bag Bj−1 of the predecessor node. More precisely, Bj = Bj−1 ∪ {v} with v 6∈ Bj−1. The algorithm goes through all skeletons Q of Qj−1. For each Q, it creates various skeletons of Qj by inserting an introduce node and a forget node for the new vertex v. All suitable places are tried for the insertion of 10 Martin Furer v. A place is suitable if it is before the forget nodes of all neighbors u of v in G. Now the forget node of v is inserted somewhere after the introduce node of v. This includes the option immediately after the introduce node of v if that place is suitable. Again, all suitable places are tried. A place is suitable if it is after the introduce nodes of v and all its neighbors u in G. A newly created skeleton is discarded rather than put into Qj, if its width is greater than k. The algorithm would certainly be correct, if the insertions were tried in all positions of the full skeletons. This would be an extremely slow brute force algorithm. Thus it is crucial to argue that there is no benefit in trying those intervals I of positions in the full skeletons that have been deleted in the proper skeletons. Such an interval I consists of the nodes j ′′ j, w′ between two positions j and j ′ with min{w′ j ′}. All the vertices introduced and deleted in these intervals are from B ∗ i−1, while all vertices that still have to be included in the path decomposition are from bags after i. There are no edges between vertices of these intervals and later introduced vertices. Thus the only concern is the width caused by insertions between j and j ′. j ′′ ≤ max{w′ j, w′ j ′} ≤ w′ The widths between positions j and j ′ can be viewed as a mountain range with the height at j ′′ being the current width w′ j ′′. If an insert or forget node of a later vertex is placed between positions j and j ′, it is not always an advantage to place these nodes in the deepest valley, because the width is also affected by mountain tops between the insertion and the deletion of a vertex. j ′′ of the bag B ′ Nevertheless, it is never an advantage to place insertions or deletions of later nodes along the slope of a mountain. All the later nodes can just as well, and often with an advantage, be placed at the bottom of a valley. From there, still the same mountain tops have to be crossed, but it can only be an advantage if the new width caused by later placed vertices is added to a smaller width (from a valley) of the earlier placed vertices. More precisely, if a highest and a lowest point of an interval I are at its boundaries, and all the intermediate nodes insert and forget vertices of B ∗ j−1, then there is never an advantage to insert or forget a new vertex at any other place on I than at the lowest point. To prove the claim by induction, we assume that Qj−1 contains a skeleton Qj−1 of width at most k induced by Bj−1 corresponding to an optimal path decomposition P (j−1) of G. If P j−1 has any vertices in- troduced or forgotten on the slopes of a skeleton Qj−1, then P (j−1) is modified to a path decomposition P (j) by sliding all these vertices down the slope to the lowest valley of its interval. The width of P (j) is also Faster Computation of Path-Width 11 optimal, because it is not more than the width of P (j−1). The skeleton Qj of this P (j) is in Qj proving the induction step of the claim. Forget node j: If j is a forget node, then the bag Bj of node j of P contains a new vertex v not in the bag Bj−1 of the predecessor node. More precisely, Bj = Bj−1\{v} with v ∈ Bj−1. Now, Qj is obtained from Qj−1 simply by restricting to the smaller set Bj, i.e., by replacing both occurrences of v by 0. This shows the correctness of the claim. Running time: The running time of the algorithm is mainly determined by the number of skeletons used. We have O(n) nodes j in the path decomposition P . For each node, we consider skeletons induced by the ℓ + 1 vertices from the bag Bj. By Proposition 1, we have 2O(ℓ log ℓ) path decompositions with ℓ+1 vertices. For each of these path decompositions, we have 2ℓ+1 intervals between the nodes where the vertices of the bag Bj are inserted and deleted. These intervals are determined by their sequence of widths. The lengths of these intervals between two nodes involving vertices of Bj in any skeleton are at most 2k + 1. This is so, because the worst width sequences in such a interval is . . . , k−2, 2, k−1, 1, k, 0, k, 1, k−1, 2, k−2, . . . and . . . , k − 2, 1, k − 1, 0, k, 0, k − 1, 1, k − 2, . . . . More importantly, there are only 2O(k) such sequences [5, Lemma 3.5]. In summary, when handling bag Bj for j = 1, . . . , 2n, we have 2O(ℓ log ℓ) path decompositions of Bj. Each has 2ℓ + 1 intervals with 2O(k) possible sequences, resulting in 2O(ℓ log ℓ)2O(ℓk) = 2O(ℓk) skeletons. Thus for all 2n nodes of P together, there are 2O(ℓk)n possible skeletons. As the algorithm only makes polynomial time (in k) manipulations on each skeleton, the total running time is still 2O(ℓk)n. It is standard for dynamic programming algorithms to actually recover the structure (the path decomposition in our case) that has produced the ⊓⊔ minimum. One should notice that there are no large hidden constants involved in the time analysis. Corollary 1. The path-width of a graph can be computed in time 2O(k2)n for graphs of path-width k if a path decomposition of width O(k) is pro- vided. Proof. Theoretically, one can just try k = 1, 2, . . . until one succeeds. Naturally, most of the work for k − 1 could be used for k. ⊓⊔ 12 Martin Furer 5 Computing a Path-Width Approximation We use the well known result that in any tree decomposition of any graph containing the complete bipartite graph Kp,q, there is a bag containing either all the p vertices of one side or all the q vertices of the other side and an additional vertex. Thus if p is greater than the tree-width k, then the addition of all edges between the q vertices on the other side does not increase the tree-width or path-width. The graph obtained from G by adding all such forced edges is called the augmented graph. A vertex is simplicial, if its neighbors form a clique. Theorem 2. The path-width of a graph can be computed and a corre- sponding path decomposition can be found in time 2O(k2)n for graphs of path-width k. Proof. We use the results of [5,12] that for any graph G of tree-width k one can quickly augment G and find a linear size matching M or a linear size subset V ′ of simplicial vertices in the augmented graph. If M is large, then one recursively computes an optimal path decom- position of width k of the graph with the vertices of M merged. It implies a path decomposition of the original graph G of width at most 2k + 1. It can be improved to a path decomposition of width k as seen in Theorem 1. If there is a large set V ′ of simplicial vertices, then one recursively computes an optimal path decomposition of width k of the graph with the vertices V ′ removed. If a tree decomposition of width k is found for the graph with the simplicial vertices removed, then immediately such a decomposition can be obtained for the given graph. This does not work for path decompositions. One obtains a caterpillar graph instead. Then, we just change the caterpillar decomposition into a path decomposition of width 1 more. This width might not be optimal, but it is a very good approximation, that can be improved to an optimal path decomposition ⊓⊔ as before. The reason why [5] works with tree decompositions, even when com- puting path decompositions, might be because the intermediate caterpil- lar decompositions prevent a direct production of path decompositions. Another reason is that for some graphs the tree-width is smaller than the path-width by a log n factor. In such situations, it could be better to work with tree-decompositions. Corollary 2. There is an algorithm computing the path-width, and out- putting a corresponding path decomposition in time 2O(k2)n, where k is the path-width. Faster Computation of Path-Width 13 Proof. As is usual for dynamic programming algorithms doing some min- imization, whenever the algorithm makes a choice, computing the min- imum width of two skeletons, it can record which option provided the minimum (an arbitrary choice is sufficient in case of a tie). Then it is easy to trace back to find an actual path decomposition once the global ⊓⊔ minimum width has been determined. 6 Conclusion Path-width is an important width parameter. The worst case linear run- ning time for its computation has not been improved over the last two decades. Our algorithm is significantly faster for path decomposition than the fastest linear time algorithms for tree decomposition. Furthermore, there are no large hidden constant factors in the expressions for the run- ning time. We conjecture that this algorithm can be implemented to run satisfactory for small path-width. The main open problem in this area is to get an improvement of Bodlaender's algorithms of tree-width computation and the production of tree-decompositions of small width. In particular, one would like to know whether an O(ckn) time algorithm is possible for some constant c. In a wider context the open question is whether similar results are possible for other important width parameters, in particular for clique-width. References 1. Arnborg, S., Corneil, D.G., Proskurowski, A.: Complexity of finding embeddings in a k-tree. SIAM J. Algebraic Discrete Methods 8(2), 277 -- 284 (Apr 1987), http://dx.doi.org/10.1137/0608024 2. Arnborg, S., Proskurowski, A.: Linear time algorithms for np-hard problems re- stricted to partial k-trees. Discrete Applied Mathematics pp. 11 -- 24 (1989) 3. Bodlaender, H.L.: A linear-time algorithm for finding tree-decompositions of small treewidth. SIAM J. Comput. 25(6), 1305 -- 1317 (1996) 4. Bodlaender, H.L., Drange, P.G., Dregi, M.S., Fomin, F.V., Lokshtanov, D., Pilipczuk, M.: An o(ckn) 5-approximation algorithm for treewidth. In: 54th An- nual IEEE Symposium on Foundations of Computer Science, FOCS 2013, 26-29 October, 2013, Berkeley, CA, USA. pp. 499 -- 508. IEEE Computer Society (2013), http://doi.ieeecomputersociety.org/10.1109/FOCS.2013.60 5. Bodlaender, H.L., Kloks, T.: Efficient and constructive algorithms for the pathwidth and treewidth of graphs. J. Algorithms 21(2), 358 -- 402 (1996), http://dx.doi.org/10.1006/jagm.1996.0049 6. Courcelle, B.: Graph rewriting: An algebraic and logic approach. In: van Leeuwen, J. (ed.) Handbook of Theoretical Computer Science, Volume B: Formal Models and Sematics (B), pp. 193 -- 242. Elsevier / MIT Press (1990) 7. Downey, R.G., Fellows, M.R.: Parameterized Complexity. Springer Verlag (1999) 14 Martin Furer 8. Downey, R.G., Fellows, M.R.: Fundamentals of Parameterized Complexity. Springer (2013) 9. Flum, J., Grohe, M.: Parameterized Complexity Theory. Text in Theoretical Com- puter Science, Springer (2006) 10. Nesetril, J., de Mendez, P.O.: Tree-depth, subgraph homomorphism bounds. http://dx.doi.org/10.1016/j.ejc.2005.01.010 Comb Eur. J. 27(6), 1022 -- 1041 coloring and (2006), 11. Niedermeier, R.: Invitation to Fixed-Parameter Algorithms. Oxford University Press (2006) 12. Perkovi´c, L., Reed, B.: An improved algorithm for finding tree decompo- sitions of small width. Int. J. Found. Comput. Sci 11(3), 365 -- 371 (2000), http://dx.doi.org/10.1142/S0129054100000247 13. Reed, B.A.: Finding approximate separators and computing tree width quickly. In: Proceedings of the Twenty-Fourth Annual ACM Symposium on the Theory of Computing. pp. 221 -- 228. Victoria, British Columbia, Canada (4 -- 6 May 1992) 14. Reidl, F., Rossmanith, P., Villaamil, F.S., Sikdar, S.: A faster parameterized algo- rithm for treedepth. In: Esparza, J., Fraigniaud, P., Husfeldt, T., Koutsoupias, E. (eds.) Automata, Languages, and Programming - 41st International Collo- quium, ICALP 2014, Copenhagen, Denmark, July 8-11, 2014, Proceedings, Part I. Lecture Notes in Computer Science, vol. 8572, pp. 931 -- 942. Springer (2014), http://dx.doi.org/10.1007/978-3-662-43948-7 Graph 15. Robertson, II. aspects mic http://dx.doi.org/10.1016/0196-6774(86)90023-4 Seymour, tree-width. P.D.: J. Algorithms N., of minors 7(3), 309 -- 322 Algorith- (1986), 16. Robertson, N., Seymour, P.D.: Graph minors XIII. The disjoint paths problem. J. Comb. Theory, Ser. B pp. 65 -- 110 (1995)
1608.06009
1
1608
2016-08-21T23:15:40
The Random Access Zipper: Simple, Purely-Functional Sequences
[ "cs.DS", "cs.PL" ]
We introduce the Random Access Zipper (RAZ), a simple, purely-functional data structure for editable sequences. A RAZ combines the structure of a zipper with that of a tree: like a zipper, edits at the cursor require constant time; by leveraging tree structure, relocating the edit cursor in the sequence requires logarithmic time. While existing data structures provide these time bounds, none do so with the same simplicity and brevity of code as the RAZ. The simplicity of the RAZ provides the opportunity for more programmers to extend the structure to their own needs, and we provide some suggestions for how to do so.
cs.DS
cs
The Random Access Zipper: Simple, Purely-Functional Sequences Kyle Headley and Matthew A. Hammer University of Colorado Boulder [email protected], [email protected] Abstract. We introduce the Random Access Zipper (RAZ), a simple, purely-functional data structure for editable sequences. The RAZ com- bines the structure of a zipper with that of a tree: like a zipper, edits at the cursor require constant time; by leveraging tree structure, relocating the edit cursor in the sequence requires log time. While existing data structures provide these time bounds, none do so with the same simplic- ity and brevity of code as the RAZ. The simplicity of the RAZ provides the opportunity for more programmers to extend the structure to their own needs, and we provide some suggestions for how to do so. 1 Introduction The singly-linked list is the most common representation of sequences for func- tional programmers. This structure is considered a core primitive in every func- tional language, and morever, the principles of its simple design recur througout user-defined structures that are "sequence-like". Though simple and ubiquitous, the functional list has a serious shortcoming: users may only efficiently access and edit the head of the list. In particular, random accesses (or edits) generally require linear time. To overcome this problem, researchers have developed other data structures representing (functional) sequences, most notably, finger trees [8]. These struc- tures perform well, allowing edits in (amortized) constant time and moving the edit location in logarithmic time. More recently, researchers have proposed the RRB-Vector [14], offering a balanced tree representation for immutable vec- tors. Unfortunately, these alternatives lack the simplicity and extensibility of the singly-linked list. In this paper, we introduce the random access zipper, or RAZ for short. Like the common linked list, the RAZ is a general-purpose data structure for purely-functional sequences. The RAZ overcomes the performance shortcomings of linked lists by using probabilistically-balanced trees to make random access efficient (expected or amortized logarithmic time). The key insight for balancing these trees comes from [12], which introduces the notion of probabilistically- chosen levels.1 To edit sequences in a persistent (purely-functional) setting, the 1 In short, these levels represent the heights of uniformly randomly chosen nodes in a full, balanced binary tree. See Section 3. RAZ also incorporates the design of a zipper [9], which provides the notion of a cursor in the sequence. A cursor focuses edits on (or near) a distinguished element. The user may move the cursor locally (i.e., forward and backward, one element at a time), or globally (i.e., based on an index into the sequence), which provides random access to sequence elements. The RAZ exposes two types to the user, 'a tree and 'a zip, which respec- tively represent a unfocused and focused sequence of elements (of type 'a). The RAZ exposes the following interface to the user based on these types: Function : Type focus unfocus insert remove replace move view : 'a tree -> int -> 'a zip O(log n) expected : 'a zip -> 'a tree : dir -> 'a -> 'a zedit : dir -> 'a zedit : 'a -> 'a zedit : dir -> 'a zedit : 'a zip -> 'a Time Complexity O(log n + m · log2 m) expected O(1) worst-case O(1) amortized O(1) worst-case O(1) amortized O(1) worst-case The second and third columns of the table respectively report the type (in OCaml) and time complexity for each operation; we explain each in turn. Function focus transforms a tree into a zipper, given a position in the se- quence on which to place the zipper's cursor. It runs in expected logarithmic time, where n is the number of elements in the sequence. We use expected anal- ysis for this function (and the next) since the tree is balanced probabilistically. Function unfocus transforms a (focused) zipper back to an (unfocused) tree; its time complexity O(log n+m·log2 m) depends on the length of the sequence n, as well as m, the number of zipper-based edits since the last refocusing. We summarize those possible edits below. Assuming that the number m is a small constant, the complexity of unfocus is merely O(log n); when m grows to be- come significant, however, the current design of the RAZ performs more poorly, requiring an additional expected O(log2 m) time to process each edit in building the balanced tree. To overcome this problem, the user can choose to refocus more often (e.g., after each edit, if desired). Functions insert, replace, remove, move each transform the zipper structure of the RAZ. We abbreviate their types using type 'a zedit, which we define as the function type 'a zip → 'a zip. Function insert inserts a given element to the left or right of the cursor, specified by a direction of type dir. Function remove removes the element in the given direction. Its time complexity is amortized, since removal may involve decomposing subtrees of logarithmic depth; overall, these costs are amortized across edits that require them. Function replace re- places the element at the cursor with the given element. Function move moves the cursor one unit in the specified direction; just as with remove, this operation uses amortized analysis. Finally, function view retrieves the element currently focused at the cursor (in constant time). In the next section, we give an in-depth example of using the operations described above. In particular, we illustrate how the RAZ represents the sequence as a tree and as a zipper, showing how the operations construct and transform these two structures. In Section 3, we present our implementation of the RAZ. It requires well under 200 lines of OCaml, which is publicly available: https://github.com/cuplv/raz.ocaml This code includes ten main functions that work over a simple set of datatypes for trees, lists of trees, and zippers, as defined in Section 3. In contrast, the finger tree [8] requires approximately 800 lines in the OCaml "Batteries Included" repo [10] to provide similar functionality. We evaluate the RAZ empirically in Section 4. In particular, we report the time required to build large sequences by inserting random elements into the sequence at random positions. Our evaluation demonstrates that the RAZ is very competitive with the finger tree implementation mentioned above, despite the simplicity of the RAZ compared with that of the finger tree. In Section 5, we discuss the design decisions we considered for this imple- mentation and exposition of the RAZ. We also discuss future enhancements that build on this design. Section 6 discusses related work, and in particular, alternative structures for persistent sequences. We give a deeper comparison to finger trees, and explain why other balanced trees designed for sets (e.g., red-black trees, or splay trees, etc) are inappropriate for representing sequences. 2 Example In this section, we give a detailed example of using the RAZ interface introduced above, and illustrate the internal tree and list structures of the RAZ informally, using pictures. In the next section, we make the code for these functions precise. Consider the sequence of seven elements (cid:104)z, a, b, c, y, d, e(cid:105). In the example that follows, the programmer uses the RAZ to perform four operations over this sequence, editing it (functionally) in the process: – She uses focus to place the cursor at offset 4 (element y), – she uses remove to remove the element to the left of the cursor (element c), – she uses unfocus in anticipation of refocusing, and – she uses focus to place the cursor at the sequence's start (element z). Figure 1 (first image, top) shows the sequence of elements represented by a RAZ. As explained further in Section 3, the RAZ interposes randomly-chosen levels as meta-data in the sequence; we show these levels, (cid:104)4, 6, 1, 2, 5, 3(cid:105), inter- posed below the sequence elements. The second image shows the tree form of the RAZ, whose structure is determined by the sequence elements and levels above. This tree represents an unfocused RAZ. Next, the programmer uses focus to place the cursor into the tree, in order to edit its elements. The third image in Figure 1 shows the zipper that results from focusing the sequence on element y. As can be seen, this structure consists of left Elements and levels for our example sequence: As a tree, levels are internal and determine heights: Zipper focused on y. Three (unfocused) sub-trees remain: Fig. 1. The RAZ represents the sequence of elements (cid:104)z, a, b, c, y, d, e(cid:105) interposed with levels 1-6 (first image); these levels uniquely determine a balanced tree (second image) that permits log-time focusing on element y (third image). Remove the level 2, to the left of the cursor: Trim the left of the cursor, deconstructing its rightmost path Remove the c Fig. 2. An example of editing a focused RAZ: Remove the c to the left of the cursor by removing level 2 (second image), trimming the left tree (third image), and removing the c (last image) 215436abcdeySeq:Level:z64abedc1235zyFocus PathTreeList4azNil6bc12y5Nilde34azNil6bc12y5Nilde3Nil6bc1y5Nilde34azNil6bc1y5Nilde34azNil6b1y5Nilde34az Store element y in the sequence to be unfocused: Append the left and right sequences, represented as trees: Result of appending: Fig. 3. Unfocus the RAZ Fig. 4. Focus on the first element, z, creating left and right lists of (unfocused) subtrees. Nil6b1y5Nilde34azNil6b15Nilyde34azFocus PathTreeListAppend Path5de3b61y4az4az2Focus PathTreeListAppend Pathb1y5de3Nil6a4zNilb1y5de3 and right lists that each contain levels and unfocused subtrees from the original balanced tree. The focusing algorithm produces this zipper by descending the balanced tree along the indicated focus path (second image of Figure 1), adding names and subtrees along this path to the left and right lists. Notice that the elements nearest to the cursor consist of the subtrees at the end of this path; in expectation, these lists order subtrees in ascending size. After focusing on element y, the programmer uses the remove function. Fig- ure 2 shows the three steps for removing the c to the left of cursor. First, we remove the level 2 from the left of the cursor, making c the next element to the immediate left of the cursor (the second image). Next, since the c resides as a leaf in an unfocused tree, we trim this left tree by deconstructing its rightmost path (viz., the path to c). Section 3 explains the trim operation in detail. Finally, with c exposed in the left list, we remove it (fourth image). After removing element c, the programmer unfocuses the RAZ. Beginning with the final state of Figure 2, Figure 3 illustrates the process of unfocusing the sequence. First, we add element y to the left list, storing its position in the sequence (second image). Next, we build trees from the left and right lists as follows: For each list, we fold its elements and trees, appending them into balanced trees; as with the initial tree, we use the levels to determine the height of internal nodes (third image). Having created two balanced trees from the left and right lists, we append them along their rightmost and leftmost paths, respectively; again, the append path compares the levels to determine the final appended tree (fourth image). Finally, the programmer refocuses the RAZ. In Figure 4 (as in Figure 1), we descend the focus path to the desired element, this time z. As before, this path induces left and right lists that consist of levels and unfocused subtrees. 3 Technical Design The full implementation of the RAZ in OCaml consists of about 170 lines. In this section, we tour much of this code, with type signatures for what we elide for space considerations. Figure 5 lists the type definitions for the RAZ structure, which is stratified into three types: tree, tlist, and zip. The tree type consists of (unfocused) binary trees, where leaves hold data, and where internal binary nodes hold a level lev and total element count of their subtrees (an int). The tlist type consists of ordinary list structure, plus two Cons-like constructors that hold levs and trees instead of ordinary data. Finally, a (focused) zip consists of a left and right tlist, and a focused element that lies between them. Levels for probabilistically-balanced trees. As demonstrated in the code below for append, the levels associated with each Bin node are critical to maintaining balanced trees, in expectation. This property of balance is critical to the time complexity bounds given for many of the RAZ's operations, including focusing, unfocusing and many local edits. type lev = int type dir = L R (* directions for moving/editing *) (* tree level *) type 'a tree = (* binary tree of elements *) Nil Leaf of 'a Bin of lev * int * 'a tree * 'a tree type 'a tlist = (* list of elements, levels and trees *) Nil Cons Level of lev Tree of 'a * 'a tlist * 'a tlist of 'a tree * 'a tlist type 'a zip = ('a tlist * 'a * 'a tlist) (* tlist zipper *) Fig. 5. RAZ defined as a zipper of tree-lists. The key insight is choosing these levels from a negative binomial distribu- tion; intuitively, drawing random numbers from this distribution yields smaller numbers much more often (in expectation) than larger numbers. More precisely, drawing the level 1 is twice as likely as drawing the level 2, which is twice as likely as level 3, and so on. This means that, in expectation, a sequence of levels drawn from this distribution describes the sizes of subtrees in a perfectly-balanced bi- nary tree. As described in Section 6, this insight comes from [12], who define the notion of level in a related context. Fortunately, we can choose these levels very quickly, given a source of (uni- formly) random numbers and a hash function. We do so by hashing a randomly- chosen number, and by counting the number of consecutive zeros in this hash value's least-significant bits. let focus : 'a tree → int → 'a zip = fun t p → let c = elm_count t in if p >= c p < 0 then failwith "out of bounds" else let rec loop = fun t p (l,r) → match t with Nil → failwith "internal Nil" Leaf(elm) → assert (p == 0); (l,elm,r) Bin(lv, _, bl, br) → let c = elm_count bl in if p < c then loop bl p else (l,Level(lv,Tree(br,r))) loop br (p - c) (Level(lv,Tree(bl,l)),r) in loop t p (Nil,Nil) Fig. 6. The focus operation transforms a tree into a zip. Focusing the RAZ. The focus operation in Figure 6 transforms an unfocused tree to a focused zipper. Given an index in the sequence, p, and an O(1)-time elm_count operation on sub-trees, the inner loop recursively walks through one path of Bin nodes until it finds the desired Leaf element. At each recursive step of this walk, the loop accumulates un-walked subtrees in the pair (l,r). In the base case, focus returns this accumulated (l,r) pair as a zip containing the located leaf element. Proposition 31 Given a tree t of depth d, and an O(1)-time implementation of elm_count, the operation focus t p runs in O(d) time. let head_as_tree : 'a tlist → 'a tree let tail : 'a tlist → 'a tlist let grow : dir → 'a tlist → 'a tree = fun d t → let rec loop = fun h1 t1 → match t1 with Nil → h1 _ → let h2 = head_as_tree t1 in match d with L → loop (append h2 h1) (tail t1) R → loop (append h1 h2) (tail t1) in grow (head_as_tree t) (tail t) let unfocus : 'a zip → 'a tree = fun (l,e,r) → append (grow L l) (append (Leaf(e)) (grow R r)) Fig. 7. Unfocusing the RAZ using append and grow. Unfocusing the RAZ. Figure 7 lists the unfocus operation, which transforms a focused zipper into an unfocused tree. To do so, unfocus uses auxiliary oper- ations grow and append to construct and append trees for the left and right tlist sequences that comprise the zipper. The final steps of unfocus consists of appending the left tree, focused element e (as a singleton tree), and the right tree. In sum, the unfocus operation consists of calls to auxiliary operations grow and append. We explain append in detail further below. The grow operation uses append, and the simpler helper function head as tree, which transforms the head constructor of a tlist into a tree; conceptually, it extracts the next tree, leaf element or binary node level as tree structure. It also uses the function tail, which is standard. The grow operation loops over successive trees, each extracted by head_as_tree, and it combines these trees via append. The direction parameter d determines whether the accumulated tree grows from left-to-right (L case), or right-to-left (R case). When the tlist is Nil, the loop within grow completes, and yeilds the accumulated tree h1. Under the conditions stated below, unfocus is efficient, running in polyloga- rithmic time for balanced trees with logarithmic depth: Proposition 32 Given a tree t of depth d, performing unfocus (focus t p) requires O(d) time. We sketch the reasoning for this claim as follows. As stated above, the op- eration focus t p runs in O(d) time; we further observe that focus produces a zipper with left and right lists of length O(d). Likewise, head_as_tree also runs in constant time. Next, the unfocus operation uses grow to produce left and right trees in O(d) time. In general, grow makes d calls to append, combining trees of height approaching d, requiring O(d2) time. However, since these trees were placed in order by focus, each append here only takes constant time. Finally, it appends these trees in O(d) time. None of these steps dominate asymptotically, so the composed operations run in O(d) time. let rec append : 'a tree → 'a tree → 'a tree = fun t1 t2 → let tot = (elm_count t1) + (elm_count t2) in match (t1, t2) with Nil, _ → t2 _, Nil → t1 Leaf(_), Leaf(_) Leaf(_), Bin(lv,_,l,r) → Bin(lv, tot, append t1 l, r) Bin(lv,_,l,r), Leaf(_) → Bin(lv, tot, l, append r t2) Bin(lv1,_,t1l,t1r), Bin(lv2,_,t2l,t2r) → → failwith "leaf-leaf should not arise" if lv1 >= lv2 then Bin(lv1, tot, t1l, append t1r t2) else Bin(lv2, tot, append t1 t2l, t2r) Fig. 8. Append the sequences of two trees into a single sequence, as a balanced tree. Appending trees. The append operation in Figure 8 produces a tree whose ele- ments consist of the elements (and levels) of the two input trees, in order. That is, an in-order traversal of the tree result of append t1 t2 first visits the ele- ments (and levels) of tree t1, followed by the elements (and levels) of tree t2. The algorithm works by traversing a path in each of its two tree arguments, and producing an appended tree with the aforementioned in-order traversal prop- erty. In the last Bin node case, the computation chooses between descending into the sub-structure of argument t1 or argument t2 by comparing their levels and by choosing the tree named with the higher level. As depicted in the ex- ample in Figure 4 (from Section 2), this choice preserves the property that Bin nodes with higher levels remain higher in the resulting tree. Below, we discuss further properties of this algorithm, and compare it to prior work. let trim : dir → 'a tlist → 'a tlist = fun d tl → match tl with Nil Cons _ Level _ → tl Tree(t, rest) → let rec trim = fun h1 t1 → match h1 with Nil → failwith "malformed tree" Leaf(elm) → Cons(elm,t1) Bin(lv,_,l,r) → match d with L → trim r (Level(lv,Tree(l,t1))) R → trim l (Level(lv,Tree(r,t1))) in trim t rest Fig. 9. Function trim exposes the next sequence element. Trimming a tree into a list. The trim operation in Figure 9 prepares a tlist for edits in the given direction dir. It returns the same, unchanged tlist if it does not contain a tree at its head. If the tlist does contain a tree at its head, trim deconstructs it recursively. Each recursive call eliminates a Bin node, pushing the branches into the tlist. The recursion ends when trim reaches a Leaf and pushes it into the tlist as a Cons. The trim operation works most efficiently when it immediately follows a re- focusing, since in this case, the cursor is surrounded by leaves or small subtrees, which each trim in constant time. If the cursor moves far through the zipper, however, it can encounter a node from high in the original tree, containing a significant proportion of the total elements of the sequence. These facts suggest the following propositions: Proposition 33 Given a direction d, a position p, a tree t of size n, and a tlist l from one side of a zipper created by focus t p, trim d l runs in O(1) time. Proposition 34 Given a direction d, a position p, a tree t of size n, and a tlist l from one side of a zipper created by focus t p, a sequence of k calls to trim d l composed with move d runs in O(k log n) time. Figure 10 lists the code for inserting and removing elements from the zipper. The function insert uses rnd_level to generate a random level to accompany the newly-inserted element ne. Based on the removal direction, the function remove uses an internal helper remove' to remove the next sequence element in the given direction, possibly by looping. In particular, the Cons case is the base case that removes the element of the Cons cell; the Nil case is erroneous, since it means that there is no element to remove. The two remaining cases recur internally; specifically, the Tree case uses trim, explained above. Figure 10 lists the type signatures of several other zipper-based editing func- tions: view accesses the next element to the right or left of the cursor, replace let insert d ne (l,e,r) = match d with L → (Level(rnd_level(),Cons(ne,l)),e,r) R → (l,e,Level(rnd_level(),Cons(ne,r))) let remove : dir → 'a zip → 'a zip = let rec remove' d s = match s with → failwith "no elements" Nil Cons(_,rest) → rest Level(lv,rest) → remove' d rest Tree _ → remove' d (trim d s) in fun d (l,e,r) → match d with L → (remove' L l,e,r) R → (l,e,remove' R r) : dir → 'a zip → 'a : dir → 'a zip → 'a zip = ··· let view let replace : dir → 'a → 'a zip → 'a zip = ··· = ··· let move = ··· let view_cursor let replace_cursor : 'a → 'a zip → 'a zip = ··· : 'a zip → 'a Fig. 10. Zipper edits: Element insertion, element removal and several other variants. replaces this element with another given one, and move moves the cursor to focus on an adjacent element. Finally, view_cursor and replace_cursor are similar to view and replace, respectively, except that they act on the element at the cursor, rather than an element that is adjacent to it. 4 Evaluation In this section we evaluate the RAZ in comparison to a data structure with similar theoretic behavior, the finger tree [8], which we elaborate on in related work, Section 6. We demonstrate that the RAZ is comparable in performance with this more complex structure. Experimental Setup. We present two experiments, each performed on both a RAZ and a finger tree. In the first experiment, we construct a sequence from scratch by inserting elements, each in a randomly chosen position. Insertion into the RAZ is by focusing, inserting a value, then unfocusing; insertion into the finger tree is by splitting, pushing a value, then appending. Upon reaching a target length, we record the total time taken. We use target lengths of 10k to 1M elements, and repeat the process for a total of five data points for each target. We plot the median of the results, shown in Figure 11. For the second experiment, we also insert elements into random positions in a sequence, but maintain a single sequence throughout the experiment. We measure the time taken for the first sequential group of 1M insertions, then the next group of 1M insertions, repeating until the sequence reaches 100M elements. We plot these measured times, shown in Figure 12. We compiled our code through opam with ocamlc verion 4.02 native mode, and ran it on a 2.8 GHz Thinkpad with 16 GB of RAM running Ubuntu 16.04. We use the "Batteries Included" [10] code for finger trees. The results in Fig- ure 11 were collected by using a separate process for each measurement, and those in Figure 12 used one process per data structure. Ocaml's min heap size parameter was set to 800MB. We report 100 values per data structure per plot. Fig. 11. Constructing sequences of different lengths from scratch Results. Figure 11 shows the RAZ as slightly faster than a finger tree, but main- taining the same asymptotic behavior. We average the ratio of times, showing that the RAZ uses 5-6% less time on average. At 500k elements the RAZ takes 1.57s vs the finger tree's 1.71s, and at 950k elements the times are 3.54s and 3.70s, respectively. Figure 12 shows a great variance in times. Even with a mil- lion elements added for each measurement, the plot is not smooth. This is true for the RAZ with its probabilistic structure, but also for the more consistently structured finger trees. The average time in the last 20 entries plotted is 10.01s for the RAZ and 9.77s for the finger tree. We suspect that garbage collection effects may be (partly) responsible for this variance, but determining this with certainty is beyond the scope of this initial evaluation. 00.511.522.533.544.5105090130170210250290330370410450490530570610650690730770810850890930970Time (s)Number of Elements (in Thousands)RAZFinger tree Fig. 12. Time taken to insert 1M elements into a sequence of varying size. 5 Discussion We made a number of design decisions for the RAZ, mainly opting for simplicity of code. One decision was to use a probabilistically balanced tree rather than the strict structure of many other tree types. Storing levels eliminates the need to rebalance a tree, which eliminates some of the most complex code required. The RAZ may not be well balanced in any local area, but it will be balanced globally, which is important for performance at scale. An additional benefit of providing a tree with specific heights is that of a stable form. The structure of the RAZ as a tree does not depend on the order of operations, but on the stored levels. This results in minimal changes, specifically, only the path from the adjusted elements to the root will be different. This is of great benefit for incremental computation, which is most effective for small changes. Early incremental structures by [12] used elements to determine heights, and had trouble with identical values. The RAZ sidesteps this issue with explicit stored levels for tree heights. Another design decision we made was to provide a current element at the cursor position, rather than leaving the cursor between elements. Doing this provided about a 25% reduction in code, removing some asymmetric logic dealing with alteration of element and level. By singling out a current item, we have levels on both sides of the cursor. This may make local edits a bit unintuitive. An elegant solution is for the ends of the RAZ to contain an "empty" element. Focusing on the far right element and inserting a new element to the left modifies the sequence more intuitively, and the empty element stays at the end. 0246810121416102030405060708090Time (s)Sequence Size (in Millions)RAZFinger tree 5.1 Enhancements One benefit of an extremely simple data structure is that it can be modified to suit a specific purpose. We annotate the RAZ with size info in order to focus on a particular location. By using other types of annotations, the RAZ can be used for other purposes. For example, by annotating each subtree with the highest priority of elements within, we have a priority tree, which can access the next item in log time, while still adding items in constant time. The paper on finger trees [8] has additional suggestions of this kind. Another modification might put the RAZ's cursor between two sequence elements for more intuitive editing. Each local editing function would require two cases, one for when there is a level present and one where there is an element. An invariant for which side the level appears on must be maintained to avoid degradation of the RAZ structure. It is possible for level data to be defined programmatically rather than ran- domly. This allows direct control over the balance of the unfocused RAZ. For example, a perfect balance might be set for a read-only sequence. Or, one could use levels as priority controls. High levels mean faster access, so elements could be inserted along with a high priority where appropriate. Some additional design work needs to be done for this to work properly. 6 Related Work and Alternative Approaches We review related work on representing purely-functional sequences that undergo small (constant-sized) edits, supplementing the discussions from earlier sections. We also discuss hypothetical approaches based on (purely-functional) search trees, pointing out their differences and short-comings for representing sequences. The "Chunky Decomposition Scheme". The tree structure of the RAZ is in- spired by the so-called "chunky decomposition scheme" of sequences, from Pugh and Teiltelbaum's 1989 POPL paper on purely-functional incremental com- puting [12]. Similar to skip lists [11], this decomposition scheme hashes the sequence's elements to (uniquely) determine a probabilistically-balanced tree structure. The RAZ enhances this structure with a focal point, local edits at the focus, and a mechanism to overcome its inapplicability to sequences of re- peated (non-unique) elements. In sum, the RAZ admits efficient random access for (purely-functional) sequence editing, to which the '89 paper alludes, but not does not address. Finger trees. As introduced in Section 1, a finger tree represents a sequence and provides operations for a double-ended queue (aka, deque) that push and pop el- ements to and from its two ends, respectively. The 2-3 finger tree supports these operations in amortized constant time. Structurally, it consists of nodes with three branches: a left branch with 1–4 elements, a center for recursive nodes, and a right branch with 1–4 elements. Each center node consists of a complete 2-3 tree. This construction's shallow left and right (non-center) branches admit efficient, amortized constant-time access to the deque's ends. This construction also provides efficient (log-time) split and append operations, for exposing ele- ments in the center of the tree, or merging two trees into a single 2-3 tree. The split operation is comparable to the focus operation of the RAZ; the append operation is comparable to that of the RAZ. While similar in asymptotic costs, in settings that demand canonical forms and/or which employ hash consing, the 2-3 finger tree and RAZ are significantly different; this can impact the asymptotics of comparing sequences for equality. In the presence of hash-consing, structural identity coincides with physical iden- tity, allowing for O(1)-time equality checks of arbitrarily long sequences. As a result of their approach, 2-3 finger trees are history dependent. This fact makes them unsuitable for settings such as memoization-based incremental comput- ing [12,7,6]. Fig. 13. A RAZ (left) and finger tree (right) representing the same sequence Fig. 14. Removing an element from a RAZ (left) and a finger tree (right), with struc- ture maintenance on the finger tree Figure 13 depicts both a RAZ and a finger tree containing 15 elements, num- bered sequentially. Elements are shown as circles, internal trees have a triangle around them, with diagonal lines denoting internal tree structure. Horizontal and vertical lines elide a simple structure for access to elements: a list in the RAZ case and an set of data types for the finger tree. Both these data structures provide access to the upper right element, labeled "15". We elide the current item and right side of the RAZ, as it is not important for this example. One major difference between the finger tree and RAZ is when they need to adjust their structure to maintain invariants. Figure Figure 14 shows the result 12345678910111213141512345678910111213141512345678910111213141234567891314101112 of deleting element 15 in both our example structures. They both expose this element, but the RAZ requires no maintenance at this point, while the finger tree does, since there are no elements left in the top finger. This is done by promoting a tree from the next deeper finger. In this case, the finger tree must promote another tree from even deeper. These promotions are indicated by the arrows in the figure. RRB Vector. The RRB-Vector [14] uses a balanced tree to represent immutable vectors, focusing on practical issues such as parallel performance and cache lo- cality. These performance considerations are outside the scope of our current work, but are interesting for future work. Balanced representations of Sets. Researchers have proposed many approaches for representing sets as balanced search trees, many of which are amenable to purely-functional representations (e.g., Treaps [2], Splay Trees [13], AVL Trees [1], and Red-Black Trees [3]). Additionally, skip lists [11] provide a struc- ture that is tree-like, and which is closely related to the probabilistic approach of the RAZ. However, search trees (and skip lists) are not designed to represent sequences, but rather sets (or finite mappings). Structures for sequences and sets are fundamentally different. Structures for sequences admit operations that alter the presence, absence and ordering of elements, and they permit elements to be duplicated in the sequence (e.g., a list of n repeated characters is different from the singleton list of one such character). By contrast, structures for sets (and finite maps) admit operations that alter the presence or absence of elements in the structure, but not the order of the elements in the structure-rather, this ordering is defined by the element's type, and is not represented by the set. Indeed, the set representation uses this (fixed) element ordering to efficiently search for elements. Moreover, set structures typically do not distinguish between the sets with duplicated elements-e.g., add(elm, set) and add(elm, add(elm, set)) are the same set, whereas a sequence structure would clearly distinguish these cases. Encoding sequences with sets. In spite of these differences between sets and se- quences, one can encode a sequence using a finite map, similar to how one can represent a mutable array with an immutable mapping from natural numbers to the array's content; however, like an array, editing this sequence by element insertion and removal is generally problematic, since each insertion or removal (naively) requires an O(n)-time re-indexing of the mapping. Overcoming this efficiency problem in turn requires employing so-called order maintenance data structures, which admit (amortized) O(1)-time insertion, removal and compari- son operations for a (mutable) total order [5,4]. Given such a structure, the ele- ments of this order could be used eschew the aforementioned re-indexing problem that arises from the naive encoding of a sequence with a finite map. Alas, exist- ing order maintenance data structures are not purely-functional, so additional accommodations are needed in settings that require persistent data structures. By contrast, the RAZ is simple, efficient and purely-functional. 7 Conclusion We present the Random Access Zipper (RAZ), a novel data structure for repre- senting a sequence. We show its simplicity by providing most of the code, which contains a minimal number of cases and helper functions. We describe some of the design decisions that increase simplicity. We evaluate the RAZ, demon- strating time bounds on par with far more complex data structures. Finally, we suggest multiple ways to enhance the RAZ to suit additional use cases. References 1. M AdelsonVelskii and Evgenii Mikhailovich Landis. An algorithm for the organi- zation of information. Technical report, DTIC Document, 1963. 2. Cecilia R. Aragon and Raimund Seidel. Randomized search trees. In 30th Annual Symposium on Foundations of Computer Science, Research Triangle Park, North Carolina, USA, 30 October - 1 November 1989, pages 540–545, 1989. 3. Rudolf Bayer. Symmetric binary B-trees: Data structure and maintenance algo- rithms. Acta Inf., 1:290–306, 1972. 4. Michael A. Bender, Richard Cole, Erik D. Demaine, Martin Farach-Colton, and Jack Zito. Two simplified algorithms for maintaining order in a list. In Algorithms - ESA 2002, 10th Annual European Symposium, Rome, Italy, September 17-21, 2002, Proceedings, pages 152–164, 2002. 5. Paul F. Dietz and Daniel Dominic Sleator. Two algorithms for maintaining order in a list. In Proceedings of the 19th Annual ACM Symposium on Theory of Computing, 1987, New York, New York, USA, pages 365–372, 1987. 6. Matthew A. Hammer, Joshua Dunfield, Kyle Headley, Nicholas Labich, Jeffrey S. Foster, Michael W. Hicks, and David Van Horn. Incremental computation with names. In Proceedings of the 2015 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2015, part of SPLASH 2015, Pittsburgh, PA, USA, October 25-30, 2015, pages 748–766, 2015. 7. Matthew A. Hammer, Yit Phang Khoo, Michael Hicks, and Jeffrey S. Foster. Adapton: composable, demand-driven incremental computation. In ACM SIG- PLAN Conference on Programming Language Design and Implementation, PLDI '14, Edinburgh, United Kingdom - June 09 - 11, 2014, page 18, 2014. 8. Ralf Hinze and Ross Paterson. Finger trees: A simple general-purpose data struc- ture. Journal of Functional Programming, 16(2):197–217, 2006. 9. G´erard Huet. The zipper. Journal of Functional Programming, 1997. 10. ocaml-batteries team. Ocaml batteries included. https://github.com/ ocaml-batteries-team/batteries-included. Accessed: 2016-07-12. 11. William Pugh. Skip lists: A probabilistic alternative to balanced trees. In Algo- rithms and Data Structures, Workshop WADS '89, Ottawa, Canada, August 17-19, 1989, Proceedings, pages 437–449, 1989. 12. William Pugh and Tim Teitelbaum. Incremental computation via function caching. In POPL, 1989. 13. Daniel Dominic Sleator and Robert Endre Tarjan. Self-adjusting binary trees. In Proceedings of the 15th Annual ACM Symposium on Theory of Computing, 25-27 April, 1983, Boston, Massachusetts, USA, pages 235–245, 1983. 14. Nicolas Stucki, Tiark Rompf, Vlad Ureche, and Phil Bagwell. RRB vector: a practical general purpose immutable sequence. In ICFP 2015, 2015.
1902.00911
1
1902
2019-02-03T15:41:09
Study, representation and applications of hypergraph minimal transversals
[ "cs.DS" ]
This work is part of the field of the hypergraph theory and focuses on hypergraph minimal transversal. The problem of extracting the minimal transversals from a hypergraph received the interest of many researchers as shown the number of algorithms proposed in the literature, and this is mainly due to the solutions offered by the minimal transversal in various application areas such as databases, artificial intelligence, e-commerce, semantic web, etc. In view of the wide range of fields of minimal transversal application and the interest they generate, the objective of this thesis is to explore new application paths of minimal transversal by proposing methods to optimize the extraction. This has led to three proposed contributions in this thesis. The first approach takes advantage of the emergence of Web 2.0 and, therefore, social networks using minimal transversal for the detection of important actors within these networks. The second part of research in this thesis has focused on reducing the number of hypergraph minimal transversal. A concise and accurate representation of minimal transversal was proposed and is based on the construction of an irredundant hypergraph, hence are calculated the irredundant minimal transversal of the initial hypergraph. An application of this representation to the dependency inference problem is presented to illustrate the usefulness of this approach. The last approach includes the hypergraph decomposition into partial hypergraph the local minimal transversal are calculated and their Cartesian product can generate all the hypergraph transversal sets. Different experimental studies have shown the value of these proposed approaches.
cs.DS
cs
MINISTÈRE DE L'ENSEIGNEMENT SUPÉRIEUR ET DE LA RECHERCHE SCIENTIFIQUE RÉPUBLIQUE TUNISIENNE UNIVERSITÉ DE TUNIS EL MANAR FACULTÉ DES SCIENCES DE TUNIS Thèse Présentée en vue de l'obtention du diplôme de Docteur en Informatique Par Mohamed Nidhal Jelassi Etude, représentation et applications des traverses minimales d'un hypergraphe Soutenue publiquement le 08/12/2014 Au sein du laboratoire : LIPAH Sous la direction de Pr. Sadok Ben Yahia et Pr. Christine Largeron 2013-2014 9 1 0 2 b e F 3 ] S D . s c [ 1 v 1 1 9 0 0 . 2 0 9 1 : v i X r a Remerciements Je tiens tout d'abord à remercier Monsieur Jean-Marc Petit, Professeur à l'Institut National des Sciences Appliquées de Lyon, et Madame Sawssen Krichen, Maître de Conférences HDR à l'Institut Supérieur de Gestion, d'avoir accepté d'être les rapporteurs de mon travail de thèse. Leurs lectures minutieuses et leurs remarques pertinentes m'ont permis d'améliorer la qualité de ce manuscrit. Plus généralement, je remercie l'ensemble du jury, notamment Messieurs Faouzi Ben Charrada, Maître de Conférences HDR à la Faculté des Sciences de Tunis, François Jacque- net, Professeur à l'Université Jean Monnet de Saint-Etienne, et Mohamed Quafafou, Professeur à l'Université d'Aix-Marseille, qui ont tout de suite accepté d'être examinateurs et juger mon travail. Je tiens à adresser mes vifs remerciements et ma profonde reconnaissance à Madame Christine Largeron, Professeur a l'Université Jean Monnet de Saint-Etienne, et Monsieur Sadok Ben Ya- hia, Professeur à la Faculté des Sciences de Tunis, pour avoir dirigé mon travail, pour leurs conseils et disponibilités, pour leurs encouragements et leurs soutiens continus. L'intérêt qu'ils ont manifesté pour mon travail, leurs suggestions, et leurs remarques ont été d'une importance capitale. Sous leur direction, j'ai appris davantage de rigueur, de sens critique et de discipline. Un merci spécial également à mon frère Nader Jelassi. Ta présence à mes côtés a été précieuse et vitale, notamment lors de nos séjours en France. Nos longues discussions, en arpentant les rues de Clermont et Saint-Etienne, ont été importantes pour l'avancement de cette thèse. Merci d'avoir toujours été là pour moi. Un immense merci aussi pour mon compagnon de route, mon ami et mon frère Aymen Sel- laouti. Nous nous sommes rencontrés lors de notre première année universitaire et nous ne nous sommes plus quittés, gravissant les échelons ensemble. Je te remercie pour tes encouragements, tes conseils et le soutien que tu m'as apporté tout au long de ces années. Enfin, je remercie tous les membres du laboratoire Lipah pour ces années passées ensemble ainsi que ceux du laboratoire Hubert Curien pour l'accueil chaleureux qui m'a été réservé lors de mes différents séjours à Saint-Etienne. Table des matières 1 Contexte et concepts de base 1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 Préliminaires . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2.1 Hypergraphes . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3 Problème de l'extraction des traverses minimales . . . . . . . . . . . . 1.4 Domaines d'application . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.1 Bases de données . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.2 Logique . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.3 Intelligence artificielle . . . . . . . . . . . . . . . . . . . . . . . 1.4.4 E-commerce . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4.5 Fouille de données . . . . . . . . . . . . . . . . . . . . . . . . 1.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 État de l'art 2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2 Algorithme de Berge [Ber89] . . . . . . . . . . . . . . . . . . . . . . 2.3 Améliorations de l'algorithme de Berge . . . . . . . . . . . . . . . . 2.3.1 Algorithme de Dong et Li [DL05] . . . . . . . . . . . . . . . . 2.3.2 Algorithme de Kavvadias et Stavropoulos [KS05] . . . . . . . 2.3.3 Algorithme de Bailey et al. [BMR03] . . . . . . . . . . . . . . 6 6 7 7 12 14 14 15 16 16 17 18 19 19 19 21 22 22 24 i TABLE DES MATIÈRES 2.4 Algorithme de Fredman et Kachiyan [FK96] . . . . . . . . . . . . . . 2.5 Algorithme MtMiner [HBC07] . . . . . . . . . . . . . . . . . . . . . 2.6 Algorithmes de type Shd [MU13] . . . . . . . . . . . . . . . . . . . . 2.7 Algorithme de Toda [Tod13] . . . . . . . . . . . . . . . . . . . . . . . 2.8 Les traverses minimales approchées . . . . . . . . . . . . . . . . . . . 2.9 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.10 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Identification des multi-membres dans un réseau social 3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 Problématique . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3 Definition d'une traverse minimale multi-membres . . . . . . . . . . . 3.4 Méthodologie et algorithmes d'extraction des multi-membres . . . . . 3.4.1 Algorithme M2D . . . . . . . . . . . . . . . . . . . . . . . . . 3.4.2 Algorithme O-M2D . . . . . . . . . . . . . . . . . . . . . . . 3.5 Etude de la complexité . . . . . . . . . . . . . . . . . . . . . . . . . . 3.6 Etude expérimentale . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 "Diviser pour régner" pour l'extraction des traverses minimales d'un hypergraphe 4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2 Objectifs de la décomposition . . . . . . . . . . . . . . . . . . . . . . 4.2.1 Diviser pour régner . . . . . . . . . . . . . . . . . . . . . . . . 4.2.2 Originalité de l'approche . . . . . . . . . . . . . . . . . . . . . 4.3 Définitions et notations . . . . . . . . . . . . . . . . . . . . . . . . . . 4.4 Traverses minimales locales : approche et algorithme . . . . . . . . . 4.5 Etude de la complétude . . . . . . . . . . . . . . . . . . . . . . . . . 26 27 31 33 35 35 38 39 39 40 43 46 47 50 54 54 64 68 68 69 69 70 71 74 77 TABLE DES MATIÈRES 4.6 Etude Expérimentale . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Conclusion générale 79 82 83 Table des figures 1.1 Exemple d'un hypergraphe . . . . . . . . . . . . . . . . . . . . . . . . 1.2 Hypergraphe dual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3 Domaines d'application des traverses minimales [Hag08] . . . . . . . . 3.1 Un exemple d'hypergraphe H = (X , ξ) et la matrice d'incidence IMH correspondante . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 Nombre de ressources partagées par les 25 utlisateurs les plus actifs . 3.3 Nombres de tags des 25 utilisateurs les plus actifs . . . . . . . . . . . 4.1 Un exemple d'hypergraphe H = (X , ξ) et la matrice d'incidence IMH correspondante . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2 Les 3 hypergraphes partiels dérivés de H : H1, H2 et H3 . . . . . . . 8 10 15 44 61 62 73 74 iv Liste des tableaux 2.1 Caractéristiques des algorithmes de l'état de l'art . . . . . . . . . . . 36 3.1 Les Tmms extraits à partir de l'hypergraphe de la Figure 3.1 . . . . . 3.2 Caractéristiques du jeu de données de gestion de projets . . . . . . . 49 56 3.3 Jeu de données de gestion de projets : temps d'exécution (en secondes) 57 3.4 Caractéristiques des bases sociales [(Haut) del.icio.us (Bas) Mo- vieLens] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 3.5 Bases sociales [(Haut) del.icio.us (Bas) MovieLens] : Temps d'exé- cution (en secondes) . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 3.6 Bases sociales[(Haut) del.icio.us (Bas) MovieLens] : Consomma- tion mémoire (en KO) . . . . . . . . . . . . . . . . . . . . . . . . . . 3.7 Base pire des cas pour ξ = 3 . . . . . . . . . . . . . . . . . . . . . . 3.8 Bases pire des cas : Temps d'exécution (en secondes) . . . . . . . . . 3.9 Bases pire des cas : Consommation mémoire (en KO) . . . . . . . . . 63 64 66 67 4.1 Caractéristiques et temps de traitement des hypergraphes Accidents et Connect (en secondes) . . . . . . . . . . . . . . . . . . . . . . . . . 79 4.2 Caractéristiques et temps de traitement des hypergraphes aléatoires (en secondes) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 v Introduction générale La théorie des hypergraphes se propose de généraliser la théorie des graphes en introduisant le concept d'hyperarête. Une traverse est définie comme un ensemble de sommets qui intersecte toutes les hyperarêtes d'un hypergraphe et elle est dite minimale si elle l'est au sens de l'inclusion. Le problème de l'extraction des traverses minimales d'un hypergraphe est connu comme étant particulièrement difficile dans la mesure où premièrement, il est connu pour être coNP-complet malgré que sa complexité exacte est une question qui reste toujours ouverte, et deuxièmement de tous les algorithmes qui se sont attachés à calculer les traverses minimales, aucun n'a, à ce jour, une complexité théorique polynomiale en la taille de l'entrée et de la sortie, sauf pour des hypergraphes bien particuliers. De plus, l'un des verrous scientifiques les plus difficiles à affronter, en matière d'extraction des traverses minimales, est le nombre de traverses minimales à explorer qui peut être très élevé même pour des hypergraphes simples. Pour autant, l'intérêt pour l'extraction des traverses minimales est en nette crois- sance due principalement aux solutions qu'elles offrent dans divers domaines d'ap- plication comme les bases de données, l'intelligence artificielle, l'e-commerce, le web sémantique, etc. Par ailleurs, la fouille de données arrive maintenant à maturité sur les contextes d'extraction classiques pour lesquels les algorithmes ont été mis au point. Ainsi, par exemple, les bases de données commerciales, qui décrivent les achats réalisés par des millions de clients sur des milliers de références sont désormais 1 Introduction générale parfaitement exploitées par les spécialistes à l'aide de méthodes fondées sur les règles d'association. Ces techniques se popularisent aussi dans les domaines médicaux, éco- nomiques ou industriels. Dans ce travail de thèse, nous focalisons notre intérêt sur les liens, déjà prouvés dans la littérature, entre la fouille de données et la théorie des hypergraphes pour redéfinir les notions d'hypergraphe et de traverse minimale. L'adaptation des tech- niques de la fouille de données, conjuguée à l'exploitation de certaines propriétés des hypergraphes, présente une voie intéressante pour la mise en place d'un cadre méthodologique pour l'optimisation de l'extraction des traverses minimales. Avec l'emergence du Web 2.0 et des réseaux sociaux, nous avons tout d'abord été amenés à mettre à profit les traverses minimales pour la recherche d'information au sein ces systèmes communautaires. Ceci nous a conduit à proposer une modélisa- tion originale d'un réseau social sous forme d'hypergraphe, particulièrement utile et adapté au cas où on ne dispose pas de toutes les relations entre les individus du ré- seau social considéré. A partir de cet hypergraphe, nous nous sommes intéressés à une classe particulière de traverses minimales, appelée traverse minimale multi-membres, dans le contexte des systèmes communautaires. Un protocole expérimental basé sur des jeux de données du monde réel a confirmé l'intérêt de cette approche. Ce faisant, nous avons été confrontés au problème du nombre important de traverses minimales à extraire même pour un hypergraphe simple. Pour le résoudre, nous préconisons de représenter cet ensemble de manière concise et exacte en exploitant l'irrédondance de l'information dans les hypergraphes. De ce fait, notre travail consiste en la re- presentation de l'ensemble des traverses minimales par un sous-ensemble succinct, composé de traverses minimales irrédondantes. L'introduction d'une mesure d'éva- luation, appelée taux de compacité, nous permettra de calculer le pourcentage de traverses minimales pouvant être déduite directement à partir de l'ensemble des tra- verses minimales irrédondantes. Nous avons illustré l'intérêt de cette représentation Introduction générale concise et exacte des traverses minimales pour résoudre le problème de l'inférence des dépendances fonctionnelles dans le but de calculer la couverture minimale d'une relation donnée. Par ailleurs, afin d'optimiser le calcul des traverses minimales d'un hypergraphe, nous avons proposé de décomposer l'hypergraphe d'entrée en un nombre d'hyper- graphes partiels égal au nombre de transversalité de l'hypergraphe initial. A partir de ces hypergraphes partiels, nous calculons leurs traverses minimales locales respec- tives, dont le produit cartésien nous fournira un ensemble de traverses de l'hyper- graphe. Les tests de minimalités permettent, ensuite, de ne garder que les traverses minimales. Le principal intérêt de cette approche est que ces tests sont inutiles pour les traverses dont la taille est égal au nombre de transversalité de l'hypergraphe d'entrée et dont nous sommes sûrs qu'ils sont minimales. Le présent mémoire, décrivant le travail réalisé au cours de cette thèse, est composé de cinq chapitres. Le premier chapitre introduit le contexte de nos recherches et présente les concepts de base que nous utiliserons dans la suite. La diversité des domaines d'ap- plication des traverses minimales est aussi mise en avant dans ce chapitre avec des points d'orgue pour les domaines ayant fait l'objet de nombreux travaux dans la littérature. Le deuxième chapitre présente l'état de l'art et notamment les différents algo- rithmes, proposés dans la littérature, pour l'extraction des traverses minimales d'un hypergraphe. Ce chapitre mettra en évidence les différentes approches, techniques et autres stratégies utilisés pour présenter des solutions à cette problématique ainsi qu'une étude comparative de ces algorithmes. Cette synthèse permet aussi de situer nos contributions par rapport aux travaux antérieurs. Introduction générale Notre première contribution est introduite dans le troisième chapitre. Nous pré- sentons les traverses minimales multi-membres (tmm), qui représentent une "sous- classe" des traverses minimales d'un hypergraphe. Ces tmm sont les plus petites tra- verses minimales, vérifiant une propriété de recouvrement, d'un hypergraphe d'entrée dont chaque hyperarête représente une communauté d'un réseau social donné. Un algorithme performant d'extraction de ces tmm, décrit dans ce chapitre, repose sur le calcul du nombre de transversalité de l'hypergraphe d'entrée. De plus, une appli- cation sur des jeux de données du monde réel est décrite et interprétée pour mettre en exergue l'intérêt des tmm. Dans le quatrième chapitre, nous présentons notre deuxième contribution qui consiste en la representation concise et exacte de l'ensemble des traverses minimales. Cette représentation exploite l'irrédondance de l'information dans les hypergraphes, qui nous a conduit à définir et à mettre en place un cadre méthodologique pour le calcul des traverses minimales irrédondantes. Nous montrons, ensuite, l'intérêt de notre representation concise et exacte des traverses minimales à travers la résolution du problème de l'inférence des dépendances fonctionnelles. Les traverses minimales ayant déjà été utilisées pour optimiser le processus de calcul de la couverture mini- male de toutes les dépendances fonctionnelles d'une relation donnée, nous proposons d'utiliser les traverses minimales irrédondantes pour réduire la taille de cette couver- ture. Dans le cinquième chapitre, nous nous intéressons à l'extraction de toutes les traverses minimales. Étant donné que le nombre de ces dernières peu être exponentiel en la taille de l'hypergraphe, nous proposons d'optimiser leur calcul en décomposant l'hypergraphe d'entrée en des hypergraphes partiels. Nous choisissons un nombre Introduction générale d'hypergraphes partiels égal au nombre de transversalité de l'hypergraphe d'entrée afin d'éliminer des tests de minimalité et d'optimiser les temps de traitement néces- saires au calcul de toutes les traverses minimales. A partir de chaque hypergraphe partiel, un ensemble de traverses minimales (dites locales) est calculé et un produit cartésien de toutes les traverses minimales locales permet de retrouver les traverses minimales de l'hypergraphe initial, suivant une stratégie "diviser pour régner". Chapitre 1 Contexte et concepts de base 1.1 Introduction Les hypergraphes généralisent la notion de graphe en définissant des hyperarêtes qui contiennent des familles de sommets, contrairement aux arêtes classiques qui ne joignent que deux sommets. D'un point de vue théorique, les hypergraphes per- mettent de généraliser certains théorèmes de graphes, voire d'en factoriser plusieurs en un seul. D'un point de vue pratique, ils sont parfois préférés aux graphes puisqu'ils modélisent mieux certains types de contraintes. Dans ce chapitre, nous présentons quelques définitions essentielles sur les hypergraphes et les traverses minimales néces- saires à l'introduction de la problématique de l'extraction des traverses minimales, en se basant essentiellement sur les définitions proposées par Berge dans [Ber89]. En- suite, nous passons en revue le large éventail des domaines d'application des traverses minimales. 6 1.2 Préliminaires 1.2 Préliminaires La théorie des hypergraphes se propose de généraliser la théorie des graphes en in- troduisant le concept d'hyperarête. Dans un hypergraphe où chaque hyperarête peut contenir plusieurs sommets, une traverse minimale correspond à un sous-ensemble de sommets qui intersecte toutes les hyperarêtes d'un hypergraphe, en étant minimal au sens de l'inclusion. 1.2.1 Hypergraphes Un hypergraphe H = (X , ξ) est donc constitué de deux ensembles X et ξ, et est défini suivant la Définition 1. Définition 1 hypergraphe [Ber89] Soit le couple H = (X , ξ) avec X = {x1, x2, . . . , xn} un ensemble fini et ξ = {e1, e2, . . . , em } une famille de parties de X . H constitue un hypergraphe sur X si : 1. ei 6= ∅, i ∈ {1,. . . , m} ; 2. Si=1,...,m Les éléments xi de X sont appelés sommets de l'hypergraphe et les éléments ei de ei = X . ξ sont appelés hyperarêtes de l'hypergraphe. Un hypergraphe est dit d'ordre n si X = n et la taille d'un hypergraphe est égale au nombre d'occurrences des sommets dans ses hyperarêtes. Exemple 1 La Figure 1.1 illustre un hypergraphe H = (X , ξ) d'ordre 8 et de taille 15 tel que X = {1, 2, 3, 4, 5, 6, 7, 8} et ξ = {{1, 2}, {2, 3, 7}, {3, 4, 5}, {4, 6}, {6, 7, 8}, {7}}. Définition 2 hypergraphe simple H = (X , ξ) est dit hypergraphe simple si pour tout ei ∈ ξ et ej ∈ ξ, alors ei ⊆ ej ⇒ 1.2 Préliminaires Figure 1.1 -- Exemple d'un hypergraphe i = j, i.e, aucune hyperarête de H ne renferme une autre hyperarête, sinon, H est dit hypergraphe multiple. Ainsi, la définition des hypergraphes englobe celle des graphes. En effet, un graphe simple est un hypergraphe simple dont toutes les hyperarêtes sont de cardinalité 2, i.e., ei = 2 ∀ ei ∈ ξ. Propriété 1 [Ber89] Tout hypergraphe simple H d'ordre n vérifie :   e De plus, le nombre d'arêtes vérifie : X e∈ξ n −1   (cid:22) 1. n ξ (cid:22)   ⌊n/2⌋   Définition 3 sous-hypergraphe [Ber89] Soit l'hypergraphe H = (X , ξ) et Y ⊆ X , nous appelons sous-hypergraphe de H tout hypergraphe HY = (Y, ξY) engendré par Y, tel que ξY = { eYi = ei ∩ Y ei ∈ ξ et eYi ∩ Y 6= ∅} Définition 4 hypergraphe partiel [Ber89] Soit l'hypergraphe H = (X , ξ) et ξ′ ⊂ ξ, nous appelons hypergraphe partiel de H 1.2 Préliminaires tout hypergraphe H′ = (X ′, ξ′) engendré par ξ′, tel que X ′ = Se′∈ξ′ e′. H′ est alors la restriction de l'hypergraphe H à un sous-ensemble d'hyperarêtes ξ′ inclus dans ξ et aux sommets inclus dans X ′. Le rang r(H) d'un hypergraphe H est, le nombre maximum de sommets d'une hyperarête et est défini par r(H) = max{ei, ∀ ei ∈ ξ}. Inversement, l'anti-rang ar(H) désigne le nombre minimum de sommets d'une hyperarête, i.e, ar(H) = min{ ei , ∀ ei ∈ ξ} [Ber89] [EG95]. Trivialement, ar(H) ≤ r(H). Si le rang et l'anti-rang d'un hypergraphe H sont égaux, alors H est dit uniforme. Tout hypergraphe uniforme est simple. Exemple 2 Considérons l'hypergraphe H de la Figure 1.1. Nous avons r(H) = 3 et ar(H) = 1. Par conséquent, H n'est pas uniforme. De plus, H est dit n-uniforme si H est un hypergraphe simple uniforme de rang n [EG95]. En ce sens, tout graphe est un hypergraphe uniforme de rang égal à 2. Un hypergraphe est dit "intersectant" si aucun couple de ses hyperarêtes n'est disjoint, i.e., ∀e1, e2 ∈ ξ, e1 ∩ e2 6= ∅ [EG95]. Dans un hypergraphe, deux sommets xi et xj sont dits adjacents s'il existe une hyperarête ei qui les contient tous les deux ; deux hyperarêtes ei et ej sont dites adjacentes si leur intersection est non vide. Un hypergraphe H = (X , ξ) peut être représenté par une matrice d'incidence, no- tée IMH, définie comme suit : IMH[ei, xj]  Définition 5 Hypergraphe dual = 1 si xj ∈ ei = 0 sinon A tout hypergraphe H = (X , ξ), nous pouvons faire correspondre un hypergraphe H∗ 1.2 Préliminaires Figure 1.2 -- Hypergraphe dual = (X ∗, ξ∗) tel que X ∗ = ξ et ξ∗ = X . Les sommets x∗1, x∗2, . . ., x∗m représentent les hyperarêtes de H et les hyperarêtes e∗1, e∗2, . . ., e∗n représentent les sommets x1, x2, . . ., xn de H, où : Xj = {Ei i (cid:22) m, ei ∋ xj} (j = 1, 2, . . ., n). On a Xj 6= ∅, Sj Xi = ξ, donc H∗ est bien un hypergraphe. Exemple 3 Reconsidérons l'hypergraphe H de la Figure 1.1. La Figure 1.2 illustre l'hypergraphe dual H∗ de H tel que H∗ = (X ∗, ξ∗) X ∗ = {1, 2, 3, 4, 5, 6} et ξ∗ = {{1}, {1, 2}, {2, 3}, {3, 4}, {3} {4, 5}, {2, 5, 6}, {5}, {6}}. H∗ est appelé l'hypergraphe dual de H. La matrice d'incidence IMH de l'hyper- graphe H, et la matrice d'incidence IMH ∗ de l'hypergraphe H∗, se déduisent l'une de l'autre par transposition ; on a donc en particulier (H∗)∗ = H. Si deux sommets xi et xj de H sont adjacents, il leur correspond dans H∗ des hyperarêtes e∗i et e∗j adjacentes ; si deux hyperarêtes ei et ej de H sont adjacentes, il leur correspond des sommets x∗i et x∗j adjacents de H∗. 1.2 Préliminaires Définition 6 Traverse minimale [Ber89] Soit un hypergraphe H = (X , ξ). L'ensemble des traverses de H, noté γH, est égal à : γH = {T ⊂ X T T ei 6= ∅, ∀i = 1, . . . , ξ }. Une traverse T de γH est dite minimale s'il n'existe pas une autre traverse S de γH incluse dans T : ∄ S ∈ γH s.t. S ⊂ T . Nous noterons MH, l'ensemble des traverses minimales définies sur H. Dans l'exemple illustratif de la Figure 1.1, l'ensemble MH des traverses minimales de l'hypergraphe est : { {1, 4, 7}, {2, 4, 7}, {1, 3, 6, 7}, {1, 3, 6, 9}, {1, 5, 6, 7}, {2, 3, 6, 7}, {2, 3, 6, 9}, {2, 5, 6, 7}, {2, 4, 6, 9}, {2, 4, 8, 9}, {2, 5, 6, 9}, {1, 3, 4, 8, 9}}. A partir d'un hypergraphe H = (X , ξ), l'ensemble des traverses minimales MH permet la construction de l'hypergraphe transversal, que nous avons noté H t = (X t, ξt), tel que ξt = MH et X t = ξt Si=1 i ∀ et et i ∈ ξt [EG02]. Lemma 1 [Ber89] Pour tout hypergraphe simple H, nous avons H (t)(t) = H. Définition 7 Nombre de Transversalité [Ber89] Soit un hypergraphe H = (X , ξ), le nombre minimum de sommets d'un ensemble transversal est appelé le nombre de transversalité de l'hypergraphe H et est désigné par : τ(H) = min {T , s.t. T ∈ MH}. Ainsi, dans l'exemple illustratif de la Figure 1.1, le nombre de transversalité de l'hypergraphe H est égal à 3 car la plus petite traverse minimale de MH renferme 3 sommets. La détermination d'un nombre de transversalité apparaît dans de nombreux pro- blèmes combinatoires comme la détermination d'un ensemble stable maximum d'un graphe ou encore la détermination d'un ensemble absorbant minimum d'un 1-graphe [Ber89]. 1.3 Problème de l'extraction des traverses minimales 1.3 Problème de l'extraction des traverses minimales L'extraction des traverses minimales d'un hypergraphe est un des problèmes les plus importants en théorie des hypergraphes. C'est un problème algorithmique cen- tral et particulièrement difficile et la question de sa complexité exacte reste toujours ouverte. Plusieurs travaux se sont attachés à proposer diverses méthodes pour le traiter [Ber89] [KS05] [BEGK03]. Fredman et Khachiyan ont proposé un algorithme avec une complexité quasi-polynomiale de N(ologN ) où N représente la taille de l'en- trée et de la sortie [FK96]. Ce résultat de Fredman et Khachiyan nous donne un algorithme d'extraction des traverses minimales dont la complexité est bornée par MH × ( MH + H )o(MH+H) [Mar13]. Ce résultat relance le débat sur le fait que ce problème soit coNP-complet puisqu'à moins que tout problème coNP-complet admette un algorithme quasi-polynomial, le problème de l'extraction des traverses minimales n'est pas coNP-complet. Trouver une traverse minimale d'un hypergraphe est une tâche aisée mais calculer l'ensemble de toutes les traverses minimales pose plusieurs problèmes dans la mesure où le nombre de sous-ensembles de sommets à tester est très important. Les travaux antérieurs, pour faire sauter les différents verrous scientifiques que posait l'extraction des traverses minimales d'un hypergraphe, se sont attachés à réduire l'espace de re- cherche. Néanmoins, le coût du calcul reste substantiellement élevé et les algorithmes existants se sont heurtés à des temps d'exécution conséquents et à l'incapacité de traitement lorsque le nombre de transversalité de l'hypergraphe d'entrée est grand. Comme nous l'avons mentionné dans la section précédente, le problème de l'ex- traction des traverses minimales à partir d'un hypergraphe H est équivalent à celui de la construction de l'hypergraphe transversal à H. Formellement, nous définissions ce problème comme suit : 1.3 Problème de l'extraction des traverses minimales Entrée : Hypergraphe simple H = (X , ξ). Sortie : Hypergraphe transversal H t = (X t, ξt). Même pour des hypergraphes simples, le nombre de traverses minimales d'un hy- pergraphe peut être exponentiel [Hag08], comme le montre l'exemple 4. Exemple 4 Soit H = (X , ξ) un hypergraphe tel que X = (x1, x2, . . . , x2n) et ξ = ({x1, x2}, {x3, x4}, . . . , {x2n−1, x2n}). H est de taille 2n mais renferme 2n traverses minimales. La complexité des approches proposées dans la littérature, et décrites dans le cha- pitre suivant, est analysée en termes de la taille d'entrée et de sortie. Plus concrè- tement, si n = X , m = ξ et m' = MH , nous disons qu'un algorithme d'extraction des traverses minimales est polynomial en la taille de l'entrée et de la sortie N si sa complexité peut être bornée, de manière polynomiale, par N, qui désigne une fonction de n, m et m'. En outre, un algorithme est incrémental s'il énu- mère une par une toutes traverses minimales de l'hypergraphe d'entrée de telle sorte que le temps nécessaire pour délivrer en sortie une nouvelle transverse minimale est polynomiale en n, m et k, k étant la taille de l'hypergraphe transversal. La notion d'algorithme incrémental a ouvert la voie à une autre approche consistant à ne générer qu'un sous-ensemble de traverses minimales, i.e., une liste partielle de traverses minimales, à partir de l'hypergraphe d'entrée. Formellement, ce problème est défini comme suit : Entrée : Hypergraphe simple H = (X , ξ) et un sous-ensemble de traverses minimales S ⊆ MH. Sortie : Vrai si S ⊆ MH, sinon retourner une traverse minimale de MH \ S. Un troisième problème a été défini par [BI95] et qui se résume à vérifier si deux 1.4 Domaines d'application hypergraphes sont transversaux l'un par rapport à l'autre. Entrée : Deux hypergraphes simples H = (X , ξ) et H′ = (X ′, ξ′). Sortie : Vrai si H′ = H t, Faux sinon. Les trois problèmes sont liés et divers algorithmes ont été proposés pour les résoudre. 1.4 Domaines d'application L'intérêt pour l'extraction des traverses minimales s'est accru, ces dernières an- nées, en raison de la diversité des domaines d'application où le recours aux traverses minimales peut constituer une solution. Le large éventail des domaines d'application, comme le résume la Figure 1.3 [Hag08], donne ainsi une importance plus grande aux traverses minimales et motive l'intérêt qu'elles suscitent. Dans ce qui suit, nous en donnerons un aperçu et nous citerons les problèmes les plus connus, où les traverses minimales sont applicables. 1.4.1 Bases de données Plusieurs travaux se sont attachés à appliquer les traverses minimales pour ré- soudre des verrous scientifiques dans le domaine des bases de données. Jouant un rôle important dans l'identification, de façon minimale, des n-uplets que renferment les relations, l'identification des clés est fortement liée au problème du calcul des traverses minimales comme l'ont démontré les travaux de [DT99] et de [TS05]. Étant donné une relation et un ensemble de clés, décider de l'existence d'une autre clé est un problème, équivalent à celui de la recherche des traverses minimales. Les dépen- dances d'inclusion [MP03], qui sont une généralisation des clés étrangères dans un modèle relationnel, peuvent ainsi être déduites en adaptant les techniques de calcul des traverses minimales d'un hypergraphe. Celles-ci peuvent, par ailleurs, présenter 1.4 Domaines d'application Figure 1.3 -- Domaines d'application des traverses minimales [Hag08] des solutions aux problèmes de réécriture des requêtes, d'exécution des requêtes et d'actualisation des vues. Ces dernières, dont le rôle est très important dans la pré- sentation des données à partir des bases, peuvent en effet être gérées en se basant sur les traverses minimales. L'inférence des dépendances fonctionnelles représente aussi un domaine d'application fort intéressant des traverses minimales comme le montre les travaux de [MR94] et [LPL00] et comme nous le verrons dans le chapitre 4. 1.4.2 Logique En logique, une clause est une disjonction de littéraux, qui sont des variables booléennes ou leurs négations, alors qu'un terme est une conjonction. Une formule est sous sa forme normale disjonctive (FND) (resp. conjonctive (FNC)) si c'est une une disjonction de termes (resp. une conjonction de clauses). La détermination de la 1.4 Domaines d'application dualité FNC/FND est équivalente au problème de calcul des traverses minimales d'un hypergraphe. En effet, le problème, connu en logique, de la dualisation où il s'agit de calculer la forme duale normale disjonctive (fnd) monotone et irrédondante à partir d'une forme normale disjonctive du même type est équivalent au calcul d'un sous-ensemble des traverses minimales d'un hypergraphe. 1.4.3 Intelligence artificielle Plusieurs problématiques en intelligence artificielle ont un lien très fort avec les traverses minimales, à commencer par l'abduction. Définie par Peirce, l'abduction est un mode de raisonnement par lequel des faits utiles sont inventés (contrairement à l'induction qui consiste à inventer des théories) et est utilisée dans deux acceptations différentes. Plus formellement, à partir de l'ensemble caractéristique d'une théorie de Horn Σ, d'un littéral q et d'un sous-ensemble A de tous les littéraux, il s'agirait de trouver toutes les interprétations possibles pour q par rapport à A. Dans ce cas, une théorie logique est un ensemble de formules. C'est une Horn s'il s'agit d'un ensemble des clauses ayant, chacune, au plus un littéral positif. Les travaux de Eiter et al. [EG02] ont montré que ce problème de l'abduction est équivalent à une adaptation du calcul des traverses minimales d'un hypergraphe. 1.4.4 E-commerce Que ce soit pour des problématiques telles que la recherche du meilleur recou- vrement, dont les applications sont nombreuses, la réécriture des requêtes dans les e-catalogues ou la découverte des web services, les techniques d'extraction des tra- verses minimales peuvent jouer un rôle important en e-commerce, comme le montre les travaux de [BHL+05]. Ainsi, à titre d'exemple, l'une des tâches les plus impor- tantes en web services est de trouver automatiquement les services qui répondent à des contraintes d'utilisation spécifiques aux utilisateurs. Ce problème est singulière- 1.4 Domaines d'application ment similaire à celui de la recherche d'un ensemble de couverture dans un contexte de contraintes et pour lequel l'application des techniques de calcul des traverses minimales s'avère judicieuse. 1.4.5 Fouille de données Les liens entre certaines problématiques de la fouille de données [ABYL11, FEJ+12a] et les traverses minimales sont nombreuses. C'est d'ailleurs le domaine où l'applica- tion des traverses minimales est la plus intéressante, comme dans la génération des règles associatives, des itemsets fermés, des itemsets fréquents ou encore l'analyse formelle de concepts [BYN04a, HBYN10a, BBBY12a]. Les règles associatives sont de la forme "si x est présent dans une transaction alors il y a 95% de chance que y soit aussi présent". Elles sont cruciales au cours du processus d'extraction des connaissances. Une des étapes les plus importantes dans la génération des règles associatives est le calcul des ensembles fréquents et infré- quents. Or, calculer les ensembles maximaux k -fréquents ou les ensembles minimaux k -infréquents est équivalent à la construction d'un hypergraphe transversal comme l'ont démontré les travaux de Boros et al. [BGKM03] et, Mannila et Toivonen [MT97]. Par ailleurs, les règles associatives ayant comme prémisses les générateurs minimaux sont les règles les plus intéressantes en fouille de données. Les générateurs minimaux d'un itemset fermé F étant les plus petits itemsets ayant cette même fermeture F , leur calcul peut être optimisé en utilisant les traverses minimales d'un hypergraphe selon les travaux de [Gar06] et de [PT02]. Les treillis de concepts qui jouent un rôle important dans l'extraction de connaissances [PT02] et la génération des règles à partir de bases de données relationnelles [YN04a, BEBY06, GBYNB07, BSBYN12] peuvent aussi bénéficier des techniques d'extraction des traverses minimales en raison de leur relation avec les itemsets fermés. 1.5 Conclusion 1.5 Conclusion Nous avons introduit, dans ce chapitre, les notions-clés de la théorie des hyper- graphes tout en mettant en exergue les verrous scientifiques que posent le problème de l'extraction des traverses minimales d'un hypergraphe. Le survol des domaines d'application des traverses minimales démontre l'intérêt, de plus en plus, croissant pour les traverses minimales et, dans la littérature, plusieurs algorithmes dédiés à leur calcul ont été proposés. Dans le chapitre suivant, nous présentons un état de l'art détaillé de ces algorithmes, qui reposent sur des approches différentes. Chapitre 2 État de l'art 2.1 Introduction Plusieurs auteurs se sont intéressés au problème de l'extraction des traverses mini- males d'un hypergraphe. Dans ce chapitre, nous présentons un état de l'art détaillé de ces différentes approches, en mettant en exergue leurs points forts et leurs limites. Le nombre de traverses minimales d'un hypergraphe pouvant être exponentiel en la taille de l'hypergraphe, la question de la mise en place d'un algorithme résolvant le problème de l'extraction des traverses minimales d'un hypergraphe H avec une complexité polynomiale en H reste néanmoins ouverte. Une étude comparative des différents algorithmes existants nous permet de situer nos contributions par rap- port à ces travaux et mettre en lumière l'intérêt des différentes approches que nous proposons dans les chapitres suivants. 2.2 Algorithme de Berge [Ber89] Berge est le premier à s'être intéressé au problème du calcul des traverses mi- nimales et à avoir proposé un algorithme pour le résoudre. Cet algorithme, dont le 19 2.2 Algorithme de Berge [Ber89] principe est simple, commence par calculer l'ensemble des traverses minimales de la première hyperarête, qui est équivalent à l'ensemble des sommets contenus dans cette dernière. Ensuite, il met à jour cet ensemble des traverses minimales en ajoutant les autres hyperarêtes, une à une, de manière incrémentale. Ainsi, l'algorithme de Berge construit des hypergraphes partiels au fur et à mesure qu'il ajoute des hyper- arêtes. Néanmoins, l'algorithme a toujours besoin de stocker les traverses minimales intermédiaires avant de passer à l'étape suivante consistant à ajouter une nouvelle hyperarête. Formellement, l'algorithme de Berge repose sur la formule suivante [Ber89] : à partir d'un hyperpgraphe partiel Hi = (X , ξ) tel que X = {x1, x2, . . . , xn} et ξ = {e1, e2, . . . , ei}, l'ensemble des traverses minimales de {Hi−1 ∪ ei} = {min{T × {x}} tel que T ∈ MHi−1 et x ∈ ei}. L'opérateur "×" désigne le produit cartésien tel que A × B comporte toutes les pairs (a,b) tel que a ∈ A et b ∈ B. Algorithme 1 : L'algorithme de Berge [Hag08] Entrées : H = (X , ξ) : Hypergraphe Sorties : MH : ensemble des traverses minimales de H 1 début 2 MH1 = {{x} x ∈ ξ1} ; pour i = 2 → ξ faire 3 4 MHi = Min {T × {x} tel que T ∈ MHi−1, x ∈ ei} 5 MH = MHξ ; retourner MH 6 La complexité de cet algorithme, dont le pseudo-code est donné par l'Algorithme 1 est exponentielle en la taille de l'entrée et de la sortie [Hag08]. Ceci s'explique par la nécessité de stocker toutes les traverses intermédiaires vu que l'ensemble des traverses minimales n'est généré qu'après l'insertion de la dernière hyperarête. Ceci 2.3 Améliorations de l'algorithme de Berge rend l'algorithme de Berge impraticable sur des hypergraphes de grande taille. Récemment, Boros et al. ont prouvé que le temps de traitement de l'algorithme de Berge a une borne supérieure subexponentielle de N √N [BEM08]. 2.3 Améliorations de l'algorithme de Berge Plusieurs chercheurs ont cherché à améliorer l'algorithme de Berge. Parmi les améliorations les plus connues proposées récemment figurent celles introduites par Dong et al. [DL05], Kavvadias et Stavropoulos [KS05] et Bailey et al. [BMR03]. Algorithme 2 : L'algorithme de Dong et Li [Hag08] Entrées : H = (X , ξ) : Hypergraphe Sorties : MH : ensemble des traverses minimales de H 1 début 2 MH1 = {{x} x ∈ ξ1} ; pour i = 2 → ξ faire 3 4 5 6 7 8 9 10 11 12 Tg = {t ∈ MHi−1 t ∩ ei 6= ∅} ; i = {x ∈ ei {x} ∈ Tg} ; ecov M′Hi−1 = MHi−1\Tg ; e′i = ei\ecov pour chaque t′ ∈ M′Hi−1 trié par ordre croissant de cardinalité faire ; i pour chaque x ∈ e′i faire si t′∪ {x} n'est le sur-ensemble d'aucun élément de Tg alors Tg = Tg∪ {t′∪ {x}} MHi = Tg ; 13 MH = MHξ ; retourner MH 14 2.3 Améliorations de l'algorithme de Berge 2.3.1 Algorithme de Dong et Li [DL05] C'est en s'inspirant de l'extraction des itemsets émergeants en fouille de données que Dong et Li ont proposé une solution, dont le pseudo-code est donné par l'Algo- rithme 2. L'algorithme de Dong et Li a été évalué expérimentalement sur de nombreux jeux de données. Néanmoins, les auteurs n'ont pas effectué une analyse théorique de la complexité en temps de traitement de leur algorithme. Cependant, cette adaptation de l'algorithme initial s'est avérée très fructueuse. La principale amélioration de Dong et Li par rapport à l'algorithme de Berge réside dans l'optimisation réalisée lors du calcul de MHi−1 ×{{x} x ∈ ei}, et qui consiste à considérer uniquement les traverses qui intersectent la nouvelle hyperarête traitée et, aussi, à ne prendre que les sommets de ξi qui n'appartiennent pas déjà aux traverses minimales déjà identifiées. 2.3.2 Algorithme de Kavvadias et Stavropoulos [KS05] L'un des inconvénients majeurs de l'algorithme de Berge, observé par Kavvadias et Stavropoulos, est la consommation excessive en mémoire. Dans la mesure où la minimalité des nouvelles traverses calculées doit être testée, les traverses minimales intermédiaires doivent aussi être stockées en mémoire. L'algorithme de Kavvadias et Stavropoulos tente de surmonter ce problème de consommation mémoire, en utilisant deux techniques. La première introduit la notion de "sommets généralisés" selon la Définition 8. Définition 8 Soit H = (X , ξ) un hypergraphe. L'ensemble X ⊆ X est un ensemble de sommets généralisés de H si tous les sommets de X appartiennent aux mêmes hyperarêtes de ξ. Le pseudo-code de l'algorithme de Kavvadias et Stavropoulos est décrit par l'Al- gorithme 3. Le principe est le suivant. En ajoutant une hyperarête ei, l'algorithme 2.3 Améliorations de l'algorithme de Berge met à jour l'ensemble des sommets généralisés avant de considérer les éléments de i−1 MH g niveau i. H g ralisés calculés au niveau i − 1, les traverses minimales de l'hypergraphe H g et les sommets constituant ξi comme les ensembles de sommets généralisés du i−1 étant l'hypergraphe partiel composé uniquement des sommets géné- , i , MH g sont ensuite calculées selon la formule de Berge, i.e., en effectuant le produit carté- i sien entre MH g traverses candidates. i−1 et les sommets généralisés de ξg i , et en testant la minimalité de ces La seconde technique introduite par Kavvadias et Stavropoulos pour diminuer la consommation mémoire élevée revient à adopter une stratégie de recherche en profondeur d'abord. Berge utilisait une forme de parcours en largeur d'abord à travers la construction d'un "arbre" de traverses minimales. Au i-ème niveau de l'arbre, les noeuds sont des traverses minimales de l'hypergraphe partiel Hi. Les descendants d'une traverse minimale T , du niveau i, sont les traverses minimales de l'hypergraphe Hi+1 incluant T . Le parcours de cet "arbre" est très coûteux puisque les traverses minimales d'un hypergraphe H sont retrouvées dans le dernier niveau de l'arbre. De plus, certains noeuds sont "visités" plusieurs fois parce qu'ils peuvent avoir plusieurs parents. Pour remédier à ce problème, Kavvadias et Stavropoulos utilisent une stratégie en profondeur d'abord et introduisent la notion de "sommets appropriés" pour vérifier la minimalité des traverses générées. Ceci permet à l'algorithme de réduire consi- dérablement le stockage en mémoire durant le calcul des traverses minimales d'un hypergraphe. Définition 9 Soit un hypergraphe H = (X , ξ) et soit T une traverse minimale de l'hypergraphe partiel Hi−1 de H. Un ensemble de sommets généralisés X ⊆ X \ T , au niveau i est un ensemble de sommets appropriés pour T si aucun sous-ensemble de T ∪ X, excepté X, ne peut être supprimé sans que les sommets restants ne représentent plus une traverse. 2.3 Améliorations de l'algorithme de Berge Algorithme 3 : L'algorithme de Kavvadias et Stavropoulos [KS05] Entrées : H = (X , ξ) : Hypergraphe Sorties : MH : ensemble des traverses minimales de H 1 début 2 3 4 5 6 7 8 pour k = 0 → ξ faire Ajouter_hyperarête(ξk+1) ; Mettre à jour les sommets généralisés ; Considérer MH g k + 1 ; k et ξk+1 comme étant des sommets généralisés du niveau Calculer MH g k+1 = Min{MH g k × {{xi} :xi ∈ ξg k+1}} ; Déduire MH à partir de MHξ ; retourner MH L'algorithme de Kavvadias et Stavropoulos n'est pas polynomial en la taille de la sortie. Son temps de traitement est de l'ordre de N Ω(loglogN ), N désignant la taille de l'entrée et de sortie [Hag08]. Cet algorithme est l'un des plus performants, en termes de temps de traitement. Adoptant une stratégie en profondeur, l'algorithme consomme, par ailleurs, très peu de mémoire vive. Ce qui représente un avantage non négligeable. 2.3.3 Algorithme de Bailey et al. [BMR03] Pour traiter les hypergraphes de grande taille, Bailey et al. ont exploité les bonnes performances de l'algorithme de Dong et Li sur les hypergraphes renfermant des hyperarêtes de petite taille. L'algorithme de Bailey et al., dont le pseudo-code est décrit par l'Algorithme 4, prend en entrée un hypergraphe et comporte un pré- traitement récursif. A partir d'un sommet ou d'un ensemble de sommets Xpart apparaissant dans le 2.3 Améliorations de l'algorithme de Berge Algorithme 4 : L'algorithme de Bailey et al. [Hag08] Entrées : H = (X , ξ) : Hypergraphe Sorties : MH : ensemble des traverses minimales de H 1 début 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 X = X ; Ordonner(X ) ; pour i = 1 → X faire ξpart = ∅ ; X = X \ xi pour chaque e ∈ ξ faire si xi 6∈ e alors ξpart = ξpart ∪ {e \ X} ; Xpart = Xpart ∪ xi ; si ξpart ≥ 2 and Volume(ξpart) ≥ 50 alors Algorithme 4 (Xpart, ξpart) ; sinon Mξpart = Algorithme 2(ξpart) ; MH = min(MH ∪ (Mξpart × Xpart)) ; Xpart = Xpart \ {xi} retourner T r plus petit nombre d'hyperarêtes dans l'hypergraphe d'entrée, ce pré-traitement vise à construire un sous-ensemble d'hyperarêtes ξpart ne contenant pas ces sommets Xpart. Si ξpart est elevée (≥ 2) et si son volume, fonction de la cardinalité moyenne de ces hyperarêtes est aussi elevée (≥ 50) alors l'algorithme de Bailey et al. est appelé de manière récursive. Sinon, les traverses minimales de ξpart sont déterminées par 2.4 Algorithme de Fredman et Kachiyan [FK96] l'algorithme de Dong et Li. Les traverses minimales de l'hypergraphe d'entrée sont ensuite déduites par la méthode de Berge via un produit cartésien entre les traverses minimales de l'hypergraphe constitué par les hyperarêtes ξpart et Xpart, conjugué à un test de la minimalité. Les expérimentations menées par les auteurs ont montré l'efficacité de leur algorithme, sur un type particulier d'hypergraphes, par rapport aux deux algorithmes considérés, i.e., celui de Fredman et Kachiyan, et celui de Kavvadias et Stavropoulos (une version antérieure à celle présentée dans la section 2.3.2) . 2.4 Algorithme de Fredman et Kachiyan [FK96] En 1996, Fredman et Kachiyan ont proposé deux algorithmes pour le calcul des traverses minimales d'un hypergraphe, l'algorithme FK-A et sa version optimisée, appelée l'algorithme FK-B. Ce dernier possède la meilleure complexité théorique connue à ce jour et qui est de N(ologN ) où N représente la taille de l'entrée et de sortie [FK96]. Les auteurs motivent le calcul de traverses minimales comme la solution au problème de la dualisation des formules booléennes monotones et c'est cette approche intuitive que nous reprenons. Étant donnée une formule f (x) = f (x1, x2, . . . , xn) sous forme normale conjonctive, il s'agit de calculer la formule duale correspondante f d(x) = ¯f (¯x) = ¯f ( ¯x1, ¯x2, . . . , ¯xn) sous forme normale conjonctive également. Pour cela, on obtient aisément f d sous forme normale disjonctive en remplaçant chaque conjonction de f par une disjonction et vice-versa. Pour calculer la forme normale conjonctive de la formule duale, il s'agit finalement de développer la forme normale disjonctive pour constituer les classes de f d. Pour cela, on prendra un littéral dans chaque terme de ¯f pour constituer une classe. Des simplifications apparaissent si l'on prend plusieurs fois le même littéral. Pour calculer les traverses minimales d'un hypergraphe, chaque traverse est construite en prenant un item dans chaque terme de ¯f : le résultat obtenu est identique à celui fourni par la dualisation des formules booléennes monotones. 2.5 Algorithme MtMiner [HBC07] Ce problème et celui du calcul des traverses minimales d'un hypergraphe sont alors parfaitement équivalents. Par exemple, soit f (x) = (x1 ∨x2) ∧ (x1 ∨x2 ∨x3) ∧ (x1 ∨x2 ∨x4) ∧ (x2 ∨x3 ∨x4) ∧ (x1 ∨ x2 ∨ x3 ∨ x4). La formule duale correspondante, obtenue en échangeant chaque conjonction par une disjonction et vice-versa, est f d(x) = (x1 ∧ x2) ∨ (x1 ∧ x2 ∧ x3) ∨ (x1 ∧ x2 ∧ x4) ∨ (x2 ∧ x3 ∧ x4) ∨ (x1 ∧ x2 ∧ x3 ∧ x4). Si nous développons scrupuleusement cette dernière expression pour la transformer en forme normale conjonctive, on obtient la série de clauses suivantes : f d(x) = (x1 ∨ x1 ∨ x1 ∨ x2 ∨ x1) ∧ (x1 ∨ x1 ∨ x1 ∨ x2 ∨ x2) ∧ . . . ∧ (x2 ∨ x3 ∨ x4 ∨ x4 ∨ x4). Ceci donne alors 216 clauses, dont il n'en restera que trois, après les simplifications : f d(x) = x2 ∧ (x1 ∨ x3) ∧ (x1 ∨ x4). La solution proposée par les auteurs revient à determiner, de façon incrémentale, si deux formules f et g ne sont pas duales, i.e., f(x) = ¯g(¯x). La vérification de la dualité, dans l'algorithme de Fredman et Khachiyan dont le pseudo-code est donné par l'Algorithme 5, et la mise en évidence d'un disqualifieur sont effectuées grâce à la propriété suivante : en factorisant f et g selon une va- riable xi, les auteurs font apparaître des formules plus courtes, f0, f1, g0 et g1 qui ne contiennent pas xi. On obtient ainsi f(x) = (xi ∧ f0(y)) ∨ f1(y) puis g(x) = (xi ∧ g0(y)) ∨ g1(y) (y ne contient pas le littéral xi). f et g sont duales si et seulement si f1 et g0 ∨ g1 le sont, ainsi que f0 ∨ f1 et g1. La taille du problème est ainsi réduite et permet d'appliquer récursivement ce procédé. Néanmoins, cette méthode est peu adaptée au calcul des traverses minimales de longueur bornée. 2.5 Algorithme MtMiner [HBC07] L'algorithme proposé par Hébert et al. consiste à exploiter les travaux réalisés, dans la littérature, sur l'extraction de motifs [HBC07]. Les auteurs ont réutilisé le principe des algorithmes par niveaux pour calculer les traverses minimales d'un hypergraphe. 2.5 Algorithme MtMiner [HBC07] Algorithme 5 : L'algorithme FK-A [FK96] Entrées : Deux formules monotones sous la Forme Normale Disjonctive f et g Sorties : Le Dual de f et g 1 début 2 3 4 5 6 7 8 9 10 11 Factoriser f et g Vérifier que f et g sont des formes mutuellement duales et que le problème peut se résoudre en un temps polynomial. si F G ≤ 1 alors le dual de f et g est calculé en O(1). si F G ≥ 2 alors Trouver une variable xi commune à f et g tel que Fréquence(xi) ≥ 1/log( F + G ) f = xif0 ∨ f1 ; g = xig0 ∨ g1 ; FK(f1, g0 ∨ g1) ; FK(g1, f0 ∨ f1) ; Cette approche repose donc sur le fait que les bases de données et les hypergraphes peuvent se représenter de la même manière, i.e, sous la forme d'une matrice booléenne où les sommets correspondent aux motifs et les hyperarêtes aux objets. Par le biais de la correspondance de Galois qui relie les ensembles de motifs et les ensembles d'objets, un parallèle est établi entre l'extraction des motifs et l'ex- traction des traverses minimales. L'extension de cette nouvelle connexion permet de définir des classes d'équivalence, pour un hypergrpahe, de façon analogue aux classes d'équivalence utilisées en fouille de motifs, selon la définition 10 [Héb07]. Ces classes regroupent les ensembles de sommets appartenant aux mêmes hyper- arêtes de l'hypergraphe d'entrée H. Le nombre d'hyperarêtes non recouvertes par un 2.5 Algorithme MtMiner [HBC07] ensemble de sommets est appelé fréquence et correspond alors au nombre d'occur- rences (support disjonctif) d'un motif en fouille de données. Les traverses de H sont, dans ce cas, les ensembles de sommets ayant une fréquence nulle. En utilisant les pro- priétés de la fouille de données, les auteurs ont prouvé que les traverses minimales de H sont les générateurs minimaux de fréquence nulle. Définition 10 La classe d'équivalence d'un ensemble de sommets X ⊆ X est notée RgH (X) et est définie comme suit : RgH (X) = {X′ ∈ X gH(X′) = gH(X)} où gH(X) est l'ensemble des hyperarêtes qui ne contient aucun sommet de X. L'algorithme MtMiner adopte deux stratégies d'élagage lors du parcours par niveau des candidats dans le treillis généré. La première repose sur la propriété d'anti-monotonie de la minimalité dans les classes d'équivalence, selon laquelle si un ensemble de sommets ne constitue pas un générateur minimal alors l'espace de recherche généré à partir de celui-ci est élagué. En effet, si un ensemble de sommets n'est pas un générateur minimal alors aucun de ses sur-ensembles ne peut être aussi un générateur minimal. Comme les auteurs ont déjà montré qu'une traverse minimale est nécessairement un générateur minimal, il est inutile de considérer ces sur-ensembles. La deuxième stratégie d'élagage consiste à éliminer les sur-ensembles d'un ensemble de sommets qui est une traverse minimale, puisqu'ils ne vérifient pas la condition de minimalité au sens de l'inclusion. L'algorithme MtMiner effectue un parcours en largeur en démarrant le balayage de l'espace de recherche par les sommets, avant de générer les ensembles plus grands, suivant une approche inspirée de Apriori [AR94]. La stratégie en largeur permet de garantir la minimalité des candidats, dans la mesure où chaque candidat n'est gardé dans un niveau i qu'après avoir calculé et testé l'extension de ses sous-ensembles directs, qui se trouvent dans le niveau i-1. L'ensemble MH est initialisé avec les sommets d'extension vide, i.e, qui appar- 2.5 Algorithme MtMiner [HBC07] Algorithme 6 : L'algorithme MtMiner [Héb07] Entrées : H = (X , ξ) : Hypergraphe Sorties : MH : ensemble des traverses minimales de H 1 début 2 MH = {{x} x ∈ X et gH({x}) = 0} ; 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Gen1 = {{x} x ∈ X et 0 < gH({x}) < ξ } ; k = 1 ; tant que Genk 6= ∅ faire pour chaque (X∪ {x1}, X∪ {x2}) ∈ Genk × Genk faire Z = X ∪ x1 ∪ x2 ; gH(Z) = gH(X∪ {x1}) ∩ gH(X∪ {x2}) ; i = 1 ; tant que i ≤ k+1 et Z\{xi} ∈ Genk et gH(Z) < gH(Z\ {xi}) faire i = i+1 ; si i = k + 2 alors si gH(Z) = 0 alors MH = MH ∪ Z ; sinon Genk+1 = Genk+1∪ {Z} ; k = k + 1 ; retourner MH tiennent à toutes les hyperarêtes de l'hypergraphe d'entrée (gH({x}) = 0). Ces sommets représentent donc des traverses minimales du niveau 1. A chaque niveau i, MtMiner génére des candidats Z, à partir des éléments calculés au niveau i-1. Si 2.6 Algorithmes de type Shd [MU13] le candidat Z vérifie la propriété d'anti-monotonie et si gH({Z}) = 0, il est alors ajouté à MH, sinon il sera reversé dans Geni+1 et servira comme générateur pour le niveau i+1. Si Z ne vérifie pas la propriété d'anti-monotonie, il n'est donc pas un générateur minimal et il est tout simplement élagué de l'espace de recherche. D'après Hébert et al., la complexité de l'algorithme MtMiner dépend de τ(H) et MH [Héb07]. Pour chaque traverse minimale T , l'algorithme considère au plus 2T ensembles de sommets et effectue, par conséquent, un nombre d'opérations inférieur à : PT∈MH De ce fait, pour un hypergraphe H, MtMiner calcule l'ensemble des traverses mi- (2T). nimales MH en O(2τ (H)× MH ). Cependant, pour Hagen, la complexité réelle de l'algorithme MtMiner est de O(N Ω(log(logN ))), telle que N est la taille de l'entrée et de la sortie de l'algorithme. Hagen présente le calcul détaillé de cette complexité dans [Hag08]. D'un point de vue performances, MtMiner présente des temps de traite- ments intéressants, notamment pour des hypergraphes denses et ayant un nombre de transversalité assez bas. Cependant, et comme souligné par les auteurs, MtMiner est assez gourmand en consommation mémoire [Elb08]. 2.6 Algorithmes de type Shd [MU13] Murakami et Uno proposent les algorithmes de type Shd, Mmcs et rs, qui visent à réduire l'espace de recherche [MU13]. En ce sens, ces algorithmes sont destinés à traiter des hypergraphes de grande taille constitués par un très grand nombre d'hyperarêtes. Les algorithmes de type Shd adoptent une stratégie de parcours en profondeur de l'espace de recherche qui, dans le cas de rs, est équivalente à celle de l'algorithme de Kavvadias et Stavropoulos. La principale différence entre ce dernier et rs repose sur l'élimination des itérations redondantes où aucun sommet n'est ajouté à un ensemble de sommets générés auparavant. De plus, Murakami et Uno introduisent deux nou- 2.6 Algorithmes de type Shd [MU13] veaux concepts, i.e, le test de la transversalité (uncov ) et les hyperarêtes critiques (crit), et ce afin d'optimiser les tests sur la minimalité effectués sur l'ensemble des traverses générées. Algorithme 7 : L'algorithme Mmcs [MU13] Var. Globale : uncov (initialisé à ξ), Cand (initialisé à X ), crit[x] initialisé à ∅ pour chaque x Entrées : H = (X , ξ) : Hypergraphe, X : ensemble de sommets Sorties : T tel que T ∈ MH 1 début 2 3 4 5 6 7 8 9 10 11 12 si uncov = ∅ alors retourner X Choisir une hyperarête e à partir de uncov ; C = Cand ∩ e ; Cand = Cand \ C ; pour chaque x ∈ C faire Update_crit_uncov(x, crit, uncov ) ; si crit(f, X ∪ x) 6= ∅ pour chaque f ∈ X alors Mmcs(X ∪ x) ; Cand = Cand ∪ x ; Restaurer les valeurs de crit et uncov d'avant la ligne 8 ; Étant donné X un ensemble de sommets, éventuellement réduit à un singleton, uncov(X) désigne l'ensemble des hyperarêtes que n'intersectent pas X, i.e, uncov(X) = {e ∈ ξ, e ∩ X = ∅}. X est une traverse si et seulement si uncov(X) = ∅. Pour un sommet x ∈ X, une hyperarête e ∈ ξ est dite critique pour x si X ∩ e = {x}. L'ensemble des hyperarêtes critiques pour x est noté crit(x, X), i.e., crit(x, X) = {e e ∈ ξ, e ∩ X = {x}}. Ainsi, un ensemble de sommets X ⊆ X est une traverse 2.7 Algorithme de Toda [Tod13] si uncov(X) = ∅ et c'est une traverse minimale si, en plus, crit(x, X) = 6 ∅ ∀x ∈ X. Par ailleurs, si X est une traverse, alors si le sommet x n'a aucune hyperarête critique, chaque e ∈ ξ renferme un sommet de X, autre que x, et X \ x est alors une traverse. Ceci est résumé par la propriété 2 proposée par les auteurs. Propriété 2 X est une traverse minimale si et seulement si uncov(X) = ∅ et crit(x, X) 6= ∅, ∀ x ∈ X. Les auteurs proposent aussi divers lemmes, dans [MU13], pour optimiser le calcul de la fonction crit, qui est la clé de leur approche. Les algorithmes de type Shd se basent donc sur la même approche et l'Algorithme 7 décrit le pseudo-code de l'algorithme Mmcs. Cet algorithme est récursif et fournit en sortie des traverses minimales en série. Pour tester un ensemble de sommets X, les algorithmes cherchent, de façon itérative, les sous-ensembles de X et effectuent un appel récursif pour chacun tout en mettant à jour les ensembles crit et uncov. En opérant de cette manière, Murakami et Uno permettent à leur algorithme de balayer l'espace de recherche en profondeur en cherchant seulement les sous-ensembles du candidat courant. La méthode et les étapes pour la recherche des sous-ensembles d'un candidat sont détaillées dans [MU13]. L'étude expérimentale effectuée par les auteurs a montré que les algorithmes de type Shd (et notamment mmcs) présentaient des performances très intéressantes et s'imposaient comme les algorithmes les plus performants dans la littérature. 2.7 Algorithme de Toda [Tod13] L'algorithme de Toda est le plus récent dans la littérature [Tod13]. Cet algorithme fait appel à des structures de données compressées qui permettent d'exploiter les capacités des diagrammes de décision binaire (bdd) et une des améliorations de ces dernières, i.e., les zéro diagrammes supprimés de décision (zdd). Les diagrammes de 2.7 Algorithme de Toda [Tod13] décision binaires permettent de représenter des fonctions booléennes sous la forme de graphes orientés. Leurs principes et mécanismes de fonctionnement sont décrits dans les travaux de [Ake78] et [BRB90]. Toda se base sur les travaux de Donald Knuth sur les zdd et tente de les additionner aux bdd pour optimiser son algorithme. L'intérêt des bdd dans l'algorithme de Toda se trouve dans la représentation des résultats intermédiaires. Comme le montre le pseudo-code de l'Algorithme 8, Toda génère d'abord les traverses avant de tester leur minimalité. Les traverses candidats sont compressées et stockées dans un bdd avant que le zdd généré ne fournisse les traverses minimales souhaitées. Ainsi, dans l'Algorithme 8, S(p) dénote la famille des ensembles d'un bdd (ou un zdd). Algorithme 8 : L'algorithme de Toda [Tod13] Entrées : H = (X , ξ) : Hypergraphe Sorties : MH 1 début 2 3 4 5 6 p = Compresser ξ en un zdd ; Calculer le bdd q pour toutes les traverses de S(p) ; Calculer le zdd r pour tous les ensembles minimaux dans S(q) ; Décompresser r en un ensemble ξ⋆ ; retourner ξ⋆ Les expérimentations effectuées par Toda visent à comparer son algorithme à celui de Murakami et Uno, présenté dans la section 2.6. L'etude expérimentale a montré que l'algorithme de Toda est compétitif, y compris sur les bases éparses. Ceci peut être expliqué par les capacités qu'offrent les zdd sur ce type de bases. 2.8 Les traverses minimales approchées 2.8 Les traverses minimales approchées Nous avons présenté, dans le chapitre précédent, le problème de l'extraction des traverses minimales d'un hypergraphe comme étant un problème NP-difficile. En ce sens, à côté des algorithmes présentés plus haut, d'autres travaux se sont inté- ressés à la recherche des traverses minimales approchées dans le but de contourner la difficulté du problème [AvG09] [DQ13]. Ces travaux, assez rares toutefois, s'inté- ressent à une sous-classe des traverses minimales dont les éléments n'intersectent pas toutes les hyperarêtes de l'hypergraphe d'entrée. Ainsi, dans [AvG09], les auteurs se sont basés sur une approche évolutionnaire où la transversalité et la minima- lité sont transcrites dans une fonction objective. D'autres approches introduisent un certain nombre d'exceptions liées à la transversalité pour générer les traverses mini- males approchées. Récemment, Durand et al. ont présenté dans [DQ13] l'algorithme δ-MTminer qui permet de calculer les transverses minimales approchées. L'algo- rithme prend en compte un nouveau paramètre, δ, qui correspond au nombre des hyperarêtes qu'une traverse minimale approchée pourrait ne pas intersecter. 2.9 Discussion A la lumière de notre description des principaux algorithmes d'extraction des tra- verses minimales d'un hypergraphe et avec pour objectif de situer nos contributions, présentées dans les chapitres suivants, par rapport à ces travaux, nous avons synthé- tisé les caractéristiques de ces algorithmes dans le tableau 2.1. Les critères que nous avons choisis pour distinguer les différentes approches sont le principe, sur lequel se base chaque algorithme, la stratégie d'exploration et les techniques d'élagages. Les caractéristiques des principaux algorithmes d'extraction des traverses mini- males ont été établies à partir des différentes sections présentées dans ce chapitre. La première constatation qui se dégage de ce tableau est qu'aucune approche n'a mis 2.9 Discussion Algorithme Algos sous-jacents Stratégie Techniques d'élagages d'exploration Berge - Processus En largeur Aucune incrémental Dong et Li - Algorithme 1 de Berge En largeur Traverses garanties Tg - Itemsets emergeants Couvertures d'hyperarêtes ecov Kavvadias et - Algorithme 1 de Berge En profondeur Sommets généralisés Stavropoulos Sommets appropriés Bailey et al. - Algorithme 1 de Berge et En largeur - Algorithme 2 de Dong et Li - Partitionnement des hyperarêtes FK - Dualisation des formules - Dualité Mutuelle booléennes monotones MtMiner - Extraction de motifs En largeur Anti-monotonie de Mmcs Toda - Itemsets fermés En profondeur la minimalité uncov et crit - Structures de En profondeur Caractéristiques des données compressées bdd et zdd Table 2.1 -- Caractéristiques des algorithmes de l'état de l'art 2.9 Discussion à profit la notion de nombre de transversalité, introduite par la Définition 7. Cette notion qui donne une indication claire sur le nombre minimum de sommets formant une traverse minimale peut être intéressante, notamment en adoptant une stratégie en largeur pour cibler directement le niveau qui contient ces plus petites traverses minimales. Notre première contribution, qui consiste à détecter les multi-membres d'un réseau social et qui correspondent à des plus petites traverses minimales d'un hypergraphe représentant les différentes communautés d'un réseau social, se base sur cette notion de nombre de transversalité pour optimiser l'extraction des plus petites traverses minimales à travers un algorithme appelé om2d que nous introduisons dans le chapitre suivant. Une deuxième constatation concerne les éléments générés en sortie par les diffé- rents algorithmes. Tous ces derniers calculent toutes les traverses minimales et leurs cardinalités sont généralement très importantes. Ce nombre de traverses minimales pouvant s'avérer exponentiel en la taille de l'hypergraphe, nous nous sommes inté- ressés à chercher une forme d'irrédondance dans l'ensemble des traverses minimales. Le fait de représenter cet ensemble de manière concise et exacte améliore le temps de traitement nécessaire à l'extraction de toutes les traverses minimales. En outre, et partant du fait que les traverses minimales apportent des solutions dans de nom- breuses applications, comme présenté dans la section 1.4 du chapitre 1 (page 14), cette représentation concise a des répercussions directes sur l'optimisation de bien d'autres problématiques. Notre deuxième contribution, présentée dans le chapitre 4, met en avant cette notion d'irredondance qui se cache dans les traverses minimales et l'illustre en présentant son impact sur le problème du calcul de la couverture minimale des dépendances fonctionnelles en bases de données. Enfin, notre troisième contribution consiste en une optimisation de l'extraction des traverses minimales en adoptant la stratégie diviser pour régner. Cette stratégie a été utilisée par l'algorithme 4 de Bailey et al. sauf que les auteurs se sont focalisés sur le 2.10 Conclusion partitionnement des hyperarêtes quand celles-ci sont composées d'un nombre impor- tant de sommets. Notre idée se base, plutôt, sur le partitionnement de l'hypergraphe d'entrée en k hypergraphes partiels tel que k est égal au nombre de transversalité. De cette manière, nous éliminons le test coûteux de la minimalité sur les traverses formées par k sommets. Cette approche s'est avérée fructueuse mais, seulement, sur un certain type d'hypergraphes. Une étude détaillée est présentée dans le chapitre 5. 2.10 Conclusion Dans ce chapitre, nous avons présenté les principaux algorithmes de calcul des traverses minimales, proposés dans la littérature. Que ce soit en adoptant une stra- tégie en largeur d'abord ou en profondeur d'abord, les différentes approches ont tenté d'innover avec pour but commun d'optimiser l'extraction des traverses minimales. En profitant de la notion de nombre de transversalité, inutilisée jusque-là, nous nous intéressons, dans le chapitre suivant, à une classe particulière des traverses minimales et à son application dans les systèmes communautaires. Chapitre 3 Identification des multi-membres dans un réseau social 3.1 Introduction Avec l'expansion des systèmes communautaires du Web 2.0, beaucoup de travaux se sont intéressés à identifier les membres clés dans les réseaux sociaux, qualifiés, se- lon les auteurs, d'influenceurs, de médiateurs, d'ambassadeurs ou encore d'experts. Ce problème a été notamment considéré comme un problème de maximisation. Dans ce chapitre, nous présentons un type particulier d'acteurs que nous appelons multi- membres, en raison de leur appartenance à plusieurs communautés. Nous introdui- sons alors un cadre méthodologique pour identifier ce type d'acteurs dans un hyper- graphe, dans lequel les sommets sont les acteurs et les hyperarêtes représentent les communautés. Nous démontrons que détecter les multi-membres pourrait être ra- mené au problème d'extraction des traverses minimales à partir d'un hypergraphe et nous présenterons deux algorithmes d'extraction des multi-membres qui conjuguent des concepts de la fouille de données et de la théorie des hypergraphes. Au cours de l'étude expérimentale, nous étudierons notamment la nature des acteurs qui consti- 39 3.2 Problématique tuent une traverse minimale multi-membres et leurs rôles au sein du réseau. 3.2 Problématique C'est en s'appuyant sur des représentations et des concepts issus de la théorie des graphes que les réseaux sociaux ont été étudiés en sciences sociales dès les années soixante [Mor34] [CH77]. Parmi les questions essentielles que l'analyse de réseau s'ef- force de traiter figure l'identification d'individus occupant un rôle déterminant dans le réseau. Ainsi, plusieurs indicateurs tels que la centralité ou le prestige ont été défi- nis pour caractériser la position occupée par un acteur [Fre79] [Sco00] [WF94] [BE92]. Néanmoins, la communauté scientifique informatique a été confrontée au problème du passage à l'échelle des algorithmes classiques de détection de tels individus. Avec l'émergence du Web 2.0 et l'explosion des réseaux sociaux sur Internet [HBGBY13a], des travaux plus récents se sont attachés à repérer des acteurs qui occupent une place particulière dans le réseau et qui selon appelés, selon les auteurs, influenceurs, média- teurs, ambassadeurs ou encore les experts [Dom05], [STE07a], [STE07b], [ALTY08], [OH10]. L'identification de tels acteurs a eu, en effet, de nombreuses applications, e.g., dans les domaines de l'épidémiologie, du marketing, ou encore de la diffusion d'innovation. En particulier, plusieurs algorithmes ont été présentés récemment [LKG+07], [CWY09], [WCSX10], [CWW10], [CYZ10], [KS06], [GLL11] pour résoudre le problème de re- cherche d'influenceurs, redéfini comme un problème de maximisation [DR01], [RD02], [KKT03]. Parmi les modèles de diffusion dans un réseau, répertoriés dans la littérature, on peut distinguer d'une part les modèles linéaires à seuil inspirés des travaux de Gra- novetter et Schelling [Gra78], [Sch78] et d'autre part les modèles à cascade indépen- dantes [JG01]. Dans tous ces modèles, on considère qu'à un instant donné, chaque 3.2 Problématique membre du réseau est soit actif soit inactif. On cherche, par un processus itératif, à déterminer les acteurs devenus actifs à partir d'un sous-ensemble d'acteurs initia- lement actifs. On suppose bien sûr qu'un acteur peut être influencé par ses voisins suivant un certain seuil ou une certaine probabilité. La mise en oeuvre de ces modèles requiert donc l'estimation de ces probabilités d'influence ou de ces seuils. Cependant, l'estimation des paramètres n'est pas le seul inconvénient de ces modèles. En effet, la recherche des influenceurs dans un réseau peut être énoncée plus formel- lement comme un problème d'optimisation discrète, connu dans la littérature sous le nom de "influence maximization" ou "spread maximisation". Étant donné A, un ensemble d'acteurs du réseau et une mesure d'influence associée à cet ensemble, défi- nie comme le nombre des acteurs devenus actifs à partir de A, le problème revient à déterminer, pour un paramètre k donné, les k acteurs du réseau qui maximise la fonc- tion d'influence. Or, Kempe et al. ont démontré que ce problème était NP-complet pour les deux familles de modèles citées précédemment [KKT03]. En s'appuyant sur la théorie des fonctions submodulaires, Kempe a aussi défini un cadre d'analyse généralisant les modèles à cascade et les modèles à seuil, et a montré qu'il est possible de déterminer une solution qui approche la solution opti- male à un facteur près, à l'aide d'algorithmes gloutons, tels que Greedy Algorithm [KKT03]. Ceci a conduit au développement d'heuristiques permettant de détermi- ner approximativement les influenceurs dans un réseau. Ainsi, en suivant ce cadre d'analyse, Leskovec et al. ont développé l'algorithme "Cost-Effective Lazy Forward" (CELF), qui a donné lieu ensuite à plusieurs extensions, telles que NewGreedy et MixedGreedy introduit par Chen et al. ou, plus récemment, CELF++ par Goyal et al. [LKG+07], [CWY09], [GLL11]. L'algorithme Greedy a fait aussi l'objet d'autres améliorations, exploitant des pro- priétés spécifiques du modèle à cascade [KS06] [CWW10] ou du modèle à seuil [CYZ10]. D'autres solutions ont aussi été proposées pour résoudre le problème de 3.2 Problématique maximisation de l'influence, comme par exemple le modèle de vote de Even-Dar et al., qui exploite d'ailleurs les mêmes hypothèses que les modèles à seuil [EDS07]. Ce- pendant, tous les travaux cités précédemment considèrent la recherche d'influenceurs comme un problème d'optimisation sans tenir compte explicitement des communau- tés présentes dans le réseau. Or, comme le souligne Scripps et. al., il peut être utile, pour identifier des influenceurs, de mieux connaître les positions occupées par les ac- teurs au sein des communautés présentes dans le réseau [STE07b], [STE07a]. C'est d'ailleurs le principe de l'algorithme Community-based Greedy, qui consiste juste- ment à détecter des communautés en tenant compte du processus de diffusion au sein du réseau puis à identifier les influenceurs au sein des communautés [WCSX10]. Cependant, comme les algorithmes précédemment cités, Community-based Greedy suppose que le réseau est décrit par un graphe simple de sorte que les relations entre les acteurs pris deux à deux sont connues. Ainsi, ces algorithmes exploitent la matrice d'adjacence associée au graphe décrivant le réseau. Dans de nombreuses applications, on ne dispose pas forcément de cette information. Par contre, on sait à quelle(s) communauté(s) appartient un acteur. Ainsi par exemple, on sait quels sont les chercheurs qui ont participé à la conférence KDD et ceux qui ont assisté à VLDB sans forcément connaître les liens directs existants entre ces chercheurs. De même, dans le domaine du marketing, on peut savoir quels sont les clients qui ont acheté des articles d'une gamme de produits sans savoir s'ils sont en relation. Dans ces deux cas, il peut être intéressant d'identifier des acteurs, en nombre le plus petit possible, susceptibles de diffuser des idées ou recommandations d'un groupe à un autre. C'est ce problème que nous nous proposons de résoudre. Nous émettons l'hypothèse que la propagation repose sur des acteurs qui sont susceptibles d'assurer la transmission entre les groupes d'individus. En ce sens, les multi-membres que nous recherchons sont, pour partie, des ambassadeurs tels que Scripss et al les définissent [STE07b]. Il s'agirait donc de déterminer le plus petit ensemble de membres du réseau susceptibles 3.3 Definition d'une traverse minimale multi-membres de couvrir toutes les communautés. L'objectif est donc de déterminer le plus petit ensemble d'acteurs, appelés multi- membres, qui sont susceptibles de représenter au mieux possible les différentes com- munautés du réseau en analysant le réseau dans ce contexte d'information incomplète où nous ne disposons pas de la matrice d'adjacence associée au graphe représentant le réseau mais où, en revanche, les communautés sont données. Pour ce faire, nous proposons de représenter le système communautaire sous la forme d'un hypergraphe dans lequel les sommets représentent les acteurs et les hy- perarêtes représentent les communautés. Dans cet hypergraphe, les multi-membres pourront être déterminés à partir des traverses minimales de l'hypergraphe, elles- mêmes définies comme un ensemble de sommets, minimal au sens de l'inclusion, qui intersecte toutes les hyperarêtes [Ber89]. 3.3 Definition d'une traverse minimale multi-membres Un réseau social peut être défini comme un ensemble d'entités interconnectés les unes aux autres [WF94]. Ces entités sont généralement des individus ou des organi- sations. Les relations matérialisent les interactions entre les entités. Dans le contexte d'un hypergraphe où nous disposons seulement des communautés d'un réseau modélisées par les hyperarêtes, nous considérons que les multi-membres correspondent au plus petit ensemble de sommets tel qu'au moins un élément ap- partient à chaque communauté et, si possible, avec plusieurs éléments appartenant à des communautés de large taille. En ce sens, la définition des multi-membres peut se baser sur celle d'une traverse minimale définie comme étant un ensemble de sommets ayant une intersection, non vide, avec chaque hyperarête. Exemple 5 Dans la suite de ce chapitre, nous utiliserons à titre illustratif l'hyper- graphe H = (X , ξ) de la Figure 3.1 (gauche) tel que X = {1, 2, 3, 4, 5, 6, 7, 8} et ξ 3.3 Definition d'une traverse minimale multi-membres 1 2 3 4 5 6 7 8 1 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 1 0 0 1 1 0 0 0 0 1 0 {1, 2} {2, 3, 7} {3, 4, 5} {4, 6} {6, 7, 8} {7} Figure 3.1 -- Un exemple d'hypergraphe H = (X , ξ) et la matrice d'incidence IMH correspondante = {{1, 2}, {2, 3, 7}, {3, 4, 5}, {4, 6}, {6, 7, 8}, {7}}. L'ensemble de ses traverses mi- nimales MH est {{1, 4, 7}, {2, 4, 7}, {1, 3, 6, 7}, {1, 5, 6, 7}, {2, 3, 6, 7}, {2, 5, 6, 7}}. La Table de la figure 3.1 (droite) représente la matrice d'incidence associée à l'hy- pergraphe H. Cet exemple d'hypergraphe H sera repris tout au long de ce chapitre pour illustrer notre approche et extraire les multi-membres de H. Nous pouvons redéfinir une traverse minimale à partir de la notion d'ensemble de sommets essentiels. Définition 11 Support d'un ensemble de sommets Soit l'hypergraphe H = (X , ξ) et X un sous-ensemble de sommets de X . Nous définissons Supp(X) comme le nombre d'hyperarêtes de H, renfermant au moins un élément de X : Supp(X) = {e ∈ ξ∃x ∈ X ∧ R(e, x) = 1}, R ⊆ ξ × X étant la relation binaire entre les hyperarêtes et les sommets de la matrice d'incidence correspondante à H. Ainsi, l'ensemble X peut être vu comme une disjonction de sommets (x1 ∨ x2 ∨ . . . ∨ xn) tel que la présence d'un seul sommet de X suffit à affirmer que X satisfait une hyperarête donnée, indépendamment des autres sommets. 3.3 Definition d'une traverse minimale multi-membres Définition 12 Ensemble essentiel de sommets ([CCL05]) Soit l'hypergraphe H = (X , ξ) et X ⊆ X . X représente un ensemble essentiel de sommets si et seule- ment si : Supp(X) > max{Supp(X\x) ∀x ∈ X}. Il est important de souligner que les ensembles essentiels, extraits à partir d'une matrice d'incidence, vérifient la propriété d'idéal d'ordre des itemsets essentiels, i.e, si X est un ensemble essentiel, alors ∀Y ⊂ X, Y est aussi un ensemble essentiel. De plus, la notion de traverse peut être redéfinie par le biais du support d'un ensemble de sommets et de la notion d'ensemble essentiel, selon la proposition 1. Proposition 1 Traverse minimale Un sous-ensemble de sommets X ⊆ X est une traverse minimale de l'hypergraphe H, si X est essentiel et si son support est égal au nombre des hyperarêtes de H, autrement dit, X est un ensemble essentiel tel que Supp(X)=ξ. Preuve 1 Soit X un ensemble essentiel de sommets tel que Supp(X)=ξ. Par conséquent, X T ei 6= ∅ ∀ei ∈ ξ, i = 1, . . . , m. Donc, d'après la définition 7, X est une traverse. La minimalité de X tient à son "essentialité". En effet, puisque X est essentiel, alors son support est strictement supérieur à celui de ses sous-ensembles directs. Par conséquent, ∄X1 ⊂ X s.t. Supp(X1)=ξ. X est donc une traverse mi- nimale. Exemple 6 L'ensemble des traverses minimales MH, calculées à partir de l'hy- pergraphe de l'Exemple 5, est {{1, 4, 7}, {2, 4, 7}, {1, 3, 6, 7}, {1, 5, 6, 7}, {2, 3, 6, 7}, {2, 5, 6, 7}}. En se basant sur les définitions présentées ci-dessus, nous pouvons donner une définition plus formelle des traverses minimales multi-membres (tmm). Définition 13 Traverse minimale multi-membres Soit H = (X , ξ), un hypergraphe et X ⊂ X . X est appelé Traverse minimale multi- membre, noté Tmm, si X vérifie les trois conditions suivantes : 3.4 Méthodologie et algorithmes d'extraction des multi-membres 1. (Condition nécessaire) : X est une traverse minimale : X ∈ MH. 2. (Condition de composition) : X est minimale dans MH dans le sens de la cardinalité : X = τ(H) where τ(H) = Min {T, ∀T∈MH}. τ(H) est le nombre de transversalité de H. 3. (Condition de recouvrement maximum) : Pei∈ξ/ei T X6=∅ ei = Max { Pei∈xi/ei T T6=∅ ei, ∀ T ∈ MH tel que T = τ(H) }. Ainsi, un ensemble de sommets est une Tmm s'il constitue une traverse minimale, si sa taille est la plus petite possible et s'il maximise la condition de recouvrement. Spécifiquement, la première condition assure qu'il existe au moins un multi-membre dans chaque communauté. La seconde suppose que l'ensemble des multi-membres est le plus petit possible. Ainsi, l'objectif est de représenter toutes les communautés avec un nombre minimal de sommets. La troisième condition, calculant le recouvrement maximum, prend en compte le fait que certains multi-membres peuvent appartenir à une ou plusieurs mêmes communautés. Dans ce cas, le but est de favoriser les éléments qui appartiennent aux communautés les plus grandes. Exemple 7 Pour l'hypergraphe de l'Exemple 5, nous avons une seule Tmm. C'est la traverse minimale {2, 4, 7}. 3.4 Méthodologie et algorithmes d'extraction des multi- membres A présent, nous introduisons un premier algorithme d'extraction des multi-membres, baptisé M2D, qui balaye l'espace de recherche en largeur. M2D repose sur la pro- priété d'ordre idéal garantie par les ensembles de sommets essentiels pour l'élagage des candidats. En ce sens, cet algorithme agit d'une manière brute-force en générant 3.4 Méthodologie et algorithmes d'extraction des multi-membres les candidats nécessaires. Il s'arrête après avoir atteint le niveau k, i.e. le nombre de transversalité, où a été détecté la première traverse minimale. 3.4.1 Algorithme M2D L'algorithme M2D, dont le pseudo-code est décrit par l'algorithme 9, prend en entrée un hypergraphe H et fournit en sortie l'ensemble des Tmms. L'algorithme effectue un parcours en largeur d'abord, i.e., il opère par niveau pour déterminer les ensembles de sommets essentiels. A chaque niveau k, un appel à la procédure Apriori-Gen [AR94] est effectué pour calculer les candidats de taille k, à partir des ensembles de sommets essentiels de taille k − 1. En effet, Apriori-Gen génère un nouveau candidat X′′ = {x1, x2, . . . , xi−1, xi, xi+1} à partir de deux candidats X′ et X, tels que X′ = {x1, x2, . . . , xi−1, xi} et X = {x1, x2, . . . , xi−1, xi+1}. M2D calcule, ensuite, le support des k-candidats générés, à la ligne 9, et vérifie si leurs supports respectifs sont strictement supérieurs à ceux de leurs sous-ensembles directs (ligne 10). Si parmi les ensembles de sommets essentiels, générés à un niveau k, il existe au moins un sommet, dont le support est égal au nombre d'hyperarêtes de l'hypergraphe (ligne 12), la boucle de la ligne 8 s'arrête et T MM renferme alors l'ensemble des traverses minimales qui sont minimales au sens de la cardinalité. Ces ensembles de sommets vérifient aussi bien la condition nécessaire que la condi- tion de composition de la définition 13. Au final, parmi ces candidats, les Tmms sont déterminés en se basant sur la fonction de calcul du recouvrement (ligne 16). Cette fonction calcule le nombre de sommets couverts par chaque candidat (i.e., la somme des cardinalités des communautés auxquelles appartient ce candidat) et retourne ceux qui ont la valeur maximale. Ainsi, la troisième condition de la définition 13 est aussi vérifiée. Exemple 8 Illustrons le déroulement de l'algorithme M2D sur l'hypergraphe de la 3.4 Méthodologie et algorithmes d'extraction des multi-membres Algorithme 9 : M2D Entrées : H = (X , ξ) : Hypergraphe Sorties : T MM 1 début 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 T MM = ∅ ; i := 1; pour chaque x ∈ X faire si Supp(x) = ξ alors T MM = T MM ∪ {x}; si T MM 6= ∅ alors Aller ligne 19 sinon find = false ; tant que Li 6= ∅ ou find = false faire Ci+1 := Apriori-Gen(Li); Li+1 := {X ∈ Ci+1 ∄ x ∈ X : Supp(X) = Supp(X\x)}; pour chaque X ∈ Li+1 faire si Supp(X) = ξ alors T MM = T MM ∪ {X}; find = true ; i := i + 1; T MM = Recouvrement(T MM) ; retourner T MM Figure 3.1. M2D balaye l'espace de recherche en opérant en largeur jusqu'à arriver au niveau 3. Toutes les traverses minimales, que renferme l'hypergraphe de la figure 3.1 3.4 Méthodologie et algorithmes d'extraction des multi-membres Min. Tran. Recouvrement 8 10 1 4 7 2 4 7⋆ 1 3 6 7 1 5 6 7 2 3 6 7 2 5 6 7 Table 3.1 -- Les Tmms extraits à partir de l'hypergraphe de la Figure 3.1 (page 44), sont données par la première colonne du tableau 3.1. Seules les plus petites traverses minimales, au sens de la cardinalité, nous intéressent et c'est la raison pour laquelle l'algorithme s'arrête au troisième niveau. Ces traverses minimales sont marquées comme étant des Tmms candidates : {1 4 7} et {2 4 7} dans le tableau 3.1. La fonction Recouvrement calcule, pour chaque candidat, la somme des tailles des communautés auxquelles il appartient et ne gardera que celui qui la maximise. Ainsi, le premier Tmm candidat est {1, 4, 7}. Le sommet 1 couvre le sommet 2, le sommet 4 couvre les sommets 3, 5 et 6. Enfin, le sommet 7 couvre les sommets 2, 3, 6 et 8. Le candidat {1, 4, 7} couvre donc, deux fois, chacun des sommets 2, 3 et 6, et une seule fois les sommets 5 et 8. Ainsi, le recouvrement du candidat Tmm {1, 4, 7} est égal à 8 sommets alors que, dans le même temps, le candidat {2, 4, 7} couvre au total 10 sommets. Ce dernier candidat est alors la seule Tmm de l'hypergraphe d'entrée et est retourné par l'algorithme M2D. L'algorithme M2D balaye l'espace de recherche du niveau 1 jusqu'au niveau k, i.e., le niveau renfermant les plus petites traverses minimales. Sachant que les Tmm appartiennent à un et un seul niveau, l'ensemble des candidats générés du niveau 1 jusqu'au niveau k − 1 est inutile puisque ces derniers ne vérifient pas la condition nécessaire de la définition 13. Cette génération inutile des candidats handicape sé- 3.4 Méthodologie et algorithmes d'extraction des multi-membres rieusement l'efficacité du processus de recherche des Tmms, spécialement dans les bases éparses où la taille des Tmms est large (i.e., localisées dans un niveau élevé de l'espace de recherche). Idéalement, il serait plus bénéfique d'accéder directement à ce niveau k. Dans l'exemple ci-dessus, les candidats de taille 1 et 2 ne renferment pas des Tmms puisque la taille de la plus petite traverse minimale est égale à 3. Ainsi, "sauter" les niveaux 1 et 2 présenterait une optimisation conséquente dans la mesure où le nouveau algorithme n'aura pas à générer et tester les candidats inutiles. Cet algorithme, appelé O-M2D, est une optimisation de l'algorithme M2D et détermine intelligemment le niveau adéquat k pour identifier les Tmm à partir des k-candidats uniquement. 3.4.2 Algorithme O-M2D Comme M2D, l'algorithme O-M2D prend en entrée un hypergraphe H et donne en sortie l'ensemble des Tmms. Le balayage s'effectue sur un seul niveau, i.e., le niveau qui renferme les Tmms. O-M2D commence par invoquer la fonction Get- MinTransversality, dont le pseudo-code est décrit par l'Algorithme 11, pour localiser le niveau où la taille des candidats générés est égale à celle des Tmms (ligne 2). Ce niveau correspond au nombre de transversalité de l'hypergraphe d'entrée. Ensuite, O-M2D génére, un à un, l'ensemble des k-candidats (ligne 3). Pour chaque k-candidat, i.e., ensemble de sommets de taille k, l'algorithme calcule son support (ligne 4). Si ce support est strictement supérieur au maximum des supports de ses sous-ensembles directs et qu'il est égal au nombre des hyperarêtes (ligne 5), alors ce candidat est marqué comme étant une traverse minimale et donc une Tmm poten- tielle. Quand toutes les traverses minimales ont été extraites, la fonction Recouvre- ment (ligne 7) se charge d'identifier l'ensemble des Tmms, comme expliqué plus haut. 3.4 Méthodologie et algorithmes d'extraction des multi-membres Algorithme 10 : O-M2D Entrées : H = (X , ξ) : Hypergraphe et IMH sa matrice d'incidence correspondante Sorties : T MM 1 début 2 3 4 5 6 7 8 Level := GetMinTransversality(IMH) ; pour chaque X ⊆ X tel que X = level faire si ∄ x ∈ X : Supp(X) = Supp(X\x) alors si Supp(X) = ξ alors T MM = T MM ∪ {X}; T MM = Recouvrement(T MM) ; retourner T MM La fonction GetMinTransversality recherche le nombre minimal de sommets pouvant constituer une traverse minimale, i.e. le nombre de transversalité de l'hy- pergraphe. Pour ce faire, la fonction parcourt les sommets, un par un (ligne 3). Pour chaque élément x de X , GetMinTransversality supprime de la matrice d'inci- dence IMH les hyperarêtes de ξ qui contiennent x (ligne 5). Les hyperarêtes restantes sont stockés dans ξ′. La fonction invoque ensuite hyp_empty, dont le pseudo-code est donné par l'Algorithme 12. hyp_empty est une fonction récursive qui stocke dans T les sommets ayant le plus grand support dans ξ′ (ligne 5) et les traitera, un par un, en supprimant à chaque fois les hyperarêtes auxquelles appartient le sommet traité (ligne 8). La condition d'arrêt de notre fonction récursive est l'absence d'hy- perarêtes dans ξ′ (ligne 2). La valeur stockée dans m correspond au nombre d'appels à la fonction hyp_empty nécessaires pour que ξ′ soit égal à l'ensemble vide. Pour chaque élément de T , la fonction vérifie si m est la valeur trouvée jusque-là, parmi les éléments traités de T . Si tel est le cas, elle est stockée dans min dont la valeur est 3.4 Méthodologie et algorithmes d'extraction des multi-membres Algorithme 11 : GetMinTransversality Entrées : Matrice d'incidence IMH associée à H = (X , ξ) Sorties : T : Une plus petite traverse minimale de H ; k : Nombre de transversalité de H 1 début 2 3 4 5 6 7 8 9 10 11 12 13 k = ξ ; T = ∅ ; pour chaque x ∈ X faire i = 1 ; Ttmp = ∅ ; Ttmp[i] = x ; ξ′ = ξ \ {e ∈ ξ x ∈ e} ; (n, Ttmp) = hyp_empty(ξ′, ξ , i, Ttmp) ; si n < k alors k = n ; T = Ttmp ; retourner (k, T ) retournée à la fin. Pour chaque sommet x traité, l'ensemble ξ′ est réactualisé à toutes les hyperarêtes de l'hypergraphe auxquelles nous supprimons celles qui contiennent x. Au final, GetMinTransversality retourne le nombre minimum d'itérations per- mettant de "vider" la matrice d'incidence. La valeur de k, retournée par la fonction, correspond ainsi au nombre de transversalité de l'hypergraphe d'entrée H. Conjecture 1 La fonction GetMinTransversality permet d'obtenir une borne maximale du nombre de transversalité, noté τ(H) dans la Definition 13, d'un hypeer- graphe. Dans le meilleur des cas, cette borne est exactement le nombre de transver- salité. 3.4 Méthodologie et algorithmes d'extraction des multi-membres Algorithme 12 : hyp_empty Entrées : ξ′ : Ensemble d'hyperarêtes ; min, i : entier ; Ttmp : tableau de sommets Sorties : min : Nombre minimum d'itérations pour obtenir un hypergraphe vide ; T ′ : Ensemble de sommets de cardinalité égale à min 1 début 2 3 4 5 6 7 8 9 10 11 12 13 14 15 si ξ′ = ∅ alors retourner (i, Ttmp) sinon T = {x ∈ X tel que {e ∈ ξ′ x ∈ e} = max { {e ∈ ξ′ xl ∈ e} , xl ∈ X }} ; T ′ = ∅ ; i = i + 1 ; pour chaque x ∈ T faire ξ′′ = ξ′ \ {e ∈ ξ′ x ∈ e} ; Ttmp[i] = x ; (m, Ttmp) = hyp_empty(ξ′′, min, i, Ttmp) ; si m < min alors min = m ; T ′ = Ttmp ; retourner (min, T ′) Exemple 9 Reconsidérons l'exemple illustratif de la Figure 3.1. En optimisant, comme nous l'avons expliqué précédemment, l'algorithme M2D, les sommets et 2-candidats ne sont pas générés et, donc, leurs supports ne sont pas calculés. O-M2D accède directement au niveau 3, générant tous les 3-candidats. Parmi ces 3-candidats, O- M2D détecte 24 ensembles de sommets essentiels mais seulement deux d'entre eux 3.5 Etude de la complexité sont des traverses minimales : {1, 2, 7} et {2, 4, 7}. En d'autres termes, seuls ces deux ensembles de sommets ont un support égal au nombre d'hyperarêtes. La fonction re- couvrement permet de déterminer, au final, la ou les Tmms. Le recouvrement du Tmm candidat {1, 4, 7} est égal à 8 sommets alors que celui du candidat {2, 4, 7} est égal à 10 sommet. Donc, O-M2D sélectionne {2, 4, 7} comme unique Tmm, en sortie. 3.5 Etude de la complexité A partir d'un hypergraphe de n sommets et m hyperarêtes, nous avons : 1. La fonction GetMinTransversality a une complexité exponentielle, au pire des cas, de O(m ∗ nm+1), avec n = X et m = ξ , pour déterminer le nombre de transversalité. 2. La cardinalité de l'ensemble des candidats de taille k générés est égale à C k n. (a) O-M2D calcule, ensuite, le support de chaque sous-ensemble direct. Le sup- port est obtenu en m opérations. (b) Le support de X est calculé en m opérations. 3. Les tests pour vérifier que X est une traverse minimale s'effectuent en O(1). Pour un hypergraphe donné H, l'algorithme O-M2D calcule donc l'ensemble des multi-membres en : O(m ∗ nm+1 × m × C k n) ≡ O(m2 ∗ nm+1 * C k n). 3.6 Etude expérimentale Au cours de notre étude expérimentale, nous mettons l'accent sur une évaluation approfondie des performances des algorithmes présentés dans la section précédente. Nous comparons à travers les nombreuses expérimentations menées, les performances de O-M2D vs respectivement M2D, MtMiner [HBC07] et ks [KS05]. De tous les 3.6 Etude expérimentale algorithmes d'extraction des traverses minimales existants dans la littérature, notre choix s'est porté sur ces deux derniers en raison des disponibilités de leurs codes sources 1. Nous avons ainsi eu la possibilité de les modifier pour qu'ils ne calculent que les plus petites traverses minimales. Par ailleurs, tous les algorithmes considérés sont implémentés en C++ (compilés avec GCC 4.1.2) et les expérimentations réalisées sur une machine munie d'un processeur Intel Core i7 ayant une fréquence d'horloge de 2GHz et 6 Go de mémoire centrale, et avec le système d'exploitation de Linux, Ubuntu 10.04. Durant ces expérimentations, nous avons considéré un jeu de données lié à une application de gestion de projet, des jeux de données "pire des cas" ainsi qu'un autre ensemble de jeux que nous avons construit à partir de deux bases de données du monde réel. Tout au long de notre étude expérimentale, nous avons vérifié que la borne maximale retournée par la fonction GetMinTransversality est bien égale au nombre de transversalité pour chaque hypergraphe traité. Jeu de données de gestion de projets En gestion de projet, nous pouvons connaître les compétences requises pour mener à bien un projet donné, ainsi que celles des acteurs. L'objectif est alors d'identifier le plus petit ensemble d'individus capables de réaliser le projet. De plus, on peut sou- haiter que chaque acteur puisse avoir le plus de compétences possibles. Ceci revient alors à chercher les tmms. Dans ce cas, une communauté serait composé d'un ensemble d'acteurs offrant une même compétence. Les communautés ne sont pas disjointes puisqu'un acteur peut avoir plusieurs compétences. Le jeu de données correspondant à ce problème est re- présenté par un hypergraphe constitué de 168 sommets, dont chacun correspond à un acteur, et 50 hyperarêtes, dont chacune correspond à une communauté, c'est à dire 1. Nous remercions les auteurs d'avoir mis à notre disposition leurs codes sources. 3.6 Etude expérimentale à une compétence nécessaire pour le projet. Les caractéristiques de cet hypergraphe, Comm. X PM 5 168 ξ 50 MH #Tmm τ(H) 320 16 9 Table 3.2 -- Caractéristiques du jeu de données de gestion de projets appelé PM, sont résumés par le tableau 3.2 où Comm. correspond à la taille de la plus petite hyperarête, X au nombre de sommets, ξ au nombre d'hyperarêtes, MH au nombre de traverses minimales, #Tmm au nombre de multi-membres cal- culés et τ(H) au nombre de transversalité. L'objectif est donc de rechercher les plus petits ensembles d'acteurs ayant les compétences requises pour mener à bien le pro- jet. Performances et interpretations sur le jeu de données de gestion de projet : Comme le montre le tableau 3.3, MtMiner est incapable de traiter ce jeu de données alors que les algorithmes ks, M2D et O-M2D nécessitent, respec- tivement, 307, 15, 1688,22 et 158,93 secondes pour extraire les traverses minimales multi-membres. Nos algorithmes ont extrait 320 traverses minimales d'une taille égale à 9 qui correspond à la valeur du nombre de transversalité, noté τ(H) dans la définition 13. Ceci signifie que nous devons réunir au moins neuf acteurs pour la réalisation du projet et ces 320 traverses minimales correspondent aux sous-ensembles d'acteurs ayant les compétences nécessaires pour le projet. Parmi ces 320 traverses minimales, seulement 16 sont considérées comme des traverses minimales multi-membres. Ces dernières maximisent la condition de recouvrement. La particularité de ces traverses minimales multi-membres est qu'elles contiennent un ou plusieurs acteurs présentant diverses compétences. Ainsi, nos algorithmes parviennent à trouver des équipes, de taille minimale ayant le maximum de compétence, qui sont le plus aptes à conduire le projet. 3.6 Etude expérimentale ks Mtminer M2D O-M2D PM 307,15 - 1688,22 158,93 Table 3.3 -- Jeu de données de gestion de projets : temps d'exécution (en secondes) Bases de communautés sociales Dans cette seconde expérimentation, nous considérons des folksonomies, à partir desquelles nous avons extrait des communautés. Une folksonomie est un néologisme, né de la jonction des mots folk (i.e., les gens) et taxonomie, désignant un système de classification collaborative par les internautes [Mik07]. L'idée est de permettre à des utilisateurs de partager et de décrire des objets via des tags librement choisis. Formellement, une folksonomie est composée de trois ensembles U, T , R et d'une relation ternaire Y entre eux, où T est un ensemble de tags (ou étiquettes) et R est un ensemble de ressources partagées par les utilisateurs, qui peuvent être des sites web à marquer 2, des vidéos personnelles à partager 3 ou des films à décrire 4 selon le type de la folksonomie considérée. Quant à l'ensemble U, il consiste en l'ensemble d'utilisateurs d'une folksonomie qui sont décrits par leurs identifiants (pseudonymes). Nous avons appliqué l'algorithme Tricons [CJB12] pour l'extraction des tri- concepts associés à de telles folksonomies. Ces derniers sont des ensembles maximaux de la forme (Utilisateurs, Ressources, Tags) : l'ensemble maximum d'utilisateurs, qui ont partagé un ensemble maximal de ressources qu'ils ont annoté avec un ensemble maximal de tags. Pour extraire les communautés, nous projetons les tri-concepts sur la dimension "Utilisateurs". Ceci est réalisé en faisant varier le seuil du support minimal des uti- lisateurs, i.e., minsuppu, qui est le nombre minimal d'utilisateurs qu'un tri-concept 2. http ://del.icio.us 3. http ://youtube.com 4. http ://movielens.org 3.6 Etude expérimentale peut contenir. Dans ce qui suit, nous décrivons les folksonomies considérées au cours de nos expérimentations. 1. del.icio.us 1 : le système del.icio.us est un service de marque-page social qui offre à ses utilisateurs la possibilité de partager leurs pages web préférées. La base de données considérée dans ce rapport contient tous les marque-pages ajoutés sur le site http ://delicious.com en Janvier 2007. Le processus de ré- cupération regroupe quelque 494, 636 marque-pages qui ont été publiés par 54, 915 utilisateurs par le biais de 64, 968 tags sur 129, 220 ressources. Dans cette étude expérimentale, nous considérons qu'une communauté, dans une base del.icio.us, est constituée des utilisateurs ayant partagé, au moins, deux mêmes pages web. Avant l'application de nos algorithmes, un pré-traitement sur ces données a permis de dégager les communautés qui serviront d'hyperarêtes dans l'hypergraphe d'entrée. 2. MovieLens 2 : il s'agit d'un système de recommandation filmographique Mo- vieLens, dont le site web a été conçu par un groupe de recherche, GroupLens, à l'université de Minnesota, aux États-Unis. Disponible au public, ce jeu de données contient des évaluations explicites au sujet de films. Le site met à dis- position deux jeux de données d'évaluations de films, de tailles différentes. Le premier jeu comprend 1, 000, 000 évaluations, de 1 à 5 étoiles, faites par envi- ron 6, 000 utilisateurs, et le second comprend 100, 000 évaluations fournies par 943 utilisateurs sur 1, 682 films, entre Septembre 1997 et Avril 1998. C'est ce second jeu de données que nous avons utilisé pour nos tests, en considérant qu'une communauté est formée des utilisateurs qui ont fourni leur avis sur au moins deux mêmes films. En variant minsuppu, nous obtenons quatre jeux de données à partir de la base 1. www.delicious.com 2. www.movielens.umn.edu 3.6 Etude expérimentale de données del.icio.us des folksonomies (notés Del1, Del2, Del3 et Del4 ) et trois jeux de données à partir de la base de données Movielens des folksonomies (no- tés Mov1, Mov2 et Mov3 ). Dans l'hypergraphe associé à chaque jeu de données, les sommets représentent les utilisateurs et les hyperarêtes correspondent aux commu- nautés où une communauté représente un ensemble d'utilisateurs ayant partagé le même ensemble de ressources avec le même ensemble de tags. Pour chaque jeu de données, l'objectif est de trouver le plus petit ensemble d'utilisateurs permettant de représenter toutes les communautés. Les caractéristiques des différents jeux de données sont résumés dans le Tableau 3.4. Ainsi, la première colonne Comm. indique le nombre minimum de sommets dans une communauté (i.e. minsuppu). La seconde colonne contient le nombre de sommets (X ) de l'hypergraphe et la troisième le nombre d'hyperarêtes (ξ). La quatrième colonne indique le nombre de traverses minimales (MH) que renferme l'hypergraphe. L'avant-dernière colonne montre le nombre de Tmms. La dernière colonne correspond à la taille des Tmms, en termes de nombre de sommets (τ(H)). Nous pouvons noter que plus la valeur de Comm. est basse, plus le nombre de Tmms (#Tmm) et leurs tailles (τ(H)) sont élevées, atteignant 21 pour Del4 et 20 pour Mov3. Performances : comme le montre le tableau 3.5, les différents tests confirment que l'algorithme O-M2D surpasse largement les algorithmes M2D, MtMiner et ks, pour l'ensemble des jeux de données. Par ailleurs, si M2D présente des temps d'exécution élevés, il est assez robuste pour venir à bout de tous les jeux de données, alors que la consommation mémoire élevée de MtMiner l'empêche de s'exécuter sur les jeux Del3, Del4 et Mov3. En déterminant le nombre d'éléments dans une Tmm, M2D est capable d'élaguer de nombreux candidats qui sont générés et traités par MtMiner. Dans les deux types de jeux de données, les résultats confirment, par ailleurs, que l'écart, en termes de temps d'exécution, des différents algorithmes est 3.6 Etude expérimentale Comm. X 6 5 3 2 5 3 2 51 119 165 248 88 143 196 ξ 38 91 157 179 80 246 501 MH #Tmm τ(H) 13 52 1800 8976 108 172 306 4 10 78 201 1 3 26 5 6 13 21 6 12 20 Del1 Del2 Del3 Del4 Mov1 Mov2 Mov3 Table 3.4 -- Caractéristiques des bases sociales [(Haut) del.icio.us (Bas) Mo- vieLens] en faveur de O-M2D. Cet écart est plus conséquent quand les nombres de sommets et d'hyperarêtes sont grands. En effet, la dernière colonne du tableau 3.4 montre que la taille des Tmms est très large, atteignant respectivement, 13 pour Del3, 21 pour Del4, et 20 pour Mov3. L'avantage principal de O-M2D se résume dans sa faculté à cibler directement ce niveau (appelé level dans l'Algorithm 2 et τ(H) dans la Définition 13). Par exemple, pour Del3 et Del4, MtMiner ne peut pas extraire les traverses minimales quand l'hypergraphe renferme plus de 157 hyperarêtes. Par ailleurs, sa- chant que le nombre de traverses minimales croît exponentiellement, l'avantage que présente l'algorithme O-M2D est sa capacité à fournir un résultat sans stocker les candidats en mémoire. Dans le but d'analyser, en profondeur, les Tmms calculées par nos algorithmes, considérons le jeu de données Del2 du Tableau 3.4 et les caractéristiques des sommets qui appartiennent à l'ensemble des Tmms. O-M2D donne en sortie 10 Tmms de taille 6, i.e, composé de 6 sommets. Cela 3.6 Etude expérimentale ks Mtminer M2D O-M2D Del1 88,26 77,45 276,65 61,28 Del2 263,90 200,66 964,32 112,50 Del3 401,38 Del4 793,08 - - 1920,12 174,78 2880,84 364,92 Mov1 72,00 53,28 335,71 59,52 Mov2 262,09 185,56 1492,34 131,84 Mov3 881,73 - 2655,63 351,27 Table 3.5 -- Bases sociales [(Haut) del.icio.us (Bas) MovieLens] : Temps d'exé- cution (en secondes) Figure 3.2 -- Nombre de ressources partagées par les 25 utlisateurs les plus actifs signifie que nous devons trouver au moins 6 utilisateurs pour représenter l'ensemble des communautés. Un examen de près de ces Tmms montre que 4 sommets (10, 47, 77, 78) appartiennent à tous les Tmms extraites à partir de ce jeu de données. Nous les appelons "actifs" car ils ont la plus importante activité de marquage (tagging) 3.6 Etude expérimentale dans le jeu de données Del2 de del.icio.us, comme le montre la Figure 3.2 et la Figure 3.3. Les deux autres sommets (que nous appelons "stratégiques") n'ont pas, au contraire, une activité de marquage exceptionnelle. Leur appartenance aux Tmms s'explique par le fait qu'ils représentent des communautés qui ne renferment aucun sommet actif. Figure 3.3 -- Nombres de tags des 25 utilisateurs les plus actifs Consommation mémoire : les statistiques fournies par le Tableau 3.6 mettent en évidence la consommation en ram très faible des algorithmes O-M2D et ks. Lorsque MtMiner et M2D doivent générer et sauvegarder en mémoire tous les candidats de tous les niveaux balayés, O-M2D cible directement le niveau adéquat et teste la condition d'essentialité des candidats générés. Un examen attentif du nombre de transversalité des hypergraphes Del4 et Mov3, dans le Tableau 3.4, in- dique la quantité de candidats que MtMiner et M2D ont à traiter. En effet, ces derniers algorithmes doivent atteindre le 21me niveau pour le jeu de données Del4 et le 20me niveau pour Mov3. Ceci explique pourquoi MtMiner est dans l'incapacité d'atteindre le 20me niveau. 3.6 Etude expérimentale ks Mtminer M2D O-M2D 4.335 4.334.102 1.807.980 9.223 6.290 5.568.931 2.606.722 11.810 - - 3.723.119 16.369 4.458.656 18.454 Del1 Del2 Del3 9.603 Del4 13.844 Mov1 3.991 3.518.223 1.366.841 8.604 Mov2 6.387 4.976.213 2.461.857 10.611 Mov3 9.640 - 3.004.886 13.602 Table 3.6 -- Bases sociales[(Haut) del.icio.us (Bas) MovieLens] : Consomma- tion mémoire (en KO) Bases "pires des cas" Les bases "pire des cas" sont introduites pour étudier plus en profondeur les per- formances des algorithmes considérés au cours de cette étude expérimentale. Elles correspondent à une matrice d'incidence définie comme suit : Définition 14 Un contexte "pire des cas" IMH = (ξ, X , R), où ξ et X sont, res- pectivement, les ensembles finis d'hyperarêtes et de sommets de l'hypergraphe H, est une matrice dans laquelle toutes les hyperarêtes sont formées du même nombre d'élé- ments, égal à n, et où chaque sommet a un support égal à 1 (Supp(x) = 1, ∀x ∈ X ). Par exemple, un contexte "pire des cas" pour ξ = 3, X = 9 et n = 3, est donné par le Tableau 3.7. Les bases "pire des cas" nous permettent d'évaluer le comportement des algorithmes dans des cas extrêmes. Le test consiste à varier les valeurs de n et ξ, jusqu'à ce que les algorithmes ne puissent plus s'exécuter correctement. Performances : le Tableau 3.8 montre pour chaque valeur de n, le nombre maxi- mal d'hyperarêtes qui peuvent être traitées par les algorithmes considérés et les 3.7 Conclusion x1 x2 x3 x4 x5 x6 x7 x8 x9 e1 × × × e2 e3 × × × × × × Table 3.7 -- Base pire des cas pour ξ = 3 temps de traitement associés. Grâce à sa capacité à déterminer le nombre d'éléments d'une Tmm, l'algorithme O-M2D présente un avantage indéniable par rapport à MtMiner et M2D. Selon les données du Tableau 3.8, pour une valeur donnée de n, O-M2D présente des temps d'exécution nettement meilleurs que les trois autres algorithmes et est capable de traiter des bases "pire des cas" pour des valeurs éle- vées de ξ. A titre d'exemple, pour n = 4, MtMiner s'arrête brusquement pour un nombre d'hyperarêtes égal à 12 alors que l'algorithme M2D résiste mieux et s'arrête à une valeur égale à 20. Dans le même temps, O-M2D et ks s'arrête pour une valeur de ξ égal à 74. Consommation mémoire : pour ces bases "pire des cas", nous avons étudié aussi la consommation mémoire. Ainsi, le Tableau 3.9 montre, respectivement, la mémoire consommée par les cinq algorithmes. O-M2D et ks se montrent alors très performant par rapport aux algorithmes MtMiner et M2D. En effet, par rapport à la consommation mémoire des trois autres algorithmes, celle de O-M2D, tout comme celle de ks, est négligeable. O-M2D ne stocke en mémoire que l'hypergraphe d'entrée et les candidats, de taille égale au nombre de transversalité, générés sont traités sans être sauvegardés. 3.7 Conclusion Au cours de ce chapitre, nous avons introduit une nouvelle approche pour la dé- tection d'une classe particulière des traverses minimales, que nous avons appelées 3.7 Conclusion traverses minimales multi-membres, à partir d'un système communautaire repré- senté par un hypergraphe. L'une de nos contributions se trouve dans la définition des Tmms en se basant sur la notion d'ensemble de sommets essentiels. Ceci nous a permis de mettre en place un algorithme optimisé, qui cible directement le niveau qui renferme les Tmms. Des expérimentations effectuées sur différents jeux de données ont montré que l'algorithme O-M2D présente des performances très intéressantes par rapport à celles obtenues avec des algorithmes classiques. Cette contribution a été publiée dans une revue internationale [JLB14a] et deux conférences avec comité de lecture [JLB12b, JLB12a]. Dans le chapitre suivant, nous allons étendre notre ap- proche pour extraire l'ensemble de toutes les traverses minimales, en proposant une représentation concise et exacte de cet ensemble grâce à la notion d'irrédondance. Ceci a été motivé par le nombre de traverses minimales, qui peut être exponentiel même pour des hypergraphes simples. 3.7 Conclusion n ξ ks Mtminer M2D O-M2D 4 4 4 4 5 5 5 5 6 6 6 6 7 7 7 7 8 8 8 8 9 9 9 9 10 10 10 10 11 12 19 73 10 11 19 60 9 10 16 53 9 10 16 44 8 9 14 29 7 8 13 22 7 8 11 13 174,06 215,73 498,68 5527,90 194,42 229,14 650,97 5139,02 211,30 228,74 616,51 5349,28 248,59 262,93 668,31 5172,55 257,30 284,36 700,94 5311,80 248,27 270,686 753,04 4868,93 264,91 289,53 841,71 4390,22 180,23 257,97 87,54 - - - 295,43 111,21 1457,78 380,89 - 3234,30 214,31 308,10 352,10 90,12 96,12 - - - 1866,42 398,78 - 3094,17 245,12 344,64 97,38 - - - 400,58 101,09 2119,47 472,39 - 3181,40 299,46 400,49 100,72 - - - 468,18 119,72 2288,46 495,08 - 2802,89 326,02 466,21 103,69 - - - 517,36 138,28 2557,73 531,44 - 2949,06 387,66 511,92 104,09 - - - 534,84 168,03 2780,79 567,56 - 2354,98 428,88 683,36 110,34 - - - 711,49 133,28 3283,36 624,66 - 1899,29 Table 3.8 -- Bases pire des cas : Temps d'exécution (en secondes) 3.7 Conclusion n ξ ks MtMiner M2D O-M2D 2.682.886 1.398.441 6.108 6.221 6.908 5.294 5.565 6.403 5.482 5.607 6.962 5.165 5.537 6.308 4.821 4.996 5.570 1.844.364 4.995.732 1.719.498 5.338.173 1.999.695 5.514.683 2.473.281 5.800.962 2.826.625 5.741.793 - - - - - - - - - - - - - - - 4 4 4 4 5 5 5 5 6 6 6 6 7 7 7 7 8 8 8 8 9 9 9 9 10 10 10 10 11 12 19 73 10 11 19 60 9 10 16 53 9 10 16 44 8 9 14 29 7 8 13 22 7 8 11 13 4.285 4.300 4.617 20.093 3.866 4.077 4.902 18.620 3.996 4.098 4.781 15.092 4.094 4.168 4.830 10.982 3.841 4.117 4.497 8.896 3.602 3.997 4.406 7.911 3.802 4.106 4.212 4.537 - 32.805 2.811.429 1.470.266 - 26.164 3.066.422 1.712.089 - 22.197 3.185.089 2.085.366 - 17.389 3.541.797 2.226.625 - 11.411 3.922.008 2.677.026 - - - 3.168.442 5.694.223 - 4.433.787 3.019.860 - - - 3.840.117 5.899.004 - 4.757 4.886 5.101 9.734 4.955 5.093 5.202 5.817 Table 3.9 -- Bases pire des cas : Consommation mémoire (en KO) Chapitre 4 "Diviser pour régner" pour l'extraction des traverses minimales d'un hypergraphe 4.1 Introduction Optimiser le calcul des traverses minimales en optant pour la décomposition de l'hypergraphe d'entrée peut présenter une solution intéressante à condition de bien choisir le nombre optimal d'hypergraphes partiels de manière à éliminer des tests de minimalité des traverses calculées. En se basant sur le nombre de transversalité, nous proposons une approche basée sur la stratégie "diviser pour régner" pour l'extrac- tion des traverses minimales. Un hypergraphe peut, en effet, être décomposé en un certain nombre d'hypergraphes partiels, égal à la taille de la plus petite traverse mini- male que renferme l'hypergraphe d'entrée. Les traverses minimales extraites à partir des hypergraphes partiels, que nous appellerons "locales", permettent de retrouver l'ensemble de toutes les traverses minimales de l'hypergraphe initial. Les traverses obtenues et dont la cardinalité est égale au nombre de transversalité seront consi- 68 4.2 Objectifs de la décomposition dérées directement comme des traverses minimales et ce, sans vérifier par des tests, leurs minimalités. C'est ce que nous détaillons à travers ce chapitre via l'algorithme local-generator et à travers l'étude expérimentale dont il a fait l'objet. 4.2 Objectifs de la décomposition La principale difficulté que pose l'extraction des traverses minimales réside dans le nombre exponentiel de ces dernières, même quand l'hypergraphe d'entrée est simple, comme le montre l'exemple 4 du chapitre ?? (page 13). 4.2.1 Diviser pour régner Les algorithmes d'extraction des traverses minimales les plus performants [BMR03, KS05, MU13] sont des améliorations de l'algorithme de Berge [Ber89]. Ce dernier traite les hyperarêtes une à une en calculant à chaque itération i les traverses mini- males de l'hypergraphe constitué par les i-èmes hyperarêtes considérées. Avec pour objectif d'optimiser le calcul des traverses minimales, notre approche repose sur cette idée en usant du paradigme "diviser pour régner", présenté dans la Définition 15. Définition 15 Diviser pour régner Le paradigme diviser pour régner se com- pose de trois étapes. La première est de diviser le problème en un certain nombre de sous-problèmes. La deuxième est de régner sur ces sous-problèmes en les résolvant de manière récursive ou directement. Enfin, combiner les solutions des sous-problèmes en une solution finale du problème initial. Le principe consiste à réduire ce nombre d'itérations en décomposant l'hypergraphe en un nombre précis d'hypergraphes partiels, équivalent au nombre de transversa- lité de l'hypergraphe d'entrée H. A partir de chaque hypergraphe partiel Hi, nous calculons alors ce que nous appelons les traverses minimales locales à Hi. Le pro- duit cartésien de ces traverses minimales locales correspondra alors à un ensemble 4.2 Objectifs de la décomposition de traverses de H qui seront soumises à une vérification de la minimalité pour être considérées comme des traverses minimales. En outre, pour un hypergraphe H avec un nombre de transversalité égal à k, le fait de décomposer H en k hypergraphes Hi permet d'éliminer le test de la minimalité pour les ensembles de sommets de taille k qui seront considérés comme traverses minimales de H, sans aucun autre calcul supplémentaire. Il est clair que cette approche ne saurait être efficace sur des hypergraphes, dont le nombre de tranversalité est très bas dans la mesure où le nombre d'hypergraphes partiels n'est pas conséquent et ne permet pas une optimisation intéressante du calcul des traverses minimales. Un profil du type d'hypergraphes sur lequel notre approche peut se montrer efficace est dressé au terme de l'étude expérimentale que nous détaillons à la fin de ce chapitre. 4.2.2 Originalité de l'approche Nous avons détaillé dans le chapitre 2 les différents algorithmes dédiés à l'extrac- tion des traverses minimales. Nous avons souligné que les algorithmes les plus per- formants étaient des améliorations de l'algorithme de Berge mais ils ne reposent pas sur le paradigme "diviser pour régner". En ce sens, notre approche est une extension complètement différente de l'algorithme de Berge. Alors que dans ce dernier, ainsi que dans les améliorations qui en ont été proposées, l'idée est de traiter les hyperarêtes une à une, nous nous proposons de traiter les hyperarêtes ensemble par ensemble. L'hypergraphe d'entrée H se trouve alors décomposé en un nombre d'hypergraphes partiels égal au nombre de transversalité k de H. Chaque hypergraphe partiel renferme des traverses minimales locales et le produit cartésien, combiné à un test de la minimalité, permet de retrouver l'ensemble des traverses minimales de H. Le test de la minimalité est nécessaire dans la mesure où les traverses minimales locales sont effectivement minimales mais au sein de l'hyper- 4.3 Définitions et notations graphe partiel à partir duquel elles sont extraites mais rien n'assure qu'elles seront minimales dans l'hypergraphe initial. Comme nous l'avons déjà souligné, seules les traverses de taille égale au nombre de transversalité sont effectivement minimales puisqu'il ne peut exister une traverse incluse dedans. Un seul algorithme, parmi tout ceux présentés dans le chapitre 2 met à profit cette notion de décomposition mais d'une façon différente. Il s'agit de celui de Bailey et al., qui consiste à décomposer les hyperarêtes formées par un nombre important de sommets de manière à n'avoir que des hyperarêtes de relativement petite taille. Dans notre algorithme, l'hypergraphe est décomposé indépendamment de la taille de ses hyperarêtes. Le nombre de transversalité d'un hypergraphe est la notion-clé, autour de laquelle est bâtie notre approche. Le choix du nombre d'hypergraphes partiels n'est pas ar- bitraire puisqu'il garantit que les traverses, dont la taille est égale à k, peuvent être directement considérées comme des traverses minimales de H. C'est sur cette éli- mination de certains de ces tests inutiles de la minimalité que nous comptons pour optimiser les temps d'extraction des traverses minimales. 4.3 Définitions et notations Dans cette section, nous proposons de présenter des définitions clés et notations que nous utiliserons tout au long des sections suivantes. Pour aboutir à notre approche d'extraction des traverses minimales, basée sur la notion de traverse minimale locale, nous avons encore combiné des concepts de la théorie des hypergraphes (union et produit cartésien d'hypergraphes) avec d'autres de la fouille de données (ensemble essentiel, support), présentés dans les chapitres précédents. Définition 16 Union et produit cartésien [Ber89] Soit H = (X , ξ) et G = (X ′, ξ′) deux hypergraphes tels que ξ = {ξ1, ξ2, . . . , ξm} et 4.3 Définitions et notations ξ′ = {ξ′1, ξ′2, . . . , ξ′m′}. H ∪ G représente l'union de H et G. Le résultat de cette union est un hypergraphe dont l'ensemble des sommets est constitué de ceux de H et de G, et l'ensemble des hyperarêtes contient celles de H et G, qui par souci de simplification sera aussi noté H ∪ G : H ∪ G = (X ∪ X ′, ξ ∪ ξ′) H × G représente le produit cartésien des deux hypergraphes dont le résultat est un hypergraphe dont l'ensemble des sommets contient ceux des deux hypergraphes. Quant à l'ensemble des hyperarêtes, il est aussi noté H × G et est égal au produit cartésien de ξ et de ξ′ autrement dit à l'union de tous les couples possibles d'hyperarêtes tels que le premier élément appartient à ξ et le deuxième à ξ′ : H × G = (X ∪ X ′, {(ξi ∪ ξ′j), i = 1, . . . , m, j = 1, . . . , m′) Proposition 2 [Ber89] Soient H et G, deux hypergraphes simples. Les traverses minimales de l'hypergraphe H ∪ G sont des couples, minimaux au sens de l'inclusion, générés par le produit cartésien des ensembles de traverses minimales de H et de G : MH∪G = Min{ MH × MG}. Définition 17 Hypergraphe partiel [Ber89] Un hypergraphe partiel H′ est la restriction d'un hypergraphe H à un sous-ensemble d'hyperarêtes ξ′ incluses dans ξ et aux sommets contenus dans ces hyperarêtes. Dans le cadre de notre approche, nous proposons d'étendre la proposition 2 en considérant plus de deux hypergraphes. Plus précisément, à partir d'un hypergraphe H=(X , ξ), dont le nombre de transversalité τ(H) est égal à k, et d'une traverse minimale T = {x1, x2, . . . , xk} de MH de taille k dont les sommets sont triés par ordre de support décroissant de sorte que x1 est le sommet qui appartient au plus grand nombre d'hyperarêtes, nous proposons de construire k hypergraphes partiels 4.3 Définitions et notations Hi= (Xi, ξi), i = 1, . . . , k tels que : -- ξ1 = {e ∈ ξ x1 ∈ e} -- X1 = {x ∈ X x ∈ e, ∀e ∈ ξ1 } -- .. -- .. -- ξi = {e ∈ ξ − i−1 Sj=1 ξj xi ∈ e} -- Xi = {x ∈ X x ∈ e, ∀e ∈ ξi } On peut remarquer que les hypergraphes partiels Hi vérifient de façon évidente les propriétés suivantes : -- ξi ⊆ ξ -- ξi = ξ. k Si=1 -- ∄e ∈ ξ tel que e ∈ ξi ∩ ξj, i 6= j. Les traverses minimales de l'hypergraphe partiel Hi sont appelées traverses mini- males locales à Hi et leur ensemble est noté par MHi. e1 = {1, 2} e2 = {2, 3, 7} e3 = {3, 4, 5} e4 = {4, 6} e5 = {6, 7, 8} e6 = {7, 9} 1 2 3 4 5 6 7 8 9 1 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 1 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 1 Figure 4.1 -- Un exemple d'hypergraphe H = (X , ξ) et la matrice d'incidence IMH correspondante Exemple 10 La figure 4.1 illustre un hypergraphe simple H = (X , ξ) tel que X = {1, 2, 3, 4, 5, 6, 7, 8, 9} et ξ = { e1, e2, e3, e4, e5, e6 } avec e1 = {1, 2}, e2 = {2, 4.4 Traverses minimales locales : approche et algorithme Figure 4.2 -- Les 3 hypergraphes partiels dérivés de H : H1, H2 et H3 3, 7}, e3 = {3, 4, 5}, e4 {4, 6}, e5 = {6, 7, 8} et e6 = {7, 9}. H a un nombre de transversalité égal à 3. H possède 2 traverses minimales de cardinalité minimale égale à 3 : {1, 4, 7} et {2, 4, 7}. Prenons, par exemple, la traverse minimale {1, 4, 7}. Après avoir ordonné les trois sommets le composant, selon un ordre décroissant de support, nous obtenons les trois hypergraphes partiels, présentés par la Figure 4.2, tel que H1 ne contient que les hyperarêtes auxquelles appartient le sommet 7 (dont le support est égal à 3), H2 ne contient que celles auxquelles appartient 4 (dont le support est égal à 2) et H3 contient les hyperarêtes restantes, i.e., celles qui renferment le sommet 1. Il importe de noter qu'en choisissant {2, 4, 7}, au lieu de {1, 4, 7}, le résultat reste le même. 4.4 Traverses minimales locales : approche et algo- rithme Optimiser le calcul de ces traverses minimales revient donc principalement à réduire le nombre de candidats traités. Ceci passe par la réduction de la taille de l'hyper- graphe d'entrée. L'approche que nous proposons consiste à construire, à partir de l'hypergraphe d'entrée H, k hypergraphes partiels (H1, H2, . . . , Hk). Le calcul de l'ensemble des traverses minimales locales, MHi de chaque hypergraphe partiel Hi s'en trouve amélioré puisque la taille de Hi est relativement petite par rapport à celle 4.4 Traverses minimales locales : approche et algorithme de H. Ainsi, nous proposons d'effectuer l'union des hypergraphes partiels de façon à déterminer l'ensemble des traverses minimales MH de H à partir des k-uplets, minimaux au sens de l'inclusion, issus du produits cartésien des ensembles de tra- verses minimales locales déterminées pour les hypergraphes partiels MHi. Dans ce qui suit, nous présentons l'algorithme local-generator dédié au calcul des tra- verses minimales et basé essentiellement sur les notions de nombre de transversalité et d'hypergraphe partiel. L'algorithme local-generator, dont le pseudo-code, est décrit par l'Algorithme 13 prend en entrée une matrice d'incidence (correspondant à l'hypergraphe d'entrée) et fournit en sortie l'ensemble des traverses minimales. On suppose que les sommets de l'hypergraphe sont triés par ordre lexicographique. local-generator démarre par un appel à la fonction GetMinTransversality, dont le pseudo-code est décrit par l'Algorithme 11 du chapitre 3 (page 52). Comme déjà mentionné, cette fonction calcule et retourne une traverse minimale dont la taille est minimale et le nombre de transversalité k de l'hypergraphe. Ce dernier correspond désormais à la cardinalité de la traverse minimale retournée par la fonction. C'est à partir de cette traverse minimale retournée par GetMinTransversality que notre algorithme décompose l'hypergraphe d'entrée en des hypergraphes partiels. Une fois la construction des k hypergraphes partiels (lignes 7-8) effectuée, l'al- gorithme local-generator fait appel à un algorithme d'extraction des traverses minimales pour calculer leurs traverses minimales locales 7, stockées dans MHi (ligne 9). Etant donné que les hypergraphes Hi sont relativement de petite taille, n'importe quel algorithme existant peut calculer les traverses minimales MHi en des temps très courts. Cet algorithme prend donc en entrée un hypergraphe partiel Hi de H, dont l'ensemble des sommets Xi et l'ensemble des hyperarêtes ξi ont été déjà calculés (lignes 7 - 8) et extrait, par niveaux, l'ensemble des traverses minimales locales à Hi 7. Dans les expérimentations, nous avons utilisé l'algorithme MtMiner pour accomplir cette tâche et nous remercions les auteurs de nous en avoir fourni une version. 4.4 Traverses minimales locales : approche et algorithme Algorithme 13 : local-generator Entrées : Une matrice d'incidence IMH associée à H = (X , ξ) Sorties : MH, ensemble des traverses minimales de H 1 début 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 T = GetMinTransversality2(IMH) ; Ordonner les éléments de T par ordre décroissant du support ; k = T ; i = 1 ; tant que i ≤ k faire ξi = {e ∈ ξ T [i] ∈ e} ; Xi = X ∩ ξi ; MHi = mtminer(Hi) ; i = i + 1 ; γH = MH1 × MH2 × . . . × MHk ; pour chaque X ∈ γH faire si X = k alors MH = MH ∪ {X} ; sinon si 6 ∃ x ∈ X : Supp(X) = Supp(X\x) alors MH = MH ∪ {X} ; retourner (MH) selon la définition 1. A la fin de la boucle de la ligne 6, local-generator a déjà préparé les ensembles des traverses minimales locales. Le produit cartésien (ligne 11) de ces ensembles MHi, permet de construire l'ensemble γH. Chaque élément de γH issu de ce produit cartésien représente une traverse. Il reste à vérifier sa minima- lité. Un des intérêts de notre décomposition de l'hypergraphe initial est d'éviter de 4.5 Etude de la complétude tester la minimalité des éléments de γH dont la cardinalité est égale à k. En effet, ces derniers représentent des traverses minimales de H puisqu'il ne peut pas exister une traverse minimale de taille inférieure au nombre de transversalité de H. Pour les traverses de taille supérieure à k, local-generator teste la minimalité (lignes 15 − 16) suivant la Proposition 1. Si le support d'un candidat X est strictement supérieur au maximum des supports de ses sous-ensembles directs alors X est une traverse minimale et est ajouté à MH. 4.5 Etude de la complétude Le résultat du produit cartésien de deux ensembles de traverses minimales, MH et MG, représente un ensemble de traverses. La minimalité est ensuite vérifiée par le biais de la condition d'essentialité de la Définition 12. Dans le but de vérifier la complétude de notre approche, nous nous proposons de prouver par récurrence que MH = Min {MH1 × MH2 × . . . × MHk}, en s'inspirant de la Proposition 2. Proposition 3 Toute traverse minimale de l'hypergraphe H peut être déduite à par- tir des ensembles de traverses minimaux des Hi, i = 1 . . . k. Preuve 2 Soient H1 = (X1, ξ1) et H2 = (X2, ξ2) deux hypergraphes et H = H1 ∪ H2, avec H = (X , ξ) tel que X = X1 ∪X2 et ξ = ξ1 ∪ξ2. D'après Berge [Ber89], l'ensemble des traverses minimales de H est égal aux éléments, minimaux au sens de l'inclusion, appartenant au produit cartésien des ensembles minimaux de H1 et H2 : MH = MH1∪H2 = Min { T T ∈ MH1 × MH2 } (P1) Supposons que cette propriété est vraie pour l'union de k hypergraphes : H′ = H1 ∪ H2 ∪ . . . ∪ Hk avec H′ = (X ′, ξ′) et Hi = (Xi, ξi), i = 1 . . . k. Par hypothèse, nous avons alors : 4.5 Etude de la complétude MH ′ = Min { T T ∈ MH1 × MH2 × . . . × MHk }. (P2) Montrons, à présent, que la propriété est vraie pour l'union de k + 1 hypergraphes tel que H = H1 ∪ H2 ∪ . . . ∪ Hk+1 où X = X1 ∪ X2 ∪ . . . ∪ Xk+1 et ξ = ξ1 ∪ ξ2 ∪ . . . ∪ ξk+1. On a : H = H1 ∪ H2 ∪ . . . ∪ Hk+1 ⇔ H = H′ ∪ Hk+1 où H′ = ∪k i=1Hi et H′ = (X ′, ξ′) avec X ′ = ∪k i=1Xi et ξ′ = ∪k i=1ξi. D'après (P1), on a MH = Min { T T ∈ MH ′ × MHk+1 } et d'après (P2), nous avons MH ′ = Min { T T ∈ MH1 × MH2 × . . . × MHk }. Nous obtenons, au final donc : MH = Min { T T ∈ MH1 × MH2 × . . . × MHk+1 }. Ceci prouve donc que toute traverse minimale de H, i.e., de l'ensemble MH, peut être calculée à partir des traverses minimales locales des k hypergraphes partiels Hi, 1 ≤ i ≤ k. Proposition 4 Toute traverse minimale T déduite à partir des MHi, tel que T = min {T1 ∪ T2 ∪ T3 . . . ∪ Tk} et Ti ∈ MHi, est une traverse minimale de H. Preuve 3 Ti ∈ MHi ⇒ Ti ∩ eji 6= ∅ ∀eji ∈ ξi, 1 ≤ i ≤ k. Étant donné que ξi = ξ et ∀(ξi, ξj) ∈ ξ × ξ\{ξi}, ξi ∩ ξj = ∅, donc ∀e ∈ ξ, ∃ k Si=1 Ti ⊂ T tel que Ti ∩ e 6= ∅. Ainsi, T est une traverse de H. (1). Par vérification de la condition de minimalité de la Définition 12 (ligne 16 de l'al- gorithme 13), T = min {T1 ∪ . . . ∪ Tk} donc T est minimal dans H (2). (1) et (2) permettent de considérer T comme une traverse minimale de H. 4.6 Etude Expérimentale 4.6 Etude Expérimentale Différentes expérimentations ont été réalisées sur des jeux de données variés afin d'évaluer l'algorithme local-generator. Le premier lot de jeux de données consi- dérés correspond aux hypergraphes générés à partir des bases de données "Acci- dents" 8 et "Connect-4 " 9, également utilisés dans le chapitre 4. Le deuxième lot contient des hypergraphes aléatoires générés (à l'aide du générateur "random hyper- graph generator" implementé par Boros et al. [BEGK03]), en fonction du nombre de sommets, du nombre d'hyperarêtes et de la taille minimale des hyperarêtes. De plus, au cours de notre étude expérimentale, nous avons pris soin de vérifir que la borne maximale retournée par la fonction GetMinTransversality est bien égale au nombre de transversalité pour chaque hypergraphe traité. Ceci implique que les traverses générées par un produit cartésien des différents ensembles de traverses mi- nimales locales et composées d'un nombre de sommets égal à la valeur retournée par GetMinTransversality sont bien des traverses minimales. Accidents1 X 81 990 ξ τ(H) MH mmcs ks local-generator Accidents2 336 10968 Connect-Win 79 12800 1 2 3 1 961 0,30 8,620 17 486 0,81 4 869 431 100,59 - - 1,52 2,47 294,50 Table 4.1 -- Caractéristiques et temps de traitement des hypergraphes Accidents et Connect (en secondes) Les caractéristiques de chacun des hypergraphes du premier lot considéré sont rappellées dans le tableau 4.1. La première et la seconde colonne correspond, res- pectivement, au nombre de sommets et au nombre d'hyperarêtes des différents hy- 8. http ://archive.ics.uci.edu/ml 9. http ://fimi.cs.helsinki.fi/data/ 4.6 Etude Expérimentale pergraphes. La troisième colonne indique le nombre de transversalité, alors que la quatrième colonne indique le nombre de traverses minimales que renferme chaque hypergraphe. Ces trois hypergraphes ont été traités par trois algorithmes : l'algorithme mmcs de [MU13] l'algorithme ks de [KS05] et notre algorithme local-generator. Le tableau 4.1 récapitule aussi les temps d'exécution de chaque algorithme sur chaque hypergraphe. L'algorithme mmcs étant déjà le plus rapide parmi tout ceux proposés dans la littérature, il l'est aussi sur ces trois jeux de données. local-generator est moins rapide alors que ks ne parvient pas à traiter les hypergraphes Accidents2 et Connect-Win. Le fait que local-generator ait des temps de traitement plus grands que mmcs s'explique par le faible nombre de transversalité des 3 hypergraphes qui varie entre 1 et 3 comme indiqué dans le tableau 4.1. Dans ce cas, la décomposi- tion de l'hypergraphe d'entrée en hypergraphes partiels, ne permet pas d'optimiser convenablement le calcul des traverses minimales. La stratégie "diviser pour régner" n'est pas pertinente lorsque la taille de la plus petite traverse minimale, d'un hy- pergraphe donné, est très petite. Extraire directement les traverses minimales sur l'hypergraphe considéré s'avère plus judicieux que de passer par les traverses mini- males locales. τ(H) MH mmcs ks local-generator 832 564 740 2804,64 3911,431 ξ 52 51 91 X 96 95 119 159 H1 H2 H3 H4 8 9 4 5 040 431 550 3608,182 4 186 560 000 3115,226 142 20 7 158 203 125 5509,455 - - - 1004,269 2899,088 1918,101 4775,364 Table 4.2 -- Caractéristiques et temps de traitement des hypergraphes aléatoires (en secondes) Le Tableau 4.2 récapitule les caractéristiques des différents hypergraphes que nous 4.6 Etude Expérimentale avons générés. Ces données synthétiques ont été générées en fonction des probabilités minimale et maximale d'appartenance d'un sommet aux hyperarêtes dans l'hyper- graphe. Si les nombres de sommets et d'hyperarêtes ne sont pas très élévés, ces hypergraphes renferment néanmoins un très grand nombre de traverses minimales qui varie entre 832 564 740 et 7 158 203 125. Le nombre de transversalité, τ(H) variant de 4 à 20, est aussi élevé en comparaison avec les hypergraphes du Tableau 4.1. Ceci favorise donc notre approche puisque les hypergraphes d'entrée sont dé- composés en un nombre important de petits hypergraphes partiels et, de ce fait, les traverses minimales de taille égale à τ(H) y sont plus nombreuses épargnant ainsi à notre algorithme le test de la minimalité. Les temps de traitement en secondes, récapitulés dans le tableau 4.2, montrent que l'algorithme local-generator présente des temps plus intéressants que ceux ob- tenus par les algorithmes ks et mmcs. Notons que l'algorithme de [KS05] ne parvient à extraire les traverses minimales que sur H1. Les temps d'exécution supérieurs à 1500 secondes peuvent s'expliquer par le nombre élevé de traverses minimales calcu- lées. L'écart entre local-generator et mmcs varie entre 709 et 1800 secondes. La différence de performances entre les tableaux 4.1 et 4.2 permet de dresser un profil des types d'hypergraphes sur lesquels notre approche est plus performante. En effet, local-generator présente des temps intéressants dès que la taille des plus petites traverses minimales de l'hypergraphe d'entrée est élevée ce qui lui permet de décomposer l'hypergraphe en plusieurs hypergraphes partiels. De plus, le nombre de traverses minimales doit être important. Sur des hyper- graphes renfermant peu de traverses minimales, local-generator peine à se mon- trer efficace puisque le nombre de traverses minimales devient négligeable par rapport au nombre de candidats traités et testés. De plus, le gain en temps de traitement est aussi conditionné par le nombre des plus petites traverses minimales. En effet, pour ces dernières, notre algorithme n'effectue pas de test de la minimalité et permet donc 4.7 Conclusion d'optimiser les temps de traitements nécessaires pour le calcul de toutes les traverses minimales. 4.7 Conclusion Dans ce chapitre, nous avons introduit une nouvelle approche pour le calcul des traverses minimales d'un hypergraphe. Cette approche repose sur le paradigme "divi- ser pour régner" afin de décomposer l'hypergraphe d'entrée en hypergraphes partiels, en fonction du nombre de transversalité. Le calcul des traverses minimales locales, correspondantes à ces hypergraphes partiels, permet de retrouver l'ensemble des tra- verses minimales à travers un produit cartésien combiné à un test de la minimalité. Ceci nous a permis d'introduire un nouvel algorithme local-generator pour l'ex- traction des traverses minimales. L'étude expérimentale a confirmé l'intérêt de notre approche sur un type précis d'hypergraphes renfermant des propriétés données. Cette approche a été publiée dans une conférence avec comité de lecture [JLB14b]. Conclusion générale Les notations semi formelles permettent de spécifier le système en fournissant ainsi un bon support de communication avec l'utilisateur alors que les notations formelles apportent une précision à la spécification. Une précision primordiale pour tout raison- nement de vérification. L'idée d'intégrer les méthodes semi formelles et les méthodes formelles permet de bénéficier de la sémantique des premières et de rendre plus ac- cessibles l'accès des utilisateurs aux deuxièmes. Parmi les travaux, qui ont vu le jour ces dernières années, intégrant les méthodes formelles aux méthodes semi formelles, nous nous sommes intéressés à ceux mettant en jeu la méthode b et le langage uml. La traduction des modèles uml en des spéci- fications b engendre des machines b compliquées et difficiles à comprendre. Dans ce contexte, les méthodes semi-formelles peuvent apporter des solutions à des problèmes qui n'ont pas été résolus par les méthodes formelles. En effet, une des faiblesses de la méthode b consiste en son manque de moyens de structuration. Ceci rend bien évidemment difficile la compréhension des modèles b surtout pour un utilisateur non habitué à ses notations. Il paraît donc utile de prévoir des méthodes de conception où les méthodes for- melles et semi-formelles coexistent en offrant deux vues complémentaires d'un modèle commun sous-jacent et en permettant au concepteur de travailler sur la vue la plus adaptée. L'approche proposée dans [?] est une démarche dans ce sens dans le mesure où elle permet de générer des diagrammes de classes à partir des machines b. Cette 83 Conclusion générale approche [?] consiste en un nombre de règles de transformation. Dans le but d'auto- matiser la traduction d'un modèle b en un diagramme de classes uml, nous avons mis en oeuvre un nouveau moteur d'inférence, nommé Thinker, qui à partir d'un modèle b initial permet de générer le diagramme de classes correspondant. Cepen- dant, cet objectif d'automatisation est conditionné par quelques contraintes auquel Thinker a dû faire face. La principale originalité de notre outil constitue donc à donner la main à l'utilisa- teur chaque fois que ceci est nécessaire. En effet, certaines règles de transformation de l'approche [?] nécessite l'intervention de l'utilisateur pour choisir un chemin de traduction parmi plusieurs. Au cours du processus de transformation, il existe des règles qui offrent plusieurs representations possibles et une seule peut être appliquée. Le choix d'une representation est tributaire du seul utilisateur et Thinker intègre cette option dans son mécanisme d'inférence. A la rencontre d'une règle ambiguë qui offre plusieurs représentations possibles, notre moteur d'inférence donne immédiate- ment la main à l'utilisateur. Ce dernier, en s'aidant des représentations graphiques en uml des différents traductions possibles de la règle en question, choisit celle qui correspond le mieux à ses besoins. Autre particularité de Thinker, dans le cas où l'utilisateur exprimerait le souhait de revenir sur un choix antérieur pour le changer, le moteur d'inférence offre la possibilité de rebrousser chemin et revenir à un choix deja pris pour en essayer un autre, et ce à n'importe quel moment du processus d'inférence. Ceci permet à l'utilisateur de diriger lui même l'application des règles en contrôlant le résultat final de la base des faits. Les résultats obtenus sont cohé- rents et sont conformes à la volonté de l'utilisateur, d'autant plus, dans le cas d'une transformation de b vers uml. D'autre part, Thinker intègre un parseur qui permet d'extraire la base des faits initiale directement à partir d'un modèle b donné et ce sans passer par l'utilisateur. Ainsi, n'importe quel personne peut utiliser notre outil sans forcément beaucoup y Conclusion générale connaître en méthode b. En outre, Thinker peut se targuer d'être générique. Outre le cas de la transformation des méthodes b en des diagrammes uml, notre moteur d'inférence est capable de déclencher un mécanisme d'inférence à partir de n'importe quelles base des faits et bases des règles. Nous avons ainsi crée un nouveau moteur d'inférence qui se distingue de ses prédécesseurs par un haut degré d'interactivité avec l'utilisateur. Cette interactivité garantit un résultat final cohérent parfaitement dirigé par l'utilisateur tout au long du processus d'inférence. De plus, le fait que les différentes représentations possibles en uml soient dessinées par notre moteur d'infé- rence donne une idée encore plus précise, à l'utilisateur, des conclusions offertes par chaque règle constituant une ambiguïté donnée. Grâce à Thinker, notre objectif d'automatisation de l'approche de transformation des méthodes b en des diagrammes des classes uml a été atteint et une étude de cas est présentée dans le dernier chapitre. Notre travail a dégagé quelques perspectives. En effet, nous n'avons pris en compte dans notre travail que la traduction d'un modèle b en un diagramme de classes uml. Nous pouvons étendre les fonctions de Thinker pour qu'il puisse générer en plus un diagramme de séquences à partir d'une spécification b donnée. Par la suite, nous pouvons envisager de mettre en place une aide à la décision pour le choix d'une solution en cas d'ambiguïté. Cette extension permettrait à l'utilisateur de se faire conseiller un choix qui ressemble le plus à ses choix antérieurs. Cette idée rentre dans l'optique d'une volonté d'automatiser encore plus le processus de transformation de b vers uml. Bibliographie [ABYL11] Sarra Ayouni, Sadok Ben Yahia, and Anne Laurent. Extracting com- pact and information lossless sets of fuzzy association rules. Fuzzy Sets and Systems, 183(1) :1 -- 25, 2011. [ADG10] Colin Atkinson, Dirk Draheim, and Verena Geist. Typed business pro- cess specification. In 2010 14th IEEE International Enterprise Dis- tributed Object Computing Conference (EDOC), pages 69 -- 78. IEEE, 2010. [AGD09] Dagmar Auer, Verena Geist, and Dirk Draheim. Extending BPMN with submit/response-style user interaction modeling. In IEEE Confe- rence on Commerce and Enterprise Computing (CEC), pages 368 -- 374. IEEE, 2009. [Ake78] S. B. Akers. Binary decision diagrams. IEEE Trans. Computers, 27(6) :509 -- 516, 1978. [ALTY08] N. Agarwal, H. Liu, L. Tang, and P. S. Yu. Identifying the influential bloggers in a community. In Proceedings of the International Confe- rence on Web Search and web Data Mining (WSDM '08), pages 207 -- 218, Stanford, USA, 2008. [AR94] R. Agrawal and S. Ramakrishnan. Fast algorithms for mining associa- tion rules in large databases. In Proceedings of the 2nd International 86 BIBLIOGRAPHIE Conference on Very Large Data Bases (VLDB '94), pages 487 -- 499, Santiago, Chili, 1994. [AvG09] R. Abreu and A. J. C. van Gemund. A low-cost approximate minimal hitting set algorithm and its application to model-based diagnosis. In Proceedings of the seventh Symposium on Abstraction, Reformulation, and Approximation (SARA'09), Minnesota, USA, 2009. [BBBY12a] Hanen Brahmi, Imen Brahmi, and Sadok Ben Yahia. Omc-ids : at the cross-roads of olap mining and intrusion detection. In Pacific-Asia Conference on Knowledge Discovery and Data Mining PAKDD, pages 13 -- 24. Springer, 2012. [BBBY12b] Hanen Brahmi, Imen Brahmi, and Sadok Ben Yahia. Omc-ids : at the cross-roads of olap mining and intrusion detection. In Pacific-Asia Conference on Knowledge Discovery and Data Mining, pages 13 -- 24. Springer, 2012. [BE92] S.P. Borgatti and M.G. Everett. Notions of position in social network analysis. In Sociological methodology, pages 1 -- 35, 1992. [BEBY06] Ines Bouzouita, Samir Elloumi, and Sadok Ben Yahia. Garc : A new associative classification approach. In International Conference on Data Warehousing and Knowledge Discovery, pages 554 -- 565. Springer, 2006. [BEGK03] E. Boros, K. Elbassioni, V. Gurvich, and L. Khachiyan. An efficient implementation of a quasi-polynomial algorithm for generating hy- pergraph transversals. In Proceedings of the 11th Annual European Symposium on Algorithms (ESA 2003), pages 556 -- 567, Amsterdam, Netherlands, 2003. [BEM08] E. Boros, K. Elbassioni, and K. Makino. On Berge multiplication for monotone boolean dualization. In Proceedings of the 35th Interna- BIBLIOGRAPHIE tional colloquium on Automata, Languages and Programming, Part I, ICALP '08, pages 48 -- 59, 2008. [Ber89] C. Berge. Hypergraphs : Combinatorics of Finite Sets. North-Holland, 3rd edition, 1989. [BGKM03] E. Boros, V. Gurvich, L. Khachiyan, and K. Makino. On maximal frequent and minimal infrequent sets in binary matrices. Annals of Mathematics and Artificial Intelligence, 39(3) :211 -- 221, 2003. [BHL+05] B. Benatallah, M. S. Hacid, A. Lager, C. Rey, and F. Toumani. On automating web services discovery. The International Journal on Very Large Data Bases, 14(1) :84 -- 96, 2005. [BI95] J.C. Bioch and T. Ibaraki. Complexity of identification and duali- zation of positive boolean functions. Information and Computation, 123(1) :50 -- 63, 1995. [BMR03] J. Bailey, T. Manoukian, and K. Ramamohanarao. A fast algorithm for computing hypergraph transversals and its application in mining emerging patterns. In Proceedings of the Third IEEE International Conference on Data Mining (ICDM '03), pages 485 -- 488, Washington, USA, 2003. [BRB90] K. S. Brace, R. L. Rudell, and R. E. Bryant. Efficient implementation of a BDD package. In Proceedings of the 27th ACM/IEEE Design Automation Conference (DAC'90), pages 40 -- 45, Florida, USA, 1990. [BSBYN12] Slim Bouker, Rabie Saidi, Sadok Ben Yahia, and Engelbert Mephu Nguifo. Ranking and selecting association rules based on dominance relationship. In Tools with Artificial Intelligence (ICTAI), volume 1, pages 658 -- 665. IEEE, 2012. [BYJ00] Sadok Ben Yahia and Ali Jaoua. A top-down approach for mining fuzzy association rules. In Proc. 8th Int. Conf. Information Pro- BIBLIOGRAPHIE cessing Management of Uncertainty Knowledge-Based Systems, pages 952 -- 959, 2000. [BYN04a] S Ben Yahia and E Mephu Nguifo. Revisiting generic bases of asso- ciation rules. In International Conference on Data Warehousing and Knowledge Discovery, pages 58 -- 67. Springer, 2004. [BYN04b] Sadok Ben Yahia and Engelbert Mephu Nguifo. Revisiting generic bases of association rules. In International Conference on Data Wa- rehousing and Knowledge Discovery, pages 58 -- 67. Springer, 2004. [CCL05] A. Casali, R. Cicchetti, and L. Lakhal. Essential patterns : A perfect cover of frequent patterns. In Proceedings of the 7th International Conference on DaWaK, pages 428 -- 437, Copenhagen, Denmark, 2005. [CFRD08] Peggy Cellier, Sébastien Ferré, Olivier Ridoux, and Mireille Ducasse. A parameterized algorithm to explore formal contexts with a taxo- nomy. International Journal of Foundations of Computer Science, 19(02) :319 -- 343, 2008. [CH77] D. Cartwright and F. Harary. A graph theoretic approach to the inves- tigation of system-environment relationships. Journal of Mathematical Sociology, 5 :87 -- 111, 1977. [CJB12] Ch.Trabelsi, N. Jelassi, and S. Ben Yahia. Scalable mining of frequent tri-concepts from folksonomies. In Proceedings of the 16th Pacific-Asia Conference on Knowledge Discovery and Data Mining, PAKDD 2012, pages 231 -- 242, Kuala Lumpur, Malysia, May 2012. [CWW10] Wei Chen, Chi Wang, and Yajun Wang. Scalable influence maximi- zation for prevalent viral marketing in large-scale social networks. In Proceedings of the 16th ACM SIGKDD international conference on Knowledge Discovery and Data mining (KDD'10), pages 1029 -- 1038, Washington, USA, 2010. BIBLIOGRAPHIE [CWY09] W. Chen, Y. Wang, and S. Yang. Efficient influence maximization in social networks. In Proceedings of the 15th ACM SIGKDD Internatio- nal Conference on Knowledge Discovery and Data mining (KDD '09), pages 199 -- 208, Paris, France, 2009. [CYZ10] Wei Chen, Yifei Yuan, and Li Zhang. Scalable influence maximization in social networks under the linear threshold model. In Proceedings of the 2010 IEEE International Conference on Data Mining (ICDM'10), pages 88 -- 97, Sydney, Australia, 2010. [DKBY15] Warith Eddine Djeddi, Mohamed Tarek Khadir, and Sadok Ben Yahia. Xmap : results for oaei 2015. In Ontology Matching (OM), pages 216 -- 221, 2015. [DL05] G. Dong and J. Li. Mining border descriptions of emerging patterns from dataset pairs. Knowledge and Information Systems, 8(2) :178 -- 202, 2005. [DLW05] Dirk Draheim, Christof Lutteroth, and Gerald Weber. Generative programming for c#. ACM SIGPLAN Notices, 40(8) :29 -- 33, 2005. [DN08] Dirk Draheim and Christine Natschläger. A context-oriented synchro- nization approach. In Electronic Proceedings of the 2nd International Workshop in Personalized Access, Profile Management, and Context Awareness : Databases (PersDB) in Conjunction with the 34th VLDB Conference, pages 20 -- 27, 2008. [Dom05] P. Domingos. Mining social networks for viral marketing. IEEE In- telligent Systems, 20(1) :80 -- 82, 2005. [DQ13] N. Durand and M. Quafafou. Approximation de bordures de motifs fre- quents par le calcul de traverses minimales approches d'hypergraphes. In actes de la 13eme Conference Francophone sur l'Apprentissage Au- tomatique, CAP'12, pages 228 -- 240, Lille, France, 2013. BIBLIOGRAPHIE [DR01] P. Domingos and M. Richardson. Mining the network value of cus- tomers. In Proceedings of the seventh ACM SIGKDD international conference on Knowledge discovery and data mining, pages 57 -- 66, New York, USA, 2001. [Dra10] Dirk Draheim. The service-oriented metaphor deciphered. Journal of Computing Science and Engineering (JCSE), 4(4) :253 -- 275, 2010. [DT99] J. Demetrovics and V. D. Thi. Describing candidate keys by hyper- graphs. Computers and Artificial Intelligence, 18(2) :191 -- 207, 1999. [EDS07] E. Even-Dar and A. Shapira. A note on maximizing the spread of influence in social networks. In Proceedings of the 3rd International Worshop on Internet and Network Economics (WINE'07), San Diego, USA, 2007. [EG95] T. Eiter and G. Gottlob. Identifying the minimal transversals of a hypergraph and related problems. SIAM Journal on Computing, 24(6) :1278 -- 1304, 1995. [EG02] T. Eiter and G. Gottlob. Hypergraph transversal computation and related problems in logic and AI. In Proceedings of the 4th European Conference on Logics in Artificial Intelligence, JELIA '02, pages 549 -- 564, 2002. [Elb08] K. Elbassioni. On the complexity of monotone dualization and genera- ting minimal hypergraph transversals. Discrete Applied Mathematics, 156(11) :2109 -- 2123, 2008. [FEJ+12a] Fethi Ferjani, Samir Elloumi, Ali Jaoua, Sadok Ben Yahia, Sahar Is- mail, and Sheikha Ravan. Formal context coverage based on isolated labels : An efficient solution for text feature extraction. Information Sciences, 188 :198 -- 214, 2012. BIBLIOGRAPHIE [FEJ+12b] Fethi Ferjani, Samir Elloumi, Ali Jaoua, Sadok Ben Yahia, Sahar Is- mail, and Sheikha Ravan. Formal context coverage based on isolated labels : An efficient solution for text feature extraction. Information Sciences, 188 :198 -- 214, 2012. [FK96] M. L. Fredman and L. Khachiyan. On the complexity of dualization of monotone disjunctive normal forms. Journal of Algorithms, 21 :618 -- 628, 1996. [Fre79] L. C. Freeman. Centrality in social networks : Conceptual clarification. Social Networks, 1(3) :215 -- 239, 1979. [Gar06] G. C. Garriga. Formal methods for mining structured objects. Phd dissertation, Universitat Politècnica de Catalunya, 2006. [GBYNB07] Ghada Gasmi, Sadok Ben Yahia, Engelbert Mephu Nguifo, and Slim Bouker. Extraction of association rules based on literalsets. In Inter- national Conference on Data Warehousing and Knowledge Discovery, pages 293 -- 302. Springer, 2007. [GLL11] A. Goyal, W. Lu, and L.V.S Lakshmanan. Celf++ : optimizing the greedy algorithm for influence maximization in social networks. In Proceedings of the 20th International Conference companion on World Wide Web (WWW '11), pages 47 -- 48, Hyderabad, India, 2011. [Gra78] M. Granovetter. Threshold models of collective behavior. American Journal of Sociology, 83(6) :1420 -- 1443, 1978. [Hag08] M. Hagen. Algorithmic and Computational Complexity Issues of MO- NET. Phd dissertation, Institut für Informatik, Friedrich-Schiller- Universität Jena, 2008. [HBC07] C. Hébert, A. Bretto, and B. Crémilleux. A data mining formalization to improve hypergraph minimal transversal computation. Fundamenta Informaticae, 80(4) :415 -- 433, 2007. BIBLIOGRAPHIE [HBGBY13a] Sana Hamdi, Amel Bouzeghoub, Alda Lopes Gancarski, and Sadok Ben Yahia. Trust inference computation for online social networks. In Trust, Security and Privacy in Computing and Communications (TrustCom), pages 210 -- 217. IEEE, 2013. [HBGBY13b] Sana Hamdi, Amel Bouzeghoub, Alda Lopes Gancarski, and Sadok Ben Yahia. Trust inference computation for online social networks. In 2013 12th IEEE International Conference on Trust, Security and Privacy in Computing and Communications (TrustCom), pages 210 -- 217. IEEE, 2013. [HBYN08] Tarek Hamrouni, Sadok Ben Yahia, and Engelbert Mephu Nguifo. Succinct system of minimal generators : A thorough study, limitations and new definitions. In Concept Lattices and Their Applications, pages 80 -- 95. Springer, 2008. [HBYN10a] Tarek Hamrouni, Sadok Ben Yahia, and Engelbert Mephu Nguifo. Generalization of association rules through disjunction. Annals of Mathematics and Artificial Intelligence, 59(2) :201 -- 222, 2010. [HBYN10b] Tarek Hamrouni, Sadok Ben Yahia, and Engelbert Mephu Nguifo. Generalization of association rules through disjunction. Annals of Mathematics and Artificial Intelligence, 59(2) :201 -- 222, 2010. [HBYN13] Tarek Hamrouni, Sadok Ben Yahia, and Engelbert Mephu Nguifo. Looking for a structural characterization of the sparseness measure of (frequent closed) itemset contexts. Information Sciences, 222 :343 -- 361, 2013. [Héb07] C. Hébert. Extraction et usage de motifs minimaux en fouille de donnes, contribution au domaine des hypergraphes. Thése de doctorat, Université de Caen, Basse Normandie, 2007. BIBLIOGRAPHIE [HGBBY12] Sana Hamdi, Alda Lopes Gancarski, Amel Bouzeghoub, and Sadok Ben Yahia. Iris : A novel method of direct trust computation for ge- nerating trusted social networks. In 2012 IEEE 11th International Conference on Trust, Security and Privacy in Computing and Com- munications (TrustCom), pages 616 -- 623. IEEE, 2012. [JG01] E. Muller J. Goldenberg, B. Libai. Talk of the network : A complex systems look at the underlying process of word-of-mouth. Marketing Letters, 12(3) :211 -- 223, 2001. [JLB12a] M.N. Jelassi, C. Largeron, and S. Ben Yahia. A la recherche d'acteurs multi-communautaires dans un reseau social. In actes de la 12eme Conference Francophone sur l'Apprentissage Automatique, CAP'12, pages 238 -- 252, Nancy, France, 2012. [JLB12b] M.N. Jelassi, C. Largeron, and S. Ben Yahia. Tmd-miner : Une nou- velle approche pour la detection des diffuseurs dans un systeme com- munautaire. In actes de la 13eme Conference Francophone sur l'Ex- traction et la Gestion des Connaissances, EGC'12, pages 423 -- 428, Bordeaux, France, 2012. [JLB14a] M.N. Jelassi, C. Largeron, and S. Ben Yahia. Efficient unveiling of multi-members in a social network. The Journal of Systems and Soft- ware, 94 :30 -- 38, 2014. [JLB14b] M.N. Jelassi, C. Largeron, and S. Ben Yahia. Local-generator : "divi- ser pour regner" pour l'extraction des traverses minimales d'un hyper- graphe. In actes de la 15eme Conference Francophone sur l'Extraction et la Gestion des Connaissances, EGC'14, pages 245 -- 256, Toulouse, France, 2014. [KBGD14] Olga Koutsoni, Mourad Barhoumi, Ikram Guizani, and Eleni Dotsika. Leishmania eukaryotic initiation factor (leif) inhibits parasite growth BIBLIOGRAPHIE in murine macrophages. PLoS One, 9(5) :e97319, 2014. [KKT03] D. Kempe, J. Kleinberg, and E. Tardos. Maximizing the spread of influence through a social network. In Proceedings of the 9th ACM SIGKDD International Conference on Knowledge Discovery and Data mining (KDD'03), pages 137 -- 146, Washington, USA, 2003. [KMZY11] Marouen Kachroudi, Essia Ben Moussa, Sami Zghal, and Sadok Ben Yahia. Ldoa results for oaei 2011. In Proceedings of the 6th Interna- tional Conference on Ontology Matching-Volume 814, pages 148 -- 155. CEUR-WS. org, 2011. [KS05] D. J. Kavvadias and E. C. Stavropoulos. An efficient algorithm for the transversal hypergraph generation. Journal of Graph Algorithms and Applications, 9(2) :239 -- 264, 2005. [KS06] M. Kimura and K. Saito. Tractable models for information diffusion in social networks. In Proceedings of the 10th European Conference on Principles of Knowledge Discovery in Databases (PKDD'06), volume 4213, pages 259 -- 271, Berlin, Allemagne, 2006. [LKG+07] J. Leskovec, A. Krause, C. Guestrin, C. Faloutsos, J. VanBriesen, and N. Glance. Cost-effective outbreak detection in networks. In Procee- dings of the 13th ACM SIGKDD International Conference on Know- ledge Discovery and Data mining (KDD '07), pages 420 -- 429, San Jose, Californie, USA, 2007. [LPL00] S. Lopes, J. M. Petit, and L. Lakhal. Efficient discovery of functio- nal dependencies and Armstrong relations. In Proceedings of the 7th International Conference on Extending Database Technology, pages 350 -- 364, Konstanz, Germany, 2000. [Mar13] A. Mary. Enumeration des dominants minimaux d'un graphe. Thése de doctorat, Universite Blaise Pascal, Clermont-Ferrand, 2013. BIBLIOGRAPHIE [Mik07] P. Mika. Ontologies are us : A unified model of social networks and semantics. Web Semantics : Science, Services and Agents on the World Wide Web, 5(1) :5 -- 15, March 2007. [Mor34] J.L. Moreno. Who shall survive ? : a new approach to the problem of Human Interrelations, volume 58 of Nervous and mental disease monograph series. 1934. [MP03] F. De Marchi and J. M. Petit. Zigzag : a new algorithm for mining large inclusion dependencies in database. In Proceedings of the 3rd IEEE International Conference on Data Mining, ICDM'03, pages 27 -- 34, Florida, USA, 2003. [MR94] Heikki Mannila and Kari-Jouko Räihä. Algorithms for inferring func- tional dependencies from relations. Data Knowledge Engineering, 12(1) :83 -- 99, 1994. [MT97] H. Mannila and H. Toivonen. Levelwise search and borders of theo- ries in knowledge discovery. Data Mining and Knowledge discovery, 1(3) :241 -- 258, 1997. [MU13] K. Murakami and T. Uno. Efficient algorithms for dualizing large-scale hypergraphs. In Proceedings of the 15th Meeting on Algorithm Engi- neering and Experiments (ALENEX'13), pages 1 -- 13, New Orleans, USA, 2013. [OH10] T. Opsahl and B. Hogan. Growth mechanisms in continuously- observed networks : Communication in a facebook-like community. CoRR, abs/1010.2141, 2010. [PT02] J. L. Pfaltz and C. M. Taylor. Scientific discovery through iterative transformations of concept lattices. In Proceedings of the Workshop on Discrete Mathematics and Data Mining at 2nd SIAM Conference on Data Mining, pages 65 -- 74, Arlington, USA, 2002. BIBLIOGRAPHIE [RD02] M. Richardson and P. Domingos. Mining knowledge-sharing sites for viral marketing. In Proceedings of the of the 8th International Confe- rence on Knowledge Discovery and Data mining (KDD '02), pages 61 -- 70, Edmontom, Canada, 2002. [Sch78] [Sco00] T. Schelling. Micromotives and Macrobehavior. 1978. J. Scott. Social Network Analysis : A Handbook. Sage, 2000. [STE07a] J. Scripps, P. N. Tan, and A. H. Esfahanian. Exploration of link structure and community-based node roles in network analysis. In Proceedings of the 7th IEEE International Conference on Data Mining (ICDM'07), pages 649 -- 654, Omaha, USA, 2007. [STE07b] J. Scripps, P. N. Tan, and A. H. Esfahanian. Node roles and com- munity structure in networks. In Proceedings of the 1st Workshop on Web Mining and Social Network Analysis (SNA-KDD'07), pages 26 -- 35, San Jose, California, 2007. [Tod13] T. Toda. Hypergraph transversal computation with binary decision diagrams. In Proceedings of the 12th International Symposium on Experimental Algorithms (SEA'13), pages 91 -- 102, Rome, Italy, 2013. [TS05] D. V. Thi and H. N. Son. On the dense families in the relational data- model. ASEAN Journal on Science and Technology for Development, 22(3) :241 -- 249, 2005. [WCSX10] Y. Wang, G. Cong, G. Song, and K. Xie. Community-based greedy algorithm for mining top-k influential nodes in mobile social networks. In Proceedings of the 16th ACM SIGKDD International Conference on Knowledge discovery and Data mining (KDD'10), pages 1039 -- 1048, New York, USA, 2010. ACM. BIBLIOGRAPHIE [WF94] S. Wasserman and K. Faust. Social Network Analysis, methods and application. Cambridge University Press, New York, USA, 4th edition : 1998, 1999 edition, Cambridge University Press, 1994. [YN04a] Sadok Ben Yahia and Engelbert Mephu Nguifo. Emulating a coope- rative behavior in a generic association rule visualization tool. In International Conference on Tools with Artificial Intelligence ICTAI, volume 110. CEUR-WS.org, 2004. [YN04b] Sadok Ben Yahia and Engelbert Mephu Nguifo. Emulating a coope- rative behavior in a generic association rule visualization tool. In In- ternational Conference on Tools with Artificial Intelligence (ICTAI), volume 110. CEUR-WS.org, 2004. [ZBYNS07] Sami Zghal, Sadok Ben Yahia, Engelbert Mephu Nguifo, and Yahya Slimani. Soda : an owl-dl based ontology matching system. In Pro- ceedings of the 2nd International Conference on Ontology Matching- Volume 304, pages 261 -- 267. CEUR-WS. org, 2007.
1904.06543
1
1904
2019-04-13T13:10:16
Online Bin Covering with Limited Migration
[ "cs.DS" ]
Semi-online models where decisions may be revoked in a limited way have been studied extensively in the last years. This is motivated by the fact that the pure online model is often too restrictive to model real-world applications, where some changes might be allowed. A well-studied measure of the amount of decisions that can be revoked is the migration factor $\beta$: When an object $o$ of size $s(o)$ arrives, the decisions for objects of total size at most $\beta\cdot s(o)$ may be revoked. Usually $\beta$ should be a constant. This means that a small object only leads to small changes. This measure has been successfully investigated for different, classic problems such as bin packing or makespan minimization. The dual of makespan minimization - the Santa Claus or machine covering problem - has also been studied, whereas the dual of bin packing - the bin covering problem - has not been looked at from such a perspective. In this work, we extensively study the bin covering problem with migration in different scenarios. We develop algorithms both for the static case - where only insertions are allowed - and for the dynamic case, where items may also depart. We also develop lower bounds for these scenarios both for amortized migration and for worst-case migration showing that our algorithms have nearly optimal migration factor and asymptotic competitive ratio (up to an arbitrary small $\eps$). We therefore resolve the competitiveness of the bin covering problem with migration.
cs.DS
cs
Online Bin Covering with Limited Migration∗ Sebastian Berndt1, Leah Epstein2, Klaus Jansen1, Asaf Levin3, Marten Maack1, and Lars Rohwedder1 1Department of Computer Science, Kiel University, Kiel, Germany 2Department of Mathematics, University of Haifa, Haifa, Israel 3Faculty of Industrial Engineering and Management, The Technion, Haifa, Israel April 16, 2019 Abstract Semi-online models where decisions may be revoked in a limited way have been studied extensively in the last years. This is motivated by the fact that the pure online model is often too restrictive to model real-world applications, where some changes might be allowed. A well-studied measure of the amount of decisions that can be revoked is the migration factor β: When an object o of size s(o) arrives, the decisions for objects of total size at most β · s(o) may be revoked. Usually β should be a constant. This means that a small object only leads to small changes. This measure has been successfully investigated for different, classic problems such as bin packing or makespan minimization. The dual of makespan minimization -- the Santa Claus or machine covering problem -- has also been studied, whereas the dual of bin packing -- the bin covering problem -- has not been looked at from such a perspective. In this work, we extensively study the bin covering problem with migration in different scenarios. We develop algorithms both for the static case -- where only insertions are allowed -- and for the dynamic case, where items may also depart. We also develop lower bounds for these scenarios both for amortized migration and for worst-case migration showing that our algorithms have nearly optimal migration factor and asymptotic competitive ratio (up to an arbitrary small ε). We therefore resolve the competitiveness of the bin covering problem with migration. 1 Introduction Online algorithms aim to maintain a competitive solution without knowing future parts of the input. The competitive ratio of such an algorithm (for a maximization problem) is thus defined as the worst-case ratio between the value of an optimal solution produced by an offline algorithm knowing the complete input and the value of the solution produced by the online algorithm. Furthermore, once a decision is made by these algorithms, this ∗This work was partially supported by DFG Project, "Robuste Online-Algorithmen für Scheduling- und Packungsprobleme", JA 612 /19-1, and by GIF-Project "Polynomial Migration for Online Scheduling". 1 decision is fixed and irreversible. While a surprisingly large number of problems do have such algorithms, the complete irreversibility requirement is often too strict, leading to high competitive ratios. Furthermore, if the departure of objects from the instance is also allowed, irreversible online algorithms are rarely able to be competitive at all. From a practical point of view, this is quite alarming, as the departure of objects is part of many applications. We call such a problem dynamic and the version with only insertions static. A number of different scenarios to loosen the strict requirement of irreversibility -- called semi-online scenarios -- have been developed over time in order to find algorithms that achieve good competitive ratios for some of the scenarios bounded reversibility. In the last few years, the concept of the migration factor has been studied intensively [4, 11, 12, 13, 14, 17, 20, 22, 23]. Roughly speaking, a migration factor of β allows to reverse a total size of β · s(o) decisions, where s(o) denotes the size of the newly arrived object o. For a packing problem, this means that the algorithm is allowed to repack objects with a total size of β · s(o). This notion of reversibility is very natural, as it guarantees that a small object can only lead to small changes in the solution structure. Furthermore, algorithms with bounded migration factor often show a very clear-cut tradeoff between their migration and the competitive ratio: Many algorithms in this setting have a bounded migration factor which can be defined as a function f (ε) (growing with 1 ε ) and a small competitive ratio g(ε) (growing with ε), where the functions f and g can be defined for all ε > 0 [4, 11, 14, 17, 20, 22, 23]. Such algorithms are called robust, as the amount of reversibility allowed only depends on the solution guarantee that one wants to achieve. Such robust algorithms thus serve as evidence for the possibility for sensitivity analysis in approximated settings. Many different problems have been studied in online and semi-online scenarios, but two problems that have been considered in nearly every scenario are classic scheduling problems: The bin packing problem and the makespan minimization problem. Both of these problems have been studied intensively in the migration model [4, 11, 13, 14, 20, 22, 23]. Both of these problems also have corresponding dual maximization variants. The dual version of the makespan minimization problem, often called the Santa Claus or machine covering problem, has also been studied with migration [17, 23]. In contrast, the dual version of bin packing, called bin covering has not yet been studied in this model. The aim of this paper is to remedy this situation by taking a look at this classic scheduling problem in the migration model. Formal Problem Statement In the bin covering problem, a set of items Γ with sizes s : Γ → (0, 1] is used to cover as many unit sized bins as possible, that is, Γ has to be partitioned maximizing the number of partitions with summed up item size of at least one. An instance of the problem will usually be denoted as I and is given as a sequence of entries (i, s(i)) where i is the identifier of the item and s(i) is the size of the item. A solution to such an instance I with items Γ is a partition P : Γ → N and a set B = P −1(k) with B 6= ∅ is called a bin and we say that the items in B are packed into the k-th bin. For a subset I ′ ⊆ I, let s(I ′) = Pi∈I ′ s(i). A bin B is covered if s(B) ≥ 1, where s(B) is called the load of B or its size, and the goal is to maximize the number of such covered bins. The optimal (maximum) number of covered bins of instance I is denoted as opt(I). 2 We also use the following notations throughout our work: The smallest size of an item in bin B is defined as smin(B) := mini∈B{s(i)} and the largest size is defined as smax(B) := maxi∈B{s(i)}. If B is a set of bins, we also define its total size s(B) := PB∈B s(B), its minimal size smin(B) := minB∈B smin(B), and its maximal size smax(B) := maxB∈B smax(B). Furthermore, we define smin(∅) = +∞ and smax(∅) = 0. We consider variants of static and dynamic online bin covering in which algorithms are allowed to reassign a bounded amount of previously assigned items. In particular, an algorithm has a migration factor of β, if the total size of items that it reassigns upon arrival or departure of an item of size s is bounded by βs. Moreover, it has an amortized migration factor of β, if at any time the total size of items that have been reassigned by the algorithm in total is bounded by βS, where S is the total size of all items that arrived before. Intuitively, an item of size s creates a migration potential of size βs upon arrival, and this potential may be used by an algorithm to reassign items right away (non-amortized) or anytime from then on (amortized). Note that if an algorithm has a non-amortized migration factor of β, then it also has an amortized migration factor of at most β. Thus, we study four variants in this work. Offline bin covering is NP-hard and therefore there is little hope for a polynomial time algorithm solving the problem to optimality, and in the online setting there is no algorithm that can maintain an optimal solution regardless of its running time. We prove that this non-existence of algorithms that maintain an optimal solution holds also for (static or dynamic) algorithms with bounded amortized migration factor (and thus also for algorithms with bounded non-amortized migration factor). Hence, algorithms satisfying some performance guarantee are studied. In particular an offline algorithm alg for a maximization problem has an asymptotic performance guarantee of α ≥ 1, if opt(I) ≤ α·alg(I)+c, where opt(I) and alg(I) are the objective values of an optimal solution or the one produced by alg respectively for some instance I, and c is an input independent constant. If c = 0 holds, α is called absolute rather than asymptotic. An online algorithm has a (asymptotic or absolute) competitive ratio of α, if after each arrival or departure an (asymptotic or absolute) performance guarantee of α for the instance of the present items holds. Note that we use the convention of competitive ratios larger than 1 for maximization problems. For minimization problems similar definitions are used but they use the required inequality alg(I) ≤ α · opt(I) + c. As we study asymptotic competitive ratios in this paper, we will sometimes omit the word asymptotic (and we always use the word absolute for absolute competitive ratios). In what follows we assume s : Γ → (0, 1), i. e., that there are no items of size 1. This is justified by the following. For any algorithm it is possible to add a rule that such an item will always be packed into its own bin, which will be covered. Without loss of generality, we can consider an optimal solution that applies this rule as well. This does not affect the (asymptotic or absolute) competitive ratio. Known Results for Bin Covering The offline bin covering problem was first studied by Assmann et al. [1]. It was shown that a simple greedy strategy achieves approximation ratio 2. For the online version of the bin covering problem, Csirik and Totik showed in [7] that this simple greedy algorithm also works in the online setting and that the competitive ratio of 2 reached by this algorithm is 3 the best possible. Csirik, Johnson, and Kenyon presented an asymptotic polynomial time approximation scheme (APTAS) with approximation ratio 1 + ε in [6]. This was improved to an asymptotic fully polynomial time approximation scheme (AFPTAS) by Jansen and Solis-Oba in [21]. Many different variants of this problem have also been investigated: If a certain number of classes needs to be part of each bin [10, 16]; if items are drawn probabilistically [15, 16]; if bins have different sizes [8, 24]; if the competitiveness is not measured with regard to an optimal offline algorithm [5, 9]. More variants are discussed for example in [18] and lower bounds for several variants are studied in [2]. The dynamic variant was not studied in the online scenario since there is no algorithm with a finite competitive ratio. Specifically, if all items are very small, it can happen that items depart in a way that no bin remains covered, while an optimal solution could pack items differently such that all items depart from a small number of bins, and in this way it will still cover many bins. Our Results ε5 We present competitive algorithms using both amortized migration and non-amortized migration and develop nearly matching lower bounds (up to an arbitrary small additive term of ε). These bounds show the optimality of all of our algorithms for both the static and the dynamic version of the bin covering problem. The main technical contribution of our work is an algorithm with competitive ratio 3/2 + ε and non-amortized migration of O( log2(1/ε) ) for the dynamic bin covering problem where items arrive and depart. A major obstacle in the design of competitive algorithms for dynamic problems is the impossibility of moving large items on the arrival or departure of small items. We overcome this obstacle by developing a delicate technique to combine the packing of large and small items. The main results of this work are summarized in the following table. Note that the lower bound of 1 in the third row indicates that there is no online algorithm that maintains an optimal solution with amortized migration factor O(1). All of our algorithms run in polynomial time. Curiously, we achieve a polynomial migration factor, while most known migration factors are exponential (e.g., for the makespan minimization problem [22]) with the exception of bin packing [19]. Thus, we show how to overcome the shortcoming of online algorithms in the dynamic setting by using migration and get a constant competitive ratio in the most general setting. Surprisingly, the constant is even smaller than the best possible competitive ratio for pure online algorithms in the static case for which the competitive ratio is 2, while our bound is 3 2 + ε for any ε > 0. Amortization Departures Lower Bound Competitive Ratio Migration é é Ë Ë é Ë é Ë 3/2 3/2 1 3/2 O(1/ε) O( log2(1/ε) ε5 O(1/ε) O( log2(1/ε) ε5 ) ) 3/2 + ε 3/2 + ε 1 + ε 3/2 + ε 4 Related Results Makespan Minimization and Santa Claus: The migration factor model was intro- duced by Sanders, Sivadasan, and Skutella in [22]. The paper investigated several algo- rithms for the makespan minimization problem and also presents an approximation scheme with absolute competitive ratio 1 + ε and non-amortized migration factor 2O((1/ε)·log2(1/ε)). Skutella and Verschae [23] studied a dynamic setting with amortized migration, where jobs may also depart from the instance. They achieved the same absolute competitive ratio, but their algorithm needs an amortized migration of 2O((1/ε)·log2(1/ε)). Their algorithm also works for the Santa Claus (or machine covering) problem, for which they show that even in the static setting no algorithm has absolute competitive ratio 1 + ε and a bounded migration factor. If one aims for a polynomial migration factor for the Santa Claus prob- lem, Gálvez, Soto, and Verschae presented an online variant of the LPT (least processing time) algorithm achieving an absolute competitive ratio of 4/3 + ε with non-amortized migration factor O((1/ε3) · log(1/ε)) [17]. For the makespan minimization problem, if jobs can be preempted, Epstein and Levin showed in [13] that an optimal algorithm with a non-amortized migration factor of 1−1/m is achievable and the best possible. Bin Packing: Epstein and Levin presented an approximation scheme with the same ratio 1+ε and the same non-amortized migration factor 2O((1/ε)·log2(1/ε)) as in the makespan minimization for the bin packing problem in [11]. This result was improved by Jansen and Klein in [19], who drastically reduced the migration factor to O(1/ε4). Berndt, Jansen, and Klein used a similar approach to also handle the dynamic bin packing problem, where items may also depart over time [4]. They also showed that a non-amortized migration factor of Ω(1/ε) is needed for this. A generalized model, where an item i has arbitrary movement costs ci -- not necessarily linked to the size of an item -- was studied by Feldkord et al. [14]. They showed that for α ≈ 1.387 and every ε > 0, a competitive ratio of α + ε is achievable with migration O(1/ε2), but no algorithm with migration o(n) and ratio α − ε exists. By strengthening the lower bound of [4], they also showed that an amortized migration factor of Ω(1/ε) is needed for the standard migration model -- where the movement costs ci are equal to the items sizes si -- if one wants to achieve a competitive ratio of 1 + ε. A generalization of bin packing, where d-dimensional cubic items are packed into as few unit size cubes was studied by Epstein and Levin [12]. 2 Non-amortized Migration in the Static Case We begin our study by analyzing the static case with non-amortized migration. We will first present a lower bound showing that no algorithm with constant non-amortized migra- tion factor can have a competitive ratio below 3/2. Then, we present an algorithm that achieves for all ε > 0 a competitive ratio of 3/2 + ε with non-amortized migration factor O(1/ε). 5 2.1 Lower Bound We start with a simple lower bound on the asymptotic competitive ratio of all algorithms with constant non-amortized migration factor. This lower bound can also be proved for a different definition of the asymptotic competitive ratio α, where we require opt(I) ≤ α · alg(I) + o(opt(I)). Proposition 1. There is no algorithm for static online bin covering with a constant non- amortized migration factor and an asymptotic competitive ratio smaller than 3/2. Proof. Let N be an integer and alg an algorithm for online bin covering with a non- amortized migration factor of β. Furthermore, let R be the asymptotic competitive ratio of alg, i. e., we have opt(I) ≤ R · alg(I) + c for some constant value c. We construct an instance that is divided into two phases, in each of which of equal size items arrive. The instance corresponding to the first phase is called I1 and the one corresponding to both phases I2. The optimal (offline) objective value of I1 and I2 will be a multiple of N and we will show that the ratio between this value and the objective value that is achieved by alg is at least 3/2 either for I1 or for I2. In both phases 6N items arrive, in the first they have size 1 − ε and in the second one size ε. We choose the parameter ε such that the items from the second phase do not fill a whole bin and such that they cannot be used to migrate items from the first, more precisely, let ε = min{(2β + 2)−1, (12N )−1}. Note that the optimal objective value for I1 and I2 is 3N and 6N respectively. See Fig. 1 for feasible packings with these objective values. The optimality follows as each covered bin must have at least two items since the sizes of the items are strictly smaller than 1. As each of the alg(I1) covered bins has to contain at least 2 items from the first phase, there are at most 6N − 2 alg(I1) bins each of which with exactly one item of the first phase. Furthermore, items from the first phase cannot be migrated during the second, as ε · β ≤ (2β + 2)−1 · β < 1/2 < 11/12 ≤ 1 − ε. Hence, we have alg(I2) ≤ alg(I1) + (6N − 2 alg(I1)) = 6N − alg(I1). We thus have alg(I1) + alg(I2) ≤ 6N . As the asymptotic competitive ratio of alg is R, we can also conclude that 3N = opt(I1) ≤ R · alg(I1) + c and 6N = opt(I2) ≤ R · alg(I2) + c. Summing these two inequalities gives 9N ≤ R(alg(I1) + alg(I2)) + 2c. As alg(I1) + alg(I2) ≤ 6N , we have 9N ≤ 6RN + 2c and thus R ≥ 3/2 − (2c)/(6N ). Letting N grow to infinity thus yields R ≥ 3/2. 2.2 Upper Bound We will now give our algorithm alg for this scenario. In addition to the instance I, a parameter ε > 0 is also given that regulates the asymptotic competitive ratio and the used migration. The assumption ε ≤ 0.5 is justified as for ε ≥ 0.5, the result follows by the online algorithm with an asymptotic competitive ratio of 2 presented in [7], or by using the algorithm below with ε = 1 2 . Theorem 2. For each ε ∈ (0, 0.5], there is an algorithm alg for static online bin covering with polynomial running time, an asymptotic competitive ratio of 1.5 + ε with an additive constant of 3, and a non-amortized migration factor of O(1/ε). 6 1 − ε 1 − ε 1 − ε . . . 1 − ε ε ε 1 − ε . . . 1 − ε opt(I1) = 3N opt(I2) = 6N Figure 1: Feasible packings of I1 and I2 The algorithm distinguishes between big, medium and small items. For each item, it calls a corresponding insertion procedure based on this classification into three classes. An item i is called big if s(i) ∈ (0.5, 1], medium if s(i) ∈ (ε, 0.5], and small otherwise. For a bin B, let small(B) be the set of small items of B. We define medium(B) and big(B) accordingly and also extend these notions to sets of bins B. Furthermore, we call a covered bin barely covered, if removing the biggest item of the smallest class of items, i. e., big, medium or small, contained in the bin, results in the bin not being covered anymore. For instance, consider a bin containing four items with sizes 0.65, 0.3, ε and 0.25ε, for ε ≥ 0.04. This bin contains items of all three classes if ε < 0.3. In this case, the biggest item of the smallest class has size ε, and if ε = 0.1, the bin is indeed barely covered. However, if ε = 0.22, the bin is not barely covered. If ε = 0.3, the bin only has items of two classes, and it is not barely covered, since removing one item of size 0.3 results in a total size above 1. Note that showing that removing an arbitrary item of the smallest class of items for a given covered bin results in an uncovered bin is sufficient for showing that it is barely covered. Let B be a barely covered bin. If B contains at most one big item, its load is bounded from above by 1.5, and if B additionally contains no medium item the bound is reduced to 1 + ε. This holds due to the following. Since the big item has size below 1, the bin contains at least one medium or small item. If the bin has no small items, removing the largest medium item reduces the load to below 1, and together with the medium item the load is below 1.5. If it has a small item, a similar calculation shows that the load is below 1 + ε. The last two types of bins are benign in the sense that they allow analysis using arguments that are based on sizes. This is not the case for bins containing two big items. Such bins could have a size arbitrarily close to 2 (even if they have no other items). Bins of this type are needed for instances with many big items (for an example we refer to the construction of the lower bound in Proposition 1). However, they cause problems not only because they are wastefully packed, but also because they exclusively contain big items that should only be moved if suitably large items arrive in order to bound migration. The basic idea of the algorithm is to balance the number of bins containing two big items and the number of bins containing one big item and no medium items. The two numbers will be roughly the same, which is obtained using migration on arrivals of big and medium 7 BB BM BSC MC SC Figure 2: Different types of bins produced by the algorithm containing big items in dark gray, medium items in light gray, and small items in white. items. As described in the previous paragraph, the guarantees of these bins that are based on loads cancel each other out in the sense that an average load not exceeding 1.5 + ε/2 can be achieved. In order to keep the number of bins with two big items in check, our algorithm will only produces very few bin types and we will maintain several invariants. This structured approach allows us also to bound the migration needed. We elaborate on the details of the algorithm. Bin Types and Invariants. We distinguish different types of bins packed by the algo- rithm. See Fig. 2 for an overview of covered bins (only). The bins are partitioned into bins containing two big items (and no other items) BB; barely covered bins containing one big item and some medium items BM; barely covered bins containing one big item and some small items BSC; bins that are not covered (partially covered) and contain one big item and no medium items (but it could contain small items) BSP; and bins that are at most barely covered (they are barely-covered, or not covered) and exclusively contain small or medium items S or M respectively. Furthermore, let MC ⊆ M and SC ⊆ S be the corresponding subsets of barely covered bins (while M \M C and S \SC are sets of bins that are not covered). We denote the (disjoint) union of BSC and BSP as BS. The set of bins packed by the algorithm (covered or not covered) is denoted as Bins. All bins covered by the algorithm are in fact barely covered, and no bin (covered or not) contains items of all three classes. Among bins that are not covered, there are no bins containing a big item and a non-empty set of medium items. We will now introduce the invariants needed. We first give a formal definition and will sometimes follow this by a mnemonic in italics to help the reader in remembering the purpose of this invariant. The first invariant the algorithm ensures that this bin structure is maintained and the second invariant was already indicated above (A ∪ B denotes the disjoint union of A and B): I1 The solution has the proposed bin type structure, i. e., Bins = BB ∪ BM ∪ BS ∪ M ∪ S, and BS = BSC ∪ BSP. I2 The sets BB and BS are balanced in size, i. e., (cid:12)(cid:12)BB − BS(cid:12)(cid:12) ≤ 1. 8 Recall that the average load of any bin of BB together with any bin of BS does not exceed 1.5 + ε/2, so by invariant I2 the average load of bins of BB ∪ BS possibly excluding one bin is not larger than 1.5 + ε/2. Therefore we have alg(I) = BB + BM + BSC + MC + SC. Furthermore, we have several invariants concerning the distribution of items to different bin types. The intuition behind these invariants is always the same: We have to ensure that no other algorithm is able to use the small and medium items to cover a much large number of bins. I3 The big items contained in BM are at least as big as the ones in BSC which in turn are at least as big as the ones in BSP, and the smallest big items are placed in BB, i. e., s(i) ≥ s(i′) for each (i) i ∈ big(BM) and i′ ∈ big(BS ∪ BB); each (ii) i ∈ big(BM ∪ BSC) and i′ ∈ big(BSP ∪ BB); each (iii) i ∈ big(BM ∪ BS) and i′ ∈ big(BB). The smallest biggest items are in BB and the largest in BM. Informally, BB ≤ BSP ≤ BSC ≤ BM. I4 The union of items in M cannot be used to cover a bin together with a big item from BS or BB, i. e., BS ∪ BB 6= ∅ =⇒ s(M) < 1 − smax(BS ∪ BB). In the case BS ∪ BB = ∅, there are no restrictions on s(M). We can not build another BM bin from M and BS∪BB. I5 If a bin containing only small items exists, all bins in BS are covered, i. e., S > 0 =⇒ BSP = 0. We do not have unnecessary S bins in the sense that if they exist, their items cannot be used elsewhere. Lastly, there are some bin types with bins that are not covered, and we have to ensure that they are not wastefully packed: I6 If there are small items in BSP, they are all included in the bin containing the biggest item in BSP. The next bin of BSP that is planned to be covered by adding small items to it is the most loaded one. I7 Each of S and M will contain at most one bin that is not covered, i. e., SC ≥ S − 1 and MC ≥ M − 1. As long as medium and small items arrive and they are packed into M and S, bins of these sets are opened one by one. This concludes the definition of all invariants. It is easy to see that the invariants all hold in the beginning when no item has arrived yet. Next, we describe the insertion procedures and argue that the invariants are maintained. In the following, we briefly discuss several examples to build intuition for Examples. the invariants. Figure 3 shows four exemplary packings. The first three are consistent with the invariants and the last one is not, and we first discuss the former three and then the latter. As indicated in the captions, only the allowed bin types (invariant I1) are present in examples 1, 2, 3; and we have BB + 1 = BS, BB = BS + 1 and BB = BS in examples 1, 2, and 3, respectively, yielding invariant I2 for the three first examples. Concerning the distribution of big items, that is, invariant I3, note that the big items get smaller when going from left to right in each of the examples which corresponds to the correct distribution. In the first two examples, there is exactly one bin in M containing only one medium item, which already gives invariant I7 with respect to M and it is easy to see that 9 BB BSP BSC BM M BS BB BS = BSC M SC S BM MC M S = SC B1 B2 B3 B4 B5 B6 B7 B8 B9 Figure 3: An exemplary packings with big items in dark gray, medium items in light gray, and small items in white. The first three examples are consistent with the invariants and the last one is not. 10 this invariant also holds for example 3. This item is relatively big in the second example, however each big item present in the solution is too small to be combined with the medium item to form a covered bin. In the first example, the big items are bigger, but the medium item is smaller, and the same holds. Hence, invariant I4 holds, and this is also the case for example 3, where each big item is contained in BM. Note that in the third example M contains multiple bins, which may only happen if BS = BB = ∅, due to invariant I4. In examples 2 and 3, we have BSP = ∅ and hence invariants I6 and I5 trivially hold. In example 1, on the other hand, there is exactly one bin in BSP containing small items, and this bin also contains a big item of maximal size among the ones in BSP, yielding I6 for this example, and we have S = ∅, yielding I5. Lastly, in each of the three examples there is at most one bin in S which is not covered, and hence invariant I7 also holds with respect to S. The last example, on the other hand, is carefully designed such that all invariants are infringed or meaningless: The two bins B5 and B8 contain both small and medium items; and bin B9 is overpacked (covered but not barely covered). Therefore invariant I1 is infringed. Furthermore, there are three bins containing one big and no medium items, but only one bin with two big items. This is in conflict to invariant I2. The two biggest big items are combined in bin B1, violating invariant I3. Moreover, the bins B6 and B7 both are not covered, and exclusively contain medium items, which could be combined with several big items to form barely covered bins. Hence, both I7 and I4 are infringed. There are two bins in BSP containing small items, infringing invariant I6; and additionally S 6= ∅, violating invariant I5. Insertion Procedures. We start with the definition of two simple auxiliary procedures used in the following: • GreedyPush(i, B) is given an item i and a set of bins B. If all the bins contained in B are covered, it creates a new bin containing item i, and otherwise it inserts i into the most loaded bin that is not covered. • GreedyPull(B, B) is given a bin B and a set of bins B. It successively removes a largest non-big item from a least loaded bin from {B′ ∈ B small(B′) ∪ medium(B′) 6= ∅} and inserts it into B. This is repeated until either B is covered or B does not contain non-big items. Consider one application of GreedyPull such that B already has a big item. The total size of moved items is smaller than 1. Both procedures are used to insert and repack non-big items. Note that calling GreedyPush for a small item and bin set BSP or S, or a medium item and bin set M, the last two invariants I6 and I7 are maintained. For BSP, the most loaded bin always contains the largest big item, and if there is at least one small item, such a bin is unique. It could happen that as a result of inserting a small item into this bin of BSP the bin is covered and moves to BSC. For each insertion procedure, we will argue that the invariants are maintained and focus on the critical ones, that is, in each context the invariants, that are not discussed explicitly, trivially hold. For example, we do not discuss I1 in the following, because it will always be easy to see that it is maintained. 11 If the arriving item i∗ is small, we call GreedyPush(i∗, BSP), Insertion of Small Items. if BSP 6= ∅, and GreedyPush(i∗, S) otherwise. Insertion into a bin of BSP (the most loaded one) may lead to a covered bin, in which case the bin becomes a bin of BSC (but remains in BS. It is easy to verify, that all invariants, and I5, I6 and I7 in particular, are maintained by this. Furthermore, there is no migration in this case. The insertion of a medium or big item, however, is more complicated. In the case that a big item i∗ arrives, we have to be careful Insertion of Big Items. where we place it exactly, because, on the one hand, the distributions of big and medium items, that is, invariants I3 and I4, have to be maintained, and, on the other hand, we have to balance out BS and BB (I2). We consider placing the item in BM, BS or BB in this order, i. e., we first try to insert i∗ into BM, then into BS and finally into BB. Figure 4 illustrates this process. • Insertion into BM. We insert i∗ into BM, if either s(i∗) + s(M) ≥ 1 or s(i∗) > smin(big(BM)). Note that the first condition implies s(i∗) ≥ smax(big(BB ∪ BS)), because of I4, and therefore the insertion of i∗ into BM maintains I3 in both situations. The second condition implies BM 6= ∅, because we set smin(∅) = +∞. In either of these cases, we create a new bin B∗ = {i∗} and call GreedyPull(B∗, M), thereby ensuring that I4 is maintained if the new bin is covered. If the first condition did hold, B∗ is covered afterwards and we do nothing else. Otherwise, there is a bin B ∈ BM containing a big item i with s(i) = smin(big(BM)) < s(i∗), and we have M = ∅. We remove i from B, yielding M = {B}, and call GreedyPull(B∗, M) a second time. Afterwards, B∗ is covered, because s(i∗) > s(i). Furthermore, s(i) + s(M) < 1, because B was barely covered before and the biggest medium item was removed from B due to the second call of GreedyPull. The item i is reinserted using a recursive call to the procedure of inserting a big item. However, item i will not be considered for insertion into BM, because neither the first nor second condition holds for this item, and the other insertion options have no recursive calls for insertion into BM. It is easy to verify that the distribution of medium items in M (I7) is maintained. • Insertion into BS. This step is possible for item i∗ that satisfies s(i∗)+s(M) < 1 and s(i∗) ≤ smin(big(BM)). Thus, BM will have the largest big items as required in Invariant I3 after the insertion is performed. In this case there is no recursive call for inserting a big item. We insert i∗ into BS, if either s(i∗) > smin(big(BS)) or the following two conditions hold: s(i∗) ≥ smax(big(BB)) and BS ≤ BB. Note that s(i∗) ≥ smax(big(BB)) trivially Inserting i∗ into BS under these conditions already ensures the holds, if BB = ∅. correct distribution of big items (I3) with respect to BS and BB, but we still have to be careful concerning the distribution within the two subsets of BS. The procedure is divided into three simple steps. As a first step, we create a new bin B∗ = {i∗} and call GreedyPull(B∗, S). No matter whether B∗ is now covered or not, Invariant I5 is satisfied as either B∗ is covered and therefore BSP = ∅ both before and after the call, or B∗ is not covered but now S = ∅ (it is possible that both will hold). Note that 12 all properties of the invariants are satisfied, if B∗ is already covered. In particular, Invariant I3 holds within BS because BSP = ∅. In the remainder of the second step of the insertion into BS algorithm we deal with the case that B∗ is not covered. Let XB denote the set of bins B ∈ BS that include small items as well as a big item i with s(i) < s(i∗). Recall that any bin of BSC has at least one small item, while at most one bin of BSP has small items. First, assume that XB = ∅ but B∗ is not covered. There are two cases. In the first case, at least one item of S was moved. In this case before we started dealing with i∗, the set BSP was empty, and now B∗ is the unique bin of BSP, and its big item is not larger than those of BSC (if the last set is not empty) so the invariants I3 and I6 are maintained. In the second case, S was empty, and B∗ is now a bin of BSP with only a big item. Since XB = ∅, adding B∗ to BSP maintains the invariants I3 and I6. Thus, it is left to deal with the case XB 6= ∅. In the remainder of the second step of the insertion into BS algorithm we deal with the case that XB is not empty. As B∗ is not yet covered, we now have S = ∅, and this might have been the case before the call of GreedyPull, in particular if we had BSP 6= ∅. Due to the existence of a big item that is smaller than i∗ in BS (such items exist in all bins of XB), we have to be careful in order to maintain the correct distribution of big and small items inside of BS (I3 and I6). In the second step, we construct a set of bins B ⊆ BS from which small items are removed in order to cover B∗. If BSP∩XB 6= ∅, this set has exactly one bin (containing small items) by Invariant I6. If such a bin exists, we denote it by B1. If BSC∩ XB 6= ∅, the set BSC includes a bin that contains a big item i′ with smin(big(BSC)) = s(i′) < s(i∗) and we denote one such bin (with a big item of minimum size in BSC) by B2. As XB 6= ∅, at least one of the bins B1 or B2 must exist, but it can also be the case that both exist. Let B be the set of cardinality 1 or 2, which contains these bins. The next operation of the second step is to call GreedyPull(B∗, B). It is easy to see that no matter whether B∗ is covered or not after this operation, the invariants I3 and I6 hold. Specifically, if B2 does not exist, B∗ is not necessarily covered, but I3 and I6 hold as all big items of BSC are not smaller than i∗ (as every such bin has at least one small item). If B2 exists, then B∗ keeps receiving items coming first from B1 and then possibly also from B2, until it is covered. As the total size of small items of B2 is sufficient for covering B∗ since the big item of B2 is smaller than i∗, B∗ will be covered, so all big items of BSP are not larger than i∗. Lastly, we describe the third step, which is performed for all cases above, after i∗ has been inserted. The insertion of i∗ might have violated I2, that is, we now have BS = BB + 2. In this case, we perform the last step, namely, we select two bins B3, B4 ∈ BS with minimal big items, merge the big items into a BB bin and remove and reinsert all small items from B3 and B4, using insertion of small items. This yields, BS = BB − 1 and I2 holds. • Insertion into BB. If i∗ was not inserted in any of the last steps, it is inserted into BB. In this case, we know from the conditions above that s(i∗) ≤ smin(big(BS ∪ BM)), and additionally that s(i∗) ≥ smax(big(BB)) implies BS = BB + 1. We consider two cases. 13 If BS = BB + 1 (and hence BS 6= ∅), we select a bin B ∈ BS with a big item of minimal size. We insert i∗ into B to obtain a BB bin and remove and reinsert all small items from B. This yields BS = BB − 1 and I2 holds. If BS < BB + 1, we have s(i∗) < smax(big(BB)) (and hence BB 6= ∅). In this case, we select a bin B ∈ BB with a big item i of maximal size, insert i∗ into B, and remove and reinsert i. Because of its size and invariant I4, the item i will be inserted into BS. Note that in both cases invariant I3 is maintained. (a) Insert into BM: open a new bin B∗ for i∗; pull M into B∗; pull from bin B ∈ BM containing the smallest big item i; remove and reinsert i. i∗ B∗ M i B i∗ B∗ B insert(i) (b) Insert into BS: open a new bin B∗ for i∗; pull S into B∗; pull from bin B ∈ BS containing the smallest big item i. i∗ B∗ i B2 S i∗ B∗ i B2 Figure 4: Insertion of a big item i∗. Big items are drawn in dark gray, medium items in light gray, and small items in white. Lemma 3. The overall size of items migrated due to the insertion of a big item i∗ is upper bounded by 11. Proof. First, note that an insertion into BS can not trigger the reinsertion of a big item. The insertion into BB can only trigger the reinsertion of a single big item into BS and the insertion into BM can only trigger the reinsertion into BB or BS. Hence, each insertion of a big item can trigger at most two other insertions of big items in total and thus only move a total size of 2 this way. Concerning the direct reassignments: • If i∗ is inserted into BM, this may directly cause reassignments of items with size at most 3: there may be two calls of GreedyPull in each of which items with overall size at most 1 may be moved and additionally a big item with size at most 1 may be moved. • If i∗ is inserted into BS, the corresponding bound is 5: there may be two calls of GreedyPull in both of which items with overall size at most 1 may be moved and additionally a big item with size at most 1 and small items with overall size at most 2 may be moved. 14 • If i∗ is inserted into BB, the corresponding bound is 1: either small items with overall size at most 1 or a big item are moved. Hence, the total size of items migrated is at most 2 + 3 + 5 + 1 = 11. If a medium item i∗ arrives, GreedyPush(i∗, M) is called. Insertion of Medium Items. Afterwards, the invariant I4 may be infringed and if this happens, we have BS ∪ BB 6= ∅ and s(M) ≥ 1 − smax(BS ∪ BB), and we continue as follows. We will now describe how to pack a barely covered bin using the items from M and a largest big item from BS ∪ BB to maintain I4 again. If BS = ∅, I2 implies that BB contains a single bin B including two items i and i′ with smax(BS ∪ BB) = s(i) ≥ s(i′). We remove i′ from B, and call GreedyPull(B, M) to create a BM bin. Afterwards, s(M) and smax(BS ∪ BB) are at most as big as they were before i∗ arrived as the first item we pulled from M is at least as big as i∗, and therefore I4 holds. Furthermore BS = BB = ∅ and I2 still holds. Lastly, we reinsert the big item i′. If, on the other hand, BS 6= ∅, the corresponding big item i with smax(BS ∪ BB) = s(i) is contained in a bin B ∈ BS, because of I3. In this case, we remove the small items from B and call GreedyPull(B, M). Afterwards I4 holds, but I2 may be infringed due to the removal of a bin from BS, i. e., BB = BS + 2. In this case, we remove the two biggest items i1 and i2 from the bins B1, B2 ∈ BB and if B1 6= B2 merge the two bins. This yields BB = BS + 1 and I2 holds. Afterwards, we reinsert the two items i1 and i2, which both will be inserted in BS due to their sizes. No matter whether we had to rebalance BB and BS or not, we reinsert the removed small items from B as a last step. Figure 5 contains an illustration of this process. i′ 1 i1 B1 i′ 2 i′ 1 j3 j2 j1 j0 i B M i∗ M i∗ i B i′ 2 i2 B2 insert(i1, i2, j0, . . . , j3) Figure 5: Insertion of a medium item i∗: push i∗ into M; remove small items j0, . . . , j3 from bin B ∈ BS containing the largest big i; pull from M into B; merge BB bins B1 and B2 containing the largest big items i1, i2; reinsert remaining items i1, i2, j0, . . . , j3. Big items are drawn in dark gray, medium items in light gray, and small items in white. 15 Lemma 4. The overall size of items migrated due to the insertion of a medium item i∗ is upper bounded by 27. Proof. In the first case, one big item is reinserted, resulting in the migration of items with size at most 1 + 11 = 12 (see Lemma 3). Furthermore, there is one call of GreedyPull moving items with overall size at most 1. This yields a size of at most 13. In the second case, medium items with size at most 1 are moved using GreedyPull and small items with overall size at most 1 are moved in the last step. Furthermore, three big items may be moved and two of them may be reinserted, causing total migration of size at most 1 + 1 + 3 + 2 · 11 = 27. Hence, the overall size of migrated items is upper bounded by 27. Analysis. The migration bound stated in Theorem 2 or more precisely 27 is already ε implied by Lemma 3 and Lemma 4, as a medium item has size above ε. Furthermore, it is easy to see that: Remark 5. The presented algorithm for static online bin covering has a polynomial running time. Hence, the only thing left to show is the stated asymptotic competitive ratio: Lemma 6. The presented algorithm has an asymptotic competitive ratio of 1.5 + ε with an additive constant of 3. Proof. First, we consider the case BSP = ∅ (see Figure 3, second and third). In this case, the claim holds because the bins on average have not too much excess size. More precisely, we obviously have opt(I) ≤ s(I), and invariants I1 and I7 imply: s(I) < 2BB + (1 + ε)BS + 1.5BM + 1.5MC + (1 + ε)SC + 2 Furthermore, we have 0.5BB ≤ 0.5(BS + 1), due to Invariant I2, and BS = BSC, as BSP = ∅ holds in the case we are currently considering. Hence: opt(I) < (1.5 + ε)(BB + BSC + BM + MC + SC) + 2.5 < (1.5 + ε) alg(I) + 3. A similar argument holds, if BSP 6= ∅ but BB = ∅. In this case, we have BSP = 1, because of invariant I2 and thus BS = BSP; and S = ∅, because of Invariant I5. Hence: opt(I) ≤ s(I) < 1.5BM + 1.5MC + 2 = 1.5 alg(I) + 2. Next, we consider the case BSP 6= ∅ and BB 6= ∅ (see Figure 3, first example). In this case, we have MC = ∅, because of Invariant I4, and S = ∅, because of Invariant I5. Note that every bin of BSC ∪ BM has at least one item that is not big, since big items have sizes below 1, and these bins are covered. Let ξ = smax(BSP) be the size of a big item from BSP with maximal size. Then all items in BB ∪ BSP are upper bounded in size by ξ (I3) and ξ > 0.5. We construct a modified instance I ∗ as follows: 1. The size of each big item with size below ξ is increased to ξ. 16 2. Every big item of size larger than ξ is split into a big item of size ξ and a medium or small item, such that the total size of these two items is equal to the size of the original item. Let X be the set of items with sizes of ξ, which we will call ξ-items in the instance after these transformations (X includes also items whose sizes were ξ in I). 3. For each bin from BSC ∪ BM, select the largest item of I that is not big and call it special. By increasing item sizes if necessary, change the sizes of all special items to 0.5. Let Y be the set of special items (whose sizes are now all equal to 0.5). Let Z be the set of the remaining items not belonging to X or Y (in the instance I ∗ after the transformations, so there maybe be items that did not exist in I resulting from splitting a big item). The set of items in I ∗ is just X ∪ Y ∪ Z. For the instance I ∗, any bin of BB contains two items of X (and no other items). Any bin of BSP has an item of X, and one of these bins may also have small items of Z, but it is not covered. Any bin of BSC ∪ BM has one item of X, one item of Y , and possibly items of Z. There may be one uncovered bin of M, containing items of Z. Note that opt(I) ≤ opt(I ∗), since any packing for I can be used as a packing for I ∗ with at least the same number of covered bins. Next, we investigate the relationship between opt(I ∗) and the packing of the algorithm for the original instance I. For some optimal solution for I ∗ without overpacked bins (more than barely covered), let k2, k1 and k0 be the sets of covered bins with 2, 1 and 0 items from X ∪ Y , respectively. Then we have opt(I ∗) = k2 + k1 + k0 and due to counting: 2k2 + k1 = X ∪ Y = (2BB + BS + BM) + (BM + BSC). Since each item in X ∪ Y is upper bounded by ξ, we have: (1 − ξ)k1 + k0 ≤ s(Z). The total size of items (of Z only) packed into the bin of M is below 1 − ξ since BSP has a big item of size ξ in I, by Invariant I4, since every item of BS ∪ BB is smaller than 1 − s(M ). For BSP only one bin may contain items of Z by Invariant I6, and this bin has an item of size ξ in I (and it is not covered), so it also has items of Z of total size below 1 − ξ. Consider a bin of BSC ∪ BM. The total size of items excluding the special item is the same for I and I ∗. Since such a bin is barely covered and for I it has items of one class except for the big item (small or medium), removing the special item results in a load below 1. The total size of items of I ∗ in such a bin excluding the ξ-item and the special item is below 1 − ξ. Therefore, we find that s(Z) ≤ (1 − ξ)(BM + BSC + 2). 17 Hence: 2 opt(I) ≤ 2(k2 + k1 + k0) ≤ (2k2 + k1) + (k1 + (1 − ξ)−1k0) ≤ (2BB + BS + BM + BM + BSC) + (BM + BSC + 2) ≤ 3BB + 3BM + 2BSC + 3 ≤ 3 alg(I) + 3. In the second to last step, we again used invariant I2. 18 3 Non-amortized Migration in the Dynamic Case In this section we extend the result of the static case and show: Theorem 7. For each 0 < ε < 1 with 1/ε ∈ Z, there is an algorithm alg for dynamic online bin covering with polynomial running time, an asymptotic competitive ratio of 1.5+ε with additive constant O(log 1/ε), and a non-amortized migration factor of O( log2(1/ε) ). ε5 It is not too hard to see that the insertion procedures for Motivation and Discussion. big and medium items designed for the static case can be reversed in order to deal with departures of such items. However, small items never cause migration in the static case algorithm and borrowing this approach in the dynamic case causes immediate problems: Let N be some positive integer. Consider the case that N 2 items of size 1/N arrived and were placed into N bins, covering each of them perfectly. Next, one item from each bin leaves yielding a solution without any covered bin while the optimum number of covered bins is N − 1. Hence, a migration strategy for arbitrarily small items is needed in order to design a competitive algorithm. Now, coming up with a migration strategy to deal with the present example is rather simple, since all the items are of the same size, but in principle small items may differ in size by arbitrary multiplicative factors. That is, it is possible that when a new small item which is relatively small arrives, some of the existing small items cannot be migrated at all. Still, the case with only small items can be dealt with comparatively easily by adapting a technique that was developed for dynamic online bin packing with migration [3]. The basic idea is to sort the items non-increasingly and maintain a packing that corresponds to a partition of this sequence into barely covered bins. If an item arrives, it is inserted into the correct bin and excess items are pushed to the right, that is, to the neighboring bin containing the next items in the ordering, and this process is repeated until the packing is restored. Correspondingly, if an item departs, items are pulled in from the next bin to the right. In this process the arrival or departure of a small item can only cause movements of items that are at most as big as the original one. While this is a useful property, it obviously does not suffice to bound migration: Too many bins have to be repacked. In order to deal with this, the bins are partitioned into chains of appropriate constant length with a buffer bin at the end, which is used to interrupt the migration process. This technique is sufficient for the set of bins S containing only small items. The small items are also placed together with big items in the bins of BS and in principle the same problem can occur here: Few items with very small overall size can leave many bins uncovered when leaving and hence we need a migration strategy and additional structure for these bins as well. Unfortunately, a straight-forward combination of the chain approach with bins containing big items fails. The main reason for this is that in order to adapt our analysis, we need to cover the bins in BS containing larger big items with higher priority and furthermore guarantee that there are no (or only few) bins contained in S if there are bins containing big items that are not covered, i. e., BSP 6= ∅. It is not hard to see that spreading one sequence of chains out over the bins of BS and S will not suffice. To overcome these problems, we developed a new technique: We partition the bins of BS into few, that is, O(log 1/ε) many, groups. Each of the groups is in turn partitioned 19 into parallel chains of length O(1/ε). The groups are defined such that they comply with a non-increasing ordering of both the big and the small items: the first group contains the largest big and small items, the next group the remaining largest, and so on. Similarly, the big or small items contained in a bin of a single parallel chain are at most as big as the ones in the predecessor bin of that chain. However, no such structure is maintained in between the parallel chains of the same group. Now, whenever a buffer bin of a parallel chain becomes empty or overfilled, items are pushed or pulled directly into or out of the next group. This may spark a recursive reaction, but since there are only few groups overall the total migration can be bounded. Furthermore, we are able to guarantee (i) that there is at most one group G containing uncovered bins, and that all groups before are covered. Finally, if S 6= ∅, we can guarantee (ii) that all bins of BS are barely covered. Properties (i) and (ii) are the essential properties we need in order to adapt our approach to the dynamic case. The buffer bins of the parallel chains act as the interface between one group and another, and therefore have a special role in this construction. We require that the buffer bins of the same group have some special properties, e. g., that they can exchange items among each other without migration cost. To guarantee these properties, we simulate the buffer bins of chains belonging to a fixed group using one group buffer bin. Hence, all chains within the same group share the same buffer bin. Because of their special role in the procedure, these group buffer bins are considered as a separate class, denoted by GB. These bins exclusively contain small items but may be overpacked, that is, unlike any other bin in the construction they may be covered but not barely covered. To avoid confusion, we slightly alter the definition of S, excluding the group buffer bins regardless of whether they are at most barely covered or not. Furthermore, we require the bins of BSC to comply with a more restricted notion of being barely covered: bins of this type need to be well-covered. A bin B is called well-covered, if it is barely covered and additionally has the following property: If smax(big(B)) + smax(B \ big(B)) ≥ 1, then B ≤ 2. In particular, consider the situation that B contains one big item and more than one small item. As B is barely covered, removing the largest small item from B makes it not covered. But B is also well-covered, hence removing all of the small items but the largest one will also leave B not covered. We call a bin B more than well-covered, if one can remove a subset of items in B to make B well-covered and at most well-covered, if one can add a (possibly empty) set of items to B to make it well-covered. In the following, we will describe in detail the additional structure The Algorithm. needed to deal with the small items along with the insertion procedures for small items. We first describe the chain structure used for S and then the group structure used for BS. Next, we discuss the insertion and deletion procedures of medium and big items. The main challenge here is to properly deal with the insertion and deletion of big items in BS, because these can interfere with the group structure. Lastly, we will argue that the migration, competitive ratio and running time of the overall algorithm is properly bounded. In order to do so we will, in the course of this section, again introduce invariants and argue that they are maintained by the algorithm. Indeed, some of the invariants can be transferred directly or with only small changes from the static case: I1 The solution has the proposed bin type structure, i. e., Bins = BB ∪ BM ∪ BS ∪ M ∪ S ∪ GB 20 and BS = BSC ∪ BSP. I2 The sets BB and BS are balanced in size, i. e., (cid:12)(cid:12)BB − BS(cid:12)(cid:12) ≤ 1. I3 The big items contained in BM are at least as big as the ones in BS which in turn are at least as big as the ones in BB, i. e., s(i) ≥ s(i′) for each i ∈ big(BM) and i′ ∈ big(BS ∪ BB); or i ∈ big(BM ∪ BS) and i′ ∈ big(BB). I4 The items in M cannot be used to cover a bin together with a big item from BS or BB, i. e., BS ∪ BB 6= ∅ =⇒ s(M) < 1 − smax(BS ∪ BB). I5 If there is a bin which only contains small items and is not a group buffer bin, then all bins in BS are covered, i. e., S > 0 =⇒ BSP = 0. I6 The set M contains at most one bin that is not covered. In the following, we slightly change our notions of bins, that is, we allow empty bins. Until now, we assumed that a bin ceases to exist as soon as it becomes empty. In the following, however, there are some situations in which empty bins are maintained by the algorithm. This will be made clear in each case. Furthermore, without loss of generality we assume that 1/ε is an integer. 3.1 Chains Preliminaries. We formally define a chain as a totally ordered finite set of bins, where each bin contains at most one big item and no medium items, such that the following conditions are fulfilled. The ordering of the chain C is consistent with a non-increasing ordering of the small items contained in C, that is, for bins B, B′ ∈ C and small items i ∈ B and i′ ∈ B′, we have s(i) ≥ s(i′), if B precedes B′ in C. Furthermore, the corresponding condition for big items holds as well, and if there is a bin B in C containing no big item, then the successors of B contain no big items as well. Let C be a chain, B ∈ C, and X a set of small items. We say that X is eligible for C and B, if C remains a chain after X is inserted into B. Furthermore, we denote the j-th bin in the ordering of C as B(C, j). We define two basic operations on chains, which are recursive procedures. Intuitively, ChainPush(X, B) puts a set of small items X into bin B and pushes the now superfluous small items to the next bin. In contrast, ChainPull(B) pulls small items from these next bins to cover B. More formally, these operations behave as follows: • ChainPush(X, B, C) is given a chain C, a bin B ∈ C, and a set X of small items eligible for C and B. The set of items X is inserted into B. If B is now overpacked, that is, more than well-covered, we repeatedly remove a smallest small item from B until B is well-covered and call the set of removed items X ′. If B is the last bin in the chain, the set X ′ is returned. Otherwise there is a successor B′ of B and ChainPush(X ′, B′, C) is called. • ChainPull(B, C) is given a chain C and a bin B ∈ C. If B is not covered and not the last bin in the chain, we repeatedly move the biggest small item from B′ to B, where B′ is the successor of B in C, until either B becomes well-covered or B′ does not contain small items anymore. Afterwards ChainPull(B′, C) is called. 21 Remember that a bin B is called well-covered, if it is barely covered and additionally we have that smax(big(B)) + smax(B \ big(B)) ≥ 1 implies B ≤ 2. Note that in both procedures the inputs of the recursive calls are legal, e.g., when ChainPush(X ′, B′, C) or ChainPull(B′, C) are called, C is still a chain, B′ ∈ C, and X ′ is eligible for C and B′. This immediately yields: Remark 8. After a call of ChainPush(X, B, C) or ChainPull(B, C), the set C remains a chain. If Y is the set of items moved away from a bin B due to a call of ChainPush, we say that Y was pushed out of B and moreover, if Y is pushed out of the last bin of the chain, we say that it was pushed out of the chain. Correspondingly, if Y was moved away from a bin B due to a call of ChainPull, we say that Y was pulled out of B. Our next goal is to formulate and prove some easy technical results concerning these operations. These results will be among the main tools for bounding the migration due to the small items. We consider ChainPush first and ChainPull second. Lemma 9. Let C be a chain, B ∈ C be at most well-covered, and X be a set of small items eligible for C and B such that X ∪ big(B) forms a bin that is at most well-covered. Furthermore, assume that smin(X) ≥ smax(small(B)) or X = 1. Finally, let Y 6= ∅ be the set of items that are pushed out of B, due to a call of ChainPush(X, B, C). Then B is well-covered after the call and we have: 1. Y ∪ big(B) forms a bin that is at most well-covered. 2. smax(X) ≥ smax(Y ). 3. s(Y ) ≤ s(X) + smax(X). 4. If B has a direct successor B′ in C, then Y is eligible for C and B′ and smin(Y ) ≥ smax(small(B′)) (before the recursive call of ChainPush(Y, B′, C)). Proof. Note that B is well-covered, as Y 6= ∅. We now distinguish two cases, namely smin(X) ≥ smax(small(B)) and smin(X) < smax(small(B)). In the first case, note that no item belonging to X will be pushed out of B, or, more precisely: if Y ′ is the subset of X that is pushed out, there is a set Z of items remaining in B that does not belong to X and that is equivalent to Y ′ in the sense that there exists a bijection between the two, mapping items of equal size onto each other. Therefore, Y ∪ big(B) is at most well-covered, because B was at most well-covered. In the second case, we have smin(X) < smax(small(B)) and hence X = 1 by assumption. Let X = {i∗}. Note that the items that are pushed out of B each have size at most s(i∗), and there can be at most one item with size s(i∗) in Y because B was at most well-covered before i∗ was inserted. Hence Y ∪ big(B) is at most well-covered, because replacing the item with size s(i∗) from Y -- if it exists -- with the biggest item from small(B), yields a set of items completely contained in B before the call to ChainPush. The above considerations also show smax(X) ≥ smax(Y ). Since B was at most well-covered, removing the smallest items from B with overall size s(X) after X was inserted will suffice to make it at most well-covered again. The exact value s(X) may not be met and therefore one extra item may be needed whose size is bounded by smax(X), due to the already established property that smax(X) ≥ smax(Y ). Note that these considerations also hold, if B was well-covered with only one small item, or X = 1 and X ∪ big(B) is well-covered. This implies the third point and the fourth holds, because the smallest items are pushed out of B and C is a chain. 22 Lemma 10. Let C be a chain, B ∈ C a bin that is not covered and not the last bin in C, and B′ its successor. Furthermore, let Y be the set of items that are pulled out of B′ due to a call of ChainPull(B, C). We have: 1. Y ⊆ small(B). 2. B is well-covered after the call, if B′ was well-covered. 3. s(Y ) ≤ (1 − s(B)) + smax(small(B′)). Proof. The first assertion follows directly from the definition of ChainPull. Note that small(B′) ∪ big(B) forms a covered bin due to the definition of chains, if B′ was well- covered. This together with the definition of ChainPull implies the second assertion and this also holds if small(B′) = 1. Furthermore, it suffices to pull items with size (1 − s(B)) out of B′ in order to cover B. However, the exact value (1 − s(B)) may not be met and therefore one extra item may be needed whose size is bounded by smax(small(B′)) and this proves the last claim. Sequential Chains. We maintain a partition of S into sequential chains SCh1, . . . , SChC with SChc ∈ [(1/ε + 1), (2/ε + 1)] for c < C and SChC ≤ 2/ε + 2. Herein, the exact value of C depends on the instance. The last bin of each chain is its buffer bin. See Figure 6 for an illustration. Figure 6: Sketch of a sequential chain decomposition. Buffer bins are hatched. We require that all bins that are not buffer bins are well-covered. Buffer bins, on the other hand, are non-empty and at most well-covered. The set of buffer bins is denoted by SB. These properties are summarized in the following invariant: I7 S has the described chain structure, in particular, S \ SC ⊆ SB and SB ≤ εSC + 1. The distribution of small items in S is already limited by our definition of chains. However, we will require an even stronger property such that all of the orderings of the small items are consistent with each other: I8 The non-increasing ordering of the small items in S by size is consistent with both the ordering of the chains and their internal ordering. More precisely, due to this invariant for each item i ∈ B(SChc, j) and i′ ∈ B(SChc′, j′), we have s(i) ≥ s(i′), if (c, j) is lexicographically smaller than (c′, j′). We next describe the insertion and deletion of a small item i∗ into S maintaining these invariants. Insertion. We describe the insertion of a set of small items X into S in two insertion scenarios: In scenario 1, a new item i∗ was inserted into the instance, that is, X = {i∗}, and in scenario 2, a set of items X with s(X) ≤ 1 and smin(X) ≥ smax(S) was moved from BS to S. In both scenarios, we treat the case S = ∅ as if there was exactly one chain with one bin, which is empty. In scenario 1, we select the first bin B (with respect to 23 the ordering of the chains and their internal ordering) containing items that are smaller than i∗, or the last bin if no such bin exists. Let C be the chain B is contained in. In scenario 2, C is the first chain and B its first bin. In both cases, we call ChainPush(X, B, C). Due to the choice of B, Remark 8 and a simple inductive application of Lemma 9, we can conclude that the ordering of the small items is maintained (invariant I8) and each non- buffer bin in C remains well-covered (I7). Let Y be the set of items that are pushed out of C. If Y 6= ∅, we know that the buffer bin B′ of C is now well-covered, due to Lemma 9, and furthermore Y forms a bin that is at most well-covered, again due to Lemma 9. Hence, we turn the buffer bin into a regular bin and declare Y the new buffer bin of C. If C now has length 2/ε + 2, we split it evenly into two chains each of which contains 1 ε + 1 bins and declare the last bin of the first chain its buffer bin. This yields two chains with length 1/ε + 1, thereby maintaining invariant I7. An example of this insertion is illustrated in Figure 7. X B X B Y . . . . . . B′ B′ Y Figure 7: Insertion of a set of small items X. The current buffer bin is drawn hatched. The set Y is pushed out of the chain and put into a new buffer bin. Remark 11. The overall size of migrated items due to the insertion of X into S is at most O(1/ε2)s(X), and therefore O(1/ε2)s(i∗) in scenario 1. Proof. Let Xk be the k-th set pushed out of a bin due to the call of ChainPush. A simple inductive application of assertions (2) and (3) of Lemma 9 yields that s(Xk) ≤ s(X) + ksmax(X) ≤ (k + 1)s(X). There are at most 2/ε + 2 bins in the chain, and hence the overall size of migrated items is at most (2/ε + 2)(2/ε + 2)s(X) = O(1/ε2)s(X). Deletion. Next, we consider the case that i∗ is deleted from a bin B belonging to chain C (that is a part of S). If B is still well-covered or a buffer bin, we do nothing. Hence, we design a procedure to deal with the case that a non-buffer bin B has become not covered. Similar to the insertion case, this procedure will work regardless of whether B is not covered because i∗ was deleted, or because some set of small items has been removed from B to be placed in another group of bins. We call ChainPull(B, C). Since the invariants I7 and I8 did hold before and due to Remark 8 and a simple inductive application of Lemma 10, we know that the ordering of the small items is maintained (invariant I8) and each 24 non-buffer bin in C except for the bin B∗ directly preceding the buffer remains well-covered. If B∗ is well-covered as well, the chain structure (invariant I7) is maintained, and we do nothing else. Otherwise, the old buffer bin of C is deleted and B∗ becomes the new buffer bin, which is not a problem, if C ≥ 1/ε + 1 or C is the last chain. Hence, we consider the case that C = 1/ε and there is a direct successor chain C′ of C. If C′ > 1/ε + 1 the first bin of C′ is removed from this chain and declared the new buffer bin of C, and otherwise C and C′ are concatenated and we call the resulting chain again C. In both cases, we call ChainPull(B∗, C), and the invariants I8 and I7 hold afterwards (and this call to ChainPull will not result in the need to concatenate two chains). Remark 12. The overall size of migrated items is at most O(1/ε)(1 − s(B)) + O(1/ε2)ψ, where ψ is the maximum size of a small item in any bin succeeding B. In particular, if i∗ was deleted from B this amounts to O(1/ε2)s(i∗). Proof. Let Xk be the k-th set pulled out of a bin due to one of the at most two calls of ChainPull. Note that there can be at most 2/ε + 1 such bins. A simple inductive application of assertion (3) of Lemma 10 yields that s(Xk) ≤ (1 − s(B)) + ksmax(B′). In the case that an item i∗ was deleted from B, we additionally have (1 − s(B)) ≤ s(i∗) and smax(B′) ≤ s(i∗). 3.2 Groups We maintain a partition of BS into groups Gr1, . . . , GrG with Grg = 2g−1⌈εBS⌉ for g < G and GrG ≤ 2G−1⌈εBS⌉. Note that Grg ≤ ⌈εBS⌉ + Pg−1 g′=1 Grg′ for each g ∈ [G] and G ≤ log(1/ε) + 2. These properties are summarized in the following invariant: I9 BS has the described group structure. Furthermore, it will be useful in the following to consider the bins S containing exclusively small items as the last group, that is, S = GrG+1. Each group Grg, for g ≤ G, is in turn partitioned into Cg = ⌈εGrg⌉ sets such that each of these sets has cardinality 1/ε except for the last which may be smaller. For each of these sets there is a buffer bin and the set of these buffer bins is called BGrg. As mentioned above, these buffer bins have a special role that will be described in more detail below. The sets together with their buffer bins form parallel chains, and since all the bins of such a chain are contained in the corresponding group, we sometimes say that the parallel chains are contained in or part of their respective group. See Figure 8 for an illustration. Figure 8: Sketch of a parallel chain decomposition. Buffer bins are hatched. Each bin in a parallel chain is at most well-covered. The well-covered bins are all placed in a sequence at the start of the chain, and there can be at most one bin of the chain 25 containing small items that is not covered, and this bin is positioned directly following the last well-covered bin of the chain. Note that this implies {B ∈ Sg∈[G] BGrg small(B) 6= ∅} ≤ εBSC + G. Again, we summarize: I10 Each group has the described internal parallel chain structure. Note that due to the definition of chains, the above invariant also restricts the internal distribution of big and small items in each group. With the next two invariants, we control the distribution of big and small items between the different groups. I11 The ordering of the groups (including S = GrG+1) is consistent with a non-increasing ordering of both the big and the small items. I12 There is a group-index g∗ ∈ [G + 1] such that each bin in each group preceding Grg∗ is well-covered and each succeeding group does not contain small items. Small items will always be used to create well-covered bins. More precisely, the former invariant together with I10 yields the following. Let i ∈ B(C, j) and i′ ∈ B(C′, j′), where C and C′ are (parallel or sequential) chains belonging to group Grg and Grg′ respectively and i, i′ belong to a common class (either both are big or both are small). Then g < g′, implies s(i) ≥ s(i′) and the same holds, if C = C′ and j < j′. Furthermore, due to the latter invariant, in some sense, there is always exactly one group being filled with or emptied of small items (i. e., the group of index g∗ of invariant I12). Next, we discuss the buffer bins of parallel chains in more detail. If we can always maintain the group structure and the chain Group Buffer Bins. structures described above, we are able to guarantee an asymptotic competitive ratio of 3/2 + ε. Unfortunately, maintaining this structure will be rather complicated. Firstly, the buffer bins of parallel chains behave very different from other bins. In order to have a notion of well-covered buffer bins, we assume that the buffer bin of each parallel chain contains a virtual big item that is of the same size as the big item in the second to last bin of the chain. This virtual big item will only be used in the theoretical analysis. Furthermore, in a parallel chain setting, each chain by itself is ordered with regards to the small and big items. But the distribution of item sizes of chains within the same group might be very complicated. For example, we might want to add a small item into a chain C1 in group Grg. This will trigger a push of small items along this chain and might remove some small items Y from the buffer bin of C1. The natural approach would be to try to insert these items into the subsequent group Grg+1, but there might be another chain C2 in group Grg that contains items smaller than those in Y . Hence, we first would need to insert the items of Y into C2, triggering even more repacking. To prevent this cascade of repacking, we observe that the smallest small items in Grg must be contained in the buffer bins. Now, if we push small items along C1, we will first rearrange the small items in the buffer bins such that the buffer bin of C1 contains only the smallest items. In this way, we can indeed push the removed items Y to Grg+1. To simplify this rearrangement of small items in buffer bins, we will make the following two assumptions that may seem counter-intuitive at first glance: Firstly, the buffer bins of the same group are allowed to exchange items without migration costs; and secondly, items may be split between buffer 26 bins of the same group, with part of an item placed in one buffer bin and the other part in another. We justify these assumptions as well as the virtual big items, by simulating these bins using one group buffer bin for each group Grg (as indicated in Figure 8). All the small items from the buffer bins of Grg are in fact placed in the group buffer bin of g and the buffer bins of the chains are only virtually maintained by the algorithm. Clearly, splitting items and moving them without cost does not pose a problem anymore, as all of these items are placed on the same bin and do not leave it. The set of group buffer bins is denoted by GB. Note that we do neither consider the (virtual) buffer bins of the parallel chains to be a part of BS, nor the actual group buffer bins to be a part of S. Let B be the buffer bin of a parallel chain C. If an item is placed fractionally in B this item is at most as big as any other item placed in a preceding bin of the chain. Furthermore, if B contains small item pieces, we guarantee that there is a small item i fully contained in B with the property that i is at least as big as any other small item for which item pieces are placed in B. Due to this property, the definition of well-covered can be extended to the buffer bins quite naturally: the bin B is called well-covered, if (i) it is covered, if (ii) the small item pieces together with the virtual big item but excluding i, cannot cover a bin where i is a largest small item fully contained in B, and if (iii) the virtual big item and i together can cover a bin, then there is no other small item piece placed in B. I13 The buffer bins of each group and the corresponding group buffer bin have the described structure. If ChainPush is called on the parallel chain C, fractional item pieces may be pushed out of C. When this case occurs, we will carefully redistribute the item pieces in the buffer bins of the group, or remove the full item from the group. The operation ChainPull, on the other hand, could pull fractional items further into the chain and we would like to avoid that also. However, as described above, we guarantee that the biggest small item in the buffer bin B is fully placed in it. Hence, it should be pulled first. Afterwards, if B still contains small item pieces, we simply choose a small item i′ with maximal size that is at least fractionally placed on B, and pull all pieces of i′ onto B. Since we only move item pieces from other buffer bins of the group, no additional migration costs occur. Insertion. When a small item i∗ arrives, we have to be careful to maintain the described structure when inserting it. In particular, we have to maintain the parallel chain structure in each group (invariant I10) and the correct distribution of small items (I11 and I12). For the group structure (I9) and the other invariants, it will be easy to see that they are maintained. The first step is to choose the appropriate group Grg depending on the size of i∗ and with respect to the correct distribution of the small items (I11 and I12). More precisely, Grg is either (i) the first group containing an item that is smaller than i∗ if such a group exists; or (ii) the last group containing small items, if that group is the last group or contains a bin that is not covered; or (iii) the group directly after the last group containing small items, otherwise. Instead of describing the insertion of i∗ into Grg, we take a slightly more general approach and consider two scenarios, where a set X of small items has to be inserted 27 into Grg, similar to the insertion into S. We do so, because the insertion procedure works recursively. In scenario 1 we have X = {i∗}, and in scenario 2 all items in X are at least as big as any small item in Grg, and adding a big item from Grg to X forms a bin that is at most well covered. For the case g = G + 1 we already discussed the same scenarios and refer to the section on sequential chains. Hence we assume g < G + 1. We distinguish two cases in the following depending on the existence of bins without any small items. If Grg contains a chain C that includes a bin without any small item, the procedure is rather easy: we choose an appropriate bin B with respect to the parallel chain structure (I10 and I12). More precisely, in scenario 1, we choose the first bin containing an item that is smaller than i∗ if such a bin exists; and otherwise the first bin that is not covered and is either the first bin of the chain or has a well-covered predecessor. In scenario 2, we simply pick the first bin of the chain. We perform ChainPush(X, B, C). Remark 8 and an easy inductive application of Lemma 9 yield that no items are pushed out of C and all invariants are maintained. On the other hand, if each bin in Grg contains small items, only the buffer bins may not be covered. This complicates the maintenance of our invariants. We pick a chain C with the property that the size of a largest small item contained in its buffer bin is minimal. This chain has the property that each small item placed in its buffer bin could also be placed in any other buffer bin of the group without violation of the ordering of small items in the chain (I10). Again, we choose an appropriate bin B with respect to the parallel chain structure, that is, the first bin in scenario 2, or in scenario 1 the first bin containing an item that is smaller than i∗ if such a bin exists, or the last bin of the chain. We call ChainPush(X, B, C) and denote the set of items pushed out of C as Y . If Y = ∅, the insertion procedure is now complete and all invariants hold (see above). Hence, we consider the case Y 6= ∅. Note that Y may contain the biggest small item previously placed in the buffer bin of C. However, in this case all items now contained in the buffer bin are not fractional and hence, the new biggest item is neither. In any case, invariant I13 is maintained. Ideally, we would like to simply insert Y into the next group Grg+1, but the structure of Y might be unsuited to do so without violating our invariants. We will thus construct a more suitable set Z from Y and BGrg and insert this set into Grg+1. The remaining items Y ′ = Y \ Z will be placed on the buffer bins of Grg. More formally, let Z ⊆ small(BGrg ∪ Y ) be a set of small items constructed greedily by choosing the smallest available item and putting it into Z until s(Z) ≥ s(Y ). Ties are broken in favor of items (fractionally) contained in Y . Clearly, we have s(Z) − smax(Z) < s(Y ) and smax(Z) ≤ smin(Y \ Z). We remove all items or item pieces belonging to Z from Y and Grg and define Y ′ = Y \ Z. Note, that in this process of creating Z, no buffer bin can become empty, because no item that is the biggest small item of a buffer bin can be included in Z due to the choice of chain C. Hence, invariant I13 is maintained. Next, we place the items and item pieces from Y ′ onto buffer bins of Grg: If a piece of an item i ∈ Z was previously placed on a buffer bin B, we can imagine that removing it left a gap. As s(Z) ≥ s(Y ), the space s(Z ∩ BGrg) freed up by constructing Z is at least s(Y ′). Hence, we can place the items from Y ′ fractionally into these gaps. Note that at this point all invariants hold and Z contains items that are appropriate for the insertion in Grg+1 with respect to the distribution of small items in the groups (invariant I11). As a last step, we split Z into two sets Z1 and Z2 such that their insertion into Grg+1 is consistent with 28 scenario 2. The sets are defined as follows. Let q be the size of the biggest item piece contained in Y . The first set Z1 is chosen such that s(Z1) ≥ q, s(Z1) − smin(Z1) < q, and smin(Z1) ≥ smax(Z \ Z1) (with smax(∅) = 0). We set Z2 = Z \ Z1 and first insert Z2 and then Z1. Lemma 13. Inserting Z1 and Z2 into Grg+1 is consistent with scenario 2, and this includes the case g = G. Proof. For the case g = G note that s(Z1) ≤ 2ε ≤ 1 and s(Z2) < s(Y ) ≤ 1 which is sufficient for scenario 2 in this case. We assume g < G in the following and consider two cases. Let i be the biggest item (fractionally) contained in Y . In the first case, we assume that i is big enough to cover a bin together with the biggest (big) item b contained in Grg+1. Note that due to invariant I11 the big items contained in Grg are at least as big as b. Since the buffer bin B′ of chain C was at most well-covered, this implies that Y = {i}. Remember that we choose the chain C in a way such that the size of the largest small item, call it i′, in its buffer bin B′ is minimal. As Y = {i}, either i is this largest small item i′ placed on B′ before the push, or scenario 1 applies and i = i∗ was just inserted into the instance. In both cases we have s(i) ≤ s(i′). Due to our choice of C, any largest small item contained in a buffer bin of Grg is large enough to cover a bin together with any big item contained in Grg. Therefore, each buffer bin contains exactly one small item and that item is at least as big as i. This in turn implies that Z = Y = {i}, Z1 = Z and Z2 = ∅, yielding the assertion in this case. In the second case, i is not big enough to cover a bin together with b. Hence, Z1 fits the requirements. Furthermore, note that Z2 is at most as big as Y minus the biggest item piece contained in that set. This implies that Z2 is suitably small as well: either Y was fully contained in the buffer bin before (yielding the assertion), or scenario 1 applies and i∗ ∈ Y . In the latter case, i∗ has to be the biggest item (and item piece) contained in Y and an item that is bigger than i∗ remains in the buffer bin B′ of C. Hence, Z2 is also suitably small. Lemma 14. The overall size of items that are migrated due to the insertion of a small item i∗ is O((1/ε3) · log2(1/ε))s(i∗). Proof. Let X0 = {i∗} and g0 be the index of the group i∗ is inserted to. For the case g0 = G + 1, we refer to Remark 11 that already guarantees the claimed bound. Hence, we assume g0 ≤ G. Furthermore, let gk = g0 + k for k ∈ {1, . . . , G + 1 − g0} and Xk be a set of items that is (recursively) inserted into Grgk. Note that at most 2k sets are inserted into Grgk for each k ∈ {0, . . . , G + 1 − g0} (due to the insertion of both parts of Z) and k ≤ G + 1 ≤ log(1/ε) + 3 (invariant I9). We first consider Grg0. When X0 is inserted into this group, ChainPush is called exactly once (not counting recursive calls). Let X0,r be the r-th set pushed out of a bin due to this call. A simple inductive application of Lemma 9 yields that s(X0,r) ≤ s(X0)+rsmax(X0) = (r + 1)s(i∗). The corresponding chain has length at most 1/ε + 1. Hence, the overall size of items moved in this group due to the insertion of X0 is at most O(1/ε2)s(i∗). Let Z1 and Z2 be the sets that are inserted into the next group. Considering the choice of these sets and the lengths of the parallel chains, we have s(Z1) + s(Z2) ≤ (1/ε + 3)s(i∗), and therefore this upper bound holds for both sets independently. This proves the base case 29 of the inductive claim that s(Xk) ≤ (1 + k(1/ε + 2))s(i∗). The claim for k holds by noting that smax(Xk) ≤ s(i∗) (using I11), and that the chain to which Xk is inserted has at most 1 ε + 1 bins (including the buffer bin). Furthermore, the overall size of migrated items in group Grgk due to the insertion of Xk is at most (1/ε + 1)(1 + k(1/ε + 2) + 1/ε + 1)s(i∗) = O((1/ε2) · log(1/ε))s(i∗) and this bound also holds for k = G + 1 − g0 (see Remark 11). Hence, the overall size of migrated items is bounded by (G + 1)2G+1O((1/ε2) · log(1/ε))s(i∗) = O((1/ε3) · log2(1/ε))s(i∗). Deletion. We now consider the case that a small item i∗ is deleted. Like in the case of insertion, we have to be careful to maintain the parallel chain structure in each group (invariant I10) and the correct distribution of small items (I11 and I12). Let i∗ be removed from a bin B∗ positioned in a chain C∗ in a group Grg. We already considered the case g = G + 1 and hence assume g ≤ G. There are several cases in which we do nothing: If (i) B∗ is still well-covered; or if (ii) B∗ is a buffer bin; or if (iii) we have g < G + 1 and Grg is the last group containing small items and B∗ was the last bin in C∗ that contained small items. In these cases, it is easy to see that the group structure and all invariants are maintained. For the steps that we take otherwise, we again take a slightly more general approach, because they are recursive in nature, and because they will also be useful when considering big and medium items. A gap bin B is a bin that is part of the group structure belonging to some parallel or sequential chain and should be covered with respect to the invariants I10, I12 and I8, but (due to repacking) is currently not. More precisely, B is not a buffer bin, and there are small items positioned in subsequent bins, which may either be part of the same parallel or sequential chain, or may be part of a subsequent group or sequential chain. Furthermore, we call a gap bin maximal, if there are no gap bins among the subsequent bins. In the following, we design a procedure GapFill(B) used to repair such a maximal gap bin B. It may be called recursively in situations in which there are more gap bins and therefore the parallel chain structure (invariant I10) and the correct distribution of small items (I12) may not hold. However, we can guarantee that for each initial (non-recursive) call of GapFill(B), the bin B will be the only gap bin, and we will guarantee that there are no gap bins left after the call (including all recursive calls). Now, it is easy to see that the bin B∗ is indeed a maximal gap bin and we will handle the remaining cases by a call of GapFill(B∗). Let B be a maximal gap bin positioned in a chain C in a group Grg. First, we discuss the special case g = G + 1. In the section on chains, we already designed a procedure for the case that a non-buffer bin B becomes not covered, that is, in the scenario discussed there, we have only a single (maximal) gap bin in the group. In all application scenarios of GapFill in the last group, this will actually be enough, but it is also very easy to see that the described procedure will work for any maximal gap bin, the only difference being that invariant I7 may not hold because of other gap bins that might be present. From now on, we assume g < G+1. As a first step, we call ChainPull(B, C). Afterwards, C remains a chain, and B as well as each bin which was followed by a well-covered bin before is well-covered (see Remark 8 and Lemma 10). Hence, if g is the last group containing small items, or the second to last bin B′ in C remains well-covered, we do nothing else, because all invariants hold (except for gap bins which may be present in preceding groups or a parallel chain). Otherwise, B′ is not covered, but all bins between B and B′ are 30 well-covered. In this case, we repeatedly move the largest small item from the subsequent group Grg+1 to B′ until either Grg+1 does not contain small items anymore or B′ becomes well-covered. Afterwards, each bin in the chain C starting from B has the correct structure with respect to the correct distribution of small items (invariants I11 and I12). Note that, if there is a small item in Grg+1 that can cover a bin together with the big item from B′, than the same holds for the biggest small item from Grg+1 and B′ did not contain small items before, because these would be even bigger (due to I11) and cover the bin. Hence, in that case only one item would be pulled from Grg+1 and it would be the only small item in B′ afterwards. Furthermore, note that at most one bin from Grg+1 can lose all of its small items in the above process, if it was well-covered to begin with, and if this happens, all the pulled items were pulled from this very bin (due to the distribution of big items I11). Therefore, each small item that was pulled from Grg+1 was previously contained in the first bin of a chain. If we stopped pulling items from Grg+1 because it did not contain small items anymore, we do nothing else, because then Grg has become the last group containing small items, and B′ does not have to be covered with respect to invariant I12. Hence, we consider the case that Grg+1 still contains small items. By pulling the items from Grg+1, we might have created multiple maximal gap bins. We now could consider each such bin individually to recurse, but in order to have bounded migration, we need to guarantee that only a constant number of maximal gap bins, namely four, have to be considered. We will achieve this by moving items within the first bins of the chains of Grg+1 such that at most four gap bins remain. To this end, we first consider the case that Grg+2 does also contain small items, i. e., Grg+1 is not the last group containing small items. Let Fst be the set of first bins in chains belonging to Grg+1. We may assume that Fst contains more than four bins that are not well-covered because otherwise there is nothing to do. In this case, each of the bins in Fst still contains at least one small item and no small item in the group can cover a bin together with the biggest big item in the group (see considerations above). We pick a set F ⊆ Fst with F = 4 and the property that a smallest small item contained in a bin belonging to F is at least as big as a smallest small item from a bin belonging to Fst\F, i. e., smin(small(F)) ≥ smin(small(Fst \ F)). Due to that choice, any small item from F can be moved to any bin from Fst \ F without violating the ordering of the small items (Invariant I10). We now repeatedly pick a bin from F with maximal load and move a biggest small item from that bin to a bin Fst \ F that is not covered. By this process each bin can receive items whose size is at most twice as big as the items that were pulled from this bin. Furthermore, for each bin B′′ contained in F, the overall size of small items contained in B′′ before small items were pulled to Grg was at least half as big as the overall size of items that were pulled. This is due to the distribution of big items (invariant I11) and due to the fact that there was no small item in Grg+1 big enough to cover a bin together with the big item from B′ in this case (see considerations above). Hence, each bin in Fst \ F can be covered by this process and we can recurse on the remaining at most four gap bins in F. If, on the other hand, Grg+1 is the last group containing small items there are two cases. In the case that g < G, we can use the same approach as before with one difference. In this case there can be bins that are positioned at the start of the chain but do not need to be covered, because there are no small items in any subsequent bin of the chain. Hence, 31 we can simply exclude these bins in the considerations. Lastly, if g = G, we do not have parallel chains in Grg+1 = S and all items have been pulled from the same bin. In any case, for each maximal gap bin B′′ in Grg+1 we call GapFill(B′′). Note that the call of GapFill(B) repairs the gap bin B as well as all created gap bins via recursive calls. Hence, after the call of GapFill(B∗) in the deletion procedure all invariants and the correct distribution of small items (I11 and I12) in particular hold. Lemma 15. Let B be a maximal gap bin. The overall size of items that are migrated due to a call of GapFill(B) is at most O((1/ε3) · log2(1/ε)). Furthermore, the migration due to the deletion of an item i∗ is bounded by O((1/ε4) · log2(1/ε))s(i∗). Proof. The initial call of GapFill(B) may cause several recursive calls in later groups. Let B∗ be a maximal gap bin for which such a call occurs, and C∗ its chain, Grg∗ its group, ϕ∗ = (1 − s(B∗)) be its free space (at the time of the call), and ψ∗ be the maximal size of a small item in any subsequent bin. We first consider the case g∗ < G + 1. The call of GapFill(B∗) results in a call of ChainPull. Let Xr be the r-th set pulled out of a bin due to this call. A simple inductive application of Lemma 10 yields that s(Xr) ≤ (1−s(B∗))+rψ∗, and we have r ≤ 1/ε. Hence, the overall size of items pulled from the last non-buffer bin B′ of C∗ is at most (1 − s(B∗)) + ψ∗/ε, and the overall size of items migrated due to the call of ChainPull is at most 1/ε((1 − s(B∗)) + ψ∗/ε). In the next step, items may be pulled to B′ from the next group, and because of the above observation their size is as well upper bounded by (1 − s(B∗)) + ψ∗/ε + ψ∗. This in turn implies, that the repacking that may be caused in the next group in order to bound the number of emerging gap bins is upper bounded by O((1 − s(B∗)) + ψ∗/ε). After this repacking, at most 4 maximal gap bins remain in the next group. It is easy to see that for each of these gap bins B′′ we have (1−s(B′′)) ≤ (1−s(B∗))+ψ∗/ε+ψ∗ as well. Summing up, the migration directly caused by the call of GapFill(B∗) (excluding recursive calls) is bounded by O(1/ε((1−s(B∗))+ψ∗/ε)). Due to Remark 12 this bounds also holds for the case g∗ = G + 1. Now, let g0 be the index of the group B is positioned in, and g0 + K the last group in which a (recursive) call of GapFill occurs. Furthermore, let gk = g0 + k for k ∈ {0, . . . , K}, Bk a maximal gap bin created in Grgk, and ψk the maximal size of a small item in any subsequent bin. Note that at most 4k ≤ 4G such gap bins are created in Grgk for k ≤ G and the bound of 4G also holds for the last group. Clearly, we have B0 = B and we set ψ = ψ0. The observations above yield that the migration directly caused by the call of GapFill(Bk) is at most O(1/ε((1 − s(Bk)) + ψk/ε)) = O(1/ε((1 − s(B)) + (G + 1)ψ/ε)), because ψr ≤ ψ for each r ∈ {0, . . . , K} (due to invariant I11) and K ≤ G. Therefore the overall migration can be bounded by: O(G × 4G × 1/ε((1 − s(B)) + Gψ/ε)) = O((1/ε3) · log(1/ε)((1 − s(B)) + (1/ε) · log(1/ε)ψ)) ≤ O((1/ε4) · log2(1/ε)[(1 − s(B)) + ψ]). In the case that an item i∗ is deleted, we have (1 − s(B)) ≤ s(i∗) and ψ ≤ s(i∗), yielding the proposed bound for that case. 32 3.3 Big and Medium Items To deal with the arrival or departure of big and medium items, we mainly use the ideas developed in the static case. However, changing bins belonging to BS is now much more complicated because we have to be careful to maintain the group and chain structure (invariants I9 and following). For example, removing a big item and its bin from BS will decrement the size of the corresponding group and possibly ⌈εBS⌉. Furthermore, the corresponding parallel chain may become too short. In this section, we first design some auxiliary procedures to carefully manipulate the group structure. Utilizing these, we next describe the deletion and insertion procedures of big items, and lastly the procedures for medium items. The latter are much simpler but may involve the insertion or deletion of big items from BS and hence are dealt with in the end. Preliminaries. We introduce a series of auxiliary procedures used for small local changes in the groups maintaining their internal structure. These procedures use GapFill and the insertion procedure for small items as subroutines, and are used in situations in which the group structure (invariant I9) may be slightly disturbed. In particular, the sizes of the groups may be different and G -- the total number of groups -- may be disturbed by some additive constant. It is easy to see that this is not a problem regarding the analysis of GapFill and the insertion procedure for small items, because the sizes of the groups do not influence and are not influenced by these procedures; and a change to G by some additive constant merely results in some additional constant factor in the analysis of their migration. Furthermore, BS and BB may not be balanced (invariant I2) before or after the call of one of the auxiliary procedures. This will be handled, when they are used. • GroupInsert(i, Grg) is called to insert a big item i into a group Grg with g < G + 1. To do so, we create a new bin B containing i. There are two cases. If Grg contains a parallel chain C with length smaller than 1/ε + 1, bin B is inserted into C at a position that maintains the correct distribution of big items in the chain (invariant I10). More precisely, right before the buffer bin, if all big items in C are at least as big as i, or right in front of the first bin containing a big item that is smaller than i. If B was inserted right in front of the buffer bin, we adjust the size of the virtual big item placed in the buffer bin of C to be s(i), thereby maintaining invariant I13. Otherwise, a new parallel chain is created in Grg containing only B and a buffer bin whose virtual big item has size s(i). Lastly, B now may be a maximal gap bin and we call GapFill(B) in this case. Afterwards, the parallel chain structure (invariant I10), as well as the correct distribution of small items (I12) are guaranteed. • GroupDelete(B, Grg) is used to repair the internal structure of a group Grg with g < G + 1 after the big item of a bin B positioned in Grg was removed. Let C be the parallel chain B is positioned in. We remove all small items from B and delete the bin. Next, we remove all small items from the buffer bin of C. If C now has length one, we delete the chain, and if additionally Grg has become empty, we also delete the group. Otherwise, we consider two cases: If C is the only chain with length smaller than 1/ε + 1, we adjust the size of the virtual big item in its buffer to be the same as the size of the big item in its direct predecessor, thereby maintaining 33 invariant I13. In the second case there is another chain C′ with length smaller 1/ε + 1 and hence C has length 1/ε (due to I10). We remove the last non-buffer bin B′ from C′, and remove all small items from B′ and the buffer bin of C′. Then, we insert B′ into C at the position maintaining the correct distribution of big items (I10). If B′ was inserted right in front of the buffer bin, we adjust the size of the virtual big item placed in the buffer of C (maintaining I13). If C′ now has length 1, we delete it, and otherwise we adjust the size of the corresponding virtual big item in its buffer bin as well, again maintaining I10 and I13. Now B′ may be a maximal gap bin and we call GapFill(B′) in this case. Lastly, we reinsert all small items that have been removed. Note that afterwards the parallel chain structure (invariant I10), as well as the correct distribution of small items (I12) are guaranteed. • GroupPush(Grg) is used to decrement the size of a group Grg, with g ≤ G, by pushing a big item of minimal size to the next group. We select a non-buffer bin B from Grg containing a big item i of minimal size, remove i from B, and call GroupDelete(B, Grg). If g < G, we then call GroupInsert(i, Grg+1). Otherwise, we create a new group belonging to BS with only one parallel chain. The chain has two bins, namely a bin containing only i and a buffer bin whose virtual item has size s(i). • GroupPull(Grg) is used to increment the size of a group Grg, with g < G, by pulling a big item of maximal size from the next group. We select a bin B from Grg+1 containing a big item i of maximal size, remove i from B, call GroupDelete(B, Grg+1), and then GroupInsert(i, Grg). Lemma 16. The overall size of items migrated due to a call of one of the auxiliary procedures above is at most O((1/ε3) · log2(1/ε)). Proof. In both GroupDelete and GroupInsert at most one big item and small items with overall size of at most 4 are removed. The small items are reinserted causing migration of at most O((1/ε3) · log2(1/ε)) (see Lemma 14), and there is a call of GapFill yielding the same bound (see Lemma 15). Both in GroupPush and GroupPull one big item is moved and the other two auxiliary procedures are called once. Deletion of Big Items. When a big item i∗ is deleted, there are three cases we have to consider based on the bin B∗ that item i∗ was positioned in. Firstly, if B∗ ∈ BM, we simply delete the bin and reinsert the corresponding medium items starting with the largest one. Next, if B∗ ∈ BB, we have to be a bit more careful in order to keep the sets BS and BB balanced (invariant I2). If BB ≥ BS did hold before, we select a bin B ∈ BB containing a big item i of maximal size (with a preference for B∗ itself), replace i with the remaining item from B∗, and reinsert i (thereby deleting B∗). If, on the other hand, BB = BS − 1 did hold, we select a big item i of minimal size from BS and move it to B∗. Afterwards, I2 holds, but the removal of i from BS may have violated several invariants concerning the structure of BS. To deal with this, we use the deletion procedure for the third case B∗ ∈ BS, which is by far the most complicated and described in the following. Let Grg be the group B∗ is positioned in. We perform GroupDelete(B∗, Grg). Now, Grg is decreased by one and ⌈εBS⌉ may have decreased by one. We first deal with the former and then consider the latter. In particular, if g < G, we iteratively perform GroupPull(Grg′) 34 for one group after another with g′ = g, . . . , G−1. Afterwards, G may have been decreased by one and we have Grg = 2g−1⌈ε(BS + 1)⌉ for g < G and GrG ≤ 2G−1⌈ε(BS + 1)⌉. If ⌈ε(BS + 1)⌉ = ⌈εBS⌉ the group structure, that is, I9, again holds. Otherwise, there are 2g−1 too many bins positioned in group Grg for g < G and up to 2G−1 too many in GrG. Hence, for each g′ ∈ [G − 1], we perform Pg′ − 1 many calls of GroupPush(Grg′). Afterwards, there are ℓ ≤ 2G − 1 too many bins in GrG and we perform ℓ calls of GroupPush(GrG), thereby creating up to one additional group. The last step is to rebalance BS and BB, if necessary, that is, if BS = BB − 2, we select a bin B ∈ BB containing a big item of maximal size. If necessary, we switch the second item in B such that the big items in B are as big as any other in BB. Then we delete B and reinsert the big items. These big items will be inserted into BS but will not incur further recursive calls for insertion or deletion of big items. r=1 2r−1 = 2g′ Insertion of Big Items. The steps that we take, when a big item i∗ has to be inserted in the dynamic case are very similar to the static case: We consider inserting i∗ into BM, BS and BB in this order and based on the same conditions. The insertion for BM works exactly as in the static case and the one for BB is changed only slightly. In particular, there are two cases considered in the procedure, namely BS = BB + 1 and BS < BB + 1. In the former, a bin B ∈ BS is selected containing a big item i of minimal size, and this item i is used to form a new bin together with i∗. The only change to the procedure is that we deal with the removal of i from BS using the deletion procedure for big items. We now describe how to insert i∗ into BS. When i∗ is to be inserted into BS we first select the correct group Grg with respect to the distribution of big items (invariant I11), that is, g = G if i∗ is at most as big as any other big item in BS, or the first group containing a big item smaller than i∗ otherwise. We call GroupInsert(i∗, Grg). Now, Grg is increased by one and ⌈εBS⌉ may have increased by one, that is, invariant I9 may not hold. We first deal with the former In particular, we iteratively call GroupPush(Grg′) for one and then consider the latter. group after another with g′ = g, . . . , G − 1. Furthermore, if the last group was of full size, that is GrG = 2G−1⌈εBS⌉ before the above operations, we also call GroupPush(GrG). Afterwards, G may have been increased by one and we have Grg = 2g−1⌈ε(BS − 1)⌉ for g < G and GrG ≤ 2G−1⌈ε(BS − 1)⌉. Hence, if ⌈ε(BS − 1)⌉ = ⌈εBS⌉ the group structure(I9) again holds. Otherwise, there are 2g−1 bins too few positioned in group Grg for g < G.For each g′ ∈ [G − 2], we perform Pg′ − 1 many calls of GroupPull(Grg′). Furthermore, if G > 1, we perform min{2G−1 − 1, GrG} many calls of GroupPull(GrG−1), thereby possibly deleting the last group. Lastly, the insertion of i∗ might have violated I2, that is, we now have BS = BB + 2. In this case, we select a big item i from BB and create a bin containing two dummy items of the same size as i. Afterwards I2 and all other invariants hold. We then delete the two dummy items one after another using the deletion procedures described above. r=1 2r−1 = 2g′ Medium items. Dealing with medium items in the dynamic case is not a big problem, because we can essentially use the same ideas as in the static case. In fact, we have to make only one small adjustment to the insertion procedure in the static case: When the arriving medium item has been inserted into M and we have the situation that s(M) ≥ 35 1 − smax(BS ∪ BB) and BS 6= ∅, then a big item i is to be removed from BS. We handle this as follows: We replace i by a dummy item of the same size, form a new bin B containing i and call GreedyPull(B, M). Afterwards I4 holds. Then we delete the big dummy item and call the corresponding deletion procedure. When a medium item i∗ is deleted from its bin B∗, we distinguish a few cases. If B∗ remains barely covered, we do nothing. Otherwise, if B∗ ∈ M, we delete the bin and reinsert all the medium items. Note that these items will simply be reinserted into M via GreedyPush and cause no further migration, because of invariant I4. Lastly if B∗ ∈ BM, we call GreedyPull(B∗, M). If B∗ is barely covered afterwards, we do nothing else. Otherwise, M = ∅ and we remove the big item i from B∗ (yielding M = {B∗}), and reinsert i. Note that in this case i will not be inserted into BM. Lemma 17. The overall size of items that are migrated due to the insertion or deletion of a big or medium item i∗ is O((1/ε)4 · log2(1/ε)). Proof. We consider the same cases as above and in the same order. If i∗ is big and deleted from a bin B∗ ∈ BM, then medium items with size at most 1 are reinserted. Because the largest item is reinserted first and because of invariants I4 and I3, only one of these items can trigger further migration and all others will be inserted into M. Hence, we get the same migration as for medium items plus some constant. If B∗ ∈ BB, the deletion may cause a reinsertion of a big item, or the deletion of a big item positioned in BS, as well as O(1) further migration. In the first case, the corresponding big item will be inserted into BS, because of its size, and because of the considered case, the insertion cannot cause further deletions of big items. Similarly, in the second case, the deletion cannot cause further insertions of big items. Hence, the migration is given by the migration for insertions or deletions of big items into BS plus some constant. If B∗ ∈ BS we may perform one call of GroupDelete, O(G) = O(log(1/ε)) calls of GroupPull, 2G+O(1) = O(1/ε) calls of GroupPush and some additional constant migration. Furthermore, there may be two big items that are reinserted. Because of the choice of the items and invariant I3, they are inserted into BS, and because of the corresponding case no deletions of big items are caused by these insertions. Hence, the migration in this case is at most O((1/ε)4 · log2(1/ε)) (see Lemma 16) plus the migration due to the possible insertions of big items. We consider the case that i∗ is big and has to be inserted. As described in Lemma 3 inserting a big item into BM may directly cause O(1) migration, and the insertion of a big item into BS or BB. Furthermore, the insertion of i∗ into BB may cause O(1) migration and either a deletion of a big item from BS or the reinsertion of a big item, which will be placed into BS. In both cases this causes no further insertions or deletions of big items. Hence, in both cases the migration is essentially given by the migration for the insertion or deletion of a big item into BS. If a big item i∗ is inserted into BS, we may perform one call of GroupInsert, O(G) = O(log(1/ε)) calls of GroupPush, 2G+O(1) = O(1/ε) calls of GroupPull and some additional constant migration. Furthermore, two deletions of big items from BB may be caused. Because of the corresponding case no reinsertions of big items are caused by these deletions. Hence, the migration in this case is at most O((1/ε)4 · log2(1/ε)) (see Lemma 16) plus the migration due to the possible insertions of big items. 36 If i∗ is a medium item and has to be inserted, we have O(1) migration and the deletion or insertion of a big item may be caused. In case of a deletion the corresponding item was positioned in BS. If the item i∗ is deleted, this may cause O(1) migration as well as the reinsertion of a big item. Hence, the migration in this case is at most O((1/ε)4 · log2(1/ε)). Summarizing, the overall size of items that are migrated due to the insertion or deletion of a big or medium item i∗ is O((1/ε)4 · log2(1/ε)). 3.4 Analysis In this section, we finish the proof of Theorem 7. We already proved bounds on the migration that may be caused due to insertions and deletions of algorithms (see Lemmas 14,15 and 17). Note that medium items may cause the migration of items with overall size O((1/ε)4 · log2(1/ε)) but may have size ε themselves yielding the bound of O((1/ε)5 · log2(1/ε)) stated in Theorem 7. Furthermore, we argued that the invariants are maintained by the insertion and deletion procedures throughout the section. Using these invariants, we prove the stated asymptotic competitive ratio and additive constant. Lemma 18. The algorithm for the dynamic case has an asymptotic competitive ratio of 1.5 + ε with additive constant O(log 1/ε). Proof. First, we consider the case BSP = ∅. In this case, the claim holds because the bins on average have not too much excess size. More precisely, we obviously have opt(I) ≤ s(I), and the invariants I1 and I6 imply: s(I) = s(BB) + s(BS) + s(GB) + s(BM) + s(M) + s(S) < 2BB + (1 + ε)BSC + s(GB) + 1.5BM + 1.5MC + 1 + (1 + ε)SC + s(S \ SC). Furthermore, we have s(GB) < (1/2 + ε)(εBSC + G) ≤ εBSC + G, due to I9 and I10; s(S \ SC) < εSC + 1, due to I7; (0.5 − ε)BB ≤ (0.5 − ε)(BS + 1), due to I2; and BS = BSC, because of the case we are considering. Hence: opt(I) < (1.5 + ε)BB + (1.5 + ε)BSC + 1.5BM + 1.5MC + (1 + 2ε)SC + G + 3 ≤ (1.5 + ε)(BB + BSC + BM + MC + SC) + log(1/ε) + 5 = (1.5 + ε) alg(I) + log(1/ε) + 5. A similar argument holds, if BSP 6= ∅ and BB = ∅. In this case, we have BS = BSP and BSP = 1, because of invariant I2; GB = ∅, because of I9 and I10; and S = ∅, because of invariant I5. Hence: opt(I) ≤ s(I) < 1.5BM + 1.5MC + 2 = 1.5 alg(I) + 2. Next, we consider the case BSP 6= ∅ and BB 6= ∅. In this case, we have MC = ∅, because of Invariant I4, and S = ∅, because of Invariant I5. According to invariant I12, there is a g∗ ∈ [G + 1] such that each bin in each group preceding Grg∗ is well-covered and each succeeding group does not contain small items, and because BSP 6= ∅, we have g∗ < G + 1. Let ξ = smin(big(Grg∗)) be the size of a big item from Grg∗ with minimal size. Because of the invariants I3 and I11, the items in BB and each group succeeding Grg∗ are upper bounded in size by ξ. We construct a modified instance I ∗ as follows: 37 1. The remaining big items (the ones bigger than ξ) are split into a big item of size ξ and a medium or small item. Let X be the set of items with size ξ. 2. For each bin from BSC ∪ BM ∪ {B B ∈ Sg∈[G] BGrg, B is well-covered}, we increase the size of a biggest item that is not big to 0.5. Let Y be the set of these items and Z be the set of the remaining items not belonging to X or Y . Note that opt(I) ≤ opt(I ∗). For some optimal solution for I ∗ in which each bin is at most barely covered, let k2, k1 and k0 be the numbers of covered bins with 2, 1 or 0 items from X ∪ Y respectively. We have: 2k2 + k1 = X ∪ Y I10 ≤ (2BB + BS + BM) + (BM + BSC + εBSC + G). Furthermore, (1 − ξ)k1 + k0 ≤ s(Z) and, due to I10, I9, I4, I12 and the choice of ξ, we have: s(Z) ≤ (1 − ξ)(BM + BSC + Grg∗ + {B ∈ [ BGrg small(B) 6= ∅}) + s(M) ≤ (1 − ξ)(BM + BSC + Grg∗ + εBSC + G) + (1 − smax(BS)) g∈[G] ≤ (1 − ξ)(BM + (1 + ε)BSC + ⌈εBS⌉ + g∗−1 X g′=1 Grg′ + G + 1) ≤ (1 − ξ)(BM + (1 + ε)BSC + ⌈εBS⌉ + BSC + G + 1) ≤ (1 − ξ)(BM + (2 + ε)BSC + εBS + G + 2). Hence: 2 opt(I) ≤ 2(k2 + k1 + k0) ≤ (2k2 + k1) + (k1 + (1 − ξ)−1k0) ≤ (2BB + BS + BM) + (BM + BSC + εBSC + G) + (BM + (2 + ε)BSC + εBS + G + 2) = 2BB + (1 + ε)BS + 3BM + (3 + 2ε)BSC + 2G + 2 I2 ≤ 2BB + (1 + ε)(BB + 1) + 3BM + (3 + 2ε)BSC + 2G + 2 I9 ≤ (3 + ε)BB + 3BM + (3 + 2ε)BSC + 2 log(1/ε) + 8 ≤ (3 + 2ε) alg(I) + 2 log(1/ε) + 8. Lastly, we conclude the proof of Theorem 7 by arguing that the running time bound holds. Lemma 19. The insertion and deletion procedures in the dynamic case have polynomial running time in both the input size and 1/ε. Proof. We first consider the insertion or deletion of small items. When one of these procedures is called, there may be O(1/ε) many recursive calls. For each of these calls it is rather ease to see that the running time is linear in the number of items. Concerning the insertion or deletion of big or medium items, we already saw in the migration analysis (Lemma 17) that only a constant number of recursive calls of big and medium items may be caused. Furthermore, small items (and there are at most n such items) may removed or reinserted due to these calls. 38 4 Amortized Migration We will now take a look at the setting, where the migration is amortized. Here we are concerned with the maximum ratio of the migration performed divided by the total size of items that have arrived up to some point. This is easier than the standard non-amortized migration considered before. 4.1 Dynamic Case For the dynamic case, we will show that the lower bound of 3/2 on the competitive ratio also holds if amortized migration is allowed. Hence, our above algorithm that only uses non-amortized migration is optimal (except for an extra ε). This result can also be proved for the other definition of asymptotic competitive ratio. Proposition 20. There is no algorithm for dynamic online bin covering with a constant amortized migration factor β and an asymptotic competitive ratio smaller than 3/2. Proof. Let alg be an algorithm for dynamic online bin covering with an amortized mi- gration factor of β. Suppose that alg has asymptotic competitive ratio 3/2 − δ for some constant value 1/2 ≥ δ > 0, i. e., for each instance we have OPT(I) ≤ (3/2 − δ) · alg(I) + c for some constant c. We will now construct for each even integer N an instance I (N ). This instance is comprised of m + 1 phases, where m is an even number that is specified later on and depends on N and β. In each of the phases some number of equally sized items either arrives or departs. The instance corresponding to the first phase is called I (N ) and the one corresponding to the first j + 1 phases is called I (N ) . The optimal (offline) objective value for each of these instances will be a multiple of N , i. e., OPT(I (N ) ) ∈ {3N, (3/2)N }. We will show that the ratio between this value and the objective value achieved by alg is at least 3/2 for at least one value of j ∈ {0, . . . , m} with constant amortized migration factor. 0 j j We now describe the instance I (N ): In the first phase 3N big items with size 1 − ε arrive; and for each odd j ∈ [m] there are 3N small items with size ε arriving in phase j and departing in phase j + 1. We choose the parameter ε such that 3N small items cannot fill a whole bin, and such that the total size of 3N small items is upper bounded by the size of a big item, e.g., ε = min{(9βN + 2)−1, (6N )−1}. Note that for each j ∈ {0, . . . , m} the optimal (offline) objective value for I (N ) is 3N/2 if j is even, and 3N if j is odd (see Fig. 9). Claim 21. For each even integer N , there is some index j ∈ {1, . . . , m} such that (3/2) alg(I (N ) OPT(I (N ) ). j j j ) ≤ j ) ≤ N for some even j or alg(I (N ) Proof. If alg(I (N ) Hence, let P denote the property that alg(I (N ) ) > 2N for all odd j, and we analyze whether P can be obtained by alg. Since two big items are needed to cover a bin and 3N small items are not sufficient for covering a bin, P implies that at least N + 1 bins have to contain at least 2 big items, if j is even; and at least N + 1 bins have to contain exactly one big item, if j is odd. ) > N for all even j and alg(I (N ) ) ≤ 2N for some odd j, we are done. j j j 39 Hence, to maintain that P holds in two consecutive phases, some big item has to be moved, and therefore the migration performed in each phase is at least 1 − ε. However, the total size of items arriving or departing in every phase I (N ) , . . . is only , I (N ) 1 2 3N ε ≤ 3N/(9βN + 2) < 3N/(9βN ) = 1/(3β) ≤ (1 − 2ε)/β. In the first inequality, we use ε ≤ (9βN + 2)−1. implying ε ≤ 1/6 ≤ 1/3 and thus (1 − 2ε) ≥ 1/3. In the last inequality, we use N ≥ 1 Hence, the total size of migrated items is at least m(1 − ε) and the total load of items arriving or departing is strictly smaller than (3N )(1 − ε) + m(1 − 2ε)/β. As alg has amortized migration factor β, it is allowed to reassign a total size of βS, after items of size S have arrived or departed. The total size of arrived and departed items equals (3N )(1 − ε) + m(1 − 2ε)/β in our setting. Hence, alg is allowed to migrate a total size (3N β)(1 − ε) + m(1 − 2ε). Choosing m -- the number of phases -- such that m > (3N β)(1 − ε)/ε then gives (3N β)(1 − ε) + m(1 − 2ε) < m(1 − ε). Hence alg can not migrate a total size of m(1 − ε). As it needs to migrate at least such a total size to maintain property P, we can conclude that P can not hold. Hence, there is some index j ∈ {1, . . . , m} such that opt(I (N ) ) ≥ 3/2, concluding our proof. )/ alg(I (N ) j j j This is sufficient to prove the proposition: From above, we know that for each even N , ). The asymptotic competitive there is some value j such that (3/2)· alg(I (N ) ratio of alg then implies opt(I (N ) ) ≤ opt(I (N ) ) ≤ (3/2 − δ) · alg(I (N ) ) + c and thus j j j (3/2) · alg(I (N ) j ) ≤ (3/2 − δ) · alg(I (N ) j ) + c. ) = kjN , we have c/δ ≥ alg(I (N ) This is equivalent to c/δ ≥ alg(I (N ) ). As alg has asymptotic competitive ratio 3/2 − δ and opt(I (N ) 3/2−δ and thus c(3/2 − δ)/δ + c ≥ kjN . As N can be made arbitrarily large, this is a contradiction to the assumption that both c and δ are constant values. Hence, an asymptotic competitive ratio of 3/2 − δ is not achievable with constant amortized migration factor β. ) ≥ kj N −c j j j 1 − ε 1 − ε 1 − ε . . . 1 − ε ε ε 1 − ε . . . 1 − ε opt(I2i) = 3/2N opt(I2i+1) = 3N Figure 9: Optimal packings of I2i and I2i+1 40 4.2 Static Case In contrast to the dynamic case, where amortized migration does not help to improve upon the lower bound of 3/2 on the competitive ratio, amortization allows to design a simple algorithm for the static case, achieving a competitive ratio of 1 + ε with amortized migration of O(1/ε). Some of the ideas applied here were used for bin packing [14] in the past. The small value ε will again satisfy 0 < ε ≤ 0.5. In order to achieve this goal, we make use of an asymptotic fully polynomial time approximation scheme (AFPTAS), denoted by algoff, for the offline version of the problem due to Jansen and Solis-Oba [21]. For an instance I and an approximation parameter ε, the algorithm algoff produces a packing that covers algoff(I, ε) bins with opt(I) ≤ (1 + ε) algoff(I, ε) + O(1/ε3) in time that is polynomial in the input size and 1 ε . Let µ ≥ 1 be a constant such that opt(I) ≤ (1 + ε) algoff(I, ε) + µ ε3 (1) holds for every input I. Our algorithm will be called algon and its profit for input I and ε is denoted by algon(I, ε). Denote the instance after τ items were presented, that is, at time τ , as Iτ . Our online algorithm algon will have the same guarantee as the offline algorithm in terms of the order of growth of the additive term, i. e., we will show opt(Iτ ) ≤ (1+O(ε)) algon(Iτ , ε)+ O(1/ε3), and more specifically, we will show that opt(Iτ ) ≤ (1 + 3ε) algon(Iτ , ε) + 6µ ε3 for every time τ . There will be a sequence of special times denoted by t1, t2, · · · for which it will hold that algon(Iti, ε) = algoff (Iti, ε) and therefore opt(Iti ) ≤ (1 + ε) algon(Iti , ε) + µ ε3 will hold for every i ≥ 1. Algorithm algon will apply algoff (with the same value of ε) in every step, i. e., when a new item arrives. This is done in order to obtain an approximated value of the profit of an optimal solution. As we saw before, arguments that are based on total size are valid for approximating this value by a factor of 2, but not within a smaller factor. In the special times t1, t2, . . . defined in what follows, the output of algoff will be used in order to obtain a new solution, and the input is completely repacked such that it is packed as in this solution (algoff (Iti, ε)). In this case, all items are removed from their bins and repacked identically to the output of algoff. This is done instead of assigning the new item. In other times which are not special, only the profit of algoff will be used, and the new item is packed into a new bin. Thus, at times that are not special, algorithm algon will always greedily assign a new item to a new non-covered bin, and on occasion it will define the current time as special and then it completely repacks the instance with the help of algoff. We define special times as follows. The first special time t1, which is the first time in which we repack the instance using algoff is when algoff(It1 ) ≥ 3µ/ε3 > 1 (by ε ≤ 0.5 and µ ≥ 1). We have t1 > 1 since after the arrival of just one item no solution has profit above 1. Before time t1, the profit of algon is zero. The other special times are defined as follows. Let ti (for i ≥ 1) be the last special time, i. e., the last time that a repacking was performed. For the current time τ > ti, if algoff (Iτ , ε) < (1 + ε) algoff (Iti, ε), the new item is packed into a new bin and τ is not a special time. Otherwise, we let ti+1 = τ , i. e., τ is a special time, and instead of packing the new item immediately, we perform the next repacking. Thus, time ti+1 > ti, is the first time τ > ti for which algoff (Iτ , ε) ≥ (1 + ε) algoff (Iti, ε), 41 and thus algoff(Iti+1, ε) ≥ (1 + ε) algoff (Iti, ε) while algoff (Iθ, ε) < (1 + ε) algoff (Iti, ε), where ti + 1 ≤ θ ≤ ti+1 − 1. Clearly, the running time of our online algorithm is polynomial in t and 1/ε, since it is the sum of running times of algoff for all prefixes of the input. Before we discuss the migration factor, we show that this algorithm always maintains a near-optimal solution. We will use the property that holds at special times, and analyze the other times. ε3 < 6µ ε3 ≤ (1 + 3ε) algon(Iτ ) + 6µ At any time τ < t1 (before the first repacking), we have that algoff(Iτ ) < 3µ/ε3 while algon(Iτ ) ≥ 0, and by (1) we get opt(Iτ ) ≤ (1 + ε) algoff(Iτ , ε) + µ ε3 ≤ (1 + ε) · ε3 + µ 3µ ε3 . For every special time ti we have opt(Iti ) ≤ (1 + ε) algoff(Iti, ε) + µ ε3 , since at any special time, once the repacking is applied, the packing of algon is identical to that of algoff. ε3 ≤ (1 + 3ε) algon(Iti, ε) + 6µ ε3 = (1 + ε) algon(Iti, ε) + µ Now consider a time τ satisfying τ > ti for some i ≥ 1, and if ti is not the last special time, then we also require τ < ti+1. Thus, no special times are defined at times ti+1, . . . , τ , and we have algoff(Iτ , ε) < (1 + ε) algoff(Iti, ε). (2) Since all items ti + 1, . . . , τ are assigned to new bins, and covered bins remain such, we have algon(Iτ , ε) ≥ algon(Iti , ε). Due to the repacking at the special time ti, we find algon(Iti, ε) = algoff (Iti, ε), and get algon(Iτ , ε) ≥ algon(Iti , ε) = algoff(Iti , ε). Combining the last two inequalities (2) and (3) gives algoff(Iτ , ε) ≤ (1 + ε) algon(Iτ , ε). (3) (4) By (1) for time τ , opt(Iτ ) ≤ (1 + ε) algoff(Iτ , ε) + µ ε3 , and we get opt(Iτ ) ≤ (1 + ε) algoff (Iτ , ε) + µ/ε3 ≤ (1 + ε)2 algon(Iτ , ε) + µ/ε3 ≤ (1 + 3ε) algon(Iτ , ε) + 6µ/ε3, as ε2 < ε. Hence, algon achieves an asymptotic competitive ratio of 1 + 3ε, and an appropriate scaling of ε allows us to obtain competitive ratio 1 + ε. Finally, we will show that algon has an amortized migration factor of O(1/ε). Let k be the number of special times (which are t1, t2, . . . , tk). Let Ui denote the optimal profit at time ti, which is a monotonically non-decreasing sequence. Let Si denote the total size of the first ti input items. The total size of migrated items is at most Pk i=1 Si, while the total size of items is at least Sk. Let ∆i = algoff(Iti , ε), where for every 1 ≤ i ≤ k − 1 we have ∆i+1 ≥ (1 + ε)∆i, and additionally, ∆1 ≥ 3µ ε3 > 1. We claim that Ui satisfies ∆i ≤ Ui < 3∆i. The inequality ∆i ≤ Ui holds since Ui is the optimal profit at a certain time while ∆i is the profit of some solution for the same input. Since Ui ≥ U1 ≥ ∆1 ≥ 3µ ε3 < 2∆i + Ui/3, which implies Ui < 3∆i. ε3 and by (1) we get Ui ≤ (1 + ε)∆i + µ Moreover, there exists an optimal solution where every bin has load in [1, 2), and there is at most one bin that is not covered. Thus, Ui ≤ Si < 2Ui + 1 < 3Ui. 42 We find by ∆k ≤ Uk ≤ Sk: k X i=1 Si < 3 ∞ X j=0 1 (1 + ε)j = By and by we find Ui ≤ 9 k X i=1 ∆i. k X i=1 1 1 − 1/(1 + ε) = 1 + ε ε = 1 + 1 ε , ∆i ≤ ∆k (1 + ε)k−i , 1 9 · k X i=1 Si ≤ ∆k · k X i=1 1 (1 + ε)k−i = ∆k · k−1 X j=0 1 (1 + ε)j ≤ Sk ∞ X j=0 1 (1 + ε)j = Sk · (1 + 1 ε ). This analysis holds also for every prefix of the input if the input was repacked at least once (and otherwise the amortized migration factor is zero). Hence, the amortized migration factor of algon is at most 9 + 9 ε = O(1/ε) and we obtain the following theorem. Theorem 22. For every ε > 0, there is an algorithm for static online bin covering with polynomial running time, an asymptotic competitive ratio of 1 + ε, and an amortized migration factor of O(1/ε). In the following, we will show that an error in the amortized setting is inevitable, even if we allow an unbounded running time. Theorem 23. There is no (possibly exponential time) algorithm for static online bin covering that maintains an optimal solution with constant amortized migration factor β. Proof. We say that a bin is perfectly covered, if it contains items of total size exactly 1, and call a solution perfect if all of its bins are perfectly covered. Obviously, if there is a perfect solution to a bin covering instance, it is optimal and each optimal solution for this instance has to be perfect. Let N be a positive even integer. Our input consists of N + 1 phases. The first phase (phase 0) consists of items of total size N and phase j (for j ≥ 1) consists of items of total size 2. Let Ij be the instance after phase j arrived. We will ensure that the optimum opt(Ij) = N + 2j is realized by a unique perfect solution (up to some transpositions). Furthermore, the total size of items that need to be moved to transform an optimal solution of Ij to an optimal solution of Ij+1 is at least (N −j +2)/3. Hence, items with total size Ω(N 2) have to be moved to maintain an optimal solution at all times while the total size of all arriving items is 3N yielding that the needed amortized migration is Ω(N ). Since the construction works for arbitrarily big values of N , this suffices to prove the claim, as this rules out a constant amortized migration factor. We will proceed by first describing all occurring items in detail and noting some basic properties, then we define the phases, describe the optimal solutions and finally we prove their uniqueness and the necessary migration. 43 Let ε = 1/(N + 1)4. The items are either huge, large, medium or tiny and each of these classes contains items of N levels. More precisely, for each level i ∈ [N ] we have: • One huge item with size huge(i) = 1 − (N − i + 1)ε(1 + (i − 1)(N + 1)). • One large item of type A with size largeA(i) = 1/2 + i(N + 1)ε, and one large item of type B with size largeB(i) = largeA(i) + ε. • One medium item of type A with size mediumA(i) = 1/2 − i(N + 1)ε, and one large item of type B with size mediumB(i) = mediumA(j) − ε. • N − i + 1 tiny items each with size tiny(i) = ε(1 + (i − 1)(N + 1)). We now state some simple properties of these items: Claim 24. It holds 1. largeA(i)+mediumA(i) = largeB(i)+mediumB(i) = huge(i)+(N −i+1)tiny(i) = 1; 2. PN 3. huge(N ) < huge(1), largeA(1) < largeA(N ), largeB(1) < largeB(N ), mediumA(N ) < i=1(N −i+1)·tiny(i) < 1 (i. e., all tiny items together cannot fill a bin completely); mediumA(1), mediumB(N ) < mediumB(1), tiny(1) < tiny(N ); 4. huge(N ) > largeB(N ), largeA(1) > mediumA(1), mediumB(N ) > tiny(N ); 5. mediumB(N ) > 1/3, largeA(1) > 1/2, mediumA(1) < 1/2, huge(N )+mediumB(N ) > 1 6. huge(i) + mediumX(i′) > 1 and huge(i) + largeX(i′) > 1 for all X ∈ {A, B} and all i, i′ ∈ {1, . . . , N }. For completeness, the simple proof of this fact can be found in the appendix. Hence, large and medium items of the same type and level can be used to pack a bin perfectly and every other combination of two large or medium items does not cover a bin perfectly. Let sh, sℓ, sm and st be sizes of some huge, large, medium and tiny item respectively. Summarizing the claim, we have (i) all tiny items together cannot fill a whole bin, (ii) sh > sℓ > sm > st, (iii) sm > 1/3, (iv) sℓ > 1/2 > sm, and (v) sh + sm > 1. Hence, in a perfect solution to an instance I comprised of a subset of the above items, a bin may contain (1) exactly one large item together with the unique matching medium item; (2) at most two items that are medium or large, and at least one tiny item; or (3) exactly one huge, and at least one tiny item. Furthermore, if I contains the first n ≤ N levels of huge items, we have: Claim 25. In a perfect solution of I, the first n levels of huge items have to be packed together with the first n levels of tiny items in a unique way. Proof. To see this, consider the bin Bk containing the huge item of level k in a perfect solution. Due to point 6 in Claim 24, Bk cannot contain any large or medium item, as the solution is perfect. Hence, Bk must contain some tiny items. These tiny items in Bk must have a total size of rk = 1 − huge(k) = (N − k + 1)ε(1 + (k − 1)(N + 1)). As (rk/ǫ) mod (N + 1) = (N − k + 1) and (tiny(i)/ε) mod (N + 1) = 1 for all i = 1, . . . , N , we need at least N − k + 1 tiny items to cover bin Bk. 44 Now, suppose that there is some bin Bk that does not contain all N − k + 1 tiny items of level k and let this k be minimal. Hence, for each i ∈ {1, . . . , k − 1}, the bin Bi contains the N − i + 1 tiny items of level i and all of these tiny items are thus packed. As Bk needs to contain N − k + 1 tiny items, it hence must contain at least one tiny item of size at least tiny(k + 1) (due to the monotonicity of tiny(i)). Hence, the sum of the tiny items in Bk is at least tiny(k + 1) + (N − k)tiny(k) = ε(1 + k(N + 1)) + (N − k)ε(1 + (k − 1)(N + 1)) > (N − k + 1)ε(1 + (k − 1)(N + 1)) = rk. Hence, Bk is not perfectly covered, a contradiction to the assumption. We proceed with the definition of the phases: Phase 0 consists of all large items of type A, all medium items of type B and the tiny items of level 1. Note that the large items of type B and the medium items of type A are not yet available. As largeA(i) + mediumB(i) + tiny(1) = 1 (see Claim 24), the total volume of items in phase 0 is N . This (perfect) packing also shows that opt(I0) = N (see Fig. 10). Claim 26. Putting one item of size largeA(i), one item of size mediumB(i), and one item of size tiny(1) into a bin is the unique optimal perfect packing (up to the packing of the tiny items) for phase 0. Proof. Due to the definition of the sizes, two large items have total size strictly larger than 1 and two medium items have total size strictly smaller than 1. The total size of items in phase 0 is exactly N , the total size of all tiny items is not enough to cover a single bin (Claim 24), and we have exactly N large and N medium items. Hence, every bin in a perfect packing must contain one large item and one medium item. Now let Bi be the bin containing largeA(i). Suppose that the solution described above is not unique. Hence, there is some bin Bi that contains an item of size mediumB(j) with i 6= j. If j > i, the monotonicity of mediumB(·) shows that this bin is not perfectly covered. If j < i, the pidgeonhole principle shows that there must be some bin Bi′ containing an item of size mediumB(j′) with j′ > i′, which is again a contradiction. For each j ∈ [N ], phase j consist of the huge item of level j, the large type B item of level j, the medium type A item of level N − j + 1 and the tiny items of level j + 1 if j < N , and no tiny items otherwise. The items of instance Ij can be packed perfectly as follows. The huge and tiny items of level 1 to j are packed in the unique possible way described above; the large and medium type B items of level 1 to j are matched to form j perfectly packed bins, and similarly the large and medium type A items of level N to N − j + 1 are matched. Lastly, for each k ∈ {1, . . . , N − j}, we have largeA(k) + mediumB(j + k) + tiny(j + 1) = 1 and we pack the remaining items correspondingly (see Fig. 11). This packing has N + 2j perfectly covered bins. Claim 27. The packing described above is unique. Proof. Claim 25 implies that the huge items are packed together with the fitting tiny ones in j perfectly covered bins. There are only N − j tiny items left and each bin that does 45 not correspond to a perfect match of a medium and large item has to contain a tiny item as described in the proof of Claim 26. As we still need to fill N + j bins perfectly, 2j of these bins need to be packed by perfect matches. This is exactly the number of perfect matches available and we thus need to pack all of them. Furthermore, large items cannot be combined in one perfectly covered bin (Claim 24) and therefore each of them has to be packed into a single bin together with a tiny item. For each such bin there is exactly one medium item left that fits perfectly, namely the one chosen above. In order to transform the unique perfect solution of instance Ij−1 into the one for Ij, at least N − j + 2 non-tiny items have to be moved (see Fig. 11). Each of these items has a size of at least 1/3. Hence, a total migration of PN j=1(N − j + 2)/3 ≥ Ω(N 2) is needed while the total size of the instance is 3N . As we are only allowed to repack a total size of β3N , this implies β ≥ Ω(N ), a contradiction to the assumption that β is a constant. This concludes the proof. tiny(1) tiny(2) mediumB(1) mediumB(2) tiny(N ) mediumB(N ) . . . largeA(1) largeA(2) largeA(N ) Figure 10: Optimal packing of phase I0 46 ×N tiny(1) ... tiny(1) huge(1) ×N − j + 1 . . . tiny(j) ... tiny(j) huge(j) ×N − j tiny(j + 1) ... tiny(j + 1) huge(j + 1) mediumB(1) mediumB(j) mediumB(j + 1) . . . largeB(1) largeB(j) largeB(j + 1) mediumA(N ) mediumA(N − j + 1) mediumA(j + 1) largeA(N ) tiny(j + 1) mediumB(j + 1) largeA(1) tiny(j + 2) mediumB(j + 2) . . . . . . . . . largeA(N − j + 1) largeA(j + 1) tiny(j + 1) mediumB(N ) largeA(N − j) tiny(j + 2) mediumB(N ) largeA(1) largeA(N − j + 1) Figure 11: Optimal packing of phase Ij and phase Ij+1 (in red) 47 A Proof of Claim 24 Proof of Claim 24. 1. We simply calculate: • largeA(i) + mediumA(i) = 1/2 + i(N + 1)ε + 1/2 − i(N + 1)ε = 1 • largeB(i) + mediumB(i) = 1/2 + i(N + 1)ε + 1/2 + ε − i(N + 1)ε − ε = 1 • huge(i) + (N − i + 1)tiny(i) = 1 − (N − i + 1)ε(1 + (i − 1)(N + 1)) + (N − i + 1)ε(1 + (i − 1)(N + 1)) = 1 2. We have (N − i + 1) · tiny(i) = N X i=1 (N − i + 1) } ≤N ·ε(1 + (i − 1) {z } ≤N −1 (N + 1)) ≤ N X i=1 N X i=1 {z X N i=1 N · ε(1 + (N − 1)(N + 1)) = N · ε(1 + N 2 − 1) = N 4ε = N 4/(N + 1)4 < 1. 3. We also calculate: • huge(N ) = 1 − N ε < 1 − N 2ε = 1 − ε(1 + (N − 1)(N + 1)) = huge(1) • largeA(1) = 1/2 + (N + 1)ε < 1/2 + N (N + 1)ε = largeA(N ) • largeB(1) = 1/2 + (N + 1)ε + ε < 1/2 + N (N + 1)ε + ε = largeB(N ) • mediumA(N ) = 1/2 − N (N + 1)ε < 1/2 − (N + 1)ε = mediumA(1) • mediumB(N ) = 1/2 − N (N + 1)ε − ε < 1/2 − (N + 1)ε − ε = mediumB(1) • tiny(1) = ε < ε(1 + (N − 1)(N + 1)) = tiny(N ) 4. Again, we calculate • Note that (N +1)4 > (N +1)4/2+N (N +3) for all N ≥ 1 and hence huge(N ) = 1 − N ε = 1 − N/(N + 1)4 > 1/2 + N (N + 2)/(N + 1)4 = 1/2 + N (N + 1)ε + ε = largeB(N ). • largeA(1) = 1/2 + (N + 1)ε > 1/2 − (N + 1)ε = mediumA(1) • Note that (N + 1)4/2 > N 2 + N (N + 2) for N ≥ 1 and hence mediumB(N ) = 1/2 − N (N + 1)ε − ε = 1/2 − N (N + 2)ε = 1/2 − N (N + 2)/(N + 1)4 > N 2/(N + 1)4 = ε(1 + (N − 1)(N + 1)) = tiny(N ) 5. Finally, some calculations show that • Note that (N + 1)4/2 > (N + 1)4/3 + N (N + 2) and hence mediumB(N ) = 1/2 − N (N + 1)ε − ε = 1/2 − N (N + 2)ε > 1/3. • largeA(1) = 1/2 + (N + 1)ε > 1/2 • mediumA(1) = 1/2 − (N + 1)ε < 1/2 • From mediumB(N ) > 1/3, we have hugeN + mediumB(N ) > 1 − N ε + 1/3 = 1 − N/(N + 1)4 + 1/3 > 1. 6. This follows from the above points. Note that huge(N ) is the smallest huge item and mediumB(1) the smallest medium item. Hence, point 5 implies that the sum of these two already exceeds 1. As every medium or large item is larger than mediumB(1) due to points 3 and 4, the claim follows. 48 References [1] Susan F. Assmann, David S. Johnson, Daniel J. Kleitman, and Joseph Y.-T. Le- ung. On a dual version of the one-dimensional bin packing problem. J. Algorithms, 5(4):502 -- 525, 1984. URL: https://doi.org/10.1016/0196-6774(84)90004-X, doi:10.1016/0196-6774(84)90004-X. [2] János Balogh, Leah Epstein, and Asaf Levin. Lower bounds for online bin covering- type problems. Journal of Scheduling, pages 1 -- 11, 2018. [3] Sebastian Berndt, Klaus Jansen, and Kim-Manuel Klein. Fully dynamic bin packing revisited. In Naveen Garg, Klaus Jansen, Anup Rao, and José D. P. Rolim, editors, Approximation, Randomization, and Combinatorial Optimization. Algorithms and Techniques, APPROX/RANDOM 2015, August 24-26, 2015, Princeton, NJ, USA, volume 40 of LIPIcs, pages 135 -- 151. Schloss Dagstuhl - Leibniz-Zentrum fuer Infor- matik, 2015. URL: https://doi.org/10.4230/LIPIcs.APPROX-RANDOM.2015.135, doi:10.4230/LIPIcs.APPROX-RANDOM.2015.135. [4] Sebastian Berndt, Klaus Jansen, and Kim-Manuel Klein. Fully dynamic bin packing revisited. Mathematical Programming, 2018. doi:10.1007/s10107-018-1325-x. [5] Marie G. Christ, line bin covering: 556:71 -- 84, 2014. doi:10.1016/j.tcs.2014.06.029. URL: Lene M. Favrholdt, Expectations vs. guarantees. On- Theor. Comput. Sci., https://doi.org/10.1016/j.tcs.2014.06.029, and Kim S. Larsen. [6] János Csirik, David S. Johnson, and Claire Kenyon. Better approxima- editor, Proceed- the Twelfth Annual Symposium on Discrete Algorithms, January 7- URL: tion algorithms ings of 9, 2001, Washington, DC, USA., pages 557 -- 566. ACM/SIAM, 2001. http://dl.acm.org/citation.cfm?id=365411.365533. In S. Rao Kosaraju, for bin covering. [7] János Csirik and V. Totik. bin of 1988. sion 167, doi:10.1016/0166-218X(88)90052-2. packing. URL: Online a Discrete Applied Mathematics, ver- dual 21(2):163 -- https://doi.org/10.1016/0166-218X(88)90052-2, algorithms for [8] Leah Epstein. 171(2):294 -- 305, doi:10.1006/inco.2001.3087. Online 2001. variable sized Inf. Comput., https://doi.org/10.1006/inco.2001.3087, covering. URL: [9] Leah Epstein, Lene M. Favrholdt, packing line 21, doi:10.1007/s10951-009-0129-5. bin URL: algorithms 2012. for and Jens S. Kohrt. problems. Comparing on- 15(1):13 -- https://doi.org/10.1007/s10951-009-0129-5, J. Scheduling, [10] Leah Epstein, bin strained 2010. doi:10.1007/s00224-008-9129-7. Csanád covering. URL: Imreh, and Asaf con- 46(2):246 -- 260, https://doi.org/10.1007/s00224-008-9129-7, Comput. Theory Levin. Syst., Class 49 [11] Leah and Asaf packing Levin. problem. the for 119(1):33 -- https://doi.org/10.1007/s10107-007-0200-y, A robust APTAS Math. Program., Epstein bin 2009. classical 49, doi:10.1007/s10107-007-0200-y. URL: [12] Leah Epstein and Asaf Levin. Robust approximation schemes packing. 23(2):1310 -- 1343, https://doi.org/10.1137/11082782X, doi:10.1137/11082782X. SIAM Journal on Optimization, 2013. for cube URL: [13] Leah Epstein and Asaf Levin. Robust algorithms for preemptive scheduling. Algo- rithmica, 69(1):26 -- 57, 2014. URL: https://doi.org/10.1007/s00453-012-9718-3, doi:10.1007/s00453-012-9718-3. [14] Björn Feldkord, Matthias Feldotto, Anupam Gupta, Guru Guruganesh, Amit Kumar, Sören Riechers, and David Wajc. Fully-dynamic bin packing with lit- tle repacking. In Ioannis Chatzigiannakis, Christos Kaklamanis, Dániel Marx, and Donald Sannella, editors, 45th International Colloquium on Automata, Lan- guages, and Programming, ICALP 2018, July 9-13, 2018, Prague, Czech Repub- lic, volume 107 of LIPIcs, pages 51:1 -- 51:24. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2018. URL: https://doi.org/10.4230/LIPIcs.ICALP.2018.51, doi:10.4230/LIPIcs.ICALP.2018.51. [15] Carsten Fischer and Heiko Röglin. Probabilistic analysis of the dual next- In Evangelos Kranakis, Gonzalo Navarro, fit algorithm for bin covering. - 12th and Edgar Chávez, 2016, Pro- Latin American Symposium, Ensenada, Mexico, April 11-15, ceedings, volume 9644 of Lecture Notes in Computer Science, pages 469 -- 482. Springer, 2016. URL: https://doi.org/10.1007/978-3-662-49529-2_35, doi:10.1007/978-3-662-49529-2\_35. editors, LATIN 2016: Informatics Theoretical [16] Carsten Fischer and Heiko Röglin. Probabilistic analysis of online (class- constrained) bin packing and bin covering. In Michael A. Bender, Martin Farach- Colton, and Miguel A. Mosteiro, editors, LATIN 2018: Theoretical Informatics - 13th Latin American Symposium, Buenos Aires, Argentina, April 16-19, 2018, Proceedings, volume 10807 of Lecture Notes in Computer Science, pages 461 -- 474. Springer, 2018. URL: https://doi.org/10.1007/978-3-319-77404-6_34, doi:10.1007/978-3-319-77404-6\_34. [17] Waldo Gálvez, José A. Soto, and José Verschae. and Grzegorz Herman, Symmetry exploitation for online machine covering with bounded migration. In Yossi Azar, Han- nah Bast, 26th Annual European Sympo- sium on Algorithms, ESA 2018, August 20-22, 2018, Helsinki, Finland, vol- ume 112 of LIPIcs, pages 32:1 -- 32:14. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2018. URL: https://doi.org/10.4230/LIPIcs.ESA.2018.32, doi:10.4230/LIPIcs.ESA.2018.32. editors, F. Gonzalez, [18] Teofilo rithms https://doi.org/10.1201/9781420010749, doi:10.1201/9781420010749. of Approximation Algo- URL: Chapman and Hall/CRC, and Metaheuristics. Handbook editor. 2007. 50 [19] Klaus Jansen and Kim-Manuel Klein. A robust AFPTAS for online bin pack- ing with polynomial migration,. In Fedor V. Fomin, Rusins Freivalds, Marta Z. Kwiatkowska, and David Peleg, editors, Automata, Languages, and Programming - 40th International Colloquium, ICALP 2013, Riga, Latvia, July 8-12, 2013, Pro- ceedings, Part I, volume 7965 of Lecture Notes in Computer Science, pages 589 -- 600. Springer, 2013. URL: https://doi.org/10.1007/978-3-642-39206-1_50, doi:10.1007/978-3-642-39206-1\_50. [20] Klaus Jansen, Kim-Manuel Klein, Maria Kosche, and Leon Ladewig. Online strip packing with polynomial migration. In Klaus Jansen, José D. P. Rolim, David Williamson, and Santosh Srinivas Vempala, editors, Approximation, Ran- domization, and Combinatorial Optimization. Algorithms and Techniques, AP- PROX/RANDOM 2017, August 16-18, 2017, Berkeley, CA, USA, volume 81 of LIPIcs, pages 13:1 -- 13:18. Schloss Dagstuhl - Leibniz-Zentrum fuer Infor- matik, 2017. URL: https://doi.org/10.4230/LIPIcs.APPROX-RANDOM.2017.13, doi:10.4230/LIPIcs.APPROX-RANDOM.2017.13. [21] Klaus Jansen and Roberto Solis-Oba. An asymptotic fully polynomial time ap- proximation scheme for bin covering. Theor. Comput. Sci., 306(1-3):543 -- 551, 2003. doi:10.1016/S0304-3975(03)00363-3. [22] Peter Sanders, Naveen Sivadasan, and Martin Skutella. with bounded migration. https://doi.org/10.1287/moor.1090.0381, doi:10.1287/moor.1090.0381. Math. Oper. Res., 34(2):481 -- 498, 2009. Online scheduling URL: [23] Martin Skutella and José Verschae. Robust polynomial-time approximation schemes for parallel machine scheduling with job arrivals and departures. Math. Oper. Res., 41(3):991 -- 1021, 2016. URL: https://doi.org/10.1287/moor.2015.0765, doi:10.1287/moor.2015.0765. [24] Gerhard J. Woeginger for 1999. variable-sized rithms 50, doi:10.1016/S0167-6377(99)00023-1. URL: and Guochuan Zhang. algo- bin 25(1):47 -- https://doi.org/10.1016/S0167-6377(99)00023-1, Oper. Res. Lett., covering. Optimal on-line 51
1009.0909
2
1009
2011-10-18T17:57:31
Comparing Pedigree Graphs
[ "cs.DS" ]
Pedigree graphs, or family trees, are typically constructed by an expensive process of examining genealogical records to determine which pairs of individuals are parent and child. New methods to automate this process take as input genetic data from a set of extant individuals and reconstruct ancestral individuals. There is a great need to evaluate the quality of these methods by comparing the estimated pedigree to the true pedigree. In this paper, we consider two main pedigree comparison problems. The first is the pedigree isomorphism problem, for which we present a linear-time algorithm for leaf-labeled pedigrees. The second is the pedigree edit distance problem, for which we present 1) several algorithms that are fast and exact in various special cases, and 2) a general, randomized heuristic algorithm. In the negative direction, we first prove that the pedigree isomorphism problem is as hard as the general graph isomorphism problem, and that the sub-pedigree isomorphism problem is NP-hard. We then show that the pedigree edit distance problem is APX-hard in general and NP-hard on leaf-labeled pedigrees. We use simulated pedigrees to compare our edit-distance algorithms to each other as well as to a branch-and-bound algorithm that always finds an optimal solution.
cs.DS
cs
Comparing Pedigree Graphs Bonnie Kirkpatrick∗, Yakir Reshef†, Hilary Finucane‡, Haitao Jiang§, Binhai Zhu¶, Richard M. Karp(cid:107) Abstract Pedigree graphs, or family trees, are typically constructed by an expensive process of exam- ining genealogical records to determine which pairs of individuals are parent and child. New methods to automate this process take as input genetic data from a set of extant individuals and reconstruct ancestral individuals. There is a great need to evaluate the quality of these methods by comparing the estimated pedigree to the true pedigree. In this paper, we consider two main pedigree comparison problems. The first is the pedigree isomorphism problem, for which we present a linear-time algorithm for leaf-labeled pedigrees. The second is the pedigree edit distance problem, for which we present 1) several algorithms that are fast and exact in various special cases, and 2) a general, randomized heuristic algorithm. In the negative direction, we first prove that the pedigree isomorphism problem is as hard as the general graph isomorphism problem, and that the sub-pedigree isomorphism problem is NP-hard. We then show that the pedigree edit distance problem is APX-hard in general and NP-hard on leaf-labeled pedigrees. We use simulated pedigrees to compare our edit-distance algorithms to each other as well as to a branch-and-bound algorithm that always finds an optimal solution. 1 1 0 2 t c O 8 1 ] S D . s c [ 2 v 9 0 9 0 . 9 0 0 1 : v i X r a tional Computer Science Institute, Berkeley, [email protected]. ∗B.K. is with the Electrical Engineering and Computer Sciences, University of California, Berkeley, and Interna- †Y.R. is with the Weizmann Institute of Science, Rehovot, Israel, [email protected]. ‡H.F. is with the Weizmann Institute of Science, Rehovot, Israel, [email protected]. §H.J. Shandong University, China., is with the School of Computer Science and Technology, [email protected]. ¶B.Z. is with the Department of Computer Science, Montana State University, Bozeman, MT 59717, USA, [email protected]. (cid:107)R.M.K. is with the Electrical Engineering and Computer Sciences, University of California, Berkeley, and Inter- national Computer Science Institute, Berkeley, [email protected]. 1 1 Introduction Pedigrees, or family trees, are of interest in a variety of fields. They are interesting to geneticists due to the accuracy with which recombinations can be inferred [11] and with which disease loci can be mapped [23, 24]. Likelihood calculations, i.e. calculations of the probability of observing the data inherited in a given pedigree, are of great interest for mapping disease loci. Pedigrees are objects of interest in computer science due to their close connection with machine learning methods [19, 12]. Many calculations on pedigree graphs are hard [26, 20, 16], but notable attempts have been made to improve the speed of these calculations [7, 13, 21]. Reconstructing pedigrees is thus an interesting but difficult problem. Genealogical methods for reconstructing pedigrees can involve multiple sources with contradictory or missing informa- tion [15, 28, 31, 22, 5]. Due to the error-prone nature of genealogical pedigree reconstruction and the unavailability of genealogical data for some animals, the pedigree reconstruction problem was introduced by Thompson [35] as follows: given genetic data for a set of extant individuals, reconstruct relationships between those individuals that may involve unobserved ancestors. State- of-the-art practical methods include [35, 29, 4, 6, 17] and theoretical work includes [34, 33]. Evaluating reconstruction methods requires inferring a pedigree on an instance for which the true pedigree is known and comparing the inferred and known pedigrees. Both the estimated pedi- gree and the true pedigree will have the same set of extant individuals -- i.e. the individuals having genetic data -- but may have different inferred ancestors. Thus, to compare these two pedigrees, we must compare their topology in a fashion that respects the labels of the extant individuals. Existing methods of comparing pedigrees are insufficient. For example, phylogenetic tree com- parison methods can only be used to compare tree-like pedigrees, but pedigrees can take more general forms. As another example, [17] evaluates accuracy using the kinship coefficient of all pairs of individuals, where the kinship coefficient of two individuals at a single locus is the average number of alleles inherited from the same ancestor. This is a poor accuracy measure, since the kin- ship coefficient is not identifiable. For example, two half-siblings have the same kinship coefficient as an uncle and nephew. A recent result demonstrates non-identifiability of larger pedigrees [27]. Furthermore, the pedigree likelihood is not an acceptable pedigree comparison method both be- cause it requires an exponential-time algorithm and because the non-identifiability of the kinship coefficient may well imply the non-identifiability of the likelihood. While pedigree isomorphisms were discussed very briefly by Steel and Hein [30] in the context of pedigree reconstruction, they did not discuss the pedigree isomorphism problem and its algorithms. Finally, brute force methods of pedigree comparison are not sufficient, as can be seen in our own brute-force comparison where the simulation was limited to pedigrees of fourteen individuals. This is in contrast to pedigree data sets which include thousands of individuals [1, 32]. Other biologists are collecting data from hundreds of individuals from large families -- i.e. 60 individuals per family for salmon [14, 3] -- where brute-force and likelihood methods fall short due to exponential running times. Two natural formulations of the pedigree comparison problem are discussed in this paper: pedigree isomorphism and pedigree edit distance. Two pedigrees are isomorphic if there exists a graph isomorphism which respects the genders of all individuals and the identities of the individuals for which we have genetic data; the pedigree isomorphism problem is to determine whether two pedigrees are isomorphic. The more difficult pedigree edit distance problem is to determine how many edge insertions and deletions are needed for two pedigrees to become isomorphic. In this paper, we formalize the isomorphism and edit distance problems, provide useful algo- rithms for certain instances of these problems, and give four hardness results. The algorithms 2 Figure 1: An Example Pedigree. This pedigree has edges implicitly directed downward from parent to child and shows two founding grand-parents, their four children, two inbred grand- children and two inbred great-grand-children. Each edge represents the transmission from parent i to offspring j of a single (possibly recombinant) copy of each chromosome. we present include a fast algorithm for leaf-labeled pedigree isomorphism and a polynomial-time dynamic programming algorithm for the edit distance of sufficiently similar pedigrees. For general pedigrees, we present a heuristic algorithm for the edit distance. Our first hardness result is that pedigree isomorphism is as hard as general graph isomorphism, making it GI-hard. The reduction we use also shows that sub-pedigree isomorphism is as hard as sub-graph isomorphism, making it NP-hard. The third and fourth hardness results show APX- hardness for the edit distance problem in general and NP-hardness on pedigrees whose leaves are all labeled. 2 Preliminaries A pedigree P = (P, s, X, (cid:96)) consists of a pedigree graph P = (I(P ), E(P )) with vertices I(P ) and edges E(P ), a gender function s : I(P ) → {m, f}, a set X ⊆ I(P ) of labeled individuals, and an injective labeling (cid:96) : X → N, such that: 1. P is directed and acyclic. 2. For all v ∈ V , the in-degree of v is either two or zero. 3. If (a, v), (b, v) ∈ E, then s(a) (cid:54)= s(b). P is called the pedigree graph of P. Vertices of P are called the individuals of P. Individuals with in-degree zero are founders while individuals with in-degree two are non-founders. Individ- uals with out-degree zero are called leaf individuals. For an individual x ∈ X, (cid:96)(x) is the label assigned to x. We will sometimes write P = (P, s) to mean P = (P,∅, s, (cid:96)) with trivial (cid:96). When X = I(P ), we will say that P is fully labeled. If the reference pedigree is clear, we may write I to refer to I(P ). Figure 1 depicts an example of a fully labeled pedigree. The labeled individuals X ⊆ I typically have an available DNA sample on which genotyping or sequencing can be performed. While it may be algorithmically convenient to assume that we have samples for all individuals, X = I, this assumption is quite impractical. Very often, there are individuals represented in the pedigree who are deceased and for whom samples are unavailable. There are circumstances in which there will be no labeled individuals, i.e., X = ∅. Then we would want to rely on the genealogical structure alone in determining whether the same individuals appear in the two pedigree graphs. 3 12345678910 A pedigree P = (P, s, X, (cid:96)) is leaf-labeled if X contains exactly the leaf-individuals of P. Very often this is the case since, for likelihood calculations, one is only interested in the individuals for whom identifying data exist. Two pedigrees P = (P, s, X, (cid:96)) and P(cid:48) = (P (cid:48), s(cid:48), X(cid:48), (cid:96)(cid:48)) are compatibly leaf-labeled if both are leaf-labeled and for every leaf individual v ∈ I(P ), there is a leaf individual v(cid:48) ∈ I(P (cid:48)) such that (cid:96)(v) = (cid:96)(cid:48)(v(cid:48)) and vice versa. Given two leaf-labeled pedigree graphs P and Q, we can always obtain new pedigree graphs P (cid:48) and Q(cid:48) that are compatibly leaf-labeled. This is done by performing a depth-first search starting at each compatibly leaf-labeled individual v, following parent-child edges backward in time, and then pruning those individuals which were not visited by the depth- first search. This is interesting, because this allows us to detect an isomorphic subgraph which is compatibly leaf-labeled. A pedigree gives rise to sub-pedigrees in the following way. If two pedigrees P = (P, s, X, (cid:96)) and P(cid:48) = (P (cid:48), s(cid:48), X(cid:48), (cid:96)(cid:48)) satisfy: 1. I(P (cid:48)) ⊆ I(P ) and P (cid:48) is the subgraph of P induced by I(P (cid:48)), 2. X(cid:48) = X ∩ I(P (cid:48)), 3. (cid:96)(cid:48) = (cid:96)I(P (cid:48)), and 4. s(cid:48) = sI(P (cid:48)), then we say that P(cid:48) is a sub-pedigree of P, and write P(cid:48) ⊆ P. Given a set A ⊆ I(P ), we will write PA to denote the minimal sub-pedigree of P containing the vertices in A. Likewise, if A ⊆ E(P ), we write PA to denote the minimal sub-pedigree of P containing the edges in A. There are two additional types of pedigrees in which we are interested: monogamous and generational pedigrees. A pedigree P = (P, s, X, (cid:96)) is monogamous if all the individuals are monogamous. An individual v ∈ I(P ) is monogamous if the number of individuals v(cid:48) (cid:54)= v such that (v, u), (v(cid:48), u) ∈ E(P ) for some u ∈ I(P ) is at most 1. A pedigree P = (P, s, X, (cid:96)) is generational if there exists a function G : I(P ) → N such that 1. G(v) = 1 for some v ∈ I(P ) where v has in-degree zero, and 2. If (u, v) ∈ E(P ), then G(v) = G(u) + 1. The number G(v) is called the generation of v, and G is called the generation map of P. Whenever P is a generational pedigree with pedigree graph P , we will use Ig(P ) to denote the individuals of P whose generation is g. We will say that a pedigree is connected if its pedigree graph is weakly connected. It is easy to see that a connected, generational pedigree has a unique generation map. The maximal value of this map is the number of generations of the pedigree. the following conditions hold: 2.1 Pedigree Isomorphism We now define the notion of an isomorphism between pedigrees. To do so, we first present the more general idea of a matching between pedigrees. Definition 2.1. Given two pedigrees P = (P, s, X, (cid:96)) and P(cid:48) = (P (cid:48), s(cid:48), X(cid:48), (cid:96)(cid:48)), and a set Y ⊆ I(P ), an injective map M : Y → I(P (cid:48)) is a pedigree matching between P and P(cid:48) if it satisfies the following conditions. 1. For every v ∈ Y , s(v) = s(cid:48)(M (v)). 2. For all n ∈ (cid:96)(X) ∩ (cid:96)(cid:48)(X(cid:48)), Y contains (cid:96)−1(n) and M ((cid:96)−1(n)) = ((cid:96)(cid:48))−1(n). 4 Informally, the second condition states that M should respect the labellings (cid:96) and (cid:96)(cid:48) in the sense that if (cid:96) and (cid:96)(cid:48) give the same label to two vertices u and v respectively, then M should match u up to v. We can now characterize a pedigree isomorphism as a matching that is also a graph isomorphism between the two pedigree graphs. Definition 2.2. Given two pedigrees P = (P, s, X, (cid:96)) and P(cid:48) = (P (cid:48), s(cid:48), X(cid:48), (cid:96)(cid:48)), a bijection φ : I(P ) → I(P (cid:48)) is a pedigree isomorphism between P and P(cid:48) if: 1. φ is a pedigree matching between P and P(cid:48), and 2. (u, v) ∈ E(P ) if and only if (φ(u), φ(v)) ∈ E(P (cid:48)) The Pedigree Isomorphism Problem. Given two pedigrees P and P(cid:48), does there exist a pedigree isomorphism between them? The Compatibly Leaf-Labeled Pedigree Isomorphism Problem. Given two compatibly leaf-labeled pedigrees P and P(cid:48), does there exist a pedigree isomorphism between them? The Sub-Pedigree Isomorphism Problem. Given two pedigrees P and P(cid:48), does there exist a pedigree isomorphism between P and some sub-pedigree of P(cid:48)? In this paper, we will show that the compatibly leaf-labeled pedigree isomorphism problem can be solved in linear time. We will also show that the pedigree isomorphism problem is as hard as the general graph isomorphism problem, and that the sub-pedigree isomorphism problem is NP-hard. 2.2 Edit Distance We are interested not only in determining whether two pedigrees are isomorphic, but also in how close they are to being isomorphic. Such a measure of distance between pedigrees would be useful for evaluating pedigree reconstruction methods: we could take a known pedigree, extract a subset of its individuals, reconstruct a pedigree from those individuals using our method of choice, and check the distance between the reconstructed pedigree and the true pedigree. Informally, given two arbitrary pedigrees P = (P, s, X, (cid:96)) and P(cid:48) = (P (cid:48), s(cid:48), X(cid:48), (cid:96)(cid:48)), we want to find the minimum number of edge additions/deletions required to convert P into P(cid:48). We call this the edit distance between P and P(cid:48). Notice that it is not necessary that I(P ) = I(P (cid:48)), because addition/deletion of edge-less vertices will be free. Formally, we can define edit distance in terms of matchings between pedigrees. To do this, we need to measure how close a matching is to being a pedigree isomorphism. This is done by looking at the set of edges that are well matched by the matching. Definition 2.3. Given two pedigrees P = (P, s, X, (cid:96)) and P(cid:48) = (P (cid:48), s(cid:48), X(cid:48), (cid:96)(cid:48)) and a matching M : Y → I(P (cid:48)) between them, the set WM of edges well-matched by M is defined by WM = {(u, v) ∈ E(P ) : u, v,∈ Y, (M (u), M (v)) ∈ E(P (cid:48) )}. Notice that the subgraph of P induced by the edges in WM is isomorphic to the subgraph of P (cid:48) induced by the edges in M (WM ). Therefore, M implicitly defines an edit path from P to P (cid:48): delete all the edges in E(P ) − WM , then add all the edges in E(P (cid:48)) − M (WM ). Moreover, the shortest edit path from P to P (cid:48) must consist only of removing edges from P and adding edges from P (cid:48), and so can be obtained in this way from a matching (up to the order in which edges are added and removed, which does not affect the length of the edit path). With this in mind, we define the match distance incurred by M to be length of the corresponding edit path: 5 Definition 2.4. Given two pedigrees P = (P, s, X, (cid:96)) and P(cid:48) = (P (cid:48), s(cid:48), X(cid:48), (cid:96)(cid:48)) and a matching M : Y → I(P (cid:48)) between them, the match distance of M is where dP (M ) = E(P ) − WM and dP (cid:48)(M ) = E(P (cid:48)) − M (WM ) d(M ) = dP (M ) + dP (cid:48)(M ) Now the edit distance is the length of the shortest edit path; in other words, the smallest possible match distance between the two pedigrees. Definition 2.5. Given two pedigrees P = (P, s, X, (cid:96)) and P(cid:48) = (P (cid:48), s(cid:48), X(cid:48), (cid:96)(cid:48)), the edit distance between P and P(cid:48) is DP,P(cid:48) = min M d(M ). The edit distance between two pedigrees can be calculated by finding a matching M with a maximum number of well-matched edges. The following proposition, which we state without proof, formalizes this. Proposition 2.1. Given two pedigrees P and P(cid:48), a matching M between P and P(cid:48) for which WM is maximized satisfies DP,P(cid:48) = d(M ). The Pedigree Edit Distance Problem. For pedigrees P and P(cid:48), find a matching M between P and P(cid:48) such that d(M ) = DP,P(cid:48). Notice that a pedigree isomorphism, if it exists, has a match distance of 0. In this paper, we will give efficient algorithms for a few different restrictions of the pedigree edit distance problem. The four main problems and their hardness, as established in this paper, are shown in the table. Compatibly Leaf-Labeled Not Labeled Isomorphism Edit Distance Linear alg. GI-hard NP-hard APX-hard 3 A Linear-Time Algorithm for the Compatibly Leaf-Labeled Pedigree Isomorphism Problem In this section, we introduce a linear-time algorithm for the compatibly leaf-labeled pedigree iso- morphism problem. In particular, we will establish that if all leaves are labeled then there exists a total order on the individuals that is easy to calculate. The total orders, calculated on both pedigrees, are such that if an isomorphism exists between two compatibly leaf-labeled pedigrees, it can be easily found from these total orders. Proposition 3.1. There exists a linear-time algorithm for the compatibly leaf-labeled pedigree iso- morphism problem. Proof. We define gender topological sort as follows. Recall that the traditional topological sort algorithm does a depth first search (DFS), and when each node is finished being visited, it gets pushed into the ordered list. Gender topological sort consists of a DFS of the ancestor tree of each leaf, where the female parent is always visited before the male parent (i.e. the DFS visits in the opposite direct of the directed edge). From a single leaf, this rule determines the order in which the 6 ancestral nodes of the leaf are visited. Now, we simply use the leaf labeling to sort the leaves, and we begin our DFS from each leaf in sorted order. This algorithm finds a total order on the nodes of the pedigree that is fully determined by the topology, gender, and leaf labels of the pedigree. Let the binary relation < be the total order found by the above gender topological sort. Let n = I(P ) = I(P (cid:48)). (If I(P ) (cid:54)= I(P (cid:48)) then there is no isomorphism.) The nodes of pedigree P are ordered via gender topological sort so that p1 < p2 < ... < pn where pi ∈ I(P ). Similarly, the nodes of pedigree P(cid:48) are ordered so that p(cid:48) i ∈ I(P (cid:48)). Because n where p(cid:48) isomorphism preserves topology, gender, and labels, it must also preserve this total order. Thus, if an isomorphism exists between P and P', it must be φ defined as φ(pi) = p(cid:48) i. So to check whether P and P(cid:48) are isomorphic, it suffices to compute the gender topological sort for each pedigree, and then check whether φ is an isomorphism. 2 < ... < p(cid:48) 1 < p(cid:48) The running time of this isomorphism algorithm is linear, since the gender topological sort is linear, and after obtaining φ, checking that the genders, edges, and labels are preserved also requires linear time. Notice that a small modification of this algorithm can find leaf-labeled subgraph isomorphisms. 4 Algorithms for Computing the Edit Distance We show later in this paper that, even for monogamous pedigrees, there is no polynomial-time approximation scheme for the edit distance problem unless P = N P . In this section, we show that if we restrict the scope of the problem, efficient algorithms are possible. Specifically, we will give exact, efficient algorithms for the following two restricted cases of the pedigree edit distance problem. In this section we assume that the pedigrees are connected, but this condition can be easily removed. 1. The case in which the two pedigrees are generational, compatibly leaf-labeled, and both have two generations. 2. The case in which the two pedigrees are generational, compatibly leaf-labeled, and "sufficiently similar". By sufficiently similar we mean that there exists an optimal matching between the pedigrees that preserves generations and that for any two consecutive generations i and i + 1, the distance between the two sub-pedigrees obtained by restricting both pedigrees to generations i and i + 1 is small. Our algorithm for this case has the advantage that its run-time improves as the pedigrees become more similar. We then give a randomized heuristic that appears to work well in the general case and is based on an alternate characterization of pedigrees in terms of lists of descendants rather than parent-child relationships, as well as a faster heuristic for the second case listed above. In the rest of this section, we will denote the two pedigrees under consideration by P = (P, s, X, (cid:96)) and P(cid:48) = (P (cid:48), s(cid:48), X(cid:48), (cid:96)(cid:48)). 4.1 Exact Algorithm for Two-Generation, Compatibly Leaf-Labeled Pedigrees When P and P(cid:48) are connected, generational, compatibly leaf-labeled, and have two generations each, the edit distance between them can be calculated in polynomial time. We find this distance by constructing two maximum-weight bipartite matching instances, one for each gender, whose 7 solutions give us an optimal matching between P and P(cid:48). In doing this, we are maximizing the number of well-matched edges, which is equivalent to minimizing the distance. Recall that Ig(P ) is the set of individuals in the gth generation of P . Our assumption that both pedigrees are compatibly leaf-labeled determines the matching M on I2(P ): map each v ∈ I2(P ) to ((cid:96)(cid:48))−1((cid:96)(v)) ∈ I2(P (cid:48)). In addition, we may assume without loss of generality that no individuals in the oldest generation of P and P (cid:48) are labeled. This is because the labels that I1(P ) and I1(P (cid:48)) share determine the matching on those vertices, and the labels not shared are irrelevant to the edit distance. 1 (P ) and I m 1 (P (cid:48)) and I m It is left to extend M optimally to I1(P ). To do this, we first define I f 1 (P ) to 1 (P (cid:48)) analogously. Now, be the females and males of I1(P ) respectively, and define I f for each gender s, we construct a complete bipartite graph Gs with left vertices I s 1(P ) and right 1(P (cid:48)) where the weight assigned to an edge (u, v) is the number of children of u who are vertices I s matched by M to children of v. Together with Proposition 2.1, the following proposition establishes that solving the maximum-weight bipartite matching instances Gf and Gm will yield an optimal matching of P and P(cid:48). Proposition 4.1. For s ∈ {m, f}, let M s be a perfect matching in Gs, and extend the matching M to a matching ¯M defined on all of I(P ) as follows: for v ∈ I1(P ), define M (v) to be the vertex matched to v by M s(v). Then the number of edges well-matched by ¯M is the sum of the weights of M f and M m. 4.2 Exact Algorithm for Sufficiently Similar, Generational, Compatibly Leaf- Labeled Pedigrees Suppose that there exists an optimal matching M between P and P(cid:48) that is generation preserving (i.e., such that the generation of v equals the generation of M (v) for all individuals v matched by M ). We will also assume for simplicity that P and P(cid:48) are each made up of g generations of m males and m females each, though this assumption can be easily removed. If the pedigree graphs P and P (cid:48) are similar enough, we can use dynamic programming to find an optimal matching between them in time exponential only in the edit distance. Thus, we have a polynomial-time algorithm if, for any two consecutive generations i and i + 1, the edit distance between the two sub-pedigrees obtained by restricting both pedigrees to generations i and i + 1 is at most O(log(n)/g), where n is the number of pedigree individuals. To describe our algorithm, we first introduce some notation. Given some S ⊆ {1, 2, ..., g}, we let PS denote the minimal sub-pedigree of P that contains Ii(P ) for every i ∈ S, and we define P(cid:48)S analogously. We can then write M(S) to denote the set of all generation-preserving matchings from PS to P(cid:48)S; note that M(S) = ×i∈SM({i}) where M({i}) is the set of matchings of generation i. Given a generation-preserving matching M , let dS(M ) be the match distance incurred by M restricted to be a matching between PS and P(cid:48)S, and let Bi(M ) be the edit distance between P{i,...,g} and P(cid:48){i,...,g} taken only over matchings that agree with M wherever M is defined. As in the previous section, we assume without loss of generality that only the leaf individuals of either pedigree are labeled. The algorithm we present rests on the following relation. 8 Lemma 4.1. For every i ∈ {1, . . . , g − 1}, and for every M ∈ M({i}), we have (cid:48) ) + d{i,i+1}(M ∪ M (cid:48) ) min Bi+1(M Bi(M ) = M(cid:48)∈M({i+1}) (1) where M ∪ M(cid:48) ∈ M({i, i + 1}) denotes the matching that equals M on P{i} and M(cid:48) on P(cid:48){i+1}. Lemma 4.1 gives rise to a simple dynamic programming algorithm: start with the matching of the gth generation determined by the labellings of the leaves, then iteratively work up the pedigree, using the lemma above to find, for every i, the values of Bi(M ) for every M ∈ S({i}). The edit distance is then given by min M∈M({1}) B1(M ). However, the problem with this straightforward algorithm is that because it needs to consider every possible matching M ∈ M({i}), its run-time is factorial in m, the number of males/females in each generation. At each generation, there are (m!)2 possible matchings M to process, and performing the minimization for each matching takes time O((m!)2). Therefore, the run-time of this algorithm is O(g(m!)4). We can improve the algorithm if we know that the two pedigrees under consideration are suffi- ciently similar at each generation and so there is no need to consider all matchings for each genera- tion. Suppose we are promised that an optimal matching ¯M between P and P(cid:48) has d{i,i+1}( ¯M ) < k for every 1 ≤ i < g. Then in the algorithm above we would only need to process, for each i and each M ∈ M({i}), the matchings M(cid:48) ∈ M({i + 1}) such that d{i,i+1}(M ∪ M(cid:48)) < k. This enumeration can be done, for a fixed M(cid:48) ∈ M({i + 1}) of the previous generation, by recursively matching vertices to gradually define M ∈ M({i}), all the time avoiding any assignment that would violate the condition d{i,i+1}(M ∪ M(cid:48)) < k. The case of a small edit distance is particularly interesting. Our simulations, see Fig. 3, show that when some number x of random changes are made to a pedigree, the edit distance is close to x when x is small but for larger values of x, some changes cancel each other out and the edit distance grows more slowly than x. Thus, when the edit distance is small, it corresponds more closely to the actual number of changes made. How many matchings are considered by this method? The following two lemmas establish an upper bound of m2k on this quantity. Lemma 4.2. For every fixed M(cid:48) ∈ M({i + 1}), the number of matchings M ∈ M({i}) such that d{i,i+1}(M ∪ M(cid:48)) < k is at most T (m, k)2, where T satisfies the recurrence relation T (n, c) = T (n − 1, c) + (n − 1)T (n − 1, c − 2) with initial conditions T (1,·) = 1 and T (n, 0) = T (n, 1) = 1. Proof. First, suppose that there are only m individuals to match (i.e. that there is only one gender). Initially, there are m individuals to match and k "cost points" that can be used in doing so. In the best case, given some u ∈ P{i}, there is at most one choice for M (u) that does not increase the cost of the matching being built. This follows from the fact that u has at least one child (otherwise u is a labeled leaf and so M (u) is already determined), who is already matched somewhere by M(cid:48). Besides this option for M (u), there are at most m− 1 other options, each of which will increase the cost of the matching by at least 2 (since at least one edge will have to be deleted and one edge will have to be added). This establishes the recurrence. The initial conditions follow from the following facts: 9 1. When one individual is left to be matched, there is only one possible way to complete the matching being built. 2. When the matching being built already has distance k (i.e. there are 0 cost points left), there is at best only one way to complete the matching. This bounds the number of matchings of each gender by T (m, k). Since this process occurs inde- pendently for each gender, the number of total matchings is at most T (m, k)2. Lemma 4.3. The recurrence T in Lemma 4.2 satisfies T (n, c) = O(nc). Proof. We proceed by induction on c. The initial conditions of T give us our base cases of c = 0, 1. The general case follows from bounding the difference between successive values of T (·, c): the recurrence gives us that T (n, c)− T (n− 1, c) = (n− 1)T (n− 1, c− 2), which is n· O(nc−2) = O(nc−1) by the inductive hypothesis. Thus, the number of matchings to be considered at generation i is m2k times the number of matchings to be considered at generation i + 1. So the run-time of this algorithm is dominated by its last step, in which matchings between the oldest generations of P and P(cid:48) are considered and the best one is chosen; the number of these matchings is at most O(m2k(g−1)) = O(m2d) where d is the maximum possible distance between the two pedigrees. Thus, if k (the distance between pairs of successive generations) and g (the number of generations) are small, the algorithm can efficiently calculate edit distance. This algorithm always finds the correct edit distance, when the upper bound k is known. When k is not known, the algorithm can be adapted to a heuristic by guessing a reasonable k, and if there is a step with no matching within distance k, the algorithm is aborted and the randomized heuristic (described below) is used instead. In Section 6, we show by comparison to a branch-and-bound algorithm that tries all possible matchings that this heuristic adaptation often finds the correct edit distance when used on randomly generated pedigrees. 4.3 Heuristic Improvement of Dynamic Programming Algorithm We can turn the dynamic programming algorithm from Section 4.2 into a faster heuristic by enu- merating a still smaller set of matchings. For each generation and for a fixed labeling of the previous generation, we can create an instance of the maximum-weight bipartite matching prob- lem. However, instead of solving the problem exactly, we can enumerate its γ best solutions and consider those matchings only. Since this can be done in time O(γm3) (see [8]), this improves the running-time of the algorithm to O(m3γg−1). 4.4 Randomized Heuristic for Compatibly Leaf-Labeled Pedigrees The randomized matching algorithm for regular pedigrees rests on the idea of viewing pedigrees not as lists of parent-child relationships, but rather as sets of so-called descendant splits. The descendant split of an individual u ∈ I(P ) is the set of individuals v ∈ I(P ) such that there is a directed path from u to v. When a pedigree is fully labeled, its full set of descendant splits uniquely specifies it. For more on descendant splits see [18]. The heuristic calculates the match distance incurred by a matching that is randomly selected as follows: at each generation, among individuals of the same gender, an individual u ∈ I(P ) is 10 matched to v ∈ I(P (cid:48)) with probability proportional to the number of individuals in the descendant splits of the two individuals which are identically labeled. This can be done in polynomial time by creating, for each generation, an m × m matrix of individual match probabilities for each gender (where there are 2m individuals per generation). The matches are then drawn from these probability matrices (without replacement of previously matched individuals). This can be done multiple times to increase the chances of finding a 'good' matching. This algorithm is difficult to analyze because different leaves do not always have disjoint paths to the vertex being matched. However, we show in simulations (Section 6) that it performs reasonably well relative to a branch-and-bound algorithm that considers all possible matchings. 5 Hardness Results Having presented algorithms for various restrictions of the pedigree isomorphism and edit distance problems, we now establish the difficulty of solving the general versions of these problems. Specif- ically, we give hardness results for the pedigree isomorphism problem (GI-Hard), the sub-pedigree isomorphism problem (NP-Hard), the pedigree edit distance problem (APX-Hard), and the com- patibly leaf-labeled pedigree edit distance problem (NP-Hard). The first few proofs require that X = ∅, while the final proof considers compatibly leaf-labeled pedigrees. 5.1 The Hardness of Pedigree Isomorphism and Sub-Pedigree Isomorphism 5.1.1 Pedigree Isomorphism is GI-Hard We begin by showing that the pedigree isomorphism problem is as hard as the general graph isomorphism problem. Graph isomorphism is one of very few problems not known to be in P that is also not known to be NP-Hard. Problems that are as hard as graph isomorphism are known as GI-Hard. To show our hardness result, we reduce from bipartite graph isomorphism, which is known to be GI-Hard [36]. Reduction: Given a bipartite graph G = (V1 ∪ V2, E), we define a pedigree P(G) = (P, s). Intuitively, each vertex u ∈ V1 is replaced with two vertices, a male denoted um and a female denoted uf , and for each edge (u, v) in E, the couple corresponding to um and uf have two children, a male denoted (u, v)m and a female denoted (u, v)f . This gives as many couples corresponding to v as there are edges going into v. To encode the fact that all of these couples correspond to edges with the same vertex v ∈ V2, we have every member of the form (u, v)m for some u ∈ V1 mate with every member of the form (u(cid:48), v)f for some u(cid:48) ∈ V1 to obtain a female child which we denote (u, u(cid:48), v)f . Formally, this gives us the following pedigree graph: • I(P ) = I1 ∪ I2 ∪ I3, where -- I1 = {um, uf : u ∈ V1} -- I2 = {(u, v)m, (u, v)f : (u, v) ∈ E} -- I3 = {(u, u(cid:48), v)f : (u, v), (u(cid:48), v) ∈ E} • E(P ) = E1 ∪ E2, where -- E1 = {(us, (u, v)s(cid:48) ) : (u, v) ∈ E, s, s(cid:48) ∈ {m, f}} 11 -- F2 = {((u, v)m, (u, u(cid:48), v)f ), ((u, v)f , (u(cid:48), u, v)f ) : (u, v), (u(cid:48), v) ∈ E} By construction, we have: Lemma 5.1. P is a pedigree graph. Next, we show: Proposition 5.1. Two bipartite graphs G = (V1 ∪ V2, E) and G(cid:48) = (V (cid:48) 2, E(cid:48)) with no isolated vertices are isomorphic if and only if the two pedigrees P(G) = (P, s) and P(G(cid:48)) = (P (cid:48), s(cid:48)) are isomorphic. Proof. (⇒:) Suppose we have a graph isomorphism ϕ : V1 ∪ V2 → V (cid:48) the following definitions give a map φ : I(P ) → I(P (cid:48)) that is a pedigree isomorphism. 2. It is easy to verify that 1 ∪ V (cid:48) 1, V (cid:48) • φ(us) = ϕ(u)s for us ∈ I1 • φ((u, v)s) = (ϕ(u), ϕ(v))s for (u, v)s ∈ I2 • φ((u, u(cid:48), v)f ) = (ϕ(u), ϕ(u(cid:48)), ϕ(v))f for (u, u(cid:48), v)f ∈ I3 (⇐:) We write I(P ) = I1 ∪ I2 ∪ I3 and write I(P (cid:48)) = I(cid:48) 1 ∪ I(cid:48) 1 ∪ I(cid:48) 2 ∪ I(cid:48) 2 ∪ I(cid:48) 3. Using this notation, our 3 that is a graph isomorphism 2 as follows. assumption gives us an injective map φ : I1 ∪ I2 ∪ I3 → I(cid:48) between P and P (cid:48). We observe that φ must map Ij to I(cid:48) j because φ preserves sources and sinks. We also note that φ must preserve familial relationships. We can therefore define the graph isomorphism ϕ : V1 ∪ V2 → 1 ∪ V (cid:48) V (cid:48) • For u ∈ V1, set ϕ(u) = u(cid:48), where u(cid:48) ∈ V (cid:48) • For v ∈ V2, let U ⊂ V1 be the neighbors of v. Because U is non-empty, there exists by construction a set of vertices in I2 corresponding to v, all of whom mate with each other and no one else. Because it is a pedigree isomorphism, φ sends this set to a set in I(cid:48) 2 all of whom mate with each other and no one else, and which thus corresponds to a vertex v(cid:48) ∈ V (cid:48) 2. We set ϕ(v) = v(cid:48). 1 is such that φ(us) = u(cid:48)s for s ∈ {m, f}. We now show that if (u, v) is an edge in G, then (ϕ(u), ϕ(v)) is an edge in G(cid:48), making ϕ a graph isomorphism. Suppose (u, v) is an edge in G. Then the vertex (u, v)m exists in I(P ), and there is an edge from um to (u, v)m in P . Then in P (cid:48), there is an edge from φ(um) = ϕ(u)m to φ((u, v)m) = (ϕ(u), ϕ(v))m. But then there must be an edge from ϕ(u) to ϕ(v) in G(cid:48). The case of bipartite graphs with isolated vertices is easy to handle when checking for bipartite graph isomorphism: we ensure that there are the same number of isolated vertices in either graph, remove them, and then check for isomorphism. Therefore, Proposition 5.1, together with the fact that bipartite graph isomorphism is at least as hard as general graph isomorphism, gives us the following theorem. Theorem 5.1. The pedigree isomorphism problem is GI-hard. 12 5.1.2 Sub-Pedigree Isomorphism is NP-Hard The reduction given in the previous section is easily adapted to show that sub-pedigree isomorphism is as hard as bipartite sub-graph isomorphism. Since bipartite sub-graph isomorphism is NP-hard by a trivial reduction from bipartite Hamiltonian cycle [2], this gives us the following result. Theorem 5.2. The sub-pedigree isomorphism problem is NP-Hard. Notice that Theorem 5.2 already implies the following corollary about the hardness of the pedigree edit distance problem. Corollary 5.1. The pedigree edit distance problem is NP-hard. Proof. By reduction from sub-pedigree isomorphism: P = (P, s) is a sub-pedigree of P(cid:48) = (P (cid:48), s(cid:48)) if and only if the edit distance between them is exactly E(P ) − E(P (cid:48)). In the next section, we will improve this result by showing that the pedigree edit distance problem is hard even to approximate in polynomial time. 5.2 Pedigree Edit Distance is APX-Hard Our results about the hardness of sub-pedigree isomorphism implied that pedigree edit distance is NP-hard. We now strengthen this result, showing that pedigree edit distance is APX-hard. Remark. There is extensive literature on the hardness/tractability of the more general problem of inexact graph matching [10, 38]. However, these hardness results do not apply to our edit distance -- perhaps the hard cases of inexact graph matching are non-pedigrees. Our reduction will actually establish the hardness of the following problem: The Minimum Cut/Paste Distance between Trees (MCPDT) Problem: Given two di- rected rooted unlabeled trees T1, T2, and a natural number k, can T1 be converted into T2 using k edge additions/deletions? Showing that MCPDT is hard suffices to establish the hardness of the pedigree edit-distance problem because an arbitrary unlabeled tree can be trivially turned into an unlabeled monogamous pedigree: consider all nodes of the tree to be female and add a founding male mate to each non-leaf in the tree. This transformation doubles the cut/paste distance between trees because it exactly doubles the number of edges in each tree. Remark. Notice that the cut/paste distance between trees is different from the subtree-prune-and- regraft (rSPR) operation for binary phylogenetic trees, since rSPR involves maintaining the binary property of a phylogenetic tree [37] and the leaves of a phylogenetic tree are labeled. (In contrast, here we have unlabeled trees that are not binary.) To show that MCPDT is hard, we reduce from Minimum Common Integer Partition. A partition of a positive integer n is a multiset of positive integers that add up to exactly n. For example, {3, 2, 2, 1} is a partition of 8. A partition of a multiset S is a multiset union of partitions of integers in S. A multiset X is a common partition of two multisets S1, S2 if it is an integer partition of both S1 and S2. For example, given S1 = {8, 5}, S2 = {9, 4}, X = {5, 3, 2, 2, 1} is a common partition of S1, S2. 13 The Minimum Common Integer Partition (MCIP) Problem: Given two multisets of integers S1, S2 find the common integer partition of S1 and S2 with minimum cardinality. Our result will rely on the following fact, proven in [9]. Fact 5.1. MCIP is APX-hard. We now reduce MCIP (Minimum Common Integer Partition) to MCPDT (Minimum Cut/Paste Distance between Trees) with an L-reduction [25]. Reduction: Given S1 = {n1, n2, ..., np}, S2 = {m1, m2, ..., mq}, we construct two trees T1, T2 with roots r1, r2 such that for each 1 ≤ i ≤ p (resp. 1 ≤ j ≤ q) there is a distinct path from r1 (resp. r2) of length ni (resp. mj). For example see Figure 2. This means that we need to cut T1, T2 into a common forest in which each tree except the ones containing r1, r2, is a path. Figure 2: An example for the reduction. Let S1 = {8, 5, 1} and S2 = {10, 4}. The optimal number of cut/paste operations is 2. Proposition 5.2. MCPDT is APX-hard. Proof. We prove that the reduction given above is an L-reduction. Let opt(MCIP) and A(MCIP) be the values of the optimal and approximate solutions, respectively, of our instance of MCIP. Let min = min{p, q}. Then the value of the optimal solution for our instance of MCPDT is opt = opt(MCIP)− min. In other words, we can conclude that S1, S2 has common integer partition of size k if and only if T1, T2 each can be cut into a common forest with k − min cuts. Moreover, A(MCPDT) = A(MCIP)− min is the value of a feasible solution of MCPDT. Clearly we have 1. opt ≤ α · opt(MCIP), by setting α = 1. 2. opt(MCIP) − A(MCIP) ≤ β · opt − A(MCPDT), by setting β = 1. To see the second claim, notice that opt − A(MCPDT) = opt − (A(MCIP) − min) = opt(MCIP) − A(MCIP) Therefore, this reduction is an L-reduction. As MCIP is APX-hard, MCPDT is also APX-hard. 14 r1r2cut851104cutcutcut This result implies that unless P=NP, there is no PTAS for MCPDT, and so the pedigree edit distance problem is APX-hard in general. Theorem 5.3. The pedigree edit distance problem is APX-hard. Certainly for leaf-labeled trees, it is well known that there is a polynomial-time algorithm for computing cut/paste distance (i.e. on trees). However, this algorithm does not work for leaf-labeled pedigree graphs. Next we establish the hardness of the leaf-labeled edit distance. 5.3 Compatibly Leaf-Labeled Pedigree Edit Distance is NP-Hard To prove the hardness of the compatibly leaf-labeled edit distance problem, we will take an instance of the edit distance problem without leaf labels (i.e. X = ∅), and create an instance of the compat- ibly leaf-labeled edit distance problem whose solution allows us to compute the edit distance for the original edit distance instance. Theorem 5.4. The leaf-labeled pedigree edit distance problem is NP-hard. Proof. Given non-labeled pedigrees P = (P, s) and P(cid:48) = (P (cid:48), s(cid:48)), we define compatibly leaf-labeled pedigrees Q = (Q, X, t, (cid:96)) and Q(cid:48) = (Q(cid:48), X(cid:48), t(cid:48), (cid:96)(cid:48)) as follows. Q is obtained from P by adding, for each individual u ∈ I(P ), an individual u(cid:48) of the opposite gender, and, for each individual v ∈ I(P (cid:48)), a new individual iu,v which is the child of u and u(cid:48). Q(cid:48) is obtained from P(cid:48) similarly: for each individual v ∈ I(P (cid:48)) and u ∈ I(P ), we create an individual jv,u in I(Q(cid:48)) which is the child of v and v(cid:48), where v(cid:48) is a founder individual of the opposite gender as v, also added to I(Q(cid:48)). Now Q and Q(cid:48) have leaf sets {iu,v} and {jv,u}, respectively. Let (cid:96) be defined arbitrarily on {iu,v}, and let (cid:96)(cid:48)(jv,u) = (cid:96)(iu,v). Then Q and Q(cid:48) are compatibly leaf-labeled pedigrees. The following proposition completes the proof of the theorem: Proposition 5.3. DP,P(cid:48) = DQ,Q(cid:48) − 2 (I(P )I(P (cid:48)) − min{I(P ),I(P (cid:48))}) Proof. Without loss of generality, we assume that I(P ) ≤ I(P (cid:48)). Suppose that DP,P(cid:48) = d. Then there is a matching M that achieves this distance and we may assume that the M is defined on all of I(P ), because if not we can extend M arbitrarily to all of I(P ) without changing the match distance. M extends uniquely to a matching N defined on all of I(Q) that respects the labels of the added leaf individuals and such that N (u(cid:48)) = M (u)(cid:48). We now note that, for every individual on which M is defined, N will have exactly one additional well-matched edge. Therefore, WN = WM+I(P ). We also have E(Q) = E(P ) + I(P )I(P (cid:48)) and E(Q(cid:48)) = E(P (cid:48)) + I(P )I(P (cid:48)). This gives that DQ,Q(cid:48) ≤ d + 2I(P )I(P (cid:48)) − 2I(P ) by Definitions 2.4 and 2.5. Now suppose that DQ,Q(cid:48) = d. This means that there is a matching N , defined again without loss of generality on all of I(Q), that achieves this edit distance. If N does not take every u(cid:48) ∈ I(Q) to N (u)(cid:48) ∈ I(Q(cid:48)), we can modify it so that this is the case, since this can only increase the number of well-matched edges of N . Once this is established, the same argument used above shows that, if we define M to be the restriction of N to I(P ), then DP,P(cid:48) ≤ d − 2I(P )I(P (cid:48)) + 2I(P ). This completes the proof of the proposition. 15 6 Simulation Results We evaluated the general randomized heuristic (Section 4.4) and the dynamic programming algo- rithm (Section 4.2) against a brute-force branch-and-bound algorithm that finds the correct edit distance on general pedigrees in time exponential in pedigree size. We used the modified dynamic programming algorithm for the case where an upper bound on the distance is unknown: we chose a reasonable upper bound, and if the algorithm failed to find a matching at a given step (because the distance between the two pedigrees was too large), it ran the randomized heuristic instead. Our simulations were performed on small, three-generation pedigrees so that the edit distance could be computed using the exponential-time branch-and-bound algorithm. From the simulations, it appears that the heuristic algorithm provides a reasonable estimate of the edit distance, especially when the two pedigrees being compared are very similar to each other. The DP algorithm provides the correct answer when the two pedigrees are similar, a reasonably close answer when the pedigrees are not very similar, and an answer that matches the heuristic algorithm when the the pedigrees are very different. Of course, these results depend on the parameter k we chose. The simulation. We first drew a leaf-labeled pedigree P = (P, s, X, (cid:96)) from a Wright-Fisher sim- ulation where every generation has a fixed number 2m of individuals, there is no inter-generational mating, each monogamous couple has a number of offspring drawn from a Poisson distribution with mean λ, and all leaves are labeled. We then randomly perturbed P to obtain P(cid:48) by having some fraction x of non-founders choose a new parent of one gender uniformly and independently at random. (Results obtained using a perturbation model that preserved monogamy were similar.) Note that P and P(cid:48) are always compatibly leaf-labeled. Algorithms compared. We recorded the following measures of similarity for the pedigrees P and P(cid:48). 1. Simulated Edit Path Length: x 2. Random-Matching Heuristic Estimate: DP,P(cid:48)/(E(P ) + E(P (cid:48))), where DP,P(cid:48) is the output of the random-matching heuristic. 3. Normalized Edit Distance: DP,P(cid:48)/(E(P )+E(P (cid:48))), where DP,P(cid:48) is the output of the branch- and-bound algorithm. 4. DP Estimate: DP,P(cid:48)/(E(P ) +E(P (cid:48))), where DP,P(cid:48) is the output of the dynamic program- ming algorithm, modified for the case where there is no guarantee on distance. Remark. Notice that x is often larger than the edit distance because the edit path taken in the simulation was longer than the shortest edit path. Remark. Since our pedigrees were randomly generated and perturbed, in practice we could not ensure the DP algorithm's condition that the pedigrees being compared be sufficiently similar at each generation. Therefore we modified the algorithm to assume a reasonable upper bound k = 8 on this distance and give the output of the random heuristic if no matching was found that met this condition. 16 h Figure 3: Comparing Different Distances Estimates. With 2m = 14 and λ = 3, there were 2500 pairs of pedigrees simulated. Each point is an average of 50 simulations. The values of n and λ were chosen such that the branch-and-bound algorithm would finish computing the true edit distance. The random matching heuristic yields an estimated edit distance which is fairly close to the true edit distance. The DP algorithm performs nearly perfectly for small numbers of actual changes, while it returns the solution found by the random-matching heuristic when it cannot find a solution for parameter k = 8. The left panel shows the accuracies of each algorithm. The right panel shows the difference in accuracy between the true edit distance and each distances returned by the random-matching heuristic and DP algorithm. Simulation results. The three different results we recorded are plotted in Figure 3 against x, the fraction of pedigree edges changed during simulation. Figure 3 also shows the difference between the random-matching and true edit distances. Figure 4 shows the running times for the three algorithms. We see the random-matching heuristic performs reasonably well, both in terms of accuracy and time. The DP algorithm agrees with the true edit distance when that distance is small and agrees with the random-matching estimate when the distance is large. However, in the intermediate area, we see that the DP produces an answer between the optimal and the heuristic value, because there are matchings that satisfy the distance threshold at every generation which are not the optimal matching and the optimal matching contains a generation that fails the distance threshold. Due to its accuracy, we recommend that the DP algorithm and the randomized heuristic be used together. If degree of accuracy is not needed, then we recommend using linear-time leaf-labeled isomorphism algorithm. 7 Discussion In this paper, we introduced two pedigree comparison problems -- pedigree isomorphism and pedi- gree edit distance -- and we presented algorithms and hardness results for both. Several interesting open questions remain: 17 0.00.20.40.60.81.00.00.20.40.60.81.0Three Generation Pedigrees with Half−SiblingsFraction of Actual ChangesNormalized DistancelllllllllllllllllllllllllllllllllllllllllllllllllllSimulated Edit PathHeuristic EstimateTrue Edit DistanceDP Estimate0.00.20.40.60.81.00.00.10.20.30.4Three Generation Pedigrees with Half−SiblingsFraction of Actual ChangesNormalized DistancelllllllllllllllllllllllllllllllllllllllllllllllllllDifference of Heuristic and True Edit DistanceDifference of DP and True Edit Distance Figure 4: Running Times. These are box plots comparing the running times of the three different algorithms: heuristic algorithm, branch-and-bound algorithm, and the DP algorithm. The heavy line is the median, the rectangle indicates the first and third quartiles. In this case the median is coincident with the first quartile for all three algorithms. The outliers are not shown; specifically, there are a number of very long execution times for the optimal algorithm. • Fractional edit distance. An alternative definition of edit distance could be based on fractional matchings: instead of minimizing over all one-to-one matchings of vertices in the two pedigrees, we could allow a vertex of P to be matched to multiple vertices in P (cid:48) with weights summing to one. Such a distance could be easier to compute, although the biological interpretation is less clear. It would also be interesting to explore the relationship between the definition presented in this paper and this alternate definition. • Pedigrees with inter-generational mating Another open problem of interest is how the edit distance algorithms work on pedigrees with inter-generational mating. The simulations used here were based on the Wright-Fisher model and did not allow any inter-generational mating events. It may be of interest to simulate the pedigrees using a birth-death model such as the Moran model where inter-generational mating is allowed. Such a simulation would allow the evaluation of the distance heuristics on non-regular pedigrees. • Pedigree isomorphism without labels A very interesting open problem is that of pedigree isomorphism without labels. Since the graph isomorphism problem is reducible to it, it is conceivable that existing algorithms for graph isomorphism might be of use for pedigree graphs. Comparison of pedigrees is an interesting and important problem. Here, we have taken the first steps towards understanding and solving it. Acknowledgments. Many thanks go to Yun Song for stimulating discussions and to Eran Halperin for the random pedigree simulation. 18 HeuristicTrueDP0.000.020.040.060.08Running TimesAlgorithmSeconds Author Disclosure Statement. No competing financial interests exist. References [1] M. Abney, C. Ober, and M. S. McPeek. Quantitative-trait homozygosity and association mapping and empirical genomewide significance in large, complex pedigrees: Fasting serum- insulin level in the hutterites. American Journal of Human Genetics, 70(4):920 -- 934, 2002. [2] T. Akiyama, T. Nishizeki, and N. Saito. NP-completeness of the hamiltonian cycle problem for bipartite graphs. J. Information Processing, 3:73 -- 76, 1980. [3] Anthony Almudevar and Chris Field. Estimation of single-generation sibling relationships based on dna markers. Journal of Agricultural, Biological, and Environmental Statistics, 4(2):pp. 136 -- 165, 1999. [4] T. Y. Berger-Wolf, S. I. Sheikh, B. DasGupta, et al. Reconstructing sibling relationships in wild populations. Bioinformatics, 23(13):i49 -- 56, 2007. [5] M. Boehnke and N. J. Cox. Accurate inference of relationships in sib-pair linkage studies. American Journal of Human Genetics, 61:423 -- 429, 1997. [6] D. Brown and T. Berger-Wolf. Discovering kinship through small subsets. WABI 2010: Pro- ceedings for the 10th Workshop on Algorithms in Bioinformatics, 2010. [7] S. Browning and B.L. Browning. On reducing the statespace of hidden Markov models for the identity by descent process. Theoretical Population Biology, 62(1):1 -- 8, 2002. [8] C. R. Chegireddy and H. W. Hamacher. Algorithms for finding the k-best perfect matchings. Discrete Applied Mathematics, 18:155 -- 165, 1987. [9] X. Chen, L. Liu, Z. Liu, and T. Jiang. On the minimum common integer partition problem. ACM Trans. on Algorithms, 5(1), 2008. [10] D. Conte, P. Foggia, C. Sansone, and M. Vento. Thirty years of graph matching in pattern recognition. International Journal of Pattern Recognition and Artificial Intelligence, 2004. [11] G. Coop, X. Wen, C. Ober, et al. High-Resolution Mapping of Crossovers Reveals Extensive Variation in Fine-Scale Recombination Patterns Among Humans. Science, 319(5868):1395 -- 1398, 2008. [12] M. Fishelson, N. Dovgolevsky, and D. Geiger. Maximum likelihood haplotyping for general pedigrees. Human Heredity, 59:41 -- 60, 2005. [13] D. Geiger, C. Meek, and Y. Wexler. Speeding up HMM algorithms for genetic linkage analysis via chain reductions of the state space. Bioinformatics, 25(12):i196, 2009. [14] C. Herbinger, P. O'Reilly, R. Doyle, J. Wright, and F. O'Flynn. Early growth performance of Atlantic salmon full-sib families reared in single family tanks versus in mixed family tanks. Aquaculture, 173(1-4):105 -- 116, March 1999. 19 [15] Anderson K.G. How well does paternity confidence match actual paternity? evidence from worldwide nonpaternity rates. Curr. Anthropol., 47:513 -- 520, 2006. [16] B. Kirkpatrick. Haplotype versus genotypes on pedigrees. WABI 2010: Proceedings for the 10th Workshop on Algorithms in Bioinformatics, 2010. [17] B. Kirkpatrick, S.C. Li, R. M. Karp, and E. Halperin. Pedigree reconstruction using identity by descent. J. of Computational Biology, 2011. [18] B. Kirkpatrick, S.C. Li, R. M. Karp, and E. Halperin. Pedigree reconstruction using identity by descent. RECOMB 2011: Proceedings of the 15th Annual International Conference on Research in Computational Molecular Biology, 2011. [19] S. L. Lauritzen and N. A. Sheehan. Graphical models for genetic analysis. Statistical Science, 18(4):489 -- 514, 2003. [20] J. Li and T. Jiang. An exact solution for finding minimum recombinant haplotype configu- rations on pedigrees with missing data by integer linear programming. In Proceedings of the 7th Annual International Conference on Research in Computational Molecular Biology, pages 101 -- 110, 2003. [21] X Li, X-L Yin, and J Li. Efficient identification of identical-by-descent status in pedigrees with many untyped individuals. Bioinformatics, 26(12):i191 -- i198, 2010. [22] M.S. McPeek and L. Sun. Statistical tests for detection of misspecified relationships by use of genome-screen data. Amer. J. Human Genetics, 66:1076 -- 1094, 2000. [23] MY Ng, DF Levinson, SV Faraone, et al. Meta-analysis of 32 genome-wide linkage studies of schizophrenia. Mol Psychiatry, 14:774 -- 85, 2009. [24] S. B. Ng, K. J. Buckingham, C. Lee, et al. Exome sequencing identifies the cause of a mendelian disorder. Nature genetics, 42(1):30 -- 35, January 2010. [25] C. Papadimitriou and M. Yannakakis. Optimization, approximation, and complexity classes. In Proceedings of the twentieth annual ACM symposium on Theory of computing, STOC '88, pages 229 -- 234, New York, NY, USA, 1988. ACM. [26] A. Piccolboni and D. Gusfield. On the complexity of fundamental computational problems in pedigree analysis. Journal of Computational Biology, 10(5):763 -- 773, 2003. [27] Nadia Pinto, Pedro V Silva, and Antonio Amorim. General derivation of the sets of pedigrees with the same kinship coefficients. Hum Hered, 70(3):194 -- 204, 2010. [28] Leigh W. Simmons, Rene E C. Firman, Gillian Rhodes, and Marianne Peters. Human sperm competition: testis size, sperm production and rates of extrapair copulations. Animal Behavior, 68:297 -- 302, 2004. [29] J. Stankovich, M. Bahlo, J.P. Rubio, et al. Identifying nineteenth century genealogical links from genotypes. Human Genetics, 117(2 -- 3):188 -- 199, 2005. 20 [30] Mike Steel and Jotun Hein. Reconstructing pedigrees: A combinatorial perspective. Journal of Theoretical Biology, 240(3):360 -- 367, 2006. [31] L. Sun, K. Wilder, and M.S. McPeek. Enhanced pedigree error detection. Hum. Hered., 54(2):99 -- 110, 2002. [32] N.B. Sutter and et al. A Single IGF1 Allele Is a Major Determinant of Small Size in Dogs. Science, 316(5821):112 -- 115, 2007. [33] B. D. Thatte. Combinatorics of pedigrees, 2006. [34] B. D. Thatte and M. Steel. Reconstructing pedigrees: A stochastic perspective. Journal of Theoretical Biology, 251(3):440 -- 449, 2008. [35] E. A. Thompson. Pedigree Analysis in Human Genetics. Johns Hopkins University Press, Baltimore, 1985. [36] R. Uehara, S. Toda, and T. Nagoya. Graph isomorphism completeness for chordal bipartite graphs and strongly chordal graphs. Discrete Appl. Math., 145:479 -- 482, January 2005. [37] Y. Wu. A practical method for exact computation of subtree prune and regraft distance. Bioinformatics, 25(2):190 -- 196, 2009. [38] K. Zhang and T. Jiang. Some max snp-hard results concerning unordered labeled trees. Inf. Process. Lett., 49(5):249 -- 254, 1994. 21
1209.0756
1
1209
2012-09-04T19:51:16
Data-Oblivious Graph Drawing Model and Algorithms
[ "cs.DS" ]
We study graph drawing in a cloud-computing context where data is stored externally and processed using a small local working storage. We show that a number of classic graph drawing algorithms can be efficiently implemented in such a framework where the client can maintain privacy while constructing a drawing of her graph.
cs.DS
cs
Data-Oblivious Graph Drawing Model and Algorithms Michael T. Goodrich1, Olga Ohrimenko2, and Roberto Tamassia2 1 Dept. Computer Science, Univ. of California, Irvine. [email protected] 2 Dept. Computer Science, Brown University. {olya,rt}@cs.brown.edu Abstract. We study graph drawing in a cloud-computing context where data is stored externally and processed using a small local working storage. We show that a number of classic graph drawing algorithms can be efficiently implemented in such a framework where the client can maintain privacy while constructing a drawing of her graph. 1 Introduction Technologies developed under the paradigm of cloud computing enable users to access their data seamlessly across devices of vastly different computational power. Moreover, these technologies support computations on a large data set using a small device whose storage capacity is insufficient to simultaneously hold all the data, since the data is held in its entirety on an external server. In this paper, we present techniques that allow a client to efficiently execute various classic graph drawing algorithms, and variations of them, in a cloud computing environment, where the storage of the graph is outsourced to an online storage service. We are particularly interested in allowing a client to access her data and perform computations on them in a privacy-preserving way. For example, an administrator for a fast-growing company may be revising (and visualizing) the organizational chart for the leadership of her company, and leaking this chart to the press or a rival could negatively impact the company. Thus, we view the storage server as an honest-but- curious adversary, who correctly performs the storage and retrieval operations requested by the client, but is nevertheless interested in learning as much from her data as possible (indeed, some cloud computing companies are basing their business model on this goal). Of course, in a cloud computing scenario, the client would encrypt the data she outsources, decrypting it when she retrieves, it and re-encrypting it when she stores it back (using a probabilistic cipher that is unlikely to repeat the same cipher text for a re-encryption of the same plaintext). But she may also be leaking information to the server from the pattern of her data accesses to the storage server. For example, accessing the memory associated with a certain department while preparing a new organizational chart leaks the fact that that department is being reorganized. So the client should additionally aim at completely hiding her access patterns in order to achieve privacy protection for her data. 1.1 Oblivious Algorithms and Storage The general techniques of oblivious RAM simulation and oblivious storage allow a client to simulate an arbitrary algorithm in such a cloud-computing environment so as to hide both the content and access patterns for her computation (e.g., see [3, 8, 12, 20, 22–25]). But these solutions involve fairly complicated simulation techniques for generic algorithms that increase the running time of the client's algorithm by a polylogarithmic factor when the client has a small amount of working storage. Privacy-preserving algorithms in the cloud computing scenario with no asymptotic time overhead have been developed for sorting [21] and for fundamental computational geometry problems on planar point sets, including convex hull, well-separated pair decomposition, compressed quadtree construction, closest pairs, and all nearest neighbors [16]. These algorithms also hide the access pattern from the server and are referred to as data-oblivious. In this paper, we develop simple privacy-preserving algorithms for some classic graph drawing problems that fully obfuscate the access pattern from the data server. Our algorithms are provably data-oblivious and utilize small working storage. 1.2 Related Work There are existing web-based systems that can perform graph drawing services for clients, such as the Brown Graph Server [9] and Grappa [5]. These differ from the framework we are describing in this paper in two ways. First, our model involves the client storing her data in an outsourced data server and accessing that data remotely, whereas the web-based graph drawing services involve a client storing her data locally and temporarily shipping it to the server. Second, in the framework we are describing here, the client performs the graph drawing algorithm herself, not the server (because of privacy concerns), whereas the web-based drawing services employ their own graph drawing algorithms to produce layouts for the client. Abello and Korn [1] describe a system of clustering and hierarchical representations for visualizing large graphs that do not fit in main memory. In addition, Abello et al. [2] discuss at a high level, in a SIGGRAPH column, some of the challenges of dealing with the visualization of large graphs with small working storage. Likewise, there is a large body of work on external-memory graph algorithms, where one solves a problem that is too big to fit in main memory by dividing it into blocks and accessing data in way that takes advantages of localities of reference (e.g., see [10, 30]). The present paper can be viewed as an approach for dealing with the challenge of drawing large graphs with small local memory, but in a different way than using clustering or external memory approaches. In particular, our approach involves accessing items individually, not in blocks, and it involves computing exact drawings, not approximate, clustered, or hierarchical drawings. Our approach is probably most similar to prior work on computations on data streams (e.g., see [4, 26, 28]). In this model, data is presented in single stream, which arrives in an arbitrary order and is processed in an online, read-only fashion using a workspace of small size. Each time an item is considered, all the processing involving that item has to be completed before considering the next item. Henzinger et al. [26] introduce a version of this model that allows for a small number of passes over the data using a small workspace, but their approach still assumes that data is presented in a read-only fashion in an arbitrary order (although they do leave as an open problem whether allowing for alternative orderings can reduce workspace memory size in some cases). In addition, Feldman et al. [17] define the MUD model for describing MapReduce algorithms, which also involves scans and small local memory, but in their model scans are only over small local memories rather than a large set of data. In the context of graph drawing, Binucci et al. [7] describe a framework for drawing trees in the streaming model, where one draws trees using a single scan of the edges, using a framework that is similar to our approach but nonetheless has some important differences. Specifically, as in the traditional data streaming model, their approach only allows for a single scan of the edges of a tree in an order that is not under the control of the algorithm. In our case, the client can make multiple scans of her data and specify the ordering of the scan each time. In addition, in their model, once a node is placed it cannot be moved, whereas we allow for the client to make tentative assignments of coordinates in one scan that can be refined or changed in a future scan, since this more naturally fits the approach of cloud computing. 1.3 Our Results To enable data-oblivious algorithms for graph drawing problems, we introduce compressed scanning, an algorithmic design framework based on a series of scans. Our method is related to the massive, unordered, distributed (MUD) model [17] for efficient computation in the map-reduce framework. We assume that the server holds a set of n data items and the client has a small private working storage of size O(log n). The data items at the server are encrypted with a semantically secure (probabilistic) cipher so that it is hard for the server to determine whether two items are equal. An algorithm for the compressed-scanning model consists of a sequence of rounds, where in each round the entire data set is scanned in some order specified by the client. During the scan, each item is processed exactly once by the client: first the client downloads the item from the server into working storage; next, the client performs some internal-memory computation on the item and the content of the working storage; finally the item is written out to an output stream at the server. When a round is completed, the output stream is either confirmed as the algorithm's output or it is used as the input data set for the next round. The efficiency of such an algorithm is measured, therefore, by the number of rounds needed and the size of the local working storage that is required. Ideally, the number of rounds should be O(1) and the working storage should be logarithmic or polylogarithmic in size. As shown in Section 2.2, an algorithm designed in the compressed scanning framework can be implemented in a data-oblivious way by randomly shuffling the items in between scans. Using the compressed-scanning approach, we provide efficient data-oblivious algorithms for a number of classic graph drawing methods [14], including symmetric straight-line drawings and treemap [27] drawings of trees, dominance drawings of planar acyclic digraphs [15], and ∆-drawings of series-parallel graphs [6]. Our methods result in privacy-preserving graph drawing algorithms whose running times are asymptotically optimal and better than could be achieved by applying general-purpose privacy-preserving techniques (e.g., see [3, 8, 12, 20, 22–25]). 2 Compressed-Scanning In this section, we formally define the compressed-scanning model for designing client-server algorithms that can be efficiently implemented using a small working storage, W , at the client. We assume that the server holds an array, S, of n data elements. 2.1 Model An algorithm for our model consists of a sequence of t rounds. A round involves accessing each of the elements of S exactly once in a read-compute-write operation. This operation consists of reading an element from the server into private working storage, using the element in some computation, and writing a new element to an output stream, O, at the server. When a round completes, either the output stream O and/or a set of values in W are confirmed as the output of the algorithm, or we assign S = O and start the next round. This size of the working storage, W , is a parameter of our model, and is intended to be small (e.g., constant or O(log n)). The name of our model is derived from the fact that each round scans the set S and computations are performed using a small, or "compressed", amount of working storage. Simple examples of algorithms that fit our model include the trivial methods for summing n integers in an array or traversing a linked list from beginning to end, which can be done with a constant-size working storage, or any algorithm in the standard data streaming model, which would have W being equal to the working storage for that algorithm. 2.2 Privacy Protection Suppose we are given a compressed-scanning algorithm, A, which runs in t rounds using a working storage, W , and a data set, S, of size n. We can implement A in a privacy-preserving way as follows. The first essential step in ensuring privacy is the encryption of the elements in S. From now on we assume that the input stream, S, is stored encrypted at the server and whenever we write elements to the output stream, O, we also encrypt them. We use semantically secure encryption [19], which takes as input the plaintext and a random value. Thus, if the same element is encrypted twice, the resulting ciphertexts are different. This is useful when we read an element, decrypt it, possibly modify it, re-encrypt and write it back. With semantically secure encryption the server will not be able to distinguish whether two data elements are equal or whether the output element of a read-compute-write operation is equal to the input element. The next step in ensuring privacy is hiding the access pattern from the server. For each round, i, of A, we use a new pseudo-random permutation [18], π, to assign a random integer, π(x) between 1 and n, to each element, x, in S. Value π(x) is stored encrypted next to item x. We then perform a random shuffle (e.g., using an oblivious sort [21]) to move each element x to location π(x) so that the server cannot figure out where each element was moved to. (Recall that the elements are reencrypted each time they are accessed.) This step takes O(n log n) time. We now put the elements in a lookup table using the π(x) values as keys, since the adversary will have no way of correlating these values to the original locations of the elements. Finally, we simulate round i, where we use π(x) to do the lookup for element x. Since each element in S is accessed exactly once in the round, each lookup is independent and random; hence, it cannot be correlated with previous or subsequent lookups. For each lookup, we do any necessary local computation, and then write an element to our output stream. Even if we have nothing to output, we can always write a dummy element, for the sake of being oblivious. In conclusion, we simulate each round of algorithm A in O(n log n) time while fully hiding the pattern of access to the items in S. Thus, the simulation of A takes time O(tn log n) and uses working space of size proportional to that of A. Definition 1. A probabilistic algorithm A is data-oblivious if given two inputs of the same size, I1 and I2, the accesses that A makes to the memory for I1 and I2 have the same probability distribution. In other words, one cannot distinguish between I1 and I2 by just looking at their access patterns. For example, consider an algorithm that scans the elements of a sorted array and writes to the output stream, O, only distinct elements. This algorithm is not data-oblivious since, given inputs (1, 1, 1, 2) and (1, 2, 2, 2), the write accesses to O happen after a different number of read accesses are made to the input stream. A data-oblivious algorithm would write a value to O for every element it reads from the input: a dummy element if the same element as the previous one is read, and a real one, otherwise. One can then make a simple sorting pass over O to bring real items to the front of the list. A workspace of constant size is used to store the last read element. Theorem 1. Let A be an algorithm in the compressed-scanning model for an input of size n that uses a working space of size k. Algorithm A can be simulated by a data-oblivious algorithm if the number of rounds and the number of elements written to the output stream at each round depend only on n. Also, the simulation uses a working space of size O(k) and runs in time O(T (n)n log n), where T (n) is the running time of A. Proof. (Sketch) Each round is simulated by reading elements from S, writing elements to O, and reshuffling the next input set. Accesses to locations in S are made only once in a random order. This ensures that accesses to S in a single round are data-oblivious. Write accesses to O are also data-oblivious, since they happen on every access to S. After every round, the input sequence is reshuffled (data-obliviously); hence, one cannot correlate accesses between rounds as well. Thus, accesses to S and O depend only on size of S (cid:117)(cid:116) while the number of rounds is fixed by the algorithm regardless of S. In the next section we describe graph drawing algorithms that fit the compressed-scanning model and, hence, can be implemented in a data-oblivious manner. These algorithms guarantee that their access patterns do not reveal the combinatorial structure of the graphs that are given as inputs (e.g., number of outgoing or incoming edges for a particular node) and run in a constant number of rounds using W of logarithmic size. 3 Graph Drawing Algorithms Most existing graph drawing algorithms are designed without privacy concerns in mind; hence, if they are run in a cloud-computing environment, they can reveal potentially sensitive information from their access patterns. For example, a recursive binary-tree drawing algorithm implemented in the standard way can reveal the depth of the tree from the access patterns used for the recursion stack, even if all the nodes in the tree are encrypted. In this section, we present several graph drawing algorithms modified to fit the compressed-scanning model. In order to build a graph drawing algorithm that fits this model, we modify the representation of the graph so that we never access the same location more than once in the same round. For example, consider a tree represented with a set of nodes and pointers from each node to its children and a parent. Traversing the tree in this case involves accessing an internal node several times depending on its degree, which reveals information about the tree. 3.1 Euler Tours in the Compressed-Scanning Model Traversing a tree in the compressed-scanning model requires that we access each memory location exactly once; hence, we need to reorganize how we normally perform data accesses, since, for example, we cannot access a parent again when coming from its left child after we have already visited it and its right child. Given our small private workspace, W , we cannot store previously accessed nodes. Thus, we need a representation of a tree that allows for a traversal where elements are accessed only once. For this purpose, we construct an Euler tour over a tree that is based on duplicating edges and defines a left to right traversal of a tree. Each copy of an edge contains a pointer to a copy of the next edge in the tour so we can go to the next edge without using recursion and visiting each edge of the tour only once. For an ordered tree, T = (V, E), we store an Euler tour as a set of items, C, where C = 2E. Each item represents an edge of the tour and stores information related to the tree, e.g., parent, child node names, and the order of the child among all its siblings. Additionally, it stores information related to the actual cycle of the Euler tour: (a) tag: a unique tag associated with this item, 0 ≤ tag < 2E. This is used to locate and permute items. (b) direction: up or down. This indicates which direction in the tree we are following. (c) next: tag of the next edge in the cycle. We assume that tag = 0 for the leftmost edge of the root of T . Suppose we shuffle the items in C using a permutation, π, over the tag field. Then a traversal of C starts with an access to location π(0), following access to π(π(0).next). The items in C are accessed only once and the tree layout is hidden behind the permutation π. Thus, the traversal is data-oblivious and reveals only the number of edges and nodes in the tree. 3.2 Computation over Euler Tour Representations Many graph drawing algorithms collect information from a tree representation of the graph to determine the layout. Such information could be the height, width, or subtree size of each node of the tree. We now show how one can use an Euler tour representation of a rooted tree to compute for each node of the tree, the size (number of nodes) of it subtree in a data-oblivious manner. For this computation, we add a new field subsize for every edge in the Euler tour C. The algorithm maintains in local memory, W , a variable, total subsize, initially set to 0. Edges in C are traversed as described in the previous section. However, every time we now read an edge, i, we update i.subsize with the value stored at total subsize and write it back. When we are going up, i.e., i.direction = up, total subsize is incremented by 1. Once the traversal finishes, we observe that for every two items, i and i(cid:48), that represent a traversal of the same edge, i.e., i.parent = i(cid:48).parent, i.child = i(cid:48).child, i.direction = down and i(cid:48).direction = up, the value (i(cid:48).subsize − i.subsize) is the size of the subtree rooted at i.child and the final value of total subsize is subsize of the root. However, we need to associate nodes of the tree T with these values in the compressed- scanning model as well. For this purpose, we obliviously sort the values in C using the fields, parent and child, to bring items that correspond to the same edge next to each other. We then simply scan the resulting sorted list and after reading a pair of items, i and i(cid:48), output a pair (i.child, i(cid:48).subsize − i.subsize). (See Figure 1.) Fig. 1: Computing the size of the subgraph via Euler tour. During the tour a locally maintained variable total subsize is incremented when the tour goes up the tree (red numbers in the figure) and is assigned to currently visited edge. The size of the node's subgraph is the counter at the edge going up from this node minus the counter of the duplicate of this edge. For example, the size for g is (4-1) = 3. The above computation consists of two rounds: the first round reads one item of C at a time, modifies it and writes it back. The second round starts after the sorting is complete, where items are read one at a time and a new item is written to the output after every two reads. We can compute the depth of each node using a similar technique. a 0 b 0 c 0 d 1 1 1 2 2 3 4 5 6 7 6 e f g h 3.3 Drawing of Planar Acyclic Digraphs We adopt an algorithm for dominance drawings of planar acyclic digraphs from [15], which is simple and elegant but is not data-oblivious. To find the x-coordinate of each node, one builds a spanning tree based on leftmost incoming edges of the nodes and then traverses this tree from left to right, numbering each node in this order. The resulting numbering of each node is its x-coordinate. The algorithm to determine the y-coordinates uses the rightmost spanning tree. Input: We assume that the graph, G, is given as a set of edges, E, where e ∈ E is an edge directed from node a to b storing indegree, the number of incoming edges to b, and child num, the order of a among all incoming edges to b; the leftmost edge has order 0. Data-oblivious algorithm: Following the original algorithm, we show how one can construct a spanning tree and number the nodes to get the final drawing. Our first task is to augment each edge with information about a spanning tree of G. We augment e with additional fields, left spanning and right spanning, which are set to true or false depending on which spanning tree e belongs to. In the compressed-scanning model, one simply accesses e, sets e.left spanning to true if e.indegree equals e.child num or e.right spanning to true if e.child num is 1, and writes e back. Given annotated edges, we construct an Euler tour over each spanning tree. Note that given that the number of nodes in G is revealed, we do not need to hide the number of edges in either of the spanning trees. For ease of explanation, we say that we traverse an edge down when we follow an edge of the spanning tree in its direction in G. The left spanning tree is traversed starting with the leftmost outgoing edge of the root, and rightmost outgoing edge for the right tree. We are now ready to make a tour traversal and assign coordinates to the nodes. We adopt a compressed version of the algorithm that minimizes the area of the drawing and start with traversal of the left tree. In private memory, a counter for x-coordinates is maintained, set to 0. Initially, we output (source, 0, x). For every edge e that has direction = down, and e.indegree > 1 or e is the first traversed edge of a, we output (e.b, counter, x). If e has down direction but is not the first edge of a traversed (in Euler tour this corresponds to remembering the latest visited edge) or is the only incoming edge to b, then we increment the counter by 1 and output (e.b, counter, x). If e.direction is set to up, then we output (dummy, 0, x). The algorithm for computing y-coordinates is similar and outputs values with (e.parent, counter, y). Note that access pattern of reads and writes is always the same: read an edge of the Euler tour and output a tuple of three values. The output of the above procedure contains tuples of real and dummy values. We can remove dummy values and bring x, y coordinates of each node together by obliviously sorting tuples by the first field (node name) such that string dummy is always greater than any real node name. The resulting list contains all dummy tuples at the end. Also, each node has its x- and y-coordinates adjacent. See Figure 2 for an example. (a) (b) (c) Fig. 2: (a) A planar acyclic digraph with its left and right spanning trees. (b) The order of the visit to each edge of Euler tour of the left spanning tree and the counter of x coordinate for child nodes, e.g., edge a-g is visited third and g is assigned x coordinate of 1. (c) The final drawing. b a c d e f b a c d e f b a c d e f g g g Le* and right spanning trees b a c d e f visit order, counter value 2,0 1,0 3,1 5,1 4,1 6,1 7,2 8,2 9,2 10,2 11,2 12,2 g 0,0 b a c d e f g 0,0 2,0 1,1 2,2 2,1 1,2 0,2 3.4 Treemap Drawings Treemaps are a representation designed for human visualization of complex tree structures, where arbitrary trees are shown with a 2-d space-filling area. Here, we present how one can draw a treemap using an algorithm from [27] adapted to the compressed-scanning model. The original algorithm takes a rectangle area and splits it vertically into two sections. The area of the first section is enough to fit the first child, child1, of the root and the rest is enough to fit the rest of its children. The next step is to divide the first section among children of child1 but this time splitting the area horizontally. The algorithm continues in the same manner for all decedents of child1. Once finished, it proceeds to splitting the second section between second child of the root, child2, and the rest of root's children. Input: A tree, T , where each node also contains a value area and the size of a rectangle area, w × h, where T should be drawn. We build an Euler tour, C, from T and add two fields parent area and child area to each edge in C. Output: Each node is labeled with (x, y) coordinates of the top-left corner, P , and bottom-right corner, Q, of the rectangle area where the node should be placed in. Data-oblivious algorithm: The original algorithm labels the nodes with values P and Q via pre-order traversal of T . The algorithm we propose here first goes down the leftmost subtree computing values P , Q and labeling the nodes on the way. In private memory, it maintains only one copy of the last two assigned values of P and Q, prevP and prevQ. It then goes up the tree "undoing" all the computations made to prevP and prevQ. We do it in such a way that when going up and reaching some node, we recover its P and Q values as they were before we visited any of its children or other nodes in its subgraph. This algorithm fits the traversal of Euler tour C of the tree T . When going down the tree, we read each item i of tour C and output P, Q values corresponding to i.child. However, when going up we cannot retrieve earlier written P, Q values, since this will not be data-oblivious and we reveal that we are going up, which consequently reveals the depth of the tree. This is where "undoing" computations when going up on prevP and prevQ helps. This is possible since the information used to compute P and Q is stored twice in C: once for edge with direction set to down and once for up. The pseudocode of the algorithm appears in Algorithm 1. Figure 3 shows an execution of the algorithm on a small tree. (a) (b) (c) Fig. 3: Treemap graph drawing. (a) The original graph. (b) The final drawing. (c) Execution of algorithm in Section 3.4 on the graph in (a) on a 10×4 rectangle area. The values in dashed rectangles are written for every edge and are never accessed. Variables prevP, prevQ, axis and unit are kept in memory. 3.5 Series-Parallel Graphs A series-parallel (SP) graph is a directed acyclic graph that can be decomposed recursively into a combination of series-parallel digraphs. The base case of such a graph is a simple directed edge. A series composition e 2 2 1 4 5 3 2 10 b a c d k l 1 1 f h i e k l c h i 2 2 1 4 5 10 e b a k l f dummy.P =(2.5,0.8) dummy.Q = (5,4) prevP = (0,4) prevQ = (5,4) axis = 1 unit = 0.8 a,b,10,5 down a.P = (0,0) a.Q =(10,4) dummy.P =(0,0) dummy.Q = (0,0) prevP = (5,0) prevQ = (5,4) axis = 0 unit = 1 l.P =(2.5,0.8) l.Q = (5,4) prevP = (2.5,0.8) prevQ = (5,4) axis = 1 unit = 1.25 Algorithm 1 Data-oblivious algorithm to compute a treemap drawing of an arbitrary tree. out.node ← root, out.P ← [0, 0], out.Q ← [w, h] write out read π(0) into e axis ← 0, unit ← w/e.parent area prevP ← [0, 0], prevQ ← [w, h] while e.parent (cid:54)= root and e.direction (cid:54)= up do (cid:46) Get an edge corresponding to the leftmost edge from the root of T (cid:46) prevP, prevQ, unit, axis are maintained in private memory, W if e.direction = down then prevQ[axis] ← prevP[axis] + unit × e.child area out.node ← child, out.Q ← prevQ, out.P ← prevP if e.child outdeg = 0 and e.child num < e.parent outdeg then else if e.child outdeg > 0 then prevP[axis] ← prevQ[axis] unit ← (prevQ[1 − axis] − prevP[1 − axis])/e.child area axis ← 1 − axis end if else if e.child num = e.parent outdeg then branch size ← unit × e.parent area unit ← (prevQ[1 − axis] − prevP[1 − axis])/e.parent area prevP[axis] ← prevQ[axis] − branch size prevP[1 − axis] ← prevQ[1 − axis] axis ← 1 − axis end if out.node ← dummy, out.Q ← [0, 0], out.P ← [0, 0] end if write out read π(e.tag) into e (cid:46) Move the top left corner for the next child (cid:46) Go further down the branch (cid:46) Going up again. Undo previous P , Q changes. end while Sort all output values by node field such that dummy values are in the end. consists of two series-parallel graphs G1 and G2 where the sink of G1 is identified with the source of G2. A parallel composition of two series-parallel graphs G1 and G2 is the digraph where source of G1 is identified with the source of G2 and similar for their sink nodes. For example, consider the series-parallel digraph shown in Figure 4a. The subgraph S(cid:48) induced by its edges c-d and d-a is a series composition of graphs c-d and d-a. While S(cid:48) and edge c-a is a parallel composition. An SP graph G can be represented with a binary tree (SPQ tree) with three types of nodes, S, P and Q. Q nodes are leaves of the tree and correspond to individual edges of G. An internal node is of type P if it is a parallel composition of the children digraphs. If a node corresponds to a series composition it is called S node. Here, we use a right-pushed embedding of G such that a transitive edge in parallel composition is always embedded on the right. (Figure 4b shows the SPQ tree of the graph of Figure 4a.) Original ∆-drawing algorithm: We adopt the ∆-drawing algorithm from [6]. This algorithm recur- sively produces a drawing of G inside a bounding triangle (cid:52)(G) which is isosceles and right-angled. In the drawing of a series composition, the two bounding triangles, (cid:52)(G1) and (cid:52)(G2), are placed one on top of another and, hence, produce a bounding triangle big enough to fit them both. For a parallel composition, (cid:52)(G2) is placed on the right of (cid:52)(G1) and a larger triangle is drawn to fit this parallel composition. The algorithm works by traversing the SPQ tree and identifying the size of the bounding triangles of each node. The length of the hypotenuse, b, is enough to store this information. Each Q node is assigned a triangle with b = 2, while for series and parallel nodes b is the sum of b values at the children nodes. When traversing the tree we also compute value b(cid:48), which makes sure that in a drawing of a parallel graph G the edge that goes from the source of G to G1, the left subgraph of the composition, does not intersect the drawing of G2. This value b(cid:48) for a Q node is simply b, for S node it is b(cid:48)((cid:52)(G1)) and for P node it is b(cid:48)((cid:52)(G1)) + b(cid:48)((cid:52)(G2)). Note that for a parallel node it is the sum of b(cid:48) values of both graphs since we want to make sure that if subgraph (a) (b) (c) Fig. 4: (a) A series-parallel graph. (b) SPQ tree representation annotated with values b and b(cid:48) (dashed rectangles). (c) The final drawing. G is later a part of a parallel composition no node will intersect either G1 or G2. If G is a transitive edge then b(cid:48)((cid:52)(G)) = b((cid:52)(G)). (See Figure 4b.) Once b and b(cid:48) are computed for every node, i.e., every bounding triangle, the algorithm computes the (x, y) value of the bottom node of each triangle. The outer most triangle is positioned at (0, 0). Given coordinates (x, y) of a triangle corresponding to the S node with hypotenuse of size b and children with hypotenuses b1 and b2, we place the first triangle at (x, y) and second at (x, y + b1). Given coordinates (x, y) of a triangle corresponding to a parallel node, we place the first triangle at (x− 0.5b2, y + 0.5b2) and second at (x, y + b(cid:48) 1). Given that we know the coordinates of each triangle, we can now assign coordinates for individual nodes. The source of G is placed at (0,0) and sink is placed at (0, b((cid:52)(G))). We then look at each node in G and place it at (x, y +b((cid:52)(Gnode))) where Gnode is a subgraph and node is its sink. (See Figure 4c for an example.) We are now ready to explain the algorithm in compressed-scanning model. Input: SPQ tree from a right-pushed embedding of SP digraph G and nodes that are annotated as S, P or Q. We convert this tree into an Euler tour with addition of parent and child node type: parent spq type and child spq type which are either S, P or Q. Data-oblivious algorithm: The above algorithm makes several computations over the tree to annotate the nodes of the SPQ tree with values b, b(cid:48) and (x, y). Value b can easily be computed in the same manner as we computed the subgraph size in Section 3.2. Value b(cid:48) of the left child is added only for parents of P nodes. When an Euler tour is going up the tree we can always check the value of parent spq type to know if b(cid:48) of the left subgraph should be carried to the right one. Coordinates (x, y) for each node are computed from a small modification of the Euler tour: the left child needs know value b((cid:52)(G2)) and right child needs to know b(cid:48)((cid:52)(G1)). It is easy to do this by always reading the next edge and remembering the last edge. Given that we know the coordinates of each triangle, we can now assign coordinates for individual nodes. Recall that every leaf node of SPQ tree is associated with an edge while an internal node is either a DAG or a path of edges in the subtree rooted at this node. Hence, we can associate each internal node of SPQ tree, and edges in the corresponding Euler tour, with two nodes of the series-parallel graph that correspond to the source and the sink of the underlying subgraphs. Given a parent node of SPQ tree and source and sink nodes of its children, c1 and c2, if csink is placed at (c1.x, c1.y + c1.b). Otherwise, we output a dummy. are equal then node csink 1 and csource 2 1 3.6 Drawing Trees with Bounding Rectangles In this section, we present an algorithm that draws a binary tree T using a bounding rectangle approach from [11], adapted to the compress-scanning model. This algorithm is slightly different from the approaches we took in previous sections and involves a more complex way of converting it to fit data-oblivious mode. The original algorithm recursively assigns bounding rectangles to nodes of the tree. A leaf node is assigned a rectangle of size 2×1, while an internal node is assigned a rectangle that fits the bounding rectangles of its children. Each rectangle is represented by its width, height and (x, y) coordinate of the left top corner, which we refer to as reference point refpoint. For leaves, the width is 2, and width of internal nodes is the sum of the width of its children. The height of the rectangle is defined as 1 + maxi childi.height. The bounding a c b d e ca, P ca, Q ca, P ca, S ca, S da, Q cd, Q ba, Q cb, S eb, Q ce, Q 2,2 2,2 4,2 6,2 2,2 10,4 2,2 2,2 4,2 12,12 2,2 a cbd e assigned to (p.refpoint.x +(cid:80) l with children childi (i = 1, 2) is assigned to a coordinate ((cid:80) childi.x/i, l.refpoint.y). rectangle of the root node is assigned to refpoint of (0, tree height). The refpoint of ith child of node p is j<i childj.width, p.height). Each leaf node l is then assigned to a coordinate (x, y) = (l.refpoint.x + l.width/2, l.refpoint.y). An internal node is placed between its children, hence, a node Data-oblivious algorithm: Here, an Euler tour over T is only sufficient to compute width, level and refpoint values. Computing (x, y) coordinate of internal nodes involves knowing the left and the right co- ordinate of its children which can only be computed when subgraphs of both children are processed. If we use Euler tour traversal we need to store the coordinates computed in the left subtree while processing the right subtree. Given that we only allow for small private workspace, we cannot store them internally, since we may need to store coordinates for several levels of the tree which in the worst case can be linear in the number of nodes in the tree. Indeed, in our previously described methods, we only store a constant number of values when traversing a tour. Therefore, in this section we propose a different technique that is based on a dashed-solid representation. This representation allows us to store only log(n) coordinates in the worst case, which fits our compressed-scanning model. This algorithm is an example that one can carry out more involved computations on graphs with sublinear private space. The dashed-solid representation of the tree splits edges into dashed and solid. An edge parent-childi is solid if parent.subsize/2 < childi.subsize. Otherwise, an edge is dashed. If subsize of the children is the same, the right edge is solid and the left one is dashed. The invariant of this representation is that a parent node has a solid edge to only one of its children and the corresponding subtree is equal or larger than the subtree of the sibling (if one exists). The main property of the dashed-solid assignment is that the length of the longest dashed path is O(log n). Note that given that we can compute subsize easily (Section 3.2), assigning edges to dashed or solid is trivial using another Euler tour traversal. Given a dashed-solid representation, we compute (x, y) coordinates by creating a tour around the tree where edges are accessed in a specific order. The traversal first goes down only via solid edges, when a leaf is reached we traverse up until a node with a dashed edge is reached. We then follow this subtree also traversing its solid edges first. To construct this traversal one needs to store with every node which of its children is solid. The coordinates (x, y) are computed as follows. We follow a solid edge path until a leaf l is reached and then the leaf node is assigned to coordinate (l.refpoint.x + l.width/2, 0). We remember this coordinate as s in the private memory. When going up, if the parent node p does not have any other children, then we assign it to (s.x, s.y) and continue traversing up the tree. If the node p indeed has a dashed edge, then we traverse the subtree of the dashed edge. Once this traversal is finished, p is assigned to ((s.x + d.x)/2, 1 + max(s.y, d.y)) where d is the coordinate of the child from the dashed edge. We now discard old value of s and d and assign s to just computed coordinate of p and keep going up. The same process is applied when we go down the subtree from the dashed edge, except we need to remember s coordinate for every subtree rooted at a solid edge we encounter going down. Since the longest path starting from a dashed edge is bounded by O(log n) we can easily fit a stack of corresponding s coordinates into our small workspace W . (See Figure 5 for an example of the drawing.) We note that this algorithm can be extended to n-ary trees if we store dashed Fig. 5: Example of the algorithm in Section 3.6. Tree annotated with the width, height and x coordinate of the top left corner of the bounding rectangle (refpoint). Figure on the right is the resulting drawing. 2x1, 2 2x1, 0 2x1, 4 2x1, 6 2x2, 2 2x2, 4 4x3, 2 6x4, 0 8x5, 0 a b c d e f g i a b d c e f g i k k edges of a single node in a balanced binary tree (see [11] for details). 3.7 Summary The following theorem summarizes the results of this section. Theorem 2. The drawing algorithms described in this section are data-oblivious according to Definition 1 and run in time O(n log n). Also, the private working space has size O(log n) for the bounding-rectangle tree-drawing algorithm (where n is the size of the tree) and has size O(1) for the other algorithms. Since we have given algorithms in the compressed-scanning model, the theorem follows from Theorem 1. All of the algorithms perform a constant number of Euler tours. In the beginning of Section 3 we showed that an Euler tour can be implemented with a single-round compressed scan, where, from the server's perspective, the items associated with the edges of the tour are accessed in random order and only once. Our algorithms hide the combinatorial structure and layout of the graphs, while the number of edges and vertices is revealed. One can achieve even stronger privacy if dummy edges and nodes are added. From the point of view of the model, the input S is a larger set of elements and the running time of algorithm A increases as well. 4 Conclusions and Open Problems We introduce the compressed-scanning technique for designing data-oblivious algorithms in a cloud-computing environment. In a nutshell, this technique involves specifying an algorithm as a series of scans where data is processed using a small working storage. Using this technique, we show how to implement classic drawing algorithms for trees, series-parallel graphs, and planar st-digraphs (and variations of these algorithms) so that the client needs only a small amount of working storage (constant or logarithmic in the size of the data set) and can fully protect the privacy of the graph and of its layout, beyond what can be accomplished by encryption alone. Open problems include finding other applications of this technique and developing al- ternative data-oblivious approaches for graph drawing. For example, it is not known how to compute in a data-oblivious way st orientations and st-numberings, used for visibility representations of planar graphs [29], or canonical orderings [13], used for planar straight-line drawings. Acknowledgments Research supported in part by the National Science Foundation under grants 0830149, 0830403, 1228485, and 1228639 and by a NetApp Faculty Fellowship. We would like to thank Giuseppe Di Battista for useful discussions. References 1. J. Abello and J. Korn. MGV: a system for visualizing massive multidigraphs. IEEE Trans. on Visualization and Computer Graphics, 8(1):21–38, jan/mar 2002. 2. J. Abello, E. Koutsofios, E. R. Gansner, and S. C. North. Large networks present visualization challenges. SIGGRAPH Comput. Graph., 33(3):13–15, Aug. 1999. 3. M. Ajtai. Oblivious RAMs without cryptographic assumptions. In Proc. ACM Symp. on Theory of Computing (STOC), pages 181–190. ACM, 2010. 4. B. Babcock, S. Babu, M. Datar, R. Motwani, and J. Widom. Models and issues in data stream systems. In Proc. Symp. on Principles of Database Systems, pages 1–16, 2002. 5. N. Barghouti, J. Mocenigo, and W. Lee. Grappa: A GRAPh PAckage in Java. In Graph Drawing (GD), volume 1353 of LNCS, pages 336–343. Springer, 1997. 6. P. Bertolazzi, R. F. Cohen, G. Di Battista, R. Tamassia, and I. G. Tollis. How to draw a series-parallel digraph. Internat. J. Comput. Geom. Appl., 4:385–402, 1994. 7. C. Binucci, U. Brandes, G. Di Battista, W. Didimo, M. Gaertler, P. Palladino, M. Patrignani, A. Symvonis, and K. Zweig. Drawing trees in a streaming model. In Graph Drawing (GD), volume 5849 of LNCS, pages 292–303. 2010. 8. D. Boneh, D. Mazi`eres, and R. A. Popa. Remote oblivious storage: Making oblivious RAM practical. Technical report, CSAIL, MIT, 2011. http://dspace.mit.edu/handle/1721.1/62006. 9. S. Bridgeman, A. Garg, and R. Tamassia. A graph drawing and translation service on the World Wide Web. Int. J. Comp. Geom. Appl., 9(4–5):419–446, 1999. 10. Y.-J. Chiang, M. T. Goodrich, E. F. Grove, R. Tamassia, D. E. Vengroff, and J. S. Vitter. External-memory graph algorithms. In 6th ACM-SIAM Symp. on Discrete Algorithms (SODA), pages 139–149, 1995. 11. R. F. Cohen, G. Di Battista, R. Tamassia, and I. G. Tollis. Dynamic graph drawings: Trees, series-parallel digraphs, and planar ST -digraphs. SIAM J. Comput., 24(5):970–1001, 1995. 12. I. Damgard, S. Meldgaard, and J. B. Nielsen. Perfectly secure oblivious RAM without random oracles. In Proc. Theory of Cryptography Conference (TCC), pages 144–163, 2011. 13. H. de Fraysseix, J. Pach, and R. Pollack. How to draw a planar graph on a grid. Combinatorica, 10(1):41–51, 1990. 14. G. Di Battista, P. Eades, R. Tamassia, and I. G. Tollis. Graph Drawing. Prentice Hall, Upper Saddle River, NJ, 1999. 15. G. Di Battista, R. Tamassia, and I. G. Tollis. Area requirement and symmetry display of planar upward drawings. Discrete Comput. Geom., 7(4):381–401, 1992. 16. D. Eppstein, M. T. Goodrich, and R. Tamassia. Privacy-preserving data-oblivious geometric algorithms for geographic data. In 18th ACM Adv. in Geographic Information Systems (ACM GIS), pages 13–22, 2010. 17. J. Feldman, S. Muthukrishnan, A. Sidiropoulos, C. Stein, and Z. Svitkina. On distributing symmetric streaming computations. ACM Trans. Algorithms, 6(4):66:1–66:19, 2010. 18. O. Goldreich. The Foundations of Cryptography - Volume 1, Basic Techniques. Cambridge University Press, 2001. 19. O. Goldreich. Foundations of Cryptography, Volume II. Cambridge University Press, 2004. 20. O. Goldreich and R. Ostrovsky. Software protection and simulation on oblivious RAMs. J. ACM, 43(3):431–473, 1996. 21. M. T. Goodrich. Randomized Shellsort: A simple oblivious sorting algorithm. In Symposium on Discrete Algo- rithms (SODA), pages 1–16, 2010. 22. M. T. Goodrich and M. Mitzenmacher. Privacy-preserving access of outsourced data via oblivious RAM simula- tion. In ICALP, pages 576–587, 2011. 23. M. T. Goodrich, M. Mitzenmacher, O. Ohrimenko, and R. Tamassia. Oblivious RAM simulation with efficient worst-case access overhead. In Proc. ACM Workshop on Cloud Computing Security (CCSW), pages 95–100, 2011. 24. M. T. Goodrich, M. Mitzenmacher, O. Ohrimenko, and R. Tamassia. Practical oblivious storage. In Proc. ACM Conference on Data and Application Security and Privacy (CODASPY), 2012. 25. M. T. Goodrich, M. Mitzenmacher, O. Ohrimenko, and R. Tamassia. Privacy-preserving group data access via stateless oblivious RAM simulation. In Proc. ACM-SIAM Symp. on Discrete Algorithms (SODA), 2012. 26. M. R. Henzinger, P. Raghavan, and S. Rajagopalan. Computing on data streams. In External Memory Algorithms, volume 50 of Discrete Mathematics and Theoretical Computer Science, pages 107–118. AMS, 1999. 27. B. Johnson and B. Shneiderman. Tree-maps: A space-filling approach to the visualization of hierarchical infor- mation structures. In IEEE Visualization, pages 284–291, 1991. 28. S. Muthukrishnan. Data Streams: Algorithms and Applications. In Foundations and Trends in Theoretical Computer Science, volume 1. Now Publishers, 2005. 29. R. Tamassia and I. G. Tollis. A unified approach to visibility representations of planar graphs. Discrete Comput. Geom., 1(4):321–341, 1986. 30. J. S. Vitter. External memory algorithms and data structures: dealing with massive data. ACM Comput. Surv., 33(2):209–271, June 2001.
1811.00487
1
1811
2018-10-29T04:34:40
On New Approaches of Maximum Weighted Target Coverage and Sensor Connectivity: Hardness and Approximation
[ "cs.DS" ]
In mobile wireless sensor networks (MWSNs), each sensor has the ability not only to sense and transmit data but also to move to some specific location. Because the movement of sensors consumes much more power than that in sensing and communication, the problem of scheduling mobile sensors to cover all targets and maintain network connectivity such that the total movement distance of mobile sensors is minimized has received a great deal of attention. However, in reality, due to a limited budget or numerous targets, mobile sensors may be not enough to cover all targets or form a connected network. Therefore, targets must be weighted by their importance. The more important a target, the higher the weight of the target. A more general problem for target coverage and network connectivity, termed the Maximum Weighted Target Coverage and Sensor Connectivity with Limited Mobile Sensors (MWTCSCLMS) problem, is studied. In this paper, an approximation algorithm, termed the weighted-maximum-coverage-based algorithm (WMCBA), is proposed for the subproblem of the MWTCSCLMS problem. Based on the WMCBA, the Steiner-tree-based algorithm (STBA) is proposed for the MWTCSCLMS problem. Simulation results demonstrate that the STBA provides better performance than the other methods.
cs.DS
cs
On New Approaches of Maximum Weighted Target Coverage and Sensor Connectivity: Hardness and Approximation Ngoc-Tu Nguyen, Bing-Hong Liu, and Shih-Yuan Wang 1 8 1 0 2 t c O 9 2 ] S D . s c [ 1 v 7 8 4 0 0 . 1 1 8 1 : v i X r a Abstract -- In mobile wireless sensor networks (MWSNs), each sensor has the ability not only to sense and transmit data but also to move to some specific location. Because the movement of sensors consumes much more power than that in sensing and communication, the problem of scheduling mobile sensors to cover all targets and maintain network connectivity such that the total movement distance of mobile sensors is minimized has received a great deal of attention. However, in reality, due to a limited budget or numerous targets, mobile sensors may be not enough to cover all targets or form a connected network. Therefore, targets must be weighted by their impor- tance. The more important a target, the higher the weight of the target. A more general problem for target coverage and network connectivity, termed the Maximum Weighted Target Coverage and Sensor Connectivity with Limited Mobile Sensors (MWTCSCLMS) problem, is studied. In this paper, an ap- proximation algorithm, termed the weighted-maximum-coverage- based algorithm (WMCBA), is proposed for the subproblem of the MWTCSCLMS problem. Based on the WMCBA, the Steiner- tree-based algorithm (STBA) is proposed for the MWTCSCLMS problem. Simulation results demonstrate that the STBA provides better performance than the other methods. Index Terms -- Mobile wireless sensor network, target coverage, network connectivity, NP-complete, approximation algorithm. I. INTRODUCTION Because of the rapid expansion of technology, well- developed sensors accompany various sensing functions, such as detecting surrounding temperatures, illuminations, and voices, calculating and processing received information, and the communication ability to transmit and receive data, which can be composed to form a wireless sensor network [1], [2], [3], [4]. Recently, wireless sensor networks have been widely applied to surveillance, security, and tracking applications [5], [6], [7], [8]. In these applications, with the communication ability, sensors can communicate with the data sink or other sensors to transmit sensed data [9]. Due to the rapid development of sensor technology, in addition to sensing ability and data transmission, sensors, also known as mobile sensors, can have the ability to move to some locations. A wireless sensor network that is composed of mobile sensors is also known as a mobile wireless sensor Corresponding author: B.H. Liu. N.T. Nguyen is with the Department of Computer Science and Engineering, University of Minnesota, Twin Cities, Minneapolis, MN 55455 USA (e-mail:, [email protected]). B.H. Liu and S.Y. Wang are with the Department of Electronic Engi- neering, National Kaohsiung University of Science and Technology, 415, Chien Kung Rd., Kaohsiung 80778, Taiwan (e-mail: [email protected], [email protected]). network (MWSN). Because the movement of sensors requires significantly higher power consumption than that in sensing and communication [10], minimizing the total movement distance of mobile sensors becomes a more important issue in MWSNs [11]. In [11], the Mobile Sensor Deployment (MSD) problem, which is the problem of scheduling mobile sensors to cover all targets and maintain network connectivity such that the total movement distance of mobile sensors is minimized, is studied. For the MSD problem, algorithms based on the clique partition and the Voronoi partition are proposed to find coverage sensors to cover targets. In addition, the Euclidean minimum spanning tree is used to span coverage sensors and the data sink, and determine some points in the sensing field such that the network composed of the sensors deployed on the points can form a connected network. Finally, the Hungarian method is applied to schedule adaptive mobile sensors to the generated points such that the total movement distance is minimized. Most research studies on target coverage when the number of mobile sensors is assumed to be high enough such that a connected network can always be formed to cover all targets. However, in reality, due to a limited budget or numerous targets, there may not be enough mobile sensors to cover all targets or form a connected network. Therefore, targets must be weighted by their importance. The more important a target, the higher the weight of the target. This motivated us to study a more general and practical problem for target coverage and network connectivity, termed the Maximum Weighted Target Coverage and Sensor Connectivity with Limited Mo- bile Sensors (MWTCSCLMS) problem. The MWTCSCLMS problem is the problem of scheduling limited mobile sensors to appropriate locations to cover targets and form a connected network such that the total weight of the covered targets is maximized. The highlights of the contribution in this paper are listed as follows: • A general problem for target coverage and network con- nectivity in MWSNs, termed the MWTCSCLMS prob- lem, and its difficulty are introduced and discussed in this paper. In addition, when the transmission range is assumed to be large enough for any communication, a subproblem of the MWTCSCLMS problem, termed the Reduced MWTCSCLMS (RMWTCSCLMS) prob- lem, and its difficulty are also introduced and discussed. termed the weighted- maximum-coverage-based algorithm (WMCBA), with an • An approximation algorithm, approximation ratio of 1 − 1/e is proposed for the RMWTCSCLMS problem, where e denotes the base of the natural logarithm. In the WMCBA, all possible sets of targets that can be covered by a mobile sensor located at any point in the sensing field are considered. Then, a greedy method is used to select suitable sets of targets to be covered by mobile sensors. • Based on the WMCBA, the Steiner-tree-based algorithm (STBA) is proposed for the MWTCSCLMS problem. In the STBA, the Fermat points [12] and a node-weighted Steiner tree algorithm [13] are used to find a tree such that the number of mobile sensors deployed by the tree structure to form a connected network is minimized. • Theoretical analyses of the WMCBA and the STBA are provided. • Simulation results demonstrate that even if the number of mobile sensors is high enough such that a connected network can always be formed to cover all targets, the STBA requires a significantly lower total movement distance than the best solution proposed for the MSD problem [11]. In addition, when the mobile sensors may be not enough to cover all targets, the STBA works better than the greedy method proposed in the simulation section of this paper. The remaining sections of this paper are organized as follows. Related work is introduced in Section II. In Section III, illustrates the MWTCSCLMS problem and the RMWTC- SCLMS problem are illustrated. In addition, the analyses of their difficulties are also provided. In Section IV, the WMCBA is proposed for the RMWTCSCLMS problem. In addition, the STBA is proposed in Section V. The performance of the STBA is evaluated in Section VI. The paper is concluded in Section VII. II. RELATED WORK The coverage problem is an important issue in a wireless sensor network, in which each sensor has its own mission to monitor a region through the sensor's sensing range. Different applications have various coverage requirements [14], [15], [16], [17]. In [14], the area coverage problem is discussed in the way to deploy sensors to form a wireless sensor network such that a particular area will be fully covered and ensure the network connectivity. In [15], the area coverage problem is studied to deploy sensors to form a connected wireless sensor network even if unpredicted obstacles exist in the sensing field. In [16], the problem of constructing a minimum size connected wireless sensor network such that the critical grids in a sensing field are all covered by sensors is addressed. In [17], the barrier coverage problem, the problem of deploying sensors to construct a barrier such that invaders will be detected by at least one sensor, is studied. 2 be reported to the data sink. When the sensors are activated to monitor targets or transmit data, the sensors will continuously consume energy. Therefore, the sensors will not be able to monitor targets or transmit data if their energy is exhausted. Because the energy of the sensors is often limited, many studies have investigated extending the network lifetime to cover targets. In [18], the problem of deploying sensors and scheduling the sensors' activation time is studied such that all targets can be covered and the network lifetime can be extended. In some cases, it is hard for people to deploy sensors manually, and therefore, random deployment [19], [20] can be used to construct a wireless sensor network. Because random deployment cannot ascertain the sensors' locations before deployment, the problem of scheduling sensors to be activated to form a wireless sensor network and covering targets such that the network lifetime is extended has received a great deal of attention [21], [22], [23]. In [21], a distributed algorithm is proposed to alternatively activate sensors to form a minimal set cover for covering all targets such that the network lifetime is maximized in energy-harvesting wireless sensor networks. In [22], a heuristic algorithm is proposed to schedule sensors into multiple sets such that the sensors in each set can cover all targets and form a connected network with the data sink. In addition, the sensor sets are activated one-by-one such that the network lifetime can be maximized. In [23], a polynomial- time constant-factor approximation algorithm is proposed to schedule sensors to form a connected network that can cover all targets and maximize the network lifetime. In MWSNs, when mobile sensors are randomly deployed in a sensing field, mobile sensors can be used to improve the coverage quality and the network connectivity in MWSNs. In [24], a survey on utilizing node mobility to extend the network lifetime is discussed and provided. In [25], algorithms are proposed to dispatch mobile sensors to designated locations such that the area of interest can be k-covered. In [26], when mobile sensors have different sensing ranges, algorithms based on the multiplicatively weighted Voronoi diagram are proposed to find coverage holes such that the coverage area can be improved. In [27], an algorithm is proposed to relocate the minimum number of redundant mobile sensors to maintain connectivity between a region of interest and a center of interest in which a particular event occurs, where mobile sensors are initially deployed in the region of interest, and the center of interest is outside the region of interest. In [28], a distributed algorithm is proposed to move mobile sensors to cover all targets and satisfy the minimum allowed detection probability such that the network lifetime is maximized. III. THE MAXIMUM WEIGHTED TARGET COVERAGE AND SENSOR CONNECTIVITY WITH LIMITED MOBILE SENSORS PROBLEM AND ITS DIFFICULTY The target coverage problem is one of the coverage prob- lems. In the target coverage problem, targets are the points of interest (POI) in the sensing field that are required to be covered and monitored by sensors. In addition, the wireless sensor network composed of sensors has to be connected such that the monitoring information generated by the sensors can The system model used in this paper is illustrated in Section III-A. Our problem, termed the Maximum Weighted Target Coverage and Sensor Connectivity with Limited Mobile Sensors (MWTCSCLMS) problem, is presented in Section III-B. Finally, the problem's difficulty is analyzed in Section III-C. t1(10) s3 t2(4) s2 s1 s4 t3(2) s5 s6 t4(1) t5(8) s9 s8 s7 s12 s10 s11 t6(5) t7(5) s13 s14 t8(6) mobile sensor target data sink Fig. 1: Example of the MWSN with 14 mobile sensors and 8 targets, where the number inside the parentheses indicates the corresponding target's weight. A. System Model In the MWSN, mobile sensors are responsible for sensing targets, collecting sensed data, and reporting the data to a special node, termed the data sink. The data sink can collect mobile sensors' location information and broadcast deploy- ment orders to mobile sensors [11]. For data collection, a mobile sensor s can sense and collect data from a target t if t is within s's sensing range, denoted by Rs. Hereafter, the target t is said to be covered if and only if t is within at least one mobile sensor's sensing range. Because some targets may be outside the sensing range of a mobile sensor in the initial deployment [20], mobile sensors must move to cover targets if necessary. Once targets are covered or sensed by a mobile sensor s, the sensed data are generated by s, and have to be reported to the data sink. In the MWSN, every mobile sensor s can transmit data to other mobile sensors within its transmission range, denoted by Rt. The sensed data can then be forwarded through sensors to the data sink by multi-hop protocols [9] if there exists a connected path from the node that generates the sensed data to the data sink. Take Fig. 1, for example. In Fig. 1, it is clear that target t4 is covered by mobile sensor s6. This is because s6 is within the circle centered at t4 with radius Rs, the distance between s6 and t4 is not greater than Rs. In addition, target t8 can be covered by mobile sensor s14 after the movement of s14. It is also clear that the sensed data generated by s6 can be forwarded to the data sink because the path from s6 to the data sink is connected. 3 In this paper, a set of n mobile sensors S = {s1, s2, . . . , sn} is pre-deployed in a sensing field. We assume that each mobile sensor in S has the same sensing range Rs to sense targets. In addition, the data sink and each mobile sensor have the same transmission range Rt to communicate with the other mobile sensors. While given a set of m targets T = {t1, t2, . . . , tm} with known locations in the field, mobile sensors can be scheduled to move in any direction and stop anywhere [10] to cover targets or connect with the data sink and the other mobile sensors. In reality, all of the targets in the field may not be covered due to the limited mobile sensors. Targets in the sensing field, therefore, must be weighted by their importance; that is, the more important a target, the higher the weight of the target. Hereafter, the weight of target t is denoted by t.ω. B. The MWTCSCLMS Problem In this paper, we study scheduling limited mobile sensors to appropriate locations to cover targets and form a connected network such that the total weight of the covered targets is maximized, termed the Maximum Weighted Target Cover- age and Sensor Connectivity with Limited Mobile Sensors (MWTCSCLMS) problem. While given an MWSN with a data sink, a set of deployed mobile sensors S = {s1, s2, . . . , sn}, and a set of targets T = {t1, t2, . . . , tm}, the MWTCSCLMS problem can be formally illustrated as follows: INSTANCE: Given Rs, Rt, a data sink sink, a set of deployed mobile sensors S = {s1, s2, . . . , sn}, and a set of targets T = {t1, t2, . . . , tm}, where each sensor s ∈ S has its own position, and each target t ∈ T has its weight t.ω. QUESTION: Does there exist a schedule of mobile sensors in an MWSN for target coverage and network connectivity such that the total weight of the covered targets is maximized? The MWTCSCLMS problem can be viewed under two issues, target coverage and network connectivity. For target coverage, we can schedule mobile sensors to maximize the total weight of the covered targets. For network connectivity, the remaining mobile sensors can be scheduled to form a connected network such that the data generated from sensing targets can be forwarded to the data sink. When given an MWSN as in Fig. 1, it is clear that the data sink and 14 mobile sensors form a connected network. In addition, because all targets can be covered by the connected network, the total weight of the covered targets is 10 + 4 + 2 + 1 + 8 + 5 + 5 + 6 = 41. C. Difficulty of the MWTCSCLMS Problem In this subsection, a special case of the MWTCSCLMS problem, termed the Reduced MWTCSCLMS (RMWTC- SCLMS) problem, is presented to show the difficulty of the MWTCSCLMS problem. In the RMWTCSCLMS problem, when Rs, a data sink sink, a set of deployed mobile sensors S = {s1, s2, . . . , sn}, and a set of targets T = {t1, t2, . . . , tm} are given, and Rt is set to be large enough such that any two mobile sensors (or any one mobile sensor and the data sink) can communicate with each other, the RMWTCSCLMS problem is scheduling mobile sensors in an MWSN for target coverage and network connectivity such that the total weight of the covered targets is maximized. We then show that the RMWTCSCLMS problem is NP-hard in Lemma 1. By Lemma 1, the difficulty of the MWTCSCLMS problem is then concluded in Theorem 1. Lemma 1: The RMWTCSCLMS problem is NP-hard. algorithm, termed the weighted-maximum-coverage-based al- gorithm (WMCBA), which takes O(m3) time, is proposed for the RMWTCSCLMS problem in Section IV-A. In addition, the theoretical analysis of the WMCBA is provided in Section IV-B. 4 Proof: Here, the Target COVerage (TCOV) [11] problem is used to show that the RMWTCSCLMS problem is NP- hard. While we are given a set of deployed mobile sensors S′ = {s1, s2, . . . , sn′} each having sensing range R′s and its own position, and a set of targets T ′ = {t1, t2, . . . , tm′}, the TCOV problem is scheduling mobile sensors in an MWSN to cover all targets such that the total movement distance of the mobile sensors is minimized. Clearly, in the RMWTCSCLMS problem, when Rs = R′s, Rt = ∞, S = S′, T = T ′, and t.ω = 1 for each t ∈ T , the TCOV problem is also an RMWTCSCLMS problem. Therefore, we have that the TCOV problem is a subproblem of the RMWTCSCLMS problem. Because the TCOV problem is NP-hard [29], the RMWTCSCLMS problem is thus NP-hard, which completes the proof. Theorem 1: The MWTCSCLMS problem is NP-complete. Proof: Because the MWTCSCLMS problem clearly be- longs to the NP class, it suffices to show that the MWTC- SCLMS problem is NP-hard. Because the RMWTCSCLMS problem, which is NP-hard by Lemma 1, is a subproblem of the MWTCSCLMS problem, the MWTCSCLMS problem is NP-hard, which completes the proof. IV. APPROXIMATION ALGORITHM FOR A SPECIAL CASE OF THE MWTCSCLMS PROBLEM In the section, we analyze a special case of the MWTC- SCLMS problem, that is, the RMWTCSCLMS problem, and present an approximation algorithm for the problem accord- ingly. In the RMWTCSCLMS problem, because Rt is large enough such that any two mobile sensors (or any one mobile sensor and the data sink) can communicate with each other, the main task is to schedule limited mobile sensors to cover the targets with the maximum total weight. Therefore, how to schedule limited mobile sensors to cover which targets is important in the RMWTCSCLMS problem. It is clear that if one mobile sensor can exactly cover one target, the collection of possible sets of targets covered by the mobile sensor is {{t1},{t2}, . . . ,{tm}}, and the cardinality of the collection is equal to (cid:18)m 1(cid:19). If one mobile sensor can exactly cover k targets covered by the mobile sensor is equal to(cid:18)m k(cid:19). Because a mobile sensor can move to cover 0 or k (1 ≤ k ≤ m) targets, the number of possible sets of targets covered by one k(cid:19) = 2m. To solve targets, the cardinality of the collection of possible sets of the RMWTCSCLMS problem, a brute-force algorithm can be used to check all possible sets of targets such that the total weight of the targets covered by the mobile sensors is maximized; however, the time complexity of the brute-force algorithm is O(2nm) because it has to check 2nm cases for n mobile sensors. To overcome the challenge, an approximation mobile sensor is therefore 1 + m Pk=1(cid:18)m A. The WMCBA In the WMCBA, the idea is to transform any instance of the RMWTCSCLMS problem into an instance of the Weighted Maximum Coverage (WMC) problem. Then, an existing algorithm is used to find the solution SOL for the instance of the WMC problem. Finally, the solution for the instance of the RMWTCSCLMS problem can thus be obtained with SOL. In the WMC problem, while given an universal set U = {u1, u2, . . . , uq} with every element ui in U having a weight ui.τ , a collection of sets of elements in U C = {C1, C2, . . . , Cr}, and a number k, the WMC problem is to find a collection C′ ⊆ C such that C′ ≤ k and the total weight of ui for all ui ∈ SCj∈C′ Cj is maximized, where C′ denotes the cardinality of C′. For example, while given an universal set U = {u1, u2, u3, u4, u5, u6} with ui.τ = 1 (1 ≤ i ≤ 6), C = {{u1, u2, u3}, {u2, u4, u6}, {u4, u5, u6}}, and k = 2, it is easy to verify that C′ = {{u1, u2, u3}, {u4, u5, u6}} has C′ ≤ k, and has maximal total weight 6. In the WMCBA, while given an instance of the RMWTC- SCLMS problem, including Rs, Rt, sink, S, and T , because Rt is large enough such that any two mobile sensors (or any one mobile sensor and the data sink) can communicate with each other, the network formed by the data sink and the mobile sensors must be connected. In addition, the targets in T can be treated as the elements in U in the WMC problem, the cardinality of S can be treated as the number k in the WMC problem, and the set of targets covered by a mobile sensor located at some position can be treated as some set in C. It is clear that when we have a solution SOL to the transformed instance of the WMC problem, the solution for the original instance of the RMWTCSCLMS problem can thus be obtained accordingly. From the transformation, it is clear that how to find all possible sets of targets that can be covered by mobile sensors with lower time complexity and how to solve the WMC problem are critical issues in the WMCBA. Because each mobile sensor has sensing range Rs, a target ti is covered by a mobile sensor s only if the distance between the mobile sensor and the target is not greater than Rs. Let Oti denote a circle centered at ti with radius Rs. This also implies that the mobile sensor s is within the area enclosed by Oti . For two targets ti and tj , if ti and tj can be covered by a mobile sensor s, it is clear that s must be within the area intersected by the circles Oti and Otj . Therefore, when we have a set of targets P in which each target ti ∈ P can be covered by a mobile sensor s, s must be within the area intersected by the circles Oti for all ti ∈ P . We know that when two circles centered at distinct positions with radii Rs intersect, at most two intersection points exist and are located in the boundary of the intersection area. When an area A is generated by the intersection of the circles Oti for all ti ∈ P , at least one intersection point is generated and located in the boundary of the A. That is, at least one intersection point can be selected to be the location of the sensor s such that ti can be covered by s for all ti ∈ P . Let Ppoint denote the set of targets that can be covered by a mobile sensor located at point. The collection of all possible sets of targets CT that can be covered by mobile sensors is constructed by the union of {{ti}} for all ti ∈ T and {Pp1 ti ,tj } for any ti, tj ∈ T , where ti,tj and p2 p1 ti,tj denote the two intersection points intersected by circles Oti and Otj . Lemma 2 shows that all possible sets of targets that can be covered by mobile sensors are included in CT . , Pp2 ti ,tj Lemma 2: For any point p in the sensing field, the set of targets Pp that can be covered by a mobile sensor located at p must be included in CT . Proof: Because CT contains {ti} for all ti ∈ T , the case for a mobile sensor that exactly covers a target is fully considered. Therefore, it suffices to show that the set of two or more targets that can be covered by a mobile sensor located at p must be included in CT . Assume that a set Pp′ = {t1, t2, . . . , tm′} whose targets can be covered by a mobile sensor located at p′ exists but is not included in CT . This implies that the distance between p′ and ti is not greater than Rs for all ti ∈ Pp′ . This also implies that p′ is within the area A intersected by the circles centered at ti with radii Rs for all ti ∈ Pp′ . Because A is constructed by the intersection of the circles centered at ti for all ti ∈ Pp′ , there must exist at least one intersection point p′′ in the boundary of A. This implies that the distance between p′′ and ti is not greater than Rs for all ti ∈ Pp′ . This also implies that Pp′′ = {t1, t2, . . . , tm′} ∈ CT because p′′ is an intersection point of circles. We have that Pp′ = Pp′′ ∈ CT , which constitutes a contradiction, and thus, completes the proof. In the WMCBA, how to solve the WMC problem is another critical issue. Because the WMC problem is NP-hard [30], a greedy algorithm with an approximation ratio 1 − 1/e [30] is applied to the WMC problem, where e denotes the base of the natural logarithm. In the greedy algorithm, the set with the maximum weight of uncovered elements is selected in each iteration. The process is repeated until all elements are covered or k sets are selected. While given an instance of the RMWTCSCLMS problem, including Rs, Rt, sink, S = {s1, s2, . . . , sn}, and T = {t1, t2, . . . , tm}, the WMCBA contains three steps that are illustrated in detail as follows: 1) Construction of U , C, and k: Let U be the set of nodes ui for each ti ∈ T , where ui.τ is set to ti.ω for each ui ∈ U . Let C be the union of {{ui}} for all ti ∈ T and {Cp1 ) is the set of ux for each tx ∈ Pp1 ). The k is set to n. ti ,tj } for any ti, tj ∈ T , where Cp1 (or Cp2 (or Pp2 , Cp2 ti ,tj ti ,tj ti ,tj ti ,tj ti ,tj 2) Establishment of Collection C′: We apply the greedy algorithm [30] to find a collection C′ ⊆ C. 3) Scheduling of Mobile Sensors: Let L = {ptz} ∪ tx ,ty ∈ C′, where ptz tx,ty , p2 {p1 tx,ty} for all Ctz , Cp1 denotes the location point of tz. Mobile sensors in S are scheduled to each points in L. , Cp2 tx ,ty 5 t1,t2 , p1 t6,t7 , pt3 , pt4 , pt5 , and pt8 . Take the MWSN in Fig. 1, for example, where Rt is assumed to be ∞. In the construction of U , C, and k, U is set to the union of {ui} for 1 ≤ i ≤ 8; ui.τ is set to ti.ω for 1 ≤ i ≤ 8; C is set to the union of {{ui}} for 1 ≤ i ≤ 8 and {{u1, u2},{u6, u7}}; and k is set to 14. When the greedy algorithm [30] is applied, C′ = {{u1, u2}, {u6, u7}, {u3}, {u4}, {u5}, {u8}} can be obtained. Then, mobile devices can be scheduled to p1 To minimize the total movement distance of mobile sensors, the Hungarian method [31] is applied for assigning mobile sensors to the points in L. The Hungarian method can be used to find an optimal solution in polynomial time for the assignment problem. In the assignment problem, when a set of agents A and a set of tasks H are given and have the same cardinality, each agent a ∈ A can be assigned to perform any task h ∈ H with cost ψ(a, h). The assignment problem is to assign exactly one agent a ∈ A to each task and assign exactly one task h ∈ H to each agent such that the total cost of the assignment is minimized. It is clear that a mobile sensor si ∈ S can be regarded as an agent ai ∈ A; a point pj ∈ L can be regarded as a task hj ∈ H; and the distance required by si to move to or cover pj can be regarded as the cost ψ(ai, hj). Therefore, the problem of assigning mobile sensors in S to the points in L can be transferred into the assignment problem and can be solved by the Hungarian method [31] if S and L have the same cardinality. However, S and L are not always the same. Because less than or equal to S sets (or location points) are selected in the WMCBA, S is greater than or equal to L. For this reason, we can obtain L′ by adding some dummy points into L such that S = L′, where the dummy points' corresponding costs ψ are set to 0. Therefore, when S and L are given, the cost matrix generated by S and L for the input of the Hungarian method is an n × n matrix and is shown as follows:  [ψ(si, pj)]n×n = ··· 0 ... . . .   ··· 0 where n = S; ℓ = L; ψ(si, pj) = ζ(si, pj) if pj is some tx,ty or p2 p1 tx,ty in L; ψ(si, pj) = ζ(si, pj) − Rs if pj is some ptz in L and ζ(si, pj) ≥ Rs; ψ(si, pj) = 0 for other cases; and ζ(si, pj) denotes the distance between si and pj . When the cost matrix is determined, the optimal assignment can be obtained with the Hungarian method [31]. . . . ψ(s1, pℓ) 0 ... . . . ··· ψ(sn, pℓ) 0 ψ(sn, p1) ψ(s1, p1) ... ... , B. Theoretical Analysis of the WMCBA In the following, the analysis of the time complexity of the WMCBA is given in Theorem 2. In addition, Lemma 3 shows that there exists a strict reduction from the RMWTCSCLMS problem to the WMC problem with the WMCBA. Theorem 3 provides the approximation ratio of the WMCBA with the help of Lemma 3. Theorem 2: The time complexity of the WMCBA is bounded in O(m3), where m is the number of targets. Proof: Because all targets can be covered if the number of mobile sensors is greater than or equal to the number of targets, that is, n ≥ m, we discuss only the case with n < m in the following. In the construction of U , C, and k, because T has m elements, it requires O(m) time to construct U . Because there are at most two intersection points for any are generated. Therefore, we have that there are at most m two distinct circles, at most 2 × (cid:18)m 2(cid:19) intersection points + 2 × (cid:18)m 2(cid:19) = m2 elements in C. In addition, because it needs at most O(m) time to check if any targets are within a circle, it requires O(m × m2) = O(m3) time to construct C. Therefore, the construction of U , C, and k requires O(m3) time because the setting of k requires only constant time. In the establishment of collection C′, because the greedy algorithm [30] is applied to iteratively select a set with the maximum weight of the uncovered elements in C until k sets are selected or all elements in U are covered, it requires O(k × m2) or O(m × m2) time to construct C′ because there are at most m2 elements in C and at most m iterations are required in the greedy algorithm. Because k = n < m, it requires O(m×m2) = O(m3) time for the construction of C′. Because at most k mobile sensors are scheduled and k < m, at most an m × m cost matrix is required for the Hungarian method. By [31], we have that it requires O(m3) time for the Hungarian method, which implies that it requires O(m3) time for the scheduling of mobile sensors. Therefore, the WMCBA requires O(m3) + O(m3) + O(m3) = O(m3) time, which completes the proof. Lemma 3: There reduction from the RMWTCSCLMS problem to the WMC problem by the WM- CBA. exists strict a Proof: Let Π1 and Π2 be the RMWTCSCLMS problem and the WMC problem, respectively. While given any instance I of Π1, including Rs, Rt, S, and T , the WMCBA can transform I into an instance of Π2, termed f (I), including U , C, and k, where f denotes the function that works as the step 1 of the WMCBA. Let g be the function that works as the step 3 of the WMCBA and can transform any feasible solution S of f (I) into a feasible solution g(S) of I. By Theorem 2, we have that f and g are polynomial time computable functions because the WMCBA can be executed in polynomial time. Therefore, it suffices to show that C1) the optimal solution of f (I) can lead to an optimal solution of I, and C2) any feasible solution of f (I) can lead to a feasible solution of I with a better or equivalent performance ratio [32]. The proof of C2 is omitted here due to the similarity of the proof of C1. For C1, when an optimal solution S2 there exists an optimal solution S1 OP T ) > c1(g(S2 OP T of f (I) is given, assume that g(S2 OP T ) is not an optimal solution of I, that OP T of I such that is, c1(S1 OP T )), where c1(S) denotes a cost function and produces the total weight of the covered targets for each feasible solution S. By Lemma 2 and the construction of C, we have that all possible sets of targets that can be covered by mobile sensors are considered and included in C; that is, if a set of targets that can be covered by a mobile sensor exists, the corresponding set also exists in C. Therefore, any set of targets that can be covered by mobile sensors in S1 OP T has a corresponding set in C. Then we can construct a feasible solution S2 to f (I) by selecting the corresponding S1 OP T 6 OP T OP T set in C for each set of targets covered by mobile sensors in S1 OP T . Because ui.τ is equal to ti.ω for each ui ∈ U , the total weight of the covered elements in S2 is equal to the total S1 weight of the covered targets in S1 OP T . Let c2(S) denote a cost function and produce the total weight of the covered element for each feasible solution S. We thus have that c2(S2 ) = S1 OP T ). In a similar way, we also have that c1(g(S2 c1(S1 OP T )) ≥ c2(S2 OP T )), we have that c2(S2 ) = c1(S1 OP T ), S1 which implies that c2(S2 OP T ). This implies that S1 S2 OP T is not an optimal solution of f (I), which constitutes a contradiction, and thus, completes the proof. OP T )) ≥ c2(S2 OP T ). Because c1(S1 OP T ) > c1(g(S2 OP T ) > c1(g(S2 ) > c2(S2 OP T OP T Theorem 3: The WMCBA achieves an approximation ratio of 1− 1/e for the RMWTCSCLMS problem, where e denotes the base of the natural logarithm. Proof: By [32], if there exists a strict reduction from Π1 to Π2, in which Π1 and Π2 represent two optimization problems, any existing ρ-approximation algorithm of Π2 can lead to a ρ-approximation algorithm of Π1. By Lemma 3, it implies that any existing ρ-approximation algorithm of the WMC problem can lead to a ρ-approximation algorithm of the RMWTCSCLMS problem by the WMCBA. Because a greedy algorithm [30] with approximation ratio 1 − 1/e for the WMC problem is applied in the WMCBA, the WMCBA has an approximation ratio 1 − 1/e to the RMWTCSCLMS problem, which completes the proof. V. ALGORITHM FOR THE MWTCSCLMS PROBLEM Because the MWTCSCLMS problem is to schedule limited mobile sensors to appropriate locations to cover targets and form a connected network, the proposed algorithm, termed the Steiner-tree-based algorithm (STBA), is designed to determine appropriate locations first, termed the potential points, and then, move mobile sensors to the potential points for target coverage and network connectivity. Hereafter, a set of points is said to be connected or form a connected network if the network with the data sink and the mobile sensors located at the points is connected. In addition, a target is said to be covered by a point if a mobile sensor located at the point can cover the target; and a set of targets is said to be covered by a point if each target in the set is covered by the point. Because only limited mobile sensors can be used to cover targets and form a connected network, the idea of the STBA is to iteratively add potential points to cover some adaptive targets and form a network connected with the data sink, until there are not enough mobile sensors or all targets are covered. Because a potential point can cover one or more targets, how to determine the positions of potential points in a sensing field for target coverage and network connectivity are critical issues in the MWTCSCLMS problem. By Lemma 2, because all possible sets of targets that can be covered by any point in a sensing field are considered in the construction of C of the WMCBA, the location points ptz for all tz ∈ T and the intersection points p1 for any ti, tj ∈ T are considered to be the reference points that can be used to be the guides for generating potential points. Let X1 be the set of location points ptz for all tz ∈ T ; and let X2 be the set of and p2 ti,tj ti,tj p1 t1 , t2 p t1 p3 p2 p t2 p2 t1 , t2 p1 p13 p14 p t3 p t4 p t5 p9 p8 p2 t6 , t7 p5 p6 p t6 p1 t6 , t7 p t7 p7 p4 p10 p11 p12 p t8 potential point reference point data sink Fig. 2: Example of reference points and potential points obtained by the STBA from the MWSN shown in Fig. 1. ti,tj ti ,tj ti ,tj ti,tj ti ,tj ti ,tj , p2 ti,tj ti,tj and p2 and Pp2 , and Pp2 , respectively. The Pptz , Pp1 intersection points p1 for any ti, tj ∈ T . Let X = X1 ∪ X2. The points p ∈ X can then be used as the guides for generating potential points. In addition, Pptz is set to {tz} for any p1 for each ptz ∈ X1; and Pp1 ti,tj ∈ X2 are set to the sets of targets covered by points p1 and p2 are similar ti,tj to the elements in the construction of C of the WMCBA, and are used to show which targets can be covered when a mobile sensor is located at ptz , p1 ti,tj . Therefore, when a set of targets Pptz , Pp1 is selected to be covered, the corresponding reference point ptz , p1 ti,tj can be regarded as a guide to generate potential points to cover the targets in Pptz , Pp1 and form a connected network. Take the MWSN in Fig. 1, for example. It is clear that X1 is the set of location points pti for 1 ≤ i ≤ 8; and X2 is {p1 t6,t7}. The X is set to the union of X1 and X2, and the reference points in X are shown in Fig. 2. ti,tj , or p2 , or Pp2 ti,tj , or p2 t1,t2 , p1 t1,t2, p2 t6,t7, p2 , or Pp2 ti ,tj ti ,tj ti ,tj ti ,tj Before deciding which set of targets Pp for any reference point p ∈ X to be covered in each iteration in the STBA, we have to know how much cost to pay for covering Pp, that is, how many additional potential points are required. Let N be a set of potential points and the data sink, which can form a network connected with the data sink. Also let ηN (p) denote the minimum distance between point p and each point in N . When a set of targets Pp, in which p is some reference point p1 in X, is considered to be covered and form a ti,tj or p2 ti,tj Rt m connected network with N , it is clear that at least l ηN (p) additional potential points are required to cover Pp and form 7 a connected network with N . That is,l ηN (p) each can be generated on the straight line from p′ to p every distance Rt, not including p′, until p is reached, where p′ is a point in N that has the minimum distance to p. In addition, when a set of targets Pp, in which p is some reference point ptz in X, is considered to be covered and forms a connected Rt m potential points network with N , at least l ηN (p)−Rs required because any point within the circle centered at ptz with radius Rs can cover target tz. Let φN (p) denote the number of additional potential points required to cover Pp and form a connected network with N . The φN (p) can then be defined in Eq. 1: m potential points are Rt φN (p) =(l ηN (p) Rt m, if p is an intersection point, m(cid:17), otherwise. max(cid:16)0,l ηN (p)−Rs Rt (1) Note that when p is some reference point ptz in X and ηN (p) ≤ Rs, φN (p) is set to 0. This is because tz can be directly covered by some potential points in N . In the WMCBA, a greedy algorithm is applied to iteratively select the set with the maximum weight of the uncovered elements for the RMWTCSCLMS problem. In the MWTC- SCLMS problem, because the number of mobile sensors is limited, the mobile sensors have to be efficiently utilized, and therefore, the idea of the STBA is to iteratively select a set of targets Pp for some p ∈ X that has the maximum weight of the uncovered targets and requires the minimum number of additional potential points for constructing a network con- nected with the data sink to cover the targets in Pp. Therefore, when N is given, a new metric for each p ∈ X, denoted by ρN (p), is defined in Eq. 2: ρN (p) =(cid:26)∞, if φN (p) = 0, ΩN (Pp ) φN (p) , otherwise, (2) where ΩN (Pp) denotes the total weight of the targets in Pp that are not covered by the potential points in N . In the STBA, the idea is to iteratively select a p with higher ρN (p) and generate potential points to construct a connected network and cover Pp. When the number of potential points is higher such that the next p is hard to select due to the limited mobile sensors, a node-weighted Steiner tree algorithm is applied to try to re-generate and minimize the number of potential points. When all targets are covered or no more potential points can be reduced, the potential points are deter- mined. Then, similar to the WMCBA, the Hungarian method is applied for assigning mobile sensors to the potential points to minimize the total movement distance of the mobile sensors. The STBA is described in detail in Algorithm 1. In Algorithm 1, the X is constructed in Lines 1-3. In addition, L and Y are initialized to be ∅, where L is used to store the generated potential points and Y is used to store the selected p ∈ X. In the inner while loop, the point p, which is in X such that at least one of the targets in Pp is not yet covered by the points in Y , with higher ρN (p) is iteratively selected, where N is the union of {sink} and L. If two or more p have the same ρN (p), the p with the lowest ηN (p) is selected. Once a p is selected, the potential points can be therefore generated by p and added into L to form a connected network. Therefore, N can become a bigger connected network when more potential points are generated. When the number of potential points is higher such that no more p can be selected, it breaks the inner while loop and calls the function ReGeneratePotentialPoints. The function ReGeneratePotentialPoints is to re-generate potential points to cover all targets in Ppy for each py ∈ Y such that the number of the required potential points is minimized, which is discussed later. The outer while loop iteratively executes the inner while loop until all targets are covered or no more potential points can be reduced. Finally, when L is determined, the deployment orders that assign mobile sensors to potential points can be generated with the Hungarian method. The cost matrix used for the Hungarian method is shown as follows: p'4 p'3 p2 t1 , t2 p'1 pa p'5 p t3 pe 8 , t7 p t5 p'7 p'6 pb p'2 pc p'8 p'9 p1 t6 p'10 pd p'11 p'12 p t8 [ψ(si, pj)]n×n =  ψ(s1, p1) ... ψ(sn, p1) . . . ψ(s1, pℓ) 0 ... . . . ··· ψ(sn, pℓ) 0 ...  ··· 0 ... . . .  ··· 0 , t1 ,t2 t1,t2 t1,t2 where n = S; ℓ = L; ψ(si, pj) = ζ(si, pj) if pj is in L; and ψ(si, pj) = 0 for other cases. Take Fig. 2, for example. When the reference points in X are obtained, the STBA then iteratively selects a reference point p with higher ρN (p), and generate potential points to construct a connected network and cover Pp. Assume that p2 t1,t2 has a higher ρN value than the other reference points and is selected. Because L = ∅ and only sink is in N , the sink in N has the shortest distance to p2 . Then, the potential points are generated on the straight line from sink to p2 t1,t2 every distance Rt, not including the sink, until p2 is reached or all targets in Pp2 are covered. Clearly, potential points p1, p2, and p3 are generated accordingly. In addition, p2 t1,t2 is inserted into Y . After some iterations, assume that Y = {pt3 , pt5 , pt8 , p2 t6,t7} and 14 potential points are generated as shown in Fig. 2. Because the number of potential points is higher such that no more reference points can be selected to cover the last target t4, the function ReGeneratePotentialPoints is called to re-generate potential points to cover all targets in Ppy for each py ∈ Y and to minimize the required potential points. Assume that the potential points re-generated by the function ReGeneratePotentialPoints are shown in Fig. 3. It is clear that only 12 potential points are required at this time. Then, the reference point pt4 can be selected, and two potential points can be generated to cover the targets in Ppt4 . Then, the deployment orders can be generated with the Hungarian method, as shown in Fig. 1. , p1 t1,t2 While given Y , which is used to store the selected reference points, the goal of the function ReGeneratePotentialPoints is designed to re-generate potential points to cover all targets in Ppy for each py ∈ Y and form a network connected with the data sink such that the number of required potential points is minimized. For this purpose, our idea is to find a tree in the plane to connect each py ∈ Y and the data sink sink, in which each tree node is either a py ∈ Y or another point, called the intermediate point hereafter, in the plane, such that the total length of the edges in the tree is minimized. To find more suitable intermediate points in the plane, a set of points F is constructed by finding the Fermat points [12] for Y and sink in the plane. Then, we transfer to the Node-Weighted potential point reference point data sink fermat point Fig. 3: Example of the potential points re-generated by the function ReGeneratePotentialPoints. Steiner Tree (NWST) problem to find a tree Υ that spans the data sink, each py ∈ Y , and some points in F , such that the total length of the edges in the tree is minimized. When the tree Υ is obtained, the potential points are re-generated by the tree structure. While given three vertices (or points) of a triangle ∆, the Fermat point p is a point in the plane such that the total distance from each of the three vertices to p is the minimum. The Fermat point can be obtained with the following rule. If the triangle ∆ has an angle not less than 120 degrees, the Fermat point is located at the obtuse angled vertex of the ∆. Otherwise, we can construct an equilateral triangle on each of any two sides of the ∆. Then, the Fermat point is located at the point intersected by the two lines that are drawn from each new vertex to the opposite vertex of the ∆. To find usable intermediate points in the plane, a set of the Fermat points F is constructed for the Y and the sink as follows. While given Y and sink, a Voronoi diagram for the points in Y ∪ {sink} is first constructed. The Voronoi diagram for Y ∪ {sink} is the polygonal partition of the plane. In addition, each polygon Z(p) is associated with a point in Y ∪ {sink} such that all points in Z(p) are closer to p than other points in Y ∪ {sink}. Two points pi, pj ∈ Y ∪ {sink} are said to be neighbors in the Voronoi diagram if Z(pi) and Z(pj) share a common boundary in the Voronoi diagram. By the generated Voronoi diagram, F can be constructed by finding the Fermat points for any three points pi, pj, pz ∈ Y ∪ {sink} that are neighbors to each other. Take Fig. 3, for example. Assume that Y = and Ppti Algorithm 1 Steiner-Tree-Based Algorithm (T , S, sink) 1: Let X1 be the set of location points pti for all ti ∈ T ; 2: Let X2 be the set of intersection points p1 is set to {ti} for each pti ∈ X1 and Pp2 ti,tj for any ti, tj ∈ T ; and Pp1 , p2 ti,tj ∈ X2 are set to the sets of targets within circles with radii Rs centered at p1 ti,tj and p2 for any p1 ti,tj , respectively ti,tj and p2 ti,tj ti ,tj ti ,tj 6: 3: X ← X1 ∪ X2 4: L ← ∅; Y ← ∅ 5: while there exists one target t ∈ T not within any circles while there exists one target t ∈ T not within any centered at p ∈ L with radii Rs do circles centered at p ∈ L with radii Rs do N ← {sink} ∪ L Let Q be the set of points p for all p ∈ X with if Q > 0 then Pp − Spy∈Y Ppy 6= ∅ and φN (p) ≤ S − L Select a point pi from Q such that ρN (pi) > ρN (pj) or (ρN (pi) = ρN (pj) and ηN (pi) ≤ ηN (pj)) for all pj ∈ Q − {pi} Let pk be the point in N that has the shortest distance to pi 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: Generate potential points on the straight line from pk to pi every distance Rt, not including pk, until pi is reached or all targets in Ppi are covered, and add the points to L else Y ← Y ∪ {pi} break end if end while L′ ← ReGenerateP otentialP oints(Y, sink) if L′ < L then else L ← L′ break end if 23: 24: end while 25: Let D be a set of deployment orders generated by the Hungarian method [31] with input L and S 26: return D t1,t2 , p1 {pt3 , pt5 , pt8 , p2 t6,t7}. By Y and the sink, the Voronoi diagram can be constructed as shown in Fig. 3. In addition, because the sink, pt3 , and p2 t1,t2 are neighbors to each other, the corresponding Fermat point can then be constructed as the point pa in Fig. 3. In Fig. 3, five Fermat points, including pa, pb, pc, pd, and pe, are generated. Here, we show how to transfer to the NWST problem to find a tree Υ, which spans the sink, each py ∈ Y , and some points in F , such that the total length of the edges in the tree is minimized. In the NWST problem, when given an undirected weighted graph G(VG, EG, κ) and a set of terminal nodes T S, the problem is to find a tree Υ(VΥ, EΥ) in G with T S ⊆ VΥ and VΥ ⊆ VG such that the total weight of the edges and nodes in Υ is minimized, where VG (or VΥ) is a set of nodes, EG (or 9 EΥ) is a set of edges connecting two nodes in VG (or VΥ), and κ(v) (or κ((u, v))) denotes the weight of node v ∈ VG (or edge (u, v) ∈ EG). Let T S = Y ∪ {sink} and V = T S ∪ F . Also let G(VG, EG, κ) be a weighted complete graph generated by V , where VG = V , E is the set of (pi, pj) for any pi, pj in V , κ(pi, pj) is the distance between pi and pj for any pi, pj in V , and κ(pi) = 0 for any pi in V . It is clear that when sink, Y , and F are given, the problem is to find a node-weighted Steiner tree with the minimum total weight. Therefore, when G and T S are generated by sink, Y , and F , a method, called the modified Klein and Ravi algorithm, extended from the algorithm [13] proposed by Klein and Ravi used for the NWST problem, is proposed to find a tree Υ(VΥ, EΥ), which can span the sink, each py ∈ Y , and some points in F , such that the total length of the edges in Υ is minimized. The details of the Klein and Ravi algorithm are described as follows. In the Klein and Ravi algorithm, initially, each terminal node in T S is in a tree by itself. Then, the trees are iteratively selected and merged into a bigger tree until only one tree is left. Let Γ be the set of all trees, and let ξ(v, Υi) denote the minimum sum of the weights of the nodes and edges in the path from v to the tree Υi, excluding its endpoints. The quotient cost of a node v is defined in Eq. 3: min Γ′⊆Γ,Γ′≥2 κ(v) +PΥi∈Γ′ ξ(v, Υi) Γ′ . (3) In each iteration of mergence, the node with the minimum quotient cost is first selected. Then, the corresponding paths and trees selected in evaluating the quotient cost are merged into one tree. Take a weighted complete graph with four nodes p1, p2, p3, and p4, for example, where p1, p2, and p3 are terminal nodes, κ(p1, p2) = κ(p1, p3) = κ(p2, p3) = 10, κ(p1, p4) = κ(p2, p4) = κ(p3, p4) = 10√3 , and κ(p1) = κ(p2) = κ(p3) = κ(p4) = 0. Initially, each of p1, p2, and p3 is in a tree by itself. Let Υ1, Υ2, and Υ3 be the trees that include only p1, p2, and p3, respectively. Clearly, the quotient cost of p1, p2, or p3 is 10 2 = 5, and the quotient cost of p4 > 5. Therefore, Υ1 and Υ2 will be merged is into a bigger tree Υ1,2 by inserting an edge (p1, p2). Finally, Υ3 and Υ1,2 will be merged into a final tree by inserting an edge (p1, p3). It is clear that the optimum solution for this case is a tree with nodes p1, p2, p3, p4 and edges (p1, p4), (p2, p4), (p3, p4). To achieve this, the modified Klein and Ravi algorithm is therefore proposed here with a modification of the definition of the quotient cost. In the modified Klein and Ravi algorithm, the quotient cost of a node v is defined in Eq. 4: √3×3 3 = 10√3 10 min Γ′⊆Γ,Γ′≥2 κ(v) +PΥi∈Γ′ ξ(v, Υi) Γ′ − 1 . (4) In the modified Klein and Ravi algorithm, the quotient cost of √3×3 p1, p2, or p3 is 20 = 5√3 < 10. Therefore, Υ1, Υ2, and Υ3 will be merged into a tree with inserting edges (p1, p4), (p2, p4), and (p3, p4). 2 = 10, and the quotient cost of p4 is 10 2 Take Fig. 3 as another example. When the data sink sink, the reference points pt3 , pt5 , pt8 , p2 t6,t7 , and the Fermat points pa, pb, pc, pd, pe are given, the weighted complete graph can be constructed accordingly as shown in Fig. 4. In Fig. t1,t2 , p1 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: pa pb pc pd pe p2 t1 ,t 2 p t3 sink p t5 p1 t6 ,t 7 p t8 terminal node tree node tree edge graph node graph edge Fig. 4: Example of constructing a tree to span all terminal nodes with the modified Klein and Ravi algorithm, where the terminal nodes include sink, pt3 , pt5 , pt8 , p2 . , and p1 t6,t7 t1,t2 4, the sink and the five reference points are terminal nodes. By the modified Klein and Ravi algorithm, a tree that spans the sink and the five reference points is constructed, where the edges in the tree include (sink, pa), (sink, pc), (pa, pt3), (pa, p2 t1,t2 ), (pc, pt5), (pc, p1 t6,t7), and (p1 t6,t7, pt8 ). When the tree Υ(VΥ, EΥ) is obtained, our idea is to deploy potential points along the paths from the data sink, through tree edges, to cover all targets in Ppy for each py ∈ Y . Let p.γ be a point for any tree node p ∈ VΥ that can represent p to connect to the potential points in the other tree edges. Initially, p.γ is set to sink if p = sink; otherwise, p.γ is initialized to null. For any tree edge (pi, pj) ∈ EΥ with pi.γ 6= null, we deploy potential points on the straight line from pi.γ to pj every distance Rt, not including pi.γ. If pj is not a Fermat point in F , the potential points are generated until pj is reached or all targets in Ppj are covered; otherwise, the potential points are generated until pj is reached or the last generated potential point can cover pj . The pj.γ is then set to the last generated potential point. In addition, the generated potential points are recorded. The process is repeated until all tree edges are referenced to generate potential points. The details can be seen in the function ReGeneratePotentialPoints. Take Fig. 4, for example. When the tree in Fig. 4 is obtained, edge (sink, pa) or edge (sink, pb) is selected to generate potential points because sink.γ = sink. Assume that edge (sink, pa) is selected first. Because pa is a Fermat point, the potential points are generated on the straight line from sink to pa every distance Rt, not including sink, until pa is reached or the last generated point can cover pa. As shown in Fig. 3, it is clear that only potential point p′1 is generated because p′1 can cover pa. In addition, pa.γ is set to p′1. Assume that edge (pa, p2 is not a Fermat point, the potential points are generated on the straight line from pa.γ (= p′1) to p2 t1,t2 every distance Rt, not including p′1, until p2 are covered. As shown in Fig. 3, clearly, potential points p′3 and p′4 are t1,t2 ) is selected later. Because p2 is reached or all targets in Pp2 t1,t2 t1,t2 t1 ,t2 generated, and p′4 is the last generated potential point for edge (pa, p2 . Using the same process, 12 potential points can be generated as in Fig. 3. t1,t2) because p′4 is located at p2 t1,t2 10 1: function REGENERATEPOTENTIALPOINTS(Y , sink) 2: F ← ∅ Generate a Voronoi diagram for Y ∪ {sink} for any three points pi, pj , pk ∈ Y ∪ {sink} that are neighbors to each other in the generated Voronoi diagram do Let p be the node located at the Fermat point generated by pi, pj , and pk F ← F ∪ {p} end for T S ← Y ∪ {sink}; V ← T S ∪ F Construct a weighted complete graph G(VG, EG, κ) by V Construct a tree Υ(VΥ, EΥ) by the modified Klein and Ravi algorithm with input G and T S for each p ∈ VΥ do end for p.γ ← sink if p = sink; otherwise, p.γ ← null L′ ← ∅ while EΥ 6= ∅ do for each (pi, pj) ∈ EΥ with pi.γ 6= null do if pj is not a Fermat point then Generate potential points on the straight line from pi.γ to pj every distance Rt, not including pi.γ, until pj is reached or all targets in Ppj are covered; and then set pj.γ to the last generated point and add all points to L′ else Generate potential points on the straight line from pi.γ to pj every distance Rt, not including pi.γ, until pj is reached or the last generated point can cover pj ; and then set pj.γ to the last generated point and add all points to L′ end if EΥ ← EΥ − {(pi, pj)} end for 24: end while return L′ 25: 26: end function The time complexity of the STBA is provided in Theorem 4. Theorem 4: The time complexity of the STBA is bounded in O(m5 + n3), where m is the number of targets and n is the number of mobile sensors. Proof: In the function ReGeneratePotentialPoints, when Y and sink are given, it requires at most O((Y + 1)3) = O(Y 3) time to find the Fermat points because any three neighboring points in Y ∪{sink} in the Voronoi diagram have to be checked. By [33], we have that at most 2 × (Y + 1) combinations of three neighboring points in Y ∪{sink} in the Voronoi diagram, and thus, the generated weighted complete graph has at most 3 × (Y + 1) nodes. In the modified Klein and Ravi algorithm, each node in the weighted complete graph has to compute its distances to all trees in each iteration [13], and thus, each iteration requires at most O((3 × (Y + 1))3) time. Because at least two trees are merged into one tree in each iteration, at most Y iterations are required, and thus, the modified Klein and Ravi algorithm requires at most O(Y × (3 × (Y + 1))3) = O(Y 4) time. Because at most 2 ×(cid:18)3 × (Y + 1) (cid:19) edges in EΥ, it requires at most O(Y 2) time to generate potential points. Therefore, function ReGeneratePotentialPoints requires at most O(Y 3) + O(Y 4) + O(Y 2) = O(Y 4) time. In the STBA, because there are m targets in T , it requires at most O(m2) time to generate 2×(cid:18)m 2(cid:19) = m2−m intersection points, and thus, it requires O(m × m2) = O(m3) time to ti,tj ∈ X2. In compute Pp1 addition, it is clear that it requires O(m) time to compute X1. Because X = X1 ∪ X2, it requires O(m3) + O(m) = O(m3) time to compute X. In each iteration of the outer while loop, at least one target will be covered in the inner while loop, or the function ReGeneratePotentialPoints is called once. Because at for any p1 ti,tj , p2 and Pp2 the 2 ti ,tj ti ,tj most (m2 − m) + m = m2 elements exist in X, at most m2 elements in X have to be checked in the inner while loop. The inner while loop requires at most O(m2× m2) = O(m4) time because each element p in X requires at most O(m2) time to verify that Pp − Spy∈Y Ppy 6= ∅ and φN (p) ≤ S − L. In addition, the function ReGeneratePotentialPoints requires at most O(m4) time because at most m reference points are included in Y to cover targets. Therefore, each iteration of the outer while loop requires at most O(m4) + O(m4) = O(m4) time. Because at least one target will be covered in each iteration of the outer while loop, except for the final iteration, at most m + 1 iterations are required in the outer while loop. Therefore, the outer while loop requires at most O((m + 1) × m4) = O(m5) time. Because the n × n cost matrix is required for the Hungarian method, the Hungarian method requires at most O(n3) time to compute deployment orders [31]. Therefore, the STBA requires at most O(m3) + O(m5) + O(n3) = (m5 + n3), which completes the proof. VI. PERFORMANCE EVALUATION In this section, simulations were used to evaluate the perfor- mance of the STBA. In the simulations, 10-400 mobile sensors and 10-50 targets were randomly deployed in a 600 × 600 square area, where the sensing range Rs and the transmission range Rt of the mobile sensors were set to 20. In addition, the data sink was deployed at the center of the sensing field. Moreover, the value of ω of each target was randomly selected from the interval the results were obtained by averaging 100 data. [1, 10]. In the following simulation, To demonstrate the performance of the STBA, the heuristic algorithm, called the target-based Voronoi greedy algorithm + Euclidean minimum spanning tree-Hungarian algorithm (TV- Greedy+ECST-H) was compared. The TV-Greedy+ECST-H is used for the problem of scheduling mobile sensors to cover all targets such that the total movement distance of the mobile sensors is minimized. The TV-Greedy+ECST-H uses targets' locations to divide the sensing field into Voronoi partitions, 11 which also divides mobile sensors into independent groups. Each target is covered by the nearest sensor selected from the target's group or the target's neighboring groups. Then, a Euclidean minimum spanning tree is adopted to determine the connected paths to the data sink such that mobile sensors can be deployed on the paths. Because the TV-Greedy+ECST-H can be used only for the MWSN with enough mobile sensors to cover all targets and form a connected network, a heuristic, termed the greedy-based algorithm (GBA), is thus proposed here for the MWTCSCLMS problem. In the GBA, the idea is to iteratively select an adaptive target ti from T , deploy a potential point at the location of the ti, that is, pti , and form a bigger network connected with the data sink and the pti , until there are not enough mobile sensors or all targets are covered. Let NGBA be a set of the points ptj located at the selected targets tj and the data sink. Also let ηNGBA (p) denote the minimum distance between point p and each point in NGBA. When an adaptive target ti is selected to form a bigger network connected with NGBA, the GBA is to separate parts by potential points, where tmin denotes the target whose in NGBA has the minimum corresponding location point m equal the straight line between ti and tmin into l ηNGBA (pti ) m. distance to the pti . Here, let φ′NGBA (p) denote l ηNGBA (p) To find an adaptive target, a new metric with a given NGBA for each target tj ∈ T is therefore defined in Eq. 5: Rt Rt ρ′NGBA(tj) = tj.ω φ′NGBA (ptj ) . (5) In the GBA, NGBA is initialized to be {sink}. The selection of an adaptive target is similar to selecting a p with higher ρN (p) in the STBA. In each iteration, the target ti with higher ρ′NGBA(ti) is selected, and the corresponding potential points are generated to form a connected network with the data sink and the pti . If two or more targets t have the same ρ′NGBA(t), the t with lowest ηNGBA (pt) is selected. Then, the pti is inserted into NGBA. The process is iteratively executed until the mobile sensors are not enough to select any target or all targets are selected. When the potential points are determined, the cost matrix is generated in the same way as that in the STBA, which is used for the Hungarian method [31] to generate deployment orders. To compare the STBA with the TV-Greedy+ECST-H, the WMCBA, and the GBA, three MWSN scenarios were consid- ered in the simulation. In the first MWSN scenario, enough mobile sensors were provided such that all targets can be fully covered and form a connected network, where 200-400 mobile sensors were randomly deployed in the sensing field, the value of ω of each target was set to 1, and the TV-Greedy+ECST- H, the GBA, and the STBA could work here. In the second MWSN scenario, the MWSN was the same as that in the RMWTCSCLMS problem; that is, there may not be enough mobile sensors to cover all targets, but the transmission range was large enough such that any two mobile sensors (or any mobile sensor and the data sink) could communicate with each other, where 10-30 mobile sensors were randomly deployed in the sensing field, Rt was set to ∞, and the WMCBA, the GBA, and the STBA could work here. In the third scenario, the d e s u s r o s n e s e l i b o m f o r e b m u n l a t o T 180 160 140 120 100 80 60 10 TV−Greedy+ECST−H GBA STBA 20 30 Number of targets 40 50 5000 4500 4000 3500 3000 2500 2000 1500 e c n a t s d i t n e m e v o m l a t o T 1000 10 TV−Greedy+ECST−H GBA STBA 20 30 Number of targets 40 50 d e s u s r o s n e s e l i b o m f o r e b m u n l a t o T 150 145 140 135 130 125 120 115 110 105 TV−Greedy+ECST−H GBA STBA 5000 4500 4000 3500 3000 2500 2000 e c n a t s d i t n e m e v o m l a t o T 100 200 250 350 Number of mobile sensors 300 400 1500 200 12 TV−Greedy+ECST−H GBA STBA 250 350 Number of mobile sensors 300 400 (a) (b) (a) (b) Fig. 5: The total number of mobile sensors used and the total movement distance required in MWSNs whose number of targets ranges from 10 to 50. The required total number of mobile sensors used and the total movement distance are shown in (a) and (b), respectively. Fig. 6: The total number of mobile sensors used and the total movement distance required in MWSNs whose number of mobile sensors ranges from 200 to 400. The required total number of mobile sensors used and the total movement distance are shown in (a) and (b), respectively. MWSN was the same as that in the MWTCSCLMS problem, where 25-175 mobile sensors were randomly deployed in the sensing field, and the GBA and the STBA could work here. In addition, the TV-Greedy+ECST-H, the WMCBA, the GBA, and the STBA were compared in terms of the total number of mobile sensors used, the total movement distance, and the total weight of the covered targets. The first, second, and third MWSN scenarios are discussed in Section VI-A, Section VI-B, and Section VI-C, respectively. A. Dense MWSNs In dense MWSNs, unless otherwise stated, the number of targets was set to 30; and the number of mobile sensors was set to 300. Fig. 5(a) and Fig. 5(b) show the comparisons of the total number of mobile sensors used and the total movement distance, respectively, in MWSNs when the number of targets ranges from 10 to 50. In Fig. 5(a), it is clear that the higher the number of targets, the higher the total number of mobile sensors used by the TV-Greedy+ECST-H, the GBA, and the STBA. This is because more mobile sensors are required to cover targets and form a connected network. Note that the STBA has a lower total number of mobile sensors used than the TV-Greedy+ECST-H and the GBA. This is because all possible sets of targets that can be covered by any point in a sensing field are considered in the STBA such that multiple targets have a high probability of being selected and covered by only one mobile sensor to minimize the number of required mobile sensors. In addition, the potential points can be re- generated by the function ReGeneratePotentialPoints such that the network connectivity is maintained and the number of required potential points is reduced as much as possible. In Fig. 5(b), the higher the number of targets, the longer the total movement distance required by the TV-Greedy+ECST- H, the GBA, and the STBA. This is because more targets are required to be covered by mobile sensors such that more total movement distance is required for mobile sensors to cover targets and form a connected network. In addition, the STBA has a shorter total movement distance than the TV- Greedy+ECST-H and the GBA. This is because fewer mobile sensors are required to cover targets and form a connected network, as observed in Fig. 5(a). Also note that the GBA has a longer total movement distance than the TV-Greedy+ECST-H. This is because the targets in the GBA are also potential points to which mobile sensors are required to move, and therefore, more total movement distance is required. it Fig. 6(a) and Fig. 6(b) show the comparisons of the total number of mobile sensors used and the total movement dis- tance, respectively, in MWSNs when the number of mobile sensors ranges from 200 to 400. In Fig. 6(a), is clear that the TV-Greedy+ECST-H, the GBA, or the STBA has similar results with the increasing number of mobile sensors. This is because there are enough mobile sensors to cover 30 targets and form a connected network. In addition, the STBA requires the lowest number of mobile sensors used because the potential points generated by the STBA are minimized to cover the targets and form a connected network, the same observation as in Fig. 5(a). In Fig. 6(b), the higher the number of mobile sensors, the lower the total movement distance required by the TV-Greedy+ECST-H, the GBA, and the STBA. This stems from the fact that more nearby mobile sensors can be selected to cover targets and form a connected network, and thus, the total movement distance of the mobile sensors is decreased. It is clear that the STBA has a shorter total movement distance than the TV-Greedy+ECST-H and the GBA, as observed in Fig. 5(b). This is because fewer mobile sensors are required to cover targets and form a connected network. Fig. 7(a) and Fig. 7(b) show the comparisons of the total number of mobile sensors used and the total movement distance, respectively, in MWSNs when the field size ranges from 200 × 200 to 1000 × 1000. In Fig. 7(a), the larger the field size, the higher the number of mobile sensors used by the TV-Greedy+ECST-H, the GBA, and the STBA. This is because more mobile sensors are required to maintain the network connectivity. In addition, the STBA outperforms the TV-Greedy+ECST-H and the GBA because the potential points generated by the STBA are as low as possible, as explained for the results in Fig. 5(a). In Fig. 7(b), the larger the field size, the longer the total movement distance of the mobile sensors required by the TV-Greedy+ECST-H, the GBA, and the STBA. This is because more mobile sensors are required to cover targets and form a connected network in a larger sensing field. 20 200x200 400x400 800x800 1000x1000 600x600 Field size (a) 0 200x200 400x400 600x600 Field size 800x800 1000x1000 (b) (a) TV−Greedy+ECST−H GBA STBA 220 200 180 160 140 120 100 80 60 40 TV−Greedy+ECST−H GBA STBA 14000 12000 10000 8000 6000 4000 2000 e c n a t s d i t n e m e v o m l a t o T d e s u s r o s n e s e l i b o m f o r e b m u n l a t o T Fig. 7: The total number of mobile sensors used and the total movement distance required in MWSNs whose field size ranges from 200 × 200 to 1000 × 1000. The required total number of mobile sensors used and the total movement distance are shown in (a) and (b), respectively. d e s u s r o s n e s e l i b o m f o r e b m u n l a t o T 260 240 220 200 180 160 140 120 100 80 TV−Greedy+ECST−H GBA STBA 12000 10000 8000 6000 4000 2000 e c n a t s d i t n e m e v o m l a t o T TV−Greedy+ECST−H GBA STBA 60 10 15 20 R t (a) 25 30 0 10 15 25 30 20 R t (b) Fig. 8: The total number of mobile sensors used and the total movement distance required in MWSNs whose mobile sensor transmission range ranges from 10 to 30. The required total number of mobile sensors used and the total movement distance are shown in (a) and (b), respectively. In addition, the STBA has a lower total movement distance than the others because fewer mobile sensors are required by the STBA. Fig. 8(a) and Fig. 8(b) show the comparisons of the total number of mobile sensors used and the total movement distance, respectively, in MWSNs when the Rt ranges from 10 to 30. In Fig. 8(a) and Fig. 8(b), the higher the value of Rt, the lower the number of mobile sensors and the lower the total movement distance required by the TV-Greedy+ECST- H, the GBA, and the STBA. This is because fewer mobile sensors are required to maintain network connectivity. In addition, the STBA outperforms the TV-Greedy+ECST-H and the GBA in terms of the number of mobile sensors used and the total movement distance because the STBA generates as few potential points as possible, as explained for the results in Fig. 5(a). B. MWSNs in the RMWTCSCLMS Problem In the MWSNs of the RMWTCSCLMS problem, unless otherwise stated, the number of targets was set to 30; and the number of mobile sensors was set to 20. Fig. 9(a), Fig. 9(b), and Fig. 9(c) illustrate the total weight of the covered targets in MWSNs with the number of targets ranging from 10 to 50, in MWSNs with the number of mobile sensors ranging from 10 to 30, and in MWSNs with the field size ranging s t e g r a t d e r e v o c e h t f o t i h g e w l a t o T 220 200 180 160 140 120 100 80 60 40 10 WMCBA GBA STBA 20 30 Number of targets 40 50 s t e g r a t d e r e v o c e h t f o t i h g e w l a t o T 170 160 150 140 130 120 110 100 90 80 10 WMCBA GBA STBA 15 20 Number of mobile sensors 25 13 30 s t e g r a t d e r e v o c e h t f o t i h g e w l a t o T (b) WMCBA GBA STBA 170 165 160 155 150 145 140 200x200 400x400 800x800 1000x1000 600x600 Field size (c) Fig. 9: The total weight of the covered targets in MWSNs. The number of targets ranging from 10 to 50, the number of mobile sensors ranging from 10 to 30, and the field size ranging from 200 × 200 to 1000 × 1000 in MWSNs are shown in (a), (b), and (c), respectively. from 200 × 200 to 1000 × 1000, respectively. In Fig. 9(a), Fig. 9(b), and Fig. 9(c), the WMCBA and the STBA have a higher total weight of the covered targets than the GBA. This is because all possible sets of targets that can be covered by any point in a sensing field are considered in the WMCBA and the STBA, and thus, it has a high probability of selecting fewer mobile sensors to cover the targets. Therefore, the remaining mobile sensors can be used to cover other targets or maintain network connectivity. In addition, the WMCBA and the STBA have the same results. This is because for any instance of the RMWTCSCLMS problem, the selection of covering targets in the STBA works in the same greedy manner as in the WMCBA. In Fig. 9(a), the higher the number of targets, the higher the total weight of the covered targets obtained by the WMCBA, the GBA, and the STBA. This stems from the fact that more targets can be covered by the mobile sensors. In Fig. 9(b), the higher the number of mobile sensors, the higher the total weight of the covered targets obtained by the WMCBA, the GBA, and the STBA because more mobile sensors can be used to cover the targets. In Fig. 9(c), the larger the field size, the lower the total weight of the covered targets obtained by the WMCBA, the GBA, and the STBA. This is because fewer targets can be covered by exactly one mobile sensor in a large sensing field, and thus, fewer targets can be covered by 20 mobile sensors. C. MWSNs in the MWTCSCLMS Problem In the MWSNs of the MWTCSCLMS problem, unless otherwise stated, the number of targets was set to 30; and the number of mobile sensors was set to 100. Fig. 10(a), Fig. 10(b), Fig. 10(c), and Fig. 10(d) show the total weight of the 14 150 (cid:8) (cid:6) (cid:6) (cid:3) (cid:4) (cid:11) (cid:6) (cid:3)(cid:2) (cid:6) (cid:7) (cid:5) (cid:7) (cid:8) (cid:10) (cid:5) (cid:11) (cid:8) (cid:7) (cid:10) (cid:8) (cid:1)(cid:8)(cid:2)(cid:2) (cid:1)(cid:7)(cid:2)(cid:2) (cid:1)(cid:6)(cid:2)(cid:2) (cid:1)(cid:5)(cid:2)(cid:2) (cid:1)(cid:4)(cid:2)(cid:2) (cid:1)(cid:3)(cid:2)(cid:2) (cid:1)(cid:2) (cid:3)(cid:2) (cid:5) (cid:7) (cid:3)(cid:2) (cid:9) (cid:7) (cid:6) (cid:7) (cid:3)(cid:2) (cid:6) (cid:8) (cid:6) (cid:6) (cid:3) (cid:4) (cid:11) (cid:6) (cid:3)(cid:2) (cid:6) (cid:7) (cid:5) (cid:7) (cid:8) (cid:10) (cid:5) (cid:11) (cid:8) (cid:7) (cid:10) (cid:8) (cid:1)(cid:8)(cid:2)(cid:2) (cid:1)(cid:7)(cid:2)(cid:2) (cid:1)(cid:6)(cid:2)(cid:2) (cid:1)(cid:5)(cid:2)(cid:2) (cid:1)(cid:4)(cid:2)(cid:2) (cid:1)(cid:3)(cid:2)(cid:2) (cid:1)(cid:2) (cid:3)(cid:2) (cid:5) (cid:7) (cid:3)(cid:2) (cid:9) (cid:7) (cid:6) (cid:7) (cid:3)(cid:2) (cid:6) (cid:1)(cid:2) (cid:1)(cid:3)(cid:2)(cid:2) (cid:1)(cid:4)(cid:2)(cid:2) (cid:1)(cid:5)(cid:2)(cid:2) (cid:1)(cid:6)(cid:2)(cid:2) (cid:1)(cid:7)(cid:2)(cid:2) (cid:1)(cid:8)(cid:2)(cid:2) (cid:1)(cid:2) (cid:1)(cid:3)(cid:2)(cid:2) (cid:1)(cid:4)(cid:2)(cid:2) (cid:1)(cid:5)(cid:2)(cid:2) (cid:1)(cid:6)(cid:2)(cid:2) (cid:1)(cid:7)(cid:2)(cid:2) (cid:1)(cid:8)(cid:2)(cid:2) (a) (b) potential point mobile sensor moving path target data sink 170 160 150 140 130 120 110 100 90 80 50 170 160 150 140 130 120 110 100 90 s t e g r a t d e r e v o c e h t f o t i h g e w l a t o T s t e g r a t d e r e v o c e h t f o t i h g e w l a t o T GBA STBA 75 125 Number of mobile sensors 100 GBA STBA (b) 20 R t (d) GBA STBA 20 30 Number of targets 40 50 (a) GBA STBA s t e g r a t d e r e v o c e h t f o t i h g e w l a t o T 240 220 200 180 160 140 120 100 80 60 40 10 170 160 150 140 130 120 110 100 s t e g r a t d e r e v o c e h t f o t i h g e w l a t o T 90 200x200 400x400 800x800 1000x1000 600x600 Field size (c) 80 10 15 25 30 Fig. 11: Deployment orders generated by the GBA and the STBA. The results for the GBA and the STBA are shown in (a) and (b), respectively. Fig. 10: The total weight of the covered targets in MWSNs. The number of targets ranging from 10 to 50, the number of mobile sensors ranging from 50 to 150, the field size ranging from 200 × 200 to 1000 × 1000, and the Rt ranging from 10 to 30 in MWSNs are shown in (a), (b), (c), and (d), respectively. covered targets in MWSNs with the number of targets ranging from 10 to 50, in MWSNs with the number of mobile sensors ranging from 50 to 150, in MWSNs with the field size ranging from 200 × 200 to 1000 × 1000, and in MWSNs with the Rt ranging from 10 to 30, respectively. In Fig. 10(a), Fig. 10(b), Fig. 10(c), and Fig. 10(d), the STBA has a higher total weight of the covered targets than the GBA because more targets can be covered by the STBA, as explained for the results in Fig. 9. In addition, the results of the GBA and the STBA in Fig. 10(a), Fig. 10(b), and Fig. 10(c) are similar to those in Fig. 9(a), Fig. 9(b), and Fig. 9(c), respectively, as explained for the results in Fig. 9, except for the results in Fig. 10(c) with a small field size. In Fig. 10(c), when the field size is smaller than 600 × 600, the GBA and the STBA have similar results. This is because almost all targets are covered by the mobile sensors in the GBA and the STBA in these cases. Moreover, in Fig. 10(d), the higher the Rt value, the higher the total weight of the covered targets obtained by the GBA and the STBA. This is because fewer mobile sensors are used for network connectivity, and thus, more mobile sensors can be used to cover targets. Fig. 11(a) and Fig. 11(b) illustrate the deployment orders generated by the GBA and the STBA, respectively, for the MWSN, in which 100 mobile sensors and 30 targets were randomly generated in a 600 × 600 sensing field, and Rs and Rt were set to 20. The total weight of the covered targets obtained by the GBA is 147, and that obtained by the STBA is 165. VII. CONCLUSION In this paper, the problem of scheduling limited mobile sensors to appropriate locations to cover targets and form a connected network such that the total weight of the covered targets is maximized, termed the Maximum Weighted Target Coverage and Sensor Connectivity with Limited Mobile Sen- sors (MWTCSCLMS) problem, was investigated. In addition, a subproblem of the MWTCSCLMS problem, termed the RMWTCSCLMS, was also investigated and analyzed. The RMWTCSCLMS problem and the MWTCSCLMS problem were shown to be NP-hard here. Moreover, an approximation algorithm, termed the weighted-maximum-coverage-based al- gorithm (WMCBA), was proposed for the RMWTCSCLMS problem. Based on the WMCBA, the Steiner-tree-based algo- rithm (STBA) was therefore proposed for the MWTCSCLMS problem. Theoretical analyses of the WMCBA and the STBA were also provided. In the simulation, three MWSN scenarios were considered, including dense MWSNs, MWSNs in the RMWTCSCLMS problem, and MWSNs in the MWTCSCLMS problem. In dense MWSNs, enough mobile sensors were provided such that all targets could be fully covered and form a con- nected network. The simulation results showed that the STBA had a significantly lower total movement distance than the TV-Greedy+ECST-H that is the best solution for the MSD problem. In the MWSNs of the RMWTCSCLMS problem, simulation results showed that the STBA was comparable to the WMCBA. In the MWSNs of the MWTCSCLMS problem, the STBA outperformed the greedy-based algorithm (GBA) proposed in the simulation section for the MWTCSCLMS problem. REFERENCES [1] Y.-C. Wang, C.-C. Hu, and Y.-C. Tseng, "Efficient placement and dispatch of sensors in a wireless sensor network," IEEE Transactions on Mobile Computing, vol. 7, no. 2, pp. 262 -- 274, Feb 2008. [2] Y. Wang, P. Shi, K. Li, and Z. Chen, "An energy efficient medium access control protocol for target tracking based on dynamic convey tree collaboration in wireless sensor networks," International Journal of Communication Systems, vol. 25, no. 9, pp. 1139 -- 1159, 2012. 15 Transactions on Vehicular Technology, vol. 64, no. 2, pp. 714 -- 727, Feb 2015. [24] Y. Yang, M. I. Fonoage, and M. Cardei, "Improving network lifetime with mobile wireless sensor networks," Computer Communications, vol. 33, no. 4, pp. 409 -- 419, 2010. [25] Y. C. Wang and Y. C. Tseng, "Distributed deployment schemes for mobile wireless sensor networks to ensure multilevel coverage," IEEE Transactions on Parallel and Distributed Systems, vol. 19, no. 9, pp. 1280 -- 1294, Sept 2008. [26] H. Mahboubi, K. Moezzi, A. G. Aghdam, and K. Sayrafian-Pour, "Distributed deployment algorithms for efficient coverage in a network of mobile sensors with nonidentical sensing capabilities," IEEE Trans- actions on Vehicular Technology, vol. 63, no. 8, pp. 3998 -- 4016, Oct 2014. [27] I. E. Korbi and S. Zeadally, "Energy-aware sensor node relocation in mobile sensor networks," Ad Hoc Networks, vol. 16, pp. 247 -- 265, 2014. [28] D. Zorbas and T. Razafindralambo, "Prolonging network lifetime un- der probabilistic target coverage in wireless mobile sensor networks," Computer Communications, vol. 36, no. 9, pp. 1039 -- 1053, 2013. [29] N. T. Nguyen and B. H. Liu, "The mobile sensor deployment problem and the target coverage problem in mobile wireless sensor networks are np-hard," IEEE Systems Journal, pp. 1 -- 4, 2018. [30] G. L. Nemhauser, L. A. Wolsey, and M. L. Fisher, "An analysis of approximations for maximizing submodular set functions -- I," Mathe- matical Programming, vol. 14, no. 1, pp. 265 -- 294, 1978. [31] H. W. Kuhn, "The hungarian method for the assignment problem," Naval Research Logistics Quarterly, vol. 2, no. 1-2, pp. 83 -- 97, 1955. [32] C. Chen and D. Freedman, "Hardness results for homology localization," Discrete & Computational Geometry, vol. 45, no. 3, pp. 425 -- 448, 2011. [33] D. T. Lee and B. J. Schachter, "Two algorithms for constructing a de- launay triangulation," International Journal of Computer & Information Sciences, vol. 9, no. 3, pp. 219 -- 242, 1980. [3] C.-X. Liu, Y. Liu, Z.-J. Zhang, and Z.-Y. Cheng, "High energy-efficient and privacy-preserving secure data aggregation for wireless sensor networks," International Journal of Communication Systems, vol. 26, no. 3, pp. 380 -- 394, 2013. [4] X. Wang, Q. Sun, and Y. Yang, "A cross-layer mobility support protocol for wireless sensor networks," Computers & Electrical Engineering, vol. 48, pp. 330 -- 342, 2015. [5] D. Mascarenas, E. Flynn, C. Farrar, G. Park, and M. Todd, "A mobile host approach for wireless powering and interrogation of structural health monitoring sensor networks," IEEE Sensors Journal, vol. 9, no. 12, pp. 1719 -- 1726, Dec 2009. [6] R. Mittal and M. P. S. Bhatia, "Wireless sensor networks for monitoring the environmental activities," Computational Intelligence and Computing Research (ICCIC), 2010 IEEE International Conference on, pp. 1 -- 5, Dec 2010. [7] A. Somov, A. Baranov, D. Spirjakin, A. Spirjakin, V. Sleptsov, and R. Passerone, "Deployment and evaluation of a wireless sensor network for methane leak detection," Sensors and Actuators A: Physical, vol. 202, pp. 217 -- 225, 2013. [8] N. M. Hassan, O. M. Olaniyi, A. Ahmed, and E. M. Dogo, "Wireless sensor networks for remote healthcare monitoring in nigeria: Challenges and way forward," 2013 IEEE International Conference on Emerg- ing Sustainable Technologies for Power ICT in a Developing Society (NIGERCON), pp. 182 -- 187, Nov 2013. [9] J. W. Jung and M. A. Weitnauer, "On using cooperative routing for lifetime optimization of multi-hop wireless sensor networks: Analysis and guidelines," IEEE Transactions on Communications, vol. 61, no. 8, pp. 3413 -- 3423, August 2013. [10] R. Tan, G. Xing, J. Wang, and H. C. So, "Exploiting reactive mobility for collaborative target detection in wireless sensor networks," IEEE Transactions on Mobile Computing, vol. 9, no. 3, pp. 317 -- 332, March 2010. [11] Z. Liao, J. Wang, S. Zhang, J. Cao, and G. Min, "Minimizing movement for target coverage and network connectivity in mobile sensor networks," IEEE Transactions on Parallel and Distributed Systems, vol. 26, no. 7, pp. 1971 -- 1983, July 2015. [12] S.-R. Qi, "The solution of problem about fermat point in application of the modern pipeline design," Electronic and Mechanical Engineering and Information Technology (EMEIT), 2011 International Conference on, vol. 7, pp. 3785 -- 3788, Aug 2011. [13] P. Klein and R. Ravi, "A nearly best-possible approximation algorithm for node-weighted steiner trees," Journal of Algorithms, vol. 19, no. 1, pp. 104 -- 115, 1995. [14] A. Raha, S. Maity, M. K. Naskar, O. Alfandi, and D. Hogrefe, "An optimal sensor deployment scheme to ensure multi level coverage and connectivity in wireless sensor networks," 2012 8th International Wireless Communications and Mobile Computing Conference (IWCMC), pp. 299 -- 304, Aug 2012. [15] C.-Y. Chang, C.-T. Chang, Y.-C. Chen, and H.-R. Chang, "Obstacle- resistant deployment algorithms for wireless sensor networks," IEEE Transactions on Vehicular Technology, vol. 58, no. 6, pp. 2925 -- 2941, July 2009. [16] W.-C. Ke, B.-H. Liu, and M.-J. Tsai, "Efficient algorithm for construct- ing minimum size wireless sensor networks to fully cover critical square grids," IEEE Transactions on Wireless Communications, vol. 10, no. 4, pp. 1154 -- 1164, April 2011. [17] H. Mostafaei, "Stochastic barrier coverage in wireless sensor networks based on distributed learning automata," Computer Communications, vol. 55, pp. 51 -- 61, 2015. [18] S. Mini, S. K. Udgata, and S. L. Sabat, "Sensor deployment and scheduling for target coverage problem in wireless sensor networks," IEEE Sensors Journal, vol. 14, no. 3, pp. 636 -- 644, March 2014. [19] K. Romer and F. Mattern, "The design space of wireless sensor net- works," IEEE Wireless Communications, vol. 11, no. 6, pp. 54 -- 61, Dec 2004. [20] C. Zhu, C. Zheng, L. Shu, and G. Han, "A survey on coverage and connectivity issues in wireless sensor networks," Journal of Network and Computer Applications, vol. 35, no. 2, pp. 619 -- 632, 2012. [21] C. Yang and K.-W. Chin, "A novel distributed algorithm for complete targets coverage in energy harvesting wireless sensor networks," 2014 IEEE International Conference on Communications (ICC), pp. 361 -- 366, June 2014. [22] Q. Zhao and M. Gurusamy, "Lifetime maximization for connected target coverage in wireless sensor networks," IEEE/ACM Transactions on Networking, vol. 16, no. 6, pp. 1378 -- 1391, Dec 2008. [23] Z. Lu, W. W. Li, and M. Pan, "Maximum lifetime scheduling for target coverage and data collection in wireless sensor networks," IEEE
1908.06318
1
1908
2019-08-17T16:54:40
Comparison-Based Indexing From First Principles
[ "cs.DS", "cs.IR" ]
Basic assumptions about comparison-based indexing are laid down and a general design space is derived from these. An index structure spanning this design space (the sprawl) is described, along with an associated family of partitioning predicates, or regions (the ambits), as well as algorithms for search and, to some extent, construction. The sprawl of ambits forms a unification and generalization of current indexing methods, and a jumping-off point for future designs.
cs.DS
cs
Comparison-Based Indexing From First Principles Magnus Lie Hetland Abstract Basic assumptions about comparison-based indexing are laid down and a general design space is derived from these. An index structure spanning this design space (the sprawl) is described, along with an associated family of partitioning predicates, or regions (the ambits), as well as algorithms for search and, to some extent, construction. The sprawl of ambits forms a unification and generalization of current indexing methods, and a jumping- off point for future designs. 1 Introduction To speed up search operations, it is common to preprocess data by constructing an index structure. In many cases, access to the data is limited to some form of comparison, such as orders or similarity measures. The index then represents possible incremental explorations, with comparisons performed along the way. Similarity search has been a particularly fertile ground for such structures, with a great variety appearing over the last few decades. These indices are based on a range of disparate ideas, with few overarching organizing principles, possibly leading to missed opportunities for intermediate, hybrid or variant structures. My aim is to map out a design space that springs from a handful of basic assumptions, covering all existing methods, as well as countless new variations, combinations and extensions. To describe this design space, I introduce the sprawl, a fully general yet fully implementable comparison-based index in the form of a region-labeled hyperdigraph, along with a new family of regions, the ambits, a common generalization of currently used comparison-based regions, and of weighted polyellipses, polytopes and metaballs (see Fig. 1).1 This work opens up two avenues of further exploration in the search for new and better methods: Either one may accept my explicitly stated assumptions and examines the resulting design space, or one may explicitly depart from them, and thus have a jumping-off point for wholly new designs. Figure 1: A sprawl of am- bits. The regions act as hy- peredges -- gatekeepers for their targets, defined in part by their sources.3 In a realistic setting, the re- gions would typically con- tain their target points. R 1 R As a side-effect, it also introduces a new query modality for existing similarity- based search, where one may search for weighted combinations of sample objects, possibly including negative weights for contrasting objects (cf. 3.2.1). 1.1 Scope, Organization and Contributions The scope of this paper is defined formally in Sect. 1.2, but intuitively my focus is on indexing methods that rely on comparing pairs of objects using some black- box oracle. That is, performing computations directly on the objects themselves, as in most hashing-based methods, is out of scope. Also, I only consider exact search, where false positives are permitted, but false negatives are not. Metric indexing [69] is a prototypical example, and one of the main motivations behind this work.∗ The basic definitions and axioms are laid out in Sect. 1.2. Following that, there are two main parts to the paper. The first part, Sect. 2, defines the sprawl data structure (Def. 2.0.1), and shows how it follows from a bare-bones conception of traversal and exploration (Theorem 2.2.4). A full search algo- rithm is presented (Alg. 2.2.2), along with several results on sprawl correctness (Sect. 2.3). Finally, a stepwise procedure is presented for transforming an arbi- trary comparison-based index structure into a sprawl with the same behavior (Sect. 2.4). The sprawl is a directed hypergraph at heart, and its hyperedges are each labeled with one or more regions of some sort. The second part of the paper, Sect. 3, defines the ambit region type, which may be used for this purpose. Metaphorically, the ambit extends some ways from the hyperedge sources, also known as the region foci. Focal comparisons are combined in some manner to become a measure of remoteness, which is capped at a radius. The manner in which comparisons are combined into remoteness is of central importance; to be useful, this remoteness map must preserve some properties of the comparisons. The idea is to take axioms and theories originally designed for the comparison function, and to apply them to some other domain, which contains the image of the remoteness map. This permits us to reuse existing region definitions, and to introduce the choice of remoteness map as an addi- tional parameter, greatly increasing the flexibility of our regions: Rather than restricting ourselves to the formal language of the original domain, we broaden our horizon to include the meta-language of structure-preserving functions. Linear remoteness in particular is examined in some detail, including con- ditions for overlap (Sect. 3.1), ways of emulating the regions of existing meth- ods (Sect. 3.2), optimizing a region's shape (Sect. 3.3) and the choice of its foci (Sect. 3.4). I also sketch out ways to work with non-linear remoteness (Sect. 3.5) as well as highly general families of comparisons and their properties, along with possible remoteness maps (Sect. 3.6). 1.2 Basic Definitions During the exploration of an index structure, we incrementally accumulate in- formation of some sort. Specifically, in a comparison-based index, this comes in the form of comparisons between objects. The following definitions clarify what this means. ∗ I include here also the less common quasi-metric indexing [see, e.g., 54]. 2 1.2.1 Definition. Given a universe U, a workload in U is a family hQiii of sets Q ⊆ U known as queries. For a given ground set V ⊆ U, the workload is atomistic if, for every query Q, the elements v ∈ Q ∩ V form valid queries {v}. This definition of a workload similar to that of Pestov and Stojmirović [54], who define it as consisting of the universe (the domain), the ground set (dataset or instance) and the queries. 1.2.2 Definition. Given a universe U and a set K of comparison values, a com- parison function on U is any binary function of the form δ : U × U ! K. 1.2.3 Examples. (a) Partial orders may be represented by binary Boolean func- tions, but we might also have a more informative codomain K := {0, 1, 2, 3}, with the values signifying, in order, that u is equal to, less than, greater than or incomparable to v, yielding a form of asymmetric distance [47]. (b) More generally, distances and similarity functions correspond to real -- valued comparisons, usually non-negative, i.e., δ : U × U ! [0, ∞]. Distances ordinarily reserve zero for identical objects. If they also satisfy the triangle in- equality, for example, they are called quasimetrics (see Sect. 3.1). (c) Generalizing further, we may have an L-fuzzy relation δ : U × U ! L, for some poset L, usually a complete lattice [33]. If, in addition, L admits a binary operation, δ may be one of several forms of generalized metrics [17, 21, 28, 59]. 1.2.4 On symmetry. In metric indexing, symmetry is assumed, and this means that one comparison suffices between any two objects. For quasimetrics and more general comparisons, we do not necessarily have symmetry, but we may have a kind of generalized skew symmetry, where for any distinct objects u and v, there exists a function δ(u, v) 7! δ(v, u). This is true of linear and partial orders, for example. If are able to determine object equality by some separate mechanism, this again means that we need only compare in one direction. 1.2.5 On totality. The comparison function need not be total; an undefined com- parison may simply be treated as one that has not been performed during a given search, thereby blocking any decisions depending on it. Resolving a query against an index structure involves incrementally exploring some of its objects, or nodes, with the goal being to examine all relevant ones and avoiding most of those that are irrelevant.4 The behavior of such a search procedure could be characterized by listing the explored objects. The index structure itself might permit several such behaviors, with any non-determinism being resolved by some heuristic. This repertoire of behaviors could then be described by a set of sequences, or language. 1.2.6 Definition. For a finite, non-empty ground set V, let V∗ be the set of finite sequences hx1, . . . , xk i of elements xi ∈ V, including the empty sequence ε. A language is a pair hV, L i where L ⊆ V∗. For any α := hx1, . . . , xki, let αx = hx1, . . . , xk, xi and α = {x1, . . . , xk}. If αx ∈ L then x is a feasible continuation of α in hV, L i. Sequences without feasible continuations are maximal. Regardless of whether we are performing a comparison-based search or some 3 other, more general exploration, there are certain properties common to any kind of such traversal -- properties I intend to capture in the axioms of Def. 1.2.7. Most fundamentally, nodes are visited one by one, and no node is explored more than once, as captured by axioms T1 to T3. Axiom T4 states that nodes are discovered and eliminated at most once, and that current availability depends on which nodes have been traversed so far, regardless of order. 1.2.7 Definition. A traversal repertoire is a language hV, L i satisfying the follow- ing traversal axioms for all α, τ, ω ∈ V∗ and x ∈ V, where α ⊆ τ ⊆ ω: [T1] ε ∈ L ; [T2] If τ x ∈ L then x /∈ τ ; [T3] If τ x ∈ L then τ ∈ L ; (non-emptiness) (simplicity) (heredity) [T4] If τ ∈ L and αx, ωx ∈ L then τ x ∈ L . (interval property) The elements of V are called nodes and the sequences in L are called traversals. 1.2.8 Remark. See Appendix B for notes on kinship to greedoids. 1.2.9 Example. The possible sequences of nodes visited when traversing a graph hV, Ei from a given start node s ∈ V form a traversal repertoire hV, L i. The contents of the traversal queue, or fringe, after traversing nodes hx1, . . . , xki =: α are exactly the feasible continuations of α. These are the nodes that have been discovered but not yet traversed, and that therefore are open or available. Any choice of priority, such as depth-first or breadth-first, yields one specific traversal. A traversal repertoire describes possible traversals of the index for one given query. A more complete description of the index structure requires a mapping from queries to traversal repertoires, as described in the following definition. An important class of such behaviors is characterized by Axiom T5, which says that narrowing the query should not lead to additional nodes becoming available. 1.2.10 Definition. Given a workload hQiii∈I in universe U, a traversal scheme with ground set V ⊆ U is a family hhV, L iiii∈I of traversal repertoires. It is monotonic if it satisfies the following axiom for all i, j ∈ I: [T5] If Qi ⊆ Qj then L i ⊆ L j. (monotonicity) A scheme is correct if Qi ∩ V ⊆ τ for all i ∈ I and each maximal traversal τ ∈ L i. 1.2.11 Example. A procedure that traverses a graph hV, Ei from a fixed starting node, searching for any nodes in Q, yields a traversal scheme. This includes some single-pair shortest path algorithms and querying any kind of search tree. 1.2.12 Definition. Given a comparison function δ : U × U ! K and a tuple p = p1, . . . , pm of sources in U, the comparisons between u and p are the comparison- based features of u. That is, p defines a feature map φ : u ! Km × Km : u 7! hx, yi , 4 where xi = δ(pi, u) and yi = δ(u, pi). We call x and y the forward and backward feature vectors of u, respectively. If δ is symmetric, we omit the redundant comparisons, and get φ : U ! Km : u 7! x, with feature space Km. 1.2.13 Example. If hU, δi is a metric space, then x and y are both equal to Ψ(u), where Ψ : U ! [0, ∞]m is the pivot mapping of metric indexing, which produces a vector of the distances from u to each of the pivots p1, . . . , pm [69]. In this case, we let φ = Ψ. 1.2.14 Definition. Given a universe U and comparison function δ : U × U ! K, a comparison-based region C[p, S] is the preimage of S along the comparison-based feature map φ : U ! Km × Km with sources p := hp1, . . . , pmi, i.e., C[p, S] := φ−1[S] = {u ∈ U : φ(u) ∈ S} , for some region S in the feature space Km × Km or (if δ is symmetric) Km. 1.2.15 Examples. (a) For an ordering relation, intervals like (p1, p2) and [p1, p2) may be specified using S := {1001}, {1001, 1101}. Intervals of partial orders work similarly. For example, axis-orthogonal hyperrectangles in Rk are intervals between two opposing corners. (b) If hU, δi is a metric space, m = 1, and we specify the S by an upper endpoint or radius, we get a metric ball B[p, r] := C[p, [0, r]]. If we provide S := [ℓ, r] with a positive lower endpoint (i.e., an inner radius) ℓ, we get a shell region, and with multiple sources, an intersection of several such shells, corresponding to axis-orthogonal hyperrectangles in feature space. (c) If hU, δi is an asymmetric distance space, there is both a forward ball B+[p, r] and a backward ball B−[p, r] for every center p and radius r, where δ(p, u) and δ(u, p), respectively, falls below r for any member u [47]. These correspond to S having upper limits hr, ∞i and h∞, ri, respectively. (d) For an L-fuzzy relation, the comparison-based regions are crisp level sets containing objects that are related to the sources to certain degrees. 1.2.16 Remark. In an actual data structure, we would not store the full exten- sion of any region, of course, but rather the parameters of some intensional definition -- a formal region. A formal closed ball, for example, is simply a pair hp, ri of a center and a radius, corresponding to the actual closed ball B[p, r], while a formal closed interval consists of two endpoints p1 and p2. In fact, as long as we have the information needed to detect overlap with any valid query, we might not even need to be able to reconstruct the region (or the query) at all. 2 The Sprawl Data Structure Conceptually, a sprawl is a network of regions and points. The regions tell us where we might find points of interest: If we determine that a region might contain something interesting, it indicates which points to examine next. Con- versely, the points help us stake out the regions: In order to determine whether a region contains something of interest, we must first examine its source points, or foci. 5 The traversal of a sprawl has an and -- or nature. We may traverse a region once all its sources are traversed, or we wouldn't have the necessary information. This is not true of points, however; we may traverse them as soon as any regions have pointed us in their direction. This is exactly how directed hypergraphs are traversed, and so it makes sense to base the definition of sprawls on them:∗ 2.0.1 Definition. A sprawl hV, E, P, Ni in a universe U consists of: (i) A directed hypergraph hV, Ei, with ground set V ⊆ U; and (ii) Two edge labelings P, N : E ! 22U . Each label P(e) or N(e) is a family of sets R ⊆ U called the positive or negative regions of e, respectively. A sprawl is finite if each label is finite. If a sprawl has explicitly specified root nodes (as in Def. C.1.2), any implicit root edge e is assumed to have P(e), N(e) = ∅. Note that the nodes of the sprawl are points from the same universe as where the regions are located. Sprawl traversal is discussed in more detail in sects. 2.1 and 2.2, and is defined by Alg. 2.2.2. That definition, however, is spread over several construc- tions and subroutines, so for reader convenience, the steps of the algorithm have been collected here, in Alg. 2.0.2.5 (For some pointers on implementation, see Appendix C.1.) Recall that each edge e ∈ E has a target tgt(e) ∈ V and a set of sources src(e) ⊆ V (cf. Def. C.1.1). 2.0.2 Algorithm. For a query Q, the sprawl hV, E, P, Ni is traversed as follows: unused edges whose sources have all been traversed become active for each active edge e if the target of e is neither traversed nor eliminated if Q is disjoint from some region in N(e) the target of e is eliminated and no longer available the target of e is discovered and is now available 1 initially, no nodes are available, traversed or eliminated 2 initially, no edges are active or have been used 3 repeat 4 5 6 7 8 9 10 11 12 13 14 15 until no nodes are available e has now been used and is no longer active else if Q intersects all regions in P(e) if there are nodes available heuristically select and examine an available node v v has now been traversed and is no longer available Every node that is examined and found to belong to Q is included in the search result. The only way for an edge e to be activated in line 2.0.2 during the first iteration is for src(e) to be empty; its target tgt(e) then becomes a starting node or root. As a shorthand, we may simply declare such roots, in which case we ∗ For more on hypergraphs, see Appendix C.1. 6 assume an incoming sourceless, regionless edge for each. That is, for each root v, we assume an edge e with tgt(e) = v and src(e), P(e), N(e) = ∅, so that when we get to line 2.0.2 in the first iteration, v is guaranteed to have been discovered (though not necessarily available, as it may have been eliminated by some other sourceless edge). The heuristic choice in line 2.0.2 may be managed by some form of priority queue. The priority of a node v may be modified whenever we examine an edge e with tgt(e) = v, i.e., whenever v is disovered or fails to be eliminated (i.e., whenever line 2.0.2 is executed). 2.0.3 Remark. An edge without regions leads to unconditional discovery. To have an edge lead to unconditional elimination once its sources have been traversed, we can let N(e) = {∅}, which will necessarily satisfy the condition in line 2.0.2. If you would like to have exactly one region for each edge (cf. Rem. 2.3.12), you could use P(e) = {U} for the positive case. Although this would not lead to discovery if Q = ∅, the correct (empty) search result would still be guaranteed. 2.0.4 On kNN. I'm assuming that we have a fixed, formal description of the set Q, which we use to determine intersection with the various regions. For relative kinds of queries, however, such as finding the k nearest neighbors to some query point, our description of Q might get more precise as the search progresses. For example, we may maintain the k nearest points found so far, as well as a bounding radius for them, giving us a ball that is certain to contain Q, but that isn't a precise description of Q itself [see, e.g., 35]. While I don't explore such updates further, they could be accommodated simply by modifying the description of Q along with the priorities used in the heuristic, as discussed in the main text, above. 2.0.5 Examples. Three examples are given in Fig. 2. We say that a sprawl edge e is positive if N(e) is empty (it can only lead to discovery) and negative if P(e) contains the empty set (it can only lead to elimination). The black and red edges in the diagrams are positive and negative, respectively. Also, each edge has exactly one (nonempty) region.6 As alluded to in the figure, hyperdigraphs may be implemented using bipartite digraphs, and a natural optimization is then to permit each hyperedge to have multiple targets, as in Fig. 2a, and to combine edges with identical sources and regions, as has been done in Fig. 2c.7 2.0.6 Remark. The laziness in Fig. 2 is not strictly necessary; it is primarily an optimization intended to prevent premature work in eliminating points that are never discovered to begin with (cf. 2.4.2). In order to emulate all traversal behaviors (cf. Theorem 2.2.4), simple hyperdi- graph traversal is not sufficient; we also need to be able to eliminate points that are found to be irrelevant, as indicated in Alg. 2.0.2. So, before we take a more in-depth look at sprawls proper, I'll make a slight detour and introduce a new form of traversal that extends to signed hyperdigraphs. 7 v1 v2 root nodes v1 v1 v2 v3 e1 e2 e3 v3 v4 v5 v6 v7 v8 e12 e21 e31 e13 v2 e32 e23 v3 lazy e1 e2 · · · e7 v6 v5 v4 (a) 2 -- 3 Tree [1]. (b) AESA [56]. (c) PM-Tree [60]. Figure 2: In a sorted search tree (a), the nodes are linearly ordered, with interval regions between them, and the topmost nodes available at the outset. For metric pivot filtering (b), all points are known initially, and they use negative regions to eliminate each other. Some structures, such as the PM-Tree (c), use both kinds of regions, with the negative regions implemented lazily, used only if we discover their children. 2.1 Signed Directed Hypergraph Traversal The established traversal algorithm for directed hypergraphs (Alg. C.1.5) may be augmented with the idea that negative edges inhibit traversal. That is, while positive edges lead to discovery, negative edges lead to the elimination of their targets, as in the added third step of the following algorithm. 2.1.1 Algorithm. A signed hyperdigraph hV, E, σi is traversed by discovering, traversing and eliminating nodes, as described in the following. Nodes are avail- able if they have been discovered but not traversed or eliminated. Edges are active once their sources have been traversed. The following steps are repeated, starting with the second step in the first iteration: Step 1. One of the available nodes is selected and traversed. Step 2. The targets of active positive edges are discovered. Step 3. The targets of active negative edges are eliminated. The steps are repeated as long as there are nodes available. When there are several nodes available, the choice is made using a traversal heuristic. 2.1.2 Definition. Any given traversal heuristic will make Alg. 2.1.1 traverse one specific sequence of nodes, for any given signed hyperdigraph G. The traversal repertoire of G is the set of traversals attainable by varying the heuristic. Note that for the traversal of an unsigned hyperdigraph, any traversal order will end up traversing the same set of nodes, i.e., all those that are reachable. With elimination, however, this is no longer true -- different traversal heuristics may lead to completely different results. 2.1.3 Remark. See Appendix B for notes on forward chaining. 8 Algorithm 2.1.1 is a straightforward generalization of directed graph traver- sal, where (i) edges may have multiple sources that must be traversed, and (ii) neg- ative edges trigger the elimination, rather than discovery, of their targets. As it turns out, this generalization is all that is needed to exactly capture the concept of a traversal repertoire, as shown in the following. 2.1.4 Construction. Given a traversal repertoire hV, L 1i, let hV, E, σi be a signed hyperdigraph where the set E of edges is the smallest set satisfying the following axioms, for all x ∈ V, α, ω ∈ L , where α ( ω, and x /∈ ω. [E1] If αx ∈ L then there is a positive edge α ! x in E. [E2] If αx ∈ L , ωx /∈ L then there is a negative edge ω ! x in E. Let hV, L 2i be the traversal repertoire of hV, E, σi. 2.1.5 Theorem. The following statements are equivalent: (i) hV, L i is a traversal repertoire. (ii) hV, L i is the traversal repertoire of some signed hyperdigraph hV, E, σi. In particular, any traversal repertoire is the traversal repertoire of the corre- sponding signed hyperdigraph produced by Con. 2.1.4. Proof. See Appendix A. 2.1.6 Remark. See Appendix B for notes on kinship to antimatroids. Traversal repertoires are only the first step, however; to capture index structure behavior in general, we need to implement traversal schemes, where each query yields its own traversal repertoire. That is where the sprawl comes in. 2.2 Sprawl Traversal Let's say we have an index structure whose behavior corresponds to a traversal scheme hhV, L iiii∈I, with workload hQiii∈I. For any query Qi, then, we have a repertoire hV, L ii, which we know we can implement with a signed dihypergraph. In order to implement the entire scheme, we would need to map each query to one of several signed dihypergraphs, all of which have the same ground set V. We can consolidate all these into a single hypergraph, and simply add predicates to the edges indicating their presence and sign.8 At this point we have what we could call a generalized sprawl. Similarly to the generalized search trees of Hellerstein, Naughton, and Pfeffer [34], such a gen- eralized sprawl could have arbitrary predicates attached to its edges. However, as we shall see (cf. Theorem 2.1.5), the assumption of monotonicity [T5] lets us restrict our attention to regions and region intersection, yielding Def. 2.0.1. As alluded to initially, the regions are used to determine the presence and sign of each edge in the presence of a query, reducing the search to a signed dihy- pergraph traversal. In the following, I describe this reduction in more detail, and show that it is indeed sufficient for implementing any monotone traversal scheme. 9 2.2.1 Construction. Given a sprawl hV, E, P, Ni in U and a query Q ⊆ U, we produce a signed hyperdigraph hV, E′, σi as follows. Let E′ be the set of edges e ∈ E for which either (i) Q intersects every region in P(e) and N(e), in which case σ(e) = +1; or (ii) Q does not intersect every region in N(e), in which case σ(e) = −1. 2.2.2 Algorithm. For a given query Q ⊆ U, a sprawl hV, E, P, Ni in U is traversed by traversing the corresponding signed hyperdigraph hV, E′, σi of Con. 2.2.1. For a more explicit listing of the steps involved, see Alg. 2.0.2, which describes the same algorithm. 2.2.3 Definition. Let hV, E, P, Ni be a sprawl and hQiii∈I a workload, both in universe U. The corresponding traversal scheme of the sprawl is the collection hhV, L iiii∈I, where each language hV, L ii is the repertoire of traversals attainable by Alg. 2.2.2 for the query Qi, i.e., the repertoire of the signed hyperdigraph of Con. 2.2.1. The sprawl is correct for this workload if its scheme is correct. 2.2.4 Theorem. For a workload hQiii∈I in U, these statements are equivalent: (i) hhV, L iiii∈I is a monotone traversal scheme with ground set V ⊆ U. (ii) hhV, L iiii∈I is the traversal scheme of some sprawl hV, E, P, Ni in U. In particular, any monotone traversal scheme is the traversal scheme of the corresponding sprawl produced by Con. A.1, for any appropriate universe. Proof. See Appendix A. In other words, the sprawl exactly maps out the design space of monotone traver- sal schemes. This, however, also includes incorrect traversal schemes; to be of any use, we need to ensure that our sprawl is correct. 2.3 Ensuring Correctness Correctness is defined in Defs. 1.2.10 and 2.2.3. Intuitively, we seek to determine whether we, for any query Qi, are guaranteed to traverse any nodes in V that are specified by Qi, regardless of our choice of priority heuristic. As it turns out, making this determination is quite hard in the general case. 2.3.1 Problem. The sprawl correctness problem is defined as follows. Instance: A sprawl hV, E, P, Ni and a workload hQiii, both in universe U. Question: Is the sprawl correct for this workload? 2.3.2 Theorem. sprawl correctness is strongly coNP-complete. Proof. Sprawl incorrectness is polytime-verifiable with an incorrect maximal traversal as certificate, so the problem is in coNP. Given that it is not a number problem [32], we can show strong coNP-hardness by polytime reduction from 10 = {∅} {∅} root nodes ϕ (x ∧ y ∧ z) ∨ (¬y ∧ ¬z ∧ ¬u ∧ v) ∨ (¬u ∧ ¬v ∧ ¬w) {{ϕ}} {{ϕ}} {{ϕ}} x ¬x y ¬y z ¬z u ¬u v ¬v w ¬w Figure 3: A DNF formula represented by a sprawl, with {ϕ} as the only possible query. The traversed bottom-row nodes form an arbitrary truth assignment, and we are guaranteed to traverse the node representing ϕ iff the formula is a tautology. dnf tautology. Given a DNF formula ϕ, we first construct a root node representing a positive and negative literal for each variable in ϕ, and add unconditionally negative edges (i.e., with N(e) = {∅}; cf. Rem. 2.0.3) between them. These nodes are available at the outset, and as long as any additional edges in the sprawl are positive (i.e., with N(e) = ∅), the subset of these nodes traversed corresponds to a valid truth assignment for the variables; that is, for each variable x, we traverse exactly one of the nodes representing x and ¬x.9 For each clause x ∧ y ∧ · · · ∧ z in ϕ, we add an edge {x, y, . . . , z} ! ϕ with no negative regions and a single positive region {ϕ}, as shown in Fig. 3. Each of these edges will trigger the discovery of ϕ just in case its sources are traversed and ϕ is relevant, and thus ϕ will be traversed exactly when at least one of the clauses of ϕ is true for the given truth assignment given by the roots.10 Finally, we let the only query be {ϕ}, so that we are not required to traverse any specific roots. The sprawl will be correct for this query if and only if for every possible subset of literal nodes (i.e., without contradictory literals) that is traversed, we also traverse ϕ. This holds exactly when ϕ is true for every possible truth assignment, i.e., when it is a tautology. 2.3.3 Remark. Note that the hardness proof requires only purely positive and negative edges, and uses at most a single (nonempty) region per edge. The result also holds if, say, we must permit queries containing arbitrary subsets of V, because we may use negative regions containing the targets (rather than empty ones) to protect relevant roots from elimination. (Otherwise, incorrect- ness would be trivial to detect.) In this case, the original proof still holds for the query where ϕ is the only relevant node, and for any other queries, we only risk additional roots being traversed, and so ϕ is still safe. Thus the sprawl is still correct just in case the formula is a tautology. Despite the previous hardness result, we are, of course, able to determine the correctness of existing index structures with ease. This is in part because of their limited structure (many have only positive regions, and are simply trees, for example), but perhaps even more importantly, they are restricted by a natural rule: The regions map out parts of the index structure itself. For example, a region associated with a subtree contains all points in that subtree. This simple interpretation of what a region should be can be generalized 11 to what I call responsibility, where each edge e is responsible for a set res(e) of nodes, and it is up to the regions of e to fulfill that responsibility. In the simplest cases, this might merely mean that the regions must contain the nodes, as for search trees. More generally, however, we only require that some hyperpath Πv is necessarily traversed for a query Q whenever v ∈ Q. More precisely (though perhaps a bit opaquely -- see also Obs. 2.3.10): 2.3.4 Definition. For a given workload, a sprawl hV, E, P, Ni is responsible if, for every node v ∈ V and every query Q with v ∈ Q, there is a hyperpath Πv in hV, Ei from ∅ to v, with node set V′ ⊆ V, such that for all edges e, e′ ∈ E and all regions R ∈ P(e), R′ ∈ N(e′), the following axioms hold. [R1] If e ∈ Πv then Q and R intersect; (discovery) [R2] If tgt(e′) ∈ V′ then Q and R′ intersect. (non-elimination) The smallest binary relation res ⊆ E × V where Πv ⊆ res−1(v) for every path Πv as described above, is called a responsibility assignment, under which any edge e ∈ E is responsible for each node v ∈ res(e). As a shorthand, we also assign responsibilities to any node v, as follows: res(v) = {v} ∪ [ e:v∈src(e) res(e) (2.1) That is, nodes are responsible for themselves, and share the responsibilities of outgoing edges. Thus the nodes responsible for v are exactly those in some Πv. 2.3.5 Remark. An irresponsible sprawl has no responsibility assignments. 2.3.6 Remark. Replacing a region with a superset preserves responsibility. Informally, existing index structures are easily verified to be responsible. This follows naturally from the interpretation of regions as a partitioning or coars- ening of the data set [cf. 14, 34], and thus containing the points for which they are responsible. This might not be the only reason, however: Most current index structures are based purely on discovery, and for irresponsible sprawls, correctness relies crucially on elimination: 2.3.7 Observation. For any given sprawl and workload, the following holds: (i) If the sprawl is responsible, then it is correct; (ii) If the sprawl is correct, then Axiom R1 holds. Thus, a correct sprawl with no negative regions is responsible. Proof. If the sprawl is responsible, then for every v ∈ Q, it is easily shown by induction over Πv that the targets of every edge e ∈ Πv, including v itself, are discovered but not eliminated, and so the sprawl is correct. Conversely, in a correct sprawl, any node v ∈ Q is reachable via positive edges in the hypergraph from Con. 2.2.1, and so there must be a path Πv satisfying Axiom R1. 12 Intuitively, the reason Axiom R2 does not follow directly from correctness is that incorrect elimination may be prevented even when R2 does not hold, by blocking the traversal of one of the sources of an edge with a negative region. This must be achieved either by eliminating the source or by not discovering it in the first place, resulting in such Goldbergian contraptions as those underlying Theorem 2.3.2. If there is no way to make such a guarantee (as is the case in, e.g., Fig. 2), the sprawl must necessarily be responsible in order to be correct. Beyond being responsible, all existing index structures are, to my knowledge, acyclic in the following sense. 2.3.8 Definition. A hyperdigraph is acyclic if its nodes may be strictly ordered so that u < v whenever u ∈ S for some edge S ! v [31, p. 195]. A sprawl is acyclic if its edges with positive regions form an acyclic hyperdigraph. This definition is motivated by the fact that discovering a node depends on having traversed certain nodes, while in a responsible sprawl, not eliminating a node does not, so purely negative edges cannot introduce cyclic dependencies.11 2.3.9 Remark. Not only do existing index structures seem to all be acyclic; the vast majority are, in fact, tree-structured, disregarding negative edges. The em-VP-forest and the D-Index [24, 67] are two exceptions, both structured as forests, the nodes of one tree having an extra edge to the root of the next. We are now poised to set up a simplified, local characterization of responsibility. 2.3.10 Observation. Given a sprawl hV, E, P, Ni and an atomistic workload, let v be any node and let {e1, . . . , ek} be the edges with tgt(ei) = v. If res is a responsibility assignment, then for any e := ei and R ∈ P(e), R′ ∈ N(e): [L1] res(e) ⊆ R; [L2] res(v) ⊆ R′; [L3] res(v) ⊆ res(e1) ∪ · · · ∪ res(ek). If the sprawl is acyclic and every node is the target of at least one edge, then ax- ioms L1 to L3, using the shorthand (2.1), are necessary and sufficient conditions for any relation res ⊆ E × V to be a responsibility assignment. Proof. See Appendix A. In other words, positive and negative regions contain edge and target responsi- bilities, respectively, and edges with a common target jointly share its responsi- bilities. 2.3.11 On false positives. Intuitively, R \ res(e) is a waste of space: A query Q intersecting R without intersecting res(e) leads to the superfluous discovery of v := tgt(e), even though the traversal would be correct without it. We would ex- pect that shrinking R or Q to avoid such a false positive would lead to improved performance, in general, but this might not be the case! Although discovering v is not necessary for correctness, it could lead us to negative regions that elimi- nate much of the data set. Such behavior is akin to that of correct, irresponsible 13 sprawls, and although I do not deal with the issue formally, I shall generally as- sume that reducing the number of false positives is desirable. That is, the reason to discover and not eliminate a node v is that we are looking for some of the nodes in res(v). If there are no negative regions, this will always be the case. Otherwise, the implication is, informally, that the sources of negative regions are readily available when needed (and not contingent on some false positive). 2.3.12 Remark. Assuming we are trying to limit false positives (cf. 2.3.11), for responsible sprawls with atomistic workloads, edge labels might as well be single regions. From Obs. 2.3.10, we know that res(e) ⊆ ∩P(e), so any query inter- secting each R ∈ P(e) but not ∩P(e) will be disjoint from res(e), leading only to superfluous traversal. Similarly, intersecting every R′ ∈ N(e) but not ∩N(e) will needlessly protect tgt(e) from elimination. 2.4 Emulating Existing Indexes In many cases, the correspondence between an index structure and a sprawl may be obvious; otherwise, one can start out by describing the index behavior as a traversal scheme, and then construct a sprawl from that. A formal construction is given in Con. A.1; what follows is a less formal (and less redundant) version. Step 1. For every t ∈ V and any minimal S ⊆ V whose traversal leads to the discovery or elimination of t for some query, add an edge e : S ! t. Step 2. For every edge e : S ! t and any maximal query Q for which traversing S does not lead to to the discovery of t, add U \ Q to P(e). Step 3. For every edge e : S ! t and any maximal query Q for which traversing S leads to the elimination of t, add U \ Q to N(e). In the first step, S need not be minimal -- the formal construction has no such requirement. However, any non-minimal sets are entirely redundant.∗ Following these steps will generally produce an infinite number of regions. For the ubiquitous case where the index corresponds to a responsible sprawl and the workload is atomistic, one might instead maintain their intersection (cf. Rem. 2.3.12). A more practical approach would be to simplify the last two steps, as follows, considering only individual nodes as queries, and using a single region per label: Step 2'. For every edge e : S ! t and any query {v} ⊆ V for which traversing S leads to the discovery of t, add v to the single region in P(e). Step 3'. For every edge e : S ! t and any query {v} ⊆ V for which traversing S does not lead to the elimination of t, add v to the single region in N(e). Here, the single regions are, most likely, members of some parameterized fam- ily of regions (as discussed in Sect. 3), and adding a point v means adjusting the region to accommodate v (e.g., increasing a radius). While this modified procedure will preserve correctness, it is not guaranteed to emulate the original behavior perfectly. It may, however, be a useful approach in practice, subject to subsequent verification. ∗ For an explanation of why the steps work, see the proof of Theorem 2.2.4 in Appendix A. 14 2.4.1 Examples. Consider how one might arrive at the first two sprawls of Ex. 2.0.5, starting with the behaviors of the emulated index structures. (a) In the 2 -- 3 Tree [1], there is no elimination in step 1, and the minimal sets that would lead to the discovery of a node (step 1) consist of the the two endpoints of the interval containing a subtree. This interval becomes the sole (positive) region of the edge (step 2). Step 3 becomes irrelevant. (b) In AESA [56], there is no discovery in step 1 (also making step 2 irrele- vant) -- all nodes are roots. Each node may be eliminated by any other (alone), leading to a complete, directed graph. The regions become metric shells (cf. Sect. 3.2) around the source, containing the target. In both cases, we will also have a root edge e targeting each root, with no sources or regions. These root edges fall out of the procedure, as the minimal set S whose traversal would lead to the discovery of a root is empty (step 1), and there are no maximal queries Q that prevent discovery or cause elimination initially, so steps 2 and 3 will not add any regions to these root edges. 2.4.2 On laziness. Some structures, such as the PM-Tree [60], have points that are the sources of a large number of negative edges, whose targets may never be discovered. In such cases, one may wish to perform elimination lazily, i.e., at some point after the point has been discovered. The traversal scheme does not differentiate between these approaches, so to emulate such behavior, one would have to introduce extra points. However, this would not be true laziness, as we would still have to maintain the state of every out-edge when examining a point (see p. 39). In an implementation, we would probably wish to have a separate kind of lazy or inverted edge, which is referenced by its target and references its sources, rather than in the other direction. Then at the very last moment before traversing the target, we can follow the lazy edge in reverse to determine if its sources have been traversed, and if its negative regions intersect the query. 2.4.3 On sublinear discovery. Another optimization is to process multiple posi- tive edges as at the same time, determining which of them to activate in sub- linear time. For example, in B-Trees [4], children are generally ordered, so one may use bisection to determine which of them are discovered. In theory, this bisection may itself be instantiated as further edges, in the form of a binary search tree, but in practice simply using binary search on an array of edges is much more efficient. Spaghettis [13] use this idea on the comparison values (i.e., distances) themselves. Going further, the D-Index [24] selects among an exponential number of children using what amounts to a simple hashing scheme, where the edges are looked up directly by patterns of overlap. Such optimiza- tions are not directly present in the sprawl, of course, and they do not affect the traversal behavior, only the efficiency of its implementation. 3 The Ambit Region Type Until now, we have assumed very little about the queries Q and regions R, at least explicitly. Implicitly, however, it has been clear all along that these sets are comparison-based, in the sense of Def. 1.2.14, and that we must have some descriptions that let us reason about them. The assumption underlying the ambit construction is that such descriptions are scarce, so we wish to leverage 15 each description to define multiple regions. Having a single description ψ refer to more than one region is a matter of reinterpretation, i.e., interpreting ψ in a different mathematical structure B. In isolation, this tactic gives us unlimited variability, but we cannot simply create regions that are completely detached from our initial domain of discourse A, as they could then no longer be used as part of our search procedure. The solution is to employ some structure-preserving map taking any given objects or parameters from A to B. In general, the only way to ensure that we preserve correctness is to use an isomorphism, but this would buy us nothing, as we would end up with the exact same range of regions. Instead, we must preserve some properties, while forsaking others. For arbitrary sprawls, this is not really feasible; however, if we assume our sprawls are responsible (Def. 2.3.4), we can ensure that overlap is preserved, while non-overlap may not be, and search would still be correct (cf. Rem. 2.3.6). This strategy is discussed in broader terms in Sect. 3.6. For now, we can make three simplifying assumptions. The first is that our map takes the form [id, f ] ◦ ∆m : A ! B (3.1) for some function f : Km ! L, were id is the identity function x 7! x and ∆m is the diagonal embedding x 7! hx, . . . , xi. The notation [id, f ] indicates a coproduct, where id is applied to object tuples and f is applied to tuples of comparison values, i.e., feature vectors. This kind of mapping lets us multiply the number of foci our description can accommodate. For example, if ψ is a unifocal description, this construction gives us an m-focal one. Though any number of descriptions could be pursued, the second simplifying assumption is a defining one for the ambit in particular, and the source of its name, namely that it is defined by its extent, in some sense, as determined by the comparisons (e.g., distances) to its foci.∗ A motivation for this is making the common practice of incremental construction feasible: Inserting an additional object simply requires increasing this extent, or radius, to cover the object. An ambit, then, is the preimage of a ball, along some structure-preserving map.† 3.0.1 Definition. An ambit of degree m in a universe U with symmetric compar- ison function δ : U × U ! K is a comparison-based region B[p, r;f ] := C(cid:2)p, {x : f (x) 6 r}(cid:3) , (3.2) as defined by (i) a tuple p of sources or foci p1, . . . , pm ∈ U; (ii) a radius r ∈ L; and (iii) a remoteness map f : Km ! L, with L partially ordered. The features xi of u are called its radients, and f (x) is its remoteness.12 If δ is asymmetric, we distinguish between forward and backward ambits B+[p, r;f ] and B−[p, r;f ], applying f to x and y, respectively, where x, y = φ(u). ∗ Recall that we use the edge sources as the foci of the edge regions. † For a visual presentation of an ambit in A corresponding to a ball in B, see Fig. 9, whose details are explained in Ex. 3.6.3. 16 x1 6 r x1 − x2 6 r x1 6 x2 ψ(x1)+ ψ(x2) 6 r (a) a ball. (b) a hyperboloid. (c) a half-space. x1 + x2 6 r x1 ∗ x2 6 r ψ(x1)+ ψ(x2) 6 r (d) an ellipsoid. (e) Hamacher product [71]. (f) Cantor function [12]. Figure 4: Bifocal ambits with linear (a -- d), non-linear (e) and fractal (f) remoteness usable in metric spaces. All but the Hamacher product preserve the triangle inequality. 3.0.2 Remarks. (a) Both δm and f ◦ δm are comparison functions on m-tuples from U, with codomains Km and L, respectively. Each may retain some of the properties of the original comparison function δ. The ambit is thus a preimage of the ball B[p, r] in the space hUm, f ◦ δmi, as discussed in Sect. 3.6. (b) It would also be possible to define ambits with mixtures of forward and backward comparisons, rather than just the two mentioned here. I do not pursue this option further. Figure 4 shows a handful of sample bifocal ambits in in the euclidean plane. Each inset shows the corresponding defining region S in the feature space Km, i.e., the feature vectors x for which f (x) 6 r. The third simplifying assumption is a temporary one, for sects. 3.1 to 3.4, namely that the remoteness map f is linear. We refer to the resulting regions as linear ambits. For a linear ambit with remoteness map f (x) = Ax, where A is a d × m matrix, we may simply write B[p, r; A], as no confusion is likely to arise. I discuss the more general case in sects. 3.5 and 3.6, but choosing the specific case of linearity affords us the opportunity to go into more detail. It also seems to cover the region types used in existing indexing method (cf. Sect. 3.2). For one thing, using linear remoteness means Km and L are ordered modules; I'll simply use Rm and Rd, for some d. For another, structure preservation simply amounts to linearity, so that is what we have to work with in our axioms for A and B. In B we are working with balls (cf. Rem. 3.0.2a), and so we might wish to have overlap between regions in A to imply overlap between balls in B, meaning we'd need a linear inequality expressing a necessary condition for the overlap of two balls B[p, r] and B[q, s] in terms of the comparison, δ. The obvious choice for such a condition is r + s > δ(p, q) (3.3) 17 which is equivalent to the (oriented) triangle inequality of metric and quasi- metric spaces.13 More generally, it is equivalent to any composition law [41], including the transitivity of partial orders, which is used to detect overlap be- tween intervals, for example.14 3.1 Linear Ambit Overlap in Quasimetric Space A linear ambit B[p, r; A] = C[p, S] is determined by an arbitrary polyhedron S := {x ∈ Rm : Ax 6 r} in the feature space, so deciding whether two linear ambits C[p, S1] and C[p, S2] intersect is equivalent to deciding whether two arbitrary polyhedra S1, S2 ⊆ Rm intersect. The intersection is also an arbitrary polyhedron, so we can reduce from the problem of linear program feasibility. Such a check may be time- consuming, and becomes unwieldy when generalizing to ambits with differing foci. Instead, I will examine the uniradial case (d = 1), and handle the multiradial case (d > 1) by performing intersection checks for each defining half-space of the polyhedron S individually. If some other region P is disjoint from any of these half-spaces, it cannot intersect S, so this approach will incur no false negatives. In principle, however, it is possible for P to intersect every defining half-space of S, and yet not intersect S itself, producing a false positive.15 Alternatively, rather than viewing this as an approximation, it can be seen as merely a compact way of representing multiple uniradial ambits sharing a set of foci, where we require intersection with each ambit; this is exactly what is required in sprawl traversal (Sect. 2.2), meaning that each edge label (Def. 2.0.1) may be represented by a single augmented matrix (A r), and be treated as a single multiradial ambit using the overlap check described here. We'll be examining two uniradial ambits R := B[p, r; a] and Q := B[q, s; c], where a and c are row vectors of focal weights, one of which is non-negative (i.e., a > 0 or c > 0).16 For arbitrary comparisons, we have no way of relating the two regions; this is exactly why we are assuming a quasimetric space. Specifically, for foci pi and qj, and some other object u, the oriented triangle inequality holds: δ(pi, u) + δ(u, qj) > δ(pi, qj) (3.4) We can create what amounts to a weighted sum of such triangles, as in the following lemma.∗ 3.1.1 Lemma. For a quasimetric space hU, δi, let xi = δ(pi, u), yj = δ(u, qj) and zij = δ(pi, qj), where pi, qj, u ∈ U, for i = 1 . . . m, j = 1 . . . k. Then kck1ax + kak1cy > aZct , (3.5) whenever a ∈ R1,m, c ∈ R1,k and either a or c is non-negative. Proof. We want to show that the inequality ∗ Here k -- k1 is the 1-norm, which for the non-negative coefficient vector is simply a sum. cjaixi + aicjyj > aicjzij (3.6) 18 q s z1 z2 p2 f(x) 6 r p1 x2 p1 f(x) = r z1 s q z2 x1 p2 (a) a weighted ellipse. (b) in the feature space. Figure 5: For an unknown metric, any point in the hatched box could be relevant. The shaded region could only be of interest if the lower left corner z − s falls within it. This happens when f (z − s) 6 r or, equivalently, f (z) − f (∆(s)) 6 r. These two conditions generalize, though differently, to some nonlinear cases, as discussed in sects. 3.5 and 3.6. holds for any indices i and j; summing then produces (3.5). Assume (wlog) that c is the non-negative one. If ai > 0, (3.6) follows directly. If ai < 0, we have aicjxi > aicjyj + aicjzij aicjxi − aicjyj > aicjzij , which again yields (3.6). This yields our desired linear ambit overlap check for quasimetric spaces: 3.1.2 Theorem. Let R := B+[p, r; a] and Q := B−[q, s; c] be linear ambits for a quasimetric δ, with either a or c non-negative and kak1, kck1 = 1. If R and Q intersect, then r + s > aZct , (3.7) where zij is the distance δ(pi, qj) between focus pi of R and focus qj of Q. Proof. Follows from Lemma 3.1.1, given that ax 6 r and cy 6 s. The requirement kak1, kck1 = 1 is easily enforced by scaling the radii; it sim- plifies the check, but is not crucial. An intuition for the more general overlap check is given in Fig. 5, for the case where Q is a ball. (See also Fig. 9.) 3.1.3 Remark. In the euclidean plane, linear ambits correspond to weighted polyellipses, which were described already by James Clerk Maxwell [46]. 3.2 Emulating Existing Regions The intervals, hyperrectangles and other polytopes of ordered and spatial in- dexing are quite easily implemented using linear ambits, by introducing one 19 Region type Ref. Ball . . . . . . . . . . . 37, 63 Sphere . . . . . . . . . 56, 49 Shell . . . . . . . . . . 9, 60 Plane . . . . . . . . . . 64, 10 Ellipse . . . . . . . . . 63, 25 Hyperbola . . . . . . . 25, 42 Voronoi cell . . . . . . 52, 51 Cut region . . . . . . . 60, 43 A ±1 [1, −1]t [1, −1]t [1, −1] [1, 1] [1, −1] [1, −I] [I, −I]t r ±r [r, −r]t [r′, −r]t 0 r r 0 ~r Table 1: Some existing region types viewed as ambits. The radii r and r′ are non-negative scalars, while ~r is a vector with m positive and m negative ele- ments; 1 is an all-ones column vector and I is the identity ma- trix. Some region types (e.g., balls) are very common, while others (e.g., hyperbolas and el- lipses) are quite rare. The references are somewhat arbi- trary examples of their use. pseudo-focus for each dimension, and using projection as the comparison, i.e., δ(x, i) = xi. Then the linear ambit devolves to a convex polyhedron in the space being indexed. For non-convex polyhedra, one could simply use the union of several ambits, each belonging to a separate sprawl edge. Of more interest, per- haps, is the case where δ is actually a quasimetric or metric, using the overlap check of Sect. 3.1. Existing methods for indexing metric spaces are quite varied, and, as Lokoč et al. put it, "After two decades of research, the techniques for efficient similarity search in metric spaces have combined virtually all the available tricks" [43]. These "tricks" have been available from the beginning. When Novak, Batko, and Zezula use "practically all known principles of metric space partitioning, pruning, and filtering" in their method [53], they are still essentially referring to the balls, spheres and planes introduced by Fukunaga and Narendra, Ruiz, and Uhlmann [30, 56, 64]. And in metric indexing in general, the query (for range search) or its inclusion-wise upper bound (for kNN, cf. 2.0.4) is simply a ball.17 These regions are, of course, simple special cases of the linear ambit, all with coefficients of 1 or −1. Table 1 provides an overview of the main region types. The ball is sometimes used as a bisector between inside and outside; the complemented ball can be represented by negating the coefficient and radius.18 A sphere is essentially the intersection of a ball and its (closed) complement, and this is reflected in the coefficients and radii. The technique of using sphere regions is generally known as pivot filtering. A shell simply lets the two radii of a sphere vary independently. The plane (or generalized hyperplane), ellipse and hyperbola are metric equivalents of the corresponding conics, and the Voronoi cells (or Dirichlet domains) and cut regions are intersections of plane and shell regions, respectively.19 It can be instructive to see how the linear ambit overlap check (3.7) reduces to the commonly used conditions in metric indexing when instantiated with the parameters from Table 1. These overlap checks assume that Q is a ball, which simplifies the check to r + kak1s > az , (3.8) if we don't require normalized coefficients. This check then applies individually to each facet of the polyhedron (i.e., each row of A and r).20 For example, for 20 the three staples ball, sphere and plane, we get the respective conditions r + s > z r + s > z −r + s > −z 0 + 2s > z1 − z2 , or the perhaps more familiar s > z − r s > z − r s > z1 − z2 2 , precisely as expected. The other overlap checks described by Zezula et al. [69, § 7], for example, may be derived similarly. Note, though, that I am focusing on nec- essary conditions for relevance; bounds providing sufficient conditions are a separate matter, but could be dealt with in a similar fashion. Some structures use weakened versions of the filtering criteria, where a pivot-based bound is substituted for z [e.g., 48, 68]. The result is still linear, and is easily emulated by letting the pivots be parents of the region as well, increasing the number of radii as appropriate. 3.2.1 Ambits as queries. If the regions of existing index structures are simply reinterpreted as linear ambits, one is free to query any current such data struc- ture using a linear ambit as the query. For example, rather than querying an M-Tree [68] or the like using a single object, one could use a weighted sum of multiple objects, some of which could even act as contrasts to be avoided, using negative weights. In these cases, one could also use the common kNN approach of updating the query radius during the search, thus returning the k points with the lowest query remoteness. 3.3 Finding Optimal Coefficients Rather than fixing the ambit coefficients arbitrarily, we might wish to determine their optimal values, based on the given data. An obvious goal in setting the coefficients is to minimize the probability of query overlap, which in turn will reduce the number discoveries and increase the number of eliminations, improv- ing the running time overall.∗ Assume that the foci and responsibilities are given, but that the number of radii is unconstrained. If intersection of the fea- ture polyhedron and another fixed set is what determines overlap, the following proposition provides an optimal solution, regardless of any probability distribu- tions involved. The constants hidden by the asymptotic notation depend on m, which is fixed. 3.3.1 Proposition. Given a set of m foci, an inclusion-wise minimum linear ambit can be found with worst-case running time O(n log n + n⌊m/2⌋), as a function of the number of responsibilities, n. This running time is optimal for metric spaces. Proof. The task is to determine the coefficients A that make the defining poly- hedron {x : Ax 6 r} an inclusion-wise minimum. This minimum is simply the convex hull (in Rm) of the n responsibility feature vectors, which can be found ∗ Note, though, that in theory spurious overlaps could improve performance (cf. 2.3.11)! 21 x2 p1 p1 p2 Ax 6 r x1 p2 (a) a linear ambit with r in R5. (b) convex hull of feature vectors. Figure 6: The optimal linear ambit is given by a convex hull in the feature space. with the stated running time [15]. Each facet of the hull then corresponds to one row of A and one component of r. That the running time is optimal can be shown by reduction from the general convex hull problem, for which the given running time is optimal [15, Th. 3.5]. That is, for any instance of the general convex hull problem, we construct points in a metric space for which the optimal linear ambit would provide us with the original convex hull. Let X := {xij} be a an m × n-matrix whose column vectors are the input points to the convex hull problem. Introduce two non-overlapping, arbitrary sets of foci and responsibilities pi and uj, and some large value ω, such as kXk∞ + ε (ε > 0). Let self-distances be zero, let the distance between foci and between responsibilities be ω, and let δ(uj, pi) = δ(pi, uj) = xij + ω . Finding an inclusion-wise minimum linear ambit will produce a convex hull for X + ω, whose vertices may be shifted by −ω to produce the final result. It is easily verified that δ is a metric: Self-distances are zero, and all other distances are symmetric and strictly positive; because they are all in the range [ω, 2ω], they also satisfy the triangle inequality. The running time of this reduction is linear in n, for any given m, which means that the worst-case bound of Ω(n log n + n⌊m/2⌋) carries over from the convex hull problem. For an example of an ambit corresponding to the convex hull of the responsibility feature vectors, see Fig. 6. Note that if we have fewer restrictions on δ (e.g., if it is only a quasimetric), the optimality of Prop. 3.3.1 would still hold; this would merely simplify the reduction. Other constraints may also be accommodated in a similar manner. While this result provides us with a method of finding optimal linear ambits, it is not entirely practical, in that we might end up with Θ(n⌊m/2⌋) radii, which is unacceptable in any actual implementation.21 Let's consider, instead, the case where we restrict ourselves to a single facet -- a hyperplane in the feature space. In the following, let z = Zct. For unifocal queries with c = 1, z retains its interpretation as the feature vector of the query center q. In general, the overlap condition from Theorem 3.1.2 becomes r + s > az, and we wish to minimize the 22 probability of this being true. Absent a probability distribution for s and z, we resign ourselves to maximizing the expected filtering lower bound ℓ, that is, ℓopt := maxa,r E[az − r] s.t. kak1 = 1 , ∀x ax 6 r , (3.9) where x ranges over the feature vectors of the ambit's responsibilities. This expectation is, of course, a heuristic proxy for the actual overlap probability, though not an unreasonable one, and not one without precedent in metric in- dexing.22 If ℓopt 6 0, we say the corresponding ambit is degenerate. In the following, let 1 = [1 . . . 1]t be an all-ones column vector and let X := {xij} be a non-negative m × n matrix whose columns are the responsibility feature vectors. Let z = E[z], in practice estimated by the average of z over a set of training queries [26]. We can efficiently determine the optimal coefficients for a non-degenerate ambit using the following linear program. ℓ′ opt := maxu,v,r uz − vz − r s.t. u1 + v1 = 1 , uX − vX − r 6 0 , & u , v > 0 . (3.10) 3.3.2 Proposition. ℓ′ opt = max {ℓopt, 0}, with a = u − v if ℓopt is positive. Proof. Given an arbitrary feasible solution to (3.9), let ui = max {ai, 0} and vi = − min {ai, 0} , for all i, so a = u − v and ai = ui + vi, where ui, vi > 0. By construction, the objective value is preserved. Furthermore, (u + v)1 = kak1 = 1, and, for each column vector x of X, we have (u − v)x = ax 6 r, so the solution is feasible for (3.10). Of course, this holds a fortiori for positive optimal solutions to (3.9). Now assume a positive optimal solution to (3.10), and let a = u − v. The objective value is then preserved in (3.9), and the radius r remains valid; we need only show that kak1 = 1, or more specifically, that ui − vi = ui + vi for each i. Assume, for the sake of contradiction, that for some i we have ui − vi < ui + ui. We can then reduce ui + vi by subtracting min {ui, vi} from both variables, preserving the objective value and the second constraint. Let ξ be the resulting value of (u + v)1. The optimum is positive, meaning u 6= v, so even if ui = vi, we have ξ > 0. We can therefore restore the first constraint by dividing all variables by ξ, and because ξ < 1 and the objective is positive, this increases the objective value. As we started with the optimum, this is a contradiction. In other words, for every positive optimal solution to either problem, there is an equivalued feasible solution to the other, where a = u − v. Thus if either optimum is positive, the two are identical, and so for this case, the proposition holds. A solution where u = v and r = 0 is always feasible for (3.10), which means that ℓ′ is 0, proving the remaining case. opt > 0. Consequently, if ℓopt 6 0, the only value available to ℓ′ opt If ℓ′ opt = 0, the ambit is degenerate, and can never be eliminated, so restruc- turing the sprawl is probably a better strategy than determining the optimal 23 Figure 7: Optimal ambits with fixed facet counts. The first two have one facet, while the last one has three, with queries (small dots) assigned to each by k-means clustering. coefficients for the given foci and responsibilities. See Fig. 7 for some ambits constructed using (3.10). While the (primal) formulation of (3.10) was motivated by maximizing the expected filtering bound, the dual problem has an interesting interpretation in its own right.∗ It is equivalent to a form of regression problem, where the feasible region is the convex hull of the feature vectors, and we are attempting to approximate z. That is, the goal is to construct a convex combination Xβ that minimizes the Chebyshev error kXβ − zk∞. As the optimal error is equal to the optimal lower bound, however, we would hope that a good fit is impossible; a perfect fit would indicate a degenerate ambit. 3.3.3 Proposition. If zi > maxj xij , then ai > 0 in every optimal solution. Proof. We can restate our problem as maximizing ℓ = (cid:16)Pi ai zi − maxj Pi aixij(cid:17) / kak1 , (3.11) subject to kak1 6= 0. Assume that for an optimal solution, we have ai < 0. We may then increase ai by some positive amount ε < ai, decreasing the denominator by ε. Let k be an index that attains the maximum in (3.11) after this increase. Then maxj Pi aixij has increased by εxik, or possibly less if k did not attain the maximum before this change. The numerator, therefore, has increased by at least εzi − εxik, which is positive because zi > xik. The objective ℓ will increase, and this contradicts optimality. Consequently, ai > 0. In other words, as one might very well intuit, a negative focal weigth indicates that the focus acts as a contrast, a prototypical non-member; if the foci are more representative of the responsibilities than they are of the queries, the focal weights will all be non-negative.23 If we assume or determine that this is the case, (3.10) can be simplified by eliminating the column associated with v, and letting a = u. If we do not have access to training queries, and have no prior weighting of the foci, the problem reduces to limiting the maximum remoteness, i.e., minimizing the radius. We can safely assume (and easily check) that the foci are distinct, which means X will have no all-zero columns, so the radius is ∗ With dual variables ε and β1, . . . , βn > 0, minimize ε s.t. −ε 6 Xβ − z 6 ε and 1tβ = 1. 24 non-zero.24 We can then find the optimal radius as follows. ropt := min a,r>0 r s.t. a1 = 1 , aX 6 r = min a>0 1/a1 s.t. a1 6= 0 , aX 6 1 . (3.12a) (3.12b) The linear program in (3.12a) is a direct formulation of the problem. The reformulation in (3.12b) is justified by he following proposition. 3.3.4 Proposition. Optimization problems (3.12a) and (3.12b) are equivalent. Proof. As noted, the definition of X implies r > 0. Let a, r and a be solutions to (3.12a) and (3.12b), respectively. If a and r are feasible, a := a/r is feasi- ble, with the same objective value. Conversely, if a is feasible, a := a/a1 and r = 1/a1 are feasible, with the same objective value. Hence the problems are equivalent, and yield the same minimum. The second formulation is simply the inverse of the problem∗ 1/ropt := max a>0 a1 s.t. aX 6 1 , (3.12c) which is a positive linear program -- a so-called packing LP, a class of optimiza- tion problems for which specialized algorithms exist [e.g., 39]. One could even use simple algorithms such as multiplicative weights update to approximate the optimum [2]. Between the two extremes of permitting an arbitrary number of facets (Prop. 3.3.1) and limiting ourselves to a single facet (Prop. 3.3.2), we could use the following heuristic procedure as a compromise: 1 2 3 4 cluster the z-vectors to get k centroids for i = 1 to k z centroid i compute ri and row i of A using (3.10) or (3.12c) See the last panel of Fig. 7 for an example ambit constructed in this way. This approach reduces the choice of facet construction heuristic to the choice of a suitable clustering algorithm, of which there are many -- even those that could cluster the queries in the original metric space, with feature centroids computed afterward [5, 66]. Each facet is optimized to separate or defend the ambit from queries in one of the clusters. The number of facets (i.e., clusters) may be fixed, or may be a result of the clustering. 3.4 The Complexity of Focus Selection If we are constructing an ambit with n responsibilities and m pre-designated foci, using a set of k sample queries, we can now efficiently find optimal focal weights. However, if we aren't told which foci to use, things get trickier. If a sprawl is built incrementally, as many index structures are, the foci will be determined ahead of the set of responsibilities, so finding an optimal focal set is ∗ The definition of X means a = 0 could never be optimal, so the constraint a1 6= 0, which served to keep the objective in (3.12b) well-defined, is now superfluous. 25 never an option. Still, the problem does merit some investigation, as it would be relevant in rebuilding or bulk loading, for example. Let the metric linear focus selection problem, or focus selection, be defined as selecting m foci from among m + n points in a metric space, with m 6 n, leaving the remaining n points as responsibilities, so that max {ℓopt, 0} is maximized, where ℓopt is defined by (3.9) and E[z] is estimated as the average over a set of k training queries. When seen as a parameterized problem, we use m as the parameter.25 This problem is slice-wise polynomial (XP), as an optimal solution can be found by solving O(nm) instances of the linear program (3.10), each using one m-subset of the n + m points as foci. It is highly unlikely, however, that we will find a fixed- parameter tractable algorithm, i.e., with a running time of f (m) · nO(1) for some computable function f . This is true even if if all we want is an approximation of the optimum to within some factor α(n), as the following theorem shows.26 3.4.1 Theorem. Approximating focus selection is W[2]-hard. Proof. By parameterized reduction from dominating set [20]. We are given a graph G = (V, E), and wish to determine whether it has a dominating set with at most m nodes. We define a metric space hU, δi, with U = V ∪ {q} for some new object q /∈ V, and δ(u, v) = 0 2 3 3 + ε   if u = v ; if {u, v} ∈ E ; if {u, v} ∈ [V]2 \ E ; and otherwise, i.e., if q ∈ {u, v} , where 0 < ε 6 1, and [V]2 is the set of 2-subsets of V. This distance satisfies the metric axioms. Consider a set of m optimal foci from V with the training query q in the metric space hU, δi. We know that zi = 3 + ε > xij for all i and j. By Prop. 3.3.3, it follows that a > 0, and since kak1 = 1, az is constant. This leaves us with the restricted radius minimization problem of (3.12a). Recall that all nodes are, by definition, adjacent to at least one node in any dominating set. Assume that there is a dominating set D ⊆ V of size at most m. If we use D as our foci, each point will have at least one focal distance of 2, i.e., each column j of X contains an entry xij = 2. One feasible solution has ai = 1/m for each i, yielding an ropt of at most 3 − 1/m, and thus an ℓopt of at least ε + 1/m. If, however, G does not have a dominating set of size at most m, then for any set D ⊆ G of m foci, there will always be at least one point whose focal distances are all 3, as it is not adjacent to any of the corresponding nodes. In this case, ropt = 3, and ℓopt = ε. To discern between the two values, we need α(n) · (ε + 1/m) to be strictly greater than ε. For the inexact case, this means making ε strictly less than α(n) m · (1 − α(n)) , ensuring that any α(n)-approximation will be greater than ε if and only if G has a dominating set of at most m nodes, completing the reduction. As previously discussed, the choice to maximize the lower bound is somewhat heuristic, and altering the problem slightly could make it more tractable. For 26 example, let simple focus selection be the problem of finding foci minimiz- ing ropt, as defined by (3.12a), still with δ being a metric. The reduction in Theorem 3.4.1 applies, so this simplified problem is also W[2]-hard; however, given that a > 0, the radius turns out to be an easier objective to approximate, as the following theorem shows. Recall from Def. 1.2.12 that for a given tuple p of foci, φ(u) = [δ(u, p)]m i=1. 3.4.2 Observation. If ka1k = 1 and a > 0 then δ(u, v) 6 aφ(u) + aφ(v). 3.4.3 Theorem. simple focus selection has an O(mn) 2-approximation. Proof. For any input point u, its k-radius, the minimum radius of a ball contain- ing k other points u, can be found in linear time.27 Let p∗ be the optimal focal tuple, whose minimal radius is r∗ opt, and let u and v be any non-focal points. By the definition of a radius, we have aφ(u), aφ(v) 6 r∗ opt and from Obs. 3.4.2 opt. Also, because aφ(u) 6 r∗ it follows that δ(u, v) 6 2r∗ opt, a > 0 and kak1 = 1, i ) 6 r∗ i for which δ(u, p∗ there must be at least one p∗ opt. Since each of the n non- focal points would be within a distance of r∗ opt of at least one focus, and within a distance of 2r∗ opt of the other n − 1 nonfocal points, it follows that there must be at least n points with n-radius at most 2r∗ opt. To select one such point p1 as the first focus, among all the n + m points, simply use a point whose n-radius is no greater than that of at least m others, for a running time of O(mn). All but m − 1 points fall within 2r∗ opt of p1, and the furthest m − 1 points become p2, . . . , pm. Even for a1 = 1, we have a 2-approximation, so ropt 6 2r∗ opt. Though a 2-approximation is a positive result, it seems likely that a radius doubling would drastically increase the overlap probability. For many approx- imation algorithms, one does of course see better results in practice, but as a heuristic, the algorithm of Theorem 3.4.3 is somewhat unsatisfying: It approx- imates the optimal m-ambit by a ball, and then picks up the m − 1 potential stragglers that fall outside it, giving them a free pass by promoting them to foci. There is no expectation that they will actually perform any work in this capacity. One natural alternative, which works for full focal selection and which seems to yield acceptable results in practice, is the following two-round or runoff heuristic: 1 use a large candidate set of foci, and solve (3.10) 2 use only the m candidates pi with highest ai as foci, and re-solve (3.10) For example, one could in the first round let all the responsibilities, or a random sample, act as candidate foci, while at the same time acting as responsibilities. In the second round, the selected foci are no longer responsibilities, and so do not constrain the radius. The value of m could either be fixed, or determined by a threshold for ai. Alternatively, one could have both such a threshold and a cap on m, and run multiple rounds using the threshold, until the number of foci falls below m. For the case where the set of candidate foci is separate from the responsibili- ties, the rationale is that rounding down low-magnitude coefficients to zero will have limited impact on the objective. Selecting foci from among the responsibil- ities could be more risky, as the constraints on the radius will change between the rounds. The number of changes will typically be low, as m ≪ n, but even 27 a single dropped responsibility could change the nature of the problem, leading to another set of foci outperforming those originally selected. Even so, if the ob- jective value of the first round is good, there may be reason to believe it will be in the second round as well: The original rationale still applies to the objective function itself, and dropping constraints can only improve the optimum. 3.5 Non-Linear Metric-Preserving Remoteness As hinted at in the introduction to Sect. 3, we now leave the assumption of linearity behind, while remaining in the realm of metric spaces. In other words, for m = 1, the structure-preserving map f : R+ ! R+ will now be an arbitrary metric-preserving function, or metric transform which takes any metric δ to another metric f ◦ δ. The image of A in B will be a metric space, even though B need not be. Deza and Deza provide an extensive list of such functions [21, ch. 4], while Doboš [22, 23] and Corazza [18] deal with the topic in more depth. The Cantor function (see Fig. 4f) is a rather forbidding example, but there are many quite straightforward metric-preserving functions such as x/(1 + x) or xα, for α ∈ [0, 1]. Metric transforms of multiple parameters also exist, giving us the desired remoteness f : Rm + ! R+ for m > 1. One could use any isotone norm, for example [8, 21, 23]. Vector-valued transforms can, in turn, be viewed as en- sembles of scalar-valued ones, as in f (x) := [f1(x) . . . fd(x)]t, making f ◦ δm a vector-valued metric, which lets us use multiple radii as in the linear case. Metric-preserving functions must start at the origin,∗ they must be subad- ditive (e.g., concave), and any such function that is non-decreasing is, in fact, a metric-preserving function [23, p. 9]. A metric-preserving function need not be monotone; to preserve relevance, however, our map must be. If, rather than non- increasing subadditive, f is non-increasing super-additive, our target inequality could be f (x) − f (y) > f (z) instead of f (x) + f (y) > f (z) , where xi = δ(u, pi), yi = δ(u, q) and zi = δ(pi, q). This follows from the fact that x 6 y + z. The general overlap check becomes r ± f (s, . . . , s) > f (z) , using +f ( -- ) to transform s for the non-decreasing case, and −f ( -- ) for the non-increasing case. There are many ways to construct monotone metric-preserving functions. We have already used the fact that the negation of a non-increasing super- additive function is non-decreasing subadditive. If we are faced with a non- decreasing superadditive or non-increasing subadditive function, we could negate their parameters as well; if f (x) is non-decreasing superadditive, for example, g(x) = −f (−x) is be non-decreasing subadditive. Indeed, we can compose non- increasing or non-decreasing sub- or super-additive function in various ways, with predictable results.28 A practical approach to non-linear ambits might be to construct single- parameter scalar transforms for each focal distance, and then combining those ∗ Strictly speaking, they must have f −1(0) = {0}. 28 Pi xα i 6 r α = 1 α = 0.5 α = 10−8 Figure 8: Ambits of varying blobbiness, using the power transform as bump function. with a single multiparameter function. One particularly manageable version of this would be a linear combination of some transform that is shared by all focal distances. For example, with the well-known metric-preserving power trans- form [21, p. 81], the remoteness map becomes f (x) = m X i=1 aixi α , (3.13) with the overlap check r + kak1sα > f (z) , where α ∈ [0, 1]. We could easily have a separate αi or even some other transform for each xi (applying them individually to s). Perhaps less obviously, we could have ambits in the form of Blinn-style metaballs [6], using Blinn's original density function (inverted, to get remoteness, a, b > 0): f (x) = m X i=1 (cid:0)1 − bie−aixi(cid:1) (3.14) This is the kind of ambit seen in Fig. 1. 3.5.1 Observation. The remoteness map in (3.14) is metric-preserving. Proof. It is easily verified that f −1(0) = {0}, so a sufficient condition would be for f to be non-decreasing subadditive, which in turn may be ensured by its summands having this property. The property obviously holds for the con- stant summands 1. The exponential ex is non-decreasing superadditive (indeed, convex) and so −e−x is non-decreasing subadditive (concave), as is −be−ax (for a, b > 0). If we use a linear combination such as the one in (3.13) or (3.14) as a tool for function approximation, i.e., adapting the region shape to the layout of its responsibilities, it can be interpreted as a radial basis function network [44], generalized from euclidean to arbitrary metric spaces, but restricted to non- decreasing subadditive radial basis functions. Alternatively, if we view ambits as generalized metaballs, the transform would correspond to the metaball bump function; different parameter values would vary what Blinn calls blobbiness (see Fig. 8 for an illustration). The blobbiness could be adjusted to maximize the lower bound -- for example, one could use some heuristic optimization procedure to set α, where the objective function is calculated in each iteration, as follows: 29 α for each focal distance xi, calculate xi 1 2 using the transformed focal distances, calculate ℓ′ 3 opt using (3.10) return (ℓ′ opt)1/α The reason for the inverse transformation in the last line is that the lower bound computed by our linear program is for δ(q, u)α, and in order for the objective values to be comparable for different values of α, we instead want the lower bound for δ(q, u). There is a link here to the optimization of power tranforms used by Skopal for approximate search using metrics or almost metric distances [61]. Other transforms could be used in the same manner, as long as they are invertible. Preliminary experiments indicate that such an approach may yield improvements over a purely linear remoteness. 3.6 Repurposing Region Definitions More Generally Consider a query and a region respectively defined as Q = {x : ϕ(x)} and R = {x : ψ(x)} , (3.15) where ϕ(x) and ψ(x) are logical formulas with their non-logical symbols drawn from some signature Σ.∗ We wish to know whether Q and R intersect, and even though we might not be able to determine this perfectly, for correctness we must detect it (cf. Rem. 2.3.6), i.e., we have some necessary condition β, so that ∀x(cid:0)ϕ(x) ! ψ(x) ! β(cid:1) . (3.16) In other words, if Q and R intersect then β must be true. We would like to repurpose the region definition ψ to extend our supply of regions, while still being able to use our overlap detector β. We do this by reinterpreting ψ in a manner that preserves the implication expressed by (3.16). Let A be the Σ-structure underlying our formulas, i.e., our actual domain of discourse. Our region R is then the set ψ(A) of objects in dom A that satisfy ψ. Now consider a map h : A ! B to some other Σ-structure B. Because B has the same signature as A, we can reuse our definition to produce a new set ψ(B). The preimage h−1(cid:2)ψ(B)(cid:3) will be a new region in A, so if we have several maps such as h, we end up with several new regions, all described by the original ψ. Even a single map h can yield multiple new regions, however. Chances are, the region definition is parameterized, and B may offer new objects we can use as parameters. For example, we may start out with ψ(A, a), for some a in dom A. Then h yields one new region h−1(cid:2)ψ(B, b)(cid:3) for every applicable b in dom B. Given that dom B might be much larger than dom A, this could increase our options considerably. This might be true even if our parameter originates in A, as it could be specified by multiple A-objects a1, . . . , am, producing regions of the form h−1(cid:2)ψ(B, f (a1, . . . , am))(cid:3), for some map f : Am ! B. As long as we use appropriate structure-preserving maps, a reinterpreted version of β, presumably with the same parameters as ψ, will still work in B. The following theorem describes some general conditions under which this is the case. For simplicity, I assume a single parameter originating in each of A and B, though the result generalizes to multiple parameters in the obvious way.† (See Ex. 3.6.3 for an application of the theorem.) ∗ See Appendix C.2 for relevant terminology. † Recall that ∆m(a) = ha, . . . , ai. 30 3.6.1 Theorem. Let A and B be structures with signature Σ, which contains some unary relation symbol S, and let ϕ, ψ, α and β be Σ-formulas. Let Q = ϕ(A) and R = h−1(cid:2)ψ(B, f (a1, . . . , am), b)(cid:3) , (3.17) where h = f ◦ ∆m, for some homomorphism f : Am ! B, and a1, . . . , am ∈ SA. Suppose that TA and TB are theories true in A and B, respectively, where [A1] TA is Horn, ϕ existential, and α positive existential; [A2] TA entails ∀xy (cid:0)S(y) ! ϕ(x) ! α(x, y)(cid:1); [A3] TB entails ∀xyz (cid:0)S(y) ! α(x, y) ! ψ(x, y, z) ! β(y, z)(cid:1). Then β is true of f (a1, . . . , am) and b in B whenever Q and R intersect. Proof. Assume that there is some element a that lies in both Q and R. Let ¯a = ha1, . . . , ami. Because S is true of each of a1, . . . , am in A, S(¯a) is true in Am and, because f is a homomorphism, S(f (¯a)) is true in B. Because TA is Horn, it is preserved in products [36, Cor. 9.1.6(a)], and is consequently true in Am; ϕ is existential, and therefore preserved by embeddings [36, Thm. 2.4.1], including the diagonal ∆m (cf. Ex. C.2.9c). By assumption, a ∈ Q, so by definition ϕ(a) is true in A, and therefore ϕ(∆m(a)) is true in Am. From Axiom A2 it follows that α(∆m(a), ¯a) is true in Am. Because α is positive existential, it is preserved by the homomorphism f [36, Thm. 2.4.3], and thus α(h(a), f (¯a)) is true in B. Because a ∈ R, ψ(h(a), f (¯a), b) is true in B by definition. From Axiom A3, we conclude that β(f (¯a), b) is true in B. 3.6.2 Remarks. (a) The role of S is to restrict the quantification of y, for cases where there are effectively different sorts of objects (cf. Rem. C.2.2b). Pre- sumably, ϕ and ψ have whatever such restrictions they need, but if α is to be positive, it cannot contain an implication, and so this predicate is extracted. (b) Values or parameters that figure in the formulas, beyond x, y and z, such as any used in ϕ, may be handled by adding constants to Σ [cf. 36, 1.4]. case, R would simply be an intersection, isomorphic to Tm (c) The details may be varied using other preservation results from model the- ory. For example, if f is surjective, α need only be positive [36, Thm. 2.4.3]. If f is a strong homomorphism, then α could be any quantifier-free formula without equality; if f is also injective (an embedding) or surjective, respectively, the re- strictions on equality and quantification could be removed [27, p. 96]. An isomor- phism (a bijective strong homomorphism) would preserve all formulas; in that i=1 ψ(cid:0)A, ai, h−1(b)(cid:1). 3.6.3 Example. Consider metric or quasimetric spaces in light of Theorem 3.6.1 A signature for these might be Σ := {δ, +, 6, U, K}, where δ is a binary function symbol representing the distance function, + and 6 represent addition and ordering of the distances, and U and K are unary relation symbols used for restricting the values of variables to points and distances (comparison values), respectively. The triangle inequality, for example, could be expressed as follows: ∀xyz (cid:0)U(x) ∧ U(y) ∧ U(z) ! δ(x, z) 6 δ(x, y) + δ(y, z)(cid:1) , In the same manner we could, if we wished, represent all the metric axioms, though probably without fully axiomatizing the real numbers. (Indeed, we 31 might not even be using real-valued distances; cf. Ex. 1.2.3c.) With some care, the result, including the axioms for ordering and addition, may be formulated as a Horn theory,∗ so it could play the role of TA. Now consider two metric balls R and Q with centers p and q and radii r an s, respectively. If these intersect, we have δ(p, q) 6 r + s. We can dissect and repurpose this overlap check using Theorem 3.6.1, as follows. Let ϕ, ψ, α, and β be defined as: ϕ(x) = U(x) ∧ δ(x, q) 6 s ψ(x, y, z) = U(x) ∧ K(z) ∧ δ(y, x) 6 z α(x, y) = δ(y, q) 6 δ(y, x) + s β(y, z) = δ(y, q) 6 z + s The first formula, ϕ(x), represents a query ball Q with center q and radius s, where both q and s are treated as constants, drawn from Σ. It is easy to verify that the second formula, α(x, y), is entailed by TA (i.e., the metric axioms) and ϕ(x), for any point y, i.e., any object for which U(y) is true. If we use U instead of S in Theorem 3.6.1, we need not make this last caveat an explicit part of ϕ. The region R is described by ψ(x, y, z), where x is the potential member, y is the center point and z is the radius. We explicitly constrain x and z, but y is already constrained in Axiom A3. Finally, combining α(x, y), ψ(x, y, z) and some basic axioms TB describing ordering and addition of comparisons (e.g., those of an ordered monoid), we can derive β(y, z), as required. We can recreate the original overlap check between two balls by setting m to 1 and letting f be the identity on A. If, however, m > 2 and A 6= B, our region R will have multiple points pi in UA, collectively corresponding to its center, and the radius r will be drawn from KB. The overlap check then becomes δB(f (p1, . . . , pm), f (q, . . . , q)) 6 r + f (s, . . . , s) . (3.18) Because f is a homomorphism and because δ acts elementwise in Am (see Defs. C.2.3 and C.2.8), we can rewrite this as f (δA(p1, q), . . . , δA(pm, q)) 6 r + f (s, . . . , s) . (3.19) As an example, take the egglipse, a trifocal relative of the ellipse (and, indeed, an example of a linear ambit). To repurpose our overlap check, we set m to 3 and let f sum the distances,29 yielding δA(p1, q) + δA(p2, q) + δA(p3, q) 6 r + 3s . (3.20) as illustrated in Fig. 9. Note that we are actually defining a ball in the new metric space B, whose points are triples of A-points and whose distance is the sum of elementwise A-distances. 3.6.4 Remarks. (a) For the ordered vector spaces of sects. 3.1 to 3.4, homomor- phisms are non-decreasing linear maps, which cannot have negative coefficients. We got around this limitation by exploiting the properties of linearity, con- structing an overlap check that permitted some components of the ordering to be reversed. The bottom line, however, is that, except in the non-negative case of (3.12a), our remoteness was not a homomorphism, so it would seem that ∗ E.g., turning U(x) ∧ U(y) ! (δ(x, y) = 0 ! x = y) into U(x) ∧ U(y) ∧ δ(x, y) = 0 ! x = y. 32 R2 R2×3 Q y q s h[Q] 3y hq, q, qi 3s u z1 z2 z3 x1 x2 x3 p1 p2 p3 hu, u, ui x1 +x2 +x3 z1 +z2 +z3 r p R = h−1(cid:2)ψ(B, p, r)(cid:3) ψ(B, p, r) (a) an egglipse (in A). (b) a metric ball (in B). Figure 9: The ambit construction, as it applies to an egglipse [57]. The foci form a central tuple p := hp1, p2, p3i, while any other point u is mapped to hu, u, ui. The sum of elementwise distances is the metric in B, where the egglipse interior becomes a ball. More generally, an m-focal polyellipse could only intersect Q if z1 + · · · + zm 6 r + ms. there is use in casting our net more widely than in Theorem 3.6.1. Take, for example, the Hamacher product, as used in Fig. 4e.30 It is not structure-pre- serving in any obviously useful way, but may still be used to define a metric ambit. Consider the situation in the feature space: The metric axioms let us circumscribe a query Q with a hypercube, and the image of the ambit is concave (see inset of Fig. 4e); the only way there can be overlap is if a query corner is inside the region image, and because f is non-decreasing, it suffices to examine the corner z − s, so f (z − s) 6 r is a valid overlap check (cf. Fig. 5b). Similar lines of reasoning about the geometry of the feature space could lead to overlap checks for other axioms or other maps, whether they are homomorphisms or not. (b) There are ways of generalizing explicit structure preservation as well, by relaxing how our map preserves functions. For example, if we for each source symbol F have some other target symbol G, and vice versa, we could relate FA to GB rather than to FB, as in so-called weak homomorphisms [58]. For our purposes, this could be achieved for homomorphisms as well, with a simple re- naming of the functions in B, such as using a different function for comparison. We may also weaken the equality requirement of Def. C.2.8, yielding [H'2] f (FA(a1, . . . , an)) ≈B FB(f (a1), . . . , f (an)) for some relation symbol ≈.31 This a form of abstraction found in so-called quasi-homomorphisms. Instead of equality, they require approximate equality, where the difference between the two values (as measured by some metric on B) is bounded [29]. However, even if our only requirement is that ≈B be transitive, we will preserve formulas of the form x0 ≈ δ(x1, . . . , xn).32 33 4 Applicability, Limitations and Future Work As discussed initially, the framework presented in this work delineates a design space intended to contain current indexing methods, as well as countless varia- tions and combinations, ripe for exploration and experimentation. If one stays within the bounds of this design space, by conforming to the necessary axioms, the various correctness results apply. However, these axioms also specify very precisely the applicability of these results, and possible jumping-off points for new indexing approaches. Deciding to break with one or more of the assump- tions laid down will necessarily make some of my results inapplicable, but will also create opportunities for wholly new designs. Of course, the work presented here is limited in its scope to a theoretical study of sprawls and ambits. Some tentative experiments have been performed, e.g., to verify that there are indeed cases where non-linear ambits will outper- form their linear counterparts (cf. Sect. 3.5), and that the heuristic facet and focus selection procedures of sects. 3.3 and 3.4 do indeed seem to yield reason- able results. However, proper experimentation is still needed to arrive at any definitive conclusions. Beyond basic implementation and benchmarking work, actually exploring the design space in a systematic, perhaps even automated, fashion might also be an interesting topic for further research. Acknowledgements The author wishes to thank Ole Edsberg and Jon Marius Venstad for highly fruit- ful discussions, and André Philipp, Joakim Skarding and Odd Magnus Trondrud for their preliminary empirical work based on the ideas presented here. A Proofs of Selected Theorems 2.1.5 Theorem. The following statements are equivalent: (i) hV, L i is a traversal repertoire. (ii) hV, L i is the traversal repertoire of some signed hyperdigraph hV, E, σi. In particular, any traversal repertoire is the traversal repertoire of the corre- sponding signed hyperdigraph produced by Con. 2.1.4. Proof. (i ⇒ ii) Assume that hV, L 1i is a traversal repertoire. Let (V, E) and L 2 be as defined by Con. 2.1.4. What remains is to show that L 2 = L 1, i.e., that a sequence γ is a member of L 1 if and only if it is a traversal of hV, Ei. By assumption, hV, L 1i obeys the traversal axioms; by the reverse impli- cation (ii ⇒ i, proven below), so does hV, L 2i. We proceed by induction on sequence length, with the inductive step proven by exhaustion. First, the base case. Case 1: γ = ε. In this case, γ is in both L 1 and L 2, as guaranteed by Axiom T1. The remaining cases cover the inductive step, where we let γ = τ x, with x ∈ V. Case 2: τ /∈ L 1. By the inductive hypothesis, we have τ /∈ L 2 and Axiom T3 immediately yields the inductive step, with τ x absent from both languages. 34 Now assume τ is present in both languages, but that τ x is not. Our goal is to show that once Alg. 2.1.1 produces the traversal τ , x either has been eliminated or remains undiscovered, as covered by the next two cases. Case 3: τ ∈ L 1, τ x /∈ L 1, but αx ∈ L 1 for some α ∈ V∗ where α ( τ . If x ∈ τ , Alg. 2.1.1 will not traverse x again. Otherwise, by Axiom E2, there is a negative edge τ ! x in E. Either way, we have τ x /∈ L 2, as desired. Case 4: τ ∈ L 1 and αx /∈ L 1 for every α ∈ V∗ where α ⊆ τ . The condition in Axiom E1 will never apply to any such α, so x can not have been discovered. Finally, assume that τ x (and therefore τ ) is in L 1. We then wish to show that x is available after traversing τ in hV, E, σi, i.e., that it has been discovered but not eliminated. Case 5: τ x ∈ L 1. Because τ x is in L 1, Axiom E1 mandates a positive edge τ ! x in E, and Axiom T2 forbids x ∈ τ , so the only obstacle to availability in hV, E, σi would be elimination. Assume there is a negative edge ω ! x in E, for some ω ⊆ τ , meaning that for some ω ∈ L 1, we have ωx /∈ L 1. If Axiom E2 is to apply, there must then be some α with α ( ω for which αx ∈ L 1. However, by the interval property [T4], because α ⊆ ω ⊆ τ and ω, αx, τ x ∈ L 1, we have ωx ∈ L 1, which is a contradiction. Therefore there can be no such edge, and consequently τ x ∈ L 2. These cases are exhaustive, and in each case τ x ∈ L 1 if and only if τ x ∈ L 2, which proves the inductive step. This, in turn, means that L 1 = L 2, which proves the implication from (i) to (ii). (ii ⇒ i) We need to show that the traversals of Alg. 2.1.1 satisfy the traversal axioms: Before the first iteration, the traversal is empty [T1]; after this, each node is traversed at most once [T2], one at a time [T3], provided they have been discovered but not eliminated [T4]. In particular, discovery and elimination depend only on the set of nodes traversed, so the interval property holds for α ⊆ τ ⊆ ω, even if α and τ are not prefixes of ω. A.1 Construction. From a monotone traversal scheme hhV, L iiii with workload hQiii, in some universe U, we produce a sprawl hV, E, P, Ni. Let hhV, Ei, σiiii be the results of Con. 2.1.4 for the corresponding traversal repertoires, with extra edges as mandated by the following axiom, for all Qi, Qj: [E3] If e ∈ Ej, σj(e) = −1 and Qi ⊆ Qj then e ∈ Ei and σi(e) = −1. Let E be the union of all the edge sets. For each edge e ∈ E, (i) Let hQiii∈I′ be the maximal queries for which σi(e) = −1 or e /∈ Ei; and (ii) Let hQiii∈I′′ be the maximal queries for which σi(e) = −1. Finally, let P(e) and N(e) be the families hU \ Qiii for i in I′ and I′′, respectively. The addition of negative edges in the previous construction is a form of normalization, to prevent the somewhat arbitrary transition from non-discovery to elimination whenever an expanding query introduces a traversal α that ac- tivates Axiom E2. This makes non-elimination monotone in the query (under 35 inclusion), just like discovery -- a property that is needed in the proof of Theo- rem 2.2.4. This normalization is harmless, as the following observation attests. A.2 Observation. Each signed hyperdigraph hV, Ei, σii in Con. A.1 has the cor- responding language hV, L ii as its traversal repertoire. Proof. If σj(τ , x) = −1, than any traversal τ that is an ordering of τ will result in the elimination of x. By Theorem 2.1.5, this means that τ x /∈ L j. Because Qi ⊆ Qj, Axiom T5 requires L i ⊆ L j, and so we also have τ x /∈ L i for every such τ , and adding e : τ ! x to Ei with σi(e) = −1, if absent, does no harm. 2.2.4 Theorem. For a workload hQiii∈I in U, these statements are equivalent: (i) hhV, L iiii∈I is a monotone traversal scheme with ground set V ⊆ U. (ii) hhV, L iiii∈I is the traversal scheme of some sprawl hV, E, P, Ni in U. In particular, any monotone traversal scheme is the traversal scheme of the corresponding sprawl produced by Con. A.1, for any appropriate universe. Proof. (i ⇒ ii) Let U be any appropriate universe, i.e., with V, Qi ⊆ U, for i ∈ I, and let hV, E, P, Ni be the sprawl produced by Con. A.1. Let Qi be any of the queries; we need to show that resolving Qi on our sprawl produces the traversal repertoire hV, L ii. More specifically, we can show that the signed hyperdigraph hV, E′, σi resulting from applying Qi to the sprawl (as described by Con. 2.2.1) is the same as hV, Ei, σii, which has hV, L ii as its repertoire (cf. Obs. A.2). We proceed by cases for an arbitrary edge e : τ ! x in E. Case 1: σi(e) = +1. We need to show that σ(e) = +1, and per Con. 2.2.1, the condition for this is that Qi intersect all sets in the families P(e) and N(e). For any region Rj in P(e) or N(e), its complement Qj := U \ Rj is, by construction, a query for we do not have σj(e) = +1, which, by Axiom E1, means that for no ordering τ of τ do we have τ x ∈ L j. By Axiom T5, this is true for any subset of Qj as well. This undercuts the only way in which Con. 2.1.4 could mandate σi(e) = +1, and so Qi 6⊆ Qj, and consequently Qi must intersect Rj. Case 2: σi(e) = −1. We need to show that there is some region R ∈ N(e) that does not intersect Qi. Let Qj be a maximal query for which σj(e) = −1, and where Qi ⊆ Qj. Qi cannot intersect Rj, and, by construction, we have Rj ∈ N(e). Case 3: e /∈ Ei. We need to show that Qi intersects every region in N(e), but not every region in P(e). First, Let Qj be some query where Qi ⊆ Qj. Because of Axiom E3 of Con. A.1, it can not be the case that σj (e) = −1, and so Rj /∈ N(e), meaning that Qi intersects all regions in N(e). Second, because e /∈ Ei, by Con. A.1(i), there is som j ∈ I′ with Qi ⊆ Qj and Rj ∈ P(e), so there is at least one region in P(e) that does not intersect Qi. (ii ⇒ i) By definition, each language in the traversal scheme of a sprawl is the traversal repertoire of some signed hyperdigraph (Con. 2.2.1, Alg. 2.2.2 and Def. 2.2.3), and therefore an actual traversal repertoire (Theorem 2.1.5). Extending some query Qi to some superset Qj will never cause Con. 2.2.1 to 36 remove positive edges or add negative ones, and so any traversal present in L i must still be present in L j, satisfying Axiom T5, making hhV, L iiii∈I a monotone traversal scheme. 2.3.10 Observation. Given a sprawl hV, E, P, Ni and an atomistic workload, let v be any node and let {e1, . . . , ek} be the edges with tgt(ei) = v. If res is a responsibility assignment, then for any e := ei and R ∈ P(e), R′ ∈ N(e): [L1] res(e) ⊆ R; [L2] res(v) ⊆ R′; [L3] res(v) ⊆ res(e1) ∪ · · · ∪ res(ek). If the sprawl is acyclic and every node is the target of at least one edge, then ax- ioms L1 to L3, using the shorthand (2.1), are necessary and sufficient conditions for any relation res ⊆ E × V to be a responsibility assignment. Proof. First, assume that res is a responsibility assignment. For any query {u}, intersecting R means u ∈ R; thus, by Axiom R1, there must be a path Πu where u ∈ R for every R ∈ P(e), e ∈ Πu. The responsibilities res(e) are, by definition, exactly the nodes u for which this situation obtains, and thus Axiom L1 holds. Any edge e′ with target v in such a path Πu would, by Axiom R2, have u ∈ R′, for every R′ ∈ N(e′). The node v would either be the source of some edge e ∈ Πu (i.e., u ∈ res(e)) or the target of the last edge (i.e., v = u). The nodes u for which this is the case are, by (2.1), exactly the responsibilities res(v), and so Axiom L2 holds. Finally, consider any node u ∈ res(v). Whether u = v or not, v must be the target of some edge in Πu, and so ei ∈ Πu, for at least one of its incoming edges ei. This means that u ∈ res(ei), which implies Axiom L3. Conversely, assume that the sprawl is acyclic and that every node is the target of at least one edge, and consider any relation res ⊆ E × V satisfying axioms L1 to L3, using the shorthand from (2.1). Let u be any node and Q be any query, with u ∈ Q. We can now show that there is a hyperpath Πv satisfying axioms R1 and R2 from ∅ to any node v ∈ V for which u ∈ res(v), with u = v being the special case we care about. Because the sprawl is acyclic, we may order the nodes v1, . . . , vn so that if and vi = tgt(e) and vj ∈ src(e), then j < i, for any edge e with at least one positive region. We proceed by induction on i. By Axiom L3 there is at least one edge e with tgt(e) = v and u ∈ res(e), and thereby, by Axiom L1, u ∈ R, for each R ∈ P(e).33 By assumption, we already have the requisite paths to each node in src(e), and so we have established Axiom R1. All that remains in order to establish Axiom R2 is to consider any edges e′ with tgt(e′) = v. For any region R′ ∈ N(e′), Axiom L2 tells us u ∈ R′, which yields the desired result. B Additional Remarks 1.2.8 Remark. A greedoid is a non-empty, simple, hereditary language hV, L i that satisfies the following greedoid exchange property, for all α, β ∈ V∗ [38]: [G1] If α, β ∈ L and α > β then βx ∈ L for some x ∈ α. 37 Interval greedoids satisfy the interval property [T4], and are thus exactly the traversal repertoires that satisfy the greedoid exchange property [G1].34 It is not hard to verify that if Axiom T4 is strengthened by removing the upper bound ωx, the resulting traversal repertoires satisfy the following stronger property: [U1] If α, β ∈ L and α 6⊆ β then βx ∈ L for some x ∈ α. These are precisely the so-called upper interval greedoids, or antimatroids,35 and they represent traversals without elimination, such as the graph traversal of Ex. 1.2.9 [cf. 38, III.2.11]. If the lower bound αx is removed instead, we get traversals without discovery, where reachable nodes are available initially, but may be eliminated. (These might not be lower interval greedoids, i.e., matroids.) 2.1.3 Remark. Alg. 2.1.1 may be seen as an application of the generalized for- ward chaining construction of Marek, Nerode, and Remmel [45] to the following general logic program, built from the hypergraph hV, Ei: τv αv, ¬ωv αv hτu : u ∈ src ei ωv hτu : u ∈ src ei, ¬τv for all v ∈ V; for all positive e ∈ E where v = tgt e; for all negative e ∈ E where v = tgt e. (†) (∗) The variables τv, αv and ωv indicate that v has been traversed, discovered and eliminated, respectively.36 The required well-ordering of the non-monotonic (i.e., non-Horn) clauses [45, § 3.1] would place all elimination rules (†) first, and then order the traversal rules (∗) by the traversal heuristic. In the absence of negative edges, we may simply use a definite logic program of Horn clauses such as τv hτu : u ∈ src ei, where v = tgt e, resulting in ordinary forward chaining [19, § 6.4.2]. This is equivalent to ordinary digraph or hyperdigraph traversal, under the hyperpath definition of, e.g., Ausiello et al. [3]. 2.1.6 Remark. As mentioned in Rem. 1.2.8, if our repertoire features only dis- covery, it is in fact an antimatroid. The hyperdigraph resulting from Con. 2.1.4 will then have only positive edges, and the source sets correspond exactly to the alternative precedence constraints of these targets, as used in one of several equivalent definitions of antimatroids [38, Thm. 1.4]. C Auxiliary Definitions C.1 Directed Hypergraphs C.1.1 Definition. A directed hypergraph or hyperdigraph is a generalization of a directed graph, where each edge may have multiple sources. Specifically a directed hypergraph hV, Ei consists of a finite, nonempty set V of nodes and a finite set E of edges with sources src(e) ⊆ V and target tgt(e) ∈ V. A signed hyperdigraph hV, E, σi consists of a hyperdigraph hV, Ei and a sign function σ : E ! {−1, +1}. An edge e ∈ E is said to be positive (resp., negative) if σ(e) is positive (resp., negative). To indicate that S = src(e) and t = src(e), we may use the shorthand e : S ! t. If we need not name the edge, we write S ! t. Note, however, that we may have e1, e2 : S ! t with e1 6= e2. 38 C.1.2 Definition. The target of a sourceless positive edge is called a root node or simply a root. A hyperdigraph may be specified by giving a set V of nodes, a set E of edges, and a set V0 ⊆ V of roots. Each root vi ∈ V0 implicitly defines a sourceless edge ei /∈ E with tgt(ei) := vi, and the hyperdigraph thus specified is hV, E ∪ {ei : vi ∈ V0}i. C.1.3 Definition. Given a signed hyperdigraph hV, Ei, a directed hyperpath or simply path from S ⊆ V to t ∈ V is a set Π ⊆ E that may be ordered into a sequence Π := he1, . . . , eki of distinct edges subject to the following, for i = 1, . . . , k: [P1] src(ei) ⊆ S ∪ {tgt(ej) : j < i}. [P2] t = tgt(ek). [P3] No strict subset of Π is a path from S to t in hV, Ei. The node set of Π is the set of all sources and targets of its edges. C.1.4 Remark. The previous definition is essentially equivalent to that given by Ausiello, Franciosa, and Frigioni [3], except their requiring S 6= ∅ and defining the path to be a subhypergraph. C.1.5 Algorithm. An unsigned hyperdigraph hV, Ei is traversed by discovering and traversing nodes, as described in the following. Nodes are available if they has been discovered but not traversed. Edges are active once their sources have been traversed. The following steps are repeated, starting with the second step in the first iteration: Step 1. One of the available nodes is selected and traversed. Step 2. The targets of active edges are discovered. The steps are repeated as long as there are nodes available. When there are several nodes available in the first step, the choice is made using a traversal heuristic. In a practical implementation, available nodes will typically be kept in a priority queue, with the traversal heuristic defining the priority. Activation of edges can be handled efficiently by tracking their number of traversed sources. Any such state information could be reset between traversals in constant time without increasing asymptotic space usage [see, e.g., 50]. The priority of a node may be updated, for example, whenever it is rediscovered in the first step. C.1.6 Remark. The version of hyperdigraph traversal described in Alg. C.1.5 does not take a set of starting nodes as a parameter. If it did, these would simply be available from the beginning, i.e., added to the priority queue before the main loop. This behavior may be emulated, however, by treating the starting nodes as roots (cf. Def. C.1.2), and traversing the resulting hyperdigraph. C.1.7 Example. Directed graphs correspond to the special case where each edge has exactly one source. The signed hyperdigraph traversal described in Alg. C.1.5 corresponds to ordinary graph traversal in this case. 39 C.2 Basic Model Theory C.2.1 Definition. A signature is a set Σ of function and relation symbols, each with non-negative arity. A Σ-structure has the following data: (i) A non-empty set A := dom A, known as the domain of A; and (ii) A family hSAiS∈Σ of functions and relations on A. These data obey the following axioms: [S1] SA : An ! A if S is an n-ary function symbol; and [S2] SA ⊆ An if S is an n-ary relation symbol. We refer to SA as the A-interpretation of S. C.2.2 Remarks. (a) It is common to permit only arities n > 1, and to have a separate class of constants S, with SA ∈ A. Nullary function symbols essentially correspond to such constants [62], and nullary relations to truth values [55]. (b) It is possible to define many-sorted logical languages and structures, where each term and each argument position is assigned a sort, and these cor- respond to a partition of A [62, p. 5]. Each sort i is also assigned its quantifier ∀i, but if we introduce a predicate Si that uniquely picks out the subset of A corresponding to sort i, we may replace any quantification ∀ix ϕ(x) with ∀x Si(x) ! ϕ(x), translating many-sorted formulas to equivalent single-sorted ones.37 When transforming a many-sorted structure to a single-sorted one, rela- tions remain intact, but functions must be (arbitrarily) extended so each argu- ment may be drawn from all of A [27, Sect. 4.3] C.2.3 Definition. We define the Cartesian product of structures A and B as the structure A × B with dom (A × B) := (dom A) × (dom B) , where functions and relations act elementwise: FA×B produces a pair of the results from FA and FB, and RA×B holds iff both RA and RB do. Powers and products of multiple structures are defined in the obvious manner. C.2.4 Examples. (a) A partially ordered set P may be seen as a structure P with domain P and a single binary relation symbol 6, representing the partial order relation 6P on P. Let M = Pm. Then dom M consists of m-tuples from dom P, and hx1, . . . , xmi 6M hy1, . . . , ymi holds iff xi 6P yi for i = 1, . . . , m. (b) A vector space V over a field F of scalars may be seen as a structure V with domain V and signature {+, 0} ∪ F, where the binary function symbol + represents the vector addition +V, the constant symbol 0 represents the vector space origin 0V, and each a ∈ F is used as a unary function symbol representing the operation aV : V ! V of scalar multiplication by a. C.2.5 Definition. A string constructed using Σ along with variables, quantifiers and Boolean operators, respecting arities and the syntax of first-order logic, is called a formula. A formula whose variables are all bound by quantifiers (i.e., one without free variables) is a sentence. Such a sentence ϕ is interpreted 40 recursively in a structure A of signature Σ, by treating each non-logical symbol as its A-interpretation, and giving the logical symbols their canonical meaning. If the resulting statement is true, we write A = ϕ, or say that ϕ is true in A. C.2.6 Example. If P represents any poset with order symbol R, then: P = ∀xyz R(x, y) ∧ R(y, z) ! R(x, z) That is, for all x, y, z ∈ dom A, if hx, yi, hy, zi ∈ RP then hx, zi ∈ RP. C.2.7 Remark. Let A be a many-sorted structure, and ϕ a sentence in the corre- sponding many-sorted language; let A∗ and ϕ∗ be the corresponding translations, as described in Rem. C.2.2b. Then A = ϕ if and only if A∗ = ϕ∗. C.2.8 Definition. For any two structures A and B with the same signature Σ, a map f : A ! B is a function from dom A to dom B. A homomorphism is a map f : A ! B that satisfies the following axioms for all function and relation symbols F and R in Σ, of any arity n > 0, and all a1, . . . , an ∈ dom A: [H1] RA(a1, . . . , an) ⇒ RB(f (a1), . . . , f (an)); [H2] f (FA(a1, . . . , an)) = FB(f (a1), . . . , f (an)). An embedding is an injective homomorphism for which H1 is biconditional, and an isomorphism is a surjective (and, consequently, bijective) embedding. C.2.9 Examples. (a) For posets P0 and P1, the homomorphisms f : P0 ! P1 are exactly the nondecreasing maps from P0 to P1. (b) For vector spaces V0 and V1, represented as in C.2.4b, the homomor- phisms f : V0 ! V1 are exactly the linear maps from V0 to V1. (c) For any structure A, the diagonal embedding ∆m : A ! Am is, as its name implies, an embedding. C.2.10 Definition. A formula ϕ with free variables x1, . . . , xn is true of a1, . . . , an in A, written A = ϕ(a1, . . . , an), if ϕ is true in A when each xi is seen as a name for ai ∈ A. For two structures A and B with the same signature, a map f : A ! B preserves a formula ϕ with n free variables if A = ϕ(a1, . . . , an) =⇒ B = ϕ(f (a1), . . . , f (an)) , for all a1, . . . , an ∈ A. If ϕ has n + 1 free variables, then, given n parameters bi ∈ A, we write ϕ(A, b1, . . . , bn) for the set {a ∈ dom A : A = ϕ(a, b1, . . . , bn)}. C.2.11 Definition. Formulas are existential if they combine quantifier-free formu- las using ∧, ∨ and ∃. They are positive if they do not contain negation (or, by extention, implication). A basic Horn formula has the form ϕ1 ∧ · · · ∧ ϕn ! ψ, where each ϕi is an atomic formula (i.e., without logical operators) and ψ is either an atomic formula or ⊥ (false). A Horn formula is built from basic Horn formulas using ∧, ∃ and ∀. 41 Notes 1. The etymology of the new terms is straightforward. In existing usage, sprawl can mean (i) an aggregation or network of regions, as in an urban sprawl, or (ii) to spread in a rambling and irregular way, while ambit is another word for extent, reach, or sphere of influence. 2. The figure simplifies things, by having a one-to-one correspondence between regions and hyperedges. In general, each hyperedge could have multiple regions, though in many cases this would not be necessary (cf. Rem. 2.3.12). 3. The figure simplifies things, by having a one-to-one correspondence between regions and hyperedges. In general, each hyperedge could have multiple regions, though in many cases this would not be necessary (cf. Rem. 2.3.12). 4. In some rare cases, one may be able to deduce relevance without explicit examination, but the performance gains this provides are generally quite modest. 5. In other words, Alg. 2.2.2 and Alg. 2.0.2 are descriptions of the same algorithm. 6. That is, P(e) = 1 for positive edges and N(e) = 1 for negative edges 7. Some definitions of directed hypergraphs do permit multiple targets; the sprawl definition could easily have been rewritten to accommodate that, or to use a bipartite digraph of nodes and signed regions. 8. Edges with the same sources and target may be identified, so the resulting dihypergraph will have a finite number of edges, even if the workload is infinite. 9. For notational convenience, I use ϕ and the literals as names also of the nodes in the sprawl. 10. Note that it does not matter to the truth value if some of the roots are traversed after ϕ. 11. For irresponsible sprawls, this is no longer the case, as traversing a node may trigger an elimination that in turn is instrumental in preventing another elimination. 12. This meaning of the term "radient" is taken from Maxwell [46]. 13. The triangle inequality may be derived from ball overlap and vice versa. 14. For quasminetric spaces, the balls should have opposite direction. The triangle inequality immediately implies Eq. (3.3), but the converse also holds: For any u, let r = δ(p, u) and s = δ(u, q), and triangularity follows. 15. Note that for the existing regions emulated in Sect. 3.2, overlap checks with ball queries will not add any false positives, as all defining hyperplanes are axis-orthogonal. 16. In older text on weighted polyellipses, the weight is also referred to as the power of the focus. 17. One notable exception is Uhlmann [63], who briefly discusses half-plane queries. 18. Note that in some existing methods, the complemented ball is defined by a strict inequal- ity. 19. As originally described, one of the components of a cut region is a ball. This corresponds to dropping the last row of the coefficient matrix. 20. The feature polyhedra of these regions are all axis-orthogonal, so checking one facet at a time will not produce additional false positives. 21. The worst case is fm−1(Cm(n)) = (cid:0)n−⌈m/2⌉ ⌊m/2⌋ (cid:1) +(cid:0)n−1−⌈(m−1)/2⌉ ⌊(m−1)/2⌋ (cid:1) facets [70, p. 25 & § 8.4]. 22. For example, Bustos, Navarro, and Chávez [11] use the same heuristic for pivot selection. 23. A weight of zero eliminates the focus, so only positive weights will actually be used. 24. A focus will usually not be a responsibility, so we could even assume X > 0. 25. For more on parameterization, see, e.g., the book by Cygan et al. [20]. 26. For more on approximation, see, e.g., the book by Williamson and Shmoys [65]. 27. For example, using Chazelle's soft heaps [16], or the classic algorithm of Blum et al. [7]. 28. See, e.g., Theorem 7.2.1 of Kuczma [40]. He discusses concave and convex functions in particular, but the results generalize. 29. For non-distance arguments, f may simply act as the identity. 30. f(x1, x2) := x1x2/(x1 + x2 − x1x2) with xi ∈ [0, 1] and f(0, 0) := 0. 31. We might also use a relation not named in our signature, as long as it's defined on B. 32. We have a0 ≈A FA(a) ⇒ f(a0) ≈B f(FA(a)) ≈B FB(fa) ⇒ f(a0) ≈B FB(fa), where a is the tuple ha1, . . . , an i and fa is the standard shorthand for hf(a1), . . . , f(an)i. 33. Note that there may be no such regions, which is perfectly fine. 42 34. Korte, Lovász, and Schrader [38] include non-emptiness in their definition of heredity [p. 5]. They also explicitly include every prefix in the heredity axiom, i.e., αβ ∈ L ⇒ α ∈ L , which is equivalent to my Axiom T3. Finally, they define the interval property only for families of sets [p. 48], but my axiom coincides with theirs when applied to greedoids. The proof is quite straightforward using Lemma I.1.1 of Korte et al. 35. Some definitions of antimatroids also require them to be normal, i.e., that every element in V occur in some sequence in L . 36. More precisely, ωv means that v has been eliminated in time to prevent traversal. Without this proviso, some eliminations would be forbidden by the forward chaining construction, because they would contradict previous traversals. 37. The common definition is used for existential quantification, i.e., ∃ix ϕ(x) = ¬∀ix ¬ϕ(x); the single-sorted translation becomes ∃x Si(x) ∧ ϕ(x). References [1] A. V. Aho, J. E. Hopcroft, and J. D. Ullman. "The Design and Analysis of Computer Algorithms". Addison-Wesley (1974). [2] S. Arora, E. Hazan, and S. Kale. "The Multiplicative Weights Update Method: A Meta- Algorithm and Applications". Theory of Computing 8 (2012). [3] G. Ausiello, P. G. Franciosa, and D. Frigioni. "Directed hypergraphs: Problems, Algo- rithmic Results, and a Novel Decremental Approach". Theoretical Computer Science. Vol. 2202. Lecture Notes in Computer Science. Springer, 2001, pp. 312 -- 328. [4] R. Bayer and E. McCreight. "Organization and maintenance of large ordered indexes". Acta Informatica 1.3 (1972), pp. 173 -- 189. [5] P. Berkhin. "A survey of clustering data mining techniques". Grouping Multidimen- sional Data. Springer, 2006, pp. 25 -- 71. [6] J. F. Blinn. "A Generalization of Algebraic Surface Drawing". ACM Trans. Graph. 1.3 (1982), pp. 235 -- 256. [7] M. Blum et al. "Time bounds for selection". Journal of Computer and System Sciences 7.4 (1973), pp. 448 -- 461. [8] [9] J. Borsík and J. Doboš. "On a Product of Metric Spaces". Mathematica Slovaca 31.2 (1981), pp. 193 -- 205. S. Brin. "Near Neighbor Search in Large Metric Spaces". Proceedings of 21th Interna- tional Conference on Very Large Data Bases. Ed. by U. Dayal, P. M. D. Gray, and S. Nishio. Morgan Kaufmann, 1995, pp. 574 -- 584. [10] E. Bugnion et al. "Approximate multiple string matching using spatial indexes". Pro- ceedings of the 1st South American Workshop on String Processing. 1993, pp. 43 -- 54. [11] B. Bustos, G. Navarro, and E. Chávez. "Pivot Selection Techniques for Proximity Search- ing in Metric Spaces". Pattern Recognition Letters 24.14 (2003), pp. 2357 -- 2366. [12] G. Cantor. "De la puissance des ensembles parfaits de points". Acta Mathematica 4.1 (1884), pp. 381 -- 392. [13] E. Chávez, J. L. Marroquín, and R. Baeza-Yates. "Spaghettis: An Array Based Algo- rithm for Similarity Queries in Metric Spaces". Proceedings of the String Processing and Information Retrieval Symposium & International Workshop on Groupware (SPIRE). IEEE Computer Society, 1999, pp. 38 -- 46. [14] E. Chávez et al. "Searching in metric spaces". ACM Computing Surveys 33.3 (2001), pp. 273 -- 321. [15] B. Chazelle. "An optimal convex hull algorithm in any fixed dimension". Discrete & Computational Geometry 10.4 (1993), pp. 377 -- 409. [16] B. Chazelle. "The soft heap: An approximate priority queue with optimal error rate". Journal of the ACM (JACM) 47.6 (2000), pp. 1012 -- 1027. [17] G. Conant. Extending partial isometries of generalized metric spaces. 2016. arXiv: 1509.04950v3 [math.LO]. 43 [18] P. Corazza. "Introduction to Metric-Preserving Functions". The American Mathemati- cal Monthly 106.4 (1999), pp. 309 -- 323. [19] Y. Crama and P. L. Hammer. Boolean Functions: Theory, Algorithms, and Applica- tions. Vol. 142. Encyclopedia of Mathematics and its Applications. Cambridge Univer- sity Press, 2011. [20] M. Cygan et al. Parameterized Algorithms. Springer, 2015. [21] M. M. Deza and E. Deza. Encyclopedia of Distances. Springer, 2013. [22] J. Doboš. "A survey of metric preserving functions". Questions and Answers in General Topology 13.2 (1995), pp. 129 -- 134. J. Doboš. Metric Preserving Functions. Štroffek, 1998. [23] [24] V. Dohnal. "An Access Structure for Similarity Search in Metric Spaces". EDBT Work- shops. Ed. by W. Lindner et al. Vol. 3268. Lecture Notes In Computer Science. Springer, 2004, pp. 133 -- 143. [25] V. Dohnal et al. "Separable Splits of Metric Data Sets". Proceedings of the Nono Con- vegno Nazionale Sistemi Evoluti per Basi di Dati. 2001. [26] O. Edsberg and M. L. Hetland. "Indexing inexact proximity search with distance regres- sion in pivot space". Proceedings of the Third International Conference on Similarity Search and Applications. ACM. 2010, pp. 51 -- 58. [27] H. B. Enderton. A Mathematical Introduction to Logic. Harcourt Academic Press, 2001. [28] A.-D. Filip and A. Petrusel. "Fixed point theorems on spaces endowed with vector- valued metrics". Fixed Point Theory and Applications 2010.1 (2010). [29] K. Fujiwara and M. Kapovich. "On quasihomomorphisms with noncommutative tar- gets". Geometric and Functional Analysis (2016), pp. 1 -- 42. [30] K. Fukunaga and P. M. Narendra. "A branch and bound algorithm for computing k- nearest neighbors". IEEE Transactions on Computers 100.7 (1975), pp. 750 -- 753. [31] G. Gallo, G. Longo, and S. Pallottino. "Directed hypergraphs and applications". Dis- crete Applied Mathematics 42.2 (1993), pp. 177 -- 201. [32] M. R. Garey and D. S. Johnson. Computers and Intractability: A Guide to the Theory [33] [34] of NP-Completeness. W. H. Freeman and Company, 1979. J. A. Goguen. "L-fuzzy sets". Journal of Mathematical Analysis and Applications 18.1 (1967), pp. 145 -- 174. J. M. Hellerstein, J. F. Naughton, and A. Pfeffer. "Generalized Search Trees for Database Systems". Proceedings of the 21st International Conference on Very Large Data Bases. 1995, pp. 562 -- 573. [35] G. R. Hjaltason and H. Samet. "Index-driven similarity search in metric spaces". ACM Transactions on Database Systems, TODS 28.4 (2003), pp. 517 -- 580. [36] W. Hodges. Model Theory. Vol. 42. Encyclopedia of Mathematics and its Applications. [37] Cambridge University Press, 1993. I. Kalantari and G. McDonald. "A Data Structure and an Algorithm for the Nearest Point Problem". IEEE Transactions on Software Engineering 9.5 (1983), pp. 631 -- 634. [38] B. Korte, L. Lovász, and R. Schrader. Greedoids. Vol. 4. Algorithms and Combinatorics. Springer, 1991. [39] C. Koufogiannakis and N. E. Young. "A nearly linear-time PTAS for explicit fractional packing and covering linear programs". Algorithmica 70.4 (2014), pp. 648 -- 674. [40] M. Kuczma. An Introduction to the Theory of Functional Equations and Inequalities : Cauchy's Equation and Jensen's Inequality. Second. Birkhäuser, 2009. [41] F. W. Lawvere. "Metric spaces, generalized logic, and closed categories". Rendiconti del [42] [43] seminario matématico e fisico di Milano 43.1 (1973), pp. 135 -- 166. J. Lokoč and T. Skopal. "On applications of parameterized hyperplane partitioning". Proceedings of the Third International Conference on Similarity Search and Applica- tions. ACM. 2010, pp. 131 -- 132. J. Lokoč et al. "On indexing metric spaces using cut-regions". Information Systems 43 (2014), pp. 1 -- 19. 44 [44] D. Lowe and D. Broomhead. "Multivariable functional interpolation and adaptive net- works". Complex Syst 2 (1988), pp. 321 -- 355. [45] V. W. Marek, A. Nerode, and J. B. Remmel. "Logic programs, well-orderings, and forward chaining". Annals of Pure and Applied Logic 96 (1999), pp. 231 -- 276. [46] J. C. Maxwell. "On the Description of Oval Curves, and those having a plurality of Foci: with remarks by Professor Forbes". Proceedings of the Royal Society of Edinburgh 2 (1851), pp. 89 -- 91. Comm. by J. Forbes. [47] A. C. G. Mennucci. "On asymmetric distances". Analysis and Geometry in Metric Spaces 1 (2013), pp. 200 -- 231. [48] L. Micó, J. Oncina, and R. C. Carrasco. "A fast branch & bound nearest neighbour classifier in metric spaces". Pattern Recognition Letters 17.7 (1996), pp. 731 -- 739. [49] M. L. Micó, J. Oncina, and E. Vidal. "A new version of the nearest-neighbour approx- imating and eliminating search algorithm (AESA) with linear preprocessing time and memory requirements". Pattern Recognition Letters 15.1 (1994), pp. 9 -- 17. [50] G. Navarro. "Constant-time array initialization in little space". Proceedings of the 31st International Conference of the Chilean Computer Science Society. IEEE CS Press, 2012. [51] G. Navarro. "Searching in metric spaces by spatial approximation". The VLDB Journal 11.1 (2002), pp. 28 -- 46. [52] G. Navarro and N. Reyes. "Dynamic Spatial Approximation Trees". Proceedings of the XXI Conference of the Chilean Computer Science Society. 2001, pp. 213 -- 222. [53] D. Novak, M. Batko, and P. Zezula. "Metric index: An efficient and scalable solution for precise and approximate similarity search". Information Systems 36.4 (2011), pp. 721 -- 733. [54] V. Pestov and A. Stojmirović. "Indexing schemes for similarity search: An illustrated paradigm". Fundamenta Informaticae 70.4 (2006), pp. 367 -- 385. [55] B. Poizat. A Course in Model Theory: An Introduction to Contemporary Mathematical Logic. Springer, 2000. [56] E. V. Ruiz. "An algorithm for finding nearest neighbours in (approximately) constant average time". Pattern Recognition Letters 4.3 (1986), pp. 145 -- 157. [57] P. V. Sahadevana. "The theory of the egglipse: A new curve with three focal points". In- ternational Journal of Mathematical Education in Science and Technology 18.1 (1987), pp. 29 -- 39. [58] F. M. Schneider. "Weak homomorphisms between functorial algebras". Demonstratio Mathematica 44.4 (2011), pp. 801 -- 818. [59] B. Schweizer and A. Sklar. Probabilistic Metric Spaces. Elsevier, 1983. [60] T. Skopal. "Pivoting M-tree: A Metric Access Method for Efficient Similarity Search". Proceedings of the Annual International Workshop on Databases, Texts, Specifications and Objects. Ed. by V. Snášel, J. Pokorný, and K. Richta. Vol. 98. Technical University of Aachen, 2004. [61] T. Skopal. "Unified framework for fast exact and approximate search in dissimilarity spaces". ACM Transactions on Database Systems (TODS) 32.4 (2007), p. 29. [62] K. Tent and M. Ziegler. A Course in Model Theory. Cambridge University Press, 2012. [63] [64] J. K. Uhlmann. "Metric trees". Applied Mathematics Letters 4.5 (1991), pp. 61 -- 62. J. K. Uhlmann. "Satisfying general proximity/similarity queries with metric trees". In- formation Processing Letters 40.4 (1991), pp. 175 -- 179. [65] D. P. Williamson and D. B. Shmoys. The Design of Approximation Algorithms. Cam- bridge University Press, 2011. [66] D. Xu and Y. Tian. "A Comprehensive Survey of Clustering Algorithms". Annals of Data Science 2.2 (2015), pp. 165 -- 193. [67] P. N. Yianilos. Excluded Middle Vantage Point Forests for Nearest Neighbor Search. Tech. rep. NEC Research Institute, 1999. 45 [68] P. Zezula, P. Ciaccia, and F. Rabitti. M-tree: A Dynamic Index for Similarity Queries in Multimedia Databases. Technical Report 7. Hermes Esprit Ltr Project, 1996. [69] P. Zezula et al. Similarity Search: The Metric Space Approach. Springer, 2006. [70] G. M. Ziegler. Lectures on Polytopes. Vol. 152. Graduate Texts in Mathematics. Springer, 1995. [71] H.-J. Zimmermann. Fuzzy set theory and its applications. Springer, 2001. 46
1110.1320
2
1110
2011-10-25T18:45:35
An efficient polynomial-time approximation scheme for Steiner forest in planar graphs
[ "cs.DS" ]
We give an $O(n \log^3 n)$ approximation scheme for Steiner forest in planar graphs, improving on the previous approximation scheme for this problem, which runs in $O(n^{f(\epsilon)})$ time.
cs.DS
cs
An efficient polynomial-time approximation scheme for Steiner forest in planar graphs David Eisenstat∗ Philip Klein∗ Claire Mathieu∗ Abstract 1 Introduction We give an O(n log3 n) approximation scheme for Steiner forest in planar graphs, improving on the pre- vious approximation scheme for this problem, which runs in O(nf ()) time. ∗Department of Computer Science, Brown University. Sup- ported in part by NSF grant CCF-0964037. 0 In the Steiner forest problem, we are given an undi- rected graph G with edge-lengths and a set D of pairs (si, ti) of vertices. The pairs are called demands, and the vertices that appear in demands are called ter- minals. The goal is to find a minimum-length forest F that, for every demand (si, ti), contains a path in F from si to ti. This problem generalizes the Steiner tree problem in networks. There is a polynomial-time 2-approximation algo- rithm [1], but the problem doesn't have an approx- imation scheme unless P=NP [3, 16]. However, for restricted input classes, polynomial-time approxima- tion schemes have been found. For the case where the vertices are the points on the plane and edge- lengths are Euclidean distances, Borradaile, Klein, and Mathieu [5] give an approximation scheme that can be implemented in O(n log n) time where n is the number of terminals. For planar graphs, Bateni, Hajiaghayi, and Marx [2] give a polynomial-time approximation scheme. The running time, however, for obtaining a (1 + )-approximate solution has the form n−c . The degree of the polynomial grows as  gets smaller. An efficient polynomial-time approximation scheme is an approximation scheme whose running time has the form O(f ()nc) for some function f and some con- stant c independent of . Thus the approximation scheme of Bateni, Hajiaghayi, and Marx is not an efficient PTAS in this sense. Our main result is an efficient PTAS: Theorem 1.1. For planar Steiner forest, there is an approximation scheme whose running time is O(n log3 n). Figure 1: Left: a carving. Right: a branch decomposition. 2 Techniques 2.1 Branchwidth Tree-decomposition and branch-decomposition are ways to map pieces of the graph to nodes of a tree so that, loosely speaking, pieces have small overlap. We formally define branch-decomposition. The gen- eral paradigm is to reduce the problem to graphs of bounded tree- or branch-width. A carving of a ground set is a maximal family C of mutually noncrossing subsets of the ground set. In this paper, we refer to the sets in C as clusters. The Hasse diagram of the inclusion partial order on the clusters is a tree in which each node has zero or two children. A branch-decomposition of a graph G is a carving C of the edges of G. The boundary ∂C of a clus- ter C is the set of vertices v such that C contains a proper nonempty subset of the edges incident to v. The width of a branch-decomposition C of G is : C ∈ C}. The branchwidth of G is the max{∂C minimum width over all branch-decompositions of G. Treewidth (not defined here) is within a constant factor of branchwidth. Graphs of bounded treewidth and branchwidth are tree-like, and many problems can be solved exactly in linear time on such graphs. As we will see, this is not the case for Steiner forest. 2.2 Framework The approximation scheme of Bateni, Hajiaghayi, and Marx fits into the framework of Klein [13], which consists of the following steps: spanner Find a subgraph G1 (called the Steiner tree spanner) of the input graph G0 such that, for constants c and d, 1. length(G1) ≤ c OPT(G0)), where OPT(G0) is the total length of the edges used by an optimum solution, and 2. OPT(G1) ≤ (1 + d) OPT(G0). thinning Partition the edges into p subsets such that the contraction of any subset yields a graph of branchwidth O(p). Let G2 be the graph ob- tained from G1 by contracting the subset S hav- ing the smallest total length. dynamic programming Find an (approximately) optimal solution in G2. lifting Lift the solution in G2 to a solution in G0 by uncontracting edges of S and adding them to the solution as needed. This presentation of the framework differs from the original in [13] in that, in the original, the dynamic- programming step finds an optimal solution. Suppose the solution in the dynamic-programming step has length at most (1 + c(cid:48)) OPT(G2). Since contraction preserves connectivity, OPT(G2) ≤ OPT(G1). By the spanner property, OPT(G1) ≤ (1 + d) OPT(G0). The addition of some edges from S in the lifting step increases the length by at most length(G1)/p. We choose p = c/ so the additional length is at most  OPT(G0). Hence the length of the final solution is ((1 + c(cid:48))(1 + d) + ) OPT(G0). (See also [9, 8]. The dynamic-programming step is straightforward the construction is given and takes linear time; in [13]. (It has been general- ized to bounded-genus graphs [9] and, more recently, to minor-excluded graphs [8].) The lifting step is problem-dependent but straightforward for the prob- lems (such as TSP, Steiner tree, and Steiner forest) to 1 which the framework has been successfully applied. The spanner and dynamic-programming steps are problem-dependent. It is in those steps that Bateni, Hajiaghayi, and Marx [2] introduced new techniques, and it is there that our improvements go. 2.3 Spanner The spanner step of Bateni et al. built on the same step in the Steiner tree PTAS of Borradaile, Klein, and Mathieu [4, 6]. The proof of the latter can be adapted to show the following. For an instance of Steiner forest consisting of a graph G and a set D of terminal pairs, let OPT(G,D) denote the optimum value. Lemma 2.1 (Borradaile et al., adapted). For a num- ber  > 0, a planar graph G0, and a tree T of G0, there is a subgraph H of length f () length(T ) such that, for any set D of pairs of terminals belonging to T , OPT(H,D) ≤ OPT(G0,D) +  length(T ), where f (·) is a fixed function. Furthermore, H can be con- structed in O(n log n) time for fixed . To use this result, Bateni et al. introduced an al- gorithm called prize-collecting (PC) clustering. Theorem 2.1 (Bateni et al.). There is a polynomial- time algorithm that, given a number  > 0 and a (not necessarily planar) Steiner-forest instance (G,D), outputs a partition D1∪···∪D(cid:96) of D and correspond- ing trees T1, . . . , T(cid:96) such that the terminals comprising Di belong to the tree 1. Ti, i=1 length(Ti) ≤ ( 4 i=1 OPT(G,Di) ≤ (1 + ) OPT(G,D).  + 2) OPT(G,D), and 2. (cid:80)(cid:96) 3. (cid:80)(cid:96) 2.4 Our improvements to the spanner step When we try to obtain a quasi-linear approximation scheme, the PC-clustering algorithm of Bateni et al. fails us in two ways. • The running time is O(n2 log n). Indeed, the run- ning time is given in [2] as "polynomial"; beyond that, it does not matter since the overall time for their approximation scheme is O(nf ()). • Once the trees T1, . . . , Tk are found, a spanner Hi needs to be found for each tree. Finding a span- ner, given Ti, takes O(n log n) time, so the over- all time for finding the spanners is O(kn log n). Since k is Ω(n) in the worst case, the bound is O(n2 log n). We give a PC-clustering theorem that addresses both issues: the algorithm runs in O(n log n) for planar graphs (in fact, for any excluded-minor family) and it returns subgraphs G1, . . . , G(cid:96) with small overlap (each edge is in O(log n) subgraphs) in which the spanners can be found.1 Theorem 2.2 (New PC-clustering). For any δ > 0, there is an algorithm that, given  > 0 and a Steiner forest instance (G,D), outputs a partition D1∪···∪D(cid:96) of D and corresponding trees T1, . . . , T(cid:96) and subgraphs G1, . . . , G(cid:96) such that the terminals comprising Di belong to the tree 1. Ti,  + 2) OPT(G,D), i=1 length(Ti) ≤ ( 4+δ i=1 OPT(Gi,Di) ≤ (1 + ) OPT(G,D), 2. (cid:80)(cid:96) 3. (cid:80)(cid:96) each edge of G is in O(log n) of the subgraphs. 4. If the input graph G is simple and planar or, more generally, comes from a fixed excluded-minor family, the running time of the algorithm is O(n log n). To obtain a spanner for the Steiner forest instance (Gin,Din), therefore, one can perform PC clustering, and then, for each tree Ti, apply Lemma 2.1 to obtain a spanner Hi. The third property of PC clustering i=1 Hi will be a Steiner-forest implies that the union(cid:83)(cid:96) spanner for the original instance. Gassner [10] showed that Steiner forest is NP-hard even in graphs of treewidth 3. Bateni et al. ad- dressed this difficulty by giving an (inefficient) PTAS for Steiner forest in bounded-treewidth graphs, one that takes nO(w2/) time (w=width). 2 Combining this algorithm with the O(n log n) con- struction of Lemma 2.1, we obtain an O(n log2 n) algorithm for obtaining a Steiner-forest spanner for simple planar graphs. PC-clustering is but one example of the use of primal-dual approximation algorithms in approxima- tion schemes for planar, bounded-genus, and minor- excluded graphs. Our technique for speeding up 1PC-clustering can be stated in a somewhat more general way and is used in this way in multiterminal cut; our result actually addresses the more general problem. PC-clustering in planar and bounded-genus graphs in such graphs applies to other primal-dual approx- imation algorithms as well. For example, the tech- nique can be used on the Goemans-Williamson ap- proximation algorithm for prize-collecting TSP and prize-collecting Steiner tree. As a consequence, we obtain O(n log n) approximation schemes for these problems in planar and bounded-genus graphs. The speed-up in the algorithm comes from use of a dy- namic data-structure [7, 14] for maintaining orienta- tions, together with ideas from a data structure [12] for efficient implementation of primal-dual approxi- mation algorithms. 2.5 Our improvements to the dynamic pro- gramming step When we try to obtain an efficient approximation scheme, the dynamic program of Bateni et al. fails us in one way: each tree that crosses the boundary of a cluster is approximately represented by O(w/) of its vertices, and there are nO(w/) possible such vertex choices. We take advantage of the spanner property in combination with the bounded branchwidth prop- erty. Recall that the graph G1 has length at most c OPT(G0), and hence so does the graph G2 result- ing from the thinning step. In Section 4, we prove the following: Theorem 2.3. For any constant  > 0, there is an O(f (w)n log2 n) algorithm that, for any instance (G,D) of Steiner forest of branchwidth w, finds a so- lution of length at most OPT(G,D) +  length(G), where f (·) is a fixed function.2 We achieve this using a new graph construction on branch-decompositions. For each cluster, if the sum of lengths of edges near the cluster's boundary is high then the edges are contracted. The result is a graph in which, for each cluster, the sum of lengths of edges near the cluster's boundary is not too big. We can therefore cover the region near the boundary by a constant number of regions of low diameter. This simplifies the dynamic program since it doesn't have 2There is no great significance to our changing from treewidth to branchwidth. to keep track of exactly where the terminals are -- just which regions contain them. Since the number of regions is constant, we can get by with fewer con- figurations. The situation is a bit more complicated because the dynamic program has to deal with regions at dif- ferent scales, and has to guess the scales. We show it suffices to guess among a number of scales that is logarithmic in the height of the branch-decomposition tree and exhibit a linear-time algorithm that, given an arbitrary branch decomposition of width w, finds a new branch decomposition of width 2w and log- arithmic height. Another complication is the edges that were contracted in the graph construction. We show that, after uncontracting these edges, the opti- mal solution can be patched so that its length does not increase much. Consequently, the solution found by the dynamic program has length not much more than optimal. Combining Theorem 2.2, Theorem 2.3, the O(n log n) spanner construction of [6] described in Lemma 2.1, and the framework, we obtain Theo- rem 1.1. 3 Proof of Theorem 2.2 We describe the algorithm that proves Theorem 2.2. It involves just a small change to the PC-clustering algorithm of [2], although our presentation is differ- ent. 3.1 Algorithm for basic PC-clustering with graph decomposition In contrast to [2], we describe PC-clustering using contractions. When an edge uv is contracted, the endpoints are coalesced to form a new vertex. The variable t represents simulated time. Part of the input is an assignment φ[·] of "energy" to vertices, that, over time,consumed. When two endpoints u, v of an edge are coalesced, the new vertex combines their remaining energy. We say a vertexv is living if it has not yet exhausted its energy, i.e. φ[v] > 0 (else dead), and d[v] represents the amount of (simulated) time v has lived so far. Our substantive change is to introduce the notion of "zombie" vertices[15], which are vertices that are joined to living vertices not too long (depending on a parameter δ) after they die. 3 PC-clustering, Phase 1: input: an initial graph G with edge-lengths length(·), and an initial assignment φ of budgets to vertices t := 0; SAVE := ∅ for each vertex v, d[v] := 0 while there is a living vertex : v ∈ V (G), v living} ∆1 := min{φ[v] ∆2 := min {length(uv) : uv ∈ E(G), one of {u, v} is living} ∆ := min{∆1, ∆2} # which happens first? t := t + ∆ # advance time for every living vertex u, ∪ {length(uv)/2 : uv ∈ E(G), both u and v are living} d[u] := d[u] + ∆ φ[u] := φ[u] − ∆ length(uv) := length(uv) − ∆ for every incident edge uv † if some edge uv now has zero length, contract uv, creating new vertex w assign φ[w] := φ[u] + φ[v] and d[w] := max{d[u], d[v]} if some endpoint (say v) is not living but t < (1 + δ)d[v] then add uv to SAVE F1 := {edges contracted} PC-clustering, Phase 2: initialize F2 := F1 while there is an edge e ∈ F2 − SAVE that is the only edge incident to a dead vertex v delete e from F2 Figure 2: The new PC-clustering algorithm 4 Let G0 denote the graph G before the contractions of Phase 1. In the following, unless otherwise stated, the term vertices includes the original vertices of G0 as well as the new ones formed by contraction. For each vertex v, let φ0[v] denote the initial value of φ[v], the value when it is first assigned (whether before Phase 1 commences, in the case of vertices of G0, or in line † for vertices created by contractions). The contractions define a binary forest, the con- traction forest, on the vertices. If an edge uv was contracted and the resulting vertex is w then u and v are the two children of w in the contraction forest. For each vertex v, let Sv be the set of vertices of G0 that were coalesced to form v, and let Gv be the subgraph of G0 induced by Sv. We say an edge e of G0 is incident to a vertex v if exactly one of the endpoints of e in G0 belongs to Sv. A vertex v is isolated if, at the end of Phase 2, no edge of F2 is incident to it. We define the isolated- dead-vertex forest I to be the forest whose nodes are the isolated dead vertices and such that the parent of v is its nearest proper isolated dead ancestor in the contraction forest. Lemma 3.1. For each vertex v ∈ V (I), there is a connected component Tv of F2 whose vertex set is Sv −(cid:83){Sw : w a child of v in I}. Lemma 3.2. The depth of I is at most 1 + log1+δ : u ∈ V (G0)} : v ∈ V (G0), φ0[v] > 0} . (cid:80){φ0[u] has d[r] ≤(cid:80){φ0[u] min{φ0[v] Proof. At the end of Phase 1, for each dead vertex v, d[v] is the time when v died. Each root r of I : u ∈ V (G0)}. Suppose v is a nonroot vertex of I, and let w be the parent of v in I. Let uv be the edge contracted to form w. Since v is isolated, uv does not remain in F2, so v (cid:54)∈ SAVE. Therefore the time t at which uv is contracted must satisfy t > (1 + δ)d[v]. Therefore d[w] > (1 + δ)d[v]. This proves the lemma. The output of the algorithm is the forest I and, for each vertex v of I, the subgraph Gv and the con- nected component Tv of Lemma 3.1. Lemma 3.2 im- plies that each vertex/edge of G0 is in a logarithmic number of subgraphs. 3.2 Length of forest returned by basic PC- clustering 2(1 + δ)(cid:80){φ0[v] : v ∈ V (G0)}. Lemma 3.3. The forest returned has length at most Proof. For each value of t, let Living(t) denote the set of vertices that are living at time t, and let RecentDead(t) denote the set of vertices v such that (time of v's death) ≤ t ≤ (1 + δ)(time of v's death) : u ∈ Sv} − φ[v]. Intuitively, τ [v] is the amount of energy "used up" by v and its descendants in the contraction tree. The algorithm ensures that φ[v] remains non- : u ∈ Sv}. Induction shows d[v] ≤ τ [v]. For each vertex v, define τ [v] = (cid:80){φ0[u] negative, so τ [v] ≤ (cid:80){φ0[u] In Phase 1, when an edge is added to F1, its its reduced length is zero. The reduction in the length of edge uv can be attributed to the endpoint(s) living. For time t, let Gt be the graph G at time t, and let Ht be the edge-subgraph of Gt consisting of edges that are in F2 at the end of Phase 2. The total length v∈Living(t)(degree of v in Ht) dt. Ht is a forest whose leaves are clusters that are living or recent dead. The degree in H of dead clusters is at C∈Living(t) degH (C) ≤ 2(Living(t) + RecentDead(t)). length of of F2 is at most(cid:82)(cid:80) least two, so(cid:80) F2 is at most (cid:82) 2(Living(t) + RecentDead(t)) dt. (cid:82) Living(t)dt ≤ (cid:80){φ[v] (cid:82) RecentDead(t))dt ≤ δ(cid:80){φ[v] While a vertex v is living, φ[v] is decreasing at unit rate, so τ [v] is increasing at unit rate. This shows : v ∈ V (G0)}. By the definition of RecentDead(t) and d[v] ≤ τ [v] shows v ∈ V (G0)}. Therefore the total : This proves the lemma. Remark The only difference between this analysis and that of [2] is the part dealing with RecentDead(t). Recall that when two vertices coalesce, the result- ing vertex gets the remaining energy from its end- points. Therefore each bit of energy possessed by a new vertex v comes from some original vertex u ∈ Sv. Following [2], we think of the energy originally as- signed to u as having the color u. If some of v's energy comes from original vertex u, we will say that v has color u. Let E(cid:48) be a set of edges of G0. We 5 say a color u is exhausted by E(cid:48) if every vertex v col- ored by u has an incident edge in E(cid:48). These concepts yield: Lemma 3.4 (Bateni et al.). Let L be the set of col- ors exhausted by E(cid:48). The length of E(cid:48) is at least (cid:80) u∈L φu. Lemma 3.5. An original vertex u is exhausted by E(cid:48) if, for some dead vertex v such that u ∈ Sv, E(cid:48) contains a path between u and some original vertex not in Sv. 3.3 Using PC-clustering in Steiner forest Now we prove Theorem 2.2. (The proof of the run- ning time is in Section 3.4.) The input instance of Steiner forest is (Gin,D). The algorithm finds a 2-approximation solution F ∗, and then obtains the graph G from Gin by contracting each connected component K of F ∗. Let k be the number of com- ponents. Let Y be the set of components of length 2k length(F ∗). For each component K not in Y , <  the algorithm assigns energy to the vertex u of G re- sulting from contracting K: φ[u] := 2−1 length(K). All other vertices of G are assigned zero energy. The algorithm runs Phase 1 and 2 of Section 3.1 on G and φ[·], obtaining F2 and the isolated-dead-vertex forest I. For each v ∈ V (I), the algorithm obtains a subgraph Gv (see Section 3.1) and (see Lemma 3.1) a connected component Tv of F2. For each, the al- gorithm obtains G(cid:48) v from Tv by un- contracting the edges of F ∗, and defines Dv to be the set of demands (s, t) ∈ D for which s, t ∈ V (T (cid:48) v). We claim that these structures satisfy the conditions in Theorem 2.2. The first condition is satisfied by con- struction. Lemma 3.3 implies that the second con- dition is satisfied. Since each vertex of G is initially k length(F ∗), Lemma 3.2 im- assigned energy at least 1 plies that I has depth ≤ 1 + log1+δ k, which implies the fourth condition. v from Gv and T (cid:48) that It remains to show the third condition, the sum of optimum values for the subinstances {(G(cid:48) v,Dv) : v ∈ V (I)} is at most 1 +  times the op- timum value for the original instance (Gin,D). Since I is a rooted forest, it induces a partial order on these subinstances. v Let E(cid:48) be the edge-set of an optimal solution to the original instance. Each connected component C of E(cid:48) is assigned to the subinstance containing C that is farthest from a root in I, i.e. the instance for which Gv is smallest. Let Hv be the subgraph of G(cid:48) v,Dv). consisting of the components assigned to (G(cid:48) Since Hv might not constitute a feasible solution for that instance, we might need to augment them. Suppose that there is a demand (s, t) ∈ Dv such that s and t are not connected by Hv. The 2-approximate solution F ∗ contained some connected component K that joined s and t; let uK be the vertex in G0 that resulted from contracting that connected component. Since E(cid:48) is a feasible solution, it too contained a connected component that joined s and t; since that component was not assigned to the v,Dv), it must be that the component subinstance (G(cid:48) is not contained in G(cid:48) v, so, by Lemma 3.5, uK is exhausted by E(cid:48). To augment Hv, we add the component K of the 2-approximate solution. In the augmented solution, s and t are joined. Ei- ther K belongs to Y or φ[uK] = 2−1 length(K). The sum of the lengths of components in Y is 2k length(F ∗) ≤  ≤ k ·  : uK is exhausted by E(cid:48)} so : K (cid:54)∈ Y, uK is exhausted by E(cid:48)} ≤  length(E(cid:48)). Therefore the sum of lengths of solu- tions to the subinstances is ≤ (1 + ) OPT(Gin,D). This proves the third property of Theorem 2.2. 2 length(E(cid:48)), and(cid:80){φ[uK] (cid:80){length(K) ≤ length(E(cid:48)), 3.4 Primal-dual on planar and minor- excluded graphs We show that some primal-dual approximation al- gorithms, including Goemans and Williamson's ap- proximation algorithm for Steiner forest, and Bateni, Hajiaghayi, and Marx's algorithm for PC clustering (and our modification of this algorithm), can be im- plemented in O(n log n) time for planar graphs. The method is to combine an approach of [12] to implementing primal-dual approximation algorithms with a technique of [7] 3.4.1 Interface to data structure Klein [12] shows that primal-dual algorithms such as that of [11] can be implemented using a data struc- ture. There are two categories (active and inactive 6 in the case of primal-dual). An ordered pair (c, c(cid:48)) of categories is called a bicategory. Each vertex v is assigned a to category c(v), and thus each edge uv is assigned to a bicategory. The data structure supports the following operations: • DecreaseCost(b, δ), where b is a bicategory and δ is a real number, decreases by δ the cost of all edges in bicategory b. (2) • FindMin(b) returns the minimum-cost edge in bi- category b. • ChangeCategory(v, c) changes the category of v to c (implying changes to the bicategories of edges incident to v). • ContractEdge(e, c) contracts e and assigns the resulting vertex to category c. 3.4.2 Representation Now we describe the data structure. We use the ideas of [12] but make some changes to allow the data structure to be made more efficient for graphs from a minor-excluded family. The data structure maintains the following: • an orientation of the edges; • an array C[·], indexed by vertices, such that C[v] is the category of v; • an array OU T [·], indexed by a vertex v, such that OU T [v] is a linked list of the outgoing edges of v; • an array OU T [·,·], indexed by a vertex v and a category c, such that OU T [v, c] is a linked list of the outgoing edges of v whose tails are in cate- gory c; • an array IN [·,·], indexed by a vertex v and a cat- egory c, such that IN [v, c] is a pointer to a merge- able heap consisting of the incoming edges uv of v for which the tail u has category c; • an array B[·], indexed by bicategories, such that : B[(c1, c2)] is a heap consisting of {IN (v, c2) C[v] = c1}. Each edge and each heap has a real-number label. The data structure maintains the label invariant: the cost of an edge is the sum of its label, the label of the heap IN [v, b] that contains it, and the label of the heap B[b] that contains its heap. The key of an edge 7 in the priority queue that contains it is the edge's label. The key of a queue IN [v, b] in the priority queue B[b] that contains it is the label of IN [v, b] plus the minimum key in IN [v, b]. 3.4.3 Implementing DecreaseCost and Find- Min DecreaseCost(b, δ) is implemented by decreasing the label of IN (b) by δ. FindMin(b) is implemented by finding the minimum heap in B(b), and returning the minimum edge in that heap. 3.4.4 Implementing ChangeCategory (v, c) Now we describe how to implement the oper- ation ChangeCategory(v, c). Let c0 := C[v] (the old category of v). To handle the incoming edges of v, for each category c(cid:48), the heap IN [v, c(cid:48)] is moved from B[(c(cid:48), c0)] to B[(c(cid:48), c)] (and the label of IN [v, c(cid:48)] is adjusted to preserve the label invariant). To han- dle the outgoing edges of v, each edge vu in OU T [v] is moved from IN [u, c0] to IN [u, c] (and the label of vu is adjusted to preserve the label invariant). Time required is O(outgoing edges log n). 3.4.5 Implementing ContractEdge To implement ContractEdge(uv, c), first delete the edge uv, and change the categories of u and v to c. Let w denote the vertex to be formed by coalescing u and v. For each category c(cid:48), merge the heaps IN [u, c(cid:48)] and IN [v, c(cid:48)], and assign the result to IN [w, c(cid:48)]; sim- ilarly, merge the lists OU T [u, c(cid:48)] and OU T [v, c(cid:48)] and assign the result to OU T [w, c(cid:48)]. Remove the edge uv from the heap and list containing it. Update the ta- bles to reflect the fact that u and v no longer exist. The time required is O(({outgoing edges of u} + {outgoing edges of v}) log n). 3.4.6 Maintaining bounded outdegree The time per operation is O(log n) if the outdegree of each vertex is bounded. Brodal and Fagerberg [7] give a method for dynamically maintaining bounded- outdegree orientations in families of graphs that guar- antee the existence of such orientations. Kowalik [14] points out that their method works with contrac- tions. Each update takes amortized O(log n) time and changes the orientation of O(log n) edges. 4 Proof of Theorem 2.3 Now we prove Theorem 2.3. We are given an instance (Gin,Din) of Steiner forest, and a branch decomposi- tion of Gin of width w. For simplicity of presentation, we want to assume that each edge has length 1. To justify this assumption, let η = length(Gin)/(cm), and define a new length assignment (cid:92)length(e) := (cid:98)length(e)/η(cid:99). Now all the lengths are integers, and the sum of lengths is at most c−1m. Replace edge e with (cid:92)length(e) edgelets (if (cid:92)length(e) = 0 then con- tract e) to achieve the assumption. Given a solution for the modified instance, the additional length due to rounding is at most ηm, which by definition of η is less than  OPT(Gin,Din). 4.1 Reducing the height of the branch de- composition Lemma 4.1. Let C be a branch decomposition rooted The output C(cid:48) = at C of width at most w. Balance(C) is a branch decomposition rooted at C of width at most 2w, and, for all edges e ∈ C, there exist at most 3 log2 m + 1 clusters D ∈ C(cid:48) such that e ∈ D. There exist linear-time implementations of Bal- ance and Complete. Proof. For all clusters D ∈ C(cid:48), either D ∈ C, or there exist clusters D1, D2 ∈ C with D1 (cid:41) D2 such that D = D1 − D2. In the latter case, since ∂D ⊆ ∂D1 ∪ ∂D2 and ∂D1,∂D2 ≤ w, it follows that ∂D ≤ 2w. In order to prove the bound on the number of clus- ters containing a particular edge, we define a binary function δ = δ(m1, . . . , mk). If m1 = 1 and, for all i ∈ {2, . . . , k}, it holds that m1 + ··· + mi−1 ≥ mi, then δ = 0. Otherwise, δ = 1. The use of a heavy path in Balance ensures that every root invocation of Complete has δ = 0. The bound follows directly from this claim, which we prove by induction on k: for all inputs C1, . . . ,Ck to Complete, for all i ∈ {1, . . . , k}, there exist at most 3(log2 m−log2 mi)+2δ clusters D ∈ C(cid:48) such that D (cid:41) Ci. The base case k = 1 is trivial, since C(cid:48) = C1. When k > 1, let m<j = m1 + ··· + mj−1 and m>j = mj+1 + ··· + mk and δ<j = δ(m1, . . . , mj−1). By the choice of j, it holds that m<j ≤ m/2 and m>j < m/2. For all i ∈ {j + 1, . . . , k}, it follows by the inductive hypothesis that there exist at most 1 + 3(log2 m>j − log2 mi) + 2δ>j < 3(log2 m − log2 mi) clusters D ∈ C(cid:48) such that D (cid:41) Ci. For all i ∈ {1, . . . , j − 1}, there exist at most 2+3(log2 m<j −log2 mi)+2δ<j < 3(log2 m − log2 mi) + 2δ clusters D ∈ C(cid:48) such that D (cid:41) Ci, since 2δ<j ≤ 2δ. Lastly, there exist at most 2 ≤ 3(log2 m − log2 mj) + 2δ clusters D ∈ C(cid:48) such that D (cid:41) Cj, since if δ = 0 then mj ≤ m/2. 4.2 A framework for Steiner forest in graphs of bounded branchwidth In this section, we make explicit the dynamic pro- gramming framework of Bateni et al., adapted to branch-decomposition instead of tree-decomposition. Definition 4.1. With respect to a cluster C, a ver- tex u ∈ V (C) is active if it either belongs to ∂C or participates in a demand {u, v} ∈ D such that v /∈ V (C) − ∂C (see Figure 4). We use active(C) to denote the active vertices. A demand {u, v} ∈ D is active if either u or v is active. Definition 4.2. Given two partitions P1 and P2, let P1 ∨ P2 denote the finest partition coarser than both P1 and P2. Definition 4.3. With respect to a cluster C, a con- figuration (πin, πout, πall) is a triple consisting of partitions πin, πout of ∂C and a partition πall of active(C) such that πall∂C = πin ∨ πout. For a subgraph F , in the canonical configuration of C, πin is the connectivity of ∂C in F ∩ C, πout is the connectivity of ∂C in F − C, and πall is the connec- tivity of active(C) in F (see Figure 5). A subgraph F and a configuration (πin, πout, πall) are compatible if πin is the connectivity of ∂C in F ∩ C and πall is the connectivity of active(C) in (F ∩ C) ∨ πout (see Figure 6). Note that compatibility is determined by the edges in F ∩ C only. Proposition 4.1. With respect to each cluster C, a subgraph F is compatible with its canonical configu- ration. 8 Balance(C): Input: a branch decomposition C with root cluster C. Output: a balanced branch decomposition C(cid:48) with root cluster C. Let H1 (cid:40) H2 (cid:40) ··· (cid:40) Hk = C be a heavy path, that is, a maximal ascending chain such that, for all i ∈ {1, . . . , k − 1}, the sibling Hi+1 − Hi of Hi satisfies Hi+1 − Hi ≤ Hi. 1 = H1. For i ∈ {2, . . . , k}, let C(cid:48) i = Balance({D : D ∈ C, D ⊆ Ci}). 1, . . . ,C(cid:48) k). Let C(cid:48) For i ∈ {1, . . . , k}, let C(cid:48) Let C(cid:48) = Complete(C(cid:48) i = Hi − Hi−1. Hk C(cid:48) 3 C(cid:48) k H3 H2 1 C(cid:48) H1 = C(cid:48) 2 i with root clusters C(cid:48) i. Complete(C1, . . . ,Ck): Input: branch decompositions C(cid:48) 1, . . . , C(cid:48) Clusters C(cid:48) Output: a branch decomposition C(cid:48) ⊇ C(cid:48) with root cluster C(cid:48) For i ∈ {1, . . . , k}, let mi = C(cid:48) i. Let m = m1 + ··· + mk. Find (via binary search) the least index j ∈ {1, . . . , k} k are pairwise disjoint. 1 ∪ ··· ∪ C(cid:48) k. 1 ∪ ··· ∪ C(cid:48) k If j > 1: Else: If j < k: j−1). j} ∪ C(cid:48) j. 1 ∪ ··· ∪ C(cid:48) such that m1 + ··· + mj > m/2. Let A = Complete(C(cid:48) 1, . . . ,C(cid:48) Let B = A ∪ {C(cid:48) Let B = C(cid:48) Let D = Complete(C(cid:48) Let C(cid:48) = B ∪ {C} ∪ D, where C = C(cid:48) Let C(cid:48) = B j+1, . . . ,C(cid:48) k). j Else: 1 ∪ ··· ∪ C(cid:48) k. C(cid:48) D j+1 ∪ ··· ∪ C(cid:48) C(cid:48) k B C(cid:48) j−1 Cj j A 1 ∪ ··· ∪ C(cid:48) C(cid:48) Figure 3: Algorithm for balancing a branch decomposition. 9 C si sj sk tk tj u ti Figure 4: Active vertices. Consider cluster C and demand pairs {si, ti}, {sj, tj} and {sk, tk}. Here, si, sj, tj and u are active vertices of C but ti, sk, tk are not. C a h b g c d f e Figure 5: Canonical configuration. Consider the subgraph F depicted above, and assume that a, b, c, d, e, f, g are the active vertices of cluster C. Then the canonical configuration of C for F is: πin = {a},{b, c},{d},{e}, πout = {a, b},{c, d},{e}, and πall = {a, b, c, d, g, h},{e, f}. C a h b g c d f e C a h b g c d f e Figure 6: Compatibility of a subgraph with a configuration. If the set of active vertices is {a, b, c, d, e, f, g, h}, then the subgraph F depicted above is compatible with the configuration πin = {a},{b, c},{d},{e}, πout = {a, b},{c, d},{e}, and πall = {a, b, c, d, g, h},{e, f} (left side). It is also compatible with the configuration σin = πin, σout = {a},{b},{c, d, e}, and σall = {a, h},{b, c, d, e, f, g} (right side). 10 i , πall 2 1 0 , πout 0 , πall 0 ), , πall 2 , πout (πin 1 , πout i , πout 1 ∨ πin For i ∈ {0, 1, 2}, Definition 4.4. Let C0 be a cluster with child clusters C1 and C2. let (πin i ) be a configuration with respect to Ci. The configurations (πin , πall 1 ) and (πin 2 ) are compatible if all of the fol- lowing conditions hold. • πin 2 )∂C0: the internal connectivity of 0 = (πin the parent is the join of the internal connectivity of the children. 0 ∨ • For i ∈ {1, 2}, 3−i)∂Ci: the external connectivity of a child is πin the join of the external connectivity of the parent and the internal connectivity of the other child. 0 ∨ πall 1 ∨ • For i ∈ {0, 1, 2}, it holds that πall it holds that πout i = (πall = (πout i 2 )active(Ci). πall See Figure 7 for an example. Lemma 4.2. Let F be a subgraph. Then, for every cluster C0 with child clusters C1 and C2, the canoni- cal configurations of F with respect to C0, to C1 and to C2 are compatible. Conversely, suppose that we have a configuration for each cluster, such that for every cluster C0 with child clusters C1 and C2, the configurations for C0, for C1 and for C2 are compatible. Then there ex- ists a subgraph F such that the configurations are the canonical configurations of F with respect to the clus- ters. The configurations essentially give a local represen- tation of F . We now show how to use the representation of F with configurations to determine, with local condi- tions, whether F is a feasible Steiner forest solution. Definition 4.5. With respect to a cluster C, a con- nected component is outgoing if it intersects ∂C. A configuration is outgoing if every part of πall inter- sects ∂C. Proposition 4.2. If F is a Steiner forest solution, then, with respect to a cluster C, for each active ver- tex u, the tree of F containing u is outgoing. Definition 4.6. Let C0 be a cluster with child clus- ters C1 and C2. Three configurations for C0, C1, C2 11 are demand-consistent if they are compatible, outgo- ing, and if the following condition holds in addition: For all demands {s, t} active for C1 and C2 but not 1 ∨ πall C0, terminals s and t are related by πall 2 . For example, in the example of Figure 7, the con- figurations are demand-consistent because terminal g is related to terminal g(cid:48): in πall 1 , g is connected to 2 , d is connected to g(cid:48). For an example d, and in πall where πall 0 comes into play, see Figure 8. 0 ∨ πall The following lemma establishes that a subgraph represented by its canonical configurations is a feasi- ble solution if and only if the configurations are con- sistent with one another. Lemma 4.3. A subgraph F is a Steiner tree solu- tion if and only if, for every cluster C0 with children C1, C2, the canonical configurations of F with respect to C0, C1 and C2 are demand-consistent. Now, suppose that for each cluster C, we restrict attention to a subset ΠC of the configurations of C. We call those configurations simple. Then the above setup leads to a dynamic program to find the shortest Steiner forest F such that for every cluster C, the canonical configuration of C for F belongs to ΠC. The dynamic program works as follows. For each cluster C0 in bottom-up order, if C0 is a single edge e, then the cost of a configuration is either 1 or 0 depending on whether e needs to be in. else, let C1 and C2 denote the two children of C0; for each configuration π0 ∈ ΠC0, cost(π0) := min(cost(π1) + cost(π2)), where the min is over π1 ∈ ΠC1 and π2 ∈ ΠC2 such that π0, π1, π2 are demand-consistent. runtime cost of that times dynamic the program is checking The of O(n(maxC ΠC)3), that three configurations are demand-consistent. Bateni et al. proposed a definition of ΠC such that maxC ΠC = npoly(1/), and proved that, under their definition, there exists a near-optimal forest such that for every C, the canonical configuration of C be- longs to ΠC. Here, building on the spanner prop- erty, we propose a different definition of ΠC, such C1 b g c d a h f e a b h f e C0 c d C2 g(cid:48) e(cid:48) f(cid:48) b(cid:48) a(cid:48) b(cid:48) a(cid:48) e(cid:48) f(cid:48) Figure 7: Compatible configurations. In the above example, assume that g is active for C1 and g(cid:48) is active for C2, but neither g nor g(cid:48) are active for C0. The dashed connections represent πout , the solid connections determine πin i , and the union of solid and dashed edges determine πall . i i s t C1 u v C2 C0 Figure 8: s and t are related by πall connected to t via πall 2 . 0 ∨ πall 1 ∨ πall 2 : s is connected to u via πall 1 , u is connected to v via πall 0 , and v is 12 that maxC ΠC = O((log log n)f ()). This gives us the improvement from an inefficient to an efficient approximation scheme. In a nutshell, here is the idea: if the optimal forest has several trees that come close to the same ver- tex v of ∂C, then we connect them with paths to transform them into a single tree; that simplifies the configuration. We charge the length of that path to the total length of edges in the neighborhood of v in ∂C. To make sure that we do not charge the same edges several times over, we contract edges that get charged. 4.3 Contractions in a branch decomposition For a graph G and a set S of vertices, SP (G, S) denotes the3 shortest-path forest rooted at S. For a number k, define SP (G, S, k) = {e ∈ SP (G, S) : e is in a path of length at most k starting at S}. That is, SP (G, S, η) is the shortest-path forest for vertices of G whose distance from ∂G is at most η. Let G be a graph with branch decomposition C. Fix a parameter α whose value, a function of  and of w, will be set later. We define a recursive algorithm that operates on the clusters of C. For each cluster C in bottom-up order, it computes a radius ρC, such that paths of length ρC are much shorter (by a factor of α) than the number of edges within distance ρC of ∂C. It then contracts all edges within distance ρC of ∂C. AC =(cid:83) def Contractα(C): Contractα(Ci) length(SP (C/AC, ∂C, ρ)) ≥ αρ} Ci child of C ρC := max{ρ : BC = SP (C/AC, ∂C, ρC) ∪ AC return BC What are the structural properties achieved by the contraction algorithm? First, the contracted graph C/BC has linear growth rate: Lemma length(SP (C/BC, ρ)) ≤ αρ. 4.4. For every ρ ≥ 0, length(SP (C/BC, ∂C, ρ)) Proof. Observe the following simple property of contractions: SP (G, S, η1 + η2) is the disjoint union and SP (G/SP (G, S, η1), S, η2). of SP (G, S, η1) Thus, = − length(SP (C/AC, ∂C, ρC length(SP (C/AC, ∂C, ρC)). By definition of ρC, SP (C/AC, ∂C, ρC) least αρC. the length of SP (C/AC, ∂C, ηC + ρ) is less than α(ηC + ρ). The lemma follows. By maximality of ρC, length total has ρ)) at + Second, the sum of all radii of contracted areas is small compared to the total length of G: C∈C ρC ≤ length(G)/α. Lemma 4.5. (cid:80) length(BC) − (cid:80) of BC, definition, Proof. By length(SP (C/AC, ∂C, ρC))/α. length(SP (C/AC, ∂C, ρC)) tion Ci child of C length(BCi). ming over clusters C ∈ C gives the lemma. By ρC ≤ defini- = Sum- What is the running time of the contraction algo- rithm? Let us explain in more detail how to compute ρC efficiently. Here, for each vertex, d[u] denotes the distance from ∂C to u: for i := 1, 2, 3, . . . , si := length({uv ∈ SP (C/AC, ∂C) : d[u] = i − 1, d[v] = i}) ρC := max{i : s1 + ··· + si ≥ α i} The total time for each invocation Contractα(C) is linear in the number of edges of C. By Lemma 4.1, C is a log-height branch-decomposition, so the total time for calling Contractα on the root cluster of a graph G of O(n) edges is O(n log n). 4.4 Regions covering partially contracted clusters 3For uniqueness, assume the edges of G are assigned distinct ID numbers, and define SP (G, S) to be the shortest-path forest in which ties are broken by ID number. Here is a high-level description of our method for find- ing regions for a cluster C. Fix a parameter β whose value, a function of  and of w, will be set later. 13 Denote by 2µC For each i = 1, 2,··· , µC, the minimum power of two greater than maxu∈active(C) dist(u, ∂C). define a set Li of regions of C/BC such that each region has diameter at most β2i, and together, the regions of Li cover SP (C/BC, 2i). It follows from Lemma 4.4 that a greedy algorithm produces such a covering, of size Li = O(α/β + ∂C). However, in order to get near-linear running time, we need an algorithm that is slightly more so- phisticated than greedy. In the rest of this subsection, we present the details of the algorithm. For each tree of SP (C/BC, µC), let v be a tree vertex that is on the boundary ∂C and let Tv denote the sequence of vertices encountered on an Euler tour of the tree. An i-region is a subpath of T C v of length at most β2i whose first vertex is at a distance at most 2i + β2i from ∂C in C/BC. In our algorithm, Li is a set of i-regions. For a vertex u of C, we use d[u] to denote the ∂C-to-u distance in C/BC. for i := 1, 2, . . . , µC, for each tree of SP (C/BC, µC), Li := ∅ root the tree at some vertex v ∈ ∂C construct an Euler tour Tv of the tree for i := µC, µC − 1, . . . , 1, : j ∈ {0, 1, 2, 3, . . .} and d[Tv[jβ2i]] ≤ (1 + β)2i} Sv,i := {jβ2i for each x ∈ Sv,i, Li := Li ∪ {subpath of Tv of length β2i truncated at Tv) starting at Tv[x]} Lemma 4.6. For each i = 1, 2,··· , µC, the regions of Li cover SP (C/BC, 2i). Lemma 4.7. For each i = 1, 2,··· , µC, 2α(1 + 2β)β−1 + ∂C. Proof. If a vertex u is in a subpath of Li, then it is at distance at most β2i from the starting point of the subpath, and so u ∈ SP (C/BC, (1 + 2β)2i). So, the Li ≤ 14 sum of lengths of the i-regions is at most the length of the Euler tours of SP (C/BC, (1 + 2β)2i), which is at most twice the number of edges in SP (C/BC, (1 + 2β)2i). By Lemma 4.4, SP (C/BC, (1 + 2β)2i) is at most α(1 + 2β)2i. Each i-region constructed from Tv has length exactly β2i, except possibly the last one. The lemma follows. The time for finding the covers is O(n log n). 4.5 Simple configurations Definition 4.7. Fix a cluster C with boundary ver- tices ∂C and, for each i = 1, 2,··· , µC, a covering Li of C/BC by i-regions. Given • an integer d ≤ ∂C; • d powers of 2 in the range [2µC /(2γ), 2µC γ is a parameter to be determined later; • a priority ordering over those d numbers, labelled ], where (2i1 , 2i2, . . . , 2id ) by order of priority; and • for each ij, a set of ij-regions Qj ⊆ Lij ; consider the subpartition of active(C), denoted P (i1, . . . , id,Q1, . . . ,Qd) , and defined by greedily set- ting the jth part to be Pj =(cid:0)active(C) ∩ Uncontract( (cid:91) Q(cid:1)) − j−1(cid:91) Q∈Qj P(cid:96), (cid:96)=1 where Uncontract takes as input vertices of C/BC and outputs the corresponding vertices of C. A configuration (πin, πout, πall) is simple iff πall = πin ∨ πout ∨ P (i1, . . . , id,Q1, . . . ,Qd) some (i1, . . . , id,Q1, . . . ,Qd). for To understand this definition intuitively, d should be interpreted as the number of outgoing trees. The d powers of 2 should be interpreted as the approximate "radii" of those trees -- maximum distance from ∂C to an active tree vertex. As in the algorithm of Bateni et al., the ordering should be interpreted as giving priority to trees whose minimal enclosing cluster is smaller. As in the algorithm of Bateni et al., the (uncontracted) ij-regions should be interpreted as a covering of the active vertices of the jth tree. For each cluster C define a table indexed by (i1, . . . , id,Q1, . . . ,Qd) Lemma 4.8. Taking α and β to be constant, the number of simple configurations is (log2 γ)f () for some function f of . The time to check demand- consistency is O(log n). We can finally state the main structural Theorem that is at the core of Theorem 2.3. Theorem 4.1. For any solution F , there exists a solution F (cid:48) ⊇ F such that for every clus- ter C, the canonical configuration of F (cid:48) with re- spect to C is simple, and whose length satisfies: length(F (cid:48)) ≤ length(F ) + 4β(2w − 1)(cid:0)1 + (3 log2 m + 1)/γ(cid:1) length(F ) + 2α−1(2w − 1) length(G). 4.6 Proof of Theorem 4.1 4.6.1 Defining F (cid:48) F (cid:48) is simply an extension obtained from F by adding some edges. First, given F and a cluster C, we define a partition of the form P (i1, . . . , id,Q1, . . . ,Qd). Q∈Qj Let d be the number of outgoing trees of F . Label these trees T1, . . . , Td in a particular order, such that the following property holds: if the minimal cluster including E(Tj) is a proper descendant of the mini- mal cluster including E(T(cid:96)), then j < (cid:96). We now de- j = (cid:100)log2 maxu∈V (Tj )∩active(C) dist(u, ∂C)(cid:101) and fine i(cid:48) ij = max{i(cid:48) j, µ − (cid:100)log2 γ(cid:101) − 1} and let Qj ⊆ Lj be Q covers the vertices of (Tj ∩ C)/BC. This defines the radii and sets of regions, hence also specifies the associated partition (P1, . . . , Pd) of active(C). a minimal set of regions such that (cid:83) The construction of F (cid:48) is in two steps. First we go from F to F1 by adding some edges, then we go from F1 to F (cid:48) by adding more edges. First step: starting from F1 := F , modify F1 by processing clusters C ∈ C in top-down order. Con- sider a cluster C. While there exists a j and an active vertex u that is in Pj but is not connected to Tj/BC in F1/BC, add to F1 a path of C/BC connecting u to Tj/BC. (This first step is similar to the construction in Bateni el al.) Second step: starting from F (cid:48) := F1, modify F (cid:48) by processing clusters C ∈ C in top-down order. Con- sider a cluster C. While there exists a pair of bound- ary vertices u, v ∈ ∂C such that u and v are not connected in (F (cid:48) ∩ C)/AC but can be connected by adding at most 2ρC edges of C/AC to F (cid:48), add those edges to F (cid:48). The result of this processing defines F (cid:48). 4.6.2 The canonical configuration of F (cid:48) is simple Lemma 4.9. After the first step of the construction, for every cluster C we have: all active vertices of Pj are connected to Tj in (F1 ∩ C)/BC. Lemma 4.10. After the second step of the construc- tion, for every cluster C we have: if two vertices of ∂C are connected in (F (cid:48) ∩ C)/BC then they are con- nected in F (cid:48) ∩ C. Proof. It suffices to show that, after those paths are added, if two vertices of ∂C are connected in (F (cid:48)∩C)/BC then they are connected in (F (cid:48)∩C)/AC. Suppose not, and let p be a ∂C-to-∂C path in (F (cid:48) ∩ C)/BC that is not a path in (F (cid:48) ∩ C)/AC, chosen so as to have a minimal number of edges. in C/AC, p starts at some vertex pstart of Then, SP (C/AC, u, ρC) and ends at some vertex pend of SP (C/AC, v, ρC). Concatenating p with a path from u to pstart at one end, and with a path from pend to v at the other end, gives a path from u to v in C/AC. The total number of edges thus added is at most 2ρC, so it would have been added during the processing. Lemma 4.11. For every cluster C, the canonical configuration of F (cid:48) is simple. Proof. It suffices to show for all j that all active ver- tices in Pj are connected by F (cid:48) to Tj. Let u(cid:48) be an active vertex in Pj. Either in F u(cid:48) belongs to Tj, in which case there is nothing to show, or u(cid:48) belongs to some tree T(cid:96) of F . Thus u(cid:48) is covered by some region of Qij and by some region of Qi(cid:96). The fact that u(cid:48) ∈ Pj indicates, by definition of Pj, that j must be less than (cid:96). Then, by the first step of the construction (Lemma 4.9), u(cid:48) get connected to Tj in (F1 ∩ C)/BC. Since T(cid:96) and Tj are both outgoing, in 15 F u(cid:48) is connected to some vertex u ∈ ∂C and Tj is connected to some vertex v ∈ ∂C. By transitivity u is connected to v in (F1∩ C)/BC. By the second step of the construction (Lemma 4.10), u is connected to v in F (cid:48) ∩ C. By transitivity again, u(cid:48) is connected to Tj in F (cid:48) ∩ C. 4.6.3 Length of F (cid:48) First we analyze the length increase when gong from F to F1. Since u ∈ Pj, there exists a region Q ∈ Qj such that u ∈ Q. By definition, Q covers at least one vertex w ∈ Tj. Thus the path added to connect u to Tj in (F (cid:48) ∩ C)/BC has length at most 2β2ij . If j, then the length is at most 4β length(Tj ∩ C). ij = i(cid:48) In this case, we charge the length of this path to Tj. Otherwise, it's at most 4β length(F ∩ C)/γ. In this case, we charge the length of this path to F ∩ C. We claim that each tree Tj of F is charged at most 2w − 1 times by paths added when ij = i(cid:48) j. Indeed, whenever Tj is charged, some other tree T(cid:96) of F is connected to Tj in (F (cid:48) ∩ C)/BC. After processing descendant clusters of C and adding connections be- tween boundary vertices, Tj is connected to T(cid:96) in F (cid:48) ∩ C. Since j < (cid:96), the minimal cluster Cj strictly enclosing Tj is either the same as for T(cid:96) or one of its descendant clusters. Either way, T(cid:96) must contain a vertex of ∂Cj, so there are only at most 2w − 1 such trees T(cid:96), so Tj is charged at most 2w− 1 times. Sum- ming over trees Tj, the total charge of those paths is at most 4β(2w − 1) length(F ). The length charged to F ∩ C is at most 4β(2w − 1)(3 log2 m + 1)/γ, since each edge is charged at most (2w − 1)(3 log2 m + 1) times. Second, we claim in the second step, going from F1 to F (cid:48), each cluster C is charged at most 2w− 1 times. Indeed, each charge corresponds to two boundary vertices of C being connected by a path, and after 2w− 1 paths are added, all of ∂C must be connected. Summing over clusters C, the total charge of those C∈C 2(2w− 1)ρC, which is at most 2(2w − 1) length(G)/α by Lemma 4.5. paths is at most(cid:80) This completes the proof of Theorem 4.1. 4.7 Proof of Theorem 2.3 Let γ = (3 log2 m + 1), β = /8(2w − 1), and α = 2−1c(2w−1) where c is the constant specified in Theorem 2.3. Lemma 4.8 implies that the DP takes time n log n(log log n)O(1), which is O(n log2 n). By Lemma 4.1, the quality of the output satisfies Theo- rem 2.3. References [1] A. Agrawal, Philip N. Klein, and R. Ravi. When trees collide: An approximation algorithm for the generalized Steiner problem on networks. SIAM Journal on Computing, 24(3):440 -- 456, 1995. [2] MohammadHossein Bateni, MohammadTaghi Hajiaghayi, and Daniel Marx. Approximation schemes for Steiner forest on planar graphs and graphs of bounded treewidth. In Proceedings of the Forty-Second Annual ACM Symposium on Theory of Computing (STOC'10), New York, NY, USA, 2010. ACM. to appear. [3] M. Bern and P. Plassmann. The Steiner problem with edge lengths 1 and 2. Information Process- ing Letters, 32:171 -- 176, 1989. [4] Glencora Borradaile, Claire Kenyon-Mathieu, and Philip N. Klein. A polynomial-time approx- imation scheme for Steiner tree in planar graphs. In Proceedings of the Eighteenth Annual ACM- SIAM Symposium on Discrete Algorithms, pages 1285 -- 1294, 2007. [5] Glencora Borradaile, Philip N. Klein, and Claire Mathieu. A polynomial-time approximation scheme for Euclidean Steiner forest. In Pro- ceedings of the 49th Annual IEEE Symposium on Foundations of Computer Science, 2008. [6] Glencora Borradaile, Philip N. Klein, and Claire Mathieu. A polynomial-time approximation scheme for steiner tree in planar graphs. ACM Transactions on Algorithms, 5, 2009. Special Is- sue on SODA 2007. [7] Gerth Stølting Brodal and Rolf Fagerberg. Dy- namic representation of sparse graphs. In Pro- ceedings of the 6th International Workshop on Algorithms and Data Structures, pages 342 -- 351, 1999. 16 [8] Erik D. Demaine, MohammadTaghi Hajiaghayi, and Kenichi Kawarabayashi. Algorithmic graph minor theory: decomposition, approximation, and coloring. In Proceedings of the 46th Annual IEEE Symposium on Foundations of Computer Science, pages 637 -- 646. IEEE Computer Soci- ety, 2005. [9] Erik D. Demaine, MohammadTaghi Hajiaghayi, and Bojan Mohar. Approximation algorithms via contraction decomposition. In Proceedings of the Eighteenth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 278 -- 287, 2007. [10] Elisabeth Gassner. The steiner forest prob- lem revisited. Journal of Discrete Algorithms, 8(2):154 -- 163, 2010. Selected papers from the 3rd Algorithms and Complexity in Durham Workshop ACiD 2007. [11] Michel Goemans and David P. Williamson. A general approximation technique for constrained forest problems. SIAM Journal on Computing, 24(2):296 -- 317, 1995. [12] Philip N. Klein. A data structure for bicate- gories, with application to speeding up an ap- proximation algorithm. Information Processing Letters, 52(6):303 -- 307, 1994. [13] Philip N. Klein. A linear-time approximation scheme for planar weighted TSP. In Proceedings of the Forty-Sixth Annual IEEE Symposium on Foundations of Computer Science, pages 647 -- 656, 2005. [14] Lukasz Kowalik. Fast 3-coloring triangle-free planar graphs. Algorithmica, 58(3):770 -- 789, 2010. [15] George Romero. Night of the living dead, 1968. [16] M. Thimm. On the approximability of the Steiner tree problem. In Mathematical Foun- dations of Computer Science, volume 2136 of Lecture Notes in Computer Science, pages 678 -- 689, 2001. 17
1907.01619
1
1907
2019-07-02T20:17:59
Learning from satisfying assignments under continuous distributions
[ "cs.DS", "cs.CC", "cs.LG" ]
What kinds of functions are learnable from their satisfying assignments? Motivated by this simple question, we extend the framework of De, Diakonikolas, and Servedio [DDS15], which studied the learnability of probability distributions over $\{0,1\}^n$ defined by the set of satisfying assignments to "low-complexity" Boolean functions, to Boolean-valued functions defined over continuous domains. In our learning scenario there is a known "background distribution" $\mathcal{D}$ over $\mathbb{R}^n$ (such as a known normal distribution or a known log-concave distribution) and the learner is given i.i.d. samples drawn from a target distribution $\mathcal{D}_f$, where $\mathcal{D}_f$ is $\mathcal{D}$ restricted to the satisfying assignments of an unknown low-complexity Boolean-valued function $f$. The problem is to learn an approximation $\mathcal{D}'$ of the target distribution $\mathcal{D}_f$ which has small error as measured in total variation distance. We give a range of efficient algorithms and hardness results for this problem, focusing on the case when $f$ is a low-degree polynomial threshold function (PTF). When the background distribution $\mathcal{D}$ is log-concave, we show that this learning problem is efficiently solvable for degree-1 PTFs (i.e.,~linear threshold functions) but not for degree-2 PTFs. In contrast, when $\mathcal{D}$ is a normal distribution, we show that this learning problem is efficiently solvable for degree-2 PTFs but not for degree-4 PTFs. Our hardness results rely on standard assumptions about secure signature schemes.
cs.DS
cs
Learning from satisfying assignments under continuous distributions Cl´ement L. Canonne∗ Stanford University Anindya De† University of Pennsylvania Rocco A. Servedio‡ Columbia University July 4, 2019 Abstract What kinds of functions are learnable from their satisfying assignments? Motivated by this simple question, we extend the framework of [DDS15a], which studied the learnability of probability distributions over {0, 1}n defined by the set of satisfying assignments to "low- complexity" Boolean functions, to Boolean-valued functions defined over continuous domains. In our learning scenario there is a known "background distribution" D over Rn (such as a known normal distribution or a known log-concave distribution) and the learner is given i.i.d. samples drawn from a target distribution Df , where Df is D restricted to the satisfying assignments of an unknown low-complexity Boolean-valued function f . The problem is to learn an approximation D′ of the target distribution Df which has small error as measured in total variation distance. We give a range of efficient algorithms and hardness results for this problem, focusing on the case when f is a low-degree polynomial threshold function (PTF). When the background distribution D is log-concave, we show that this learning problem is efficiently solvable for degree-1 PTFs (i.e., linear threshold functions) but not for degree-2 PTFs. In contrast, when D is a normal distribution, we show that this learning problem is efficiently solvable for degree-2 PTFs but not for degree-4 PTFs. Our hardness results rely on standard assumptions about secure signature schemes. 9 1 0 2 l u J 2 ] S D . s c [ 1 v 9 1 6 1 0 . 7 0 9 1 : v i X r a ∗Supported by a Motwani fellowship. Some of this work was carried out while visiting Northwestern University. †Supported by NSF CCF-1926872 (transferred from CCF-1814706). Most of the work done while the author was at Northwestern University. ‡Supported in part by NSF awards CCF-1814873 and CCF-1563155. 1 1 Introduction Over the past decade or so there has been an explosion of research effort aimed at establishing rig- orous results about the learnability of various classes of probability distributions. A natural goal in this line of work is to understand how the complexity of learning an unknown high-dimensional dis- tribution scales with the complexity of the distribution being learned. This immediately leads to a question of how to measure the computational complexity of a high-dimensional distribution; need- less to say, a range of different approaches are possible here. In early work, Kearns et al. [KMR+94] proposed a model in which the complexity of a distribution D over {0, 1}n is measured in terms of the circuit complexity of an m-input, n-output Boolean circuit C : {0, 1}m → {0, 1}n which is such that D is the output distribution when a uniform random string from {0, 1}m is given as input to C (i.e., D = C(U )). This is a natural approach, but as Kearns et al. showed, even depth-1 circuits of bounded fan-in OR gates lead to distributions D which are hard to learn in this model. Moreover, it is not clear how to extend the [KMR+94] framework to distributions over the continuous domain Rn as opposed to the Boolean cube {0, 1}n. More recently [DDS15a] took a different approach by considering "low-complexity" distributions Uf over {0, 1}n which are uniform over the set of satisfying assignments of a "low-complexity" Boolean function f : {0, 1}n → {−1, 1}. They gave a range of algorithms and hardness results for learning distributions Uf of this sort, where the unknown low-complexity Boolean function is assumed to be a linear threshold function, a degree-2 polynomial threshold function, a DNF formula, a monotone width-2 CNF, and so on. The main positive results of [DDS15a] showed that if f is a linear threshold function or a DNF formula, then the distribution Uf is learnable to total variation distance ε by an efficient algorithm (in time poly(n, 1/ε) for f a linear threshold function, and in time nO(log(n/ε)) for f a poly(n)-term DNF formula). [DDS15a] also established a range of hardness results showing that these positive results are close to the limit of what can be achieved by efficient algorithms in their model. They showed that under known constructions of secure cryptographic signature schemes, degree-2 polynomial threshold functions over {0, 1}n already give rise to distributions which cannot be learned in sub-exponential time. (The same is true for distributions arising from satisfying assignments of monotone width-2 CNF formulas.) This work: Learning continuous distributions from satisfying assignments One attrac- tive feature of the [DDS15a] framework is that it can be straightforwardly extended to learning low-complexity distributions over continuous domains. Given a known "background distribution" D (analogous to the uniform distribution over {0, 1}n) such as a normal distribution or a log-concave distribution over Rn, one can naturally consider the problem of learning the distribution Df in- duced by restricting D to the satisfying assignments of an unknown low-complexity Boolean-valued function f : Rn → {0, 1}. It is particularly natural in this setting to take f to be a low-degree polynomial threshold function (PTF), as such functions (unlike, say, DNF or CNF formulas) can very naturally be viewed as functions over the entire domain Rn. (Recall that a degree-d PTF over Rn is a function f : Rn → {−1, 1} defined by f (x) = sign(p(x)) where p(x1, . . . , xn) is a degree-d real polynomial.) With this motivation, and the additional motivating hope of establishing efficient learnability of distributions of satisfying assignments over Rn whose discrete analogues over {0, 1}n do not have efficient learning algorithms, in this paper we consider the aforementioned extension of the [DDS15a] framework to learning continuous distributions of satisfying assignments. We define our learning 1 framework, and describe our results in this framework, below. 1.1 The learning framework We now introduce our learning model in more detail but still at an informal level; see Section 2 for a detailed description of the model. Similar to [DDS15a], a learning problem in our framework is defined by a class C of Boolean-valued functions from Rn to {−1, 1}. In our setting an instance of the learning problem is defined by a choice of a function f ∈ C, which is unknown to the learning algorithm, and a background distribution D, which is provided to the learning algorithm. (We ex- plain in detail just what this means in Section 2; here we note that the distribution D is analogous to the uniform distribution over {0, 1}n, which is the background distribution in [DDS15a] and is certainly "known" to any learning algorithm.) The learning algorithm has access to i.i.d. sam- ples drawn from Df , which is the distribution D restricted to the set of satisfying assignments { x ∈ Rn : f (x) = 1 } of f . The learner's task is to output a hypothesis distribution D′ (we will amplify on precisely what this means in the next section) which is such that the total variation distance dTV(Df ,D′) is at most ε; a successful learning algorithm is one which does this, with high probability over its random samples and any internal randomness, for any f ∈ C. We say that such an algorithm is a distribution learning algorithm for class C with respect to background distribution D. 1.2 Our results The above framework is quite general; the results of [DDS15a] fall into this framework by taking the background distribution D to be the uniform distribution over {0, 1}n. It is not difficult to see that if the distribution D is totally unrestricted, then learning is intractable in this framework even for simple classes of Boolean functions such as linear threshold functions(see Appendix A). Thus, in this paper we restrict our attention to two different types of background distributions D: (i) log- concave distributions over Rn, and (ii) normal distributions over Rn. (We recall that a distribution D over Rn is log-concave if its density function p satisfies p = exp(φ) where φ : R → [−∞,∞) is a concave function.) We further restrict our attention to the function class C = PTFn d , the class of polynomial threshold functions over Rn of degree at most d, where d is some fixed small constant. Log-concave distributions. Our first positive result is an efficient distribution learning algorithm for linear threshold functions (i.e., PTFs of degree 1) with respect to any log-concave background distribution: Theorem 1 (Informal statement; see Theorem 5 in Section 2 for detailed statement). There is an algorithm A, running in time poly(n, 1/ε), that is a distribution learning algorithm for the class LTF of n-variable linear threshold functions with respect to any log-concave background distribution D over Rn. We complement this positive result with a negative result for degree-2 PTFs, showing that the above is essentially best possible for log-concave background distributions: Theorem 2. Under known constructions of secure signature schemes, there is no subexponential- time algorithm A for learning the class PTFn 2 of n-variable degree-two polynomial threshold functions with respect to every log-concave background distribution D. 2 Normal distributions. Turning next to normal distributions, our first positive result is an efficient distribution learning algorithm for degree-two polynomial threshold functions with respect to any normal distribution: Theorem 3 (Informal statement; see Theorem 6 in Section 2 for detailed statement). There is an algorithm A, running in time poly(n, 1/ε), that is a distribution learning algorithm for the class PTFn 2 of n-variable degree-two polynomial threshold functions with respect to any normal background distribution D over Rn. We complement this positive result with a negative result for degree-4 PTFs: Theorem 4. Under known constructions of secure signature schemes, there is no subexponential- time algorithm A for learning the class PTFn 4 of n-variable degree-four polynomial threshold func- tions with respect to the standard normal distribution N (0, 1)n. Discussion. Theorems 1 and 2 align closely with the positive and negative results established in [DDS15a] in the discrete setting where the background distribution D is simply the uniform distribution U over {0, 1}n. Recall that in [DDS15a] it is shown that there is an efficient distribu- tion learning algorithm for the class of linear threshold functions with respect to the background distribution U , but there is no such efficient distribution learning algorithm for degree-2 PTFs with respect to the background distribution U . In contrast, Theorem 3 shows that normal distributions are "easier" background distributions than uniform or arbitrary log-concave distributions, as satis- fying assignments of degree-2 PTFs are efficiently learnable for normal background distributions. But there is a limit to the power afforded by normal background distributions, as Theorem 4 shows that already degree-4 PTFs are hard to learn under normal background distributions. 1.3 Related work A recent line of work which focuses on learning high-dimensional normal distributions from trun- cated samples [DGTZ18, KTZ19] has a somewhat similar flavor to ours: in this setting, the under- lying distribution is an unknown multivariate normal D = N (µ, Σ), and observed samples come from Df , where f is the indicator function of an arbitrary truncation set S ⊆ Rn. The goal is to learn the parameters µ and Σ of the true distribution (or, equivalently, to learn D). Daskalakis, Gouleakis, Tzamos, and Zampetakis [DGTZ18] gave an efficient algorithm for this task when the truncation set S is known. An incomparable result of Kontonis, Tzamos, and Zampetakis [KTZ19] gives an efficient algorithm to recover µ and Σ even when S is unknown; however, [KTZ19] require S to have bounded surface area (see [KOS08] for background on this notion) and, more importantly, the covariance matrix Σ is required to be diagonal. In contrast, in our setting the parameters µ and Σ are known to the algorithm; the function f is assumed to be an unknown LTF or degree-2 PTF (for our positive results); and the goal is to learn the truncated distribution Df . One important difference between our results and those of [DGTZ18, KTZ19] is that our algorithm is efficient even when the truncation set S (i.e., the set of satisfying assignments of the unknown LTF or PTF) has inverse exponential density in the Gaussian space; indeed, achieving this is the most challenging aspect of our result. In contrast, in the setting of [DGTZ18, KTZ19], even achieving a sample-efficient algorithm requires that the truncation set S has at least an inverse poly(n) density. Further, for a computationally efficient algorithm, [KTZ19] requires that the truncation set has a constant density in the Gaussian space. 3 Finally, another work which is related to the current paper is that of [AGR13], which gives an efficient algorithm for learning an n-dimensional simplex when the algorithm is given uniformly random samples from (the uniform distribution on) the simplex. Recall that a simplex in Rn is the same as the intersection of exactly n + 1 halfspaces along with the requirement that the intersection is a bounded set. Their result and tools seem quite different from ours (as their techniques crucially rely on a reduction to ICA). 1.4 Our upper bound techniques At the highest level our approach follows the general method for learning from satisfying assign- ments that was given in [DDS15a], though as described later there are many technical issues and obstacles that are specific to this work. [DDS15a] developed a general framework in which, very roughly, if one is given a number of different types of algorithms for a class C of functions from {0, 1}n to {0, 1}, then one obtains a distribution learning algorithm for C with respect to the background distribution U , the uniform distribution over the Boolean hypercube {0, 1}n. The re- quired algorithms are specifically (i) an approximate uniform generation algorithm for C, (ii) an approximate counting algorithm for C, (iii) a Statistical Query learning algorithm for C, and (iv) a "densifier" for C, explained below. (See Theorem 3.1 of [DDS15a] for a precise statement of the original framework.) We note that approximate uniform generation, approximate counting, and statistical query learning are of course well-studied and standard notions, but the notion of a "densifier" was new to [DDS15a] and a significant amount of the technical work in that paper came in developing densifiers for linear threshold functions and DNF formulas. As our starting point, we observe that the algorithmic framework of [DDS15a] can be straightfor- wardly extended to non-uniform background distributions D by making some natural modifications. In particular, 1. In place of an approximate uniform generation algorithm (which outputs approximately uni- form satisfying assignments of a function f ∈ C) one needs the natural analogue for distribu- tion D, namely a procedure for approximately sampling from Df . 2. In place of an approximate counting algorithm for C (which outputs an approximation of (cid:12)(cid:12)f−1(1)(cid:12)(cid:12) /2n, where f : {0, 1}n → {0, 1} belongs to C), one needs a procedure for approximate integration of D over the domain f−1(1). 3. We also need a densifier with respect to D, which is a natural extension of the densifier notion from [DDS15a]. Roughly speaking, a densifier is an algorithm which is given random positive examples of f (drawn according to D restricted to f−1(1)) and prunes the entire domain Rn down to a set S which (essentially) contains all of f−1(1) and which is such that f−1(1) is "dense" in S under distribution D. (The fourth ingredient, a Statistical Query algorithm, is unchanged from [DDS15a] to the present work, since even the earlier work needed Statistical Query learning with respect to various non-uniform distributions.) In Section 3 we give a precise statement of the extension of [DDS15a]'s Theorem 3.1, Theorem 12, which we will use to obtain our results. In the rest of this subsection we give an overview of how each of the above three ingredients -- approximate sampling, approximate integration, and densification, all with respect to D -- are achieved for each of our two positive results (learning linear threshold functions with respect to arbitrary log-concave distributions, and learning 4 degree-2 PTFs with respect to the normal distribution). We begin with the simpler scenario of linear threshold functions. Learning LTFs with respect to log-concave distributions. The key insight here is that if D is a log-concave distribution and f is any LTF, then since f−1(1) is a convex set in Rn, the distribution Df is again a log-concave distribution. Our approach leverages this simple observation using known results, due to [LV06], for approximate sampling and approximate integration of log- concave distributions. (We note that significant work is required to align these known results with our setting; see Section 3.1, where Lemma 3.1 formally establishes the approximate sampling and approximate integration results that we require.) For the densifier, at a high level our approach is similar to the construction of a densifier for linear threshold functions in [DDS15a] where the background distribution is uniform over {0, 1}n. Like [DDS15a], we show how an efficient online mistake-bound algorithm for linear threshold func- tions can be leveraged to obtain the desired densifier, now with respect to the log-concave back- ground distribution D; however, subtleties arise in our current setting which were not present in [DDS15a] since we are now working in a continuous rather than discrete setting. In particular, online algorithms for learning LTFs with a finite mistake bound do not exist over continuous do- mains. To circumvent this issue, we use anticoncentration properties of log-concave distributions and the fact that the boundary of f−1(1) is a very "well-structured" set (it is simply a hyperplane in Rn) to give an analysis in Section 3.2 showing that, after suitable discretization of the domain, one can apply the discrete-setting mistake-bound algorithms without compromising the required guarantees. Intuitively, this is because a suitably fine discretization only "flips the label" of a tiny fraction of points. Learning degree-2 PTFs with respect to normal distributions. Conceptually, the densifi- cation step for degree-2 PTFs and normal distributions can be handled in roughly the same way as the densification step for the LTF scenario described above. (There are some differences in the technical arguments which show that online mistake-bound learning algorithms can be success- fully used in the discretized version of the degree-2 PTF setting. In this setting the boundary of f−1(1) is not simply a hyperplane, so now we must rely on results of Carbery and Wright [CW01] which establish anticoncentration of quadratic polynomials in Gaussian random variables; details are in Section 4.1.) However, new challenges arise in obtaining the required approximate sampling and approximate integration algorithms. The central obstacle is that for f a degree-2 PTF over Rn, the set f−1(1) can be non-convex; this means that the resulting restricted normal distribution Nf need not be log-concave, so the known tools for working with log-concave distributions, such as [LV06], are no longer at our disposal. We circumvent this obstacle through a careful approach which heavily exploits the degree-2 polynomial structure of f .1 We first discuss the approximate integration/counting problem. Via a change of basis, we convert a general degree-2 polynomial to a "decoupled" degree-2 multivariate polynomial, which is a sum of n univariate quadratic polynomials over distinct variables, of the form nXi=1 λi(xi − µi)2 + c. This change of basis does not change the underlying geometry of the problem, but it enables us to reframe the counting/integration problem as the problem of estimating the probability that a 1This should not be a surprise, recalling our negative results for degree-4 polynomial threshold functions. 5 random Gaussian G = (G1, . . . , Gn) satisfies a linear inequality nXi=1 λi(Gi − µi)2 ≥ C. Crucially, the above polynomial is a sum of independent random variables λi(Gi − µi)2. We solve this problem by adapting a FPTAS, due to Li and Shi [LS14], for multiplicatively approximating the probability that a sum of independent random variables exceeds a threshold value. The results of [LS14] are for discrete random variables, whereas our setting is continuous; in our adaptation we use anticoncentration results due to Carbery and Wright [CW01] in order to establish that the rounding we perform (so that the [LS14] results can be used) only incurs an acceptably low amount of error. Details are given in Section 4.2. It remains only to give an efficient routine for approximate sampling from the normal distri- bution subject to a degree-2 PTF constraint. This is done in Section 4.3, where we extend the usual reduction from approximate counting to approximate sampling and leverage our approxi- mate counting result described in the previous paragraph; an extension is required because the usual reduction is for counting and sampling problems over the domain {0, 1}n, whereas now the relevant domain is Rn. We show that it suffices to discretize Rn to an exponentially fine grid, and augment the usual reduction with binary search in each coordinate (which can be carried out efficiently even over an exponential-size domain). We note that, prior to this work, no (provably) efficient algorithm was known for sampling from a high-dimensional normal subject to quadratic constraints, a task used as a subroutine in many applied settings (see, e.g., [EM07, PP14], and references therein). 1.5 Our lower bound techniques Our computational hardness results are obtained via an extension of the approach that was given in [DDS15a]. This approach is based on a connection between secure cryptographic signature schemes with certain properties and learning from satisfying assignments. The crux of the idea is very simple when the background distribution is uniform over {0, 1}n (as in [DDS15a]): if we view Uf as the uniform distribution over signed messages, an algorithm which can construct a sampler for Uf given access to independent draws from it corresponds to an algorithm which, given a batch of signed messages, can generate a new signed message, and this violates the security of a signature scheme. Via reductions, this intuition is leveraged to show that assuming the existence of suitably secure signature schemes, no efficient algorithm can learn various types of functions given access only to random satisfying assignments. In the current paper we extend this connection to our setting of more general background distributions other than uniform on {0, 1}n. The heart of our lower bound proof for degree-2 PTFs under log-concave distributions is a reduction from Subset-Sum. By designing a suitable degree-2 PTF based on a subset sum instance, we are able to establish hardness even when the background distribution is a very simple and well-structured log-concave distribution, namely the uniform distribution on the solid cube [0, 1]n; this gives Theorem 2.2 2Some care is required to ensure that our lower bound construction complies with a natural "reasonableness" requirement we put on learning problems in our framework, which is that the set of all satisfying assignments f −1(1) has at least an inverse exponential amount of probability mass under the background distribution -- see the discussion in Section 2 -- but this is essentially a technical issue. 6 Since the background log-concave distribution for our degree-2 PTF hardness result is uniform on [0, 1]n, which is very "tame," it is natural to wonder whether this hardness result can be extended to the normal distribution N (0, 1)n as the background distribution. However, this natural intuition is directly contradicted by our main algorithmic result, Theorem 3, which says that degree-2 PTFs are easy to learn under the normal background distribution! Indeed, it turns out that the bounded support of [0, 1]n plays an essential role in letting the reduction go through. We show that by work- ing with a suitable degree-four polynomial, it is possible to essentially enforce the bounded support requirement even when the background distribution is N (0, 1)n, and we thereby obtain computa- tional hardness for learning degree-four PTFs with respect to the normal background distribution. The learnability of degree-three PTFs with respect to the normal background distribution is an interesting open problem for future work. 2 Preliminaries Detailed description of our model. We now explain in detail the sense in which, as stated in Section 1.1, the background distribution D is "provided to" the learning algorithm. For the case where D is a normal distribution, this simply means that the learning algorithm is given, as part of its input, the mean µ ∈ Rn and covariance matrix Σ ∈ Rn×n defining the normal distribution. In fact, since the class of low-degree polynomial threshold functions is closed under affine transformations of the input space Rn (i.e., if f (x) is a PTF of degree d, then f (Ax+b) is also a PTF of degree d for every n × n matrix A and every vector b ∈ Rn), for our normal distribution results we may simply assume that the background distribution is the standard N (0, 1)n distribu- tion. (If the background normal distribution is not full dimensional, then an affine transformation converts it to N (0, 1)k for some k < n, and our algorithms can simply be carried out over Rk rather than Rn.) Thus we subsequently assume, without loss of generality for our normal distribution results, that the given normal background distribution is simply N (0, 1)n. For the case when D is a log-concave distribution, the learning algorithm is provided with an evaluation oracle for a function µ which is proportional to the probability density function µ : Rn → [0, 1] of D. We will assume that µ satisfies three conditions, where C > 1 is some sufficiently large absolute constant: C1: all but at most 2−Cn of the probability mass is concentrated in the L2 ball of radius nC; C2: kµk∞ ≤ 2n and kµk∞ ≤ 2nC C3: Let µT (x) be obtained by truncating µ(x) at nC bits after the binary point. Then ; Z 1 2 µ(x) ≤Z µT (x) ≤Z µ(x)dx . The first two conditions restrict to log-concave distributions that are at least mildly concen- trated, and not too "peaked," while the third condition says that truncating µ up to polynomial precision provides a good approximation (in a certain weak average sense). We note that these three conditions are quite benign and do not significantly restrict the scope of our results. In par- ticular, they are satisfied by any uniform distribution over a convex set of reasonable size (as well as by the distributions used in our hardness results). We refer to a log-concave distribution that satisfies the above conditions C1 through C3 as being well-behaved. 7 Next we specify what is exactly meant for the learning algorithm to "output a hypothesis distribution." What we require is that the learning algorithm output a description of a polynomial- time procedure which has query access to µ (equivalently, it outputs a polynomial-size circuit with oracle gates for µ) which, on input uniformly random bits, outputs a draw from a distribution D′ that is ε-close to Df . Detailed theorem statements. Before giving detailed theorem statements, we briefly discuss some numerical issues that arise since we are considering distributions over the continuous space Rn. If the target function f : Rn → {−1, 1} and background distribution D over Rn are such that f−1(1) has extremely low mass under D -- say, Prx←D[f (x) = 1] = 2−nω(1) -- then a super-polynomial number of bits may be required even to differentiate any point in f−1(1) from points in f−1(−1). To avoid such extreme scenarios, we assume for our positive results that the target function f has a "reasonable" (at least inverse exponential) fraction of satisfying assignments under the background distribution. Thus, a detailed statements of our positive results is as follows: Theorem 5 (Detailed statement of Theorem 1: algorithm for LTFs under log-concave background distribution). There is an algorithm A with the following property: Let D be a well-behaved log- concave distribution provided to A as described above, and let f be a unknown LTF over Rn such that Prx←D[f (x) = 1] ≥ 2−n. Given access to i.i.d. samples from Df = (D restricted to f−1(1)), for ε = 1/2o(n) algorithm A runs in poly(n, 1/ε) time and with high probability outputs a hypothesis distribution D′ such that dTV(D′,Df ) ≤ ε. Theorem 6 (Detailed statement of Theorem 3: algorithm for degree-2 PTFs under normal back- ground distribution). There is an algorithm A with the following property: Let f be a unknown degree-two PTF over Rn such that Prx←N (0,1)n[f (x) = 1] ≥ 2−n. Given access to i.i.d. samples from Nf = (N (0, 1)n restricted to f−1(1)), for ε = 1/2o(n) algorithm A runs in poly(n, 1/ε) time and with high probability outputs a hypothesis distribution D′ such that dTV(D′,Nf ) ≤ ε. Remark 7. We remark that our hardness results as well as our algorithms will adhere to this "reasonableness" condition: in our constructions establishing computational hardness, the learning problems which we show to be hard are all ones in which the target function f and background distribution D are such that Prx←D[f (x) = 1] is at least 2−poly(n). 2.1 The framework of [DDS15a] and the ingredients it requires We now recall the algorithmic components of [DDS15a] which, suitably generalized to the contin- uous case, will prove instrumental to our upper bounds. In order to do so, we first must introduce some of the notions they require, starting with that of a densifier : Definition 8. Fix a function γ(n, 1/ε, 1/δ) taking values in (0, 1] and two classes C,C′ of n-variate Boolean functions from Rn to {−1, 1}. An algorithm A(C,C′) is said to be a γ-densifier for C using C′ under D if it has the following behavior: For every ε, δ ∈ (0, 1], every 1/2n ≤ bp ≤ 1, and every f ∈ C, given as input ε, δ,bp and a set of independent samples from Df , the following If p ≤ bp < (1 + ε)p, then with probability at least 1 − δ holds. Let p := Prx←D [ f (x) = 1 ]. the algorithm outputs a function g ∈ C′ such that: (a) Prx←Df [ g(x) = 1 ] ≥ 1 − ε, and (b) Prx←Dg [ f (x) = 1 ] ≥ γ(n, 1/ε, 1/δ). den The intuition behind this definition is that by (a) almost all of the satisfying assignments of f are also satisfying assignments of g, and by (b) the satisfying assignments of f are "dense" in 8 g−1(1) (at least a γ fraction under D). We will sometimes make explicit the parameters of the definition, and write that such an algorithm is an (ε, γ, δ)-densifier. The second notion we need is that of the statistical query (SQ) learning model from [Kea98], a restriction of the PAC learning model which only allows the learning algorithm to obtain, via a statistical query oracle STAT(f,D), estimates of the form Ex←D[χ(x, f (x))] to within an additive τ , where χ : Rn × {−1, 1} → {−1, 1} and τ ∈ (0, 1] constitute the query (χ, τ ), and f ∈ C is the unknown concept. As in the PAC model, the algorithm must output a hypothesis g such that Prx←D [ f (x) 6= g(x) ] ≤ ε with probability at least 1 − δ; such an algorithm, referred to as an (ε, δ)-SQ learning algorithm for C, is said to be efficient if it makes a number of queries polynomial in n, 1/ε, and log(1/δ), all with accuracy τ = poly(1/n, ε). We will also need the standard definitions of approximate counting and approximate generation, slightly adapted to our setting in which the relevant background distribution is some other distri- bution than the uniform distribution over {0, 1}n. Since it is more straightforward, we begin with the notion of approximate counting that we will require: Definition 9. Let C be a class of n-variate Boolean functions mapping Rn to {−1, 1}. A randomized algorithm A(C) count is said to be an efficient approximate counting algorithm for C under D if, for any ε, δ ∈ (0, 1] and any f ∈ C, on input ε, δ and f ∈ C and given oracle access to D, it runs in time poly(n, 1/ε, log(1/δ)) and with probability at least 1 − δ outputs a value bp such that Taking D to be the uniform distribution over {0, 1}n, this corresponds precisely to the usual There is an issue which arises in defining approximate generation algorithms in our setting Prx←D [ f (x) = 1 ] ≤bp ≤ (1 + ε) Prx←D [ f (x) = 1 ] . notion of approximate counting which was used in [DDS15a]. 1 1 + ε 1 1 + εDf (x) ≤ bDf,ε(x) ≤ (1 + ε)Df (x) which we now discuss (and explain how to handle). We begin with the following definition: Definition 10. Let C be a class of n-variate Boolean functions mapping Rn to {−1, 1}. A random- ized algorithm A(C) gen is said to be an efficient strong approximate generation algorithm for C under D if, for any ε ∈ (0, 1] and f ∈ C, there is a distribution bDf,ε supported on f−1(1) with for every x ∈ f−1(1), such that for any δ ∈ (0, 1], on input ε, δ, and f ∈ C, and given oracle access to D, the algorithm runs in time poly(n, 1/ε, log(1/δ)) and either outputs a point x ∈ f−1(1) exactly distributed according to bDf,ε, or outputs ⊥. Moreover, the probability that it outputs ⊥ is at most δ. Taking the distribution D in Theorem 10 to be the uniform distribution over {−1, 1}n, we recover precisely the usual notion of approximate generation which was used in [DDS15a]. While this compatibility with [DDS15a] is an attractive feature, it is not difficult to see that the requirement that bDf,ε put approximately the right amount of weight (in a multiplicative sense) on every x ∈ f−1(1) is overly demanding. If Df puts only an extremely small amount of weight on a point x, it may be impossible for an efficient algorithm to very precisely match this extremely small amount of weight; moreover, since the weight on x is so tiny, as long as a purported approximate generation algorithm puts only a tiny amount of weight on x, it should not matter whether or not the tiny amount it puts is multiplicatively accurate. We thus introduce the following relaxed notion of approximate generation, which we call "weak approximate generation": 9 Definition 11. Let C be a class of n-variate Boolean functions mapping Rn to {−1, 1}. A random- ized algorithm A(C) gen is said to be an efficient weak approximate generation algorithm for C under D if, for any τ ∈ (0, 1] and any f ∈ C, there is a distribution D′f,τ with dTV(Df ,D′f,τ ) ≤ τ such that on input τ , and f ∈ C, and given oracle access to D, the algorithm runs in time poly(n, log(1/τ )) and outputs a point x ∈ f−1(1) distributed according to D′f,τ . 2.2 The algorithmic result we use With the above notions in hand, we are ready to state the algorithmic result that we will rely on: Theorem 12 (based on [DDS15a, Theorem 3.1]). Let C,C′ be classes of n-variate Boolean functions mapping Rn to {−1, 1}. Suppose that den is an (ε, γ, δ)-densifier for C using C′ under D running in time Tden(n, 1/ε, 1/δ). • A(C,C′) • A(C′) count is an (ε, δ)-approximate counting algorithm for C′ under D running in time Tcount(n, 1/ε, 1/δ). • A(C′) gen is an (ε, δ)-weak approximate generation algorithm for C′ under D running in time Tgen(n, 1/ε, 1/δ).3 SQ is an (ε, δ)-SQ learning algorithm for C such that: A(C) • A(C) SQ runs in time t1(n, 1/ε, 1/δ), t2(n) is the maximum time needed to evaluate any query provided to STAT, and τ (n, 1/ε) is the minimum value of the tolerance parameter ever provided to STAT in the course of A(C) SQ's execution. Then there exists a distribution learning algorithm AC for C under D. The running time of AC is polynomial in Tden(n, 1/ε, 1/δ), Tcount(n, 1/ε, 1/δ), Tgen(n, 1/ε, 1/δ), t1(n, 1/ε, 1/δ), t2(n), and 1/τ (n, 1/ε), provided that Tden(·), Tcount(·), Tgen(·), t1(·), t2(·), 1/τ (·) are polynomial in their param- eters. The above statement is almost verbatim from [DDS15a], with the difference that (i) we apply it to our setting of continuous distributions and Boolean functions over Rn, and (ii) the third bullet uses the notion of a weak approximate generation algorithm rather than a strong one. Theorem 12 can be established in two stages. First, it is straightforward to check by inspection of the proof of [DDS15a] that the proof of their Theorem 3.1 goes through essentially unchanged to establish the variant of the above theorem in which we substitute "strong" for "weak" in the third bullet. (We note that the proof of Theorem 3.1 of [DDS15a] requires a multiplicatively accurate evaluation oracle for each hypothesis distribution constructed in the course of the algorithm's execution, and that such oracles can be obtained in our setting since by our assumptions we have an approximate counting algorithm for the class C′.) For the second stage, we claim that the variant of the above theorem with "strong" in place of "weak" easily implies Theorem 12 as stated above (with "weak" in the third bullet). To see this, observe that if s draws are made from a distribution D′f,τ which gen succeed as long as f ∈ C′ satisfies Prx←D[f (x) = 1] ≥ 3Actually, the theorem only requires that A(C′) count and A(C′) 2−poly(n). 10 has variation distance at most τ from Df , then the variation distance between the distribution of that sample of s draws and the corresponding distribution (over samples of s draws) from Df is at most sτ. Hence any procedure A (such as the distribution learning algorithm AC) which makes s calls to a strong approximate generation algorithm can instead be run using a weak approximate generation algorithm, and if the τ -parameter of the weak approximate generation algorithm is set to be δ/s, this will decrease the success probability of the procedure A by at most an additive δ. Miscellaneous notation and terminology. We write B1(z, r) to denote the ℓ1-ball of radius r in Rn around a point z, and write B2(z, r) to denote the ℓ2-ball. 3 A distribution learning algorithm for LTFs with respect to log- concave background distributions 3.1 Sampling and integration over log-concave distributions The ability to efficiently sample from log-concave distributions, and to approximate various quan- tities such as the normalizing factor of a log-concave function, is crucial for our upper bound result Theorem 5. As mentioned in the introduction, there is an extensive literature on these prob- lems. In this subsection we state and explain the specific results we shall rely on, and prove that our assumptions imply that we can indeed use them in our setting. In particular, the key take-away result from this subsection is the following crucial lemma: Lemma 3.1. Let µ : Rn → [0,∞) be a log-concave measure which is assumed to satisfy condi- tions (C1), (C2) and (C3) from Section 2, and let µ := µ/kµk1 be the corresponding probability distribution. There is an algorithm with the following performance guarantee: Given access to an evaluation oracle for µ, a halfspace g : Rn → {−1, 1}, a confidence parameter δ and an error pa- rameter ε > 1/2o(n) such that Prx←µ[g(x) = 1] ≥ 2−n, it runs in time poly(n, 1/ε, log(1/δ)) and with probability 1 − δ outputs a number bp such that (1 − ε) · Prx←µ[g(x) = 1] ≤bp ≤ (1 + ε) · Prx←µ[g(x) = 1]. Let µg denote the distribution µ conditioned on g(x) = 1. Under the above assumptions, there is also a randomized algorithm which runs in time poly(n, log(1/ε)) and samples from a distribution ν such that kν − µgk1 ≤ ε. 3.1.1 Setup for the proof of Lemma 3.1 We first observe that we can apply Theorem 38 (see Appendix B) to the log-concave measure µ to obtain a new measure µ1 which is a "smoothed" version of µ. As detailed in Theorem 38, the distribution µ1 corresponding to µ1 satisfies kµ − µ1k1 ≤ 2−3n/2, so µ and µ1 are statistically extremely close. Let µg (resp. µ1g) denote the distribution µ (resp. µ1) conditioned on g = 1. Since Prx←µ[g(x) = 1] ≥ 2−n, it follows that kµg − µ1gk1 ≤ 2−n/2. Since we only work with error parameters ε ≥ 1/2o(n), the algorithms we consider only draw at most 2o(n) many samples from µg, and hence with very high probability sampling from µ1g is identical to sampling from µg. Thus, from now on, we will assume the following (see Theorem 38): Claim 3.2. The log-concave measure µ satisfies the following conditions. 11 1. For x 6∈ B2(0, nC ), µ(x) = 0. 2. The resulting density µ is such that for all x ∈ B2(0, nC ), µ(x) ≥ 2−2nC−5n−3 · n−2Cn. Lemma 3.1 is proved by leveraging results of [LV06]. We first recall two assumptions from [LV06] which suffice for their results to go through. Their algorithms deal with an unknown log-concave function µ : Rn → [0,∞) (and the associated probability density function µ := µ/kµk1), and are given (LV1) an evaluation oracle that returns the value of µ at any given x ∈ Rn, as well as two values R, r > 0 such that (i) the variance of µ in every direction is at most R2; and (ii) if the level set L(c) := { x ∈ Rn : µ(x) ≥ c } satisfies µ(L(c)) ≥ 1/8, then L(c) contains a ball of radius r; and (LV2) a random "starting point" x0 ∈ Rn drawn from a probability distribution σ, along with a bound M ≥ 1 such that dσ dµ ≤ M . Remark 13. If condition (LV1) holds for R and r such that R/r = O(√n), then the log-concave measure µ (and the resulting distribution µ) is said to be well-rounded. Theorem 1.1 in [LV06] states that under the conditions (LV1) and (LV2), there is an efficient algorithm to approximately sample from the density µ: Theorem 14 (Theorem 1.1, [LV06]). There is an algorithm ALV-sampler which, under conditions (LV1) and (LV2), given an error parameter ε > 0, has the following properties: 1. The running time of ALV-sampler is poly(n, R/r, log(1/ε), log M ). 2. The output distribution of the algorithm (denoted by ν) satisfies kµ − νk1 ≤ ε. Note that the algorithm in Theorem 14 runs in polynomial time provided that ε ≥ 2−nO(1) , M ≤ 2nO(1) , and R/r ≤ poly(n). Moreover, when the distribution µ is well-rounded, then the next theorem (Theorem 1.3 in [LV06]) also gives an efficient algorithm to computeR µ(x). Theorem 15. There is an algorithm ALV-integral which, for a well-rounded log-concave function µ, under conditions (LV1) and (LV2), given access to an error parameter ε > 0, outputs a number Q such that The running time of the algorithm is poly(n/ε). 1 − ε ≤ Q Rx µ(x)dx ≤ 1 + ε. We stress that both Theorem 15 and Theorem 14 rely on R/r being not too large. While this may not always be the case for the distribution µ to begin with, it is possible to achieve this via a linear transformation, as we discuss next. Definition 16. Let T : Rn → Rn be an invertible linear transformation, let z ∈ Rn, and let µ be any measure supported on Rn. We define the measure µT,z which is given by µT,z(x) = 1 det(T ) µ(T −1(x − z)). 12 We observe that if µ is a probability density, then µT,z is the density obtained by sampling x ← µ and applying the linear transformation x 7→ T x + z to x. Since linear transformations preserve log-concavity, if µ is log-concave then µT,z is also log-concave. We further observe that for any log-concave measure µ, any z ∈ Rn, and any invertible matrix T , we have Zx µ(x)dx =Zx µT,z(x)dx Moreover, given an efficient algorithm that samples from a distribution that is ε-close to the dis- tribution µT,z, there is also an efficient algorithm to sample from a distribution that is ε-close to distribution µ. With the above observations in hand, a strategy to prove Lemma 3.1 naturally suggests it- self. Given oracle access to a log-concave measure µ and a halfspace g satisfying the conditions of Lemma 3.1, we will compute a linear transformation T : Rn → Rn and a random starting point z ∈ Rn such that the density µT,z satisfies LV1 with R/r = O(√n). In particular, we will prove the following lemma: Lemma 3.3. Let µ : Rn → [0,∞) be a log-concave measure and g be a halfspace satisfying the hypothesis of Lemma 3.1. There is a polynomial time algorithm which, given evaluation oracle access to µ and a halfspace g, computes an invertible linear transformation T : Rn → Rn and a z ∈ Rn such that the density (µT,z)g satisfies LV1 with R/r = O(√n). 3.1.2 Proof of Lemma 3.1 assuming Lemma 3.3 We now explain the details of how Lemma 3.3 implies Lemma 3.1. To do this, we need to recall the following result from [KLS97]: Theorem 17 ([KLS97]). Given a separation oracle for a convex body K ⊆ Rn, there is an algorithm AKLS-sampler which makes O(n5) oracle calls and produces a uniformly random sample from K. Proof of Lemma 3.1 assuming Lemma 3.3. Let us define the set Ag ⊂ Rn to be Ag = {x ∈ B2(0, nd) : g(x) = 1}, and let us define σ to be the uniform distribution over Ag. We observe that we can efficiently sample from the distribution σ because the set Ag has an separation oracle (recall that in the setting of Lemma 3.1 we are given g) and thus we can sample from Ag using the algorithm AKLS-sampler from Theorem 17. Let V denote the volume of the set Ag, so σ(x) = 1/V for all x ∈ Ag. Since Prx←µ[g(x) = 1] ≥ 2−n and µ(x) ≤ 2n for all x (by condition C2), it follows that V ≥ 2−2n, and consequently for all x ∈ Ag, we have σ(x) ≤ 22n. By Claim 3.2, µ(x) ≥ 2−2nC−5n−3 · n−2Cn for every x ∈ B2(0, nC ). Since Prx←µ[g(x) = 1] ≥ 2−n, it follows that µg(x) ≥ 2−2nC−7n−3 · n−2Cn. Consequently, we have that for every x ∈ Ag, σ(x) µg(x) ≤ 22nC +9n+3 · n2Cn. Hence for any invertible linear transformation T : Rn → Rn and any z ∈ Rn, we also get σT,z(x) (µT,z)g(x) ≤ 22nC +9n+3 · n2Cn. In particular, if we apply the linear transformation T and z by applying Lemma 3.3 to the log- concave measure µ and the halfspace g, then we satisfy LV1 and LV2 with R/r = O(√n) and 13 M = 22nC +9n+3 · n2Cn, taking the point x0 specified in LV2 to be a random point sampled from σ. We can now apply Theorem 15 and Theorem 14 to obtain the desired conclusion of Lemma 3.1. 3.1.3 Proof of Lemma 3.3 In the rest of this section we prove Lemma 3.3. Towards this end, we first recall a useful definition: Definition 18. Let µ be a log-concave distribution supported on Rn. For β > 0, µ is said to be β-isotropic if for every unit vector u ∈ Rn, we have 1 β ≤Zx∈Rnhu, xi2µ(x)dx ≤ β. In other words, the variance of µ in every direction is between 1/β and β. A log-concave measure µ is said to be β-isotropic if the corresponding distribution µ is β-isotropic. Lov´asz and Vempala showed that if a log-concave distribution is 1-isotropic, then it is well- rounded (Lemma 5.13, [LV07]). However, it is easy to see by inspection of their proof that if a log-concave distribution is β-isotropic for any absolute constant β > 1, then it is also well-rounded. We record this here: Lemma 3.4. is well-rounded. If a log-concave distribution µ is β-isotropic for an absolute constant β > 1, then it We need two more ingredients to prove Lemma 3.3. The first is a result of Lov´asz and Vempala which shows that given a maximizer of a log-concave measure, the measure can efficiently be brought to an O(1)-isotropic position. Theorem 19 ([LV07]). Given evaluation oracle access to a full-dimensional log-concave measure ν and a point y such that ν(y) ≥ (1 − 2−n) · maxx ν(x), there is an algorithm which makes O(n4) oracle calls to ν and computes an invertible linear transformation T and a point z ∈ Rn such that the transformed measure νT,z (defined as in Theorem 16) is 2-isotropic. We remark that the theorem statement of Theorem 19 in [LV07] stipulates that the point y be an exact maximizer, as opposed to a near-maximizer; however, by inspecting the proof one can verify that having a near-maximizer (in the sense provided by our theorem statement) also suffices to find the linear transformation T and point z.4 The second ingredient we will use is the following theorem from [LSV18] (though weaker results might also suffice): Theorem 20 ([LSV18, Theorem 1]). Let K be a convex set specified by a membership oracle, let w ∈ Rn, and let 0 < r′ < R′ be numbers such that B2(w, r′) ⊆ K ⊆ B2(w, R′). For any convex function f : Rn → R given by an evaluation oracle and any ε > 0, there is a randomized algorithm that with constant probability computes a point z ∈ B2(K, ε) such that f (x)(cid:1) f (x) − min x∈K f (z) ≤ min x∈K f (x) + ε ·(cid:0) max ε·r′(cid:1) oracle calls and n3 logO(1)(cid:0) n·R′ x∈K using n2 logO(1)(cid:0) n·R′ 4This was confirmed in personal communication with Vempala [Vem18]. ε·r′(cid:1) arithmetic operations. 14 Now we are ready to prove Lemma 3.3: Proof of Lemma 3.3. By applying Lemma 3.4, it suffices to compute T, z such that the distribution (µT,z)g is 2-isotropic. We start by observing that µg(x) is proportional to µ(x) · 1[g(x) = 1], so in the setting of Lemma 3.3 we have evaluation oracle access to a measure proportional to µg. By Theorem 19, it suffices to find a point y ∈ Rn such that µg(y) ≥ (1 − 2−n) · maxx∈Ag µg(x). To find the required point y, we will use Theorem 20. Note that since µg is log-concave, the function − log µg is convex, so minimizing h(x) = − log µg(x) is equivalent to maximizing µg(x). We now provide the details. Recalling that kµk∞ ≤ 2n and Prx←µ[g(x) = 1] ≥ 2−n, we get that kµgk∞ ≤ 22n; combining this with the lower bound on µg(x) established in Section 3.1.2, we get that 2−2nC−7n−3 · n−2Cn ≤ µg(x) ≤ 22n for all x ∈ B2(0, nC). We take the set K of Theorem 20 to be K = Ag, and we observe that by the above bounds on µg, we have max x∈K h(x) − min x∈K h(x) ≤ 2nC + 2Cn log n + 9n + 3. (1) We further observe that we clearly have both a separation oracle and a membership oracle for the set K. We use this separation oracle with Theorem 17 to generate a point w which is uniformly sampled from K. We will now show that setting R′ = 2nC, r′ = 2 · (2n)−(n−1)C · π−(n−1) · 2−3n, we have B2(w, r′) ⊆ K ⊆ B2(w, R′). The second inclusion is clear (that for the above R′, we have K ⊆ B2(w, R′)). For the first inclusion we recall the following fact from high-dimensional convex geometry (which follows from the existence of higher-dimensional Crofton formulas, see, e.g., [sur16]): Fact 3.5. Let K be any convex body contained in a ball of radius ρ = nC. Then the surface area of K is at most the surface area of the sphere of radius ρ (which is bounded by 2πn−1ρn−1). We will now use this to bound the volume of the set of the points at a distance r′ from the boundary of Ag. To do this, for any convex body K, define Kt = {x : dist(x, K) ≤ t}. Observe that Kt is a convex body for any K and t. The following relation is well-known: surf(K) = lim δ→0 vol(Kδ) − vol(K) δ . Here surf(K) is the surface area of K. Thus, it follows that for any t ≥ 0, vol(Kt) − vol(K) =Z t s=0 surf(Ks)ds. (2) Let Ag,t = {x : dist(x, Ag) ≤ t}. Applying Fact 3.5 to Ag,t, we have surf(Ag,t) ≤ 2πn−1· (nC + t)n−1. This is because if Ag is contained in a ball of radius nC, then Ag,t is contained in a ball of radius nC + t. Combining this with (2) applied to the body Ag, vol(Ag,r′) − vol(Ag) ≤Z r′ s=0 2πn−1 · (nC + s)n−1ds 15 Using the fact that r′ ≤ nC, we have that vol(Ag,r′)−vol(Ag) ≤ 2πn−1(2n)(n−1)C ·r′. Thus, the total volume of the set of points at a distance r′ from the boundary of Ag is at most 2πn−1(2n)(n−1)C · r′. By plugging in the value of r′ from above, this volume is at most 2−3n. Since Vol(Ag) ≥ 2−2n (see Section 3.1.2), this means that with probability 1 − 2−n, the point w satisfies B2(w, r′) ⊆ K ⊆ B2(w, R′). We now set ε to be 2−2n−1 ε := 2nC + 2Cn log n + 9n + 3 . We apply Theorem 20 with w, R′, r′ and ε as above to get a point z such that h(z) ≤ min x∈K h(z) + ε ·(cid:0) max x∈K h(x) − min x∈K h(x)(cid:1) ≤ min x∈K h(x) + 2−2n−1 using (1). Thus, µg(z) ≥ e−2−2n−1 · maxx∈K µg(x), which implies that µg(z) ≥ (1 − 2−n) maxx∈K µg(x). With this point z in hand, we can apply Theorem 19 to bring µg to 2-isotropic position. This finishes the proof. 3.2 An algorithm for LTFs under well-behaved log-concave distributions In this subsection we prove Theorem 5. We do this by applying Theorem 12, where both the classes C and C′ are taken to be the class PTFn 1 of linear threshold functions over Rn. Thus what is needed is to establish the existence of each of the four algorithmic ingredients -- a densifier, an approximate counting algorithm, a weak approximate generation algorithm, and an SQ-learning algorithm -- required by Theorem 12. (Some of these will be reused in the proof of Theorem 6 as well.) Several of these ingredients are provided for us in the literature. An SQ-learning algorithm for the class of linear threshold functions over Rn was given in [BFKV97]: Theorem 21. There is a distribution-independent SQ learning algorithm ALTF SQ for the class of linear threshold functions over Rn that has running time poly(n, 1/ε, log(1/δ)), uses at most poly(n) time to evaluate each query and requires tolerance of its queries no more than τ = 1/poly(n, 1/ε). An approximate counting algorithm for linear threshold functions under well-behaved log- concave distributions is given by Lemma 3.1, and this lemma also gives a weak approximate generation algorithm. Thus, it remains only to establish the existence of an efficient densifier for linear threshold functions under log-concave background distributions. Construction of a densifier for PTFn 1 under well-behaved log-concave distributions. To explain the construction of the densifier, we will need to recall the notion of an online learning algorithm. An online algorithm A for a concept class C operates in a sequential model of learning: at every stage, the algorithm is presented with an unlabeled point x and is asked to predict the binary value f (x) where f is the target function. After the prediction, the true value of f (x) is revealed. A is said to have a mistake bound of M if the maximum number of incorrect predictions made by the algorithm is M on any sequence of unlabeled examples and any target function f ∈ C. We will use the following celebrated result from [MT94], which gives an online learning algorithm for PTFn Theorem 22. There is an online learning algorithm (which we call MTn,L) for PTF1 n over the domain [L]n with the following guarantee: MTn,L has a mistake bound of M (L, n) := O(n2(log L + 1 if the example points come from a discrete grid: 16 log n)) and runs in time poly(n, log L) at each stage. Further, at every stage of its execution, MTn,L maintains a (weights based) representation of a LTF which correctly labels all the examples received so far. We now state our main theorem establishing the existence of densifiers for PTF1 n when the ambient distribution is a well-behaved log-concave distribution: Theorem 23. Let D be any log-concave density satisfying conditions C1, C2 and C3. There is an algorithm ALTF 1 under D where γ = 1/poly(n). Algorithm ALTF den which is an (ε, γ, δ)-densifier for PTFn den has running time poly(n, 1/ε, log(1/δ)). 1 using PTFn The proof of Theorem 23 is a modification of the analogous proof in [DDS15a] (Theorem 11 in the full version) where the background distribution D is uniform over {−1, 1}n, so, instead of giving a full proof, we limit ourselves to a proof sketch. (The key new issue that needs to be dealt with is the fact that mistake-bound guarantees do not hold in a completely unrestricted setting of learning over continuous domains. At a high level we surmount this issue by exploiting specific properties of our well-behaved log-concave distributions, such as the fact that such a density cannot be too concentrated in a very small region.) 3.2.1 Proof sketch of Theorem 23 We begin by recalling that to show a function g is a densifier for f , it suffices to establish two properties: (a) Agreement: Prx←Df [ g(x) = 1 ] ≥ 1 − ε, and (b) Density: Prx←D [ g(x) = 1 ] ≤ (1/γ) Prx←D [ f (x) = 1 ]. A densifier for LTFs in the uniform-distribution [DDS15a] setting. We first recall the algorithm to construct a densifier from [DDS15a] and give a high level overview of its proof of correctness (Theorem 11 in [DDS15a]). Note that [DDS15a] constructs a densifier for PTFn 1 where the domain is {−1, 1}n (or equivalently, [2]n) and the background distribution D is uniform on {−1, 1}n. In the following, the value of γ is chosen to be a suitably small 1/poly(n) quantity (small compared to 1/M as defined below). 1. Sample N+ = Θ((n2 + log(1/δ))/ε2) points x1, . . . , xN+ where each xi is drawn from Df (i.e., D conditioned on f (xi) = 1). 2. Define the set S + := {x1, . . . , xN+}. Let M = O(n2 log n) and i = 0. 3. Initialize the online algorithm MTn,L with L = 2 and let h0 be the initial hypothesis. 4. If i = M , output hi and terminate. 5. If there exists x ∈ S+ such that hi(x) = −1, then feed such an x to MTn,L along with the 6. Otherwise, use the approximate counting algorithm to get bpi, a high-accuracy approximation label ℓx = 1 for x. Go to Step 4. of Prx←D[hi(x) = 1]. 17 7. If bp ≥ γ 2 ·bpi, then terminate the procedure and output hi. 8. Otherwise, generate x ← Dhi and feed x to MTn,L along with the label ℓx = −1 for x. Update hypothesis hi using MTn,L and set i ← i + 1. Go to Step 4. The proof of correctness of the algorithm in [DDS15a] relies on two claims. Claim 3.6. With very high probability over the draw of S +, (a) is satisfied by any halfspace g : {−1, 1}n → {−1, 1} such that g(x) = 1 for every x ∈ S+. Claim 3.7. With very high probability over the execution of the densifier, every sample x and label ℓx fed to MTn,L is correct, i.e., f (x) = ℓx. (For intuition, Claim 3.6 is argued using a simple Chernoff bound and union bound. Claim 3.7 exploits the fact that since γ is very small compared to 1/M where M is the number of stages, with high probability each random point x ← Dhi obtained in Step 8 is indeed a negative example for f .) Given Claim 3.7 and Claim 3.6, it is not hard to show that with high probability, the output of the above algorithm terminates with a hypothesis hi which satisfies both (a) and (b) and thus we have a densifier. Adapting the [DDS15a] densifier to our setting. We now return to our setting in which the background distribution D is log-concave and satisfies C1, C2 and C3. We change the densifier algorithm as described below. and let L = 1/κ. For any point x ∈ Rn, let [x]κ denote the point obtained by rounding each coordinate of x to the nearest integral multiple of κ, and let M = O(n2(log L+log n)) (note that this new value of M is still poly(n)). We adapt the algorithm of [DDS15a] to our setting in the following way: Let κ = 2−n10C 1. Set L and M in the algorithm with the values specified above. 2. The background distribution is the log-concave distribution D satisfying C1, C2 and C3. 3. For each point x fed to the learner in Steps 5 and 8, we instead feed [x]κ to the learner (so each point fed to the learner is rounded to the nearest integral multiple of κ). These changes induce analogous changes to Claims 3.6 and 3.7, where now the points [x]κ play the role that x played throughout the statements; more precisely, we state New Version of Claim 3.6. With very high probability over the draw of S +, the bound Prx←Df [g([x]κ) = 1] ≥ 1 − 2ε is satisfied by any halfspace g : [L]n → {−1, 1} such that g(x) = 1 for every x ∈ S+. New Version of Claim 3.7. With very high probability over the execution of the densifier, every sample [x]κ and label ℓx fed to MTn,L is correct, i.e., f ([x]κ) = ℓx. We now give proof sketches of these new versions of Claims 3.6 and 3.7 in our context. (The high-level idea throughout the arguments given below is that since the rounded version [x]κ is always extremely close to x and the relevant distributions are not too concentrated, they can only put a tiny amount of mass on points close to the boundary, and thus it is very unlikely that the rounding causes the label to change for any point arising in the algorithm.) 18 Proof Sketch of New Version of Claim 3.6. Let g be any halfspace and define the set Kg := g−1(−1)∩ f−1(1). Observe that Kg is an intersection of two LTFs and further that if g does not satisfy (a), then Prx←Df [x ∈ Kg] = Prx←Df [x ∈ g−1(−1)] ≥ ε. (3) We upper bound the probability Prx←Df [x ∈ Kg and [x]κ 6∈ Kg]. To bound this, observe that since D satisfies C2, instead of Kg, we can consider Kg ∩ B2(0, nC ). Since the surface area of this (convex) body is upper bounded by nC(n−1)· πn−1· 2n by Fact 3.5, the surface area of the portion of the two hyperplanes defined by f and g which is within B2(0, nC ) is at most nC(n−1) · πn−1 · 2n. We additionally recall that the density of Df is bounded by 4n. Now, the event "x ∈ Kg and [x]κ 6∈ Kg" implies that x lies in B2(0, nC ) and is κ-close to a point on the separating hyperplane for the LTF f or a point on the separating hyperplane for the LTF g. By the above surface area and density upper bounds, this probability can be upper bounded by nC(n−1) · πn−1 · 2n · κ · 4n ≪ ε 2 (recall that by assumption the value of ε is at least 1/2o(n)). Combining this with Equation (3), we conclude that Prx←Df [[x]κ ∈ g−1(−1)] ≥ ε/2. Since g is a halfspace and the VC-dimension of halfspaces is n + 1, a standard uniform convergence argument now gives the claim. Proof Sketch of New Version of Claim 3.7. Consider any example (x, ℓx) fed to the online learner. We first consider the case when ℓx = 1 (corresponding to Step 5). In this case, note that x = [y]κ and ℓx = f (y) = 1 where y ← Df . Similar to before, note that the only way ℓx can differ from f (x) is if y ∈ B2(0, N c) and y is κ-close to the boundary of the set K, where now K = f−1(1). As in the argument in the previous proof sketch, this probability can be bounded by nC(n−1) · πn−1 · 2n · κ · 4n ≪ 2−n. Next we consider the case when ℓx = −1 (corresponding to Step 8). In this case, we note that the point x generated in Step 8 is indeed in f−1(−1) with probability at least 1 − γ. Consequently, Pr[[x]κ 6∈ f−1(−1)] ≤ γ + 2−n. Since the total number of points the algorithm generates in Step 8 is at most M , the claim follows from the fact that M (γ + 2−n) ≪ 1 (as in the analysis of [DDS15a]). Given the new versions of Claims 3.6 and 3.7, an argument entirely analogous to the argument employed in [DDS15a] to establish (a) and (b) from Claims 3.6 and 3.7 gives us the following analogues of (a) and (b): (a′) Agreement in our setting: Prx←Df [ g([x]κ) = 1 ] ≥ 1 − 2ε, (b′) Density in our setting: Prx←D [ g([x]κ) = 1 ] ≤ (1/γ) Prx←D [ f (x) = 1 ]. Similar arguments to those employed above show that the probability (under either Df or D) that x is so close to the boundary of g as to have g([x]κ) 6= g(x) is extremely small. Hence conditions (a) and (b) can be inferred from (a′) and (b′), as required by the definition of a densifier. This concludes the proof sketch of Theorem 23. 19 4 A distribution learning algorithm for degree-2 PTFs under the normal background distribution In this section we fix the ambient distribution to be a standard Gaussian, N := N (0, 1)n. We wish to learn the distribution Nf induced by N and an (unknown) degree-2 PTF f . In this section, we give an algorithm with time and sample complexity poly(n, 1/ε) which learns Nf to total variation ε, given independent samples from it. Theorem 24 (Theorem 6, restated). There is an algorithm A with the following property: Let f ∈ PTFn 2 be such that Prx←N (0,1)n [f (x) = 1] ≥ 2−n. Given access to i.i.d. samples from Nf = (N (0, 1)n restricted to f−1(1)), for ε = 1/2o(n) algorithm A runs in poly(n, 1/ε) time and with high probability outputs a hypothesis distribution D′ such that dTV(D′,Nf ) ≤ ε. As in the previous section, to prove this theorem we will rely on the general algorithmic result of Theorem 12, with C and C′ both set to be PTFn 2 and D being N (0, 1)n. That is, we will provide (i) a densifier (Section 4.1); (ii) an approximate counting algorithm (Section 4.2); (iii) a weak approximate generation algorithm (Section 4.3); and (iv) an SQ learning algorithm for PTFn 2 .5 In fact, (iv) follows from Theorem 21, since upon reparameterization a degree-2 PTF over Rn is a 2(cid:1). degree-1 PTF over Rm, for m := n +(cid:0)n 4.1 Construction of densifier for PTFn 2 under normal distribution In this subsection, we establish the following theorem, which provides a densifier for PTFn the ambient normal distribution: 2 under den which is an (ε, γ, δ)-densifier for PTFn Theorem 25. There is an algorithm APTF under N where γ = 1/poly(n). Algorithm APTF Proof sketch. We follow the same outline as for the proof sketch of Theorem 23. Indeed, the algorithm itself is, up to some change in parameters, the same: we will again rely on the online- mistake bound learning algorithm of Maass -- Turan from Theorem 22 (observe that the Maass -- Turan algorithm can be used to learn degree-2 PTFs over a discrete domain [L]n, by viewing such a PTF as an LTF over O(n2) variables), and we will use the same approach as in the previous section. den has running time poly(n, 1/ε, log(1/δ)). 2 using PTFn 2 To make this approach work for degree-2 PTFs under the normal distribution, it suffices to (1) adapt the algorithm in two places (namely, by using the approximate counting and approximate generation algorithms for degree-2 PTFs, given in Sections 4.2 and 4.3, instead of their LTF coun- terparts); and (2) establish the analogues of Claims 3.6 and 3.7 in this new setting (which will correspond to slightly different choices for the parameters N+ and M ). The main hurdle in doing this is that the proofs of Claims 3.6 and 3.7, in order to establish that the discretization of the space and rounding of the points (required to apply the Maass -- Turan algorithm over a discrete grid of points) did not affect correctness, used the fact that the relevant sets (e.g., g−1(−1)∩f−1(1) and f−1(1)) were convex sets with a very simple structure (the satisfying assignments of a single LTF or an intersection of two LTFs). This simple structure made it possible to bound the volume of the set of points in B2(0, nC ) that are very close to the boundary of these 5We note that for (ii) and (iii), we will actually provide a marginally less general result, which we will show to be sufficient for our purposes given the assumptions of Theorem 24: namely, counting and generation algorithms only for f ∈ PTFn x←N (0,1)n [f (x) = 1] ≥ 2−n. 2 such that Pr 20 sets using Fact 3.5. While the rest of the argument goes through for degree-2 PTFs (using, for the uniform convergence in the analogue of Claim 3.6, that the VC dimension of the class of degree-2 PTFs over n real variables is (cid:0)n+2 affects the value of the function in the same way as before since we are no longer dealing with LTFs; indeed, the relevant sets of satisfying assignments need no longer be convex. 2 (cid:1) [Ant95]), we cannot bound the probability that the rounding Instead, we bound this probability more directly by exploiting the fact that the ambient dis- tribution is Gaussian, as follows. First, we may assume without loss of generality that the current hypothesis degree-2 PTF g = sign(p) has been normalized, so that the squared non-constant coeffi- cients of p sum to 1. Given any x ∈ B2(0, nC ), consider its rounding [x]κ. Using Cauchy -- Schwarz, the triangle inequality, and the fact that the coefficients of p have been normalized as described above, it is not hard to see that p(x) − p([x]κ) ≤ O(1) · κ · kxk2 = O(κnC ) := τ . Consequently, one can only have g(x) 6= g([x]κ) if p(x) itself is very small, namely at most O(κnC). However, invoking a well-known result of Carbery and Wright [CW01], this itself only can happen with probability O(√τ ) = O(√κnC) under the standard normal distribution: Theorem 26 ([CW01]). Let p : Rn → R be a non-identically zero degree-d polynomial. Then, for all ε > 0 and θ ∈ R, Pr x←N (0,1)nhp(x) − θ < εpVar[p]i ≤ O(dε1/d) . Since p is degree-2, Var[p] is the sum of the squared degree-1 and degree-2 Hermite coefficients when p is expressed in the Hermite basis of polynomials that are orthonormal under N (0, 1)n. Recalling that the degree-1 univariate Hermite polynomial is h1(x) = x and the degree-2 univariate Hermite polynomial is h2(x) = x2−1√2 , the fact that p's squared non-constant coefficients sum to 1 implies that Var[p] = Θ(1). In our setting θ = 0, and d = 2, and so applying Theorem 26 we get the claimed bound. We can use this to derive the counterparts of the main probability bounds from Claim 3.6 and Claim 3.7, respectively, allowing the proofs of the two analogous statements to go through. First, letting Kg := g−1(1) ∩ f−1(−1), we have [x ∈ Kg ∩ [x]κ /∈ Kg] ≤ Pr x←Nf [p(x) ≤ τ ] ≤ O(2n√τ ) ≪ 2−n [p(x) ≤ τ ] ≤ 2n Pr x←N Pr x←Nf recalling that Prx←N [ f (x) = 1 ] ≥ 2−n and the setting of κ. This (along with the aforementioned VC dimension argument) yields the counterpart of Claim 3.6. A similar argument applied to the degree-2 PTF f (instead of g) allows us, considering K := f−1(−1) and following the outline of the proof of Claim 3.7, to establish the counterpart of that second claim as well. 4.2 Approximate counting: Gaussian integration under quadratic constraints Recall that our goal in this subsection is an algorithm with the following property: given the full description of a degree-2 PTF g = sign(p) over Rn such that g−1(1) has mass at least 1/2n under N , the algorithm should efficiently output a (multiplicatively accurate) estimate of PrG∼N [g(G) = 1]. The main theorem of this subsection is the following. 21 Theorem 27. There is a deterministic algorithm AC with the following guarantee: Given as input a degree-2 polynomial p over Rn such that g−1(1) has mass at least 1/2n under N (where g = sign(p)) and input ε ∈ (0, 1] such that ε ≥ 1/2O(n), AC runs in time poly(n, 1/ε) and outputs an (1 + ε)-approximation to PrG←N [ g(G) = 1 ]. Although sampling G = (G1, . . . , Gn) ← N is easy, the additional quadratic constraint sig- nificantly complicates the problem of both (i) estimating Pr[ p(G) ≥ 0 ] as well as (ii) sampling G conditioned on Pr[ p(G) ≥ 0 ]. Indeed, as is the case with many sampling and approximate counting problems [JVV86], the complexities of (i) and (ii) are closely related. We note that these problems are of interest in the statistics literature [PP14], but rigorous guarantees were previously not known. To prove Theorem 27, we leverage an approximate counting algorithm due to Li and Shi [LS14] for the knapsack problem (which in turn builds on the algorithm of [SVV12]). To state the result of Li and Shi, we first need the definition of an oracle to a probability distribution. Definition 28. For any real valued random variable X, an oracle OX takes inputs ν1 ≤ ν2 ∈ R and outputs the quantity Pr[ν1 ≤ X ≤ ν2]. With this, we are ready to state the result of Li and Shi. Theorem 29 ([LS14, Theorem 1.1]). There exists an algorithm LS with the following guarantees. Given as input an integer C > 0, an approximation parameter ε > 0, and oracle access to n independent integer-valued random variables X1, . . . , Xn such that 0 ∈ supp(Xi) ⊆ {0, 1, . . . , C +1} for all 1 ≤ i ≤ n, the algorithm outputs a value bρ such that 1 Pr" nXi=1 1 + ε Xi ≤ C# ≤bρ ≤ (1 + ε) Pr" nXi=1 ∆ ), where ∆ :=Qn ε , log C, log 1 Xi ≤ C# . i=1 Pr[ Xi = 0 ]. Moreover, LS runs in time poly(n, 1 To see why Theorem 29 is useful, we begin by observing that, upon rotating Rn and translating the Gaussians, the approximate counting problem considered in Theorem 27 is equivalent to the following problem: Given (λi, µi)i∈[n], ε ∈ (0, 1], and θ ∈ R such that (4) is at least 2−n, output an (1 ± ε)- approximation of [p(G) ≥ 0] = Pr" nXi=1 Pr G∼N λiG2 i + µiGi ≤ θ# . (4) Since both (4) and Theorem 29 deal with the probability that a sum of independent random variables exceeds a threshold, the relevance of Theorem 29 should now be clear. In order to prove Theorem 27 using Theorem 29 using the formulation (4), we will need to do two preprocessing steps. These steps will be useful in Section 4.3 as well. 22 Pre-Processing Steps: Discretization and Rounding: Let us set γ := 1/2nC1 and τ := 1/2nC1 for suitably big constants C1, C2 > 0. First, without loss of generality, we may assume that i=1 and i=1 to the nearest integral multiple of γ; we call the resulting rounded coefficients λ′i and µ′i. i ) = 1. We can now round the coefficients {λi}n i + µ2 i=1(λ2 i=1((λi − λ′i)2 + (µi − µ′i)2) ≤ O(nγ2), and that we also have the coefficients in (4) satisfy Pn {µi}n We observe thatPn 1 2 ≤ nXi=1 (λ′2 i + µ′2 i ) ≤ 3 2 . (5) We now recall the following useful fact from [DS17]: Lemma 4.1 ([DS17, Lemma 6]). Let a(x) and b(x) be multivariate degree-d polynomials over Rn such that for G ← N , E[a(G) − b(G)] = 0, Var[a] = 1 and Var[a − b] ≤ (τ /d)3d. Then, [sign(a(G)) 6= sign(a(G))] ≤ τ. Pr G∼N i=1(λix2 Recalling that p(x) =Pn i + µixi) − θ, we define q(x) =Pn i=1(λ′ix2 1 3 ), we get that 1 6 · γ ing Lemma 4.1 to p(x) and q(x) with d = 2 and τ = O(n i + µ′ixi) − θ. Apply- Pr" sign(cid:0) nXi=1 (λiG2 i + µiGi) − θ(cid:1) 6= sign(cid:0) nXi=1 (λ′iG2 i + µ′iGi) − θ(cid:1)# = O(n 1 3 ). 1 6 · γ For a suitable choice of the constant C1, the right hand side is at most O(2−n2 1] ≥ 2−O(n), this implies the following claim: Claim 4.2. Let g = sign(p) and h = sign(q). For any ε ≥ 2−O(n), PrG←N [g(G) = 1] is an (1 + ε)-approximation of PrG←N [h(G) = 1]. Similarly, kGh − Ggk1 ≤ 2−O(n). Thus, to sample from Gg, it suffices to design an efficient sampling algorithm for Gh. ). Since Pr[sign(p(G)) = We next define a discretization [G]τ := ([G1]τ , . . . , [Gn]τ ) of the Gaussian random variable G = (G1, . . . , Gn) as follows: each [Gi]τ is only supported on the points AP−n,n,τ := {−n,−n + τ, . . . , n − τ, n}. For each point κ ∈ AP−n,n,τ , [Gi]τ (κ) = Pr[Gi ∈ [κ, κ + τ )] Pr[Gi ∈ [κ,∞)] Pr[Gi ∈ (−∞, κ + τ ) if κ 6∈ {−n, n}, if κ = n, if κ = −n. (6) In other words, we assign each point κ ∈ AP−n,n,τ , the probability mass that the standard Gaussian puts in the interval [κ, κ+τ ) (with the exception of −n and n, whose probability is slightly increased by the capping). To proceed further, for conciseness let us adopt the shorthand H = (H1, . . . , Hn) to denote the random variable [G]τ = ([G1]τ , . . . , [Gn]τ ). We next have the following claim. Claim 4.3. For q(x) as specified above, we have that PrG[sign(q(G)) 6= sign(q(H))] ≤ 2−Θ(n2). 23 Proof. First of all, note that Pr[Gi > n] ≤ 2−Θ(n2) for each i ∈ [n]. Let E be the event that for all 1 ≤ i ≤ n, Gi ≤ n. By a union bound, we obtain Pr(cid:2) E(cid:3) = Pr[Gi > n for some i ∈ [n]] ≤ 2−Θ(n2). Using the upper bound on coefficients of q from (5), we have that conditioned on event E, q(G) − q(H) ≤ O(n2τ ). Consequently, conditioned on event E, sign(q(G)) 6= sign(q(H)) only if q(G) = O(n2 · τ ). However, by anti-concentration of quadratic polynomials (Theorem 26), we have (7) (8) [q(G) = O(n2τ )] ≤ O(n√τ ) = 2−Θ(n2). Pr G∼N The above application of Theorem 26 uses the lower bound on the sum of squares of the coefficients of q from (5). Combining (8) and (7) yields the claim. In light of Claims 4.2 and 4.3, it suffices to give an algorithm to compute PrH [sign(q(H)) = 1] where q and H are as defined above; we do this below. Approximate counting of PrH [sign(q(H)) = 1]. Recall that q(H) =Pn and that our plan is to leverage the algorithm of [LS14] (Theorem 29) to approximate PrH [sign(q(H)) = 1]. Our argument employs the following three claims. i +µ′iHi)−θ i=1(λ′2 i H 2 i + µ′iHi. This random variable is supported Claim 4.4. Define the random variable Xi = λ′iH 2 on integral multiples of γτ 2 = 2−nC1−2nC2 bounded in the range [−2n2, 2n2]. Proof. The range of this random variable can be bounded just by observing that each λ′i and µ′i is bounded in absolute value by 1. Further, since λ′i and µ′i are integral multiples of γ and H is supported on integral multiples of τ , the random variable Xi is supported on integral multiples of γτ 2. Claim 4.5. Let α be such that Pr[Xi = α] > 0. Then, Pr[Xi = α] ≥ 2−Θ(nC1 ). Proof. Note that any draw of Xi is completely determined by the corresponding draw of Hi. Thus, it suffices to show that min α:Pr[Hi=α]>0 Pr[Hi = α] ≥ 2−Θ(nC1 ). Note that at any point x ∈ [−n, n], the density of Gi is at least 2−Θ(n2). Note further that any support point of Hi lies in the set AP−n,n,τ . For any point α 6= n in this set, one can easily lower bound Hi(α) as For α = n, Hi(α) =Zx∈[α,α+τ ) Hi(α) =Zx≥n Gi(x)dx =Zx≥n Gi(x)dx ≥ 2−Θ(n2) · τ ≥ 2−Θ(nC1 ). 1 √2π e− x2 2 dx ≥ 2−Θ(n2). So, for every possibility for α, we get the claimed lower bound on Hi(α), finishing the proof. 2 + Claim 4.6. Let a, b ∈ R where a,b ≤ 1. Let Y denote the random variable defined by a[G]τ b[G]τ where G is a standard normal random variable. Assuming a and b are rational multiples of 2−poly(n), we can implement OY in poly(n) time. 24 Proof. First, we observe that given any a and b as above, the set Ca,b := {x : ν1 ≤ ax2 + bx ≤ ν2} is given by a union of at most two closed intervals I1 and I2 where the boundary points of I1 and I2 can be (efficiently) obtained by solving quadratic equations in one-variable. Moreover, in view of the definition of [G]τ from G, for any interval I we have that Pr[[G]τ ∈ I] = Pr[G ∈ J], where J ⊇ I is an efficiently computable interval (depending only on the endpoints of I and on τ ). Finally, given any interval J, the value Pr[G ∈ J] can clearly be computed in polynomial time. This finishes the claim. Given the above three claims, we are left in a position where we can apply Theorem 29 to the discrete random variables X′i := 1 γτ 2 (Xi − mi) , 1 ≤ i ≤ n γτ 2 where mi = min−n≤j≤n(λ′ij2 + µ′ij) (this ensures that indeed 0 belongs to the support of X′i). By Claim 4.4, the X′i's are thus non-negative integer-valued random variables with 0 ∈ supp(X′i) ⊆ {0, 1, . . . , mi+2n2 γτ 2}. The parameter C in Theorem 29 is therefore upper bounded by 4n2 γτ 2 = 2nC1 +2nC2 +o(n), so log C is indeed poly(n). Moreover, we can implement the required oracles {OX′ i}n i=1 with a poly(n)-time overhead by Claim 4.6. } ⊆ {0, 1, . . . , 4n2 To conclude and be able to claim a poly(n, 1/ε) runtime overall after invoking Theorem 29, i=1 Pr[ X′i = 0 ]. This bound fol- i=1 Pr[ X′i = αi ] ≥ = 2−Θ(nC1+1). Since 0 ∈ supp(X′i) for all i, this leads to the same lower bound on ∆, we also require a 2−poly(n) bound on the parameter ∆ = Qn (cid:16)2−Θ(nC1 )(cid:17)n for any α ∈ supp(X′1) × ··· × supp(X′n), we have Qn and applying Theorem 29 concludes the proof of Theorem 27. lows from Claim 4.5: 4.3 Weak approximate generation: Gaussian sampling under quadratic con- straints In this subsection, we will prove the following theorem. Theorem 30. There is an efficient algorithm RS with the following guarantee: Given as input a degree-2 polynomial p defining a PTF g = sign(p) over Rn such that g−1(1) has mass at least 2−n under N , and input ε ∈ (0, 1] such that ε ≥ 1/2O(n), the algorithm runs in time poly(n/ε) and outputs a point x distributed according to a distribution D such that kD − Ggk1 ≤ ε. Similar to Section 4.2, we can assume that p is of the form p(x) = nXi=1 λix2 i + µixi − θ. As in the previous section, we set parameters γ := 1/2nC1 and τ := 1/2nC1 for suitably big constants C1, C2 > 0, we define the coefficients λ′i and µ′i obtained by rounding the parameters λi and µi to the nearest integral multiple of γ (identical to Section 4.2), and we define q(x) = i=1 µ′ixi− θ and h = sign(q). Using Claim 4.2, it suffices to give an efficient sampling i=1 λ′ix2 algorithm for the distribution Gh. Pn i +Pn 25 We define the random variable H as in (6). We also define Gh(H) as the random variable G conditioned on h(H) = 1. Finally, Hh denotes the distribution H conditioned on h(H) = 1. By Claim 4.3, we have that kGh − Gh(H)k1 ≤ 2−Θ(n2). Thus, it suffices to produce a sampler for the distribution Gh(H). Next, observe that since our algorithms are efficient, it suffices to sample points Gh(H) up to nΘ(1) bits of precision. We further recall that Pr[kGk∞ > n] ≤ 2−Θ(n2). Together, these observations imply that it suffices to sample from Hh. To accomplish this, we use the generic idea of reducing sampling to approximate counting [JVV86]. We begin with the following definition. Definition 31. Let κ(1), κ(2) ∈ APn for every 1 ≤ j ≤ n (this is denoted by κ(1) (cid:22) κ(2)). Then the random variable Hκ(1),κ(2) represents H conditioned on the jth coordinate lying in the interval [κ(1) −n,n,τ where κ(1) j ≤ κ(2) , κ(2) j j j ] for every 1 ≤ j ≤ n. We now claim that the algorithm from the preceding subsection can be augmented to achieve the following guarantee: Theorem 32. There exists a deterministic algorithm AC′ with the following guarantee: Given a degree-2 polynomial q : Rn → R (satisfying the above conditions), error parameter ε ≥ 2−O(n), −n,n,τ , algorithm AC′ returns a (1 ± ε) approximation to the quantity and vectors κ(1) (cid:22) κ(2) ∈ APn Pr[h(Hκ(1),κ(2)) = 1]. Briefly, the algorithm in the preceding subsection relies on three crucial claims: 1. The random variable Xi = λ′iH 2 i + µ′iHi is an integral multiple of γτ 2 = 2−nC1−2nC2 bounded in the range [−2n2, 2n2] (Claim 4.4). Here Hi is the ith coordinate of H. Let us now define Xi,κ(1),κ(2) by replacing H with Hκ(1),κ(2) in the definition of Xi. Note that the support of Hκ(1),κ(2) is a subset of the support of H. Thus, the support of Xi,κ(1),κ(2) is a subset of the support of Xi, and as a result, Claim 4.4 will continue to hold true for Xi,κ(1),κ(2). 2. For any α such that Pr[Xi = α] > 0, we have that Pr[Xi = α] ≥ 2−Θ(nC1 ) (Claim 4.5). It is easy to see that the same proof also implies Claim 4.5 when Xi is replaced by Xi,κ(1),κ(2). 3. Let a, b be rational multiples of 2−poly(n) of magnitude at most 1. Let Y denote the random i + bHi. Then, we can implement the oracle OY in polynomial time (Claim 4.6). variable aH 2 It is easy to see that this continues to hold if we replace Hi by Hi,κ(1),κ(2). As the analogues of Claim 4.5, Claim 4.4 and Claim 4.6 hold for Xi,κ(1),κ(2), the proof of correctness of the algorithm in the previous subsection can be modified mutatis mutandis to prove Theorem 32. We now complete the proof of Theorem 30 by presenting and analyzing the algorithm RS. The algorithm is a recursive routine and is given below; it is a straightforward translation of the usual counting-to-sampling reduction to our setting (augmented with binary search since in our context we are dealing with larger domains for each coordinate than {0, 1}). (1) Initialize κℓ = (−n,−n, . . . ,−n) and κu = (n, n, . . . , n). (2) Initialize A as Aε = [κℓ n] ∩ (AP−n,n,τ )n. 1 ] × . . . × [κℓ n, κu 1, κu 26 (3) Set δ = ε/(2 log A). (4) If A = 1, then return A. (5) Else, choose the first j such that [κℓ and κ2,mid as ℓ + κj u)/2. Define κ1,mid j, κu j ]∩ AP−n,n,τ > 1. Let ηmid = (κj 1 , . . . , κu 1, . . . , κℓ j−1, ηmid, κu j−1, ηmid, κℓ j+1, κu j+1, κℓ n). n). κ1,mid = (κu κ2,mid = (κℓ (6) Invoke Theorem 32 to obtain (1 ± δ) approximations to the quantities Pr[h(Hκ1,κ1,mid) = 1] and Pr[h(Hκ2,mid,κ2) = 1]. (7) Call these approximations η1 and η2. Let b be a Bernoulli random variable where Pr[b = 0] = η1/(η1 + η2). (8) Define A0 and A1 as A0 = [κℓ A1 = [κℓ 1, κu 1, κu 1 ] × . . . [κℓ 1 ] × . . . [κℓ j−1, κu j−1, κu j−1] × [κℓ j−1] × [ηmid, κu j, ηmid] × [κℓ j ] × [κℓ j+1, κu j+1, κu j+1] × . . . [κℓ j+1] × . . . [κℓ n, κu n]; n, κu n]. (9) Sample b ← b and go to Step 2 with A ← Ab. We now make the following claim. Claim 4.7. The above procedure terminates after log A repetitions. The total running time is poly(n, 1/ε). Proof. Note that at each stage A shrinks in size by a factor of 2 and when A = 1, then the procedure terminates. This proves the first part of the claim. The second part follows from the fact that in each iteration every step (including Step 6) runs in time poly(n, 1/ε). Next, we observe that corresponding to any string z of length at most m = ⌈log A⌉, we can associate a set Az as follows: 1. Set A ← Aε (recall step (2) of algorithm RS). 2. Set j ← 1. 3. If A = 1 or j = z + 1, return Az := A. 4. Else, we define A0 and A1 by Steps (5) and (8) of the above algorithm. 5. Let b be the jth bit of z. Then, set A ← Ab and j ← j + 1. Go to Step 3. We observe that (1) the above routine associates a unique string of length at most m with any element x ∈ Aε. (2) If a string z is a prefix of a string w, then Aw ⊆ Az. We are now ready for the following claim: 27 Claim 4.8. Let z be any string and let Az ⊆ Aε defined above. Define psample,z to be the probability that RS samples an element from Az. Let ptrue,z = PrH[H ∈ Azh(H) = 1]. Then 1 − 2δ · z ≤ psample,z ptrue,z ≤ 1 + 2δ · z. Proof. The proof is a simple induction on the length of z. First, observe that the bounds trivially hold when z = ε. Now, inductively assume that the bounds hold when the length of z is at most ℓ. Let us consider any z = z′ ◦ b where b ∈ {0, 1}. For steps (5), (6) and (7) of the above algorithm, define η1,true to be Pr[h(Hκ1,κ1,mid) = 1] and η2,true to be Pr[h(Hκ2,mid,κ2) = 1]. Further, let η1 and η2 be the (1 ± δ) approximations to η1 and η2 respectively that are obtained in step (6). We have that psample,z = psample,z′ · ηb+1 η1 + η2 and ptrue,z = ptrue,z′ · ηb+1,true η1,true + η2,true . Using the induction hypothesis for z′ and the fact that ηb is a (1 ± δ) approximation of ηb,true, we get the claim for z. To complete the proof of Theorem 30, it remains only to recall that δ = ε/2m. 5 Hardness results for learning from satisfying assignments In this section we show that under various standard cryptographic assumptions, our algorithmic results from the previous sections are close to the strongest possible for learning with respect to log- concave and normal background distributions. In particular, we will show that under cryptographic assumptions, there is no efficient algorithm to 1. learn the class of n-variable degree-two polynomial threshold functions PTFn 2 when the back- ground distribution is a known log-concave distribution. In fact, this lower bound holds even when the background distribution is the uniform distribution over the solid n-dimensional hypercube [0, 1]n (which is an extremely simple log-concave distribution). 2. learn the class of n-variable degree-four polynomial threshold functions PTFn 4 when the back- ground distribution is the n-dimensional standard Gaussian N (0, 1)n. We obtain these results using (an extension of) a general condition for showing hardness of learning from [DDS15a]. We begin by recalling the notion of an invertible Levin reduction. Definition 33. A binary relation R is said to reduce to another binary relation R0 by a polynomial- time invertible Levin reduction if there are three algorithms α(·), β(·,·) and γ(·,·), each running in polynomial time, with the following properties: 1. For each x, y, if (x, y) ∈ R then (α(x), β(x, y)) ∈ R0. 2. For each x, z, if (α(x), z) ∈ R0 then (x, γ(α(x), z)) ∈ R. 3. Finally, the functions β and γ are such that for each x, y, we have γ(α(x), β(x, y)) = y. 28 In the context of this paper, we note that for any class C of Boolean functions (over any domain), we can define a relation RC which contains those pairs (f, z) such that f ∈ C and f (z) = 1. In this section, whenever we say that there is an invertible Levin reduction from class C1 to class C2, we mean that there is an invertible Levin reduction from RC1 to RC2. As an illustrative example, we may take C1 to be the class of all polynomial-size Boolean circuits (corresponding to the Circuit- SAT problem) and C2 to be the class of all 3-CNF formulas. For property (1), given a circuit C and a satisfying assignment z, the output α(C) is the 3-CNF formula (over an expanded variable space) that is produced by the standard reduction, and if (C, z) belongs to RC1 (meaning that z is a satisfying assignment for circuit C) then the output β(C, z) is the corresponding satisfying assignment for the 3-CNF formula α(C). For property (2), given a 3-CNF α(C) and a satisfying assignment z′ of that 3CNF, γ(α(C), z′) outputs the (unique) satisfying assignment z of C that "gave rise to" z′, and it is easy to see that property (3) holds. Next, we recall a standard assumption from the cryptographic literature [MRV99], which is a slight variant of the standard RSA assumption. Assumption 1. Let RSAk be the set of all integers which are products of two primes of length ⌊(k − 1)/2⌋. Let m be chosen uniformly from RSAk and let x be chosen uniformly from Z∗m. Let p be a uniformly chosen prime of length k + 1. There exists some absolute constant δ > 0 such that, for any probabilistic algorithm A running in time 2nδ , Prm,x,p[A(m, x, p) = y and yp = x mod m] ≤ 2−nδ . Under the above assumption [MRV99] showed the existence of a so-called unique signature scheme which is secure for subexponential time algorithms under "random message attack" (RMA). In [DDS15a], the authors showed how the existence of such unique signature schemes implies hardness of learning under the uniform background distribution over {−1, 1}n for classes C for which there is an invertible Levin reduction from Circuit-SAT. More precisely, [DDS15a] established the following theorem. Theorem 34. Let C be a class of functions such that there is a polynomial-time invertible Levin reduction from Circuit-SAT to C. Then, under Assumption 1, there exists an absolute constant δ′ > 0 such that no 2nδ′ -time algorithm can learn C under the uniform background distribution. In the current work we will need a slight extension of Theorem 34 which is suitable for establish- ing hardness when the background distribution is something other than the uniform distribution on {−1, 1}n. The precise result we shall use is stated below. Theorem 35. Let C be a class of functions from Rn to {−1, 1} such that there is a polynomial-time invertible Levin reduction from Circuit-SAT to C. Suppose further that the background distribution D and the reduction are such that the following properties hold: 1. There is an efficient algorithm which, on input a point x, outputs the value of the probability density function for D at x (i.e., an efficient algorithm to simulate an evaluation oracle for D). 2. If C is a circuit which is an instance of Circuit-SAT and f ∈ C is an instance of C which arises from C in the reduction, then f−1(1) is the disjoint union of some collection of K sets S1, . . . , SK , where K is the number of satisfying assignments for C and each set Si corresponds to precisely one solution to C. Moreover, 29 (a) For any i, j ≤ K, the regions Si and Sj have probability mass within a factor of two of each other under D; and (b) There is an efficient algorithm which, for any j ∈ [K], given any x ∈ Sj, outputs a sample drawn from DSj (the distribution D restricted to Sj). Then, under Assumption 1, there exists an absolute constant δ′ > 0 such that no 2nδ′ can learn C under the background distribution D. -time algorithm Inspection of the proof of Theorem 34 shows that the arguments used in its proof straightfor- wardly extend to yield Theorem 35. Intuitively, Item 1 ensures that given the hypothesis distribu- tion generated by a learning algorithm for C with respect to background distribution D (recall that in our model such a hypothesis distribution requires query access to an evaluation oracle for D), it is indeed possible to generate samples from a distribution that is statistically close to Df . Intu- itively, Item 2, together with the invertible Levin reduction, makes it possible to translate a draw from the hypothesis distribution back to a signed message and thereby contradict Assumption 1. 5.1 A lower bound for degree-2 PTFs under log-concave background distribu- tions In this subsection we prove Theorem 2. Theorem 36 (Theorem 2, restated). Under Assumption 1, there is no subexponential-time algo- rithm A for learning the class PTFn 2 of n-variable degree-two polynomial threshold functions with respect to the (log-concave) background distribution D which is uniform over the solid cube [0, 1]n. We prove Theorem 36 using Theorem 35 and a reduction from Subset-Sum. Recall that an instance W of the Subset-Sum problem is given by a non-negative integer w0 and an n-tuple w = (w1, . . . , wn) of non-negative integers, and the problem is to determine whether there is a subset S ⊆ [n] such that w0 =Pi∈S wi. It is well known that there is a polynomial-time invertible reduction from Circuit-Sat to Subset-Sum in which a Circuit-Sat instance of size n is mapped to a Subset-Sum instance in which each wi is at most 2n2 . Since polynomial-time invertible Levin reductions compose, to prove Theorem 36 it suffices for us to give a polynomial-time invertible Levin reduction from Subset-Sum to the class of degree-2 PTFs which satisfies the properties stated in Theorem 35. The reduction from Subset-Sum. Given an instance W = (w0, w) ∈ N × Nn of Subset-Sum which has each wi ≤ 2n2 , define the quadratic polynomial pW (x) = nXi=1 wixi − w0!2 + λ nXi=1 xi(1 − xi) , (9) where λ := M · kwk2 ≫ 1 for some M = M (n) = cn to be determined later. The first observation is that the points achieving the minimum of pW over [0, 1]n are in one-to-one correspondence with the solutions of W . Specifically, we observe the following. Proposition 5.1. Suppose that the Subset-Sum instance W is satisfiable. Then the minimum of pW over [0, 1]n is 0, and this minimum is achieved exactly at the points x ∈ {0, 1}n satisfying hw, xi = w0. 30 Proof. It is immediate to see that pW ≥ 0 on [0, 1]n, and further that for any solution of W we have pW (x) = 0 (as the first term is zero by assumption, and the second is zero since x ∈ {0, 1}n). Conversely, consider any x ∈ [0, 1]n such that pW (x) = 0. This implies both that w · x = w0 (since the first term has to be zero) and that Pn i=1 xi(1 − xi) = 0, which since x ∈ [0, 1]n yields x ∈ {0, 1}n. Based on Lemma 5.1, a natural choice of degree-two PTF for our hardness reduction would be, given an instance W , to take fW (x) := sign(−pW (x)) (recall that sign(0) is defined to be 1). Indeed, in this case the satisfying assignments of fW in [0, 1]n are in one-to-one correspondence with the solutions of the Subset-Sum instance, and given x ∈ [0, 1]n ∩ f−1 W (1) it is trivial to produce the corresponding solution. We do not pursue exactly this simple approach, though, because of the issue discussed in Remark 7, namely that [0, 1]n ∩ f−1 W (1) has measure zero under the uniform distribution on [0, 1]n (as it is a finite set of discrete points). Since this set has measure zero, such an instance of the degree-2 PTF learning problem violates our requirement that the target function have a 2−nO(1) fraction of satisfying assignments under the background distribution. We get around this issue by considering a slightly modified version of the above polynomial. More precisely, we will instead define fW (x) := sign(cid:18) 1 2 − pW (x)(cid:19) , (10) and we will establish the following: Proposition 5.2. With fW defined as in Eq. (10), we have that W (1) has measure at least 1/2O(n3) under U[0,1]n; W (1) is the disjoint union of K sets S1, . . . , SK , each with volume within a factor 2 of each other under U[0,1]n, where K is the number of solutions to the Subset-Sum instance W (and each set Si contains precisely one solution to W ); and 1. [0, 1]n ∩ f−1 2. [0, 1]n ∩ f−1 3. There is an efficient algorithm which, for any j ∈ [K], given any x ∈ Sj, outputs a uniform sample drawn from Sj. Part 1 of Lemma 5.2 addresses the "reasonableness" condition discussed in Theorem 7. Part 2, together with our earlier discussion, is easily seen to give the desired polynomial-time invertible Levin reduction from Subset-Sum to degree-2 PTFs satisfying the properties stated in Theorem 35. Towards proving Lemma 5.2 (which we will do at the end of this subsection), let us rewrite Eq. (9) pW (x) = sW (x) + λB(x) (11) as with sW (x) = nXi=1 wixi − w0!2 and B(x) = nXi=1 xi(1 − xi). Our next three claims will establish that (i) fW outputs −1 on any point too far from the Boolean hypercube (Claim 5.3); (ii) fW outputs −1 on any point close to a point of the Boolean hypercube which is not a solution to the Subset-Sum instance W (Claim 5.4); and (iii) fW outputs 1 on any point close to a point of the Boolean hypercube which is a solution to the Subset-Sum 31 instance W (Claim 5.5). Combining the three (for suitable notions of "too close" and "too far" along with corresponding volume considerations will establish the proposition. Define the parameter αn as αn := 1 2 1 −r1 − 2 λ! = 1 2λ + O(cid:18) 1 λ2(cid:19) (12) Claim 5.3. Suppose x ∈ [0, 1]n is at ℓ1 distance more than αn from every point from {0, 1}n. Then fW (x) = −1. Proof. By symmetry, it is enough to consider the point 0n ∈ {0, 1}n. For any x ∈ [0, 1]n such that αn < kxk1 = kx − 0nk1 < 1/2, we have B(x) = kxk1 − kxk2 2 ≥ kxk1 − kxk2 1 > αn (1 − αn) = 1 2λ by our choice of αn as the solution to the equation X(1− X) = 1 1/2, so fW (x) = −1. Claim 5.4. Let x ∈ [0, 1]n, and suppose that x is at ℓ1 distance at most 1/(4kwk2) of some z ∈ {0, 1}n (thus necessarily unique). If z is not a solution to the Subset-Sum instance W , then fW (x) = −1. Proof. We can write 2λ , and therefore pW (x) ≥ λB(x) > wizi − w0(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) ≤(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) 1 ≤(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) nXi=1 nXi=1 ≤ kwk2 · kx − zk2 +(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) nXi=1 wizi − wixi(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) +(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) nXi=1 wi(zi − xi)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) wixi − w0(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) =(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) nXi=1 nXi=1 wixi − w0(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) ≤ wixi − w0(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) ≤ kwk2 · kx − zk1 +(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) nXi=1 1 4 wixi − w0(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) +(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) nXi=1 +psW (x) the first inequality from the fact that all wi's are positive integers and z ∈ {0, 1}n, the third-to-last from Cauchy -- Schwarz, and the second-to-last from monotonicity of ℓp norms. Therefore, we have pW (x) ≥ sW (x) ≥ (3/4)2 > 1/2, and fW (x) = −1. (Note that since αn ∼n→∞ is at ℓ1 distance at most αn from a non-solution point of {0, 1}n must have fW (x) = −1.) Define the parameter βn as = o(1/kwk2), Claim 5.4 obviously implies that any x ∈ [0, 1] which 2Mkwk2 1 βn := 1 2kwk2(cid:16)pM 2 + 2 − M(cid:17) = 1 2Mkwk2 − O(cid:18) 1 M 3kwk2(cid:19) (13) Claim 5.5. Let x ∈ [0, 1]n, and suppose that x is at ℓ1 distance at most βn from some z ∈ {0, 1}n (thus necessarily unique). If z is a solution to the Subset-Sum instance W , then fW (x) = 1. Proof. We can write (cid:12)(cid:12)(cid:12)(cid:12)(cid:12) nXi=1 wixi − w0(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) ≤(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) nXi=1 wi(xi − zi)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) +(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) nXi=1 wizi − w0(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) 32 =(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) nXi=1 wi(xi − zi)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) ≤ kwk2 · kx − zk1 the last inequality again from Cauchy -- Schwarz and monotonicity of ℓp norms. Moreover, we also have B(x) = xi(1 − xi) ≤ nXi=1 min(xi, 1 − xi) = nXi=1 2 · kx − zk2 1 + Mkwk2 · kx − zk1 = (kwk2 · kx − zk1)2 + M (kwk2 · kx − zk1) xi − zi = kx − zk1 nXi=1 so that pW (x) = sW (x) + λB(x) ≤ kwk2 ≤ (βnkwk2)2 + M (βnkwk2) = 1 2 , where the last inequality is a direct consequence of our choice of βn such that βnkwk2 is a solution to X 2 + M X = 1/2. This implies fW (x) = 1, as claimed. Proof of Lemma 5.2. Claims 5.3 and 5.4 together imply (since, as noted after Claim 5.4, 1/(4kwk2 ≫ αn) that if x ∈ [0, 1]n is not within ℓ1 distance αn of a solution z ∈ {0, 1}n of the Subset-Sum in- stance W , then fW (x) = −1. Moreover, Claim 5.5 ensures that any x ∈ [0, 1]n which is within ℓ1 distance βn of a solution z ∈ {0, 1}n of the Subset-Sum instance W satisfies fW (x) = 1. Therefore, as αn = o(1) and any two point in {0, 1}n are at least at unit ℓ1 distance, the satisfying assignments f−1 W (1) are disjoint sets S1, . . . , SK (one around each of the K satisfying assignments z1, . . . , zK ∈ {0, 1}n of the Subset-Sum instance) such that, for all 1 ≤ k ≤ K, B1 n(zk, βn) ∩ [0, 1]n ⊆ Sk ⊆ B1 n(zk, αn) ∩ [0, 1]n . This gives item (2) of the proposition, except for the assertion that any two Si, Sj have volume within a factor of two of each other (we will establish this below). For items (1) and (3), by symmetry it suffices to consider the case zk = 0n. Noting that the , and that restricting this ball to [0, 1]n n! and therefore volume of the ℓ1 ball of radius r is Leb(B1 yields an 1/2n fraction of the original volume, we get Leb(B1 by Claims 5.3 and 5.5 we have n(0n, r) ∩ [0, 1]n) = rn n(0n, r)) = 2nrn n! βn n n! ≤ Leb(Sk) ≤ αn n n! . From Eqs. (12) and (13) and our setting of λ = Mkwk2, we get that αn, βn are respectively 1 constant c > 0 to make c′ > 0 below small enough), we get 2λ − O(cid:0) 1 M λ(cid:1), from which, as long as M = cn (for some sufficiently big absolute n(cid:19)n 2λ + O(cid:0) 1 M λ(cid:1) and 1 √2 · 2nλnn! ≤(cid:18)1 − βn n n! ≤ Leb(Sk) ≤ n! ≤(cid:18)1 + √2 2nλnn! n(cid:19)n 2nλnn! ≤ 2nλnn! ≤ (14) αn n c′ c′ 1 1 1 . This shows that all volumes Leb(Sk) are within a constant factor 2 of each other, finishing item 2 of the Proposition. Moreover, under the uniform distribution U[0,1]n over [0, 1]n, the above along with our bound kwk∞ ≤ 2n2 and the choice of λ = M · kwk2 implies that U[0,1]n(Sk) ≥ 2O(n3) = 1 1 , √2 · 2nλnn! as λ ≤ M√nkwk∞ = O(n3/22n2 This establishes item 1 of Lemma 5.2, so it remains only to show that item 3 holds. To establish this last item (i.e., that for any k one can efficiently, given any x∗ ∈ Sk, sample uniformly ). (15) 33 from Sk) it suffices to observe that (i) given such a x∗, it is immediate to find the corresponding satisfying assignment zk ∈ {0, 1}n (by rounding the coordinates); (ii) efficient sampling uniformly from B1 n(zk, αn) can be done using elementary techniques; and (iii) since the volume of Sk is within a factor of 2 of the volume of B1 n(zk, αn) and fW can be efficiently evaluated, rejection sampling allows us to sample uniformly from Sk in an efficient way. This concludes the proof of Lemma 5.2 and hence also of Theorem 36. 5.2 A lower bound for degree-4 PTFs under the normal distribution In this subsection, we prove Theorem 4, which shows that even under a very strong assumption on the ambient distribution one cannot hope for much better than Theorem 3: Theorem 37 (Theorem 4, restated). Under Assumption 1, there is no subexponential-time algo- rithm A for learning the class PTFn 4 of n-variable degree-four polynomial threshold functions with respect to the standard normal distribution N (0, 1)n. The rest of this section is dedicated to the proof of this theorem. As for Theorem 2, our starting point is a reduction from Subset-Sum, although a slightly different one. First off, it will be convenient for us to now view the Subset-Sum problem as being over {−1, 1}n rather than {0, 1}n: i.e., the goal is to determine whether there is a string z ∈ {−1, 1}n such that w · z = w0. (It is easy to see that this is equivalent to the original problem over {0, 1}n.) Now, given an instance W = (w0, w) ∈ N × Nn of this form of Subset-Sum in which each wi ≤ 2n2 , we define the quartic polynomial where λ := cn max(kwk2 2, n) ≫ 1 for some sufficiently large absolute constant c > 0, and we define i − 1)2 = sW (x) + λB(x) , (x2 pW (x) = nXi=1 + λ wixi − w0!2 nXi=1 2 − pW (x)(cid:19) , fW (x) := sign(cid:18) 1 (16) (17) as in Theorem 2. Compared to the degree-2 lower bound, the "penalization" term B(x) is now a degree-4 polynomial, whose role is to enforce that satisfying assignments to fW from Rn must be "essentially Boolean", where now "Boolean" means "belonging to {−1, 1}n" (note that B vanishes exactly on {−1, 1}n) over inputs from Rn). Analogously to the proof of Theorem 2, we establish the facts that (1) zeros of pW are exactly the solutions to the Subset-Sum instance W ; (2) if a point is far from a Boolean point, then it does not satisfy fW ; (3) if a point is close to a Boolean point not satisfying W , then it does not satisfy fW ; and (4) if a point is close to a Boolean point satisfying W , then it does satisfy fW . Altogether, this will in turn allow us to establish the proposition below, which is closely analogous to Lemma 5.2: Proposition 5.6. With fW defined as in Eq. (17), we have that 1. f−1 2. f−1 W (1) has measure at least 1/2O(n3) under N (0, 1)n; W (1) is the disjoint union of K sets S1, . . . , SK , each with measure within a factor 2 of each other under N (0, 1)n, where K is the number of solutions to the Subset-Sum instance W (and each set Si contains precisely one solution to W ); and 34 αn := 1 21 −s1 −r 2 λ = 1 √8λ + 1 8λ + o(cid:18) 1 λ(cid:19) . (18) 3. There is an efficient algorithm which, for any j ∈ [K], given any x ∈ Sj, outputs a draw from N (0, 1)n restricted to Sj. Similar to Lemma 5.2, Lemma 5.6 is easily seen to satisfy the "reasonableness" condition and give the desired polynomial-time invertible Levin reduction from Subset-Sum to degree-2 PTFs satisfying the properties stated in Theorem 35. The following is entirely analogous to Lemma 5.1: Proposition 5.7. Suppose that the Subset-Sum instance W is satisfiable. Then the minimum of pW over Rn is 0, and this minimum is achieved exactly at the points x ∈ {−1, 1}n satisfying hw, xi = w0. Proof. For any solution x of W we have pW (x) = 0 (as the first term sW (x) is zero by assumption, and the penalization term B(x) is zero since x ∈ {−1, 1}n). Conversely, consider any x ∈ Rn such that pW (x) = 0. Since sW , B ≥ 0, this implies both that w · x = w0 (since the first term has to be zero) and thatPn i − 1)2 = 0, which yields x ∈ {−1, 1}n. As before, our actual construction works with the PTF sign( 1 2−pW (x)) rather than sign(−pW (x)) because of the requirement that the learning problems under consideration have at least an inverse exponential fraction of probability mass under the background distribution lying on satisfying as- signments of the target function (recall Theorem 7). Define the parameter αn as the smallest positive solution to to 4(1 − X)2X 2 ≥ 1/(2λ), i.e., i=1(x2 Claim 5.8. Suppose x ∈ Rn is at ℓ2 distance more than αn from every point from {−1, 1}n. Then fW (x) = −1. Proof. For any such x ∈ Rn, we have that the closest Boolean point to x is x∗ ∈ {−1, 1}n, defined by x∗i = sign(xi) for every i ∈ [n]. Then, B(x) = nXi=1 (xi − 1)2(xi + 1)2 = nXi=1 (xi − x∗i )2(xi + x∗i )2 . Since (xi + x∗i )2 ≥ 1 for all i, we first observe that if there exists some i ∈ [n] such that xi − x∗i > n > 1/(2λ), and we are done. Thus we may assume that xi − x∗i < 2αn for 2αn, then B(x) > 4α2 all i. It follows that B(x) > nXi=1 (xi − x∗i )2(2 − 2αn)2 = 4(1 − αn)2 nXi=1 (xi − x∗i )2 > 4(1 − αn)2α2 n , 2 > α2 n. We then get pW (x) ≥ λB(x) > 1/2, so fW (x) = −1. where the first inequality uses xi − x∗i < 2αn and the last inequality follows by recalling that kx − x∗k2 Claim 5.9. Let x ∈ Rn, and suppose that x is at ℓ2 distance at most 1/(4kwk2) from some z ∈ {−1, 1}n (thus necessarily unique). If z is not a solution to the Subset-Sum instance W , then fW (x) = −1. 35 Proof. The proof is almost identical to that of Claim 5.4. We write 1 ≤(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) nXi=1 wizi − w0(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) ≤(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) nXi=1 wizi − nXi=1 wixi(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) +(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) nXi=1 wixi − w0(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) ≤ kwk2kx − zk2 +psW (x) ≤ 1 4 +psW (x) the first inequality from the fact that all wi's are positive integers and z ∈ {−1, 1}n, the third from Cauchy -- Schwarz. Therefore, we have pW (x) ≥ sW (x) ≥ (3/4)2 > 1/2, and fW (x) = −1. Define the parameter βn as the smallest positive solution to (kwk2 2 + 4λ) − O(cid:18) 1 λ(cid:19). 2 + λ(2 + X)2)X 2 = 1/2, so that βn := (19) 1 Claim 5.10. Let x ∈ Rn, and suppose that x is at ℓ2 distance at most βn from some z ∈ {−1, 1}n (thus necessarily unique). If z is a solution to the Subset-Sum instance W , then fW (x) = 1. q2(kwk2 nXi=1 wi(xi − zi)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) Proof. We can write (cid:12)(cid:12)(cid:12)(cid:12)(cid:12) nXi=1 wixi − w0(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) ≤(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) nXi=1 B(x) = (xi − 1)2(xi + 1)2 = =(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) nXi=1 wizi − w0(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) +(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) nXi=1 nXi=1 (xi − zi)2(xi + zi)2 ≤ (2 + βn)2 wi(xi − zi)(cid:12)(cid:12)(cid:12)(cid:12)(cid:12) ≤ kwk2 · kx − zk2 ≤ kwk2βn, nXi=1 (xi − zi)2 ≤ (2 + βn)2β2 n the second-to-last inequality again from Cauchy -- Schwarz. Moreover, we also have where we used the fact that xi + zi ≤ 2 + βn for all i (since otherwise kx − zk2 > βn). Therefore, pW (x) = sW (x) + λB(x) ≤ (kwk2 2 + λ(2 + βn)2)β2 n = 1 2 , where the last inequality is due to our choice of βn in (19). This implies fW (x) = 1, as claimed. Proof of Lemma 5.6. Claims 5.8 and 5.9 together imply (since 1/(4kwk2 ≫ αn) that if x ∈ Rn is not within ℓ2 distance αn of a solution z ∈ {−1, 1}n of the Subset-Sum instance W , then fW (x) = −1. Moreover, Claim 5.10 ensures that any x ∈ Rn which is within ℓ2 distance βn of a solution z ∈ {−1, 1}n of the Subset-Sum instance W satisfies fW (x) = 1. Therefore, as αn = o(1) and any two points in {−1, 1}n are at least at unit ℓ2 distance, the satisfying assignments f−1 W (1) are disjoint sets S1, . . . , SK (one around each of the K satisfying assignments z1, . . . , zK ∈ {−1, 1}n of the Subset-Sum instance) such that, for all 1 ≤ k ≤ K, n(zk, βn) ⊆ Sk ⊆ B2 B2 This gives the first part of item (2) of the proposition. n(zk, αn) . For items (1) and (3) (and the last part of item (2)), by symmetry it suffices to consider the n(1n, r)). n(1n, r)), i.e., we case zk = 1n: we want to estimate the Gaussian measure of the ℓ2 ball of radius r, φ(B2 For r = O(1/√n), we claim that this is within constant factors of φ(1n) · Leb(B2 claim that φ(B2 n(1n, r)) = Θ(cid:18)Leb(B2 n(1n, r)) · 1 (2π)n/2 e−k1nk2 2/2(cid:19) = Θ(cid:18) rn 2n/2Γ(n/2 + 1) e−n/2(cid:19) . 36 This is because, for such a small radius r, the Gaussian density changes by at most a constant factor within the radius-r ℓ2 ball centered at 1n: indeed, for any z in this ball, kzk2 = √n ± r, so that e−kzk2 en 2/2 = e−n/2±O(1) = Θ(cid:0)e−n/2(cid:1). Therefore, by the above we have √n · nn/2(cid:19) . √n · nn/2(cid:19) ≤ φ(Sk) ≤ O(cid:18)αn Ω(cid:18)βn From Eqs. (18) and (19) and our setting of λ = cnkwk2 λ(cid:1), from which, because λ ≫ n2, we get λ(cid:1) and 1√8λ − O(cid:0) 1 1√8λ √λ(cid:19)(cid:19) = Θ(cid:18) 1 (8λ)n/2(cid:18)1 ± O(cid:18) 1 + O(cid:0) 1 (8λ)n/2(cid:19). αn n, βn n = en n 1 n 2, we get that αn, βn are respectively (20) This shows that all measures φ(Sk) are within a constant factor of each other. Moreover, under the Gaussian measure φ over Rn, the above along with our bound kwk∞ ≤ 2n2 and the choice of λ = cn max(kwk2 2, n) implies that φ(Sk) = , (21) 1 2O(n3) as λ = O(n222n2 ). This establishes item 1 of Lemma 5.6, so it remains only to show that item 3 holds. To establish this last item (i.e., that for any k one can efficiently, given any x∗ ∈ Sk, sample according to the Gaussian measure restricted to Sk) it suffices to observe that (i) given such a x∗, it is immedi- ate to find the corresponding satisfying assignment zk ∈ {−1, 1}n (by rounding the coordinates); (ii) efficient sampling uniformly from B2 n(zk, αn) can be done using elementary techniques; and (iii) since the volume of Sk is within a constant factor of the volume of B2 n(zk, αn) and fW can be efficiently evaluated, and the Gaussian pdf can be easily computed on any point in Sk and this value varies only by an O(1) factor between any two points in Sk, rejection sampling allows us to sample according to the Gaussian measure restricted to Sk in an efficient way. This concludes the proof of Lemma 5.6 and hence also of Theorem 37. References [AGR13] Joseph Anderson, Navin Goyal, and Luis Rademacher. Efficient learning of simplices. In Conference on Learning Theory, pages 1020 -- 1045, 2013. 1.3 [Ant95] Martin Anthony. Classification by polynomial surfaces. Discrete Appl. Math., 61(2):91 -- 103, 1995. 4.1 [BFKV97] Avrim Blum, Alan M. Frieze, Ravi Kannan, and Santosh Vempala. A polynomial-time algorithm for learning noisy linear threshold functions. Algorithmica, 22(1/2):35 -- 52, 1997. 3.2 [CW01] Anthony Carbery and James Wright. Distributional and Lq norm inequalities for poly- nomials over convex bodies in Rn. Mathematical Research Letters, 8(3):233 -- 248, 2001. 1.4, 4.1, 26 37 [DDS15a] Anindya De, Ilias Diakonikolas, and Rocco A. Servedio. Learning from satisfying as- signments. In SODA, pages 478 -- 497. SIAM, 2015. (document), 1, 1, 1.1, 1.2, 1.2, 1.4, 3, 1.4, 1.5, 2.1, 2.1, 2.1, 12, 2.2, 3.2, 3.2.1, 3.2.1, 3.2.1, 3.2.1, 5, 5, A [DDS15b] Anindya De, Ilias Diakonikolas, and Rocco A. Servedio. from satisfying ing http://www.cs.columbia.edu/ rocco/papers/soda15.html, 2015. A assignments. Full version available Learn- at [DGTZ18] Constantinos Daskalakis, Themis Gouleakis, Christos Tzamos, and Manolis Zam- In FOCS, petakis. Efficient statistics, in high dimensions, from truncated samples. pages 639 -- 649. IEEE Computer Society, 2018. 1.3 [DS17] [Dye03] [EM07] Anindya De and Rocco A. Servedio. A new central limit theorem and decomposition for Gaussian polynomials, with an application to deterministic approximate counting. Probability Theory and Related Fields, pages 1 -- 64, 2017. 4.2, 4.1 Martin Dyer. Approximate Counting by Dynamic Programming. In Proceedings of the 35th Annual Symposium on Theory of Computing (STOC), pages 693 -- 699, 2003. A Nick Ellis and Ranjan Maitra. Multivariate gaussian simulation outside arbitrary ellip- soids. Journal of Computational and Graphical Statistics, 16(3):692 -- 708, 2007. 1.4 [JVV86] Mark Jerrum, Leslie G. Valiant, and Vijay V. Vazirani. Random generation of combi- natorial structures from a uniform distribution. Theor. Comput. Sci., 43:169 -- 188, 1986. 4.2, 4.3 [Kea98] Michael Kearns. Efficient noise-tolerant learning from statistical queries. Journal of the ACM, 45(6):983 -- 1006, 1998. 2.1 [KLS97] Ravi Kannan, L´aszl´o Lov´asz, and Mikl´os Simonovits. Random walks and an o∗(n5) volume algorithm for convex bodies. Random Structures & Algorithms, 11(1):1 -- 50, 1997. 3.1.2, 17 [KMR+94] Michael J. Kearns, Yishay Mansour, Dana Ron, Ronitt Rubinfeld, Robert E. Schapire, and Linda Sellie. On the learnability of discrete distributions. In Proceedings of the 26th Symposium on Theory of Computing, pages 273 -- 282, 1994. 1 [KOS08] Adam Klivans, Ryan O'Donnell, and Rocco A. Servedio. Learning geometric concepts via Gaussian surface area. In Proceedings of the 49th Symposium on Foundations of Computer Science (FOCS), pages 541 -- 550, 2008. 1.3 [KTZ19] Vasilis Kontonis, Christos Tzamos, and Manolis Zampetakis. Efficient truncated statis- tics with unknown truncation. In FOCS. IEEE Computer Society, 2019. To appear (Private communication). 1.3 [LS14] Jian Li and Tianlin Shi. A fully polynomial-time approximation scheme for approxi- mating a sum of random variables. Operations Research Letters, 42(3):197 -- 202, 2014. 1.4, 4.2, 29, 4.2 38 [LSV18] Yin Tat Lee, Aaron Sidford, and Santosh S. Vempala. Efficient Convex Optimization with Membership Oracles. In Proceedings of the 31st Conference On Learning Theory, volume 75, pages 1292 -- 1294, 2018. 3.1.3, 20 [LV06] [LV07] L´aszl´o Lov´asz and Santosh Vempala. Fast algorithms for logconcave functions: Sam- pling, rounding, integration and optimization. In FOCS, pages 57 -- 68. IEEE Computer Society, 2006. 1.4, 3.1.1, 3.1.1, 14, 3.1.1 L´aszl´o Lov´asz and Santosh Vempala. The geometry of logconcave functions and sam- pling algorithms. Random Structures and Algorithms, 30(3):307 -- 358, 2007. 3.1.3, 19, 3.1.3 [MRV99] Silvio Micali, Michael O. Rabin, and Salil P. Vadhan. Verifiable Random Functions. In Proc. 40th IEEE Symposium on Foundations of Computer Science (FOCS), pages 120 -- 130, 1999. 5, 5 [MS04] Ben Morris and Alistair Sinclair. Random Walks on Truncated Cubes and Sampling 0-1 Knapsack Solutions. SIAM J. Comput., 34(1):195 -- 226, 2004. A [MT94] Wolfgang Maass and Gyorgy Tur´an. How fast can a threshold gate learn? In Com- putational Learning Theory and Natural Learning Systems: Volume I: Constraints and Prospects, pages 381 -- 414. MIT Press, 1994. 3.2 [PP14] [sur16] Ari Pakman and Liam Paninski. Exact Hamiltonian Monte Carlo for truncated multi- variate Gaussians. Journal of Computational and Graphical Statistics, 23(2):518 -- 542, 2014. 1.4, 4.2 Surface area of convex bodies contained in one another. Mathematics Stack Exchange, 2016. URL: https://math.stackexchange.com/q/1783298 (version: 2016-05-13). 3.1.3 [SVV12] Daniel Stefankovic, Santosh Vempala, and Eric Vigoda. A deterministic polynomial- time approximation scheme for counting knapsack solutions. SIAM Journal on Com- puting, 41(2):356 -- 366, 2012. 4.2 [Vem18] Santosh S. Vempala. Personal communication, 2018. 4 A Hardness of distribution learning with respect to arbitrary back- ground distributions In this appendix we justify our focus on structured continuous distributions (namely Gaussian and log-concave) by proving that for general distributions D, learning Df even for very simple functions f (indeed, linear threshold functions) is computationally hard. We actually prove an even stronger hardness result, by assuming both that • the background distribution D is provided to the learning algorithm via an evaluation oracle to a function D such that on any input x, D(x) is proportional to D(x); and that • the algorithm has access to an exact sampler for D. 39 (This is at least as strong as the model we use for our positive results on log-concave distri- butions, presented in Section 2, in which the learner only receives an evaluation oracle for some measure which is a rescaling of the probability density function.) We show that, even in this set- ting, any distribution learning algorithm with respect to an arbitrary background distribution D may need to take exponential time, even if the function f is guaranteed to be a halfspace which is provided to the learning algorithm. To see this, suppose that the distribution D is Ug (the uniform distribution over {−1, 1}n restricted to the satisfying assignments of g), where g is a halfspace whose description is provided to the algorithm. We note that the distribution D satisfies both our hypothesis. Namely, • The 0/1-valued function g(x) is proportional to D(x), and g(x) can be efficiently computed. (In fact, the result of Dyer [Dye03] (and earlier work of Morris and Sinclair [MS04]) also establishes that D(x) itself can be efficiently evaluated to a multiplicative factor of (1 + ε) in poly(n/ε) time.) • By the result of Dyer [Dye03]), there is an efficient algorithm to exactly sample from D. Now let us define h(x) = f (x) ∧ g(x), so h is an intersection of two halfspaces. Note that the distribution Uh is exactly Df . However, under Assumption 1, it was shown in [DDS15a] that there is no algorithm with running time 2nδ (for some fixed δ > 0) to learn Uh given samples from the distribution (Theorem 1.5 of [DDS15a], see also Theorem 62 of [DDS15b]). It can be verified that this hardness result continues to hold even if the description of both halfspaces f and g is given to the algorithm. This implies that under Assumption 1, there is no algorithm with running time 2nδ to learn Df given samples from the distribution. Now, since g is known to the algorithm, by the above discussion the algorithm can efficiently (i) sample from D, and (ii) evaluate the function g(x) which is proportional to D(x). This shows that for arbitrary distributions D over the discrete cube, learning Df is computationally hard for a halfspace f even when we have access to a sampler for D as well as an evaluation oracle to D. Finally, observe that this example straightforwardly generalizes to continuous probability dis- tributions by replacing the points of {−1, 1}n in the support by disjoint (suitably small) balls centered at those points, and making D uniform on the union of these disjoint balls (akin to the constructions of Section 5). B Smooth version of µ For technical reasons related to the details of the literature on sampling from log-concave distribu- tions, it is helpful for us to be able to work with a "cleaned-up" version of the measure µ, which we denote µ1. The associated distribution µ1 is entirely supported on B(0, nC ), puts at least some minimum amount of mass on every point in B(0, nC ), and is statistically very close to the actual distribution µ. The precise statement we will use is stated and proved below. Theorem 38. Let µ be a measure such that the associated density µ satisfies conditions C1, C2 and C3 from Section 2. Let µ1 : Rn → (0,∞) be the measure which is defined as follows: µ1(x) =(0 µ(x) + 2−nC−4n · n−Cn if x 6∈ B2(0, nC ) otherwise Let µ1 be the density corresponding to µ1. Then, 40 1. µ1 is log-concave. 2. For any x ∈ B2(0, nC ), µ1(x) ≥ 2−2nC−5n−3 · n−2Cn 3. kµ − µ1k1 ≤ 2− 3n 2 . Proof. The first item follows simply from the fact that restricting µ to a convex set preserves log-concavity as does adding a constant function. To prove the next item, observe that Zx µ(x) ≤2 ·Zx µT (x) = 2 ·Zx∈B2(0,nC ) µT (x) + 2Zx6∈B2(0,nC ) µT (x) (uses C3) ≤2 ·Zx∈B2(0,nC ) ≤2 ·Zx∈B2(0,nC ) µT (x) + 2Zx6∈B2(0,nC ) µT (x) + 21−Cn ·Zx µ(x) (since µ(x) ≤ µ(x) for all x) µ(x) (uses C1) (22) We now make two observations: (i) By C2, we have that µT (x) is at most 2nC for all x. Since the volume of B2(0, nC ) is at most 2n · nCn, the first integral in Equation (22) is at most 2n+nC · nCn. 1. Since n ≥ 1 and C ≥ 2, 21−Cn ≤ 1/2. Combining these two observations with (22), we have Rx µ(x) ≤ 2nC +n+2 · nCn, and hence Rx µ1(x) ≤ 2nC +n+3 (with room to spare). This immediately implies that for any x ∈ B2(0, nC ), µ1(x) = µ1(x) Rx µ1(x) ≥ 2−2nC−5n−3 · n−2Cn. This proves the second item. To prove the third item, first observe that if µT denotes the density induces by the measure µT , then max x µT (x) = max x µT (x) Rx µT (x) ≤ max x 2µ(x) Rx µ(x) ≤ 2n+1. Here the penultimate inequality uses that µT (x) ≤ µ(x) as well as condition C3, and the last inequality uses condition C2. Consequently, if A = {x : µT (x) 6= 0}, then since µT is a distribution, it must hold that Vol(A) ≥ 2−n−1. We thus have that Zx µT (x) ≥Zx:µT (x)6=0 µT (x) ≥ min x:µT (x)6=0 µT (x) · Vol(A) ≥ 2−n−1−nC , where the last inequality is by the definition of µT as given in condition C3 (truncating nC bits after the binary point). Again using that µ(x) ≥ µT (x), we obtain Zx µ(x) ≥ 2−n−1−nC . 41 (23) Further, we also have that (cid:12)(cid:12)(cid:12)(cid:12)Zx µ(x) − µ1(x)(cid:12)(cid:12)(cid:12)(cid:12) ≤ Zx6∈B2(0,nC ) µ(x) +Zx∈B2(0,nC ) 2−nC−4n · n−Cn µ(x) · 2−Cn + 2−nC−3n (uses C1) µ(x)(2−Cn + 2−2n+1), ≤ Zx ≤ Zx (24) where the last inequality is by (23). With this, we are ready to prove the third item. Zx µ(x) − µ1(x) = Zx∈B2(0,nC ) µ(x) − µ1(x) +Zx6∈B2(0,nC ) µ(x) − µ1(x) = Zx∈B2(0,nC ) µ(x) − µ1(x) +Zx6∈B2(0,nC ) µ(x) (by definition of µ1) ≤ Zx∈B2(0,nC ) µ(x) − µ1(x) + 2−Cn (uses C1) ≤ Zx∈B2(0,nC )(cid:12)(cid:12)(cid:12)(cid:12) Rx µ(x)(cid:12)(cid:12)(cid:12)(cid:12) +Zx∈B2(0,nC )(cid:12)(cid:12)(cid:12)(cid:12) Rx µ1(x) − Rx µ(x) − Rx µ(x)(cid:12)(cid:12)(cid:12)(cid:12) + 2−Cn.(25) µ1(x) µ1(x) µ1(x) µ(x) Here the last inequality uses the definitions of µ and µ1 and the triangle inequality. We now bound the terms in Appendix B individually. We start with the first term. To bound the second term, we have · Vol(B(0, nC )) (uses 23) · 2n · nCn ≤ 2−2n. (26) Zx∈B2(0,nC )(cid:12)(cid:12)(cid:12)(cid:12) µ1(x) Rx µ(x)(cid:12)(cid:12)(cid:12)(cid:12) ≤ 2−nC −4n·n−Cn 2−n−1−nC ≤ 2−nC −4n·n−Cn 2−n−1−nC µ(x) Rx µ(x) − Rx µ(x)(cid:12)(cid:12)(cid:12)(cid:12) ≤Zx∈B2(0,nC ) µ1(x) Zx∈B2(0,nC )(cid:12)(cid:12)(cid:12)(cid:12) Combining this with (26) and plugging back into (25), we get µ1(x) µ1(x) Rx µ1(x) − Zx µ(x) − µ1(x) ≤ 2−Cn + 2−2n + 2−Cn + 2−2n+1 ≤ 2− 3n Rx µ1(x) · (2−Cn + 2−2n+1) ≤ 2−Cn + 2−2n+1. 2 . The above assumes that n ≥ 5. This finishes the proof. 42
1904.04916
2
1904
2019-05-17T06:53:25
The Complexity of Subtree Intersection Representation of Chordal Graphs and Linear Time Chordal Graph Generation
[ "cs.DS", "cs.CC" ]
It is known that any chordal graph on $n$ vertices can be represented as the intersection of $n$ subtrees in a tree on $n$ nodes. This fact is recently used in [2] to generate random chordal graphs on $n$ vertices by generating $n$ subtrees of a tree on $n$ nodes. It follows that the space (and thus time) complexity of such an algorithm is at least the sum of the sizes of the generated subtrees assuming that a tree is given by a set of nodes. In [2], this complexity was mistakenly claimed to be linear in the number $m$ of edges of the generated chordal graph. This error is corrected in [3] where the space complexity is shown to be $\Omega(m n^{1/4})$. The exact complexity of the algorithm is left as an open question. In this paper, we show that the sum of the sizes of $n$ subtrees in a tree on $n$ nodes is $\Theta(m\sqrt{n})$. We also show that we can confine ourselves to contraction-minimal subtree intersection representations since they are sufficient to generate every chordal graph. Furthermore, the sum of the sizes of the subtrees in such a representation is at most $2m+n$. We use this result to derive the first linear time random chordal graph generator. Based on contraction-minimal representations, we also derive structural properties of chordal graphs related to their connectivity. In addition to these theoretical results, we conduct experiments to study the quality of the chordal graphs generated by our algorithm and compare them to those in the literature. Our experimental study indicates that the generated graphs do not have a restricted structure and the sizes of maximal cliques are distributed fairly over the range. Furthermore, our algorithm is simple to implement and produces graphs with 10000 vertices and $4 . 10^7$ edges in less than one second on a laptop computer.
cs.DS
cs
The Complexity of Subtree Intersection Representation of Chordal Graphs and Linear Time Chordal Graph Generation∗† Tınaz Ekim1, Mordechai Shalom2, and Oylum S¸eker1 1 Department of Industrial Engineering, Bogazici University, Istanbul, Turkey ‡ 2 TelHai Academic College, Upper Galilee, 12210, Israel § May 20, 2019 Abstract It is known that any chordal graph on n vertices can be represented as the intersection of n subtrees in a tree on n nodes [5]. This fact is recently used in [2] to generate random chordal graphs on n vertices by generating n subtrees of a tree on n nodes. It follows that the space (and thus time) complexity of such an algorithm is at least the sum of the sizes of the generated subtrees assuming that a tree is given by a set of nodes. In [2], this complexity was mistakenly claimed to be linear in the number m of edges of the generated chordal graph. This error is corrected in [3] where the space complexity is shown to be Ω(mn1/4). The exact complexity of the algorithm is left as an open question. √ In this paper, we show that the sum of the sizes of n subtrees in a tree on n nodes is Θ(m n). We also show that we can confine ourselves to contraction-minimal subtree intersection repre- sentations since they are sufficient to generate every chordal graph. Furthermore, the sum of the sizes of the subtrees in such a representation is at most 2m + n. We use this result to derive the first linear time random chordal graph generator. Based on contraction-minimal representations, we also derive structural properties of chordal graphs related to their connectivity. In addition to these theoretical results, we conduct experiments to study the quality of the chordal graphs generated by our algorithm and compare them to those in the literature. Our experimental study indicates that the generated graphs do not have a restricted structure and the sizes of maximal cliques are distributed fairly over the range. Furthermore, our algorithm is simple to implement and produces graphs with 10000 vertices and 4.107 edges in less than one second on a laptop computer. Keywords: Chordal graph, Representation Complexity, Graph Generation. 1 Introduction Chordal graphs are extensively studied in the literature from various aspects which are motivated by both theoretical and practical reasons. Chordal graphs have many application areas such as ∗The first author acknowledges the support of the Turkish Academy of Science TUBA GEBIP award. †A preliminary version of this work will be presented in the SEA2 2019 conference ‡tinaz.ekim,[email protected] §[email protected] 1 sparse matrix computations, database management, perfect phylogeny, VLSI, computer vision, knowledge based systems, and Bayesian networks (see e.g. [6, 9, 10, 12]). Consequently, numerous exact / heuristic / parameterized algorithms have been developed for various optimization and enumeration problems on chordal graphs. The need for testing and comparing these algorithms motivated researchers to generate random chordal graphs [1, 8, 11]. A more systematic study of random chordal graph generators has been initiated more recently in [2, 3]. The generic method developed in these papers is based on the characterization of chordal graphs as the intersection graph of subtrees of a tree [5], to which we will refer as a subtree intersection representation. In this method a chordal graph on n vertices and m edges is generated in three steps: at Step 2 which is (cid:80)n the size of G, that is O(n + m). In [3], this mistake is corrected by showing that(cid:80)n of chordal graphs. We show that(cid:80)n 1. Generate a tree T on n nodes uniformly at random. 2. Generate n non-empty subtrees {T1, . . . , Tn} of T . 3. Return the intersection graph G of {V (T1), . . . , V (Tn)}. Three methods for generating subtrees in Step 2 have been suggested. In all these methods, every node of every subtree is generated. Steps 1 and 3 being linear in the size of G, the time and space complexities of the algorithm are dominated by the sum of the sizes of the subtrees generated i=1 V (Ti). In [2], this complexity was mistakenly claimed to be linear in i=1 V (Ti) is Ω(mn1/4), leaving the upper bound as an open question. This question is crucial for the complexity of any chordal graph generator that produces every subtree intersection representation on a tree of n nodes. In this paper, we investigate the complexity of subtree intersection representations n). In other words, we both improve the lower bound of Ω(mn1/4) given in [3] and provide a matching upper bound. On the other hand, we show that the size of a "contraction-minimal" representation is linear, more precisely, at most 2m + n. This result plays the key role in developing a linear time chordal graph generator, the first algorithm in the literature having this time complexity, to the best of our knowledge. Our algorithm is also simple to implement. Our experiments indicate that it produces graphs for which the maximal clique sizes are distributed fairly over the range. Furthermore, the running time of the algorithm clearly outperforms the existing ones: graphs with 10000 vertices and 4.107 edges are generated in less than one second on a personal computer. √ i=1 V (Ti) is Θ(m Contraction-minimal representations of chordal graphs are further exploited to exhibit struc- tural properties of chordal graphs. In particular, we show that every minimal representation of a chordal graph G is on a tree with t nodes where t is the number of maximal cliques of G. Subse- quently, we derive from this result that the connectivity of a chordal graph is at most n − t. Using this result, we show that our chordal graph generator can guarantee k-connectivity also in linear time. We proceed with definitions and preliminaries in Section 2. Then, for technical reasons, we first consider contraction-minimal representations in Section 3. We develop our linear time random chordal graph generator in Section 3.1. We study the variety of chordal graphs generated by this algorithm in Section 3.2; to this end, following the practice in similar studies in the literature, we analyze maximal cliques of the generated graphs. In Section 3.3, we analyze the links between contraction-minimal representations and the connectivity properties of chordal graphs they repre- sent. We proceed with the complexity of arbitrary subtree intersection representations in Section 4. We conclude in Section 5 by suggesting further research. 2 2 Preliminaries Graphs: We use standard terminology and notation for graphs, see for instance [4]. We denote by [n] the set of positive integers not larger than n. Given a simple undirected graph G, we denote by V (G) the set of vertices of G and by E(G) the set of the edges of G. We denote an edge between two vertices u and v as uv. We say that a) the edge uv ∈ E(G) is incident to u and v, b) u and v are the endpoints of uv, and c) u and v are adjacent to each other. We denote by G/e the graph obtained from G by contracting the edge e. A chord of a cycle C of a graph G is an edge of G that connects two vertices that are non-adjacent in C. A graph is chordal if it contains no induced cycles of length 4 or more. In other words, a graph is chordal if every cycle of length at least 4 contains a chord. A vertex v of a graph G is termed simplicial if the subgraph of G induced by v and its neighbors is a complete graph. A graph G on n vertices is said to have a perfect elimination order if there is an ordering v1, . . . , vn of its vertices, such that vi is simplicial in the subgraph induced by the vertices {vi, . . . , vn} for every i ∈ [n]. It is known that a graph is chordal if and only if it has a perfect elimination order [6]. Trees, subtrees and their intersection graphs: Let T = {T1, . . . , Tn} be a set of subtrees of a tree T . Let G = (V, E) be a graph over the vertex set {v1, . . . , vn} where vi represents Ti and such that vi and vj are adjacent if and only if Ti and Tj have a common node. Then, G is termed as the vertex-intersection graph of (cid:104)T,T (cid:105) and conversely (cid:104)T,T (cid:105) is termed a subtree intersection representation, or simply a representation of G. We will denote the intersection graph of (cid:104)T,T (cid:105) simply as G(T ). Gavril [5] showed that a graph is chordal if and only if it is the vertex-intersection graph of subtrees of a tree. Throughout this work, we refer to the vertices of T as nodes to avoid possible confusion with the vertices of G(T ). Let G be a chordal graph with a representation (cid:104)T,T (cid:105), and j be a node of T . We denote as Tj the set of subtrees in T that contain the node j, i.e. Tj = {Ti ∈ T j ∈ V (Ti)}. Clearly, the set Tj corresponds to a clique of G that we will denote Vj. It is also known that, conversely, if K is a maximal clique of G then K = Vj for some node j of T . Two sets of subtrees T and T (cid:48) are equivalent if G(T ) = G(T (cid:48)). Let T be a set of subtrees of a tree T and e an edge of T . We denote by T/e the set of subtrees of T/e that is obtained by contracting the edge e of every subtree in T that contains e. A set of subtrees is contraction-minimal (or simply minimal ) if for every edge e of T we have G(T/e) (cid:54)= G(T ). Throughout the rest of this work, G is a chordal graph with vertex set [n] and m edges, T is a tree on t ≤ n nodes and T = {T1, . . . , Tn} is a set of subtrees of T such that G(T ) = G and (cid:104)T,T (cid:105) is contraction-minimal. We will adopt index i ∈ [n] for vertices of G and subtrees in T whereas index j ∈ [t] is used to denote the nodes of T . We also denote by tj = Tj the number of subtrees in T that contain the node j of T . The nodes of T are numbered such that def def tt = max{tjj ∈ [t]} and all the other vertices are numbered according to a bottom-up order of T where t is the root. In what follows, we first analyze contraction-minimal representations, then proceed into the analysis of the general case. 3 3 Contraction-minimal Representations We first show in Section 3.1 that the size of a contraction-minimal representation is at most 2m+n. Based on this result, we derive a linear time algorithm to generate random chordal graphs. In Section 3.2, we conduct experiments to compare chordal graphs obtained by our algorithm to those in the literature. Our experimental study indicates that our method is faster than existing methods in the literature. Our algorithm produces graphs with 10000 vertices and 4.107 edges in less than one second on a personal computer. In addition, the generated graphs do not have a restricted structure as far as the size of their maximal cliques are concerned. In Section 3.3, we first show that minimal representations are exactly those representations of chordal graphs on a so-called clique tree of it. Subsequently, we analyze the links between contraction-minimal representations and the connectivity of the corresponding chordal graphs. We show that the connectivity of a chordal graph is at most n − t and derive from this result a modification of our random chordal graph generator which ensures k-connectivity of the produced chordal graph also in linear time. 3.1 Chordal Graph Generation in Linear Time The following observation plays an important role in our proofs as well as in our chordal graph generation algorithm. Observation 1 (cid:104)T,T (cid:105) is minimal if and only if for every edge jj(cid:48) of T , none of Tj and Tj(cid:48) contains the other (i.e., both Tj \ Tj(cid:48) and Tj(cid:48) \ Tj are non-empty). Proof: Suppose that Tj ⊆ Tj(cid:48) for some edge jj(cid:48) of T and let v be the node obtained by the contraction of the edge jj(cid:48). Then every pair of subtrees that intersect on j also intersect on j(cid:48). Thus, they intersect also on v (after the contraction of jj(cid:48)). Conversely, every pair of subtrees that intersect on v contains at least one of j, j(cid:48). By our assumption, they contain j(cid:48), thus they intersect on j(cid:48). Therefore, a pair of subtrees intersect in T if and only if they intersect in T/jj(cid:48). Therefore, G(T/jj(cid:48)) = G(T ), thus (cid:104)T,T (cid:105) is not contraction-minimal. j (cid:54)= ∅ for every edge jj(cid:48) of T . Then, for every edge jj(cid:48) of T there exists a subtree that contains j but not j(cid:48) and another subtree that contains j(cid:48) but not j. These two subtrees do not intersect, but they intersect on v after the contraction of jj(cid:48). Therefore, G(T/jj(cid:48)) (cid:54)= G(T ) for every edge jj(cid:48) of T . We conclude that (cid:104)T,T (cid:105) is contraction-minimal. (cid:3) j \Tj (cid:54)= ∅ and Tj \T (cid:48) Now suppose that T (cid:48) Lemma 1 Let (cid:104)T,T (cid:105) be a minimal representation of some chordal graph G on n vertices and m edges. There exist numbers s1, . . . , st such that ∀j ∈ [t] sj ≥ 1, t(cid:88) sj ≤ tj ≤ t(cid:88) sj = n, j=1 j=1 4 sjtj − t(cid:88) t(cid:88) j=1 2 si i=j s2 j = 2m + n (1) (2) (3) (4) j is at most the number of subtrees containing node j. Observe also that tj ≤ n −(cid:80)j−1 Proof: Consider the following pruning procedure of T that implies a perfect elimination order for G. We first remove the leaf j = 1 from T and all the simplicial vertices of G which are represented by the subtrees Ti ∈ T that consist of the leaf j = 1. There is at least one such subtree by Observation 1. We continue in this way for every j ∈ [t] until both T and G vanish. Let Gj be the remaining graph at step j before node j is removed, and sj be the number of simplicial vertices of Gj eliminated with the removal of node j. Clearly, the numbers sj satisfy relations (1) and (2). Recall that tj = Tj. To see that (3) holds, observe that the number of subtrees removed at step i=1 si as the subtrees eliminated at prior steps do not contain the node j by the choice of the nodes to be removed at every step. To show (4), let ej be the number of edges of G that have been eliminated at phase j of the pruning procedure (during which node j of T is removed). We recall that a clique of sj vertices is removed, each vertex of which is adjacent to tj − sj other vertices of G. Therefore, ej = sj(sj − 1)/2 + sj(tj − sj), i.e., 2ej + sj = 2sjtj − s2 j . Summing up over all j ∈ [t] we get t(cid:88) sjtj − t(cid:88) 2 t(cid:88) s2 j = (2ej + sj) = 2m + n. (cid:3) We are now ready to prove the main result of this section. j=1 j=1 j=1 Theorem 1 If (cid:104)T,T (cid:105) is a minimal representation of some chordal graph G on n vertices and m edges then one to both sides of the equation. We conclude as follows using Lemma 1: j=1 tj since every node of every subtree Ti contributes j=1 j=1 j=1 j=1 where the first inequality and the last equality hold by relations (1) and (4) of Lemma 1 and the second inequality is obtained by replacing tj with tj + (tj − sj) and noting that tj − sj ≥ 0. (cid:3) We now present algorithm GenerateContractionMinimal that generates a random contraction- minimal representation together with the corresponding chordal graph where every contraction- minimal representation has a positive probability to be returned. It creates a tree T at random by starting from a single node and every time adding a leaf j(cid:48) adjacent to some existing node j that is chosen uniformly at random. Every time a node j(cid:48) is added, the algorithm performs the following: a) a non-empty set of subtrees consisting of only j(cid:48) is added to T , b) a proper subset of the subtrees in Tj (i.e., those containing j) is chosen at random and every subtree of it is extended by adding the node j(cid:48) and the edge jj(cid:48), c) the graph G is extended to reflect the changes in T . A pseudo code of the algorithm is given in Algorithm 1. Theorem 2 Algorithm GenerateContractionMinimal generates a chordal graph in linear time. Moreover, it generates any chordal graph on n vertices with strictly positive probability. 5 Proof: We first note that(cid:80)n t(cid:88) i=1 n(cid:88) i=1 V (Ti) =(cid:80)t tj ≤ t(cid:88) sjtj ≤ 2 V (Ti) ≤ 2m + n. t(cid:88) sjtj − t(cid:88) s2 j = 2m + n Algorithm 1 GenerateContractionMinimal Require: n ≥ 1 Ensure: A contraction-minimal representation (cid:104)T,T (cid:105) with T = n, and G = G(T ). 1: T ← ∅. 2: G ← (∅,∅). 3: j(cid:48) ← NewNode. 4: T ← ({j(cid:48)} ,∅). 5: while T < n do 6: 7: 8: 9: 10: 11: 12: Pick a node j of T uniformly at random. j(cid:48) ← NewNode. T ← (V (T ) + j(cid:48), E(T ) + jj(cid:48)). Pick a proper subset T (cid:48) of Tj at random. for all Ti ∈ T (cid:48) do Ti ← (V (Ti) + j(cid:48), E(Ti) + jj(cid:48)). E(G) ← E(G) ∪ {i} × Vj(cid:48). return ((cid:104)T,T (cid:105) , G). 15: 16: 13: function NewNode Pick a number k ∈ [n − T ] at random. 14: j(cid:48) ← a new node. U ← ({j(cid:48)} ,∅). T ← T ∪ k copies of U . Vj(cid:48) ← a clique on k vertices. G ← G ∪ Vj(cid:48). return j(cid:48). 17: 18: 19: 20: (cid:46) A tree with a single vertex Proof: The algorithm creates the tree T incrementally, and the subtrees of T are created and extended together with T . More precisely, the set of subtrees containing a node of T is not altered after a newer node is created. Note that, however, the subtrees themselves might be altered to contain newer nodes. Consider an edge jj(cid:48) of T where j(cid:48) is newer than j. The sets Tj and Tj(cid:48) of the subtrees containing j and j(cid:48) respectively, are established by the end of the iteration that creates j(cid:48). Since only a proper subset of Tj is chosen to be extended to j(cid:48), at least one subtree in Tj does not contain j(cid:48). Furthermore, since j(cid:48) is created with a non-empty set of subtrees containing it, and none of these subtrees may contain j, there is at least one subtree in Tj(cid:48) that does not contain j. Therefore, by Observation 1, we conclude that (cid:104)T,T (cid:105) is contraction-minimal. We proceed with the running time of the algorithm. It is well known that the addition of a single node and the addition of a single edge to a graph can be done in constant time. We observe (cid:1) =(cid:12)(cid:12)Vj(cid:48)(cid:12)(cid:12) +(cid:12)(cid:12)E(Vj(cid:48))(cid:12)(cid:12). Therefore, the that the number of operations performed by NewNode is k +(cid:0)k (cid:12)(cid:12)E(Vj(cid:48))(cid:12)(cid:12). Let jj(cid:48) number of operations performed in all invocations of NewNode is n +(cid:80) this iteration is exactly (cid:12)(cid:12)E(G) ∩ (Vj × Vj(cid:48))(cid:12)(cid:12). We conclude that the number of operations of the Consider a contraction-minimal representation(cid:10) ¯T , ¯T(cid:11) with(cid:12)(cid:12) ¯T(cid:12)(cid:12) = n and let ¯t =(cid:12)(cid:12) ¯T(cid:12)(cid:12). It remains to show that the algorithm returns(cid:10) ¯T , ¯T(cid:11) with a positive probability. be the edge added to T at some iteration of GenerateContractionMinimal. We now observe that the number of other operations (i.e., except the invocation of NewNode) performed during algorithm is proportional to n + E(G). j(cid:48)∈V (T ) 2 6 We show by induction on h, that at the beginning of iteration h (the h'th time the algorithm subtree of ¯T and T consists of the non-empty intersections of the subtrees of ¯T with T (formally, executes Line 6) (cid:104)T,T (cid:105) is a sub-representation of(cid:10) ¯T , ¯T(cid:11) with positive probability. That is, T is a T = (cid:8) ¯Ti[V (T )] ¯Ti ∈ ¯T(cid:9) \ {(∅,∅)}) with positive probability. Let ¯j(cid:48) be a node of ¯T , and let ¯k =(cid:12)(cid:12) ¯T ¯j(cid:48)(cid:12)(cid:12). Clearly, ¯k ≤ n. With probability 1/n the algorithm will start by creating a node with ¯k trivial subtrees in which case (cid:104)T,T (cid:105) is a sub-representation of(cid:10) ¯T , ¯T(cid:11). Therefore, the claim holds for h = 1. Now suppose that (cid:104)T,T (cid:105) is a sub-representation of(cid:10) ¯T , ¯T(cid:11) at the beginning of iteration h with probability p > 0. If T = ¯T then (cid:104)T,T (cid:105) =(cid:10) ¯T , ¯T(cid:11), thus T =(cid:12)(cid:12) ¯T(cid:12)(cid:12) = n and the algorithm does is at most n − T . Since(cid:10) ¯T , ¯T(cid:11) is contraction-minimal, we have ¯k ≥ 1. Therefore, ¯k ∈ [n − T ] and the algorithm creates ¯k trivial subtrees in j(cid:48) with probability 1/(n − T ) > 1/n. Since(cid:10) ¯T , ¯T(cid:11) h + 1), (cid:104)T,T (cid:105) is a sub-representation of(cid:10) ¯T , ¯T(cid:11) with probability at least p/(n22n) > 0. (cid:3) not proceed to iteration h. Otherwise, T is a proper subtree of ¯T , i.e. ¯T contains an edge jj(cid:48) with j ∈ V (T ) and j(cid:48) /∈ V (T ). At iteration h, j will be chosen with probability 1/V (T ) ≥ 1/n by the algorithm and the edge jj(cid:48) will be added to T , ensuring that T is a subtree of ¯T with probability at least p/n at the end of iteration h. The number ¯k of subtrees in ¯T that contain j(cid:48) but not j is contraction-minimal, the set of subtrees in ¯T that contain both j and j(cid:48) is a proper subset of ¯Tj = Tj. The algorithm chooses this proper subset with probability 1/(2Tj − 1) and adds the edge jj(cid:48) to each of them. We conclude that at the end of iteration h (thus at the beginning of iteration 3.2 Experimental studies In this section, we present our experimental results to demonstrate the computational efficiency of GenerateContractionMinimal and to provide some insight into the distribution of chordal graphs it generates. We implemented the presented algorithm in C++, and executed it on a laptop computer with 2.00-GHz Intel Core i7 CPU. The implementation of the algorithm spans only 70 lines of C++ code. Our source code is available in http://github.com/cmshalom/ChordalGraphGeneration. m Following the approach of works [2,3,11], we consider the characteristics of the maximal cliques of the returned graph. Table 1 provides a summary of the computational results of our algorithm. The first column reports the number of vertices n. For every value of n, we use four different average edge density values of 0.01, 0.1, 0.5, and 0.8, where edge density is defined as ρ = n(n−1)/2 with m being the number of edges in the graph. For each pair of values n, ρ, we performed ten independent runs and reported the average values across those ten runs. The table exhibits the number of connected components, the number of maximal cliques, and the minimum, maximum, and average size of the maximal cliques along with their standard deviation. The rightmost column shows the time in seconds that it takes the algorithm takes to construct one graph. In order to achieve the desired edge density values, we discarded the graphs that turned out to be outside the range [(1 − )ρ, (1 + )ρ], for  = 0.05. For ρ ≤ 0.1, we adjusted the upper bound at Line 14 in function NewNode so that graphs with small edge densities are obtained more probably. Algorithm GenerateContractionMinimal produces connected chordal graphs for ρ ≥ 0.1. When the average edge density is 0.01, the average number of connected components decreases as n increases. A minimum clique size of 1 for ρ = 0.01 and n = 1000 implies that the disconnectedness of the graphs is due to the existence of isolated vertices. As for the running time of the algorithm, the linear time complexity shown in Theorem 2 clearly manifests itself in the amount of time it takes to construct a chordal graph. The rightmost column of Table 1 shows that our algorithm 7 Table 1: Experimental results of algorithm GenerateContractionMinimal n Density # # conn. comp.s maximal cliques 1000 2500 5000 10000 0.010 0.100 0.500 0.780 0.010 0.100 0.507 0.808 0.010 0.102 0.503 0.796 0.010 0.100 0.499 0.797 24.6 1.0 1.0 1.0 6.3 1.0 1.0 1.0 1.7 1.0 1.0 1.0 1.4 1.0 1.0 1.0 422.2 62.8 9.5 6.5 582.8 70.7 10.0 7.2 703.6 78.5 9.7 7.2 825.0 90.0 9.9 9.2 Min clique size 1.0 7.3 92.5 167.2 1.1 12.4 227.5 379.9 1.8 22.7 457.6 775.5 2.8 32.0 829.4 902.7 Max clique size 17.2 125.0 520.0 767.4 38.8 311.9 1357.7 1997.9 75.7 635.1 2479.1 3986.7 146.4 1385.9 5343.8 8125.6 Avg clique size 5.8 43.3 255.7 393.1 12.1 101.4 617.6 931.1 21.8 196.1 1236.1 1914.0 40.4 356.9 2407.2 3065.4 Sd of clique sizes 2.9 26.8 127.1 201.0 6.7 65.8 330.4 535.3 12.9 131.0 636.2 1058.4 25.3 266.5 1366.3 2243.1 Time to build 0.002 0.003 0.008 0.010 0.005 0.010 0.030 0.049 0.014 0.035 0.166 0.204 0.036 0.132 0.659 0.952 constructs a chordal graph in less than one second on average, even when n = 10000 and ρ = 0.797, i.e., m > 4 · 107. We compare our results to those of the two other methods from the literature. The first one is algorithm ChordalGen proposed in S¸eker et al.'s work [3], which is based on the subtree inter- section representation of chordal graphs. This algorithm is presented along with three alternative subtree generation methods. Here, we only consider algorithm ChordalGen together with the subtree generation method called GrowingSubtree, because this one is claimed to stand out as compared to the other presented methods, as far as the distribution of maximal clique sizes are concerned. The second algorithm we compare to is Andreou et al.'s algorithm [1]. This algorithm is also used in [3] for comparison purposes, and we refer to the implementation therein. In order to obtain results comparable to those given in [3], we use the same n, ρ value pairs in our experiments. We now compare the results in Table 1 to those reported in [3] for algorithm ChordalGen with GrowingSubtree and Andreou et al.'s algorithm. We observe that the number of max- imal cliques of the graphs produced by GenerateContractionMinimal is usually lower than the others, and inevitably, their average clique sizes are higher than the others. The most no- table difference of our algorithm from the others is its running time. Whereas a running time analysis of Andreou et al.'s algorithm has not been given in [1], the average running time of our implementation of their algorithm is of 477.1 seconds per generated graph, excluding graphs on 10000 vertices for which the algorithm was extremely slow. The average running times of our im- plementation of algorithm ChordalGen is 93.2, 4.7, 182.6 seconds with the subtree generation methods GrowingSubtree, ConnectingNodes, and PrunedTree, respectively. Algorithm GenerateContractionMinimal, however, achieves an average running time of 0.14 seconds. In our next set of experimental results, we investigate the distribution of the sizes of maximal cliques to get some visual insight into the structure of the chordal graphs produced. Figure 1 shows 8 the average number of maximal cliques across ten independent runs for n = 1000 vertices and four edge density values. The figure is comprised of three rows, each row describing the result of the experiments on one algorithm; algorithms GenerateContractionMinimal, ChordalGen combined with GrowingSubtree method, and the implementation of Andreou et al.'s algorithm [1] as given in [3]. Every row consists of four histograms corresponding to four different average edge density values ρ = 0.01, 0.1, 0.5, and 0.8. The bin width of the histograms is taken as five; that is, frequencies of maximal clique sizes are summed over intervals of width five (from one to five, six to ten, etc.) and divided by the number of runs (i.e., ten) to obtain the average values. For a given n and average edge density value, we keep the ranges of x-axes the same in order to make the histograms comparable. The y-axes, however, have different ranges because maximum frequencies in histograms vary considerably. (a) Results from algorithmGenerateContractionMinimal. (b) Results from algorithm ChordalGen with GrowingSubtree method. (c) Results from Andreou et al.'s method [1]. Figure 1: Histograms of maximal clique sizes for n = 1000 and average edge densities 0.01, 0.1, 0.5, and 0.8 (from left to right). The histograms in Figure 3.2 reveal that the sizes of maximal cliques of graphs produced by our algorithm are not clustered around specific values; they are distributed fairly over the range. The shapes of the histograms for average edge densities 0.01 and 0.1 are similar for our algorithm and algorithm ChordalGen, as we observe from the first half of Figure 3.2 and 3.2. For higher densities (as we proceed to the right), the sizes of maximal cliques are distributed more uniformly in the graphs generated by our algorithm; there is no obvious mode of the distribution. In the graphs produced by Andreou et al.'s method, the vast majority of maximal cliques have up to 15 vertices when the average edge densities are 0.01 and 0.1. As we increase the edge density, frequencies of large-size maximal cliques become noticeable relative to the dominant frequencies of small-size 9 maximal cliques. In any case, the range outside its extremes is barely used. For brevity, we do not present the histograms for every n-value we consider in this study. Having presented the histograms for the smallest value of n we consider, next we provide the set of results for a larger value of n. The implementation of Andreou et al.'s algorithm [1] turned out to be too slow to allow testing graphs on 10000 vertices in a reasonable amount of time. In order to present a complete comparison with the methods we look at from the literature, we provide the results for the next largest value of n in Figure 2. From the histograms in Figure 2, we observe that the general distribution of maximal clique sizes do not change much with the increase in the number of vertices. Maximal clique sizes of chordal graphs produced by our algorithm are not confined to a limited area; they are distributed fairly over the range. To summarize, our experiments show that GenerateContractionMinimal is by far faster than the existing methods in practice, in accordance with our theoretical bounds. Moreover, our inspection of the generated graphs in terms of their maximal cliques shows that the algorithm produces chordal graphs with no restricted structure. (a) Results from algorithm GenerateContractionMinimal. (b) Results from algorithm ChordalGen with GrowingSubtree method. (c) Results from Andreou et al.'s method [1]. Figure 2: Histograms of maximal clique sizes for n = 5000 and average edge densities 0.01, 0.1, 0.5, and 0.8 (from left to right). 3.3 Structural Consequences By further analysis of contraction-minimal representations of chordal graphs, we show in this section that minimal representations are exactly those representations of chordal graphs on a so-called clique tree of it. Consequently, they provide us with important information about the connectivity 10 properties of chordal graphs they represent. Maximal cliques and clique trees: A clique tree of a chordal graph G is a tree T such that a) there is a bijection between the maximal cliques of G and the nodes of T and for every vertex i ∈ V (G), the nodes of T corresponding to maximal cliques of G that contain i form a subtree of T . It is well-known that a chordal graph on n vertices has at most n maximal cliques [6], thus every clique tree of it has at most n nodes. It turns out that there is a one-to-one correspondence between minimal representations of a chordal graph and its clique trees as shown in the following. Proposition 1 (cid:104)T,T (cid:105) is a minimal representation of a chordal graph G if and only if T is a clique tree of G and every vertex i of G is represented by the subtree Ti of T induced by the nodes representing the maximal cliques of G containing i. Proof: Let T be a clique tree of G and T = {T1, . . . Tn} where Ti is the subtree of T corresponding to the maximal cliques containing the vertex i of G. We claim that (cid:104)T,T (cid:105) is a minimal representation of G. Indeed, consider an edge e = jj(cid:48) of T . Since j and j(cid:48) correspond to distinct maximal cliques Vj and Vj(cid:48) of G, neither Vj \ Vj(cid:48) nor Vj(cid:48) \ Vj is empty. That is, there is a subtree in T that contains j but does not contain j(cid:48) and vice versa. By Observation 1, (cid:104)T,T (cid:105) is a minimal representation of G. Let now (cid:104)T,T (cid:105) be a minimal representation of G. If T consists of a single node, then G is a complete graph and it has only one maximal clique that corresponds to the single node of T . Therefore, T is a clique tree of G. Otherwise, let e = jj(cid:48) be an edge of T . By Observation 1, neither Tj \ Tj(cid:48) nor Tj(cid:48) \ Tj is empty, i.e., neither Vj \ Vj(cid:48) nor Vj(cid:48) \ Vj is empty. Therefore both Vj and Vj(cid:48) are maximal cliques of G. Since e is an arbitrary edge of T , we conclude that Vj is a maximal clique of G for every node j of T . Let now Vj and Vj(cid:48) be two maximal cliques of G corresponding to two (not necessarily adjacent) nodes j and j(cid:48) in T , where j (cid:54)= j(cid:48). Let j(cid:48)(cid:48) be the node adjacent to j on the path between j and j(cid:48) in T (with possibly j(cid:48)(cid:48) = j(cid:48)). By Observation 1, there is a subtree Ti ∈ T such that Ti ∈ Tj and Ti /∈ Tj(cid:48)(cid:48). Therefore, Ti /∈ Tj(cid:48), thus Vj (cid:54)= Vj(cid:48). We conclude that the maximal cliques corresponding to nodes of T are distinct. Clearly, the subtree Ti that represents a vertex i of G corresponds to the set of maximal cliques that contain i. Therefore, T is a clique tree as claimed. (cid:3) As the number of maximal cliques is a graph invariant, Proposition 1 implies that making any arbitrary representation of a chordal graph minimal by repetitively contracting edges always yields a minimal representation on a tree with the same number of nodes (which is the number of maximal cliques of G). Corollary 1 Given a chordal graph G, every minimal representation (cid:104)T,T (cid:105) of G has a tree T on t nodes where t is the number of maximal cliques of G. Separators and minimal separators: A set S of vertices of a connected graph G is called a separator if G \ S is not connected where G \ S denotes the graph induced by V (G) \ S. For two non adjacent vertices i and i(cid:48) of G, the set S is an i-i(cid:48) separator if i and i(cid:48) are in different connected components of G \ S. An i-i(cid:48) separator is minimal if none of its proper subsets separates i and i(cid:48). We say that S is a minimal separator of G if there exists two non adjacent vertices i and i(cid:48) in G such that S is a minimal i-i(cid:48) separator. A graph is k-connected if it has more than k vertices 11 and every separator of it has at least k vertices. The (vertex) connectivity κ(G) of G is the largest number k such that G is k-connected. Given a representation (cid:104)T,T (cid:105) of a chordal graph G and an edge e of T , we denote by Te the set of subtrees in T that contain e, and by Ve the set of vertices of G represented by them. It is well-known that the minimal separators of a chordal graph are complete subgraphs [6]. The following result describes more precisely the minimal separators of a chordal graph by means of its clique trees. Theorem 3 [7] Given a chordal graph G and any clique tree T of G, a set of vertices S is a minimal separator of G if and only if S = Ve for some edge e of T . Proposition 1 and Theorem 3 imply the following relation between minimal representations of a chordal graph and its minimal separators. Corollary 2 Let (cid:104)T,T (cid:105) be a minimal representation of a chordal graph G where V (T ) = t. Then i) The set of minimal separators of G is {Vee ∈ E(T )}. ii) The number of minimal separators of a chordal graph is at most t − 1. iii) κ(G) = min{Vee ∈ E(T )}. Proposition 2 Let (cid:104)T,T (cid:105) be a minimal representation of a chordal graph G on n vertices where V (T ) = t. Then, i) For every edge e of T , the number of subtrees in T that contain e is at most n − t, ii) κ(G) ≤ n − t. Proof: i) Let (cid:104)T,T (cid:105) be a minimal representation of a chordal graph G on n vertices and e = jj(cid:48) be an edge of T . We prove by induction on t. If t = 2 then since (cid:104)T,T (cid:105) is contraction-minimal, there is at least one subtree in Tj that does not contain jj(cid:48) and at least one subtree in Tj(cid:48) that does not contain jj(cid:48), and we are done. If t > 2 at least one of j, j(cid:48) is not a leaf of T . Therefore, T contains at least one leaf j(cid:48)(cid:48) /∈ {j, j(cid:48)}. Let T (cid:48) = T − j(cid:48)(cid:48) and (cid:104)T (cid:48),T (cid:48)(cid:105) be the sub-representation of (cid:104)T,T (cid:105) where T (cid:48) consists of the non- empty intersections of the subtrees of T with T (cid:48). Then (cid:104)T (cid:48),T (cid:48)(cid:105) is a minimal representation of G[V (cid:48)] where V (cid:48) is the set of vertices of G represented by the subtrees in T (cid:48). By the induction hypothesis, T (cid:48) contains at least V (T (cid:48)) = t − 1 subtrees not containing jj(cid:48). Furthermore, T contains at least one subtree Ti that contains j(cid:48)(cid:48) but not its neighbour in T . Thus Ti ∈ T \ T (cid:48) and it does not contain jj(cid:48). Therefore, T contains at least V (T (cid:48)) + 1 = t subtrees that do not contain jj(cid:48). We conclude that T contains at most n − t subtrees that contain e. ii) We have Ve = Te ≤ n − t. The result follows from Corollary 2. (cid:3) Corollary 3 With the following modifications, GenerateContractionMinimal generates k- connected chordal graphs in linear time. 12 i) At line 9 where a proper subset to contain the edge jj(cid:48) is chosen, pick a proper subset T (cid:48) of Tj of cardinality at least k. ii) At the first invocation of NewNode, create a clique of at least k + 1 vertices. Proof: By Corollary 2, the choice of a proper subset of cardinality at least k, i.e., the successful execution of (the modified) Line 9 at every node is necessary and sufficient for k-connectivity. Suppose that the execution of Line 9 fails at some node of T , and let j be the first node that this If j is not the first node of T , let j(cid:48)(cid:48) be the node chosen by the algorithm when j is happens. created. Since Line 9 did not fail at j(cid:48)(cid:48), at least k subtrees from Tj(cid:48)(cid:48) contain j(cid:48)(cid:48)j. Moreover, at least one more subtree is created by NewNode when j is created. Therefore, Tj contains at least k + 1 subtrees, and Line 9 does not fail at j, a contradiction. We conclude that j must be the first node of T . Therefore, the second modification is sufficient to guarantee that the chordal graph generated by the algorithm is k-connected. Clearly, these modifications do not change the time complexity of GenerateContractionMinimal. (cid:3) Noting that in a minimal representation (cid:104)T,T (cid:105) of a chordal graph G, a subtree of T containing an edge of T yields an edge in G, Proposition 2 implies the following simple characterization of minimal representations of an independent set. Indeed, this can be viewed as a reformulation of the following well known fact in terms of minimal representations: A chordal graph G on n vertices has at most n maximal cliques, with equality if and only if G is an independent set [6]. Observation 2 Let (cid:104)T,T (cid:105) be a minimal representation of a chordal graph G on n vertices where V (T ) = t. Then, G is an independent set if and only if t = n. Proposition 2 also gives some insight about minimal representations of special chordal graphs such as trees and forests as described in Propositions 3 and 4 respectively. Proposition 3 Let (cid:104)T,T (cid:105) is a minimal representation of a connected chordal graph G on n ≥ 2 vertices where V (T ) = t. Then, G is a tree if and only if t = n − 1. Proof: Assume that t = n − 1. Since G is connected, it remains to show that G does not contain cycles. Suppose that G contains a cycle. Since G is chordal, it must contain a triangle. Therefore, the clique number of G is at least 3. Consider an execution of GenerateContractionMinimal that generates the representation (cid:104)T,T (cid:105) and the graph G = G(T ). Let T (j) be the set of subtrees of T generated by the j-th invocation of NewNode (that created the node j of T ). Then (cid:8)T (1), . . . ,T (n−1)(cid:9) is a partition of T . Therefore, (cid:12)(cid:12)T (j)(cid:12)(cid:12) = 2 for some j ∈ [n − 1] and (cid:12)(cid:12)(cid:12)T (j(cid:48))(cid:12)(cid:12)(cid:12) = 1, for every j(cid:48) (cid:54)= j. Corollary 3 implies that j = 1. By the behaviour of GenerateContractionMinimal, it is easy to show by induction on j, that, Tj = 2 for every j ∈ [n − 1]. That is, every maximal clique of G has exactly two vertices, i.e. the clique number of G is at most 2, a contradiction. Conversely, assume that G is a tree on n vertices. The set of maximal cliques of G is the set of its n − 1 edges. By Proposition 1, every minimal representation of G has a tree T on t = n − 1 nodes. (cid:3) We note that a minimal representation of a tree is not unique. For example, let G be a star on n vertices. For every tree T on n − 1 vertices, G has a representation (cid:104)T,T (cid:105). Indeed, T consists of T itself and the n − 1 trivial subtrees of T . 13 If we relax the condition that G is connected in Proposition 3, then we obtain the following result. Proposition 4 i) If (cid:104)T,T (cid:105) is a minimal representation of a chordal graph G on n vertices, and V (T ) = t = n − 1 then G is a forest, where all the trees of G except one are trivial. ii) Every forest on n ≥ 2 vertices with exactly one non-trivial tree has a minimal representation (cid:104)T,T (cid:105) with V (T ) = t = n − 1. Proof: i) By Proposition 2, every edge of T is contained in at most one subtree in T . Let T (1), . . . , T ((cid:96)) be the subtrees of T obtained by the removal of the edges e such that Te = ∅, and ni be the number (cid:12)(cid:12)V (T (i))(cid:12)(cid:12) = t = n−1, of subtrees in T that are contained in T (i) for every i ∈ [(cid:96)]. Clearly,(cid:80)(cid:96) i=1 ni = n, and ni ≥(cid:12)(cid:12)V (T (i))(cid:12)(cid:12) for every i ∈ (cid:96). Therefore, there exists some j ∈ [(cid:96)] such that (cid:80)(cid:96) (cid:12)(cid:12)(cid:12) for every j(cid:48) ∈ [(cid:96)] different than j. By Proposition nj = (cid:12)(cid:12)V (T (j))(cid:12)(cid:12) + 1, and nj(cid:48) = (cid:12)(cid:12)(cid:12)V (T (j(cid:48))) 3, the subtrees in T (j) represent a tree. By Observation 2, the subtrees in T (j(cid:48)) represent an independent set for every j(cid:48) ∈ [(cid:96)] different than j. i=1 ii) Let G be a forest on n vertices, with exactly one non-trivial tree G(cid:48) on n(cid:48) vertices. Let (cid:104)T (cid:48),T (cid:48)(cid:105) be a representation of G(cid:48) with T (cid:48) = n(cid:48) − 1. By adding n − n(cid:48) new nodes to T (cid:48), and adding to T (cid:48) a trivial tree (consisting of that node) for every new node, we get a representation of G on a tree with n − 1 nodes. (cid:3) 4 Arbitrary Representations We start this section by showing that the upper bound of Theorem 1 does not hold for arbitrary representations on trees with n nodes. We denote by L(T ) the set of leaves of a tree T . Lemma 2 Let T (cid:48) = {T (cid:48) of edges of G(T (cid:48)). Then n} be a set of subtrees on a tree with n nodes and m be the number 1, . . . , T (cid:48) n(cid:88) n). i )(cid:12)(cid:12) is Ω(m (cid:12)(cid:12)L(T (cid:48) √ i=1 Proof: Let k be a non-negative integer, and n = 6·32k. Let T (cid:48) be a tree on n nodes {v1, . . . , v4·32k , u1, . . . , u2·32k}, where the nodes {v1, . . . , v4·32k} induce a path and the nodes {u1, . . . , u2·32k} induce a star with center u1. The representation contains the following subtrees: • S1: 2 trivial paths on every node in {v1, . . . , v2·32k}, for a total of 4 · 32k paths, • S2: 3k+1 copies of the star on nodes {u1, . . . , u2·32k}, and • S3: 2 · 32k − 3k+1 disjoint trivial paths on part of the nodes in {v2·32k+1, . . . , v4·32k}. Note that the number of these paths is less than the number 2 · 32k of nodes in the path, thus disjointness can be achieved. 14 n(cid:88) The number of subtrees is 4 · 32k + 3k+1 + 2 · 32k − 3k+1 = 6 · 32k = n, as required. As for the total number of leaves, we have: i )(cid:12)(cid:12) ≥ 3k+1 · (2 · 32k − 1) + 4 · 32k + 2 · 32k − 3k+1 ≥ 6 · 33k. (cid:12)(cid:12)L(T (cid:48) (cid:80)n i=1 L(T (cid:48) i ) Let G be the intersection graph of these subtrees. G consists of a K3k+1, 2 · 32k disjoint K2s and isolated vertices. We have m = 2 · 32k + 3k+1 3k+1−1 6 · 33k 2 · 32k − 3 2 3k √ = Ω(3k) = Ω( , thus ≥ n). i=1 m 13 2 (cid:3) Since the space needed to represent a subtree is at least the number of its leaves, Lemma 2 implies the following: Corollary 4 The time complexity of any algorithm that generates chordal graphs by picking an arbitrary subtree representation on a tree with n nodes is Ω(m n). √ We now proceed to show that this bound is tight up to a constant factor. Through the rest of this section T (cid:48) is a tree on n nodes and T (cid:48) = {T (cid:48) of T (cid:48) such that G(T (cid:48)) = G. We also denote by t(cid:48) the node j of T (cid:48). We assume that (cid:104)T,T (cid:105) is a contraction-minimal representation of G obtained from (cid:104)T (cid:48),T (cid:48)(cid:105) by zero or more successive contraction operations. Then, T has t ≤ n nodes and the multiplicity of j (with respect to T (cid:48)), denoted by kj, is the number of contractions effectuated in T (cid:48) in order to obtain node j in T , plus one. def = j (cid:12)(cid:12)(cid:12)T (cid:48) j (cid:12)(cid:12)(cid:12) the number of subtrees in T (cid:48) that contain n} is a set of subtrees 1, . . . , T (cid:48) Lemma 3 With the above notations, we have i=1 j=1 Proof: Relations (5) and (6) hold by definition of t and multiplicity. When an edge jj(cid:48) of T (cid:48) is contracted to a node v we have kv = kj + kj(cid:48) and tv = max(cid:8)tj, tj(cid:48)(cid:9). Using the above fact and noting that we have (cid:80)n j, inequality (7) follows by induction on the number of contractions. (cid:3) Recall that our task is to find an upper bound on kvtv = (kj + kj(cid:48))tv ≥ kjtj + kj(cid:48)tj(cid:48). i ) = (cid:80)n i=1 V (T (cid:48) Therefore, j=1 t(cid:48) the sum of the sizes of subtrees in a representation on a tree with n nodes of a chordal graph on n vertices. Relation (7) allows us to focus on the sum of kjtj values (in a minimal representation) in order to achieve this goal. In what follows, we treat this task as an optimization problem under a given set of constraints. Thus, the following lemma can be (and should be) read independently from graph theoretic interpretations of each parameter. 15 ∀j ∈ [t] kj ≥ 1 t(cid:88) i )(cid:12)(cid:12) ≤ t(cid:88) (cid:12)(cid:12)V (T (cid:48) j=1 n(cid:88) kj = n. kjtj. (5) (6) (7) Proof: Let kj, sj, tj(j ∈ [t]) be values that maximize ρ which we refer as optimal. Such values exist since kj, tj ≤ n, thus ρ ≤ n3 2m+n . Let also λj = kj/sj. If t = 1 we have k1 = s1 = t1 = n. Then (4) implies 2m + n = n2, thus ρ = 1. Therefore, in the rest of the proof we assume t ≥ 2. Since the only constraints for kj are (5) and (6), and kj does not appear in the denominator of ρ, there are optimal values where Therefore, we have λj = 1 sj (cid:80)t j=1 kj =(cid:80)t−1 j=1 kj + kt ≤(cid:80)t−1 By (3) we have st ≤ tt = (cid:80)t j < t since otherwise tj =(cid:80)t 1 kj = if j = t otherwise. (cid:26) n − t + 1 j=1 sj + kt <(cid:80)t−1 i=t si = st, thus tt = st. Furthermore, tj < (cid:80)t i=j si >(cid:80)t j=1 sj + st = n, a contradiction. ≤ 1 for all j ∈ [t − 1]. This implies λt ≥ 1 since otherwise n = i=j si for every i=t si = tt, contradicting the maximality of tt (recall that tt = max{tjj ∈ [t]}). Also, st = tt ≥ tj ≥ sj for every j ∈ [t]. Let (cid:96) ∈ [t − 1] be such that s(cid:96) = minj∈[t−1] sj. The following claim guarantees optimal values with an even more restricted structure. Claim 1 There are optimal values with sj = tj for every j ∈ [t] different from (cid:96). Proof: Consider optimal values minimizing(cid:80) choice of (cid:96) we have λj ≤ λ(cid:96), and recall that t(cid:96) <(cid:80)t j(cid:54)=(cid:96) tj among all optimal values that satisfy relations (1) - (6) and where kjs are defined as above. Assume by way of contradiction that these values do not satisfy the claim, i.e. there exists j (cid:54)= (cid:96) with sj < tj. Since tt = st, we have j (cid:54)= t. By the sj Let t(cid:48) for some  > 0. We have (cid:96) = t(cid:96) +  and t(cid:48) j = tj −  s(cid:96) sjt(cid:48) j + s(cid:96)t(cid:48) Therefore, if we replace tj, t(cid:96) by t(cid:48) (cid:96) respectively, relation (4) remains valid. Moreover, we can choose  sufficiently small so that all constraints (3) are still satisfied. As for the numerator of ρ, we have (cid:96) = sj(tj −  j and t(cid:48) ) + s(cid:96)(t(cid:96) + ) = sjtj + s(cid:96)t(cid:96). s(cid:96) sj i=(cid:96) si. kjt(cid:48) j + k(cid:96)t(cid:48) (cid:96) = kj(tj −  i.e. the values are optimal. However(cid:80) values were chosen. (cid:3) We now note that t(cid:96) ≤ tt = st = n −(cid:80)t−1 j(cid:54)=(cid:96) tj decreased by  s(cid:96) sj s(cid:96) sj ) + k(cid:96)(t(cid:96) + ) = kjtj + k(cid:96)t(cid:96) + s(cid:96)(λ(cid:96) − λj) ≥ kjtj + k(cid:96)t(cid:96), Lemma 4 Let t, s1, . . . , st, t1, . . . tt and k1, . . . , kt be numbers that satisfy (1), (2), (3), (4), (5), and (6). Then (cid:80)t def = ρ j=1 kjtj 2m + n √ is O( n). t(cid:88) j=1 kjtj = j∈[t−1]\{(cid:96)} (cid:88) sj + (n − t + 1)st + t(cid:96) ≤ (cid:88) sjtj − t(cid:88) t(cid:88) j ≥ t(cid:88) t−1(cid:88) s2 j + s2 s2 j = s2 < n + (n − t + 1)st j∈[t−1]\{(cid:96)} 2m + n = 2 , contradicting the way the optimal j=1 sj. Therefore, we have sj + (n − t + 1)st + n − t−1(cid:88) j=1 + s2 t sj (8) (9) t ≥ (n − st)2 t − 1 j=1 j=1 j=1 j=1 16 where the last inequality holds because(cid:80)t−1 j=1 sj = n − st and when the sum is fixed, the sum of squares is smallest when all numbers are equal. Now, we note that 0 < 2(n − t) + 1 and this is equivalent to (t − 1)n < t(2n − t) − (t − 1)(n − t + 1) which implies in turn the following inequality since st ≥ 1: (t − 1)(n + (n − t + 1)st) < t(2n − t)st. (10) We combine inequalities (8), (9) and (10) as follows ρ < n + (n − t + 1)st (n−st)2 t−1 + s2 t (t − 1)(n + (n − t + 1)st) (n − st)2 + (t − 1)s2 t = < t(2n − t)st n2 − 2nst + ts2 t = ¯ρ(st). t ≥ st(2tst − 2n) if and only if n2 ≥ ts2 t . Therefore, ¯ρ is ∂ ¯ρ ∂st maximum when st = n√ ≥ 0 if and only if n2 − 2nst + ts2 . We conclude √ t(2n − t)n/ √ n2 − 2n2/ ρ < ¯ρ( n√ t ) = t t t + n2 t(2n − t) √ t − 1) 2n( = ≤ 2t(2n − t) √ n t = √ 2 t(2n − t) = ¯¯ρ(t) n √ t to get where we use the fact that t ≥ 2 to derive the inequality. We substitute u = ¯¯ρ(t) = 2u(2n − u2) n = 4u − 2u3 n and we derive Since ∂u ∂t > 0, ¯¯ρ attains its maximum at t = u2 = 2n 3 . We conclude ∂ ¯¯ρ ∂u = 4 − 6u2 n . (cid:114) 2n ¯¯ρ(t) ≤ ¯¯ρ(2n/3) = 4 − 2 n · 2n 3 3 = 8 3 3 (cid:114) 2n (cid:114) 2n 3 . (cid:3) We can now infer the following theorem. Theorem 4 Let (cid:104)T (cid:48),T (cid:48)(cid:105) be a representation of a chordal graph G where T (cid:48) has n nodes and G has n vertices and m edges. Then we have n(cid:88) (cid:12)(cid:12)V (T (cid:48) i )(cid:12)(cid:12) is Θ(m √ n). i=1 Proof: Let (cid:104)T,T (cid:105) be a minimal representation of G obtained from (cid:104)T (cid:48),T (cid:48)(cid:105). Then (cid:104)T,T (cid:105) satisfies (1), (2), (3), (4) by Lemma 1, and (5), (6), (7) hold by Lemma 4. The lower and upper bounds provided in Lemmas 2 and 4 respectively allows us to conclude the proof. (cid:3) 17 5 Conclusion In this work, we present a linear time algorithm to generate random chordal graphs. To the best of our knowledge, this is the first algorithm with this time complexity. Our algorithm is fast in practice and simple to implement. We also show that the complexity of any random chordal graph √ generator which produces any subtree intersection representation on a tree of n nodes with positive probability is Ω(m n). We conducted experiments to analyze the distribution of the sizes of the maximal cliques of the generated chordal graphs. As a result, we concluded that our method generates fairly varied chordal graphs with respect to this measure. It should be noted that, however, we do not know the distribution of the maximal clique sizes over the space of all chordal graphs of a given size. We have shown that every chordal graph on n vertices is returned by our algorithm with positive probability. Our algorithm allows us to analyze connectivity properties of the generated chordal graphs, and can be used to generate chordal graphs having a given (vertex) connectivity. The development of an algorithm that generates chordal graphs uniformly at random is subject of further research. References [1] M. I. Andreou, V. G. Papadopoulou, P. G. Spirakis, B. Theodorides, and A. Xeros. Generating and radiocoloring families of perfect graphs. In Sotiris E. Nikoletseas, editor, Experimental and Efficient Algorithms, pages 302 -- 314, Berlin, Heidelberg, 2005. Springer Berlin Heidelberg. [2] O. S¸eker, P. Heggernes, T. Ekim, and Z. C. Ta¸skın. Linear-time generation of random chordal graphs. In 10th International Conference on Algorithms and Complexity, CIAC 2017, volume 10236 of Lecture Notes in Computer Science, pages 442 -- 453. Springer Berlin Heidelberg, 2017. [3] O. S¸eker, P. Heggernes, T. Ekim, and Z. C. Ta¸skın. Generation of random chordal graphs using subtrees of a tree. arXiv preprint arXiv:1810.13326, 2018. [4] Reinhard Diestel. Graph Theory, 4th Edition, volume 173 of Graduate texts in mathematics. Springer, 2012. [5] Fanica Gavril. The intersection graphs of subtrees in trees are exactly the chordal graphs. Journal of Combinatorial Theory, 16:47 -- 56, 1974. [6] Martin Charles Golumbic. Algorithmic Graph Theory and Perfect Graphs (Annals of Discrete Mathematics, Vol 57). North-Holland Publishing Co., Amsterdam, The Netherlands, 2004. [7] C. W. Ho and R. C. T. Lee. Computing clique trees and computing perfect elimination schemes in parallel. Information Processing Letters, 31:61 -- 68, 1989. [8] L. Markenzon, O. Vernet, and L. H. Araujo. Two methods for the generation of chordal graph. Ann. of Op. Res., 157(1):47 -- 60, 2008. [9] T. A. McKee and F. R McMorris. Topics in Intersection Graph Theory. SIAM monographs on Discrete Mathematics and Applications, 1999. 18 [10] J. Pearl. Probabilistic Reasoning in Intelligent Systems: Networks of Plausible Inference. Morgan Kaufmann, 2014. [11] S. V. Pemmaraju, S. Penumatcha, and R. Raman. Approximating interval coloring and max- coloring in chordal graphs. Journal of Experimental Algorithms, 10:2 -- 8, 2005. [12] D. J. Rose. A graph-theoretic study of the numerical solution of sparse positive definite systems of linear equation. Graph theory and computing, pages 183 -- 217, 1972. 19
1311.6126
1
1311
2013-11-24T14:12:41
An energy function and its application to the periodic behavior of k-reversible processes
[ "cs.DS" ]
We consider the graph dynamical systems known as k-reversible processes. In such processes, each vertex in the graph has one of two possible states at each discrete time step. Each vertex changes its state between the current time and the next if and only if it currently has at least k neighbors in a state different than its own. For such processes, we present a monotonic function similar to the decreasing energy functions used to study threshold networks. Using this new function, we show an alternative proof for the maximum period length in a k-reversible process and provide better upper bounds on the transient length in both the general case and the case of trees.
cs.DS
cs
An energy function and its application to the periodic behavior of k-reversible processes Leonardo I. L. Oliveira Valmir C. Barbosa Programa de Engenharia de Sistemas e Computação, COPPE Universidade Federal do Rio de Janeiro Caixa Postal 68511, 21941-972 Rio de Janeiro - RJ, Brazil Fábio Protti∗ Instituto de Computação Universidade Federal Fluminense Rua Passo da Pátria, 156, 24210-240 Niterói - RJ, Brazil Abstract We consider the graph dynamical systems known as k-reversible pro- cesses. In such processes, each vertex in the graph has one of two possible states at each discrete time step. Each vertex changes its state between the current time and the next if and only if it currently has at least k neighbors in a state different than its own. For such processes, we present a monotonic function similar to the decreasing energy functions used to study threshold networks. Using this new function, we show an alterna- tive proof for the maximum period length in a k-reversible process and provide better upper bounds on the transient length in both the general case and the case of trees. Keywords: k-reversible processes, Threshold networks, Energy function, Graph dynamical systems. ∗Corresponding author ([email protected]). 1 1 Introduction Let G be a simple, undirected, finite graph with n vertices and m edges. The set of vertices of G is denoted by V (G) = {v1, v2, . . . , vn}, its set of edges by E(G), and its maximum node degree by ∆(G). A k-reversible process on G is an iterative process in which, at each discrete time t, each vertex in G has one of two possible states. The state of a vertex is represented by an integer belonging to the set {−1, +1} and each vertex has its state changed from one time to the next if and only if it currently has at least k neighbors in a state different than its own, where k is a positive integer. We denote by x(t) the sequence in which the ith component, xi(t), is the state of vertex vi at time t, and by op(t) the sequence in which the ith component, op i(t), is the number of neighbors of vi in a state different than its own at time t. Any sequence x(t) is called a configuration and the sequence x(0) is an initial configuration. Regarding the periodic behavior of such processes, p(x(0)) denotes the length of the period reached after a finite number of steps starting with configuration x(0). The length of the transient is denoted by τ (x(0)). Formally, p(x(0)) and τ (x(0)) are integer numbers such that: • x(t + p(x(0))) = x(t) for any t ≥ τ (x(0)); • x(t + q) 6= x(t) for any t < τ (x(0)) or q < p(x(0)). The motivation to study k-reversible processes is related to the analysis of opinion dissemination in social networks. As graph dynamical systems, their study is multidisciplinary and related to several other areas, like optics [4], neural networks [8], statistical mechanics [1], and opinion [2] and disease [9] dissemination. In the work by Dreyer [3], some important results regarding the periodic behavior of k-reversible processes are presented; for instance, τ (x(0)) is O(m + n2) and p(x(0)) ≤ 2. Most of these results are based on reductions from the so-called threshold networks, which are broadly studied by Goles and Olivos [6, 5]. It is known that, for all threshold networks, p(x(0)) ≤ 2 [7, 10]. An intuitive approach to prove this result is based on a monotonic function called an energy function. Its definition is very similar to that of the energy function associated with Hopfield networks [8] and it is a Lyapunov function. This function is used to prove several results associated with the period and transient lengths of threshold and majority networks. The remainder of the paper is organized as follows. In Section 2 we describe the new energy function for k-reversible processes and some of its properties. In Section 3 we use this function to provide an alternative proof of the maximum length of the period and of the transient length for k-reversible processes, for the general case and also for trees. Section 4 contains our conclusions. 2 2 An energy function for k-reversible processes Let S1(t) and S2(t) be subsets of V (G), defined as a function of time t as follows: S1(t) = {vi op i(t) ≥ k} and S2(t) = {vi op i(t) < k}. (1) We define a nonnegative energy function E(t) for k-reversible processes as fol- lows: E(t) = X (op i(t) − k) + X (k − op i(t)). (2) i∈S1(t) i∈S2(t) We also define an auxiliary function E ′(t) that will be helpful later in this section to prove that E(t) is a monotonically nondecreasing function: E ′(t) = X (op i(t + 1) − k) + X (k − op i(t + 1)). (3) i∈S1(t) i∈S2(t) Lemma 1. E(t) = E ′(t) for all t ≥ 0. Proof. From (2) and (3), we have E(t) = X op i(t) − X op i(t) − S1(t)k + S2(t)k (4) i∈S1(t) i∈S2(t) and E ′(t) = X op i(t + 1) − X op i(t + 1) − S1(t)k + S2(t)k. (5) i∈S1(t) i∈S2(t) Thus, we need to show that X op i(t) − X op i(t) = X op i(t + 1) − X op i(t + 1). (6) i∈S1(t) i∈S2(t) i∈S1(t) i∈S2(t) First we define the following sets: • A(t) = {(vi, vj ) ∈ E(G) vi ∈ S1(t), vj ∈ S1(t), xi(t) 6= xj(t)}; • B(t) = {(vi, vj) ∈ E(G) vi ∈ S2(t), vj ∈ S2(t), xi(t) 6= xj(t)}; • C(t) = {(vi, vj ) ∈ E(G) \ (A(t) ∪ B(t)) xi(t) 6= xj(t)}. Then we note that P i∈S1(t) 2B(t) + C(t). Therefore, i∈S2(t) op i(t) = 2A(t) + C(t) and that P op i(t) = X op i(t) − X op i(t) = 2A(t) − 2B(t). (7) i∈S1(t) i∈S2(t) Next we define the following sets: 3 • A′(t) = {(vi, vj) ∈ E(G) vi ∈ S1(t), vj ∈ S1(t), xi(t + 1) 6= xj (t + 1)}; • B ′(t) = {(vi, vj) ∈ E(G) vi ∈ S2(t), vj ∈ S2(t), xi(t + 1) 6= xj (t + 1)}; • C ′(t) = {(vi, vj) ∈ E(G) \ (A′(t) ∪ B ′(t)) xi(t + 1) 6= xj (t + 1)}. In a manner similar to the above, we have X op i(t + 1) − X op i(t + 1) = 2A′(t) − 2B ′(t). (8) i∈S1(t) i∈S2(t) We finally note that A(t) = A′(t) and B(t) = B ′(t), whence X op i(t + 1) − X op i(t + 1) = 2A(t) − 2B(t), (9) i∈S1(t) i∈S2(t) which completes the proof. Let ∆E(t) be the variation in the energy function from time t to time t + 1, i.e., ∆E(t) = E(t + 1) − E(t). An important property of the energy function E(t) is given in the following lemma. Lemma 2. E(t) is a monotonically nondecreasing function. Proof. By Lemma 1, Then ∆E(t) = E(t + 1) − E ′(t). ∆E(t) = X (op i(t + 1) − k) + X (k − op i(t + 1)) i∈S1(t+1) i∈S2(t+1) − X (op i(t + 1) − k) − X (k − op i(t + 1)). i∈S1(t) i∈S2(t) (10) (11) Focusing on each vertex's contribution to ∆E(t) yields: • op i(t + 1) − k − op i(t + 1) + k = 0, if vi ∈ S1(t) and vi ∈ S1(t + 1); • k − op i(t + 1) − k + op i(t + 1) = 0, if vi ∈ S2(t) and vi ∈ S2(t + 1); • k − op i(t + 1) − opi(t + 1) + k = 2(k − opi(t + 1)) > 0, since k > op i(t + 1), if vi ∈ S1(t) and vi ∈ S2(t + 1); • op i(t + 1) − k − k + opi(t + 1) = 2(op i(t + 1) − k) ≥ 0, since op i(t + 1) ≥ k, if vi ∈ S2(t) and vi ∈ S1(t + 1). The lemma follows from noting that no vertex contributes negatively to ∆E(t). 4 3 Application of the energy function to the study of the periodic behavior of k-reversible pro- cesses As G is finite, E(t) cannot grow indefinitely and there exists a time tmax such that E(t) = E(tmax) for all t ≥ tmax. Theorem 3. p(x(0)) ≤ 2 for any x(0). Proof. Let t0 be such that t0 > τ (x(0)) and t0 > tmax. Also, suppose that p(x(0)) > 2. For all t > t0, there cannot be a vertex vi such that vi ∈ S1(t) and vi ∈ S2(t + 1), since this would lead to ∆E(t) > 0, contradicting t > tmax by Lemma 2. Likewise, it cannot be the case that all vertices are in both S1(t) and S1(t + 1), or in both S2(t) and S2(t + 1), since these cases represent periodic behaviors of length at most 2, which contradicts our supposition. Hence, in order for inequality p(x(0)) > 2 to hold, there exists at least one vertex vi such that vi ∈ S2(t) and vi ∈ S1(t + 1), and thus it holds that xi(t) 6= xi(t + 2). That is, there exists a vertex vi such that op i(t) < k and op i(t + 1) = k, otherwise the energy function would increase. As vi ∈ S1(t + 1), then necessarily vi ∈ S1(t + 2), vi ∈ S1(t + 3), vi ∈ S1(t + 4), and so on. Otherwise, if vi ∈ S2(t′) for some t′ > t + 1, then again the energy function would increase, contradicting the assumption that t > tmax. Thus, xi(t) 6= xi(t + 2) and xi(t′ + 2) = xi(t′) for every t′ > t. Hence, vi reaches a periodic behavior only at time t > t0, contradicting t0 > τ (x(0)). It follows that only vertices with periodic behavior of length 2 can exist, thence the theorem. The transient length of a k-reversible process is closely related to E(tmax), since ∆E(t) = 0 for all t ≥ τ (x(0)), otherwise it would be true that x(t + 2) 6= x(t). If t < τ (x(0)), then ∆E(t) = 0 only if there is at least one vertex vi such that vi ∈ S2(t), vi ∈ S1(t + 1), and op i(t + 1) = k. Thus, the energy function may remain unchanged for at most n consecutive steps during the transient phase. Consider a configuration x(t′) and the associated E(t′). This value of the energy function would be the same for exactly n consecutive steps if we had S1(t′) = 1, S2(t′) = n − 1, and the following conditions were true: • S1(t′) S1(t′ + 1) · · · S1(t′ + n − 1); • S2(t′) ! S2(t′ + 1) ! · · · ! S2(t′ + n − 1); • If vi ∈ S2(j) ∩ S1(j + 1), then op i(j + 1) = k. Theorem 4. τ (x(0)) ≤ E(tmax) + n − 1 for any x(0). Proof. In order for the energy function to remain unchanged within a time step, by the argument in the proof of Lemma 2 it is necessary that at least one vertex vi exists for which vi ∈ S2(t), vi ∈ S1(t + 1), and op i(t + 1) = k. We have two cases: 5 • vi belongs to the sets S2(0), S2(1), . . . , S2(t). • There is a time t′ such that 0 < t′ < t and vi ∈ S1(t′), vi ∈ S2(t′ + 1), vi ∈ S2(t′ + 2), . . . , vi ∈ S2(t). Only in the second case does vertex vi contribute to increase the energy function from its value at some time prior to t, since the transition from S1(t′) to S2(t′ + 1) implies such an increase, again as in the proof of Lemma 2. Thus, except for the vertices for which the first case holds, all other vertices that help to keep the energy function constant at time t were responsible for increasing it at a previous time step by at least 2. So, apart from the first-case vertices, the increase in the energy function is, on average, of at least 1 per time step. But the first case can only hold for a vertex once, at time t. After t, any contribution from a vertex to keep the energy function constant is necessarily preceded by an increase of at least 2. Hence, the transient length can be at most E(tmax) + S2(0). However, if S2(0) = n then x(0) is already a periodic configuration. The theorem follows by using S2(0) < n. Corollary 5. τ (x(0)) ≤ n(∆(G) + 1) − 1 for any x(0). Proof. We only need to consider the case of k ≤ ∆(G). The maximum value of E(t) is at most n∆(G), when k = ∆(G) and S2(t) = n. The corollary follows directly from Theorem 4. For the cases in which 2k > ∆(G), this bound can be improved. Corollary 6. If 2k > ∆(G), then τ (x(0)) ≤ n(k + 1) − 1 for any x(0). Proof. The corollary follows directly from Theorem 4 by noting that E(t) ≤ nk when 2k > ∆(G). We proceed by studying the case of trees. Theorem 7. If G is a tree, then E(tmax) = nk. Proof. Using (4) and (7) from the proof of Lemma 1, we obtain E(t) = 2(A(t) − B(t)) + k(S2(t) − S1(t)). (12) If S2(t) = n and S1(t) = 0, then in order to maximize E(t) we need to assume that all vertices in S2(t) have the same state at time t, and consequently B(t) = 0. As S1(t) is empty, A(t) = 0 and E(t) = 2(A(t) − B(t)) + k(S2(t) − S1(t)) = nk. (13) Now assume that S1(t) = w and S2(t) = n − w, with 0 < w < n. When all vertices in S2(t) are in the same state at time t, yielding B(t) = 0, and moreover A(t) = S1(t) − 1, we have E(t) ≤ 2(A(t) − B(t)) + k(S2(t) − S1(t)) = kn + w(2 − 2k) − 2. (14) 6 Note that E(t) > nk if and only if w(2 − 2k) > 2. However, for any k ≥ 1, w(2 − 2k) ≤ 0. Hence, whenever w > 0, there is no configuration x(t) such that E(t) > nk. It follows that the maximum value of the energy function in a tree occurs when all vertices have the same state, thence the theorem. Corollary 8. If G is a tree, then τ (x(0)) ≤ n(k + 1) − 1 for any x(0). Proof. The corollary follows directly from Theorems 4 and 7. Corollary 8 is a clear improvement on Corollary 5. As k is a constant, the upper bound on the length of the transient is linear in the number of vertices. 4 Conclusions We have presented an energy function that is useful to study the periodic behav- ior of k-reversible processes. We have shown that this function is monotonic, and using this fact we have presented and alternative proof that the maxi- mum period length is 2 for such processes, and also that the transient length is O(n∆(G)) in the general case and O(nk) in the case of trees. For 2-reversible processes on trees, we conjecture that the sharp upper bound on the transient length is n − 3, provided n ≥ 5. We give support to this conjecture in Appendix A. Acknowledgments The authors acknowledge partial support from CNPq, CAPES, and FAPERJ BBP grants. References [1] J. Adler. Bootstrap percolation. Physica A, 171:453 -- 470, 1991. [2] M. H. DeGroot. Reaching a consensus. J. Am. Stat. Assoc., 69:167 -- 182, 1974. [3] P. A. Dreyer Junior. Application and Variations of Domination in Graphs. Ph.D. dissertation, The State University of New Jersey, New Brunswick, NJ, 2000. [4] D. C. Ghiglia, G. A. Mastin, and L. A. Romero. Cellular automata method for phase unwrapping. J. Opt. Soc. Am. A, 4:267 -- 280, 1987. [5] E. Goles and J. Olivos. The convergence of symmetric threshold automata. Inform. Control, 51:98 -- 104, 1981. [6] E. Goles and J. Olivos. Periodic behavior of binary threshold functions and applications. Discrete Appl. Math., 3:93 -- 105, 1985. 7 [7] E. Goles-Chacc, F. Fogelman-Soulie, and D. Pellegrin. Decreasing energy functions as a tool for studying threshold networks. Discrete Appl. Math., 12:261 -- 277, 1985. [8] J. J. Hopfield. Neural networks and physical systems with emergent col- lective computational abilities. Proc. Natl. Acad. Sci. USA, 79:2554 -- 2558, 1987. [9] A. R. Mikler, S. Venkatachalam, and K. Abbas. Modeling infectious dis- eases using global stochastic cellular automata. J. Biol. Syst., 13:421 -- 439, 2005. [10] S. Poljak and M. Sůra. On periodical behaviour in societies with symmetric influences. Combinatorica, 3:119 -- 121, 1983. A Supplementary material Conjecture 9. For 2-reversible processes on trees with n ≥ 5, the sharp upper bound on the transient length is n − 3. We have confirmed this conjecture computationally by exhaustive enumer- ation for n ≤ 20. Throughout these experiments, a pattern emerged regarding the trees and initial configurations for which a transient length of exactly n − 3 was verified. This pattern is such that the upper bound is achieved by exactly 2 trees for n even and exactly n−1 n 2 − 1 trees for n odd, always for exactly one initial configuration of the tree in question. Such trees and configurations can be generated by Algorithm 1, whose results are shown in Figure 1 for n = 8 and in Figure 2 for n = 9. 8 Algorithm 1: Generate all trees and corresponding initial configurations leading to a transient length of n − 3 in a 2-reversible process. Input: Number n of vertices. Output: Trees Tj, each with the corresponding initial configuration Xj such that τ (Xj ) = n − 3. 1 begin 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 V ← {v1, v2, . . . , vn}; E ← ∅; j ← 1; for i ← 1 to n − 2 do E ← E ∪ (vi, vi+1); if i = n − 2 then E ← E ∪ (vi, vi+2); for i ← 1 to n do if i is odd then x[i] ← +1; else x[i] ← −1; Tj ← G(V, E); Xj ← x; j ← j + 1; for i ← 3 to n − 3 do if i is odd then E ← E \ (vi, vi−1); E ← E ∪ (vi−1, vi+1); Tj ← G(V, E); Xj ← x; j ← j + 1; if i = n − 3 and n is even then E ← E \ (vi+1, vi+3); E ← E ∪ (vi, vi+3); Tj ← G(V, E); Xj ← x; j ← j + 1; 9 v1 v2 v3 v4 v5 v8 v6 v7 v1 v2 v8 v5 v4 v3 v6 v7 v1 v2 v5 v6 v7 v4 v3 v8 v1 v2 v4 v3 v6 v7 v5 v8 Figure 1: Output of Algorithm 1 for n = 8 (T1 through T4, from top to bottom). Shaded circles indicate state +1, empty circles indicate state −1. v1 v2 v3 v4 v5 v6 v8 v7 v9 v1 v2 v5 v6 v4 v3 v8 v7 v9 v1 v2 v4 v3 v6 v5 v7 v9 v8 Figure 2: Output of Algorithm 1 for n = 9 (T1 through T3, from top to bottom). Shaded circles indicate state +1, empty circles indicate state −1. 10
1510.07676
1
1510
2015-10-26T20:54:31
Faster Exact and Parameterized Algorithm for Feedback Vertex Set in Tournaments
[ "cs.DS" ]
A tournament is a directed graph T such that every pair of vertices are connected by an arc. A feedback vertex set is a set S of vertices in T such that T - S is acyclic. In this article we consider the Feedback Vertex Set problem in tournaments. Here input is a tournament T and integer k, and the task is to determine whether T has a feedback vertex set of size at most k. We give a new algorithm for Feedback Vertex Set in Tournaments. The running time of our algorithm is upper bounded by O(1.618^k + n^{O(1)}) and by O(1.46^n). Thus our algorithm simultaneously improves over the fastest known parameterized algorithm for the problem by Dom et al. running in time O(2^kk^{O(1)} + n^{O(1)}), and the fastest known exact exponential time algorithm by Gaspers and Mnich with running time O(1.674^n). On the way to prove our main result we prove a new partitioning theorem for undirected graphs. In particular we show that the vertices of any undirected m-edge graph of maximum degree d can be colored white or black in such a way that for each of the two colors, the number of edges with both endpoints of that color is between m/4-d/2 and m/4+d/4.
cs.DS
cs
Faster Exact and Parameterized Algorithm for Feedback Vertex Set in Tournaments Mithilesh Kumar∗ Daniel Lokshtanov October 9, 2018 Abstract A tournament is a directed graph T such that every pair of vertices are connected by an arc. A feedback vertex set is a set S of vertices in T such that T − S is acyclic. In this article we consider the Feedback Vertex Set problem in tournaments. Here input is a tournament T and integer k, and the task is to determine whether T has a feedback vertex set of size at most k. We give a new algorithm for Feedback Vertex Set in Tournaments. The running time of our algorithm is upper bounded by O(1.618k + nO(1)) and by O(1.46n). Thus our algorithm simultaneously improves over the fastest known parameterized algorithm for the problem by Dom et al. running in time O(2kkO(1) + nO(1)), and the fastest known exact exponential time algorithm by Gaspers and Mnich with running time O(1.674n). On the way to prove our main result we prove a new partitioning theorem for undirected graphs. In particular we show that the vertices of any undirected m-edge graph of maximum degree d can be colored white or black in such a way that for each of the two colors, the number of edges with both endpoints of that color is between m/4 − d/2 and m/4+d/2. 1 Introduction A feedback vertex set in a graph G is a vertx set S such that G − S is acyclic. For undirected graphs this means that G − S is a forest, while for directed graphs this implies that G − S is a directed acyclic graph (DAG). In the Feedback Vertex Set (FVS) problem we are given as input an undirected graph G and integer k, and asked whether there exists a feedback vertex set of size at most k. The corresponding problem for directed graphs is called Directed Feedback Vertex Set (DFVS). Both problems are NP-complete [11] and have been extensively studied from the perspective of approximation algorithms [1, 9], parameterized algorithms [3, 5, 13], exact exponential time algrithms [15, 17] as well as graph theory [8, 16]. In this paper we consider a restriction of DFVS, namely the Feedback Vertex Set in Tournaments (TFVS) problem, from the perspective of parameterized algorithms and exact exponential time algorithms. We refer to the textbooks of Cygan et al. [4] and Fomin and Kratsch [10] for an introduction to these fields. A tournament is a dircted graph T such that every pair of vertices is connected by an arc, and FVST is simply DFVS when the input graph is required to be a tournament. Even this restricted variant of DFVS has applications in voting systems and rank aggrega- tion [7], and is quite well-studied [2, 7, 12, 14]. TFVS was shown to be fixed parameter tractable by Raman and Saurabh [14], who obtained an algorithm with running time O(2.42k · nO(1)). In 2006, Dom et al. [6] (see also [7]) gave an algorithm for TFVS with running time 2knO(1). Prior to our work this was the fastest known parameterized algorithm for the problem. The fastest ∗Department of Informatics, University of Bergen, Norway {mithilesh.kumardaniello}@ii.uib.no 1 exact exponential time algorithm for TFVS was due to Gaspers and Mnich [12] and has running time O(1.674n). Our main result is a new algorithm for TFVS. The running time of our algorithm is upper bounded by O(1.618k +nO(1)) and by O(1.46n). Thus, we give a single algorithm that simultane- ously significantly improves over the previously best known parameterized algorithm and exact exponential time algorithm for the problem. It is worth noting that the algorithm of Gaspers and Mnich [12] also lists all inclusion minimal feedback vertex sets in the input tournament, while our algorithm can not be used for this purpose. On the way to proving our main result we prove a new balanced edge partition theorem for general undirected graphs. In particular we show that the vertices of any undirected m-edge graph G of maximum degree d can be colored white or black in such a way that for each of the two colors, the number of edges with both endpoints of that color is between m/4 − d/2 and m/4+d/2. This partition theorem is of independent interest, and we believe it will find further applications both in algorithms and in graph theory. Methods. As a preliminary step our algorithm applies the kernel of Dom et al. [7] to ensure that the number of vertices in the input tournament is upper bounded by O(k3). After this step, our algorithm has three phases. In the first phase the algorithm finds, in subexponential time, a "large enough" set M of vertices disjoint from the solution S sought for, such that M is evenly distributed in the topological ordering of T − S. From the set M we can infer a rough sketch of the unique topological ordering of T − S without knowing the solution S. More concretely, every vertex v gets a tentative position in the ordering, and we know that if v is not deleted, then v's position in the topological order of T − S is close to this tentative position. We can now use this tentative ordering to identify conflicts between two vertices u and v. Two vertices u and v are in conflict if their tentative positions are so far apart that we know the order in which they have to appear in the topological sort of T − S, but the arc between u and v goes in the opposite direction. Thus, if u and v are in conflict then at least one of them has to be in the solution feedback vertex set S. The second phase of the algorithm eliminates vertices that are in conflict with more than one other vertex. Suppose that u is in conflict with both v and w. If u is not deleted then both v and w have to be deleted. The algorithm finds the optimal solution by branching and recursively solving the instance where u is deleted, and the instance where u is not deleted but both v and w are deleted. This branching step is the bottleneck of the algorithm and gives rise to the O(1.618knO(1)) and the O(1.46n) running time bounds. The third and last phase of the algorithm deals with the case where every vertex has at most one conflict. Here we apply a divide and conquer approach that is based on our new partitioning theorem. Organization of the paper. In Section 2 we set up definitions and notation, and state a few useful preliminary results. Section 3 describes and analyzes the first phase of the algorithm. Section 4 contains the second phase, as well as the final analysis of the correctness and running time of the entire algorithm, conditioned on the correctness and running time bound of the third and last phase. In Section 5 we formally state and prove our new decomposition theorem for undirected graphs, while the description and analysis of the third phase of the algorithm is deferred to Section 6. 2 Preliminaries In this paper, we work with graphs that do not contain any self loops. A multigraph is a graph that may contain more than one edge between the same pair of vertices. A graph is mixed if it 2 can contain both directed and undirected edges. We will be working with mixed multigraphs; graphs that contain both directed and undirected edges, and where two vertices may have several edges between them. When working with a mixed multigraph G we use V (G) to denote the vertex set, E(G) to denote the set of directed edges, and E(G) to denote the set of undirected edges of G. A directed edge from u to v is denoted by uv. A supertournament is a directed graph T such that for every pair of vertices u, v at least one (and possibly both) edges uv and vu are edges of T . Thus, every tournament is a supertorunament, but not vice versa. Graph Notation. In a directed graph D, the set of out-neighbors of a vertex v is defined as N +(v) := {uvu ∈ E(D)}. Similarly, the set of in-neighbors of a vertex v is defined as N −(v) := {uuv ∈ E(D)}. A triangle in a directed graph is a directed cycle of length 3. Note that in this paper, whenever the term triangle is used it refers to a directed triangle. A topological sort of a directed graph D is a permutation π : V (D) 7→ [n] of the vertices of the graph such that for all edges uv ∈ E(D), π(u) < π(v). Such a permutation exists for a directed graph if and only if the directed graph is acyclic. For an acyclic tournament, the topological sort is unique. For a graph or multigraph G and vertex v, G − v denotes the graph obtained from G by deleting v and all edges incident to v. For a vertex set S, G − S denotes the graph obtained from G by deleting all vertices in S and all edges incident to them. For any set of edges C directed or undirected and set of vertices X, the set NX(C) represents the subset of vertices of X which are incident on an edge in C. For a vertex v ∈ V (G), the set NC(v) represents the set of vertices w ∈ V (G) such that there is an undirected edge wv ∈ C. Fixed Parameter Tractability. A parameterized problem Π is a subset of Σ∗ × N. A param- eterized problem Π is said to be fixed parameter tractable(FPT) if there exists an algorithm that takes as input an instance (I, k) and decides whether (I, k) ∈ P i in time f (k) · nc, where n is the length of the string I, f (k) is a computable function depending only on k and c is a constant independent of n and k. A kernel for a parameterized problem Π is an algorithm that given an instance (T, k) runs in time polynomial in T, and outputs an instance (T ′, k′) such that T ′, k′ ≤ g(k) for a computable function g and (T, k) ∈ P i if and only if (T ′, k′) ∈ Π. For a comprehensive introduction to FPT algorithms and kernels, we refer to the book by Cygan et al. [4]. Preliminary Results. If a tournament is acyclic then it does not contain any triangles. It is a well-known and basic fact that the converse is also true, see e.g. [7]. Lemma 1. [7] A tournament is acyclic if and only if it contains no triangles. Lemma 1 immediately gives rise to a folklore greedy 3-approximation algorithm for TFVS: as long as T contains a triangle, delete all the vertices in this triangle. Lemma 2 (folklore). There is a polynomial time algorithm that given as input a tournament T and integer k, either correctly concludes that T has no feedback vertex set of size at most k or outputs a feedback vertex set of size at most 3k. In fact, TFVS has a polynomial time factor 2.5-approximation, due to Cai et al. [2]. However, the simpler algorithm from Lemma 2 is already suitable to our needs. The preliminary phase of our algorithm for TFVS is the kernel of Dom et al. [7]. We will need some additional properties of this kernel that we state here. Essentially, Lemma 3 allows us to focus on the case when the number of vertices in the input tournament is O(k3). Lemma 3. [7] There is a polynomial time algorithm that given as input a tournament T and integer k, runs in polynomial time and outputs a tournament T ′ and integer k′ such that V (T ′) ≤ V (T ), V (T ′) = O(k3), k′ ≤ k, and T ′ has a feedback vertex set of size at most k′ if and only if T has a feedback vertex set of size at most k. 3 3 Finding an Undeletable, Evenly Spread Out Set Consider a tournament T that has a feedback vertex set H of size at most k. Then T − H is acyclic. Consider now the topological order of T − H. Let M be the set of vertices of T − H whose position in the topological order is congruent to 0 mod log2 k. We have now found a set disjoint from H such that, in the topological order of T − H the distance between two consecutive vertices of M is O(log2 k). We shall see later in the article that having such a set at our disposal is very useful for finding the optimum feedback vertex set H. Of course there is a catch; we defined M using the solution H, but we want to use M to find the solution H. In the rest of this section we show how to find a set M with the above properties without knowing the optimum feedback vertex set H in advance. We begin with a few definitions. Definition 1. Let D be a directed graph. For any pair of vertices u, v ∈ V (D) the set between(D, u, v) is defined as N +(u) ∩ N −(v) \ {u, v}. Observe that for an acyclic tournament T , between(T, u, v) is exactly the set of vertices coming after u and before v in the unique topological ordering of T . Definition 2. Let D be a directed graph and S ⊆ V (D). Two vertices u, v ∈ S are called S-consecutive if uv ∈ E(D) and between(D, u, v) ∩ S = ∅. In an acyclic tournament T and vertex set S, two vertices u and v in S are S-consecutive if no other vertex of S appears between u and v in the topological ordering. Definition 3. Let D be a directed graph and S ⊆ V (D). We define the set of S-blocks in D. Each pair of S-consecutive vertices u and v defines the S-block between(D, u, v). Further, each vertex u ∈ S with no in-neighbors in S defines an S-block N −(u). Each vertex u ∈ D with no out-neighbors in S defines the S-block N +(u). The size of an S-block is its cardinality. In an acyclic tournament T the S-blocks form a partition of V − S, where two vertices are in the same block if and only if no vertex of S appears between them in the topological order of T . For example, consider an acyclic tournament T = u0u1...u11 where vertices are topologically sorted. Let S = {uii mod 4 = 1}. between(T, u1, u9) = {u2, u3, u4, u5, u6, u7, u8}. u5 and u9 are S-consecutive and {u6, u7, u8} is an S-block. The set of all S-blocks in T is {{u0},{u2, u3, u4},{u6, u7, u8},{u10, u11}}. Lemma 4. There exists an algorithm that given a tournament T with V (T ) = O(k3) where k log k ) in 2O( k is an integer, outputs a family of sets M,M = 2O( k log k ) time, such that for every feedback vertex set H of T of size at most k, ∃M ∈ M, such that : 1. M ∩ H = ∅, 2. The size of any M -block in T − H is at most 2 log2 k. Furthermore, M can be enumerated in polynomial space. Proof. Let X be a feedback vertex set of size at most 3k obtained using Lemma 2. Let Y := V (T ) \ X and v0v1...vY −1 be the topological sort of T [Y ] such that the edges in T [Y ] are directed from left to right. Color Y using ⌊log2 k⌋ colors such that for each c′ ∈ [0, ...,Y − 1], vc′ gets color c′ mod ⌊log2 k⌋. For each c ∈ [0, ...,⌊log2 k⌋ − 1], let Yc be the set of vertices in Y which get color c. Each M ∈ M is specified by a 4-tuple hc, H, R, Xi where • c is a color in the above coloring of Y , • H ⊆ Yc such that H ≤ k log2 k , 4 • R ⊆ Y \ Yc, R ≤ H, and • X ⊆ X such that X ≤ 3k log2 k . For each 4-tuple hc, H, R, Xi, let M := (Yc \ H) S R S X. Hence, M is upper bounded by the maximum number of such 4-tuples. M ≤ 2log(log2 k) × k = 2O( k log k ) 6k log2 k × (3k) 3k log2 k log2 k Clearly, all such 4-tuples can be enumerated in polynomial space thereby providing an enumer- ation of M. We prove the correctness of the above algorithm by showing that for every feedback vertex set H of T of size at most k, M contains a set M which satisfies the properties listed in the statement of the lemma. Let H be an arbitrary feedback vertex set of T of size at most k. For each j ∈ [0, ...,⌊log2 k⌋ − 1], let Hj := Yj ∩ H. By averaging, there is a color c such that . For this color c, let H := Hc. Consider a set R obtained as follows: for every 0 < Hc ≤ k vertex v ∈ Hc, pick the first vertex after v (if there is any) in Y \ (Yc ∪ H) in the topological ordering of T [Y ]. Note that T [X \ H] is acyclic. Color X \ H using ⌊log2 k⌋ colors as was done for Y . Let X be the set of all vertices colored 0 in this coloring. The size of any X-block in T [X \ H] is log2 k. Clearly, X ≤ 3k The 4-tuple hc, H, R, Xi described above satisfies all the properties listed in the construction of M. Let M := (Yc \ Hc) S R S X. Clearly, M ∩ H = ∅ and M ∈ M. Since the size of any [(Yc \ Hc) S R]-block in Y is at most log2 k, the size of any M -block in T − H is at most 2 log2 k. log2 k . Lemma 4 gets us quite close to our goal. Indeed, for any feedback vertex set H of size at most k we will find a set M such that the M -blocks in T − H are small. However, the M -blocks of T do not have to be small, because they could contain many vertices from H. The next lemma deals with this problem. Definition 4. Let D be a directed graph. A vertex v ∈ V (D) is consistent with a set M ⊆ V (D) if there are no cycles in D[M ∪ v] containing v. Define a function I that given a directed graph D and a set M ⊆ V (D) outputs a set of vertices inconsistent with M . Define another function L that given a directed graph D, a set M ⊆ V (D) and an integer k outputs a set of vertices which is the union of all M -blocks of size at least 2 log4 k in D − I(D, M ). Lemma 5. There exists an algorithm that given a tournament T on O(k3) vertices where k is an integer outputs a family of set pairs X = {(M1, P1), (M2, P2), ..., (Ml, Pl)},X = 2O( k log k ) in 2O( k log k ) time such that for every feedback vertex set H of size at most k, there exists (M, P ) ∈ X such that 1. M ∩ H = ∅, 2. P ⊆ H, 3. Every vertex of V (T ) \ P is consistent with M , and 4. The size of every M -block in T − P is at most 2 log4 k. Furthermore, X can be enumerated in polynomial space. 5 log2 k Proof. Use the algorithm of Lemma 4 to compute M. For each M ∈ M compute the sets I(T, M ) and L(T, M, k). For each B ⊆ L(T, M, k) such that B ≤ 2k output a pair of sets (M, P ) = (M,I(T, M ) ∪ L(T, M, k) \ B). The set X is the collection of all such pair of sets. We prove that the algorithm satisfies the stated properties. Consider a feedback vertex set H of size at most k By Lemma 4 there exists M ∈ M such that M ∩ H = ∅. Let C = I(T, M ) be the set of vertices that are not consistent with M . These vertices must belong to H. Since, for every vertex v ∈ T − C, T [M ∪ v] is an acyclic tournament, v can be placed uniquely in the topological ordering of T [M ]. Hence, for each v ∈ T − C, there is an unique M -block containing it. Since the size of any M -block in T − H is at most 2 log2 k, the size of each M -block in T − C will be at most k + 2 log2 k. An M -block is called large if its size is at least 2 log4 k. From each large M -block at least 2 log4 k−2 log2 k × 2 log2 k ≤ 2k 2 log4 k − 2 log2 k vertices belong to H. Hence, in total at most log2 k vertices from the union of large M -blocks do not belong to H. Since the algorithm loops over all choices of subsets B ⊆ L(T, M, k), B ≤ 2k , X contains a pair (M, P ) satisfying the properties listed in the lemma. log2 k k Moreover, X is bounded by the product of M and the number of subsets B. Now log2 k = log2 k = 2 3 log k× 2k log k ) = 2O( k log k ) × 2O( k L(T, M, k) ≤ V (T ) which implies the number of subsets B is at most (k3) 2O( k log k ). Hence, X ≤ 2O( k Observe that the algorithm of Lemma 5 does not store the family X , but enumerates all the pairs (M, P ) ∈ X . Our algorithm for TFVS will go through all pairs in (M, P ) ∈ X and for each such pair (M, P ) search for a feedback vertex set H of size at most k such that (M, P ) satisfy the conclusion of Lemma 5 for H. In the next section we shall see that the extra restrictions imposed on H by M and P make it easier to find H. log k ) 2k 4 Faster Algorithm for Tournament Feedback Vertex Set In this section we consider the following problem. We are given as input a tournament T and an integer k, and a pair (M, P ) of vertex set in T . The objective is to find a feedback vertex set H of T of size at most k, such that (M, P ) satisfy the conclusion of Lemma 5. The pair (M, P ) naturally leads to a partition of the vertices of T − (P ∪ M ) into local subtournaments corresponding to the induced graphs on the M -blocks in T−P . At this point the triangles in T −P can be classified into two types: those that are entirely within a subtournament and those whose vertices are shared between more than one subtournament. The goal of our algorithm is to eliminate all the shared triangles. When there are no such triangles left, we can solve the problem independently on each of the subtournaments. Since the subtournaments are small, even brute force search is fast enough. To formalize our approach it is convenient to define an intermediate problem, and interpret the search for a feedback vertex set H such that (M, P ) satisfies the conclusion of Lemma 5 as an instance of this intermediate problem. Let d and t be two positive integers. Consider a class of mixed multigraphs G(d, t) in which each member is a mixed multigraph T with the vertex set V (T ) partitioned into vertex sets V1, V2, ..., Vt such that for each i ∈ [t], Vi ≤ d and Ti := T [Vi] is a supertournament and the undirected edge set is E(T ) ⊆ Si<j Vi × Vj. d-Feedback Vertex Cover (d-FVC) Input: A mixed multigraph T ∈ G(d, t), positive integer k. Parameter: k Task: determine whether there exists a set S ⊆ V (T ) such that S ≤ k and T − S is acyclic and contains no undirected edges. 6 Now we show how TFVS reduces to solving d-feedback vertex cover problem. Lemma 6. There exists a polynomial time algorithm that given a TFVS instance (T, k) and a subset M ⊆ V (T ) outputs a d-FVC instance (T , k) such that T has a feedback vertex set S disjoint from M and S ≤ k if and only if (T , k) is a yes-instance of d-FVC. Proof. We describe an algorithm that reduces T to T on the same set of vertices as in T − M . If T [M ] is not acyclic, then output a trivial no-instance. Otherwise, let B := {B1, B2, ..., Bt} be the set of M -blocks in T such that the elements in B are indexed according to the topological order of T [M ]. We assume that the topological order of T [M ] is such that the edges in T [M ] are directed from left to right. Let V (T ) := V (T )\M . The directed edge set E(T ) is E(T )\{e∀i, j ∈ [t], i 6= j and e ∈ Bj × Bi}. The undirected edge set in T is E(T ) := {undirected(e)i, j ∈ [t], i < j and e ∈ Bj × Bi} where undirected(e) is an undirected edge between the endpoints of e. Now we argue about the correctness. Since T is essentially a subgraph of T − M with some additional undirected edges, we use the same symbol to refer to vertex or directed edge sets in both the instances. Suppose S is a feedback vertex cover of T . Clearly S is disjoint from M . We claim that S is a feedback vertex set of T . The triangles in T − M are of two types: ones whose endpoints lie entirely in Bi for some i and others whose endpoints are shared among multiple M -blocks. Clearly, S hits all the triangles within each subtournament T [Bi] in T . Hence, all that remains to show is that S is also a hitting set for all triangles between different subtournaments T [Bi]. For the sake of contradiction suppose that there is a triangle uvwu in T − M − S such that not all of u, v and w belong to the same subtournament of T . Then at least one edge ab in this triangle is such that a ∈ Bi, b ∈ Bj and i > j. But by the construction of E(T ) there is an undirected edge between a and b implying that at least one of a or b belongs to S, a contradiction. In the other direction, suppose S is a feedback vertex set of T disjoint from M . Clearly, S hits all the triangles within each subtournament T [Bi] in T . Hence, all that remains to show is that S is a hitting set for E(T ). Suppose not. Then there is an undirected edge e = uv ∈ E which is not hit by S. Consider the directed edge in T corresponding to e. Without loss of generality, we can assume that u ∈ Bi and v ∈ Bj for some i, j ∈ [t] such that the directed edge is from u to v and i > j. Now in T , there is a vertex w ∈ M which lies after all elements of Bj and before all vertices of Bi and forms a triangle vwuv. Since, w /∈ S, either u ∈ S or v ∈ S, a contradiction. In light of Lemma 6 we need an efficient algorithm for d-FVC. Next we will give an efficient algorithm for d-FVC and show how it can be used to obtain our claimed algorithm for TFVS. Our algorithm for FVC is based on branching on vertices that appear in at least two edges of E(T ). The case when there are no such vertices has to be handled separately, the algorithm for this case is deferred to Section 6. For now, we simply state the existence of the algorithm for this case, and complete the argument using this algorithm as a black box. Lemma 7. There exists an algorithm running in 1.5874s · 2O(d2+d log s) · nO(1) time which finds an optimal feedback vertex cover in a mixed multigraph T ∈ G(d, t) in which the undirected edge set E(T ) is disjoint and E(T ) = s. The proof of Lemma 7 can be found in Section 6. Armed with Lemma 7 we can give a simple and efficient algorithm for d-FVC. The algorithm is based on branching. In the course of the branching we will sometimes conclude (or guess) that a vertex v is not put into the solution S. The operation described below encapsulates the effects of making a vertex undeletable. In a mixed multigraph D, for any vertex v, D/v is a mixed multigraph obtained by adding a directed edge uw in D − v for every u ∈ N −(v) and w ∈ N +(v). The next lemma shows that looking for a solution disjoint from v amounts to putting all the undirected neighbors NE (v) of v into the solution, and finding the optimum solution of (T − NE (v))/v. 7 Lemma 8. Let (T , k) be a d-FVC instance. If for any vertex v ∈ V (T ) such that NE (v) = ∅, then (T , k) has a solution of size at most k not containing v if and only if (T /v, k) is a yes- instance. Proof. Let S be a feedback vertex cover of T of size at most k not containing v. We show that S is a feedback vertex cover of T /v. Clearly, S hits every undirected edge in T /v. For the sake of contradiction suppose there is a cycle of length 3 containing v in T /v not hit by S. If this cycle is in T − v, then it is hit by S. Hence, the triangle must contain an edge not in T − v. Note that T /v is obtained by adding a directed edge yx for every triangle xyvx in T − v thereby creating a 2-cycle between x and y. Since v /∈ S, either x ∈ S or y ∈ S, a contradiction. For the same reason there are no cycles of length 2 in T /v − S. Now suppose S is a feedback vertex cover of T /v. Since every cycle in T − v is a cycle in T /v which are hit by S, we need to consider cycles in T containing v. But, for every such cycle xyvx we have a cycle xyx of length 2 in T /v which is hit by S, we have that T − S is acyclic. Lemma 9. There exists an algorithm for d-FVC running in 1.466n · 2O(d2+d log n) time and in 1.618k · 2O(d2+d log k) · nO(1) time. Proof. We describe a recursive algorithm which searches for a potential solution S of size at most k by branching. For any vertex v, let NE (v) denote the set of vertices w such that vw ∈ E. Let s = E. As long as there is a vertex v such that NE (v) ≥ 2 and k > 0, the algorithm branches by considering both the possibilities: either v ∈ S or v /∈ S. In the branch in which v is picked, n and k are decreased by 1 each and v is removed from the graph. In the other branch, NE (v) is added to S, and k is decreased by NE (v). At the same time, NE (v) is removed from the graph. Since, NE (v) = ∅, by Lemma 8 (T , k) is reduced to (T /v, k). Thus the number of vertices is decreased by NE [v]. The algorithm stops branching further in a branch in which either k < 0 or k > 0 and for every vertex v, NE (v) ≤ 1. In the case that k < 0, the algorithm terminates the branch and moves on to other branches. In the other case, if E(T ) > k, the algorithm terminates that branch, otherwise the algorithm of Lemma 7 is applied. If the size of the optimal solution of Lemma 7 is at most k, then the algorithm outputs yes and terminates, otherwise the algorithm moves to another branch. If the algorithm fails to find any solution of size at most k in every branch, it outputs no. Now we do the runtime analysis of the algorithm. At each internal node of the recursion tree, the algorithm spends polynomial time. At a leaf node, either the algorithm terminates or makes a call to the algorithm of Lemma 7 with parameter s = E(T ) which is at most k. So, we need to bound the number of times Lemma 7 is called with parameter s for each value of s in [k]. Note that for any s, the smallest value of k with which a call to the algorithm of Lemma 7 is made is s. Therefore, for each value of s ∈ [k], the number of calls to the algorithm of Lemma 7 is bounded by the number of nodes in the recursion tree with k = s. The recurrence relation for bounding the number of leaves in the recursion tree of the algorithm is given by: fs(k) ≤ fs(k − 1) + fs(k − 2) which solves to fs(k) ≤ 1.618k−s as fs(k) ≤ 1 for k = s. Hence, the runtime of the algorithm is upper bounded by 1.618k−s × 1.5874s · 2O(d2+d log s) · nO(1) ≤ 1.618k · 2O(d2+d log k) · nO(1). k P s=1 We can do a similar analysis to bound the runtime in terms of n. Note that in direct correspondence with the fact that when ever k decreases by 1, n decreases by 1 and whenever k decreases by x ≥ 2, n decreases by x + 1, we get the following recurrence relation: fs(n) ≤ fs(n − 1) + fs(n − 3) 8 implying fs(n) ≤ 1.466n−s as fs(k) ≤ 1 for n = s. If s is the size of of the graph, then the largest value of E with which a call to the algorithm of Lemma 7 is made, is at most s 2 . Hence, 2 · 2O(d2+d log n) · nO(1) ≤ the runtime of the algorithm is upper bounded by 1.466n · 2O(d2+d log n) · nO(1). 1.466n−s × 1.5874 n P s=1 s Having shown an efficient algorithm for d-FVC, we are now in position to prove our main theorem. Theorem 1. There exists an algorithm for TFVS running in O(1.466n) time and in O(1.618k + nO(1)) time. Proof. The algorithm begins by running the kernelization algorithm of Lemma 3 for the given TFVS instance. In the remainder we assume that n = O(k3). Next the algorithm proceeds to apply Lemma 5 to create a family of set pairs X . For each set pair (M, P ) ∈ X it determines whether there is a feedback vertex set H of size at most k such that H ∩ M = ∅ and P ⊆ H as follows: First it runs the algorithm of Lemma 6 with input (T − P, k − P) and M to reduce the problem to an equivalent d-FVC instance which is then passed to the algorithm of Lemma 9 as input. The algorithm outputs yes and terminates if the output of the algorithm of Lemma 9 is yes. If no solution of size at most k is obtained for any set pair in X , the algorithm outputs no and terminates. The correctness of the algorithm follows from Lemma 5 and Lemma 6. The running time of the algorithm is upper bounded by X times (the runtime of the algorithm of Lemma 9). Since X = 2o(k) and the bulk of the algorithm is run on a tournament with at most O(k3) vertices the total time used by the algorithm is upper bounded by O(1.466n) and O(1.618k + nO(1)). We have now proved our main result, assuming the correctness of Lemma 7. The remainder of the paper is devoted to proving Lemma 7. The engine of the algorithm of Lemma 7 is a new graph partitioning theorem. The next section contains the statement and proof of this theorem, while Section 6 wraps up the proof of Lemma 7, thereby completing the proof of Theorem 1. 5 Balanced Edge Partition Theorem Given an undirected graph G,E(G) = m, if each vertex in V (G) is colored red or blue uniformly at random, then in expectation there will be m 4 blue edges, where a red edge is an edge whose both endpoints are red and a blue edge is an edge whose both endpoints are blue. Using Chebysev inequality it can be shown that, with high probability, the number of red or blue edges will be within O(√md) of m 4 where d is the maximum degree of a vertex in the graph. A proof of this fact is skipped in favor of a local search algorithm which runs in polynomial time and provides a coloring with smaller deviation from the expected value than random coloring. 4 red edges and m Theorem 2. Given an undirected, multigraph without self-loops and isolated vertices G of max- imum degree at most d and E(G) = m, there exists a partition (A, B) of V (G) such that • m • m • m 2 ≤ E(G[A]) ≤ m 2 ≤ E(G[B]) ≤ m 4 − d 4 + d 2 , 4 − d 4 + d 2 − d ≤ E(G[A, B]) ≤ m 2 + d 2 , and 9 where E(G[A, B]) is the set of edges with one endpoint in A and other in B. Furthermore, there is a polynomial time algorithm to obtain this partition. Proof. The following local search algorithm is used to obtain the desired partition: 4 4 + E(G[B]) − m At each step, the algorithm maintains a partition (A, B) of V (G). As long as there exists a vertex v ∈ A (or v ∈ B) such that moving it to other part decreases the measure µ = E(G[A]) − m 4 , the algorithm changes the partition to (A \ v, B ∪ v) (or (A ∪ v, B \ v)). The algorithm terminates if no vertex can be moved. Since µ ≤ m and in each step, it decreases by at least one, above algorithm terminates in polynomial time. Correctness: Let mA := E(G[A]), mB := E(G[B]), and mC := E(G[A, B]). Let x := mA− m and y := mB − m 4 when the algorithm terminates. Then, µ = x + y. For any vertex v, let av denote the number of edges incident on v whose other endpoints are in A and bv denote the number of edges incident on v whose other endpoints are in B. Clearly, for every vertex v, av + bv ≤ d. Suppose that a vertex v ∈ A is moved to B. The new partition is (A′, B′) = (A \ v, B ∪ v). Then, mA′ = m 4 + y + bv and the measure at this partition is µ′ = x− av +y + bv. Define δv A := µ′ − µ = x− av−x +y + bv−y. Similarly, if a vertex v ∈ B moves to A creating new partition (A′, B′) = (A ∪ v, B \ v), we can define B := µ′ − µ = x + av − x + y − bv − y. Note that since the algorithm has terminated, for δv any vertex v ∈ V (G), δv 2 and y ≤ d x > d A = x − av − x + bv. Suppose A = av − x − x + bv = av + bv − 2x. But, for every vertex v ∈ V , av + bv ≤ d A < 0, a contradiction. 2 . For the sake of contradiction assume the following possible values of x and y: 2 , y > d that x < av, δv which implies δv Hence, for all vertices v ∈ A, x ≥ av, δv that av > bv, then δv P v∈A A = x − av − x + bv = bv − av. If v ∈ A is such A < 0, a contradiction. Hence, for all vertices v ∈ A, av ≤ bv. Then, B ≥ 0. Then, the claim of the theorem is that x ≤ d 2 : Consider moving a vertex v ∈ A to B. Then, δv bv =⇒ 2mA ≤ mC =⇒ mC ≥ m 2 + d which is a contradiction. 4 + x − av, mB ′ = m A ≥ 0 and δv 2 + 2x > m av ≤ P v∈A x < − d v∈A v∈A m bv =⇒ 2mA ≥ mC =⇒ mC ≤ m 2 : Consider moving a vertex v ∈ A to B. Then, δv 2 : Consider moving a vertex v ∈ A to B. Then, δv A = y−bv−y+av = A < 0, a contradiction. Hence, for all vertices 2 + 2x < A = y + bv−y+ av. Suppose A = bv − y − y + av = av + bv − 2y. But, for all vertices v, av + bv ≤ d 2 , y < − d that y < bv, δv which implies that av − 2y + bv < 0, i.e. δv A < 0, a contradiction. Hence, for every vertex v ∈ A, we have that y ≥ bv and therefore, δv av − bv. If v ∈ A is such that av < bv, then δv av ≥ P v ∈ A, av ≥ bv. This implies that P 2 − d which is a contradiction. 2 , y < − d A := µ′ − µ = x− av−x +y + bv − y < 0 as x − av − x ≤ 0 and y + bv − y ≤ 0 and at least one of the inequalities is strict, hence a contradiction. 2 , x < − d 2 ,y ≤ d av − 2x + y + bv − y ≤ av − 2x + bv < 0, a contradiction. Hence, for every vertex v ∈ A, x ≥ av, then δv that av > bv, then δv av ≤ bv. This implies that P which is a contradiction. 2 ,x ≤ d 2 : Similar to the previous case. 2 : Consider moving a vertex v ∈ A to B. Suppose that x < av, then δv A = y+bv−y−av ≤ bv−av. If v ∈ A is such A < 0, a contradiction. Hence, for every vertex v ∈ A, we have that 2 + d bv =⇒ 2mA ≤ mC =⇒ mC ≥ m 2 : Similar to the previous case. 2 + 2x > m av ≤ P A = v∈A v∈A 10 x > d y > d x > d y > d x < − d 2 ,y ≤ d 2 : Consider moving a vertex v ∈ B to A. If x ≥ av, then δv B = av − 2x + y − bv − y ≤ av − 2x + bv < 0, a contradiction. So, for every vertex v ∈ B, x < av and 0 ≤ δv B = x − av − x + y − bv − y ≤ −av + bv. Hence, for each vertex v ∈ B, av ≤ bv. This implies P 2 which is a contradiction. 2 ,x ≤ d y < − d Hence, x ≤ d the theorem. 2 : Similar to the previous case. 2 . This implies that s 2 and y ≤ d bv =⇒ mC ≤ 2mB =⇒ mC ≤ m 2 + d. This concludes the proof of 2 − d ≤ mC ≤ s 2 + 2y < m av ≤ P v∈B v∈B 6 d-Feedback Vertex Cover with Undirected Degree at Most One Now that we are equipped with Theorem 2, we are almost ready to prove Lemma 7. First we show a lemma that encapsulates the use of Theorem 2 inside the algorithm of Lemma 7. Lemma 10. There exists a polynomial time algorithm that given a mixed multigraph T ∈ G(d, t) with disjoint undirected edge set E(T ) outputs a partition (X, Y ) of V (T ) such that there are no directed edge with one endpoint in X and other in Y and • E(X) ∩ E − s • E(Y ) ∩ E − s • E(X, Y ) ∩ E − s 4 ≤ d 2 , 4 ≤ d 2 and 2 ≤ d where s = E(T ) and E(X) is the set of undirected edges in T [X], E(Y ) is the set of undirected edges in T [Y ] and E(X, Y ) is the set of undirected edges with one endpoint in X and other in Y . Proof. Construct an undirected, multigraph Z such that V (Z) = {zii ∈ [t]} and E(Z) = {zizjuv ∈ E, u ∈ Vi, v ∈ Vj}. Run the algorithm of Theorem 2 to get the partition (A, B) of V (Z). Output X := S Vi and Y := S Vi. i,zi∈A i,zi∈B Since E is disjoint and for each i ∈ [t], Vi ≤ d, maximum degree of a vertex in Z is at most d. Hence, the correctness of the algorithm and the size bound in the lemma follows from Theorem 2. We are now ready to prove Lemma 7. For convenience we re-state it here. Lemma 7 There exists an algorithm running in 1.5874s · 2O(d2+d log s) · nO(1) time which finds an optimal feedback vertex cover in a mixed multigraph T ∈ G(d, t) in which the undirected edge set E(T ) is disjoint and E(T ) = s. Proof. The algorithm maintains a set S which is initialized to the empty set ∅. If the underlying undirected graph of T is disconnected, then the algorithm solves each connected component independently and outputs S as the union of sets returned for each component. If s ≤ d, then S is an optimal solution set obtained by a brute force search in the instance. If s > d, the algorithm obtains a partition (X, Y ) of V (T ) by running the algorithm of Lemma 10. Then, it loops over all subsets C ⊆ E(X, Y ), calling itself recursively on T (cid:2)V (T ) \ (VX (C)∪ VY (E(X, Y ) \ C))] and computes SC := VX(C)∪ VY (E(X, Y )\ C)∪ S′ where S′ is the set returned at the recursive call. Finally, the algorithm outputs the smallest set SC over all choices of C ⊆ E(X, Y ). 11 Now to argue about the correctness of the algorithm, we use induction on E(T ). In the base case E(T ) ≤ d, S is an optimal feedback vertex cover. As the induction hypothesis, suppose that the algorithm outputs an optimal solution for d < E(T ) < s. Consider E(T ) = s. Note that for any C ⊆ E(X, Y ), SC is a d-feedback vertex cover as VX (C) ∪ VY (E(X, Y ) \ C) is a hitting set for E(X, Y ) and by the induction hypothesis, S′ is an optimal solution for T [V (T ) \ (VX (C) ∪ VY (E(X, Y ) \ C))]. At the same time, for any C ⊆ E(X, Y ), VX(C) ∪ VY (E(X, Y ) \ C) = E(X, Y ) which is the size of the smallest hitting set for E(X, Y ). Let So be an optimal solution and Co := E(So ∩ X, Y \ So). Then, we claim that SCo = So. Clearly, SCo ≥ So. Now, So \ VX(Co) ∪ VY (E(X, Y ) \ Co) is a d-feedback vertex cover for T [V (T ) \ (VX (Co) ∪ VY (E(X, Y ) \ Co))]. Therefore, S′ ≤ So \ (VX(Co) ∪ VY (E(X, Y ) \ Co) = So − E(X, Y ) =⇒ SCo ≤ So, thus proving the claim. Now we proceed to the runtime analysis of the algorithm. Let h(s, d) be the maximum number of leaves in the recursion tree of the algorithm when run on an input with parameters s and d. Since, in each recursive call, s decreases by at least 1, the depth of the recursion tree is at most s. In each internal node of the recursion tree, the algorithm spends polynomial time in size of the input and in each leaf, it spends at most 2O(d2) time as the total number of vertices in each connected component of T is O(d2). Thus, the runtime of the algorithm on any input with parameters s and d is upper bounded by h(s, d) × 2O(d2) × nO(1). To upper bound h(s, d), first note that h(a, d)+ h(b, d) ≤ h(a+ b, d) because h(a, d) and h(b, d) represent the number of leaves of two independent subtrees. Now for each C ⊆ E(X, Y ), in T [V (T )\(VX (C)∪VY (E(X, Y )\C))], the undirected edge set E(X, Y ) = ∅. Hence, the algorithm effectively solves T [V (T ) \ (VX (C)] and T [V (T ) \ VY (E(X, Y ) \ C)] independently where by Lemma 10, the number of undirected edges is at most s 2 + d. Hence, the 2 +d. As we have seen for each C, the algorithm number of choices for C ⊆ E(X, Y ) is at most 2 calls itself twice on graphs with the undirected edge set size at most s 2 . So in total, the algorithm makes 2 2 . Thus h(s, d) is upper bounded by the recurrence relation h(s, d) ≤ 21+ s 2 , d) which solves to h(s, d) = 1.5874s · 2O(d log s). Hence, the runtime of the algorithm is bounded by 1.5874s · 2O(d log s)× 2O(d2)× nO(1) = 1.5874s · 2O(d2+d log s) · nO(1). 2 for each instance. Again by Lemma 10, E(X, Y ) ≤ s 4 + d 2 +d+1 recursive calls with parameter s 2 +dh( s 4 + d 4 + d s s 4 + d The proof of Lemma 7 completes the proof of our main result, an algorithm for TFVS with running time upper bounded by O(1.466n) and by O(1.618k + nO(1)). References [1] Vineet Bafna, Piotr Berman, and Toshihiro Fujito. A 2-approximation algorithm for the undirected feedback vertex set problem. SIAM J. Discrete Math., 12(3):289 -- 297, 1999. [2] Mao-cheng Cai, Xiaotie Deng, and Wenan Zang. An approximation algorithm for feedback vertex sets in tournaments. SIAM J. Comput., 30(6):1993 -- 2007, 2000. [3] Jianer Chen, Yang Liu, Songjian Lu, Barry O'Sullivan, and Igor Razgon. A fixed-parameter algorithm for the directed feedback vertex set problem. J. ACM, 55(5), 2008. [4] Marek Cygan, Fedor V. Fomin, Lukasz Kowalik, Daniel Lokshtanov, D´aniel Marx, Marcin Pilipczuk, Michal Pilipczuk, and Saket Saurabh. Parameterized Algorithms. Springer, 2015. [5] Marek Cygan, Jesper Nederlof, Marcin Pilipczuk, Michal Pilipczuk, Johan M. M. van Rooij, and Jakub Onufry Wojtaszczyk. Solving connectivity problems parameterized by treewidth in single exponential time. In IEEE 52nd Annual Symposium on Foundations of Computer Science, FOCS 2011, Palm Springs, CA, USA, October 22-25, 2011, pages 150 -- 159, 2011. 12 [6] Michael Dom, Jiong Guo, Falk Huffner, Rolf Niedermeier, and Anke Truss. Fixed-parameter tractability results for feedback set problems in tournaments. In Algorithms and Complexity, 6th Italian Conference, CIAC 2006, Rome, Italy, May 29-31, 2006, Proceedings, pages 320 -- 331, 2006. [7] Michael Dom, Jiong Guo, Falk Huffner, Rolf Niedermeier, and Anke Truss. Fixed-parameter tractability results for feedback set problems in tournaments. J. Discrete Algorithms, 8(1):76 -- 86, 2010. [8] P Erdos and L P´osa. On independent circuits contained in a graph. Canad. J. Math, 17:347 -- 352, 1965. [9] Guy Even, Joseph Naor, Baruch Schieber, and Madhu Sudan. Approximating minimum feedback sets and multicuts in directed graphs. Algorithmica, 20(2):151 -- 174, 1998. [10] Fedor V. Fomin and Dieter Kratsch. Exact Exponential Algorithms. Texts in Theoretical Computer Science. An EATCS Series. Springer, 2010. [11] Michael R. Garey and David S. Johnson. Computers and Intractability: A Guide to the Theory of NP-Completeness. Series of Books in the Mathematical Sciences. W. H. Freeman and Co., 1979. [12] Serge Gaspers and Matthias Mnich. Feedback vertex sets in tournaments. Journal of Graph Theory, 72(1):72 -- 89, 2013. [13] Tomasz Kociumaka and Marcin Pilipczuk. Faster deterministic feedback vertex set. Inf. Process. Lett., 114(10):556 -- 560, 2014. [14] Venkatesh Raman and Saket Saurabh. Parameterized algorithms for feedback set problems and their duals in tournaments. Theor. Comput. Sci., 351(3):446 -- 458, 2006. [15] Igor Razgon. Computing minimum directed feedback vertex set in o(1.9977n). In Theo- retical Computer Science, 10th Italian Conference, ICTCS 2007, Rome, Italy, October 3-5, 2007, Proceedings, pages 70 -- 81, 2007. [16] Bruce Reed, Neil Robertson, Paul Seymour, and Robin Thomas. Packing directed circuits. Combinatorica, 16(4):535 -- 554, 1996. [17] Mingyu Xiao and Hiroshi Nagamochi. An improved exact algorithm for undirected feedback vertex set. J. Comb. Optim., 30(2):214 -- 241, 2015. 13
1712.06763
1
1712
2017-12-19T03:15:14
A tight lower bound for an online hypercube packing problem and bounds for prices of anarchy of a related game
[ "cs.DS" ]
We prove a tight lower bound on the asymptotic performance ratio $\rho$ of the bounded space online $d$-hypercube bin packing problem, solving an open question raised in 2005. In the classic $d$-hypercube bin packing problem, we are given a sequence of $d$-dimensional hypercubes and we have an unlimited number of bins, each of which is a $d$-dimensional unit hypercube. The goal is to pack (orthogonally) the given hypercubes into the minimum possible number of bins, in such a way that no two hypercubes in the same bin overlap. The bounded space online $d$-hypercube bin packing problem is a variant of the $d$-hypercube bin packing problem, in which the hypercubes arrive online and each one must be packed in an open bin without the knowledge of the next hypercubes. Moreover, at each moment, only a constant number of open bins are allowed (whenever a new bin is used, it is considered open, and it remains so until it is considered closed, in which case, it is not allowed to accept new hypercubes). Epstein and van Stee [SIAM J. Comput. 35 (2005), no. 2, 431-448] showed that $\rho$ is $\Omega(\log d)$ and $O(d/\log d)$, and conjectured that it is $\Theta(\log d)$. We show that $\rho$ is in fact $\Theta(d/\log d)$. To obtain this result, we elaborate on some ideas presented by those authors, and go one step further showing how to obtain better (offline) packings of certain special instances for which one knows how many bins any bounded space algorithm has to use. Our main contribution establishes the existence of such packings, for large enough $d$, using probabilistic arguments. Such packings also lead to lower bounds for the prices of anarchy of the selfish $d$-hypercube bin packing game. We present a lower bound of $\Omega(d/\log d)$ for the pure price of anarchy of this game, and we also give a lower bound of $\Omega(\log d)$ for its strong price of anarchy.
cs.DS
cs
A tight lower bound for an online hypercube packing problem and bounds for prices of anarchy of a related game Y. Kohayakawa1, F.K. Miyazawa2, and Y. Wakabayashi1 1 Institute of Mathematics and Statistics University of São Paulo, Brazil {yoshiyw}@ime.usp.br 2 Institute of Computing University of Campinas, Brazil [email protected] Abstract. We prove a tight lower bound on the asymptotic performance ratio ρ of the bounded space online d-hypercube bin packing problem, solving an open question raised in 2005. In the classic d-hypercube bin packing problem, we are given a sequence of d-dimensional hypercubes and we have an unlimited number of bins, each of which is a d-dimensional unit hypercube. The goal is to pack (orthogonally) the given hypercubes into the minimum possible number of bins, in such a way that no two hypercubes in the same bin overlap. The bounded space online d-hypercube bin packing problem is a variant of the d-hypercube bin packing problem, in which the hypercubes arrive online and each one must be packed in an open bin without the knowledge of the next hypercubes. Moreover, at each moment, only a constant number of open bins are allowed (whenever a new bin is used, it is considered open, and it remains so until it is considered closed, in which case, it is not allowed to accept new hypercubes). Epstein and van Stee [SIAM J. Comput. 35 (2005), no. 2, 431 -- 448] showed that ρ is Ωplog dq and Opd{ log dq, and conjectured that it is Θplog dq. We show that ρ is in fact Θpd{ log dq. To obtain this result, we elaborate on some ideas presented by those authors, and go one step further showing how to obtain better (offline) packings of certain special instances for which one knows how many bins any bounded space algorithm has to use. Our main contribution establishes the existence of such packings, for large enough d, using probabilistic arguments. Such packings also lead to lower bounds for the prices of anarchy of the selfish d-hypercube bin packing game. We present a lower bound of Ωpd{ log dq for the pure price of anarchy of this game, and we also give a lower bound of Ωplog dq for its strong price of anarchy. 1 Introduction and main results The bin packing problem is an iconic problem in combinatorial optimization that has been largely investigated from many different viewpoints. In special, it has served as a proving ground for new approaches to the analysis of approximation 7 1 0 2 c e D 9 1 ] S D . s c [ 1 v 3 6 7 6 0 . 2 1 7 1 : v i X r a algorithms. It is one of the first problems for which approximation algorithms were proposed in the beginning of seventies, and also ideas to prove lower bounds for online algorithms and probabilistic analysis first appeared [1]. We believe that the technique we present in this paper is novel and contributes with new ideas that may possibly be incorporated into this area of research. We prove bounds for two variants of the bin packing problem, in which the items to be packed are d-dimensional cubes (also referred to as d-hypercubes or simply hypercubes, when the dimension is clear). More precisely, we show results for the online bounded space d-hypercube bin packing problem and the selfish hypercube bin packing game. Before we state our results in the next section, we define these problems and mention some known results. The d-hypercube bin packing problem (d-CPP) is defined as follows. We are given a list L of items, where each item h P L is a d-hypercube of side length sphq ď 1, and an unlimited number of bins, each of which is a unit d-hypercube. The goal is to find a packing P of the items of L into a minimum number of bins. More precisely, we have to assign each item h to a bin, and specify its position px1phq, . . . , xdphqq in this bin. As usual, we consider that each bin is defined by the region r0, 1sd, and thus, we must have 0 ď xiphq ď 1 ´ sphq, for i " 1, . . . , d. Additionally, we must place the items parallel to the axes of the bin and guarantee that items in the same bin do not overlap. The size of the packing P is the number of used bins (those with at least one item assigned to it). Throughout this paper, the bins are always assumed to be unit hypercubes of the same dimension of the items that have to be packed. The d-CPP is in fact a special case of the d-dimensional bin packing problem (d- BPP), in which one has to pack d-dimensional parallelepipeds into d-dimensional unit bins. For d " 1, both problems reduce to the well known bin packing problem. In the online variant of d-CPP, the hypercubes arrive online and must be packed in an open bin (without the knowledge of the next hypercubes). The online bounded space variant of the d-CPP is a more restricted variant of the online d-CPP. Whenever a new empty bin is used, it is considered an open bin and it remains so until it is considered closed, after which it is not allowed to accept other hypercubes. In this variant, during the packing process, only a constant number of open bins is allowed. The corresponding problem or algorithm in which the whole list of items is known beforehand is called offline. As it is usual, for bin packing problems, we consider the asymptotic perfor- mance ratio to measure the quality of the algorithms. For an algorithm A, and an input list L, let ApLq be the number of bins used by the solution produced by algorithm A for the list L, and let OPTpLq be the minimum number of bins needed to pack L. The asymptotic performance ratio of algorithm A is defined as A " lim sup R8 nÑ8 sup L ApLq OPTpLq : OPTpLq " n . (1) " * Given a packing problem Π, the optimal asymptotic performance ratio for Π is defined as Π " inf tR8 R8 A : A is an algorithm for Πu . (2) 2 Many results have been obtained for the online d-BPP and d-CPP problems (see [2,3,4,5,6,7]). Owing to space limitation, we mention only results for the online bounded space versions of these problems. For the online bounded space 1-BPP, Csirik [8] presented an algorithm with asymptotic performance ratio at most Π8 « 1.69103, shown to be an optimal online bounded space algorithm by Seiden [9]. For the online bounded space d-BPP, d ě 2, a lower bound of pΠ8qd follows from [10]; Epstein and van Stee [11] showed that this bound is tight. For the online bounded space d-CPP, Epstein and van Stee [11] showed that its asymptotic performance ratio is Ωplog dq and Opd{ log dq, and conjectured that it is Θplog dq. They also showed an optimal algorithm for this problem, but left as an interesting open problem to determine its asymptotic performance ratio. One of our main results builds upon their work and shows a lower bound that matches the known upper bound. Theorem 1. The asymptotic performance ratio of the online bounded space d-hypercube bin packing problem is Ωpd{ log dq. In view of the previous results [11], we have that the asymptotic performance ratio of the online bounded space d-hypercube bin packing problem is Θpd{ log dq. Results on lower and upper bounds for d P t2, . . . , 7u have also been obtained by Epstein and van Stee [12]. The technique that we use to prove the above theorem can also be used to obtain lower bounds for a game theoretic version of the d-CPP problem, called selfish d-hypercube bin packing game. This game starts with a set of d-hypercubes arbitrarily packed into unit bins. Each of these hypercubes is (controlled by) a player. For simplicity, in the game context, we will use the terms hypercube, item and player in an interchangeable manner. For a game with n items, a configuration is a vector p " pp1, . . . , pnq, where pi indicates in which bin item i is packed. (Equivalently, a configuration is a packing of the items into bins.) The cost of an item is defined as the ratio between its volume and the total occupied volume of the respective bin. In this game, an item can migrate to another bin only when its cost decreases. Players may act selfishly by changing their strategy (that is, moving to another bin) to minimize their costs. For a given game configuration p, its social cost, denoted by SCppq, is the total cost paid by the players (which is precisely the number of used bins). The optimal social goal is a game configuration of minimum social cost, which we denote by OPTpLq. An important concept in game theory is the Nash equilibrium [13]. In the selfish hypercube bin packing game, a (pure) Nash equilibrium is a stable packing where no player can reduce his cost by unilaterally changing his strategy (that is, moving to another bin), while the strategies of all other players remain unchanged. The pure Nash equilibrium may not be resilient to the action of coalitions, as it does not assume that players negotiate and cooperate with each other. Aumann [14] introduced the concept of strong Nash equilibrium in coalitional game theory; in this case, a group of players may agree to coordinate their actions in a mutually beneficial way. A strong Nash equilibrium is a game 3 configuration where no group of players can reduce the cost of each of its members by changing strategies together, while non-members maintain their strategies. Throughout the paper, the Nash equilibrium is considered only in the setting of pure strategies (for pure strategies, a player chooses only one strategy at a time, while for mixed strategies, a player chooses an assignment of probabilities to each pure strategy). Given a game G, we denote by NpGq (resp. SNpGq) the set of configurations in Nash equilibrium (resp. strong Nash equilibrium). To measure the quality of an equilibrium, Koutsoupias and Papadimitriou [15] proposed a measure in a game-theoretic framework that nowadays is known as the price of anarchy (resp. strong price of anarchy), which is the ratio between the worst social cost of a Nash equilibrium (resp. strong Nash equilibrium) and the optimal social cost. The price of anarchy measures the loss of the overall performance due to the decentralized environment and the selfish behavior of the players. As it is common for bin packing problems, for bin packing games one also considers asymptotic price of anarchy. The (asymptotic) price of anarchy of a class G of games is defined as PoApGq :" lim sup mÑ8 sup GPG, OPTpGq"m max pPNpGq SCppq m . (3) The (asymptotic) strong price of anarchy of a class G of games, denoted SPoApGq, is defined analogously, considering only configurations that are strong Nash equilibria. We are interested in the case G is the class of the selfish d-hypercube bin packing games, with the natural cost function (proportional model) we have defined. (Note that, other cost functions can also be defined for bin packing games.) We will prove bounds for the asymptotic prices of anarchy of this class of games. The corresponding measures will be denoted by PoApdq and SPoApdq, where d indicates the dimension of the items in the game. Although we may not mention explicitly, the prices of anarchy considered are always asymptotic. The case d " 1 of this game was first investigated by Bilò [16], who referred to it as selfish bin packing game. He proved that this game always converges to a pure Nash equilibrium and proved that PoAp1q P r1.6, 1.666s. Yu and Zhang [17] improved this result to PoAp1q P r1.6416, 1.6575s. Epstein and Kleiman [18] obtained (independently) the same lower bound and improved the upper bound to 1.6428; they also proved that SPoAp1q P r1.6067, 1.6210s. Very recently, Epstein, Kleiman and Mestre [19] showed that SPoAp1q « 1.6067. For d " 1, Ma et al. [20], obtained results considering another cost function. The case d " 2 was first investigated by Fernandes et al. [21]. They showed in [22] that PoAp2q P r2.3634, 2.6875s and SPoAp2q P r2.0747, 2.3605s. For a survey on bin packing games with selfish items, we refer the reader to Epstein [23]. Our second set of results concern lower and upper bounds for PoApdq and SPoApdq. 4 Theorem 2. Let PoApdq be the price of anarchy of the selfish d-hypercube bin packing game. There is an absolute constant d0 such that, for all d ě d0, we have PoApdq ě d 5 log d . (4) We remark that our proof of Theorem 2, presented in Section 3, may be adapted to prove the following statement: for any ε ą 0 there is d0 " d0pεq such that, for any d ě d0, we have PoApdq ě p1{4 ´ εqd{ log d. Theorem 3. Let SPoApdq be the strong price of anarchy of the selfish d-hypercube bin packing game. There is an absolute constant d0 such that, for all d ě d0, we have (5) The proof of Theorem 3 uses arguments similar to those used in the proof of Theorem 2 and is therefore omitted (see Appendix C). We also prove that the price of anarchy of the selfish d-hypercube bin packing game is at most 2d (see Appendix G). We believe the probabilistic technique used to obtain the lower bounds in Theorems 1, 2 and 3 is novel and promising for obtaining lower bounds for other packing problems and games. SPoApdq ě log d. 2 Notation, special packings and central lemmas kpεq defined below will be crucial in what follows. The open d-hypercubes Qd * Definition 1. Let d ě 2 be an integer. For all integer k ě 2 and 0 ă ε ď 1, let d Ă r0, 1sd (6) " x P R : 0 ă x ă 1 ` ε be the open d-hypercube of side length p1 ` εq{k 'based' at the origin. kpεq " p1 ` εq Qd 1 ` ε k d " d " 0, 0, 1 k k 1 k´ kpεq " Qd For convenience, given ε ą 0 and a positive integer q, we write q´ε for q{p1`εq. The quantity ε will often be clear from the context, and in those cases we simply write q´ for q´ε. Note that, for instance, we have d . 0, (7) In what follows, we are interested in certain types of packings U of hypercubes into a unit bin. If a packing P of hypercubes is made up of packings U1, . . . ,UN, with each Ui being a packing into a unit bin, then we write P " pU1, . . . ,UNq, and denote by P the number of bins N in P. kpεq and Hdpεq). Let d ě 2 be fixed. For Definition 2 (Packings of type Hd kpεq any integer k ě 2 and 0 ă ε ď 1{pk ´ 1q, a packing U of pk ´ 1qd copies of Qd kpεq. A packing P " pU1,U2, . . .q into a unit bin is said to be a packing of type Hd is said to be of type Hdpεq if for each i there is some k such that Ui is a packing of type Hd kpεq. 5 of Qd notice that, under that assumption on ε, we have pk ´ 1qp1 ` εq{k ď 1. In the definition above, the upper bound on ε guarantees that pk ´ 1qd copies kpεq exists): it suffices to kpεq can be packed into a unit bin (and hence Hd kpεq and Hdpεq are called homogeneous packings. They Packings of type Hd will be important for us because they are Nash equilibria (see Lemma 3), and also because they can be used to create instances for which any bounded space algorithm performs badly (following ideas of Epstein and van Stee [11,12]). Two packing lemmas. For the next definition, suppose D is a given set of integers, and ε is a positive real number. Definition 3 (Packings of type p1 ` εqD´1). A packing U of d-hypercubes into a unit bin is of type p1 ` εqD´1 if, for every member Q of U, there is some integer k P D such that Q is a copy of Qd kpεq. In what follows, we shall restrict to packings U of type p1 ` εqD´1, where D is one of the following sets: (a) D " Zě2 " tk P Z : k ě 2u or (b) D " Z2`, where Z2` denotes the set t2i : i ě 1u. Following [18,19], we consider D " Z2` to deal with strong Nash equilibria (see Appendix C). Let U be a packing of type p1 ` εqD´1 for some D Ă Zě2 and ε ą 0. Let KpUq " tk P D : U contains a copy of Qd kpεqu and For every k P KpUq, let kmaxpUq " maxtk : k P KpUqu. (8) (9) νkpUq be the total number of copies of Qd (10) Clearly, we have 0 ď νkpUq ď pk ´ 1qd for every k (recall that we suppose ε ą 0). Finally, we define the weight of U as kpεq in U. ÿ kPKpUq wpUq " pk ´ 1q´dνkpUq. (11) We shall be interested in packings U with large weight. In that direction, we prove the following two technical results that are the core of our contribution. The first is essential to derive the lower bound for the online bounded space d-hypercube bin packing problem (Theorem 1) and a lower bound for PoA (Theorem 2); the second is essential to derive a lower bound for SPoA (Theorem 3). We remark that the technique of using weight functions in the analysis of packing algorithms dates back to the seventies (see [11] and the references therein). R Lemma 1 (Packing lemma A). There is an absolute constant d0 for which the following holds for any d ě d0. Let S " (12) V 2d . 9 log d 6 The unit bin admits a packing U of type p1 ` S´2qZ´1ě2 with kmaxpUq " S and with wpUq ě d 5 log d . (13) Lemma 2 (Packing lemma B). There is an absolute constant d0 for which the following holds for any d ě d0. Let S1 " rlog2 d ´ log2 log d ´ 3s (14) and ε " 2´2pS1´1q. The unit bin admits a packing U of type p1`εqZ´1 2S1´1 and with wpUq ě log d. 2` with kmaxpUq " 3 Proofs of Theorems 1 and 2 To prove Theorem 1, one can use Lemma 1 to produce suitable instances that are 'hard' for algorithms for the online bounded space d-hypercube bin packing problem; see, e.g., [11, Lemma 2.3]. A detailed proof is given in Appendix A. To prove Theorem 2, we shall use Lemma 1 and the next two lemmas, the proofs of which are presented in Appendix B. Lemma 3. Let d ě 2 and ε ą 0 be given. Any packing P " pU1,U2, . . .q of type Hdpεq is a Nash equilibrium. Lemma 4. If U is a packing of d-hypercubes into a unit bin of type p1 ` εqZ´1ě2, where 0 ă ε ď 1 kmaxpUq ´ 1 , (15) then PoApdq ě wpUq. We now prove Theorem 2. Let d0 be as in Lemma 1 and suppose d ě d0. Moreover, let U be as given in that lemma. We now invoke Lemma 4 with ε " S´2. Note that condition (15) does hold, as ε " S´2 ď 1{pS ´ 1q " 1{pkmaxpUq ´ 1q. Combining Lemma 4 and Lemma 1, we conclude that PoApdq ě wpUq ě d{5 log d. 4 Proof of Lemma 1 We shall describe packings in terms of words of certain languages. For that, we define the languages we are interested in, show the properties we require, and then prove their existence. Owing to space limitation, we present only an outline of the proof of Lemma 1. 7 4.1 Separated families of languages Let an integer d ě 2 be fixed. We consider sets of words Lk Ă rksd " t1, . . . , kud for k ě 2. We refer to such Lk as languages or k-languages. Such languages Lk kpεq in certain packings (roughly will specify 'positions' where we shall place Qd speaking, for each w P Lk, we put a certain copy Qpwq of Qd kpεq in our packings (see (18) -- (24) for the definition of Qpwq)). We now introduce some conditions on the Lk that will help us make sure that we have a packing when we consider the Qpwq (w P Lk) all together. Definition 4 (Gapped languages). Suppose k ě 2 and let a k-language Lk Ă rksd be given. We say that Lk misses j at coordinate i0 if every word w " pwiq1ďiďd in Lk is such that wi0 ‰ j. Furthermore, Lk is said to be gapped if, for each 1 ď i ď d, either Lk misses k ´ 1 at i or Lk misses k at i. The reason we are interested in gapped languages is as follows. Suppose Lk is a gapped language as in Definition 4, and suppose w " pwiq1ďiďd and w1 " iq1ďiďd are distinct words in Lk. Then Qpwq and Qpw1q do not overlap (this pw1 can be checked from (23) and Fact 4(ii ); see Lemma 6(i)). Thus, if we let Pk be the collection of the Qpwq (w P Lk), then Pk is a packing. We now introduce a certain notion of 'compatibility' between two languages Lk and Lk1, so that Pk and Pk1 can be put together to obtain a packing if they come from 'compatible' languages Lk and Lk1. Definition 5 (Separated languages). Suppose 2 ď k ă k1 and Lk Ă rksd and Lk1 Ă rk1sd are given. We say that Lk and Lk1 are separated if, for any w " pwiq1ďiďd P Lk and any w1 " pw1 iq1ďiďd P Lk1, there is some i such that wi ă k ă k1 " w1 i. Suppose Lk and Lk1 are gapped and separated. Consider the corresponding packings Pk and Pk1 as above. Fact 4(i ) and (23) imply that PkYPk1 is a packing. To check this, let w " pwiq1ďiďd P Lk and any w1 " pw1 iq1ďiďd P Lk1 be given. Then, by definition, there is some i such that wi ă k ă k1 " w1 i. This implies that Qpwq " Qpkqpwq and Qpw1q " Qpk1qpw1q are disjoint 'in the ith dimension' (see Fact 4(i ) and Lemma 6(i)). Definition 6 (Separated families). Let L " pLkq2ďkďS be a family of k-lan- guages Lk Ă rksd. If, for every 2 ď k ă k1 ď S, the languages Lk and Lk1 are (cid:32) separated, then we say that L is a separated family of languages. ( w " pwiq1ďiďk P rksd : wk " k and wi ă Remark 1. For 2 ď k ď d, let Lk " k for all i ‰ k . One can then check that L " pLkq2ďkďd is a family of gapped, ř separated languages. Consider the packing P " 2ďkďd Pk with the Pk defined by the Lk as above. We have νkpPq " Lk " pk´ 1qd´1 (recall (10)) and wpPq " 2ďkďd 1{pk ´ 1q „ log d (recall (11)). The existence of P implies a weak form of Theorem 1 (namely, a lower bound of Ωplog dq instead of Ωpd{ log dq); for details, see the proof of Theorem 1 in Appendix A. Ť 8 Remark 1 above illustrates the use we wish to make of families of gapped, separated languages. Our focus will soon shift onto producing much 'better' families than the one explicitly defined in Remark 1. Indeed, the main result in this section is the following lemma, for which we give a probabilistic proof (see Section 5 and Appendix D). Lemma 5 (Many large, separated gapped languages). There is an ab- solute constant d0 such that, for any d ě d0, there is a separated family L " pLkq2ďkďS of gapped k-languages Lk Ă rksd such that for every 2 ď k ď S, where Lk ě 10 R 11 pk ´ 1qd, V S " 2d . 9 log d (17) Fix L " pLkq2ďkďS a family of separated, gapped k-languages Lk Ă rksd. We shall now give, for every sufficiently small ε ą 0, the construction of a packing Uε " UεpLq of d-hypercubes into the unit bin r0, 1sd using L. Choosing L suitably, we shall be able to prove Lemma 7 below, which takes us very close to the proof of Lemma 1. The packing Uε. The packing Uε " UεpLq contains copies of the hyper- kpεq for 2 ď k ď S. In fact, for each w P Lk (2 ď k ď S), we place a cubes Qd copy Qpwq of Qd kpεq in Uε, we need a definition. Definition 7 (Base point coordinates of the Qpwq). For every k ě 2 and 0 ă ε ă 1{pk ´ 1q, let kpεq in Uε. To specify the location of the copy Qpwq of Qd $'&'% j ´ 1 k´ 1 ´ 1 k´ " pj ´ 1qp1 ` εq " 1 ´ 1 ` ε k , k , if 1 ď j ă k if j " k. xpkqpjq " xpkq ε pjq " Moreover, for 1 ď j ď k, let (16) (18) (19) (20) (21) " xpkqpjq ` 1 ` ε ypkqpjq " xpkqpjq ` 1 k´ Note that, for each 2 ď k ď S, we have 0 " xpkqp1q ă ypkqp1q " xpkqp2q ă ypkqp2q " xpkqp3q ă ă ypkqpk ´ 2q " xpkqpk ´ 1q ă xpkqpkq ă ypkqpk ´ 1q ă ypkqpkq " 1. k . For convenience, for every k ě 2 and every 1 ď j ď k, let Ipkqpjq " pxpkqpjq, ypkqpjqq Ă r0, 1s. 9 Now, for each word w " pwiq1ďiďd P Lk (2 ď k ď S), let xrws " xpkqrws " pxpkqpw1q, . . . , xpkqpwdqq P Rd, and Qpwq " Qpkqpwq " xpkqrws ` Qd Putting together the definitions, one checks that kpεq Ă r0, 1sd. Qpwq " Qpkqpwq " Ipkqpw1q Ipkqpwdq ` ` " xpkqpw1q, ypkqpw1q xpkqpwdq, ypkqpwdq Ă r0, 1sd. (22) (23) (24) Definition 8 (Packing Uε " UεpLq). Suppose L " pLkq2ďkďS is a family of separated, gapped k-languages Lk Ă rksd. Let 0 ă ε ď S´2. Define the packing Uε " UεpLq as follows. For each 2 ď k ď S and each w P Lk, place the copy Qpwq " Qpkqpwq Ă r0, 1sd of Qd kpεq in Uε. To prove that Uε is indeed a packing, that is, that the hypercubes in Uε are pairwise disjoint, the following fact can be used (see Appendix D). Fact 4 The following assertions hold. (i ) Suppose 2 ď k ă k1 ď S and 0 ă ε ď S´2. Then ypkqpk ´ 1q ă xpk1qpk1q. (25) (ii ) For any 2 ď k ď S, the intervals Ipkqpjq p1 ď j ď kq are pairwise disjoint, In particular, the intervals Ipkqpjq p1 ď j ă kq are disjoint from Ipk1qpk1q. except for the single pair formed by Ipkqpk ´ 1q and Ipkqpkq. For the next lemma, recall (8) and (10), and Definition 3. Lemma 6. Suppose L " pLkq2ďkďS is a family of separated, non-empty gapped k-languages Lk Ă rksd. Suppose 0 ă ε ď S´2. Let Uε " UεpLq be the family of all the hypercubes Qpwq " Qpkqpwq Ă r0, 1sd with w P Lk and 2 ď k ď S. Then the following assertions hold: (i) the hypercubes in Uε are pairwise disjoint and form a packing of type p1 ` εqZ´1ě2; (ii) for every 2 ď k ď S, we have νkpUεq " Lk; (iii) KpUεq " S ´ 1. Lemma 7. There is an absolute constant d0 for which the following holds for any d ě d0. Let S " r2d{p9 log dqs. The unit bin admits a packing U of type p1 ` S´2qZ´1ě2 and with kmaxpUq " S such that wpUq ě p10{11qpS ´ 1q. Lemma 7 is an immediate corollary of Lemmas 5 and 6. From it, the proof of Lemma 1 follows easily: taking the packing U given in this lemma, we have that wpUq ě p10{11qpS ´ 1q ě d{p5 log dq, as long as d is large enough. 10 5 Proof of Lemma 5 We need the following auxiliary fact, which follows from standard Chernoff bounds for the hypergeometric distribution. Fact 5 There is an absolute constant d0 such that, for any d ě d0, there are sets F1, . . . , Fd Ă rds such that (i) for every 1 ď k ď d, we have Fk " rd{2s and (ii) for every 1 ď k ă k1 ď d, we have Fk X Fk1 ă 7d{26. We now proceed to prove Lemma 5. Let S " r2d{9 log ds and let F1, . . . , Fd be as in Fact 5. In what follows, we only use Fk for 2 ď k ď S. For each 2 ď k ď S, we shall construct Lk Ă rksd in two parts. First, let k Ă prks (cid:114) tk ´ 1uqFk " tw " pwiqiPFk : wi P rks (cid:114) tk ´ 1u for all i P Fku (26) L1 and then set Lk " L1 k rk ´ 1srds(cid:114)Fk " tw " pwiq1ďiďd : Dw1 " pw1 iqiPFk P L1 k such that wi " w1 and wi P rk ´ 1s for all i P rds (cid:114) Fku. i for all i P Fk (27) Note that, by (26) and (27), the k-language Lk will be gapped (k ´ 1 is missed at every i P Fk and k is missed at every i P rds (cid:114) Fk). We shall prove that k ě p10{11qpk ´ 1qd ensuring there is a suitable choice for the L1 that L " pLkq2ďkďS is separated. Since we shall then have pk ´ 1qd, (28) condition (16) will be satisfied. We now proceed with the construction of the L1 k. kpk ´ 1qd´Fk ě 10 k with L1 Lk " L1 11 Fix 2 ď k ď S. For 2 ď (cid:96) ă k, let R and note that V Jp(cid:96), kq " Fk (cid:114) F(cid:96), (29) ď d´1, (31) (32) Jp(cid:96), kq ą (30) Let v " pviqiPFk be an element of prks (cid:114) tk ´ 1uqFk chosen uniformly at random. For every 2 ď (cid:96) ă k, we say that v is (cid:96)-bad if vi ‰ k for every i P Jp(cid:96), kq. Moreover, we say that v is bad if it is (cid:96)-bad for some 2 ď (cid:96) ă k. It is clear that d. d 2 ´ 7 26 d ě 3 13 Ppv is (cid:96)-badq " ď e´Jp(cid:96),kq{S ď exp ´ 3d 13r2d{9 log ds Jp(cid:96),kq 1 ´ 1 k ´ 1 for every large enough d, whence Ppv is badq ď Sd´1 ď 1 4 log d ď 1 11 11 if d is large enough. Therefore, at least p10{11qpk´1qFk words v P prks(cid:114)tk´1uqFk k Ă prks (cid:114) tk ´ 1uqFk be the are not bad, as long as d is large enough. We let L1 set of such good words. The following claim completes the proof of Lemma 5. k p2 ď k ď Sq, the family L " pLkq2ďkďS of Claim. With the above choice of L1 the languages Lk as defined in (27) is separated. Proof. Fix 2 ď (cid:96) ă k ď S. We show that L(cid:96) and Lk are separated. Let u " puiq1ďiďd P L(cid:96) and w " pwiq1ďiďd P Lk be given. By the definition of Lk, there is v " pviqiPFk P L1 k such that wi " vi for all i P Fk. Furthermore, since v P L1 is not a bad word, it is not (cid:96)-bad. Therefore, there is i0 P Jp(cid:96), kq " Fk (cid:114) F(cid:96) for which we have vi0 " k. Observing that i0 R F(cid:96) and recalling the definition of L(cid:96), we see that ui0 ă (cid:96) ă k " vi0 " wi0, as required. k References 1. Coffman, Jr., E.G., Garey, M.R., Johnson, D.S.: Approximation algorithms for bin packing: a survey. In Hochbaum, D., ed.: Approximation Algorithms for NP-hard Problems. PWS (1997) 46 -- 93 1 2. van Vliet, A.: An improved lower bound for online bin packing algorithms. Inform. Process. Lett. 43 (1992) 277 -- 284 1 3. Seiden, S.S.: On the online bin packing problem. Journal of the Association for Computing Machinery 49(5) (2002) 640 -- 671 1 4. Balogh, J., Békési, J., Galambos, G.: New lower bounds for certain classes of bin packing algorithms. In: Proc. of the 8th International Workshop on Approximation and Online Algorithms. (2010) 25 -- 36 1 5. Heydrich, S., van Stee, R.: Improved lower bounds for online hypercube packing. CoRR abs/1607.01229 (2016) 1 6. Heydrich, S., van Stee, R.: Beating the Harmonic Lower Bound for Online Bin Packing. In: ICALP 2016. Volume 55 of LIPIcs., Dagstuhl, Germany (2016) 41:1 -- 41:14 (See newer version http://arxiv.org/abs/1511.00876v5). 1 7. Balogh, J., Békési, J., Dósa, G., Epstein, L., Levin, A.: Lower bounds for several online variants of bin packing. CoRR abs/1708.03228 (2017) 1 8. Csirik, J.: An on-line algorithm for variable-sized bin packing. Acta Informatica 26(8) (1989) 697 -- 709 1 9. Seiden, S.S.: An optimal online algorithm for bounded space variable-sized bin packing. SIAM J. Discrete Math. 14 (2001) 458 -- 470 1 10. Csirik, J., van Vliet, A.: An on-line algorithm for multidimensional bin packing. Operations Research Letters 13 (1993) 149 -- 158 1 11. Epstein, L., Stee, R.v.: Optimal online algorithms for multidimensional packing problems. SIAM J. Comput. 35(2) (2005) 431 -- 448 1, 1, 2, 2, 3 12. Epstein, L., van Stee, R.: Bounds for online bounded space hypercube packing. Discrete Optimization 4(2) (2007) 185 -- 197 1, 2 13. Nash, J.: Non-cooperative games. Annals of Mathematics 54(2) (1951) 286 -- 295 1 14. Aumann, R.J.: Acceptable points in general cooperative n-person games. In Luce, R.D., Tucker, A.W., eds.: Annals of Mathematical Study. Volume 40. University Press (1959) 287 -- 324 1 15. Koutsoupias, E., Papadimitriou, C.H.: Worst-case equilibria. In: Proc. of the 16th Annual Symposium on Theoretical Aspects of Computer Science. (1999) 404 -- 413 1 12 16. Bilò, V.: On the packing of selfish items. In: Proc. 20th Internacional Parallel and Distributed Processing Symposium, IEEE (2006) 9 -- 18 1 17. Yu, G., Zhang, G.: Bin packing of selfish items. In: Proc. of the 4th International Workshop on Internet and Network Economics. (2008) 446 -- 453 1 18. Epstein, L., Kleiman, E.: Selfish bin packing. Algorithmica 60(2) (2011) 368 -- 394 1, 2 19. Epstein, L., Kleiman, E., Mestre, J.: Parametric packing of selfish items and the subset sum algorithm. Algorithmica 74(1) (January 2016) 177 -- 207 1, 2 20. Ma, R., Dósa, G., Han, X., Ting, H.F., Ye, D., Zhang, Y.: A note on a selfish bin packing problem. Journal of Global Optimization 56(4) (2013) 1457 -- 1462 1 21. Fernandes, C.G., Ferreira, C.E., Miyazawa, F.K., Wakabayashi, Y.: Selfish square packing. In: Proc. of the VI Latin-american Algorithms, Graphs and Optimization Symposium. Volume 37 of Elect. Notes in Discrete Mathematics. (2011) 369 -- 374 1 22. Fernandes, C.G., Ferreira, C.E., Miyazawa, F.K., Wakabayashi, Y.: Prices of anarchy of selfish 2D bin packing games. CoRR abs/1707.07882 (2017) 1 23. Epstein, L.: Bin packing games with selfish items. In: Proc. of the 38th International Symposium on Mathematical Foundations of Computer Science. (2013) 8 -- 21 1 24. Janson, S., Łuczak, T., Ruciński, A.: Random graphs. Wiley-Interscience, New 25. Meir, A., Moser, L.: On packing of squares and cubes. J. Combinatorial Theory York (2000) E Ser. A 5 (1968) 116 -- 127 7 Appendix. Omitted proofs A Proof of Theorem 1 Let A be any algorithm for the online bounded space d-hypercube bin pack- ing problem. Let M be the maximum number of bins that A is allowed to leave open during its execution. To prove that A has asymptotic performance ratio Ωpd{ log dq, we construct a suitable instance I for A. Let a packing U as in the statement of Lemma 1 be fixed. The instance I will be constructed by choosing a suitable integer N and then arranging the hypercubes in 2M N copies of U in a linear order, with all the hypercubes of the same size appearing together. Let us now formally describe I. Let ź N " kPKpUq pk ´ 1qd ź fp(cid:96)q " 2M N νk(cid:96)pUq, 13 and, for every k P KpUq, let Npk " N pk ´ 1qd " k1PKpUq(cid:114)tku Recall that U contains νkpUq copies of Qd kpεq for every k P KpUq. Let K " KpUq and suppose KpUq " tk1, . . . , kKu. The instance I that we shall construct is the concatenation of K segments, say I " I1 . . .IK, with each segment I(cid:96) (1 ď (cid:96) ď K) composed of a certain number of copies of Qd k(cid:96)pεq. For every 1 ď (cid:96) ď K, set pk1 ´ 1qd. (34) (33) (35) and I(cid:96) " pQd k(cid:96)pεqq " Qd k(cid:96)pεq, . . . , Qd k(cid:96)pεqfp(cid:96)q. (36) k(cid:96)pεq. This completes That is, I(cid:96) is composed of a sequence of fp(cid:96)q copies of Qd the definition of our instance I. Let us first state the following fact concerning the offline packing of the hypercubes in I. This fact is clear, as we obtained I by rearranging the hypercubes in 2M N copies of U. Fact 6 The hypercubes in I can be packed into at most 2M N unit bins. We now prove that, when A is given the instance I above, it will have performance ratio at least as bad as wpUq{2. In view of (13) in Lemma 1, this will complete the proof of Theorem 1. Let us examine the behaviour of A when given input I. Fix 1 ď (cid:96) ď K and suppose A has already seen the hypercubes in I1 . . .I(cid:96)´1 and it has already packed them somehow. We now consider what happens when A examines the fp(cid:96)q hypercubes in I(cid:96), which are all copies of Qd k(cid:96)pεq in I(cid:96) cannot be packed into k(cid:96)pεq. Clearly, since ε ą 0, the fp(cid:96)q copies of Qd fewer than fp(cid:96)q pk(cid:96) ´ 1qd " 2M N νk(cid:96)pUq pk(cid:96) ´ 1qd " 2M Npkνk(cid:96)pUq ě M Npkνk(cid:96)pUq ` M (37) unit bins. Therefore, even if some hypercubes in I(cid:96) are placed in bins still left open after the processing of I1 . . .I(cid:96)´1, the hypercubes in I(cid:96) will add at least M Npkνk(cid:96)pUq new bins to the output of A. Thus, the total number of bins that A will use when processing I is at least M NpkνkpUq " M N pk ´ 1q´dνkpUq " M N wpUq. (38) ÿ kPKpUq ÿ kPKpUq In view of Fact 6, it follows that the asymptotic performance ratio of A is at least wpUq, as required. This completes the proof of Theorem 1. " 1 2 2M N M N wpUq (39) B Proofs of Section 3 We start with the proof of Lemma 3, which depends on the following simple result. Proposition 1. Suppose d ě 2, (cid:96) ě k ` 1 and k ą 1. Then 1 ´ 1 k d ` 1 (cid:96)d ă d 1 ´ 1 (cid:96) 14 . (40) Proof. Inequality (40) is equivalent to That is, ` (cid:96)dpk ´ 1qd ` kd (cid:96)dpk ´ 1qd ` kd ă p(cid:96) ´ 1qdkd. 1{d ă p(cid:96) ´ 1qk. ` Since d ě 2, we have` . Therefore, it suffices to prove that (42) holds for d " 2, that is, (cid:96)dpk ´ 1qd ` kd (cid:96)2pk ´ 1q2 ` k2 1{2 1{d ď (cid:96)2pk ´ 1q2 ` k2 ă p(cid:96) ´ 1q2k2. (41) (42) (43) (44) A quick calculation shows that (44) is equivalent to (45) Since 2 ă k ` 1 ď (cid:96), we conclude that (44) holds, and this completes the proof. p2k ´ 1q (cid:96) ą 2k2. Proof. [Proof of Lemma 3] Recall that, for any integer q, we let q´ " q´ε " q{p1 ` εq. Let 2 ď k ă (cid:96) be integers and suppose P includes a packing Upkq of (cid:96)pεq. It suffices to show that the cost of type Hd (cid:96)pεq within Up(cid:96)q is smaller than the cost that it would incur if it were a copy of Qd moved into Upkq. Recall that the volume of Qd kpεq is p1 ` εqd{kd " 1{kd´. Thus, we have to show the following inequality: kpεq and a packing Up(cid:96)q of type Hd 1{(cid:96)d´ pk ´ 1qd{kd´ ` 1{(cid:96)d´ which is equivalent to k ´ 1 k´ which, in turn, is equivalent to k ´ 1 k ă d ` 1 (cid:96)d´ d ` 1 1{(cid:96)d´ ą p(cid:96) ´ 1qd{(cid:96)d´ d , d (cid:96) ´ 1 (cid:96)´ (cid:96) ´ 1 (cid:96) (cid:96)d ă , (46) (47) (48) (recall that q´ " q{p1 ` εq). Inequality (48) is precisely inequality (40) asserted in Proposition 1. 15 Proof. [Proof of Lemma 4] Let U be a packing as in the statement of Lemma 4. We shall again use the quantities N and Npk as defined in (33) and (34). Consider the packing P " pU1, . . . ,UNq, where each Un (1 ď n ď N) is a copy of U. Fix k P KpUq. Let νkpPq be the total number of copies of Qd kpεq in P. Then νkpPq " N νkpUq " Npkpk ´ 1qdνkpUq. In view of (15) (recall the observation just after Definition 2), the νkpPq copies of Qd kpεq in P may be arranged into νkpPq{pk ´ 1qd " NpkνkpUq copies of packings of type Hd kpεq. Doing this for every k P KpUq, kpεq (k P KpUq), we and taking the resulting collection of packings of type Hd obtain a packing P1 of all the hypercubes in P. Clearly, (i ) P1 is a packing of type Hdpεq and (ii ) the number of bins in P1 is NpkνkpUq " N pk ´ 1q´dνkpUq " N wpUq. P1 " ÿ ÿ (49) kPKpUq kPKpUq Lemma 3 and (i ) tell us that P1 is a Nash equilibrium. On the other hand, the fact that P uses N bins and (ii ) tell us that P " N wpUq PoApdq ě P1 " wpUq, (50) N as required. C Proof of Theorem 3 stated in Section 1 2kpεq. 2`pεq is a strong Nash equilibrium. 2`pεq). A packing P " pU1,U2, . . .q is said 2`pεq if for each i there is some integer k ě 1 such that Ui is a Theorem 3 follows from Lemma 2 and the next two lemmas. These lemmas are the analogue of Lemmas 3 and 4 for the strong price of anarchy. Definition 9 (Packings of type Hd to be of type Hd packing of type Hd Lemma 8. Let d ě 2 and ε ą 0 be given. Any packing P " pU1,U2, . . .q of type Hd 2`pεq Proof. The proof is by contradiction. Suppose there is a packing P of type Hd that is not a strong Nash equilibrium. Recall that P is a homogeneous packing kpεq, where and each bin in P has the maximum number of identical copies of Qd k " 2t, for some t. Let S be a set of hypercubes (coalition) that can migrate to another bin, say B1, decreasing the cost of each of its items. Let h be a smallest hypercube in S. Suppose h is in bin B, and has side length sphq. Since h can migrate to bin B1, it follows that sphq is smaller than (and also divides) the side length sph1q of any item h1 in B1. Thus, we can replace each hypercube h1 originally in B1 by psph1q{sphqqd hypercubes of side length sphq, with the same total volume. Likewise, each hypercube h1 P S that migrates to B1 can be replaced 16 by psph1q{sphqqd hypercubes of side length sphq. After this replacement, the new equivalent packing configuration of bin B1 has only hypercubes of side length sphq, and has an occupied volume larger than the occupied volume of bin B (before the migration), a contradiction, because bin B had the best possible occupied volume with items of side length sphq. Lemma 9. If U is a packing of d-hypercubes into a unit bin of type p1 ` εqZ´1 2` , where 0 ă ε ď 1 kmaxpUq ´ 1 , (51) then SPoApdq ě wpUq. Lemma 9 follows from Lemma 8, in the same way that Lemma 4 follows from Lemma 3. The proof of Theorem 3 follows from Lemmas 2 and 9 in the same way that Theorem 2 follows from Lemmas 1 and 4. D Proofs of Section 4 (Proof of Lemma 1) Proof. [Proof of Fact 4] Assertion (ii ) is clear (recall (20)). The second assertion in (i ) follows from inequality (25), and therefore it suffices to verify that inequality. We have ypkqpk ´ 1q " xpkqpk ´ 1q ` 1{k´ " pk ´ 1q{k´ " 1 ` ε ´ p1 ` εq{k. Moreover, xpk1qpk1q " 1 ´ 1{pk1q´ " 1 ´ p1 ` εq{k1. Therefore, (25) is equivalent to ε ă p1 ` εq 1 k ´ 1 k1 . (52) Since k ` 1 ď k1 ď S and ε ď S´2, inequality (52) does hold. Proof. [Proof of Lemma 6] Let us check that the Qpwq in Uε are indeed pairwise disjoint. Let w " pwiq1ďiďd P Lk and w1 " pw1 iq1ďiďd P Lk1 with 2 ď k ď k1 ď S with w ‰ w1 be given, and consider Qpwq " Qpkqpwq and Qpw1q " Qpk1qpw1q. We have to show that (53) Suppose first that k " k1. In that case, both w and w1 are in Lk " Lk1. Since w ‰ w1, there is some 1 ď i ď d such that wi ‰ w1 i. Furthermore, since Lk is gapped, either k ´ 1 or k is missed by Lk at i. In particular, the pair twi, w1 iu cannot be the pair tk ´ 1, ku and therefore Qpwq X Qpw1q " ∅. Ipkqpwiq X Ipkqpw1 iq " ∅ (54) (recall Fact 4(ii )). Expression (24) applied to Qpwq and Qpw1q, together with (54), confirms (53) when k " k1. Suppose now that k ă k1. Since Lk and Lk1 are separated, there is some 1 ď i0 ď d such that wi0 ă k ă k1 " w1 . Fact 4(i ) tells us that i0 Ipkqpwi0q X Ipk1qpw1 i0q " ∅. (55) 17 Expression (24) applied to Qpwq and Qpw1q, together with (55), confirms (53) in this case also. We therefore conclude that Uε is indeed a packing. kpεq for 2 ď k ď S, and therefore Uε is a packing of type p1 ` εqZ´1ě2. This concludes the proof of assertion 6(i). Assertions 6(ii) and 6(iii) are clear. The hypercubes in Uε are copies of the hypercubes Qd Lemma 7 is an immediate corollary of Lemmas 5 and 6. Proof. [Proof of Lemma 1] Let U be as given in Lemma 7. We claim that U will do. In fact, R V wpUq ě 10 11 2d 9 log d ´ 1 ě d 5 log d , (56) where the last inequality holds as long as d is large enough. This completes the proof of Lemma 1. E Proof of Fact 5 Let r " rd{2s. We select each Fk (1 ď k ď d) among the r-element subsets of rds uniformly at random, with each choice independent of all others. Let s " 7d{26. Note that, for any k ‰ k1, we have EpFk X Fk1q " r2{d. Let λ " r2{d. Let ` d ` 1 t " s ´ λ ě s ´ pd{2 ` 1q2{d ě 7d 26 ´ 1 d d2 4 ě d 52 ´ 2 ě d 53 , (57) as long as d is large enough. We may now apply a Chernoff bound for the hyper- geometric distribution (see, for example, [24, Theorem 2.10, inequality (2.12)]) to see that PpFk X Fk1 ě sq " PpFk X Fk1 ě λ ` tq ď exp for every large enough d. Therefore, the expected number of pairs tk, k1u (1 ď k ă k1 ď d) for which Fk X Fk1 ě s is less than d2 expp´3d{532q, which tends to 0 as d Ñ 8. Therefore, for any large enough d, a family of sets F1, . . . , Fd as required does exist. ´ 2pd{53q2 rd{2s ď e´3d{532 (58) F Proof of Lemma 2 The packing Uε,2`. The construction of Uε,2` " Uε,2`pLq will be based on a variant of Lemma 5 (namely, Lemma 10), to be stated in a short while. Let S1 " rlog2 d ´ log2 log d ´ 3s . (59) For 2 ď k ď S1, let tpkq " 2k´1. Moreover, let TpS1q " ttpkq : 2 ď k ď S1u " t2, 22, . . . , 2S1´1u. 18 Lemma 10 (Many large, separated gapped languages (variant)). There is an absolute constant d0 such that, for any d ě d0, there is a separated family L " pLtqtPTpS1q of gapped t-languages Lt Ă rtsd, where S1 is as in (59), and for every t P TpS1q. Lt ě 10 11 pt ´ 1qd (60) The proof of Lemma 10 is very similar to the proof of Lemma 5, and is omitted here. With Lemma 10 at hand, we may define the packing Uε,2`. Let languages Lt (t P TpS1q) as in Lemma 10 be fixed. For each w P Lt, we consider xrws " xptqrws as defined in (22), namely, xrws " xptqrws " pxptqpw1q, . . . , xptqpwdqq P Rd. Furthermore, we consider Qpwq " Qptqpwq as defined in (23), namely, Qpwq " Qptqpwq " xptqpwq ` Qd tpεq Ă r0, 1sd. (61) (62) We now define the packing Uε,2`. Definition 10 (Packing Uε,2` " Uε,2`pLq). Suppose L " pLtqtPTpS1q is a fam- ily of separated, gapped t-languages Lt Ă rtsd. Let 0 ă ε ď 2´2pS1´1q. Define the packing Uε,2` " Uε,2`pLq as follows. For each t P TpS1q and each w P Lt, place the copy Qpwq " Qptqpwq Ă r0, 1sd of Qd tpεq in Uε,2`. We now state, without proof, the analogue of Lemma 6 for Uε,2` Lemma 11. Suppose L " pLtqtPTpS1q is a family of separated, non-empty gapped t-languages Lt Ă rtsd. Suppose 0 ă ε ď 2´2pS1´1q. Let Uε,2` " Uε,2`pLq be the family of all the hypercubes Qpwq " Qptqpwq Ă r0, 1sd with w P Lt and t P TpS1q. Then the following assertions hold. (i ) The hypercubes in Uε,2` are pairwise disjoint and form a packing of type (ii ) For every t P TpS1q, we have νtpUε,2`q " Lt. (iii ) We have KpUε,2`q " S1 ´ 1. p1 ` εqZ´1 2` . The following result is an immediate corollary of Lemmas 10 and 11. Lemma 12. There is an absolute constant d0 for which the following holds for any d ě d0. Let S1 " rlog2 d ´ log2 log d ´ 3s (63) and ε " 2´2pS1´1q. The unit bin admits an pS1 ´ 1, 10{11q-good packing U of type p1 ` εqZ´1 2` and with kmaxpUq " 2S1´1. The proof of Lemma 2 follows from Lemma 12 in the same way that the proof of Lemma 1 follows from Lemma 7. 19 G Upper bound for the prices of anarchy It is not difficult to obtain a simple upper bound for the price of anarchy of the selfish hypercube bin packing game. Such a bound can be obtained using the following result. Theorem 7 (Meir and Moser [25]). Every set S of d-hypercubes whose largest hypercube has side length (cid:96) ď 1 can be packed into a unit bin if VolpSq ď (cid:96)d ` p1 ´ (cid:96)qd, where VolpSq is the total volume of the hypercubes in S. Proposition 2. For the prices of anarchy of the selfish d-hypercube bin packing game, we have SPoApdq ď PoApdq ď 2d. (64) Proof. The fact that SPoApdq ď PoApdq follows directly from the definitions. We therefore only address the second inequality in (64). Let P " tB1, . . . , Bku be a packing that is a Nash equilibrium, where each Bi is a packing into a unit bin. The proof is based on volume arguments. We prove that each bin in P has volume occupation of at least 1{2d, except possibly for one bin. For simplicity, if B is a packing, we denote by VolpBq the total volume of the hypercubes in B, and by HpBq the set of hypercubes in B. Let P1 " tB P P : VolpBq ă 1{2du. We will prove that P1 is at most 1. First, note that, if B P P1 then, the side length of any hypercube in B is smaller than 1{2. The proof is by contradiction. Suppose there are at least two distinct bins B1, B2 P P1 such that 1{2d ą VolpB1q ě VolpB2q, and let b P HpB2q. Since P is a Nash equilibrium, HpB1q Ytbu cannot be packed in only one bin. If (cid:96) " maxtsphq : h P HpB1q Y tbuu, by Theorem 7 we conclude that VolpHpB1q Y tbuq ą (cid:96)d ` p1 ´ (cid:96)qd. (65) Thus, VolpB1q ą p1 ´ (cid:96)qd ` (cid:96)d ´ Volptbuq ě p1 ´ (cid:96)qd ě 1{2d, (66) a contradiction to the choice of B1. Therefore, there is at most one bin in P1 (and consequently at most one bin in P with volume occupation smaller than 1{2d) and we can conclude that P ď 2d VolpHpPqq ` 1 ď 2d OPTpHpPqq ` 1. This completes the proof. Exponentially better upper bounds than the one in Proposition 2 can be proved for SPoApdq. However, we do not quite see how to close the exponential gap between our lower and upper bounds (in fact the gap is doubly exponential in the case of SPoApdq). We shall address these topics elsewhere. 20
1507.05544
1
1507
2015-07-20T16:04:14
Meta-Kernelization using Well-Structured Modulators
[ "cs.DS" ]
Kernelization investigates exact preprocessing algorithms with performance guarantees. The most prevalent type of parameters used in kernelization is the solution size for optimization problems; however, also structural parameters have been successfully used to obtain polynomial kernels for a wide range of problems. Many of these parameters can be defined as the size of a smallest modulator of the given graph into a fixed graph class (i.e., a set of vertices whose deletion puts the graph into the graph class). Such parameters admit the construction of polynomial kernels even when the solution size is large or not applicable. This work follows up on the research on meta-kernelization frameworks in terms of structural parameters. We develop a class of parameters which are based on a more general view on modulators: instead of size, the parameters employ a combination of rank-width and split decompositions to measure structure inside the modulator. This allows us to lift kernelization results from modulator-size to more general parameters, hence providing smaller kernels. We show (i) how such large but well-structured modulators can be efficiently approximated, (ii) how they can be used to obtain polynomial kernels for any graph problem expressible in Monadic Second Order logic, and (iii) how they allow the extension of previous results in the area of structural meta-kernelization.
cs.DS
cs
Meta-Kernelization using Well-Structured Modulators∗ Eduard Eiben, Robert Ganian, and Stefan Szeider Algorithms and Complexity Group, TU Wien Vienna, Austria Abstract Kernelization investigates exact preprocessing algorithms with performance guarantees. The most preva- lent type of parameters used in kernelization is the solution size for optimization problems; however, also structural parameters have been successfully used to obtain polynomial kernels for a wide range of prob- lems. Many of these parameters can be defined as the size of a smallest modulator of the given graph into a fixed graph class (i.e., a set of vertices whose deletion puts the graph into the graph class). Such param- eters admit the construction of polynomial kernels even when the solution size is large or not applicable. This work follows up on the research on meta-kernelization frameworks in terms of structural parameters. We develop a class of parameters which are based on a more general view on modulators: instead of size, the parameters employ a combination of rank-width and split decompositions to measure structure inside the modulator. This allows us to lift kernelization results from modulator-size to more general parameters, hence providing smaller kernels. We show (i) how such large but well-structured modulators can be efficiently approximated, (ii) how they can be used to obtain polynomial kernels for any graph problem expressible in Monadic Second Order logic, and (iii) how they allow the extension of previous results in the area of structural meta-kernelization. 1998 ACM Subject Classification F.1.3 Complexity Measures and Classes, G.2.1 Combinatorics Keywords and phrases Kernelization, Parameterized complexity, Structural parameters, Rank-width, Split decompositions 1 Introduction Kernelization investigates exact preprocessing algorithms with performance guarantees. Similarly as in parameterized complexity analysis, in kernelization we study parameterized problems: decision problems where each instance I comes with a parameter k. A parameterized problem is said to admit a kernel of size f : N → N if every instance (I, k) can be reduced in polynomial time to an equivalent instance (called the kernel) whose size and parameter are bounded by f(k). For practical as well as theoretical reasons, we are mainly interested in the existence of polynomial kernels, i.e., kernels whose size is polynomial in k. The study of kernelization has recently been one of the main areas of research in parameterized complexity, yielding many important new contributions to the theory. The by far most prevalent type of parameter used in kernelization is the solution size. Indeed, the existence of polynomial kernels and the exact bounds on their sizes have been studied for a plethora of distinct problems under this parameter, and the rate of advancement achieved in this direction over the past 10 years has been staggering. Important findings were also obtained in the area of meta-kernelization [5, 13, 20], which is the study of general kernelization techniques and frameworks used to establish polynomial kernels for a wide range of distinct problems. In parameterized complexity analysis, an alternative to parameterization by solution size has traditionally been the use of structural parameters. But while parameters such as treewidth and the ∗ Supported by the Austrian Science Fund (FWF), project P26696. © Eduard Eiben and Robert Ganian and Stefan Szeider Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany 5 1 0 2 l u J 0 2 ] S D . s c [ 1 v 4 4 5 5 0 . 7 0 5 1 : v i X r a more general rank-width allow the design of FPT algorithms for a range of important problems, it is known that they cannot be used to obtain polynomial kernels for problems of interest. Instead, the structural parameters used for kernelization often take the form of the size of minimum modulators (a modulator of a graph is a set of vertices whose deletion puts the graph into a fixed graph class). Examples of such parameters include the size of a minimum vertex cover [12, 6] (modulators into the class of edgeless graphs) or of a minimum feedback vertex set [7, 19] (modulators into the class of forests). While such structural parameters are not as universal as the structural parameters used in the context of fixed-parameter tractability, these results nonetheless allow efficient preprocessing of instances where the solution size is large and for problems where solution size simply cannot be used (such as 3-coloring). This paper follows up on the recent line of research which studies meta-kernelization in terms of structural parameters. Gajarský et al. [14] developed a meta-kernelization framework parameterized by the size of a modulator to the class of graphs of bounded treedepth on sparse graphs. Ganian et al. [16] independently developed a meta-kernelization framework using a different parameter based on rank-width and modular decompositions (see Subsection 2.4 for details). Our results build upon both of the aforementioned papers by fully subsuming the meta-kernelization framework of [16] and lifting the meta-kernelization framework of [14] to more general graph classes. The class of problems investigated in this paper are problems which can be expressed using Monadic Second Order (MSO) logic (see Subsection 2.5). The parameters for our kernelization results are also based on modulators. However, instead of parameterizing by the size of the modulator, we instead measure the structure of the modulator through a combination of rank-width and split decompositions. Due to its technical nature, we postpone the definition of our parameter, the well-structure number, to Section 3; for now, let us roughly describe it as the number of sets one can partition a modulator into so that each set induces a graph with bounded rank-width and a simple neighborhood. We call modulators which satisfy our conditions well-structured. A less restricted variant of the well-structure number has recently been used to obtain meta-theorems for FPT algorithms on graphs of unbounded rank-width [11]. After formally introducing the parameter, in Section 4 we showcase its applications on the special case of generalizing the vertex cover number by considering well-structured modulators to edgeless graphs. While it is known that there exist MSO-definable problems which do not admit a polynomial kernel parameterized by the vertex cover number on general graphs, on graphs of bounded expansion this is no longer the case (as follows for instance from [14]). On the class of graphs of bounded expansion, we prove that every MSO-definable problem admits a linear kernel parameterized by the well-structure number for edgeless graphs. As a corollary of our approach, we also show that every MSO-definable problem admits a linear kernel parameterized by the well-structure number for the empty graph (without any restriction on the expansion). We remark that the latter result represents a direct generalization of the results in [16]. The proof is based on a combination of a refined version of the replacement techniques developed in [11] together with the annotation framework used in [16]. Before we can proceed to wider applications of our parameter in kernelization, it is first necessary to deal with the subproblem of finding a suitable well-structured modulator in polynomial time. We resolve this question for well-structured modulators to a vast range of graph classes. In particular, in Subsection 5.1 we obtain a 3-approximation algorithm for finding well-structured modulators to acyclic graphs, and in the subsequent Subsection 5.2 we show how to approximate well-structured modulators to any graph class characterized by a finite set of forbidden induced subgraphs within a constant factor. Section 6 then contains our most general result, Theorem 15, which is the key for lifting kernel- ization results from modulators to well-structured modulators. The theorem states that whenever a modulator to a graph class H can be used to poly-kernelize some MSO-definable problem, this © Eduard Eiben and Robert Ganian and Stefan Szeider Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany problem also admits a polynomial kernel when parameterized by the well-structure number for H as long as well-structured modulators to H can be approximated in polynomial time. The remainder of Section 6 then deals with the applications of this theorem. Since the class of graphs of treedepth bounded by some fixed integer can be characterized by a finite set of forbidden induced subgraphs, we can use well-structured modulators to lift the results of [14] from modulators to well-structured modulators for all MSO-definable decision problems. Furthermore, by applying the protrusion machinery of [5, 20] we show that, in the case of bounded degree graphs, parameterization by a modulator to acyclic graphs (i.e., a feedback vertex set) allows the computation of a linear kernel for any MSO-definable decision problem. By our framework it then follows that such modulators can also be lifted to well-structured modulators. Preliminaries 2 The set of natural numbers (that is, positive integers) will be denoted by N. For i ∈ N we write [i] to denote the set {1, . . . , i}. If ∼ is an equivalence relation over a set A, then for a ∈ A we use [a]∼ to denote the equivalence class containing a. 2.1 Graphs We will use standard graph theoretic terminology and notation (cf. [10]). All graphs in this document are simple and undirected. Given a graph G = (V (G), E(G)) and A ⊆ V (G), we denote by N(A) the set of neighbors of A in V (G) \ A; if A contains a single vertex v, we use N(v) instead of N({v}). We use V and E as shorthand for V (G) and E(G), respectively, when the graph is clear from context. G − A denotes the subgraph of G obtained by deleting A. For A ⊆ V (G) we use G[A] to denote the subgraph of G obtained by deleting V (G) \ A. 2.2 Splits and Split-Modules A split of a connected graph G = (V, E) is a vertex bipartition {A, B} of V such that every vertex of A0 = N(B) has the same neighborhood in B0 = N(A). The sets A0 and B0 are called frontiers of the split. A split is said to be non-trivial if both sides have at least two vertices. A connected graph which does not contain a non-trivial split is called prime. A bipartition is trivial if one of its parts is the empty set or a singleton. Cliques and stars are called degenerate graphs; notice that every non-trivial bipartition of their vertices is a split. Let G = (V, E) be a graph. To simplify our exposition, we will use the notion of split-modules instead of splits where suitable. A set A ⊆ V is called a split-module of G if there exists a connected component G0 = (V 0, E0) of G such that {A, V 0 \ A} forms a split of G0. Notice that if A is a split-module then A can be partitioned into A1 and A2 such that N(A2) ⊆ A and for each v1, v2 ∈ A1 it holds that N(v1) ∩ (V 0 \ A) = N(v2) ∩ (V 0 \ A); A1 is then called the frontier of A. For technical reasons, V and ∅ are also considered split-modules. We say that two disjoint split-modules X, Y ⊆ V are adjacent if there exist x ∈ X and y ∈ Y such that x and y are adjacent. We use λ(A) to denote the frontier of split-module A. 2.3 Rank-Width For a graph G and U, W ⊆ V (G), let AG[U, W] denote the U × W -submatrix of the adjacency matrix over the two-element field GF(2), i.e., the entry au,w, u ∈ U and w ∈ W , of AG[U, W] is 1 if and only if {u, w} is an edge of G. The cut-rank function ρG of a graph G is defined as follows: © Eduard Eiben and Robert Ganian and Stefan Szeider Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany For a bipartition (U, W) of the vertex set V (G), ρG(U) = ρG(W) equals the rank of AG[U, W] over GF(2). A rank-decomposition of a graph G is a pair (T, µ) where T is a tree of maximum degree 3 and µ : V (G) → {t : t is a leaf of T} is a bijective function. For an edge e of T , the connected components of T − e induce a bipartition (X, Y ) of the set of leaves of T . The width of an edge e of a rank-decomposition (T, µ) is ρG(µ−1(X)). The width of (T, µ) is the maximum width over all edges of T . The rank-width of G, rw(G) in short, is the minimum width over all rank-decompositions of G. We denote by Ri the class of all graphs of rank-width at most i, and say that a graph class H is of unbounded rank-width if H 6⊆ Ri for any i ∈ N. c (cid:18) 0 (cid:18) 1 1 1 0 (cid:19) (cid:19) 1 0 0 c b d a e d ( 0 0 1 1 ) ( 1 0 0 1 ) e Figure 1 A rank-decomposition of the cycle C5. ( 0 0 1 1 0 0 ) (cid:17) (cid:16) 1 0 (cid:18) 1 (cid:19) 0 1 0 0 0 0 1 a b (cid:73) Fact 1 ([18]). Let k ∈ N be a constant and n ≥ 2. For an n-vertex graph G, we can output a rank-decomposition of width at most k or confirm that the rank-width of G is larger than k in time O(n3). More properties of rank-width can be found, for instance, in [24]. 2.4 Fixed-Parameter Tractability and Kernels A parameterized problem P is a subset of Σ∗ × N for some finite alphabet Σ. For a problem instance (x, k) ∈ Σ∗ × N we call x the main part and k the parameter. A parameterized problem P is fixed- parameter tractable (FPT in short) if a given instance (x, k) can be solved in time O(f(k) · p(x)) where f is an arbitrary computable function of k and p is a polynomial function. A bikernelization for a parameterized problem P ⊆ Σ∗ × N into a parameterized problem Q ⊆ Σ∗ × N is an algorithm that, given (x, k) ∈ Σ∗ × N, outputs in time polynomial in x + k a pair (x0, k0) ∈ Σ∗ × N such that (i) (x, k) ∈ P if and only if (x0, k0) ∈ Q and (ii) x0 + k0 ≤ g(k), where g is an arbitrary computable function. The reduced instance (x0, k0) is the bikernel. If P = Q, the reduction is called a kernelization and (x0, k0) a kernel. The function g is called the size of the (bi)kernel, and if g is a polynomial then we say that P admits a polynomial (bi)kernel. The following fact links the existence of bikernels to the existence of kernels. (cid:73) Fact 2 ([2]). Let P, Q be a pair of decidable parameterized problems such that Q is in NP and P is NP-complete. If there is a bikernelization from P to Q producing a polynomial bikernel, then P has a polynomial kernel. Within this paper, we will also consider (and compare to) various structural parameters which have been used to obtain polynomial kernels. We provide a brief overview of these parameters below. A modulator of a graph G to a graph class H is a vertex set X ⊆ V (G) such that G− X ∈ H. We denote the cardinality of a minimum modulator to H in G by modH(G). The vertex cover number of a graph G (vcn(G)) is a special case of modH(G), specifically for H being the set of edgeless graphs. The vertex cover number has been used to obtain polynomial kernels for problems such as LARGEST INDUCED SUBGRAPH [12] or LONG CYCLE along with other path and cycle problems [6]. Similarly, © Eduard Eiben and Robert Ganian and Stefan Szeider Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany a feedback vertex set is a modulator to the class of acyclic graphs, and the size of a minimum feedback vertex set has been used to kernelize, for instance, TREEWIDTH [7] or VERTEX COVER [19]. For the final considered parameter, we will need the notion of module, which can be defined as a split-module with the restriction that every vertex in the split-module lies in its frontier. Then the rank-widthc cover number [16] of a graph G (rwcc(G)) is the smallest number of modules the vertex set of G can be partitioned into such that each module induces a subgraph of rank-width at most c. A wide range of problems, and in particular all MSO-definable problems, have been shown admit linear kernels when parameterized by the rank-widthc cover number [16]. 2.5 Monadic Second Order Logic on Graphs We assume that we have an infinite supply of individual variables, denoted by lowercase letters x, y, z, and an infinite supply of set variables, denoted by uppercase letters X, Y, Z. Formulas of monadic second-order logic (MSO) are constructed from atomic formulas E(x, y), X(x), and x = y using the connectives ¬ (negation), ∧ (conjunction) and existential quantification ∃x over individual variables as well as existential quantification ∃X over set variables. Individual variables range over vertices, and set variables range over sets of vertices. The atomic formula E(x, y) expresses adjacency, x = y expresses equality, and X(x) expresses that vertex x in the set X. From this, we define the semantics of monadic second-order logic in the standard way (this logic is sometimes called MSO1). Free and bound variables of a formula are defined in the usual way. A sentence is a formula without free variables. We write ϕ(X1, . . . , Xn) to indicate that the set of free variables of formula ϕ is {X1, . . . , Xn}. If G = (V, E) is a graph and S1, . . . , Sn ⊆ V we write G = ϕ(S1, . . . , Sn) to denote that ϕ holds in G if the variables Xi are interpreted by the sets Si, for i ∈ [n]. The problem framework we are mainly interested in is formalized below. MSO MODEL CHECKING (MSO-MCϕ) Instance: A graph G. Question: Does G = ϕ hold? While MSO model checking problems already capture many important graph problems, there are some well-known problems on graphs that cannot be captured in this way, such as VERTEX COVER, DOMINATING SET, and CLIQUE. Many such problems can be formulated in the form of MSO optimization problems. Let ϕ = ϕ(X) be an MSO formula with one free set variable X and ♦ ∈ {≤,≥}. MSO-OPT♦ Instance: A graph G and an integer r ∈ N. Question: Is there a set S ⊆ V (G) such that G = ϕ(S) and S♦ r? ϕ It is known that MSO formulas can be checked efficiently as long as the graph has bounded rank-width. (cid:73) Fact 3 ([15]). Let ϕ and ψ = ψ(X) be fixed MSO formulas and let c be a constant. Then ϕ can be solved in O(n3) time on the class of graphs of rank-width at MSO-MCϕ and MSO-OPT♦ most c, where n is the order of the input graph. Moreover, if G has rank-width at most c and and S ⊆ V (G), it is possible to check whether G = ψ(S) in O(n3) time. We review MSO types roughly following the presentation in [22]. The quantifier rank of an MSO formula ϕ is defined as the nesting depth of quantifiers in ϕ. For non-negative integers q and l, let MSOq,l consist of all MSO formulas of quantifier rank at most q with free set variables in {X1, . . . , Xl}. © Eduard Eiben and Robert Ganian and Stefan Szeider Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany Let ϕ = ϕ(X1, . . . , Xl) and ψ = ψ(X1, . . . , Xl) be MSO formulas. We say ϕ and ψ are equivalent, written ϕ ≡ ψ, if for all graphs G and U1, . . . , Ul ⊆ V (G), G = ϕ(U1, . . . , Ul) if and only if G = ψ(U1, . . . , Ul). Given a set F of formulas, let F/≡ denote the set of equivalence classes of F with respect to ≡. A system of representatives of F/≡ is a set R ⊆ F such that R ∩ C 6= ∅ for each equivalence class C ∈ F/≡. The following statement has a straightforward proof using normal forms (see [22, Proposition 7.5] for details). (cid:73) Fact 4 ([16]). Let q and l be fixed non-negative integers. The set MSOq,l/≡ is finite, and one can compute a system of representatives of MSOq,l/≡. We will assume that for any pair of non-negative integers q and l the system of representatives of MSOq,l/≡ given by Fact 4 is fixed. (cid:73) Definition 1 (MSO Type). Let q, l be non-negative integers. For a graph G and an l-tuple ~U of sets of vertices of G, we define typeq(G, ~U) as the set of formulas ϕ ∈ MSOq,l such that G = ϕ(~U). We call typeq(G, ~U) the MSO q-type of ~U in G. Let Φ ∈ MSOq,l be the formula defined as Φ =V It follows from Fact 4 that up to logical equivalence, every type contains only finitely many formulas. The following Lemma 2 is obtained as an adaptation of a technical lemma from [16] to our setting, and allows us to represent types using MSO formulas. (cid:73) Lemma 2 (see also [16]). Let q, c and l be non-negative integer constants, let G be an n-vertex graph of rank-width at most c, and let ~U be an l-tuple of sets of vertices of G. One can compute a formula Φ ∈ MSOq,l such that for any graph G0 and any l-tuple ~U0 of sets of vertices of G0 we have G0 = Φ(~U0) if and only if typeq(G, ~U) = typeq(G0, ~U0). Moreover, Φ can be computed in time O(n3). Proof. Let R be a system of representatives of MSOq,l/≡ given by Fact 4. Because q and l are constants, we can consider both the cardinality of R and the time required to compute it as constants. ϕ∈R\S ¬ϕ, where S = { ϕ ∈ R G = ϕ(~U)}. We can compute Φ by deciding G = ϕ(~U) for each ϕ ∈ R. Since the number of formulas in R is a constant, this can be done in time O(n3) by applying Fact 3. Let G0 be an arbitrary graph and let ~U0 be an l-tuple of subsets of V (G0). We claim that typeq(G, ~U) = typeq(G0, ~U0) if and only if G0 = Φ(~U0). Since Φ ∈ MSOq,l the forward direction is trivial. For the converse, assume typeq(G, ~U) 6= typeq(G0, ~U0). First suppose ϕ ∈ typeq(G, ~U) \ typeq(G0, ~U0). The set R is a system of representatives of MSOq,l/≡ , so there has to be a ψ ∈ R such that ψ ≡ ϕ. But G0 = Φ(~U0) implies G0 = ψ(~U0) by construction of Φ and thus G0 = ϕ(~U0), a contradiction. Now suppose ϕ ∈ typeq(G0, ~U0) \ typeq(G, ~U). An analogous argument proves that there has to be a ψ ∈ R such that ψ ≡ ϕ and G0 = ¬ψ(~U0). It follows that G0 6= ϕ(~U0), which (cid:74) again yields a contradiction. ϕ∈S ϕ ∧V (k, c)-Well-Structured Modulators 3 (cid:73) Definition 3. Let H be a graph class and let G be a graph. A set ~X of pairwise-disjoint split-modules of G is called a (k, c)-well-structured modulator to H if 1. ~X ≤ k, and 2. S Xi∈ ~X Xi is a modulator to H, and 3. rw(G[Xi]) ≤ c for each Xi ∈ ~X. © Eduard Eiben and Robert Ganian and Stefan Szeider Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany S Xi∈ ~X Xi (for instance G − ~X is shorthand for G −S For the sake of brevity and when clear from context, we will sometimes identify ~X with Xi∈ ~X Xi). To allow a concise descrip- c in tion of our parameters, for any hereditary graph class H we let the well-structure number (wsnH short) denote the minimum k such that G has a (k, c)-well-structured modulator to H. Figure 2 A graph with a (2, 1)-well-structured modulator to forests (in the two shaded areas). conditions restricting the contents of the modulatorS ~X have been chosen as the most general means We conclude this section with a brief discussion on the choice of the parameter. The specific which allow both (1) the efficient finding of a suitable well-structured modulator, and (2) the efficient use of this well-structured modulator for kernelization. In this sense, we do not claim that there is anything inherently special about rank-width or split modules, other than being the most general notions which are currently known to allow the achievement of these two goals. In some of the applications of our results, we will consider graphs which have bounded expansion or bounded degree. We remark that in these cases, our results could equivalently be stated in terms of treewidth (instead of rank-width) and MSO2 logic (instead of MSO1 logic). Details follow. We say that a class H of graphs is uniformly k-sparse if there exists k such that for every G ∈ H every finite subgraph of G has a number of edges bounded by k times the number of vertices. (cid:73) Fact 5 ([9]). For each integer k, one can effectively transform a given monadic second-order formula using edge set quantifications into one that uses only vertex set quantifications and is equivalent to the given one on finite, uniformly k-sparse, simple, directed or undirected graphs. (cid:73) Fact 6 ([9]). A class of finite, uniformly k-sparse, simple, directed or undirected graphs has bounded tree-width if and only if it has bounded clique-width. For definitions of Shallow minor, Greatest reduced average density, and bounded expansion we refer to Definition 2.1, Definition 2.5, and Definition 2.6 in [14], respectively. (cid:73) Observation 1. Every class of graphs of bounded expansion is uniformly k-sparse for some positive integer constant k. Proof. Let H be a class of graphs of bounded expansion and let f be the expansion function of H. Then f(0) or equivalently the greatest reduced average density of H with rank 0 is constant and is an exact upper bound on the ratio between the number of edges and vertices of any subgraph of a graph in H. Therefore, H is uniformly f(0)-sparse. (cid:74) 4 A Case Study: Vertex Cover In this section we show how well-structured modulators to edgeless graphs can be used to obtain polynomial kernels for various problems. In particular, this special case can be viewed as a generaliza- tion of the vertex cover number. We begin by comparing the resulting parameter to known structural parameters. Let c ∈ N be fixed and E denote the class of edgeless graphs. The class Z containing only the empty graph will also be of importance later on in the section; we remark that while modZ represents a very weak parameter as it is equal to the order of the graph, this is not the case for wsnZ c . © Eduard Eiben and Robert Ganian and Stefan Szeider Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany We begin by comparing well-structured modulators to edgeless graphs with similar parameters used in kernelization. (cid:73) Proposition 1. Let E be graph class of edgeless graphs. Then: 1. rwcc(G) ≥ wsnE 2. vcn(G) ≥ wsnE c (G) for any graph G. Furthermore, for every i ∈ N there exists a graph Gi such 1 (G) for any graph G. Furthermore, for every i ∈ N there exists a graph Gi such that rwcc(Gi) ≥ 2i and wsnE that vcn(G) ≥ i and wsnE c = 2. 1 = 1. Proof. The first claim follows from the fact that rank-width cover is also a well-structured modulator to the empty graph. For the second claim, let G0 c be a graph of rank-width c + 1, of bounded degree c − v has rank-width c. Next, and of order at least i containing at least one vertex, say v, such that G0 c − v by exhaustively applying the following operation: for each we construct the graph Gc from G0 module in the graph containing more than a single vertex, we create a new pendant and attach it to a single vertex in that module. Observe that this operation preserves the rank-width of the graph, and moreover the resulting graph only contains trivial modules (i.e., modules which contain a single vertex). Finally, let G∗ c, and making the vertices which were adjacent to v in G1 c. Then wsnE c (G∗ c and G2 c are each a split-module of rank-width at most c. However, since c, it follows that rw(G∗ G∗ c is a (vertex-)supergraph of G0 c only contains c) ≥ 2i. trivial modules. Hence rwcc(G∗ to E. Finally, consider a path P of length 2i + 1. Then vcn(P) ≥ i but wsnE The third claim follows from the fact that any vertex cover of G is also a well-structured modulator (cid:74) c adjacent to the vertices which were adjacent to v in G2 c be obtained from 2 disjoint copies of Gc, say G1 c) ≥ c + 1 and furthermore G∗ c) = 2, since G1 c and G2 1 (P) = 1. As we have established that already wsnE It will be useful to observe that the above Proposition 1 also holds when restricted to the class of graphs of bounded expansion and bounded degree, and even when the graph class E is replaced by Z. 1 ≤ vcn(G), it is important to mention that an additional structural restriction on the graph is necessary to allow the polynomial kernelization of MSO-OPT problems in general (as is made explicit in the following Fact 7). (cid:73) Fact 7 ([8]). CLIQUE parameterized by the vertex cover number does not admit a polynomial kernel, unless NP ⊆ coNP/poly. However, it turns out that restricting the inputs to graphs of bounded expansion completely changes the situation: under this condition, it is not only the case that all all MSO-MC and MSO-OPT problems admit a linear kernel when parameterized by the vertex cover number, but also when parameterized by the more general parameter wsnE c . To prove these claims, we begin by stating the following result. (cid:73) Fact 8 ([14]). Let K be a graph class with bounded expansion. Suppose that for G ∈ K and S ∈ V (G), C1, . . . ,Cs are sets of connected components of G− S such that for all pairs C, C0 ∈ ∪iCi it holds that C, C0 ∈ Cj for some j if and only if NS(C) = NS(C0). Let δ ≥ 0 be a constant bound on the diameter of these components, i.e., for all C ∈ ∪iCi, diam(G[V (C)]) ≤ δ. Then there can be only at most O(S) such sets Ci. c and wsnZ This allows us to establish a key link between wsnE c on graphs of bounded expansion. (cid:73) Lemma 4. Let K be a graph class with bounded expansion. Then there exists a constant d such that for every G ∈ K it holds that wsnZ c (G) and let ~H be a (k, c)-well-structured modulator to E. Let S be a set Proof. Let k = wsnE of vertices containing exactly one vertex from the frontier of every split-module in ~H. The graph G0 = G− ( ~H − S) is a graph with bounded expansion and S is its vertex cover. Clearly, the diameter c (G) ≤ d · (wsnE c (G)). © Eduard Eiben and Robert Ganian and Stefan Szeider Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany of every connected component of G0 \ S is at most 1 (every connected component is a singleton). Therefore, by Fact 8 there exists a constant d0 such that there are at most d0 · S = d0 · wsnE c (G) sets of vertices C1, . . . ,Cs in G0 − S such that for all pairs v, v0 ∈ ∪iCi it holds that v, v0 ∈ Cj for some j if and only if NS(v) = NS(v0). Clearly each such Ci is a split-module in G0, and hence also in G. Furthermore, each such Ci has rank-width at most 1. Hence wsnZ c (G). (cid:74) The above lemma allows us to shift our attention from modulators to E to a partition of the vertex set into split-modules of bounded rank-width. The rest of this section is then dedicated to proving our results for well-structured modulators to Z. Our proof strategy for this special case of well-structured modulators closely follows the replacement techniques used to obtain the kernelization results for the rank-width cover number [16], with the distinction that many of the tools and techniques had to be generalized to cover splits instead of modules. (cid:73) Fact 9 ([11]). Let q, c be non-negative integer constants. Let G be an n-graph of rank-width at most c and S ⊆ V (G). Then one can in time O(n3) compute a graph G0 and a set S0 ⊆ V (G0) such that V (G0) is bounded by a constant and typeq(G, S) = typeq(G0, S0). c (G)+d0·wsnE c (G) ≤ wsnE We use the notion of similarity [11] to prove that this procedure does not change the outcome of 1, . . . , X0 i = λ(X0 to S0 i. S0 j are adjacent. MSO-MCϕ. (cid:73) Definition 5. Let q and k be non-negative integers, H be a graph class, and let G and G0 be k} to H, graphs with (k, c)-well-structured modulators ~X = {X1, . . . , Xk} and ~X0 = {X0 respectively. For 1 ≤ i ≤ k, let Si = λ(Xi) and similarly let S0 i). We say that (G, ~X) and (G0, ~X0) are q-similar if all of the following conditions are met: 1. There exists an isomorphism τ between G − ~X and G0 − ~X0. 2. For every v ∈ V (G)\ ~X and i ∈ [k], it holds that v is adjacent to Si if and only if τ(v) is adjacent 3. if k ≥ 2, then for every 1 ≤ i < j ≤ k it holds that Si and Sj are adjacent if and only if S0 4. For each i ∈ [k], it holds that typeq(G[Xi], Si) = typeq(G0[X0 (cid:73) Lemma 6. Let q, c be non-negative integer constants and H be a graph class. Then given an n-vertex graph G and a (k, c)-well-structured modulator ~X = {X1, . . . Xk} of G into H, one can in time O(n3) compute a graph G0 with a (k, c)-well-structured modulator ~X0 = {X0 k} into H 1, . . . X0 such that (G, ~X) and (G0, ~X0) are q-similar and for each i ∈ [k] it holds that X0 i is bounded by a constant. Proof. For i ∈ [k], let Si = λ(Xi), Gi = G[Xi], and let G0 = G \ G[ ~X]. We compute a graph G0 of constant size and a set S0 i) with the same MSO q-type as (Gi, Si). By Fact 9, all of this can be done in time O(n3). Now let G0 be the graph obtained by the following procedure: 1. Perform a disjoint union of G0 and G0 2. If k ≥ 2 then for each 1 ≤ i < j ≤ k such that Si and Sk are adjacent in G, we add edges 3. for every v ∈ V (G0) and i ∈ [k] such that Si and {v} are adjacent, we add edges between v and between every v ∈ S0 every w ∈ S0 i. It is easy to verify that (G, ~X) and (G0, ~X0), where ~X0 = {V (G0 k)}, are q-similar. (cid:74) (cid:73) Fact 10 ([11]). Let q, c, and k be non-negative integers, H be a graph class, and let G and G0 be graphs with (k, c)-well-structured modulators ~X = {X1, . . . , Xk} and ~X0 = {X0 k} to H, respectively. If (G, ~X) and (G0, ~X0) are q-similar, then typeq(G,∅) = typeq(G0,∅). i for each i ∈ [k]; i and i i ⊆ V (G0 i and w ∈ S0 j. i], S0 i). 1), . . . , V (G0 1, . . . , X0 © Eduard Eiben and Robert Ganian and Stefan Szeider Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany (cid:73) Theorem 7. Let K be a graph class of bounded expansion, E be the class of edgeless graphs and Z be the class of empty graphs. For every MSO sentence ϕ the problem MSO-MCϕ admits a linear kernel parameterized by wsnZ c . Furthermore, the problem MSO-MCϕ admits a linear kernel parameterized by wsnE c on K. c . Let G be a graph, k = wsnZ Proof. By Lemma 4 it is sufficient to show that MSO-MCφ admits a linear kernel parameterized by wsnZ c (G), and q be the nesting depth of quantifiers in φ. By Fact 12 we can find the set ~X of equivalence classes of ∼G c in polynomial time. Clearly, the set ~X is a (k, c)-well-structured modulator to the empty graph. We proceed by constructing (G0, ~X0) by Lemma 6. Since each X0 follows that G0 is an instance of MSO-MCϕ of size O(k). Finally, since G and G0 are q-similar, it follows from Fact 10 that G = φ if and only if G0 = φ. (cid:74) i ∈ ~X0 has size bounded by a constant, ~X0 ≤ k, andS ~X0 = V (G0), it Next, we combine the approaches used in [16] and [11] to handle MSO-OPT♦ ϕ problems by using our more general parameters. Similarly as in [16], we use a more involved replacement procedure which explicitly keeps track of the original cardinalities of sets and results in an annotated version of MSO-OPT♦ ϕ . However, some parts of the framework (in particular the replacement procedure) had to be reworked using the techniques developed in [11], since we now use split-modules instead of simple modules. Given a graph G = (V, E), an annotation W is a set of triples (X, Y, w) with X ⊆ V, Y ⊆ V, w ∈ N. For every set A ⊆ V we define W(A) =P (X,Y,w)∈W,X⊆Z,Y ∩Z=∅ w. The idea is that a triple (X, Y, w) assigns weight w to a vertex set X. Specifying the set Y allows us to control which subsets of Z the above sum is taken over. In the kernel, each set X will be a subset of a module M (with weight w corresponding to the optimum cardinality of a set in the matching module of the original graph). Setting Y = M \ X ensures that the sum W(Z) contains at most one term for each module M. Note that an instance of MSO-OPT♦ ϕ can be represented as an instance ϕ with the annotation W = { ({v},∅, 1) v ∈ V (G)}. We call the pair (G,W) an of aMSO-OPT♦ annotated graph. If the integer w is represented in binary, we can represent a triple (X, Y, w) in space X + Y + log2(w). Consequently, we may assume that the size of the encoding of an annotated graph (G,W) is polynomial in V (G) + W + max(X,Y,w)∈W log2 w. Each MSO formula ϕ(X) and ♦ ∈ {≤,≥} gives rise to an annotated MSO-optimization problem. aMSO-OPT♦ Instance: A graph G with an annotation W and an integer r ∈ N. Question: Is there a set Z ⊆ V (G) such that G = ϕ(Z) and W(Z)♦ r? ϕ ϕ ϕ if and only if (G0,W, r) ∈ aMSO-OPT≤ ϕ . (cid:73) Lemma 8. Let ϕ = ϕ(X) be a fixed MSO formula. Then given an instance (G, r) of MSO-OPT≤ and a (k, c)-well-structured modulator ~X = X1, . . . , Xk to Z of G, an annotated graph (G0,W) satisfying the following properties can be computed in polynomial time. 1. (G, r) ∈ MSO-OPT≤ 2. V (G0) ∈ O(k). 3. The encoding size of (G0,W) is O(k log(V (G))). Proof. The proof proceeds analogously to the proof of Theorem ********* in [16], with the distinction that we use the replacement procedure described in Fact 9. In particular, using Lemma 6 we compute a graph G0 with a (k, c)-well-structured modulator i is bounded by a {X0 1, . . . , X0 constant for each i ∈ [k]. To compute the annotation W, we proceed as follows. For each i ∈ [k], k} to Z such that (G, ~X) and (G0, ~X0) are (q + 1)-similar and X0 © Eduard Eiben and Robert Ganian and Stefan Szeider Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany we go through all subsets W 0 ⊆ X0 i. By Lemma 2, we can compute a formula Φ such that for any i], W 0) = typeq(H, W) if and only if H = Φ(W). graph H and W ⊆ V (H) we have typeq(G0[X0 i has constant size for every i ∈ [k], this can be done within a constant time bound. Since X0 Moreover, since (G, ~X) and (G0, ~X0) are (q + 1)-similar, there has to exist a W ⊆ Xi such that G[Xi] = Φ(W). Using Fact 3, we can compute a minimum-cardinality subset W ∗ ⊆ Xi with this i \ W 0,W ∗) to W. In total, the number property in polynomial time. We then add the triple (W 0, X0 of subsets processed is in O(k). From this observation we get the desired bounds on the total runtime, V (G0), and the encoding size of (G0,W). ϕ . Suppose there is a set W ⊆ V (G) of vertices such that G = ϕ(W) and W ≤ r. Since X1, . . . , Xk i∈[k] Wi, where Wi = W ∩ Xi. For each i ∈ [k], let i ⊆ Xi be a subset of minimum cardinality such that typeq(G[Xi], Wi) = typeq(G[Xi], W ∗ W ∗ i ). i for each i ∈ [k] such that From the (q + 1)-similarity of (G, ~U) and (G0, ~U0), there is W 0 i ,W ∗ i ). typeq(G0[X0 Observe that (X, Y, w) ∈ W and (X, Y, w0) ∈ W implies w = w0. Let W 0 = ∪i∈[k]W 0 i . Then by (q + 1)-similarity of (G, ~X) and (G0, ~X0) and Fact 10, we must have typeq(G, W) = typeq(G0, W 0). In particular, G0 = ϕ(W 0). Furthermore, is a partition of V (G), we have W = S i ). By construction, W contains a triple (W 0 ϕ if and only if (G, r) ∈ MSO-OPT≤ We claim that (G0,W, r) ∈ aMSO-OPT≤ i], W 0 i) = typeq(G[Xi], W ∗ i ⊆ X0 i , X0 i \ W 0 i ≤P W ∗ i∈[k] Wi = W ≤ r. W(W 0) =P (W 0 i ,X0 i\W 0 i ,W ∗ i )∈W,X0 i∩W 0=W 0 i i denote W 0 ∩ For the converse, let W 0 ⊆ V (G0) such that W(W 0) ≤ r and G0 = ϕ(W 0), let W 0 i for i ∈ [k]. By construction, there is a set Wi ⊆ Xi for each i ∈ [k] such that typeq(G[Xi], Wi) = X0 i∈[k] Wi. Let W = ∪i∈[k]Wi. Then by congruence and typeq(G0[X0 Fact 10 we get typeq(G, W) = typeq(G0, W 0) and thus G = ϕ(W). Moreover, W = W(W 0) ≤ r. (cid:74) i) and W(W 0) = P i], W 0 To complete the proof, we will make use of a win-win argument based on the following fact. (cid:73) Fact 11 (Folklore). Given an MSO sentence ϕ and a graph G, one can decide whether G = ϕ in time O(2nl), where n = V (G) and l = ϕ. (cid:73) Theorem 9. Let E be a class of edgeless graphs and Z be the class containing the empty graph. For every MSO formula ϕ the problem MSO-OPT≤ ϕ admits a linear bikernel parameterized by wsnE on any class of graphs of bounded expansion, and a linear bikernel parameterized by wsnZ c . c Proof. By Lemma 4 it is sufficient to show that MSO-MCφ admits a linear bikernel parameterized c . By Fact 12 we can find equivalence classes ~X = {X1, . . . , Xk} of ∼c in polynomial time. by wsnZ Let (G0,W) be the annotated graph computed from G and ~X according to Lemma 8. Let n = V (G) and suppose 2k ≤ n. Then we can solve (G0,W, r) in time nO(1). To do this, we go through all 2O(k) subsets W of G0 and test whether W(W) ≤ r. If that is the case, we check whether G0 = ϕ(W). By Fact 11 this check can be carried out in time c12c2k ≤ c1nc2 for suitable constants c1 and c2 depending only on ϕ. Thus we can find a constant t such that the entire procedure runs in time nt whenever n is large enough. If we find a solution W ⊆ V (G0) we return a trivial yes-instance; otherwise, a trivial no-instance (of aMSO-OPT≤ ϕ ). Now suppose n < 2k. Then log(n) < k and so the encoding size of W is polynomial in k. Thus (G0,W, r) is a polynomial bikernel. (cid:74) 5 Finding (k, c)-Well-Structured Modulators For the following considerations, we fix c and assume that the graph G has rank-width at least c + 2 (this is important for Fact 12). This assumption is sound, since the considered problems can be solved in polynomial time on graphs of bounded rank-width. Recall that given a split-module A in © Eduard Eiben and Robert Ganian and Stefan Szeider Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany G, we use λ(A) to denote the frontier of A. This section will show how to efficiently approximate well-structured modulators to various graph classes; in particular, we give algorithms for the class of forests and then for any graph class which can be characterized by a finite set of forbidden induced subgraphs. The following Fact 12 linking rank-width and split-modules will be crucial for approximating our well-structured modulators. (cid:73) Definition 10. Let G be a graph and c ∈ N. We define a relation ∼G c w if and only if there is a split-module M of G with v, w ∈ M and rw(G[M]) ≤ c. We drop the superscript from ∼G (cid:73) Fact 12 ([11]). Let c ∈ N be fixed and G be a graph of rank-width at least c + 2. The relation ∼G c is an equivalence, and any graph G has its vertex set uniquely partitioned by the equivalence classes of ∼c into inclusion-maximal split-modules of rank-width at most c. Furthermore, for a, b ∈ V (G) it is possible to test a ∼c b in O(n3) time. c if the graph G is clear from context. c on V (G) by letting v ∼G 5.1 Finding (k, c)-Well-Structured Modulators to Forests Our starting point is the following lemma, which shows that long cycles which hit a non-singleton frontier imply the existence of short cycles. (cid:73) Lemma 11. Let C be a cycle in G such that C intersects at least three distinct equivalence classes of ∼c, one of which has a frontier of cardinality at least 2. Let Z be the set of equivalence classes of ∼c which intersect C. Then there exists a cycle C0 such that the set Z0 of equivalence classes it intersects is a subset of Z and has cardinality at most 3. Proof. Let B be an equivalence class in Z such that b1, b2 ∈ λ(B) are two distinct vertices. By assumption, C must contain two distinct vertices a, c 6∈ B which are adjacent to λ(B). Then a, b1, c, b2 forms a C4 in G[B ∪ {a, c}]. (cid:74) We will use the following observation to proceed when Lemma 11 cannot be applied. (cid:73) Observation 2. Assume that for each equivalence class B of ∼c it holds that G[B] is acyclic, and that no cycle intersects B if λ(B) ≥ 2. Then for every cycle C in G and every vertex a ∈ C, it holds that a is in the frontier of some equivalence class of ∼c. Fact 13 below is the last ingredient needed for the algorithm. (cid:73) Fact 13 ([4]). FEEDBACK VERTEX SET can be 2-approximated in polynomial time. (cid:73) Theorem 12. Let c ∈ N and F be the class of forests. There exists a polynomial algorithm which takes as input a graph G of rank-width at least c + 2 and computes a set ~X of split-modules such that ~X is a (k, c)-well-structured modulator to F and k ≤ 3 · wsnF c . Proof. We first describe the algorithm and then argue correctness. The algorithm proceeds in three steps. I By deciding a ∼c b for each pair of vertices in G as per Fact 12, we compute the equivalence classes of ∼c. II For each set of up to three equivalence classes {A1, A2, A3} of ∼c, we check if G[A1 ∪ A2 ∪ A3] is acyclic; if it's not, then we add A1, A2 and A3 to ~X and set G := G − (A1 ∪ A2 ∪ A3). every equivalence class of ∼c which intersects S. We then set ~X := ~X ∪ S0, and output ~X. III We use Fact 13 to 2-approximate a feedback vertex set S of G in polynomial time; let S0 contain © Eduard Eiben and Robert Ganian and Stefan Szeider Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany For correctness, observe that Step III guarantees that G − ~X is acyclic. Hence we only need to argue that ~X ≤ 3 · wsnF c . So, assume for a contradiction that there exists a (k, c)-well-structured modulator ~X0 to F such that ~X > 3· k. Let Λ be the set of all equivalence classes of ∼c which were added to ~X in Step II of the algorithm. Since for each such {A1, A2, A3} the graph G[A1 ∪ A2 ∪ A3] contains a cycle and A1, A2, A3 are inclusion-maximal split-modules of rank-width at most c by Fact 12, ~X0 must always contain at least one split-moduleA0 such that A0 ⊆ Ai for some i ∈ [3]. Let Λ0 contain all such split-modules A0, i.e., all elements of ~X0 which form a subset of a split-module added to ~X in Step II. 3 = ~X0 \ Λ0. Since Λ ≤ 3 · Λ0 by the argument above, from our Let ~X3 = ~X \ Λ and ~X0 3. Let us consider the graphs G3 = G − Λ and assumption it would follow that ~X3 > 3 · ~X0 3 = G0 − Λ0; observe that G3 ⊆ G0 G0 3. Furthermore, by Lemma 11 a cycle C in G3 cannot intersect any equivalence class B of ∼c such that λ(B) ≥ 2. Hence we can apply Observartion 2, from which it follows that there is a one-to-one correspondence between any minimal feedback vertex set in G3 and the equivalence classes of ∼c in G3. Let z be the cardinality of a minimum feedback vertex set in G3; by the correctness of the algorithm of Fact 13, we have z ≤ ~X3 ≤ 2z. Since G0 3 is a supergraph of G3, it follows that ~X0 3 ≥ z, and hence from our assumption we would obtain 3 ≥ 3z. We have thus reached a contradiction, and conclude that there exists no 2z ≥ ~X3 > 3 · ~X0 (k, c)-well-structured modulator to F such that ~X > 3 · k. (cid:74) 5.2 Finding (k, c)-Well-Structured Modulators via Obstructions Here we will show how to efficiently find a sufficiently small (k, c)-well-structured modulator to any graph class which can be characterized by a finite set of forbidden induced subgraphs. Let us fix a graph class H characterized by a set R of forbidden induced subgraphs, and let r be the maximum order of a graph in R. Our first step is to reduce our problem to the classical HITTING SET problem, the definition of which is recalled below. d-HITTING SET Instance: A ground set S and a collection C of subsets of S, each of cardinality at most d. Notation: A hitting set is a subset of S which intersects each set in C. Task: Find a minimum-cardinality hitting set. Given a graph G (of rank-width at least c + 2), we construct an instance WG of r-HITTING SET as follows. The ground set of W contains each equivalence class A ⊆ V (G) of ∼c. For each induced subgraph R ⊆ G isomorphic to an element of R, we add the set CR of equivalence classes of ∼c which intersect R into C. This completes the construction of WG; we let hit(WG) denote the cardinality of a solution of WG. (cid:73) Lemma 13. For any graph G of rank-width at least c + 2, the instance WG is unique and can be constructed in polynomial time. Every hitting set Y in WG is a (Y , c)-well-structured modulator to H in G. Moreover, wsnH c = hit(WG). Proof. The uniqueness of WG, as well as the fact that WG can be constructed in polynomial time, follow from Fact 12 together with the observation that all subgraphs R ⊆ G isomorphic to an element of R can be enumerated in polynomial time. For the second claim, consider a hitting set Y ⊆ S. The graph G − Y cannot contain any obstruction for H, and hence G − Y ∈ H. For the third claim, assume G contains a (hit(WG) − 1, c)-well-structured modulator ~X to H. By Fact 12, each element A of ~X forms a subset of an equivalence class A0 of ∼c. Let ~X0 be obtained by replacing each element of A by its respective superset A0. Then G − ~X0 is a subgraph of G − ~X, © Eduard Eiben and Robert Ganian and Stefan Szeider Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany and hence by our assumption G − ~X0 cannot contain any subgraph isomorphic to an element of R. However, this would imply that ~X0 is a hitting set in WG of cardinality hit(WG) − 1, which is a (cid:74) contradiction. The final ingredient we need for our approximation algorithm is the following folklore result. (cid:73) Fact 14 (Folklore, see also [21]). There exists a polynomial-time algorithm which takes as input an instance W of r-HITTING SET and outputs a hitting set Y of cardinality at most r · hit(W). (cid:73) Theorem 14. Let c ∈ N and H be a class of graphs characterized by a finite set of forbidden induced subgraphs of order at most r. There exists a polynomial algorithm which takes as input a graph G of rank-width at least c + 2 and computes a (k, c)-well-structured modulator to H such that k ≤ r · wsnH c . Proof. We proceed in two steps: first, we compute the r-HITTING SET instance WG, and then we use Fact 14 to compute an r-approximate solution Y of WG in polynomial time. We then set ~X := Y and output. Correctness follows from Lemma 13. In particular, the hitting set Y computed by Fact 14 has cardinality at most r · hit(WG) and hence ~X ≤ r · wsnH (cid:74) c (G) by Lemma 13. 6 Applications of (k, c)-Well-Structured Modulators We now proceed by outlining the general applications of our results. Our algorithmic framework is captured by the following Theorem 15. (cid:73) Theorem 15. Let p, q be polynomial functions. For every MSO sentence φ and every graph class H such that 1. MSO-MCφ admits a (bi)kernel of size p(modH(G)), and 2. there exists a polynomial algorithm which finds a (q(wsnH the problem MSO-MCφ admits a (bi)kernel of size p(q(wsnH Proof. Let G be a graph, k = wsnH c (G) and s be the nesting depth of quantifiers in φ. We begin by c ), c)-well-structured modulator to H, denoted ~X, in polynomial time by using computing a (q(wsnH i ∈ ~X0 has size Condition 2. We then proceed by constructing (G0, ~X0) by Lemma 6. Since each X0 O(q(k)). Then, using Condition 1, MSO-MCφ admits a kernel of size p(q(k)) on G0. Finally, since G and G0 are q-similar, it follows from Fact 10 that G = φ if and only if G0 = φ. (cid:74) bounded by a constant and ~X0 ≤ k, it follows thatS ~X0 is a modulator to H graphs of cardinality c ), c)-well-structured modulator to H, c (G))). Let us briefly discuss the limitations of the above theorem. The condition that MSO-MCφ admits a polynomial (bi)kernel parameterized by modH(G) is clearly necessary for the rest of the theorem to hold, since wsnH(G) ≤ modH(G). One might wonder whether a weaker necessary condition could be used instead; specifically, would it be sufficient to require that MSO-MCφ is polynomial-time tractable in H? This turns out not to be the case, as follows from the following fact. (cid:73) Fact 15 ([11]). There exists an MSO sentence φ and a graph class H characterized by a finite set of forbidden induced subgraphs such that MSO-MCφ is polynomial-time tractable on H but NP-hard on the class of graphs with modH(G) ≤ 2. Condition 2 is also necessary for our approach to work, as we need some (approximate) well- structured modulator; luckily, Section 5 shows that a wide variety of studied graph classes satisfy this condition. Finally, one can also rule out an extension of Theorem 15 to MSO-OPT problems (which was possible in the special case considered in Section 4), as we show below. © Eduard Eiben and Robert Ganian and Stefan Szeider Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany First, we prove that MSO-OPT≤ (cid:73) Lemma 16. There exists an MSO formula ϕ and a graph class H characterized by a finite ϕ admits a bikernel parameterized by modH but is paraNP-hard obstruction set such that MSO-OPT≤ parameterized by wsnH 1 . Proof. Consider the formula ϕ(S) = fvs(S) ∨ deg(S), where fvs(S) expresses that S is a feedback vertex set in G and deg(S) expresses that S is a modulator to graphs with maximum degree 4. Let H be the class of graphs of maximum degree 4. ϕ admits a polynomial bikernel parameterized by k = modH(G). ϕ , we check if r ≥ k. If this Consider the following algorithm: given an instance (G, r) of MSO-OPT≤ is the case, we can immediately output YES, since k is the minimum size of a set S satisfying deg(S). ≤ fvs from (G, r), and a polynomial If r < k, we compute a polynomial kernel (G1, r1) of MSO-OPT ≤ kernel (G2, r2) for MSO-OPT deg from (G, r). Both (G1, r1) and (G2, r2) have size bounded by a polynomial of k, G1 can be constructed by using any kernelization algorithm for FEEDBACK VERTEX SET [25], and G2 can be constructed by enumerating all obstructions (supergraphs of K1,5) and then using a kernelization algorithm for 6-HITTING SET [1]. Now it is easily observed that (G, r) is a YES instance of MSO-OPT≤ ϕ if and only if ((G1, r1), (G2, r2)) is a YES instance of the following problem: given an instance (A, a) of FEEDBACK VERTEX SET and an instance (B, b) of 6-HITTING SET, answer YES if and only if at least one of (A, a) and (B, b) is a YES instance. ϕ is NP-hard even when G has a (1, 1)-well- structured modulator to H. We reduce from the (unparameterized) FEEDBACK VERTEX SET problem on graphs of degree at most 4, which is known to be NP-hard [17]. Let (G, r) be an instance of FEEDBACK VERTEX SET where G is an n-vertex graph of degree at most 4. We construct the graph G0 from G by adding a single vertex x and a disjoint union of n + 1 stars with five leaves, denoted S1, . . . , Sn+1, and then adding an edge from x to the center of each star and from x to a single arbitrary vertex in G. Observe that any feedback vertex set in G is also a feedback vertex set in G0, and that any set S sayisfying deg(S) must have cardinality at least n + 1. Hence (G, r) is a YES-instance of FEEDBACK VERTEX SET if and only if (G0, r) is a YES-instance of MSO-OPT≤ ϕ . Since x together with the stars added in G0 forms a tree (which has rank-width 1), it follows that this forms a (1, 1)-well-structured modulator to H. (cid:74) To conclude the proof, we show that MSO-OPT≤ 6.1 Applications of Theorem 15 As our first general application, we consider the results of Gajarský et al. in [14]. Their main result is summarized below. (cid:73) Fact 16 ([14]). Let Π be a problem with finite integer index, K a class of graphs of bounded expansion, d ∈ N, and H be the class of graphs of treedepth at most d. Then there exist an algorithm that takes as input (G, ξ) ∈ K × N and in time O(G + log ξ) outputs (G0, ξ0) such that 1. (G, ξ) ∈ Π if and only if (G0, ξ0) ∈ Π; 2. G0 is an induced subgraph of G; and 3. G0 = O(modH(G)). The following fact provides a link between the notion of finite integer index used in the above result and the MSO-MCϕ problems considered in this paper. (cid:73) Fact 17 ([3], see also [5]). For every MSO sentence ϕ, it holds that MSO-MCϕ is finite-state and hence has finite integer index. Finally, the following well-known fact is the last ingredient we need to apply our machinery. (cid:73) Fact 18 ([23], page 138). Let d ∈ N and H be the class of graph of treedepth at most d. Then H can be characterized by finite set of forbidden induced subgraphs. © Eduard Eiben and Robert Ganian and Stefan Szeider Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany (cid:73) Theorem 17. Let c, d ∈ N and H be the class of graphs of treedepth at most d. For every MSO sentence ϕ, it holds that MSO-MCϕ admits a linear kernel parameterized by wsnH c on any class of graphs of bounded expansion. Proof. Our proof relies on Theorem 15. From Fact 17 and Fact 16 it follows that MSO-MCϕ admits a kernel of size O(modH(G)). Hence the assumptions of the theorem satisfy Condition 1 of Theorem 15, where the polynomial p is a linear function. By Fact 18 H can be characterized by finite set of forbidden induced subgraphs. Therefore, by Theorem 14 there exists a polynomial algorithm that can find a (k, c)-well-structured modulator to H and k ≤ r· wsnH c , where r ∈ N is a constant (depending on d). Therefore, Condition 2 of Theorem 15 is also satisfied, where the polynomial q is also linear function. Hence we conclude that MSO-MCϕ admits a kernel of size r · wsnH (cid:74) c (G). As our second general application, we consider well-structured modulators to the class of forests. Lemma 18 shows that feedback vertex set may be used to kernelize any MSO-definable decision problem on graphs of bounded degree. However, before we proceed to the lemma itself, we need to briefly introduce the protrusion replacement rule. Given a graph G, an r-protrusion is a set of vertices L ⊆ V (G) such that N(G − L) ≤ r and the treewidth of G[L] is at most r. The set N(G − L) is called the boundary of L. A much more in-depth explanation of protrusion replacement can be found, e.g., in [5] or [20]. (cid:73) Fact 19 ([5, 20]). Let r ∈ N be a constant, φ be a fixed MSO formula and G be a graph containing an r-protrusion L. Then there exists a constant-size graph G0 L such that the graph G0 obtained by L adjacent to the neighbors of L satisfies G0 = ϕ iff deleting L and making at most r vertices of G0 G = ϕ. Furthermore the graph G0 L may be computed from G and L in polynomial time. The graph G0 L is sometimes called a representative. (cid:73) Lemma 18. Let F be the class of forests and d ∈ N. For every MSO sentence ϕ, it holds that MSO-MCϕ admits a linear kernel parameterized by modF on any class of graphs of degree at most d. Proof. Let G0 be the input graph. We first use Fact 13 to compute a feedback vertex set X ⊆ V (G) of cardinality k ≤ 2modF(G). Let G0 0 denote the graph containing all the connected components of G0 − X which are not adjacent to X. Since G0 0 has treewidth 1 and an empty boundary, by Fact 19 we can find a constant-size graph G∗ 0 such that the graph G∗ obtained from G0 by replacing G0 0 with 0 satisfies the following: G∗ = ϕ iff G0 = ϕ. G∗ Let G be obtained from G∗ by deleting G∗ 0. Then the number of connected components in H = G − X is bounded by k · d, since each tree in H is adjacent to at least one vertex in X. Let u be the order of the largest representative G0 L as per Fact 19 for treewidth 1, boundary-size 2 and ϕ. We proceed by marking each vertex in H which is adjacent to some vertex in X. This is followed by a secondary marking procedure, where we mark each vertex v ∈ V (H) of degree at least 3 with the following property: deleting v separates its connected component in H into at least 3 connected components of H, each containing at least 1 marked vertex. Observe that the total number of marked vertices is bounded by 2dk. Now assume that H contains a tree T of diameter r such that r > u · (z + 1), where z is the number of marked vertices in T . Let P be a path in T of length r. Let us partition P into path segments P0, P1, . . . Py, where P0 ends at the first marked vertex on P , Py starts at the first marked vertex on P , and each other Pj starts at the j-th and ends at the (j + 1)-th marked vertex on P . Then there must exist some path segment of diameter greater than u; let us pick an arbitrary such path segment Pi between vertices a and b. Let T 0 be the subtree of T between a and b (including a, b); observe that the only marked vertices which may occur in T 0 are a and b. Then T 0 forms a subgraph © Eduard Eiben and Robert Ganian and Stefan Szeider Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany in G with a boundary size of 2, treewidth 1, and size larger than the representative of T 0. Hence invoking the replacement procedure on T 0 results in a new, equivalent graph G of smaller order. The step outlined in this paragraph takes polynomial time and is guaranteed to reduce the order of G by at least 1. So, assume that each tree in H has diameter at most u · (z + 1), where z is the number of marked vertices in that tree. In particular, this implies that each tree has order at most ud · (z + 1). Since the total number of marked vertices in H is at most dk, it follows that V (H) ∈ O(k). In particular, this implies that V (G∗) ∈ O(k), which means that we have a linear kernel. (cid:74) With Lemma 18, the proof of the following theorem is analogous to the proof of Theorem 17. (cid:73) Theorem 19. Let c ∈ N and F be the class of forests. For every MSO sentence ϕ, it holds that MSO-MCϕ admits a linear kernel parameterized by wsnF c on any class of graphs of bounded degree. Proof. The theorem once again follows from Theorem 15. In particular, Condition 1 follows directly from Lemma 18 with a linear function p. Theorem 12 then gives us a polynomial time algorithm to find a 3-approximation of wsnF c , satisfying Condition 2 with q also linear. Therefore we conclude by Theorem 15 that MSO-MCϕ admits a linear kernel parameterized by wsnH c on any class of graphs of (cid:74) bounded degree. 7 Conclusion Our results show that measuring the structure of modulators can lead to an interesting and, as of yet, relatively unexplored spectrum of structural parameters. Such parameters have the potential of combining the best of decomposition-based techniques and modulator-based techniques, and can be applied both in the context of kernelization (as demonstrated in this work) and FPT algorithms [11]. We believe that further work in the direction of modulators will allow us to push the frontiers of tractability towards new, uncharted classes of inputs. One possible direction for future research is the question of whether the class of MSO-definable problems considered in Theorem 15 can be extended to other finite-state problems. It would of course also be interesting to see more applications of Theorem 15 and new methods for approximating well-structured modulators. Last but not least, we mention that the split-modules used in the definition of our parameters could in principle be refined to less restrictive notions (for instance cuts of constant cut-rank [24]); such a relaxed parameter could still be used to obtain polynomial kernels, as long as there is a way of efficiently approximating or computing such modulators. 1 References F. N. Abu-Khzam. A kernelization algorithm for d-hitting set. J. Comput. Syst. Sci., 76(7):524 -- 531, 2010. 2 N. Alon, G. Gutin, E. J. Kim, S. Szeider, and A. Yeo. Solving max-r-sat above a tight lower bound. 3 Algorithmica, 61(3):638 -- 655, 2011. S. Arnborg, B. Courcelle, A. Proskurowski, and D. Seese. An algebraic theory of graph reduction. J. of the ACM, 40(5):1134 -- 1164, 1993. 4 A. Becker and D. Geiger. Optimization of pearl's method of conditioning and greedy-like approxi- mation algorithms for the vertex feedback set problem. Artif. Intell., 83(1):167 -- 188, 1996. 5 H. L. Bodlaender, F. V. Fomin, D. Lokshtanov, E. Penninkx, S. Saurabh, and D. M. Thilikos. (meta) kernelization. In FOCS 2009, pages 629 -- 638. IEEE Computer Society, 2009. 6 H. L. Bodlaender, B. M. P. Jansen, and S. Kratsch. Kernel bounds for path and cycle problems. Theor. Comput. Sci., 511:117 -- 136, 2013. © Eduard Eiben and Robert Ganian and Stefan Szeider Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany 7 H. L. Bodlaender, B. M. P. Jansen, and S. Kratsch. Preprocessing for treewidth: A combinatorial analysis through kernelization. SIAM J. Discrete Math., 27(4):2108 -- 2142, 2013. 8 H. L. Bodlaender, B. M. P. Jansen, and S. Kratsch. Kernelization lower bounds by cross- 9 10 11 12 13 14 15 16 composition. SIAM J. Discrete Math., 28(1):277 -- 305, 2014. B. Courcelle. The monadic second-order logic of graphs XIV: uniformly sparse graphs and edge set quantifications. Theoretical Computer Science, 299(1 -- 3):1 -- 36, 2003. R. Diestel. Graph Theory, volume 173 of Graduate Texts in Mathematics. Springer Verlag, New York, 2nd edition, 2000. E. Eiben, R. Ganian, and S. Szeider. Solving problems on graphs of high rank-width. In WADS, 2015. To appear; preprint available at: http://www.ac.tuwien.ac.at/wp/ wp-content/uploads/EibenGanianSzeider15-Preprint.pdf. F. V. Fomin, B. M. P. Jansen, and M. Pilipczuk. Preprocessing subgraph and minor problems: When does a small vertex cover help? J. Comput. Syst. Sci., 80(2):468 -- 495, 2014. F. V. Fomin, D. Lokshtanov, S. Saurabh, and D. M. Thilikos. Bidimensionality and kernels. In SODA, pages 503 -- 510, 2010. J. Gajarský, P. Hlinený, J. Obdržálek, S. Ordyniak, F. Reidl, P. Rossmanith, F. S. Villaamil, and S. Sikdar. Kernelization using structural parameters on sparse graph classes. In ESA 2013, volume 8125 of Lecture Notes in Computer Science, pages 529 -- 540. Springer, 2013. R. Ganian and P. Hlinený. On parse trees and Myhill-Nerode-type tools for handling graphs of bounded rank-width. Discr. Appl. Math., 158(7):851 -- 867, 2010. R. Ganian, F. Slivovsky, and S. Szeider. Meta-kernelization with structural parameters. In MFCS, pages 457 -- 468, 2013. 17 M. R. Garey and D. R. Johnson. Computers and Intractability. W. H. Freeman and Company, New York, San Francisco, 1979. P. Hlinený and S. il Oum. Finding branch-decompositions and rank-decompositions. SIAM J. Comput., 38(3):1012 -- 1032, 2008. B. M. P. Jansen and H. L. Bodlaender. Vertex cover kernelization revisited - upper and lower bounds for a refined parameter. Theory Comput. Syst., 53(2):263 -- 299, 2013. 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 ICALP (1), pages 613 -- 624, 2013. J. M. Kleinberg and É. Tardos. Algorithm design. Addison-Wesley, 2006. L. Libkin. Elements of Finite Model Theory. Springer, 2004. J. Nesetril and P. O. de Mendez. Sparsity - Graphs, Structures, and Algorithms, volume 28 of Algorithms and Combinatorics. Springer, 2012. S. Oum and P. Seymour. Approximating clique-width and branch-width. J. Combin. Theory Ser. B, 96(4):514 -- 528, 2006. S. Thomassé. A 4k2 kernel for feedback vertex set. ACM Transactions on Algorithms, 6(2), 2010. 18 19 20 21 22 23 24 25 © Eduard Eiben and Robert Ganian and Stefan Szeider Leibniz International Proceedings in Informatics Schloss Dagstuhl -- Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany
1903.02185
4
1903
2019-10-25T08:54:56
Stable Noncrossing Matchings
[ "cs.DS", "cs.CG" ]
Given a set of $n$ men represented by $n$ points lying on a line, and $n$ women represented by $n$ points lying on another parallel line, with each person having a list that ranks some people of opposite gender as his/her acceptable partners in strict order of preference. In this problem, we want to match people of opposite genders to satisfy people's preferences as well as making the edges not crossing one another geometrically. A noncrossing blocking pair w.r.t. a matching $M$ is a pair $(m,w)$ of a man and a woman such that they are not matched with each other but prefer each other to their own partners in $M$, and the segment $(m,w)$ does not cross any edge in $M$. A weakly stable noncrossing matching (WSNM) is a noncrossing matching that does not admit any noncrossing blocking pair. In this paper, we prove the existence of a WSNM in any instance by developing an $O(n^2)$ algorithm to find one in a given instance.
cs.DS
cs
Stable Noncrossing Matchings Suthee Ruangwises∗ 1 and Toshiya Itoh†1 1Department of Mathematical and Computing Science, Tokyo Institute of Technology, Tokyo, Japan Abstract Given a set of n men represented by n points lying on a line, and n women repre- sented by n points lying on another parallel line, with each person having a list that ranks some people of opposite gender as his/her acceptable partners in strict order of preference. In this problem, we want to match people of opposite genders to satisfy people's preferences as well as making the edges not crossing one another geometrically. A noncrossing blocking pair w.r.t. a matching M is a pair (m, w) of a man and a woman such that they are not matched with each other but prefer each other to their own partners in M , and the segment (m, w) does not cross any edge in M . A weakly stable noncrossing matching (WSNM) is a noncrossing matching that does not admit any noncrossing blocking pair. In this paper, we prove the existence of a WSNM in any instance by developing an O(n2) algorithm to find one in a given instance. Keywords: stable matching, stable marriage problem, noncrossing matching, geo- metric matching 1 Introduction The stable marriage problem is one of the most classic and well-studied problems in the area of matching under preferences, with many applications in other fields including economics [5, 10]. We have a set of n men and a set of n women, with each person having a list that ranks some people of opposite gender as his/her acceptable partners in order of preference. A matching is a set of disjoint man-woman pairs. A blocking pair w.r.t. a matching M is a pair of a man and a women that are not matched with each other in M but prefer each other to their own partners. The goal is to find a stable matching, a matching that does not admit any blocking pair. On the other hand, the noncrossing matching problem is a problem in the area of geometric matching. We have a set of 2n points lying on two parallel lines, each containing n points. We also have some edges joining vertices on the opposite lines. The goal is to select a set of edges that do not cross one another subject to different objectives, e.g. maximum size, maximum weight, etc. In this paper, we study a problem in geometric matching under preferences. In partic- ular, we investigate the problem of having n men and n women represented by points lying ∗[email protected][email protected] 1 on two parallel lines, with each line containing n people of one gender. Each person has a list that ranks some people of opposite gender in strict order of preference. A noncrossing blocking pair w.r.t. a matching M is a blocking pair w.r.t. M that does not cross any edge in M . Our goal is to find a noncrossing matching that does not admit any noncrossing blocking pair, called a weakly stable noncrossing matching (WSNM). Note that the real-world applications of this geometric problem are more likely to involve immovable objects, e.g. construction of noncrossing bridges between cities on the two sides of a river, with each city having different preferences. In this paper, however, we keep the terminologies of men and women used in the original stable marriage problem in order to understand and relate to the original problem more easily. 1.1 Related Work The stable marriage problem was first introduced by Gale and Shapley [3]. They proved that a stable matching always exists in an instance with n men and n women, with each person's preference list containing all n people of opposite gender and not containing ties. They also developed an O(n2) algorithm to find a stable matching in a given instance. Gusfield and Irving [5] later showed that the algorithm can be adapted to the setting where each person's preference list may not contain all people of opposite gender. The algorithm runs in O(m) time in this setting, where m is the total length of people's preference lists. Gale and Sotomayor [4] proved that in this modified setting, a stable matching may have size less than n, but every stable matching must have equal size. Irving [7] then generalized the notion of a stable matching to the case where ties are allowed in people's preference lists. He introduced three types of stable matchings in this setting: weakly stable, super- stable, and strongly stable, as well as developing algorithms to determine whether each type of matching exists in a given instance and find one if it does. The Stable Roommates problem is a generalization of the stable marriage problem to a non-bipartite setting where people can be matched regardless of gender. Unlike in the original problem, a stable matching in this setting does not always exist. Irving [6] developed an O(n2) algorithm to find a stable matching or report that none exists in a given instance, where n is the number of people. On the other hand, the noncrossing matching problem in a bipartite graph where the points lie on two parallel lines, each containing n points, was encountered in many real- world situations such as in VLSI layout design [8]. In the special case where each point is adjacent to exactly one point on the opposite line, Fredman [2] presented an O(n log n) algorithm to find a maximum size noncrossing matching by computing the length of the longest increasing subsequence (LIS). Widmayer and Wong [11] developed another algorithm that runs in O(k +(n−k) log(k +1)) time, where k is the size of the solution. This algorithm has the same worst-case runtime as Fredman's, but runs faster in most general cases. In a more general case where each point may be adjacent to more than one point, Malucelli et al. [9] developed an algorithm to find a maximum size noncrossing matching. The algorithm runs in either O(m log log n) or O(m + min (nk, m log k)) time depending on implementation, where m is the number of edges and k is the size of the solution. In the case where each edge has a weight, they also showed that the algorithm can be adapted to find a maximum weight noncrossing matching with O(m log n) runtime. 2 1.2 Our Contribution In this paper, we constructively prove that a weakly stable noncrossing matching always exists in any instance by developing an O(n2) algorithm to find one in a given instance. 2 Preliminaries In this setting, we have a set of n men m1, ..., mn represented by points lying on a vertical line in this order from top to bottom, and a set of n women w1, ..., wn represented by points lying on another parallel line in this order from top to bottom. Only people of opposite genders can be matched with each other, and each person can be matched with at most one other person. A matching is a set of disjoint man-woman pairs. For a person a and a matching M , define M (a) to be the person matched with a (for convenience, let M (a) = null for an unmatched person a). For each person a, let Pa be the preference list of a containing people of opposite gender to a as his/her acceptable partners in decreasing order of preference. Note that a preference list does not have to contain all n people of opposite gender. Throughout this paper, we assume that the preference lists are strict (containing no tie involving two or more people). Also, let ra(b) be the rank of a person b in Pa, with the first entry having rank 1, the second entry having rank 2, and so on (for convenience, let ra(null) = ∞ and treat null as the last entry appended to the end of Pa, as being matched is always better than being unmatched). A person a is said to prefer a person b to a person c if ra(b) < ra(c). A pair of edges cross each other if they intersect in the interior of both segments. Formally, an edge (mi, wx) crosses an edge (mj, wy) if and only if (i − j)(x − y) < 0. A matching is called noncrossing if it does not contain any pair of crossing edges. The following are the formal definitions of a blocking pair given in the original stable marriage problem, and a noncrossing blocking pair introduced here. Definition 1. A blocking pair w.r.t. a matching M is a pair (m, w) of a man and a woman that are not matched with each other, but m prefers w to M (m) and w prefers m to M (w). Definition 2. A noncrossing blocking pair w.r.t. a matching M is a blocking pair w.r.t. M that does not cross any edge in M . We also introduce two types of stable noncrossing matchings, distinguished as weakly and strongly stable. Definition 3. A matching M is called a weakly stable noncrossing matching (WSNM) if M is noncrossing and does not admit any noncrossing blocking pair. Definition 4. A matching M is called a strongly stable noncrossing matching (SSNM) if M is noncrossing and does not admit any blocking pair. Note that an SSNM is a matching that is both noncrossing and stable, while a WSNM is "stable" in a weaker sense as it may admit a blocking pair, just not a noncrossing one. An SSNM may not exist in some instances. For example, in an instance of two men and two women, with Pm1 = (w2, w1), Pm2 = (w1, w2), Pw1 = (m2, m1), and Pw2 = (m1, m2), the only stable matching is {(m1, w2), (m2, w1)}, and its two edges do cross each other. On the other hand, the above instance has two WSNMs {(m1, w2)} and {(m2, w1)}. It also 3 turns out that a WSNM always exists in every instance. Throughout this paper, we focus on the proof of existence of a WSNM by developing an algorithm to find one. 3 Our Algorithm 3.1 Outline Without loss of generality, for each man m and each woman w, we assume that w is in m's preference list if and only if m is also in w's preference list (otherwise we can simply remove the entries that are not mutual from the lists). Initially, every person is unmatched. Our algorithm uses proposals from men to women similarly to the Gale Shapley al- gorithm in [3], but in a more constrained way. With M being the current noncrossing matching, when a woman w receives a proposal from a man m, if she prefers her current partner M (w) to m, she rejects m; if she is currently unmatched or prefers m to M (w), she dumps M (w) and accepts m. Consider a man m and a woman w not matched with each other. An entry w in Pm has the following possible states: 1. accessible (to m), if (m, w) does not cross any edge in M ; 1.1. available (to m), if w is accessible to m, and is currently unmatched or matched with a man she likes less than m, i.e. m is going to be accepted if he proposes to her (for convenience, if w is currently matched with m, we also call w accessible and available to m). 1.2. unavailable (to m), if w is accessible to m, but is currently matched with a man she likes more than m, i.e. m is going to be rejected if he proposes to her; 2. inaccessible (to m), if w is not accessible to m; For a man m, if every entry in Pm before M (m) is either inaccessible or unavailable, then we say that m is stable; otherwise (there is at least one available entry before M (m)) we say that m is unstable. The main idea of our algorithm is that, at any point, if there is at least one unstable man, we pick the topmost unstable man mi (the unstable man mi with least index i) and perform the following operations. 1. Let mi dump his current partner M (mi) (if any), i.e. remove (mi, M (mi)) from M , and let him propose to the available woman wj that he prefers most. 2. Let wj dump her current partner M (wi) (if any), i.e. remove (M (wj), wj) from M , and let her accept mi's proposal. 3. Add the new pair (mi, wj) to M . We repeatedly perform such operations until every man becomes stable. Note that through- out the algorithm, every proposal will result in acceptance and M will always be noncrossing since men propose only to women available to them. 4 3.2 Proof of Correctness First, we will show that if our algorithm stops, then the matching M given by the algorithm must be a WSNM. Assume, for the sake of contradiction, that M admits a noncrossing blocking pair (mi, wj). That means mi prefers wj to his current partner M (mi), wj prefers mi to her current partner M (wj), and (mi, wj) does not cross an edge in M , thus the entry wj in Pmi is available and is located before M (mi). However, by the description of our algorithm, the process stops when every man becomes stable, which means there cannot be an available entry before M (mi) in Pmi, a contradiction. Therefore, we can conclude that our algorithm gives a WSNM as a result whenever it stops. However, it is not trivial that our algorithm will eventually stop. In contrast to the GaleShapley algorithm in the original stable marriage problem, in this problem a woman is not guaranteed to get increasingly better partners throughout the process because a man can dump a woman too if he later finds a better available woman previously in- accessible to him (due to having an edge obstructing them). In fact, it is actually the case where the process may not stop if at each step we pick an arbitrary unstable man instead of the topmost one. For example, in an instance of two men and two women with Pm1 = (w2, w1), Pm2 = (w1, w2), Pw1 = (m1, m2), Pw2 = (m2, m1), the order of pick- ing m1, m2, m2, m1, m1, m2, m2, m1, ... results in the process continuing forever, with the matching M looping between {(m1, w2)}, {(m2, w2)}, {(m2, w1)}, and {(m1, w1)} at each step. We will prove that our algorithm must eventually stop and evaluate its worst-case run- time after we introduce the explicit implementation of the algorithm in the next subsection. 3.3 Implementation To implement the above algorithm, we have to consider how to efficiently find the topmost unstable man at each step in order to perform the operations on him. Of course, a straight- forward way to do this is to update the state of every entry in every man's preference list after each step, but that method will be very inefficient. Instead, we introduce the following scanning method. Throughout the algorithm, we do not know exactly the set of all unstable men, but we instead keep a set S of men that are "possibly unstable." Initially, the set S contains all men, i.e. S = {m1, m2, ..., mn}, and at each step we maintain the set S of the form {mi, mi+1, ..., , mn} for some i ∈ [n] (that means m1, m2, ..., mi−1 are guaranteed to be stable at that time). Note that in the actual implementation, we can store only the index of the topmost man in S instead of the whole set. At each step, we scan the topmost man mi in S and check whether mi is stable. If mi is already stable, then we simply skip him by removing mi from S and moving to scan the next man in S. If mi is unstable, then mi is indeed the topmost unstable man we want, so we perform the operations on mi. Note that the operations may cause some men to become unstable, so after that we have to add all men that are possibly affected by the operations back to S. The details of the scanning and updating processes are as follows. During the scan of mi, let mprev be the matched man closest to mi that lies above him, and let wf irst = M (mprev) (we let wf irst = w1 if there is no mprev). Also, let mnext be the matched man closest to mi that lies below him, and let wlast = M (mnext) (we let wlast = wn 5 . . . . . . available to mi iff wf irst prefers mi to mprev mprev wf irst mi available to mi accessible to mi mnext wlast . . . . . . available to mi iff wlast prefers mi to mnext Figure 1: Accessible and available women to mi if there is no mnext). Observe that matching mi with anyone lying above wf irst will cross the edge (mprev, wf irst), and matching mi with anyone lying below wlast will cross the edge (mnext, wlast). Therefore, the range of all women accessible to mi ranges exactly from wf irst to wlast, hence the range of all women available to mi ranges from either wf irst or wf irst+1 (depending on whether wf irst prefers mi to mprev) to either wlast or wlast−1 (depending on whether wlast prefers mi to mnext). See Fig. 1. Then in the available range, mi selects the woman wj that he prefers most. Case 1: wj does not exist or mi is currently matched with wj. That means mi is currently stable, so we can skip him. We remove mi from S and proceed to scan mi+1 in the next step (called a downward jump). Case 2: wj exists and mi is not currently matched with wj That means mi is indeed the topmost unstable man we want, so we perform the oper- ations on him by letting mi propose to wj and dump his current partner (if any). Case 2.1: mprev exists and wj = wf irst. That means wf irst dumps mprev to get matched with mi, which leaves mprev unmatched and he may possibly become unstable. Furthermore, mprev+1, mprev+2, ..., mi−1 as well as mi himself may also possibly become unstable since they now gain access to women lying above wf irst previously inaccessible to them (if wf irst 6= w1). On the other hand, m1, m2, ..., mprev−1 clearly remain stable, hence we add mprev, mprev+1, ..., mi−1 to S and proceed to scan mprev in the next step (called an upward jump). Case 2.2: mprev does not exist or wj 6= wf irst. Case 2.2.1: mi is currently matched and wj lies geometrically below M (mi). Then, mprev, mprev+1, ..., mi−1 (or m1, m2, ...mi−1 if mprev does not exist) may possibly becomes unstable since they now gain access to women between M (mi) and wj previously inaccessible to them. Therefore, we perform the upward jump to mprev (or to m1 if mprev 6 does not exist), adding mprev, mprev+1, ..., mi−1 (or m1, m2, ...mi−1) to S and proceed to scan mprev (or m1) in the next step, except when mi = m1 that we perform the downward jump to m2. It turns out that this case is impossible, which we will prove in the next subsection. Case 2.2.2: mi is currently unmatched or wj lies geometrically above M (mi). Then all men lying above mi clearly remain stable (because the sets of available women to m1, ..., mi−1 either remain the same or become smaller). Also, mi now becomes stable as well (because mi selects a woman he prefers most in the available range), except in the case where wj = wlast (because the edge (mnext, wlast) is removed and mi now has access to women lying below wlast previously inaccessible to him). Therefore, we perform the downward jump, removing mi from S and moving to scan mi+1 in the next step, except when wj = wlast that we have to scan mi again in the next step (this exception, however, turns out to be impossible, which we will prove in the next subsection). We scan the men in this way until S becomes empty (see Example 1). By the way we add all men that may possibly become unstable after each step back to S, at any step S is guaranteed to contain the topmost unstable man. Example 1. Consider an instance of three men and three women with the following pref- erence lists. m1 : w3, w1, w2 m2 : w2, w3, w1 m3 : w2, w1, w3 w1 : m3, m2, m1 w2 : m3, m2, m1 w3 : m3, m2, m1 Our algorithm will scan the men in the following order and output a matching M = {(m2, w1), (m3, w2)}, which is a WSNM. Step Process 0 1 2 3 4 5 6 7 8 9 scan m1, add (m1, w3) scan m2, add (m2, w3), remove (m1, w3) scan m1, add (m1, w1) scan m2, add (m2, w2), remove (m2, w3) scan m3, add (m3, w2), remove (m2, w2) scan m2, add (m2, w1), remove (m1, w1) scan m1 scan m2 scan m3 M at the end S at the end of step of step Ø {(m1, w3)} {(m2, w3)} {(m1, w1), (m2, w3)} {(m1, w1), (m2, w2)} {(m1, w1), (m3, w2)} {(m2, w1), (m3, w2)} {(m2, w1), (m3, w2)} {(m2, w1), (m3, w2)} {(m2, w1), (m3, w2)} Ø {m1, m2, m3} {m2, m3} {m1, m2, m3} {m2, m3} {m3} {m2, m3} {m1, m2, m3} {m2, m3} {m3} 3.4 Observations First, we will prove the following lemma about the algorithm described in the previous subsection. 7 Lemma 1. During the scan of a man mi, if mi is currently matched, then mi does not propose to any woman lying geometrically below M (mi). Proof. We call a situation when a man mi proposes to a woman lying geometrically below M (mi) a downward switch. Assume, for the sake of contradiction, that a downward switch occurs at least once during the whole algorithm. Suppose that the first downward switch occurs at step s, when a man mi is matched to wk = M (mi) and proposes to wj with j > k. We have mi prefers wj to wk. Consider the step t < s when mi proposed to wk (if mi proposed to wk multiple times, consider the most recent one). At step t, wj must be inaccessible or unavailable to mi (otherwise he would choose wj instead of wk), meaning that there must be an edge (mp, wq) with p > i and k < q < j obstructing them in the inaccessible case, or an edge (mp, wq) with p > i, q = j, and wj preferring mp to mi in the unavailable case. We define a dynamic edge e as follows. First, at step t we set e = (mp, wq). Then, throughout the process we update e by the following method: whenever the endpoints of e cease to be partners of each other, we update e to be the edge joining the endpoint that dumps his/her partner with his/her new partner. Formally, suppose that e is currently (mx, wy). If mx dumps wy to get matched with wy′, we update e to be (mx, wy′); if wy dumps mx to get matched with mx′, we update e to be (mx′, wy). By this updating method, the edge e will always exist after step t, but may change over time. Observe that from step t to step s, we always have x > i because of the existence of (mi, wk). Moreover, before step s, if mx dumps wy to get matched with wy′, by the assumption that a downward switch did not occur before step s, we have y′ < y, which means the index of the women's side of e's endpoints never increases. Consider the edge e = (mx, wy) at step s, we must have x > i and y ≤ q ≤ j. If y < j, then the edge e obstructs mi and wj, making wj inaccessible to mi. If y = j, that means wj never got dumped since step t, so she got only increasingly better partners, thus wj prefers mx to mi, making wj unavailable to mi. Therefore, in both cases mi could not propose to wj, a contradiction. Hence, a downward switch cannot occur in our algorithm. Lemma 1 shows that a woman cannot get her partner stolen by any woman that lies below her, which is equivalent to the following corollary. Corollary 1. If a man mi dumps a woman wj to propose to a woman wk, then k < j. It also implies that Case 2.2.1 in the previous subsection never occurs. Therefore, the only case where an upward jump occurs is Case 2.1 (mprev exists and mi proposes to wf irst). We will now prove the following lemma. Lemma 2. During the scan of a man mi, if mnext exists, then mi does not propose to wlast. Proof. Assume, for the sake of contradiction, that mi proposes to wlast. Since mnext exists, this proposal obviously cannot occur in the very first step of the algorithm. Consider a man mk we scanned in the previous step right before scanning mi. Case 1: mk lies below mi, i.e. k > i. In order for the upward jump from mk to mi to occur, mi must have been matched with a woman but got her stolen by mk in the previous step. However, mi+1, mi+2, ..., mnext−1 are all currently unmatched (by the definition of mnext), so the only possibility is that 8 mk = mnext, and thus his partner that got stolen was wlast. Therefore, we can conclude that wlast prefers mnext to mi, which means wlast is currently unavailable to mi, a contradiction. Case 2: mk lies above mi, i.e. k < i. The jump before the current step was a downward jump, but since mnext has been scanned before, an upward jump over mi must have occurred at some point before the current step. Consider the most recent upward jump over mi before the current step. Suppose than it occurred at the end of step t and was a jump from mk′ to mj, with k′ > i and j < i. In order for this jump to occur, mj must have been matched with a woman but got her stolen by mk′ at step t. However, mi+1, mi+2, ..., mnext−1 are all currently unmatched (by the definition of mnext), so the only possibility is that mk′ = mnext, and thus mj's partner that got stolen was wlast. We also have mj+1, mj+2, ..., mnext−1 were all unmatched during step t (otherwise wlast would be inaccessible to mk′ ), and wlast prefers mnext to mj. Now, consider the most recent step before step t in which we scanned mi. Suppose it occurred at step s. During step s, mj was matched with wlast and wlast was accessible to mi. However, mi was still left unmatched after step s (otherwise an upward jump over mi at step t could not occur), meaning that wlast must be unavailable to him back then due to wlast preferring mj to mi. Therefore, we can conclude that wlast prefers mnext to mi, thus wlast is currently unavailable to mi, a contradiction. Lemma 2 shows that a man cannot get his partner stolen by any man lying above him, or equivalent to the following corollary. Corollary 2. If a woman wj dumps a man mi to accept a man mk, then k > i. 3.5 Proof of Finiteness Now, we will show that the position of each woman's partner can only move downward throughout the process, which guarantees the finiteness of the number of steps in the entire process. Lemma 3. After a woman wj ceases to be a partner of a man mi, she cannot be matched with any man mi′ with i′ ≤ i afterwards. Proof. Suppose that wj's next partner (if any) is ma. It is sufficient to prove that a > i. First, consider the situation when mi and wj cease to be partners. Case 1: wj dumps mi. This means wj dumps mi to get matched with ma right away. By Corollary 2, we have a > i as required. Case 2: mi dumps wj. Suppose that mi dumps wj to get matched with wk. By Corollary 1, we have k < j. Case 2.1: mi never gets dumped afterwards. That means mi will only get increasingly better partner, and the position of his partner can only move upwards (by Corollary 1), which means wj cannot be matched with mi again, or any man lying above mi afterwards due to having an edge (mi, M (mi)) obstructing. Therefore, ma must lie below mi, i.e. a > i. Case 2.2: mi gets dumped afterwards. 9 Suppose that mi first gets dumped by wy at step s. By Corollary 1, we have y ≤ k < j (because mi only gets increasingly better partners before getting dumped). Also suppose that wy dumps mi in order to get matched with mx. By Corollary 2, we have x > i. Similarly to the proof of Lemma 1, consider a dynamic e first set to be (mx, wy) at step s. We have the index of the men's side of e's endpoints never decreases, and that of the women's side never increases. Therefore, since step s, there always exists an edge (mx, wy) with x > i and y < j, obstructing wj's access to mi and all men lying above him. Therefore, ma must lie below mi, i.e. a > i. 3.6 Runtime Analysis Consider any upward jump from mi to mk with i > k that occurs right after mi stole wj from mk. We call such a jump associated to wj, and it has size i − k. For any woman wj, let Uj be the sum of the sizes of all upward jumps associated to wj. From Lemma 3, we know that the position of wj's partner can only move upward throughout the process, so we have Uj ≤ n − 1. Therefore, the sum of the sizes of all upwards jumps is Pn j=1 Uj ≤ n(n − 1) = O(n2). Since the scan starts at m1 and ends at mn, the total number of downward jumps equals to the sum of the sizes of all upward jumps plus n − 1, hence the total number of steps in the whole algorithm is O(n2). For each mi, we keep an array of size n, with the jth entry storing the rank of wj in Pmi. Each time we scan mi, we query the minimum rank of available women, which is a consecutive range in the array. Using an appropriate range minimum query (RMQ) data structure such as the one introduced by Fischer [1], we can perform the scan with O(n) preprocessing time per array and O(1) query time. Therefore, the total runtime of our algorithm is O(n2). In conclusion, we proved that our developed algorithm is correct and can be imple- mented in O(n2) time, which also implicitly proves the existence of a WSNM in any in- stance. Theorem 1. A weakly stable noncrossing matching exists in any instance with n men and n women with strict preference lists. Theorem 2. There is an O(n2) algorithm to find a weakly stable noncrossing matching in an instance with n men and n women with strict preference lists. Remark. Our algorithm does not require the numbers of men and women to be equal. In the case that there are n1 men and n2 women, the algorithm works similarly with O(n1n2) runtime. Also, in the case that people's preference lists are not strict, we can modify the instance by breaking ties in an arbitrary way. Clearly, a WSNM in the modified instance will also be a WSNM in the original one (because every noncrossing blocking pair in the original instance will also be a noncrossing blocking pair in the modified instance). 4 Discussion In this paper, we constructively prove that a WSNM always exists in any instance by developing an O(n2) algorithm to find one. Note that the definition of a WSNM al- lows multiple answers with different sizes for an instance. For example, in an instance 10 of three men and three women, with Pm1 = (w3, w1, w2), Pm2 = (w1, w2, w3), Pm3 = (w2, w3, w1), Pw1 = (m2, m3, m1), Pw2 = (m3, m1, m2), and Pw3 = (m1, m2, m3), both {(m1, w3)} and {(m2, w1), (m3, w2)} are WSNMs, but our algorithm only outputs the first one with smaller size. A possible future work is to develop an algorithm to find a WSNM with maximum size in a given instance, which seems to be a naturally better answer then other WSNMs as it satisfies more people. Another possible future work is to develop an algorithm to determine whether an SSNM exists in a given instance, and to find one if it does. Other interesting problems include investigate the noncrossing matching in the geo- metric version of the stable roommates problem where people can be matched regardless of gender. The most basic and natural setting of this problem is where people are repre- sented by points arranged on a circle. A possible future work is to develop an algorithm to determine whether a WSNM or an SSNM exists in a given instance, and to find one if it does. References [1] J. Fischer. Optimal Succinctness for Range Minimum Queries. In Proceedings of the 9th Latin American Symposium on Theoretical Informatics (LATIN), pages 158-169 (2010). [2] M.L. Fredman. On computing the length of longest increasing subsequences. Discrete Applied Mathematics, 11(1):29-35 (1975). [3] D. Gale and L.S. Shapley. College admissions and the stability of marriage. American Mathematical Monthly, 69:9-15 (1962). [4] D. Gale and M. Sotomayor. Some remarks on the stable matching problem. Discrete Applied Mathematics, 11(3):223-232 (1985). [5] D. Gusfield and R.W. Irving. The Stable Marriage Problem: Structure and Algorithms. MIT Press (1989). [6] R.W. Irving. An efficient algorithm for the "stable roommates" problem. Journal of Algorithms, 6:577-595 (1985). [7] R.W. Irving. Stable marriage and indifference. Discrete Applied Mathematics, 48(3):261-272 (1994). [8] Y. Kajitami and T. Takahashi. The noncross matching and applications to the 3-side switch box routing in VLSI layout design. In Proceedings of the IEEE International Symposium on Circuits and Systems, pages 776-779 (1986). [9] F. Malucelli, T. Ottmann, and D. Pretolani. Efficient labelling algorithms for the maximum noncrossing matching problem. Discrete Applied Mathematics, 47(2):175- 179 (1993). [10] A.E. Roth and M.A.O. Sotomayor. Two-sided matching: a study in game-theoretic modeling and analysis. Volume 18 of Econometric Society Monographs. Cambridge University Press (1990). 11 [11] P. Widmayer and C.K. Wong. An optimal algorithm for the maximum alignment of terminals. Information Processing Letters. 10:75-82 (1985). 12
1908.08911
1
1908
2019-08-23T17:36:13
Parameterized Algorithms for Book Embedding Problems
[ "cs.DS" ]
A k-page book embedding of a graph G draws the vertices of G on a line and the edges on k half-planes (called pages) bounded by this line, such that no two edges on the same page cross. We study the problem of determining whether G admits a k-page book embedding both when the linear order of the vertices is fixed, called Fixed-Order Book Thickness, or not fixed, called Book Thickness. Both problems are known to be NP-complete in general. We show that Fixed-Order Book Thickness and Book Thickness are fixed-parameter tractable parameterized by the vertex cover number of the graph and that Fixed-Order Book Thickness is fixed-parameter tractable parameterized by the pathwidth of the vertex order.
cs.DS
cs
Parameterized Algorithms for Book Embedding Problems(cid:63) Sujoy Bhore1, Robert Ganian1, Fabrizio Montecchiani2, and Martin Nollenburg1 1 Algorithms and Complexity Group, TU Wien, Vienna, Austria {sujoy,rganian,noellenburg}@ac.tuwien.ac.at 2 Engineering Department, University of Perugia, Perugia, Italy [email protected] Abstract. A k-page book embedding of a graph G draws the vertices of G on a line and the edges on k half-planes (called pages) bounded by this line, such that no two edges on the same page cross. We study the problem of determining whether G admits a k-page book embedding both when the linear order of the vertices is fixed, called Fixed-Order Book Thickness, or not fixed, called Book Thickness. Both problems are known to be NP-complete in general. We show that Fixed-Order Book Thickness and Book Thickness are fixed-parameter tractable parameterized by the vertex cover number of the graph and that Fixed- Order Book Thickness is fixed-parameter tractable parameterized by the pathwidth of the vertex order. 1 Introduction A k-page book embedding of a graph G is a drawing that maps the vertices of G to distinct points on a line, called spine, and each edge to a simple curve drawn inside one of k half-planes bounded by the spine, called pages, such that no two edges on the same page cross [20,25]; see Fig. 1 for an illustration. This kind of layout can be alternatively defined in combinatorial terms as follows. A k-page book embedding of G is a linear order ≺ of its vertices and a coloring of its edges which guarantee that no two edges uv, wx of the same color have their vertices ordered as u ≺ w ≺ v ≺ x. The minimum k such that G admits a k-page book embedding is the book thickness of G, denoted by bt(G), also known as the stack number of G. Book embeddings have been extensively studied in the literature, among others due to their applications in bioinformatics, VLSI, and parallel computing (see, e.g., [7,19] and refer also to [11] for a survey). A famous result by Yannakakis [29] states that every planar graph has book thickness at (cid:63) Research of Fabrizio Montecchiani supported in part by MIUR under Grant 20174LF3T8 AHeAD: efficient Algorithms for HArnessing networked Data. Robert Ganian acknowledges support by the FWF (Project P31336, "NFPC") and is also affiliated with FI MUNI, Brno, Czech Republic. Research of Sujoy Bhore and Martin Nollenburg is supported by the Austrian Science Fund (FWF) grant P 31119. 9 1 0 2 g u A 3 2 ] S D . s c [ 1 v 1 1 9 8 0 . 8 0 9 1 : v i X r a (a) (b) (c) Fig. 1. (a) A planar graph G with book thickness two. (b) A 2-page book embedding of G. (c) A linear order of G such that its fixed-order book thickness is three (and the corresponding 3-page book embedding). most four. Several other bounds are known for special graph families, for instance planar graphs with vertex degree at most four have book thickness two [3], while graphs of treewidth w > 2 have book thickness w + 1 [12,17]. Given a graph G and a positive integer k, the problem of determining whether bt(G) ≤ k, called Book Thickness, is known to be NP-complete. Namely, Bern- hart and Kainen [4] proved that bt(G) ≤ 2 if and only if G is subhamiltonian, i.e., G is a subgraph of a planar Hamiltonian graph. Since deciding whether a graph is subhamiltonian is an NP-complete problem, Book Thickness is also NP-complete in general [7]. Book Thickness has been studied also when the linear order ≺ of the vertices is fixed, indeed, this is one of the original formulations of the problem, which arises in the context of sorting with parallel stacks [7]. We call this problem Fixed-Order Book Thickness and we denote by fo-bt(G,≺) the fixed-order book thickness of a graph G. Obviously, we have fo-bt(G,≺) ≥ bt(G), see Fig. 1. Deciding whether fo-bt(G,≺) ≤ 2 corresponds to testing the bipartiteness of a suitable conflict graph, and thus it can be solved in linear time. On the other hand, deciding if fo-bt(G,≺) ≤ 4 is equivalent to finding a 4-coloring of a circle graph and hence is an NP-complete problem [28]. Our Results. In this paper we study the parameterized complexity of Book Thickness and Fixed-Order Book Thickness. For both problems, when the answer is positive, we naturally also expect to be able to compute a correspond- ing k-page book embedding as a witness. While both problems are NP-complete already for small fixed values of k on general graphs, it is natural to ask which structural properties of the input (formalized in terms of structural parame- ters) allow us to solve these problems efficiently. Indeed, already Dujmovic and Wood [13] asked whether Book Thickness can be solved in polynomial time when the input graph has bounded treewidth [27] -- a question which has turned out to be surprisingly resilient to existing algorithmic techniques and remains open to this day. Bannister and Eppstein [2] made partial progress towards an- swering Dujmovic and Wood's question by showing that Book Thickness is fixed-parameter tractable parameterized by the treewidth of G when k = 2. We provide the first fixed-parameter algorithms for Fixed-Order Book Thickness and also the first such algorithm for Book Thickness that can be used when k > 2. In particular, we provide fixed-parameter algorithms for: 2 125341234513425 1. Fixed-Order Book Thickness parameterized by the vertex cover number of the graph; 2. Fixed-Order Book Thickness parameterized by the pathwidth of the graph and the vertex order; and 3. Book Thickness parameterized by the vertex cover number of the graph. Results 1 and 2 are obtained by combining dynamic programming techniques with insights about the structure of an optimal book embedding. Result 3 then applies a kernelization technique to obtain an equivalent instance of bounded size (which can then be solved, e.g., by brute force). All three of our algorithms can also output a corresponding k-page book embedding as a witness (if it exists). The remainder of this paper is organized as follows. Section 2 contains prelim- inaries and basic definitions. Results 1 and 2 on Fixed-Order Book Thick- ness are presented in Section 3, while Result 3 on Book Thickness is described in Section 4. Conclusions and open problems are found in Section 5. Statements with a proof in the appendix are marked by an asterisk (*). 2 Preliminaries We use standard terminology from graph theory [9]. For r ∈ N, we write [r] as shorthand for the set {1, . . . , r}. Parameterized complexity [8,10] focuses on the study of problem complexity not only with respect to the input size n but also a parameter k ∈ N. The most desirable complexity class in this setting is FPT (fixed-parameter tractable), which contains all problems that can be solved by an algorithm running in time f (k) · nO(1), where f is a computable function. Algorithms running in this time are called fixed-parameter algorithms. A k-page book embedding of a graph G = (V, E) will be denoted by a pair (cid:104)≺, σ(cid:105), where ≺ is a linear order of V , and σ : E → [k] is a function that maps each edge of E to one of k pages [k] = {1, 2, . . . , k}. In a k-page book embedding (cid:104)≺, σ(cid:105) it is required that for no pair of edges uv, wx ∈ E with σ(uv) = σ(wx) the vertices are ordered as u ≺ w ≺ v ≺ x, i.e., each page is crossing-free. We consider two graph parameters for our algorithms. A vertex cover C of a graph G = (V, E) is a subset C ⊆ V such that each edge in E has at least one end-vertex in C. The vertex cover number of G, denoted by τ (G), is the size of a minimum vertex cover of G. The second parameter is pathwidth, a classical graph parameter [26] which admits several equivalent definitions. The definition that will be most useful here is the one tied to linear orders [21]; see also [22,23] for recent works using this formulation. Given an n-vertex graph G = (V, E) with a linear order ≺ of V such that v1 ≺ v2 ≺ ··· ≺ vn, the pathwidth of (G,≺) is the minimum number κ such that for each vertex vi (i ∈ [n]), there are at most κ vertices left of vi that are adjacent to vi or a vertex right of vi. Formally, for each vi we call the set Pi = {vj j < i,∃q ≥ i such that vjvq ∈ E} the guard set for vi, and the pathwidth of (G,≺) is simply maxi∈[n] Pi. The elements of the guard sets are called the guards (for vi). We remark that the pathwidth of G is equal to the minimum pathwidth over all linear orders ≺. 3 3 Algorithms for Fixed-Order Book Thickness Recall that in Fixed-Order Book Thickness the input consists of a graph G = (V, E), a linear order ≺ of V , and a positive integer k. We assume that V = {v1, v2, . . . , vn} is indexed such that i < j ⇔ vi ≺ vj. The task is to decide if there is a page assignment σ : E → [k] such that (cid:104)≺, σ(cid:105) is a k-page book embedding of G, i.e., whether fo-bt(G,≺) ≤ k. If the answer is 'YES' we shall return a corresponding k-page book embedding as a witness. In fact, our algorithms will return a book embedding with the minimum number of pages. 3.1 Parameterization by the Vertex Cover Number As our first result, we will show that Fixed-Order Book Thickness is fixed- parameter tractable when parameterized by the vertex cover number. We note that the vertex cover number is a graph parameter which, while restricting the structure of the graph in a fairly strong way, has been used to obtain fixed- parameter algorithms for numerous difficult problems [1,14,15]. Let C be a minimum vertex cover of size τ = τ (G); we remark that such a vertex cover C can be computed in time O(2τ +τ·n) [6]. Moreover, let U = V \C. Our first observation shows that the problem becomes trivial if τ ≤ k. Observation 1 Every n-vertex graph G with a vertex cover C of size k admits a k-page book embedding with any vertex order ≺. Moreover, if G and C are given as input, such a book embedding can be computed in O(n + k · n) time. Proof. Let C = {c1, . . . , ck} be a vertex cover of size k and let σ be a page assignment on k pages defined as follows. For each i ∈ [k] all edges uci with u ∈ U ∪ {c1, . . . , ci−1} are assigned to page i. Now, consider the edges assigned to any page i ∈ [k]. By construction, they are all incident to vertex ci, and thus no two of them cross each other. Therefore, the pair (cid:104)≺, σ(cid:105) is a k-page book embedding of G and can be computed in O(n + k · n) time. (cid:117)(cid:116) We note that the bound given in Observation 1 is tight, since it is known that complete bipartite graphs with bipartitions of size k and h > k(k − 1) have book thickness k [4] and vertex cover number k. We now proceed to a description of our algorithm. For ease of presentation, we will add to G an additional vertex of degree 0, add it to U , and place it at the end of ≺ (observe that this does not change the solution to the instance). If τ ≤ k then we are done by Observation 1. Otherwise, let S be the set of all possible non-crossing page assignments of the edges whose both endpoints lie in C, and note that S < τ τ 2 ) (recall that k < τ by assumption). As its first step, the algorithm branches over each choice of s ∈ S, where no pair of edges assigned to the same page crosses. and S can be constructed in time O(τ τ 2 For each such non-crossing assignment s, the algorithm performs a dynamic programming procedure that runs on the vertices of the input graph in sequential (left-to-right) order. We will define a record set that the algorithm is going to 4 Fig. 2. A partial 2-page book embedding of a graph G with a vertex cover C of size 7. The visibilities of vertices in C (squares) from u2 are marked by dashed edges (left). Corresponding visibility matrix M2(2, α, s) (right). compute for each individual vertex in left-to-right order. Let c1 ≺ . . . ≺ cτ be the ordering of vertices of C, and let u1 ≺ . . . ≺ un−τ be the ordering of vertices of U . In order to formalize our records, we need the notion of visibility. Let i ∈ [n − τ ] and let Ei = {ujc ∈ E j < i, c ∈ C} be the set of all edges with one endpoint outside of C that lies to the left of ui. We call α : Ei → [k] a valid partial page assignment if α ∪ s maps edges to pages in a non-crossing fashion. Now, consider a valid partial page assignment α : Ei → [k]. We say that a vertex c ∈ C is (α, s)-visible to ut (for t ∈ [n − τ ]) on page p if it is possible to draw an edge from ut to c on page p without crossing any other edge mapped to page p by α ∪ s. Fig. 2 shows the visibilities of a vertex in two pages. Based on this notion of visibility, for an index a ∈ [n − τ ] we can define a k × τ visibility matrix Mi(a, α, s), where an entry (p, b) of Mi(a, α, s) is 1 if cb is (α, s)-visible to ua on page p and 0 otherwise (see Fig. 2). Intuitively, this visibility matrix captures information about the reachability via crossing-free edges (i.e., visibility) to the vertices in C from ua on individual pages given a particular assignment α of edges in Ei. Note that for a given tuple (i, a, α, s), it is straightforward to compute Mi(a, α, s) in polynomial time. Observe that while the number of possible choices of valid partial page as- signments α : Ei → [k] (for some i ∈ [n − τ ]) is not bounded by a function of τ , for each i, a ∈ [n− τ ] the number of possible visibility matrices is upper-bounded by 2τ 2 . On a high level, the core idea in the algorithm is to dynamically process the vertices in U in a left-to-right fashion and compute, for each such vertex, a bounded-size "snapshot" of its visibility matrices -- whereas for each such snap- shot we will store only one (arbitrarily chosen) valid partial page assignment. We will later (in Lemma 1) show that all valid partial page assignments leading to the same visibility matrices are "interchangeable". With this basic intuition, we can proceed to formally defining our records. Let X = {x ∈ [n − τ ] ∃c ∈ C : ux is the immediate successor of c in ≺} be the set of indices of vertices in U which occur immediately after a cover vertex; we will denote the integers in X as x1, . . . , xz (in ascending or- der), and we note that z ≤ τ . For a vertex ui ∈ U , we define our record set ∃ valid partial page assignment α : Ei → [k]}. Note that each entry in Ri(s) captures one possible set (a "snapshot") of at most τ + 1 visibility matrices: as follows: Ri(s) = {(cid:0)Mi(i, α, s), Mi(x1, α, s), Mi(x2, α, s), . . . , Mi(xz, α, s)(cid:1) 5 c2c3c4c5c6c7u1c1u2u3M2(2,α,s)=(cid:18)11000111111000(cid:19)... the visibility matrix for ui itself, and the visibility matrices for the z non- cover vertices which follow immediately after the vertices in C. The intuition behind these latter visibility matrices is that they allow us to update our vis- ibility matrix when our left-to-right dynamic programming algorithm reaches a vertex in C (in particular, as we will see later, for i ∈ X it is not possi- ble to update the visibility matrix Mi(i, α, s) only based on Mi−1(i − 1, α, s)). Along with Ri(s), we also store a mapping Λs i from Ri(s) to valid partial page assignments of Ei which maps (M0, . . . , Mz) ∈ Ri(s) to some α such that (M0, . . . , Mz) = (Mi(i, α, s), Mi(x1, α, s), Mi(x2, α, s), . . . , Mi(xz, α, s)). Let us make some observations about our records Ri(s). First, Ri(s) ≤ . Second, if Rn−τ (s) (cid:54)= ∅ for some s, since un−τ is a dummy vertex of 2τ 3+τ 2 degree 0, then there is a valid partial page assignment α : En−τ → [k] such that s ∪ α is a non-crossing page assignment of all edges in G. Hence we can output n−τ on any entry in Rn−τ (s). Third: a k-page book embedding by invoking Λs Observation 2 (*) If for all s ∈ S it holds that Rn−τ (s) = ∅, then (G,≺, k) is a NO-instance of Fixed-Order Book Thickness. The above implies that in order to solve our instance, it suffices to compute Rn−τ (s) for each s ∈ S. As mentioned earlier, we do this dynamically, with the first step consisting of the computation of R1(s). Since E1 = ∅, the visibil- ity matrices M1(1,∅, s), M1(x1,∅, s), . . . , M1(xz,∅, s) required to populate R1(s) depend only on s and are easy to compute in polynomial time. Finally, we proceed to the dynamic step. Assume we have computed Ri−1(s). We branch over each possible page assignment β of the (at most τ ) edges incident to ui−1, and each tuple ρ ∈ Ri−1(s). For each such β and γ = Λs i−1(ρ), we check whether β ∪ γ is a valid partial page assignment (i.e., whether β ∪ γ ∪ s is non-crossing); if this is not the case, we discard this pair of (β, ρ). Otherwise we compute the visibility matrices Mi(i, β∪γ, s), Mi(x1, β∪γ, s), . . . , Mi(xz, β∪γ, s), add the corresponding tuple into Ri(s), and set Λs i to map this tuple to β ∪ γ. We remark that here the use of Λs i−1(ρ) allows us not to distinguish between i ∈ X and i (cid:54)∈ X -- in both cases, the partial page assignment γ will correctly capture the visibility matrix for ui. Lemma 1. The above procedure correctly computes Ri(s) from Ri−1(s). Proof. Consider an entry (M0, . . . , Mz) computed by the above procedure from some β ∪ γ. Since we explicitly checked that β ∪ γ is a valid partial page assign- ment, this implies that (M0, . . . , Mz) ∈ Ri(s), as desired. For the opposite direction, consider a tuple (M0, . . . , Mz) ∈ Ri(s). By defi- nition, there exists some valid partial page assignment α of Ei such that M0 = Mi(i, α, s), M1 = Mi(x1, α, s), . . . , Mz = Mi(xz, α, s). Now let β be the restric- tion of α to the edges incident to ui−1, and let γ(cid:48) be the restriction of α to all other edges (i.e., all those not incident to ui−1). Since γ(cid:48) ∪ s is non-crossing and in particular γ(cid:48) is a valid partial page assignment for Ei−1, Ri−1(s) must contain an entry ω = (Mi−1(i − 1, γ(cid:48), s), . . . , (Mi−1(xz, γ(cid:48), s)) -- let γ = Λs i−1(ω). 6 To conclude the proof, it suffices to show that (1) β ∪ γ is a valid par- tial page assignment, and (2) (Mi(i, β ∪ γ(cid:48), s), . . . , Mi(xz, β ∪ γ(cid:48), s)), which is the original tuple corresponding to the hypothetical α, is equal to (Mi(i, β ∪ γ, s), . . . , Mi(xz, β ∪ γ, s)), which is the entry our algorithm computes from β and γ. Point (1) follows from the fact that Mi−1(i − 1, γ(cid:48), s) = Mi−1(i − 1, γ, s) in conjunction with the fact that ui−1 is adjacent only to vertices in C. Point (2) then follows by the same argument, but applied to each visibility matrix in the respective tuples: for each x ∈ X we have Mi−1(x, γ(cid:48), s) = Mi−1(x, γ, s) -- meaning that the visibilities of ux were identical before considering the edges incident to ui−1 -- and so assigning these edges to pages as prescribed by β leads (cid:117)(cid:116) to an identical outcome in terms of visibility. This proves the correctness of our algorithm. The runtime is upper-bounded by the product of S < τ τ 2 (the initial branching factor), n (the number of times we compute a new record set Ri(s)), and 2τ 3+τ 2·τ τ (to consider all combinations of γ and β so to compute a new record set from the previous one). A minimum- page book embedding can be computed by trying all possible choices for k ∈ [τ ]. We summarize Result 1 below. Theorem 1. There is an algorithm which takes as input an n-vertex graph G with a vertex order ≺, runs in time 2O(τ 3) · n where τ is the vertex cover number of G, and computes a page assignment σ such that (≺, σ) is a (fo-bt(G,≺))-page book embedding of G. 3.2 Parameterization by the Pathwidth of the Vertex Ordering As our second result, we show that Fixed-Order Book Thickness is fixed- parameter tractable parameterized by the pathwidth of (G,≺). We note that while the pathwidth of G is always upper-bounded by the vertex cover number, this does not hold when we consider a fixed ordering ≺, and hence this result is incomparable to Theorem 1. For instance, if G is a path, it has arbitrarily large vertex cover number while (G,≺) may have a pathwidth of 1, while on the other hand if G is a star, it has a vertex cover number of 1 while (G,≺) may have arbitrarily large pathwidth. To begin, we can show that the pathwidth of (G,≺) provides an upper bound on the number of pages required for an embedding. Lemma 2 (*). Every n-vertex graph G = (V, E) with a linear order ≺ of V such that (G,≺) has pathwidth k admits a k-page book embedding (cid:104)≺, σ(cid:105), which can be computed in O(n + k · n) time. We note that the bound given in Lemma 2 is also tight for the same reason as for Observation 1: complete bipartite graphs with bipartitions of size k and h > k(k−1) have book thickness k [4], but admit an ordering ≺ with pathwidth k. We now proceed to a description of our algorithm. Our input consists of the graph G, the vertex ordering ≺, and an integer k that upper-bounds the desired number of pages in a book embedding. Let κ be our parameter, i.e., the pathwidth of (G,≺); observe that due to Lemma 2, we may assume that k ≤ 7 Fig. 3. An assignment of the edges of Si to a page p, where the edge vcvd is the (α, i, p)- important edge of va. Any vertex w with vc ≺ w ≺ va is visible to va, and any vertex w(cid:48) ≺ vc is not visible to va. κ. The algorithm performs a dynamic programming procedure on the vertices v1, v2, . . . , vn of the input graph G in right-to-left order along ≺. For technical reasons, we initially add a vertex v0 of degree 0 to G and place it to the left of v1 in ≺; note that this does not increase the pathwidth of G. vi = {gi 1, . . . , gi m} where for each j ∈ [m − 1], gi We now adapt the concept of visibility introduced in Section 3.1 for use in this algorithm. First, let us expand our notion of guard set (see Section 2) as follows: for a vertex vi, let P ∗ j is the j-th guard of vi in reverse order of ≺ (i.e., gi 1 is the guard that is nearest to vi in ≺), and gi m = v0. For a vertex vi, let Ei = {vavb vavb ∈ E, b > i} be the set of all edges with at least one endpoint to the right of vi and let Si = {gi jvb ∈ Ei} be the restriction of Ei to edges between . An assignment α : Ei → [k] is a vertex to the right of vi and a guard in P ∗ called a valid partial page assignment if α maps the edges in Ei to pages in a non-crossing manner. Given a valid partial page assignment α : Ei → [k] and a vertex va with a ≤ i, we say a vertex vx (x < a) is α-visible to va on a page p if it is possible to draw the edge vavx in page p without crossing any other edge mapped to p by α. jvb gi j ∈ P ∗ vi, gi vi Before we proceed to describing our algorithm, we will show that the visibil- ities of vertices w.r.t. valid partial page assignments exhibit a certain regularity property. Given a ≤ i ≤ n, p ∈ [k], and a valid partial page assignment α of Ei, let the (α, i, p)-important edge of va be the edge vcvd ∈ Si with the following properties: (1) α(vcvd) = p, (2) c < a, and (3) a− c is minimum among all such edges in Si. If multiple edges with these properties exist, we choose the edge with minimum d − c. Intuitively, the (α, i, p)-important edge of va is simply the shortest edge of Si which encloses va on page p; note that it may happen that va has no (α, i, p)-important edge. Observe that, if the edge exists, its left endpoint is vc ∈ P ∗ , and we call vc the (α, i, p)-important guard of va. The next observation easily follows from the definition of (α, i, p)-important edge, see also Fig. 3. vi Observation 3 If va has no (α, i, p)-important edge, then every vertex vx with x < a is α-visible to va. If the (α, i, p)-important guard of va is vc, then vx (x < a) is α-visible to va if and only if x ≥ c. Observation 3 not only provides us with a way of handling vertex visibilities in the pathwidth setting, but also allows us to store all the information we require about vertex visibilities in a more concise way than via the matrices 8 vavcvivd used in Section 3.1. For an index i ∈ [n], a vertex va where a ≤ i and a valid partial page assignment α, we define the visibility vector Ui(va, α) as follows: the p-th component of Ui(va, α) is the (α, i, p)-important guard of va, and (cid:5) if va has no (α, i, p)-important guard. Observe that since the number of pages is upper-bounded by κ by assumption and the cardinality of P ∗ is at most κ + 1, there are at most (κ + 2)κ possible distinct visibility vectors for any fixed i. vi Observe that thanks to Observation 3 the visibility vector Ui(vi, α) provides us with complete information about the visibility of vertices vb (b < i) from vi -- notably, vb is not α-visible to vi on page p if and only if vb lies to the left of the (α, i, p)-important guard Ui(vi, α)[p] (and, in particular, if Ui(vi, α)[p] = (cid:5) then every such vb is α-visible to vi on page p). On a high level, the algorithm will traverse vertices in right-to-left order along ≺ and store the set of all possible visibility vectors at each vertex. To this end, it will use the following observation to update its visibility vectors. vi Observation 4 Let α be a valid partial page assignment of Ei and p be a page. If vi−1 (cid:54)∈ P ∗ , then a vertex vb (b < i − 1) is α-visible to vi−1 on page p if and only if vb is α-visible to vi on page p. Proof. By definition vi−1 and vi are consecutive in ≺. Let vb (for b < i − 1) be a vertex that is α-visible to vi−1 on page p. If vb is not α-visible to vi on p, then there must be a vertex w between vi−1 and vi that is incident to an edge in Ei separating vi−1 and vi on page p. But this contradicts that vi−1 and vi are (cid:117)(cid:116) consecutive in ≺. The other direction follows by the same argument. There is, however, a caveat: Observation 4 does not (and in fact cannot) allow us to compute the new visibility vector if vi−1 ∈ P ∗ i . To circumvent this issue, our algorithm will not only store the visibility vector Ui(vi, α) but also the visibility vectors for each guard of vi. We now prove that we can compute the visibility vector for any vertex from the visibility vectors of the guards -- this is important when updating our records, since we will need to obtain the visibility records for new guards that are introduced at some step of the algorithm. Lemma 3. Let va ≺ vi, α be a valid partial page assignment of Ei, p ∈ [k] be a page, and assume va /∈ P ∗ i ∪ {vi} be such that b > a and b − a is minimized, i.e., vb is the first guard to the right of va. Then Ui(va, α) = Ui(vb, α). i . Let vb ∈ P ∗ Proof. Let vx for x < a be any vertex that is α-visible to va in page p and assume vx is not α-visible to vb. Then there must be an edge wz ∈ Ei separating va from vb in page p, i.e., va ≺ w ≺ vb. But in that case w is a guard in P ∗ i closer to va contradicting the choice of vb. Conversely, let vx for x < a be a vertex that is not α-visible to va in page p. Then there must be an edge wz ∈ Ei separating vx from va on page p. Then edge wz also separates vx from vb and vx is not α-visible to vb. Therefore, the visibility vectors Ui(va, α) and Ui(vb, α) (cid:117)(cid:116) corresponding to the vertices va and vb, respectively, are equal. We can now formally define our record set as Qi = {(Ui(vi, α), Ui(gi 1, α), . . . , m−1, α)) ∃ valid partial page assignment α : Ei → [k]}, where each indi- Ui(gi vidual element (record) in Qi can be seen as a queue starting with the visibility 9 1, α), . . . , Ui(gi m−1, α)). i , then ω(cid:48) = (ω2, . . . , ωm), and i , then ω(cid:48) = (ω1, . . . , ωm) (Recall Observation 4). vector for vi and then storing the visibility vectors for individual guards (note that there is no reason to store an "empty" visibility vector for gi m). To facilitate the construction of a solution, we will also store a function Λi from Qi to valid partial page assignments of Ei which maps each tuple ω ∈ Qi to some α such that ω = (Ui(vi, α), Ui(gi Let us make some observations about our records Qi. First of all, since there are at most (κ + 2)κ many visibility vectors, Qi ≤ (κ + 2)κ2 . Second, if Q0 > 0 then, since E0 = E, the mapping Λ0(ω) will produce a valid page assignment of E for any ω ∈ Q0. On the other hand, if G admits a k-page book embedding α with order ≺, then α witnesses the fact that Q0 cannot be empty. Hence, the algorithm can return one, once it correctly computes Q0 and Λ0. The computation is carried out dynamically and starts by setting Qn = {ω}, where ω = ((cid:5)), and Λn(ω) = ∅. For the inductive step, assume that we have correctly computed Qi and Λi, and the aim is to compute Qi−1 and Λi−1. For each ω = (ω1, . . . , ωm) ∈ Qi, we compute an intermediate record ω(cid:48) which represents the visibility vector of vi−1 w.r.t. α = Λi(ω) as follows: -- if vi−1 ∈ P ∗ -- if vi−1 (cid:54)∈ P ∗ We now need to update our intermediate record ω(cid:48) to take into account the ∈ new guards. In particular, we expand ω(cid:48) by adding, for each new guard gi−1 i−1 \ P ∗ i , an intermediate visibility vector Ui−1(gi−1 P ∗ , α) at the appropriate position in ω(cid:48) (i.e., mirroring the ordering of guards in P ∗ i−1). Recalling Lemma 3, we compute this new intermediate visibility vector Ui−1(gi−1 , α) by copying the visibility vector that immediately succeeds it in ω(cid:48). Next, let Fi−1 = Ei−1 \ Ei be the at most κ new edges that we need to account for, and let us branch over all assignments β : Fi−1 → [k]. For each such β, we check whether α∪β is a valid partial page assignment of Ei−1, i.e., whether the new edges in Fi−1 do not cross with each other or other edges in Ei when following the chosen assignment β and the assignment α obtained from Λi. As expected, we discard any β such that α ∪ β is not valid. Our final task is now to update the intermediate visibility vectors Ui−1(∗, α) (with ∗ being a placeholder) to Ui−1(∗, α∪ β). This can be done in a straightfor- ward way by, e.g., looping over each edge e ∈ Fi−1, obtaining the page p = β(e) that e is mapped to, reading Ui−1(∗, α)[p] and replacing that value by the guard g incident to e if g occurs to the right of Ui−1(∗, α)[p] and to the left of ∗. Finally, we enter the resulting record ω(cid:48) into Qi−1. j j j Lemma 4. The above procedure correctly computes Qi−1 from Qi. Proof. Consider an entry ω(cid:48) computed by the above procedure from some α ∪ β and ω. Since we explicitly checked that α ∪ β is a valid partial page assign- ment for Ei−1, there must exist a record (Ui−1(vi−1, α ∪ β), Ui−1(gi−1 , α ∪ m−1)) ∈ Qi−1, and by recalling Observation 3, Lemma 3 and Ob- β), . . . , Ui−1(gi−1 servation 4 it can be straightforwardly verified that this record is equal to ω(cid:48). 1 10 For the opposite direction, consider a tuple ω0 ∈ Qi−1 that arises from the valid partial page assignment γ of Ei−1, and let β, α be the restrictions of γ to Fi−1 and Ei, respectively. Since α is a valid partial page assignment of Ei, there must exist a tuple ω ∈ Qi that arises from α. Let α(cid:48) = Λi(ω). To conclude the proof, it suffices to note that during the branching stage the algorithm will compute a record from a combination of α(cid:48) (due to ω being in Qi) and β, and (cid:117)(cid:116) the record computed in this way will be precisely ω0. This proves the correctness of the algorithm. The runtime is upper bounded by O(n · (κ + 2)κ2 · κκ) (the product of the number of times we compute a new record, the number of records and the branching factor for β). A minimum-page book embedding can be obtained by trying all possible choices for k ∈ [κ]). We summarize Result 2 below. Theorem 2. There is an algorithm which takes as input an n-vertex graph G = (V, E) with a vertex ordering ≺ and computes a page assignment σ of E such that (≺, σ) is a (fo-bt(G,≺))-page book embedding of G. The algorithm runs in n · κO(κ2) time where κ is the pathwidth of (G,≺). 4 Algorithms for Book Thickness We now turn our attention to the general definition of book thickness (without a fixed vertex order). We show that, given a graph G, in polynomial time we can construct an equivalent instance G∗ whose size is upper-bounded by a function of τ (G). Such an algorithm is called a kernelization and directly implies the fixed-parameter tractability of the problem with this parameterization [8,10]. Theorem 3. There is an algorithm which takes as input an n-vertex graph G = (V, E) and a positive integer k, runs in time O(τ τ + 2τ · n) where τ = τ (G) is the vertex cover number of G, and decides whether bt(G) ≤ k. If the answer is positive, it can also output a k-page book embedding of G. O(τ ) Proof. If k > τ , by Observation 1 we can immediately conclude that G admits a k-page book embedding. Hence we shall assume that k ≤ τ . We will also compute a vertex cover C of size τ in time O(2τ · n) using well-known results [6]. For any subset U ⊆ C we say that a vertex of V \ C is of type U if its set of neighbors is equal to U . This defines an equivalence relation on V \ C and (cid:1) = 2τ distinct types. In what follows, we partitions V \ C into at most(cid:80)τ denote by VU the set of vertices of type U . We claim the following. Claim. Let v ∈ VU such that VU ≥ 2 · kτ + 2. Then G admits a k-page book embedding if and only if G(cid:48) = G\{v} does. Moreover, a k-page book embedding of G(cid:48) can be extended to such an embedding for G in linear time. (cid:0)τ i i=0 Proof (of the Claim). One direction is trivial, since removing a vertex from a book embedding preserves the property of being a book embedding of the resulting graph. So let (cid:104)≺, σ(cid:105) be a k-page book embedding of G(cid:48). We prove that 11 a k-page book embedding of G can be easily constructed by inserting v right next to a suitable vertex u in VU and by assigning the edges of v to the same pages as the corresponding edges of u. We say that two vertices u1, u2 ∈ VU are page equivalent, if for each vertex w ∈ U , the edges u1w and u2w are both assigned to the same page according to σ. Each vertex in VU has degree exactly U, hence this relation partitions the vertices of VU into at most kU ≤ kτ sets. Since VU \ {v} ≥ 2 · kτ + 1, at least three vertices of this set, which we denote by u1, u2, and u3, are page equivalent. Consider now the graph induced by the edges of these three vertices that are assigned to a particular page. By the above argument, such a graph is a Kh,3, for some h > 0. However, since already K2,3 does not admit a 1-page book embedding, we have h ≤ 1, that is, each ui has at most one edge on each page. Then we can extend ≺ by introducing v right next to u1 and assign each edge vw to the same page as u1w. Since each such edge vw runs arbitrarily close to the corresponding crossing-free edge u1w, this results in (cid:117)(cid:116) a k-page book embedding of G and concludes the proof of the claim. We now construct a kernel G∗ from G of size O(kτ ) as follows. We first classify each vertex of G based on its type. We then remove an arbitrary subset of vertices from each set VU with VU > 2 · kτ + 1 until VU = 2 · kτ + 1. Thus, constructing G∗ can be done in O(2τ + τ · n) time, where 2τ is the number of types and τ · n is the maximum number of edges of G. From our claim above we can conclude that G∗ admits a k-page book embedding if and only if G does. Determining the book thickness of G∗ can be done by guessing all possible linear orders and and page assignments in O(kτ !·kkτ ) time. A k-page book embedding of G∗ (if any) can be extended to one of G by iteratively applying the constructive procedure from the proof of the above claim, in O(τ · n) time. (cid:117)(cid:116) The next corollary easily follows from Theorem 3, by applying a binary search on the number of pages k ≤ τ and by observing that a vertex cover of minimum size τ can be computed in 2O(τ ) + τ · n time [6]. Corollary 1. Let G be a graph with n vertices and vertex cover number τ . A book embedding of G with minimum number of pages can be computed in O(τ τ + τ log τ · n) time. ) = O(τ τ O(τ ) O(τ ) 5 Conclusions and Open Problems We investigated the parameterized complexity of Book Thickness and Fixed- Order Book Thickness. We proved that both problems can be parameterized by the vertex cover number of the graph, and that the second problem can be parameterized by the pathwidth of the fixed linear order. The algorithm for Book Thickness is the first fixed-parameter algorithm that works for general values of k, while, to the best of our knowledge, no such algorithms were known for Fixed-Order Book Thickness. We believe that our techniques can be extended to the setting in which we allow edges on the same page to cross, with a given budget of at most c crossings 12 over all pages. This problem has been studied by Bannister and Eppstein [2] with the number of pages k restricted to be either 1 or 2. It would also be interesting to investigate the setting where an upper bound on the maximum number of crossings per edge is given as part of the input, which is studied in [5]. The main question that remains open is whether Book Thickness (and Fixed-Order Book Thickness) can be solved in polynomial time (and even fixed-parameter time) for graphs of bounded treewidth, which was asked by Dujmovi´c and Wood [13]. As an intermediate step towards solving this problem, we ask whether the two problems can be solved efficiently when parameterized by the treedepth [24] of the graph. Treedepth restricts the graph structure in a stronger way than treewidth, and has been used to obtain algorithms for several problems which have proven resistant to parameterization by treewidth [16,18]. References 1. Bannister, M.J., Cabello, S., Eppstein, D.: Parameterized of ity https://doi.org/10.7155/jgaa.00457 1-planarity. J. Graph Algorithms Appl. 22(1), 23 -- 49 complex- (2018). 2. Bannister, M.J., Eppstein, D.: Crossing minimization for 1-page and 2-page draw- ings of graphs with bounded treewidth. J. Graph Algorithms Appl. 22(4), 577 -- 606 (2018). https://doi.org/10.7155/jgaa.00479 3. Bekos, M.A., Gronemann, M., Raftopoulou, C.N.: Two-page book em- (2016). graphs. Algorithmica 158 -- 185 75(1), beddings https://doi.org/10.1007/s00453-015-0016-8 4-planar of 4. Bernhart, F., Kainen, P.C.: The book thickness of a graph. J. Comb. Theory, Ser. B 27(3), 320 -- 331 (1979). https://doi.org/10.1016/0095-8956(79)90021-2 5. Binucci, C., Di Giacomo, E., Hossain, M.I., Liotta, G.: 1-page and 2-page drawings with bounded number of crossings per edge. Eur. J. Comb. 68, 24 -- 37 (2018). https://doi.org/10.1016/j.ejc.2017.07.009 6. Chen, J., Kanj, I.A., Xia, G.: Improved upper bounds for vertex cover. Theor. Com- put. Sci. 411(40-42), 3736 -- 3756 (2010). https://doi.org/10.1016/j.tcs.2010.06.026 7. Chung, F., Leighton, F., Rosenberg, A.: Embedding graphs in books: A layout problem with applications to VLSI design. SIAM J. Alg. Discr. Meth. 8(1), 33 -- 58 (1987). https://doi.org/10.1137/0608002 8. Cygan, M., Fomin, F.V., Kowalik, L., Lokshtanov, D., Marx, D., Pilipczuk, M., Pilipczuk, M., Saurabh, S.: Parameterized Algorithms. Springer (2015). https://doi.org/10.1007/978-3-319-21275-3 9. Diestel, R.: Graph Theory, 4th Edition, Graduate texts in mathematics, vol. 173. Springer (2012) 10. Downey, R.G., Fellows, M.R.: Fundamentals of Parameterized Complexity. Texts in Computer Science, Springer (2013). https://doi.org/10.1007/978-1-4471-5559-1 11. Dujmovi´c, V., Wood, D.R.: On linear layouts of graphs. Discrete Math. Theor. Comput. Sci. 6(2), 339 -- 358 (2004) 12. Dujmovic, V., Wood, D.R.: Graph treewidth parameters. Discrete Computat. Geom. ness https://doi.org/10.1007/s00454-007-1318-7 and 37(4), geometric 641 -- 670 thick- (2007). 13. Dujmovi´c, V., Wood, D.R.: On the book thickness of k-trees. Discrete Math. Theor. Comput. Sci. 13(3), 39 -- 44 (2011) 13 14. Fellows, M.R., Lokshtanov, D., Misra, N., Rosamond, F.A., Saurabh, S.: Graph layout problems parameterized by vertex cover. In: Algorithms and Computation (ISAAC'08). pp. 294 -- 305 (2008). https://doi.org/10.1007/978-3-540-92182-0 28 15. Ganian, R.: Improving vertex cover as a graph parameter. Discrete Math. Theor. Comput. Sci. 17(2), 77 -- 100 (2015) 16. Ganian, R., Ordyniak, S.: The complexity landscape of 61 -- 71 decom- (2018). positional https://doi.org/10.1016/j.artint.2017.12.006 parameters ILP. Artif. for Intell. 257, 17. Ganley, J.L., Heath, L.S.: The pagenumber of k-trees is O(k). Discrete Appl. Math. 109(3), 215 -- 221 (2001). https://doi.org/10.1016/S0166-218X(00)00178-5 18. Gutin, G.Z., Jones, M., Wahlstrom, M.: The mixed Chinese postman problem parameterized by pathwidth and treedepth. SIAM J. Discrete Math. 30(4), 2177 -- 2205 (2016). https://doi.org/10.1137/15M1034337 19. Haslinger, C., Stadler, P.F.: RNA structures with pseudo-knots: Graph-theoretical, combinatorial, and statistical properties. Bull. Math. Biol. 61(3), 437 -- 467 (1999). https://doi.org/10.1006/bulm.1998.0085 20. Kainen, P.C.: Some recent results in topological graph theory. In: Bari, R.A., Harary, F. (eds.) Graphs and Combinatorics. pp. 76 -- 108. Springer (1974). https://doi.org/10.1007/BFb0066436 21. Kinnersley, N.G.: The vertex separation number of a graph equals its path- width. Inf. Process. Lett. 42(6), 345 -- 350 (1992). https://doi.org/10.1016/0020- 0190(92)90234-M 22. Lodha, N., Ordyniak, S., Szeider, S.: Sat-encodings for special treewidth and pathwidth. In: Gaspers, S., Walsh, T. (eds.) Theory and Applications of Sat- isfiability Testing (SAT'17). LNCS, vol. 10491, pp. 429 -- 445. Springer (2017). https://doi.org/10.1007/978-3-319-66263-3 27 23. Mallach, S.: Linear ordering based MIP formulations for the vertex separation or pathwidth problem. In: Brankovic, L., Ryan, J., Smyth, W. (eds.) Combina- torial Algorithms (IWOCA'17). LNCS, vol. 10765, pp. 327 -- 340. Springer (2017). https://doi.org/10.1007/978-3-319-78825-8 27 24. Nesetril, J., de Mendez, P.O.: Sparsity -- Graphs, Structures, and Algorithms, Al- gorithms and combinatorics, vol. 28. Springer (2012). https://doi.org/10.1007/978- 3-642-27875-4 25. Ollmann, L.T.: On the book thicknesses of various graphs. In: 4th Southeastern Conference on Combinatorics, Graph Theory and Computing. vol. 8, p. 459 (1973) 26. Robertson, N., Seymour, P.D.: Graph minors. I. Excluding a forest. J. Comb. Theory, Ser. B 35(1), 39 -- 61 (1983). https://doi.org/10.1016/0095-8956(83)90079- 5 27. Robertson, N., Seymour, P.D.: Graph minors. II. Algorithmic aspects of tree-width. J. Algorithms 7(3), 309 -- 322 (1986). https://doi.org/10.1016/0196-6774(86)90023- 4 28. Unger, W.: The complexity of (extended ab- stract). (eds.) Theoretical Aspects of Com- puter Science (STACS'92). LNCS, vol. 577, pp. 389 -- 400. Springer (1992). https://doi.org/10.1007/3-540-55210-3 199 In: Finkel, A., Jantzen, M. colouring circle graphs 29. Yannakakis, M.: Embedding planar graphs in four pages. J. Comput. Syst. Sci. 38(1), 36 -- 67 (1989). https://doi.org/10.1016/0022-0000(89)90032-9 14 A Missing Proofs of Section 3 Observation 2 If for all s ∈ S it holds that Rn−τ (s) = ∅, then (G,≺, k) is a NO-instance of Fixed-Order Book Thickness. Proof. Assume for a contradiction that G admits a k-page book embedding with order ≺. Let s be the restriction of that book embedding to edges whose both endpoints lie in C, and let α be the restriction of that book embed- ding to all other edges. Then α is a valid page assignment, and hence by defi- nition (Mn−τ (n − τ, α, s), Mn−τ (x1, α, s), Mn−τ (x2, α, s), . . . , Mn−τ (xz, α, s)) ∈ Rn−τ (s). In particular, Rn−τ (s) (cid:54)= ∅. (cid:117)(cid:116) Lemma 2. Every n-vertex graph G = (V, E) with a linear order ≺ of V such that (G,≺) has pathwidth k admits a k-page book embedding (cid:104)≺, σ(cid:105), which can be computed in O(n + k · n) time. Proof. Let σ be the page assignment to [k] defined as follows. We parse the vertices of G following ≺ from right to left. Consider the rightmost vertex vn of ≺, and let Un be an arbitrary injective assignment from Pn (the guard set of vn) to [k]. For each edge e incident to vn there exists some p ∈ Pn, and we assign e to page Un(p). Observe that, this results in a non-crossing page assignment of the edges incident to vn. Next, we proceed by induction. Assume, we have obtained a non-crossing page assignment for all edges incident to the last i vertices, i.e., for all edges incident to {vjj ≥ n− i}, and that furthermore we have a mapping Un−i which maps the guards Pn−i for vn−i to [k] and a non-crossing partial page assignment which maps all edges pvj where p ∈ Pn−i and j ≥ n− i to Un−i(p). In particular, all edges with an endpoint to the left of vn−i end in the guards for vn−i and are assigned to distinct pages if and only if they are incident to distinct guards. We extend this page assignment to all edges incident to the last i + 1 vertices as follows. First, we extend Un−i to an arbitrary injective mapping Un−i−1, which is always possible since the number of guards for vi+1 is at most k. Second, we assign each left edge e = vn−i−1p of vn−i−1 to Un−i−1(p). To conclude the proof, observe that the page assignment obtained in this way is non-crossing. Indeed, the only edges added to the current page assignment are left edges of vn−i−1, and each such edge e = vn−i−1p is assigned to the page Un−i−1(p) -- notably, they maintain the property of being assigned to distinct pages if and only if they are incident to distinct guards. Also, it can be computed in O(n + k · n) time. (cid:117)(cid:116) 15
1505.01523
5
1505
2017-01-03T16:51:14
Fast and Powerful Hashing using Tabulation
[ "cs.DS" ]
Randomized algorithms are often enjoyed for their simplicity, but the hash functions employed to yield the desired probabilistic guarantees are often too complicated to be practical. Here we survey recent results on how simple hashing schemes based on tabulation provide unexpectedly strong guarantees. Simple tabulation hashing dates back to Zobrist [1970]. Keys are viewed as consisting of $c$ characters and we have precomputed character tables $h_1,...,h_c$ mapping characters to random hash values. A key $x=(x_1,...,x_c)$ is hashed to $h_1[x_1] \oplus h_2[x_2].....\oplus h_c[x_c]$. This schemes is very fast with character tables in cache. While simple tabulation is not even 4-independent, it does provide many of the guarantees that are normally obtained via higher independence, e.g., linear probing and Cuckoo hashing. Next we consider twisted tabulation where one input character is "twisted" in a simple way. The resulting hash function has powerful distributional properties: Chernoff-Hoeffding type tail bounds and a very small bias for min-wise hashing. This also yields an extremely fast pseudo-random number generator that is provably good for many classic randomized algorithms and data-structures. Finally, we consider double tabulation where we compose two simple tabulation functions, applying one to the output of the other, and show that this yields very high independence in the classic framework of Carter and Wegman [1977]. In fact, w.h.p., for a given set of size proportional to that of the space consumed, double tabulation gives fully-random hashing. We also mention some more elaborate tabulation schemes getting near-optimal independence for given time and space. While these tabulation schemes are all easy to implement and use, their analysis is not.
cs.DS
cs
Fast and Powerful Hashing using Tabulation Mikkel Thorup∗ University of Copenhagen January 4, 2017 Abstract Randomized algorithms are often enjoyed for their simplicity, but the hash functions employed to yield the desired probabilistic guarantees are often too complicated to be practical. Here we survey recent results on how simple hashing schemes based on tabulation provide unexpectedly strong guarantees. Simple tabulation hashing dates back to Zobrist [1970]. Keys are viewed as consisting of c characters and we have precomputed character tables h1, ..., hc mapping characters to random hash values. A key x = (x1, ..., xc) is hashed to h1[x1]⊕ h2[x2].....⊕ hc[xc]. This schemes is very fast with character tables in cache. While simple tabulation is not even 4-independent, it does provide many of the guarantees that are normally obtained via higher independence, e.g., linear probing and Cuckoo hashing. Next we consider twisted tabulation where one input character is "twisted" in a simple way. The resulting hash function has powerful distributional properties: Chernoff-style tail bounds and a very small bias for min-wise hashing. This also yields an extremely fast pseudo-random number generator that is provably good for many classic randomized algorithms and data-structures. Finally, we consider double tabulation where we compose two simple tabulation functions, applying one to the output of the other, and show that this yields very high independence in the classic framework of Carter and Wegman [1977]. In fact, w.h.p., for a given set of size proportional to that of the space con- sumed, double tabulation gives fully-random hashing. We also mention some more elaborate tabulation schemes getting near-optimal independence for given time and space. While these tabulation schemes are all easy to implement and use, their analysis is not. 1 Introduction A useful assumption in the design of randomized algorithms and data structures is the free availability of fully random hash functions which can be computed in unit time. Removing this unrealistic assumption is the subject of a large body of work. To implement a hash-based algorithm, a concrete hash function has to be chosen. The space, time, and random choices made by this hash function affects the overall performance. The generic goal is therefore to provide efficient constructions of hash functions that for important randomized algorithms yield probabilistic guarantees similar to those obtained assuming fully random hashing. To fully appreciate the significance of this program, we note that many randomized algorithms are very simple and popular in practice, but often they are implemented with too simple hash functions without the necessary guarantees. This may work very well in random tests, adding to their popularity, but the real world ∗Research partly supported by Advanced Grant DFF-0602-02499B from the Danish Council for Independent Research under the Sapere Aude research carrier programme. 1 is full of structured data, e.g., generated by computers, that could be bad for the hash function. This was illustrated in [51] showing how simple common inputs made linear probing fail with popular hash functions, explaining its perceived unreliability in practice. The problems disappeared when sufficiently strong hash functions were used. In this paper we will survey recent results from [12, 13, 14, 15, 41, 42, 50] showing how simple realistic hashing schemes based on tabulation provide unexpectedly strong guarantees for many popular randomized algorithms, e.g., linear probing, Cuckoo hashing, min-wise independence, treaps, planar partitions, power- of-two-choices, Chernoff-style concentration bounds, and even high independence. The survey is from a users perspective, explaining how these tabulation schemes can be applied. While these schemes are all very simple to describe and use, the analysis showing that they work is non-trivial. For the analysis, the reader will be referred to the above papers. The reader is also referred to these papers for a historical account of previous work. Background Generally a hash function maps a key universe U of keys into some range R of hash values. A random hash function h is a random variable from RU , assigning a random hash value h(x) ∈ R to every x ∈ U. A truly random hash function is picked uniformly from RU , assigning a uniform and independent hash value h(x) ∈ R to each key x ∈ U. Often randomized algorithms are analyzed assuming access to truly random hash functions. However, just storing a truly random hash function requires U log2 R bits, which is unrealistic for large key universes. In general, the keys may originate come from a very large universe U. However, often we are only interested in the performance on an unknown set S ⊆ U of up to n keys. Then our first step is to do a universe reduction, mapping U randomly to "signatures" in [u] = {0, 1, . . . , u − 1}, where u = nO(1), e.g., u = n3, so that no two keys from S are expected to get the same signature [9]. Below we generally assume that this universe reduction has been done, if needed, hence that we "only" need to deal with keys from the polynomial universe [u]. The concept of k-independence was introduced by Wegman and Carter [52] in FOCS'79 and has been the cornerstone of our understanding of hash functions ever since. As above, we think of a hash function h : [u] → [m] as a random variable distributed over [m][u]. We say that h is k-independent if (a) for any distinct keys x1, . . . , xk ∈ [u], the hash values h(x1), . . . , h(xk) are independent random variables; and (b) for any fixed x, h(x) is uniformly distributed in [m]. As the concept of independence is fundamental to probabilistic analysis, k-independent hash functions are both natural and powerful in algorithm analysis. They allow us to replace the heuristic assumption of truly random hash functions that are uniformly distributed in [m][u], hence needing u lg m random bits (lg = log2), with real implementable hash functions that are still "independent enough" to yield provable performance guarantees similar to those proved with true randomness. We are then left with the natural goal of understanding the independence required by hashing-based algorithms. Once we have proved that k-independence suffices for a hashing-based randomized algorithm, we are free to use any k-independent hash function. The canonical construction of a k-independent hash function is based on polynomials of degree k − 1. Let p ≥ u be prime. Picking random a0, . . . , ak−1 ∈ {0, . . . , p− 1}, the hash function is defined by: h(x) =(cid:16)(cid:0)ak−1xk−1 + ··· + a1x + a0(cid:1) mod p(cid:17) (1) If we want to limit the range of hash values to [m], we use h(x) mod m. This preserves requirement (a) of independence among k hash values. Requirement (b) of uniformity is close to satisfied if p ≫ m. As 2 suggested in [9], for a faster implementation, we can let p be a Mersenne prime, e.g., to hash 64-bit integers, we could pick p = 281 − 1. Sometimes 2-independence suffices. For example, 2-independence implies so-called universality [9]; namely that the probability of two keys x and y colliding with h(x) = h(y) is 1/m; or close to 1/m if the uniformity of (b) is only approximate. Universality implies expected constant time performance of hash tables implemented with chaining. Universality also suffices for the 2-level hashing of Fredman et al. [24], yielding static hash tables with constant query time. Moreover, Mitzenmacher and Vadhan [34] have proved that 2-independent hashing in many applications works almost like truly random hashing if the input has enough entropy. However, structured, low-entropy data, are very common in the real world. We do have very fast implementations of universal and 2-independent hashing [16, 17], but unfortu- nately, these methods do not generalize nicely to higher independence. At the other end of the spectrum, when dealing with problems involving n objects, O(lg n)-independence suffices in a vast majority of applications. One reason for this is the Chernoff bounds of [43] for k- independent events, whose probability bounds differ from the full-independence Chernoff bound by 2−Ω(k). Another reason is that random graphs with O(lg n)-independent edges [3] share many of the properties of truly random graphs. When it comes to high independence, we note that the polynomial method from Equation (1) takes O(k) time and space for k-independence. This is no coincidence. Siegel [46] has proved that to implement k- independence with less than k memory accesses, we need a representation using u1/k space. He also gives a solution that for any c uses O(u1/c) space, cO(c) evaluation time, and achieves uΩ(1/c2) independence (which is superlogarithmic, at least asymptotically, for c = O(1)). The construction is non-uniform, assuming a certain small expander which gets used in a graph product. Siegel [46] states about his scheme that it is "far too slow for any practical application". The independence measure has long been central to the study of randomized algorithms. For example, [29] considers variants of QuickSort, [1] consider the maximal bucket size for hashing with chaining, and [28, 19] consider Cuckoo hashing. In several cases [1, 19, 29], it is proved that linear transformations x 7→ (cid:0)(ax + b) mod p(cid:1) do not suffice for good performance, hence that 2-independence is not in itself sufficient. This paper surveys a family of "tabulation" based hash function that like Siegel's hash function use O(u1/c) space for some constant c, but which are simple and practical, and offer strong probabilistic guar- antees for many popular randomized algorithms despite having low independence. We start with the sim- plest and fastest tabulation scheme, and move later to more complicated schemes with stronger probabilistic guarantees. We note that there has been several previous works using tabulation to construct efficient hash func- tions (see, e.g., [18, 20]), but the schemes discussed here are simpler and more efficient. More detailed comparisons with previous works are found in the papers surveyed. 2 Simple tabulation The first scheme we consider is simple tabulation hashing where the hash values are r-bit numbers. Our goal is to hash keys from U = [u] into the range R = [2r]. In tabulation hashing, a key x ∈ [u] is interpreted as a vector of c > 1 "characters" from the alphabet Σ = [u1/c], i.e., x = (x0, ..., xc−1) ∈ Σc. As a slight abuse of notation, we shall sometimes use Σ instead of Σ to denote the size of the alphabet when the context makes this meaning clear. This matches the classic recursive set-theoretic definition of a natural as the set of smaller naturals. 3 For "simple tabulation hashing" we initialize independent random character tables h0, . . . , hc−1 : Σ → (2) R. The hash h(x) of a key x = (x0, ..., xc−1) is computed as: hi[xi]. h(x) =Mi∈[c] If the piece at a position i changes from xi to x′ Here ⊕ denotes bit-wise exclusive-or. This is a well-known scheme dating back at least to Zobrist [53]. For him a character position corresponds to a position on a game board, and the character is the piece at the position. i, he updates the overall hash value h to h′ = h ⊕ hi[xi] ⊕ hi[x′ i]. It is easy to see that simple tabulation is 3-independent, for if we have a set X of two or three keys, then there must be a position i ∈ [c] where one key x has a character xi not shared with any other key in X. This means that x is the only key in X whose hash value depends on hi[xi], so the hash value of x is independent of the other hash values from X. On the other hand, simple tabulation is not 4-independent. Given 4 keys (a0, b0), (a1, b0), (a0, b1), (a1, b1), no matter how we fill our tables, we have h(a0, b0) ⊕ h(a1, b0) ⊕ h(a0, b1) ⊕ h(a1, b1) = 0. Thus, given the hash values of any of three of the keys, we can uniquely determine the fourth hash value. In our context, we assume that the number c = O(1) of character positions is constant, and that character tables fit in fast cache. Justifying this assumption, recall that if we have n keys from a very large universe, we can first do a universe reduction, applying a universal hashing function [9] into an intermediate universe of size u = nO(1), expecting no collisions (sometimes, as in [48], we can even accept some collisions from the first universal hashing, and hence use an intermediate universe size closer to n). Now, for any desired small constant ε > 0, we get down to space O(nε) picking c = O(1) so that Σ = u1/c < nε. We shall refer to the lookups in the hi as "character lookups", emphasizing that they are expected to be much faster than a general lookup in a table of size n. Putting things into a practical perspective (this paper claims practical schemes with strong theoretical guarantees), in the experiments from [41, 49], for 32-bit keys, simple tabulation with 4 character lookups took less than 5ns whereas a single memory lookup in a 4MB table took more than 120ns. Character lookups were thus about 100 times faster than general lookups! We note that the character lookups parallelize easily and this may or may not have been exploited in the execution (we just wrote portable C-code, leaving the rest to compiler and computer). Simple tabulation was only 60% slower than the 2-independent multiply-shift scheme from [16] which for 32-bit keys is dominated by a single 64-bit multiplication. However, simple tabulation is 3-independent and in experiments from [41], it was found to be more than three times faster than 3-independent hashing implemented by a degree-2 polynomial tuned over the Mersenne prime field 261−1. The high speed of simple tabulation conforms with experiments on much older architectures [47]. Z Because cache is so critical to computation, most computers are configured with a very fast cache, and this is unlikely to change. Usually it is not a problem to fill the character tables h0, . . . , hc−1 with random numbers, e.g., down- loading them from http://random.org which is based on atmospheric noise. However, for the theory presented here, it would suffice to fill them with a strong enough pseudo-random number generator (PRG), like a (lg u)-independent hash function, e.g., using the new fast generation from [11]. The character tables just need to point to an area in memory with random bits, and this could be shared across many applica- tions. One could even imagine computers configured with random bits in some very fast read-only memory allowing parallel access from multiple cores. 4 In [41] simple tabulation hashing was proved to have much more power than suggested by its 3- independence. This included fourth moment bounds, min-wise hashing, random graph properties necessary in cuckoo hashing [39], and Chernoff bounds for distributing balls into many bins. The details follow below. Concentration bounds First we consider using simple tabulation hashing to distribute n balls into m = 2r bins, that is, assuming that the balls have keys from [u], we are using a simple tabulation hash function h : [u] → [m]. In a hash table with chaining, the balls in a bin would be stored in a linked list. Consider the number X of balls landing in a given bin. We have µ = E[X] = n/m. Patras¸cu and Thorup [41] have proved that, w.h.p., we get a Chernoff-style concentration on X. First recall the classic Chernoff bounds [36, §4] for full randomness. On the upper bound side, we have [36, Theorem 4.1] eδ Pr[X ≥ (1 + δ)µ] ≤(cid:18) (1 + δ)(1+δ)(cid:19)µ(cid:2) ≤ exp(−δ2µ/3) for δ ≤ 1(cid:3) The corresponding probabilistic lower bound [36, Proof of Theorem 4.2] for δ ≤ 1 is (1 − δ)(1−δ)(cid:19)µ(cid:2) ≤ exp(−δ2µ/2) for δ ≤ 1(cid:3) Pr[X ≤ (1 − δ)µ] ≤(cid:18) e−δ (3) (4) We note that in connection with hash tables, we are often not just interested in a given bin, but rather we care about the bin that a specific query ball lands in. This is why the hash of the query ball is involved in the theorem below with Chernoff-style bounds for simple tabulation. Theorem 1 ([41]) Consider hashing n balls into m ≥ n1−1/(2c) bins by simple tabulation (recall that c = O(1) is the number of characters). Define X as the number of regular balls that hash into a given bin or a bin chosen as a function of the bin h(q) of an additional query ball q. The following probability bounds hold for any constant γ: eδ Pr[X ≥ (1 + δ)µ] ≤(cid:18) Pr[X ≤ (1 − δ)µ] ≤(cid:18) (1 + δ)(1+δ)(cid:19)Ω(µ) (1 − δ)(1−δ)(cid:19)Ω(µ) n/m ± O(cid:16)pn/m logc n(cid:17) . e−δ With m ≤ n bins (including m < n1−1/(2c)), every bin gets + 1/mγ + 1/mγ. (5) (6) (7) balls with probability 1 − n−γ. Contrasting the standard Chernoff bounds, we see that Theorem 1 (5) and (6) can only provide poly- nomially small probability, i.e. at least m−γ for any desired constant γ. This corresponds to if we had Θ(log m)-independence in the Chernoff bound from [43]. In addition, the exponential dependence on µ is reduced by a constant which depends (exponentially) on the constants γ and c. The upper bound (5) implies that any given bin has O(lg n/ lg lg n) balls w.h.p., but then this holds for all m bins w.h.p. Simple tabulation is the simplest and fastest constant time hash function to achieve this fundamental property. Complementing the above Chernoff-style bound, Dahlgaard et al. [13] have proved that we also get the kth moment bounds normally associated with k-independence. 5 Theorem 2 ([13]) With the same setup as in Theorem 1, for any constant k = O(1), Eh(X − µ)ki = O(µ + µk/2). For k ≤ 4, this bound was proved in [41], and disallowing the dependence on a query ball, it was also proved in [6], again for k ≤ 4. Compelling applications of 4th moment bounds are given by [2], [29], and [38]. In [29], it was shown that any hash function with a good 4th moment bound suffices for a non-recursive version of QuickSort, routing on the hypercube, etc. In [2], the 4th moment is used to estimate the 2nd moment of a data stream. In [38], limited 4th moment is shown to imply constant expected performance for linear probing. The applications in [29, 38] both require dependence of a query bin. Since kth moment bounds is one of the main ways k-independence is used, it is nice that they are achieved by simple tabulation which is only 3-independent. Linear probing Theorem 1 is used in [41] to get bounds for linear probing. Linear probing is a classic implementation of hash tables. It uses a hash function h to map a set of n keys into an array of size m. When inserting x, if the desired location h(x) ∈ [m] is already occupied, the algorithm scans h(x) + 1, h(x) + 2, . . . , m − 1, 0, 1, . . . until an empty location is found, and places x there. The query algorithm starts at h(x) and scans until it either finds x, or runs into an empty position, which certifies that x is not in the hash table. When the query search is unsuccessful, that is, when x is not stored, the query algorithm scans exactly the same locations as an insert of x. A general bound on the query time is hence also a bound on the insertion time. This classic data structure is one of the most popular implementations of hash tables, due to its un- matched simplicity and efficiency. The practical use of linear probing dates back at least to 1954 to an assembly program by Samuel, Amdahl, Boehme (c.f. [31]). On modern architectures, access to memory is done in cache lines (of much more than a word), so inspecting a few consecutive values typically translates into a single memory access. Even if the scan straddles a cache line, the behavior will still be better than a second random memory access on architectures with prefetching. Empirical evaluations [5, 26, 39] con- firm the practical advantage of linear probing over other known schemes, while cautioning [26, 51] that it behaves quite unreliably with weak hash functions. Linear probing was shown to take expected constant time for any operation in 1963 by Knuth [30], in a report which is now regarded as the birth of algorithm analysis. This analysis, however, assumed a truly random hash function. However, Pagh et al. [38] showed that just 5-independence suffices for this expected constant operation time. In [40], 5-independence was proved to be best possible, presented a concrete combination of keys and a 4-independent random hash function where searching certain keys takes Ω(log n) expected time. In [41], the result from [38] is strengthened for more filled linear probing tables, showing that if the table size is m = (1 + ε)n, then the expected time per operation is O(1/ε2), which asymptotically matches the bound of Knuth [30] with truly random hashing. More important for this paper, [41] proved that this performance bound also holds with simple tabulation hashing. In fact, for simple tabulation, we get quite strong concentration results for the time per operation, e.g,, constant variance for constant ε. For contrast, with 5-independent hashing, the variance is only known to be O(log n) [38, 51]. Some experiments are done in [41] comparing simple tabulation with the fast 2-independent multiply- shift scheme from [16] in linear probing. For simple inputs such as consecutive integers, the performance was extremely unreliable with the 2-independent hashing, but with simple tabulation, everything worked perfectly as expected from the theoretical guarantees. 6 Cuckoo hashing In cuckoo hashing [39] we use two tables of size m ≥ (1 + ε)n and independent hash functions h0 and h1 mapping the keys to these two tables. Cuckoo hashing succeeds if we can place every key in one of its two hash locations without any collision. We can think of this as a bipartite graph with a set for each table and an edge (h0(x), h1(x)) for each key x. Cuckoo hashing fails exactly if this graph has a component with more edges than vertices. With truly random hashing, this bad event happens with probability Θ( 1 n ). Patras¸cu and Thorup [41] study the random graphs induced by simple tabulation, and obtain a rather unintuitive result: the worst failure probability is inversely proportional to the cube root of the set size. Theorem 3 ([41]) Any set of n keys can be placed in two tables of size m = (1 + ε) by cuckoo hashing and simple tabulation with probability 1 − O(n−1/3). There exist sets on which the failure probability is Ω(n−1/3). Thus, cuckoo hashing with simple tabulation is an excellent construction for a static dictionary. The dictionary can be built (in linear time) after trying O(1) independent hash functions w.h.p., and later every query runs in constant worst-case time with two probes. We note that even though cuckoo hashing requires two independent hash functions, these essentially come for the cost of one in simple tabulation: the pair of hash codes can be stored consecutively, in the same cache line, making the running time comparable with evaluating just one hash function. In the dynamic case, Theorem 3 implies that we expect Ω(n4/3) updates between failures requiring a complete rehash with new hash functions. Minwise independence In [41] it is shown that simple tabulation is ε-minwise independent, for a van- ishingly small ε (inversely polynomial in the set size n). This takes Θ(log n)-independence by general techniques [27, 40]. More precisely, we have Theorem 4 ([41]) Consider a set S ⊆ Σc of n = S keys and q ∈ S. If h : Σc → [m], m ≥ n1+1/c is implemented by simple tabulation: Pr[h(q) = min h(S)] = 1 ± ε n , n1/c(cid:19) . where ε = O(cid:18) lg2 n (8) The classic application of ε-minwise hashing of Broder [8, 7] is the estimation of Jaccard set similarity A ∩ B/A ∪ B. Ignoring the probability of collisions in the minimum hash value, we get Pr[min h(A) = min h(B)] For better bounds on the probabilities, we would make multiple experiments with independent hash func- tions, yet this cannot eliminate the bias ε. Pr[h(x) = min h(A ∪ B)] = Xx∈A∩B A ∪ B ·(cid:18)1 ± eO(cid:18) = A ∩ B 1 A ∪ B1/c(cid:19)(cid:19) . 7 The power of two choices The power of two choices is a standard scheme for placing balls into bins where each ball hashes to two bins, and is placed in the lightest loaded one (see [33] for a survey). When placing n balls into n bins, using the two-choice paradigm with truly random hash functions, the maximum load of any bin is lg lg n + O(1) w.h.p. [4]. Dahlgaard et al. [14] have proved that simple tabulation gives a maximum load which is lg lg n + O(1) in expectation and O(log log n) w.h.p.. This is the simplest constant time hashing scheme known to offer such strong two-choice load balancing. Weakness with small numbers As described above, simple tabulation has much more power than sug- gested by its 3-independence. However, there are also some weaknesses. For example, in the Chernoff-style bounds (5) and (6) from Theorem 1, we have an additive error probability of 1/mγ when hashing into m bins. Here γ is an arbitrarily large constant, so this is fine when m is large. However, this is not good if m is small, e.g., m = 2 as when we toss a coin. A somewhat related problem is that our bias ε in ε-minwise independence in (8) is O(1/n1/c) where n is the size of the set considered. This is fine if the set is large, but not if the set is small. Both of these problems and more will be addressed by twisted tabulation described below. 3 Twisted tabulation We will now consider twisted tabulation proposed by Patras¸cu and Thorup in [42]. It adds a quick twist to simple tabulation, leading to more general distributional properties, including Chernoff bounds that also work for few bins and better minwise hashing that also works well for small sets. For i = 1, . . . , c − 1, we expand the entries of hi with a random character called the "twister". More precisely, for i > 0, we now have random tables h⋆ i : Σ → Σ × R. This adds lg Σ bits to each entry of the table (in practice, we want entries to have bit lengths like 32 or 64, so depending on R, the twister may, or may not, increase the actual entry size). The table h0 : Σ → R is kept unchanged. The hash function is now computed in two statements: (t, h>0) = c−1Mi=1 h⋆ i [xi]; h(x) = h>0 ⊕ h0[x0 ⊕ t]. (9) Figure 1 contains the C-code for simple and twisted tabulation. The highlight of twisted tabulation is its minimalistic nature, adding very little to the cost of simple tabulation (but, as we shall see, with significantly stronger guarantees). Twisted tabulation uses exactly c character lookups into tables with Σ entries, just like simple tabulation, though with larger entries. Essen- tially twisted tabulation only differs from simple tabulation by two AC0 operations, so we would expect it to be almost as fast as simple tabulation (whose practicality has long been established). This was confirmed experimentally in [42], where twisted tabulation was less than 30% slower than simple tabulation, and still nearly three times faster than a second degree polynomial. When we discuss properties of twisted tabulation, we view keys x = (x0, . . . , xc−1) as composed of a head, head(x) = x0 and a tail, tail(x) = (x1, . . . , xc−1). We refer to the following implementation of twisted tabulation which is less efficient but mathematically equivalent to (9): 1. Pick a simple tabulation hash function hτ : Σc−1 → Σ from c − 1 characters to 1 character. This c−1. Applying hτ to the tail of a key x, we get corresponds to the twister components of h⋆ 1, . . . , h⋆ 8 #include <stdint.h> //defines uintX_t as unsigned X-bit integer. uint32_t SimpleTab32(uint32_t x, uint32_t[4][256] H) { uint32_t i; uint32_t h=0; uint8_t c; for (i=0;i<4;i++) { c=x; h=H[i][c]; x = x >> 8; } return h; } uint32_t TwistedTab32(uint32_t x, uint64_t[4][256] H) { uint32_t i; uint64_t h=0; uint8_t c; for (i=0;i<3;i++) { c=x; h=H[i][c]; x = x >> 8; } c=xh; h=H[i][c]; h>>=32; return ((uint32_t) h); } // extra xor compared with simple // extra shift compared with simple Figure 1: C-code for simple and twisted tabulation for 32-bit keys assuming a pointer H to some randomly filled storage (4KB for simple and 8KB for twisted). 9 the combined twister t = hτ(tail(x)), the "twisted head" x0 ⊕ t, and the "twisted key" hT(x) = (cid:0)x0 ⊕ t, x1, . . . , xc−1(cid:1). 2. Pick a simple tabulation hash function hS : Σc → R (where R was the desired output range). This i (remember that tails are not corresponds to h0 and for i > 0, the non-twister component hi of h⋆ touched by twisting). The twisted tabulation hash function is then x 7→ hS (hT(x)). For all the results presented here, it does not matter which character we view as the head. Above it is the first character, but sometimes it is more efficient if it is the last least significant character. As noted in [42], the twisting by hT can be seen as a single-round Feistel permutation where the hash function is simple tabulation. Because twisting is a permutation, twisted tabulation inherit from simple tabulation any (probabilistic) property that holds regardless of concrete key values, e.g., the above Cuckoo hashing and the power of two choices. Like simple tabulation, twisted tabulation is only 3-independent, but it does have some more general distributional guarantees, which we explain in detail below. Chernoff Bounds Chernoff bounds play a prominent role in the design of randomized algorithms [36, §4]. The Chernoff-style bounds from Theorem 1 where limited in that they only really worked for throwing balls into a large number m of bins. In [42], Patras¸cu and Thorup prove the following far more general Chernoff-style bounds for twisted tabulation. Theorem 5 ([42]) Choose a random c-character twisted tabulation hash function h = hS ◦ hT : [u] → [u], [u] = Σc. For each key x ∈ [u] in the universe, we have an arbitrary "value function" vx : [u] → [0, 1] assigning a value Vx = vx(h(x)) ∈ [0, 1] to x for each hash value. Define V = Px∈[u] Vx and µ = Px∈[u] µx where µx = E[vx(h(x))]. Let γ, c and ε > 0 be constants. Then for any µ < Σ1−ε and δ > 0, we have: Pr[V ≥ (1 + δ)µ] ≤(cid:18) Pr[V ≤ (1 − δ)µ] ≤(cid:18) + 1/uγ + 1/uγ . Moreover, for any µ ≥ √Σ (including µ ≥ Σ1−ε), with probability 1 − u−γ, eδ (1 + δ)(1+δ)(cid:19)Ω(µ) (1 − δ)(1−δ)(cid:19)Ω(µ) e−δ V = µ ± eO(√µ). (10) (11) (12) If we have a given distinguished query key q ∈ [u], the above bounds hold even if we condition everything on h(q) = a for any given a ∈ [u]1. The statement of Theorem 5 may seem a bit cryptic, so before proceeding, we will show that it improves the simple tabulation bounds from Theorem 1. Those bounds considered a set S of n balls or keys mapped into m bins, and had an error bound of m−γ. The error is here improved to u−γ. We now do the translation. Discounting all irrelevant keys x ∈ [u] \ S, we zero their value functions, setting vx(·) = 0. Also, we define the bin hash function from Theorem 1 as h′(x) = h(x) mod m, noting that m ↑ u since both are powers of two. Theorem 1 studies the number of balls landing a bin b which may be a function of the bin h′(q) of a query ball q ∈ [u] \ S. Thanks to the last statement of Theorem 1This last statement conditioning on h(q) = a was not proved in [42], but it is an easy extension provided in Appendix A. 10 5, we can condition on any value a of h(q), which determines h′(q) and hence b. Now, for x ∈ S, define Vx = vx(h(x)) = 1 if h′(x) = b; 0 otherwise. Now V =Px∈[u] Vx is the variable X from Theorem 1, and (5) and (6) follow from (10) and (11), but with the improved error u−γ. This is important when m is small, e.g., if m = 2 corresponding to unbiased coin tosses. A different illustration of the versatility of Theorem 5 is if we want each key x ∈ [u] to be sampled with some individual sampling probability px. In this case we have no distinguished query key, and we can just define vx(y) = 1 if y < px · m; otherwise vx(y) = 0. Since h(x) is uniform in [m], we have that x is sampled with Vx = vx(h(x)) = 1 with probability px = ⌈pxm⌉/m. The number V = Px∈[u] Vx of samples is now concentrated according to (10) and (11). Minwise independence Concerning minwise hashing, Dahlgaard and Thorup [15] have proved that twisted tabulation yields the following strengthening of Theorem 4 for simple tabulation. Theorem 6 ([15]) Consider a set S ⊆ Σc of n = S keys and q ∈ S. If h : Σc → [m], m ≥ nu1/c is implemented by twisted tabulation then: Pr[h(q) = min h(S)] = , u1/c(cid:19) . where ε = O(cid:18) lg2 u 1 ± ε n n1/c(cid:17) from Theorem 4 is replaced by O(cid:16) lg2 u (13) u1/c(cid:17) which is small The important difference is that the bias O(cid:16) lg2 n regardless of the set size. Such an absolutely small bias generally requires Ω(log u)-independence [40]. Short range amortization for chaining and linear probing We now switch to a quite different illustra- tion of the power of twisted tabulation hashing from [42]. Consider linear probing in a half-full hash table with n keys. Out of √n operations, we expect some to take Ω(log n) time. Nevertheless we show that any window of log n operations on distinct keys is executed in O(lg n) time with high probability. This also holds for the simpler case of chaining. The general point is that for any set of stored keys and any set of window keys, the operation times within the window are sufficiently independent that the average concentrates nicely around the expected constant operation time. Such concentration of the average should not be taken for granted with real hash functions. In [40] are input examples for linear probing with multiplication-shift hashing [16] such that if one operation is slow, then most operations are slow. In [42] is presented a parallel universe construction causing similar problems for simple tabulation. As stated above, twisted tabulation does, however, provide sufficient independence, and we expect this to prove useful in other applications. Pseudo-random numbers generators Like any hash function, twisted tabulation naturally implies a pseudo-random numbers generators (PRG) with the pseudo-random sequence h(0), h(1), . . .. For maximal efficiency, we use the last and least significant character as the head. Thus, a key x = (xc−1, . . . , x0) ∈ Σc has head(x) = x0 and tail(x) = x>0 = (xc−1, . . . , x1). For twisted tabulation, we use a simple tabulation function h⋆ : Σc−1 → Σ × [2r] and a character function h0 : Σ → [2r], and then h(x) is computed, setting (t, h>0) = h⋆(x>0) and h(x) = h0[x0 ⊕ t]⊕ h>0. We now think of x as the pair (x>0, x0) ∈ Σc−1 × Σ. As we increase the index x = 0, 1, . . . , Σ − 1, Σ, Σ + 1, . . . = (0, 0), (0, 1), . . . , (0, Σ − 1), (1, 0), (1, 1), . . ., the tail x>0 only increases when x0 wraps around to 0-once in every Σ calls. We therefore store (t, h>0) = h⋆(x>0) in a register, recomputing it only when x>0 increases. Otherwise we compute h(x) = h0[x0 ⊕ t]⊕ h>0 using just one character lookup and two ⊕-operations. We found this to be exceedingly fast: as fast as 11 a single multiplication and 4 times faster than the standard random number generator random() from the GNU C library which has almost no probabilistic guarantees. Besides being faster, the twisted PRG offers the powerful distributional guarantees discussed above. As an alternative implementation, we note that h⋆ is itself applied to consecutive numbers x>0 = 0, 1, 2, . . ., so h⋆ can also be implemented as a PRG. The h⋆-PRG is only applied once for every Σ numbers generated by h, so the h⋆-PRG can be much slower without affecting the overall performance. Instead of implementing h⋆ by simple tabulation, we could implement it with any logarithmically independent PRG, thus not storing any tables for h⋆, but instead generating each new value h⋆(x>0) on the fly as x>0 increases. We can view this as a general conversion of a comparatively slow but powerful PRG into an extremely fast one preserving the many probabilistic properties of twisted tabulation. The recent PRG of Christiani and Pagh [11] would be a good choice for the h⋆-PRG if we do not want to implement it with simple tabulation. Randomized Algorithms and Data Structures When using the twisted PRG in randomized algorithms [36], we get the obvious advantage of the Chernoff-style bounds from Theorem 5 which is one of the basic techniques needed [36, §4]. The ε-minwise hashing from Theorem 6 with ε = eO(1/u1/c) is important in contexts where we want to assign randomized priorities to items. A direct example is treaps [44]. The classic analysis [36, §8.2] of the expected operation time is based on each key in an interval having the same chance of getting the lowest priority. Assigning the priorities with an ε-minwise hash function, expected cost is only increased by a factor (1 + ε) compared with the unrealistic case of true randomness. In static settings, we can also use this to generate a random permutation, sorting items according to priorities. This sorting itself takes linear time since we essentially only need to look at the log n most significant bits to sort n priorities. Using this order to pick items, we get that classic algorithms like QuickSort [36, §1] and Binary Planar Partitions [36, §1.3] perform within an expected factor (1 + ε) of what they would with true randomness. With ε = eO(1/u1/c) as with our twisted PRG, this is very close the expected performance with true randomness. 4 Double tabulation and high independence Thorup [50] has shown that simple tabulation can also be used to get high independence if we apply it twice. More precisely, we consider having two independent simple tabulation functions h0 : Σc → Σd and h1 : Σd → [2r], and then the claim is that h1 ◦ h0 is likely to be highly independent. The main point from [50] is that the first simple tabulation h0 is likely to have an expander-type property. More precisely, given a function f : [u] → Σd, a key set X ⊆ [u] has a unique output character if there is a key x ∈ X and a j ∈ [d] and such that for all y ∈ X \ {x}, h(y)j 6= h(x)j, that is, the jth output character is unique to some x in X. We say that f is k-unique if each non-empty key set Y ⊆ [u] of size at most k has a unique output character. Siegel [46] noted that if f is k-unique and h1 : Σd → [2r] is a random simple tabulation function, then h1 ◦ f : [u] → [2r] is k-independent. The main technical result from [50] is Theorem 7 ([50]) Consider a random simple tabulation function h0 : Σc → Σd. Assume c = Σo(1) and (c + d)c = Σo(1). Let k = Σ1/(5c). With probability 1 − o(Σ2−d/(2c)), the function h0 is k-unique. More concretely for 32-bit keys with 16-bit characters, h0 is 100-unique with probability 1 − 1.5 × 10−42. Assuming that h0 is k-unique, if h1 : Σd → [2r] is a random simple tabulation function, then h1 ◦ h0 is k-independent. This construction for highly independent hashing is much simpler than that of Siegel [46] mentioned in Section 1, and for d = O(c), the evaluation takes O(c) time as opposed to the O(c)c time used by Siegel. 12 Complementing the above result, Dahlgaard et al. [13] have proved that double tabulation is likely to be truly random for any specific set S with less than (1 − Ω(1))Σ keys: Theorem 8 ([13]) Given a set S ⊆ [u] of size (1− Ω(1))Σ, consider two random simple tabulation function h0 : Σc → Σd and h1 : Σd → [2r]. With probability 1 − O(Σ1−⌊d/2⌋), every non-empty subset X ⊆ S gets a unique output character with h0, and then the double tabulation function h1 ◦ h0 is fully random over S. It is interesting to compare Theorem 8 and Theorem 7. Theorem 8 holds for one large set while Theorem 7 works for all small sets. Also, Theorem 8 with d = 4 "derived" characters gets essentially the same error probability as Theorem 7 with d = 6c derived characters. Siegel [46] has proved that with space Σ, we cannot in constant time hope to get independence higher than Σ1−Ω(1), which is much less than the size of the given set in Theorem 8. Theorem 8 provides an extremely simple O(n) space implementation of a constant time hash function that is likely uniform on any given set S. This should be compared with the previous linear space uni- form hashing of Pagh and Pagh [37, §3]. The most efficient implementation of [37, §3] uses the highly independent double tabulation from Theorem 7 a subroutine. However, as discussed earlier, double tabu- lation uses much more derived characters for high independence than for uniformity on a given set, so for linear space uniform hashing on a given set, it is much faster and simpler to use the double tabulation of Theorem 8 directly. We note that [37, §4] presents a general trick to reduce the space from linear, that is, O(n(lg n + lg R)) bits, downto (1 + ε)n lg R + O(n) bits, preserving the constant evaluation time. This reduction can also be applied to Theorem 8 so that we also get a simpler overall construction for a succinct dictionary using (1 + ε)n lg R + O(n) bits of space and constant evaluation time. scheme can get quite to Siegel's lower-bound. Very recently, Christiani et al. [12] have shown that we using a more elaborate recursive tabulation Theorem 9 ([12, Corollary 3]) For word-size w, and parameters k and c = O(w/(log k)), with probability 1− u1/c, we can construct a k-independent hash function h : [2w] → [2w] in O(cku1/c) time and space that is evaluated in O(c log c) time. In Theorem 8, we used the same space to get independence Σ1/(5c) and evaluation time O(c), and the construction of Theorem 8 is simpler. We should thus use Theorem 9 if we need its very high independence, but if, say, logarithmic independence suffices, then Theorem 8 is the better choice. A major open problem is get the space and independence of Theorem 9 but with O(c) evaluation time, matching the lower bound of [46]. In its full generality, the lower bound from [46] says that we for indepen- dence k with c < k cell probes need space Ω(k(u/k)1/cc). Invertible Bloom filters with simple tabulation Theorem 8 states that if a random simple tabulation function h0 : Σc → Σd is applied to a given set S of size (1−Ω(1))Σ, then with probability 1−O(Σ1−⌊d/2⌋), every non-empty subset X ⊆ S gets a unique output character. This is not only relevant for fully-random hashing. This property is also sufficient for the hash function in Goodrich and Mitzenmacher's Invertible Bloom Filters [25], which have found numerous applications in streaming and data bases [21, 22, 35]. So far Invertible Bloom Filters have been implemented with fully random hashing, but Theorem 8 shows that simple tabulation suffices for the underlying hash function. 4.1 k-partitions via mixed tabulation The general goal of Dahlgaard et al. [13] is a hash function for k-partitioning a set into bins so that we get good concentration bounds when combining statistics from each bin. 13 To understand this point, suppose we have a fully random hash function applied to a set X of red and blue balls. We want to estimate the fraction f of red balls. The idea of Minwise hashing is to sample the ball with the smallest hash value. This sample is uniformly random and is red with probability f . If we repeat the experiment k times with k independent hash functions, we get a multiset S of k samples with replacement from X and the fraction red balls in S concentrates around f as we increase the number of samples. Consider the alternative experiment using a single hash function, where we use some bits of the hash value to partition X into k bins, and then use the remaining bits as a local hash value. We pick the ball with the smallest hash value in each bin. This is a sample S from X without replacement, and again, the fraction of red balls is concentrated around f . The big difference between the two schemes is that the second one runs Ω(k) times faster. In the first experiment, each ball participated in k independent experiments, but in the second one with k-partitions, each ball picks its bin, and then only participates in the local experiment for that bin. Thus with the k- partition, essentially, we get k experiments for the price of one. This generic idea has been used for different types of statistics. Flajolet and Martin [23] introduced it to count the number of distinct items in a multiset, Charikar et al. [10] used it in their count sketches for fast estimation of the second moment of a data stream, and recently, Li et al. [32, 45] used it for Minwise estimation of the Jaccard Similarity of two sets. The issue is that no realistic hashing scheme was known to make a good enough k-partition for the above kind of statistics to make sense. The point is that the contents of different bins may be too correlated, and then we get no better concentration with a larger k. In the independence paradigm of Carter and Weg- man [52], it would seem that we need independence at least k to get sufficiently independent statistics from the different bins. An efficient solution is based on a variant of double tabulation described below. Mixed tabulation For Theorem 8 we may use d = 4 even if c is larger, but then h0 will introduce many collisions. To avoid this problem we mix the schemes in mixed tabulation. Mathematically, we use two simple tabulation hash functions h1 : [u] → Σd and h2 : Σc+d → [2r], and define the hash function h(x) 7→ h2(x ◦ h1(x)), where ◦ denotes concatenation of characters. We call x ◦ h1(x) the derived key, consisting of c original characters and d derived characters. Since the derived keys includes the original keys, there are no duplicate keys. We note that mixed tabulation only requires c + d lookups if we instead store simple tabulation functions 2 : Σd → [r], computing h(x) by (v1, v2) = h1,2(x); h(x) = v1 ⊕ h2(v2). This h1,2 : Σc → Σd × [r] and h′ efficient implementation is similar to that of twisted tabulation, and is equivalent to the previous definition. As long as we have at least one derived character, mixed tabulation has all the distribution properties of twisted tabulation, particularly, the Chernoff-style concentration bound from Theorem 5. At the same time, we get the full randomness from Theorem 8 for any given set S of size (1 − Ω(1))Σ. Based on these properties and more, it is proved in [13] that mixed tabulation, w.h.p., gets essentially the same concentration bounds as full randomness for all of the above mentioned statistics based on k-partitions. References [1] N. Alon, M. Dietzfelbinger, P. B. Miltersen, E. Petrank, and G. Tardos. Linear hash functions. J. ACM, 46(5):667–683, 1999. 14 [2] N. Alon, Y. Matias, and M. Szegedy. The space complexity of approximating the frequency moments. Journal of Computer and System Sciences, 58(1):209–223, 1999. Announced at STOC'96. [3] N. Alon and A. Nussboim. k-wise independent random graphs. In Proc. 49th IEEE Symposium on Foundations of Computer Science (FOCS), pages 813–822, 2008. [4] Y. Azar, A. Z. Broder, A. R. Karlin, and E. Upfal. Balanced allocations. SIAM Journal on Computing, 29(1):180–200, 1999. Announced at STOC'94. [5] J. R. Black, C. U. Martel, and H. Qi. Graph and hashing algorithms for modern architectures: Design and performance. In Proc. 2nd International Workshop on Algorithm Engineering (WAE), pages 37– 48, 1998. [6] V. Braverman, K.-M. Chung, Z. Liu, M. Mitzenmacher, and R. Ostrovsky. AMS without 4-wise In Proc. 27th Symposium on Theoretical Aspects of Computer independence on product domains. Science (STACS), pages 119–130, 2010. [7] A. Z. Broder, M. Charikar, A. M. Frieze, and M. Mitzenmacher. Min-wise independent permutations. Journal of Computer and System Sciences, 60(3):630–659, 2000. Announced at STOC'98. [8] A. Z. Broder, S. C. Glassman, M. S. Manasse, and G. Zweig. Syntactic clustering of the web. Computer Networks, 29:1157–1166, 1997. [9] L. Carter and M. N. Wegman. Universal classes of hash functions. Journal of Computer and System Sciences, 18(2):143–154, 1979. Announced at STOC'77. [10] M. Charikar, K. Chen, and M. Farach-Colton. Finding frequent items in data streams. In Proc. 29th International Colloquium on Automata, Languages and Programming (ICALP), pages 693–703. Springer-Verlag, 2002. [11] T. Christiani and R. Pagh. Generating k-independent variables in constant time. In Proceedings of the 55th IEEE Symposium on Foundations of Computer Science (FOCS), pages 196–205, 2014. [12] T. Christiani, R. Pagh, and M. Thorup. From independence to expansion and back again. In Proceed- ings of the 47th ACM Symposium on Theory of Computing (STOC), pages 813–820, 2015. [13] S. Dahlgaard, M. B. T. Knudsen, E. Rotenberg, and M. Thorup. Hashing for statistics over k-partitions. In Proceedings of the 56th IEEE Symposium on Foundations of Computer Science (FOCS), pages 1292–1310, 2015. [14] S. Dahlgaard, M. B. T. Knudsen, E. Rotenberg, and M. Thorup. The power of two choices with simple tabulation. In Proceedings of the 27th ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1631–1642, 2016. [15] S. Dahlgaard and M. Thorup. Approximately minwise independence with twisted tabulation. In Proc. 14th Scandinavian Workshop on Algorithm Theory (SWAT), pages 134–145, 2014. [16] M. Dietzfelbinger. Universal hashing and k-wise independent random variables via integer arithmetic without primes. In Proc. 13th Symposium on Theoretical Aspects of Computer Science (STACS), pages 569–580, 1996. 15 [17] M. Dietzfelbinger, T. Hagerup, J. Katajainen, and M. Penttonen. A reliable randomized algorithm for the closest-pair problem. Journal of Algorithms, 25(1):19–51, 1997. [18] M. Dietzfelbinger and F. Meyer auf der Heide. A new universal class of hash functions and dynamic hashing in real time. In Proc. 17th International Colloquium on Automata, Languages and Program- ming (ICALP), pages 6–19, 1990. [19] M. Dietzfelbinger and U. Schellbach. On risks of using cuckoo hashing with simple universal hash classes. In Proc. 20th ACM/SIAM Symposium on Discrete Algorithms (SODA), pages 795–804, 2009. [20] M. Dietzfelbinger and P. Woelfel. Almost random graphs with simple hash functions. In Proc. 25th ACM Symposium on Theory of Computing (STOC), pages 629–638, 2003. [21] D. Eppstein and M. T. Goodrich. Straggler identification in round-trip data streams via newton's identi- ties and invertible bloom filters. Knowledge and Data Engineering, IEEE Transactions on, 23(2):297– 306, 2011. [22] D. Eppstein, M. T. Goodrich, F. Uyeda, and G. Varghese. What's the difference?: efficient set recon- ciliation without prior context. ACM SIGCOMM Computer Communication Review, 41(4):218–229, 2011. [23] P. Flajolet and G. N. Martin. Probabilistic counting algorithms for data base applications. Journal of Computer and System Sciences, 31(2):182–209, 1985. [24] M. L. Fredman, J. Koml´os, and E. Szemer´edi. Storing a sparse table with 0(1) worst case access time. Journal of the ACM, 31(3):538–544, 1984. Announced at FOCS'82. [25] M. T. Goodrich and M. Mitzenmacher. Invertible bloom lookup tables. In Proceedings of the 49th Allerton Conference on Communication, Control, and Computing, pages 792–799, 2011. [26] G. L. Heileman and W. Luo. How caching affects hashing. In Proc. 7th Workshop on Algorithm Engineering and Experiments (ALENEX), pages 141–154, 2005. [27] P. Indyk. A small approximately min-wise independent family of hash functions. Journal of Algo- rithms, 38(1):84–90, 2001. Announced at SODA'99. [28] D. M. K. Jeffery S. Cohen. Bounds on the independence required for cuckoo hashing, 2009. Manuscript. [29] H. J. Karloff and P. Raghavan. Randomized algorithms and pseudorandom numbers. Journal of the ACM, 40(3):454–476, 1993. [30] D. E. Knuth. Notes on open addressing. Unpublished memorandum. See http://citeseer.ist.psu.edu/knuth63notes.html, 1963. [31] D. E. Knuth. The Art of Computer Programming, Volume III: Sorting and Searching. Addison-Wesley, 1973. [32] P. Li, A. B. Owen, and C.-H. Zhang. One permutation hashing. In Proc. 26th Conference on Neural Information Processing Systems (NIPS), pages 3122–3130, 2012. 16 [33] M. Mitzenmacher, A. W. Richa, and R. Sitaraman. The power of two random choices: A survey of techniques and results. In P. Pardalos, S. Rajasekaran, and J. Rolim, editors, Handbook of Randomized Computing: volume 1, pages 255–312. Springer, 2001. [34] M. Mitzenmacher and S. P. Vadhan. Why simple hash functions work: exploiting the entropy in a data stream. In Proc. 19th ACM/SIAM Symposium on Discrete Algorithms (SODA), pages 746–755, 2008. [35] M. Mitzenmacher and G. Varghese. Biff (bloom filter) codes: Fast error correction for large data sets. In Information Theory Proceedings (ISIT), 2012 IEEE International Symposium on, pages 483–487. IEEE, 2012. [36] R. Motwani and P. Raghavan. Randomized Algorithms. Cambridge University Press, 1995. [37] A. Pagh and R. Pagh. Uniform hashing in constant time and optimal space. SIAM Journal on Comput- ing, 38(1):85–96, 2008. [38] A. Pagh, R. Pagh, and M. Ruzi´c. Linear probing with constant independence. SIAM Journal on Computing, 39(3):1107–1120, 2009. Announced at STOC'07. [39] R. Pagh and F. F. Rodler. Cuckoo hashing. Journal of Algorithms, 51(2):122–144, 2004. Announced at ESA'01. [40] M. Patras¸cu and M. Thorup. On the k-independence required by linear probing and minwise indepen- dence. In Proc. 37th International Colloquium on Automata, Languages and Programming (ICALP), pages 715–726, 2010. [41] M. Patras¸cu and M. Thorup. The power of simple tabulation-based hashing. Journal of the ACM, 59(3):Article 14, 2012. Announced at STOC'11. [42] M. Patras¸cu and M. Thorup. Twisted tabulation hashing. In Proc. 24th ACM/SIAM Symposium on Discrete Algorithms (SODA), pages 209–228, 2013. [43] J. P. Schmidt, A. Siegel, and A. Srinivasan. Chernoff-Hoeffding bounds for applications with limited independence. SIAM Journal on Discrete Mathematics, 8(2):223–250, 1995. Announced at SODA'93. [44] R. Seidel and C. R. Aragon. Randomized search trees. Algorithmica, 16(4/5):464–497, 1996. An- nounced at FOCS'89. [45] A. Shrivastava and P. Li. Densifying one permutation hashing via rotation for fast near ne ighbor search. In Proc. 31th International Conference on Machine Learning (ICML), pages 557–565, 2014. [46] A. Siegel. On universal classes of extremely random constant-time hash functions. SIAM Journal on Computing, 33(3):505–543, 2004. Announced at FOCS'89. [47] M. Thorup. Even strongly universal hashing is pretty fast. In Proc. 11th ACM/SIAM Symposium on Discrete Algorithms (SODA), pages 496–497, 2000. [48] M. Thorup. String hashing for linear probing. In Proc. 20th ACM/SIAM Symposium on Discrete Algorithms (SODA), pages 655–664, 2009. [49] M. Thorup. Timeouts with time-reversed linear probing. In Proc. IEEE INFOCOM, pages 166–170, 2011. 17 [50] M. Thorup. Simple tabulation, fast expanders, double tabulation, and high independence. In Proc. 54th IEEE Symposium on Foundations of Computer Science (FOCS), pages 90–99, 2013. [51] M. Thorup and Y. Zhang. Tabulation-based 5-independent hashing with applications to linear probing and second moment estimation. SIAM Journal on Computing, 41(2):293–331, 2012. Announced at SODA'04 and ALENEX'10. [52] M. N. Wegman and L. Carter. New classes and applications of hash functions. Journal of Computer and System Sciences, 22(3):265–279, 1981. Announced at FOCS'79. [53] A. L. Zobrist. A new hashing method with application for game playing. Technical Report 88, Com- puter Sciences Department, University of Wisconsin, Madison, Wisconsin, 1970. A Conditioning on the hash value of a query key We are here going to argue that the Chernoff-style bounds from Theorem 5 hold when we for a given query key q and hash value a condition everything on h(q) = a. This will be a simple extension of the proof of Theorem 5 in [42, §3] without the condition. Below we first describe the essential points from the proof in [42, §3], referring the reader to [42, §3] for more details. Afterwards we describe the extension to handle the condition. No conditioning. In [42, §3], the twisted tabulation hash function is picked in 3 steps. 1. We randomly fix hT twisting the keys. This defines the twisted groups Gα consisting of keys with the same twisted head α. 2. We randomly fix the hS i , i > 0, hashing the tails of the keys. 3. We randomly fix hS 0 , hashing the twisted heads. This finalizes the twisted tabulation hashing h = hS ◦ hT. Let Vα =Px∈Gα vx(h(x)) be the total value of keys in twisted group Gα. The main technical point in [42, §3] is to prove that, w.h.p., after step 2, we will have Vα ≤ d = O(1) no matter how we fix hS this holds simultaneously for all twisted groups. While hS every x ∈ Gα, so the expected value µα = E[Vα] = Px∈Gα µx over Gα is unchanged before step 3. It also follows from [42, §3] that µα ≤ d. Our final value is V = Pα∈Σ Vα which still has the correct mean E[V ] = µ. Moreover, V is Chernoff-concentrated since it is summing d-bounded variables Vα as we fix the hS 0 [α] in step 3. We are here ignoring some technicalities explained in [41, 42], e.g., how to formally handle if some variable Vα is not d-bounded. 0 [α], and 0 [α] has not been fixed, h(x) is uniform in [u] for Conditioning on h(q) = a. We now consider the effects of the condition h(q) = a. First we note that since twisted tabulation is 2-independent, the condition h(q) = a does not affect the expected value µx = E[vx(h(x))] of any key x 6= q. Now, for the above step-wise fixing of the twisted tabulation hash function, we note that the only effect of the condition h(q) = a is in step 3. If α0 is the twisted head of the query key, then instead of picking 0 [α0] at random, we have to fix it as hS hS i [qi]. Since the first steps were not affected, i=1 hS 0 [α0] = a ⊕Lc−1 18 w.h.p, for all α ∈ Σ, we still have that Vα ≤ d = O(1) no matter how we fix hS twisted head α0. 0 [α], and this includes the We are now again considering V = Pα∈Σ Vα where each Vα is d-bounded. For all α 6= α0, we have E[Vα] = µα. However, Vα0 is fixed to some value in [0, d] when we after steps 1–2 are forced to set 0 [α0] = a ⊕Lc−1 hS i [qi]. The error Vα0 − µα0 from this fixing is less than d, and this has no effect on our error probability bounds except in cases where Markov's bound takes over. However, Markov's bound holds directly for twisted tabulation without any of the above analysis. Thus we conclude that Theorem 5 holds also when we condition on h(q) = a. i=1 hS 19
1910.14344
1
1910
2019-10-31T10:09:17
Computing and Testing Small Connectivity in Near-Linear Time and Queries via Fast Local Cut Algorithms
[ "cs.DS" ]
Consider the following "local" cut-detection problem in a directed graph: We are given a seed vertex $x$ and need to remove at most $k$ edges so that at most $\nu$ edges can be reached from $x$ (a "local" cut) or output $\bot$ to indicate that no such cut exists. If we are given query access to the input graph, then this problem can in principle be solved without reading the whole graph and with query complexity depending on $k$ and $\nu$. In this paper we consider a slack variant of this problem where, when such a cut exists, we can output a cut with up to $O(k\nu)$ edges reachable from $x$. We present a simple randomized algorithm spending $O(k^2\nu)$ time and $O(k\nu)$ queries for the above variant, improving in particular a previous time bound of $O(k^{O(k)}\nu)$ by Chechik et al. [SODA '17]. We also extend our algorithm to handle an approximate variant. We demonstrate that these local algorithms are versatile primitives for designing substantially improved algorithms for classic graph problems by providing the following three applications. (Throughout, $\tilde O(T)$ hides $\operatorname{polylog}(T)$.) (1) A randomized algorithm for the classic $k$-vertex connectivity problem that takes near-linear time when $k=O(\operatorname{polylog}(n))$, namely $\tilde O(m+nk^3)$ time in undirected graphs. For directed graphs our $\tilde O(mk^2)$-time algorithm is near-linear when $k=O(\operatorname{polylog}(n))$. Our techniques also yield an improved approximation scheme. (2) Property testing algorithms for $k$-edge and -vertex connectivity with query complexities that are near-linear in $k$, exponentially improving the state-of-the-art. This resolves two open problems, one by Goldreich and Ron [STOC '97] and one by Orenstein and Ron [Theor. Comput Sci. '11]. (3) A faster algorithm for computing the maximal $k$-edge connected subgraphs, improving prior work of Chechik et al. [SODA '17].
cs.DS
cs
Computing and Testing Small Connectivity in Near-Linear Time and Queries via Fast Local Cut Algorithms∗ Sebastian Forster†1, Danupon Nanongkai2, Thatchaphol Saranurak3, Liu Yang4, and Sorrachai Yingchareonthawornchai‡5 1University of Salzburg, Austria 2KTH Royal Institute of Technology, Sweden 3Toyota Technological Institute at Chicago, USA 4Independent Researcher 5Aalto University, Finland Abstract Consider the following "local" cut-detection problem in a directed graph: We are given a seed vertex x and need to remove at most k edges so that at most ν edges can be reached from x (a "local" cut) or output ⊥ to indicate that no such cut exists. If we are given query access to the input graph, then this problem can in principle be solved without reading the whole graph and with query complexity depending on k and ν. In this paper we consider a slack variant of this problem where, when such a cut exists, we can output a cut with up to O(kν) edges reachable from x. We present a simple randomized algorithm spending O(k2ν) time and O(kν) queries for the above variant, improving in particular a previous time bound of O(kO(k)ν) by Chechik et al. [SODA '17]. We also extend our algorithm to handle an approximate variant. We demonstrate that these local algorithms are versatile primitives for designing substantially improved algorithms for classic graph problems by providing the following three applications. (Throughout, O(T) hides polylog(T).) 1. A randomized algorithm for the classic k-vertex connectivity problem that takes near-linear time when k = O(polylog(n)), namely O(m + nk3) time in undirected graphs. Prior to our work, the state of the art for this range of k were linear-time algorithms for k ≤ 3 [Tarjan FOCS '71; Hopcroft, Tarjan SICOMP '73] and a recent algorithm with O(m + n4/3k7/3) time [Nanongkai et al. STOC '19]. The story is the same for directed graphs where our O(mk2)-time algorithm is near-linear when k = O(polylog(n)). Our techniques also yield an improved approximation scheme. 2. Property testing algorithms for k-edge and -vertex connectivity with query complexities that are near-linear in k, exponentially improving the state-of-the-art. This resolves two open problems, one by Goldreich and Ron [STOC '97] and one by Orenstein and Ron [Theor. Comput. Sci. '11]. 3. A faster algorithm for computing the maximal k-edge connected subgraphs, improving prior work of Chechik et al. [SODA '17]. 9 1 0 2 t c O 1 3 ] S D . s c [ 1 v 4 4 3 4 1 . 0 1 9 1 : v i X r a ∗This paper resulted from a merge of two papers submitted to arXiv [FY19, NSY19b] and will be presented at the 31st Annual ACM-SIAM Symposium on Discrete Algorithms (SODA 2020). †This author previously published under the name Sebastian Krinninger. Work partially done while at Max Planck Institute for Informatics and while at University of Vienna. ‡Work partially done while at Michigan State University, USA. 1 Contents 1 Introduction 2 Preliminaries 3 Local Edge Connectivity 4 Local Vertex Connectivity 4.1 Reducing from Vertex to Edge Connectivity . . . . . . . . . . . . . . . . . . . . 4.2 Proof of Theorem 4.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Vertex Connectivity 5.1 Undirected Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2 Directed Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Property Testing . . . . . . . . . . . . . 6.1 Testing k-Edge Connectivity: Unbounded-Degree Model . . . . . . . . . . . . . . 6.2 Testing k-Edge Connectivity: Bounded-Degree Model 6.3 Testing k-Vertex Connectivity: Unbounded-Degree Model . . . . . . . . . . . . 6.4 Testing k-Vertex Connectivity: Bounded-Degree Model . . . . . . . . . . . . . . 7 Maximal k-Edge Connected Subgraphs 7.1 Directed Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2 Undirected Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A An Alternative Algorithm for Local Edge Connectivity References 3 8 8 12 13 15 15 17 17 18 18 23 25 29 31 31 33 35 37 2 1 Introduction We study a natural "local" version of the problem of finding an edge cut of bounded size with applications to higher connectivity: given a seed vertex x, detect a "small" component containing x with less than k outgoing edges (if it exists). More precisely, given a vertex x and two integers ν and k, our object of interest is a set L ⊆ V such that x ∈ L, E(L, V − L) < k, and volout(L) ≤ ν , (1) where E(L, V − L) is the set of edges from vertices in L to vertices outside of L, and volout(L) is the outgoing volume of L, the total number of outgoing edges for vertices in L. In particular, we will allow some slack in finding such a set. For the problem we study, the input consists of x, k, ν, and a pointer to an adjacency-list representation of G, and an algorithm either • returns a vertex set S such that E(S, V − S) < k, or • outputs that no L ⊆ V satisfying Equation (1) exists. This problem, which we call LocalEC, has implicitly been studied before in the context of property testing [GR02, OR11] and for developing a centralized algorithm that computes the maximal k-edge connected subgraphs of a directed graph [Che+17]. Recently, a variant for vertex cuts has been studied for obtaining faster vertex connectivity algorithms [NSY19a]. A somewhat similar problem of locally detecting a small component with low-conductance has recently been studied extensively [KT19, HRW17, SW19], in particular to obtain centralized algorithms for deterministically computing the edge connectivity of an undirected graph. In this paper, we present a simple randomized (Monte Carlo) algorithm for the problem above that takes O(νk2) time and makes O(νk) edge queries. Theorem 1.1 (Main Result). There is a randomized (Monte Carlo) algorithm that takes as input a vertex x ∈ V of an n-vertex m-edge graph G = (V, E) represented as adjacency lists, and integers k and ν such that k < ν < m/(130k), which accesses (i.e., makes queries for) O(νk) edges and runs in O(νk2) time to output either (i) the symbol "⊥" to indicate that no such L exists, or (ii) a set S ⊆ V such that E(S, V − S) < k in the following manner: • If L ⊆ V satisfying (1) exists, the algorithm outputs a set S as specified above with probability at least 3/4. With probability at most 1/4, it (incorrectly) outputs ⊥. • Otherwise, it outputs either a set S as specified above or ⊥. Note that the error probability 1/4 above can be made arbitrarily small by repeating the algorithm. Our result in particular improves the previous deterministic time bound of O(kO(k)ν) by Chechik et al. [Che+17]. It furthermore needs to be compared to a local variant [GR02] of Karger's randomized cut algorithm [Kar00] for undirected graphs which finds a set L with E(S, V − S) < k of size L ≤ σ (where σ is a given parameter) and volume at most ν in time O(σ2−2/kν) (if such a set exists). Our algorithm is in fact very simple: it repeatedly finds a path starting at x and ending at some random vertex. Our analysis is also very simple. Besides local computation algorithms being an object of study of independent inter- est [Rub+11, LM17], the significance of our contribution is illustrated by the fact that it almost readily implies faster algorithms for several problems in higher connectivity, as described below. 3 (Global) Vertex Connectivity. The main application of our result is efficient algorithms for the vertex connectivity problem. There has been a long line of research on this problem since at least five decades ago (e.g. [Kle69, Pod73, ET75, Eve75, Gal80, EH84, Mat87, Bec+82, LLW88, CT91, NI92, CR94, Hen97, HRG00, Gab06, CGK14]). (See Nanongkai et al. [NSY19a] for a more comprehensive literature survey.) For the undirected case, Aho, Hopcroft and Ullman [AHU74, Problem 5.30] asked in their 1974 book for an O(m)-time algorithm for computing κG, the vertex connectivity of graph G. Prior to our result, O(m)-time algorithms were known only when κG ≤ 3, due to the classic results of Tarjan [Tar72] and Hopcroft and Tarjan [HT73]. In this paper, we present an algorithm that takes near-linear time whenever κG = O(polylog(n)). Theorem 1.2. There is a randomized (Monte Carlo) algorithm that takes as input an undirected graph and, with high probability, in time O(m + nκ3) outputs a vertex cut S of size κ.1 The above result is near-linear time whenever κ = O(polylog(n)). By combining with previous results (e.g., [HRG00, LLW88]), the best running time for solving vertex connectivity in undirected graphs now is O(m + min{nκ3, n2κ, nω + nκω}). Prior to our work, the best running time for κ > 3 was O(m + min{n4/3κ7/3, n2κ, nω + nκω}) [NSY19a, HRG00, LLW88] where ω ≤ 2.3728 is the current matrix-multiplication exponent. In particular, we have an improved running time when κ ≤ O(n0.457). Table 1 gives an overview of all these results. Graph class directed directed directed directed directed undirected undirected undirected undirected undirected Running time O(min{n3/4, κ3/2} · κm + mn) O(mn) O(nω + nκω) O(κ · min{m2/3n, m4/3}) O(κ · min{nκ2 + m1/2nκ1/2, mκ}) O(min{n3/4, κ3/2} · κ2n + κn2) O(κn2) O(nω + nκω) O(m + κ7/3n4/3) O(m + κ3n) Deterministic Reference yes no no no no yes no no no no [Gab06] [HRG00] [CR94] [NSY19a] here [Gab06] [HRG00] [LLW88] [NSY19a] here Table 1: Comparison of algorithms for computing the vertex connectivity κ. This result is obtained essentially by using our LocalEC algorithm to solve the local vertex connectivity problem (LocalVC) that was recently studied by Nanongkai, Saranurak, and Yingchareonthawornchai [NSY19a], and then plugging this algorithm into the recent framework of [NSY19a]. The overall algorithm is fairly simple: Let L be one side of the optimal vertex cut M, i.e., M consists of the neighbors of L. We guess the values ν = vol(L) and k = κ, and run our LocalVC algorithm with parameters ν and k on n/ν randomly-selected seed vertices x. Approximation Algorithms and Directed Graphs. The results in Theorems 1.1 and 1.2 can be generalized to (1 + )-approximation algorithms and to algorithms on directed graphs. The approximation guarantee means that the output vertex cut S is of size less than b(1 + )kc. 1As usual, with high probability (w.h.p.) means with probability at least 1 − 1/nc for an arbitrary constant c ≥ 1. 4 κ/ poly()}). In particular, the time complexity for locally computing a vertex cut (LocalVC) is O(νk/).2 √ k1.5))-time algorithm of Nanongkai et al. [NSY19a] when ν ≥ k3/. This improves the O(ν1.5/( For computing κ exactly, our time complexity is O(κ · min{nκ2 + m1/2nκ1/2, mκ}), and for approximating κ, it is O(min{mκ/, n2+o(1)√ Testing Vertex- and Edge- Connectivity. The study of testing graph properties, initiated by Goldreich et al. [GGR98], concerns the number of queries made to answer questions about graph properties. In the (unbounded-degree) incident-lists model [GR02, OR11], it is assumed that there is a list Lv of edges incident to each vertex v (or lists of outgoing and incoming edges for directed graphs), and an algorithm can make a query q(v, i) for the ith edge in the list Lv (if i is bigger than the list size, the algorithm receives a special symbol in return). For any  > 0, we say that an m-edge graph G is -far from having a property P if the number of edge insertions and deletions to make G satisfy P is at least m. Testing k-vertex connectivity is the problem of distinguishing between G being k-vertex connected and G being -far from having this property. Testing k-edge connectivity is defined analogously. It is assumed that the algorithm receives n, , and k in the beginning. We show the following. Theorem 1.3. In the unbounded-degree incident-list model, k-vertex and -edge connectivity (where k = O(n)) for directed graphs can be tested with O(k/2) queries with probability at least 2/3. Further, k-edge connectivity for simple directed graphs can be tested with O(min{k/2, 1/3}) queries. In particular, our O(k/2) bound is linear in k, and it can be independent of k for testing k-edge connectivity on simple graphs. In the bounded-degree incident-list model, the maximum degree d is assumed to be given to the algorithm and a graph is said to be -far from a property P if it needs at least nd edge modifications to have this property. We show the following. Theorem 1.4. In the bounded-degree incident-list model, k-vertex and -edge connectivity (where k = O(n)) for directed graphs can be tested with O(k/) queries with probability at least 2/3. Further, k-edge connectivity for simple directed graphs can be tested with O(min{k/, 1/2}) queries. It has been open for many years whether the bounds from [OR11, YI10, YI12] which are exponential in k can be made polynomial (this was asked in e.g. [OR11]). We answer this question affirmatively with bounds near-linear in k using our local approximation algorithms. We additionally solve the open problem of Goldreich and Ron [GR02] of improving the local version of Karger's cut algorithm for undirected graphs in the parameter range most relevant to property testing. Detailed comparisons: To precisely compare our bounds with the previous ones, note that there are two sub-models: (i) In the unbounded-degree incident-list model, previous work assumes that d = m/n is known to the algorithm in the beginning. (ii) in the bounded-degree incident-list model, the maximum degree d is assumed to be given to the algorithm and a graph is said to be -far from a property P if it needs at least nd edge modifications to have this property. Our O(k/2) bound can be generalized to a O(k2/(2d)) bound in the unbounded-degree model. Similarly, our O(min{k/2, 1/3}) bound can be generalized to a O(min{k2/(d2), k/(d3)}) 2In Theorem 3.1, we will state our result as an algorithm for the gap version of LocalVC, where the output S in Theorem 1.1 satisfies E(S, V − S) < k + γ for some parameter γ. In this case, the time and query complexities decrease by a factor of γ. 5 undirected k-edge connectivity directed k-edge connectivity directed k-edge connectivity in simple graphs (un)directed k-vertex connectivity O State of the art O [PR02] k4 (d)4 (cid:18) (cid:19) (cid:18)(cid:16) ck (cid:17)k+1(cid:19) (cid:17)k+1(cid:19) (cid:18)(cid:16) ck d O d [OR11] [YI10, OR11] 2d Here (cid:16) k2 (cid:17) = O (cid:17) = O (cid:16) k2 (cid:16)min{ k2 (cid:16)min{ k (cid:17) = O (cid:16) k2 O O O = O O 2d 2d 2d 2 (cid:17) (cid:16) k (cid:17) (cid:16) k }(cid:17) 3}(cid:17) (cid:17) (cid:16) k 2 , k 3d 2 , 1 2 Table 2: Comparison of property testing algorithms for higher connectivity in unbounded-degree graphs. undirected 3-edge connectivity undirected k-edge connectivity directed k-edge connectivity directed k-edge connectivity in simple graphs undirected k-vertex connectivity directed k-vertex connectivity State of the art [GR02] d ) 2− 2 k 3− 2  2d k3 k d (cid:18) log( 1 (cid:18) (cid:18)(cid:16) ck (cid:17)k (cid:18)(cid:16) ck (cid:17)k (cid:18)(cid:16) ck (cid:17)k d d d (cid:19) (cid:19) (cid:19) (cid:19) (cid:19) d d O O O O O d [OR11] (cid:19) O   O O Here d ) (cid:18) log2( 1 (cid:17) (cid:16) k (cid:16) k (cid:17) (cid:16)min{ k (cid:16) k (cid:17)  , 1 (cid:16) k (cid:17) O O    2}(cid:17) [GR02] [YI10] [YI12] O Table 3: Comparison of property testing algorithms for higher connectivity in bounded-degree graphs. 6 bound in the unbounded-degree model.3 The bounds that are exponential in k by [OR11, YI10, YI12] are O(( ck d)kd) in the unbounded- and bounded-degree models, respectively, for testing both directed k-vertex and -edge connectivity. Tables 2 and 3 provide detailed comparisons between our and previous results. )k+1) and O(( ck d Computing the Maximal k-Edge Connected Subgraphs. For a set C ⊆ V of vertices, its induced subgraph G[C] is a maximal k-edge connected subgraph of G if G[C] is k-edge connected and no superset of C has this property.4 The problem of computing all maximal k-edge connected subgraphs of G is a natural generalization of computing the strongly connected components to higher edge connectivity. For a long time, the state of the art for this problem was a running time of O(kmn) for k > 2 and O(mn) for k = 2 (implied by [GT85] and [Gab95], respectively). The first improvement upon this was given by Henzinger, Krinninger, and Loitzenbauer with a running time of O(kO(1)n2) for k > 2 and O(n2) for k = 2. The second improvement was given by Chechik et al. [Che+17] with a running time of O((2k)k+2m3/2) for k > 2 and O(m3/2) for k = 2. In undirected graphs, a version of the algorithm by Chechik et al. runs in time O((2k)k+2m n) √ for k ≥ 4 and in time O(m n) for k ≤ 3. In this paper, we improve upon this by designing an algorithm that has expected running time O(k3/2m3/2) in directed graphs, reducing the dependence on k from exponential to polynomial. We furthermore improve the running time for undirected graphs to O(k3n3/2 + km), thus improving both the dependence on k and on m. Table 4 compares our results to previous results. √ Parameter Graph class Running time Deterministic k = 2 k ≥ 3 k = 2 k ≥ 3 k = 2 k ≥ 3 k ≤ 3 k ≥ 4 k ≥ 2 k ≥ 2 directed directed directed directed directed directed undirected undirected directed undirected O(mn) O(kmn) O(n2) O(kO(1)n2) O(m3/2) O(m O((2k)k+2m3/2) √ n) √ O((2k)k+2m O(k3/2m3/2) O(k3n3/2 + km) n) yes yes yes yes yes yes yes yes no no Reference implied by [GT85] implied by [Gab95] [HKL15] [HKL15] [Che+17] [Che+17] [Che+17] [Che+17] here here Table 4: Comparison of algorithms for computing the maximal k-edge connected subgraphs. Note that another natural way of generalizing the concept of strongly connected components to higher edge connectivity is the following: A k-edge connected component is a maximal subset of vertices such that any pair of distinct vertices is k-edge connected in G.5 For a summary on the state of the art for computing the maximal k-edge connected subgraphs and 3Theorem 1.3 can be obtained simply from the fact that k ≤ d and d ≤ k/ can be assumed without loss of 4This is related to the notion of edge strength by Benczúr and Karger [BK15] as follows: The strength of an edge e is defined as the maximum value of k such that some maximal vertex-induced k-edge connected subgraph contains both endpoints of e. 5Note that the k edge disjoint paths between a pair of vertices in a k-edge connected component might use edges that are not contained in the k-edge connected component. This is not allowed for maximal connected subgraphs. generality. 7 components in both directed and undirected graphs, as well as the respective counterparts for vertex connectivity, we refer to [Che+17] and the references therein. Organization. We provide basic graph notations in Section 2. We first prove the results for local edge connectivity in Section 3. We then present three applications. First, by developing an algorithm for local vertex connectivity in Section 4, we give near-linear time algorithms for small vertex connectivity in Section 5. Second, we use approximate local vertex/edge connectivity to develop property testing algorithms for vertex/edge connectivity with near-linear in k many edge queries in Section 6. Finally, in Section 7, we give improved algorithms for computing the maximal k-edge connected subgraphs. set S ⊆ V , the out-volume of S is volout(S) =P 2 Preliminaries Let G = (V, E) be a directed graph. For any S, T ⊆ V , let E(S, T) = {(u, v) u ∈ S, v ∈ T}. For each vertex u, we let degout(u) = {v ∈ V (u, v) ∈ E} denote the out-degree of u. For a u∈S degout(u). The set of out-neighbors of S is N out(S) = {v (u, v) ∈ E(S, V − S)}. We define in-degree degin(u), in-volume volin(S), and the set of in-neighbors N in(S) analogously. We add a subscript G to the notation when it is not clear which graph we are referring to. A graph is strongly connected if for every pair of vertices u and v there is a path from u to v and a path from v to u. (The former implies the latter in undirected graphs and we usually just call the graph connected in that case.) A graph is k-edge connected if it is strongly connected whenever fewer than k edges are removed. A graph is k-vertex connected if it has more than k vertices and is strongly connected whenever fewer than k vertices (and their incident edges) are removed. The edge connectivity λG of a graph G is the minimum value of k such that the graph is k-edge connected and the vertex connectivity κG is the minimum value of k such that the graph is k-vertex connected. We say that (L, S, R) is a separation triple of G if L, S, R partition V such that L, R 6= ∅, and E(L, R) = ∅. We also say that S is a vertex cut of G of size S. S is an st-vertex cut if s ∈ L and t ∈ R. We say that s and t are k-vertex connected if there is no st-vertex cut of size less than k. Observe that G is k-vertex connected if and only if s and t are k-vertex connected for every pair s, t ∈ V . 3 Local Edge Connectivity In this section, we give a local algorithm for detecting an edge cut of size k and volume ν containing some seed vertex in O(νk2) time. The algorithm accesses (i.e., make queries for) O(νk) edges (this bound is needed for our property testing results). Roughly speaking, it outputs either a "small" cut or the symbol "⊥" indicating that there is no small cut containing x. The algorithm makes one-sided errors -- it might be wrong when it outputs ⊥ -- with probability at most 1/4. By standard arguments, we can make the error probability arbitrarily small by executing the algorithm repeatedly. Both the algorithm description and the analysis are very simple. Theorem 3.1. There exists the following randomized algorithm. It takes as inputs, 8 directed graph G = (V, E), • a pointer to a seed vertex x ∈ V in an adjacency list representing an n-vertex m-edge • a volume parameter (positive integer) ν, • a cut-size parameter (positive integer) k, and • a slack parameter (non-negative integer) γ, where γ ≤ k < ν < m(γ + 1)/(130k). (2) It accesses (i.e., makes queries for) O(νk/(γ + 1)) edges and runs in O(νk2/(γ + 1)) time. in the following manner: • If there exists a vertex-set S0 such that S0 3 x, volout(S0) ≤ ν, and E(S0, V − S0) < k, then with probability at least 3/4, the algorithm outputs a non-empty vertex-set S (cid:40) V such that E(S, V − S) < k + γ and volout(S) ≤ 130νk/(γ + 1) (otherwise it outputs ⊥). • Otherwise (i.e., no such S0 exists), the algorithm outputs either a set S as specified above or ⊥. Remark. simple algorithm with the same running time in Appendix A. If we are not concerned about the number of edge queries, then there is an another In particular, we obtain exact and (1 + )-approximate local algorithms for Theorem 3.1 as follows. We set γ = 0 in Theorem 3.1 for the exact local algorithm. For (1 + )-approximation, we set γ = bkc. Corollary 3.2. There exists the following randomized algorithm. It takes as the same inputs as in Theorem 3.1 but with γ = 0. It accesses (i.e., makes queries for) O(νk) edges and runs in O(νk2) time. It then outputs in the following manner. • If there exists a vertex-set S0 such that S0 3 x, volout(S0) ≤ ν, and E(S0, V − S0) < k, then with probability at least 3/4, the algorithm outputs a non-empty vertex-set S (cid:40) V such that E(S, V − S) < k (otherwise it outputs ⊥). • Otherwise (i.e., no such S0 exists), the algorithm outputs either a set S as specified above or ⊥. Corollary 3.3. There exists the following randomized algorithm. It takes as the same inputs as in Theorem 3.1 but with an additional parameter  ∈ (0, 1] and γ = bkc. It accesses (i.e., makes queries for) O(ν/) edges and runs in O(νk/) time. It then outputs in the following manner. • If there exists a vertex-set S0 such that S0 3 x, volout(S0) ≤ ν, and E(S0, V − S0) < k, then with probability at least 3/4, the algorithm outputs a non-empty vertex-set S (cid:40) V such that E(S, V − S) < b(1 + )kc (otherwise it outputs ⊥). • Otherwise (i.e., no such S0 exists), the algorithm outputs either a set S as specified above or ⊥. Proof. The results follow from Theorem 3.1 where we set γ = bkc, and the following fact: k + γ = k + bkc = bkc + bkc ≤ bk + kc = b(1 + )kc. (3) The algorithm for Theorem 3.1 is described in Algorithm 1. Roughly speaking, in each iteration of the repeat-loop the algorithm runs a standard depth-first search (DFS)6 algorithm, 6The choice of depth-first search is arbitrary. Breadth-first search would also work. 9 Algorithm 1: LocalEC(x ∈ V, ν, k, γ) Input: Seed vertex x ∈ V, target volume ν > k, target cut-size k ≥ 1, slack γ ≤ k. Output: A vertex-set S or the symbol ⊥ as specified in Theorem 3.1. y ← NIL. Grow a DFS tree T of vertices reachable from the seed vertex x as follows: while the DFS algorithm still has an edge e = (a, b) to explore do if e is not marked then 1 repeat k + γ times 2 3 4 5 6 7 8 Mark e. if the algorithm has marked ≥ 128νk/(γ + 1) edges then return ⊥. With probability (γ + 1)/(8ν), set y ← a and break the while-loop. if y = NIL then return S = V (T). else Reverse the direction of edges on the path Pxy in T from x to y. 9 10 11 return ⊥. but randomly stops before finishing the DFS; this stopping corresponds to breaking the while- loop in Algorithm 1. (If the DFS finishes before being stopped, our algorithm outputs all vertices found by the DFS.) Let (a, b) denote the last edge explored by the DFS before the random stop happens. We reverse the direction of all edges on the unique path from x to a in the DFS tree. We repeat this whole process for k + γ iterations. Additionally, we keep track of the number of edges visited in total over all iterations, which affects the query complexity. If this number exceeds a certain bound, we stop the algorithm. It is easy to see to bound the running time and the query complexity of Algorithm 1. Lemma 3.4. Algorithm 1 runs in time O(νk2/(γ + 1)), and accesses O(νk/(γ + 1)) edges. Proof. By line 7, the algorithm accesses at most d128νk/(γ + 1)e = O(νk/(γ + 1)) edges in total. For every vertex v, we store all outgoing edges accessed so far in a doubly linked list. As long as not all outgoing edges of v have yet been accessed, we additionally store the index of the next edge to query from the adjacency list of v. In addition, we store a pointer to the position in the doubly linked list of the last outgoing vertex of v visited in the current DFS. Whenever we reverse an edge (v, w), we remove (w, v) from the list of v and append (w, v) to the list of w. Note that we only reverse edges (v, w) for which w was the last outgoing vertex of v visited in the current DFS. from each vertex v to the last outgoing vertex of v visited in the current DFS. Therefore the position of each edge to be reversed in its doubly linked list can be found in constant time by using the corresponding pointers. Thus, both the DFS and edge-reversal step take time at most linear in the total number of edges accessed so far. As we repeat this for at most k + γ ≤ 2k iterations, the running time follows. We start the correctness proof with the following important observation from [Che+17]. Lemma 3.5. Let S (cid:40) V be any set with x ∈ S. Let Pxy be a path from x to some vertex y. Suppose we reverse the direction of all edges on Pxy. Then, we have that E(S, V − S) and volout(S) are both decreased exactly by one if y /∈ S. Otherwise, E(S, V − S) and volout(S) stay the same. 10 Proof. We fix the set S and the path Pxy where x ∈ S. If y /∈ S, then Pxy crosses the edges between S and V − S back and forth so that the number of crossing outgoing edges (i.e., from S to V − S) is one plus the number of crossing incoming edges (i.e., from V − S to S). Therefore, reversing the direction of the edges in Pxy decreases both E(S, V − S) and volout(S) exactly by one. If y ∈ S, then the number crossing outgoing edges is equal to the number of crossing incoming edges. Thus, reversing the direction of edges in Pxy does not change E(S, V − S) and volout(S). The following two lemmas prove the correctness of Algorithm 1. Lemma 3.6. If a vertex set S is returned, then ∅ 6= S (cid:40) V,E(S, V − S) < k + γ and volout(S) ≤ 130νk/(γ + 1). Proof. If a vertex set S is returned, then the algorithm terminates in line 9 and S = V (T) (for the DFS tree T) is the set of vertices reachable from x. Thus, we have E(S, V − S) = 0 and volout(S) ≤ 128νk/(γ + 1) (2) < m. Note that by design x ∈ S (and thus S 6= ∅), and since volout(S) < m, also S (cid:40) V . The algorithm has reversed strictly less than k + γ many paths Pxy because the algorithm did not reverse a path in the final iteration that returns S. Therefore, Lemma 3.5 implies that, initially, E(S, V −S) < k+γ, and volout(S) < 128νk/(γ +1)+k+γ ≤ 130νk/(γ + 1). Lemma 3.7. If there is a set S0 such that x ∈ S0,E(S0, V − S0) < k and volout(S0) ≤ ν, then ⊥ is returned with probability at most 1/4. ⊥ be the event that ⊥ is returned in line 7 and let R (11) (7) Proof. Let τ = 128νk/(γ + 1), let R ⊥ be the event that ⊥ is returned in line 11. We will show that each of these events will occur with probability at most 1/8. As there are no other ways of returning ⊥ in the algorithm and the two events are mutually exclusive, it will follow that the probability of returning ⊥ is at most 1/8 + 1/8 = 1/4. (7) Note that event R ⊥ only occurs if the decision to break the while loop in line 8 has been made less than k + γ times before the limit of τ marked edges is reached. We view the probabilistic decision to break the loop in line 8 as a Bernoulli trial with success probability p = (γ + 1)/(8ν). Let X be the random variable that denotes the number of successes in a sequence of τ − 1 such (7) trials with success probability p. Clearly, Pr[R ⊥ ] = Pr[X < k + γ]. Now consider an infinite sequence of Bernoulli trials with success probability p and let Y be the random variable that denotes the number of trials needed to obtain k + γ successes in this sequence. Observe that Pr[X < k + γ] = Pr[Y > τ − 1] = Pr[Y ≥ τ]. The distribution of Y is exactly the negative binomial distribution with parameters k + γ and p (see, e.g., [Fel68]) and thus E[Y ] = (k + γ)/p. By Markov's inequality, Pr[Y ≥ τ] = Pr[Y ≥ 8 · (k + γ)/p] = Pr[Y ≥ 8 · E[Y ]] ≤ 1/8. Thus, Pr[R ⊥ ] = Pr[Y ≥ τ] ≤ 1/8. (7) ⊥ ] ≤ 1/8, recall first that the events R (7) (11) (11) ⊥ are mutually To show that P[R ⊥ ⊥ ¯R ⊥ ], where ¯R (7) (7) (11) (7) (11) ⊥ is the counter-event of R ⊥ . To prove exclusive and thus P[R ⊥ ] = P[R ⊥ ¯R ⊥ ] ≥ 1 − 1/8, where ¯R our claim, we will show that P[ ¯R (11) (7) (11) is the counter-event of ⊥ ⊥ . We first argue that, conditioned on ¯R (11) (11) ⊥ is implied by the following event Q: the R algorithm either performs at most k + γ −1 iterations or the algorithm performs k + γ iterations and for at most γ of these iterations y is set to a vertex in S0 in line 8. If this is true, then we have Pr[ ¯R ⊥ , ¯R (7) and R ⊥ ¯R (11) ⊥ ] ≥ Pr[Q ¯R (7) (7) ⊥ ]. 11 If the algorithm performs only k + γ − 1 iterations, without the occurrence of event R (7) ⊥ , it must return some set S = V (T) in line 9, which implies event ¯R (11) ⊥ as desired. Now assume that the algorithm performs k + γ iterations and for at most γ of these iterations y is set to a vertex in S0. We show that this situation implies event ¯R (11) ⊥ . The assumption implies that during the first k + γ − 1 iterations, the algorithm must have set y to a vertex in V − S0 in at least k − 1 iterations. In each of these k − 1 iterations, E(S0, V − S0) is reduced by exactly one by Lemma 3.5 and initially E(S0, V − S0) ≤ k − 1. Therefore the algorithm has set y to a vertex in V − S0 in exactly k − 1 iterations. Now at the beginning of iteration k + γ (the final iteration) we have E(S0, V − S0) = 0. It is therefore not possible that y is set to a vertex in V − S0 in that iteration as these vertices are not reachable anymore. It is furthermore not possible that y is set to a vertex in S0 as the number of times this already happened in previous iterations must be γ and for event Q to occur cannot increase to γ + 1. Therefore, the only option left is that y remains NIL in that final iteration and the algorithm returns S = V (T) in line 9, which implies event ¯R ⊥ ] ≥ Pr[Q ¯R (7) ⊥ ], it remains to show that Pr[Q ¯R (7) ⊥ ] ≥ 1 − 1/8. Let Z (7) be the random variable denoting the number of iterations for which y is set to a vertex in S0 in ⊥ , Q simply is the event that Z ≤ γ. Note that for each newly Line 8. Now, conditioned on ¯R (7) marked edge, y is set to the tail of this edge with probability p = (γ + 1)/(8ν). Furthermore, we only mark edges that have not been reversed yet. Thus, y can be set to a vertex in S0 only if the newly marked edge is from E(S0, V ) (where we refer to the state of this set at the beginning of the algorithm). As we never unmark edges, the probability for each edge from E(S0, V ) to have y set to its tail is at most p. Therefore, E[Z ¯R ⊥ ] ≤ E(S0, V )· p = νp = (γ +1)/8. By Markov's (7) ⊥ ] ≥ 1−1/8, and since γ+1 ≥ 8·E[Z ¯R inequality, we have Pr[Z < 8·E[Z ¯R ⊥ ] ¯R (7) (7) (7) ⊥ ] we get Pr[Z < γ + 1 ¯R ⊥ ] ≥ Pr[Z < 8 · E[Z ¯R ⊥ ] ¯R (7) (7) (7) ⊥ ]. Finally, note that Z and γ are integer and ⊥ ] = Pr[Z < γ + 1 ¯R ⊥ ] ≥ Pr[Z < 8 · E[Z ¯R therefore Pr[Z ≤ γ ¯R (7) (7) ⊥ ] ≥ 1 − 1/8. (7) Since Pr[ ¯R ⊥ ¯R (11) (11) ⊥ . ⊥ ] ¯R (7) 4 Local Vertex Connectivity In this section, we give the vertex cut variant of the local algorithms from Section 3. Theorem 4.1. There exists the following randomized algorithm. It takes as inputs, directed graph G = (V, E) • a pointer to a seed vertex x ∈ V in an adjacency list representing an n-vertex m-edge • a volume parameter (positive integer) ν, • a cut-size parameter (positive integer) k, and • a slack parameter (non-negative integer) γ, where 1 ≤ k < n/4, γ ≤ k < ν < m(γ + 1)/(12480k). (4) It accesses (i.e., makes queries for) O(νk/(γ + 1)) edges and runs in O(νk2/(γ + 1)) time. It then outputs in the following manner. • If there exists a separation triple (L0, S0, R0) such that L0 3 x, volout(L0) ≤ ν, and S0 < k, then with probability at least 3/4, the algorithm outputs a vertex-cut of size at most k + γ (otherwise it outputs ⊥). • Otherwise (i.e., no such separation triple (L0, S0, R0) exists), the algorithm outputs either a vertex-cut of size at most k + γ or ⊥. and 12 We obtain exact and (1 + )-approximate local algorithms for Theorem 4.1 by setting γ = 0 and γ = bkc, respectively. Corollary 4.2. There exists the following randomized algorithm. It takes as the same inputs as in Theorem 4.1 where γ is set to be equal to 0. It accesses (i.e., makes queries for) O(νk) edges and runs in O(νk2) time. It then outputs in the following manner. • If there exists a separation triple (L0, S0, R0) such that L0 3 x, volout(L0) ≤ ν, and S0 < k, then with probability at least 3/4, the algorithm outputs a vertex-cut of size at most k (otherwise it outputs ⊥). • Otherwise (i.e., no such (L0, S0, R0) exists), the algorithm outputs either a vertex-cut of size at most k or ⊥. Corollary 4.3. There exists the following randomized algorithm. It takes as the same inputs as in Theorem 4.1 with additional parameter  ∈ (0, 1] where γ is set to be equal to bkc. It accesses (i.e., makes queries for) O(ν/) edges and runs in O(νk/) time. It then outputs in the following manner. • If there exists a separation triple (L0, S0, R0) such that L0 3 x, volout(L0) ≤ ν, and S0 < k, then with probability at least 3/4, the algorithm outputs a vertex-cut of size at most b(1 + )kc (otherwise it outputs ⊥). • Otherwise (i.e., no such (L0, S0, R0) exists), the algorithm outputs either a vertex-cut of size at most b(1 + )kc or ⊥. Proof. The results follow from Theorem 4.1 where we set γ = bkc, and Equation (3). To prove Theorem 4.1, in Section 4.1 we first reduce the problem to the edge version of the problem using a well-known reduction (e.g., [Eve75, HRG00]) and then in Section 4.2 we plug the algorithm from Theorem 3.1 into the reduction. 4.1 Reducing from Vertex to Edge Connectivity Given a directed n-vertex m-edge graph G = (V, E) and a vertex x ∈ V , let G0 = (V 0, E0) be an n0-vertex m0-edge graph defined as follows. We call G0 the split graph w.r.t. x. For each v ∈ V − {x}, we add vertices vin and vout to V 0 and a directed edge (vin, vout) to E0. We also add x to V 0 and we denote xin = xout = x for convenience. For each edge (u, v) ∈ E, we add (uout, vin) to E0. Suppose, for convenience, that the minimum out-degree of vertices in G is 1. The following two lemmas draw connections between G and G0. Lemma 4.4. Let (L, S, R) be a separation triple in G where S = N out v ∈ L} ∪ {vin v ∈ S} be a set of vertices in G0. Then EG0(L0, V 0 − L0) = S and volout G0 (L0) ≤ 3 volout volout Proof. As S = N out volout least 1 and S = N out G (L). G (L), we have EG0(L0, V 0 − L0) = {(vin, vout) v ∈ S} = S. Also, G (L) because every vertex in G has out-degree at G (L). G (L). Let L0 = {vin, vout G (L) ≤ G0 (L0) = volout G (L) + L + S ≤ 3 volout G (L) ≤ 2 volout Lemma 4.5. Let L0 3 x be a set of vertices of G0. Then, there is a set of vertices L in G such G0 (L0) and S ≤ EG0(L0, V 0 − L0) where S = NG(L). Given L0, L can that volout G0 (L0)) time. Furthermore, for R = V − (L ∪ S) we have R 6= ∅, i.e., be constructed in O(volout (L, S, R) is a separation triple, if volout G0 (L0) ≤ m0/32 and EG0(L0, V 0 − L0) ≤ n/2. 13 L0 0 L0 aout bout L pin qin S uin vin pout win qout yin cout rin rout zin x uout vout wout yout zout ain bin cin Figure 1: Construction of a separation triple (L, S, R) in G from an edge cut L0 in G0. Most 0 = L0 ∪ {uin, vin}, L = {r, p, q, x}, S = {u, v, w, y, z}. edges are omitted. For this example, L0 Proof. First, note that if there is v ∈ V such that vout ∈ L0 and degout then we can return L = {v} and S = N out that degout G0 (vout) ≤ EG0(L0, V 0−L0), G ({v}) and we are done. So from now, we assume G0 (vout) > EG0(L0, V 0 − L0). By the structure of G0, observe that there are sets S1, S2 ⊆ V such that EG0(L0, V 0 − L0) = {(vin, vout) v ∈ S1} ∪ {(uout, vin) v ∈ S2} Let L0 0 = L0 ∪ {vin v ∈ S2}. See Figure 1 for illustration. So there is a set S (cid:40) V where 0) = {(vin, vout) v ∈ S}. EG0(L0 0, V 0 − L0 G0 (L0 Let L = {v vin, vout ∈ L0 G0 (L0) + EG0(L0, V 0 − L0) ≤ 2 volout G (L) ≤ volout 0, V 0 − L0 0) ≤ EG0(L0, V 0 − L0) because for each v ∈ S2, degout(vin) = 0) ≤ volout 0}. Note that L ∩ S = ∅. See Figure 1 for illustration. Observe G0 (L0). G0 (L0)) because the minimum out-degree in = {vin ∈ 0). Suppose for contradiction We have S = EG0(L0 1 ≤ degin(vin). Also, volout that x ∈ L because xout = xin. Moreover, NG(L) = S and volout L be can constructed in time O({vout ∈ L0}) = O(volout of vertices in G is 1. V 0}∪{x} and V 0 that R = ∅. We first claim that R = ∅ implies 0 = V 0 out, and EG0(L0 out = {vout ∈ V 0}−{x}. Let k0 = EG0(L0 For the second statement, observe that R = V − (L ∪ S) = {v vin /∈ L0 0) only contains edges of the This holds because L0 0 ⊇ V 0 in, V 0 − L0 G0 (L0). G0 (L0 0) ≤ 2 volout 0}. Let V 0 0, V 0 − L0 V 0 − L0 0 ⊆ V 0 out − L0 0 = k0. 0, V 0 − L0 14 form (vin, vout). Now, there are two cases. If m0 ≥ 4n0k0, then we have G0 (L0 m0 = volout 0) + volout ≤ 2 volout G0 (L0) + V 0 ≤ 2 · m0/32 + k0n0 ≤ m0/16 + m0/4 < m0 G0 (V 0 − L0 0) out − L0 0n0 which is a contradiction. Otherwise, we have m0 < 4n0k0. Note that n0 < 2n by the construction G0 (vout) ≤ EG0(L0, V 0 − L0) ≥ k for every vout ∈ L0 we of G0 and so m0 < 8nk0. Hence, as degout have 0 ∩ V 0 outk0 ≥ (n − k0)k0 ≥ nk0/2 > m0/16 0) ≥ L0 G0 (L0) ≤ 2 · m0/32 = m0/16. 0) ≤ 2 volout G0 (L0 volout G0 (L0 which contradicts volout 4.2 Proof of Theorem 4.1 Given an n-vertex m-edge G = (V, E) represented as adjacency lists, a vertex x ∈ V and parameters ν, k, γ from Theorem 4.1 where ν ≤ (γ + 1)m/(12480k) and k ≤ n/4, we will work on the split graph G0 with n0-vertices m0-edges as described in Section 4.1. The adjacency list of G0 can be created "on the fly". Let LocalEC(x0, ν0, k0, γ0) denote the algorithm from Theorem 3.1 with parameters x0, ν0, k0, γ0. We run LocalEC(x, 3ν, k, γ) on G0 = (V 0, E0) in time O(νk2/(γ + 1)). Note that 3ν ≤ (γ + 1)m/(8k) ≤ (γ + 1)m0/(8k) as required by Theorem 3.1. We show that if there exists a separation triple (L, S, R) in G where L 3 x,S < k, and G (L) ≤ ν, then LocalEC(x, 3ν, k, γ) outputs ⊥ with probability at most 1/4. By Lemma 4.4, volout there exists L0 in G0 such that L0 3 x,EG0(L0, V − L0) < k, and volout G (L) ≤ 3ν. Therefore, by Theorem 3.1, LocalEC(x, 3ν, k, γ) returns ⊥ with probability at most 1/4. If, in G0, LocalEC(x, 3ν, k, γ) returns L0, then by Theorem 3.1 we have L0 3 x,EG0(L0, V 0 − L0) < k + γ and volout G0 (L0) ≤ 390νk/γ. It remains to show that we can construct L (cid:40) V in G G (L) < k + γ. By Lemma 4.5, we can obtain in such that N out O(νk/(γ + 1)) time and two sets L and S = N out(L) where S < k + γ. Let R = V − L ∪ S. (4)≤ m0/32 and k + γ ≤ 2k ≤ n/2, we have that (L, S, R) is a As volout separation triple by Lemma 4.5. That is, S = N out G (L) is a vertex-cut, and N out G0 (L0) ≤ 3 volout G0 (L0) ≤ 390νk/(γ + 1) G (L) is a vertex cut. 5 Vertex Connectivity In this section, we give the first near-linear time algorithm for checking k-vertex connectivity for any k = O(1) in both undirected and directed graphs. Theorem 5.1. There is a randomized (Monte Carlo) algorithm that takes as input an undirected graph G, a cut-size parameter k, and an accuracy parameter  ∈ (0, 1], and in time O(m+nk2/) either outputs a vertex cut of size less than b(1 + )kc or declares that G is k-vertex connected w.h.p. By setting  < 1/k, the same algorithm decides (exact) k-vertex connectivity of G in O(m + nk3) time. Now we present the new results for directed graph. Theorem 5.2. There is a randomized (Monte Carlo) algorithm that takes as input a directed graph G, a cut-size parameter k, and an accuracy parameter  ∈ (0, 1], and in time 15 O(min{mk/, poly(1/)n2+o(1)√ k}) either outputs a vertex cut of size less than b(1 + )kc or declares that G is k-vertex connected w.h.p. For exact vertex connectivity, there is a randomized (Monte Carlo) algorithm for exact k-vertex connectivity of G in O(min{mk2, k3n + k3/2m1/2n}) time. To prove Theorem 5.1 and Theorem 5.2, we will apply our framework [NSY19a] for reducing the vertex connectivity problem to the local vertex connectivity problem. To describe the reduction, let Tpair(m, n, k, , p) be the time required to either find, for given vertices s and t, an st-vertex cut of size less than b(1 + )kc or to declare that s and t are k-vertex connected correctly with probability at least 1 − p. Let Tlocal(ν, k, , p) be the time for solving correctly with probability at least 1 − p the local vertex connectivity problem from Corollary 4.3 when a volume parameter is ν, the cut-size parameter is k, and the accuracy parameter is . Lemma 5.3 ([NSY19a] Lemma 5.14, 5.15). There is a randomized (Monte Carlo) algorithm that takes as input a graph G, a cut-size parameter k, and an accuracy parameter  > 0, and runs in time proportional to one of these expressions O(m/ν) · (Tpair(m, n, k, , 1/ poly(n)) + Tlocal(ν, k, , 1/ poly(n))) O(n/σ) · (Tpair(m, n, k, , 1/ poly(n)) + Tlocal(σ2 + σk, k, , 1/ poly(n))) (5) (6) where ν ≤ m, and σ ≤ n are parameters that can be chosen arbitrarily, and either outputs a vertex cut of size less than b(1 + )kc or declares that G is k-vertex connected w.h.p. For completeness, we give a simple proof sketch of Equation (5) which is used for our algorithm for undirected graphs. The idea for other equations is similar and also simple. Proof sketch. Suppose that G is not k-vertex connected. It suffices to give an algorithm that outputs a vertex cut of size less than b(1 + )kc w.h.p. By considering both G and its reverse graph (where the direction of each edge is reversed), there exists w.l.o.g. a separation triple (L, S, R) where volout(L) ≤ volout(R). There are two cases. Suppose volout(L) ≥ ν. By sampling O(m/ν) pairs of edges e = (x, x0) and f = (y, y0), there exists w.h.p. a pair (e, f) where x ∈ L and y ∈ R. For such a pair (x, y), if we check whether x and y are k-vertex connected in time Tpair(m, n, k, , 1/poly(n)), we must obtain an xy-vertex cut of size less than b(1 + )kc. So, if we check this for each pair (x, y), then we will obtain the cut w.h.p. Suppose volout(L) ≤ ν. Suppose further that volout(L) ∈ (2i−1, 2i]. By sampling O(m/2i) pairs of edges e = (x, x0), there exists w.h.p. an edge e where x ∈ L. For such vertex x, if we check the local vertex connectivity in time Tlocal(2i, k, , 1/poly(n)), then the algorithm must return a vertex cut of size less than b(1 + )kc. So, if we check this for each pair (x, y), then we will obtain the cut w.h.p. To conclude, the running time in the first case is O(m/ν) · Tpair(m, n, k, , 1/poly(n)). For the second case, we try all O(log n) many 2i, and each such try takes time O(m/2i) · Tlocal(2i, k, , 1/poly(n)) = O(m/ν)·Tlocal(ν, k, , 1/poly(n)) (if Tlocal(ν, k, , 1/poly(n)) = Ω(ν)). This completes the proof of the running time. For the correctness, if G is not k-vertex connected, we must obtain a desired vertex cut of size b(1 + )kc w.h.p. So if we do not find any cut, we declare that G is k-vertex connected w.h.p. 16 5.1 Undirected Graphs Here, we prove Theorem 5.1. First, it suffices to provide an algorithm with O(mk/) time. Indeed, by using the sparsification algorithm by Nagamochi and Ibaraki [NI92], we can sparsify an undirected graph in linear time so that m = O(nk) and k-vertex connectivity is preserved. By this preprocessing, the total running time is O(m)+ O((nk)k/)) = O(m+ nk2/) as desired. Next, we assume that k ≤ min{n/4, 5δ} where δ is the minimum out-degree of G. If k > 5δ, then it is G is clearly not k-vertex connected and the out-neighborhood of the vertex with minimum out-degree is a vertex cut of size less than k. If k > n/4, then we can invoke the algorithm by Henzinger, Rao and Gabow [HRG00] for solving the problem exactly in time O(mn) = O(mk). Now, we have Tpair(m, n, k, , p) = O(mk) by the Ford-Fulkerson algorithm. By repeating the algorithm from Corollary 4.3 O(log 1 p) times for boosting its success probability, Tlocal(ν, k, , p) = p). We choose ν = O(m) as required by Corollary 4.3 and also k ≤ min{n/4, 5δ}. O(νk−1 log 1 Applying Lemma 5.3 (Equation (5)), we obtain an algorithm for Theorem 5.1 with running time O(m/m) · O(mk + (m)k−1 log n) = O(mk/). 5.2 Directed Graphs Here, we prove Theorem 5.2. We again assume that k ≤ min{n/4, 5δ} using the same reasoning as in the undirected case. We first show how to obtain the claimed time bound for the approximate problem. Note that the O(mk/)-time algorithm follows by the same argument as in the undirected case, because both the Ford-Fulkerson algorithm and the local algorithm from Corollary 4.3 work as well in directed graphs. Next, we give an approximation algorithm with running time O(poly(1/)n2+o(1)√ k). We assume k ≤ n2/3 (for k ≥ n2/3, we use state-of-the-art O(poly(1/)n3+o(1)/k)-time al- gorithm by [NSY19a]). We have Tlocal(ν, k, , p) = O(νk−1 log 1 p) by Corollary 4.3 and Tpair(m, n, k, , 1/ poly(n)) = O(poly(1/)n2+o(1)) using the recent result for (1+)-approximating the minimum st-vertex cut by Chuzhoy and Khanna [CK19]. By choosing σ = n/ k for Lemma 5.3 (Equation (6)), we obtain an algorithm with running time √ √ O(n/σ) · (n2+o(1) poly(1/) + (σ2k + σk2)/) = O( k poly(1/)) · (n2+o(1) + n2 + nk1.5) = O(n2+o(1)√ k poly(1/)). Next, we show how to obtain the time bound for the exact problem. First, observe that we can obtain a O(mk2)-time exact algorithm from the O(mk/)-time approximate algorithm by setting  < 1/k. It remains to provide an algorithm with the running time O(k3n + k3/2m1/2n). By Corollary 4.2, there is an exact algorithm for local vertex connectivity with running time Tlocal(ν, k, 1/2k, p) = O(νk2 log 1 p). Also, we have Tpair(m, n, k, , p) = O(mk) by the Ford- Fulkerson algorithm. By choosing σ = O(pm/k) in Lemma 5.3 (Equation (6)), we obtain an algorithm with running time √ O(n/σ) · (mk + (σ2 + σk)k2) = O(n/σ) · (mk + (m/k + mk)k2) k/m) · (mk + k2.5√ m) q = O(n = O(k3/2m1/2n + k3n). Note that σ2 + σk = O(m/k) as required by Corollary 4.2. 17 6 Property Testing In this section, we give property testing algorithms for distinguishing between a graph that is k-edge/k-vertex connected and a graph that is -far from having such property with correct probability at least 2/3 for both unbounded-degree and bounded-degree incident-list model. Recall that for any  > 0, a directed graph G is -far from having a property P if at least m edge modifications are needed to make G satisfy property P. We assume that d = m/n is known to the algorithm at the beginning. We state our main results in this section. Theorem 6.1. For the unbounded-degree model, there is a one-sided property testing algorithm for k-edge (k-vertex) connectivity where k < O(n) with false reject probability at most 1/3 that uses O(k2/(2d)) queries (same for k-vertex). If d is unknown, then there is a similar algorithm that uses O(k/2) queries (same for k-vertex). If G is simple, then the same algorithm for testing k-edge connectivity queries at most O(min{k2/(d2), k/(d3)}) (or O(min{k/2, 1/3}) edges if d is unknown). In the bounded-degree model, we assume that d is known in the beginning. Theorem 6.2. For the bounded-degree model, there is a one-sided property testing algorithm for k-edge (k-vertex) connectivity where k < O(n) with false reject probability at most 1/3 that uses O(k/) queries (same for k-vertex). If G is simple, then the same algorithm for testing k-edge connectivity queries at most O(min{k/, 1/2}). We prove Theorem 6.1 using properties of -far from being k-edge/vertex connected from [OR11] and [FJ99] along with a variant of approximate local edge connectivity in Section 6.1, and approximate local vertex connectivity in Section 6.3. 6.1 Testing k-Edge Connectivity: Unbounded-Degree Model In this section, we prove Theorem 6.1 for testing k-edge connectivity where k < n 520(blog2(m/n)c + 1) = O(n). (7) The key tool for our property testing algorithm is an algorithm for approximate local edge connectivity in a suitable form for the application to property testing. Corollary 6.3. There exists the following randomized algorithm. It takes as inputs, graph G = (V, E), • a pointer to a seed vertex x ∈ V in an adjacency list representing an n-vertex m-edge • a volume parameter (positive integer) ν, • a cut-size parameter (positive integer) k, and • a slack parameter (non-negative integer) γ, where k ≥ 1 + γ, γ ≤ k/2 and ν < m(γ + 1)/(130(k − γ)). (8) It accesses (i.e., makes queries for) O(νk/(γ + 1)) edges. It then outputs in the following manner. • If there exists a vertex-set S0 such that S0 3 x, volout(S0) ≤ ν, and E(S0, V − S0) < k − γ, then with probability at least 3/4, the algorithm outputs S a non-empty vertex-set S (cid:40) V such that E(S, V − S) < k (otherwise it outputs ⊥). 18 • Otherwise (i.e., no such S0 exists), the algorithm outputs either a set S as specified above or ⊥. Proof. If ν < k − γ, then it is enough to run the following procedure. If deg(x) < k − γ, then we found a cut of size smaller than k, and return {x}. Otherwise, we return ⊥. To see that we return ⊥ correctly, for any vertex set S0 that contains x, we have volout(S0) ≥ k − γ > ν, and thus we correctly output ⊥. From now, we assume that ν ≥ k − γ. (9) Let the following tuple (x0, ν0, k0, γ0) be a list of parameter supplied to Theorem 3.1. We run the local algorithm in Theorem 3.1 using the following parameters (x0, ν0, k0, γ0) = (x, ν, k − γ, γ). Note that Equation (8) and Equation (9) ensure that the conditions in Equation (2) for the local algorithm with parameter (x0, ν0, k0, γ0) are satisfied. The query complexity follows from Theorem 3.1. We now present an algorithm for testing k-edge connectivity. Algorithm. 1. Sample Θ( 1 2. If any of the sampled vertices has out-degree less than k, return the corresponding trivial  ) vertices uniformly at random. edge cut. 3. Sample Θ( k log k vertices instead). d ) vertices uniformly at random (if d is unknown, then sample Θ( log k  ) 4. For each sampled vertex x, and for i ∈ {0, 1, . . . ,blog2 kc}, (a) Let ν = 2i+2−1blog2 kc, and γ = min{2i − 1,bk/2c}. (b) Run the local algorithm in Corollary 6.3 with parameters (x, ν, k, γ) on both G and GR where GR is G with reversed edges. 5. Return an edge cut of size less than k if any execution of the local algorithm above returns a cut. Otherwise, declare that G is k-edge connected. Query Complexity. We first show that the number of edge queries is at most O(k2/(2d)). For each sampled vertex x and i ∈ {0, 1, . . . ,blog2 kc}, by Corollary 6.3, the local algorithm queries O(νk/γ) = O(k/) edges. The result follows as we repeat log2 k times per sample, and we sample O(k log k/(d)) times. If d is unknown, we can remove the term k/d from above since we sample Θ( log k  ) vertices instead. Correctness. If G is k-edge connected, the algorithm above never returns an edge cut. We show that if G is -far from being k-edge connected, then the algorithm outputs an edge cut of size less k with constant probability. We start with a simple observation. Lemma 6.4. If m < nk/4, then with constant probability, the algorithm outputs an edge cut of size less than k at step 2. 19 Remark. This observation applies to any tester. Proof. Suppose m < nk/4. There are at most n/2 vertices with out-degree at least k. Hence, there are at least n/2 vertices of degree less than k. In this case, we can sample O(1) time where each sampled vertex x we check degout(x) < k to get k-edge cut with constant probability. From now we assume that m ≥ nk/4. (10) Next, we state important properties when G is -far from being k-edge connected. For any non-empty subset X ⊂ V , let dout(X) = E(X, V − X), and din(X) = E(V − X, X). Theorem 6.5 ([OR11] Corollary 8). A directed graph G = (V, E) is -far from being k-edge connected (for k ≥ 1) if and only if there exists a family of disjoint subsets {X1, . . . , Xt} of vertices for which either P i(k − dout(Xi)) > m or P i(k − din(Xi)) > m. Let F := {X1, . . . , Xt} as in Theorem 6.5. We assume without loss of generality that X (k − dout(Xi)) > m. (11) i Let C−1 = {X ∈ F : k ≤ dout(X)}. For i ∈ {0, 1, . . . ,blog2 kc}, let Ci = {X ∈ F : k − dout(X) ∈ [2i, 2i+1)}. Note that 2i ≤ k, for any i ∈ {0, . . . ,blog2 kc} (12) and blog2 kcG Ci F = (13) where F is the disjoint union. Let Ci,big = {X ∈ Ci : volout(X) ≥ 2i+2−1(blog2 kc + 1)}, and Ci,small = Ci − Ci,big. The following lemma is the key for the algorithm's correctness. Lemma 6.6. There is some i∗ ∈ {0, 1, . . . ,blog2 kc} such that Ci∗,small ≥ nd/(4k(blog2 kc + 1)). If d is unknown, we have Ci∗,small ≥ n/(16(blog2 kc + 1)) instead. i=−1 Let us briefly argue that Lemma 6.6 implies the correctness of the algorithm. If Lemma 6.6 is true, then by sampling Θ((k log k)/(d)) many vertices (or Θ(log k/) if d is unknown), the event that a sampled vertex belongs to some vertex set S0 ∈ Ci∗,small has constant probability (since Ci∗,small contains disjoint sets). Now, assuming that a sampled vertex x belongs to a vertex set S0 as specified above. Since S0 ∈ Ci∗,small, by definition, volout(S0) ≤ 2i∗+2−1(blog2 kc + 1), and k − dout(S0) ∈ [2i∗ , 2i∗+1). In other words, there exists a vertex set S0 such that S0 3 x, volout(S0) ≤ 2i∗+2−1(blog2 kc + 1), and E(S0, V − S0) ≤ k − 2i∗ < k − (2i∗ − 1). If i∗ was known, then we run the local algorithm in Corollary 6.3 with parameters (x, ν, k, γ) where ν = 2i∗+2−1(blog2 kc + 1), and γ = min{2i∗ − 1,bk/2c} to obtain a non-empty set S such that E(S, V −S) < k with probability at least 3/4. Since i∗ ∈ [0, 1, . . . ,blog2 kc}, it is enough to run the local algorithm in Corollary 6.3 with parameters (x, νi, k, γi) where νi = 2i+2−1(blog2 kc+1) and γi = min{2i − 1,bk/2c} for every i ∈ {0, 1, . . . ,blog2 kc}. 20 It remains to check the preconditions for the local algorithm in Corollary 6.3. We show that Equation (8) is satisfied for any call of the local algorithm. It is easy to see that the first condition k ≥ 1 + γ is satisfied. The second condition γ ≤ k/2 follows since γi = min{2i − 1,bk/2c} ≤ bk/2c ≤ k/2 for any i ∈ {0, 1, . . . ,blog2 kc}. Finally, we show the last condition ν < m(γ + 1)/(130(k − γ)) is satisfied. First, note that for any i ∈ {0, 1, . . . ,blog2 kc}, νi = 2i+2−1(blog2 kc + 1) ≤ 4−1k(blog2 kc + 1). Therefore, blog2(m/n) + 1c (7) ν ≤ 4−1k(blog2 kc + 1) This last inequality follows since 0 ≤ γ < k/2. Therefore, the correctness follows. Proof of Lemma 6.6. We begin by showing that there is some i ∈ {0, 1, . . . ,blog2 kc} such that Ci > m/(2i+1(blog2 kc + 1)). that there is some i ∈ {0, 1, . . . ,blog2 kc} such that < m(γ + 1)/(130(k − γ)) (14) (10)≤ 4 m−1 m 130k < n (k − dout(X)) > m/(blog2 kc + 1). X∈Ci Suppose otherwise that for every i ∈ {0, 1, . . . ,blog2 kc},P Then we have P (k−dout(X)) ≤ m/(blog2 kc+1). (k − dout(X)) ≤ m. However, this contradicts Equation (11) as in Theorem 6.5. Second, we claim that for every i ∈ {0, 1, . . . ,blog2 kc}, (k − dout(X)) ≤ Pblog2 kc X∈F(k − dout(X)) (13)= Pblog2 kc Ci2i+1 ≥ X (k − dout(X)). P P X∈Ci i=−1 X∈Ci (15) i=0 X∈Ci X X∈Ci This follows trivially from the definition that each element X of the set Ci has k−dout(X) < 2i+1. Now for the i that satisfies Equation (15) we have (k − dout(X))/2i+1 > m/(2i+1(blog2 kc + 1)) (16) Ci ≥ X X∈Ci as desired. Recall that Ci,big = {X ∈ Ci : volout(X) ≥ 2i+2−1(blog2 kc + 1)}, and Ci,small = Ci − Ci,big. We show that Ci,big < Ci/2 for i that satisfies Equation (16) by the following chain of inequalities: volout(X)/(2i+1−1(blog2 kc + 1)) ≤ m/(2i+1(blog2 kc + 1)) (16) 2Ci,big ≤ X each X ∈ Ci,big from the definition of Ci,big, we have P The first inequality holds because by the inequality volout(X)/(2i+1−1(blog2 kc + 1)) ≥ 2 for X∈Ci,big volout(X)/(2i+1−1(blog2 kc + P 1)) ≥ 2Ci,big. The second inequality holds because elements in Ci,big are disjoint and thus X∈Ci,big volout(X) ≤ m. The final inequality follows from Equation (16). For the same i, since Ci,big < Ci/2, we have < Ci. X∈Ci,big Ci,small ≥ Ci/2 > m/(2i+2(blog2 kc + 1)) ≥ nd/(4k(blog2 kc + 1)). (17) The last inequality follows from m = nd, and Equation (12). If d is unknown, by Equation (10), the last inequality becomes m/(2i+2(blog2 kc + 1)) ≥ nk/(16kblog2 kc) = n/(16(blog2 kc + 1)). 21 An improved bound for simple graphs. The same algorithm gives an improved bound when G is simple. If  ≤ 4/k, the algorithm queries at most O(k2/(2d)) = O(1/(4d)) edges (and O(1/3) edges if d is unknown). Now, we assume  > 4/k, we show that there are Ω(nd/k) (Ω(n) if d is unknown) many vertices with degree less than k. Lemma 6.7. If  > 4/k, G is simple, and -far from being k-edge connected, then there exist at least n/2 vertices (dn/(8k) vertices if d is unknown) with degree less than k. Lemma 6.7 immediately yields the correctness of the algorithm as number of singleton with degree less than k is at least n/2 vertices (dn/(8k) vertices if d is unknown), and we sample Θ(k/(d)) (or Θ(1/) vertices if d is unknown) at step 1 and 2 to check if each sampled vertex has degree less than k. Next, we prove Lemma 6.7. Proof of Lemma 6.7. Let C = {X : k − dout(X) ≥ 1}. We claim that C > m/k. (18) This follows from Ck ≥ X X∈C (k − dout(X)) ≥ X X∈F (k − dout(X)) > m. The first inequality follows from each term k − dout(X) is at most k, and there are C terms. The second inequality follows from each X ∈ F − C, k − dout(X) ≤ 0. The third inequality follows from Equation (11). Let Cbig = {X ∈ C : volout(X) ≥ 2k/}, and Csmall = C − Cbig. We claim that Csmall > n/8. Cbig < C/2. (19) (20) volout(X)/(2k−1) ≤ m/(2k) < C/2. First, we show that This follows from Cbig ≤ X X∈Cbig P The first inequality follows from the fact that for each X ∈ Cbig, volout(X)/(2k−1) ≥ 1. Hence, contains disjoint sets, andP X∈Cbig volout(X)/(2k−1) ≥ Cbig. The second inequality follows from the fact that Cbig X∈Cbig volout(X) ≤ volout(V ) = m. The last inequality follows from Equation (18). Next, we have Csmall ≥ C/2 ≥ m/(2k) ≥ (nd)/(2k) ≥ (nd)/2. (21) The first inequality follows from Equation (20) and that Csmall = C −Cbig. The second inequality follows from Equation (18). The third inequality follows from m = nd. If d is unknown, the last part of Equation (21) becomes m/(2k) ≥ (nk)/(8k) ≥ n/8. This follows from Equation (10). It suffices to show that, for each X ∈ Csmall, the average degree of vertices in X, which , is less than k. If this is true, then there exists vertex x ∈ X where deg x < k. is volout(X) X Since the sets in C are disjoint, each set X ∈ C contains a vertex with degree less than k, and 22 X < Now, fix X ∈ Csmall and we want to show that volout(X) X = dout(X) < k. Next, if X ≥ 2/, then volout(X) Csmall > n/8 (by Equation (19)), we have that the number of singleton vertex with degree less than k is > n/8, and we are done. X < k. Consider three cases. If X = 1, 2/ = k as X ∈ Csmall. In then volout(X) 2k/ the last case, we have 2 ≤ X < 2/ ≤ k/2. Here we use the assumption  < 4/k. Note that volout(X) ≤ dout(X) + X2 because the graph is simple. So, X + X < 2 = k. 6.2 Testing k-Edge Connectivity: Bounded-Degree Model In this section, we prove Theorem 6.1 for testing k-edge connectivity for bounded degree model. In this model, we know the maximum out-degree d. We assume that G is d-regular, meaning that every vertex has degree d. If G is not d-regular, we can "treat" G as if it is d-regular as follows. For any list Lv of size less than d, and i ∈ (Lv, d], we ensure that query(v, i) returns a self-loop edge (i.e., an edge (v, v)). 2 + k vol(X) X ≤ dout(X) + X2 X k k < Edge-sampling procedure. The key property of a d-regular graph is that we can easily sample edges uniformly. The other arguments made in the following would in principle also apply to the unbounded-degree model. However, in the unbounded-degree model any algorithm √ that samples an edge from an almost uniform distribution must perform Ω(n/ d) queries [ER18], which is not feasible for our purposes. The sampling in the bounded-degree model works as follows: We first sample a vertex x ∈ V . Then, we perform query(x, i) where i is an integer sampled uniformly from [1, d]. Proposition 6.8. For any edge e ∈ E, the probability that e is sampled from the edge-sampling procedure is 1/m. Proof. Fix any edge e ∈ E. The edge e belongs to some list Lv. Therefore, the probability that e is queried according to our edge-sampling procedure is √ m) = Ω( √ n/ Pr[e is queried] = Pr[e is queried Lv is sampled] · Pr[Lv is sampled] + Pr[e is queried Lv is not sampled] · Pr[Lv is not sampled] = Pr[e is queried Lv is sampled] · Pr[Lv is sampled] = (1/d) · (1/n) = 1/m. We present an algorithm for testing k-edge connectivity for bounded-degree model and analysis. Algorithm. 1. Sample Θ( 1 2. If any of the sampled vertices has out-degree less than k, return the corresponding trivial  ) vertices uniformly at random. edge cut. 3. For each i ∈ {0, . . . ,blog2 kc} and each j ∈ {0, . . . ,blog2 ηic} where ηi = 2i+2−1blog2 kc, 23 2j−i ) = Θ( (a) Sample Θ(blog2 kcblog2 ηic (b) Let ν = 2j+1, and γ = min{2i − 1,bk/2c}. (c) Run the local algorithm in Corollary 6.3 with parameters (x, ν, k, γ) on both G and GR where GR is G with reversed edges, and x is a vertex from the sampled edge of the form (x, y). 1 2j−i ) edges uniformly at random. 4. Return an edge cut of size less than k if any execution of the local algorithm above returns a cut. Otherwise, declare that G is k-edge connected. Query Complexity. We first show that the number of edge queries is at most O(k/). For each vertex x from the sampled edge (x, y) and for each (i, j) pair in loops, the local algorithm in Corollary 6.3 queries O(νk/γ) = O(2j−ik) edges, and we sample O(1/(2j−i)) times. Therefore, by repeating O(1) time, the total edge queries is at most O(k/). Correctness. If G is k-edge connected, then the algorithm never returns any edge cut, and we are done. Suppose G is -far from being k-edge connected, then we show that the algorithm outputs an edge cut of size less than k with constant probability. Since G is d-regular, we have d = d. Therefore, we can use results from Section 6.1. Let F := {X1, . . . , Xt} as in Theorem 6.5. We assume without loss of generality thatX (k − dout(Xi)) > m. (22) i Let C−1 = {X ∈ F : k ≤ dout(X)}. For i ∈ {0, 1, . . . ,blog2 kc}, let Ci = {X ∈ F : k − dout(X) ∈ [2i, 2i+1)}. Let Ci,big = {X ∈ Ci : volout(X) ≥ 2i+2(blog2 kc + 1)/}, and Ci,small = Ci − Ci,big. By Lemma 6.6, there is an i ∈ {0, 1, . . . ,blog2 kc} such that X∈Ci,small,j Ci,small ≥ nd/(4k(blog2 kc + 1)) = m/(4k(blog2 kc + 1)). {0, 1, . . . ,blog2 ηic} such that P (23) This last inequality follows since nd = nd = m. Now let ηi = 2i+2−1blog2 kc, and for every j ∈ {0, 1, . . . ,blog2 ηic}, let Ci,small,j = {X ∈ Ci,small : volout(X) ∈ [2j, 2j+1)}. Lemma 6.9. For the i ∈ {0, . . . ,blog2 kc} that satisfies Equation (23), there is a j ∈ volout(X) ≥ m2j−i/(4(blog2 kc + 1)(blog2 ηic + 1)). Let us briefly argue that Lemma 6.9 implies the correctness of the algorithm. By sampling Θ(blog2 kcblog2 ηic 1 2j−i ) edges, we get that the event that a sampled edge (u, v) has u ∈ X for some X ∈ Ci,small,j with constant probability (since Ci,small,j contains disjoint elements). For each (i, j) ∈ {0, 1, . . . ,blog2 kc} × {0, . . . ,blog2 ηic}, we run the local algorithm thatP in Corollary 6.3 with ν = 2j+1, and γ = min{2i − 1,bk/2c}; also, there exists a pair (i, j) such volout(X) ≥ m2j−i/(4(blog2 kc + 1)(blog2 ηic + 1)) by Lemma 6.9. Therefore, the local algorithm in Corollary 6.3, outputs an edge cut of size less than k with constant probability. Note that the preconditions of the local algorithm in Corollary 6.3 can be shown to hold in a similar manner as in the previous subsection . Proof of Lemma 6.9. We first claim that there is j ∈ {0, 1, . . . ,blog2 ηic} such that ) = Θ( 2j−i X∈Ci,small,j Ci,small,j ≥ Ci,small/(blog2 ηic + 1) (24) 24 Suppose otherwise. Then we have that Ci,small,j < Ci,small/(blog2 ηic + 1) for all j ∈ j∈{0,...,blog2 ηic} Ci,small,j < Ci,small, a contradiction. {0, . . . ,blog2 ηic}, and thereforeP Now, for the j ∈ {0, 1, . . . ,blog2 ηic} that satisfies (24) we have X X∈Ci,small,j volout(X) ≥ Ci,small,j2j (24)≥ Ci,small2j/(blog2 ηic + 1) (23)≥ m2j/(4k(blog2 kc + 1)(blog2 ηic + 1)) (12)≥ m2j−i/(4(blog2 kc + 1)(blog2 ηic + 1)) The first inequality holds because the set Ci,small,j contains disjoint elements and volout(X) ≥ 2j by the definition of Ci,small,j. An improved bound for simple graphs. The same algorithm gives the improved bound of O(min{k/, 1/2}) queries when G is simple. If  ≤ 4/k, then the algorithm queries at most O(k/) = O(1/2) edges. Otherwise, if  > 4/k, by Lemma 6.7, there are Ω(n) many vertices with degree less than k, and this implies that the algorithm outputs an edge cut of size less than k at step 2. 6.3 Testing k-Vertex Connectivity: Unbounded-Degree Model In this section, we prove Theorem 6.1 for testing k-vertex connectivity where k < n 8 min{1,  12480blog2(m/n) + 1c} = O(n) (25) The key tool for our property testing algorithm is approximate local vertex connecitvity in a suitable form for the application to property testing. Corollary 6.10. There exists the following randomized algorithm. It takes as inputs, • a pointer to an adjacency list representing an n-vertex m-edge graph G = (V, E), • a seed vertex x ∈ V , • a volume parameter (positive integer) ν, • a cut-size parameter (positive integer) k, and • a slack parameter (non-negative integer) γ, where 1 ≤ k − γ ≤ n/4, γ ≤ k/2 and ν < m(γ + 1)/(12480(k − γ)). (26) It accesses (i.e., makes queries for) O(νk/(γ + 1)) edges. It then outputs in the following manner. • If there exists a separation triple (L0, S0, R0) such that L0 3 x, volout(L0) ≤ ν, and S0 < k − γ, then with probability at least 3/4, the algorithm outputs a vertex-cut of size at most k (otherwise it outputs ⊥). • Otherwise (i.e., no such separation triple (L0, S0, R0) exists), the algorithm outputs either a vertex-cut of size at most k or ⊥. 25 Proof. If ν < k − γ, then it is enough to run the following procedure. If deg(x) < k − γ, then we found a cut of size smaller than k, and return N out(x). Otherwise, we return ⊥. To see that we return ⊥ correctly, for any vertex set L0 that contains x, we have volout](L0) ≥ k − γ > ν, and thus we correctly output ⊥. From now, we assume that ν ≥ k − γ. (27) Let the following tuple (x0, ν0, k0, γ0) be a list of parameter supplied to Theorem 4.1. We run the local algorithm in Theorem 4.1 using (x0, ν0, k0, γ0) = (x, ν, k−γ, γ). Note that Equation (26) and Equation (27) ensure that the conditions in Equation (4) for the local algorithm with parameter (x0, ν0, k0, γ0) are satisfied. The query complexity follows from the algorithm from Theorem 4.1. We present an algorithm for testing k-vertex connectivity and analysis. Algorithm. 1. Sample Θ(1) vertices uniformly at random. 2. If any of the sampled vertices x has out-degree less than k, return N(x). 3. Sample Θ(k log k/(d)) vertices uniformly at random (if d is unknown, sample Θ(log k/) vertices instead). 4. For each sampled vertex x, and for i ∈ {0, . . . ,blog2 kc}, (a) Let ν = 2i+3blog2 kc/, and γ = min{2i − 1,bk/2c}. (b) Run the local algorithm in Corollary 6.10 with parameters (x, ν, k, γ) on both G and GR where GR is the same graph with reversed edges. 5. Return a vertex cut of size less than k if any execution of the local algorithm above returns a vertex cut. Otherwise, declare that G is k-vertex connected. Query Complexity. We first show that the number of edge queries is at most O(k2/(2d)). For each sampled vertex x and i ∈ {0, . . . ,blog2 kc}, the local algorithm in Corollary 6.10 queries O(νk/γ) = O(k/) edges. The result follows as we repeat blog2 kc times per sample, and we sample O(k log k/(d)) times. Correctness. If G is k-vertex connected, it is clear that the local algorithm Corollary 6.10 never returns any vertex cut. We show that if G is -far from k-vertex connected, then the algorithm outputs a vertex cut of size less than k with constant probability. We start with a simple observation. Lemma 6.11. If m < nk/4, then with constant probability, the algorithm outputs a vertex cut of size less than k at step 2. Proof. Suppose m < nk/4. There are at most n/2 vertices with out-degree at least k. Hence, there are at least n/2 vertices of degree less than k. In this case, we can sample O(1) times where for each sampled vertex x we check N(x) < k to find a k-vertex cut with constant probability. 26 From now we assume that m ≥ nk/4. (28) We start with important properties when G is -far from k-vertex connected. We say that (L,S,R)∈F0 max{k − S, 0} > m. two separation triples (L, S, R) and (L0, S0, R0) are independent if L ∩ L0 = ∅ or R ∩ R0 = ∅. Theorem 6.12 ([OR11] Corollary 17). If a directed graph G = (V, E) is -far from being k-vertex connected, then there exists a set F0 of pairwise independent separation triples7 such that P p(F) :=P Let F be a family of pairwise independent separation triples of G such that P (L,S,R)∈F(max{k − S, 0}) is maximized. It directly follows from Theorem 6.12 that (L,S,R)∈F max{k − S, 0} > m. We say that a left-partition L of a separation triple (L, S, R) is small if L ≤ R. Similarly, a right-partition R is small if R ≤ L. Lemma 6.13 ([FJ99] Lemma 7). The small left-partitions8 in F are pairwise disjoint, and the small right-partitions in F are pairwise disjoint. Let FL be the set of separation triples with small left-partitions in F, and FR be the set of separation triples with small-right partitions in F. By Theorem 6.12, we have that max{p(FL), p(FR)} > m/2. We assume without loss of generality that p(FL) > m/2. (29) Let C−1 = {(L, S, R) ∈ FL : S ≥ k}. For i ∈ {0, . . . ,blog2 kc}, let Ci = {(L, S, R) ∈ FL : k − S ∈ [2i, 2i+1)}. Let Ci,big = {(L, S, R) ∈ Ci : volout(L) ≥ 2i+3−1(blog2 kc + 1)}, and Ci,small = Ci − Ci,big. The following lemma is the key for the algorithm's correctness. Lemma 6.14. There is an i∗ ∈ {0, 1, . . . ,blog2 kc} such that Ci∗,small > nd/(8k(blog2 kc+1)). If d is unknown, then there is an i∗ ∈ {0, 1, . . . ,blog2 kc} such that Ci∗,small ≥ n/(32(blog2 kc+ 1)). Let us briefly argue that Lemma 6.14 implies the correctness of the algorithm. If Lemma 6.14 is true, then by sampling Θ((k log k)/(d)) many vertices (or Θ(log k/()) vertices if d is unknown), the event that a sampled vertex belongs to some vertex set L0 in a separation triple (L0, S0, R0) ∈ Ci∗,small has constant probability (since Ci∗,small contains pairwise disjoint small left-partitions by Lemma 6.13).9 Now, assuming that a sampled vertex x belongs to a vertex set L0 as specified above. Since L0 ∈ Ci∗,small, by definition, volout(L0) ≤ 2i∗+3−1(blog2 kc + 1), and k − S0 ∈ [2i∗ , 2i∗+1). In other words, L0 3 x, volout(L0) ≤ 2i∗+3−1(blog2 kc + 1), and S0 ≤ k − 2i∗ < k − (2i∗ − 1). If i∗ was known, then we run the local algorithm in Corollary 6.10 with parameters (x, ν, k, γ) where ν = 2i∗+3−1(blog2 kc + 1), and γ = min{2i∗ − 1,bk/2c} to 7We use the term separation triple (L, S, R) instead of the term one-way pair (L, R) used by [OR11] for notational consistency in our paper. These terms are equivalent in that there is no edge from L to R and our S is their V − (L ∪ R). 8In [FJ99], they use the term one-way pair (T, H), and define a tail T of a pair (T, H) if small if T ≤ H. Similarly, they define a head H of a pair (T, H) to be small if H ≤ T. We only repharse from "tail" to left-partition, and "head" to right-partition. 9We assumed left-partition above without loss of generality in the proof above, but in the algorithm both cases can happen. 27 obtain a vertex cut of size less than k with probability at least 3/4. Since i∗ ∈ [0, 1, . . . ,blog2 kc}, it is enough to run the local algorithm in Corollary 6.10 with parameters (x, νi, k, γi) where νi = 2i+3−1(blog2 kc + 1) and γi = min{2i − 1,bk/2c} for every i ∈ {0, 1, . . . ,blog2 kc}. It remains to check the preconditions for the local algorithm in Corollary 6.10. We show that Equation (26) is satisfied for any call of the local algorithm. It is easy to see that the first condition k ≥ 1+γ is satisfied, and k−γ ≤ n/4 follows from Equation (25). The second condition γ ≤ k/2 follows since γi = min{2i − 1,bk/2c} ≤ bk/2c ≤ k/2 for any i ∈ {0, 1, . . . ,blog2 kc}. Finally, we show the last condition ν < m(γ + 1)/(12480(k − γ)) is satisfied. First, note that the for any i ∈ {0, 1, . . . ,blog2 kc}, νi = 2i+3−1(blog2 kc + 1) ≤ 8−1k(blog2 kc + 1). Therefore, ν ≤ 8−1k(blog2 kc + 1) (28)≤ 8 m−1 n blog2(m/n) + 1c (25) < m 12480k < m(γ + 1)/(12480(k − γ)) (30) This last inequality follows since 0 ≤ γ ≤ k/2. Therefore, the correctness follows. Proof of Lemma 6.14. First, we show that there is an i ∈ {0, 1, . . . ,blog2 kc} such that To this end, we show that there is an i ∈ {0, 1, . . . ,blog2 kc} such that Ci > m/(2i+2(blog2 kc + 1)). X (k − S) > m/(2(blog2 kc + 1)). (L,S,R)∈Ci Suppose otherwise that for every i ∈ {0, 1, . . . ,blog2 kc}, we have P X m/(2(blog2 kc + 1)). Then we get blog2 kcX blog2 kcX X X (max{k − S, 0}) = (k − S) = (L,S,R)∈Ci (k − S) ≤ m/2. (31) (32) (k − S) ≤ (L,S,R)∈FL However, this contradicts Equation (29). Second, observe that for every i ∈ {0, 1, . . . ,blog2 kc}, (33) Ci2i+1 ≥ X (k − S). (L,S,R)∈Ci (L,S,R)∈Ci i=0 i=−1 (L,S,R)∈Ci This follows trivially from that each (L, S, R) in the set Ci, k − S ≤ 2i+1. Therefore, for the i ∈ {0, 1, . . . ,blog2 kc} that satisfies Equation (32), we have (k − S)/2i+1 (32) > m/(2i+2(blog2 kc + 1)). (34) Ci (33)≥ X (L,S,R)∈Ci Recall that Ci,big = {(L, S, R) ∈ Ci : volout(L) ≥ 2i+3(blog2 kc + 1)/}, and Ci,small = Ci − Ci,big. We claim that for the i ∈ {0, 1, . . . ,blog2 kc} that satisfies Equation (34), Ci,big < Ci/2. Indeed, we have 2Ci,big ≤ X (L,S,R)∈Ci,big volout(L)/(2i+2−1(blog2 kc + 1)) ≤ m/(2i+2−1(blog2 kc + 1)) (31) < Ci. 28 The first inequality follows because volout(L)/(2i+2−1(blog2 kc + 1)) ≥ 2 for each (L, S, R) ∈ disjoint, andP Ci,big by the definition of Ci,big. The second inequality follows since left-partitions in Ci,big are (L,S,R)∈Ci,big volout(L) ≤ m. Next, we have Ci,small ≥ Ci/2 (31) > m/(2i+3(blog2 kc + 1)) ≥ nd/(8k(blog2 kc + 1)). (35) The first inequality follows because Ci,big < Ci/2, and Ci = Ci,big + Ci,small. The last inequality follows because m = nd, and 2i ≤ k. If d is unknown, the last inequality of (28)≥ nk/(32k(blog2 kc + 1)) = n/(32(blog2 kc + Equation (35) becomes m/(2i+3(blog2 kc + 1)) 1)). 6.4 Testing k-Vertex Connectivity: Bounded-Degree Model In this section, we prove Theorem 6.1 for testing k-vertex connectivity in the bounded degree model. By the same argument as in Section 6.2, we assume that G is d-regular, and thus we can sample edge uniformly by Proposition 6.8. We present an algorithm for testing k-edge connectivity for bounded-degree model assuming Corollary 6.10. Algorithm. 1. Sample Θ(1) vertices uniformly at random. 2. If any of the sampled vertices x has out-degree less than k, return N(x). 3. For each i ∈ {0, . . . ,blog2 kc} and each j ∈ {0, . . . ,blog2 ηic} where ηi = 2i+2−1blog2 kc, 2j−i ) = Θ( (a) Sample Θ(blog2 kcblog2 ηic (b) Let ν = 2j+1, and γ = min{2i − 1,bk/2c} . (c) Run the local algorithm in Corollary 6.10 with parameters (x, ν, k, γ) on both G and GR where GR is G with reversed edges, and x is a vertex from the sampled edge of the form (x, y). 1 2j−i ) edges uniformly at random. 4. Return a vertex cut of size less than k if any execution of the local algorithm above returns a vertex cut. Otherwise, declare that G is k-vertex connected. Query Complexity. We first show that the number of edge queries is at most O(k/). For each vertex x from the sampled edge (x, y) and for each (i, j) pair in loops, the local algorithm in Corollary 6.10 queries O(νk/γ) = O(2j−ik) edges, and we sample O(1/(2j−i)) times. Therefore, by repeating O(1) itereations, the total edge queries is at most O(k/). Correctness. If G is k-vertex connected, then the algorithm never returns any vertex cut, and we are done. Suppose G is -far from being k-vertex connected, then we show that the algorithm outputs a vertex cut of size less than k with constant probability. Since G is d-regular, we have d = d. Therefore, we can use results from Section 6.3. Let FL be the set of separation triples with small left-partitions in F, and FR be the set of separation triples with small-right 29 partitions in F. By Theorem 6.12, we have that max{p(FL), p(FR)} > m/2. We assume without loss of generality that (36) Let C−1 = {(L, S, R) ∈ FL : k ≤ S}. For i ∈ {0, . . . ,blog2 kc}, let Ci = {(L, S, R) ∈ FL : k − S ∈ [2i, 2i+1)}. Let Ci,big = {(L, S, R) ∈ Ci : volout(L) ≥ 2i+3−1blog2 kc}, and Ci,small = Ci − Ci,big. By Lemma 6.14, there is i such that p(FL) > m/2. Ci,small > nd/(8k(blog2 kc + 1)) = m/(8k(blog2 kc + 1)). (37) 2j−i ) = Θ( (L,S,R)∈Ci,small,j {0, . . . ,blog2 ηic} such thatP The last inequality follows since nd = nd = m. We fix i as in Equation (37). Let ηi = 2i+3−1blog2 kc. For j ∈ {0, . . . ,blog2 ηic}, let Ci,small,j = {(L, S, R) ∈ Ci,small : volout(L) ∈ [2j, 2j+1)}. Lemma 6.15. For the i ∈ {0, . . . ,blog2 kc} that satisfies Equation (37), there is a j ∈ volout(L) ≥ m2j−i/(8(blog2 kc + 1)(blog2 ηic + 1)). Let us briefly argue that Lemma 6.15 implies the correctness of the algorithm. By sampling Θ(blog2 kcblog2 ηic 1 2j−i ) many edges, we get that the event that a sampled edge (u, v) has u ∈ L for some L from a separation triple (L, S, R) ∈ Ci,small,j hat constant probabil- ity (since Ci,small contains pairwise disjoint small left-partitions by Lemma 6.13). For each ν = 2j+1, and γ = 2i − 1; also, there exists a pair (i, j) such that P (i, j) ∈ {0, 1, . . . ,blog2 kc}×{0, . . . ,blog2 ηic}, we run the local algorithm in Corollary 6.10 with volout(X) ≥ m2j−i/(8(blog2 kc + 1)(blog2 ηic + 1)) by Lemma 6.15. Therefore, the local algorithm in Corollary 6.10 outputs a vertex cut of size less than k with constant probability. Note that the preconditions of the local algorithm in Corollary 6.10 can be shown to hold in a similar manner as in the previous subsection. Proof of Lemma 6.15. We claim that there is j ∈ {0, . . . ,blog2 ηic} such that X∈Ci,small,j (38) Suppose otherwise. Then we have that Ci,small,j < Ci,small/(blog2 ηic + 1) for all j ∈ Ci,small,j ≥ Ci,small/(blog2 ηic + 1) {0, . . . ,blog2 ηic}, and thereforeP j∈{0,...,blog2 ηic} Ci,small,j < Ci,small, a contradiction. Now, for the j ∈ {0, . . . ,blog2 ηic} satisfying (38), we have X (L,S,R)∈Ci,small,j volout(L) ≥ Ci,small,j2j (38)≥ Ci,small2j/(blog2 ηic + 1) (37)≥ m2j/(8k(blog2 kc + 1)(blog2 ηic + 1)) ≥ m2j−i/(8(blog2 kc + 1)(blog2 ηic + 1)) The first inequality holds because the small left-partitions in Ci,small,j are pairwise disjoint by Lemma 6.13 and volout(L) ≥ 2j by definition. The last inequality follows since 2i ≤ k by definition. 30 7 Maximal k-Edge Connected Subgraphs In the following, we consider the problem of computing the maximal k-edge connected sub- graphs of directed and undirected graphs. In directed graphs, we essentially follow the overall algorithmic scheme of Chechik et al. [Che+17] and obtain an improvement by plugging in our new local cut-detection procedure. In undirected graphs, we additionally modify the algorithmic scheme to obtain further running time improvements. A maximal k-edge connected subgraph H of a graph G is a subgraph that is k-edge connected and there is no other subgraph of G that is k-edge connected and contains H as a proper subgraph. Observe that each maximal k-edge connected subgraph is characterized by its set of vertices, we can thus restrict ourselves to subgraphs induced by subsets of vertices. Furthermore, two overlapping vertex sets inducing a k-edge connected subgraph each can always be joined to form a larger vertex set inducing a k-edge connected subgraph. Thus, the decomposition of a graph into its maximal k-edge connected subgraphs is unique. To recap, the goal in this problem is to find a partition of the vertices of a graph such that (a) the subgraph induced by each vertex set of the partition is k-edge connected and (b) there is no vertex set that induces a k-edge connected subgraph and strictly contains one of the vertex sets of the partition. 7.1 Directed Graphs The baseline recursive algorithm for computing the maximal k-edge connected subgraphs works as follows: First, try to find a cut with at most k − 1 cut edges. If such a cut exists, remove the cut edges from the graph and recurse on each strongly connected component of the remaining graph. If no such cut exists, then the graph is k-edge connected. The recursion depth of this algorithm is at most n, and using Gabow's cut algorithm [Gab95], it takes time O(km log n) to find a cut with at most k − 1 cut edges. Therefore this algorithm has a running time of O(kmn log n). The idea of Chechik et al. is to speed up this baseline algorithm by using a local cut-detection procedure as follows: The algorithm ensures that the graph contains no components with less than k outgoing edges of out-volume at most ν and no components with less than k incoming edges of in-volume at most ν anymore before Gabow's global cut algorithm is invoked. This can be achieved as follows: If the number of edges in the graph is at most S(ν) (an upper bound on the volume of the component returned by the local cut-detection procedure), then the basic algorithm is invoked. Otherwise, the algorithm maintains a list L of vertices which it considers as potential seed vertices for the local cut procedure. Initially, L consists of all vertices. For every vertex x of L the algorithm first tries to detect a small component containing x and then a small containing x. It then removes x from L and if a component C was detected, it removes C from the graph (as well as the outgoing and incoming edges of C) and adds the heads of the outgoing edges and the tails of the incoming edges to L. Each component found in this way is processed (recursively) with the baseline algorithm. Once L is empty, Gabow's cut algorithm is invoked on the remaining graph, the cut edges are removed from the graph, and the strongly connected components of the remaining graph are computed. The algorithm then recurses on each strongly connected component with a new list L0 consisting of all endpoints of the removed cut edges contained in this strongly connected component. As a preprocessing step to this overall algorithm, we first compute the strongly connected components and run the algorithm on each strongly connected component separately.10 10We have added this preprocessing step to ensure that n = O(m) for each strongly connected component in 31 The running time analysis is as follows. The strongly connected components computation in the preprocessing can be done in time O(m + n). For every vertex, we initiate the local cut detection initially and whenever it was the endpoint of a removed edge. We thus initiate at most O(n + m) = O(m) local cut detections, each taking time T(ν). It remains to bound the time spent for the calls of Gabow's cut algorithm and the subsequent computations of strongly connected components after removing the cut edges. On a strongly connected graph with initially m0 edges, these two steps take time O(km0 log n). Consider all recursive calls at the same recursion level of the algorithm. As the graphs that these recursive calls operate on are disjoint, the total time spent at this recursion level is O(km log n). To bound the total recursion depth, observe that for a graph with initially m0 edges, the graph passed to each recursive call has at most max{m0 − ν, S(ν)} edges as the only cuts left to find for Gabow's cut algorithm either have in- or out-volume at least ν on one side of the cut. Thus, the recursion depth is O( m ν + S(ν)). Altogether, we therefore arrive at a running time of (cid:18) (cid:18) m ν (cid:19) m · T(ν) + O + S(ν) · km log n + n . (cid:19) Observe further that a one-sided Monte-Carlo version of the local cut-detection procedure, as the one we are giving in this paper, only affects the recursion depth. If each execution of the procedure is successful with probability p ≥ 1 − 1 n3 , then the probability that all O(m) = O(n2) executions of the procedure are successful is at least 1− O( 1 n). As the worst-case recursion depth is at most n, the expected recursion depth is at most O((1− 1 n)·( m ν +S(ν)). n·n) = O( m The analysis of this algorithmic scheme can be summarized in the following lemma. ν +S(ν))+ 1 Lemma 7.1 (Implicit in [Che+17]). Suppose there is an algorithm that, given constant-time query access to a directed graph, for a fixed k ≥ 2, any integer ν ≥ 1 and any seed vertex x, runs in time T(ν) and has the following behavior: (1) If there is a set L ⊆ V containing x with E(L, V − L) < k of volume at most ν, then the algorithm returns such a set of volume at most S(ν) with probability at least 1 − 1 n3 (and ⊥ otherwise) and (2) if no such set exists, then the algorithm returns ⊥. Then there is an algorithm for computing the maximal k-edge connected subgraphs of a ν + S(ν)) · km log n + n) for every directed graph with expected running time O(m · T(ν) + ( m 1 ≤ ν ≤ m. For any ν ≥ 1, our improved local cut-detection procedure of Corollary 3.2 has T(ν) = O(k2ν) 2.11 We can boost the success probability to 1 − 1 and S(ν) = O(kν) with success probability 1 n3 by repeating the algorithm dlog(3n)e times, which leads to T(ν) = O(k2ν log n). By setting ν = , we arrive at running time of O k2mν log n + + kν · km log n + n = O(k3/2m3/2 log n + n) . (cid:19) (cid:18) m ν (cid:19) √ m√ k (cid:18) Theorem 7.2. There is a randomized Las Vegas algorithm for computing the maximal k-edge connected subgraphs of a directed graph that has expected running time O(k3/2m3/2 log n + n). the running time analysis. 11Note that with this choice of ν the precondition ν < m/(130k) of Corollary 3.2 holds for any k < m/1302. For larger k, we can simply return V to satisfy the conditions of (1) in Lemma 7.1. 32 7.2 Undirected Graphs In undirected graphs, we obtain a tighter upper bound on the running time of the algorithm for three reasons. First, instead of parameterizing the algorithm by a target volume ν, we parameterize it by a target vertex size σ. Thus, whenever the list L in the algorithm becomes empty we can be sure that there is no component of vertex size at most σ in the current graph anymore. Components that are larger can be found at most n σ times. Second, for each component detected by the local cut procedure the number of incoming edges equals its number of outgoing edges and is at most k − 1. Thus, the number of removed edges per successful component detection is at most k − 1. As there are at most n such successful detections in total, the total number of executions of the local cut-detection procedure is at most n + (k − 1)n = kn. Third, in undirected graphs we can run instances of both Gabow's global cut detection algorithm and our local cut detection algorithm on a sparse k-edge connectivity certificate [Thu89, NI92] of the current graph. The sparse certificate can be computed in time O(m + n), but we do not want to explicitly perform this expensive computation each time edges are removed from the graph. Instead, we maintain the sparse certificate with a dynamic algorithm as outlined below.12 As the k-edge connectivity certificate has O(kn) edges, Gabow's cut algorithm has running time O(k2n log n) if it is run on the certificate. Furthermore, as observed by Nanongkai et al. [NSY19a], the k-edge connectivity certificate has arboricity k. Since the arboricity bounds the local density of any vertex-induced subgraph, the volume of a component of vertex size σ is O(σk) on the k-edge connectivity certificate. Each instance of the local cut detection procedure therefore has running time T(kσ) and if successful detects a component of volume S(kσ). A sparse k-edge connectivity certificate of a graph G = (V, E) is a graph H = (V, F1∪. . .∪Fk) 1≤j≤i−1 Fj) (where in particular (V, F1) is a spanning forest of G). The dynamic connectivity algorithm of Holm et al. [HLT01] can be used to dynamically maintain a spanning forest of a graph undergoing edge insertions and deletions in time O(log2 n) per update. Maintaining the hierarchy of spanning forests for a k-edge connectivity certificate under a sequence edge removals to G takes time O(km log2 n) by the following argument13: The dynamic algorithm of Holm et al. makes at most one change to the spanning forest per change to the input graph. Therefore each deletion in G causes at most one update to to each of the k levels of the hierarchy. As at most m edges can be removed from G, the total update time is O(km log2 n). such that for every 1 ≤ i ≤ k the graph (V, Fi) is a spanning forest of (V, E−S Using otherwise the same analysis as in Section 7.1, we arrive at the following running time: + S(kσ) · k2n log n + km log2 n . (cid:19) (cid:18) kn · T(kσ) + O (cid:18) n σ (cid:19) The analysis of this algorithmic scheme can be summarized in the following lemma. Lemma 7.3. Suppose there is an algorithm that, given constant-time query access to an undirected graph, for a fixed k ≥ 2, any integer ν ≥ 1 and any seed vertex x, runs in time T(ν) and has the following behavior: (1) If there is a set L ⊆ V containing x with E(L, V −L) < k of volume at most ν, then the algorithm returns such a set of volume at most S(ν) with probability n3 (and ⊥ otherwise) and (2) if no such set exists, then the algorithm returns ⊥. at least 1 − 1 12Let us emphasize again that the sparse certificate is not w.r.t. to the input graph but w.r.t. to the graph in which all cut edges found by Gabow's algorithm and all edges incident on components detected by the local algorithm have been removed. 13This argument is similar to the one for maintaining the cut sparsifier in [Abr+16]. 33 Then there is a randomized Las Vegas algorithm for computing the maximal k-edge connected σ + S(kσ)) · subgraphs of an undirected graph with expected running time O(kn · T(kσ) + ( n k2n log n + km log2 n) for every 1 ≤ σ ≤ n. For any σ ≥ 1, our local cut-detection procedure of Corollary 3.2 has T(kσ) = O(k3σ) and 2. We can boost the success probability to 1 − 1 S(kσ) = O(k2σ) with success probability 1 n3 by repeating the algorithm dlog(3n)e times, which leads to T(ν) = O(k3σ log n). Thus, the (cid:19) running time is (cid:18) (cid:19) O k4nσ log n + + k2σ · k2n log n + km log2 n . (cid:18) n σ n √ k , we obtain a running time of O(k3n3/2 log n + km log2 n). By setting σ = Theorem 7.4. There is a randomized Las Vegas algorithm for computing the maximal k-edge connected subgraphs of an undirected graph that has expected running time O(k3n3/2 log n + km log2 n). Remark on Sparse Certificates Our algorithm tailored to undirected graphs relies on sparse certificates. It would be tempting to run our algorithm for directed graphs directly on a sparse certificate to achieve running-time savings by performing a maximum amount of sparsification. However this approach does not work as Figure 2 shows. Sparse certificates preserve the k-edge connectivity, but not necessarily the maximal k-edge connected subgraphs. Figure 2: The top row shows an example of an undirected graph on the left with maximal 3-edge component consisting of four vertices (marked by the yellow box) that is not preserved in its sparse certificate on the right. The bottom row shows the 3 spanning forests found for the sparse certificate. Acknowledgement S. Forster and L. Yang would like to thank Asaf Ferber for fruitful discussions. S. Forster would additionally like to thank Gramoz Goranci for giving comments on a draft related to this 34 paper. 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 and 759557. Nanongkai was also partially supported by the Swedish Research Council (Reg. No. 2015-04659.). A An Alternative Algorithm for Local Edge Connectivity In this section, we give another local algorithm for detecting an edge cut of size k and volume ν containing some seed vertex in time O(νk2). Both algorithm and analysis are very simple. Theorem A.1. There is a randomized (Monte Carlo) algorithm that takes as input a vertex x ∈ V of an n-vertex m-edge graph G = (V, E) represented as adjacency lists, a volume parameter ν, a cut-size parameter k ≥ 1, and an accuracy parameter  ∈ (0, 1] where ν < m/8 and runs in O(νk/) time and outputs either • the symbol "⊥" indicating that, with probability 1/2, there is no S 3 x where E(S, V − S) < k and volout(S) ≤ ν, or k, we have that b(1 + )kc = k. In particular, we obtain an algorithm for • a set S 3 x where S 6= V , E(S, V − S) < b(1 + )kc and volout(S) ≤ 10ν/.14 By setting  < 1 the exact problem: Corollary A.2. There is a randomized (Monte Carlo) algorithm that takes as input a vertex x ∈ V of an n-vertex m-edge graph G = (V, E) represented as adjacency lists, a volume parameter ν, and a cut-size parameter k ≥ 1 where ν < m/8k and runs in O(νk2) time and outputs either • the symbol "⊥" indicating that, with probability 1/2, there is no S 3 x where E(S, V − S) < k and volout(S) ≤ ν, or • a set S 3 x where S 6= V , E(S, V − S) < k and volout(S) ≤ 10νk. Algorithm 2: LocalEC(x, ν, k, ) 1 repeat b(1 + )kc times 2 3 4 5 6 7 8 return ⊥. Grow a DFS tree T starting from x and stop once exactly 8ν/ edges have been visited. Let EDFS be the set of edges visited. if EDFS < 8ν/ then return V (T). else Sample an edge (y0, y) ∈ EDFS uniformly. Reverse the direction of edges in the path Pxy in T from x to y. The algorithm for Theorem A.1 in described in Algorithm 2. We start with the following important observation. 14We note that the factor 10 in Theorem A.1 can be improved. We only use this factor for simplifying the analysis. 35 Lemma A.3. Let S ⊂ V be any set where x ∈ S. Let Pxy be a path from x to y. Suppose we reverse the direction of edges in Pxy. Then, we have E(S, V − S) and volout(S) are both decreased exactly by one if y /∈ S. Otherwise, E(S, V − S) and volout(S) stay the same. It is clear that running time of Algorithm 2 is b(1 + )kc × O(ν/) = O(νk/) because the DFS tree only requires O(ν/) for visiting O(ν/) edges. The two lemmas below imply the correctness of Theorem A.1 Lemma A.4. If a set S is returned, then S 3 x, S 6= V , E(S, V − S) < b(1 + )kc and volout(S) ≤ 10ν/. Proof. If S is returned, then the DFS tree T get stuck at S = V (T). That is, E(S, V − S) = 0 and volout(S) ≤ 8ν/ at the end of the algorithm. Note that x ∈ S and S 6= V because 8ν/ < m. Observe that the algorithm has reversed strictly less than b(1 + )kc many paths Pxy, because the algorithm did not reverse a path in the iteration that S is returned. So Lemma A.3 implies that, initially, E(S, V − S) < b(1 + )kc and, volout(S) < 8ν/ + b(1 + )kc ≤ 10ν/. Lemma A.5. If ⊥ is returned, then, with probability at least 1/2, there is no S 3 x where E(S, V − S) < k and volout(S) ≤ ν. Proof. Suppose that such S exists. We will show that ⊥ is returned with probability less than 1/2. Suppose that no set S0 is returned before the last iteration. It suffices to show that at the beginning of the last iteration, E(S, V − S) = 0 with probability at least 1/2. If this is true, then the DFS tree T in the last iteration will not be able to visit more than ν edges and so will return the set V (T). Let k0 = b(1 + )kc − 1 denote the number of iterations excluding the last one. Let Xi be the random variable where Xi = 1 if the sampled edge (y0, y) in the i-th iteration of the algorithm satisfies y ∈ S. Otherwise, Xi = 0. As volout(S) never increases, observe that E[Xi] ≤ EDFS ≤ ν i=1 Xi. We have E[X] ≤ k0/8 by linearity of volout(S) expectation and Pr[X ≤ k0/4] ≥ 1/2 by Markov's inequality. So Pr[X ≤ bk0/4c] ≥ 1/2 as X is integral. Let Y = k0 − X. Notice that Y is the number of times before the last iteration where the algorithm samples y /∈ S. We claim that k0 − bk0/4c ≥ k − 1 (see the proof at the end). Hence, with probability at least 1/2, Y ≥ k0 − bk0/4c ≥ k − 1 ≥ E(S, V − S). By Lemma A.3, if Y ≥ E(S, V − S), then E(S, V − S) = 0 at the beginning of the last iteration. This concludes the proof. Claim A.6. k0 − bk0/4c ≥ k − 1 for  ∈ [0, 1] Proof. If  < 4/k0, then bk0/4c = 0, so k0 − bk0/4c = b(1 + )kc − 1 ≥ k − 1. If  ≥ 4/k0, then15 8ν/ = /8 for each i ≤ k0. Let X =Pk0 k0 −(cid:4)k0/4(cid:5) ≥ (1 − /4)k0 ≥ (1 − /4)((1 + )k − 2) ≥ (1 − /4)(1 + )k − 2 ≥ (1 + /2)k − 2 ≥ k − 1. 15The main reason we choose the factor 8 in the number 8ν/ of visited edges by the DFS is for simplifying the following inequalities. 36 where the last inequality is because k/2 ≥ 4 k0 · k 2 ≥ 1 as k0 ≤ b(1 + )kc ≤ 2k. References [Abr+16] Ittai Abraham, David Durfee, Ioannis Koutis, Sebastian Krinninger, and Richard Peng. "On Fully Dynamic Graph Sparsifiers". In: Proc. of the Symposium on Foundations of Computer Science (FOCS). 2016, pp. 335 -- 344. doi: 10.1109/FOCS. 2016.44. arXiv: 1604.02094 (cit. on p. 33). [AHU74] Alfred V. Aho, John E. Hopcroft, and Jeffrey D. Ullman. The Design and Analysis of Computer Algorithms. Addison-Wesley, 1974 (cit. on p. 4). [Bec+82] Michael Becker, W. Degenhardt, Jürgen Doenhardt, Stefan Hertel, Gerd Kaninke, W. Kerber, Kurt Mehlhorn, Stefan Näher, Hans Rohnert, and Thomas Winter. "A Probabilistic Algorithm for Vertex Connectivity of Graphs". In: Information Processing Letters 15.3 (1982), pp. 135 -- 136. doi: 10.1016/0020-0190(82)90046-1 (cit. on p. 4). András A. Benczúr and David R. Karger. "Randomized Approximation Schemes for Cuts and Flows in Capacitated Graphs". In: SIAM Journal on Computing 44.2 (2015). Announced at STOC '96, pp. 290 -- 319. doi: 10.1137/070705970 (cit. on p. 7). [BK15] [CK19] [Che+17] [CGK14] Keren Censor-Hillel, Mohsen Ghaffari, and Fabian Kuhn. "Distributed connectivity decomposition". In: Proc. of the Symposium on Principles of Distributed Computing (PODC). 2014, pp. 156 -- 165. doi: 10.1145/2611462.2611491. arXiv: 1311.5317 (cit. on p. 4). Shiri Chechik, Thomas Dueholm Hansen, Giuseppe F. Italiano, Veronika Loitzen- bauer, and Nikos Parotsidis. "Faster Algorithms for Computing Maximal 2-Connected Subgraphs in Sparse Directed Graphs". In: Proc. of the Symposium on Discrete Algorithms (SODA). 2017, pp. 1900 -- 1918. doi: 10.1137/1.9781611974782.124. arXiv: 1705.10709 (cit. on pp. 1, 3, 7, 8, 10, 31, 32). Julia Chuzhoy and Sanjeev Khanna. "A new algorithm for decremental single-source shortest paths with applications to vertex-capacitated flow and cut problems". In: Proc. of the Symposium on Theory of Computing (STOC). 2019, pp. 389 -- 400. doi: 10.1145/3313276.3316320. arXiv: 1905.11512 (cit. on p. 17). Joseph Cheriyan and John H. Reif. "Directed s-t Numberings, Rubber Bands, and Testing Digraph k-Vertex Connectivity". In: Combinatorica 14.4 (1994). Announced at SODA '92, pp. 435 -- 451. doi: 10.1007/BF01302965 (cit. on p. 4). Joseph Cheriyan and Ramakrishna Thurimella. "Algorithms for Parallel k-Vertex Connectivity and Sparse Certificates". In: Proc. of the Symposium on Theory of Computing (STOC). 1991, pp. 391 -- 401. doi: 10.1145/103418.103460 (cit. on p. 4). Abdol-Hossein Esfahanian and S. Louis Hakimi. "On computing the connectivities of graphs and digraphs". In: Networks 14.2 (1984), pp. 355 -- 366. doi: 10.1002/net. 3230140211 (cit. on p. 4). [EH84] [CR94] [CT91] 37 [ER18] [ET75] [Eve75] [Fel68] [FJ99] [FY19] [Gab06] [Gab95] [Gal80] Talya Eden and Will Rosenbaum. "On Sampling Edges Almost Uniformly". In: Proc. of the Symposium on Simplicity in Algorithms (SOSA). 2018, 7:1 -- 7:9. doi: 10.4230/OASIcs.SOSA.2018.7. arXiv: 1706.09748 (cit. on p. 23). Shimon Even and Robert Endre Tarjan. "Network Flow and Testing Graph Con- nectivity". In: SIAM Journal on Computing 4.4 (1975), pp. 507 -- 518. doi: 10.1137/ 0204043 (cit. on p. 4). Shimon Even. "An Algorithm for Determining Whether the Connectivity of a Graph is at Least k". In: SIAM Journal on Computing 4.3 (1975), pp. 393 -- 396. doi: 10.1137/0204034 (cit. on pp. 4, 13). William Feller. An Introduction to Probability Theory and Its Applications. Wiley, 1968 (cit. on p. 11). András Frank and Tibor Jordán. "Directed vertex-connectivity augmentation". In: Mathematical Programming 84.3 (1999), pp. 537 -- 553. doi: 10.1007/s101070050038 (cit. on pp. 18, 27). Sebastian Forster and Liu Yang. "A Faster Local Algorithm for Detecting Bounded- Size Cuts with Applications to Higher-Connectivity Problems". In: CoRR abs/1904.08382 (2019). arXiv: 1904.08382 (cit. on p. 1). Harold N. Gabow. "Using expander graphs to find vertex connectivity". In: Journal of the ACM 53.5 (2006). Announced at FOCS '00, pp. 800 -- 844. doi: 10.1145/ 1183907.1183912 (cit. on p. 4). Harold N. Gabow. "A Matroid Approach to Finding Edge Connectivity and Pack- ing Arborescences". In: Journal of Computer and System Sciences 50.2 (1995). Announced at STOC '91, pp. 259 -- 273. doi: 10.1006/jcss.1995.1022 (cit. on pp. 7, 31). Zvi Galil. "Finding the Vertex Connectivity of Graphs". In: SIAM Journal on Computing 9.1 (1980), pp. 197 -- 199. doi: 10.1137/0209016 (cit. on p. 4). [GR02] [GT85] [GGR98] Oded Goldreich, Shafi Goldwasser, and Dana Ron. "Property Testing and its Connection to Learning and Approximation". In: Journal of the ACM 45.4 (1998). Announced at FOCS '96, pp. 653 -- 750. doi: 10.1145/285055.285060 (cit. on p. 5). Oded Goldreich and Dana Ron. "Property Testing in Bounded Degree Graphs". In: Algorithmica 32.2 (2002). Announced at STOC '97, pp. 302 -- 343. doi: 10.1007/ s00453-001-0078-7 (cit. on pp. 1, 3, 5, 6). Harold N. Gabow and Robert Endre Tarjan. "A Linear-Time Algorithm for a Special Case of Disjoint Set Union". In: Journal of Computer and System Sciences 30.2 (1985). Announced at STOC '83, pp. 209 -- 221. doi: 10.1016/0022-0000(85)90014- 5 (cit. on p. 7). Monika Rauch Henzinger. "A Static 2-Approximation Algorithm for Vertex Con- nectivity and Incremental Approximation Algorithms for Edge and Vertex Connec- tivity". In: Journal of Algorithms 24.1 (1997), pp. 194 -- 220. doi: 10.1006/jagm. 1997.0855 (cit. on p. 4). [Hen97] 38 [HKL15] Monika Henzinger, Sebastian Krinninger, and Veronika Loitzenbauer. "Finding 2-Edge and 2-Vertex Strongly Connected Components in Quadratic Time". In: Proc. of the International Colloquium on Automata, Languages, and Programming. 2015, pp. 713 -- 724. doi: 10.1007/978-3-662-47672-7\_58. arXiv: 1412.6466 (cit. on p. 7). Jacob Holm, Kristian de Lichtenberg, and Mikkel Thorup. "Poly-logarithmic deter- ministic fully-dynamic algorithms for connectivity, minimum spanning tree, 2-edge, and biconnectivity". In: Journal of the ACM 48.4 (2001). Announced at STOC '98, pp. 723 -- 760. doi: 10.1145/502090.502095 (cit. on p. 33). [HLT01] [HRG00] Monika Rauch Henzinger, Satish Rao, and Harold N. Gabow. "Computing Vertex Connectivity: New Bounds from Old Techniques". In: Journal of Algorithms 34.2 (2000). Announced at FOCS '96, pp. 222 -- 250. doi: 10.1006/jagm.1999.1055 (cit. on pp. 4, 13, 17). [Kar00] [HRW17] Monika Henzinger, Satish Rao, and Di Wang. "Local Flow Partitioning for Faster Edge Connectivity". In: Proc. of the Symposium on Discrete Algorithms (SODA). 2017, pp. 1919 -- 1938. doi: 10.1137/1.9781611974782.125. arXiv: 1704.01254 (cit. on p. 3). John E. Hopcroft and Robert Endre Tarjan. "Dividing a Graph into Triconnected Components". In: SIAM Journal on Computing 2.3 (1973), pp. 135 -- 158. doi: 10.1137/0202012 (cit. on pp. 1, 4). David R. Karger. "Minimum cuts in near-linear time". In: Journal of the ACM 47.1 (2000). Announced at STOC '96, pp. 46 -- 76. doi: 10.1145/331605.331608 (cit. on p. 3). Daniel J. Kleitman. "Methods for investigating connectivity of large graphs". In: IEEE Transactions on Circuit Theory 16.2 (1969), pp. 232 -- 233. doi: 10.1109/TCT. 1969.1082941 (cit. on p. 4). Ken-ichi Kawarabayashi and Mikkel Thorup. "Deterministic Edge Connectivity in Near-Linear Time". In: Journal of the ACM 66.1 (2019). Announced at STOC '15, 4:1 -- 4:50. doi: 10.1145/3274663. arXiv: 1411.5123 (cit. on p. 3). [Kle69] [HT73] [KT19] [LM17] [LLW88] Nathan Linial, László Lovász, and Avi Wigderson. "Rubber bands, convex embed- dings and graph connectivity". In: Combinatorica 8.1 (1988). Announced at FOCS '86, pp. 91 -- 102. doi: 10.1007/BF02122557 (cit. on p. 4). Reut Levi and Moti Medina. "A (Centralized) Local Guide". In: Bulletin of the EATCS 122 (2017) (cit. on p. 3). David W. Matula. "Determining Edge Connectivity in O(nm)". In: Proc. of the Symposium on Foundations of Computer Science (FOCS). 1987, pp. 249 -- 251. doi: 10.1109/SFCS.1987.19 (cit. on p. 4). Hiroshi Nagamochi and Toshihide Ibaraki. "A Linear-Time Algorithm for Finding a Sparse k-Connected Spanning Subgraph of a k-Connected Graph". In: Algorithmica 7.5&6 (1992), pp. 583 -- 596. doi: 10.1007/BF01758778 (cit. on pp. 4, 17, 33). [Mat87] [NI92] 39 [NSY19a] Danupon Nanongkai, Thatchaphol Saranurak, and Sorrachai Yingchareonthaworn- chai. "Breaking Quadratic Time for Small Vertex Connectivity and an Approxima- tion Scheme". In: Proc. of the Symposium on Theory of Computing (STOC). 2019, pp. 241 -- 252. doi: 10.1145/3313276.3316394. arXiv: 1904.04453 (cit. on pp. 1, 3 -- 5, 16, 17, 33). [OR11] [NSY19b] Danupon Nanongkai, Thatchaphol Saranurak, and Sorrachai Yingchareonthaworn- chai. "Computing and Testing Small Vertex Connectivity in Near-Linear Time and Queries". In: CoRR abs/1905.05329 (2019). arXiv: 1905.05329 (cit. on p. 1). Yaron Orenstein and Dana Ron. "Testing Eulerianity and connectivity in directed sparse graphs". In: Theoretical Computer Science 412.45 (2011), pp. 6390 -- 6408. doi: 10.1016/j.tcs.2011.06.038 (cit. on pp. 1, 3, 5 -- 7, 18, 20, 27). V. D. Podderyugin. "An algorithm for finding the edge connectivity of graphs". In: Vopr. Kibern. 2 (1973), p. 136 (cit. on p. 4). Michal Parnas and Dana Ron. "Testing the diameter of graphs". In: Random Structures & Algorithms 20.2 (2002). Announced at APPROX/RANDOM '99, pp. 165 -- 183. doi: 10.1002/rsa.10013 (cit. on p. 6). [Pod73] [PR02] [Tar72] [SW19] [Rub+11] Ronitt Rubinfeld, Gil Tamir, Shai Vardi, and Ning Xie. "Fast Local Computation Algorithms". In: Proc. of Innovations in Computer Science (ITCS). 2011, pp. 223 -- 238. arXiv: 1104.1377 (cit. on p. 3). Thatchaphol Saranurak and Di Wang. "Expander Decomposition and Pruning: Faster, Stronger, and Simpler". In: Proc. of the Symposium on Discrete Algorithms (SODA). 2019, pp. 2616 -- 2635. doi: 10 . 1137 / 1 . 9781611975482 . 162. arXiv: 1812.08958 (cit. on p. 3). Robert Endre Tarjan. "Depth-First Search and Linear Graph Algorithms". In: SIAM Journal on Computing 1.2 (1972). Announced at FOCS '71, pp. 146 -- 160. doi: 10.1137/0201010 (cit. on pp. 1, 4). Ramakrishna Thurimella. "Techniques for the design of parallel graph algorithms". PhD thesis. University of Texas at Austin, 1989 (cit. on p. 33). Yuichi Yoshida and Hiro Ito. "Testing k-edge-connectivity of digraphs". In: Journal of Systems Science and Complexity 23.1 (2010), pp. 91 -- 101. doi: 10.1007/s11424- 010-9280-5 (cit. on pp. 5 -- 7). Yuichi Yoshida and Hiro Ito. "Property Testing on k-Vertex-Connectivity of Graphs". In: Algorithmica 62.3-4 (2012). Announced at ICALP '08, pp. 701 -- 712. doi: 10. 1007/s00453-010-9477-y (cit. on pp. 5 -- 7). [Thu89] [YI10] [YI12] 40
1905.07483
1
1905
2019-05-17T21:16:39
Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles
[ "cs.DS" ]
In this work we derandomize two central results in graph algorithms, replacement paths and distance sensitivity oracles (DSOs) matching in both cases the running time of the randomized algorithms. For the replacement paths problem, let G = (V,E) be a directed unweighted graph with n vertices and m edges and let P be a shortest path from s to t in G. The {\sl replacement paths} problem is to find for every edge e \in P the shortest path from s to t avoiding e. Roditty and Zwick [ICALP 2005] obtained a randomized algorithm with running time of ~O(m \sqrt{n}). Here we provide the first deterministic algorithm for this problem, with the same ~O(m \sqrt{n}) time. For the problem of distance sensitivity oracles, let G = (V,E) be a directed graph with real-edge weights. An f-Sensitivity Distance Oracle (f-DSO) gets as input the graph G=(V,E) and a parameter f, preprocesses it into a data-structure, such that given a query (s,t,F) with s,t \in V and F \subseteq E \cup V, |F| \le f being a set of at most f edges or vertices (failures), the query algorithm efficiently computes the distance from s to t in the graph G \setminus F ({\sl i.e.}, the distance from s to t in the graph G after removing from it the failing edges and vertices F). For weighted graphs with real edge weights, Weimann and Yuster [FOCS 2010] presented a combinatorial randomized f-DSO with ~O(mn^{4-\alpha}) preprocessing time and subquadratic ~O(n^{2-2(1-\alpha)/f}) query time for every value of 0 < \alpha < 1. We derandomize this result and present a combinatorial deterministic f-DSO with the same asymptotic preprocessing and query time.
cs.DS
cs
Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles Noga Alon Department of Mathematics, Princeton University, Princeton, NJ 08544, USA and Schools of Mathematics and Computer Science, Tel Aviv University, Tel Aviv 69978, Israel. [email protected] Shiri Chechik Blavatnik School of Computer Science, Tel Aviv University, Tel Aviv 69978, Israel. [email protected] Sarel Cohen Blavatnik School of Computer Science, Tel Aviv University, Tel Aviv 69978, Israel. [email protected] Abstract In this work we derandomize two central results in graph algorithms, replacement paths and distance sensitivity oracles (DSOs) matching in both cases the running time of the randomized algorithms. For the replacement paths problem, let G = (V, E) be a directed unweighted graph with n vertices and m edges and let P be a shortest path from s to t in G. The replacement paths problem is to find for every edge e ∈ P the shortest path from s to t avoiding e. Roditty and Zwick [ICALP √ n). Here we provide the first √ n) time. Due to matching conditional lower bounds of Williams et. al. [FOCS 2010], our deterministic combinatorial algorithm for the replacement paths problem is optimal up to polylogarithmic factors (unless the long standing bound 2005] obtained a randomized algorithm with running time of eO(m deterministic algorithm for this problem, with the same eO(m of eO(mn) for the combinatorial boolean matrix multiplication can be improved). This also implies a deterministic algorithm for the second simple shortest path problem in eO(m deterministic algorithm for the k-simple shortest paths problem in eO(km n) time, and a n) time (for any integer √ √ constant k > 0). For the problem of distance sensitivity oracles, let G = (V, E) be a directed graph with real-edge weights. An f-Sensitivity Distance Oracle (f-DSO) gets as input the graph G = (V, E) and a parameter f, preprocesses it into a data-structure, such that given a query (s, t, F ) with s, t ∈ V and F ⊆ E ∪ V,F ≤ f being a set of at most f edges or vertices (failures), the query algorithm efficiently computes the distance from s to t in the graph G \ F (i.e., the distance from s to t in the graph G after removing from it the failing edges and vertices F ). For weighted graphs with real edge weights, Weimann and Yuster [FOCS 2010] presented several randomized f-DSOs. In particular, they presented a combinatorial f-DSO with eO(mn4−α) prepro- cessing time and subquadratic eO(n2−2(1−α)/f) query time, giving a tradeoff between preprocessing and query time for every value of 0 < α < 1. We derandomize this result and present a combinatorial deterministic f-DSO with the same asymptotic preprocessing and query time. 2012 ACM Subject Classification Theory of computation → Design and analysis of algorithms; Theory of computation → Dynamic graph algorithms Keywords and phrases Replacement Paths, Distance Sensitivity Oracles, Derandomization Funding Noga Alon: Research supported in part by NSF grant DMS-1855464, ISF grant 281/17 and GIF grant G-1347-304.6/2016. Shiri Chechik: Research supported in part by the Israel Science Foundation grant No. 1528/15 and the Blavatnik Fund. Sarel Cohen: Research supported in part by the Israel Science Foundation grant No. 1528/15 and the Blavatnik Fund. 9 1 0 2 y a M 7 1 ] S D . s c [ 1 v 3 8 4 7 0 . 5 0 9 1 : v i X r a 2 Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles Introduction 1 In many algorithms used in computing environments such as massive storage devices, large scale parallel computation, and communication networks, recovering from failures must be an integral part. Therefore, designing algorithms and data structures whose running time is efficient even in the presence of failures is an important task. In this paper we study variants of shortest path queries in setting with failures. The computation of shortest paths and distances in the presence of failures was extensively studied. Two central problems researched in this field are the Replacement Paths problem and Distance Sensitivity Oracles, we define these problems hereinafter. The Replacement Paths problem (See, e.g., [37, 40, 20, 18, 30, 39, 6, 43, 31, 33, 34, 35, 42, 19]). Let G = (V, E) be a graph (directed or undirected, weighted or unweighted) with n vertices and m edges and let PG(s, t) be a shortest path from s to t. For every edge e ∈ PG(s, t) a replacement path PG(s, t, e) is a shortest path from s to t in the graph G \ {e} (which is the graph G after removing the edge e). Let dG(s, t, e) be the length of the path PG(s, t, e). The replacement paths problem is as follows: given a shortest path PG(s, t) from s to t in G, compute dG(s, t, e) (or an approximation of it) for every e ∈ PG(s, t). Distance Sensitivity Oracles (See, e.g., [11, 21, 8, 9, 13, 15, 16, 17, 28]). An f- Sensitivity Distance Oracle (f-DSO) gets as input a graph G = (V, E) and a parameter f, preprocesses it into a data-structure, such that given a query (s, t, F) with s, t ∈ V and F ⊆ E ∪ V,F ≤ f being a set of at most f edges or vertices (failures), the query algorithm efficiently computes (exactly or approximately) dG(s, t, F) which is the distance from s to t in the graph G \ F (i.e., in the graph G after removing from it the failing edges and vertices F). Here we would like to optimize several parameters of the data-structure: minimize the size of the oracle, support many failures f, have efficient preprocessing and query algorithms, and if the output is an approximation of the distance then optimize the approximation-ratio. An important line of research in the theory of computer science is derandomization. In many algorithms and data-structures there exists a gap between the best known randomized algorithms and the best known deterministic algorithms. There has been extensive research on closing the gaps between the best known randomized and deterministic algorithms in many problems or proving that no deterministic algorithm can perform as good as its randomized counterpart. There also has been a long line of work on developing derandomization techniques, in order to obtain deterministic versions of randomized algorithms (e.g., Chapter 16 in [2]). In this paper we derandomize algorithms and data-structures for computing distances and shortest paths in the presence of failures. Many randomized algorithms for computing shortest paths and distances use variants of the following sampling lemma (see Lemma 1 in Roditty and Zwick [37]). (cid:73) Lemma 1 (Lemma 1 in [37]). Let D1, D2, . . . , Dq ⊆ V satisfy Di > L for 1 ≤ i ≤ q and V = n. If R ⊆ V is a random subset obtained by selecting each vertex, independently, with probability (c ln n)/L, for some c > 0, then with probability of at least 1 − q · n−c we have Di ∩ R 6= ∅ for every 1 ≤ i ≤ q. Our derandomization step of Lemma 1 is very simple, as described in Section 1.3, we use the folklore greedy approach to prove the following lemma, which is a deterministic version of Lemma 1. (cid:73) Lemma 2. [See also Section 1.3] Let D1, D2, . . . , Dq ⊆ V satisfy Di > L for 1 ≤ i ≤ q and and Di ∩ R 6= ∅ for every 1 ≤ i ≤ q. V = n. One can deterministically find in eO(qL) time a set R ⊂ V such that R = eO(n/L) N. Alon, S. Chechik and S. Cohen 3 We emphasize that the use of Lemma 2 is very standard and is not our main contribution. The main technical challenge is how to efficiently and deterministically compute a small number of sets D1, D2, . . . , Dq ⊆ V so that the invocation of Lemma 2 is fast. 1.1 Derandomizing the Replacment Paths Algorithm of Roditty and Zwick [37] We derandomize the algorithm of Roditty and Zwick [37] and obtain a near optimal determ- inistic algorithm for the replacement paths problem in directed unweighed graphs (a problem which was open for more than a decade since the randomized algorithm was published) as stated in the following theorem. (cid:73) Theorem 3. There exists a deterministic algorithm for the replacement paths problem n). This algorithm is near optimal assuming the conditional lower bound of combinatorial boolean matrix multiplication of [42]. in unweighted directed graphs whose runtime is eO(m √ Vassilevska Williams and Williams [42] proved a subcubic equivalence between The term "combinatorial algorithms" is not well-defined, and it is often interpreted as non-Strassen-like algorithms [4], or more intuitively, algorithms that do not use any matrix multiplication tricks. Arguably, in practice, combinatorial algorithms are to some extent considered more efficient since the constants hidden in the matrix multiplication bounds are high. On the other hand, there has been research done to make fast matrix multiplication practical, e.g., [27, 5]. √ n occurrences of the combinatorial replacement paths problem in unweighted directed graphs and the combinatorial boolean multiplication (BMM) problem. More precisely, they proved that there exists some fixed  > 0 such that the combinatorial replacement paths problem can be solved in O(mn1/2−) time if and only if there exists some fixed δ > 0 such that the combinatorial boolean matrix multiplication (BMM) can be solved in subcubic O(n3−δ) time. Giving a subcubic combinatorial algorithm to the BMM problem, or proving that no such algorithm exists, is a long standing open problem. This implies that either both problems can be polynomially improved, or neither of them does. Hence, assuming the conditional lower n) algorithm for the replacement bound of combinatorial BMM, our combinatorial eO(m paths problem in unweighted directed graphs is essentially optimal (up to no(1) factors). √ The replacement paths problem is related to the k simple shortest paths problem, where the goal is to find the k simple shortest paths between two vertices. Using known reductions from the replacement paths problem to the k simple shortest paths problem, we close this gap as the following Corollary states. (cid:73) Corollary 4. There exists a deterministic algorithm for computing k simple shortest paths in unweighted directed graphs whose runtime is eO(km eO(mn) time algorithm for solving the replacement paths problem in directed weighted graphs algorithms for general directed weighted graphs whose runtime is eO(mn) leaving a significant paper we derandomize the eO(m More related work can be found in Section 1.5. As written in Section 1.5, the trivial (simply, for every edge e ∈ PG(s, t) run Dijkstra in the graph G \ {e}) is deterministic and near optimal (according to a conditional lower bound by [42]). To the best of our knowledge the only deterministic combinatorial algorithms known for directed unweighted graphs are the gap between the randomized and deterministic algorithms. As mentioned above, in this n) algorithm of Roditty and Zwick [37] and close this gap. n). √ √ 4 Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles 1.2 Derandomizing the Combinatorial Distance Sensitivity Oracle of Weimann and Yuster [39] Our second result is derandomizing the combinatorial distance sensitivity oracle of Weimann and Yuster [39] and obtaining the following theorem. (cid:73) Theorem 5. Let G = (V, E) be a directed graph with real edge weights, let V = n and E = m. There exists a deterministic algorithm that given G and parameters f = O( log n log log n) (s, t, F) with s, t ∈ V and F ⊆ E ∪ V,F ≤ f being a set of at most f edges or vertices from s to t in the graph G \ F. and 0 < α < 1 constructs an f-sensitivity distance oracle in eO(mn4−α) time. Given a query (failures), the deterministic query algorithm computes in eO(n2−2(1−α)/f) time the distance We remark that while our focus in this paper is in computing distances, one may obtain the actual shortest path in time proportional to the number of edges of the shortest paths, using the same algorithm for obtaining the shortest paths in the replacement paths problem [37], and in the distance sensitivity oracles case [39]. 1.3 Technical Contribution and Our Derandomization Framework Let A be a random algorithm that uses Lemma 1 for sampling a subset of vertices R ⊆ V . We say that P = {D1, . . . , Dq} is a set of critical paths for the randomized algorithm A if A uses the sampling Lemma 1 and it is sufficient for the correctness of algorithm A that R is a hitting set for P (i.e., every path in P contains at least one vertex of R). According to Lemma 2 one can derandomize the random selection of the hitting set R in time that depends on the number of paths in P. Therefore, in order to obtain an efficient derandomization procedure, we want to find a small set P of critical paths for the randomized algorithms. Our main technical contribution is to show how to compute a small set of critical paths that is sufficient to be used as input for the greedy algorithm stated in Lemma 2. Our framework for derandomizing algorithms and data-structures that use the sampling Lemma 1 is given in Figure 1. 1 Step 1: Prove the existence of a small set of critical paths {D1, . . . , Dq} such that Di > L and show that it is sufficient for the correctness of the randomized algorithm that the set R obtained by Lemma 1 hits all the paths D1, . . . , Dq. 2 Step 2: Find an efficient algorithm to compute the paths D1, . . . , Dq. 3 Step 3: Use a deterministic algorithm to compute a small subset R ⊆ V of vertices such that Di ∩ R 6= ∅ for every 1 ≤ i ≤ q. For example, one can use the greedy algorithm of Lemma 2 or the blocker set algorithm of [29] to find a subset R ⊂ V of eO(n/L) vertices. Figure 1 Our derandomization framework to derandomize algorithms that use the sampling Lemma 1. Our first main technical contribution, denoted as Step 1 in Figure 1, is proving the existence of small sets of critical paths for the randomized replacement path algorithm of Roditty and Zwick [37] and for the distance sensitivity oracles of Weimann and Yuster [39]. Our second main technical contribution, denoted as Step 2 in Figure 1, is developing algorithms to efficiently compute these small sets of critical paths. N. Alon, S. Chechik and S. Cohen 5 For the replacement paths problem, Roditty and Zwick [37] proved the existence of a ne edges. Simply applying critical set of O(n2) paths, each path containing at least d√ Lemma 2 on this set of paths requires eO(n2.5) time which is too much, and it is also not clear from their algorithm how to efficiently compute this set of critical paths. As for Step 1, we prove the existence of a small set of O(n) critical paths, each path contains d√ ne edges, eO(m and for Step 2, we develop an efficient algorithm that computes this set of critical paths in 0 < α < 1). Simply applying Lemma 2 on this set of paths requires eO(n2f+3+(1−α)/f) time √ For the problem of distance sensitivity oracles, Weimann and Yuster [39] proved the existence of a critical set of O(n2f+3) paths, each path containing n(1−α)/f edges (where n) time. For Step 3, we use the folklore greedy deterministic algorithm denoted here by which is too much, and here too, it is also not clear from their algorithm how to efficiently and deterministically compute this set of critical paths. As for Step 1, we prove the existence of a small set of O(n2+) critical paths, each path contains n(1−α)/f edges, and for Step 2, we develop an efficient deterministic algorithm that computes this set of critical paths in eO(mn1+) time. 1 ≤ i ≤ q it holds that Di ∩ R 6= ∅. In addition, it holds that R = eO( n the algorithm is eO(qL). GreedyPivotsSelection({D1, . . . , Dq}). Given as input the paths D1, . . . , Dq, each path contains at least L vertices, the algorithm chooses a set of pivots R ⊆ V such that for every L) and the runtime of The GreedyPivotsSelection algorithm works as follows. Let P = {D1, . . . , Dq}. Starting with R ← ∅, find a vertex v ∈ V which is contained in the maximum number of sets of P, add it to R and remove all the sets that contain v from P. Repeat this process until P = ∅. (cid:73) Lemma 6. Let 1 ≤ L ≤ n and 1 ≤ q < poly(n) be two integers. Let D1, . . . , Dq ⊆ V be paths satisfying Di ≥ L for every 1 ≤ i ≤ q. The algorithm GreedyPivotsSelection({D1, . . . , Dq}) R = O( n log q Proof. We first prove that for every 1 ≤ i ≤ q it holds that R∩ Di 6= ∅ and R = O( n log q finds in eO(qL) time a set R ⊂ V such that for every 1 ≤ i ≤ q it holds that R ∩ Di 6= ∅ and eO(n/L). L ) = When the algorithm terminates then every set D ∈ D contains at least one of the vertices of R, as otherwise D would have contained the sets which are disjoint from R and the algorithm should have not finished since D 6= ∅. L ) = eO(n/L). For every vertex v ∈ V , let c(v) be a variable which denotes, at every moment of the algorithm, the number of sets in D which contain v. Denote by Di the set D after i iterations. Let D0 = {D1, . . . , Dq} be the initial set D given as input to the algorithm, then D0 = q. We claim that the process terminates after at most eO(n/L) iterations, and since at every iteration we add one vertex v to R, it follows that R = eO(n/L). Recall that D contains sets of size at least L. Hence, Σv∈V c(v) ≥ DL. It follows that the average number of sets that a vertex v ∈ V belongs to n . By the pigeonhole principle, the vertex vi = arg maxv∈V {c(v)} is: avg = Σv∈V c(v) belongs to at least DL sets of D. Therefore, Di = {D ∈ Dvi ∈ D} ≥ DL n . At iteration i we remove from D the sets Di, so in each iteration we decrease the size of D by at least a factor of (1− L/n). After the ith iteration, the size of D is at most (1− L/n)iD0. Therefore, after the i = (n/L) ln q + 1 iteration, the size of D is at most (1 − L/n)iD0 < 1/qD0 ≤ 1, where the last inequality holds since D0 = q. It follows that after (n/L) ln q + 1 iterations we have D = ∅. At each iteration we add one vertex vi to the set R, thus the size of the set R is eO(n/L). ≥ DL n n 6 Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles Next we describe an implementation of the GreedyPivotsSelection algorithm (see Figure 2 for pseudo-code). The first thing we do is keep only an arbitrary subset of L vertices from every D ∈ D so that every set D ∈ D contains exactly L vertices. We implement the algorithm GreedyPivotsSelection as follows. During the runtime of the algorithm we maintain a counter c(v) for every vertex v ∈ V which equals the number of sets in D that contain v. During the initialization of the algorithm, we construct a subset of vertices V 0 ⊆ V which contains all the vertices in all the paths D, and compute we compute c(v) directly, first by setting ∀v∈V 0c(v) ← 0 and then we scan all the sets D ∈ D and every vertex v ∈ D and increase the counter c(v) ← c(v) + 1. After this initialization we have c(v) = {D ∈ Dv ∈ D} which is the number of sets of D that contain v. We further initialize a binary search tree BST and insert every vertex v ∈ V 0 into BST with the key c(v), and initialize R ← ∅. We also create a list L(v) for every vertex v ∈ V 0 which contains pointers to the sets D ∈ D that contain v. Hence, L(v) = {D ∈ Dv ∈ D} and c(v) = L(v). To obtain the set R we run the following loop. While D 6= ∅ we find the vertex v ∈ V 0 which is contained in the maximum number of paths of D and add v to R. The vertex v is computed in O(log n) time by extracting the element in BST whose key is maximal. Then we remove from D all the sets which contain v (these are exactly the sets L(v)) and we update the counters c(v) by scanning every set D ∈ L(v) and every vertex u ∈ D and decreasing the counter c(u) by one (we also update the key of u in BST to the counter c(u)). We analyse the runtime of this greedy algorithm. Computing the subset of vertices time. Computing the values c(v) = {D ∈ Dv ∈ D} takes O(qL) time as we loop over all the q sets D ∈ D and for every D we loop over the exactly L vertices v ∈ D and increase the counter c(v) by one. Initializing the binary search tree BST and inserting to it every V 0 ⊆ V and setting all the values c(v) ← 0 at the beginning for every v ∈ V 0 takes eO(qL) vertex v ∈ V 0 with key c(v) takes eO(V 0) = eO(qL) time, and all the extract-max operations on BST take additional O(V 0) = eO(qL) time. The total time of operations of the form this is the sum of sizes of all sets L(v). Therefore, the total running time is eO(qL). c(v) ← c(v) − 1 is O(qL) as this is the sum of all values c(v) at the beginning and each such operation is handled in O(log n) time by updating the key of the vertex v in BST to c(v)− 1. The total time for checking the lists L(v) of all vertices chosen to R is at most O(qL), as (cid:74) 1.4 Related Work - the Blocker Set Algorithm of King We remark that the GreedyPivotsSelection algorithm is similar to the blocker set algorithm described in [29] for finding a hitting set for a set of paths. The blocker set algorithm was used in [29] to develop sequential dynamic algorithms for the APSP problem. Additional [1]. They presented a deterministic distributed related work is that of Agarwal et. al. algorithm to compute APSP in an edge-weighted directed or undirected graph in eO(n3/2) rounds in the Congest model by incorporating a deterministic distributed version of the blocker set algorithm. While our derandomization framework uses the greedy algorithm (or the blocker set algorithm) to find a hitting set of vertices for a critical set of paths D1, . . . , Dq, we stress that our main contribution are the techniques to reduce the number of sets q the greedy algorithm must hit (Step 1), and the algorithms to efficiently compute the sets D1, . . . , Dq (Step 2). These techniques are our main contribution, which enable us to use the greedy algorithm (or the blocker set algorithm) for a wider range of problems. Specifically, these techniques allow us to derandomize the best known random algorithms for the replacement N. Alon, S. Chechik and S. Cohen 7 Algorithm: GreedyPivotsSelection({D1, . . . , Dq}) /* Initialization */ for v ∈ D do V 0 ← V 0 ∪ {v} end 1 V 0 ← ∅ 2 for D ∈ D do 3 4 5 6 end 7 for v ∈ V 0 do 8 9 end 10 for D ∈ D do 11 12 13 c(v) ← 0, L(v) ← ∅ for v ∈ D do c(v) ← c(v) + 1 L(v).append(D) D */ end 14 15 end 16 BST ← Empty-Binary-Search-Tree() 17 for v ∈ V 0 do 18 19 end 20 R ← ∅. 21 while D 6= ∅ do 22 v = BST.Extract − M ax() maximal. */ R ← R ∪ {v} for D ∈ L(v) do if D ∈ D then for u ∈ D do 23 24 25 26 27 28 29 30 31 32 33 34 end end D.delete(D) end end Figure 2 Algorithm GreedyPivotsSelection /* Append the list L(v) with a pointer to the set Insert v to the binary-search BST with the key c(v). /* Loop Invariant: c(v) = {D ∈ Dv ∈ D} */ /* v is the vertex in BST whose key c(v) is BST.remove(u) c(u) ← c(u) − 1 Insert u to the binary-search BST with the key c(u). 8 Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles paths problem and distance sensitivity oracles. We believe that our techniques can also be leveraged for additional related problems which use a sampling lemma similar to Lemma 1. 1.5 More Related Work We survey related work for the replacement paths problem and distance sensitivity oracles. The replacement paths problem. The replacement paths problem is motivated by several different applications and has been extensively studied in the last few decades (see e.g. It is well motivated by its own right from the fault-tolerance perspective. In many applications it is desired to find algorithms and data-structures that are resilient to failures. Since links in a network can fail, it is important to find backup shortest paths between important vertices of the graph. [34, 26, 25, 35, 42, 20, 37, 18, 30, 6]). Furthermore, the replacement paths problem is also motivated by several applications. First, the fastest algorithms to compute the k simple shortest paths between s and t in directed graphs executes k iterations of the replacement paths between s and t in total eO(mnk) time (see [43, 31]). Second, considering path auctions, suppose we would like to find the shortest path from s to t in a directed graph G, where links are owned by selfish agents. Nisan and Ronen [36] showed that Vickrey Pricing is an incentive compatible mechanism, and in order to compute the Vickery Pricing of the edges one has to solve the replacement paths problem. It was raised as an open problem by Nisan and Ronen [36] whether there exists an efficient algorithm for solving the replacement paths problem. In biological sequence alignment [10] replacement paths can be used to compute which pieces of an alignment are most important. The replacement paths problem has been studied extensively, and by now near optimal algorithms are known for many cases of the problem. For instance, the case of undirected graphs admits deterministic near linear solutions (see [34, 26, 25, 35]). In fact, Lee and Lu present linear O(n + m)-time algorithms for the replacement-paths problem in on the following classes of n-node m-edge graphs: (1) undirected graphs in the word-RAM model of computation, (2) undirected planar graphs, (3) undirected minor-closed graphs, and (4) directed acyclic graphs. A natural question is whether a near linear time algorithm is also possible for the directed case. Vassilevska Williams and Williams [42] showed that such an algorithm is essentially not possible by presenting conditional lower bounds. More precisely, Vassilevska Williams and Williams [42] showed a subcubic equivalence between the combinatorial all pairs shortest paths (APSP) problem and the combinatorial replacement paths problem. They proved that there exists a fixed  > 0 and an O(n3−) time combinatorial algorithm for the replacement paths problem if and only if there exists a fixed δ > 0 and an O(n3−δ) time combinatorial algorithm for the APSP problem. This implies that either both problems admit truly subcubic algorithms, or neither of them does. Assuming the conditional lower bound that no subcubic APSP algorithm exists, then the trivial algorithm of computing Dijkstra from s in every graph G \ {e} for every edge e ∈ PG(s, t), which takes O(mn + n2 log n) time, is essentially near optimal. The near optimal algorithms for the undirected case and the conditional lower bounds for the directed case seem to close the problem. However, it turned out that if we consider the directed case with bounded edge weights then the picture is not yet complete. Williams presented [40] an eO(M nω) time algebraic randomized algorithm for the replacement For instance, if we assume that the graph is directed with integer weights in the range [−M, M] and allow algebraic solutions (rather than combinatorial ones), then Vassilevska paths problem, where 2 ≤ ω < 2.373 is the matrix multiplication exponent, whose current N. Alon, S. Chechik and S. Cohen 9 best known upper bound is 2.3728639 ([32, 41, 14]). weight in the graph and c is the smallest edge weight). √ Bernstein presented in [6] a (1+)-approximate deterministic replacement paths algorithm which is near optimal (whose runtime is eO((m log(nC/c)/), where C is the largest edge whose runtime is eO(m For unweighted directed graphs the gap between randomized and deterministic solutions is even larger for sparse graphs. Roditty and Zwick [37] presented a randomized algorithm n) time for the replacement paths problem for unweighted directed graphs. Vassilevska Williams and Williams [42] proved a subcubic equivalence between the combinatorial replacement paths problem in unweighted directed graphs and the combinatorial boolean multiplication (BMM) problem. They proved that there exists some fixed  > 0 such that the combinatorial replacement paths problem can be solved in O(mn1/2−) time if and only if there exists some fixed δ > 0 such that the combinatorial boolean matrix multiplication (BMM) can be solved in subcubic O(n3−δ) time. Giving a subcubic combinatorial algorithm to the BMM problem, or proving that no such algorithm exists, is a long standing open problem. This implies that either both problems can be polynomially improved, or neither of them does. Hence, assuming the conditional lower bound of combinatorial BMM, the randomized algorithm of Roditty and Zwick [37] is near optimal. In the deterministic regime no algorithm for the directed case is known that is asymptotic- ally better (up to ploylog) than invoking APSP algorithm. Interestingly, in the fault-tolerant and the dynamic settings many of the existing algorithms are randomized, and for many of the problems there is a polynomial gap between the best randomized and deterministic algorithms (see e.g. sensitive distance oracles [21], dynamic shortest paths [22, 7], dynamic strongly connected components [23, 24, 12], dynamic matching [38, 3], and many more). Randomization is a powerful tool in the classic setting of graph algorithms with full knowledge and is often used to simplify the algorithm and to speed-up its running time. However, physical computers are deterministic machines, and obtaining true randomness can be a hard task to achieve. A central line of research is focused on the derandomization of algorithms that relies on randomness. deterministic algorithm for the replacement paths problem, whose runtime is eO(m Our main contribution is a derandomization of the replacement paths algorithm of [37] for the case of unweighted directed graphs. After more than a decade we give the first n). Our deterministic algorithm matches the runtime of the randomized algorithm, which is near optimal assuming the conditional lower bound of combinatorial boolean matrix multiplication [42]. In addition, to the best of our knowledge this is the first deterministic solution for the directed case that is asymptotically better than the APSP bound. √ The replacement paths problem is related to the k shortest paths problem, where the goal is to find the k shortest paths between two vertices. Eppstein [19] solved the k shortest paths problem for directed graphs with nonnegative edge weights in O(m + n log n + k) time. However, the k shortest paths may not be simple, i.e., contain cycles. The problem of k simple shortest paths (loopless) is more difficult. The deterministic algorithm by Yen [43] (which was generalized by Lawler [31]) for finding k simple shortest paths in weighted directed graphs can be implemented in O(kn(m + n log n)) time. This algorithm essentially uses in each iteration a replacement paths algorithm. Roditty and Zwick [37] described how to reduce the problem of k simple shortest paths into k executions of the second shortest path problem. For directed unweighted graphs, the randomized replacement paths algorithm of Roditty and Zwick [37] n) time algorithm. To the best of our knowledge no better deterministic algorithm is known than the algorithms for general directed weighted graphs, yielding a significant gap between randomized and the implies that the k simple shortest paths has a randomized eO(km √ 10 Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles deterministic k simple shortest paths for directed unweighted graphs. Our deterministic replacement paths algorithm closes this gap and gives the first deterministic k simple shortest The best known randomized algorithm for the k simple shortest paths problem in directed n) time ([37]), leaving a significant gap compared to the paths algorithm for directed unweighted graphs whose runtime is eO(km unweighted graphs takes eO(km best known deterministic algorithm which takes eO(kmn) time (e.g., [43], [31]). We close this paths in unweighted directed graphs whose runtime is eO(km gap by proving the existence of a deterministic algorithm for computing k simple shortest n). √ √ √ n). 1.6 Outline The structure of the paper is as follows. In Section 2 we describe some preliminaries and notations. In Section 3 we apply our framework to the replacement paths algorithm of Roditty and Zwick [37]. In Section 4 we apply our framework to the DSO of Weimann and Yuster for graphs with real-edge weights [39]. In order for this paper to be self-contained, a full description of the combinatorial deterministic replacement paths algorithm is given in Section 5 and a full description of the deterministic distance sensitivity oracles is given in Section 6. Preliminaries 2 Let G = (V, E) be a directed weighted graph with n vertices and m edges with real edge weights ω(·). Given a path P in G we define its weight ω(P) = Σe∈E(P )ω(e). Given s, t ∈ V , let PG(s, t) be a shortest path from s to t in G and let dG(s, t) = ω(PG(s, t)) be its length, which is the sum of its edge weights. Let PG(s, t) denote the number of edges along PG(s, t). Note that for unweighted graphs we have PG(s, t) = dG(s, t). When G is known from the context we sometimes abbreviate PG(s, t), dG(s, t) with P(s, t), d(s, t) respectively. We define the path concatenation operator ◦ as follows. Let P1 = (x1, x2, . . . , xr) and P2 = (y1, y2, . . . , yt) be two paths. Then P = P1 ◦ P2 is defined as the path P = (x1, x2, . . . , xr, y1, y2, . . . , yt), and it is well defined if either xr = y1 or (xr, y1) ∈ E. For a graph H we denote by V (H) the set of its vertices, and by E(H) the set of its edges. When it is clear from the context, we abbreviate e ∈ E(H) by e ∈ H and v ∈ V (H) by v ∈ H. along P. We denote by P[u..v] the subpath of P from u to v. Let P be a path which contains the vertices u, v ∈ V (P) such that u appears before v For every edge e ∈ PG(s, t) a replacement path PG(s, t, e) for the triple (s, t, e) is a shortest path from s to t avoiding e. Let dG(s, t, e) = ω(PG(s, t, e)) be the length of the replacement path PG(s, t, e). We will assume, without loss of generality, that every replacement path PG(s, t, e) can be decomposed into a common prefix CommonPref s,t,e with the shortest path PG(s, t), a detour Detours,t,e which is disjoint from the shortest path PG(s, t) (except for its first vertex and last vertex), and finally a common suffix CommonSuff s,t,e which is common with the shortest path PG(s, t). Therefore, for every edge e ∈ PG(s, t) it holds that PG(s, t, e) = CommonPref s,t,e ◦ Detours,t,e ◦ CommonSuff s,t,e (the prefix and/or suffix may be empty). Let F ⊆ V ∪ E be a set of vertices and edges. We define the graph G\ F = (V \ F, E \ F) as the graph obtained from G by removing the vertices and edges F. We define a replacement path PG(s, t, F) as a shortest path from s to t in the graph G \ F, and let dG(s, t, F) = w(PG(s, t, e)) be its length. N. Alon, S. Chechik and S. Cohen 11 √ 3 Deterministic Replacement Paths in eO(m √ n) Time - an Overview In this section we apply our framework from Section 1.3 to the replacement paths algorithm of Roditty and Zwick [37]. A full description of the deterministic replacement paths algorithm is given in Section 5. The randomized algorithm by Roddity and Zwick as described in [37] takes eO(m n) expected time. They handle separately the case that a replacement path has a short detour containing at most d√ ne edges, and the case that a replacement path has a long detour containing more than d√ ne edges. The first case is solved deterministically. The second case is solved by first sampling a subset of vertices R according to Lemma 1, where each vertex is sampled uniformly independently at random with probability c ln n/ n for large enough constant c > 0. Using this uniform sampling, it holds with high probability (of at least 1 − n−c+2) that for every long triple (s, t, e) (as defined hereinafter), the detour Detours,t,e of the replacement path PG(s, t, e) contains at least one vertex of R. (cid:73) Definition 7. Let s, t ∈ V, e ∈ PG(s, t). The triple (s, t, e) is a long triple if every replacement path from s to t avoiding e has its detour part containing more than d√ ne edges. Note that in Definition 7 we defined (s, t, e) to be a long triple if every replacement path from s to t avoiding e has a long detour (containing more than d√ ne edges). We could have defined (s, t, e) to be a long triple even if at least one replacement path from s to t avoiding e has a long detour (perhaps more similar to the definitions in [37]), however we find Definition 7 more convenient for the following reason. If (s, t, e) has a replacement path whose detour part contains at most d√ ne edges, then the algorithm of [37] for handling short detours finds deterministically a replacement path for (s, t, e). Hence, we only need to find the replacement paths for triples (s, t, e) for which every replacement path from s to t avoiding e has a long detour, and this is the case for which we define (s, t, e) as a long triple. √ It is sufficient for the correctness of the replacement paths algorithm that the following condition holds; For every long triple (s, t, e) the detour Detours,t,e of the replacement path PG(s, t, e) contains at least one vertex of R. As the authors of [37] write, the choice of the random set R is the only randomization used in their algorithm. To obtain a deterministic algorithm for the replacement paths problem and to prove Theorem 3, we prove the following deterministic alternative of Lemma 2. (cid:73) Lemma 8 (Our derandomized version of Lemma 2 for the replacement paths algorithm). n) vertices, such that for every long triple (s, t, e) there exists a replacement path PG(s, t, e) whose detour part contains at least one of the vertices of R. n) time deterministic algorithm that computes a set R ⊆ V of eO( There exists an eO(m Following the above description, in order to prove Theorem 3, that there exists an eO(m √ n) deterministic replacement paths algorithm, it is sufficient to prove the derandomization Lemma 8, we do so in the following sections. √ √ 3.1 Step 1: the Method of Reusing Common Subpaths - Defining the Set Dn In this section we prove the following lemma. (cid:73) Lemma 9. There exists a set Dn of at most n paths, each path of length exactly d√ ne with the following property; for every long triple (s, t, e) there exists a path D ∈ Dn and a replacement path PG(s, t, e) such that D is contained in the detour part of PG(s, t, e). 12 Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles n and the set of We use the following definitions of the index ρ(x), the set of vertices V√ In order to define the set of paths Dn and prove Lemma 9 we need the following definitions. Let G0 = G \ E(PG(s, t)) be the graph obtained by removing the edges of the path PG(s, t) from G. For two vertices u and v, let dG0(u, v) be the distance from u to v in G0. paths Dn. (cid:73) Definition 10 (The index ρ(x)). Let PG(s, t) =< v0, . . . , vk > and let X = {x ∈ V ∃0≤i≤k dG0(vi, x) = d√ ne} be the subset of all the vertices x ∈ V such that there exists at least one index 0 ≤ i ≤ k with dG0(vi, x) = d√ that dG0(vρ(x), x) = d√ (cid:73) Definition 11 (The set of vertices V√ X∀i<ρ(x)dG0(vi, x) > d√ for all the vertices vi before vρ(x) along PG(s, t) it holds that dG0(vi, x) > d√ (cid:73) Definition 12 (A set of paths Dn). For every vertex x ∈ V√ shortest path from vρ(x) to x in G0 (whose length is d√ define Dn = {D(x)x ∈ V√ n). We define the set of vertices V√ ne. For every vertex x ∈ X we define the index 0 ≤ ρ(x) ≤ k to be the minimum index such n = {x ∈ n is the set of all vertices x ∈ X such that ne as dG0(vρ(x), x) = d√ n, let D(x) be an arbitrary ne). We ne. ne}. In other words, V√ ne. n}. Note that while V√ n is uniquely defined (as it is defined according to distances between vertices) the set of paths Dn is not unique, as there may be many shortest paths from vρ(x) to x in G0, and we take D(x) = PG0(vρ(x), x) to be an arbitrary such shortest path. The basic intuition for the method of reusing common subpaths is as follows. Let PG(s, t, e1), . . . , PG(s, t, er) be arbitrary replacement paths such that x is the (d√ ne + 1)th vertex along the detours of all the replacement path PG(s, t, e1), . . . , PG(s, t, er). Then one can G(s, t, er) such that the subpath D(x) ∈ Dn is construct replacement paths P 0 contained in all these replacement paths. Therefore, the subpath D(x) is reused as a common subpath in many replacement paths. We utilize this observation in the following proof of Lemma 9. G(s, t, e1), . . . , P 0 ne. Proof of Lemma 9. Obviously, the set Dn described in Definition 12 contains at most n paths, each path is of length exactly d√ We prove that for every long triple (s, t, e) there exists a path D ∈ Dn and a replacement path P 0(s, t, e) s.t. D is contained in the detour part of P 0(s, t, e). Let PG(s, t, e) be a replacement path for (s, t, e). Since (s, t, e) is a long triple then the detour part Detours,t,e of PG(s, t, e) contains more than d√ ne edges. Let x ∈ Detours,t,e be the (d√ ne + 1)th vertex along Detours,t,e, and let vj be the first vertex of Detours,t,e. Let P1 be the subpath of Detours,t,e from vj to x and let P2 be the subpath of PG(s, t, e) from x to t. In other words, PG(s, t, e) =< v0, . . . , vj > ◦P1 ◦ P2. Since Detours,t,e contains more than d√ ne edges and is disjoint from PG(s, t) except for the first and last vertices of Detours,t,e and P1 ⊂ Detours,t,e it follows that P1 is disjoint from PG(s, t) (except for the vertex vj). In particular, since P1 is a shortest path in G \ {e} that is edge-disjoint from PG(s, t), then P1 is also a shortest path in G0 = G \ E(PG(s, t)). We get that dG0(vj, x) = P1 = d√ ne. n. As we have already proved that dG0(vj, x) = d√ ne, we need to prove that for every 0 ≤ i < j it holds that dG0(vi, x) > d√ ne. Assume by contradiction that there exists an index 0 ≤ i < j such that dG0(vi, x) ≤ d√ ne. Then the path P =< v0, . . . , vi > ◦PG0(vi, x) ◦ P2 is a path from s to t that avoids e and its length is: We prove that j = ρ(x) and x ∈ V√ N. Alon, S. Chechik and S. Cohen 13 P = < v0, . . . , vi > ◦PG0(vi, x) ◦ P2 ne + P2 ne + P2 ≤ i + d√ < j + d√ = PG(s, vj) ◦ P1 ◦ P2 = PG(s, t, e) This means that the path P is a path from s to t in G \ {e} and its length is shorter than the length of the shortest path PG(s, t, e) from s to t in G \ {e}, which is a contradiction. We get that dG0(vj, x) = d√ ne and for every 0 ≤ i < j it holds that dG0(vi, x) > d√ ne. Therefore, according to Definitions 10 and 11 it holds that j = ρ(x) and x ∈ V√ Let D(x) ∈ Dn, then according to Definition 12, D(x) is a shortest path from vρ(x) to x in G0. We define the path P 0(s, t, e) =< v0, . . . , vρ(x) > ◦D(x) ◦ P2. It follows that P 0(s, t, e) is a path from s to t that avoids e and P 0(s, t, e) = < v0, . . . , vρ(x) > ◦D(x) ◦ P2 = ρ(x) + d√ ne + P2 = PG(s, t, e) = dG(s, t, e). Hence, P 0(s, t, e) is a replacement path for (s, t, e) such that D(x) ⊂ P 0(s, t, e) so the lemma follows. (cid:74) n. 3.2 Step 2: the Method of Decremental Distances from a Path - Computing the Set Dn In this section we describe a decremental algorithm that enables us to compute the set of √ n) time, proving the following lemma. (cid:73) Lemma 13. There exists a deterministic algorithm for computing the set of paths Dn in paths Dn in eO(m eO(m n) time. √ √ Our algorithm for computing the set of path Dn is a variant of the decremental SSSP (single source shortest paths) algorithm of King [29]. Our variant of the algorithm is used to find distances of vertices from a path rather than from a single source vertex as we define below. Overview of the Deterministic Algorithm for Computing Dn in eO(m n) Time. In the following description let P = PG(s, t). Consider the following assignment of weights ω to edges of G. We assign weight  for every edge e on the path P, and weight 1 for all the other edges where  is a small number such that 0 <  < 1/n. We define a graph Gw = (G, w) as the weighted graph G with edge weights ω. We define for every 0 ≤ i ≤ k the graph Gi = G\{vi+1, . . . , vk} and the path Pi = P \{vi+1, . . . , vk}. We define the graph i = (Gi, w) as the weighted graph Gi with edge weights ω. Gw The algorithm computes the graph Gw by simply taking G and setting all edge weights of PG(s, t) to be  (for some small  such that  < 1/n) and all other edge weights to be 1. The algorithm then removes the vertices of PG(s, t) from Gw one after the other (starting from the vertex that is closest to t). Loosely speaking after each vertex is removed, the algorithm computes the distances from s in the current graph. In each such iteration, the algorithm n all vertices such that their distance from s in the current graph is between d√ ne adds to V w√ and d√ ne + 1. We will later show that at the end of the algorithm we have V w√ n = V√ n. Unfortunately, we cannot afford running Dijkstra after the removal of every vertex of PG(s, t) as there might be n vertices on PG(s, t). To overcome this issue, the algorithm only maintains nodes at distance at most d√ ne + 1 from s. In addition, we observe that to compute the SSSP from s in the graph after the removal of a vertex vi we only need to spend time on 14 Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles In Section 5.4 we give a formal description and analysis of the algorithm and prove ne + 1 iterations until its distance from s is bigger than d√ nodes such that their shortest path from s uses the removed vertex. Roughly speaking, for these nodes we show that their distance from s rounded down to the closest integer must increase by at least 1 as a result of the removal of the vertex. Hence, for every node we spend time on it in at most d√ ne + 1. As we will show later this will yield our desired running time. Proof of Theorem 3. We summarize the eO(m algorithm and outline the proof of Theorem 3. First, compute in eO(m GreedyPivotsSelection(Dn) (as described in Lemma 2) computes a set R ⊂ V of eO( vertices in eO(n n) deterministic replacement paths n) time the set of paths Dn as in Lemma 13. Given Dn, the deterministic greedy selection algorithm √ n) n) time with the following property; every path D ∈ Dn contains at least Lemma 13. √ √ √ one of the vertices of R. Theorem 3 follows from Lemmas 8, 9 and 13. 4 Deterministic Distance Sensitivity Oracles - an Overview In this section we apply our framework from Section 1.3 to the combinatorial distance sensitivity oracles of Weimann and Yuster [39]. A full description of the deterministic combinatorial distance sensitivity oracles is given in Section 6. Let 0 <  < 1 and 1 ≤ f = O( log n log log n) be two parameters. In [39], Weimann and Yuster considered the following notion of intervals (note that in [39] they use a parameter 0 < α < 1 and we use a parameter 0 <  < 1 such that  = 1 − α). They define an interval of a long simple path P as a subpath of P consisting of n/f consecutive vertices, so every simple path induces less than n (overlapping) intervals. For every subset F ⊂ E of at most f edges, and for every pair of vertices u, v ∈ V , let PG(u, v, F) be a shortest path from u to v in G \ F. The path PG(u, v, F) induces less than n (overlapping) intervals. The total number of possible intervals is less than O(n2f+3) as each one of the (at most) O(n2f+2) possible queries (u, v, F) corresponds to a shortest path PG(u, v, F) that induces less than n intervals. (cid:73) Definition 14. Let Df be defined as all the intervals (subpaths containing n/f edges) of all the replacement paths PG(s, t, F) for every s, t ∈ V, F ⊆ E ∪ V with F ≤ f. Weimann and Yuster apply Lemma 1 to find a set R ⊆ V of eO(n1−/f) vertices that deterministically according to Lemma 2 takes eO(n2f+3+/f) time, which is very inefficient. hit w.h.p. all the intervals Df. According to these bounds (that Df contains O(n2f+3) paths, each containing exactly n/f edges) applying the greedy algorithm to obtain the set R In this section we assume that all weights are non-negative (so we can run Dijkstra's algorithm) and that shortest paths are unique, we justify these assumptions in Section 6.4. 4.1 Step 1: the Method of Using Fault-Tolerant Trees to Significantly Reduce the Number of Intervals In Lemma 15 we prove that the set of intervals Df actually contains at most O(n2+) unique intervals, rather than the O(n2f+3) naive upper bound mentioned above. From Lemmas 15 and 2 it follows that the GreedyPivotsSelection(Df) finds in eO(n2++/f) time the subset R ⊆ V of eO(n1−/f) vertices that hit all the intervals Df. In Section 6.3.4 we further reduce the time it takes for the greedy algorithm to compute the set of pivots R to eO(n2+). (cid:73) Lemma 15. Df = O(n2+). G(s, t) (and its length dL G(s, t)), and also G(s, t) = ∅ G(s, t) in a binary search tree BST L(s, t); If P L G(s, t,{a1})) and we also store the vertices and edges of P L G(s, t) we recursively build a subtree F T L,f(s, t, a1) as G(s, t,{a1}) be the shortest path from s to t that contains at most L edges G(s, t,{a1}) G(s, t,{a1}) in G(s, t,{a1}) = ∅ we terminate the construction of G(s, t,{a1}) we recursively In the root of F T L,f(s, t) we store the path P L store the vertices and edges of P L then we terminate the construction of F T L,f(s, t). For every edge or vertex a1 of P L follows. Let P L in the graph G\{a1}. Then in the subtree F T L,f(s, t, a1) we store the path P L (and its length dL a binary search tree BST L(s, t, a1); If P L F T L,f(s, t, a1). If f > 1 then for every vertex or edge a2 in P L build the subtree F T L,f(s, t, a1, a2) as follows. For the recursive step, assume we want to construct the subtree F T L,f(s, t, a1, . . . , ai). In G(s, t,{a1, . . . , ai}) (and its length the root of F T L,f(s, t, a1, . . . , ai) we store the path P L G(s, t,{a1, . . . , ai})) and we also store the vertices and edges of P L G(s, t,{a1, . . . , ai}) in a dL G(s, t,{a1, . . . , ai}) = ∅ then we terminate binary search tree BST L(s, t, a1, . . . , ai). If P L the construction of F T L,f(s, t, a1, . . . , ai). If i < f then for every vertex or edge ai+1 in G(s, t,{a1, . . . , ai})) we recursively build the subtree F T L,f(s, t, a1, . . . , ai, ai+1). P L Observe that there are two conditions in which we terminate the recursive construction of F T L,f(s, t, a1, . . . , ai): N. Alon, S. Chechik and S. Cohen 15 In order to prove Lemma 15 we describe the fault-tolerant trees data-structure, which is a variant of the trees which appear in Appendix A of [11]. G(s, t, F) be the shortest among the s-to-t paths in G \ F that (cid:73) Definition 16. Let P L G(s, t, F) = G(s, t, F) = ω(P L contain at most L edges and let dL min{ω(P) P is an s − to − t path on at most L edges}. If there is no path from s to t in G(s, t, F) = ∞. For G \ F containing at most L edges then we define P L F = ∅ we abbreviate P L G(s, t) as the shortest path from s to t that contains at G(s, t,∅) as its length. most L edges, and dL G(s, t, F)). In other words, dL G(s, t, F) = ∅ and dL G(s, t,∅) = P L G(s, t) = dL Let s, t ∈ V be vertices and let L, f ≥ 1 be fixed integer parameters, we define the trees F T L,f(s, t) as follows. Either i = f in which case F T L,f(s, t, a1, . . . , af) is a leaf node of F T L,f(s, t) and we store in the leaf node F T L,f(s, t, a1, . . . , af) the path P L Or there is no path from s to t in G\{a1, . . . , ai} that contains at most L edges and then G(s, t,{a1, . . . , ai}) = F T L,f(s, t, a1, . . . , ai) is a leaf vertex of F T L,f(s, v) and we store in it P L ∅. Querying the tree F T L,f(s, t). Given a query (s, t, F) such that F ⊂ V ∪ E with G(s, t,{a1, . . . , af}). F = f we would like to compute dL G(s, t, F) using the tree F T L,f(s, t). The query procedure is as follows. Let P L G(s, t) be the path stored in the root of G(s, t, F) = ∞). F T L,f(s, t) (if the root of F T L,f(s, t) contains ∅ then we output that dL G(s, t) ∩ F = ∅ by checking if any of the elements a1 ∈ F appear in First we check if P L G(s, t) ∩ F = ∅ we BST L(s, t) (which takes O(log L) time for each element a1 ∈ F). If P L G(s, t) does not contain any of the vertices or edges in F). G(s, t) (as P L output dL G(s, t, F) = dL G(s, t) ∩ F. Otherwise, let a1 ∈ P L G(s, t,{a1}) be the path stored in the root of F T L,f(s, t, a1) (if the root of F T L,f(s, t, a1) contains ∅ then G(s, t,{a1}) ∩ F = ∅ by checking if any we output that dL of the elements a2 ∈ F appear in BST L(s, t, a1) (which takes O(log L) time for each element G(s, t,{a1}) a2 ∈ F). If P L We continue the search similarly in the subtree F T L,f(s, t, a1) as follows. Let P L G(s, t, F) = ∞). First we check if P L G(s, t,{a1}) ∩ F = ∅ we output dL G(s, t,{a1}) (as P L G(s, t, F) = dL 16 Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles G(s, t,{a1})∩F. We does not contain any of the vertices or edges in F). Otherwise, let a2 ∈ P L continue the search similarly in the subtrees F T L,f(s, t, a1, a2), F T L,f(s, t, a1, a2, . . . , ai) until we either reach a leaf node which contains ∅ (and in this case we output that dL G(s, t, F) = ∞) G(s, t,{a1, . . . , ai}) ∩ F = ∅ and then we or we find a path P L output dL G(s, t,{a1, . . . , ai}) such that P L In Section 6.1 we prove the following lemma. G(s, t, F) = dL G(s, t,{a1, . . . , ai}). (cid:73) Lemma 17. Given the tree F T L,f(s, t) and a set of failures F ⊂ V ∪ E with F ≤ f, the query procedure computes the distance dL G(s, t, F) in O(f 2 log L) time. We are now ready to prove lemma 15 asserting that Df = O(n2+). Proof of Lemma 15. Let L = n/f and let D be the set of all the unique shortest paths G(s, t,{a1, . . . , ai}) stored in all the nodes of all the trees {F T L,f(s, t)}s,t∈V (see Section P L 6.4 for more details on the assumption of unique shortest paths in our algorithms). Since the number of nodes in every tree F T L,f(s, t) is at most Lf = (n/f)f = n, and there are O(n2) trees (one tree for every pair of vertices s, t ∈ V ) we get that the number of nodes in all the trees {F T L,f(s, t)}s,t∈V is O(n2+) and hence D = O(n2+). We prove that Df ⊆ D. By definition, Df contains all the intervals (subpaths containing n/f edges) of all the replacement paths PG(s, t, F) for every s, t ∈ V, F ⊆ E ∪ V with F ≤ f. Let P ∈ Df be the unique shortest path as defined in Section 6.4, then P is a subpath containing n/f edges of the replacement paths PG(s, t, F). Let u be the first vertex of P, and let v be the last vertex of P. Then P is a shortest path from u to v in G \ F, and since we assume that the shortest paths our algorithms compute are unique (according to Section 6.4) then P = PG(u, v, F) is the unique shortest path from u to v in G \ F. Since P is assumed to be a path on exactly L = n/f edges, then P = PG(u, v, F) = P L G(u, v, F). According to the query procedure in the tree F T L,f(u, v) and Lemma 17, if we query the tree F T L,f(u, v) with (u, v, F) then we reach a node G(u, v,{a1, . . . , ai}) with {a1, . . . , ai} ⊆ F F T L,f(u, v, a1, . . . , ai) which contains the path P L G(u, v, F) = P is the shortest u-to-v path in G \ F. such that P L Hence, P ∈ D and thus Df ⊆ D and Df ≤ D = O(n2+) (cid:74) G(u, v,{a1, . . . , ai}) = P L 4.2 Step 2: Efficient Construction of the Fault-Tolerant Trees - Computing the Paths Df Recall that we defined the trees F T L,f(u, v) with respect the parameters f (the maximum number of failures) and L (where we search for shortest paths among paths of at most L edges). The idea is to build the trees F T L,f(u, v) using dynamic programming having the trees F T L−1,f(u, v) with parameters f, L − 1 as subproblems. Assume we have already built the trees F T i,f(u, v), where u, v ∈ V, 1 ≤ i < L, we describe how to build the trees F T i+1,f(u, v). Let (u, v, F) be a query for which we want to compute the distance di+1(u, v, F) (as part of the construction of the tree F T i+1,f(u, v)). Scan all the edges (u, z) ∈ E and query the tree F T i,f(z, v) with the set F to find the distance di(z, v, F). Querying the tree F T i,f(z, v) takes O(f 2 log i) = O(f 2 log L) time as described in Lemma 17 (note that f 2 log L = eO(1) for f ≤ log n as L ≤ n), and we run O(out-degree(u)) such queries and take the minimum of the following equation. di+1(u, v, F) = min z {ω(u, z) + di(z, v, F) (u, z) ∈ E AN D u, z, (u, z) 6∈ F} (1) parenti+1(u, v, F) = arg min z {ω(u, z) + di(z, v, F) (u, z) ∈ E AN D u, z, (u, z) 6∈ F} (2) N. Alon, S. Chechik and S. Cohen 17 the self loops (u, u) ∈ E such that ω(u, u) = 0. Note that in Equation 1 we assume that for every vertex u ∈ V it holds that G contains So the time to compute di+1(u, v, F) is eO(out-degree(u)). Next, we describe how to reconstruct the path P i+1(u, v, F) in O(L) additional time. We reconstruct the shortest path P i+1(u, v, F) by simply following the (at most L) parent pointers. In more details, let z = parenti+1(u, v, F) be the vertex defined according to Equation 2. We reconstruct the shortest path P i+1(u, v, F) by concatenating (u, z) with the shortest path P i(z, v, F) (which we reconstruct in the same way), thus we can reconstruct P i+1(u, v, F) edge by edge in constant time per edge, and hence it takes O(L) time to reconstruct the path P i+1(u, v, F) that contains at most L edges. The tree F T i,f(u, v) contains if ≤ Lf nodes, and thus all the trees {F T i,f(u, v)} for all i ≤ L, u, v ∈ V contain O(n2Lf+1) nodes together. and reconstruct the path P i(u, v,{a1, . . . , aj}) in additional O(L) time. Theretofore, com- puting all the distances di(u, v,{a1, . . . , aj}) and all the paths P i(u, v,{a1, . . . , aj}) in all the i≤L,u,v∈V Lf(out-degree(u) + L)) = In each such node we compute the distance di(u, v,{a1, . . . , aj}) in eO(out-degree(u)) time nodes of all the trees {F T i,f(u, v)}u,v∈V,1≤i≤L takes eO(P eO(mnLf+1 + n2Lf+2) time. substituting L = eO(n/f) we get an algorithm to compute the trees {F T L,f(u, v)}u,v∈V in eO(mn1++/f + n2++2/f) time. in eO(mn1++/f + n2++2/f) time. In Section 6.3 we further reduce the runtime to eO(mn1+) by using dynamic programming we also boost-up the runtime of the greedy pivots selection algorithm from eO(n2++/f) to eO(n2+) time. only for computing the first f − 1 levels of the trees F T L,f(s, t) and then applying Dijkstra in a sophisticated manner to compute the last layer of the trees F T L,f(s, t). In addition, (cid:73) Lemma 18. One can deterministically construct the trees F T L,f(s, t) for every s, t ∈ V This proves the following Lemma. 5 Deterministic Replacement Paths Algorithm In this section we add the missing parts of the eO(m √ ne edges. n) replacement paths algorithm of Roditty and Zwick [37]. In order for this paper to be self-contained, let us start by describing the randomized √ n) time deterministic replacement paths algorithm, derandomizing the replacement paths algorithm of Roddity and Zwick [37]. Recall the notion of a long triple (s, t, e) as in Definition 7. Let s, t ∈ V, e ∈ PG(s, t), the triple (s, t, e) is a long triple if for every replacement path from s to t avoiding e has its detour part containing more than d√ eO(m 5.1 The Randomized eO(m √ The algorithm by Roddity and Zwick that is described in [37] takes eO(m n) time. Their algorithm handles separately the case that a replacement path has a short detour containing at most d√ ne edges, and the case that a replacement path has a long detour containing more than d√ ne edges. The first case is solved deterministically while the second case is solved by a randomized algorithm as described below. n) Replacement Paths Algorithm of Roditty and Zwick - a Summary √ 18 Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles nc. 5.1.1 Handling Short Detours Roditty and Zwick's algorithm finds replacement paths with short detours (containing at most d√ ne edges) deterministically. Let P = PG(s, t) =< v0, . . . , vk > be the shortest path from s to t, and let G0 = G \ E(PG(s, t)) be the graph G after removing the edges of P and let ' = b k √ 2 As explained in Section 2, for every triple (s, t, e) ∈ V × V × E every replacement paths PG(s, t, e) can be partitioned into a common prefix CommonPref s,t,e, a disjoint detour Detours,t,e and a common suffix CommonSuff s,t,e. In this part of handling short detours, we would like to find all distances dG(s, t, e) such that there exists at least one replacement path PG(s, t, e) whose detour part Detours,t,e contains at most d√ ne edges. The algorithm for handling short detours has two parts. The first part, computes a table RD[i, j] which is defined as follows. For every 0 ≤ i ≤ k and 0 ≤ j ≤ d√ ne − 1 the entry RD[i, j] gives the length of the shortest path in G0 (i.e., the detour) starting at vi and ending at vi+j, if its length is at most d√ ne, or indicates that dG0(vi, vi+j) > d√ ne. The second part, uses the table of detours RD to find replacement paths whose detour part contains at most d√ First part: computing the table RD. The algorithm builds an auxiliary graph GA obtained by adding a new source vertex r to G0 and an edge (r, v2qd√ ne) of weight ne for every 0 ≤ q ≤ '. The weight of all the edges E \ E(P) is set to 1. ω(r, v2qd√ Then the algorithm runs Dijkstra's algorithm from r in GA to find all the best short detours (i.e., the shortest paths on at most d√ ne edges from vi to vj in G0 where 1 ≤ i < j ≤ k) that start in one of the vertices v0, v2d√ ne, . . . , v2'd√ ne. See Figure 3 as an illustration of the graph GA. ne) = qd√ ne edges. Figure 3 An illustration of the auxiliary graph GA obtained from G0 = G \ E(P ) by adding the ne for every 0 ≤ q ≤ '. In ne, where we add ne, (q + 1)d√ ne following auxiliary edges. We add the edges (r, v2qd√ this example we present the subgraph with the vertices v(2q−2)d√ the edges (r, v(2q−2)d√ respectively. ne) with weights (q − 1)d√ ne, . . . , v(2q+3)d√ ne, qd√ ne) of weight qd√ ne), (r, v2qd√ ne), (r, v(2q+2)d√ n of the In a sense, the algorithm already found all the relevant detours from about k√ vertices. More precisely, the algorithm has found the entries RD[i, j] for 0 ≤ i ≤ k, 0 ≤ √ j ≤ d√ ne) = 0. By running this algorithm in O( n) phases (in phase p we compute the entries of RD[i, j] such that 0 ≤ i ≤ k, 0 ≤ j ≤ d√ ne − 1 and (i mod 2d√ ne) = p), we can find all the relevant detours starting from all the nodes of ne − 1 such that (i mod 2d√ 𝑟𝑣2𝑖−2𝑛𝑣2𝑖−1𝑛𝑣2𝑖𝑛𝑣(2𝑖+1)𝑛𝑣(2𝑖+2)𝑛𝑣(2𝑖+3)𝑛𝑖−1𝑛𝑖𝑛(𝑖+1)𝑛 N. Alon, S. Chechik and S. Cohen 19 the path P. That is, we run this algorithm 2d√ emanating from the other vertices of PG(s, t). In the pth phase (for 0 ≤ p ≤ 2d√ the short detours emanating from one of the vertices vp, vp+2d√ ne, . . . , vp+2'd√ the algorithm on the graph GA obtained by adding to G0 the edges (r, vp+2qd√ ω(r, vp+2qd√ RD. ne − 1 more times to find short detours ne − 1) find ne by running ne) of weight nec. Store the computed detours in the table ne instances of Dijkstra's algorithm whose ne for every 0 ≤ q ≤ b k−p 2d√ n) time, as we run d√ ne) = qd√ This part takes eO(m runtime is eO(m). The correctness of this algorithm for computing short detours is based on the following √ ne − 1, then dG0(v2qd√ ne+j) > d√ ne, v2qd√ ne. ne + dG(v2zd√ ne+j) ≤ (q +1)d√ ne, v2qd√ ne+j) = dGA(r, v2qd√ ne + dG0(v2zd√ ne ≥ (q + 1)d√ ne, where 0 ≤ q ≤ ' and ne. Otherwise, ne+j) − qd√ ne which is already larger than (q + 1)d√ ne+j in GA is less than (q + 1)d√ ne+j starts with the edge (r, v2qd√ theorem from [37]. (cid:73) Theorem 19 (Theorem 1 in [37]). If dGA(r, v2qd√ 0 ≤ j ≤ d√ dG0(v2qd√ The basic idea of the proof of Theorem 19 is the following. Let 0 ≤ q ≤ ' and 0 ≤ j ≤ d√ ne then it must ne − 1. If the distance from r to v2qd√ be that the shortest path from r to v2qd√ ne). Otherwise, if it starts with the edge (r, v2zd√ ne) for z > q then the weight of this edge is at least (z + 1)d√ ne contradicting the assumption that ne+j in GA is less than (q + 1)d√ ne. On the other hand, if the distance from r to v2qd√ it starts with the edge (r, v2zd√ ne) for z < q then the length of any such path is at least zd√ ne + j) = qd√ ne, 2qd√ ne + j) ≥ qd√ ne, 2qd√ ne + 2(q − z)d√ ne where the first inequality holds since distances in G0 (which is obtained by removing the edges of PG(s, t) from G) are only larger than distances in G, and the last inequality holds since z < q. Second part: using the table RD to find replacement paths whose detour part contains at most d√ ne edges. To find the replacement path from s to t that avoids the edge (vi, vi+1) and uses a short detour, the algorithm finds indices i − d√ ne ≤ a ≤ i and i < b ≤ i+d√ ne for which the expression dG(s, va)+RD[a, b−a]+dG(vb, t) = a+RD[a, b−a]+(k−b) queue Q and a sliding window approach in time eO(m is minimized. The algorithm computes it for every edge (vi, vi+1) ∈ PG(s, t) using a priority n) as follows. When looking for the shortest replacement path for the edge (vi, vi+1), the priority queue Q contains all pairs (a, b) such that i − d√ ne. The key associated with a pair (a, b) is, as mentioned above, a + RD[a, b − a] + (k − b). In the start of the iteration corresponding to the edge (vi, vi+1), the algorithm inserts the pairs (i, j), for i + 1 ≤ j ≤ i + d√ ne into Q, and removes from it the pairs (j, i), for i − d√ ne ≤ j ≤ i. A find-min operation on Q then The complexity of this process is only eO(nd√ returns the minimal pair (a, b). we perform O( is larger than the assumed distance from r to v2id√ delete operations (for all values of j such that i − d√ n) operations of insert/delete/find-min which take eO(n time. Thus, the total running time of the algorithm for handling short detours is eO(m operation. In total, we have O(n ne): for every vertex vi (for every 0 ≤ i ≤ n) ne) which √ ne + j O( n) ne ≤ j ≤ i), and a single find-min √ n) √ n). n) insert operations (for all values of j such that i + 1 ≤ j ≤ i +d√ ne ≤ a ≤ i and i < b ≤ i + d√ ne+j in GA is at most id√ √ √ √ 5.1.2 Handling Long Detours To find long detours, the algorithm samples a random set R as in Lemma 1 such that each √ vertex is sampled independently uniformly at random with probability (4 ln n)/ n, the set R 20 Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles has expected size of eO( √ n). For every sampled vertex r ∈ R and for every edge ei = (vi, vi+1) (where 0 ≤ i ≤ k) we find the shortest replacement path PG(s, t, e) which passes through r. This algorithm has two steps as well. In the first step, for every sampled vertex r ∈ R, we construct two BFS trees from r, one in G0 = G \ E(P) and one in the graph obtained from G0 by reversing all the edge directions. This computes the distances dG0(r, v) and dG0(v, r), for every r ∈ R and v ∈ V . In the second step, we run the following procedure for every sampled vertex r ∈ R. Given r ∈ R, we find for every edge ei = (vi, vi+1) ∈ PG(s, t) the shortest path from s to t avoiding ei which passes through r. To do so, we construct two priority queues Qin[r] and Qout[r] containing indices of vertices on PG(s, t). During the computation of a replacement path for the edge ei = (vi, vi+1) we would like to run a find-min operation using priority queue Qin[r] to find the shortest path from s to r which avoids ei, and we would like to run a find-min operation using priority queue Qout[r] to find the shortest path from r to t which avoids ei. To do so, during the computation of a replacement path for the edge ei = (vi, vi+1) we would like to have Qin[r] = {0, 1, . . . , i} and Qout[r] = {i + 1, . . . , k} such that an element j ∈ Qin[r] has its key in Qin[r] equal to j + dG0(vj, r) and an element j ∈ Qout[r] has its key in Qout[r] equal to dG0(r, vj) + (k − j). Note that we have already computed dG0(vj, r) in the BFS tree rooted in r in the graph G0 with reverse edge directions and we have already computed dG0(r, vj) in the BFS tree rooted in r in the graph G0. In order to achieve that at iteration i (for 0 ≤ i ≤ k − 1) we have Qin[r] = {0, 1, . . . , i} and Qout[r] = {i + 1, . . . , k} we apply the following sliding window approach. We initiate the queues Qin[r] contains only the element 0 with key equal to dG0(v0, r) and Qout[r] = {1, . . . , k} such that an element j ∈ Qout[r] has its key in Qout[r] equal to dG0(r, vj) + (k − j). Then we compute the length of the shortest path from s to t avoiding e0 and passing through r as find-min(Qin[r])+ find-min(Qout[r]). Next, we remove from Qout[r] the element 1 and insert it to Qin[r] with its key equal to 1 + dG0(v1, r), and compute the length of the shortest path from s to t avoiding e1 and passing through r as find-min(Qin[r])+ find-min(Qout[r]). In general, after finishing the ith iteration we run the (i + 1)th iteration as follows. we remove from Qout[r] the element i + 1 and insert it to Qin[r] with its key equal to i + 1 + dG0(vi+1, r), and compute the length of the shortest path from s to t avoiding ei+1 and passing through r as find-min(Qin[r])+ find-min(Qout[r]). Finally, for every edge ei = (vi, vi+1) we iterate over all vertices r ∈ R and find the shortest path from s to t going through one of the vertices R. When (s, t, e) is a long triple, there exists at least one replacement path PG(s, t, e) whose detour part contains at least d√ ne edges, and thus with high probability at least one of the vertices of the detour is sampled in the set R (since we sample every vertex uniformly at random with probability √ (4 ln n)/ n). The total expected time of computing these distances is eO(m are eO( queues Qin[r] and Qout[r] which takes eO(n) time per vertex r ∈ R, and hence eO(n O(R) vertices which is eO( eO(n n): first of all, there n) randomly chosen vertices R and every BFS computation takes O(m + n) time. Secondly, for every r ∈ R we perform O(n) insert, delete and find-min operations on the √ n) expected time. Finally for every edge ei we iterate over all the vertices r ∈ R to find the minimum length of a shortest path from s to t avoiding ei which passes through one of the vertices r ∈ R. There are O(n) edges ei ∈ PG(s, t), and for every edge ei we iterate over n) in expectation, and thus the total runtime of this part is n). In total we get that the algorithm takes eO(m √ √ n) time. √ √ √ N. Alon, S. Chechik and S. Cohen 21 5.2 The Only Randomization Used in The Replacement Paths Algorithm of Roditty and Zwick √ As mentioned above, the algorithm by Roddity and Zwick handles separately the case that the replacement path has a short detour containing at most d√ ne edges, and the case that the replacement path has a long detour containing more than d√ ne edges. The first case is solved deterministically. The second case is solved by first sampling a subset of vertices R according to Lemma 1, where each vertex is sampled uniformly independently at random with probability c ln n/ n for large enough constant c > 0. Using this uniform sampling, it holds with high probability (of at least 1 − n−c+2) that for every long triple (s, t, e), the detour Detours,t,e of the replacement path PG(s, t, e) contains at least one vertex of R. As the authors of [37] write, the choice of the random set R is the only randomization used by their algorithm. More precisely, the only randomization used in the algorithm of [37] is described in the following lemma (to be self-contained, we re-write the lemma here). (cid:73) Lemma 20 (proved in [37]). Let R ⊆ V be a random subset obtained by selecting each √ n, for some constant c > 0. Then with high vertex, independently, with probability (c ln n)/ n) vertices and for every long triple (s, t, e) there exists a replacement path PG(s, t, e) whose detour part contains at least one of the vertices of R. probability of at least 1 − n−c+2, the set R contains eO( √ 5.3 Derandomizing the Replacement Paths Algorithm of Roditty and Zwick - Outline √ √ √ n) vertices. To obtain a deterministic algorithm for the replacement paths problem and to prove Theorem 3, we prove the following deterministic alternative to Lemma 20 by a clever choice of the set R of eO( (cid:73) Lemma 21 (Our derandomized version of Lemma 20). There exists an eO(m deterministic algorithm which computes a set R ⊆ V of eO( Following the above description, in order to prove Theorem 3, that there exists an eO(m We compute in eO(m n) time n) vertices, such that for every long triple (s, t, e) there exists a replacement path PG(s, t, e) whose detour part contains at least one of the vertices of R. √ n) deterministic replacement paths algorithm, it is sufficient to prove the derandomization lemma (Lemma 21), we do so in the following sections. Following is an overview our approach. n) time a set Dn of at most n paths, each path of length exactly d√ ne. The crucial part of our algorithm is in efficiently computing the set of paths Dn with the following property; for every long triple (s, t, e) there exists a path D ∈ Dn and a replacement path PG(s, t, e) such that D is contained in the detour part of PG(s, t, e). More (cid:73) Lemma 22. There exists a deterministic eO(m precisely, we prove the following Lemma. n) algorithm for computing a set Dn of at most n paths, each path of length exactly d√ ne with the following property; for every long triple (s, t, e) there exists a path D ∈ Dn and a replacement path PG(s, t, e) such that D is the detour part of PG(s, t, e). √ √ After computing Dn we obtain the set of vertices R by running the GreedyPivotsSelection(Dn) algorithm as described in Section 1.3 and Section 1.3, and as stated in Lemma 2. Given Dn, the deterministic greedy selection algorithm GreedyPivotsSelection(Dn) computes a set n) time with the following property; every path D ∈ Dn n) vertices in eO(n R ⊂ V of eO( √ √ contains at least one of the vertices of R. 22 Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles Using Lemma 22 and Lemma 2 we can prove the derandomization Lemma 21 and thus prove Theorem 3. √ Proof of Theorem 3. According to Lemma 22 we deterministically compute in eO(m n) time the set Dn of at most n paths, each path of length exactly d√ ne with the following property; for every long triple (s, t, e) there exists a path D ∈ Dn and a replacement path PG(s, t, e) such that D is contained in the detour part of PG(s, t, e). 2, the greedy selection algorithm takes eO(n Then, we run the greedy selection algorithm on the set of paths Dn. According to Lemma √ n) n) time, and computes the set R ⊂ V of eO( vertices such that every path D ∈ Dn contains at least one of the vertices of R. We get that for every long triple (s, t, e) there exists a path D ∈ Dn and a replacement path PG(s, t, e) such that D is contained in the detour part of PG(s, t, e), and the path D ∈ Dn contains at least one of the vertices of R. Hence, for every long triple (s, t, e) there exists a replacement path PG(s, t, e) whose detour part contains at least one of the vertices of R. This proves Lemma 21. √ obtain an eO(m Thus, we derandomize the randomized selection of the set of vertices R in Roditty and Zwick's algorithm [37], and as this is the only randomization used by their algorithm we n) deterministic algorithm for the replacement paths problem in unweighted (cid:74) √ directed graphs. In the following section we prove Lemma 22. In Section 3.1 we already mathematically defined the set Dn and in Section 5.4 we describe a deterministic algorithm for computing √ Dn in eO(m n) time. 5.4 An eO(m √ In this section we describe how to compute Dn in eO(m √ n) Deterministic Algorithm for Computing Dn n) time and thus proving Lemma 22. In Section 3.2 we presented an overview of the algorithm. We refer the reader to first read the overview in Section 3 before reading the following formal description of the algorithm and its analysis. n to be V w√ n ← {v ∈ V d√ n, let Dw(v) be the suffix of the last d√ In this section we describe the algorithm more formally, and analyse its correctness and runtime. Given the shortest path PG(s, t) =< s = v0, . . . , vk = t > the algorithm computes the weighted graph Gw = (G, w) by taking the graph G and setting the weight of the edges of PG(s, t) to be  for some small  such that 0 <  < 1/n and the weight of all other edges to be 1. The algorithm then invokes Dijkstra from s in Gw, builds the shortest paths tree Ts rooted at s and sets the distances array d[v] = dGw(s, v) for every v ∈ V . In addition, the ne + 1}. For every algorithm initializes the set V w√ vertex v ∈ V w√ ne edges of the shortest path from s to v in Ts. Add to the set Dw√ n (initially is set to be the empty set) the subpath Dw(v) for every vertex v ∈ V w√ n. ne + 1 and The algorithm then removes from Ts all the vertices v such that d[v] > d√ Next, the algorithm operates in PG(s, t) iterations. In iteration i starting from k − 1 to 0 the algorithm does the following. Let Ts,vi+1 be the subtree of Ts rooted at vi+1. Construct the graph Gs,vi+1 as follows. The set of vertices Vs,vi+1 of Gs,vi+1 is Vs,vi+1 = {s} ∪ {v ∈ V v ∈ Ts,vi+1 \ {vi+1} or (∃(v, v0) ∈ E such that v ∈ Ts \ {vi+1} and v0 ∈ Ts,vi+1)} \ {vi+1}. Essentially, Vs,vi+1 contains all the vertices in the subtree of Ts rooted in vi+1 and all of their neighbours (except the vertex vi+1 itself). ne ≤ d[v] < d√ sets d[v] = ∞. N. Alon, S. Chechik and S. Cohen 23 The set of edges of Gs,vi+1 contains two types of edges. The first type is auxiliary shortcut edges, for every vertex v ∈ Vs,vi+1 such that v /∈ Ts,vi+1 add an edge (s, v) with weight d[v]. The second type is original edges, for every vertex v ∈ Ts,vi+1 \ {vi+1} add all its incident edges (v, v0) such that v0 ∈ Vs,vi+1 with weight 1. The algorithm removes from the tree Ts the vertex vi+1. The algorithm then computes Dijkstra from s in Gs,vi+1 and for every vertex v ∈ Ts,vi+1 \{vi+1} it sets d[v] = dGs,vi+1 (s, v) and sets the parent of v in Ts to be the parent of v in the computed Dijkstra. For every vertex v ∈ Ts,vi+1 such that d[v] > d√ ne + 1 remove v from Ts and set d[v] = ∞. For every vertex v ∈ Ts,vi+1 such that d√ n and the subpath Dw(v) to Dw√ ne ≤ d[v] < d√ ne + 1 add v to V w√ We prove the correctness and efficiency of our algorithm in the following Lemmas. n. n then by definition of V√ ne edges, and thus any path from s to x in Gw n and let D0(x) be the suffix of the last ρ(x). Then D0(x) is a shortest path from n for every index 0 ≤ i < ρ(x) it holds that ne. Thus, every path in G0 from vi to x for every i < ρ(x) contains more ρ(x) that does not pass through vρ(x) (cid:73) Lemma 23. Let x be a vertex such that x ∈ V√ d√ ne edges of the shortest path from s to x in Gw vρ(x) to x in G0. Proof. Since x ∈ V√ dG0(vi, x) > d√ than d√ has length at least d√ Therefore, the shortest path from s to x in Gw ρ(x)(s, vρ(x)) + dGw the last inequality holds as  < 1/n and ρ(x) ≤ n). Hence, the suffix of the last d√ ρ(x) is a shortest path from vρ(x) to x in G0. of the shortest path from s to x in Gw trimmed at distance d√ (cid:73) Lemma 24. After the ith iteration, if dGw (s, v), and otherwise d[v] = ∞. dTs(s, v) = dGw Proof. We prove the claim by induction on i. ne + 1. ρ(x)(vρ(x), x) = ρ(x) + dG0(vρ(x), x) = ρ(x) + d√ ρ(x) passes through vρ(x) and its length is ne + 1 (where ne edges (cid:74) The following lemma shows that after the i'th iteration Ts is a shortest path tree in Gw ne + 1 and d[v] is the distance from s to v in Ts for every v ∈ V . ne + 1 then v ∈ Ts and d[v] = (s, v) < d√ ne < d√ dGw i i i i (s, v) < d√ i ⊆ Gw i+1(s, v). For i = k, that is, Gw ne + 1. We also have dGw k = Gw the claim trivially holds by the correctness of Dijkstra on Gw. Assume the claim is correct for iteration j such that j > i and consider iteration i for some i < k. Consider a vertex v such that dGw i+1(s, v) < d√ ne + 1 as Gw i+1. By induction hypothesis we have that before iteration i, d[v] = dTs(s, v) = dGw If v /∈ Ts,vi+1 then d[v] and dTs(s, v) do not change. Moreover the shortest path from s i+1, since this shortest path does not i . Hence, after iteration i it holds that v ∈ Ts to v in Ts before the iteration is a shortest path in Gw contain vi+1 it is also a shortest path in Gw and d[v] = dTs(s, v) = dGw (s, v). We first prove that dGs,vi+1 (s, v) ≥ dGw (s, v). By construction of Gs,vi+1, every edge (x, y) of i , or it is an auxiliary Gs,vi+1 is either an original edge of G with weight 1 that exists also in Gw shortcut edge (s, y) such that y /∈ Ts,vi+1 and its weight in Gs,vi+1 is defined as ω(s, y) = d[y]. In the latter case, we have already proved in the previous paragraph that d[y] = dGw (s, y) i . Hence, every s-to-v path in Gs,vi+1 is is the length of the shortest path from s to y in Gw i of the same length, and hence dGs,vi+1 (s, v) ≥ dGw (s, v). associated with an s-to-v path in Gw (s, v) ≤ dGs,vi+1 (s, v). Let P 0 be a shortest path from s to v in i+1(s, v) < d√ (s, v) < d√ ne + 1 Consider the case that v ∈ Ts,vi+1 \ {vi+1}. We prove that dGs,vi+1 (s, v) = dGw We now prove that dGw i . Since we assumed dGw Gw ne + 1 and Gw i+1 then dGw i ⊂ Gw (s, v). i i i i i i i 24 Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles i i and hence by the induction hypothesis all the vertices along P 0 are in Ts at the beginning of iteration i. Let v0 ∈ P 0 be the last vertex of P 0 such that v0 /∈ Ts,vi+1. Since we assume v ∈ Ts,vi+1, then v0 6= v and all the vertices following v0 in P 0 are in Ts,vi+1. Let P1 be the subpath of P 0 from s to v0, and let P2 be the subpath of P 0 from v0 to v. We claim that the edge (s, v0) ∈ Gs,vi+1 and its weight is ω(s, v0) = dGw (s, v0). Since v0 is a neighbour of a vertex in Ts,vi+1 (e.g., the vertex which follows v0 in P 0 is in Ts,vi+1 by definition of v0) then it holds that v0 ∈ Vs,vi+1. Hence (s, v0) is a shortcut edge from s to v0 whose weight equals to the weight of the shortest path d[v0] and as v0 6∈ Ts,vi+1 then we have already proved above that v0 ∈ Ts and d[v0] = dTs(s, v0) = dGw (s, v0). Furthermore, since all the vertices of P 0 after v0 are contained in Ts,vi+1 and thus in Vs,vi+1, then it follows that all the edges of P2 i . Hence, the path are contained in Gs,vi+1 with weight 1 which is their original weights in Gw P 00 = (s, v0)· P2 is a path in Gs,vi+1 whose length is P 00 = ω(s, v0)+P2 = P1+P2 = P 0. Therefore, Gs,vi+1 contains a s-to-v path (e.g., the path P 00) whose length is P 0. It follows (s, v) and the that dGw claim follows. ne + 1 then the claim follows by induction hypothesis. Otherwise it follows that v ∈ Ts,vi+1. It is not hard to verify that for every vertex u that belongs to Ts after iteration i, we indeed have ne + 1 we have v /∈ Ts and dGs,vi+1 (s, u) = dGw d[v] = ∞ after iteration i. (cid:74) ne + 1 trees Ts,vi+1. (s, v) ≤ dGs,vi+1 (s, v). Therefore, it holds that dGs,vi+1 (s, v) = dGw i+1(s, v) > d√ The following lemmas show that every vertex x belongs to at most d√ ne + 1. Hence, since v > d√ Consider the case where dGw (s, u) ≤ d√ (s, v) > d√ ne + 1. If dGw As we will later see, this will imply our desired running time. (cid:73) Lemma 25. Consider an iteration i for some 0 ≤ i ≤ k − 1 and a vertex x such that x ∈ Ts,vi+1 \ {vi+1}. Then i i i i bdGw (s, x)c ≥ bdGw i i+1(s, x)c + 1. i (s, x)c ≤ bdGw i+1. Therefore, dGw i+1 at most i0 + bdGw i+1(s, x) = (i + 1) + dG0(vi+1, x) which is a contradiction since dGw Proof. Assume x belongs to Ts,vi+1 \ {vi+1} for some 0 ≤ i ≤ k − 1. By Lemma 24 after the i'th iteration, the shortest path between s and x in Ts is a shortest path between i . Moreover, since x belongs to Ts,vi+1 \ {vi+1} then vi+1 is on a shortest s and x in Gw path from s to x in Gw i+1(s, x) = (i + 1) + dG0(vi+1, x). Observe that i+1(s, x)c is the length of the shortest path from vi+1 to x in G0 (since  < 1/n). Assume bdGw i+1(s, x)c. Then the length of the shortest path from by contradiction that bdGw vi0 to x in G0 for some index i0 < i + 1 is at most the length of the path from vi+1 to x in G0. Then the path from s to vi0 along PG(s, t) concatenated with the shortest path from i+1(vi0, x)c and hence it is shorter than vi0 to x in G0 has length in Gw i+1(s, x) is the length of dGw (cid:74) the shortest path from s to x in Gw d√ (cid:73) Lemma 26. Every vertex x belongs to at most d√ Proof. Assume x belongs to the trees Ts,vi1 ...Ts,vir r ≤ d√ holds that d[v] = dGw bdGw ne + 1 subtrees Ts,vi+1 for 0 ≤ i ≤ k − 1. for i1 < i2 < ... < ir. We will show that By Lemma 24 as long as x ∈ Ts for some iteration j we have that after iteration j it ij−1(s, x)c ≤ By Lemmas 24 and 25 and the fact that the algorithm trims the tree Ts at distance ne + 1 we get the following. (s, v). By Lemma 25 we have bdGw ne + 1, which implies the lemma. (s, x)c + 1 ≤ bdGw (s, x)c. i+1. ij j ij−1 N. Alon, S. Chechik and S. Cohen 25 ne + 1 as required. Since the algorithm only maintains vertices v whose distance d[v] is less than d√ ne + 1 ne + 1 subtrees Ts,vi+1 the algorithm removes it from Ts and (cid:74) then after x participates in d√ therefore r ≤ d√ (cid:73) Lemma 27. The total running time of the algorithm is O(m Proof. The dominant part of the running time of the algorithm is the computations of Dijkstra. The first Dijkstra computation is on the graph Gw and it takes O(m + n log n) time. We claim that the computation of iteration i takes O(P deg(v) log n), where number of edges in Gs,vi+1 is bounded by O(P deg(v) is the degree of v in G. To see this, note that both the number of nodes and the deg(v)). By Lemma 26 every node v belongs to at most d√ ne + 1 trees Ts,vi+1. It is not hard to see now that the lemma (cid:74) follows. v∈Ts,vi+1 v∈Ts,vi+1 n). √ The following Lemma proves Lemma 9. n = V√ ne and d√ i ne. n. Let x ∈ V w√ ne ≤ d[x] < d√ We first prove that dG0(vi, x) = d√ ne ≤ P = < v0, . . . , vi > + PG0(vi, x) = i + dG0(vi, x) < d√ n and Dw√ n can be chosen as the set Dn according to Definition 12. (cid:73) Lemma 28. V w√ n. As x ∈ V w√ n ⊆ V√ Proof. We first prove that V w√ n then there exists an iteration i0 such that after iteration i0, d√ ne + 1. Consider the tree Ts after iteration i0. By Lemma 24 after iteration i0, the path from s to x in Ts is of length d[x] and i0 . Let P be the shortest path from s to x in Ts. is a shortest path in Gw Let i be the maximal index such that vi is on the shortest path P. As P does not contain any vertex vj such that i + 1 ≤ j then P is also a shortest path in Gw i . As P is of length ne+1 we prove that i = ρ(x). We need to prove that dG0(vi, x) = d√ between d√ ne and that the distance from vj for every j ≤ i to x in G0 is more than d√ ne. Since P is a shortest s-to-x path in Ts and i be the maximal index such that vi is on the shortest path P then P is composed of the path < v0, . . . , vi > followed by a shortest path from vi to x in G0. That is P =< v0, . . . , vi > ·PG0(vi, x) (where PG0(vi, x) is a shortest path from vi to x in G0) . We have that d√ ne + 1 and < v0, . . . , vi > = i < 1 (as  < 1/n). Since all the edges of PG0(vi, x) have weight 1, we get that PG0(vi, x) = dG0(vi, x) = bPc = d√ Next, we prove that the distance from vj for every j < i to x in G0 is more than d√ ne. Indeed, assume by contradiction there exists an index j < i such that dG0(vj, x) ≤ d√ ne. Then the path P 0 =< v0, . . . , vj > ◦PG0(vj, x) (where PG0(vj, x) is a shortest path from vj to x in G0) has length P 0 = j + dG0(vj, x) ≤ j + d√ ne = P. We get that P 0 which is a s-to-x path in Gw i , which is a contradiction. We proved that dG0(vi, x) = d√ ne for every j ≤ i and hence i = ρ(x). By Lemma 23 it follows that Dw(x) (which is the subpath containing the last d√ ne edges of P) is a shortest path from vρ(x) to x in G0. Note also that the algorithm adds to Dw√ n then there exists an index 0 ≤ ρ(x) ≤ k n. Let x ∈ V√ We now prove that V√ such that dG0(vρ(x), x) = d√ ne + 1. Consider the tree Ts at the end of iteration ρ(x). ne+1 and hence by Lemma 24 it follows that x ∈ Ts. We first prove that dGw Let P be the following path from s to x. P =< v0, . . . , vρ(x) > ◦PG0(vρ(x), x), that is, the path composed of the first ρ(x) edges from s to vρ(x) along PG(s, t) followed by a shortest n ⊆ V w√ ne and for all 0 ≤ i < ρ(x) it holds that dG0(vi, x) ≥ d√ is shorter than P which is a shortest s-to-x path in Gw ne and dG0(vj, x) > d√ n the subpath Dw(v). ρ(x)(s, x) < d√ ne. ne < i + d√ 26 Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles ne + 1. ne + 1 and ne < d√ ne. Let P 0 = PGw Next, we prove that dGw ρ(x)(s, x) ≥ d√ ρ(x)(s, x) ≤ P < d√ path from vρ(x) to x in G0. Since P = ρ(x) + dG0(vρ(x), x) = ρ(x) +d√ P is a path in Gw ρ(x) it follows that dGw ρ(x)(s, x) be a shortest path ρ(x). Let i be the maximal index such that vi ∈ P 0, then the subpath from s to x in Gw of P 0 from vi to x is a shortest path in G0 and its length dG0(vi, x). Since i ≤ ρ(x) (as ρ(x)) then by Definition 10 it follows that dG0(vi, x) ≥ d√ ne. Therefore, P 0 is a path in Gw ρ(x)(s, x) = P 0 ≥ dG0(vi, x) ≥ d√ dGw ρ(x)(s, x). Hence, by the end of the By Lemma 24 after the ρ(x) iteration, d[v] = dGw ρ(x) iteration d√ ne ≤ d[v] < d√ n. Let P be the shortest s-to-x path in Ts after the ρ(x) iteration. By Lemma 24 it holds that P is a ρ(x), and by Lemma 23 it follows that Dw(x) (which is the subpath shortest s-to-x path in Gw containing the last d√ ne edges of P) is a shortest path from vρ(x) to x in G0. Note that the algorithm adds to Dw√ n the subpath Dw(v). ne + 1. Therefore, by construction x ∈ V w√ ne. In the proof above, we have also proved that every vertex x ∈ V√ ne) of weight ω(rz, vz+2q) = qd√ n. The path D(x) is obtained by the algorithm by taking the last d√ n we add a single path ne edges D(x) to Dw√ ρ(x), and we have already proved that it is a of a shortest path from s to x in the graph Gw shortest path from ρ(x) to x in G0 whose length is d√ n can be used as the set of paths Dn according to Definition 12. (cid:74) 5.5 An Alternative eO(m √ n) Deterministic Algorithm for Computing Dn We shortly describe an alternative eO(m n) deterministic algorithm for computing Dn. The algorithm of Roddity and Zwick [37] for handling short detours constructs 2d√ ne auxiliary ne−1 (see Figure 3 as an illustration of the graph GA = GA0 ). For every graphs GA0 , . . . , GA 2d√ 0 ≤ z ≤ 2d√ z is obtained by adding a new source vertex rz to ne for every integer 0 ≤ q ≤ √ G0 and an edge (rz, vz+2qd√ 2 . The weight of all the edges E \ E(P) is set to 1. Then run Dijkstra's algorithm from rz in z that computes a shortest paths tree Tz. GA We claim that given the shortest paths trees T0, . . . , T2d√ ne−1, the following algorithm computes the set of paths Dn. For every v ∈ V the algorithm computes the minimum index 0 ≤ i ≤ k such that at least one of the shortest paths trees T0, . . . , T2d√ ne−1 contains a path from vi to v of length d√ ne, and let P 0(v) be this path from vi to v. If no such index 0 ≤ i ≤ k exists, then set P 0(v) = ∅. For every vertex v ∈ V finding this minimum index i √ n) shortest paths trees to check, and in every shortest takes O( paths tree Tz we only need to check the first edge (rz, vj) of the path from rz to v. So, given ne−1, computing the paths Dn = {P 0(v) v ∈ V } takes the shortest paths trees T0, . . . , T2d√ O(n (cid:73) Lemma 29. Let x ∈ V√ Tz contains a shortest path in G0 from vρ(x) to x of length d√ Proof. Since x ∈ V√ to x contains exactly d√ must start with the edge (rz, vρ(x)). that starts with the edge (rz, v0) such that v0 = vρ(x)−i·2d√ ω(P1) = ω(rz, v0) + dG0(v0, x) = ω(rz, vρ(x)) − i · d√ (2i + 1) · d√ shorter than P1 and thus P1 is not a shortest path in GA z . ne edges. We prove that every shortest path in GA Let P 0 = (rz, vρ(x)) ◦ PG0(vρ(x), x). Assume there exists a path P1 in GA z from rz to x ne for some integer i > 0. Then ne + ne = ω(P 0). Then P 0 is ne and thus the shortest path in G0 from vρ(x) z from rz to x ne + dG0(v0, x) ≥ ω(rz, vρ(x)) − i · d√ n and let z := (ρ(x) mod 2d√ ne = ω(rz, vρ(x)) + (i + 1) · d√ n then dG0(vρ(x), x) = d√ √ n) time as there are O( ne > ω(rz, vρ(x)) + d√ ne). Then the shortest paths tree ne. ne − 1, the auxiliary graph GA n ne. This proves that Dw√ √ √ n) time. N. Alon, S. Chechik and S. Cohen 27 Assume there exists a path P2 in GA such that v0 = vρ(x)+i·2d√ ω(rz, vρ(x)) + i · d√ P2 and thus P2 is not a shortest path in GA z . ne + dG0(v0, x) > ω(rz, vρ(x)) + d√ It follows that every shortest path from rz to x in GA z from rz to x that starts with the edge (rz, v0) ne for some integer i > 0. Then ω(P2) = ω(rz, v0) + dG0(v0, x) = ne = ω(P 0). Then P 0 is shorter than ne. z must start with the edge (rz, vρ(x)). In particular, the shortest paths tree Tz contains a shortest path in G0 from vρ(x) to x of length d√ (cid:74) Finally, let Dn := {P 0(v) v ∈ V } be the set of paths computed by the above algorithm. Then Dn is a set of O(n) paths, each path contains exactly d√ ne edges, and it follows from Lemma 29 and Definition 12 that a subset of the paths Dn satisfies the conditions of Definition 12. Hence, it is sufficient to use the greedy algorithm GreedyPivotsSelection to hit the set of paths Dn. 6 Deterministic f-Sensitivity Distance Oracles As explained in the introduction, an f-Sensitivity Distance Oracle gets as an input a graph G and a parameter f, preprocesses it into a data-structure, such that given a query (s, t, F) with s, t ∈ V, F ⊆ E ∪ V,F ≤ f one may efficiently compute the distance dG\F (s, t). In this section we derandomize the result of Weimann and Yuster [39] for real edge weights. They presented an f-sensitivity distance oracle whose preprocessing time is eO(mn1+) (which query time is subquadratic eO(n2−2/f). More precisely, we prove the following theorem which is larger than the time it takes to compute APSP which is O(mn) by a factor of n) and whose obtains deterministically the same preprocessing and query time bounds as the randomized f-sensitivity distance oracle in [39] for real edge weights. (cid:73) Theorem 30. Let G be a weighted directed graph, and let f ≥ 1 be a parameter. One given a query (s, t, F) with F ⊂ V ∪ E and F ≤ f the deterministic query algorithm for can deterministically construct an f-sensitivity distance oracle in eO(mn1+) time, such that computing dG\F (s, t) takes subquadratic eO(n2−2/f) time. The basic idea in derandomizing the real weighted f-sensitivity distance oracles of Weimann and Yuster [39] is to use a variant of the fault tolerant trees F T L,f(s, t) described in Appendix A in [11] to find short replacement paths, and then use the greedy algorithm from Section 1.3 and Lemma 2 for derandomizing the random selection of the pivots, and finally continue with the algorithm of [39] for stitching short segments to obtain the long replacement paths. This overview is made clear in the description below. According to Section 6.4, we will assume WLOG the following holds. Unique shortest paths assumption: we assume that all the shortest paths are unique. Non-negative weights assumption: we assume that edge weights are non-negative, so that we can run Dijkstra. Outline. Let s, t ∈ V be vertices and let f, L ≥ 1 be integer parameters. In Section 4.1 we described the trees F T L,f(s, t) which are a variant of the trees that appear in Appendix A of [11]. In Section 4.2 we described how to construct the trees F T L,f(s, t) in eO(mn1++/f + n2++2/f) time. In Section 6.1 we prove Lemma 17, that the algorithm described in Section 4.1 computes the distance dL G(s, t, F) in O(f 2 log L) time. In Section 6.2 we describe how to use the trees F T L,f(s, t) in order to construct an f-sensitivity distance oracle. In Section 6.3 we reduce 28 Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles the construction time of the trees F T L,f(s, t) to eO(mn1+). In Section 6.3.4 we reduce the runtime of the GreedyPivotsSelection algorithm from eO(n2++/f) to eO(n2+). In Section 6.4 we justify our assumptions of non-negative edge weights and unique shortest paths. G(s, t,{a1, . . . , ai})∩F = ∅ (note that this includes the case that dL 6.1 Proof of Lemma 17 Proof of Lemma 17. We first prove correctness, that the query procedure outputs dL G(s, t, F). G(s, t,{a1, . . . , ai}) such that {a1, a2, . . . , ai} ⊆ F The query procedure outputs a distance dL G(s, t,{a1, . . . , ai}) = and P L ∞ when there is no path from s to t in G\{a1, a2, . . . , ai} that contains at most L edges). The G(s, t,{a1, . . . , ai}) is the minimum length of an s-to-t path that contains at most distance dL L edges in the graph G \ {a1, a2, . . . , ai}. On the one hand, since {a1, a2, . . . , ai} ⊆ F and distances may only increase as we delete more and more vertices and edges, we obtain that G(s, t,{a1, . . . , ai}) ≤ dL G(s, t,{a1, . . . , ai}) ∩ F = ∅ dL G(s, t,{a1, . . . , ai}) is a path in the graph G \ F that contains at most L edges, and then P L G(s, t,{a1, . . . , ai}) is at least the length of the shortest s-to-t path in G\ F hence its length dL that contains at most L edges which is dL G(s, t, F). It follows that the output of the query is dL G(s, t, F). On the other hand, since P L G(s, t,{a1, . . . , ai}) ≥ dL G(s, t, F), so we get dL G(s, t,{a1, . . . , ai}) = dL G(s, t, F). We analyze the runtime of the query. The runtime of the query is O(f 2 log L) as we advance along a root to leaf path in F T L,f(s, t) (whose length is at most f) and in each node F T L,f(s, t, a1, . . . , ai) of the tree F T L,f(s, t) we make O(f) queries ai+1 ∈ F to BST L(s, t, a1, . . . , ai) which take O(log L) as we search in a binary search tree with L elements. So query time is the multiplication of the following terms: G(s, t,{a1, . . . , ai}) f -- length of root-to-leaf path in F T L,f(s, t) f -- number of elements ai+1 ∈ F to check in the node F T L,f(s, t, a1, . . . , ai) whether or not ai+1 ∈ P L O(log L) -- time to check for a single element ai+1 ∈ F whether or not ai+1 ∈ G(s, t,{a1, . . . , ai}) by searching ai+1 in BST L(s, t, a1, . . . , ai) which is a binary search P L tree containing L elements. (cid:74) 6.2 Deterministic f-Sensitivity Distance Oracles with eO(mn1++/f + n2++2/f) Preprocessing Time In this section we describe how to plug-in the trees F T L,f(s, t) from Section 4.1 in the f-sensitivity distance oracles of Weimann and Yuster [39]. Let us first recall how the f-sensitivity distance oracle of Weimann and Yuster [39] works. The following Lemma is proven in [39]. (cid:73) Lemma 31 (Theorem 1.1 in [39]). Given a directed graph G with real positive edge weights, an integer parameter 1 ≤ f ≤  log n/ log log n and a real parameter 0 <  < 1, there exists a randomized f-sensitivity distance oracle whose construction is randomized and takes eO(mn1+) time. Given a query (s, t, F) where F ⊂ V ∪ E with F ≤ f, the data-structure answers the query by computing w.h.p. dG(s, t, F) in eO(n2−2/f) time. Proof. Use α = 1−  in the construction of Weimann and Yuster [39]. In order for this result to be self-contained, we briefly explain the preprocessing and query procedures of Weimann and Yuster [39]. Preprocessing: N. Alon, S. Chechik and S. Cohen 29 1. Randomly generate graphs G1, . . . , Gr (with r = eO(n)) where every graph is independ- ently obtained by removing each edge with probability 1/n/f. Compute APSP on each of the graphs {G1, . . . , Gr}. It is proven in [39] that with high probability for every set F ⊆ E ∪ V with F ≤ f and for every s − t shortest path PG(s, t, F) that contains at most n/f edges in the graph G \ F, there exists at least one graph Gi ∈ {G1, . . . , Gr} that excludes F and contains PG(s, t, F). 2. Sample a random set B of pivots, where every vertex is taken with probability 6f ln n n/f . Query: Given a query (s, t, F) build the dense graph H (denoted by GS in [39]) whose vertices are B ∪ {s, t} as follows. First, find all the graphs that exclude F, GF = {Gi 1 ≤ i ≤ r, F ∩ Gi = ∅}. Then, for every u, v ∈ B ∪ {s, t} add the edge (u, v) to H and set is weight to be the minimum length of the shortest path from u to v in all the graphs GF . If there is no path from u to v in any of the graphs GF then set ωH(u, v) = ∞. Finally, run (cid:74) Dijkstra from s in the graph H and output dG(s, t, F) = dH(s, t). We derandomize Lemma 31 as follows. (cid:73) Lemma 32. Given a directed graph G with real positive edge weights, an integer parameter 1 ≤ f ≤  log n/ log log n and 0 <  < 1, there exists a deterministic f-sensitivity distance a query (s, t, F) where F ⊂ V ∪ E with F ≤ f, the data-structure answers deterministically oracle whose construction is deterministic and takes eO(mn1++/f + n2++2/f) time. Given the query by computing dG(s, t, F) in eO(n2−2/f) time. To prove Lemma 32 we describe how to use the fault-tolerant trees {F T L,f(s, t)}s,t∈V to construct the deterministic f-sensitivity distance oracle. Preprocessing: 1. Compute the trees F T L,f(u, v) . Deterministically construct the fault-tolerant trees F T L,f(u, v) for every u, v ∈ V as in Lemma 18. 2. Compute the set of vertices B ⊆ V . Let P L,f be the set of all paths in all the nodes of all the trees {F T L,f(u, v)}u,v∈V that contain at least n/f /2 edges. Use the greedy algorithm as in Lemma 2, to find deterministically a set of pivots B, such that for every P ∈ P L,f it holds that B ∩ V (P) 6= ∅. Query: Given a query (s, t, F) build the complete graph H (also referred to as the dense graph) whose vertices are B ∪ {s, t} as follows. For every u, v ∈ B ∪ {s, t} query the tree F T L,f(u, v) with (u, v, F) according to the query procedure described in Section 4.1 and set the weight of the edge (u, v) in H to the distance computed dL G(u, v, F) (i.e., set ωH(u, v) = dL G(u, v, F)). Finally, run Dijkstra from s in the graph H and output dH(s, t) as an estimate of the distance dG(s, t, F). Proof of Lemma 32. We prove the correctness of the DSO and then analyse its preprocessing and query time. Proof of correctness. We prove that dG(s, t, F) = dH(s, t). Since dH(s, t) is the length of some path from s to t in G \ F then dH(s, t) ≥ dG(s, t, F). Next we prove that dG(s, t, F) ≥ dH(s, t). Let PG(s, t, F) be the shortest path from s to t in G \ F. We prove that the set of vertices B hits every subpath of PG(s, t, F) that contains exactly n/f /2 edges. To see that, let u, v be two vertices such that u appears before v along PG(s, t, F) and PG(s, t, F)[u..v] contains n/f /2 edges. It follows that the shortest path from u to v in G \ F contains less than L = n/f edges. According to the assumption of unique shortest paths (as in Section 6.4.2) it follows that querying the tree F T L,f(u, v) with (u, v, F) finds a path P L G(u, v, F), 30 Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles and since the shortest path from u to v in G \ F contains less than L = n/f edges then G(u, v, F) = PG(u, v, F) = PG(s, t, F)[u..v] is the shortest path from u to v in G \ F, and P L it contains exactly n/f /2 edges. Therefore, P L G(u, v, F) is a path in a node of the tree G(u, v, F) ∈ P L,f. Hence, when computing the hitting set B that F T L,f(u, v) and thus P L hits all the paths of P L,f the algorithm obtains a set B, and in particular it holds that B ∩ P L G(u, v, F) 6= ∅ and thus B hits the path PG(s, t, F)[u..v] = PG(u, v, F). This prove that B hits every subpath of PG(s, t, F) that contains exactly n/f /2 edges. Let s = v1, v2, . . . , vk = t be all the vertices of H = B ∪ {s, t} that appear along PG(s, t, F) sorted according to the order of their appearance along the path PG(s, t, F). As B hits every subpath of PG(s, t, F) that contains exactly n/f /2 edges, it follows that for every 0 ≤ i < k the subpath of PG(s, t, F) from vi to vi+1 contains at most n/f edges. Therefore, the shortest path from vi to vi+1 in G \ F contains at most L = n/f edges and hence dL G(vi, vi+1, F) = dG(vi, vi+1, F). By Lemma 17 it holds that querying the tree F T L,f(vi, vi+1) according to the query procedure described in Section 4.1 computes the G(vi, vi+1, F) = dG(vi, vi+1, F). Hence ωH(< v1, . . . , vk >) = ωH(v1, v2) + . . . + distance dL ωH(vk−1, vk) = dL G(vk−1, vk, F) = dG(v1, v2, F)+ . . .+ dG(vk−1, vk, F) = dG(s, t, F) where the last equality holds as s = v1, v2, . . . , vk = t are the vertices of H that appear along PG(s, t, F) sorted according to the order of their appearance along the path PG(s, t, F). G(v1, v2, F)+ . . .+ dL (cid:74) It follows that the path < v1, . . . , vk > is an s-to-t path in H whose weight in H is dG(s, t, F) and hence the shortest s-to-t path in H has length at most ωH(< v1, . . . , vk > ) = dG(s, t, F). Therefore dH(s, t) ≤ ωH(< v1, . . . , vk >) = dG(s, t, F) and since we already proved that dH(s, t) ≥ dG(s, t, F) it follows that dH(s, t) = dG(s, t, F). Constructing the trees F T L,f(u, v) for every u, v ∈ V as in Lemma 18 takes eO(mn1++/f + Analysing the preprocessing time. Next we analyse preprocessing time of the DSO. n2++2/f) time. We analyse the time it takes to compute the set of vertices B ⊆ V . Let P L,f be the set of all paths in all the nodes of all the trees {F T L,f(u, v)}u,v∈V that contain at least n/f /2 edges. Observe that P L,f contains at most O(n2+) paths, as the number of nodes in each of the n2 trees F T L,f(u, v) is O(n) and every such node contains a single path Analysing the query time. Next we analyse the query time of the DSO. During query, the algorithm constructs the graph H. During the construction of H the algorithm of G. Thus, using the greedy algorithm as in Lemma 2 finds deterministically in eO(n2++/f) time a set of pivots B, such that B = eO(n1−/f) and B hits all the paths in P L,f. Thus, the total preprocessing time of the DSO is eO(mn1++/f + n2++2/f) time. runs eO(n2−2/f) queries using the trees {F T L,f(u, v)}u,v∈V , each query is answered in O(f 2 log n) = eO(1) time since we assumed f ≤ log n/ log log n. Thus, constructing the graph H takes eO(n2−2/f) time, and also running Dijkstra from s in the graph H takes eO(n2−2/f) time. Therefore, the total query time is eO(n2−2/f) time. 6.3 Deterministic f-Sensitivity Distance Oracles with eO(mn1+) oracle described in Lemma 32 from eO(mn1++/f + n2++2/f) to match the preprocessing time of [39] which is eO(mn1+), while keeping the same query time of eO(n2−2/f). trees {F T L,f(u, v)}u,v∈V from eO(mn1++/f + n2++2/f) to eO(mn1+). In Section 6.3.4 we We improve the preprocessing time in two ways: improving the construction time of the trees F T L,f(u, v) and reducing the runtime of the greedy selection algorithm by considering a smaller set of paths P L,f. In Section 6.3.1 we reduce the time it takes to construct the In this section we reduce the preprocessing time of constructing the f-sensitivity distance Preprocessing Time N. Alon, S. Chechik and S. Cohen 31 show that the runtime of the greedy selection algorithm of the pivots B can be reduced from eO(n2++/f) to eO(n2+) which is negligible compared to eO(mn1+). This will give us the desired eO(mn1+) preprocessing time. 6.3.1 Building the Trees F T L,f(u, v) in eO(mn1+) Time In this section we describe how to construct the trees F T L,f(u, v) in eO(mn1+) time. We first define the node F T L0,f(u, v, a1, . . . , ai) of the tree F T L0,f(u, v) as follows. (cid:73) Definition 33. Let 1 ≤ L0 ≤ L, 0 ≤ i ≤ f and u, v ∈ V . Assume a1 ∈ P L0(u, v), a2 ∈ P L0(u, v,{a1}), . . . , ai ∈ P L0(u, v,{a1, . . . , ai−1}). We define the node F T L0,f(u, v, a1, . . . , ai) of depth i in the tree F T L0,f(u, v) as the node we reach if we query the tree F T L0,f(u, v) with F = {a1, . . . , ai} according to the query procedure described in Section 4.1. If i = f then F T L0,f(u, v, a1, . . . , af) is a leaf node of F T L0,f(u, v) of depth f. We slightly abuse notation and use F T L0,f(u, v, a1, . . . , ai) to both denote the node F T L0,f(u, v, a1, . . . , ai) and the subtree of F T L0,f(u, v) rooted in F T L0,f(u, v, a1, . . . , ai). gramming Equation 1 in all the nodes of all the trees {F T L0,f(u, v)}u,v∈V,1≤L0≤L. In Section Recall that in Section 4.1 we described how to build the trees F T L,f(u, v) in eO(mn1++/f+ n2++2/f) time. More generally, we built the trees {F T L0,f(u, v)}1≤L0≤L,u,v∈V in eO(mnLf+1+ n2Lf+2) time, where the construction time consists of the following two terms eO(mnLf+1) and eO(n2Lf+2). The first term eO(mnLf+1) is the time it takes to solve the dynamic pro- 6.3.3 we reduce the runtime of this part to eO(mnLf) by applying Dijkstra on auxiliary The second term eO(n2Lf+2) is the time it takes to reconstruct all the paths P L0(s, t,{a1, . . . , ai}) takes eO(n2Lf+2) time since the number of nodes in all the trees {F T L0,f(u, v)}u,v∈V,1≤L0≤L is eO(n2Lf+1), and it takes O(L) time to reconstruct each path (which contains at most L edges). In Section 6.3.2 we reduce this term to eO(n2Lf) = eO(n2+) by not reconstructing graphs HF,t we define later rather than computing the dynamic-programming in the last layer of the trees. that are explicitly stored in all the nodes of all the trees {F T L0,f(u, v)}u,v∈V,1≤L0≤L. It the paths in the leaves of the trees of depth f. 6.3.2 The improved algorithm for constructing the trees F T L,f(u, v) We describe the algorithm with the improved construction time. First, the algorithm constructs the trees {F T L0,f(u, v)}1≤L0≤L,u,v∈V up to level f − 1, i.e., constructing the trees {F T L0,f−1(u, v)}1≤L0≤L,u,v∈V , without constructing the nodes in level f. Note that using the analysis above this takes eO(mnL(f−1)+1) = eO(mnLf) = eO(mn1+) time. We are left with explaining how to accelerate the construction of the last layer (the layer of depth f) of the trees {F T L,f(u, v)}u,v∈V . The algorithm reconstructs the paths in level f − 1 only for the trees {F T L,f(u, v)}u,v∈V . That is, for every leaf node F T L,f−1(u, v, a1, . . . , af−1) G(u, v,{a1, . . . , af−1}) in O(L) time by of F T L,f−1(u, v) we can reconstruct the path P L G(u, v,{a1, . . . , af−1}) take eO(n2Lf) = eO(n2+) time. Then following the parent pointers parentL(u, v, F) as computed in Equation 2. Reconstruct- for every vertex or edge af ∈ P L G(u, v,{a1, . . . , af−1}) we need to construct the leaf node F T L,f(u, v, a1, . . . , af−1, af). We describe the construction of the leaves F T L,f(u, v, a1, . . . , af−1, af) in the following paragraphs. ing these eO(n2Lf−1) paths P L Let Fu,v = {{a1, . . . , af} the node F T L,f(u, v, a1, . . . , af) is a leaf node of F T L,f(u, v)}. Equivalently, Fu,v = {{a1, . . . , af} a1 ∈ P L(u, v), a2 ∈ P L(u, v,{a1}), . . . , af ∈ P L(u, v,{a1, . . . , af−1})}. 32 Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles In the remaining of this section we describe how to compute the distances dL the parent pointer parentL(u, v, F) for every u, v ∈ V, F ∈ Fu,v in total eO(mnLf) time. We first explain why it is not possible to use Equation 1 to compute the distance G(u, v,{a1, . . . , af}). Let F = {a1, . . . , af} ∈ Fu,v. According to Equation 1, dL G(u, v, F) = dL minz{ω(u, z) + dL−1(z, v, F) (u, z) ∈ E AN D u, z, (u, z) 6∈ F}, where the distance dL−1(z, v, F) need to be obtained by querying the tree F T L−1,f(z, v) using the query F. But querying the tree F T L−1,f(z, v) with the set F might reach a leaf node F T L−1,f(z, v, a1, . . . , af), and since we did not construct yet the last layer (of level f) of F T L−1,f(z, v) then we do not have the distance dL−1(z, v, F) computed yet. This breaks the dynamic programming of Equation 1. To overcome this difficulty, we run Dijkstra in auxiliary graphs HF,t. G(u, v, F) and F,t ∪ N(V 0 F,t). 6.3.3 The auxiliary graphs HF,t Let t ∈ V be a fixed vertex, we define Ft = ∪s∈V Fs,t. For every F ∈ Ft we build the F,t ⊆ V be the set of all vertices s ∈ V such that graph HF,t = (VF,t, EF,t) as follows. Let V 0 F,t for all the vertices t ∈ V in eO(n2Lf) time F ∈ Fs,t. using the following procedure. Initialize an empty hash table h. For every s ∈ V, F ∈ Fs,t: Check if h contains (F, t). If (F, t) 6∈ h then set h[F, t] to be an empty list of vertices (which will eventually represent V 0 F,t). Append s to the end of the list h[F, t]. Note that we can easily compute the sets V 0 After scanning all the sets F ∈ Fs,t for every s, t ∈ V , we get that the vertices V 0 in h[F, t]. The runtime of this procedure is eO(n2Lf) for all the vertices t ∈ V as the number F,t are listed of sets F inS which is eO(n2Lf). s,t∈V Fs,t is at most the number of leaves in all the trees {F T L,f(s, t)}s,t∈V , F,t and their neighbours, i.e., VF,t = V 0 Let VF,t be the set of vertices V 0 Let s ∈ VF,t and let u be a neighbour of s in G, i.e., (s, u) ∈ E, such that s, u has not failed (i.e., s, u, (s, u) 6∈ F). If u ∈ VF,t then we add the edge (s, u) to HF,t with its weight ω(s, u). Otherwise, u 6∈ VF,t, this means that if we query the tree F T L,f(u, t) with the set F then the query ends in an internal node of F T L,f(u, t) and not in a leaf of depth f. Let F T L,f(u, t, a1, . . . , ai) be the internal node we reach at the end of the query such that {a1, . . . , ai} (cid:40) F. Then the path P L G(u, t,{a1, . . . , ai}) does not contain F (as otherwise we would have not finished the query of F in the tree F T L,f(u, t) at this node), and hence we G(u, t,{a1, . . . , ai}) in the node F T L,f(u, t, a1, . . . , ai). We already computed dL add an edge (u, t) to HF,t and assign to it the weight dL G(u, t, F), and we refer to these edges as shortcuts. and that computing all the Dijkstra's in all the graphs HF,t takes eO(mn1+) time. gives us the distances dHF,t(s, t) for every s ∈ VF,t. We claim that dHF,t(s, t) ≤ dL (cid:73) Lemma 34. Let s ∈ VF,t, then dG(s, t, F) ≤ dHF,t(s, t) ≤ dL Proof. We first prove that dG(s, t, F) ≤ dHF,t(s, t). If dHF,t(s, t) < ∞ then the shortest path from s to t in HF,t is composed of two types of edges: An edge (u, v) such that u, v, (u, v) 6∈ F whose weight equals to ω(u, v) (its weight in the graph G). In this case, the edge (u, v) also exists in the graph G \ F with the same weight. A "shortcut" edge (u, t) whose weight is dL to t in the graph G \ F whose weight is dL Finally, we compute Dijkstra from t in the graph HF,t with reverse edge directions. This G(s, t, F) G(u, t, F). In this case, there is a path from u G(u, t, F). G(u, t, F) = dL G(s, t, F). N. Alon, S. Chechik and S. Cohen 33 G(s, t, F). Let P L In both cases we get that for every edge (u, v) in the graph HF,t there exists a u-to-v path in the graph G \ F whose weight in G \ F equals to the weight of the edge (u, v) in HF,t. Hence, dG(s, t, F) ≤ dHF,t(s, t). We now prove that dHF,t(s, t) ≤ dL G(s, t, F) =< v0, . . . , vk > be a shortest path from s to t in G\F on at most L edges (i.e., k ≤ L). We prove that there exists an s-to-t G(s, t, F)) and since dHF,t(s, t) ≤ ωHF,t(P) path P in HF,t whose weight ωHF,t(P) ≤ ωG(P L it follows that dHF,t(s, t) ≤ ωHF,t(P) ≤ ωG(P L G(s, t, F). In order to construct G(s, t, F)) = dL G(s, t, F) (for every 0 ≤ i < k) the path P in HF,t, note that for every edge (vi, vi+1) of P L it holds that either (vi, vi+1) ∈ G \ F exists in HF,t with the same weight as its weight in G(vi, t, F). Let 0 ≤ ' ≤ k be the G, or there exists an edge (vi, t) in HF,t whose weight is dL maximum index such that for every 0 ≤ i < ' the edge (vi, vi+1) ∈ HF,t. We define the path P :=< v0, . . . , v' > ◦(v', t), then P is a path in HF,t and its weight is ωHF,t(P) = ωHF,t(< v0, . . . , v' >)+ ωHF,t(v', t) = ωG(< v0, . . . , v' >)+ dL G(v', t, F) where the last inequality holds as every 0 ≤ i < ' the edge (vi, vi+1) exists in HF,t with the same weight as its weight in G and the edge (v', t) exists in HF,t and its weight in HF,t is dL G(vi, t, F). It follows that G(s, t) where the ωHF,t(P) = ωG(< v0, . . . , v' >) + dL last equality holds by the triangle inequality and the fact that < v0, . . . , v' >⊆ P L G(s, t, F). Hence, the shortest path from s to t in HF,t has weight at most dL G(s, t, F), and thus dHF,t(s, t) ≤ dL (cid:74) (cid:73) Lemma 35. Computing Dijkstra's algorithm in all the graphs HF,t takes eO(mnLf) = eO(mn1+) time. Proof. The runtime of Dijkstra in the graph HF,t is eO(Σ{s∈V 0 It follows that the runtime of running all Dijkstra algorithms is eO(Σt∈V ΣF∈FtΣ{s∈V 0 Note that a vertex s ∈ V 0 F,t iff F = {a1, . . . , af} and F T L,f(s, t, a1, . . . , af) is a leaf node of is the sum of deg(s) for every leaf node of F T L,f(s, t). As F T L,f(s, t) contains eO(Lf) leaves, F T L,f(s, t) at depth f. Hence, for a fixed vertex t ∈ V it holds that ΣF∈FtΣ{s∈V 0 F,t}deg(s) F,t}deg(s) = eO(Lf · Σs∈V deg(s)) = eO(mLf). Therefore, F,t}deg(s)) = eO(nmLf) = eO(mn1+), where the last equality holds as eO(Σt∈V ΣF∈FtΣ{s∈V 0 is a bound on the number of edges and vertices in HF,t. G(v', t, F) ≤ dL F,t}deg(s)), as O(Σ{s∈V 0 F,t}deg(s)) G(v', t, F) = d' G(s, v') + dL F,t}deg(s)). (cid:74) G(s, t, F). then ΣF∈FtΣ{s∈V 0 L = n/f. 6.3.4 Reducing the Runtime of the Greedy Selection Algorithm We have O(n2) trees {F T L,f(s, t)}s,t∈V , every tree contains O(n) nodes, and every node G(s, t,{a1, . . . , ai}) with at most L = n/f edges. In F T L,f(s, t, a1, . . . , ai) contains a path P L the greedy algorithm we want to hit all of these paths that contain at least n/f /2 edges and at most n/f edges. In total there might be O(n2+) such paths {PG(s, t, a1, . . . , ai)}, each 2 finding a set of vertices R of size eO(n1−/f) which hits all these paths takes eO(n2++/f) path contains at least n/f /2 edges and at most n/f edges, and thus according to Lemma time. Let R<f be the hitting set of vertices obtained by the greedy algorithm which hits all the paths P<f = {PG(s, t,{a1, . . . , ai})1 ≤ i < f} that contains at least n/f /4 edges and at most n/f edges, these are paths that appear in the internal nodes of the trees F T L,f(s, t) (which are not in the last layer of the trees). Since there are only O(n2+−/f) such paths P<f, each path contains at least n/f /8 edges and at most n/f edges, and thus according to Lemma 2 finding a set of vertices R<f of size eO(n1−/f) which hits all of these paths takes eO(n2+) time. 34 Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles following conditions hold: We define Premaining to be the subset of paths {PG(s, t,{a1, . . . , af})} for which the PG(s, t,{a1, . . . , af}) is a path stored in a some leaf node (F T L,f(s, t, a1, . . . , af)) of depth f in at least one of the trees F T L,f(s, t). PG(s, t,{a1, . . . , af}) contains between n/f /2 to n/f edges. PG(s, t,{a1, . . . , af}) does not contain any of the vertices R<f. Following we describe how to compute in eO(mn1+) time a set Pf of eO(n2+−/f) paths, each path contains at least n/f /8 edges, such that if we hit all the paths Pf then we also hit every path of Premaining. In Lemma 35 we run Dijkstra in the graph HF,t and computed shortest paths to t, let TF,t be the shortest paths tree rooted in t in the graph HF,t. Let XF,t be all the vertices x ∈ VF,t in the tree TF,t at depth n/f /8 (i.e., the number of edges from the root of TF,t to x is n/f /8) such that there exists at least one vertex y ∈ VF,t which is a descendent of x in TF,t and y is at depth n/f /4 in TF,t. Let PF,t be the set of paths in the tree TF,t from every vertex x ∈ XF,t to the root t where a shortcut edge (u, t) is replaced with the subpath F,t PF,t. P L such that if we hit all the paths Pf then we also hit all the paths Premaining. We first need the following lemma. G(u, t, F), so that every path in PF,t is a valid path in G \ F. Finally, let Pf =S We claim that Pf is a set of eO(n2+−/f) paths, each path contains at least n/f /8 edges, (cid:73) Lemma 36. The total number of vertices in all the graphs HF,t is ΣF,tVF,t = eO(n2+). Proof. Since every vertex of VF,t is either a vertex of V 0 then it holds that ΣF,tVF,t ≤ ΣF,tΣ{x∈V 0 F,t}deg(x). F,t or a neighbour of such a vertex, F,t Note that a vertex x ∈ V 0 F,t iff querying the tree F T L,f(x, t) with F results in reaching a leaf at depth f of the tree F T L,f(x, t). Hence, for a fixed vertex x ∈ V , the sum (ΣF,t x∈V 0 deg(x)) is bounded by the number of nodes in the last layer of all the trees {F T L,f(x, t)}t∈V multiplied by deg(x). Since the last layer of every tree F T L,f(x, t) contains n nodes, and for every vertex x ∈ V there are n trees {F T L,f(x, t)}t∈V , then we get a bound (cid:74) eO(Σx∈V n1+deg(x)) = eO(mn1+) on the number of vertices in all the graphs HF,t. (cid:73) Lemma 37. Pf is a set of eO(n2+−/f) paths, each path contains at least n/f /8 edges, compute Pf is eO(mn1+). such that if we hit all the paths Pf then we also hit all the paths Premaining. The runtime to Proof. Let PG(s, t,{a1, . . . , af}) = PG(s, t, F) ∈ Premaining be the path stored in the node F T L,f(s, t, a1, . . . , af) such that {a1, . . . , af} = F. Denote by PG(s, t, F) =< v1, . . . , vr >. Since PG(s, t, F) ∈ Premaining then PG(s, t, F) contains between n/f /2 to n/f edges and it is not hit by R<f. Let 1 ≤ i < r − n/f /4 − 1, then vi is a vertex on the path PG(s, t, F) which is not among the last n/f /4 vertices of the path. Then PG(vi, t, F) is a subpath of PG(s, t, F) (since shortest paths are unique). Furthermore, since R<f (which hits all the paths which contain at least n/f /4 vertices in all the non-leaf nodes of all the trees) does not hit PG(vi, t, F) then it follows that PG(vi, t, F) is stored in a leaf node F T L,f(vi, t, F) of the tree F T L,f(vi, t). A similar argument shows that PG(vi+1, t, F) is stored in a leaf node F T L,f(vi+1, t, F) of the tree F T L,f(vi+1, t). It follows that vi, vi+1 ∈ VF,t and (vi, vi+1) ∈ HF,t. Therefore, PH(s, t) contains at least all the edges (vi, vi+1) for every 1 ≤ i < r − n/f /4 − 1, and since r is the number of vertices of PG(s, t, F) which contains at least n/f /2 vertices then PH(s, t) contains at least n/f /4 vertices. Since PH(s, t) is a path in HF,t containing at least n/f /4 vertices then it holds for the n/f /8-th vertex x from the end of PH(s, t) that x ∈ XF,t. Therefore, the subpath PH(x, t) N. Alon, S. Chechik and S. Cohen 35 F,t XF,t = eO(n2+/(n/f /8) = eO(n2+−/f). of PH(s, t) from x to t which contains n/f /8 edges is contained in Pf. Hence, if we hit Pf we also hit PH(x, t) and therefore we also hit PG(s, t, F). This proves that hitting all the paths of Pf also hits all the paths of Premaining. Next, we prove that Pf contains eO(n2+−/f) paths. We have already proved in 35 that the number of vertices in all the graphs HF,t is eO(n2+). Recall that Pf =S F,t{PH(x, t) x ∈ XF,t}. Furthermore, for every vertex x ∈ XF,t there exists at least n/f /8 unique vertices in the subtree of x. To see this, recall that by definition if the vertex x ∈ XF,t there exists at least one vertex y ∈ VF,t which is a descendent of x in TF,t and y is at depth n/f /4 in TF,t. Thus, the set of vertices of TF,t from x to y contains at least n/f /8 vertices which belong to the subpath of TF,t rooted at x. Therefore, Pf =P Finally, the run time to compute Pf is eO(mn1+) as it is dominated by the Dijkstra algorithms in the graphs HF,t whose runtime is eO(mn1+) according to Lemma 35, and every After computing Pf in eO(n2+) time, we run the greedy selection algorithm from Lemma 2 on the set of paths Pf in eO(n2+) time (note that the bound on the runtime follows as Pf = eO(n2+−/f)) to obtain a set Rf of eO(n1−/f) vertices that hit all the paths Pf and thus they also hit all the paths Premaining. Let R = R<f ∪ Rf. So in total this takes eO(n2+) time to find the set R of eO(n1−/f) vertices that hit all the paths {PG(s, t,{a1, . . . , ai})} in (cid:73) Corollary 38. One can find deterministically in eO(n2+) time a set R of eO(n1−/f) vertices all the nodes of all the trees F T L,f(s, t) which contain at least n/f /2 edges and at most n/f edges. path in Pf contains at least n/f /8 edges by definition. (cid:74) that hit all the paths {PG(s, t,{a1, . . . , ai})} in all the nodes of all the trees F T L,f(s, t) which contain at least n/f /2 edges and at most n/f edges. 6.4 Assumptions In the algorithms we described for the case of directed graphs with real edge weights for constructing and querying the DSO we made two assumptions: We assumed all edge weights are non-negative, so that we can run Dijkstra algorithm. G(s, t, F) are unique. We assumed all the shortest paths: PG(s, t), PG(s, t, F), P L In this section we justify these two assumptions. G(s, t), P L 6.4.1 Handling Negative Weights In the description above we assumed that edge weights are non-negative. In this section we describe how to reduce the problem of general edge weights to non-negative edge weights. We handle it similarly to Weimann and Yuster [39] by the well known method of feasible price functions in order to transform the negative edge weights to be nonnegative in the graph G as the first step of the preprocessing algorithm. For a directed graph G = (V, E) with (possibly negative) edge weights ω(·), a price function is a function φ from the vertices of G to the reals. For an edge (u, v), its reduced weight with respect to φ is ωφ(u, v) = ω(u, v) + φ(u) − φ(v). A price function φ is feasible if ωφ(u, v) ≥ 0 for all edges (u, v) ∈ E. The reason feasible price functions are used in the computation of shortest paths is that for any two vertices s, t ∈ V , for any s-to-t path P, ωφ(P) = ω(P) + φ(s)− φ(t). This shows that an s-to-t path is shortest with respect to ωφ(·) iff it is shortest with respect to 36 Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles ω(·). Moreover, the s-to-t distance with respect to the original weights ω(·) can be recovered by adding φ(t) − φ(s) to the s-to-t distance with respect to ωφ(·). The most natural feasible price function comes from single-source distances. Let s be a new vertex added to G with an edge from s to every other vertex of G having weight 0. Let d(v) denote the distance from s to vertex v ∈ G. Then for every edge (u, v) ∈ E, we have that d(v) ≤ d(u) + ω(u, v), so ωd(u, v) ≥ 0 and thus d(·) is feasible. This means that knowing d(·), we can now use Dijkstra's SSSP algorithm on G (with reduced weights) from any source we choose and obtain the SSSP with respect to the original G. Therefore, we first compute φ = d(·) in the original graph, store φ and change the weights of every edge (u, v) to ωd(u, v) which are non-negative. Then we continue with the preprocessing and query algorithms as described in Section 6. Finally, at the end of the query when we computed dG(s, t, F) with respect to the weights ωφ(·), we add to it φ(t) − φ(s) to obtain the weight of this shortest path PG(s, t, F) with respect to the original weights ω(·). 6.4.2 Unique Shortest Paths Assumption In this section we justify the unique shortest paths assumption. For randomized algorithms, unique shortest paths can be achieved easily by using a folklore method of adding small perturbations to the edge weights, such that all the shortest paths in the resulting graph are unique w.h.p. and a shortest path in the resulting graph is also a shortest path in the original graph. H(s, s) =< s > and d0 H(s, t) = ∅ and d0 We describe a way to define unique shortest paths in a graph H which fits the algorithms we presented. First, we assume that the weights are non-negative according to the reduction described in Section 6.4.1. Next, let 0 < 0 < 1 be a small enough number such that n· 0 < min{ω(u, v) (u, v) ∈ E}. Add 0 to the weight of all the edges of the graph. Then we get that all the edges have positive weights, and every shortest path in the graph after adding 0 is also a shortest path in the original graph. Now, we define the unique shortest paths P L H(s, t) in the graph H by recursion on L ≥ 0. For L = 0 we define P 0 H(s, s) = 0, and for every pair of vertices s, t ∈ V, s 6= t we define P 0 H(s, t) = ∞. For the inductive step we need to define P L H(s, t). Let u1, . . . , u' be all the neighbours of s which minimize ω(s, ui) + dL−1 H (ui, t) among all the vertices V . Let ui be the vertex whose index (label) is minimal among u1, . . . , u'. We define P L H (ui, t) and H(s, t) = ω(s, ui) + dL−1 H (ui, t) are uniquely defined by the induction dL hypothesis. For every pair of vertices s, t ∈ V such that the above inductive step did not H(s, t) = ∞. We define PH(s, t) as follows. Let define P L X = arg min0≤L≤n{dL H (s, t). Finally, for every s, t ∈ V we define PG(s, t) = PG(s, t), dG(s, t) = ω(PG(s, t)), and for every 0 ≤ L ≤ n we define P L G(s, t)). For a subset F ⊆ E∪V we define P L G\F (s, t), PG(s, t, F) = PG\F (s, t) and G(s, t, F) = P L dG(s, t, F) = dG\F (s, t). It is not difficult to prove the following lemma. (cid:73) Lemma 39. For every s, t ∈ V, F ⊆ E ∪ V, 0 ≤ L ≤ n the path P L G(s, t, F) is a shortest path among all s to t paths in G \ F that contain L edges, and the path PG(s, t, F) is a shortest path from s to t in G\ F. Both PG(s, t, F) and P L G(s, t, F) are uniquely defined, and their lengths are dG(s, t, F) and dL H(s, t)}. Then we define PH(s, t) = P X H (ui, t), such that P L−1 H(s, t) = (s, ui) ◦ P L−1 G(s, t) = P L G\F (s, t), dL G(s, t), dL G(s, t, F) = dL H(s, t) we define P L H(s, t) = ∅ and dL G(s, t) = ω(P L G(s, t, F) respectively. The following lemma is also not difficult to prove. (cid:73) Lemma 40. When running Dijkstra or the dynamic programming algorithm as described in Section 4.2 in the graph G\ F, if during the execution of the algorithm instead of considering N. Alon, S. Chechik and S. Cohen 37 vertices in arbitrary order we always consider vertices in ascending order of their labels (indices) then we compute the unique shortest paths P L G(s, t, F). 7 Open Questions Here are some open questions that immediately follow our work. Weimann and Yuster [39] presented a randomized algebraic algorithm for constructing a DSO whose runtime is subcubic and the query has subquadratic runtime supporting f = O(lg n/ lg lg n) edges or vertices failures. Grandoni and Vassilevska Williams [21] presented a randomized algebraic algorithm for constructing a DSO whose runtime is subcubic and the query has sublinear runtime supporting a single (f = 1) edge failure. The preprocessing algorithms of both these DSOs is randomized and algebraic, and it remains an open question if there exists a DSO with subcubic deterministic preprocessing algorithm and subquadratic or sublinear deterministic query algorithm, matching their randomized equivalents? Both the DSOs of Weimann and Yuster [39] and Grandoni and Vassilevska Williams [21] use the following randomized procedure (e.g., Lemma 2 in [21]): Let 0 <  < 1, 1 ≤ f ≤  lg n/ lg lg n, L = n/f, and let C > 0 be a large enough constant. Sample s = Lf · C log n graphs {G1, . . . , Gs}, where each Gi is obtained from G by independently removing each edge with probability (1/L). For C large enough, it holds whp that for every (s, t, e) for which there exists a replacement path PG(s, t, F) on at most L nodes, there is at least one Gi that does not contain F but contains at least one replacement path for (s, t, F) on at most L edges. The time to compute the graphs G1, . . . , Gs using randomization is eO(m · s) = eO(n2+). G1, . . . , Gs in eO(n2 · s) time such that the above property holds (that for every (s, t, e) We ask what is the minimum s such that we can deterministically compute such graphs for which there exists a replacement path PG(s, t, F) on at most L nodes, there is at least one Gi that does not contain F but contains at least one replacement path for (s, t, F) on at most L edges). The randomized algorithm has a simple solution (as mentioned above, sample s = Lf · C log n graphs {G1, . . . , Gs}, where each Gi is obtained from G by independently removing each edge with probability (1/L)). As there are O(n2f+2) different possible queries (s, t, F), and there are at most O(n2f+3) intervals PG(s, t, F) (which we want to maintain) containing exactly n/f vertices, it is not difficult to prove (as done in [39]) that for every possible query (s, t, F) there exists whp at least one graph Gi which does not contain F but contains PG(s, t, F). It is not clear how to efficiently derandomize a degenerated version of the above con- struction. We can even allow some relaxations to the above requirements. Assume there is a list L = {(s1, t1, F1), . . . , (s', t', F')} of at most ' = O(n2+) queries which are the only queries that interest us, and assume there is a smaller set of intervals P = {PG(s1, t1, F1), . . . , PG(s', t', F')} each contains exactly n/f edges that we want to maintain. Then, what is the minimum s (asymptotically) such that one can construct deterministically graphs {G1, . . . , Gs} in eO(n2 · s) time, such that for every 1 ≤ i ≤ ' there exists at least one graph Gi which does not contain Fi but contains PG(si, ti, Fi)? It is an open question how to achieve this goal, even for f = 1 and even if we allow s to be greater than Ω(n) (to the extend that running APSP in the graphs G1, . . . , Gs still takes subcubic time)? 38 Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles An indirect open question is to derandomize more randomized algorithms and data- structures in closely related fields, perhaps utilizing some of our techniques and framework. References 1 Udit Agarwal, Vijaya Ramachandran, Valerie King, and Matteo Pontecorvi. A deterministic distributed algorithm for exact weighted all-pairs shortest paths in õ(n 3/2 ) rounds. In Proceedings of the 2018 ACM Symposium on Principles of Distributed Computing, PODC 2018, Egham, United Kingdom, July 23-27, 2018, pages 199 -- 205, 2018. 2 N. Alon and J.H. Spencer. The Probabilistic Method. Fourth Edition. Wiley, 2016. 3 Moab Arar, Shiri Chechik, Sarel Cohen, Cliff Stein, and David Wajc. Dynamic match- ing: Reducing integral algorithms to approximately-maximal fractional algorithms. 2017. Manuscript. 4 Grey Ballard, James Demmel, Olga Holtz, and Oded Schwartz. Graph expansion and communication costs of fast matrix multiplication. J. ACM, 59(6):32:1 -- 32:23, January 2013. doi:10.1145/2395116.2395121. 5 Austin R. Benson and Grey Ballard. A framework for practical parallel fast matrix multi- plication. SIGPLAN Not., 50(8):42 -- 53, January 2015. URL: http://doi.acm.org/10.1145/ 2858788.2688513, doi:10.1145/2858788.2688513. 6 Aaron Bernstein. A nearly optimal algorithm for approximating replacement paths and k shortest simple paths in general graphs. In Proceedings of the Twenty-first Annual ACM- SIAM Symposium on Discrete Algorithms, SODA '10, pages 742 -- 755, 2010. URL: http: //dl.acm.org/citation.cfm?id=1873601.1873662. 7 Aaron Bernstein and Shiri Chechik. Deterministic decremental single source shortest paths: beyond the o(mn) bound. In Proceedings of the 48th Annual ACM Symposium on Theory of Computing (STOC), pages 389 -- 397, 2016. URL: http://doi.acm.org/10.1145/2897518. 2897521, doi:10.1145/2897518.2897521. 10 11 8 Aaron Bernstein and David Karger. Improved distance sensitivity oracles via random sampling. In Proceedings of the Nineteenth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA, pages 34 -- 43, 2008. URL: http://dl.acm.org/citation.cfm?id=1347082.1347087. 9 Aaron Bernstein and David Karger. A nearly optimal oracle for avoiding failed vertices and edges. In Proceedings of the Forty-first Annual ACM Symposium on Theory of Computing (STOC), pages 101 -- 110, 2009. URL: http://doi.acm.org/10.1145/1536414.1536431, doi: 10.1145/1536414.1536431. Thomas H. Byers and Michael S. Waterman. Technical note - determining all optimal and near- optimal solutions when solving shortest path problems by dynamic programming. Operations Research, 32(6):1381 -- 1384, 1984. URL: https://doi.org/10.1287/opre.32.6.1381, doi: 10.1287/opre.32.6.1381. Shiri Chechik, Sarel Cohen, Amos Fiat, and Haim Kaplan. (1 + ) approximate f-sensitive distance oracles. In Proceedings of the Twenty-Eighth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA '17, pages 1479 -- 1496, 2017. URL: http://dl.acm.org/citation. cfm?id=3039686.3039782. Shiri Chechik, Thomas Dueholm Hansen, Giuseppe F. Italiano, Jakub Lacki, and Nikos Parotsidis. Decremental single-source reachability and strongly connected components in √ O(m n) total update time. In IEEE 57th Annual Symposium on Foundations of Computer Science, FOCS 2016, 9-11 October 2016, Hyatt Regency, New Brunswick, New Jersey, USA, pages 315 -- 324, 2016. doi:10.1109/FOCS.2016.42. Shiri Chechik, Michael Langberg, David Peleg, and Liam Roditty. f-sensitivity distance oracles and routing schemes. Algorithmica, 63(4):861 -- 882, 2012. URL: http://dx.doi.org/10.1007/ s00453-011-9543-0, doi:10.1007/s00453-011-9543-0. 12 13 N. Alon, S. Chechik and S. Cohen 39 14 Don Coppersmith and Shmuel Winograd. Matrix multiplication via arithmetic progressions. J. Symb. Comput., 9(3):251 -- 280, 1990. URL: https://doi.org/10.1016/S0747-7171(08) 80013-2, doi:10.1016/S0747-7171(08)80013-2. 15 Camil Demetrescu and Mikkel Thorup. Oracles for distances avoiding a link-failure. In Proceedings of the Thirteenth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA, pages 838 -- 843, 2002. URL: http://dl.acm.org/citation.cfm?id=545381.545490. 16 Camil Demetrescu, Mikkel Thorup, Rezaul Alam Chowdhury, and Vijaya Ramachandran. Oracles for distances avoiding a failed node or link. SIAM J. Comput., 37(5):1299 -- 1318, January 2008. URL: http://dx.doi.org/10.1137/S0097539705429847, doi:10.1137/ S0097539705429847. 17 Ran Duan and Seth Pettie. Dual-failure distance and connectivity oracles. In Proceedings of the Twentieth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA, pages 506 -- 515, 2009. URL: http://dl.acm.org/citation.cfm?id=1496770.1496826. 18 Yuval Emek, David Peleg, and Liam Roditty. A near-linear-time algorithm for computing replacement paths in planar directed graphs. ACM Trans. Algorithms, 6(4):64:1 -- 64:13, September 2010. Appeared also in the Proceedings of the Nineteenth Annual ACM-SIAM Symposium on Discrete Algorithms (SODA '08). doi:10.1145/1824777.1824784. 19 David Eppstein. Finding the k shortest paths. SIAM J. Comput., 28(2):652 -- 673, 1998. doi:10.1137/S0097539795290477. Zvi Gotthilf and Moshe Lewenstein. Improved algorithms for the k simple shortest paths and the replacement paths problems. Inf. Process. Lett., 109(7):352 -- 355, March 2009. URL: http://dx.doi.org/10.1016/j.ipl.2008.12.015, doi:10.1016/j.ipl.2008.12.015. Fabrizio Grandoni and Virginia Vassilevska Williams. Improved distance sensitivity oracles via fast single-source replacement paths. In 53rd Annual IEEE Symposium on Foundations of Computer Science, FOCS 2012, 20-23, 2012, pages 748 -- 757, 2012. URL: http://dx.doi. org/10.1109/FOCS.2012.17, doi:10.1109/FOCS.2012.17. 20 21 25 27 22 Monika Henzinger, Sebastian Krinninger, and Danupon Nanongkai. Decremental single-source shortest paths on undirected graphs in near-linear total update time. In Proceedings of the 55th Annual Symposium on Foundations of Computer Science, FOCS, pages 146 -- 155, 2014. doi:10.1109/FOCS.2014.24. 23 Monika Henzinger, Sebastian Krinninger, and Danupon Nanongkai. Sublinear-time decremental algorithms for single-source reachability and shortest paths on directed graphs. In Proc. of 46th STOC, pages 674 -- 683, 2014. 24 Monika Henzinger, Sebastian Krinninger, and Danupon Nanongkai. Improved algorithms for decremental single-source reachability on directed graphs. In Proceedings of the 42nd International Colloquium, ICALP, pages 725 -- 736, 2015. URL: http://dx.doi.org/10.1007/ 978-3-662-47672-7_59, doi:10.1007/978-3-662-47672-7_59. J. Hershberger and Subhash Suri. Erratum to "vickrey pricing and shortest paths: What is an edge worth?". In The 43rd Annual IEEE Symposium on Foundations of Computer Science, 2002. Proceedings., pages 809 -- 809, Nov 2002. doi:10.1109/SFCS.2002.1182006. John Hershberger and Subhash Suri. Vickrey prices and shortest paths: What is an edge worth? In 42nd Annual Symposium on Foundations of Computer Science, FOCS 2001, 14-17 October 2001, Las Vegas, Nevada, USA, pages 252 -- 259, 2001. doi:10.1109/SFCS.2001.959899. J. Huang, L. Rice, D. A. Matthews, and R. A. v. d. Geijn. Generating families of practical fast matrix multiplication algorithms. In 2017 IEEE International Parallel and Distributed Processing Symposium (IPDPS), pages 656 -- 667, May 2017. doi:10.1109/IPDPS.2017.56. 26 28 Neelesh Khanna and Surender Baswana. Approximate shortest paths avoiding a failed vertex: Optimal size data structures for unweighted graphs. In 27th International Symposium on Theoretical Aspects of Computer Science, STACS, pages 513 -- 524, 2010. URL: http: //dx.doi.org/10.4230/LIPIcs.STACS.2010.2481, doi:10.4230/LIPIcs.STACS.2010.2481. 29 Valerie King. Fully dynamic algorithms for maintaining all-pairs shortest paths and transitive closure in digraphs. In 40th Annual Symposium on Foundations of Computer Science, FOCS 40 Deterministic Combinatorial Replacement Paths and Distance Sensitivity Oracles 30 31 32 37 38 '99, 17-18 October, 1999, New York, NY, USA, pages 81 -- 91, 1999. URL: https://doi.org/ 10.1109/SFFCS.1999.814580, doi:10.1109/SFFCS.1999.814580. Philip N. Klein, Shay Mozes, and Oren Weimann. Shortest paths in directed planar graphs with negative lengths: A linear-space o(n log2 n)-time algorithm. ACM Trans. Algorithms, 6(2):30:1 -- 30:18, April 2010. doi:10.1145/1721837.1721846. Eugene L. Lawler. A procedure for computing the k best solutions to discrete optimization problems and its application to the shortest path problem. Management Science, 18(7):401 -- 405, 1972. doi:10.1287/mnsc.18.7.401. François Le Gall. Powers of tensors and fast matrix multiplication. In Proceedings of the 39th International Symposium on Symbolic and Algebraic Computation, ISSAC '14, pages 296 -- 303, New York, NY, USA, 2014. ACM. URL: http://doi.acm.org/10.1145/2608628.2608664, doi:10.1145/2608628.2608664. 35 33 Cheng-Wei Lee and Hsueh-I Lu. Replacement paths via row minima of concise matrices. SIAM J. Discrete Math., 28(1):206 -- 225, 2014. URL: https://doi.org/10.1137/120897146, doi:10.1137/120897146. 34 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. URL: http://dx.doi.org/10.1016/ 0167-6377(89)90065-5, doi:10.1016/0167-6377(89)90065-5. Enrico Nardelli, Guido Proietti, and Peter Widmayer. A faster computation of the most vital edge of a shortest path. Inf. Process. Lett., 79(2):81 -- 85, June 2001. URL: http: //dx.doi.org/10.1016/S0020-0190(00)00175-7, doi:10.1016/S0020-0190(00)00175-7. 36 Noam Nisan and Amir Ronen. Algorithmic mechanism design. Games and Economic Behavior, 35(1-2):166 -- 196, 2001. URL: https://doi.org/10.1006/game.1999.0790, doi: 10.1006/game.1999.0790. Liam Roditty and Uri Zwick. Replacement paths and k simple shortest paths in unweighted directed graphs. In Automata, Languages and Programming, 32nd International Colloquium, ICALP, 2005, pages 249 -- 260. See also ACM Trans. Algorithms, 8(4):33:1 -- 11, 2012. doi: 10.1007/11523468_21. Shay Solomon. Fully dynamic maximal matching in constant update time. In Foundations of Computer Science (FOCS), 2016 IEEE 57th Annual Symposium on, pages 325 -- 334. IEEE, 2016. 39 Oren Weimann and Raphael Yuster. Replacement paths and distance sensitivity oracles via fast matrix multiplication. In Proceedings of the 2010 IEEE 51st Annual Symposium on Foundations of Computer Science, FOCS '10, pages 655 -- 662, Washington, DC, USA, 2010. IEEE Computer Society. URL: http://dx.doi.org/10.1109/FOCS.2010.68, doi:10.1109/FOCS.2010.68. 40 Virginia Vassilevska Williams. Faster replacement paths. In Proceedings of the Twenty-Second Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2011, 23-25, 2011, pages 1337 -- 1346, 2011. doi:10.1137/1.9781611973082.102. 41 Virginia Vassilevska Williams. Multiplying matrices faster than coppersmith-winograd. In Proceedings of the 44th Symposium on Theory of Computing Conference, STOC 2012, New York, NY, USA, May 19 - 22, 2012, pages 887 -- 898, 2012. URL: http://doi.acm.org/10. 1145/2213977.2214056, doi:10.1145/2213977.2214056. 42 Virginia Vassilevska Williams and Ryan Williams. Subcubic equivalences between path, matrix and triangle problems. In 51st Annual IEEE Symposium on Foundations of Computer Science, FOCS 2010, October 23-26, 2010, pages 645 -- 654, 2010. URL: https://doi.org/10.1109/ FOCS.2010.67, doi:10.1109/FOCS.2010.67. Jin Y. Yen. Finding the k shortest loopless paths in a network. Management Science, 17(11):712 -- 716, 1971. doi:10.1287/mnsc.17.11.712. 43
1611.09664
1
1611
2016-11-29T14:55:30
Optimizing run-length algorithm using octonary repetition tree
[ "cs.DS" ]
Compression is beneficial because it helps detract resource usage. It reduces data storage space as well as transmission traffic and improves web pages loading. Run-length coding (RLC) is a lossless data compression algorithm. Data are stored as a data value and counts. This is useful on data that contains many consecutive runs. This paper proposes a compression algorithm using octonary repetition tree (ORT), based on RLC. ORT is used to overcome the duplication problem in primary RLC algorithms, instead of using flag or codeword. It's the first method of run-length encoding which has the compression ratio greater than one in all tested cases. Experimental results, show average improvement of roughly 3 times, 3 times and 2 times in compression ratio field of study comparing to PRLC1, PRLC2, DF-RLC respectively. By using this approach of run-length encoding we can compress wider types of data, such as multimedia, document, executive files, etc.
cs.DS
cs
Optimizing run-length algorithm using octonary repetition tree Kaveh Geyratmand Haghighi1, Mir Kamal Mirnia*2, Ahmad Habibizad Navin3 1Department of Computer ,East Azarbaijan Science and Research Branch, Islamic Azad University,Tabriz, Iran 1 Department of Computer Engineering, Tabriz Branch, Islamic Azad University, Tabriz, Iran. 2Department of Computer Engineering, University Of Tabriz, Tabriz, Iran 3Department of Computer ,East Azarbaijan Science and Research Branch, Islamic Azad University,Tabriz, Iran Abstract-Compression is beneficial because it helps detract resource usage. It reduces data storage space as well as transmission traffic and improves web pages loading. Run-length coding (RLC) is a lossless data compression algorithm. Data are stored as a data value and counts. This is useful on data that contains many consecutive runs. This paper proposes a compression algorithm using octonary repetition tree (ORT), based on RLC. ORT is used to overcome the duplication problem in primary RLC algorithms, instead of using flag or codeword. It's the first method of run-length encoding which has the compression ratio greater than one in all tested cases. Experimental results, show average improvement of roughly 3 times, 3 times and 2 times in compression ratio field of study comparing to PRLC1, PRLC2, DF-RLC respectively. By using this approach of run-length encoding we can compress wider types of data, such as multimedia, document, executive files, etc. I. INTRODUCTION Digital image compression has become an important tool because image capturing devices, display units and social networks are widely used. When a raw image is stored as an array, usually the volume of file will be large and variable due to image resolution and color channel numbers. So, image compression may offer lower file size for storage and transmission. Usually there are two main approaches to compress data, such as lossy and lossless. Lossy image compression is irreversible, in the sense that it will lead missing details depending on the level of compression. Thus, this approach cannot be used in medical and satellite images and high level graphic design, since the original image should be remained with no changes. But, the original data can be reconstructed from the compressed data obtained from compression algorithm in lossless image compression. Run-Length Coding (RLC) or run-length encoding [1], being part of JPEG [2], is a common lossless compression method which is used in International Telecommunication Union too. Run-length Coding is often used in other compression algorithms. In RLC sequence of bytes with the same value, encoded to number of repetition beside of byte value. For example, this sequence of values 338888888 is encoded to (3 2 8 7), where, 3 and 8 stands for the value of bytes, 2 and 7 shows the repetition correspondingly. The RLC is very efficient in encoding images when long International Journal of Computer Science and Information Security (IJCSIS), Vol. 14, No. 8, August 2016265https://sites.google.com/site/ijcsis/ ISSN 1947-5500 runs of bytes appear with the same intensity value (eg., black and white images). In the other hand it is inefficient in encoding image with different values in sequence [5]. For example, 5 9 6 1 2 is a sequence of different bytes and will be encoded as (5 1 9 1 6 1 1 1 2 1) by RLC. In this case, adding number of repetition will increase data size (double in this case) and this is named as duplication problem in Run-Length Coding. A new optimizing run-length algorithm is proposed here by using ORT. An octonary tree is added to point the sequence of bytes with the same value. The tree features is used to locate sequence of the same bytes with less overhead. Hence, in the proposed algorithm, there is no need to use extra bytes for determining the number of the same bytes, nor reserving a bit as a flag. The proposed approach has no duplication problem, and there is no limitation to encode number of bytes with the same value in a sequence. Also existence of an unused byte in image is unnecessary. To the best of our knowledge, the compression rate just in this method is greater than 1 in all tested images. Thus it is possible to use the compressing method for wider types of data, such as multimedia, documents, executive files, etc. This paper is organized in five sections: Section 2 describes related works in RLC compression algorithm. Proposed method explains in section 3. Section 4 compares the new proposed method with recent works and section 5 concludes the paper and suggests future works. II. RELATED WORKS As a solution to solve the duplication problem, [2], [5], [6] offered that RLC encoding occurs only when number of bytes with the same value is three or more and code other cases without using RLC. In this method, it is necessary to use unique flag bits for pointing byte intensity levels from number of occurrence in a stream of RLC encoded bytes. Two main techniques were suggested to implement the flag bits in RLC. The first technique uses a reserved and fixed codeword. This codeword treated as flag. The flag, locates a byte value with its count. In [6], flag is associated to a byte intensity value that does not exist. However, this technique is not acceptable if all of 256 bytes brought in the image. A similar approach that uses an unmatched codeword of one byte was applied in [7]. We named this technique as primary Run-Length 1 (PRLC1). Since a byte including 8-bits has range of [0, 255], count of consecutive bytes (with the same intensity value) that can be encoded with one run is at most 256. The main problem of PRLC1 is that, adding extra byte for separation run from byte value causes to duplication problem when different values in sequence appears. This approach could not Assurances that compression ratio is always greater than 1. The second technique distinguishes count from value by defining MSB bit as a flag [8]. When MSB is set to 0, rest of bits (7-bits) indicates byte value and MSB=1, indicates following 7-bits is the count. This technique solves the duplication problem, but it is only acceptable when the image contains less than 128 unique values. Also, the count of consecutive bytes that can be encoded is at most 128. We named this technique as primary Run-Length 2 (PRLC2). Same as PRLC1, this method could not Assurances that compression ratio is always greater than 1. Another approach in [10], named duplication free run-length coding (DF-RLC), uses rule-based generative coding to deriving codeword. This method solves duplication problem and the count of consecutive bytes that can be encoded is infinitive. This technique achieves better compression ratio than PRLC1 and PRLC2. But looks like other methods in this section, compression ratio is not always greater than 1. International Journal of Computer Science and Information Security (IJCSIS), Vol. 14, No. 8, August 2016266https://sites.google.com/site/ijcsis/ ISSN 1947-5500 j k l … … … … a b c d e f g h i a: Root b: 1st child (a) c: 2nd child (a) d: 3nd child (a) e: 4th child (a) f: 5th child (a) g: 6th child (a) h: 7th child (a) i: 8th child (a) j: 1st child (b) k: 2nd child (b) l: 3nd child (b) d: 3nd child (a) Figure 1: ORT structure III. PROPOSED METHOD In the proposed method, a tree used to display duplicate bytes instead of using flag or codeword. This tree generates dynamically while reviewing the data. Fig.1 has shown the generated tree structure Each node of this tree includes one byte (containing 8 bit). We named this tree "octonary repetition tree". This tree has 8 childes for each node, named k= {1,2, … ,8}. The formula for calculating the array structure indices of the different relatives of a node are as follows: Parent(r) =⌊(r−1)/8⌋ if r≠0. Kth child(r) =8r+k if 8r+k≤n. (1) (2) The total count of nodes in the tree is n in (1), (2). The index of the node named as r, which is in the range of 0 to n−1. Each node in this tree has been ranged in [0-255] that represents a byte (containing 8-bits) in binary. The root of this tree has eight childes. As the lower layers has been reached, the data is divided into eight parts for each layer. This trend continues till leaves has reached. This method represents exact place of the duplicated byte. Each 8-bits in non-leaves, represents existence of equality of pair bytes in sub-branches. If there is no equality in sub-branches, calculating the array structure indices of the different relatives of a node Table 1 Position Parent 1st Child 2nd Child 3nd Child 4th Child 5th Child 6th Child 7th Child 8th Child 0 - 1 2 3 4 5 6 7 8 1 0 9 10 11 12 13 14 15 16 2 0 17 18 19 20 21 22 23 24 3 0 25 26 27 28 29 30 31 32 6 0 49 50 51 52 53 54 55 56 7 0 57 58 59 60 61 62 63 64 8 0 65 66 67 68 69 70 71 72 9 1 73 74 75 76 77 78 79 80 10 1 81 82 83 84 85 86 87 88 4 0 33 34 35 36 37 38 39 40 5 0 41 42 43 44 45 46 47 48 11 1 89 90 91 92 93 94 95 96 International Journal of Computer Science and Information Security (IJCSIS), Vol. 14, No. 8, August 2016267https://sites.google.com/site/ijcsis/ ISSN 1947-5500 Figure 2. Pruned tree for assumptive file algorithm prunes it. Fig.2 has shown pruned tree for assumptive file including 64 bytes of data. Bytes with the same value are {(3,4,5),(7,8),(13,14,15),(51,52,53,54)}. Actually the non-leaf nodes are in charge of dividing the file. This division continues till the eight byte blocks has reached in data. Each 8-bits in leaves, shows equality of pair bytes in sequence. If bit value is set to 0, indicates pair bytes is not the same; when bit value is 1, means that pair bytes are the same. So, one byte in leaf of tree, shows similarity of 8 bytes in data. Also we defined limitation of similarity to construct leaves of tree. For example, limitation of 2, only allows to have leaves with at least 2 bits with value=1. Levels of the tree is determined by the size of the file. If N is the total counts of bytes in file, then we calculate the number of levels as: Level=⌈𝑙𝑜𝑔8(𝑁)⌉ (3) A fixed table defined to determine the depth of the tree and as it is fixed, it is embedded in the application and would not lead to further process. Proposed algorithm eliminates the same bytes in sequence while passes data and locates their place in tree. When algorithm reaches to end of file, attaches generated tree to end of it. This algorithm runs more than one time recursively to gain better results. In each run, we treat the output of algorithm as input and encode it again. In each iteration, comparison of bytes increases by one. Fig.3 has shown these steps in flowchart. If n is count of bytes and k is number of runs. comparison of bytes at each run is as follow: 10 10 ∑ 𝑏𝑦𝑡𝑒[𝑛] = ∑ 𝑏𝑦𝑡𝑒[𝑛 + 𝑘 + 1] 𝑘=0 𝑘=0 (4) IV. EXPERIMENTAL RESULTS The ORT method is implemented in C# programing language software. Hardware used to run implemented program has an intel processor with 3.2 GHz frequency containing 8 thread and 8 GB ram with 1600 MHz frequency and SSD International Journal of Computer Science and Information Security (IJCSIS), Vol. 14, No. 8, August 2016268https://sites.google.com/site/ijcsis/ ISSN 1947-5500 Figure 3. Flowchart of proposed algorithm storage drive with reading and writing speed of 500 m/s. Windows 10 is also used as the operating system. and tested with 12 standard images [9]. Some of the test images is shown in Fig4. Compared with the methods used codeword for encoding, the proposed method in this article outs down the need for a codeword table. Compared with the methods used flag bit, this method has eliminated the limits of coding consecutive bytes (this problem exist in PRLC1, PRLC2). The proposed method in this article just as the PRLC1 does not have the duplication issue. The use of tree to display the duplicated bytes is an innovative method in this branch of encoding and has not be seen in any other article. One of the features of this tree is pruning any extra sub- branches to reach the least occupied byte. Generating individual tree (at the end of the file) also simplifies the uncompressing task. One of the important challenges in compressing is compression ratio. Data compression ratio (CR) is the ratio between the uncompressed and compressed size. 𝐶𝑅 = 𝑈𝑛𝑐𝑜𝑚𝑝𝑟𝑒𝑠𝑠𝑒𝑑 𝑆𝑖𝑧𝑒 𝑐𝑜𝑚𝑝𝑟𝑒𝑠𝑠𝑒𝑑 𝑆𝑖𝑧𝑒 (5) The results of the proposed method shown in Fig.5 and Table 2. Note that this results written after 10 times of running proposed algorithm recursively and limitation of the same bytes is >=3. In this table the comparison criterion International Journal of Computer Science and Information Security (IJCSIS), Vol. 14, No. 8, August 2016269https://sites.google.com/site/ijcsis/ ISSN 1947-5500 800 600 ( R C ) 400 200 0 Figure 4. Test images General Image Gray-21 Ruler TRLC1 TRLC2 DF-RLC Proposed method Figure 5. CR comparison of recent methods with proposed method is compression ratio. These results comprised with the PRLC1, PRLC2 and DF-RLC. If the compression ratio>1 it means the compression resulting data has gained free spaces after encoding. if compression ratio<1 indicates the increased size of data after encoding. Our approach has reached the CR>1 in any tested images. While in other methods, CR<1 has shown in some of cases. Table 2 Comparison of proposed algorithm compression ratio with other approaches 1 2 3 4 5 6 7 8 9 10 11 12 Image General Image Gray-21 Ruler Clock Tank APC Lenna Numbers Airplane F-16 Boat House Proposed method DF-RLC TRLC2 TRLC1 9.467 625.961 69.866 1.113 1.009 1.000 1.000 1.171 1.084 1.021 1.001 1.050 8.3 42.7 11.1 1.1 1.1 1.4 0.9 0.9 2.1 1.0 0.9 0.9 5.4 38.0 4.6 0.9 0.9 0.9 0.9 1.1 1.1 0.9 0.9 0.9 5.5 49.0 4.4 0.9 0.9 0.9 0.9 1.1 1.1 0.9 0.9 0.9 International Journal of Computer Science and Information Security (IJCSIS), Vol. 14, No. 8, August 2016270https://sites.google.com/site/ijcsis/ ISSN 1947-5500 New approach improved the compression ratio in all cases. The previous approaches which used the RLC for compression were limited to black and white or simple colored images due to their ineffectiveness. Hence these methods were limited to geographical and satellite and medical image. But the proposed approach in this article, is able to encode and compress other types of data such as multimedia files, applications, documents. In this method instead of using flag or codeword, a tree has been used to indicate the duplicated bytes. This tree is generated while passing the data and avoids reviewing the data repeatedly. V. CONCLUSION & FUTURE WORKS In this paper run-length compression algorithm using ORT has been proposed. In this method, a tree used to display duplicate bytes instead of using flag or codeword. This method has eliminated the limits of coding consecutive bytes. In comparison to the traditional RLC approaches, this method overcomes to duplication problem. Our approach has reached the CR>1 in any tested cases and considered to the test results of compressed photos, improvements have been made in this regard. While in other methods, CR<1 has shown in some of images. It makes our algorithm suitable to use in compression of other types of data. The generated tree is pruned which leads to decreasing the number of bytes. We have a fixed table to determine the depth of the tree and since it is fixed it is embedded in the application and would not lead to further process. Parallelizing the algorithm by dividing the data and pipelining the recursive runs, speeds up compressing. References [1] Bentley, J. L., et al. (1986). "A locally adaptive data compression scheme." Commun. ACM 29(4): 320-330. [2] Acharya, T. (2006). "VLSI Algorithms and architectures for JPEG2000." Ubiquity 2006(September): 1-42. [3] Togneri, R. and J. Christopher (2003). Fundamentals of information theory and coding design, CRC Press. [4] Zhan, W. and A. El-Maleh (2009). A new collaborative scheme of test vector compression based on equal-run- length coding (ERLC). Proceedings of the 2009 13th International Conference on Computer Supported Cooperative Work in Design, IEEE Computer Society: 21-25. [5] Luse, M. (1993). Bitmapped graphics programming in C++, Addison-Wesley. [6] (2008). "Data Compression: The Complete Reference (by D. Salomon; 2007) [Book review]." IEEE Signal Processing Magazine 25(2): 147-149. [7] Hughes, J. F., et al. (2014). Computer graphics: principles and practice, Pearson Education. [8] Glassner, A. (1991). "Adaptive Run-Length Encoding." Graphics Gems II 2: 89.\ [9] "USC-SIPI image database." [Online]. Available http://sipi.usc.edu/services/database/ [10] Al-Wahaib, M. S. and K. Wong (2010). A Lossless Image Compression Algorithm Using Duplication Free Run- Length Coding. Network Applications Protocols and Services (NETAPPS), 2010 Second International Conference on. International Journal of Computer Science and Information Security (IJCSIS), Vol. 14, No. 8, August 2016271https://sites.google.com/site/ijcsis/ ISSN 1947-5500
1407.2774
3
1407
2015-04-28T21:01:03
Subsampled Power Iteration: a Unified Algorithm for Block Models and Planted CSP's
[ "cs.DS", "math.CO", "math.PR" ]
We present an algorithm for recovering planted solutions in two well-known models, the stochastic block model and planted constraint satisfaction problems, via a common generalization in terms of random bipartite graphs. Our algorithm matches up to a constant factor the best-known bounds for the number of edges (or constraints) needed for perfect recovery and its running time is linear in the number of edges used. The time complexity is significantly better than both spectral and SDP-based approaches. The main contribution of the algorithm is in the case of unequal sizes in the bipartition (corresponding to odd uniformity in the CSP). Here our algorithm succeeds at a significantly lower density than the spectral approaches, surpassing a barrier based on the spectral norm of a random matrix. Other significant features of the algorithm and analysis include (i) the critical use of power iteration with subsampling, which might be of independent interest; its analysis requires keeping track of multiple norms of an evolving solution (ii) it can be implemented statistically, i.e., with very limited access to the input distribution (iii) the algorithm is extremely simple to implement and runs in linear time, and thus is practical even for very large instances.
cs.DS
cs
Subsampled Power Iteration: a Unified Algorithm for Block Models and Planted CSP’s Vitaly Feldman∗ Will Perkins† Santosh Vempala‡ Abstract We present an algorithm for recovering planted solutions in two well-known models, the stochastic block model and planted constraint satisfaction problems, via a common generaliza- tion in terms of random bipartite graphs. Our algorithm matches up to a constant factor the best-known bounds for the number of edges (or constraints) needed for perfect recovery and its running time is linear in the number of edges used. The time complexity is significantly better than both spectral and SDP-based approaches. The main contribution of the algorithm is in the case of unequal sizes in the bipartition that arises in our reduction from the planted CSP. Here our algorithm succeeds at a significantly lower density than the spectral approaches, surpassing a barrier based on the spectral norm of a random matrix. Other significant features of the algorithm and analysis include (i) the critical use of power iteration with subsampling, which might be of independent interest; its analysis requires keeping track of multiple norms of an evolving solution (ii) the algorithm can be implemented statis- tically, i.e., with very limited access to the input distribution (iii) the algorithm is extremely simple to implement and runs in linear time, and thus is practical even for very large instances. 5 1 0 2 r p A 8 2 ] S D . s c [ 3 v 4 7 7 2 . 7 0 4 1 : v i X r a ∗IBM Research - Almaden †University of Birmingham and the IMA. ‡Georgia Tech. Supported in part by NSF award CCF-1217793. 1 Introduction Partitioning a graph into parts based on the density of the edges within and between the parts is a fundamental algorithmic task both in its own right as a method of clustering data into similar pieces, and as a powerful subroutine of divide-and-conquer algorithms. There are many choices for the number of parts required and the measure of the quality of a partition, and different choices give rise to algorithmic problems such as Max Clique, Max Cut, Uniform Sparsest Cut, and Min Bisection. While finding an optimal graph partition is often an NP-hard problem in the worst case, the average-case study of graph partitioning problems is particularly rich, as the underlying distribu- tions come from natural and widely studied models of random graphs (we review the previous work in Section 1.2). The simplest model is the stochastic block model: partition a set of vertices into two equal parts A and B, and add edges independently, with probability p for an edge within a part, and q (cid:54)= p for a crossing edge. The algorithmic task is to recover the partition given the random graph. Generalizations include parts of unequal size, more than two parts, and more than two edge probabilities. Another broad and fundamental class of algorithmic problems is the class of boolean Constraint Satisfaction Problems (CSP’s, defined precisely below). The average-case complexity of k-CSP’s is a large area of research that intersects cryptography, computational complexity, probabilistic combinatorics and statistical physics. In the planted k-SAT problem each constraint is a disjunction of k literals, variables or their negations, eg. {x5, x6, x10} and is referred to as k-clause. A random instance of this problem is produced by choosing a random and uniform assignment σ and then selecting k-clauses at random independently (but not necessarily uniformly) from the set of k- clauses satisfied by σ. This distribution is guaranteed to have at least one satisfying assignment, σ. In the ‘noisy’ version of the problem unsatisfied clauses are also included with some probability. The algorithmic task is to recover the planted assignment σ. An additional model of planted CSP’s we consider is Goldreich’s pseudorandom generator [42] that has been studied in cryptography. We describe it in more detail below. 1.1 Our results and techniques We propose a natural bipartite stochastic block model that generalizes the classic stochastic block model defined above. The key motivation for the study of this model is that the two types of planted k-CSP’s can be reduced to our block model, thus unifying graph partitioning and planted CSP’s into one problem. We then give an algorithm for solving random instances of the model. The model begins with two vertex sets, V1 and V2 (of possibly unequal size), each with a balanced partition, (A1, B1) and (A2, B2) respectively. Edges are added independently at random between V1 and V2 with probabilities that depend on which parts the endpoints are in: edges between A1 and A2 or B1 and B2 are added with probability δp, while the other edges are added with probability (2− δ)p, where δ ∈ [0, 2] and p is the overall edge density. To obtain the stochastic block model we can identify V1 and V2. To reduce planted CSP’s to this model, we first reduce the problem to an instance of noisy r-XOR-SAT, where r is the complexity parameter of the planted CSP distribution defined in [35] (see Sec. 2 for details). We then identify V1 with literals, and V2 with (r − 1)-tuples of literals, and add an edge between literal l ∈ V1 and tuple t ∈ V2 when the r-clause consisting of their union appears in the formula. The reduction leads to a bipartition with V2 much larger than V1. Our algorithm is based on applying power iteration with a sequence of matrices subsampled 1 from the original adjacency matrix. This is in contrast to previous algorithms that compute the eigenvectors (or singular vectors) of the full adjacency matrix. Our algorithm has several advan- tages. Such an algorithm, for the special case of square matrices, was previously proposed and analyzed in a different context by Korada et al [48]. • Up to a constant factor, the algorithm matches the best-known (and in some cases the best- possible) edge or constraint density needed for complete recovery of the planted partition or assignment. The algorithm for planted CSP’s finds the planted assignment using O(nr/2·log n) clauses for a clause distribution of complexity r (see Sec. 2 for the formal definition), nearly matching computational lower bounds for SDP hierarchies [60] and the class of statistical algorithms [35]. • The algorithm is fast, running in time linear in the number of edges or constraints used, unlike other approaches that require computing eigenvectors or solving semi-definite programs. • The algorithm is conceptually simple and very easy to describe and implement. In fact it can be implemented in the statistical query model, with very limited access to the input graph [35]. • It is based on the idea of iteration with subsampling which may have further applications in the design and analysis of algorithms. • Most notably, the algorithm succeeds where generic spectral approaches fail. For the case of the planted CSP, when V2 (cid:29) V1, our algorithm succeeds at a polynomial factor sparser density than the approaches of McSherry [55], Coja-Oghlan [19], and Vu [64]. The algorithm succeeds despite the fact that the ‘energy’ of the planted vector with respect to the random adjacency matrix is far below the spectral norm of the matrix. In previous analyses, this was believed to indicate failure of the spectral approach. For a full discussion, see Section 5. The remainder of the paper is organized as follows: • In Section 1.2, we review previous work. • In Section 2 we formally define the model and present the main theorems. • In Section 3 we describe the algorithm and analyze its performance. • In Section 4 we give the reduction of the planted k-CSP problems to the bipartite stochastic block model. • In Section 5 we compare our algorithm to other spectral approaches. • In Section 6 we present full details of the analysis. 1.2 Related work Planted partitioning The stochastic block model was introduced in [43]. Boppana [15] gave a spectral-based algorithm for the model, and Jerrum and Sorkin [45] gave a Metropolis approach. Dyer and Frieze [30] and Blum and Spencer [13] give algorithms for the related planted k-coloring model in which the vertex set is partitioned into k equal parts and then edges crossing the partition are added independently 2 at random while edges within the partition are forbidden. Alon and Kahale [5] gave a spectral algorithm for this problem. Later algorithms [25, 32, 18, 16, 24] improved either the running time or the density at which the algorithms succeed. Of particular note is McSherry’s algorithm [55] which is based on a low- rank projection and is a generic algorithm for many planted partitioning problems, including the stochastic block model, the planted coloring problem, and the planted clique problem. Coja-Oghlan [19] gave a refined general purpose partitioning algorithm and showed that the planted partition in the stochastic block model can be partially recovered when the average degree is just a constant. Vu [64] recently gave a simple SVD-based general partitioning algorithm. While all of the above works seek to recover the partition at as low a density as possible, only recently have sharp thresholds for the possibility of recovery been identified. Based on ideas from statistical physics, Decelle et al. [29] conjectured that in fact there is a sharp threshold for efficient recovery in the stochastic block model: if p = a/n, q = b/n, and (a − b)2 < 2(a + b) then any non-trivial recovery of the planted partition is impossible, while if (a − b)2 > 2(a + b) then there is an efficient algorithm (polynomial in the size of the graph) that gives a partition with significant correlation to the planting. Mossel, Sly, and Neeman proved the lower bound [58], and then Massoulie [54] and Mossel, Neeman, Sly [56] independently analyzed algorithms proving the upper bound. See also [59, 51] for more on related algorithms. Recent work has found algorithms that succeed at the optimal threshold for complete recovery [1, 57]. Planted k-CSP’s A width-k CSP is defined by a set of m predicates denoted by P1, . . . , Pm and a set of m k-tuples of boolean variables from the set V = {x1, . . . , xn} denoted by C1, . . . , Cm. Each predicate Pi is a function from {±1}k to {±1}. Identifying +1 with TRUE and −1 with FALSE, a predicate Pi is satisfied by an assignment σ : V → {±1} if the evaluation of the predicate Pi on the values assigned by σ to the k-tuple of variables Ci = (xi1, . . . , xik ) is TRUE. Given such a k-CSP the algorithmic task is to find an assignment σ that maximizes the number of satisfied constraints. It was noted in [9] that drawing satisfied k-SAT clauses uniformly at random from all those satisfied by σ does not result in a difficult algorithmic problem even if the number of observed clauses is relatively small (simply taking the majority vote for each variable suffices; see [10] for optimal statistical tests in this setting). However, by changing the proportions of clauses depending on the number of satisfied literals under σ, one can create a more challenging distribution over instances. Such ‘quiet plantings’ were further studied in [46, 2, 52, 50]. Algorithms for solving instances with various values of relative proportions for planted 3-SAT were given in [36, 49, 20]. Following [35], we define such problems using a planting distribution Q. This distribution is defined over {±1}k and for a vector z it gives the proportion of clauses in which the values σ assigns to the k-tuple of literals in the clause is z (see Section 2 for the formal definition). A related class of problems is one in which for some fixed predicate P , an instance is generated by choosing a planted assignment σ uniformly at random and generating a set of m random and uniform P -constraints. That is, each constraint is of the form P (xi1, . . . , xik ) = P (σi1, . . . , σik ), where (xi1, . . . , xik ) is a randomly and uniformly chosen k-tuple of variables (without repetitions). The algorithmic problem is to determine σ given the m k-tuples of variables and the corresponding values of P on those tuples. Goldreich [42] proposed a one-way function based on the apparent hardness of these problems. In his proposal the predicate is chosen randomly. The hardness of such problems for other predicates, most notably noisy k-XOR-SAT, has been used in cryptographic applications including public key cryptosystems [4, 7], and secure two-party computation [44]. It has also been used to derive hardness of approximation [6] (for public discussions of these problems/assumptions 3 see [8, 63]). Problems of this type are usually referred to as Goldreich’s pseudorandom generator (PRG). Bogdanov and Qiao [14] show that an SDP-based algorithm of Charikar and Wirth [17] can be used to find the planted assignment for any predicate that is not pairwise-independent using m = O(n) constraints. The same approach can be used to recover the input for any t-wise independent predicate using O(n(t+1)/2) evaluations via the folklore birthday “paradox”-based reduction to t = 1 (see [60] for details). Finding the planted assignment in a randomly generated k-SAT formula is at least as hard as distinguishing between a satisfiable formula generated using a planted assignment and a randomly and uniformly generated k-SAT formula. Even this seemingly easier problem appears to be hard for certain planting distributions. This problem is a special case of another well-studied hard problem: refuting the satisfiability of SAT formulas in which the goal is to distinguish a satisfiable formula from a randomly an uniformly generated one (see [35] for the details of the connection). It is important to note that in planted k-CSP’s the planted assignment becomes identifiable with high probability after at most O(n log n) random clauses yet the best known efficient algorithms require nΩ(r/2) clauses. Problems exhibiting this type of behavior have attracted significant interest in learning theory [12, 28, 61, 33, 62, 11, 26] and some of the recent hardness results are based on the conjectured computational hardness of the k-SAT refutation problem [26, 27]. The connection of planted CSP’s to graph partitioning is that many algorithms for planted CSP’s use graph partitioning, and spectral graph partitioning in particular, as a subroutine. Examples of such algorithms for some classes of constraint distributions include Flaxman’s algorithm for planted 3-SAT [36], Krivelevich and Vilenchik’s algorithm [49] that runs in expected polynomial time, and the algorithm of Coja-Oghlan, Cooper, Frieze [20] for planted 3-SAT distributions that include the quiet plantings described above. Many of the same spectral techniques have been applied here as well for the SAT refutation problem [40, 41, 21, 31, 39, 23]. Comparison with previous work The algorithm of Mossel, Neeman, and Sly [56] for the case n1 = n2 also runs in near linear time, while other known algorithmic approaches for planted partitioning that succeed near the optimal edge density [55, 19, 54] perform eigenvector or singular vector computations and thus require superlinear time, though a careful randomized implementation of low-rank approximations can reduce the running time of McSherry’s algorithm substantially [3]. For planted satisfiability, the algorithm of Flaxman for planted 3-SAT works for a subset of planted distributions (those with distribution complexity at most 2 in our definition below) using O(n) constraints, while the algorithm of Coja-Oghlan, Cooper, and Frieze [20] works for planted 3-SAT distributions that exclude unsatisfied clauses and uses O(n3/2 ln10 n) constraints. The only previous algorithm that finds the planted assignment in Goldreich’s PRG for all predicates is the SDP-based algorithm of Bogdanov and Qiao [14] with the folklore generalization to r-wise independent predicates (cf. [60]). Similar to our algorithm, it uses O(nr/2) constraints. This algorithm effectively solves the noisy r-XOR-SAT instance and therefore can be also used to solve our general version of planted satisfiability using O(nr/2) clauses (via the reduction in Section 4). Notably for both this algorithm and ours, having a completely satisfying planted assignment plays no special role: the number of constraints required depends only on the distribution complexity. To the best of our knowledge, our algorithm is the first for the planted k-SAT problem that runs in linear time in the number of constraints used. Our algorithm is arguably simpler than the approach in [14] and substantially improves the running time even for small k. Another advantage of our approach is that it can be implemented 4 using restricted access to the distribution of constraints referred to as statistical queries [47, 34]. Roughly speaking, for the planted SAT problem this access allows an algorithm to evaluate multi- valued functions of a single clause on randomly drawn clauses or to estimate expectations of such functions, without direct access to the clauses themselves. Recently, in [35], lower bounds on the number of clauses necessary for a polynomial-time statistical algorithm to solve planted k-CSPs were proved. It is therefore important to understand the power of such algorithms for solving planted k-CSPs. A statistical implementation of our algorithm gives an upper bound that nearly matches the lower bound for the problem. See [35] for the formal details of the model and statistical implementation. Korada, Montanari, and Oh [48] analyzed the ‘Gossip PCA’ algorithm, which for the special case of an equal bipartition is the same as our subsampled power iteration. The assumptions, model, and motivation in the two papers are different and the results incomparable. In particular, while our focus and motivation are on general (nonsquare) matrices, their work considers extracting a planting of rank k greater than 1 in the square setting. Their results also assume an initial vector with non-trivial correlation with the planted vector. The nature of the guarantees is also different. Two other algorithms are similar in spirit to our approach: clustering via matrix powering of Zhou and Woodruff [65] and ‘Power Iteration Clustering’ of Lin and Cohen [53]. In each, partitioning is performed by multiplying an initial vector by the adjacency matrix of the random graph repeatedly. These methods are similar to ours in their simplicity; the subsampling in our algorithm allows us to carry out a rigorous analysis through many more iterations. 2 Model and results Bipartite stochastic block model Definition 1. For δ ∈ [0, 2] \ {1}, n1, n2 even, and P1 = (A1, B1), P2 = (A2, B2) biparti- tions of vertex sets V1, V2 of size n1, n2 respectively, we define the bipartite stochastic block model B(n1, n2,P1,P2, δ, p) to be the random graph in which edges between vertices in A1 and A2 and B1 and B2 are added independently with probability δp and edges between vertices in A1 and B2 and B1 and A2 with probability (2 − δ)p. Here δ is a fixed constant while p will tend to 0 as n1, n2 → ∞. Note that setting n1 = n2 = n, and identifying A1 and A2 and B1 and B2 gives the usual stochastic block model (with loops allowed); for edge probabilities a/n and b/n, we have δ = 2a/(a + b) and p = (a + b)/2n, the overall edge density. For our application to k-CSP’s, it will be crucial to allow vertex sets of very different sizes, i.e. n2 (cid:29) n1. The algorithmic task for the bipartite block model is to recover one or both partitions (com- pletely or partially) using as few edges and as little computational time as possible. In this work we will assume that n1 ≤ n2, and we will be concerned with the algorithmic task of recovering the partition P1 completely, as this will allow us to solve the planted k-CSP problems described below. We define complete recovery of P1 as finding the exact partition with high probability over the randomness in the graph and in the algorithm. Theorem 1. Assume n1 ≤ n2. There is a constant C so that the Subsampled Power Iteration algorithm described below completely recovers the partition P1 in the bipartite stochastic block model B(n1, n2,P1,P2, δ, p) with probability 1 − o(1) as n1 → ∞ when p ≥ C log n1 (δ−1)2√ . Its running time is O (cid:16)√ n1n2 (cid:17) . n1n2 · log n1 (δ−1)2 5 Figure 1: Bipartite stochastic block model. Note that for the usual stochastic block model this gives an algorithm using O(n log n) edges and O(n log n) time, which is the best possible for complete recovery since that many edges are needed for every vertex to appear in at least edge. With edge probabilities a log n/n and b log n/n, our results requires (a− b)2 ≥ C(a + b) for some absolute constant C, matching the dependence on a and b in [15, 55] (see [1] for a discussion of the best possible threshold for complete recovery). √ For any n1, n2, at least n1n2 edges are necessary for even non-trivial partial recovery, as below that threshold the graph consists only of small components (and even if a correct partition is found √ on each component, correlating the partitions of different components is impossible). Similarly at n1n2 log n1) are needed for complete recover of P1 since below that density, there are least Ω( vertices in V1 joined only to vertices of degree 1 in V2. For very lopsided graphs, with n2 (cid:29) n1 log2 n1, the running time is sublinear in the size of V2; this requires careful implementation and is essential to achieving the running time bounds for planted CSP’s described below. Planted k-CSP’s We now describe a general model for planted satisfiability problems introduced in [35]. For an integer k, let Ck be the set of all ordered k-tuples of literals from x1, . . . , xn, x1, . . . , xn with no repetition of variables. For a k-tuple of literals C and an assignment σ, σ(C) denotes the vector of values that σ assigns to the literals in C. A planting distribution Q : {±1}k → [0, 1] is a probability distribution over {±1}k. Definition 2. Given a planting distribution Q : {±1}k → [0, 1], and an assignment σ ∈ {±1}n, we define the random constraint satisfaction problem FQ,σ(n, m) by drawing m k-clauses from Ck 6 Figure 2: Planted random 3-SAT. independently according to the distribution Qσ(C) = (cid:80) Q(σ(C)) Q(σ(C(cid:48))) C(cid:48)∈Ck where σ(C) is the vector of values that σ assigns to the k-tuple of literals comprising C. Definition 3. The distribution complexity r(Q) of the planting distribution Q is the smallest integer r ≥ 1 so that there is some S ⊆ [k], S = r, so that the discrete Fourier coefficient Q(S) is non-zero. In other words, the distribution complexity of Q is r if Q is an (r − 1)-wise independent distribution on {±1}k but not an r-wise independent distribution. The uniform distribution over all clauses, Q ≡ 2−k, has Q(S) = 0 for all S ≥ 1, and so we define its complexity to be ∞. The uniform distribution does not reveal any information about σ, and so inference is impossible. For any Q that is not the uniform distribution over clauses, we have 1 ≤ r(Q) ≤ k. Note that the uniform distribution on k-SAT clauses with at least one satisfied literal under σ has distribution complexity r = 1. r = 1 means that there is a bias towards either true or false literals. for each variable, count the number of times it appears negated and not negated, and take the majority vote. For distributions with complexity r ≥ 2, the expected number of true and false literals in the random formula are equal and so this simple algorithm fails. In this case, a very simple algorithm is effective: Theorem 2. For any planting distribution Q, there exists an algorithm that for any assignment σ, given an instance of FQ,σ(n, m) completely recovers the planted assignment σ for m = O(nr/2 log n) using O(nr/2 log n) time, where r ≥ 2 is the distribution complexity of Q. For distribution complex- ity r = 1, there is an algorithm that gives non-trivial partial recovery with O(n1/2) constraints and complete recovery with O(n log n) constraints. We also show that the same result applies to recovering the planted assignment in Goldreich’s PRG defined above. 7 Theorem 3. For any predicate P : {±1}k → {±1}, there exists an algorithm that for any assignment σ, given m random P -constraints completely recovers the planted assignment σ for m = O(nr/2 log n) and using O(nr/2 log n) time, where r ≥ 2 is the degree of the lowest-degree non-zero Fourier coefficient of P . For r = 1, the algorithm gives non-trivial partial recovery with O(n1/2) constraints and complete recovery with O(n log n) constraints. 3 The algorithm We now present our algorithm for the bipartite stochastic block model. We define vectors u and v of dimension n1 and n2 respectively, indexed by V1 and V2, with ui = 1 for i ∈ A1, ui = −1 for i ∈ B1, and similarly for v. To recover the partition P1 it suffices to find either u or −u. We will find this vector by multiplying a random initial vector x0 by a sequence of centered adjacency matrices and their transposes. We form these matrices as follows: let Gp be the random bipartite graph drawn from the model B(n1, n2,P1,P2, δ, p), and T a positive integer. Then form T different bipartite graphs G1, . . . , GT on the same vertex sets V1, V2 by placing each edge from Gp uniformly and independently at random into one of the T graphs. The resulting graphs have the same marginal distribution. Next we form the n1 × n2 adjacency matrices A1, . . . , AT for G1, . . . GT with rows indexed by V1 and columns by V2 with a 1 in entry (i, j) if vertex i ∈ V1 is joined to vertex j ∈ V2. Finally we center the matrices by defining Mi = Ai − p T J where J is the n1 × n2 all ones matrix. In the bipartite block model, these subsampled matrices are nearly independent (see Lemma 2), leading to a strong bound on the number of iterations required to solve the problem. The subsampling also mitigates the influence of high-degree vertices leading to significant improvement over the spectral approach for a large subclass of planted CSP’s. The analysis of the algorithm proceeds by tracking a potential function, Ui = xi·u for a sequence of unit vectors x0, x1, . . . of dimension n1. We must bound various norms of the xi’s as well as norms of a sequence of auxiliary vectors y1, y2, . . . of dimension n2. We use superscripts to denote the current step of the iteration and subscripts for the components of the vectors, so xi j is the jth coordinate of the vector after the ith iteration. The basic iterative steps are the multiplications y = M T x and x = M y. 8 Algorithm: Subsampled Power Iteration. 1. Form T = 10 log n1 matrices M1, . . . , MT by uniformly and independently assigning each edge T J, of the bipartite block model to a graph G1, . . . , GT , then forming the matrices Mi = Ai− p where Ai is the adjacency matrix of Gi and J is the all ones matrix. 2. Sample x ∈ {±1}n1 uniformly at random and let x0 = x√ n1 . 3. For i = 1 to T /2 let yi = 2i−1xi−1 M T (cid:107)M T 2i−1xi−1(cid:107) ; xi = M2iyi (cid:107)M2iyi(cid:107) ; zi = sgn(xi). 4. For each coordinate j ∈ [n1] take the majority vote of the signs of zi j for all i ∈ {T /4, . . . , T /2} and call this vector v: vj = sgn  T(cid:88)  . zi j 5. Return the partition indicated by v. i=T /2 The analysis of the resampled power iteration algorithm proceeds in four phases, during which we track the progress of two vectors xi and yi, as measured by their inner product with u and v respectively. We define Ui := u · xi and Vi := v · yi. Here we give an overview of each phase; the complete analysis is in Section 6. • Phase 1. Within log n1 iterations, Ui reaches log n1. We show that conditioned on the value of Ui, there is at least a 1/2 chance that Ui+1 ≥ 2Ui; that Ui never gets too small; and that in log n1 steps, a run of log log n1 doublings pushes the magnitude of Ui above log n1. • Phase 2. After reaching log n1, Ui makes steady, predictable progress, doubling at each √ step whp until it reaches Θ( n1), at which point we say xi has strong correlation with u. • Phase 3. Once xi is strongly correlated with u, we show that zi+1 agrees with either u or −u on a large fraction of coordinates. • Phase 4. We show that taking the majority vote of the coordinate-by-coordinate signs of zi over O(log n1) additional iterations gives complete recovery whp. Running time If n2 = Θ(n1), then a straightforward implementation of the algorithm runs in time linear in the number of edges used: each entry of xi = M yi (resp. yi = M T xi−1) can be computed as a sum over the edges in the graph associated with M . The rounding and majority vote are both linear in n1. However, if n2 (cid:29) n1, then simply initializing the vector yi will take too much time. In this Say we have a vector xi−1 and want to compute xi = M2iyi without storing the vector yi. 2i−1xi−1, we create a set Si ⊂ V2 of all vertices with degree at least case, we have to implement the algorithm more carefully. Instead of computing yi = M T 9 1 in the current graph G2i−1 corresponding to the matrix M2i−1. The size of Si is bounded by the number of edges in G2i−1, and checking membership can be done in constant time with a data structure of size O(Si) that requires expected time O(Si) to create [38]. Recall that M2i−1 = A2i−1 − qJ. Then we can write  n1(cid:88)  1n2 = y − qL1n2, xi−1 j yi = (A2i−1 − qJ)T xi−1 = y − q where y is 0 on coordinates j /∈ Si, L =(cid:80)n1 Then to compute xi = M2iyi, we write j=1 , and 1n2 is the all ones vector of length n2. j=1 xi−1 j xi = (A2i − qJ)yi = (A2i − qJ)(y − qL1n2) = (A2i − qJ)y − qLA2i1n2 + q2LJ1n2 = A2i y − qJ y − qLA2i1n2 + q2Ln21n1 by the number of edges of G2i−1. Computing L =(cid:80)n1 We bound the running time of the computation as follows: we can compute y in linear time in the number of edges of G2i−1 using Si. Given y, computing A2i y is linear in the number of edges of G2i and computing qJ y is linear in the number of non-zero entries of y, which is bounded is linear in n1 and gives q2Ln21n1. Computing qLA2i1n2 is linear in the number of edges of G2i. All together this gives our linear time implementation. j=1 xi−1 j 4 Reduction of planted k-CSP’s to the block model Here we describe how solving the bipartite block model suffices to solve the planted k-CSP problems. Consider a planted k-SAT problem FQ,σ(n, m) with distribution complexity r. Let S ⊆ [k], S = r, be such that Q(S) = η (cid:54)= 0. Such an S exists from the definition of the distribution complexity. We assume that we know both r and this set S, as trying all possibilities (smallest first) requires only a constant factor (2r) more time. We will restrict each k-clause in the formula to an r-clause, by taking the r literals specified by the set S. If the distribution Q is known to be symmetric with respect to the order of the k-literals in each clause, or if clauses are given as unordered sets of literals, then we can simply sample a random set of r literals (without replacement) from each clause. We will show that restricting to these r literals from each k-clause induces a distribution on r-clauses defined by Qδ : {±1}r → R+ of the form Qδ(C) = δ/2r for C even, Qδ(C) = (2 − δ)/2r for C odd, for some δ ∈ [0, 2] , δ (cid:54)= 1, where C is the number of TRUE literals in C under σ. This reduction allows us to focus on algorithms for the specific case of a parity-based distribution on r-clauses with distribution complexity r. Recall that for a function f : {−1, 1}k → R, its Fourier coefficients are defined for each subset S ⊂ [k] as f (S) = E x∼{−1,1}k [f (x)χS(x)] where χS are the Walsh basis functions of {±1}k with respect to the uniform probability measure, i.e., χS(x) =(cid:81) i∈S xi. 10 Lemma 1. If the function Q : {±1}k → R+ defines a distribution Qσ on k-clauses with distribution complexity r and planted assignment σ, then for some S ⊆ [k], S = r and δ ∈ [0, 2]\{1}, choosing r literals with indices in S from a clause drawn randomly from Qσ yields a random r-clause from Qδ σ. Proof. From Definition 3 we have that there exists an S with S = r such that Q(S) (cid:54)= 0. Note that by definition, Q(x)χS(x) Q(x) − (cid:88)  Q(x) (cid:88)  (cid:88) x∈{±1}k 1 2k 1 2k Q(S) = E x∼{±1}k [Q(x)χS(x)] = = = x:∈{±1}k:xS even x:∈{±1}k:xS odd 1 2k (Pr[xS even] − Pr[xS odd]) where xS is x restricted to the coordinates in S, and so if we take δ = 1 + 2k Q(S), the distribution induced by restricting k-clauses to the r-clauses specified by S is Qδ σ. Note that by the definition of the distribution complexity, Q(T ) = 0 for any 1 ≤ T < r, and so the original and induced distributions are uniform over any set of r − 1 coordinates. √ First consider the case r = 1. Restricting each clause to S for S = 1, induces a noisy 1-XOR- SAT distribution in which a random true literal appears with probability δ and random false literal appears with probability 2 − δ. The simple majority vote algorithm described above suffices: set each variable to +1 if it appears more often positively than negated in the restricted clauses of the formula; to −1 if it appears more often negated; and choose randomly if it appears equally often. with σ (or −σ) on n/2 + t n variables with probability at least 1 − ; using cn log n clauses it will recover σ exactly with probability 1 − o(1). Using c(cid:112)t log(1/) clauses for c = O(1/1 − δ2) this algorithm will give an assignment that agrees (cid:1). We partition each of all (r − 1)-tuples of literals. We have n1 = V1 = 2n and n2 = V2 =(cid:0) 2n Now assume that r ≥ 2. We describe how the parity distribution Qδ σ on r-constraints induces a bipartite block model. Let V1 be the set of 2n literals of the given variable set, and V2 the collection set into two parts as follows: A1 ⊂ V1 is the set of false literals under σ, and B1 the set of true literals. A2 ⊂ V2 is the set of (r − 1)-tuples with an even number of true literals under σ, and B2 the set of (r − 1)-tuples with an odd number of true literals. For each r-constraint (l1, l2, . . . , lr), we add an edge in the block model between the tuples l1 ∈ V1 and (l2, . . . , lr) ∈ V2. A constraint drawn according to Qδ σ induces a random edge between A1 and A2 or B1 and B2 with probability δ/2 and between A1 and B2 or B1 and A2 with probability 1 − δ/2, exactly the distribution of a single edge in the bipartite block model. r−1 Now the model in Definition 2 is that of m clauses selected independently with replacement according to a given distribution, while in Definition 1, each edge is present independently with a given probability. To reduce from m independent edges with replacement to the binomial model, we can fix some  > 0 (e.g.  = 1/2), draw a Poisson random variable Z with mean (1 − )m, and select the first Z of the m edges (whp Z ≤ m), discarding any multiple edges. By Poisson thinning, this leaves us with a graph where each edge e appears independently with probability pe, where pe = Pr[Poisson((1 − )m · qe) ≥ 1] where qe is the probability of edge e in the single edge distribution. In particular, if for example e joins a vertex in A1 to a vertex in A2 and  = 1/2, then 11 qe = δ/2 · 2 n1n2 and (cid:18) − δm 2n1n2 (cid:19) = δp pe = 1 − exp where p = m (1 + o(1)). Recovering the partition P1 = A1 ∪ B1 in this bipartite block model partitions the literals into 2n1n2 true and false sets giving σ (up to sign). The reduction from Goldreich’s PRG to the bipartite block model is even simpler. By definition, the value of the predicate is correlated with the parity function of some r of the k inputs of the predicate (see for example [14]). Therefore the input can be seen as produced by the noisy r-XOR predicate on random and uniform r-tuples of variables. The r-tuples for which this predicate is equal to 1 give an instance of noisy r-XOR-SAT. A bipartite block model can now be formed on the set of variables and (r − 1)-tuples of variables (instead of literals) analogously to the construction above. p = O((n1n2)−1/2), corresponding to O(nr/2) clauses in the planted CSP. The key feature of our bipartite block model algorithm is that it uses O( n1n2) edges (i.e. √ 5 Comparison with spectral approach As noted above, many approaches to graph partitioning problems and planted satisfiability problems use eigenvectors or singular vectors. These algorithms are essentially based on the signs of the top eigenvector of the centered adjacency matrix being correlated with the planted vector. This is fairly straightforward to establish when the average degree of the random graph is large enough. However, in the stochastic block model, for example, when the average degree is a constant, vertices of large degree dominate the spectrum and the straightforward spectral approach fails (see [51] for a discussion and references). In the case of the usual block model, n1 = n2 = n, while our approach has a fast running time, it does not save on the number of edges required as compared to the standard spectral approach: both require Ω(n log n) edges. However, when n2 (cid:29) n1, eg. n1 = Θ(n), n2 = Θ(nk−1) as in the case of the planted k-CSP’s for odd k, this is no longer the case. Consider the general-purpose partitioning algorithm of [55]. Let G be the matrix of edge probabilities: Gij is the probability that the edge between vertices i and j is present. Let Gu, Gv denote columns of G corresponding to vertices u, v. Let σ2 be an upper bound of the variance of an entry in the adjacency matrix, sm the size of the smallest part in the planted partition, q the number of parts, δ the failure probability of the algorithm, and c a universal constant. Then the condition for the success of McSherry’s partitioning algorithm is: min u,v in different parts (cid:107)Gu − Gv(cid:107)2 > cqσ2(n/sm + log(n/δ)) Similar conditions appear in [19, 64]. In our case, we have q = 4, n = n1 + n2, sm = n1/2, σ2 = Θ(p), and (cid:107)Gu − Gv(cid:107)2 = 4(δ − 1)2p2n2. When n2 (cid:29) n1 log n, the condition requires p = Ω(1/n1), √ while our algorithm succeeds when p = Ω(log n1/ n1n2). In our application to planted CSP’s with (cid:1), this gives a polynomial factor improvement. odd k and n1 = 2n, n2 =(cid:0) 2n In fact, previous spectral approaches to planted CSP’s or random k-SAT refutation worked for even k using nk/2 constraints [40, 22, 32], while algorithms for odd k only worked for k = 3 and used considerably more complicated constructions and techniques [31, 39, 20]. In contrast to previous approaches, our algorithm unifies the algorithm for planted k-CSP’s for odd and even k, works for odd k > 3, and is particularly simple and fast. k−1 12 We now describe why previous approaches faced a spectral barrier for odd k, and how our algorithm surmounts it. The previous spectral algorithms for even k constructed a similar graph to the one in the reduction above: vertices are k/2-tuples of literals, and with edges between two tuples if their union appears as a k-clause. The distribution induced in this case is the stochastic block model. For odd k, such a reduction is not possible, and one might try a bipartite graph, with either the reduction described above, or with (cid:98)k/2(cid:99)-tuples and (cid:100)k/2(cid:101)-tuples (our analysis works for this reduction as well). However, with O(k/2) clauses, the spectral approach of computing the largest or second largest singular vector of the adjacency matrix does not work. Consider M from the distribution M (p). Let u be the n1 dimensional vector indexed as the rows of M whose entries are 1 if the corresponding vertex is in A1 and −1 otherwise. Define the n2 dimensional vector v analogously. The next propositions summarize properties of M . Proposition 1. E(M ) = (δ − 1)puvT . Proposition 2. Let M1 be the rank-1 approximation of M drawn from M (p). Then (cid:107)M1−E(M )(cid:107) ≤ 2(cid:107)M − E(M )(cid:107). Proof. Using the triangle inequality and then the optimality of M1, (cid:107)M1−E(M )(cid:107) ≤ (cid:107)M −E(M )(cid:107)+ (cid:107)M − M1(cid:107) ≤ 2(cid:107)M − E(M )(cid:107). √ √ The above propositions suffice to show high correlation between the top singular vector and the vector u when n2 = Θ(n1) and p = Ω(log n1/n1). This is because the norm of E(M ) is p n1n2; pn2), the norm of M − E(M ) for this range of p. Therefore the top singular this is higher than O( vector of M will be correlated with the top singular vector of E(M ). The latter is a rank-1 matrix with u as its left singular vector. However, when n2 (cid:29) n1 (eg. k odd) and p = O((n1n2)−1/2), the norm of the zero-mean matrix M − E(M ) is in fact much larger than the norm of E(M ). Letting x(i) be the vector of length n1 with a 1 in the ith coordinate and zeroes elsewhere, we see that (cid:107)M x(i)(cid:107)2 ≈ √ √ √ pn2, and so (cid:107)M−E(M )(cid:107) = Ω( pn2), while (cid:107) E(M )(cid:107) = O(p n1n2); the former is Ω((n2/n1)1/4) while the latter is O(1)). In other words, the top singular value of M is much larger than the value obtained by the vector corresponding to the planted assignment! The picture is in fact richer: the straightforward spectral approach succeeds for p (cid:29) n , the top left singular vector of the centered adjacency matrix is asymptotically uncorrelated with the planted vector [37]. In spite of this, one can exploit correlations to recover the planted vector below this threshold with our resampling algorithm, which in this case provably outperforms the spectral algorithm. , while for p (cid:28) n −2/3 1 −2/3 1 −1/3 2 −1/3 2 n n 6 Analysis of the subsampled power iteration algorithm We abuse notation and let A1, B1, A2, B2 denote the sets of coordinates of the corresponding vertex sets. Recall that u ∈ {±1}n1 is 1 on A1 and −1 on B1, and v ∈ {±1}n2 is 1 on A2, −1 on B2. and q = p/T . For convenience we denote d = 100/(δ − 1)2. We Set T = 10 log n2, p = assume WLOG that δ > 1. (δ−1)2√ n1n2 100T Recall that the sequence of matrices M1, . . . MT is formed by taking Gp and randomly assigning each edge to one of T different bipartite graphs, then forming the corresponding centered adjacency matrices. The marginal distribution of each Mi is a random n1×n2 matrix with independent entries such that the entry (i, j) takes value 1 − q with probability δq, −q otherwise if i ∈ A1, j ∈ A2 or i ∈ B1, j ∈ B2, and value 1 − q with probability (2 − δ)q, −q otherwise if i ∈ A1, j ∈ B2 or i ∈ B1, j ∈ A2. 13 The matrices are not independent, but are nearly independent. Consider the distribution of Mi conditioned on the matrices M1, . . . Mi−1, call this set of edges. Let Ei−1 be the set of all edges from Gp that are assigned to one of M1, M2, . . . Mi−1. Conditioned on M1, . . . Mi−1, the entries of Mi are independent. Mi is necessarily −q in every entry (u, v) with (u, v) ∈ Ei−1. All other entries take the values 1 − q with probabilities Pr[(u, v) ∈ Gi ∧ (u, v) /∈ G1, . . . Gi−1] Pr[(u, v) /∈ G1, . . . Gi−1] δq 1 − δp i−1 T = δq + O(pq) if u ∈ A1, v ∈ A2 or u ∈ B1, v ∈ B2 ρi := = and ρi := = Pr[(u, v) ∈ Gi ∧ (u, v) /∈ G1, . . . Gi−1] Pr[(u, v) /∈ G1, . . . Gi−1] (2 − δ)q 1 − (2 − δ)p i−1 T = (2 − δ)q + O(pq) if u ∈ A1, v ∈ B2 or u ∈ A2, v ∈ B1 and the value −q otherwise. The deviation from the fully independent setting is the O(pq) term. Let Hi−1 be the event that (1) Ei−1 ≤ 2n1n2p, (2) each vertex of V1 appears in Ei−1 at most 3n2p times, and (3) each vertex of V2 appears in Ei−1 at most 3T (δ − 1)−2 times. Hi−1 holds for all 1 ≤ i ≤ T whp from simple Chernoff bounds. We will condition on the set Ei−1 and the event Hi−1, to calculate the effect of multiplying a unit vector by Mi or M T i . The calculations are based on bounding two deviations from the simpler calculations involving the marginal distribution of Mi: the deviations from the probabilities ρi and ρi differing from δq and (2 − δ)q, and the deviations from the entries that are fixed to −q. We write g(n) = f (n) + O(h(n)) to denote two-sided error, i.e. f (n) − Ch(n) ≤ g(n) ≤ f (n) + Ch(n). Lemma 2. Let x and y be unit vectors of dimension n1 and n2 respectively. Then 1. E[u · (Miy)Ei−1, Hi−1] = (δ − 1)n1q(v · y)(1 + o(1)) + O(n1n2p2(cid:107)y(cid:107)∞) 2. var[u · (Miy)Ei−1, Hi−1] = n1q(1 + o(1)) + O(n1n2p2(cid:107)y(cid:107)2∞). 3. E[v · (M T 4. var[v · (M T 5. E[(cid:107)Miy(cid:107)2 i x(cid:107)2 6. E[(cid:107)M T 7. var[(cid:107)Miy(cid:107)2 i x(cid:107)2 8. var[(cid:107)M T Proof. If j ∈ A1, i x)Ei−1, Hi−1] = (δ − 1)n2q(u · x)(1 + o(1)) + O(n2p(cid:107)x(cid:107)∞) i x)Ei−1, Hi−1] = n2q(1 + o(1)) + O(n2p2(cid:107)x(cid:107)2∞). 2Ei−1, Hi−1] = n1q(1 + o(1)) + (δ − 1)2n1q2(v · y)2(1 + o(1)) + O(n1n2 2p4(cid:107)y(cid:107)2∞). 2Ei−1, Hi−1] = n2q(1 + o(1)) + (δ − 1)2n2q2(u · x)2(1 + o(1)) + O(n2p2(cid:107)x(cid:107)2∞). 2Ei−1, Hi−1] = O(n1q((cid:107)y(cid:107)1 · (cid:107)y(cid:107)3∞ + q3(cid:107)y(cid:107)4 2Ei−1, Hi−1] = O(n2n1q(cid:107)x(cid:107)4∞). (cid:88) 1 + q(cid:107)y(cid:107)2∞ · (cid:107)y(cid:107)2 (cid:88) 1 + q + q2(cid:107)y(cid:107)2 1)). E[(Miy)jEi−1, Hi−1] = − n2(cid:88) (cid:88) l=1 var(M y)j = qyl + ρiyl + ρiyl l∈A2 (j,l) /∈Ei−1 l∈B2 (j,l) /∈Ei−1 = (δ − 1)q(v · y)(1 + O(p)) + O(n2pq(cid:107)y(cid:107)∞) ρi(1 − ρi)y2 l + ρi(1 − ρi)y2 l (cid:88) l∈B2 (j,l) /∈Ei−1 l∈A2 (j,l) /∈Ei−1 14 and similarly for j ∈ B1. This gives E[u · (Miy)Ei−1, Hi−1] = (δ − 1)n1q(v · y)(1 + O(p)) + O(n1n2p2(cid:107)y(cid:107)∞) var[u · (Miy)Ei−1, Hi−1] = n1q(cid:107)y(cid:107)2 = n1q(cid:107)y(cid:107)2 Then if j ∈ A2, i x)jEi−1, Hi−1] = − n1(cid:88) (cid:88) i x)jEi−1, Hi−1] = l=1 E[(M T var[(M T l∈A1 (l,j) /∈Ei−1 2 + O(n1q2(cid:107)y(cid:107)2 2 + n1n2p2(cid:107)y(cid:107)2∞) 2(1 + O(p)) + O(n1n2p2(cid:107)y(cid:107)2∞) (cid:88) (cid:88) qxl + ρixl + l∈A1 (l,j) /∈Ei−1 = (δ − 1)q(u · x)(1 + O(p)) + O(p(cid:107)x(cid:107)∞) (l,j) /∈Ei−1 ρixl l∈B1 ρi(1 − ρi)x2 l + ρi(1 − ρi)x2 l (cid:88) l∈B1 (l,j) /∈Ei−1 and similarly for j ∈ B2. This gives E[v · (M T var[v · (M T i x)Ei−1, Hi−1] = (δ − 1)n2q(u · x)(1 + O(p)) + O(n2p(cid:107)x(cid:107)∞) i x)Ei−1, Hi−1] = n2q(cid:107)x(cid:107)2 2(1 + O(p)) + O(n2p2(cid:107)x(cid:107)2∞) Finally we have 2(1 + O(p)) + (δ − 1)2q2n1(v · y)2(1 + O(p)) + O(n1n2 2p4(cid:107)y(cid:107)2∞) E[(cid:107)Miy(cid:107)2 and var[(cid:107)Miy(cid:107)2 2Ei−1, Hi−1] = n1q(cid:107)y(cid:107)2 n1(cid:88) ≤ n1(cid:88) 2Ei−1, Hi−1] = i=1 var((M y)i)2) E((M y)i)4) i=1 = O(n1((cid:107)y(cid:107)3∞(cid:107)y(cid:107)1q + q4(cid:107)y(cid:107)4 = O(n1q((cid:107)y(cid:107)3∞(cid:107)y(cid:107)1 + q3(cid:107)y(cid:107)4 1 + q2(cid:107)y(cid:107)4 1 + q + q2(cid:107)y(cid:107)2 2 + q3(cid:107)y(cid:107)2 1(cid:107)y(cid:107)2 2 + q2(cid:107)y(cid:107)2∞(cid:107)y(cid:107)2 1)) 1 + q(cid:107)y(cid:107)2∞(cid:107)y(cid:107)2 1)) E[(cid:107)M T i x(cid:107)2 2Ei−1, Hi−1] = n2q(cid:107)x(cid:107)2 2(1 + O(p)) + (δ − 1)2q2n2(u · x)2(1 + O(p)) + O(n2p2(cid:107)x(cid:107)2∞) and and var[(cid:107)M T i x(cid:107)2 2Ei−1, Hi−1] = i=1 var((M T x)i)2) n2(cid:88) ≤ n2(cid:88) = n2(cid:107)x(cid:107)4∞ · O(cid:0)n1q + n2 = O(cid:0)n2n1q(cid:107)x(cid:107)4∞(cid:1) E((M T x)i)4) i=1 15 1q4(cid:1) 1q2 + n3 1q3 + n4 working with the matrix Mi. For cleaner notation in the rest of the proof we will write simply E[·] for E[·Ei−1, Hi−1] when i x(cid:107)2 are concentrated at each step; the Next we show the normalizing factors (cid:107)Miy(cid:107)2 and (cid:107)M T l∞ norms of the xi’s are bounded over all iterations, and the l∞ and l1 norms of the yi’s are bounded. This proposition is critical in ensuring steady progress of our potential functions. Lemma 3. With probability 1 − O , for all i = 1, . . . T , (cid:17) (cid:16) −1/6 T n 1 2 = (n1q(cid:107)yi(cid:107)2 2 = (n2q(cid:107)xi(cid:107)2 2 + (δ − 1)2n1q2(v · yi)2)(1 + o(1)) 2 + (δ − 1)2n2q2(u · xi)2)(1 + o(1)) 1. (cid:107)Miyi(cid:107)2 2. (cid:107)M T i xi(cid:107)2 −1/3 3. (cid:107)xi(cid:107)∞ ≤ n 1 −1/4 4. (cid:107)yi(cid:107)∞ ≤ n 2 √ 5. (cid:107)yi(cid:107)1 ≤ 4 n2n1q −1/12 1 n Proof. We begin by showing that(cid:12)(cid:12)(cid:12)(cid:12)(cid:26) j : yi j > (cid:114) 2qn1 n2 (cid:27)(cid:12)(cid:12)(cid:12)(cid:12) ≤ 3n2n1q. (1) We bound the number L of (1−q) entries in Mi−1. L is stochastically bounded by a Binom(n2n1, 2q) random variable, and so, √ Pr[L ≥ 3n2n1q] ≤ e−qn2n1 = e−Θ( n2n1). The remaining entries have value −q. If the jth row of Mi−1 has only −q entries, then (cid:112)n2q/2 j ≤ q(cid:107)xi−1(cid:107)1 (cid:114) 2qn1 yi ≤ n2 using (2) inductively. This proves (1). rows of Mi−1 with every entry −q, and ∆ the rest. Then To prove (5), partition the coordinates of yi into two sets ∆ and ∆, with ∆ corresponding to yi j + (cid:88) (cid:107)yi(cid:107)1 ≤(cid:88) (cid:114) 2qn1 (cid:113)∆ ≤(cid:112)2n2n1q +(cid:112)3n2n1q j∈∆ ∆ + yi j j∈∆ ≤ n2 √ qn2n1 ≤ 4 using part (2) inductively We show by induction that whp the following hold for i = 1, . . . T : 16 (cid:3) = n1q + (δ − 1)2n1q2(v · yi)2 + O(n1q2) (cid:3) = n2q + (δ − 1)2n2q2(u · xi)2 + O(n2q2) (cid:1)(cid:12)(cid:12) > α E(cid:0)(cid:107)Miyi(cid:107)2 2 (cid:1)(cid:3) (cid:19) (cid:33) (cid:17) 1 + q(cid:107)y(cid:107)2∞ · (cid:107)y(cid:107)2 1 + q + q2(cid:107)y(cid:107)2 1 2n2 n1q 1 + q2n1/2 n1q 2n1 + qn1/2 2 n 1 + n−1 + n−1 (cid:17) 1 + q4n2 −2/3 1 2 n5/6 1 + q + q3n2n1 −1/6 1 + n−1 1 + q2n2 2 = E(cid:0)(cid:107)Miyi(cid:107)2 2 = E(cid:0)(cid:107)M T 2 (cid:1) (1 + O(n (cid:1) (1 + O(n −1/8 1 i xi(cid:107)2 1. (cid:107)Miyi(cid:107)2 2. (cid:107)M T i xi(cid:107)2 3. (cid:107)xi(cid:107)∞ ≤ n 4. (cid:107)yi(cid:107)∞ ≤ n Conditional on yi and xi respectively, we have −1/3 1 −1/4 2 )) −1/12 1 −1/12 1 )) n 2 i xi(cid:107)2 Using Chebyshev and part (3), 2 2 2 E(cid:2)(cid:107)Miyi(cid:107)2 E(cid:2)(cid:107)M T Pr(cid:2)(cid:12)(cid:12)(cid:107)Miyi(cid:107)2 2 − E(cid:0)(cid:107)Miyi(cid:107)2 ≤ var((cid:107)Miyi(cid:107)2 (cid:18)(cid:107)y(cid:107)1 · (cid:107)y(cid:107)3∞ + q3(cid:107)y(cid:107)4 2) n2 1q2α2 (cid:32) = α−2 · O (cid:16) (cid:16) = α−2 · O n1/4 1 + q5n2 = α−2 · O = α−2 · O q−1/2n −1/2 1 n + n−1 −1/4 2 −1/4 2 −3/4 1 1 + n q1/2n n (cid:33) (cid:32) (cid:16) n = O = O −1/8 1 . 2 − E(cid:0)(cid:107)M T i xi(cid:107)2 (cid:19) 2) (cid:33) for α = n 1 n1/2 1 α2 −1/4 1 (cid:17) Pr(cid:2)(cid:12)(cid:12)(cid:107)M T i xi(cid:107)2 ≤ var((cid:107)M T (cid:18) n1(cid:107)xi(cid:107)4∞ n2 2q2α2 (cid:32) (cid:33) (cid:32) (cid:16) 1 n2n1/3 1 qα2 n1/6 1 n1/2 2 α2 −1/6 1 n2qα2 (cid:17) = O = O = O = O n Similarly, using Chebyshev and part (4), (cid:1)(cid:12)(cid:12) > α E(cid:0)(cid:107)M T i xi(cid:107)2 2 (cid:1)(cid:3) i xi(cid:107)2 2 for α = n −1/12 1 . To prove (3), note that (cid:107)xi+1(cid:107)∞ = max j∈[n1] (M T (cid:107)M T i yi)j i yi(cid:107)2 17 Using part (1), (cid:107)M T i yi(cid:107)2 ≥ √ that for every j = 1, . . . n1, n1q/2 with probability 1− O(n −1/4 1 ). Therefore it suffices to show To this end we will show that for any j, (M T i yi)j ≤ n (cid:34) Pr (M T i yi)j > √ −1/3 1 n1q 2 √ = −1/4 2 . dn1/6 1 n 2 (cid:35) √ dn1/6 1 n 2 −1/4 2 ≤ 1 n2 1 j ≤(cid:113) 2qn1 n2 (2) and ∆ the Again partition the coordinates of yi, with ∆ being the set of j so that yi rest. The contribution to (M T i yi)j from ∆ is bounded by (cid:114) 2qn1 n2 (n2q + mj) where mj is the number of 1 − q entries in the jth row of M T i . This number mj is dominated by a Binom(n2, 2q) random variable and so with probability 1 − exp(−n2q), mj ≤ 3n2q. Therefore, the contribution from ∆ is bounded by (n2q + 3n2q) (cid:114) 2qn1 n2 (cid:112) (cid:16) ≤ 5 = O n2n1q3 (n2n1)−1/4(cid:17) = o(n1/6 1 n −1/4 2 ). The contribution to (M T i yi)j from ∆ is bounded by (3n2n1q · q + mj · 1) n −1/4 2 −1/12 1 n where we have used (4) and (1)), and mj is the number of 1− q entries in the jth row of M T i whose column has index in ∆. mj is dominated by a Binom(3n2n1q, q) random variable, and so with probability 1 − O(exp(−Ω(3n2n113/12q2))), mj ≤ 3n2n1q2 · n1/12 in which case we have that the contribution from ∆ is bounded by 1 −1/4 2 −1/4 2 −1/12 1 n −1/12 n 1 −1/4 2 3n2n1q2n = 3d2n ≤ −1/4 √ 2 dn1/6 1 n 4 + 3n2n1q2n + 3d2n −1/4 2 proving inequality (2). (We remark that for this part, the loose bounds we have above suffice; it is the next part that controls parameter settings). To prove (4), set λ = n −1/4 2 n −1/12 1 . (cid:107)yi+1(cid:107)∞ = max j∈[n2] (M T (cid:107)M T i xi)j i xi(cid:107)2 18 We will show that for any j, (cid:34) Pr (cid:35) ≤ 1 n2 2 (3) √ λ dn1/4 2 2n1/4 1 We partition the coordinates of xi according to their magnitude, in bins B1, . . . BL, defined for (M T √ i xi)j ≤ λ n2q √ 2 dn1/4 λ = 2 2n1/4 1 (M T i xi)j > (cid:32) i : xi ∈ (cid:40) (cid:35)(cid:41) n −1/3 1 2l , −1/3 n 1 2l−1 Using part (2), (cid:107)M T i xi(cid:107)2 ≥ √ that for every j = 1, . . . n2, n2q/2 with probability 1− O(n −1/6 1 ). Therefore it suffices to show l < L as Bl = −1/3 with the interval for BL being [0, n 1 /2L−1]. We set L = (cid:100)log(n1/6 tl = Bl ≤ 22ln2/3 1 1 )(cid:101). Let using the fact that xi has unit 2-norm. We will bound the probability that bin l contributes more than βl towards the value of (M T i xi)j, with βl = √ dn1/4 λ 2 4n1/4 l2 1 If all bins fall within these bounds, then i xi)j ≤(cid:88) (M T l βl ≤ λ √ dn1/4 2 2n1/4 1 and therefore (cid:107)yi+1(cid:107)∞ ≤ n −1/4 2 −1/12 1 . n (cid:12)(cid:12)q(cid:80) (cid:12)(cid:12) ≤ q Let Zl ∼ Binom(tl, q). The contribution of bin l is bounded by the maximum of n r xi r n1 ≤ βl. To bound the first term, let √ −1/3 2l−1 Zl and 1 1 ml = βl2l−1n1/3 2 n1/12 dn1/4 8l2 √ = λ2l √ 1 = 2l d 8l2 19 and consider Pr [Zl ≥ ml] ≤ 2 ≤ 2 ≤ 2 (cid:33)√ d2l/(8l2) 1 d(n2n1)−1/2 e22ln2/3 √ (cid:33)√ d2l/(8l2) √ 8el22l dn1/6 1 n1/2 2 d log2(n1)n1/3 d2l/(8l2) (cid:33)√ d2l/(8l2) = 2 ≤ 2 qml (cid:19)ml ml ml (cid:19) (cid:18) tl (cid:18) etlq (cid:32) (cid:32) (cid:32) (cid:32) 8e √ √ 1 (cid:33)√ d/4 n1/2 2 d log2(n1) n1/6 2 d log2(n1))7 n7/3 2 ≤ 2 8e √ ≤ (8e √ for d/4 ≥ 7. Taking a union bound over all L bins, we have (3). Next we show that the vector yi reaches high correlation with v after T /2 steps. Recall the definitions Vi := v · yi and Ui := u · xi. Proposition 3. With probability 1 − O((ln n1)−2), one of the following happens: 1. For all i ∈ {T /2, . . . T}, 2. For all l ∈ {T /2, . . . T}, √ Vi ≥ (δ − 1) n2n1q 4 √ Vi ≤ − (δ − 1) n2n1q 4 First we need the following bounds on the progress of Ui: Proposition 4. The following bounds on Ui hold: 1. With probability at least 1/2, Ui ≥ 1/4 regardless of the value of Vi. 2. If 1/4 ≤ Ui ≤ ln n1, then with probability at least 1/2, Ui+1 ≥ 2Ui. 3. Pr [Ui+1 ≥ 2Ui] ≥ 1 − 1Ui2 for ln n1 ≤ Ui ≤ √ n1/2(cid:3) ≥ 1− O(1/ Pr(cid:2)Ui+1 ≤ −√ 4. If Ui ≥ √ 5. If Ui ≥ √ n1/4, then Pr(cid:2)Ui+1 ≥ √ n1/2(cid:3) ≥ 1 − O(1/ √ √ n1/2, then Vi+1 ≥ (δ−1) 4 √ with probability 1 − O(1/ n1/4. √ n1n2). n2n1q n1n2). n1n2). Similarly, if Ui ≤ −√ n1/4, then 20 1) and 2) ensure that Phase 1 succeeds, and that Ui attaints value ln n1 within ln n1 steps. 3) and 4) ensure steady progress in Phase 2 and that once Ui attains a high value, it maintains it. 5) connects the two potential functions by showing that Vi+1 is large if Ui is large. Proof of Proposition 4. 1. The variance of u · (Miyi) is ∼ n1q, and so a Berry-Esseen bound gives that with probability at least 1/2, u · Miyi ≥ √ n1q/4. Then using Lemma 3, we have that Miyi2 = i xi) is (δ − 1)n2q(u· xi), with variance n2q. Both are ω(1), and the expectation is at least (δ − 1)/4 times the variance in absolute value, and so whp, v · (M T i xi) = (δ − 1)n2q(u · xi)(1 + o(1)). Using Lemma 3 again, we have that whp, √ Vi+1 = (δ − 1) n1q(1 + o(1)) whp, and so with probability at least 1/2, Ui = u · xi ≥ 1/4. 2. We prove this in two steps. The expectation of v · (M T n2q(u · xi). √ Conditioning on this value, we have E[u · (Mi+1yi+1)] = (δ − 1)2√ n2qn1q(u · xi)(1 + o(1)) and its variance is n1q. With probability 1/2 we have u· (Mi+1yi+1) ≥ (δ− 1)2√ n2qn1q(u· xi)(1− o(1)), and then normalizing with Lemma 3 we have Ui+1 ≥ (δ − 1)2√ n2n1qUi, which from our choice of q, is at least 2Ui. i xi) = (δ − 1)n2q(u· xi)(1 + o(1)) with 3. Similar to the above. Apply Chebyshev so that v · (M T √ probability 1 − o(1), and normalize so that v · yi+1 = (δ − 1) n2q(u · xi)(1 + o(1)) whp. Now the expectation of u· (Mi+1yi+1) is (δ− 1)2√ n2qn1q(u· xi)(1 + o(1)) with variance n1q, and so applying Pr[u · (Mi+1yi+1) < (δ − 1)2√ n2qn1qu · xi/2] ≤ Chebyshev, we have n1q (δ − 1)4n2n2 1q3(u · xi)2/4 4 (δ − 1)4n2n1q2(u · xi)2 25(u · xi)2 1 = ≤ Then normalizing, and using Lemma 2 and part (2) above, we get Ui+1 ≥ n2qn1qUi 2(cid:112)n1q + (δ − 1)2n1q2(Vi+1)2 (δ − 1)2√ 2(cid:112)n1q + (δ − 1)4n2n1q3(Ui)2 (δ − 1)2√ n2qn1qUi ≥ ≥ 2Ui. 4,5. Chebyshev again. Proof of Proposition 3. In the first phase, we show that it takes ln n1 iterations for Ui to reach n1/2. Finally, Ui will remain above √ ln n1 whp. Next, it takes a further ln n1 iterations to reach n1/2 whp for an additional 2 ln n1 iterations. Step 1: We call a step from Ui to Ui+1 ‘good’ if Ui+1 ≥ 2Ui, or if Ui+1 ≥ 1/4 following a ‘bad’ step. A run of ln ln n1 good steps must end with Ui ≥ ln n1. As long as Ui < ln n1, the proposition above shows that the probability of a good step is at least 1/2, so in ln n1 steps, with probability 1 − o(1) we will either have such a run of ln ln n1 good steps or reach ln n1 even earlier. √ 21 Step 2: Once we have Ui ≥ ln n1, the value will double whp in successive steps until Ui ≥ n1/4. This takes at most ln n1 steps. The total error probability, by part 3) of Proposition 4 is √ a geometric series that sums to O(1/(ln n1)2). n1/4 then for the next 2 ln n1 steps, Ui+1, Ui+2, . . . , we have Ui ≥ √ Step 3: Once Ui ≥ √ n1/2, √ with total error probability O(T / n1n2). Step 4: Finally we use part 5) of Proposition 4 to conclude that yi has high correlation with v. We now use Proposition 3 to prove the main theorem. Proof of Theorem 1. Now that we know whp yT /2, yT /2+1, . . . all have large correlation with v, we show that taking the majority vote for each coordinate of zT /2+1, zT /2+2, . . . recovers ±u whp. . Assume j ∈ A1, then we have, √ Take the first case from Proposition 3, with Vi ≥ (δ−1) 4 n2n1q conditioned on the value of Vi Pr[zi+1 j = 1] = Pr[xj > 0] ≥ 1 − ≥ 1 − var((M yi)j) (E((M yi)j))2 (δ − 1)4q3n1n2 1002 ≥ .9 = 1 − 32 32q 0. Similarly, for j ∈ B1, we have(cid:80)T Now an application of Azuma’s inequality shows that with probability at least 1−o(n−2 i=T /2 zi j > 1 ), and so whp the majority vote recovers u exactly. The same argument shows that if the second case of Proposition 3 holds, then we find −u whp. j > 0 with probability at least 1− o(n−2 i=T /2 zi 1 ),(cid:80)T References [1] Emmanuel Abbe, Afonso S Bandeira, and Georgina Hall. Exact recovery in the stochastic block model. arXiv preprint arXiv:1405.3267, 2014. [2] Dimitris Achlioptas, Haixia Jia, and Cristopher Moore. Hiding satisfying assignments: Two are better than one. J. Artif. Intell. Res.(JAIR), 24:623–639, 2005. [3] Dimitris Achlioptas and Frank McSherry. Fast computation of low rank matrix approximations. In Proceedings of the thirty-third annual ACM symposium on Theory of computing, pages 611–618. ACM, 2001. [4] Michael Alekhnovich. More on average case vs approximation complexity. Computational Complexity, 20(4):755–786, 2011. [5] Noga Alon and Nabil Kahale. A spectral technique for coloring random 3-colorable graphs. SIAM Journal on Computing, 26(6):1733–1748, 1997. 22 [6] Benny Applebaum. Pseudorandom generators with long stretch and low locality from random local one-way functions. In Proceedings of the 44th symposium on Theory of Computing, pages 805–816. ACM, 2012. [7] Benny Applebaum, Boaz Barak, and Avi Wigderson. Public-key cryptography from different assumptions. In Proceedings of the 42nd ACM symposium on Theory of computing, pages 171–180. ACM, 2010. [8] Boaz Barak. Truth vs proof: The unique games conjecture and Feige’s hypothesis. http://windowsontheory.org/2012/07/31/ truth-vs-proof-the-unique-games-conjecture-and-feiges-hypothesis/, July 2012. [9] Wolfgang Barthel, Alexander K Hartmann, Michele Leone, Federico Ricci-Tersenghi, Martin Weigt, and Riccardo Zecchina. Hiding solutions in random satisfiability problems: A statistical mechanics approach. Physical review letters, 88(18):188701, 2002. [10] Quentin Berthet. Optimal testing for planted satisfiability problems. arXiv preprint arXiv:1401.2205, 2014. [11] Quentin Berthet and Philippe Rigollet. Complexity theoretic lower bounds for sparse principal component detection. In COLT, pages 1046–1066, 2013. [12] Avrim Blum. Learning boolean functions in an infinite attribute space. Machine Learning, 9:373–386, 1992. [13] Avrim Blum and Joel Spencer. Coloring random and semi-random k-colorable graphs. Journal of Algorithms, 19(2):204–234, 1995. [14] Andrej Bogdanov and Youming Qiao. On the security of goldreich’s one-way function. In Approximation, Randomization, and Combinatorial Optimization. Algorithms and Techniques, pages 392–405. Springer, 2009. [15] Ravi B Boppana. Eigenvalues and graph bisection: An average-case analysis. In Foundations of Computer Science, 1987., 28th Annual Symposium on, pages 280–285. IEEE, 1987. [16] Julia Bottcher. Coloring sparse random k-colorable graphs in polynomial expected time. Mathematical Foundations of Computer Science 2005, page 156, 2005. [17] Moses Charikar and Anthony Wirth. Maximizing quadratic programs: extending grothendieck’s inequality. In Foundations of Computer Science, 2004. Proceedings. 45th Annual IEEE Symposium on, pages 54–60. IEEE, 2004. [18] Amin Coja-Oghlan. A spectral heuristic for bisecting random graphs. Random Structures & Algorithms, 29:3:351–398, 2006. [19] Amin Coja-Oghlan. Graph partitioning via adaptive spectral techniques. Combinatorics, Probability & Computing, 19(2):227, 2010. [20] Amin Coja-Oghlan, Colin Cooper, and Alan Frieze. An efficient sparse regularity concept. SIAM Journal on Discrete Mathematics, 23(4):2000–2034, 2010. [21] Amin Coja-Oghlan, Andreas Goerdt, and Andr´e Lanka. Strong refutation heuristics for random k-sat. In Approximation, Randomization, and Combinatorial Optimization. Algorithms and Techniques, pages 310–321. Springer, 2004. 23 [22] Amin Coja-Oghlan, Andreas Goerdt, Andr´e Lanka, and Frank Schadlich. Certifying unsatisfiability of random 2k-sat formulas using approximation techniques. In Fundamentals of Computation Theory, pages 15–26. Springer, 2003. [23] Amin Coja-Oghlan, Andreas Goerdt, Andr´e Lanka, and Frank Schadlich. Techniques from combinatorial approximation algorithms yield efficient algorithms for random 2k-sat. Theoretical Computer Science, 329(1):1–45, 2004. [24] Amin Coja-Oghlan and Andr´e Lanka. Finding planted partitions in random graphs with general degree distributions. SIAM Journal on Discrete Mathematics, 23(4):1682–1714, 2009. [25] Anne Condon and Richard M Karp. Algorithms for graph partitioning on the planted partition model. Random Structures & Algorithms, 18(2):116–140, 2001. [26] Amit Daniely, Nati Linial, and Shai Shalev-Shwartz. More data speeds up training time in learning halfspaces over sparse vectors. In NIPS, pages 145–153, 2013. [27] Amit Daniely and Shai Shalev-Shwartz. Complexity theoretic limitations on learning dnf’s. CoRR, abs/1404.3378, 2014. [28] S. Decatur, O. Goldreich, and D. Ron. Computational sample complexity. SIAM Journal on Computing, 29(3):854–879, 1999. [29] Aurelien Decelle, Florent Krzakala, Cristopher Moore, and Lenka Zdeborov´a. Asymptotic analysis of the stochastic block model for modular networks and its algorithmic applications. Physical Review E, 84(6):066106, 2011. [30] Martin E. Dyer and Alan M. Frieze. The solution of some random np-hard problems in polynomial expected time. Journal of Algorithms, 10(4):451–489, 1989. [31] Uriel Feige and Eran Ofek. Easily refutable subformulas of large random 3cnf formulas. In Automata, languages and programming, pages 519–530. Springer, 2004. [32] Uriel Feige and Eran Ofek. Spectral techniques applied to sparse random graphs. Random Structures & Algorithms, 27(2):251–275, 2005. [33] V. Feldman. Attribute efficient and non-adaptive learning of parities and DNF expressions. Journal of Machine Learning Research, (8):1431–1460, 2007. [34] Vitaly Feldman, Elena Grigorescu, Lev Reyzin, Santosh Vempala, and Ying Xiao. Statistical algorithms and a lower bound for planted clique. In Proceedings of the 45th annual ACM symposium on Symposium on theory of computing, pages 655–664. ACM, 2013. [35] Vitaly Feldman, Will Perkins, and Santosh Vempala. On the complexity of random satisfiability problems with planted solutions. arXiv preprint arXiv:1311.4821, 2013. [36] Abraham Flaxman. A spectral technique for random satisfiable 3cnf formulas. In Proceedings of the fourteenth annual ACM-SIAM symposium on Discrete algorithms, pages 357–363. Society for Industrial and Applied Mathematics, 2003. [37] Laura Florescu and Will Perkins. Spectral thresholds in the bipartite stochastic block model. preprint, 2015. 24 [38] Michael L Fredman, J´anos Koml´os, and Endre Szemer´edi. Storing a sparse table with 0 (1) worst case access time. Journal of the ACM (JACM), 31(3):538–544, 1984. [39] Joel Friedman, Andreas Goerdt, and Michael Krivelevich. Recognizing more unsatisfiable random k-sat instances efficiently. SIAM Journal on Computing, 35(2):408–430, 2005. [40] Andreas Goerdt and Michael Krivelevich. Efficient recognition of random unsatisfiable k-sat instances by spectral methods. In STACS 2001, pages 294–304. Springer, 2001. [41] Andreas Goerdt and Andr´e Lanka. Recognizing more random unsatisfiable 3-sat instances efficiently. Electronic Notes in Discrete Mathematics, 16:21–46, 2003. [42] Oded Goldreich. Candidate one-way functions based on expander graphs. IACR Cryptology ePrint Archive, 2000:63, 2000. [43] Paul W Holland, Kathryn Blackmond Laskey, and Samuel Leinhardt. Stochastic blockmodels: First steps. Social networks, 5(2):109–137, 1983. [44] Yuval Ishai, Eyal Kushilevitz, Rafail Ostrovsky, and Amit Sahai. Cryptography with constant computational overhead. In Proceedings of the 40th annual ACM symposium on Theory of computing, pages 433–442. ACM, 2008. [45] Mark Jerrum and Gregory B Sorkin. The metropolis algorithm for graph bisection. Discrete Applied Mathematics, 82(1):155–175, 1998. [46] Haixia Jia, Cristopher Moore, and Doug Strain. Generating hard satisfiable formulas by hiding solutions deceptively. In PROCEEDINGS OF THE NATIONAL CONFERENCE ON ARTIFICIAL INTELLIGENCE, volume 20, page 384. Menlo Park, CA; Cambridge, MA; London; AAAI Press; MIT Press; 1999, 2005. [47] Michael Kearns. Efficient noise-tolerant learning from statistical queries. Journal of the ACM (JACM), 45(6):983–1006, 1998. [48] Satish Babu Korada, Andrea Montanari, and Sewoong Oh. Gossip pca. In Proceedings of the ACM SIGMETRICS joint international conference on Measurement and modeling of computer systems, pages 209–220. ACM, 2011. [49] Michael Krivelevich and Dan Vilenchik. Solving random satisfiable 3cnf formulas in expected polynomial time. In Proceedings of the seventeenth annual ACM-SIAM symposium on Discrete algorithm, pages 454–463. ACM, 2006. [50] Florent Krzakala, Marc M´ezard, and Lenka Zdeborov´a. Reweighted belief propagation and quiet planting for random k-sat. Journal on Satisfiability, Boolean Modeling and Computation, 8:149–171, 2014. [51] Florent Krzakala, Cristopher Moore, Elchanan Mossel, Joe Neeman, Allan Sly, Lenka Zdeborov´a, and Pan Zhang. Spectral redemption in clustering sparse networks. Proceedings of the National Academy of Sciences, 110(52):20935–20940, 2013. [52] Florent Krzakala and Lenka Zdeborov´a. Hiding quiet solutions in random constraint satisfaction problems. Physical review letters, 102(23):238701, 2009. [53] Frank Lin and William W Cohen. Power iteration clustering. In Proceedings of the 27th International Conference on Machine Learning (ICML-10), pages 655–662, 2010. 25 [54] Laurent Massouli´e. Community detection thresholds and the weak ramanujan property. In STOC 2014: 46th Annual Symposium on the Theory of Computing, pages 1–10, 2014. [55] Frank McSherry. Spectral partitioning of random graphs. In Foundations of Computer Science, 2001. Proceedings. 42nd IEEE Symposium on, pages 529–537. IEEE, 2001. [56] Elchanan Mossel, Joe Neeman, and Allan Sly. A proof of the block model threshold conjecture. arXiv preprint arXiv:1311.4115, 2013. [57] Elchanan Mossel, Joe Neeman, and Allan Sly. Consistency thresholds for binary symmetric block models. arXiv preprint arXiv:1407.1591, 2014. [58] Elchanan Mossel, Joe Neeman, and Allan Sly. Reconstruction and estimation in the planted partition model. Probability Theory and Related Fields, pages 1–31, 2014. [59] Raj Rao Nadakuditi and Mark EJ Newman. Graph spectra and the detectability of community structure in networks. Physical review letters, 108(18):188701, 2012. [60] Ryan O’Donnell and David Witmer. Goldreich’s prg: Evidence for near-optimal polynomial stretch. In Conference on Computational Complexity, 2014. [61] R. Servedio. Computational sample complexity and attribute-efficient learning. Journal of Computer and System Sciences, 60(1):161–178, 2000. [62] Shai Shalev-Shwartz, Ohad Shamir, and Eran Tromer. Using more data to speed-up training time. In AISTATS, pages 1019–1027, 2012. [63] Luca Trevisan. More ways to prove unsatisfiability of random k-sat. http://lucatrevisan.wordpress.com/2007/08/21/ more-ways-to-prove-unsatisfiability-of-random-k-sat/, August 2007. [64] Van Vu. A simple svd algorithm for finding hidden partitions. arXiv preprint arXiv:1404.3918, 2014. [65] Hanson Zhou and David Woodruff. Clustering via matrix powering. In Proceedings of the twenty-third ACM SIGMOD-SIGACT-SIGART symposium on Principles of database systems, pages 136–142. ACM, 2004. 26
1507.03648
1
1507
2015-07-13T22:54:20
Deadline-aware Power Management in Data Centers
[ "cs.DS", "cs.DC", "cs.PF" ]
We study the dynamic power optimization problem in data centers. We formulate and solve the following offline problem: in which slot which server has to be assigned to which job; and in which slot which server has to be switched ON or OFF so that the total power is optimal for some time horizon. We show that the offline problem is a new version of generalized assignment problem including new constraints issuing from deadline characteristics of jobs and difference of activation energy of servers. We propose an online algorithm that solves the problem heuristically and compare it to randomized routing.
cs.DS
cs
Deadline-aware Power Management in Data Centers† Cengis Hasana and Zygmunt J. Haasb aThe University of Edinburgh, School of Informatics bCornell University, School of Electrical and Computer Engineering Abstract We study the dynamic power optimization problem in data centers. We formulate and solve the following offline problem: in which slot which server has to be as- signed to which job; and in which slot which server has to be switched ON or OFF so that the total power is optimal for some time horizon. We show that the offline problem is a new version of generalized assignment problem including new con- straints issuing from deadline characteristics of jobs and difference of activation energy of servers. We propose an online algorithm that solves the problem heu- ristically and compare it with randomized routing. 1. Introduction Energy consumption is one of the most important practical and timely problem associated with data centers for cloud computing. The urgency of this problem has been exposed by both, the governmental agencies and the industry. While policies that consider the physical design of the data centers have been studied in the technical literature rather thoroughly, the operational characteristics of the data centers (e.g., the required performance of the executed applications, such as the type of services and the applications being supported, their QoS requirements, associated background server maintenance processes, etc.) have rarely been ac- † This work was supported by NSF Grant EAGER: Job-Centered Power Management Policies for Data Centers. The first author was a postdoctoral research associate at Cornell University when this work was carried out. Email addresses: [email protected](Cengis Hasan) [email protected](Zygmunt J. Haas) 1 counted for. In particular, there is a need to investigate the implications of exploit- ing the operational characteristics of the data centers in the context of power man- agement policies, as those could lead to potentially significant energy savings and operational cost reduction of a computer cloud. In this work, we study the effect of the deadline characteristics of the jobs (appli- cations) and their requirements on the design of the data centers’ power manage- ment policies. A particular interest of our study is to solve the dynamic power optimization problem. Assuming a time interval, we seek to minimize the total energy consumed during this time interval. We solve the offline problem in which we know the arrival times of jobs and their service demands and deadlines. Actu- ally, the offline problem is the following one: consider a discrete time horizon:  ={1,…,} where an element in  • • • • • • • shows a slot, a server can be only in ON or OFF state, a server can serve only one or none job during a slot, a job might be served by only one or none server during a slot, a job has to be served within its deadline constraint, i.e. the job’s service de- mand has to be handled within its deadline, a server needs ON consecutive slots (i.e. the setup time) and ON energy per a server consumes slot energy per slot when it serves a job. slot in order to be ON when it is in OFF state, Based on these information, we calculate the minimal total energy in the follow- ing way: find: in which slot which server has to be assigned to which job; and in which slot which server has to be switched ON or OFF Thus, the offline solution becomes a reference for evaluating an online algorithm solving the corresponding problem. Note that an online algorithm can find a so- lution for only present time. We propose an online algorithm which aims to min- imize the total cost per slot. The cost is composed of the energy cost per slot and 2 a weighted sum of deadline and service demand of the job. We calculate every possible assignment of servers to jobs present in the system based on the above cost definition. Then, we need to find which assignment of servers to jobs mini- mizes the total cost per slot. We show that this problem is exactly the assignment problem which is solvable in polynomial time using the well-known Hungarian algorithm. In case of a server is not assigned to a job, we keep this server ON during a portion of time. This is a similar approach studied in [1]. 1.1. Related Work High-level approaches aiming to reduce data center power consumption could be classified in four way [1]: power-proportionality which is to find ways in order to guarantee that servers consuming power in proportion to their utilization [2], [3], [4]; energy-efficient server design which is to establish the proper server architec- ture for a given workload [5], [6], [7]; dynamic server provisioning which is keep- ing servers on and off at the right times [8], [9]; consolidation and virtualization which is reducing power consumption by resource sharing [10], [11], [12]. The dynamic version of the generalized assignment problem is directly related to the offline problem that we study in this paper. Actually, our problem could be considered as a version of the dynamic generalized assignment problem which includes new additional constraints. In [13], the authors firstly put forward the dynamic generalized assignment problem, and they formulate the continuous- time optimal control model in order to develop an efficient time-decomposition procedure for solving the problem. The discrete time version is studied in [14] by associating a starting time and a finishing time with each task. The authors also use column generation algorithm to compute lower bounds. 2. The Offline Problem 2.1. Problem Description Let us represent by  ={∅,1,…,} the servers,  ={∅,1,…,} the jobs served starting from their arrival slot  up to the time characterized by the dead- line +Δ where Δ denotes the deadline of job . We denote by  = {,…, +Δ} the maximal lifetime of a job within the system. Consider  = max∈  +Δ, then the total time horizon is  ={1,…,}. We would like to calculate 3 the minimal total energy consumption starting from slot 1 until . second The duration of a slot is . We assume that the deadline of a job can be given by Δ = where  is an integer. The service demand of any job  is denoted by  in terms of processor cycles. Each server is characterized by its speed  = ,∀∈ . So, the total demand that a server can handle during a slot processor cycle is calculated by . If the initial service demand of job  is  and server  is assigned to job , then at the end of the slot the service demand of job  reduces to −. We assume that a server needs ON slots in order to switch ON when it is switched OFF. A server consumes slot energy per a slot. If the server is in OFF state and is activated to ON then ON energy per slot is needed for it. Let us define the following binary integer variable, =1, 0, if server  is assigned to job  in slot  otherwise. other hand, we also take into consideration that a server is also possible not to be Note that if ∅ =1, it means that no server is assigned to job  in slot . On the assigned to any job in a slot but it is still ON in that slot, i.e. ∅ =1. Based on this definition, we assume that any server  in slot  is in OFF state if the following is true: Besides, we define a new variable  which has the following meaning: =0, ∀∈,∀∈. ࢣ ∈ if server  is OFF and switched ON in slot  otherwise. =1, 0, Note that if =1 then, it is always ∅ =1, otherwise it is not true, i.e. if  = 0 then, ∅ =0 or 1. This constraint can be given by ∀∈,∀∈. ≤∅, (4) (1) (2) (3) Thus, the minimal total energy can be calculated by min, 0ࢣࢣ∅ ∈ ∈ ∈\∅ +slot ࢣ ࢣࢣ ∈ +(ON−slot) ࢣ ࢣ ∈ ∈ ∈\∅ Constraints. (5) 4 As we mentioned above, if a server is in OFF state in slot −1, and it is switched ON in slot , then it will spend ON consecutive slots to setup. Using the above definitions, in order to satisfy that all jobs are fully served, we need the following constraints: ≥, ∀ ∈\∅ ≤Δ , ∀ ∈\∅ ࢣ ࢣ ∈ ∈ ࢣ ࢣ ∈ ∈ Δ slot, job  has to be handled. Note that ∅ =0 mean- (6) (7) which means that until the ing that if a job is not assigned to a particular server in a slot, its service demand will not be processed during that slot. The constraint allowing at most one job can be assigned to a server in a slot can be given by ࢣ ∈ ≤1, ∀∈,∀∈. (8) We also need to guarantee that only one or none server can be assigned to a job during a slot (i.e. it is not possible to assign more than one server to a job): ࢣ ∈ =1, ∀ ∈,∀∈. (9) We also set ∅∅ =0,∀∈ . Moreover, whenever an OFF server is switched ON in slot , then the server cannot be assigned to any job during consecutive ON slots. If a server is OFF and we would like to switch it ON in slot , then the following constraints must hold: ⎩⎪⎪⎨⎪⎪⎧if ࢣ ߰(−1) ߰∈ otherwise, +ON−1 =0 and ∅=1, ࢣ ߰ ߰= +ON−1 ࢣ ߰ ߰= ≥ON ≥0. (10) Actually, this if-then constraint can be transferred into the following: +ON−1 ࢣ ߰ ߰= ,∀∈\∅,∀∈. We denote as =∅1−∑  the variable which takes value 1 if server  is switched OFF in slot −1 and it is switched ON in slot , otherwise the ≥ON∅1− ࢣ ߰(−1) ߰∈ ߰(−1) ߰∈ (11) 5 variable is equal to 0. We are able to transform the multiplication in variable  as following:  ≤∅, ∀∈\∅,∀∈  ≤1− ࢣ ߰(−1) , ∀∈\∅,∀∈ , ∀∈\∅,∀∈.  ≥∅− ࢣ ߰(−1) ߰∈ ߰∈ Note that the following must hold always ONࢣ ∈  ≤, , ∀∈\∅ =ࢣ ∈ ∀∈\∅,∀∈. (12) (13) (14) If a server is OFF, it is forbidden to switch it ON last ON consecutive slots of last arriving job: if ࢣ ߰(−ON−1) ߰∈ −1 =0, ࢣ ߰ ߰=−ON ≤0 which can be transformed to the following form: −1 ࢣ ߰ ߰=−ON ≤ON ࢣ ߰(−ON−1) ߰∈ ,∀∈\∅. (15) (16) On the other hand, no job can be assigned to an OFF server. The constraint can be given by if ࢣ ߰(−1) ߰∈ =0, ࢣ ߰ ߰∈\∅ ≤0 which can be simplified to ࢣ ߰ ߰∈\∅ ≤ ࢣ ߰(−1) ߰∈ . 2.2. The Binary Integer Program (17) (18) The binary integer program based on the above definitions can be collected as following: 6 +(ON−slot) ࢣ ࢣ ∈ ∈\∅ ∈ , ∀∈\∅,∀∈, , ∀∈\∅,∀∈, ,∀∈\∅, , ∀∈\∅,∀∈, ∈\∅ min, slot ࢣ ࢣࢣ ∈ ≤Δ , ∀ ∈\∅, ≥, ∀ ∈\∅, ∀∈\∅,∀∈, ࢣ ࢣ ∈ ∈ ࢣ ࢣ ∈ ∈ ≤1, ࢣ ∈ ≤ ࢣ ߰(−1) ࢣ ߰ ߰∈ ߰∈\∅  ≤∅, ∀∈\∅,∀∈, +ON−1 ࢣ ߰ ≥ON, ∀∈\∅,∀∈, ߰=  ≤, ∀∈\∅,∀∈,  ≤∅, ∀∈\∅,∀∈,  ≤1− ࢣ ߰(−1)  ≥∅− ࢣ ߰(−1) ߰∈ −1 ≤ON ࢣ ߰(−ON−1) ࢣ ߰ ߰=−ON ࢣ ∀ ∈\∅,∀∈, =1, ∈ ∀∈\∅. , =ࢣ ONࢣ ∈ ∈ ߰∈ ߰∈  subject to (19) (20) (21) (22) (23) (24) (25) (26) (27) (28) (29) (30) (31) 2.3. Linear Programming Relaxation The optimization that we formulated is a binary integer problem. Since its con- straint matrix is not totally unimodular, it is NP-hard to calculate the optimal value 7 in such a case. The linear programming relaxation of a binary integer program is the problem that arises by replacing the constraint that each variable must be 0 or 1 by a weaker constraint, that each variable belongs to the interval [0,1]. That is, for each constraint of the form ∈{0,1} of the original integer program, one instead uses a pair of linear constraints 0≤≤1. The resulting relaxation is a linear program. 3. Online Heuristics 3.1. Assumptions and Cost Function We consider that the algorithm needs only the information of the current slot  and the previous slot −1. We denote by () the jobs in the system in slot , the available servers ON(), the unavailable servers OFF(), the servers being in the activation process A() in slot . Let us also define the jobs-to-server ratio per slot as following: () ON()+A(). Moreover, JA is the number of jobs to be accumulated in order that we can acti- (32) vate an OFF server. We assume that 1. if server  is not assigned to a job in slot , then the algorithm starts the waiting time W(,) for server ; 2. if W(,)≥wait, then the algorithm switches server  from ON to OFF where wait is the maximal wait time; ON()+A()≥JA, then activate an OFF server; () Let () represent total delay of job  until slot  since its first occurrence in the system. Let us consider the following cost of assigning server  to job  in slot : 3. if =slot +exp(−1)−Δ  (−1)−+ (33) Figure 1. exp (−(cid:10))−(cid:12)   increases monotonically with respect to the time for different deadlines. The -axis is logarithmic. 8 where by (−1)−Δ , we normalize the difference by slot length  letting to char- acterize the cost of delay. In Figure 1, we depict the change of exp(−1)−Δ    with respect to the time. On the other hand, (−1)−+ is a monotonically decreasing function job  in slot  can thus be given by with respect to the increasing values of slots. The cost of not assigning a server to ∅=exp(−1)−Δ  (−1). If no job is assigned to server  in slot , the cost is only the energy consumed (34) (35) during a slot ∅=slot. We set ∅∅ =0 if no server is assigned to no job. 3.2. Total Cost Minimization per Slot Consider that we would like to calculate the total minimal cost per slot based on the above cost definitions. We below show that this problem is exactly the classi- cal assignment problem being solvable in polynomial time. Denote as the number that a server may not be assigned to a job as well as no server can be assigned to of ON servers and the jobs in slot  as ON() and (), respectively. Recall a job. Consider some “virtual servers” of which number is equal to () in ad- dition to ON servers in slot . We represent by ∅, the th virtual server. Besides, consider some ON() “virtual jobs” in addition to the jobs in slot . We show 9 by ∅, the th virtual job. We define those virtual elements that will substitute the empty set in formulations. Thus, we have totally ON()+() both ON serv- ers and jobs in slot . Below, an example is given. Assume there are 2 servers and 4 jobs in slot . The cost matrix can be represented 3.3. An Explanatory Example as following: Servers Jobs 1 4 3 2 ∅1 ∅2 1 11 12 13 14 1∅1 1∅2 2 21 22 23 24 2∅1 2∅2 ∅1 ∅11 ∅12 ∅13 ∅14 ∅1∅1 ∅1∅2 ∅2 ∅21 ∅22 ∅23 ∅24 ∅2∅1 ∅2∅2 ∅3 ∅31 ∅32 ∅33 ∅34 ∅3∅1 ∅3∅2 ∅4 ∅41 ∅42 ∅43 ∅44 ∅4∅1 ∅4∅2 lowing binary integer program: subject to Note that ∅=∅, ∀ ∈{1,2,…,ON()} as well as ∅=∅, ∀∈ {1,2,…,()}. It is obvious that ∅∅ =∅∅ =0, ∀∈{1,2,…,()} and ∀ ∈{1,2,…,ON()}. The total minimal cost in slot  can be calculated by fol- ࢣ  min ࢣ ∈()∪ ∈ON()∪ {∅1,…,∅()} =1, ࢣ  ∈()∪ ∅1,…,∅ON() =1, ࢣ  ∈ON()∪ {∅1,…,∅()} ∈{0,1}, ∀∈ON()∪∅1,…,∅(), ∀ ∈()∪∅1,…,∅ON(), ∀∈ON()∪∅1,…,∅(), ∀ ∈()∪∅1,…,∅ON(). ∅1,…,∅ON() (36) The formulation corresponds exactly to the classical assignment problem. The first constraint requires that every server is assigned to exactly one job, and the second constraint requires that every job is assigned to exactly one server. It is known that there is always an optimal solution taking integer values even ≥ 0. This is because the constraint matrix is totally unimodular. The optimal solution 10 of any assignment problem can be found using well known Hungarian algorithm. Therefore, we utilize this algorithm in calculation of optimal assignments in each slot. 4. Online Algorithm Let us introduce the variables and sets used in the algorithm: - (): set of jobs not served fully in slot  - ON(): set of available servers in slot  - OFF(): set of unavailable servers in slot  - A(): set of servers in activation process in slot  - - - - - - A(,): time spent until slot  since activation of server  W(,): waiting time until slot  of server  (): vector of time spent until slot  since activation W(): vector waiting time until slot  W(,): the flag bit showing if server  should be in waiting state in slot  W(): vector of the flag bits (): total delay of job  until slot  since its first occurrence in the system - (): remained demand of job  in slot  - (): assignment matrix in slot  We show by (⋅ ) a set or variable evolved within the algorithm in step . - The algorithm works step by step as following: Algorithm 1: Online Algorithm 2. Output arguments: Input arguments: ⎩⎪⎨⎪⎧(),(−1),ON(−1),OFF(−1),A(−1), ⎭⎪⎬⎪⎫ A(−1),W(−1),W(−1) (),(),(−1),(−1)∀∈() ⎩⎪⎨⎪⎧(),ON(),OFF(),A(), (+1),(+1)∀∈()⎭⎪⎬⎪⎫ A(),W(),W() set ON()=ON(−1), OFF()=OFF(−1), A()=A(−1), A()=A(−1), W()=W(−1), W()=W(−1) forall ∈A(), if A(,)≥setup a) Add server  to ON(), i.e. ON( 4)=ON()∪ 1. 3. 4. 11 5. 6. 9. endfor if endfor endif endif b) Remove server  from A(), i.e. A( 4)=A()\ c) Remove A(,) from A(), i.e. A( 4)=A()\A(,) d) set W(, 4)=0 e) set W(, 4)=0 forall ∈ON( 4), if W(, 4)=1 and W(, 4)≥wait a) set OFF( 5)=OFF()∪ b) set ON( 5)=ON( 4)\ c) set W( 5)=W( 4)\(, 4) d) set W( 5)=W( 4)\(, 4) ON()+A()≥JA, () a) set OFF( 6)={Remove ()−ON( 5)− A( 4) servers from OFF( 5)} b) set A( 6)=A( 4)∪{OFF( 4)\OFF( 5)} forall ∈A( 6) a) set A( 6)=A( 4)∪A(,) c) set A( 6)=A( 6)+ a) set A( 6)=A( 4)+ set cost matrix () set TEMP =∅. forall ∈A( 6), if server  is not assigned to a job in slot , a) add server  to TEMP, i.e. TEMP =TEMP∪ if W(, 5)=1, a) set W(, 8)=0 b) set W(, 8)=0 endfor else else endif 7. 8. Calculate optimal assignments for slot : ()=Hungarian[()] endif endif endfor 10. Choose randomly a server ∈TEMP if W(, 5)=0 a) set W(, 9)=1 b) set W(, 9)= else 11. a) set W(, 9)=W(, 5)+ endif 12 12. if server ∈A( 6) is assigned to job  ∈() in slot  else a) (+1)=()− a) (+1)=() a) set (+1)=()+ 13. forall  ∈() endfor 5. Possible Enhancements in Online Algorithm Surely, in the current version of online algorithm, the decision of optimal assign- ments is performed only taking into account the available information preceding two subsequent slots; that can be improved by using some statistical inference techniques where the assignment cost’s exponential part given in equation (33) will be updated dynamically. On the other hand, jobs-to-servers ratio given in equation (32) can be transformed to total service demand per total server speed in ()  ∑ the following way: ∑  ∈ON() ∈() () could be decided whenever ∑ ∑  ∈() ∈ON() . So, the activation of a new server  ≥ min ∈() +Δ −. Another enhancement may be to define a new criterion of activation or switching OFF a server which takes into consideration periodically the average number of jobs, service demand, and deadline of jobs. For example, the distribution of hourly number of jobs, service demand, and deadline of jobs is found and applied in the criterion. 6. Randomized Routing We introduce randomized routing algorithm which is similar to online algorithm but having a random assignment matrix in step 8. Random assignment matrix is obtained by random permutations. 13 Table 1. Comparison of online total power cost with random, optimal and relaxed optimal total power cost.  = 3,  = 8. Example ∈ ∈ ∈ Δ∈ [4 2 2] [4 1 2 5 5 5 1 3] [2 2 3 3 3 5 5 5] [3 4 2 2 4 4 4 3] [2 2 4] [1 1 5 3 2 1 4 1] [2 2 2 3 4 4 5 6] [2 4 2 2 4 3 2 3] [4 3 2] [3 1 2 1 3 2 3 2] [2 2 3 4 4 6 6 6] [3 2 3 3 4 4 2 4] [4 4 4] [4 4 2 3 3 3 5 2] [2 2 2 2 4 6 6 6] [2 3 3 2 2 4 2 4] [4 3 4] [4 3 1 4 3 1 2 4] [2 2 3 4 4 4 6 6] [4 3 4 4 2 2 4 4] 1 2 3 4 5 Online Total Randomized Routing Optimal Total Relaxed Optimal Power Cost 3500 2940 3440 137400 3800 Total Power Cost 543960 93380 137780 138880 273400 Power Cost 2200 1800 1600 1800 1600 Total Power Cost 1300 900 850 1300 1100 Table 2. Comparison of online total power cost with random online total power cost for different values of parameters. Example 4 in Table 1 is studied. J wait =1 4 5 6 2 3 Online Total Power Cost 1 8 137400 92600 92600 47400 47400 47400 47400 47400 Random Online Total Power Cost 138880 138160 228200 92600 137800 183000 47400 183000 8 6 3600 3600 3600 6600 4800 4200 1 3600 Random Online Total Power Cost 5400 wait =2 3 4 5 3600 3600 3600 4200 3600 4200 2 3600 4200 Online Total Power Cost J 7 7 7. Numerical Results In each numerical result, we assume that  =1 second, slot =200 Jouls, ON = 160 Jouls. 7.1. Small Size Examples In Table 1 and Table 2, the speed of servers, service demands of jobs, arrival slots tially. of jobs, deadlines of jobs follows a uniform distribution taking integer values from [1,4], [1,5], [2,6], [1,4]×, respectively. We assume that all servers are ON, ini- In Table 1, we assume that wait =1 second, J =1, ON =250. The comparison in Table 1 is based on =3 servers and =8 jobs. Note that even in case of a small size example, the randomized routing algorithm is far from optimal cost. In Example 4, an extreme case occurs where none server is ON when 4th job arrives to the system in slot 5. This happens because of our choice of wait = 14 of a server increases the total power cost. gorithm; but, it is not always guaranteed for randomized routing algorithm. arrival slots of jobs, deadlines of jobs, initial states of servers follow a uniform respectively. 1 second which causes to switch OFF all servers. Since ON =250, the activation In Table 2, for different values of wait and J, we compare online total power cost with random online total power cost. Note that when wait increases, both algo- rithms do better. Increasing J could also improve the performance of online al- 7.2. Critical Values of  and  In Figure 2 and Figure 3, the following parameters are assumed: wait =2 seconds, J =5, ON =10, and =30. The speed of servers, service demands of jobs, distribution taking integer values from [2,4], [10,20], [2,200], [10,20]×, [0,1], In Figure 2, average total power cost with respect to J is depicted for = 1,2 and 3. The figure implies that increasing values of J tends to result in a pos- itive effect on average total power cost; but, it also shows that for =4, the curve is not monotonically decreasing with respect to J. In Figure 3, average number of jobs handled within deadline with respect to J is depicted for =1,2 and 3. It is inevitable that average number of jobs handled within deadline decreases with increasing values of J. In Figure 4, we plot how average total power cost changes with respect to wait . We again assume that ON =250. Figure 4 implies that the average total power could be very dependent on wait. We see that in the considered default values, for wait ≥2, the average total power cost decreases dramatically. Changing the num- ber of servers and jobs do not affect the critical value of wait. In Figure 5 and Figure 6, the following parameters are assumed: wait =2 seconds, J =5, ON =250. Figure 5 plots the change of average total power cost as well with respect to number of jobs for =6,7,and 8. The advantage of online al- 7.3. Comparison of Online Algorithm with Randomized Routing as Figure 6 depicts the change of average number of jobs handled within deadline gorithm is inevitable in the figures. 15 8. Future Work As an immediate extension in the offline problem, we can take into account more than two states of the servers, i.e. instead of only ON and OFF modes, we can also consider IDLE, HIBERNATE modes, etc. We can introduce a new time cost in case of a preemption which corresponds to migration a job from a server to an- other one. Moreover, another constraint can be geographically separated servers as well as we can define hierarchy among jobs and forbid a particular job to be assigned to a particular server. A possible work could also discuss to do flexibility by some factor in deadline constraints of jobs. 9. Conclusions We studied the dynamic power optimization problem in data centers. The corre- sponding offline problem has been formulated and solved using binary integer programming. We showed that the offline problem is a new version of dynamic generalized assignment problem including new constraints issuing from deadline characteristics of jobs and difference of activation energy of servers. Furthermore, we proposed an online algorithm that solves the problem heuristically and com- pared it to randomized routing. 10. References [1] A. Gandhi, "Dynamic server provisioning for data center power management," Carnegie Mallon University, Pittsburgh, 2013. [2] L. A. Barroso and U. Hölzle, "The case for energy-proportional computing," IEEE Computer, vol. 40, no. 12, pp. 33-37, 2007. [3] K. Choi, R. Soma and M. Pedram, "Fine-grained dynamic voltage and frequency scaling for precise energy and performance trade-off on the ratio of off-chip access to on-chip computation times," in Proceedings of the Conference on Design, Automation and Test in Europe, DATE'04, Paris, France, 2004. [4] C.-h. Hsu and W.-c. Feng, "A power-aware run-time system for high-performance computing," in Proceedings of the 2005 ACM/IEEE Conference on Supercomputing, SC'05, Seattle, WA, USA, 2005. [5] H. Amur and K. Schwan, "Achieving power-efficiency in clusters without distributed," in Workshop on Energy Efficient Design, Saint-Maolo, France, 2010. [6] Y. Agarwal, S. Hodges, R. Chandra, J. Scott, P. Bahl and R. Gupta, "Augmenting network interfaces to reduce PC energy usage," in Proceedings of the 6th USENIX Symposium on Networked Systems Design and Implementation, NSDI'09, Boston, MA, USA, 2009. [7] Q. Deng, D. Meisner, A. Bhattacharjee, T. F. Wenisch and R. Bianchini, "CoScale: Coordinating CPU and memory system DVFS in server systems," in Proceedings of the 45th Annual IEEE/ACM International Symposium on Microarchitecture, MICRO'12, British Columbia, Canada, 2012. 16 [8] A. Gandhi, M. Harchol-Balter, R. Raghunathan and M. A. Kozuch, "Distributed, robust auto- scaling policies for power management in compute intensive server farms," in IEEE Sixth Open Cirrus Summit (OCS), 2011, Atlanta, GA, USA, Oct. 2011. [9] M. Lin, A. Wierman, L. Andrew and E. Thereska, "Dynamic right-sizing for power-proportional data centers," in Proceedings of 2011 IEEE INFOCOM, INFOCOM'11, Shanghai, China, 2011. [10] B. Urgaonkar, P. Shenoy and T. Roscoe, "Resource overbooking and application profiling in shared hosting platforms," SIGOPS Operating Systems Review, vol. 36, no. SI, pp. 239-254, December 2002. [11] A. Verma, P. Ahuja and A. Neogi, "pMapper: power and migration cost aware application placement in virtualized systems," in Proceedings of the 9th ACM/IFIP/USENIX International Conference on Middleware, Middleware'08, Leuven, Belgium, 2008. [12] R. Nathuji, A. Kansal and A. Gha, "Q-clouds: Managing performance interference effects for QoS- aware clouds," in Proceedings of the 5th European Conference on Computer Systems, EuroSys'10, Paris, France, 2010. [13] K. Kogan and A. Shtub, "DGAP - The dynamic generalized assignment problem," Annals of Operations Research, vol. 69, no. 0, pp. 227-239, 1997. [14] L. Moccia, J.-F. Cordeau, M. F. Monaco and M. Sammarrab, "A column generation heuristic for a dynamic generalized assignment problem," Computers & Operations Research, vol. 36, no. 9, pp. 2670-2681, 2009. 17 Figure 2. Average total power cost with respect to (cid:23). Figure 3. Average number of jobs handled within Figure 4. Average total power cost with respect deadline with respect to (cid:23). to (cid:25)(cid:26)(cid:27)(cid:28). Figure 5. Comparison of online algorithm with randomized routing in terms of average total power cost with respect to . Figure 6. Comparison of online algorithm with randomized routing in terms of average number of jobs handled within deadline with respect to . 18
1602.06708
2
1602
2017-06-13T05:41:16
Online Bounded Analysis
[ "cs.DS" ]
Though competitive analysis is often a very good tool for the analysis of online algorithms, sometimes it does not give any insight and sometimes it gives counter-intuitive results. Much work has gone into exploring other performance measures, in particular targeted at what seems to be the core problem with competitive analysis: the comparison of the performance of an online algorithm is made to a too powerful adversary. We consider a new approach to restricting the power of the adversary, by requiring that when judging a given online algorithm, the optimal offline algorithm must perform as well as the online algorithm, not just on the entire final request sequence, but also on any prefix of that sequence. This is limiting the adversary's usual advantage of being able to exploit that it knows the sequence is continuing beyond the current request. Through a collection of online problems, including machine scheduling, bin packing, dual bin packing, and seat reservation, we investigate the significance of this particular offline advantage.
cs.DS
cs
Journal of Scheduling manuscript No. (will be inserted by the editor) Online-Bounded Analysis Joan Boyar · Leah Epstein · Lene M. Favrholdt · Kim S. Larsen · Asaf Levin Received: date / Accepted: date Abstract Though competitive analysis is often a very good tool for the analysis of online algorithms, sometimes it does not give any insight and sometimes it gives counter-intuitive results. Much work has gone into exploring other performance measures, in particular tar- geted at what seems to be the core problem with competitive analysis: the comparison of the performance of an online algorithm is made with respect to a too powerful adversary. We consider a new approach to restricting the power of the adversary, by requiring that when judging a given online algorithm, the optimal offline algorithm must perform at least as well Supported in part by the Danish Council for Independent Research, Natural Sciences, and the Villum Founda- tion. A preliminary version of this paper appeared in the Eleventh International Computer Science Symposium in Russia, Lecture Notes in Computer Science, vol. 9691, Springer, 2016, pp. 131–145. Joan Boyar Dept. of Mathematics and Computer Science University of Southern Denmark Odense, Denmark. E-mail: [email protected] Leah Epstein Dept. of Mathematics University of Haifa Haifa, Israel. E-mail: [email protected] Lene M. Favrholdt Dept. of Mathematics and Computer Science University of Southern Denmark Odense, Denmark. E-mail: [email protected] Kim S. Larsen Dept. of Mathematics and Computer Science University of Southern Denmark Odense, Denmark. E-mail: [email protected] Asaf Levin Faculty of IE&M The Technion Haifa, Israel. E-mail: [email protected] 7 1 0 2 n u J 3 1 ] S D . s c [ 2 v 8 0 7 6 0 . 2 0 6 1 : v i X r a 2 Boyar, Epstein, Favrholdt, Larsen, Levin as the online algorithm, not just on the entire final request sequence, but also on any prefix of that sequence. This is limiting the adversary's usual advantage of being able to exploit that it knows the sequence is continuing beyond the current request. Through a collection of online problems, including machine scheduling, bin packing, dual bin packing, and seat reservation, we investigate the significance of this particular offline advantage. 1 Introduction An online problem is an optimization problem where requests from a sequence I are given one at a time, and for each request an irrevocable decision must be made for it before the next request is revealed. For a minimization problem, the goal is to minimize some cost function, and if ALG is an online algorithm, we let ALG(I) denote this cost on the request sequence I. Similarly, for a maximization problem, the goal is to maximize some value function (also known as profit), and in this case, ALG(I) is the profit of an online algorithm ALG. 1.1 Performance Measures Competitive analysis [34, 28] is the most common tool for comparing online algorithms. For a minimization problem, an online algorithm is c-competitive if there exists a constant α such that for all input sequences I, ALG(I) ≤ c OPT(I) + α. Here, OPT denotes an optimal offline algorithm. As usual, the term "offline" is just used for emphasis, since most algo- rithms we discuss are online. The (asymptotic) competitive ratio of ALG is the infimum over all such c. Similarly, for a maximization problem, an online algorithm is c-competitive if there exists a constant α such that for all input sequences I, ALG(I) ≥ c OPT(I)− α. The (asymptotic) competitive ratio of ALG is the supremum over all such c. In both cases, if the inequality can be established using α = 0, we refer to the result as being strict (some authors use the terms absolute or strong). Note that for maximization problems, we use the convention of competitive ratios smaller than 1. For many online problems, competitive analysis gives useful and meaningful results. However, researchers also realized from the very beginning that this is not always the case: Sometimes competitive analysis does not give any insight and sometimes it even gives counter-intuitive results, in that it points to the worse of two algorithms as the better one (in the sense that the common belief is that one of the two algorithms is worse, or even that experimental studies provide clear evidence that this is the case). A recent list of exam- ples with references can be found in [21, p. 289]. Much work has gone into exploring other performance measures, in particular targeted at what seems to be the core problem with competitive analysis: the comparison of the performance of an online algorithm is made with respect to a too powerful adversary. Four main techniques for addressing this have been employed, sometimes in combi- nation. We discuss these ideas below. No chronological order is implied by the order the techniques are presented in. First, one could completely eliminate the optimal offline algo- rithm by comparing algorithms to each other directly. Measures taking this approach include max/max analysis [9], relative worst order analysis [12], bijective and average analysis [3], and relative interval analysis [20]. Second, one could limit the resources of the optimal offline algorithm, or correspond- ingly increase the resources of the online algorithm, as is done in extra resource analysis [27, 34]. Thus, the offline algorithm's knowledge of the future is counter-acted by requiring that Online-Bounded Analysis 3 it solves a harder version of the problem than the online algorithm. Alternatively, the online algorithm could be given limited knowledge of the future in terms of some form of look- ahead, as has been done for paging. In those set-ups, one assumes that the online algorithm can see a fixed number ℓ of future requests, though it varies whether it is simply the next ℓ requests, or, for instance, the next ℓ expensive requests [36], the next ℓ new requests [16], or the next ℓ distinct requests [1]. Third, one could limit the adversary's control over exactly which sequence is being used to give the bound by grouping sequences and/or considering the expected value over some set as has been done with the statistical adversary [33], diffuse adversary [31], ran- dom order analysis [30], worst order analysis [12], Markov model [29], and distributional adversary [25]. Finally, one could limit the adversary's choice of sequences it is allowed to present to the online algorithm. An early approach to this, which at the same time addressed issues of locality of reference, was the access graph model [10], where a graph defines which requests are allowed to follow each other. Another locality of reference approach was taken in [2], limiting the maximum number of different requests allowed within some fixed-sized slid- ing window. Both of these models were targeted at the paging problem, and the techniques are not meant to be generally applicable to online algorithm analysis. A resource-based ap- proach is taken in [14], where only sequences that could be fully accommodated given some resource are considered, eliminating some pathological worst-case sequences. A general- ization of this, where the competitive ratio is found in the limit, appears in [15, 13]. All of these approaches are aimed at removing pathological sequences from consideration such that the worst-case (or expected case) behavior is taken over a smaller and more realistic set of sequences, thereby obtaining results aligning better with observed behavior in practice. A similar concept for scheduling problems is the "known-OPT" model, where the cost of an optimal offline solution is known in advance [6]. Finally, loose competitive analysis [37] allows for a set of sequences, asymptotically smaller than the whole infinite set of input sequences, to be disregarded, while the remaining sequences should either be c-competitive or have small cost. In this way, infrequent pathological as well as unimportant (due to low cost) sequences can be eliminated. 1.2 Online-Bounded Analysis Much work has been done in all of the four categories mentioned above. In this paper, we consider a new approach to restricting the power of the adversary that does not really fit into any of the known categories. Given an online algorithm, we require that the optimal offline algorithm perform at least as well as the online algorithm, not just on the entire final request sequence, but also on any prefix of that sequence. In essence, this is limiting the adversary's usual advantage of being able to exploit that it knows the sequence is continuing beyond the current request, without completely eliminating this advantage. Since the core of the problem of the adversary's strength is its knowledge of the future, it seems natural to try to limit that advantage directly. This new measure is generally applicable to online problems, since it is only based on the objective function. Comparing with other measures, it is a new element that the be- havioral restriction imposed on the optimal offline algorithm is determined by the online algorithm, which is the reason we name this technique online-bounded analysis. It is adap- tive in the sense that online algorithms attempting non-optimal behavior face increasingly harder conditions from the adversary the farther the online algorithm goes in the direction 4 Boyar, Epstein, Favrholdt, Larsen, Levin of non-optimality (on prefixes). The measure judges greediness more positively than does competitive analysis, since making greedy choices limits the adversary's options more, so the focus shifts towards the quality of a range of greedy or near-greedy decisions. Behavioral restrictions on the optimal offline algorithm have been seen before, as in [17], where it is used as a tool to arrive at the final result. Here they first show a O(1)-competitive result against an offline algorithm restricted to, among other things, using shortest remaining processing time for job selection. Later they show that this gives rise to a schedule at most three times as bad as for an unrestricted offline algorithm. Thus, the end goal is the usual competitive ratio, and the restriction employed in the process is problem specific. 1.2.1 The Definition We start by giving the definitions for a minimization problem. If I is an input sequence for some minimization problem and A is a deterministic online algorithm for this problem, we let A(I) denote the objective function value returned by A on the input sequence I. We let OPTA denote an offline algorithm which is optimal under the restriction that it is not allowed to be worse than A on any prefix of the input sequence I being considered. Thus, for any sequence I, for which we want to determine OPTA(I), it must hold for all prefixes I′ of I that OPTA(I′) ≤ A(I′). Additionally, no offline algorithm with that property is strictly better than OPTA on I. If these conditions are fulfilled, we say that OPTA is an online-bounded optimal solution (for A). If for some constants, b and c, it holds for all sequences I that A(I) ≤ c OPTA(I) + b, then we say that A has an online-bounded ratio of at most c. The online-bounded ratio of A is the infimum over all such c. For a maximization problem, the requirement is instead that OPTA(I′) ≥ A(I′), and if for some constants, b and c, it holds for all sequences I that A(I) ≥ c OPTA(I)− b, then we say that A has an online-bounded ratio of at least c. The online-bounded ratio of A is the supremum over all such c. For maximization problems, it varies whether authors use ratios greater than or smaller than one. Note that with our definitions, an online-bounded ratio for a minimization problem is at least 1, while this ratio for a maximization problem is at most 1. Just as with the competitive ratio, one could also define a strict variant of the online- bounded ratio with b = 0. For the scheduling problems considered in this paper, this would not change the results. As has also been observed for competitive analysis, for any constant b, the job sizes of a worst-case input can be scaled such that allowing the additive constant b makes no difference. Thus, for simplicity, in Sections 3 and 4, we assume b = 0. When con- sidering the seat reservation problem, the total number of reservations accepted is bounded by a constant, so we also assume that b = 0 in Section 7. 1.3 Results Through a collection of online problems, including machine scheduling, bin packing, dual bin packing, and seat reservation, we investigate the workings of online-bounded analysis. The large collection of measures that have been defined indicates that there is no universal measure which is the best choice for all problems. With our approach, we try to learn more about the nature of online problems, greediness, and robustness. As a first approach, we Online-Bounded Analysis 5 study our new idea in the simplest possible setting, and leave it for future work to investigate if our approach works best in isolation or in combination with ideas from other measures. First, we observe that some results from competitive analysis carry over. Then we note that some problem characteristics imply that a greedy algorithm is optimal. m ≥ 2 identical machines, we get an online-bounded ratio of 2− 1 this is smaller than the competitive ratio of 2− 1 For machine scheduling, we obtain the following results. For minimizing makespan on m−1 for GREEDY. Though m [26], it is a comparable result, demonstrat- ing that non-greedy behavior is not the key to the adversary performing better by a factor close to 2 for large m. Two machines are called uniformly related if there exists a fixed fac- tor s such that one machine is s times faster than the other, that is, the two machines have speeds, and s is the ratio between those speeds, also called the speed ratio. For two uniformly related machines, we prove that GREEDY has online-bounded ratio 1. This is consistent with competitive ratio results, where GREEDY has been proven optimal [24, 18] with competitive s+1}, if the speed ratio is s. For the case where the faster machine is at least φ (the golden ratio) times faster than the slower machine, competitive analysis finds that GREEDY and FAST, the algorithm that only uses the faster machine, are equally good. Using relative worst order analysis, GREEDY is deemed the better algorithm [23], which seems reasonable since GREEDY is never worse on any sequence than FAST, and sometimes better. We also obtain this positive distinction, establishing the online-bounded ratios 1 and s+1 for GREEDY and FAST, respectively. ratio 1 + min{ 1 s , s s For the Santa Claus machine scheduling problem [8], we prove that GREEDY is optimal for identical machines with respect to the online-bounded ratio. For two related machines with speed ratio s, we present an algorithm with an online-bounded ratio better than 1 s and show that no online algorithm has a higher online-bounded ratio. For this problem, it is known that the best possible competitive ratio for identical machines is 1 m , and the best possible competitive ratio for two related machines is 1 s+1 [35, 5, 22]. For classic bin packing, we show that any Any-Fit algorithm has an online-bounded 2 . We observe that for bin covering, the best online-bounded ratio is equal ratio of at least 3 to the best competitive ratio [19]. For these problems, asymptotic measures are used. We show a connection between results concerning the competitive ratio on accommo- dating sequences (that is, sequences where OPT packs all items) and the online-bounded ratio. For dual bin packing (namely, the multiple knapsack problem with equal capacity knapsacks and unit value items), we show that the online-bounded ratio is the same as the competitive ratio on accommodating sequences for a large class of algorithms including First-Fit, Best-Fit, and Worst-Fit. It then follows from results in [13] that any algorithm in this class has an online-bounded ratio of at least 1 2 . Furthermore, the online-bounded ratio of First-Fit and Best-Fit is 5 2 . We also note that, for any dual bin packing algorithm, an upper bound on the competitive ratio on accommodating sequences is also an upper bound on the online-bounded ratio. Using a result from [13], this implies that any algorithm has an online-bounded ratio of at most 6 7 . 8 , and that of Worst-Fit is 1 For seat reservation, we have preliminary results, and conjecture that results are similar to machine scheduling for identical machines, in that ratios similar to but slightly better than those obtained using competitive analysis can be established. We found that the new measure sometimes leads to the same results as the standard competitive ratio, and in some cases it leads to an online-bounded ratio of 1. However, there are problem variants for which we obtain an intermediate value, which confirms the relevance of our approach. 6 Boyar, Epstein, Favrholdt, Larsen, Levin 2 Online-Bounded Analysis Before considering concrete problems, we discuss some generic properties. 2.1 Measure Properties The online-bounded ratio of an algorithm is never further away from 1 than the competitive ratio, since the online algorithm's performance is being compared to a (possibly) restricted, optimal algorithm. Since algorithms are compared with different optimal algorithms, one might be con- cerned that two algorithms, A and O, could have online-bounded ratio 1, and yet one al- gorithm could do better on some sequences than the other. However, if both algorithms have online-bounded ratio 1, there is no point where one algorithm makes a decision which changes the objective value more than the other does, since the adversary could end the sequence there and the one algorithm with the worst objective value would not have online- bounded ratio 1. Thus, both algorithms have the same objective function value at all points, so they always compete against the same adversary. Thus, if algorithm A performs better than algorithm O on any input sequence, then algorithm O does not have online-bounded ratio 1. For some problems, such as paging, OPTA is the same as OPT under competitive analysis for all algorithms A, because OPT's behavior on any sequence is also optimal on any prefix of that sequence. Thus, the competitive analysis results for paging and similar problems also hold with this measure, giving the same online-bounded ratio as competitive ratio. 2.2 GREEDY is Sometimes Optimal It is sometimes the case that there is one natural greedy algorithm that always has a unique greedy choice in each step. In such situations, the greedy algorithm is optimal with respect to this measure, having online-bounded ratio 1. For example, consider weighted matching in a graph where the edges arrive in an online fashion (the edge-arrival model) and the algorithm in each step decides if the current edge is added to the matching or discarded. Here, the greedy algorithm, denoted by GREEDY, adds the current edge if adding the edge will keep the solution feasible (that is, its two end-vertices are still exposed by the matching that the algorithm created so far) and the weight of the edge is strictly positive. Note that indeed the online-bounded ratio of GREEDY is 1, as the solution constructed by OPTGREEDY must coincide with the solution created by GREEDY. The last claim follows by a trivial induction on the number of edges considered so far by both GREEDY and OPTGREEDY . If GREEDY adds the current edge, then by the definition of OPTGREEDY , we conclude that OPTGREEDY adds the current edge. If GREEDY discards the current edge because at least one of its end- vertices is matched, then OPTGREEDY cannot add the current edge either (using the induction assumption). Last, if GREEDY discards the current edge since its weight is non-positive, then we can remove the edge from the bounded optimal solution, OPTGREEDY , if it was added (removing it from OPTGREEDY will not affect the future behavior of OPTGREEDY since OPTGREEDY must accept an edge whenever GREEDY does). Similar proofs hold in other cases when there is a unique greedy choice for OPT in each step. Note that for the weighted matching problem where vertices arrive in an online fashion and when a vertex arrives the Online-Bounded Analysis 7 edge set connecting this vertex to earlier vertices is revealed with their weights (the vertex- arrival model), the standard negative result (the value of the negative result is smaller than the ratio of the smallest strictly positive weight in the graph to the largest) for weighted matching holds as can be seen in the following construction. The first three vertices arrive in the order 1, 2, 3 and when vertex 3 arrives, two edges {1, 3},{2, 3} are revealed each of which has weight of 1 (vertices 1 and 2 are not connected). At this point, an online algorithm with a strictly positive online-bounded ratio must add one of these edges to the matching. Then, either 1 or 2 are matched in the current solution, and in the last step, vertex 4 arrives with an edge of weight M connecting 4 to the vertex among 1 and 2 that was matched by the algorithm. Observe that when vertex 3 arrives, the algorithm adds an edge to the matching while the bounded optimal solution can add the other edge, and this will allow the bounded optimal solution to add the last edge as well. The argument for the optimality of GREEDY for the weighted matching problem in the edge-arrival model clearly holds if all weights are 1 also. This unweighted matching problem in the edge-arrival model is an example of a maximization problem in the online complexity class Asymmetric Online Covering (AOC) [11]: Definition 1 An online accept-reject problem is in Asymmetric Online Covering (AOC) if, for the set Y of requests accepted, the following holds: For minimization (maximization) problems, the objective value of Y is Y if Y is feasible and ∞ (−∞) otherwise, and any superset (subset) of a feasible solution is feasible. For all maximization problems in the class AOC, there is an obvious greedy algorithm, GREEDY, which accepts a request whenever acceptance maintains feasibility. The argument above showing that the online-bounded ratio of GREEDY is 1 for the weighted matching problem in the edge-arrival model generalizes to all maximization problems in AOC. Theorem 1 For any maximization problem in AOC, the online-bounded ratio of GREEDY is 1. Thus, GREEDY is optimal according to online-bounded analysis for online independent set in the vertex-arrival model, unweighted matching in the edge-arrival model, and online disjoint path allocation where requests are paths. Note that this does not hold for all minimization problems in AOC. For example, cy- cle finding in the vertex-arrival model, the problem of accepting as few vertices as pos- sible, but accepting enough so that there is a cycle in the induced subgraph accepted, is AOC-Complete. However, consider the first vertex requested in a graph with only one cy- cle. GREEDY is forced to accept it, since the vertex could be part of the unique cycle, but OPTGREEDY will reject the vertex if it is not in that cycle. However, there are online-bounded optimal greedy algorithms for minimization prob- lems in AOC, such as vertex cover, which are complements of maximization problems in AOC (independent set in the case of vertex cover). By complement, we mean that set S is a maximal feasible set in the maximization problem if and only if the requests not in S are a feasible solution for the minimization problem. The greedy algorithm in the case of these minimization problems would be the algorithm that accepts exactly those requests that GREEDY for the complementary maximization problem rejects. 3 Machine Scheduling: Makespan We study the load balancing problem of minimizing makespan for online job scheduling without preemption. We first consider m identical machines, and analyze the classic greedy 8 Boyar, Epstein, Favrholdt, Larsen, Levin algorithm (also known as list scheduling). At any point, GREEDY schedules the next job on a least loaded machine, where the load of a machine is the sum of the sizes of all jobs assigned to it. Since the machines are identical, ties can be resolved arbitrarily without loss m [26]. With the more m−1 as the online-bounded ratio of GREEDY. Any algorithm assigns every job to run within a specific time window of this job, and the completion time of a job is the ending point of its window. of generality. It is known that the competitive ratio of GREEDY is 2− 1 restricted optimal algorithm, we get a smaller value of 2− 1 Lemma 1 For the problem of minimizing makespan for online job scheduling on m identical machines, GREEDY has online-bounded ratio of at most 2− 1 m−1 . Proof Consider a sequence I. Let j be the first job in I that is completed at the final makespan of GREEDY, and assume that it has size w. Let t and t′ be the starting times of j in OPTGREEDY and GREEDY, respectively, and let ℓ and ℓ′ be the makespans of OPTGREEDY and GREEDY, respectively, just before the arrival of j. Let V denote the sum of the sizes of the jobs in I just before j arrives. We have the following inequalities: – OPTGREEDY (I) ≥ t + w – OPTGREEDY (I) ≥ ℓ In addition, since, just before j arrived, the machine where OPTGREEDY placed j had load t and the other machines had load at most ℓ, V ≤ t + (m− 1)ℓ. Since m− 1 ≥ 1, V ≤ (m− 1)(t + ℓ). Because GREEDY placed j on its least loaded machines, all machines had load at least t′ before j arrived. At least one machine had load ℓ′, so V ≥ (m − 1)t′ + ℓ′. By the defini- tion of online-bounded analysis, ℓ ≤ ℓ′. Thus, V ≥ (m− 1)t′ + ℓ. Combining the upper and lower bounds on V gives (m− 1)t′ ≤ (m− 1)t + (m− 2)ℓ and t′ ≤ t + m−2 m−1 ℓ. We now bound GREEDY's makespan: GREEDY(I) = t′ + w = (t′ − t) + (t + w) ≤ (cid:0) m−2 m−1(cid:1)· ℓ + OPTGREEDY (I) ≤(cid:0)2− 1 m−1(cid:1) OPTGREEDY (I) ⊓⊔ Lemma 2 For the problem of minimizing makespan for online job scheduling on m identical m−1 . machines, GREEDY has online-bounded ratio of at least 2− 1 Proof The adversarial sequence I consists of one job of size m− 1, followed by (m− 1)(m− 2) jobs of size 1, and finally one job of size m− 1. Clearly, GREEDY(I) = 2m− 3. Since the makespan of GREEDY after the first job is m− 1, OPTGREEDY is allowed to schedule the (m− 1)(m − 2) jobs on m− 2 machines, all of which are different from the machine getting the first job, until m − 1 machines all have load m − 1. This leaves one machine for the final job, and gives a final makespan of m − 1. The online-bounded ratio becomes 2m−3 ⊓⊔ m−1 = 2− 1 m−1 . By Lemmas 1 and 2, we find the following. Theorem 2 For the problem of minimizing makespan for online job scheduling on m iden- tical machines, GREEDY has online-bounded ratio 2− 1 m−1 . Online-Bounded Analysis 9 Note that Theorem 2 establishes the existence of an online algorithm, GREEDY, for makespan minimization on two identical machines with an online-bounded ratio of 1. Next, we generalize this last result to the case of two uniformly related machines. Note that for two uniformly related machines we can assume that machine number 1 is strictly faster than machine number 2, and the two speeds are s > 1 and 1. The load of a job assigned to a machine with speed s′ is the size of the job divided by s′, and the load of a machine is the sum of the loads of the jobs assigned to it. We define GREEDY as the algorithm that assigns the current job to the machine such that adding the job there results in a solution of a smaller makespan breaking ties in favor of assigning the job to the slower machine (that is, to machine number 2). If an algorithm breaks ties in favor of assigning the job to the faster machine (let this algorithm be called GREEDY′), then its online-bounded ratio is strictly above 1, as the following example implies. The first job has size s − 1 (and it is assigned to machine 1), and the second job has size 1 (and assigning it to any machine will result in the current makespan 1). The first job must be assigned to machine 1 by OPTGREEDY′ , and it assigns the second job to the second machine. A third job of size s + 1 arrives. This job is assigned to the first machine by OPTGREEDY′ , obtaining a makespan of 2. GREEDY′ will have a makespan of at least min{2 + 1/s, s + 1} > 2 as s > 1. Theorem 3 For the problem of minimizing makespan for online job scheduling on two uni- formly related machines, GREEDY has online-bounded ratio 1. Proof Consider an input, and assume by contradiction that the makespan of GREEDY ex- ceeds that of OPTGREEDY . Consider the last time that the loads of the two machines of GREEDY are equal (this time may be before any jobs arrive or later). Since the makespan of OPTGREEDY at that time cannot be lower than the makespan of GREEDY, OPTGREEDY must have the same makespan and its machines also have equal loads (it is possible that the sched- ules are not identical). After this time, the machines of GREEDY never have equal loads. If, starting at this time and until the input ends, GREEDY and OPTGREEDY select the same ma- chine for every job, then they will have the same final makespan. Thus, there is a job that they assign to different machines. Let j be the first such job. Before j is assigned, starting the last time that the machines had equal loads, the two solutions have the same load for each of the two machines as they received the same jobs. As OPTGREEDY cannot obtain a larger makespan than GREEDY, while GREEDY selects a machine that minimizes the makespan, it must be the case that no matter which machine receives j, the resulting makespan will be the same. Thus, GREEDY assigns j to the slower machine because of its tie breaking rule, while OPTGREEDY assigns the job to the faster machine. Since for both solutions the loads of both of the two machines were lower than the makespan achieved after j is assigned, the ma- chine that achieves the makespan is unique (since there are only two machines), and for each solution, it is the machine that received the current job. If the makespan of GREEDY does not increase in any future step, then its final makespan cannot exceed that of OPTGREEDY . Thus, assume that there is at least one such future increase of the makespan of the solution constructed by GREEDY and consider the first such future step. Let j′ be the job assigned at that step. By the definition of j′, at the time when j′ arrives, the load of the faster machine is no larger than the load of the slower machine. Hence, by the definition of GREEDY, the assignment of any job arriving later than j and up to and including j′ (by GREEDY) is to the faster machine. Since OPTGREEDY cannot assign any job that arrives after j but before j′ such that its makespan increases (since the makespan of GREEDY does not increase), OPTGREEDY assigns all these jobs to the slower machine. Let X1 and X2 be the total sizes of jobs that 10 Boyar, Epstein, Favrholdt, Larsen, Levin were assigned to the two machines (in both solutions) before the arrival of j, p j and p j′ the sizes of j and j′, and Z the size of jobs that arrived after j but before j′. Recall that we have X1 + p j s = X2 + p j (1) and this is the value of the makespan (of both solutions) after j was assigned. Let I′ be the prefix of the input sequence ending with j′. We find that the makespan of GREEDY after j′ is assigned is GREEDY(I′) = X1 + Z + p j′ s . Since X1+Z s < X2 + p j = X1+p j s while X1+Z+p j′ s > X2 + p j = X1+p j s , we have Z < p j < Z + p j′ . (2) By (2) and s > 1, X1 + Z + p j′ = X1 + (1− s)(Z + p j′ ) + s(Z + p j′ ) < X1 + (1− s)p j + s(Z + p j′ ). Thus, GREEDY(I′) < X1 + p j − p j + Z + p j′ . s The makespan of OPTGREEDY after j′ is assigned is OPTGREEDY (I′) ≥ min(cid:26)X2 + Z + p j′ , X1 + p j + p j′ s (cid:27) . X1+p j +p j′ X1+Z+p j′ s − p j + Z + p j′ , and by (2), By (1), X2 + Z + p j′ = X1+p j . Thus, when j′ arrives, OPTGREEDY cannot assign it without increasing its makespan beyond the makespan ⊓⊔ of GREEDY, contradicting the definition of an online-bounded optimal solution. We now consider the algorithm FAST that simply schedules all jobs on the faster ma- chine. In contrast to GREEDY, FAST does not have an online-bounded ratio of 1. This also contrasts with competitive analysis, since FAST has an optimal competitive ratio for s ≥ φ, where φ = 1+√5 > s s 2 ≈ 1.618. Theorem 4 For two related machines with speed ratio s, FAST has an online-bounded ratio of s+1 s . Proof For the upper bound, consider any input sequence I and let P denote the total size of the jobs in I. Then, FAST(I) = P s and OPT(I) ≥ P 1 + s , yielding a ratio of at most s+1 s . For the lower bound, consider the sequence hs2, si. Both OPT and FAST schedule the first job on the faster machine. However, for the second job, OPT will use the slower machine, obtaining a makespan of s. Placing both jobs on the faster machine, FAST ends up with a makespan of s + 1. ⊓⊔ By Theorem 2, the result of Theorem 3 cannot be extended to three or more identical machines for GREEDY. We conclude this section by proving that such a generalization is impossible, not only for GREEDY, but for any deterministic online algorithm. Online-Bounded Analysis 11 Theorem 5 Let m ≥ 3. For the problem of minimizing makespan for online job scheduling on m identical machines, any deterministic online algorithm A has online-bounded ratio of at least 4 3 . Proof The input sequence starts with m− 2 jobs of size 3 followed by two jobs of size 1. At this point, the makespan of the solution created by A is either 3 and in this case we continue, or at least 4 and in this case we stop the sequence. If we decide to continue and the two jobs of size 1 are assigned to a common machine (thus A has m − 2 machines each with load of 3 and another machine with load 2), the sequence is augmented by two jobs, each of size 2, and thus the resulting makespan of A is at least 4. Otherwise, if we decide to continue and the two jobs of size 1 are assigned to different machines (and thus the load of every machine in A is at least 1), then the sequence is augmented by one job of size 3 and so the resulting makespan of A is at least 4. Note that in all cases the makespan of OPTA is 3. This holds since after the processing of the first job, an optimal algorithm is allowed to have a makespan of 3 and for each possible case, there exists a solution with makespan 3 for the entire sequence. The claim follows because in all ⊓⊔ cases the makespan of A is at least 4. 3 by designing an algorithm that places each job on the most loaded machine where the bound of 4 3 would not be violated. However, even for m = 3, this would not work, as seen by the input sequence I = h 3 6i. The algorithm would combine the first two jobs on one machine and the following two on another machine. Since the optimal makespan at this point is 3 4 , the algorithm will schedule the fifth job on the third machine. When the last job arrives, all machines have a load of at least 7 12 > 1.4. Note that I can be scheduled such that each machine has a load of exactly 1. Since the algorithm has a makespan of 1 already after the second job, the online-bounded restriction is actually no restriction on OPT for this sequence. An obvious next step would be to try to match the general lower bound of 4 12 , resulting in a makespan of 17 4 , 5 12 , 1 4 , 1 6 , 7 12 , 5 4 Machine Scheduling: Santa Claus In contrast to makespan, the objective in Santa Claus scheduling is to maximize the min- imum load. The problem is also known as machine covering. Traditionally, the algorithm GREEDY for this problem assigns any new job to a machine having a minimum load in the schedule that was created up to the time just before the job is added to the solution (breaking ties arbitrarily). For identical machines, this algorithm is equivalent to the greedy algorithm for makespan minimization. Unlike the makespan minimization problem, where this algo- rithm has online-bounded ratio of 1 only for two identical machines, here we show that GREEDY has an online-bounded ratio of 1 for any number of identical machines. Theorem 6 For the Santa Claus problem on m identical machines, GREEDY has online- bounded ratio 1. Proof Let a configuration be a multi-set of the current loads on all of the machines, i.e., without any annotation of which machine is which. As long as OPTGREEDY also assigns each job to a machine with minimum load, the configurations of GREEDY and OPTGREEDY are identical. Consider the first time OPTGREEDY assigns a job j to a non-minimal load machine. If, when that job j arrives, there is a unique machine with minimum load, OPTGREEDY would 12 Boyar, Epstein, Favrholdt, Larsen, Levin have a worse objective value than GREEDY after placing j, so, by definition of online- bounded analysis, this cannot happen. Now consider the situation where k ≥ 2 machines have minimum load. Then, after processing j, GREEDY has k− 1 machines with minimum load, whereas OPTGREEDY has k. In that case, no more than k− 2 further jobs can be given. This is seen as follows: If k − 1 jobs were given, GREEDY would place one on each of its k− 1 machines with minimum load, and, thus, raise the minimum. OPTGREEDY , on the other hand, would not be able to raise (at this step) the minimum of all of its k machines with minimum load, and would therefore not be at least as good as GREEDY; a contradiction. Thus, OPTGREEDY can only have a different configuration than GREEDY after GREEDY (and OPTGREEDY ) have obtained their final (and identical) objective value, and so, the online- ⊓⊔ bounded ratio of GREEDY is 1. Next, we show that unlike the makespan minimization problem, for which there is an on- line algorithm with online-bounded ratio of 1 for the case of two uniformly related machines (Theorem 3), such a result is impossible for the Santa Claus problem. Theorem 7 For the Santa Claus problem on two uniformly related machines with speed ratio s, no deterministic online algorithm has an online-bounded ratio larger than 1 s . Proof For the setting of two uniformly related machines with speeds 1 and s, consider any online algorithm A. The input consists of exactly two jobs. After the first job is assigned by A, the objective function value remains zero, and only if the algorithm assigns the two jobs to distinct machines, will it have a positive objective function value. Thus, when there are only two jobs, OPTA is simply the optimal solution for the instance. The first job is of size 1. If A assigns the job to the machine of speed s, then the next job is of size s. At this point OPTA has value 1 (by assigning the first job to the slower machine and the second to the faster machine), but A has either zero value (if both jobs are assigned to the faster machine) or a value of 1 s . In the second case where A assigns the first job (of size 1) to the slower machine of speed 1, the second job has size 1 s (by assigning the first job to the faster machine and the second to the slower machine), but A has either zero value (if both jobs are assigned to the slower machine) or a value of 1/s ⊓⊔ s . Interestingly, the online-bounded ratio of GREEDY matches this bound, whereas post- GREEDY does not. The algorithm post-GREEDY is relevant for uniformly related machines, and places a job on the machine where its resulting completion time will be minimum, which is not necessarily the machine with the smallest load when the job arrives. GREEDY also achieves the best possible competitive ratio 1 s . At this point OPTA has value 1 s+1 [22]. Theorem 8 For the Santa Claus problem on two uniformly related machines with speed ratio s, the online-bounded ratio of GREEDY is 1 s . Proof By Theorem 7, the online-bounded ratio of GREEDY is at most 1 s . Now we show that it is at least 1 s . Assume s > 1 (otherwise the result follows from Theorem 6). For a given input, I, and the output of GREEDY for this input, let j denote a job of maximum completion time. Let x denote the load of the machine with job j just before j is assigned. Let y denote the load of the other machine at the same time. By the definition of GREEDY, y ≥ x. Let y + z denote the final load of the machine whose previous load was y (the machine that does not receive j). The value y + z is also the value of GREEDY on this input. Consider a solution by OPTGREEDY (that is, an online-bounded optimal solution). Let t1 and t2 denote the loads of the machines of speeds 1 and s, respectively, before j is assigned. Online-Bounded Analysis 13 By the definition of such an optimal solution, min{t1, t2} ≥ x. We split the analysis into two cases, based on which machine receives j in the output of GREEDY. Assume that the machine of speed 1 runs j in the schedule of GREEDY. Just before j arrives, the total size of jobs is x + sy. We find t1 = x + sy− st2 ≤ x + sy− sx < sy (since s > 1) and t2 = x+sy−t1 s ≤ y. The total size of jobs arriving strictly after j is sz, and in the optimal solution, the load of the machine that does not receive j is at most max{t1 + sz, t2 + z} ≤ max{sy + sz, y + z} = s(y + z). Thus, OPTGREEDY (I) ≤ s(y + z) ≤ s· GREEDY(I). Next, assume that the machine of speed s runs j in the schedule of GREEDY. Just before j arrives, the total size of jobs is sx + y. We find t1 = sx + y− st2 ≤ y and t2 = sx+y−t1 ≤ sx+y−x = y (by x ≤ y). The total size of jobs arriving strictly after j is z, and in the optimal solution, the load of the machine that does not receive j is at most max{t1 + z, t2 + z s} = y + z, and in this case the solution of GREEDY is optimal. ⊓⊔ s} ≤ max{y + z, y + z s ≤ (s−1)y+y s s 5 Classic Bin Packing and Bin Covering In classic bin packing, the input is a sequence of items of sizes s, 0 < s ≤ 1, that should be packed in as few bins of size 1 as possible. We say that a bin is open if at least one item has been placed in the bin. An Any-Fit algorithm is an algorithm that never opens a new bin if the current item fits in a bin that is already open. Theorem 9 Any Any-Fit algorithm has an online-bounded ratio of at least 3 2 . Proof The adversary sequence, I, consists of three parts, I1, I2, and I3. I1 and I2 contain just a few items each, while I3 contains 4(n− 1) items, for some large integer n. We show that any Any-Fit algorithm, ALG, uses 3(n− 1) bins for I3, whereas OPTALG uses only 2(n− 1) bins. The first part of I consists of three items: I1 =(cid:28) 2 3 , 5 12 , 1 4(cid:29) Any algorithm will have to use two bins for the first two items, and any Any-Fit algorithm will pack the third item in one of these two bins. The second part of the sequence depends on whether ALG packs the third item in the first or the second bin. If ALG packs the item of size 1 4 in the first bin together with the item of size 2 3 , the second part of the sequence contains four items: I2 =(cid:28) 1 3 , 1 3 , 1 2 − nε, 1 2 + nε(cid:29), for some small ε, 0 < ε < 1 12n . Since ALG is an Any-Fit algorithm, it packs the first of these four items in the second bin and then opens a third bin for the next two items and a fourth bin for the last item. OPTALG uses only three bins in total for I1 and I2, combining the items of sizes 2 3 in the first bin and the items of sizes 1 2 + nε in the third bin. 4 in the second bin together with the item of size 5 If ALG packs the item of size 1 2 − nε and 1 12 , the 3 and 1 second part of the sequence contains only one item: 12(cid:29) I2 =(cid:28) 7 14 Boyar, Epstein, Favrholdt, Larsen, Levin ALG will have to open a new bin for this item. OPTALG , on the other hand, will combine the items of sizes 2 4 in one bin and the items of size 5 3 and 1 12 and 7 12 in another bin. In both cases, ALG has now opened one more bin than OPTALG and each of ALG's bins is filled to at least 1 2 + nε. The last part of the sequence consists of n− 1 consecutive subsequences: (cid:28) 1 2 − iε, 1 2 − iε, 1 2 + iε, 1 2 + iε(cid:29), i = n− 1, n− 2, . . . , 1 For each of these n− 1 subsequences, I′, none of the four items fit in any of the bins opened before the arrival of the first item of I′. Hence, ALG uses 3 bins for each of the n− 1 subse- quences of I3, 3(n− 1) bins in total. OPTALG , on the other hand, will put the first two items of each subsequence in separate bins and pack the last two items in the same two bins. This is allowed, since ALG has opened one more bin than OPTALG , already before the arrival of the first item of I3. In this way, OPTALG uses only 2(n− 1) bins for I3. Since both algorithms use only a constant number of bins for I1 and I2, the ratio of ALG bins to OPTALG bins tends to 3/2 as n tends to infinity. ⊓⊔ In classic bin covering, the input is as in bin packing, and the goal is to assign items to bins so as to maximize the number of bins whose total assigned size is at least 1. For this problem, it is known that a simple greedy algorithm (which assigns all items to the active bin until the total size assigned to it becomes 1 or larger, and then it moves to the next bin and defines it as active) has the best possible competitive ratio 1 2 . The negative result [19] is proven using inputs where the first batch of items consists of a large number of very small items, and it is followed by a set of large identical items of sizes close to 1 (where the exact size is selected based on the actions of the algorithm). The total size of the very small items is strictly below 1, so as long as large items were not presented yet, the value of any algorithm is zero. An optimal offline solution packs the very small items such that packing every large item results in a bin whose contents have a total size of exactly 1. Thus, no algorithm can perform better on any prefix, and this construction shows that the online-bounded ratio is at most 1 2 . 6 Dual Bin Packing Dual bin packing is like the classic bin packing problem, except that there is only a limited number, n, of bins and the goal is to pack as many items in these n bins as possible. Known results concerning the competitive ratio on accommodating sequences can be used to obtain results for the online-bounded ratio. Online-Bounded Ratio vs. Competitive Ratio on Accommodating Sequences. In general, ac- commodating sequences [14, 15] are defined to be those sequences for which OPT does not get a better result by having more resources. For the dual bin packing problem, accommo- dating sequences are sequences of items that can be fully accommodated in the n bins, i.e., OPT packs all items. We show that, for a large class of algorithms for dual bin packing containing First-Fit and Best-Fit, the online-bounded ratio is the same as the competitive ratio on accommodating sequences. To show that this does not hold for all algorithms, we also give an example of a 2 3 -competitive algorithm on accommodating sequences that has an online-bounded ratio of 0. Online-Bounded Analysis 15 Dual bin packing is an example of a problem in a larger class of problems which includes the seat reservation problem discussed below. A problem is an accept/reject accommodating problem if algorithms can only accept or reject requests (and they act on accepted requests only), the goal is to accept as many requests as possible, and the accommodating sequences are those where OPT accepts all requests. Theorem 10 For any online algorithm ALG for any accept/reject accommodating problem, the competitive ratio of ALG on accommodating sequences is equal to the online-bounded ratio of ALG on accommodating sequences. Proof For any accommodating sequence, OPT rejects no items. Thus, the requirement that at any point in time, OPT has packed at least as many items as ALG does not change the behavior of OPT. This means that, for accommodating sequences, the competitive ratio and ⊓⊔ the online-bounded ratio are identical. Note that this result applies to all algorithms for dual bin packing. Since any accommo- dating sequence is also a valid adversarial sequence for the case with no restrictions on the sequences, we obtain the following corollary of Theorem 10. Corollary 1 For any online algorithm ALG for any accept/reject accommodating problem, any upper bound on the competitive ratio of ALG on accommodating sequences is also an upper bound on the online-bounded ratio of ALG. A fair algorithm for dual bin packing is an algorithm that never rejects an item that it could fit in a bin. A rejection-invariant algorithm is an algorithm that does not change its behavior based on rejected items. Theorem 11 For any fair, rejection-invariant dual bin packing algorithm ALG, the online- bounded ratio of ALG equals the competitive ratio of ALG on accommodating sequences. Proof The upper bound follows from Corollary 1. For the lower bound, we show that, for any input sequence I, there is an accommodating sequence I′ such that OPTALG (I) = OPTALG(I′) = OPT(I′) and ALG(I) = ALG(I′). Assume without loss of generality that for I it holds that any request is accepted either by ALG or by OPTALG (or by both of them). This can be assumed as ALG is rejection-invariant, and all requests rejected by both ALG and OPTALG can be removed from I without changing the action of ALG, and thus the action of OPTALG is unchanged as well. Let ho1, o2, . . ., oki be the subsequence of I consisting of the items that are packed by OPTALG but not by ALG. Similarly, let ha1, a2, . . . , ali be the subsequence of I consisting of the items packed by ALG but not by OPTALG . Clearly, k ≥ l. Furthermore, for each i, 1 ≤ i ≤ l, oi arrives before ai, since at any point in time, OPTALG must have packed at least as many items as ALG. This means that oi is larger than ai, since ALG is fair and packs ai after rejecting oi. Let I′ be the subsequence of I resulting from the removal of ho1, o2, . . . , oli. We claim that I′ is accommodating. The packing of OPTALG consists of all items of I excluding ha1, a2, . . ., ali. This packing is adapted for I′ as follows. For i = 1, 2, . . . , l, oi is replaced with ai (which is smaller). In this packing, all items of I′ are packed. Therefore, OPT (I′) = OPTALG(I) (since in the packing we just defined, the number of packed items is unchanged, and all items of I′ are packed). Recall that since I′ is an accommodating sequence, it holds that OPTALG(I′) = OPT(I′). Since ALG rejects all items of I \ I′ and is rejection-invariant, its behavior for I and I′ is the same and ALG(I′) = ALG(I). ⊓⊔ 16 Boyar, Epstein, Favrholdt, Larsen, Levin One algorithm which is fair and rejection-invariant is First-Fit, which packs each item in the first bin it fits in (and rejects it if no such bin exists). Another example of a fair, rejection-invariant algorithm is Best-Fit, which packs each item in a most full bin that can accommodate it. Worst-Fit is the algorithm that packs each item in a most empty bin. Corollary 2 Both Best-Fit and First-Fit have online-bounded ratios of 5 online-bounded ratio of 1 2 . 8 . Worst-Fit has an Proof For Best-Fit, the corollary follows from Theorem 11, since Corollary 2 and Theo- rem 4 in [13] imply that Best-Fit's competitive ratio on accommodating sequences is 5 8 . Theorem 4 in [13] does not specifically mention Best-Fit, but it is well known that any neg- ative result for the competitive ratio of First-Fit holds for any Any-Fit algorithm. This is because, for any sequence I, an adversary can force any Any-Fit algorithm to produce the First-Fit packing of I by permuting I such that the items packed by First-Fit are given first, in the order they appear in the bins in the First-Fit packing. For First-Fit, the corollary follows from Theorem 11, since Corollary 1 and Theorem 4 in [13] imply that First-Fit's competitive ratio on accommodating sequences is 5 8 . imply that Worst-Fit's competitive ratio on accommodating sequences is 1 2 . For Worst-Fit, the corollary follows from Theorem 11, since Theorems 1 and 5 in [13] ⊓⊔ For the first part of the corollary below, note that the fairness restriction gives rise to a lower bound, i.e., a guarantee of at least a certain competitive ratio. Corollary 3 Any fair, rejection-invariant dual bin packing algorithm has an online-bound- ed ratio of at least 1 2 . Any dual bin packing algorithm has an online-bounded ratio of at most 6 7 . Proof The first part follows from Theorem 11 above combined with Theorem 1 in [13]. The ⊓⊔ second part follows from Corollary 1 above combined with Theorem 3 in [13]. The algorithm Unfair-First-Fit (UFF) defined in [4] is designed to work well on accom- modating sequences. Whenever an item larger than 1 2 arrives, UFF rejects the item unless it will bring the number of accepted items below 2 3 of the total number of items that are accepted by an optimal solution of the prefix of items given so far (for an accommodating sequence this is the number of items in the prefix). Accepted items are packed using First- Fit. The competitive ratio of UFF on accommodating sequences is 2 3 [4]. We show that, in contrast to Theorem 11, UFF has an online-bounded ratio of 0. Theorem 12 Unfair-First-Fit has an online-bounded ratio of 0. Proof For a fixed n ≥ 2, consider the following input sequence I, for some small ε > 0, 2N for some large integer N. The sequence starts with hε,ε, 1 where ε = 1 2 + ε, 1− 2εi, fol- lowed by h 1 2i repeated 2(n− 1) times, and hεi repeated N − 3 times. The first four items can be packed into two bins. Unfair-First-Fit rejects the third item and accepts the other three items among the first four items. Moreover, Unfair-First-Fit packs those three items into one bin. Next, Unfair-First-Fit accepts and packs all items of size 1 2 into its n− 1 remaining bins. It is forced to reject all remaining items (each of which has size ε). For OPTUFF, it is possible to reject the fourth item instead of the third one, and as a result, it can pack all other items (it also packs the items of sizes 1 2 in pairs into bins of indices 2, 3, . . . , n). After all items of size 1 2 have been presented, OPTUFF has empty space, which is filled by small items, resulting in the ratio UFF(I) ⊓⊔ 2n+N−2 , tending to 0 as N grows to inifinity. OPT UFF (I) = 2n+1 Online-Bounded Analysis 17 7 Unit Price Seat Reservation In the seat reservation problem, there is a train with n seats traveling from station 1 to station k. The input is a sequence of requests for getting a seat from a station i to a station j > i. Two requests can be assigned the same seat, if the end station of one request is no larger than the start station of the other request. Algorithms for the problem are required to be fair, i.e., a request cannot be rejected if at least one seat can accommodate the request. In the unit price version, the objective is to maximize the number of accepted requests (requests that are assigned a seat), and in the proportional price version, the objective is to maximize the total length (end station minus start station) of the accepted requests. Since both versions of the seat reservation problem have competitive ratios Θ(1/k), the problem has often been studied using the competitive ratio on accommodating sequences, which for the seat reservation problem restricts the input sequences considered to those where OPT could have accepted all of the requests. For proportional price seat reservation, the competitive ratio remains Θ(1/k), even on accommodating sequences. However, for the unit price version, the optimal competitive ratio on accommodating sequences is 1 2 [14, 7]. Thus, by Theorem 10, the optimal online-bounded ratio on accommodating sequences is 1 2 . On general sequences, the optimal online-bounded ratio for unit price seat reservation is essentially as bad as the competitive ratio. This is true, even though both the original proof, showing that no deterministic online algorithm is more than 8 k+5 -competitive [14], and the proof improving this to [32], used an optimal offline algorithm which 4 k−2√k−1+4 rejected some requests before the online algorithm did. The main idea in these proofs was that the adversary could give small request intervals which OPT could place differently from the algorithm, allowing it to reject some long intervals and still be fair. Rejecting long intervals allowed it to accept many short intervals which the algorithm was forced to reject. By using small intervals involving only the last few stations, one can force the online algorithm to reject intervals early. Then, giving nearly the same sequence as for the k+5 bound, using two fewer stations, OPT can still reject the same long intervals and do just as badly asymptotically. Note that in the proof, the [k− 3, k− 2) intervals are used both in the initial part, targeting the last few stations, and in the main construction that follows. 8 Theorem 13 No deterministic online algorithm for the unit price seat reservation problem has an online-bounded ratio of more than 11 k+7 . Proof Assume the number of seats n is divisible by 4. We compare an online algorithm A to an algorithm O, which follows all of the rules for OPTA. The adversary gives n/2 pairs of requests for [k − 3, k − 2) and [k − 1, k). Suppose the online algorithm, A, places these intervals such that after these requests there are exactly r seats which contain two intervals. One of two cases will occur: – Case 1: r ≥ n/4, or – Case 2: r < n/4. If Case 1 occurs, the algorithm O places all of the first n intervals on separate seats. Next there will be n/2 requests to [k − 2, k), followed by n/2 requests to [k − 3, k − 1). A will reject r ≥ n/4 of these requests to [k − 3, k − 1), but O accepts them all. This allows O to later reject n/4 intervals that A accepts. If Case 2 occurs, O pairs up the first n intervals, placing two on each of the first n/2 seats. Next there will be n/2 requests for [k− 3, k) intervals, and A rejects n/2− r ≥ n/4 of them, but O accepts them. This also allows O to later reject n/4 intervals that A accepts. 18 Boyar, Epstein, Favrholdt, Larsen, Levin Note that in both cases, A now has at least n/4 seats with the interval [k− 3, k− 2) free, while O has none. Let a be the number of intervals accepted by A up to this point and o be the number of intervals accepted by O. The value a is at most 7n/4 in Case 1 and at most 5n/4 in Case 2. The value of o is 2n in Case 1 and 3n/2 in Case 2. Now there will be n/4 requests for [1, k − 2), that A accepts and O rejects. These are followed by 3n/4 requests for [1, k − 3) that both A and O accept. Finally, there are n/4 requests for each of the intervals [i, i + 1), 1 ≤ i ≤ k − 4. A cannot accept any of these n(k− 4)/4 requests, but O accepts all of them. For this adversarial sequence, IA, A(IA) OPTA(IA) ≤ ≤ ≤ = A(IA) O(IA) a + n o + 3n/4 + n(k− 4)/4 7n/4 + n 2n + 3n/4 + n(k− 4)/4 11 , k + 7 bounds in Case 1 give the larger result. where the third inequality holds because in both cases we have o ≥ a + n 4 , so the ⊓⊔ Using a similar proof, one can show that the online-bounded ratios of First-Fit and Best- 5 Fit are at most k+1 . The major difference is that in the first part, First-Fit and Best-Fit each reject n/2 intervals, so in the second part, O can also reject n/2 intervals. Since any online algorithm for the unit price problem is 2/k-competitive, any online algorithm for the unit price problem has an online-bounded ratio of at least 2/k. 4 and a ≤ 7n References 1. Albers, S.: On the influence of lookahead in competitive paging algorithms. Algorithmica 18, 283–305 (1997) 2. Albers, S., Favrholdt, L.M., Giel, O.: On paging with locality of reference. J. Comput. Syst. Sci. 70(2), 145–175 (2005) 3. Angelopoulos, S., Dorrigiv, R., L ´opez-Ortiz, A.: On the separation and equivalence of paging strategies. In: 18th ACM-SIAM Symposium on Discrete Algorithms (SODA), pp. 229–237 (2007) 4. Azar, Y., Boyar, J., Epstein, L., Favrholdt, L.M., Larsen, K.S., Nielsen, M.N.: Fair versus unrestricted bin packing. Algorithmica 34(2), 181–196 (2002) 5. Azar, Y., Epstein, L.: On-line machine covering. Journal of Scheduling 1(2), 67–77 (1998) 6. Azar, Y., Regev, O.: On-line bin-stretching. Theoretical Computer Science 268(1), 17–41 (2001) 7. Bach, E., Boyar, J., Epstein, L., Favrholdt, L.M., Jiang, T., Larsen, K.S., Lin, G., van Stee, R.: Tight bounds on the competitive ratio on accommodating sequences for the seat reservation problem. Journal of Scheduling 6(2), 131–147 (2003) 8. Bansal, N., Sviridenko, M.: The Santa Claus problem. In: 38th Annual ACM Symposium on the Theory of Computing (STOC), pp. 31–40 (2006) 9. Ben-David, S., Borodin, A.: A new measure for the study of on-line algorithms. Algorithmica 11(1), 73–91 (1994) 10. Borodin, A., Irani, S., Raghavan, P., Schieber, B.: Competitive paging with locality of reference. Journal of Computer and System Sciences 50(2), 244–258 (1995) 11. Boyar, J., Favrholdt, L., Mikkelsen, J., Kudahl, C.: Advice complexity for a class of online problems. In: 32nd International Symposium on Theoretical Aspects of Computer Science, (STACS), Leibniz Interna- tional Proceedings in Informatics, vol. 30, pp. 116–129 (2015) Online-Bounded Analysis 19 12. Boyar, J., Favrholdt, L.M.: The relative worst order ratio for on-line algorithms. ACM Transactions on Algorithms 3(2), article 22, 24 pages (2007) 13. Boyar, J., Favrholdt, L.M., Larsen, K.S., Nielsen, M.N.: Extending the Accommodating Function. Acta Informatica 40(1), 3–35 (2003) 14. Boyar, J., Larsen, K.: The seat reservation problem. Algorithmica 25, 403–417 (1999) 15. Boyar, J., Larsen, K.S., Nielsen, M.N.: The accommodating function-a generalization of the competi- tive ratio. SIAM Journal on Computing 31(1), 233–258 (2001) 16. Breslauer, D.: On competitive on-line paging with lookahead. Theoretical Computer Science 209(1–2), 365–375 (1998) 17. Chan, S.H., Lam, T.W., Lee, L.K., Liu, C.M., Ting, H.F.: Sleep management on multiple machines for energy and flow time. In: L. Aceto, M. Henzinger, J. Sgall (eds.) Automata, Languages and Programming (ICALP), LNCS, vol. 6755, pp. 219–231. Springer-Verlag Berlin Heidelberg (2011) 18. Cho, Y., Sahni, S.: Bounds for list schedules on uniform processors. SIAM Journal on Computing 9(1), 91–103 (1980) 19. Csirik, J., Totik, V.: On-line algorithms for a dual version of bin packing. Discrete Applied Mathematics 21, 163–167 (1988) 20. Dorrigiv, R., L ´opez-Ortiz, A., Munro, J.I.: On the relative dominance of paging algorithms. Theoretical Computer Science 410, 3694–3701 (2009) 21. Ehmsen, M.R., Kohrt, J.S., Larsen, K.S.: List Factoring and Relative Worst Order Analysis. Algorithmica 66(2), 287–309 (2013) 22. Epstein, L.: Tight bounds for bandwidth allocation on two links. Discrete Applied Mathematics 148(2), 181–188 (2005) 23. Epstein, L., Favrholdt, L.M., Kohrt, J.S.: Separating online scheduling algorithms with the relative worst order ratio. Journal of Combinatorial Optimization 12(4), 363–386 (2006) 24. Epstein, L., Noga, J., Seiden, S.S., Sgall, J., Woeginger, G.J.: Randomized online scheduling on two uniform machines. Journal of Scheduling 4(2), 71–92 (2001) 25. Giannakopoulos, Y., Koutsoupias, E.: Competitive analysis of maintaining frequent items of a stream. Theoretical Computer Science 562, 23–32 (2015) 26. Graham, R.L.: Bounds for certain multiprocessing anomalies. Bell Systems Technical Journal 45, 1563– 1581 (1966) 27. Kalyanasundaram, B., Pruhs, K.: Speed is as powerful as clairvoyance. Journal of the ACM 47(4), 617–643 (2000) 28. Karlin, A.R., Manasse, M.S., Rudolph, L., Sleator, D.D.: Competitive snoopy caching. Algorithmica 3, 79–119 (1988) 29. Karlin, A.R., Phillips, S.J., Raghavan, P.: Markov paging. SIAM Journal on Computing 30(3), 906–922 (2000) 30. Kenyon, C.: Best-fit bin-packing with random order. In: 7th ACM-SIAM Symposium on Discrete Algo- rithms (SODA), pp. 359–364 (1996) 31. Koutsoupias, E., Papadimitriou, C.H.: Beyond competitive analysis. SIAM Journal on Computing 30(1), 300–317 (2000) 32. Miyazaki, S., Okamoto, K.: Improving the competitive ratios of the seat reservation problem. In: 6th IFIP TC 1/WG 2.2 International Conference on Theoretical Computer Science (IFIP TCS), IFIP Advances in Information and Communication Technology, vol. 323, pp. 328–339. Springer (2010) 33. Raghavan, P.: A statistical adversary for on-line algorithms. In: On-Line Algorithms, Series in Discrete Mathematics and Theoretical Computer Science, vol. 7, pp. 79–83. American Mathematical Society (1992) 34. Sleator, D.D., Tarjan, R.E.: Amortized efficiency of list update and paging rules. Communications of the ACM 28(2), 202–208 (1985) 35. Woeginger, G.J.: A polynomial-time approximation scheme for maximizing the minimum machine com- pletion time. Operations Research Letters 20(4), 149–154 (1997) 36. Young, N.: Competitive paging and dual-guided algorithms for weighted caching and matching (thesis). Tech. Rep. CS-TR-348-91, Computer Science Department, Princeton University (1991) 37. Young, N.E.: The k-server dual and loose competitiveness for paging. Algorithmica 11, 525–541 (1994)
1205.6787
1
1205
2012-05-30T19:44:17
Lyndon Words and Short Superstrings
[ "cs.DS" ]
In the Shortest-Superstring problem, we are given a set of strings S and want to find a string that contains all strings in S as substrings and has minimum length. This is a classical problem in approximation and the best known approximation factor is 2 1/2, given by Sweedyk in 1999. Since then no improvement has been made, howerever two other approaches yielding a 2 1/2-approximation algorithms have been proposed by Kaplan et al. and recently by Paluch et al., both based on a reduction to maximum asymmetric TSP path (Max-ATSP-Path) and structural results of Breslauer et al. In this paper we give an algorithm that achieves an approximation ratio of 2 11/23, breaking through the long-standing bound of 2 1/2. We use the standard reduction of Shortest-Superstring to Max-ATSP-Path. The new, somewhat surprising, algorithmic idea is to take the better of the two solutions obtained by using: (a) the currently best 2/3-approximation algorithm for Max-ATSP-Path and (b) a naive cycle-cover based 1/2-approximation algorithm. To prove that this indeed results in an improvement, we further develop a theory of string overlaps, extending the results of Breslauer et al. This theory is based on the novel use of Lyndon words, as a substitute for generic unbordered rotations and critical factorizations, as used by Breslauer et al.
cs.DS
cs
Lyndon Words and Short Superstrings Marcin Mucha∗ [email protected] June 11, 2018 Abstract In the shortest superstring problem, we are given a set of strings {s1, . . . , sk} and want to find a string that contains all si as substrings and has minimum length. This is a classical problem in approximation and the best known approximation factor is 2 1 2 , given by Sweedyk [19] in 1999. Since then no improvement has been made, howerever two other approaches yielding a 2 1 2 -approximation algorithms have been proposed by Kaplan et al. [10] and recently by Paluch et al. [16] -- both based on a reduction to maximum asymmetric TSP path (Max-ATSP-Path) and structural results of Breslauer et al. [5]. In this paper we give an algorithm that achieves an approximation ratio of 2 11 23 , breaking through the long-standing bound of 2 1 2 . We use the standard reduction of Shortest-Superstring to Max-ATSP-Path. The new, somewhat surprising, algo- rithmic idea is to take the better of the two solutions obtained by using: (a) the currently best 2 3 -approximation algorithm for Max-ATSP-Path and (b) a naıve cycle-cover based 2 -approximation algorithm. To prove that this indeed results in an improvement, we fur- ther develop a theory of string overlaps, extending the results of Breslauer et al. [5]. This theory is based on the novel use of Lyndon words, as a substitute for generic unbordered rotations and critical factorizations, as used by Breslauer et al. 1 1 Introduction The Shortest Superstring Problem In the Shortest-Superstring problem we are given a set of strings {s1, . . . , sk} and want to find a string that contains all si as substrings and has minimum length. The problem has several applications including data compression [8, 18] and DNA sequencing [13, 14, 17, 24]. In the latter, one attempts to reconstruct a DNA molecule, which is a string over the alphabet {A, C, G, T }, based on a massive set of short fragments. These fragments (i.e. substrings) of the molecule can be obtained by sequencing. The reconstruction problem can be viewed as a shortest superstring problem based on the premise that the original molecule is a superstring of all the fragments, and that shorter superstrings should in general be more similar to the original. Previous Results Since Shortest-Superstring is NP-hard [8, 9] and even MAX-SNP- hard [4, 23], the best we can hope for in terms of approximation is a constant factor. A lot of effort went into designing approximation algorithms for the problem, Table 1 summarizes these developments. Note that the last two results, by Kaplan et al. [10] and Paluch et al. [16] ∗This work was partially supported by the ERC StG project PAAl no. 259515 1 Authors Li [14] Blum, Jiang, Li, Tromp, Yannakakis [4] Teng, Yao [21] Czumaj, Gasieniec, Piotr´ow, Rytter [7] Kosaraju, Park, Stein [12] Armen, Stein [1] Armen, Stein [2] Breslauer, Jiang, Jiang [5] Sweedyk [19] Kaplan, Lewenstein, Shafrir, Sviridenko [10] Paluch, Elbassioni, van Zuylen [16] Factor Date 1990 O(log(n)) 1991 1993 1994 1994 1995 1996 1997 1999 2005 2012 3 2 8 9 2 5 6 2 50 63 2 3 4 2 2 3 2 25 42 2 1 2 2 1 2 2 1 2 Table 1: Previous results for the Shortest-Superstring problem. do not improve the approximation factor. They both give 2 3 -approximation algorithms for the related Max-ATSP-Path problem. Using a black-box reduction due to Breslauer et al. [5], these give 2 1 2 -approximation algorithms for Shortest-Superstring. Both, especially the one due to Paluch et al., are significantly simpler than the original result of Sweedyk. Parallel to these developments, some progress has been made towards resolving the Greedy Superstring Conjecture (see [18, 20, 22]), which says that the greedy approach of repeatedly picking the two strings that overlap the most and gluing them together until only a single string remains, is actually a 2-approximation. Blum et al. [4] showed that the greedy algorithm gives a 4-approximation, and Kaplan et al. [11] improved this to 3 1 2 . Our Results/Techniques In this paper we develop several results that describe the struc- ture of the overlaps of a collection of strings. Our results can be viewed as an extension of the framework introduced by Breslauer et al. [5]. However, while Breslauer et al. use generic unbordered rotations and critical factorizations, we construct ours by using Lyndon words. It turns out that the added control we gain in this way allows for much more precise structural analysis of string overlaps. We use these results to obtain a 2 11 therefore break a long-standing bound of 2 1 2 . 23 -approximation for Shortest-Superstring, and The basic idea of our approach is the following. For two strings u, v, let the overlap of u and v, denoted ov(u, v), be the longest suffix of u which is also a prefix of v. The overlap graph of a set of strings S is a complete directed graph on S with edge weights equal to lengths of corresponding overlaps. Blum et al. [4] show how approximating Shortest-Superstring for a set of strings S can be reduced to approximating the problem of finding a longest path in the overlap graph of a certain auxiliary set of strings R(S), called representative strings. The performance of the resulting algorithm depends on how well we can bound the overlap loss in the longest path approximation. This bound can essentially be improved in two ways: by using a better approximation algorithm for the longest path problem in directed graphs (Max-ATSP-Path), or by pro- viding a better bound on the overlap of the optimum path. For the first direction, Kaplan et al. [10] and Paluch et al. [16] both give 2 3 -approximation for Max-ATSP-Path, which is the 2 best known. For the second, the bounds given by Breslauer et al. [5] are essentially tight. In this paper we propose a third way to improve by joining the two objectives. Note that one can approximate Max-ATSP-Path by finding a maximum weight cycle cover, removing the lightest edge on each cycle, and then joining the resulting paths with arbitrary edges. This naıve algorithm only gives 1 3 , the tight case being balanced 2-cycles. We observe however, that with a careful choice of representative strings R(S), if the bounds given by Breslauer et al. are nearly tight, the cycles in the maximum weight cycle cover are far from balanced. So far in fact, that choosing the better of the two solutions: one given by a 2 3 -approximation algorithm, and one given by our naıve algorithm, results in an approximation algorithm for Shortest-Superstring with ratio strictly smaller than 2 1 2 . 2 -approximation, significantly weaker than 2 It is worth noting that, similarly to the approach of Breslauer et al., our algorithm is a black-box reduction from Shortest-Superstring to Max-ATSP-Path. Therefore, any improvements on the approximation factor for the latter will yield an improvement for the former. Organization of the Paper The paper is organized as follows. In Section 2 we recall some facts regarding the properties of strings and their overlaps, as well as the standard approach to shortest string approximation. In Section 3 we describe the new algorithm and analyse its approximation factor. This analysis relies on Theorem 3.2, which is the main technical result of this paper. The remaining part of the paper is devoted to proving this theorem. In Section 4 we present some general bounds concerning overlaps of strings. We believe they might be of independent interest. In Section 5 we use these bounds to prove the main theorem. Since the proof is a rather long and detailed case analysis, to facilitate understanding of the basic ideas of the paper, in Subsection 5.2 we give a simple proof of a weaker version of the main theorem. This version still gives an approximation factor smaller than 2 1 2 . Finally in Section 6 we show that Theorem 3.2 is essentially tight. We also briefly discuss reasons why using our bounds to improve the analysis of the greedy algorithm might be difficult. 2 Preliminaries In this section we recall some definitions, results and ideas concerning basic properties of strings. For a more extensive exposition the reader should consult any of the standard text- books on combinatorics on words, e.g. the excellent monograph by Lothaire [15]. We also describe the standard framework for Shortest-Superstring approximation. Our presentation mostly follows that of Breslauer et al. [5]. Note however, that instead of generic critical factorizations we use nice rotations, introduced at the end of Subsection 2.1. This requires almost no changes in the framework, except for the proof of Lemma 2.7, which we provide. 2.1 Stringology Basic concepts For a string v, we will use v[i] to denote the i-th letter of v, and v[i, j] to denote the substring of v consisting of letters i, . . . , j. We will use vu to denote concatenation of v and u, and vk to denote the concatenation of k copies of v. We will also use v∞ to denote 3 the semi-infinite string vvv . . .. Any representation of w = uv as a concatenation of two (not necessarily nonempty) strings is called a factorization of w. The factorization is nontrivial if both u and v are nonempty. For a string w of length n, any integer 1 ≤ p ≤ n is a period of w if w[i] = w[i + p] for all 1 ≤ i ≤ n − p. Note that w always has at least one period, that is its length. The smallest period of w is called the minimum period of w or simply the period of w, and denoted p(w). A string w is primitive if there is no v such that w = vk with k ≥ 2. A string z is called a rotation of w if there exists a factorization w = uv such that z = vu. In that case we also say that z is a rotation starting at position u + 1, or that u + 1 is z's starting position in w. It is easy to see that if z is a rotation of w, then z is primitive iff w is. It is also a standard fact that if w is primitive, then any rotation corresponding to a nontrivial factorization of w is different from w. More generally, for a primitive w and two different factorizations w = u1v1 and w = u2v2, the rotations v1u1 and v2u2 are different. It follows that for primitive w, every rotation of w has a unique starting position in w. We say that two strings are equivalent if one is a rotation of the other. Otherwise they are non-equivalent. We will assume a fixed order on the alphabet. This order induces a standard lexicograph- ical order on the set of strings. We use u ≺ v to denote that u is lexicographically smaller than v, and u (cid:22) v to denote that u is smaller or equal to v. Let w be a primitive string and consider the order induced by ≺ on all rotatations of w. Let wmin and wmax be the minimal and maximal rotations in this order. Also, denote by imin(w) and imax(w) the starting positions of wmin and wmax in w. Moreover, let pmin(w) and pmax(w) be strings such that wmin = pmin(w)pmax(w) and wmax = pmax(w)pmin(w). Lemma 2.1. Let w, w ≥ 2 be a primitive string. Then both pmin(w) and pmax(w) are nonempty. In other words, wmin 6= wmax. Proof. Since w ≥ 2 and w is primitive, it contains at least 2 different letters. It follows that wmin and wmax start with different letters, and so they are different strings. In particular both pmin(w) and pmax(w) are nonempty. The following property of wmin and wmax is implicitly used by Crochemore et al. [6]. Lemma 2.2. Let w, w ≥ 2 be a primitive string. Then wmax is the only rotation of w that starts with pmax(w), and wmin is the only rotation that starts with pmin(w). Proof. We will prove the claim for pmax(w), the other part of the proof is analogous. Suppose that there is a rotation z = pmax(w)v of w, other than wmax = pmax(w)pmin(w), that starts with pmax(w). We claim that z ≻ wmax which is a contradiction. To see that, notice that they both start with pmax(w), and v (cid:23) pmin(w) since pmin(w) is a prefix of the minimal rotation of w. The claim follows, since v 6= pmin(w). Borders A nonempty string b is called a border of a string w if w = bu = vb for some nonempty u, v. A string is unbordered if it has no border. So, a string w is unbordered if w has no proper prefix that is also a suffix of w. The following is a standard fact (see e.g. Proposition 5.1.2 in Lothaire [15]). Lemma 2.3. Every primitive string w has a rotation that is unbordered. In particular, wmin and wmax are unbordered. 4 Proof. Suppose that wmax has a border, i.e. there exists a proper prefix v of wmax which is also its suffix. Let w = wmax = n and v = k < n. Since v is a suffix of wmax, we know that u = (vwmax)[1, n] is a rotation of w. We claim that u ≻ wmax, which is a contradiction. To see this, notice that u[1, k] = v = wmax[1, k] and also u[k + 1, n] = wmax[1, n − k] (cid:23) wmax[k + 1, n], since wmax is maximal. So u (cid:23) wmax, but this cannot be an equality since rotations of a primitive string are all different. The same proof applies to wmin or one can simply notice that it is a maximal rotation in the lexicographical order induced by the reversed order on the alphabet. Remark. A primitive string w such that w = wmax is called a Lyndon word1 (w.r.t. the particular order on the alphabet that is used to define the lexicographical order). Note that the two rotations appearing in Lemma 2.3 are Lyndon words, and in fact this Lemma is equivalent to saying that Lyndon words are unbordered. Remark. One of the key ingredients of the results of Breslauer et al. [5] is the notion of a crit- ical factorization and ,,The Critical Factorization Theorem" (see C´esari et al. [25]). Although we do not use them directly, a reader acquainted with Breslauer et al. [5] will realize that they are nevertheless present in our work. In particular pmin(w)pmax(w) and pmax(w)pmin(w) are critical factorizations (this fact was used by Crochemore et al. [6] in their proof of the Critical Factorization Theorem). Nice rotations Let w, w ≥ 2 be a primitive string. The nice rotation of w is de- fined to be wmax if pmax(w) ≤ pmin(w), otherwise it is defined to be wmin. Let α(w) = min(pmax(w), pmin(w)). We will call a primitive string nice if it is its own nice rotation. Note that if w is nice, then: • w = wmax and α(w) = pmax(w) ≤ w/2, or • w = wmin and α(w) = pmin(w) < w/2. In particular we always have α(w) ≤ w/2. For a nice string w, we call x a w-string if x is a prefix of w∞. 2.2 Shortest Superstring Approximation Basic ideas strings and that no string in S is a substring of another string In the remainder of this paper we assume w.l.o.g. that S contains at least two For two strings u, v define the overlap of u and v, denoted ov(u, v), as the longest suffix of u that is also a prefix of v. Also, define the prefix of u w.r.t. v, denoted pref(u, v), as the string x such that u = xov(u, v), i.e. prefix is the part of u that does not overlap v. The following two directed graphs are good models of how the strings in S overlap with each other. The overlap graph of S is a complete directed graph with S as the vertex set, and edge (si, sj) having length ov(si, sj). The prefix graph (also called the distance graph) is defined similarly, only edge (si, sj) now has length pref(si, sj). 1We use term "word" here and not "string" as "Lyndon word" seems to be a well established phrase. In general, the algorithmic community tends to use the term "string" and the combinatorial community uses the term "word". We decided to follow this rule and use the term "string" with the single exception of "Lyndon word". 5 Let hsi1, si2, . . . , sini be the string pref(si1, si2)pref(si2, si3) . . . pref(sin−1, sin)sin. Obvi- ously, it is the shortest string containing si1, si2, . . . , sin in that order. Notice that the optimal solution has the form hsi1, si2, . . . , sini for some ordering si1, si2, . . . , sin of the strings in S. The length of hsi1, si2, . . . , sini is equal to pref(si1, si2) + pref(si2, si3) + . . . + pref(sin−1, sin) + pref(sin, si1) + ov(sin, si1), which is the length of the cycle si1 → si2 → . . . → sin in the prefix graph of S increased by ov(sin, si1). Thus, the length of the shortest TSP tour in the prefix graph of S lowerbounds the length of the shortest superstring. The above considerations suggest that reduction to asymmetric TSP might be useful in approximating Shortest-Superstring. Unfortunately, the best known approximation algorithm for asymmetric TSP has factor O(cid:16) log n log log n(cid:17) (see [3]), so this approach is not very useful. Let us look again at a generic solution hsi1, si2, . . . , sini and this time express its length in terms of the overlap graph: hsi1, si2, . . . , sini = n Xj=1 sj − n−1 Xj=1 ov(sij , sij+1). The right term in the above expression (the total overlap of hsi1, si2, . . . , sini) is the length of the path si1, . . . , sin in the overlap graph, so the longest TSP path in the overlap graph corresponds to the optimal solution for Shortest-Superstring. Longest TSP path in a directed graph (called Max-ATSP-Path) can be approximated within constant factor. Notice however, that this does not lead to a constant factor approximation for Shortest- Superstring. The problem is that the total overlap of the optimal solution could be very large compared to its length. In that case even a very good approximation algorithm for total overlap might only give mediocre approximation for the length of the superstring. Two-step reduction to Max-ATSP-Path We can avoid the problems described in the previous paragraph by using the following two-step approach introduced by Blum et al. [4]: 1. Find a minimum cycle cover Cmin in the distance graph. 2. For each cycle C ∈ Cmin construct a representative string R(C) containing all strings in C as substrings, let R = R(Cmin) = {R(C) : C ∈ Cmin}. 3. Find a Shortest-Superstring solution for R by reducing to Max-ATSP-Path. The idea here is that the first step groups strings with large overlaps together, so that the overlaps of the strings in R are relatively small, and then the last step actually gives good approximation. The following series of lemmas and definitions from Blum et al. [4] and Breslauer et al. [5] gives an idea of why this approach works. For any cycle C = si1 → si2 → . . . → sik in Cmin let R(C) = hsi1, si2, . . . , sik , si1i. Note two interesting features of this definition. First, depending on where we break the cycle we can start R(C) with any of the strings si1, . . . , sik . Second, R(C) is actually "too long" as it unnecessarily contains two copies of si1 -- this will turn out useful later on. Let OP T (S) and OP T (R) be the lengths of optimal Shortest-Superstring solutions for S and R. 6 Lemma 2.4 (Follows from Lemma 2.6 of [5], also implicit in [4]). OP T (R) ≤ 2OP T (S). For a cycle C = si1 → si2 → . . . → sik in the prefix graph define s(C) = pref(si1, si2)pref(si2, si3), . . . , pref(sik , si1). Then s(C) is the length of C and s(C) essentially reads the prefixes along the cycle. The strings s(C) for C ∈ Cmin have very interesting properties. Lemma 2.5 (Claims 3 and 5 in Blum et al. [4] ). The strings s(C) all all primitive with s(C) ≥ 2 and are all non-equivalent. Let w(C) be the nice rotation of s(C) for every C ∈ Cmin. As we already mentioned, the representative strings R(C) defined as earlier are unnecessary long. This can be used to prove the following. Lemma 2.6 (Special case of Lemma 5.1 in Breslauer et al. [5]). One can define the repre- sentative R(C) for a cycle si1 → . . . → sik so that: • R(C) is a substring of hsij , sij+1, . . . , sik , si1, . . . , sij i for some j (in particular OP T (R) ≤ 2OP T (S) still holds), • R(C) is a w(C)-word. Finally, we need to show that the strings R(C) do not overlap too much. The lemma below is stated in a slightly more general fashion so that it can be used more easily later on. Lemma 2.7 (Implicit in the proof of Lemma 3.3 in Breslauer et al. [5]). Let w1 and w2 be non-equivalent nice words and let xi be a wi-word for i = 1, 2. Also let αi = α(wi) and li = wi. Then ov(x1, x2) < l1 + α2. Proof. Assume for a contradiction that ov(x1, x2) ≥ l1 + α2. Consider the string z = ov(x1, x2)[l1 + 1, l1 + α2]. We have z = ov(x1, x2)[1, α2] = w2[1, α2], so we need to have l1 = kl2 for some k because of Lemma 2.2, which is impossible. To see why, notice that if l1 = kl2 and ov(x1, x2) ≥ l1, then either w1 and w2 are equivalent (if k = 1) or w1 is nonprimitive (if k > 1). Theorem 2.8 (Breslauer et al. [5]). Given c-approximation for Max-ATSP-Path, one can approximate Shortest-Superstring with approximation factor of 3 1 2 − 1 1 2 c. Proof. Consider the string s = hR(C1), . . . , R(Ck)i that is the optimal solution for R. Let ROV be the total overlap of this string. Then by applying Lemma 2.7 to every pair of consecutive strings we get ROV ≤ k−1 Xi=1 (w(Ci) + α(w(Ci+1))) ≤ 3 2 k Xi=1 w(Ci) ≤ 3 2 OP T (S). A c-approximation algorithm for Max-ATSP-Path can be used to obtain a solution with to- tal overlap of cROV . The length of the resulting Shortest-Superstring solution is therefore at most OP T (R) + 3 2 (1 − c)OP T (S) ≤ 2OP T (S) + 3 2 (1 − c)OP T (S) = (cid:18)3 1 2 − 1 1 2 c(cid:19) OP T (S). 7 Since 2 3 -approximation algorithms for Max-ATSP-Path are known we obtain the follow- ing Corollary 2.9 (Kaplan et al. [10], also Paluch et al. [16]). There exists a 2 1 algorithm for Shortest-Superstring. 2 -approximation 3 The Algorithm In this section we give the new approximation algorithm and bound its approximation factor. Description The algorithm we are going to analyse is very simple. It returns a solution S0 which is the better of the following two solutions S1, S2: • S1 is obtained by using any algorithm that reduces Shortest-Superstring to Max- ATSP-Path (e.g. one due to Kaplan et al. [10] or Paluch et al. [16]), • S2 is also obtained by reducing to Max-ATSP-Path, but this time we get the final solution by computing the maximum weight cycle cover in the overlap graph of R and dropping the lightest edge from every cycle. Analysis For any cycle C in the overlap graph let OC be the total overlap of C, i.e. sum of the weights of its edges. Let MC be the minimum weight of an edge of C. Also, let LC be the sum of the periods of the strings in C, which is equal to the total length of the corresponding cycles in Cmin. Let R be the total length of the representative strings in R and let C be the maximum weight cycle cover in the overlap graph of R. Note that PC∈C LC = w(Cmin). Moreover, let OC = PC∈C OC , let MC = PC∈C MC . Finally, let c be the best known approximation ratio for Max-ATSP-Path. Lemma 3.1. S1 ≤ OP T (R) + (1 − c)OC and S2 ≤ OP T (R) + MC. Proof. We have R − OC ≤ OP T (R) and S2 ≤ R − OC + MC which proves the second part. For the first, note that since OC ≥ R − OP T (R), any algorithm that approximates R − OP T (R) with factor c gives a solution of length at most S1 ≤ R − c(R − OP T (R)) = OP T (R) + (1 − c)(R − OP T (R)) ≤ OP T (R) + (1 − c)OC. The main technical ingredient of this paper is the following theorem (we show in Section 6 that it is essentially tight). Theorem 3.2 (Main Theorem (local version)). For any cycle C in the overlap graph, we have 2MC + 7OC ≤ 11LC . By summing over all cycles of C we obtain the following. Theorem 3.3 (Main Theorem (global version)). 2MC + 7OC ≤ 11w(Cmin) ≤ 11OP T (S). The next two sections are devoted to the proof of Theorem 3.2. For now let us see what it implies. 8 Corollary 3.4. Shortest-Superstring can be approximated with factor (cid:16)2 + 11(1−c) 9−2c (cid:17). In particular for c = 2 3 we get 2 11 23 -approximation. Proof. It follows from Lemma 3.1 and Lemma 2.4 that S0 ≤ 2OP T (S) + min(MC, (1 − c)OC). We can bound the second term as follows: min(MC, (1 − c)OC) ≤ 2 − 2c 9 − 2c MC + 7 9 − 2c (1 − c)OC ≤ 11(1 − c) 9 − 2c OP T (S). For c = 2 3 we obtain 11· 1 3 9−2· 2 3 = 11 23 and so S0 ≤ 2 11 23 OP T (S). 4 The General Bounds In this section we present and prove the bounds on overlaps of strings. We consider a set of non-equivalent nice strings w1, . . . , wk, and for each i = 1, . . . , k a wi-string xi. We use li to denote wi, and αi to denote α(wi). Moreover, for each i 6= j, i, j ∈ {1, . . . , k} we define ovij = ov(xi, xj) and oij = ovij. Finally, let wij be the rotation of wi that matches ov(xi, xj) from the left. If there is more than one such rotation (which might happen if oij < li), choose any such rotation. By Lemma 2.7 we have o12 ≤ l1 + 1 2 l2. The main theme of this section is characterizing situations in which this inequality is in some way non-tight. The underlying idea in most (but not all) of these results is the following: We show that if o12 is actually close to its upper-bound, then the set of possible starting positions of the maximal/minimal rotation of w1 is strongly limited, which in turn leads to an upper-bound on α1. This can be used to upper-bound other overlaps using Lemma 2.7. We start with another lemma from the work of Breslauer et al. [5]. Lemma 4.1 (Implicit in the proof of Lemma 3.3 of Breslauer et al. [5]). If l1 ≤ l2 then o12 < l2. For general l1, l2 we have o12 < kl2 whenever l1 ≤ kl2. Proof. Assume for a contradiction that l1 ≤ kl2 and o12 ≥ kl2. Also, w.l.o.g. assume that k is the smallest integer such that l1 ≤ kl2. Similarly as in the proof of Lemma 2.7 we cannot have l1 = kl2, and we also cannot have l1 = (k − 1)l2 for the same reasons. Therefore (k − 1)l2 < l1 < kl2. Consider now the string ov12[l1 + 1, kl2] = ov12[1, kl2 − l1]. This string is a non-trivial suffix of w2, and also a prefix of w2, a contradiction with w2 being nice and Lemma 2.3. The next two lemmas demonstrate that o12 getting close to l1 + 1 2 l2 implies an upper- bound on the value of α1. While Lemma 4.3 gives this bound explicitly, Lemma 4.2 describes it in terms of constraints on the starting positions of maximal and minimal rotations of w1. Lemma 4.2. Let l1 ≥ l2, o12 ≥ l2 and let w2 be its maximal rotation, then: • imax(w12) = 1, or imax(w12) = l2⌊ o12−1 l2 α2 + 1). ⌋ + 1 or imax(w12) > max(l2⌊ o12−1 l2 ⌋ + 1, o12 − 9 • imin(w12) = α2+1, or imin(w12) = l2⌊ o12−α2−1 ⌋+α2+1, or imin(w12) > max(l2⌊ o12−α2−1 l2 ⌋+ l2 α2 + 1, o12 − (l2 − α2) + 1), Moreover, if o12 ≥ l1, then imax(w12) 6= 1 and imin(w12) = α2 + 1. Remark. Several of the lemmas appearing in the remainder of this section assume that one of the strings involved is its maximal rotation. In all cases a symmetrical statement is true as well, in which the roles of minimal and maximal rotations of all strings involved are reversed. We omit the corresponding statements in all these lemmas. Proof (of Lemma 4.2). Let us start with claims concerning imax(w12). Since we assume o12 ≥ l2, we know that w12 contains pmax(w2). Therefore (w12)max[1, α2] (cid:23) pmax(w2). We now consider two cases, depending on whether or not imax(w12) ≤ o12 − α2 + 1. If imax(w12) ≤ o12 − α2 + 1, then imax(w12) + α2 − 1 ≤ o12 and consequently Case 1: (w12)max[1, α2] (cid:22) pmax(w2). By the previous observation this is in fact an equality, and by Lemma 2.2 imax(w2) = kl2 + 1 for some natural k, i.e. the maximal rotation of w12 is aligned with the starting position of some occurence of w2 in o12. The two positions that appear in the statement of the lemma: α2 + 1 and l2⌊ o12−1 ⌋ + 1, are the starting positions of the leftmost and the rightmost occurences, respectively. We will show that imax(w12) has to be equal to one of them. l2 Suppose that this is not the case. This means that we have imax(w12) = kl2 + 1 and both (k − 1)l2 + 1 and (k + 1)l2 + 1 are in [1, . . . , o12]. Note that by Lemma 4.1 we then also have (k + 1)l2 ≤ l1, and in fact (k + 1)l2 < l1 since otherwise l1 would not be primitive. Therefore (k + 1)l2 + 1 ≤ l1. Consider the rotations r1, r2, r3 of w12 starting at positions (k − 1)l2 + 1, kl2 + 1 and (k + 1)l2 + 1, respectively. We have r1 = w2w2w, r2 = w2ww2 and r3 = ww2w2 for some string w. Since all rotations of a primitive string are different, we have ww2 6= w2w. If ww2 ≻ w2w, then r3 is the largest of the three rotations. If, on the other hand, ww2 ≺ w2w, then r1 is the largest one. Therefore imax(w12) 6= kl2 + 1, a contradiction. Case 2: We are left with the case where imax(w12) > o12 − α2 + 1, and we can also assume that we do not have imax(w12) = l2⌊ o12−1 ⌋ + 1 since then the lemma clearly holds. We need to prove that imax(w12) > l2⌊ o12−1 ⌋ + 1. If that was not the case, then (k − 1)l2 + 1 < imax(w12) ≤ kl2 < o12 for k = ⌊ o12−1 ⌋. Then w12[imax(w12), kl2] is a non-trivial suffix of w2, and it is also a prefix of w2 by maximality of the rotation of w12 starting at imax(w12). But that is a contradiction with the fact that w2 is unbordered by Lemma 2.3. This ends the proof of the bounds for imax(w12). l2 l2 l2 One final claim we need to show concerning imax(w12) is that if o12 ≥ l1, then imax(w12) 6= 1. Since for o12 ≥ l1 we have l1 > l2, there are at least two positions of the form kl2 + 1 within w12. Consider rotations r1 and r2 of w12 starting at two consecutive such positions kl2 + 1 and (k + 1)l2 + 1. We will prove that r1 ≺ r2, which implies our claim. We have r1 = w2wwk 2 . In particular, we have r1 = wvwk 2 for some v which is a rotation of w2. Since r1 6= r2 by Lemma 2.2, and w2 is its maximal rotation, we conclude that r1 ≺ r2. for some w which is a prefix of w∞ 2 and r2 = wwk+1 2 Let us now prove the claims concerning imin(w12). Similarly to the case of imax(w12) we can argue that either imin(w12) > o12 − (l2 − α2) + 1 or we have imin(w12) = kl2 + α2 + 1 for some k. This time it will be more convenient to start with the case of o12 ≥ l1. Among rotations starting at positions of the form kl2 + α2 + 1, the one starting at α2 + 1 is minimal in this case, and the proof is almost identical to the one we just presented for imax(w12). 10 So we only need to exclude the case where o12 ≥ l1 and imin(w12) > o12 − (l2 − α2) + 1. If that happened, then we would have (w12)min[1, l2 − α2] = w12[imin(w12), l1]w, where w is a non-empty prefix of w2. Call this string r1 and let r2 = w12[α2 + 1, l2]. We claim that r2 ≺ r1, which is a contradiction with minimality of r1. To see that r2 ≺ r1, note that w12[α2 + 1, α2 + l1 − imin(w12)] (cid:22) w12[imin(w12), l1] by the definition of α2. Moreover w12[l2 − w + 1, l2] (cid:22) w because w is a prefix of (w2)max. But we cannot have an equality here, since then w would also be a suffix of (w2)max, a contradiction with Lemma 2.3. Let us now prove the main claims concerning imin(w12). Again, we consider two cases. If imin ≤ o12 − (l2 − α2) + 1 and consequently imin(w12) is of the form kl2 + α2 + 1, Case 1: then we can show that we have either imin(w12) = α2 + 1 or imin(w12) = l2⌊ o12−α2−1 ⌋ + α2 + 1. The proof is almost identical to the one we provided for imax(w12). The only step that does not directly translate, is that the rightmost position of the form kl2 + α2 + 1 within ov12 is also within w12. Luckily, we already considered the case of o12 ≥ l1. Case 2: imin(w12) = l2⌊ o12−α2−1 Again, the proof is almost identical to the one for imax(w12). If imin(w12) > o12 − (l2 − α2) + 1, then we can also assume that we do not have ⌋ + α2 + 1. ⌋ + α2 + 1. We need to show that imin(w12) > l2⌊ o12−α2−1 l2 l2 l2 Lemma 4.3. Let l1, o12 ≥ l2 and let w2 be its maximal rotation. Then we always have α1 ≤ l2 + (l1 + α2 − o12) and moreover: 1. either α1 ≤ l1 + l2 − o12, or 2. the maximal rotation of w12 starts at the rightmost position of the form kl2 + 1, or the minimal rotation of w12 starts at the rightmost position of the form kl2 + α2 + 1. Proof. Since we assume o12 ≥ l2, Lemma 4.2 describes all posibilities for imin(w12) and imax(w12). The rest is simple case analysis. If either imax(w12) = l2⌊ o12−1 ⌋ + 1 or imin(w12) = l2⌊ o12−α2−1 ⌋ + α2 + 1 (i.e. the second alternative in the statement of the lemma holds) then imin(w12) is either at most α2 + 1 or at least o12 − l2 + 1 by Lemma 4.2, and the same bounds hold for imax(w12). "Wrapping around" the end of w12, they both land in an interval of length l1 − (o12 − l2) + α2 = l2 + (l1 + α2 − o12) and hence this quantity is also an upper bound on α1. If neither imax(w12) = l2⌊ o12−1 ⌋+α2 +1, then Lemma 4.2 gives even stronger bounds. We have imin(w12) ≤ α2 + 1 or imin(w12) > o12 − (l2 − α2) + 1 and the same bounds (in fact stronger) hold for imax(w12). Repeating the previous argument we get ⌋+1 nor imin(w12) = l2⌊ o12−α2−1 l2 l2 l2 l2 α1 ≤ l1 − (o12 − (l2 − α2)) + α2 = l1 + l2 − o12. The next two lemmas state some of the consequences of Lemmas 4.2 and 4.3, that are particularly easy to use. Lemma 4.4. If l1 ≥ l2 then: 1. o12 + α1 ≤ l1 + l2 for l1 < 2l2, 2. o12 + α1 ≤ 2l1 − l2 = l1 + l2 + (l1 − 2l2) for 2l2 ≤ l1 < 5 2 l2, 3. o12 + α1 ≤ l1 + l2 + α2. 11 Proof. In the proof, we assume w.l.o.g. that w2 is its maximal rotation. Let us first consider the case of l1 < 2l2. If o12 < l1 then we get the claim, since α1 ≤ 1 2 l1 ≤ l2. On the other hand, if o12 ≥ l1 (note that in this case l1 > l2), then by Lemma 4.2 we have imin(w12) = α2 + 1 and imax(w12) ∈ {l2 + 1} ∪ (o12 − α2 + 1, . . . , l1]. Therefore, we either have α1 ≤ l2 − α2 or α1 ≤ (l1 − o12 + α2) + α2 and in both cases it is easy to verify that our claim is true. To prove the second inequality, we consider three cases: Case 1: If o12 < l1 then o12 + α1 ≤ l1 + α1 ≤ 3 2 l1 ≤ 2l1 − l2. Case 2: If the first alternative in Lemma 4.3 holds, i.e. α1 ≤ l1 + l2 − o12 then o12 + α1 ≤ l1 + l2 ≤ 2l1 − l2. Case 3: We are left with the case where the second alternative of Lemma 4.3 holds. Since o12 ≥ l1 and so imin(w12) = α2 + 1, this means that imax(w12) = 2l2 + 1. It follows that α1 ≤ (l1 − 2l2) + α2 and so o12 + α1 ≤ (l1 + α2) + (l1 − 2l2) + α2 ≤ 2l1 − l2. The third inequality of Lemma 4.4 follows immediately from the inequality α1 ≤ l2 + (l1 + α2 − o12) in the first part of Lemma 4.3. 2 lj) − oij and ∆αi = 1 oij and αi are from their maximum values. Let ∆oij = (li + 1 2 li − αi. These basically measure how much smaller Corollary 4.5. 1. ∆o12 + ∆α1 ≥ 1 2 (l1 − l2) if l1 < 2l2, 2. ∆o12 + ∆α1 ≥ 1 4 (l1 − l2) if l1 ≥ 3l2, and 3. ∆o12 + ∆α1 ≥ 1 6 (l1 − l2). Proof. For the first inequality, we have by Lemma 4.4 ∆o12 + ∆α1 = 3 2 l1 + 1 2 l2 − o12 − α1 ≥ 3 2 l1 + 1 2 l2 − l1 − l2 = 1 2 (l1 − l2). For the second inequality, we have by Lemma 4.4 ∆o12 +∆α1 ≥ 3 2 l1 + 1 2 l2 −(l1 +l2 +α2) = 1 2 l1 − 1 2 l2 −α2 ≥ 1 2 l1 −l2 ≥ 1 4 l1 + 3 4 l2 −l2 = 1 4 (l1 −l2). Clearly, we only need to prove the third inequality for 2l2 ≤ l1 < 3l2. We consider two cases: Case 1: If 2l2 ≤ l1 ≤ 5 ∆o12 + ∆α1 ≥ 3 2 l1 + 2 l2 then 1 2 l2 − (2l1 − l2) = 3 2 l2 − 1 2 l1 = 1 6 (l1 − l2) + 10 6 l2 − 4 6 l1 ≥ 1 6 (l1 − l2). Case 2: If 5 2 l2 ≤ l1 < 3l2 then we have ∆o12 + ∆α1 ≥ 3 2 l1 + 1 2 l2 − (l1 + l2 + α2) ≥ 1 2 l1 − l2 ≥ 1 6 l1 + 5 2 · 1 3 l2 − l2 = 1 6 (l1 − l2). 12 The last lemma is not used in the proof of the main theorem. Nevertheless, we decided to include it in this section, as we believe it might turn out useful in future developments. Lemma 4.6. Let l1 ≤ l2 and let w2 be its maximal rotation. If o12 ≥ l1 + α2 − α1, then α1 ≤ α2 − kl1 for all positive integers k. Remark. The most important consequence of the above lemma is that if l2 ∼ 2l1, then we cannot have α1 ∼ 1 2 l2 and o12 ∼ l1 + α2 all happening at the same time. 2 l1, α2 ∼ 1 Proof. We have o12 ≥ l1 − α1 ≥ pmax(w12), so w2[1, pmax(w12)] = (w2)max[1, pmax(w12)] is a substring of ov12, and in particular pmax(w12) (cid:23) (w2)max[1, pmax(w12)]. Therefore, if pmax(w12) is contained in ov12 we need to have pmax(w12) = w12[1, pmax(w12)] and imax(w12) = 1 by Lemma 2.2. If, on the other hand, pmax(w12) is not contained in ov12, then we have imax(w12) > o12 − (l1 − α1) + 1 ≥ α2 + 1 and so imax(w12) ∈ [α2 + 1, . . . , l1]. Similarly we can see that ov12 contains w2[α2 + 1, α2 + pmin(w12)], and so if pmin(w12) is contained in ov12, we have pmin(w12) = x2[α2 + 1, α2 + pmin(w12)], and by Lemma 2.2 imin(w12) = (α2 + 1) mod l1. Otherwise, we have imin(w12) ∈ [α2 + 1, . . . , l1]. It is easy to verify that in all cases for imax(w12) and imin(w12) we get α1 ≤ α2 − kl1 for all positive integers k. 5 The Proof of the Main Theorem In this section we present the proof of Theorem 3.2. We first introduce some additional definitions and technical lemmas, designed specifically for this proof, in Subsection 5.1. Since the proof itself is a rather long and detailed case analysis, in Subsection 5.2 we present a simple proof of a weaker version of Theorem 3.2. This weaker statement still gives an approximation ratio below 2 1 2 . The proof of Theorem 3.2 follows, for easier reading split into a subsection covering some basic observations and four subsections corresponding to different cycle lengths. 5.1 Preliminaries In particular, for a cycle C = x1 → x2 → We keep the notation from previous chapters. . . . → xk → x1, we are interested in bounding M = MC = min{oij : (xi, xj) ∈ C} and 2 lj)−oij O = OC = P(xi,xj)∈C oij in terms of L = LC = Pk 2 li − αi. Let ∆O = P(xi,xj)∈C ∆oij = 3 and ∆αi = 1 i=1 li. Recall also, that ∆oij = (li+ 1 2 L − O. We now introduce a couple more definitions. We call an edge xi → xj a down-edge if li ≥ lj and we call it an up-edge otherwise. We denote the sets of down-edges and up-edges of C by Cd and Cu respectively. A down-edge xi → xj is steep if li ≥ 2lj, otherwise it is flat. Similarly an up-edge xi → xj is steep if li ≤ 1 2 lj, and flat otherwise. Finally let lmin and lmax = l1 be the smallest and the largest among l1, . . . , lk breaking ties arbitrarily. Lemma 5.1. For any up-edge xi → xj we have ∆oij ≥ li − 1 2 lj ≥ lmin − 1 2 lmax. Proof. The second inequality is obvious. 13 As for the first, there is nothing to prove for steep up-edges since then li − 1 2 lj ≤ 0. For flat up-edges we have by Lemma 4.1. ∆oij ≥ (cid:16)li + 1 2 lj(cid:17) − lj = li − 1 2 lj, Lemma 5.2. For any cycle C we have ∆O ≥ 1 12 X(xi,xj)∈Cd (cid:16)li − lj(cid:17) ≥ 1 12(cid:16)lmax − lmin(cid:17). The constant can be improved to 1 to 1 4 , if there are no steep down-edges in C. 8 if there are no two consecutive steep down-edges in C, and Proof. Let xi → xj be a down-edge, and let xl → xi be the edge preceding it on C. Then we get from Corollary 4.5: ∆oli + ∆oij ≥ ∆αi + ∆oij ≥ 1 6(cid:16)li − lj(cid:17) (1) The right-hand side of the sum of inequality (1) over all down-edges is upper-bounded by 2∆O and the claim follows. If there are no steep down-edges in C, then this reasoning can be repeated using the sharper bound in Corollary 4.5. Finally, if there are no two consecutive steep down-edges in C, then let Cs be the set of steep down-edges and consider the sum of inequality (1) over Cs. Since steep down-edges are nonconsecutive, the right-hand side of this inequality is upperbounded by ∆O, and so ∆O ≥ 1 6 X(xi,xj)∈Cs(cid:16)li − lj(cid:17). We can also slightly improve the first part of the proof by using a stronger bound for flat edges to obtain: 2∆O ≥ 1 6 X(xi,xj)∈Cs(cid:16)li − lj(cid:17) + 1 2 X(xi,xj)∈Cd\Cs(cid:16)li − lj(cid:17). Adding twice the first inequality to the second one, we get 4∆O ≥ 1 2 X(xi,xj)∈Cs(cid:16)li − lj(cid:17) + 1 2 X(xi,xj)∈Cd\Cs(cid:16)li − lj(cid:17), and the claim follows. Lemma 5.3. If lmin > 1 2 lmax then ∆O ≥ 1 4 lmin. 14 Proof. Note that in the proof of Lemma 5.2 we actually have 2∆O ≥ 1 6 X(xi,xj)∈Cs(cid:16)li − lj(cid:17) + 1 2 X(xi,xj)∈Cd\Cs(cid:16)li − lj(cid:17) + X(xi,xj)∈Cu ∆oij. If lmin > 1 the case of all li equal) we obtain 2 lmax, then since all edges are flat and there is at least one down-edge (we excluded 2∆O ≥ 1 2 X(xi,xj)∈Cd (cid:16)li − lj(cid:17) +(cid:16)lmin − 1 2 lmax(cid:17) ≥ 1 2(cid:16)lmax − lmin(cid:17) +(cid:16)lmin − 1 2 lmax(cid:17) = 1 2 lmin, by Lemma 5.1 and the claim follows. 5.2 Proof of a Weaker Version of the Main Theorem In this subsection we present a weaker version of the Theorem 3.2, which is relatively easy to prove, and still leads to approximation factor smaller than 2 1 2 . Theorem 5.4 (Main Theorem, weak local version). For any cycle C in the overlap graph of R we have MC + 24OC ≤ 36 LC. 1 4 Remark. Note that the emphasis here is on simplicity, and the proof below can easily be improved in many ways. Proof. We first prove that we always have ∆O ≥ 1 We consider two cases: Case 1: If lmax < 2lmin then by Lemma 5.3 we have ∆O ≥ 1 24k L, where k is the length of the cycle. ∆O ≥ 1 4 lmin ≥ 1 4(2k − 1)(cid:16)2k−1(cid:17)lmin ≥ 4 lmin and so 4(2k − 1)(cid:16)lmin +(k−1)lmax(cid:17) ≥ 1 1 4(2k − 1) L ≥ 1 24k L. Case 2: If lmax ≥ 2lmin then we have by Lemma 5.2 1 ∆O ≥ 12(cid:16)lmax − lmin(cid:17) ≥ 12(2k − 1)(cid:16)(2k − 1)lmax − (2k − 1)lmin(cid:17) ≥ 1 1 ≥ 12(2k − 1)(cid:16)(k − 1)lmax + lmin(cid:17) ≥ 1 12(2k − 1) L ≥ 1 24k L. From the inequality we have just proved we get We also always have Joining these gives O ≤ (cid:18) 3 2 − 1 24k(cid:19) L. M ≤ 1 k · O ≤ 3 2k L. M + 24O ≤ (cid:18) 3 2k + 36 − 1 k(cid:19) L = (cid:18)36 + 1 2k(cid:19) L ≤ 36 1 4 L. 15 Corollary 5.5. There exists a 2 145 292 -approximation algorithm for Shortest-Superstring. Proof. Similarly as in the proof of Corollary 3.4, we get from Lemma 3.1 and Lemma 2.4 that We can bound the second term as follows: S0 ≤ 2OP T (S) + min(cid:16)M,(cid:16)1 − 2 3(cid:17)O(cid:17). min(cid:16)M, and so S0 ≤ 2 145 292 OP T (S). 1 3 O(cid:17) ≤ (cid:16) 1 73 M + 72 73 · 1 3 O(cid:17) ≤ 36 1 4 L 73 = 145 292 L ≤ 145 292 OP T (S), 5.3 The Proof of Theorem 3.2 -- Basic Observations Let us recall Theorem 3.2. Theorem 3.2 (restated). For every cycle C in the overlap graph of R, we have 2MC + 7OC ≤ 11LC . We can easily get rid of the following special case, which will make some reasonings easier later on. Lemma 5.6. If all li are equal for a cycle C then the claim of Theorem 3.2 holds. Proof. Since two non-equivalent strings of equal length l cannot have an overlap of length l or greater, it follows that in this case γ ≤ 1. Therefore β ≤ 1 2 and 2β + 7γ ≤ 8, a much stronger bound than needed. 2 γ ≤ 1 In the remainder of this section we assume that not all li are equal. Lemma 5.7. Either of the following statements imply the claim of Theorem 3.2 for a k-cycle C: • 2M − 7∆O ≤ 1 2 , • ∆O ≥ 6−k 2(7k+2) L. Before proving the above lemma, let us note its particularly useful consequences: Corollary 5.8. Let C be a k-cycle, then the claim of Theorem 3.2 for C • is implied by ∆O ≥ 1 30 L if k = 4, • is implied by ∆O ≥ 1 74 L if k = 5, • holds if k ≥ 6. Proof (of Lemma 5.7). For the first part we have 2M + 7O = 2M + 7(cid:18) 3 2 L − ∆O(cid:19) = 10 1 2 L + (2M − 7∆O), and the claim follows. For the second part, note that M ≤ 1 k O. Therefore if we have ∆O ≥ 6−k 2(7k+2) L, then 2M + 7O ≤ 2 + 7k k O ≤ 2 + 7k k (cid:18) 3 2 L − 6 − k 2(7k + 2) L(cid:19) = 2 + 7k k · 22k 2(7k + 2) L = 11L. 16 5.4 The Proof of Theorem 3.2 for 5-cycles The remainder of the proof is divided into four parts, one for each cycle length in {2, 3, 4, 5}. Although there are similarities between these parts, they are mostly independent. For easier reading, we put each part in a separate subsection. Lemma 5.9. If C is 5-cycle, then 2M + 7O ≤ 11L. Proof. We consider three cases. In all three we prove that ∆O ≥ 1 from Corollary 5.8. Case 1: If lmin > 1 74 L and the claim follows 2 lmax we have by Lemma 5.3 that ∆O ≥ 1 36(cid:16)lmin + 4lmax(cid:17) ≥ ∆O ≥ 1 1 36(cid:16)9lmin(cid:17) ≥ 2 lmax, then we cannot have two consecutive steep down-edges, L. 1 36 4 lmin and so 4 lmax < lmin ≤ 1 Case 2: and so by Lemma 5.2 we have If 1 ∆O ≥ 1 8(cid:16)lmax − lmin(cid:17) ≥ 1 72(cid:16)9lmax − 9lmin(cid:17) ≥ 1 72(cid:16)4lmax + lmin(cid:17) ≥ 1 72 L. Case 3: Finally, if lmin ≤ 1 4 lmax, then we have ∆O ≥ 1 12(cid:16)lmax − lmin(cid:17) ≥ 1 72(cid:16)6lmax − 6lmin(cid:17) ≥ 1 72(cid:16)4lmax + 2lmin(cid:17) ≥ 1 72 L. 5.5 The Proof of Theorem 3.2 for 4-cycles Lemma 5.10. If C is 4-cycle, then 2M + 7O ≤ 11L. Proof. We again consider several cases. Case 1: If lmin > 1 2 lmax then by Lemma 5.3 we have ∆O ≥ 1 28(cid:16)lmin + 3lmax(cid:17) ≥ 28(cid:16)7lmin(cid:17) ≥ ∆O ≥ 1 1 1 28 L, 4 lmin and so and the claim follows by Corollary 5.8. Case 2: ∆O ≥ 1 4 (lmax − lmin) and so If lmin ≤ 1 2 l1, but all down-edges of C are flat then we have by Lemma 5.2 that ∆O ≥ 1 28(cid:16)7lmax − 7lmin(cid:17) ≥ 1 28(cid:16)3lmax + lmin(cid:17) ≥ 1 28 L. Therefore we only need to consider cases where at least one down-edge of C is steep. This is implicitly assumed in all remaining cases. Case 3: If l1 ≥ l2 ≤ l3 ≥ l4, i.e. the edges of C are alternating down-up-down-up, then ∆O = (cid:16)∆o41 + ∆o12(cid:17) +(cid:16)∆o23 + ∆o34(cid:17) ≥ 1 6(cid:16)l1 − l2(cid:17) + 1 6(cid:16)l3 − l4(cid:17), by Corollary 4.5. We also have M ≤ min(cid:16)o41, o23(cid:17) ≤ min(cid:16)l1, l3(cid:17) ≤ 1 2(cid:16)l1 + l3(cid:17). 17 Therefore 2M − 7∆O ≤ l1 + l3 + 7 6(cid:16) − l1 + l2 − l3 + l4(cid:17) = 1 6(cid:16) − l1 + 7l2 − l3 + 7l4(cid:17) ≤ 1 2(cid:16)l1 + l2 + l3 + l4(cid:17) since l2 ≤ l1 and l4 ≤ l3. Case 4: If l1 ≥ l2 ≤ l3 ≤ l4, then we have ∆O ≥ 1 2M − 7∆O ≤ 2l3 − 7 6 l1 + 7 6 l2 ≤ (cid:16) 1 2 l3 + 1 2 6 (l1 − l2) and M ≤ o23 ≤ l3. Therefore l4 + l1(cid:17) − l1 +(cid:16) 3 l1(cid:17) = l2 + 1 2 4 6 7 6 L, 6 If l1 ≥ l2 ≥ l3 ≤ l4, we consider two subcases. Since we excluded Cases 1 and 2, at and the claim follows from Lemma 5.7. Case 5: least one down-edge of C is steep. Case 5a: 2 l1, then ∆O ≥ 1 If l2 ≤ 1 2M − 7∆O ≤ 2l3 + l4 + 7 6 l2 − 7 6 Case 5b: l3 + 1 2 l4. Therefore If l2 > 1 2 l1 and l3 ≤ 1 6 (l1 − l2) and M ≤ o34 ≤ l3 + 1 l1 ≤ (cid:16) 1 2 l2, then ∆O ≥ 1 l1(cid:17) +(cid:16) 1 l3 + l4 + l1(cid:17) +(cid:16) 3 3 4 1 2 2 2 2 l4. Therefore l1(cid:17) − l2 + 2 6 6 8 (l1 − l3) by Lemma 5.2 and M ≤ o34 ≤ 7 6 l1 ≤ 1 2 L 2M −7∆O ≤ 2l3+l4− 7 8 l1+ 7 8 l3 ≤ 23 8 l3+l4− 7 8 l1 ≤ (cid:16) 4 8 l3+ 4 8 l2+ 11 16 l1(cid:17)+(cid:16) 1 2 l4+ 1 2 l1(cid:17)− 7 8 l1 ≤ 1 2 L. Case 6: We are left with the case where l1 ≥ l2 ≥ l3 ≥ l4, i.e. C has three down-edges, and at least one of them is steep. We consider three subcases: Case 6a: If l2 ≤ 1 2 l1 then similarly to Case 3 we have ∆O ≥ (cid:16)∆o41 + ∆o12(cid:17) +(cid:16)∆o23 + ∆o34(cid:17) ≥ 1 6(cid:16)l1 − l2(cid:17) + 1 6(cid:16)l3 − l4(cid:17). We also have M ≤ o34 ≤ l3 + 1 2M − 7∆O ≤ 2l3 + l4 + 7 2 l4. Therefore 6(cid:16) − l1 + l2 − l3 + l4(cid:17) = − l1 +(cid:16) 3 2 l2 then ∆O ≥ 1 1 6 6 (l2 − l3) and M ≤ l3 + 1 l1(cid:17) +(cid:16) 3 l2 + l3 + ≤ − 2 6 7 6 6 6 Case 6b: If l3 ≤ 1 2M − 7∆O ≤ 2l3 + l4 − 7 6 l2 + 7 6 l3 = − 19 6 l2 + l3 + l4 ≤ − 7 6 l1 + 7 6 l2 + 5 6 l3 + 13 6 6 l4 + l1(cid:17) +(cid:16) 3 5 6 2 l4. Therefore 22 6 l2 + 7 6 l4 ≤ 1 2 L. l1(cid:17) ≤ l3 + 1 2 l4 ≤ 1 2 L. ≤ − l2 +(cid:16) 3 l1 + 13 12 l2 + 3 6 l3(cid:17) + 1 2 l4 ≤ Case 6c: If l4 ≤ 1 6 2 l3 then similarly to Case 6a we have 6(cid:16)l1 − l2(cid:17) + but this time we use the bound M ≤ o41 ≤ l4 + 1 ∆O ≥ 2M − 7∆O ≤ 2l4 + l1 + 1 1 6(cid:16)l3 − l4(cid:17), 2 l1. We get 1 6(cid:16) − l1 + l2 − l3 + l4(cid:17) = − 6 7 l1(cid:17) − 6 l1 +(cid:16) 3 l2 + ≤ − 1 6 4 6 7 6 l1 + 7 6 l2 − 7 6 l3 + 19 6 l4 ≤ l3 +(cid:16) 3 6 l4 + 8 6 l3(cid:17) ≤ 1 2 L. 7 6 7 6 18 5.6 The Proof of Theorem 3.2 for 3-cycles Lemma 5.11. If C is a 3-cycle then 2M + 7O ≤ 11L. Proof. There are essentially two kinds of 3-cycles - ones with (cyclically) increasing li, and ones with decreasing li. Case 1: Case 1a: If l1 ≥ l2 ≤ l3 (i.e. li are cyclically increasing), then we consider three subcases. If lmax < 2lmin, i.e. l1 < 2l2, then ∆O ≥ ∆o23 + ∆o31 ≥ (cid:16)l2 − 1 2 l3(cid:17) +(cid:16)l3 − 1 2 l1(cid:17) = l2 + 1 2 l3 − 1 2 l1 > 1 2 l3 by Lemma 5.1. We also have M ≤ o23 ≤ l3. Then 2M − 7∆O ≤ 2l3 − 7 2 l3 < 0 ≤ 1 2 L. Case 1b: If l1 ≥ 2l3 then we have ∆O ≥ ∆o12 ≥ 1 6(cid:16)l1 − l2(cid:17) and M ≤ o23 ≤ l2 + 1 2M −7∆O ≤ 2l2+l3+ 2 l3. Therefore 6(cid:16)−l1+l2(cid:17) ≤ − 7 7 6 l1+ 19 6 l2+l3 ≤ − 7 6 l1+(cid:16) 3 6 l2+ 8 6 l1(cid:17)+(cid:16) 1 2 l3+ 1 4 l1(cid:17) ≤ 1 2 L. Case 1c: If 2l2 ≤ l1 < 2l3 then ∆O ≥ max(cid:16)∆o12, ∆o31(cid:17) ≥ max(cid:16) 1 6(cid:16)l1 − l2(cid:17), l3 − 1 2 l1(cid:17) and M ≤ o23 ≤ l2 + 1 2 l3. Hence 2M −7∆O ≤ 2l2 +l3 −(cid:16)l3 − 1 2 l1(cid:17)−6· 1 6(cid:16)l1 −l2(cid:17) = − 1 2 l1 +3l2 ≤ − 1 2 l1 +(cid:16)l1 + 1 2 l2 + 1 2 l3(cid:17) ≤ 1 2 L. Case 2: If l1 ≥ l2 ≥ l3 then we consider several subcases. The logic in their ordering is that we are trying to eliminate the easy ones first until only the hardest case remains -- one that is actually tight. Case 2a: M ≤ min(o23, o31) ≤ min(l2 + 1 If l1 < 2l3, i.e. lmax < 2lmin, then by Lemma 5.3 we have ∆O ≥ 1 4 l3. We also have 2M − 7∆O ≤ 2 l3, l1). Therefore 2(cid:16)l2 + l3(cid:17) + 1 2 3 2 1 l1 − 7 4 l3 = 3 2 l1 + 1 2 l2 − 3 2 l3 ≤ 1 2 L. Case 2b: 1 4 (l1 − l3). Using the same bound on M as in the previous case, we obtain If l1 ≥ 2l3, but both down-edges are flat, then by Lemma 5.2 we have ∆O ≥ 2M − 7∆O ≤ 1 2(cid:16)l2 + 1 2 l3(cid:17) + 3 2 l1 − 7 4(cid:16)l1 − l3(cid:17) = − 1 4 l1 + 1 2 l2 + 2l3 ≤ 1 2 L. We are left with the case where at least one down-edge of C is steep. 19 Case 2c: M ≤ o23 ≤ l2 + 1 2 l3. Hence If l2 ≤ 1 2 l1 then we have ∆O ≥ 1 6 (l1 − l2) by Corollary 4.5. We also have 2M −7∆O ≤ 2l2 +l3 − 7 6 l1 + 7 6 l2 = − 7 6 l1 + 19 6 l2 +l3 ≤ − 7 6 l1 +(cid:16) 3 6 l2 + 8 6 l1(cid:17)+(cid:16) 1 2 l3 + 1 4 l1(cid:17) ≤ 1 2 L. Case 2d: If l2 > 1 2 l1 and 2l3 ≤ l2 < 5 2 l3 then we have ∆O ≥ ∆o12 + ∆o23 ≥ ∆α2 + ∆o23 ≥ (cid:16) 3 2 l2 + 1 2 l3(cid:17) −(cid:16)2l2 − l3(cid:17) = 3 2 l3 − 1 2 l2 by Lemma 4.4, and we also have Joining these two bounds with M ≤ o31 ≤ l3 + 1 ∆O ≥ ∆o12 ≥ 1 2(cid:16)l1 − l2(cid:17). 2 l1 gives 2M −7∆O ≤ 2l3+l1−6(cid:16) 3 2 l3− 1 2 l2(cid:17)− 1 2(cid:16)l1−l2(cid:17) = 1 2 l1+ 7 2 l2−7l3 ≤ 1 2 l1+(cid:16) 1 2 l2+ 15 2 l3(cid:17)−7l3 = 1 2 L. Case 2e: Finally if l2 > 1 2 l1 and l2 ≥ 5 2 l3 then we have ∆O ≥ ∆o12 + ∆o23 ≥ ∆α2 + ∆o23 ≥ (cid:16) 3 2 l2 + 1 2 l3(cid:17) −(cid:16)l2 + l3 + α3(cid:17) ≥ 1 2 l2 − l3 by Lemma 4.4. We now proceed similarly to the previous case: 2M − 7∆O ≤ 2l3 + l1 − 6(cid:16) 1 2 l2 − l3(cid:17) − 1 2(cid:16)l1 − l2(cid:17) ≤ 1 2 l1 − 5 2 l2 + 8l3 = 1 2 L − 3l2 + 15 2 l3 ≤ 1 2 L. 5.7 The Proof of Theorem 3.2 for 2-cycles Before we proceed with the case of 2-cycles, we need an additional technical lemma. Lemma 5.12. If l1 ≥ 2l2 then ∆o12 + ∆o21 ≥ 1 2 l2. Proof. If o12 ≤ l1 then clearly ∆O ≥ ∆o12 ≥ 1 this means that l1 is not a multiple of l2, since w1 is primitive. 2 l2. Hence we can assume o12 ≥ l1. Note that Assume w.l.o.g. that w2 is its maximal rotation and let k ≥ 2 be such, that kl2 < l1 < (k + 1)l2. Since o12 ≥ l1, by Lemma 4.2 we get imin(w12) = α2 + 1 and imax(w12) ≥ kl2 + 1. This means that pmin(w1) ≥ kl2 − α2 = (k − 1)l2 + (l2 − α2) ≥ 3 2 l2 and pmax(w1) ≤ l1 − kl2 + α2 < 3 2 l2. Therefore, w1 is its maximal rotation as well. Since imax(w12) ≥ kl2 + 1 and l2 does not divide l1, we know pmax(w1) = wpmax(w2), where w = w12[imax(w12), l1]. Note that w < w2 and w is a prefix of w2 (because it is an initial segment of a maximal rotation of w1). We will show that o21 < pmax(w1) = α1, which implies the claim of the lemma. Assume the opposite, i.e. o21 ≥ α1. Then o21[1, α1] = pmax(w1) = wpmax(w2). By Lemma 2.2 this can only happen if w2 is aligned with position w + 1 of ov21. But then w is a suffix of w2, and since it is also a prefix of w2 we get a contradiction with Lemma 2.3. 20 Lemma 5.13. If C is a 2-cycle, then 2M + 7O ≤ 11L. Proof. We consider three cases. Case 1: If l1 < 2l2, i.e. the down-edge of C is flat, then we have ∆O ≥ max(cid:16) 1 2(cid:16)l1 − l2(cid:17), l2 − 1 2 l1(cid:17) by Corollary 4.5 and Lemma 5.1. We also have M ≤ o21 ≤ l1, and so 2M − 7∆O ≤ 2l1 − 5 · 1 2(cid:16)l1 − l2(cid:17) − 2(cid:16)l2 − 1 2 l1(cid:17) = 1 2 L. Case 2: main claim since using M ≤ o21 ≤ l2 + 1 If 2l2 ≤ l1 < 3l2 then we have ∆O ≥ 1 2 l1 we have 2 l2 by Lemma 5.12. This easily gives our 2M − 7∆O ≤ 2l2 + l1 − 7 2 l2 = l1 − 3 2 l2 ≤ (cid:16) 1 2 l1 + 3 2 If 3l2 ≤ l1 then by Corollary 4.5 we have ∆O ≥ 1 3 2 1 2 L. l2 ≤ l2(cid:17) − 4 (l1 − l2) and together with Case 3: M ≤ o21 ≤ l2 + 1 2 l1 we get 2M − 7∆O ≤ 2l2 + l1 − 7 4 l1 + 7 4 l2 = − 3 4 l1 + 15 4 l2 = − 3 4 l1 + 5 4 l1 ≤ 1 2 L. 6 Tight examples 6.1 Tightness of Theorem 3.2 We will now show that Theorem 3.2 is essentially tight. To this end, we give two examples of cycles in the overlap graph, for which 2M + 7O = 11L − O(1). Note that by increasing the lengths of the strings in these cycles we can get 2M +7O 11L → 1. Example 6.1. Let w1 = bakbak+1bak+1 and w2 = ak+1bakb (we use the symbol to mark the border between pmax and pmin). Here l1 = 3k + 5, l2 = 2k + 3, so L = 5k + 8. Now, let xi = (w2 i )[1, 2li − 1] for i = 1, 2. Note that all wi are nice words and every xi is a wi-word. We have o12 = 4k + 5 and o21 = 3k + 4, so O = 7k + 9 and M = 3k + 4. Note that 2M + 7O = 6k + 8 + 49k + 63 = 55k + 71 = 11L − O(1) Example 6.2. Let w1 = banban+1banban+1ban+1ban+1, w2 = an+1ban+1banban+1banb, w3 = an+1banb. We have l1 = 6n + 10, l2 = 5n + 8, l3 = 2n + 3, so L = 13n + 21. Now, let x1 = (w2 1)[1, 2l1 − 1], x2 = (w3 2)[1, 2l2 + α2 − 1] and x3 = (w4 3)[1, 4l3 − 1]. Note that all wi are nice words and every xi is a wi-word. We have o12 = 8n + 12, o23 = 6n + 8 and o31 = 5n + 7, so O = 19n + 27 and M = 5n + 7. Note that 2M + 7O = 10n + 14 + 133n + 189 = 11L − O(1). We will now show that the bound we give on min(M, (1 − c)O) in Corollary 3.4 is also essentially tight. 21 Consider a cycle cover C in the overlap graph, composed of two collections of cycles: C2 consisting of 2-cycles of the form described in Example 6.1, and C3 consisting of 3-cycles described in Example 6.2 (note that these cycles need to use different n so that their vertices are non-equivalent). Let L2, L3 be the total length of the periods of the strings in the cycles of C2 and C3, respectively. Let O2 be the sum of all overlaps on the cycles in C2 and let M2 be the sum of smallest overlaps for each cycle in C2. Similarly define O3 and M3 for C3. Finally let L = L2 + L3, O = O2 + O3 and M = M2 + M3. Note that to make the analysis in Corollary 3.4 tight we only need to make M = (1 − c)O, 19 O3, this can 19 ]. The current since we already have 2M + 7O = 11L − O(1). Since M2 ∼ 3 be done by adjusting the balance between L2 and L3, provided that c ∈ [ 4 best approximation ratio of 2 7 O2 and M3 ∼ 5 7 , 14 3 for Max-ATSP-Path sits well within this interval. 6.2 The Greedy Algorithm Recall the greedy algorithm, which picks two strings with the largest overlap and combines them together until a single string remains. The bounds in Breslauer et al. can be used to improve the analysis of this algorithm, as shown by Kaplan et al. [11]. It is natural to ask whether our bounds can be used in a similar fashion. Unfortunately, it seems that there is no simple way to do this. In their analysis, Kaplan et al. require a good bound on the the total overlap of a (possibly) long path of strings in the overlap graph. As it turns out, in this case the overlap can actually approach the bound of 3 in the following example. 2 Pi li arbitrarily close, as can be seen Example 6.3. For any k ≥ 1 let w2k = bkak and w2k−1 = ak−1bk. Also, let x2k = bkakbkak−1 and x2k−1 = ak−1bkak−1bk−1. Note that all wi are nice words and every xi is a wi-word. Consider S = {x3, x4, . . . , xn} = {ab2ab, b2a2b2a, a2b3a2b2, b3a3b3a2, . . .} and the path 2 ⌋. xn → xn−1 → . . . → x3 in the overlap graph of S. It is easy to verify that oi+1,i = ⌊ 3i Therefore, the total overlap of the path is approximately 3 4 n2, and Pn i=3 li ∼ 1 2 n2. This, of course, does not rule out using our results to improve the analysis of the greedy algorithm. However, any such result requires some additional insight. 7 Acknowledgements The author would like to thank Anupam Gupta and Piotr Sankowski for valuable suggestions that helped to improve the presentation of the paper, and Jakub Radoszewski for his advice in matters of stringology. References [1] Chris Armen and Clifford Stein. Improved length bounds for the shortest superstring problem. In WADS, pages 494 -- 505, 1995. [2] Chris Armen and Clifford Stein. A 2 2/3-approximation algorithm for the shortest superstring problem. In CPM, pages 87 -- 101, 1996. 22 [3] Arash Asadpour, Michel X. Goemans, Aleksander Madry, Shayan Oveis Gharan, and Amin Saberi. An O(log n/ log log n)-approximation algorithm for the asymmetric trav- eling salesman problem. In SODA, pages 379 -- 389, 2010. [4] Avrim Blum, Tao Jiang, Ming Li, John Tromp, and Mihalis Yannakakis. Linear approx- imation of shortest superstrings. J. ACM, 41(4):630 -- 647, 1994. [5] Dany Breslauer, Tao Jiang, and Zhigen Jiang. Rotations of periodic strings and short superstrings. J. Algorithms, 24(2):340 -- 353, 1997. [6] Maxime Crochemore and Dominique Perrin. Two-way string matching. J. ACM, 38(3):651 -- 675, 1991. [7] Artur Czumaj, Leszek Gasieniec, Marek Piotr´ow, and Wojciech Rytter. Sequential and parallel approximation of shortest superstrings. J. Algorithms, 23(1):74 -- 100, 1997. [8] John Gallant, David Maier, and James A. Storer. On finding minimal length superstrings. J. Comput. Syst. Sci., 20(1):50 -- 58, 1980. [9] M. R. Garey and David S. Johnson. Computers and Intractability: A Guide to the Theory of NP-Completeness. W. H. Freeman, 1979. [10] Haim Kaplan, Moshe Lewenstein, Nira Shafrir, and Maxim Sviridenko. Approximation algorithms for asymmetric tsp by decomposing directed regular multigraphs. J. ACM, 52(4):602 -- 626, 2005. [11] Haim Kaplan and Nira Shafrir. The greedy algorithm for shortest superstrings. Inf. Process. Lett., 93(1):13 -- 17, 2005. [12] S. Rao Kosaraju, James K. Park, and Clifford Stein. Long tours and short superstrings. In FOCS, pages 166 -- 177, 1994. [13] A.M. Lesk. Computational molecular biology: sources and methods for sequence analysis. Oxford University Press, 1988. [14] M. Li. Towards a dna sequencing theory. In FOCS, pages 125 -- 134, 1990. [15] M. Lothaire. Combinatorics on Words. Cambridge Mathematical Library. Cambridge University Press, 1997. [16] Katarzyna E. Paluch, Khaled M. Elbassioni, and Anke van Zuylen. Simpler approxima- tion of the maximum asymmetric traveling salesman problem. In STACS, pages 501 -- 506, 2012. [17] Hannu Peltola, Hans Soderlund, Jorma Tarhio, and Esko Ukkonen. Algorithms for some string matching problems arising in molecular genetics. In IFIP Congress, pages 59 -- 64, 1983. [18] James A. Storer. Data Compression: Methods and Theory. Computer Science Press, 1988. [19] Z. Sweedyk. A 2 1 29(3):954 -- 986, 1999. 2 -approximation algorithm for shortest superstring. SIAM J. Comput., 23 [20] Jorma Tarhio and Esko Ukkonen. A greedy approximation algorithm for constructing shortest common superstrings. Theor. Comput. Sci., 57:131 -- 145, 1988. [21] Shang-Hua Teng and F. Frances Yao. Approximating shortest superstrings. SIAM J. Comput., 26(2):410 -- 417, 1997. [22] Jonathan S. Turner. Approximation algorithms for the shortest common superstring problem. Inf. Comput., 83(1):1 -- 20, 1989. [23] Virginia Vassilevska. Explicit inapproximability bounds for the shortest superstring prob- lem. In MFCS, pages 793 -- 800, 2005. [24] Michael S. Waterman. Introduction to computational biology - maps, sequences, and genomes: interdisciplinary statistics. CRC Press, 1995. [25] Y.C´esari and M. Vincent. Une caract´erisation des mots p´eriodiques. C. R. Acad. Sci. Paris S´er. A, 286:1175 -- 1177, 1978. 24
1805.08612
3
1805
2019-07-07T21:03:01
On the Worst-Case Complexity of TimSort
[ "cs.DS" ]
TimSort is an intriguing sorting algorithm designed in 2002 for Python, whose worst-case complexity was announced, but not proved until our recent preprint. In fact, there are two slightly different versions of TimSort that are currently implemented in Python and in Java respectively. We propose a pedagogical and insightful proof that the Python version runs in $\mathcal{O}(n\log n)$. The approach we use in the analysis also applies to the Java version, although not without very involved technical details. As a byproduct of our study, we uncover a bug in the Java implementation that can cause the sorting method to fail during the execution. We also give a proof that Python's TimSort running time is in $\mathcal{O}(n + n\log \rho)$, where $\rho$ is the number of runs (i.e. maximal monotonic sequences), which is quite a natural parameter here and part of the explanation for the good behavior of TimSort on partially sorted inputs.
cs.DS
cs
On the Worst-Case Complexity of TimSort Nicolas Auger, Vincent Jugé, Cyril Nicaud, and Carine Pivoteau Université Paris-Est, LIGM (UMR 8049), UPEM, F77454 Marne-la-Vallée, France Abstract TimSort is an intriguing sorting algorithm designed in 2002 for Python, whose worst-case complexity was announced, but not proved until our recent preprint. In fact, there are two slightly different versions of TimSort that are currently implemented in Python and in Java respectively. We propose a pedagogical and insightful proof that the Python version runs in time O(n log n). The approach we use in the analysis also applies to the Java version, although not without very involved technical details. As a byproduct of our study, we uncover a bug in the Java implementation that can cause the sorting method to fail during the execution. We also give a proof that Python's TimSort running time is in O(n + nH), where H is the entropy of the distribution of runs (i.e. maximal monotonic sequences), which is quite a natural parameter here and part of the explanation for the good behavior of TimSort on partially sorted inputs. Finally, we evaluate precisely the worst-case running time of Python's TimSort, and prove that it is equal to 1.5nH + O(n). 2012 ACM Subject Classification Theory of computation → Sorting and searching Keywords and phrases Sorting algorithms, Merge sorting algorithms, TimSort, Analysis of algorithms 1 Introduction TimSort is a sorting algorithm designed in 2002 by Tim Peters [9], for use in the Python programming language. It was thereafter implemented in other well-known programming languages such as Java. The algorithm includes many implementation optimizations, a few heuristics and some refined tuning, but its high-level principle is rather simple: The sequence S to be sorted is first decomposed greedily into monotonic runs (i.e. nonincreasing or nondecreasing subsequences of S as depicted on Figure 1), which are then merged pairwise according to some specific rules. S = ( 12, 10, 7, 5 , 7, 10, 14, 25, 36 , 3, 5, 11, 14, 15, 21, 22 , 20, 15, 10, 8, 5, 1 ) first run {z } second run {z } third run {z } fourth run {z } Figure 1 A sequence and its run decomposition computed by TimSort: for each run, the first two elements determine if it is increasing or decreasing, then it continues with the maximum number of consecutive elements that preserves the monotonicity. The idea of starting with a decomposition into runs is not new, and already appears in Knuth's NaturalMergeSort [6], where increasing runs are sorted using the same mechanism as in MergeSort. Other merging strategies combined with decomposition into runs appear in the literature, such as the MinimalSort of [10] (see also [2] for other considerations on the same topic). All of them have nice properties: they run in O(n log n) and even O(n+n log ρ), where ρ is the number of runs, which is optimal in the model of sorting by comparisons [7], using the classical counting argument for lower bounds. And yet, among all these merge-based algorithms, TimSort was favored in several very popular programming languages, which suggests that it performs quite well in practice. TimSort running time was implicitly assumed to be O(n log n), but our unpublished preprint [1] contains, to our knowledge, the first proof of it. This was more than ten years after TimSort started being used instead of QuickSort in several major programming languages. The growing popularity of this algorithm invites for a careful theoretical investigation. In the present paper, we make a thorough analysis which provides a better understanding of the inherent qualities of the merging strategy of Tim- Sort. Indeed, it reveals that, even without its refined heuristics,1 this is an effective sorting algorithm, computing and merging runs on the fly, using only local properties to make its decisions. 1 These heuristics are useful in practice, but do not improve the worst-case complexity of the algorithm. 2 On the Worst-Case Complexity of TimSort Algorithm 1: TimSort (Python 3.6.5) Input : A sequence S to sort Result: The sequence S is sorted into a single run, which remains on the stack. Note: The function merge_force_collapse repeatedly pops the last two runs on the stack R, merges them and pushes the resulting run back on the stack. 1 runs ← a run decomposition of S 2 R ← an empty stack 3 while runs 6= ∅ do 4 5 remove a run r from runs and push r onto R merge_collapse(R) 6 if height(R) 6= 1 then 7 merge_force_collapse(R) // main loop of TimSort // the height of R is its number of runs We first propose in Section 3 a new pedagogical and self-contained exposition that TimSort runs in time O(n+n log n), which we want both clear and insightful. In fact, we prove a stronger statement: on an input consisting of ρ runs of respective lengths r1, . . . , rρ, we establish that TimSort runs in O(n+nH) ⊆ O(n + n log ρ) ⊆ O(n + n log n), where H = H(r1/n, . . . , rρ/n) and H(p1, . . . , pρ) = −Pρ i=1 pi log2(pi) is the binary Shannon entropy. We then refine this approach, in Section 4, to derive precise bounds on the worst-case running time of TimSort, and we prove that it is equal to 1.5nH + O(n). This answers positively a conjecture of [3]. Of course, the first result follows from the second, but since we believe that each one is interesting on its own, we devote one section to each of them. To introduce our last contribution, we need to look into the evolution of the algorithm: there are actually not one, but two main versions of TimSort. The first version of the algorithm contained a flaw, which was spotted in [4]: while the input was correctly sorted, the algorithm did not behave as announced (because of a broken invariant). This was discovered by De Gouw and his co-authors while trying to prove formally the correctness of TimSort. They proposed a simple way to patch the algorithm, which was quickly adopted in Python, leading to what we consider to be the real TimSort. This is the one we analyze in Sections 3 and 4. On the contrary, Java developers chose to stick with the first version of TimSort, and adjusted some tuning values (which depend on the broken invariant; this is explained in Sections 2 and 5) to prevent the bug exposed by [4]. Motivated by its use in Java, we explain in Section 5 how, at the expense of very complicated technical details, the elegant proofs of the Python version can be twisted to prove the same results for this older version. While working on this analysis, we discovered yet another error in the correction made in Java. Thus, we compute yet another patch, even if we strongly agree that the algorithm proposed and formally proved in [4] (the one currently implemented in Python) is a better option. 2 TimSort core algorithm The idea of TimSort is to design a merge sort that can exploit the possible "non randomness" of the data, without having to detect it beforehand and without damaging the performances on random-looking data. This follows the ideas of adaptive sorting (see [7] for a survey on taking presortedness into account when designing and analyzing sorting algorithms). The first feature of TimSort is to work on the natural decomposition of the input sequence into maximal runs. In order to get larger subsequences, TimSort allows both nondecreasing and decreasing runs, unlike most merge sort algorithms. Then, the merging strategy of TimSort (Algorithm 1) is quite simple yet very efficient. The runs are considered in the order given by the run decomposition and successively pushed onto a stack. If some conditions on the size of the topmost runs of the stack are not satisfied after a new run has been pushed, this can trigger a series of merges between pairs of runs at the top or right under. And at the end, when all the runs in the initial decomposition have been pushed, the last operation is to merge the remaining N. Auger, V. Jugé, C. Nicaud, and C. Pivoteau 3 Algorithm 2: The merge_collapse procedure (Python 3.6.5) Input : A stack of runs R Result: The invariant of Equations (1) and (2) is established. Note: The runs on the stack are denoted by R[1] . . . R[height(R)], from top to bottom. The length of run R[i] is denoted by ri. The blue highlight indicates that the condition was not present in the original version of TimSort (this will be discussed in section 5). 1 while height(R) > 1 do 2 3 4 5 6 7 8 9 n ← height(R) − 2 if (n > 0 and r3 6 r2 + r1) or (n > 1 and r4 6 r3 + r2) then if r3 < r1 then merge runs R[2] and R[3] on the stack else merge runs R[1] and R[2] on the stack else if r2 6 r1 then merge runs R[1] and R[2] on the stack else break runs two by two, starting at the top of the stack, to get a sorted sequence. The conditions on the stack and the merging rules are implemented in the subroutine called merge_collapse detailed in Algorithm 2. This is what we consider to be TimSort core mechanism and this is the main focus of our analysis. Another strength of TimSort is the use of many effective heuristics to save time, such as ensuring that the initial runs are not to small thanks to an insertion sort or using a special technique called "galloping" to optimize the merges. However, this does not interfere with our analysis and we will not discuss this matter any further. Let us have a closer look at Algorithm 2 which is a pseudo-code transcription of the merge_collapse procedure found in the latest version of Python (3.6.5). To illustrate its mechanism, an example of execution of the main loop of TimSort (lines 3-5 of Algorithm 1) is given in Figure 2. As stated in its note [9], Tim Peter's idea was that: "The thrust of these rules when they trigger merging is to balance the run lengths as closely as possible, while keeping a low bound on the number of runs we have to remember." To achieve this, the merging conditions of merge_collapse are designed to ensure that the following invariant2 is true at the end of the procedure: ri+2 > ri+1 + ri, ri+1 > ri. (1) (2) This means that the runs lengths ri on the stack grow at least as fast as the Fibonacci numbers and, therefore, that the height of the stack stays logarithmic (see Lemma 10, section 3). Note that the bound on the height of the stack is not enough to justify the O(n log n) running time of TimSort. Indeed, without the smart strategy used to merge the runs "on the fly", it is easy to build an example using a stack containing at most two runs and that gives a Θ(n2) complexity: just assume that all runs have size two, push them one by one onto a stack and perform a merge each time there are two runs in the stack. We are now ready to proceed with the analysis of TimSort complexity. As mentioned earlier, Al- gorithm 2 does not correspond to the first implementation of TimSort in Python, nor to the current one in Java, but to the latest Python version. The original version will be discussed in details later, in Section 5. 2 Actually, in [9], the invariant is only stated for the 3 topmost runs of the stack. 4 On the Worst-Case Complexity of TimSort #1 18 24 #1 24 #1 50 18 24 #2 50 42 #1 28 92 #3 92 #1 8 4 6 20 28 92 #1 4 6 20 28 92 #2 8 10 20 28 92 #5 18 20 28 92 #1 6 20 28 92 #1 20 28 92 #4 38 28 92 #3 66 92 #1 1 66 92 merge_collapse merge_collapse Figure 2 The successive states of the stack R (the values are the lengths of the runs) during an execution of the main loop of TimSort (Algorithm 1), with the lengths of the runs in runs being (24, 18, 50, 28, 20, 6, 4, 8, 1). The label #1 indicates that a run has just been pushed onto the stack. The other labels refer to the different merges cases of merge_collapse as translated in Algorithm 3. Algorithm 3: TimSort: translation of Algorithm 1 and Algorithm 2 Input : A sequence to S to sort Result: The sequence S is sorted into a single run, which remains on the stack. Note: At any time, we denote the height of the stack R by h and its ith top-most run (for 1 6 i 6 h) by Ri. The size of this run is denoted by ri. 1 runs ← the run decomposition of S 2 R ← an empty stack 3 while runs 6= ∅ do 4 5 6 7 8 9 10 remove a run r from runs and push r onto R while true do if h > 3 and r1 > r3 then merge the runs R2 and R3 else if h > 2 and r1 > r2 then merge the runs R1 and R2 else if h > 3 and r1 + r2 > r3 then merge the runs R1 and R2 else if h > 4 and r2 + r3 > r4 then merge the runs R1 and R2 else break 11 while h 6= 1 do merge the runs R1 and R2 // main loop of TimSort // #1 // #2 // #3 // #4 // #5 3 TimSort runs in O(n log n) At the first release of TimSort [9], a time complexity of O(n log n) was announced with no element of proof given. It seemed to remain unproved until our recent preprint [1], where we provide a confirmation of this fact, using a proof which is not difficult but a bit tedious. This result was refined later in [3], where the authors provide lower and upper bounds, including explicit multiplicative constants, for different merge sort algorithms. Our main concern is to provide an insightful proof of the complexity of TimSort, in order to highlight how well designed is the strategy used to choose the order in which the merges are performed. The present section is more detailed than the following ones as we want it to be self-contained once TimSort has been translated into Algorithm 3 (see below). As our analysis is about to demonstrate, in terms of worst-case complexity, the good performances of TimSort do not rely on the way merges are performed. Thus we choose to ignore their many optimizations and consider that merging two runs of lengths r and r′ requires both r + r′ element moves and r + r′ element comparisons. Therefore, to quantify the running time of TimSort, we only take into account the number of comparisons performed. In particular, aiming at computing precise bounds on the running time of TimSort, we follow [5, 1, 3, 8] and define the merge cost for merging two runs of lengths r and r′ as r + r′, i.e., the length of the resulting run. Henceforth, we will identify the time spent for merging two runs with the merge cost of this merge. N. Auger, V. Jugé, C. Nicaud, and C. Pivoteau 5 ◮ Theorem 1. Let C be the class of arrays of length n, whose run decompositions consist of ρ mono- tonic runs of respective lengths r1, . . . , rρ. Let H(p1, . . . , pρ) = −Pρ i=1 pi log2(pi) be the binary Shannon entropy, and let H = H(r1/n, . . . , rρ/n). The running time of TimSort on arrays in C is O(n + nH). From this result, we easily deduce the following complexity bound on TimSort, which is less precise but more simple. ◮ Theorem 2. The running time of TimSort on arrays of length n that consist of ρ monotonic runs is O(n + n log ρ), and therefore O(n log n). Proof. The function f : x 7→ −x ln(x) is concave on the interval R>0 of positive real numbers, since its second derivative is f ′′(x) = −1/x. Hence, when p1, . . . , pρ are positive real numbers that sum up to one, we have H(p1, . . . , pρ) = Pρ i=1 f (pi)/ ln(2) 6 ρf (1/ρ)/ ln(2) = log2(ρ). In particular, this means that H 6 log2(ρ), and therefore that TimSort runs in time O(n + n log ρ). Since ρ 6 n, it further follows that O(n + n log ρ) ⊆ O(n + n log n) = O(n log n), which completes the proof. ◭ Before proving Theorem 1, we first show that it is optimal up to a multiplicative constant, by recalling the following variant of a result from [2, Theorem 2]. ◮ Proposition 3. For every algorithm comparing only pairs of elements, there exists an array in the class C whose sorting requires at least nH − 3n element comparisons. Proof. In the comparison model, at least log2(C) element comparisons are required for sorting all arrays in C. Hence, we prove below that log2(C) > nH − 3n. Let π = (π1, . . . , πρ) be a partition of the set {1, . . . , n} into ρ subsets of respective sizes r1, . . . , rρ; we say that π is nice if max πi > min πi+1 for all i 6 ρ − 1. Let us denote by P the set of partitions π of {1, . . . , n} such that πi = ri for all i 6 ρ, and by N the set of nice partitions. Let us transform every partition π ∈ P into a nice partition as follows. First, by construction of the run decomposition of an array, we know that r1, . . . , rρ−1 > 2, and therefore that min πi < max πi for all i 6 ρ − 1. Then, for all i 6 ρ − 1, if max πi < min πi+1, we exchange the partitions to which belong max πi and min πi+1, i.e., we move max πi from the set πi to πi+1, and min πi+1 from πi+1 to πi. Let π∗ be the partition obtained after these exchanges have been performed. Observe that π∗ is nice, and that at most 2ρ−1 partitions π ∈ P can be transformed into π∗. This proves that 2ρ−1N > P. Let us further identify every nice partition π∗ with an array in C, which starts with the elements of π∗ ρ. We thereby define an injective map from N to C, which proves that C > N. Finally, variants of the Stirling formula indicate that (k/e)k 6 k! 6 e√k(k/e)k for all k > 1. This 1 (listed in increasing order), then of π∗ 2, . . . , π∗ proves that log2(C) > log2(C) > (1 − ρ) + log2(P) > (1 − ρ) + n log2(n) − ρ log2(e) − Pρ > nH + (1 − ρ − ρ log2(e)) − 1/2Pρ i=1(ri + 1/2) log2(ri) i=1 log2(ri). By concavity of the function x 7→ log2(x), it follows that Pρ i=1 log2(ri) 6 ρ log2(n/ρ). One checks easily that the function x 7→ x log2(n/x) takes its maximum value at x = n/e, and since n > ρ, we conclude that log2(C) > nH − (1 + log2(e) + log2(e)/e)n > nH − 3n. ◭ We focus now on proving Theorem 1. The first step consists in rewriting Algorithm 1 and Algorithm 2 in a form that is easier to deal with. This is done in Algorithm 3. ◮ Claim 4. For any input, Algorithms 1 and 3 perform the same comparisons. Proof. The only difference is that Algorithm 2 was changed into the while loop of lines 5 to 10 in Algorithm 3. Observing the different cases, it is straightforward to verify that merges involving the same runs take place in the same order in both algorithms. Indeed, if r3 < r1, then r3 6 r1 + r2, and therefore line 5 is triggered in Algorithm 2, so that both algorithms merge the 2nd and 3rd runs. On the contrary, 6 On the Worst-Case Complexity of TimSort if r3 > r1, then both algorithms merge the 1st and 2nd runs if and only if r2 6 r1 or r3 6 r1 + r2 (or r4 6 r2 + r3). ◭ ◮ Remark 5. Proving Theorem 2 only requires analyzing the main loop of the algorithm (lines 3 to 10). Indeed, computing the run decomposition (line 1) can be done on the fly, by a greedy algorithm, in time linear in n, and the final loop (line 11) might be performed in the main loop by adding a fictitious run of length n + 1 at the end of the decomposition. In the sequel, for the sake of readability, we also omit checking that h is large enough to trigger the cases #2 to #5. Once again, such omissions are benign, since adding fictitious runs of respective lengths 8n, 4n, 2n and n (in this order) at the beginning of the decomposition would ensure that h > 4 during the whole loop. We sketch now the main steps of our proof, i.e., the amortized analysis of the main loop. A first step is to establish the invariant (1) and (2), ensuring an exponential growth of the run lengths within the stack. Elements of the input array are easily identified by their starting position in the array, so we consider them as well-defined and distinct entities (even if they have the same value). The height of an element in the stack of runs is the number of runs that are below it in the stack: the elements belonging to the run Ri in the stack S = (R1, . . . , Rh) have height h − i, and we recall that the length of the run Ri is denoted by ri. ◮ Lemma 6. At any step during the main loop of TimSort, we have ri + ri+1 < ri+2 for all i ∈ {3, . . . , h − 2}. Proof. We proceed by induction. The proof consists in verifying that, if the invariant holds at some point, then it still holds when an update of the stack occurs in one of the five situations labeled #1 to #5 in the algorithm. This can be done by a straightforward case analysis. We denote by S = (R1, . . . , Rh) the new state of the stack after the update: If Case #1 just occurred, a new run R1 was pushed. This implies that none of the conditions of Cases #2 to #5 hold in S, otherwise merges would have continued. In particular, we have r2 + r3 < r4. As ri = ri−1 for all i > 2, and since the invariant holds for S, it also holds for S. If one of the Cases #2 to #5 just occurred, ri = ri+1 for all i > 3. Since the invariant holds for S, it must also hold for S. ◭ ◮ Corollary 7. During the main loop of TimSort, whenever a run is about to be pushed onto the stack, we have ri 6 2(i+1−j)/2rj for all integers i 6 j 6 h. Proof. Since a run is about to be pushed, none of the conditions of Cases #2 to #5 hold in the stack S. Hence, we have r1 < r2, r1 +r2 < r3 and r2 +r3 < r4, and Lemma 6 further proves that ri +ri+1 < ri+2 for all i ∈ {3, . . . , h − 2}. In particular, for all i 6 h − 2, we have ri < ri+1, and thus 2ri 6 ri + ri+1 6 ri+2. It follows immediately that ri 6 2−kri+2k 6 2−kri+2k+1 for all integers k > 0, which is exactly the statement of Corollary 7. ◭ Corollary 7 will be crucial in proving that the main loop of TimSort can be performed for a merge cost O(n + nH). However, we do not prove this upper bound directly. Instead, we need to distinguish several situations that may occur within the main loop. Consider the sequence of Cases #1 to #5 triggered during the execution of the main loop of TimSort. It can be seen as a word on the alphabet {#1, . . . , #5} that starts with #1, which completely encodes the execution of the algorithm. We split this word at every #1, so that each piece corresponds to an iteration of the main loop. Those pieces are in turn split into two parts, at the first occurrence of a symbol #3, #4 or #5. The first half is called a starting sequence and is made of a #1 followed by the maximal number of #2's. The second half is called an ending sequence, it starts with #3, #4 or #5 (or is empty) and it contains no occurrence of #1 (see Figure 3 for an example). N. Auger, V. Jugé, C. Nicaud, and C. Pivoteau 7 #1 #2 #2 #2 #3 #2 #5 #2 #4 #2 #1 #2 #2 #2 #2 #2 #5 #2 #3 #3 #4 #2 starting seq. {z } ending seq. {z } starting seq. {z } ending seq. {z } Figure 3 The decomposition of the encoding of an execution into starting and ending sequences. We bound the merge cost of starting sequences first, and will deal with ending sequences afterwards. ◮ Lemma 8. The cost of all merges performed during the starting sequences is O(n). Proof. More precisely, for a stack S = (R1, . . . , Rh), we prove that a starting sequence beginning with a push of a run R of size r onto S uses at most γr comparisons in total, where γ is the real constant 2Pj>1 j/2j/2. After the push, the stack is S = (R, R1, . . . , Rh) and, if the starting sequence contains k > 1 letters, i.e. k − 1 occurrences of #2, then this sequence amounts to merging the runs R1, R2, . . . , Rk. Since no merge is performed if k = 1, we assume below that k > 2. More precisely, the total cost of these merges is C = (k − 1)r1 + (k − 1)r2 + (k − 2)r3 + . . . + rk 6 Pk i=1(k + 1 − i)ri. The last occurrence of Case #2 ensures that r > rk, hence applying Corollary 7 to the stack S = (R1, . . . , Rh) shows that r > rk > 2(k−1−i)/2ri for all i = 1, . . . , k. It follows that C/r 6 Pk i=1(k + 1 − i)2(i+1−k)/2 = 2Pk j=1j2−j/2 < γ. This concludes the proof, since each run is the beginning of exactly one starting sequence, and the ◭ sum of their lengths is n. Now, we must take care of run merges that take place during ending sequences. The cost of merging two runs will be taken care of by making run elements pay tokens: whenever two runs of lengths r and r′ are merged, r + r′ tokens are paid (not necessarily by the elements of those runs that are merged). In order to do so, and to simplify the presentation, we also distinguish two kinds of tokens, the ♦-tokens and the ♥-tokens, which can both be used to pay for comparisons. Two ♦-tokens and one ♥-token are credited to an element when its run is pushed onto the stack or when its height later decreases because of a merge that took place during an ending sequence: in the latter case, all the elements of R1 are credited when R1 and R2 are merged, and all the elements of R1 and R2 are credited when R2 and R3 are merged. Tokens are spent to pay for comparisons, depending on the case triggered: Case #2: every element of R1 and R2 pays 1 ♦. This is enough to cover the cost of merging R2 and R3, because r1 > r3 in this case, and therefore r2 + r1 > r2 + r3. Case #3: every element of R1 pays 2 ♦. In this case r1 > r2, and the cost is r1 + r2 6 2r1. Cases #4 and #5: every element of R1 pays 1 ♦ and every element of R2 pays 1 ♥. The cost r1 + r2 is exactly the number of tokens spent. ◮ Lemma 9. The balances of ♦-tokens and ♥-tokens of each element remain non-negative throughout the main loop of TimSort. Proof. In all four cases #2 to #5, because the height of the elements of R1 and possibly the height of those of R2 decrease, the number of credited ♦-tokens after the merge is at least the number of ♦-tokens spent. The ♥-tokens are spent in Cases #4 and #5 only: every element of R2 pays one ♥-token, and then belongs to the topmost run R1 of the new stack S = (R1, . . . , Rh−1) obtained after merging R1 and R2. Since Ri = Ri+1 for i > 2, the condition of Case #4 implies that r1 > r2 and the condition of Case #5 implies that r1 + r2 > r3: in both cases, the next modification of the stack S is another merge, which belongs to the same ending sequence. This merge decreases the height of R1, and therefore decreases the height of the elements of R2, who will regain one ♥-token without losing any, since the topmost run of the stack never pays with ♥-tokens. This proves that, whenever an element pay one ♥-token, the next modification is another merge during which it regains its ♥-token. This concludes the proof by direct induction. ◭ 8 On the Worst-Case Complexity of TimSort Finally, consider some element belonging to a run R. Let S be the stack just before pushing the run R, and let S = (R1, . . . , Rh) be the stack just after the starting sequence of the run R (i.e., the starting sequence initiated when R is pushed onto S) is over. Every element of R will be given at most 2h ♦-tokens and h ♥-tokens during the main loop of the algorithm. ◮ Lemma 10. The height of the stack when the starting sequence of the run R is over satisfies the inequality h 6 4 + 2 log2(n/r). Proof. Since none of the runs R3, . . . , Rh has been merged during the starting sequence of R, applying Corollary 7 to the stack S proves that r3 6 22−h/2rh 6 22−h/2n. The run R has not yet been merged either, which means that r = r1. Moreover, at the end of this starting sequence, the conditions of case #2 do not hold anymore, which means that r1 6 r3. It follows that r = r1 6 r3 6 22−h/2n, which entails the desired inequality. ◭ Collecting all the above results is enough to prove Theorem 1. First, as mentioned in Remark 5, computing the run decomposition can be done in linear time. Then, we proved that the starting sequences of the main loop have a merge cost O(n), and that the ending sequences have a merge cost O(Pρ i=1(1 + log(n/ri))ri) = O(n + nH). Finally, the additional merges of line 11 may be taken care of by Remark 5. This concludes the proof of the theorem. 4 Refined analysis and precise worst-case complexity The analysis performed in Section 3 proves that TimSort sorts arrays in time O(n + nH). Looking more closely at the constants hidden in the O notation, we may in fact prove that the cost of merges performed during an execution of TimSort is never greater than 6nH + O(n). However, the lower bound provided by Proposition 3 only proves that the cost of these merges must be at least nH +O(n). In addition, there exist sorting algorithms [8] whose merge cost is exactly nH + O(n). Hence, TimSort is optimal only up to a multiplicative constant. We focus now on finding the least real constant κ such that the merge cost of TimSort is at most κnH+O(n), thereby proving a conjecture of [3]. ◮ Theorem 11. The merge cost of TimSort on arrays in C is at most κnH + O(n), where κ = 3/2. Furthermore, κ = 3/2 is the least real constant with this property. The rest of this Section is devoted to proving Theorem 11. The theorem can be divided into two statements: one that states that TimSort is asymptotically optimal up to a multiplicative constant of κ = 3/2, and one that states that κ is optimal. The latter statement was proved in [3]. Here, we borrow their proof for the sake of completeness. ◮ Proposition 12. There exist arrays of length n on which the merge cost of TimSort is at least 3/2n log2(n) + O(n). Proof. The dynamics of TimSort when sorting an array involves only the lengths of the monotonic runs in which the array is split, not the actual array values. Hence, we identify every array with the sequence of its run lengths. Therefore, every sequence of run lengths hr1, . . . , rρi such that r1, . . . , rρ−1 > 2, rρ > 1 and r1 + . . . + rρ = n represents at least one possible array of length n. We define inductively a sequence of run lengths R(n) as follows: R(n) =   hni R(k) · R(k − 2) · h2i R(k) · R(k − 1) · h2i if 1 6 n 6 6, if n = 2k for some k > 4, if n = 2k + 1 for some k > 3, where the concanetation of two sequences s and t is denoted by s · t. Then, let us apply the main loop of TimSort on an array whose associated monotonic runs have lengths r = hr1, . . . , rρi, starting with an empty stack. We denote the associated merge cost by c(r) and, N. Auger, V. Jugé, C. Nicaud, and C. Pivoteau 9 if S = (R1, . . . , Rh) is the stack obtained after the main loop has been applied, we denote by s(r) the sequence hr1, . . . , rhi. An immediate induction shows that, if r1 > r2 + . . . + rρ + 1, then c(r) = c(hr2, . . . , rρi) and s(r) = hr1i· s(hr2, . . . , rρi). Similarly, if r1 > r2 + . . . + rρ + 1 and r2 > r3 + . . . + rρ + 1, then c(r) = c(hr3, . . . , rρi) and s(r) = hr1, r2i · s(hr3, . . . , rρi). Consequently, and by another induction on n, it holds that s(R(n)) = hni and that c(R(n)) =   0 c(R(k)) + c(R(k − 2)) + 3k c(R(k)) + c(R(k − 1)) + 3k + 2 if 1 6 n 6 6, if n = 2k for some k > 4, if n = 2k + 1 for some k > 3. Let ux = c(R(⌊x⌋)) and vx = (ux−4 − 15/2)/x − 3 log2(x)/2. An immediate induction shows that c(R(n)) > c(R(n + 1)) for all integers n > 0, which means that x 7→ ux is non-decreasing. Then, we have un = un/2 + u(n−3)/2 + ⌈3n/2⌉ for all integers n > 6, and therefore ux > 2ux/2−2 + 3(x − 1)/2 for all real numbers x > 6. Consequently, for x > 11, it holds that xvx = ux−4 − 3x log2(x)/2 − 15/2 > 2ux/2−4 + 3(x − 5)/2 − 3x log2(x)/2 − 15/2 = xvx/2. : 11/2 6 t < 11}. Since vt = This proves that vx > vx/2, from which it follows that vx > inf{vt −15/(2t)− 3 log2(t)/2 > −15/11− 3 log2(11)/2 > −7 for all t ∈ [11/2, 11), we conclude that vx > −7 for all x > 11, and thus that c(R(n)) = un > (n + 4)vn+4 + 3(n + 4) log2(n + 4)/2 > 3n log2(n)/2 − 7(n + 4), thereby proving Proposition 12. ◭ It remains to prove the first statement of Theorem 11. Our initial step towards this statement consists in refining Lemma 6. This is the essence of Lemmas 13 to 15. ◮ Lemma 13. At any step during the main loop of TimSort, if h > 4, we have r2 < r4 and r3 < r4. Proof. We proceed by induction. The proof consists in verifying that, if the invariant holds at some point, then it still holds when an update of the stack occurs in one of the five situations labeled #1 to #5 in the algorithm. This can be done by a straightforward case analysis. We denote by S = (R1, . . . , Rh) the stack just before the update, and by S = (R1, . . . , Rh) the new state of the stack after the update: If Case #1 just occurred, a new run R1 was pushed. This implies that the conditions of Cases #2 and #4 did not hold in S, otherwise merges would have continued. In particular, we have r2 = r1 < r3 = r4 and r3 = r2 < r1 + r2 < r3 = r4. If one of the Cases #2 to #5 just occurred, it holds that r2 6 r2 + r3, that r3 = r4 and that r4 = r5. Since Lemma 6 proves that r3 + r4 < r5, it follows that r2 6 r2 + r3 < r3 + r4 < r5 = r4 and that r3 = r4 < r3 + r4 < r5 = r4. ◭ ◮ Lemma 14. At any step during the main loop of TimSort, and for all i ∈ {3, . . . , h}, it holds that r2 + . . . + ri−1 < φ ri. Proof. Like for Lemmas 6 and 13, we proceed by induction and verify that, if the invariant holds at some point, then it still holds when an update of the stack occurs in one of the five situations labeled #1 to #5 in the algorithm. Let us denote by S = (R1, . . . , Rh) the stack just before the update, and by S = (R1, . . . , Rh) the new state of the stack after the update: If Case #1 just occurred, then we proceed by induction on i > 3. First, for i = 3, since the conditions for Cases #3 and #4 do not hold in S, we know that r2 = r1 < r2 = r3 and that r2 + r3 = r1 + r2 < r3 = r4. Then, for i > 5, Lemma 6 states that ri−2 + ri−1 < ri, and therefore (i) if ri−1 6 φ−1 ri, then r2 + . . . + ri−1 < (φ + 1)ri−1 = φ2ri−1 6 φri, and (ii) if ri−1 > φ−1 ri, then ri−2 6 (1− φ−1) ri = φ−2 ri, and thus r2 + . . . + ri−1 < (φ + 1) ri−2 + ri−1 6 φ ri−2 + ri 6 (φ−1 + 1)ri = φ ri. Hence, in that case, it holds that r2 + . . . + ri−1 < φ ri for all i ∈ {3, . . . , h}. 10 On the Worst-Case Complexity of TimSort If one of the Cases #2 to #5 just occurred, it holds that r2 6 r2 + r3 and that rj = rj+1 for all j > 3. It follows that r2 + . . . + ri−1 6 r2 + . . . + ri < φ ri+1 = ri. ◭ ◮ Remark. We could also have derived directly Lemma 13 from Lemma 14, by noting that φ2 r2 = (φ + 1)r2 < φ r2 + φ r3 < φ2 r4. ◮ Lemma 15. After every merge that occurred during an ending sequence, we have r1 < φ2r2. Proof. Once again, we proceed by induction. We denote by S = (R1, . . . , Rh) the stack just before an update occurs, and by S = (R1, . . . , Rh) the new state of the stack after after the update: If Case #2 just occurred, then this update is not the first one within the ending sequence, hence r1 = r1 < φ2 r2 < φ2(r2 + r3) = φ2 r2. If one of the Cases #2 to #5 just occurred, then r1 6 r3 and Lemma 14 proves that r2 < φ r3, which proves that r1 = r1 + r2 < (φ + 1)r3 = φ2 r2. ◭ ◮ Lemma 16. After every merge triggered by Case #2, we have r2 < φ2r1. Proof. We denote by S = (R1, . . . , Rh) the stack just before an update triggered by Case #2 occurs, and by S = (R1, . . . , Rh) the new state of the stack after after the update. It must hold that r1 > r3 and Lemma 14 proves that r2 < φ r3. It follows that r2 = r2 + r3 < (φ + 1)r3 = φ2 r3 < φ2 r1 = φ2 r1. ◭ Our second step towards proving the first statement of Theorem 11 consists in identifying which sequences of merges an ending sequence may be made of. More precisely, in the proof of Lemma 9, we proved that every merge triggered by a case #4 or #5 must be followed by another merge, i.e., it cannot be the final merge of an ending sequence. We present now a variant of this result, which involves distinguishing between merges triggered by a case #2 and those triggered by a case #3, #4 or #5. Hence, we denote by #X every #3, #4 or #5. ◮ Lemma 17. No ending sequence contains two conscutive #2's, nor does it contain a subsequence of the form #X #X #2. Proof. Every ending sequence starts with an update #X, where #X is equal to #3, #4 or #5. Hence, it suffices to prove that no ending sequence contains a subsequence t of the form #X #X #2 or #X #2 #2. Indeed, for the sake of contradiction, assume that it does, and let S = (R1, . . . , Rh) be the stack just before t starts. We distinguish two cases, depending on the value of t: If t is the sequence #X #X #2, it must hold that r1 + r2 < r4 and that r1 + r2 + r3 > r5, as illustrated in Figure 4 (top). Since Lemma 6 proves that r3 + r4 < r5, it follows that r1 + r2 + r3 > r5 > r3 + r4 > r1 + r2 + r3, which is impossible. If t is the sequence #X #2 #2, it must hold that r1 < r3 and that r1 + r2 > r5, as illustrated in Figure 4 (bottom). Since Lemmas 6 and 13 prove that r3 + r4 < r5 and that r2 < r4, it comes that r1 + r2 > r5 > r3 + r4 > r1 + r2, which is also impossible. ◭ Our third step consists in modifying the cost allocation we had chosen in Section 3, which is not sufficient to prove Theorem 11. Instead, we associate to every run R its potential, which depends only on the length r of the run, and is defined as pot(r) = 3r log2(r)/2. We also call potential of a set of runs the sum of the potentials of the runs it is formed of, and potential variation of a (sequence of) merges the increase in potential caused by these merge(s). We shall prove that the potential variation of every ending sequence dominates its merge cost, up to a small error term. In order to do this, let us study more precisely individual merges. Below, we respectively denote by ∆pot(m) and c(m) the potential variation and the merge cost of a merge m. Then, we say that m is a balanced merge if c(m) 6 ∆pot(m). In the next Lemmas, we prove that most merges are balanced or can be grouped into sequences of merges that are balanced overall. ◮ Lemma 18. Let m be a merge between two runs R and R′. If φ−2 r 6 r′ 6 φ2 r, then m is balanced. N. Auger, V. Jugé, C. Nicaud, and C. Pivoteau 11 r1 r2 r3 r4 r5 r1 r2 r3 r4 r5 merge #X merge #X r1 6 r3 r1 + r2 r3 r4 r5 r1 + r2 r3 r4 r5 merge #X r1 + r2 < r4 merge #2 r1 + r2 + r3 r4 r5 r1 + r2 r3 + r4 r5 merge #2 r1 + r2 + r3 > r5 merge #2 r1 + r2 > r5 r1 + r2 + r3 r4 + r5 r1 + r2 r3 + r4 + r5 Figure 4 Applying successively merges #X #2 #2 or #X #X #2 to a stack is impossible. Proof. Let x = r/(r + r′): we have Φ < x < 1 − Φ, where Φ = 1/(1 + φ2). Then, observe that ∆(m) = 3(r + r′)H(x)/2, where H(x) = −x log2(x) − (1 − x) log2(x) is the binary Shannon entropy of a Bernoulli law of parameter x. Moreover, the function z 7→ H(z) = H(1 − z) is increasing on [0, 1/2]. It follows that H(x) > H(Φ) ≈ 0.85 > 2/3, and therefore that ∆(m) > r + r′ = c(m). ◮ Lemma 19. Let m be a merge that belongs to some ending sequence. If m is a merge #2, then m is balanced and, if m is followed by another merge m′, then m′ is also balanced. ◭ Proof. Lemma 17 ensures that m was preceded by another merge m⋆, which must be a merge #X. Denoting by S = (R1, . . . , Rh) the stack just before the merge m⋆ occurs, the update m consists in merging the runs R3 and R4. Then, it comes that r1 6 r3 and that r1 + r2 > r4, while Lemma 13 and 14 respectively prove that r3 < r4 and that r2 < φ r3. Hence, we both have r3 < r4 and r4 < r1 + r2 < (1 + φ)r3 = φ2 r3, and Lemma 19 proves that m is balanced. Then, if m is followed by another merge m′, Lemma 17 proves that m′ is also a merge #X, between runs of respective lengths r1 + r2 and r3 + r4. Note that r1 6 r3 and that r1 + r2 > r4. Since Lemma 13 proves that r2 < r4 and that r3 < r4, it follows that 2(r1 + r2) > 2r4 > r3 + r4 > r1 + r2 and, using the fact that 2 < 1 + φ = φ2, Lemma 19 therefore proves that m is balanced. ◭ ◮ Lemma 20. Let m be a merge #X between two runs R1 and R2 such that r1 < φ−2 r2. Then, m is followed by another merge m′, and c(m) + c(m′) 6 ∆pot(m) + ∆pot(m′). Proof. Let m⋆ be the update the immediately precedes m. Let also S⋆ = (R⋆ and S ′ = (R′ and just after m occurs. h⋆ ), S = (R1, . . . , Rh) h′) be the respective states of the stack just before m⋆ occurs, just before m occurs 1, . . . , R⋆ 1, . . . , R′ Since r1 < φ−2 r2, Lemma 16 proves that m⋆ is either an update #1 or a merge #X. In both cases, Indeed, if m⋆ is an update #1, then we must have 3 = r4, and if m′ is a merge #X, then Lemmas 6 and 13 5 = r4 and that r2 = r⋆ it follows that r2 < r3 and that r2 + r3 < r4. r2 = r⋆ 2 = r3 and r2 + r3 = r⋆ respectively prove that r2 + r3 = r⋆ 2 < r⋆ 4 < r⋆ 1 + r⋆ 3 + r⋆ 1 < r⋆ 3 < r⋆ 4 = r3. Then, since m is a merge #X, we also know that r1 6 r3. Since r1 < φ−2 r2 and r2 + r3 < r4, this 1 = r1 + r2 6 r2 + r3 < r4 = r′ 3. means that r1 + r2 > r3. It follows that r′ Consequently, the merge m must be followed by a merge m′, which is triggered by case #3. 2 = r3 6 r1 + r2 = r′ 1 and that r′ Finally, let x = r1/(r1 + r2) and y = (r1 + r2)/(r1 + r2 + r3). It comes that c(m) + c(m′) = (r1 + r2 + r3)(1 + y) and that ∆pot(m)+ ∆pot(m′) = 3(r1 + r2 + r3) (yH(x) + H(y))/2, where we recall that H is the binary Shannon entropy function, with H(t) = −t log2(t)− (1− t) log2(t). The above inequalities about r1, r2 and r3 prove that 0 6 2− 1/y 6 x 6 1/(1 + φ2). Since H is increasing on the interval [0, 1/2], and since 1 + φ2 > 2, it follows that ∆pot(m) + ∆pot(m′) > 3(r1 + r2 + r3) (yH(2 − 1/y) + H(y))/2. Hence, let F (y) = 3 (yH(2 − 1/y) + H(y))/2 − (1 + y). We shall prove that F (y) > 0 for all y > 0 such that 0 6 2 − 1/y 6 1/(1 + φ2), i.e., such that 1/2 6 y 6 (1 + φ2)/(1 + 2φ2). To that mean, observe that F ′′(y) = 3/((1 − y)(1 − 2y) ln(2)) < 0 for all y ∈ (1/2, 1). Thus, F is concave on (1/2, 1). 12 On the Worst-Case Complexity of TimSort Since F (1/2) = 0 and F (3/4) = 1/2, it follows that F (y) > 0 for all y ∈ [1/2, 3/4]. Checking that (1 + φ2)/(1 + 2φ2) < 3/4 completes the proof. ◭ ◮ Lemma 21. Let m be the first merge of the ending sequence associated with a run R. Let R1 and R2 be the runs that m merges together. If r1 > φ2 r2, it holds that c(m) 6 ∆pot(m) + r. Proof. By definition of m, we have R = R1, and thus r = r1 > r2. Hence, it follows that ∆pot(m) = r log((r + r2)/r) + r2 log((r + r2)/r2) > r2 log((r + r2)/r2) > r2 = c(m) − r. ◭ ◮ Proposition 22. Let s be the ending sequence associated with a run R, and let ∆pot(s) and c(s) be its potential variation and its merge cost. It holds that c(s) 6 ∆pot(s) + r. Proof. Let us group the merges of s as follows: (i) if m is an unbalanced merge #X between two runs R1 and R2 such that r1 < r2, then m is followed by another merge m′, and we group m and m′ together; (ii) otherwise, and if m has not been grouped with its predecessor, it forms its own group. In case (i), Lemma 21 ensures that m′ itself cannot be grouped with another merge. This means that our grouping is unambiguous. Then, let g be such a group, with potential variation ∆pot(g) and merge cost c(g). Lemmas 18 to 21 prove that c(g) 6 ∆pot(g) + r if g is formed of the first merge of s only, and that c(g) 6 ∆pot(g) in all other cases. Proposition 22 follows. ◭ Collecting all the above results is enough to prove Theorem 11. First, like in Section 3, computing the run decomposition and merging runs in starting sequences has a cost O(n), and the final merges of line 11 may be taken care of by Remark 5. Second, by Proposition 22, ending sequences have a merge cost dominated by ∆pot + n, where ∆pot is the total variation of potential during the algorithm. Observing that ∆pot = −3/2Pρ i=1 ri log2(ri/n) = −3nH/2 concludes the proof of the theorem. 5 About the Java version of TimSort #1 #1 50 18 24 #1 18 24 24 #1 #1 20 28 92 #3 28 92 92 #2 50 42 #1 4 6 20 28 92 #1 6 20 28 92 #1 8 4 6 20 28 92 #2 8 10 20 28 92 #1 1 8 10 20 28 92 Figure 5 Execution of the main loop of Java's TimSort (Algorithm 3, without merge case #5, at line 9), with the lengths of the runs in runs being (24, 18, 50, 28, 20, 6, 4, 8, 1). When the second to last run (of length 8) is pushed onto the stack, the while loop of line 5 stops after only one merge, breaking the invariant (in red), unlike what we see in Figure 2 using the Python version of TimSort. Algorithm 2 (and therefore Algorithm 3) does not correspond to the original TimSort. Before release 3.4.4 of Python, the second part of the condition (in blue) in the test at line 3 of merge_collapse (and therefore merge case #5 of Algorithm 3) was missing. This version of the algorithm worked fine, meaning that it did actually sort arrays, but the invariant given by Equation (1) did not hold. Figure 5 illustrates the difference caused by the missing condition when running Algorithm 3 on the same input as in Figure 2. This was discovered by de Gouw et al. [4] when trying to prove the correctness of the Java imple- mentation of TimSort (which is the same as in the earlier versions of Python). And since the Java version of the algorithm uses the (wrong) invariant to compute the maximum size of the stack used to store the runs, the authors were able to build a sequence of runs that causes the Java implementation of TimSort to crash. They proposed two solutions to fix TimSort: reestablish the invariant, which led to the current Python version, or keep the original algorithm and compute correct bounds for the stack size, which is the solution that was chosen in Java 9 (note that this is the second time these values had to be changed). To do the latter, the developers used the claim in [4] that the invariant cannot be violated for N. Auger, V. Jugé, C. Nicaud, and C. Pivoteau 13 two consecutive runs on the stack, which turns out to be false,3 as illustrated in Figure 6. Thus, it is still possible to cause the Java implementation to fail: it uses a stack of runs of size at most 49 and we were able to compute an example requiring a stack of size 50 (see http://igm.univ-mlv.fr/~pivoteau/ Timsort/Test.java), causing an error at runtime in Java's sorting method. #1 16 25 83 109 #1 25 83 109 #1 83 109 #1 109 #1 7 8 16 25 83 109 #1 8 16 25 83 109 #1 26 7 8 16 25 83 109 #2 26 15 16 25 83 109 #2 26 31 25 83 109 #1 2 26 56 83 109 #2 26 56 83 109 #1 27 2 26 56 83 109 #2 27 28 56 83 109 Figure 6 Execution of the main loop of the Java version of TimSort (without merge case #5, at line 9 of Algorithm 3), with the lengths of the runs in runs being (109, 83, 25, 16, 8, 7, 26, 2, 27). When the algorithm stops, the invariant is violated twice, for consecutive runs (in red). Even if the bug we highlighted in Java's TimSort is very unlikely to happen, this should be corrected. And, as advocated by de Gouw et al. and Tim Peters himself,4 we strongly believe that the best solution would be to correct the algorithm as in the current version of Python, in order to keep it clean and simple. However, since this is the implementation of Java's sort for the moment, there are two questions we would like to tackle: Does the complexity analysis holds without the missing condition? And, can we compute an actual bound for the stack size? We first address the complexity question. It turns out that the missing invariant was a key ingredient for having a simple and elegant proof. At any time during the main loop of Java's TimSort, if the stack of runs is ◮ Proposition 23. (R1, . . . , Rh) then we have r3 < r4 < . . . < rh and, for all i > 3, we have (2 + √7)ri > r2 + . . . + ri−1. Proof ideas. The proof of Proposition 23 is much more technical and difficult than insightful, and there- fore we just summarize its main steps. As in previous sections, this proof relies on several inductive arguments, using both inductions on the number of merges performed, on the stack size and on the run sizes. The inequalities r3 < r4 < . . . < rh come at once, hence we focus on the second part of Proposition 23. Since separating starting and ending sequences was useful in Section 4, we first introduce the notion of stable stacks: a stack S is stable if, when operating on the stack S = (R1, . . . , Rh), Case #1 is triggered (i.e. Java's TimSort is about to perform a run push operation). We also call obstruction indices the integers i > 3 such that ri 6 ri−1 + ri−2: although they do not exist in Python's TimSort, they may exist, and even be consecutive, in Java's TimSort. We prove that, if i − k, i − k + 1, . . . , i are obstruction indices, then the stack sizes ri−k−2, . . . , ri grow "at linear speed". For instance, in the last stack of Figure 6, obstruction indices are 4 and 5, and we have r2 = 28, r3 = r2 + 28, r4 = r3 + 27 and r5 = r4 + 26. Full proof in Section A.1.1. Finally, we study so-called expansion functions, i.e. functions f : [0, 1] 7→ R such that, for every stable stack S = (R1, . . . , Rh), we have r2 + . . . + rh−1 6 rhf (rh−1/rh). We exhibit an explicit function f such that f (x) 6 2 + √7 for all x ∈ [0, 1], and we prove by induction on rh that f is an expansion function, from which we deduce Proposition 23. ◭ Once Proposition 23 is proved, we easily recover the following variant of Lemmas 6 and 10. ◮ Lemma 24. At any time during the main loop of Java's TimSort, if the stack is (R1, . . . , Rh) then we have r2/(2 + √7) 6 r3 < r4 < . . . < rh and, for all i > j > 3, we have ri > δi−j−4rj , where δ = (cid:0)5/(2 + √7)(cid:1)1/5 > 1. Furthermore, at any time during an ending sequence, including just before it starts and just after it ends, we have r1 6 (2 + √7)r3. 3 This is the consequence of a small error in the proof of their Lemma 1. The constraint C1 > C2 has no reason to be. Indeed, in our example, we have C1 = 25 and C2 = 31. 4 Here is the discussion about the correction in Python: https://bugs.python.org/issue23515. 14 On the Worst-Case Complexity of TimSort Proof. The inequalities r2/(2 + √7) 6 r3 < r4 < . . . < rh are just a (weaker) restatement of Proposi- tion 23. Then, for j > 3, we have (2 + √7)rj+5 > rj + . . . + rj+4 > 5rj, i.e. rj+5 > δ5rj , from which one gets that ri > δi−j−4rj. Finally, we prove by induction that r1 6 (2 + √7)r3 during ending sequences. First, when the ending sequence starts, r1 < r3 6 (2 + √7)r3. Before any merge during this sequence, if the stack is S = (R1, . . . Rh), then we denote by S = (R1, . . . , Rh−1) the stack after the merge. If the invariant holds before the merge, in Case #2, we have r1 = r1 6 (2 + √7)r3 6 (2 + √7)r4 = (2 + √7)r3; and using Proposition 23 in Cases #3 and #4, we have r1 = r1 + r2 and r1 6 r3, hence r1 = r1 + r2 6 r2 + r3 6 (2 + √7)r4 = (2 + √7)r3, concluding the proof. ◭ We can then recover a proof of complexity for the Java version of TimSort, by following the same proof as in Sections 3 and 4, but using Lemma 24 instead of Lemmas 6 and 10. ◮ Theorem 25. The complexity of Java's TimSort on inputs of size n with ρ runs is O(n + n log ρ). Another question is that of the stack size requirements of Java's TimSort, i.e. computing hmax. A first result is the following immediate corollary of Lemma 24. ◮ Corollary 26. On an input of size n, Java's TimSort will create a stack of runs of maximal size hmax 6 7 + logδ(n), where δ = (cid:0)5/(2 + √7)(cid:1)1/5 . Full proof in Sections A.1.2 and A.1.3. Proof. At any time during the main loop of Java's TimSort on an input of size n, if the stack is (R1, . . . , Rh) and h > 3, it follows from Lemma 24 that n > rh > δh−7r3 > δh−7. ◭ Unfortunately, for integers smaller than 231, Corollary 26 only proves that the stack size will never exceed 347. However, in the comments of Java's implementation of TimSort,5 there is a remark that keeping a short stack is of some importance, for practical reasons, and that the value chosen in Python -- 85 -- is "too expensive". Thus, in the following, we go to the extent of computing the optimal bound. It turns out that this bound cannot exceed 86 for such integers. This bound could possibly be refined slightly, but definitely not to the point of competing with the bound that would be obtained if the invariant of Equation (1) were correct. Once more, this suggests that implementing the new version of TimSort in Java would be a good idea, as the maximum stack height is smaller in this case. ◮ Theorem 27. hmax 6 3 + log∆(n), where ∆ = (1 + √7)1/5. Furthermore, if we replace ∆ by any real number ∆′ > ∆, On an input of size n, Java's TimSort will create a stack of runs of maximal size the inequality fails for all large enough n. Proof ideas. The first part of Theorem 27 is proved as follows. Ideally, we would like to show that ri+j > ∆jri for all i > 3 and some fixed integer j. However, these inequalities do not hold for all i. Yet, we prove that they hold if i + 2 and i + j + 2 are not obstruction indices, and i + j + 1 is an obstruction index, and it follows quickly that rh > ∆h−3. The optimality of ∆ is much more difficult to prove. It turns out that the constants 2+√7, (1+√7)1/5, and the expansion function referred to in the proof of Proposition 23 were constructed as least fixed points of non-decreasing operators, although this construction needed not be explicit for using these constants and function. Hence, we prove that ∆ is optimal by inductively constructing sequences of run sizes that show that lim sup{log(rh)/h} > ∆; much care is required for proving that our constructions are indeed feasible. ◭ 6 Conclusion At first, when we learned that Java's QuickSort had been replaced by a variant of MergeSort, we thought that this new algorithm -- TimSort -- should be really fast and efficient in practice, and that we should look into its average complexity to confirm this from a theoretical point of view. Then, we 5 Comment at line 168: http://igm.univ-mlv.fr/~pivoteau/Timsort/TimSort.java. N. Auger, V. Jugé, C. Nicaud, and C. Pivoteau 15 realized that its worst-case complexity had not been formally established yet and we first focused on giving a proof that it runs in O(n log n), which we wrote in a preprint [1]. In the present article, we simplify this preliminary work and provide a short, simple and self-contained proof of TimSort's complexity, which sheds some light on the behavior of the algorithm. Based on this description, we were also able to answer positively a natural question, which was left open so far: does TimSort runs in O(n + n log ρ), where ρ is the number of runs? We hope our theoretical work highlights that TimSort is actually a very good sorting algorithm. Even if all its fine-tuned heuristics are removed, the dynamics of its merges, induced by a small number of local rules, results in a very efficient global behavior, particularly well suited for almost sorted inputs. Besides, we want to stress the need for a thorough algorithm analysis, in order to prevent errors and misunderstandings. As obvious as it may sound, the three consecutive mistakes on the stack height in Java illustrate perfectly how the best ideas can be spoiled by the lack of a proper complexity analysis. Finally, following [4], we would like to emphasize that there seems to be no reason not to use the recent version of TimSort, which is efficient in practice, formally certified and whose optimal complexity is easy to understand. References 2 1 Nicolas Auger, Cyril Nicaud, and Carine Pivoteau. Merge strategies: From Merge Sort to TimSort. Research Report hal-01212839, hal, 2015. URL: https://hal-upec-upem.archives-ouvertes.fr/ hal-01212839. Jérémy Barbay and Gonzalo Navarro. On compressing permutations and adaptive sorting. Theor. Comput. Sci., 513:109 -- 123, 2013. URL: http://dx.doi.org/10.1016/j.tcs.2013.10.019, doi:10.1016/j.tcs.2013.10.019. Sam Buss and Alexander Knop. Strategies for stable merge sorting. Research Report abs/1801.04641, arXiv, 2018. URL: http://arxiv.org/abs/1801.04641. Stijn De Gouw, Jurriaan Rot, Frank S de Boer, Richard Bubel, and Reiner Hähnle. OpenJDK's Java.utils.Collection.sort() is broken: The good, the bad and the worst case. In International Conference on Computer Aided Verification, pages 273 -- 289. Springer, 2015. 4 3 5 Mordecai J Golin and Robert Sedgewick. Queue-mergesort. Information Processing Letters, 48(5):253 -- 259, 1993. 6 Donald E. Knuth. The Art of Computer Programming, Volume 3: (2nd Ed.) Sorting and Searching. Addison Wesley Longman Publish. Co., Redwood City, CA, USA, 1998. 7 Heikki Mannila. Measures of presortedness and optimal 8 1985. 34(4):318 -- 325, Computers, doi:10.1109/TC.1985.5009382. J. Ian Munro and Sebastian Wild. Nearly-optimal mergesorts: Fast, practical sorting methods that optimally adapt to existing runs. In Hannah Bast Yossi Azar and Grzegorz Herman, editors, 26th An- nual European Symposium on Algorithms (ESA 2018), Leibniz International Proceedings in Informatics (LIPIcs), pages 63:1 -- 63:15, 2018. URL: IEEE Trans. http://dx.doi.org/10.1109/TC.1985.5009382, sorting algorithms. 9 Tim Peters. Timsort description, accessed june 2015. http://svn.python.org/projects/python/ trunk/Objects/listsort.txt. 10 Tadao Takaoka. Partial solution and entropy. In Rastislav Královič and Damian Niwiński, editors, Mathematical Foundations of Computer Science 2009, pages 700 -- 711, Berlin, Heidelberg, 2009. Springer Berlin Heidelberg. 16 On the Worst-Case Complexity of TimSort A Appendix A.1 Proofs We provide below complete proofs of the results mentioned in Section 5. In what follows, we will often refer to so-called stable stacks: we say that a stack S = (R1, . . . , Rh) is stable if r1 + r2 < r3 and r1 < r2, i.e. if the next operation that will be performed by TimSort is a push operation (Case #1). A.1.1 Proving Proposition 23 Aiming to prove Proposition 23, and keeping in mind that studying stable stacks may be easier than studying all stacks, a first step is to introduce the following quantities. ◮ Definition 28. Let n be a positive integer. We denote by αn (resp., βn), the smallest real number m such that, in every stack (resp., stable stack) S = (R1, . . . , Rh) obtained during an execution of TimSort, and for every integer i ∈ {1, . . . , h} such that ri = n, we have r2 + . . . + ri−1 6 m × ri; if no such real number exists, we simply set αn = +∞ (resp., βn = +∞). By construction, αn > βn for all n > 1. The following lemma proves that αn 6 βn. ◮ Lemma 29. At any time during the main loop of TimSort, if the stack is (R1, . . . , Rh), then we have (a) ri < ri+1 for all i ∈ {3, 4, . . . , h − 1} and (b) r2 + . . . + ri−1 6 βnri for all n > 1 and i 6 h such that ri = n. Proof. Assume that (a) and (b) do not always hold, and consider the first moment where some of them do not hold. When the main loop starts, both (a) and (b) are true. Hence, from a stack S = (R1, . . . , Rh), on which (a) and (b) hold, we carried either a push step (Case #1) or a merging step (Cases #2 to #4), thereby obtaining the new stack S = (R1, . . . , Rh). We consider separately these two cases: After a push step, we have h = h + 1 , r1 + r2 < r3 (otherwise, we would have performed a merging step instead of a push step) and ri = ri−1 for all i > 2. It follows that r3 = r2 < r1 + r2 < r3 = r4, and that ri = ri−1 < ri = ri+1 for all i > 4. This proves that S satisfies (a). In addition, the value of r1 has no impact on whether S satisfies (b). Hence, we may assume without loss of generality that r1 < min{r2, r3 − r2} (up to doubling the size of every run ever pushed onto the stack so far and setting r1 = 1), thereby making S stable. This proves that S satisfies (b). After a merging step, we have h = h − 1, r2 6 r2 + r3 and ri = ri+1 for all i > 3. Hence, ri = ri+1 < ri+2 = ri+1 for all i > 3, and S satisfies (a). Furthermore, we have 0 6 βr2r2, and r2 + r3 + . . . + ri 6 r2 + r3 + . . . + ri+1 6 βnri+2 = βnri+1 whenever i > 1 and ri+1 = ri+2 = n. This proves that S also satisfies (b). Hence, in both cases, (a) and (b) also hold in S, which contradicts our assumption and completes the ◭ proof. ◮ Corollary 30. For all integers n > 1, we have αn = βn. It remains to prove that αn 6 α∞ for all n > 1, where α∞ = 2 + √7. This is the object of the next results. What makes Java's TimSort much harder to study than Python's TimSort is the fact that, during the execution of Java's TimSort algorithm, we may have stacks S = (R1, . . . , Rh) on which the invari- ant (1) : ri > ri−1 + ri−2 fails for many integers i > 3, possibly consecutive. In Section 5, such integers were called obstruction indices of the stack S. Hence, we focus on sequences of consecutive obstruction indices. ◮ Lemma 31. Let S = (R1, . . . , Rh) be a stable stack obtained during the main loop of Java's TimSort. Assume that i − k, i + 1 − k, . . . , i are consecutive obstruction indices of S, and that αn 6 α∞ for all n 6 ri − 1. Then, ri−k−2 6 α∞ + 1 − k α∞ + 2 ri−1. N. Auger, V. Jugé, C. Nicaud, and C. Pivoteau 17 Proof. Let T be the number of merge or push operations performed between the start of the main loop and the creation of the stack S. For all k ∈ {0, . . . , T} and all j > 1, we denote by Sk the stack after k operations have been performed. We also denote by Pj,k the jth bottom-most run of the stack Sk, and by pj,k the size of Pj,k; we set Pj,k = ∅ and pj,k = 0 if Sk has fewer than j runs. Finally, for all j 6 h, we set tj = min{k > 0 ∀ℓ ∈ {k, . . . , T}, pj,ℓ = pj,T}. First, observe that tj < tj+2 for all j 6 h − 2, because a run can be pushed or merged only in top or 2nd-to-top position. Second, if tj > tj+1 for some j 6 h − 1, then the runs Pj,tj , Pj+1,tj are the two top runs of Stj . Since none of the runs P1, . . . , Pj+1 is modified afterwards, it follows, if j > 2, that pj+1 + pj = pj+1,tj + pj,tj < pj−1,tj = pj−1, and therefore that h + 2 − j is not an obstruction index. Conversely, let m0 = h + 3 − i. We just proved that tm0−2 < tm0 and also that tm0−1 < tm0 < . . . < th operation was a merge operation tm0+k. Besides, for all m ∈ {m0, . . . , m0 + k}, we prove that the tm of type #2. Indeed, if not, then the run Pm,tm would be the topmost run of Stm ; since the runs Pm−1 and Pm−2 were not modified after that, we would have pm + pm−1 < pm−2, contradicting the fact that h + 3− m is an obstruction index. In particular, it follows that pm+1,tm = pm+2,tm−1 > pm,tm−1 and that pm = pm,tm 6 pm−1,tm − pm+1,tm = pm−1 − pm+1,tm. Moreover, for m = m0, observe that pm = pm,tm = pm,tm−1 + pm+1,tm−1. Applying Lemma 29 on the stacks ST and Stm−1, we know that pm,tm−1 6 pm 6 pm−2 − 1 = ri − 1 and that pp+1,tm−1 6 apm,tm−1 pm,tm−1 6 α∞pm,tm−1, which proves that pm 6 (α∞ + 1)pm,tm−1 6 (α∞ + 1)pm+1,tm, i.e., pm0 6 (α∞ + 1)pm0+1,tm0 . Henceforth, we set κ = pm0+1,tm0 . In addition, for all m ∈ {m0 + 1, . . . , m0 + k}, observe that the sequence (pm+1,k)tm6k6T is non- decreasing. Indeed, when tm 6 k, and therefore ti 6 k for all i 6 m, the run pm+1,k can only be modified by being merged with another run, thereby increasing in size. This proves that pm+2,tm+1 > = κ for all pm+1,tm+1−1 > pm+1,tm. Hence, an immediate induction shows that pm+1,tm > pm0+1,tm0 m ∈ {m0, . . . , m0 + k}, and it follows that pm 6 pm−1 − κ. pm0+1,tm0} = min{(α∞ + 1)κ, pm0−1 − κ}. It follows that Overall, this implies that ri−k−2 = pm0+k 6 pm0 − kκ. Note that pm0 6 min{(α∞ + 1)κ, pm0−1 − ri−k−2 6 min{(α∞ + 1)κ, pm0−1 − κ} − kκ 6 min{(α∞ + 1 − k)κ, ri−1 − (k + 1)κ}, whence (α∞ + 2)ri−k−2 6 (k + 1)(α∞ + 1 − k)κ + (α∞ + 1 − k)(ri−1 − (k + 1)κ) = (α∞ + 1 − k)ri−1. ◭ Lemma 31 paves the way towards a proof by induction that αn 6 α∞. Indeed, a first, immediate consequence of Lemma 31, is that, provided that αn 6 α∞ for all n 6 ri − 1, then the top-most part (R1, . . . , Ri) may not contain more than α∞ + 2 (and therefore no more than 6) consecutive obstruction indices. This suggests that the sequence r1, . . . , ri should grow "fast enough", which might then be used to prove that αri 6 α∞. We present below this inductive proof, which relies on the following objects. ◮ Definition 32. We call expansion function the function f : [0, 1] → R>0 defined by f : x →  (1 + α∞)x x + α∞(1 − x)  α∞x if 0 6 x 6 1/2 if 1/2 6 x 6 α∞/(2α∞ − 1) if α∞/(2α∞ − 1) 6 x 6 1. In the following, we denote by θ the real number α∞/(2α∞ − 1). Let us first prove two technical results about the expansion function. ◮ Lemma 33. We have α∞x 6 f (x) for all x ∈ [0, 1], f (x) 6 f (1/2) for all x ∈ [0, θ], f (x) 6 f (1) for all x ∈ [0, 1], x + α∞(1 − x) 6 f (x) for all x ∈ [1/2, 1] and x + α∞(1 − x) 6 f (1/2) for all x ∈ [1/2, 1]. Proof. Since f is piecewise linear, it is enough to check the above inequalities when x is equal to 0, 1/2, θ or 1, which is immediate. ◭ ◮ Lemma 34. For all real numbers x, y ∈ [0, 1] such that x(y + 1) 6 1, we have x(1 + f (y)) 6 min{f (1/2), f (x)}. 18 On the Worst-Case Complexity of TimSort Proof. We treat three cases separately, relying in each case on Lemma 33: if 0 6 x 6 1/2, then x(1 + f (y)) 6 x(1 + f (1)) = (1 + α∞)x = f (x) 6 f (1/2); if 1/2 < x 6 1 and f (1/2) < f (y), then θ 6 y 6 1, hence x(1 + f (y)) = x + α∞xy 6 x + α∞(1 − x) 6 min{f (x), f (1/2)}; if 0 6 f (y) 6 f (1/2), and since α∞ > 1, we have x(1 + f (y)) 6 x(1 + f (1/2)) = x(3 + α∞)/2 6 x(1 + α∞) 6 f (x); if, furthermore, y 6 1/2, then x(1 + f (y)) 6 (1 + (1 + α∞)y)/(1 + y) = (1 + α∞) − α∞/(1 + y) 6 (1 + α∞) − 2α∞/3 = (3 + α∞)/3, and if 1/2 6 y, then x(1 + f (y)) 6 (1 + f (1/2))/(1 + y) 6 2(1 + f (1/2))/3 = (3 + α∞)/3; since α∞ > 3, it follows that x(1 + f (y)) 6 (3 + α∞)/3 6 (1 + α∞)/2 = f (1/2) in both cases. ◭ Using Lemma 31 and the above results about the expansion function, we finally get the following result, of which Proposition 23 is an immediate consequence. ◮ Lemma 35. Let S = (R1, . . . , Rh) be a stable stack obtained during the main loop of Java's TimSort. For all integers i > 2, we have r1 + r2 + . . . + ri−1 6 rif (ri−1/ri), where f is the expansion function. In particular, we have αn = βn 6 α∞ for all integers n > 1. Proof. Lemma 33 proves that 2x 6 α∞x 6 yf (x/y) whenever 0 < x 6 y, and therefore the statement of Lemma 35 is immediate when i 6 3. Hence, we prove Lemma 35 for i > 4, and proceed by induction on ri = n, thereby assuming that αn−1 exists. Let x = ri−1/ri and y = ri−2/ri−1. By Lemma 29, and since the stack S is stable, we know that ri−2 < ri−1 < ri, and therefore that x < 1 and y < 1. If i is not an obstruction index, then we have ri−2 + ri−1 6 ri, i.e., x(1 + y) 6 1 and, using Lemma 34, it follows that r1 + . . . + ri−1 = (r1 + . . . + ri−2) + ri−1 6 f (y)ri−1 + ri−1 = x(1 + f (y))ri 6 f (x)ri. On the contrary, if i is an obstruction index, let k be the smallest positive integer such that i − k is not an obstruction index. Since the stack S is stable, we have r1 + r2 < r3, which means that 3 is not an obstruction index, and therefore i − k > 3. Let u = ri−k−1/ri−k and v = ri−k−2/ri−k−1. By construction, we have ri−k−2 + ri−k−1 6 ri−k, i.e., u(1 + v) 6 1. Using Lemma 31, and since ri−k−1 < ri and αri−1 6 f (1) = α∞ by induction hypothesis, we have r1 + . . . + ri−1 = (r1 + . . . + ri−k−2) + ri−k−1 + . . . + ri−1 6 ri−k−1f (v) + ri−k−1 + . . . + ri−1 6 ri−ku(1 + f (v)) + ri−k + . . . + ri−1 6 ri−kf (1/2) + ri−k + . . . + ri−1 1 α∞ + 2 k  (α∞ + 3 − k)f (1/2) + (α∞ + 3 − j) X ∞ + (4 + k)α∞ − k2 + 4k + 3(cid:1) ri−1. j=1  ri−1 1 2(α∞ + 2) (cid:0)α2 6 6 The function g : t → α2 ∞ + (4 + t)α∞ − t2 + 4t + 3 takes its maximal value, on the real line, at t = (α∞ + 4)/2 ∈ (4, 5). Consequently, for all integers k, and since α∞ 6 5, we have g(k) 6 max{g(4), g(5)} = α2 ∞ + max{8α∞ + 3, 9α∞ − 2} = α2 ∞ + 8α∞ + 3. Then, observe that 2(α∞ + 2)α∞ = 30 + 12√7 = α2 ∞ + 8α∞ + 3. It follows that r1 + . . . + ri−1 6 α2 ∞ + 8α∞ + 3 2(α∞ + 2) ri−1 = α∞xri 6 f (x)ri. Hence, regardless of whether i is an obstruction index or not, we have r1 + . . . + ri−1 6 f (x)ri 6 ◭ f (1)ri = α∞ri, which completes the proof. N. Auger, V. Jugé, C. Nicaud, and C. Pivoteau 19 A.1.2 Proving the first part of Theorem 27 We prove below the inequality of Theorem 27; proving that that the constant ∆ used in Theorem 27 is optimal will be the done in the next section. In order to carry out this proof, we need to consider some integers of considerable interest. Let S = (R1, . . . , Rh) be a stable stack of runs. We say that an integer i > 1 is a growth index if i + 2 is not an obstruction index, and that i is a strong growth index if i is a growth index and if, in addition, i + 1 is an obstruction index. Note that h an h − 1 are necessarily growth indices, since h + 1 and h + 2 are too large to be obstruction indices. Our aim is now to prove inequalities of the form ri+j > ∆jri, where 3 6 i 6 i + j 6 h. However, such inequalities do not hold in general, hence we restrict the scope of the integers i and i + j, which is the subject of the two following results. ◮ Lemma 36. Let i and j be positive integers such that i + 2 6 j 6 h. If no obstruction index k exists such that i + 2 6 k 6 j, then 2∆j−i−2ri 6 rj . Proof. For all n > 0, let Fn denote the nth Fibonacci number, defined by F0 = 0, F1 = 1 and Fn+2 = Fn + Fn+1 or, alternatively, by Fn = (φn − (−φ)−n)/√5, where φ = (1 + √5)/2 is the Golden ratio. Observe now that Fj−i+1ri 6 Fj−i−1ri + Fj−iri+1 6 Fj−i−2ri+1 + Fj−i−1ri+2 6 . . . 6 F0rj−1 + F1rj = rj . Moreover, for all n > 3, we have Fn = 2Fn/F3 = 2φn−3(1 − (−1)nφ−2n)/(1 − φ−6) > 2φn−3. Since ∆ < φ, it follows that 2∆j−i−2ri 6 Fj−i+1ri 6 rj. ◭ ◮ Lemma 37. Let i and j be positive integers such that 1 6 i 6 j 6 h. If i is a growth index and j is a strong growth index, then ∆j−iri 6 rj . Proof. Without loss of generality, let us assume that i < j and that there is no strong growth index k such that i < k < j. Indeed, if such an index k exists, then a simple induction completes the proof of Lemma 37. Let ℓ be the largest integer such that ℓ 6 j and ℓ is not an obstruction index. Lemmas 31 and 35 prove that (α∞ + 2)rℓ 6 (α∞ + 2 + ℓ − j)rj and that (α∞ + 2)rℓ−1 6 (α∞ + 1 + ℓ − j)rj . The latter inequality proves that j − ℓ 6 ⌊α∞ + 1⌋ = 5. By construction, we have i + 2 6 ℓ, and no integer k such that i + 2 6 k 6 ℓ is an obstruction index. Hence, Lemma 36 proves that 2(α∞ + 2)∆ℓ−i−2ri 6 (α∞ + 2)rℓ 6 (α∞ + 2 + ℓ − j)rj . Moreover, simple numerical computations, for j − ℓ ∈ {0, . . . , 5}, prove that ∆j−ℓ+2 6 2(α∞ + 2)/(α∞ + 2 + ℓ − j), with equality when j − ℓ = 3. It follows that ∆j−iri = ∆j−ℓ+2∆ℓ−i−2ri 6 rj. ◭ Finally, the inequality of Theorem 27 is an immediate consequence of the following result. ◮ Lemma 38. Let S = (R1, . . . , Rh) be a stack obtained during the main loop of Java's TimSort. We have rh > ∆h−3. Proof. Let us first assume that S is stable. Then, r1 > 1, and 1 is a growth index. obstruction index, then Lemma 36 proves that rh > 2∆h−3r1 > ∆h−2. If there is no Otherwise, let ℓ be the largest obstruction index. Then, ℓ− 1 is a strong growth index, and Lemma 37 proves that rℓ−1 > ∆ℓ−2r1 > ∆ℓ−2. If ℓ = h, then rh > rℓ−1 > ∆h−2, and if ℓ 6 h − 1, then Lemma 36 also proves that rh > 2∆h−ℓ−1rℓ−1 > ∆h−ℓ∆ℓ−2 = ∆h−2. Finally, if S is not stable, the result is immediate for h 6 3, hence we assume that h > 4. The stack S was obtained by pushing a run onto a stable stack S ′ of size at least h − 1, then merging runs from S ′ into the runs R1 and R2. It follows that Rh was already the largest run of S ′, and therefore that Rh > ∆h−3. ◭ 20 On the Worst-Case Complexity of TimSort A.1.3 Proving the second part of Theorem 27 We finally focus on proving that the constant ∆ of Theorem 27 is optimal. The most important step towards this result consists in proving that α∞ = limn→∞ αn, with the real numbers αn introduced in Definition 28 and α∞ = 2 + √7. Since it is already proved, in Lemma 35, that αn 6 α∞ for all n > 1, it remains to prove that α∞ 6 lim inf n→∞ αn. We obtain this inequality by constructing explicitly, for k large enough, a stable sequence of runs (R1, . . . , Rh) such that rh = k and r2 + . . . + rh−1 ≈ α∞k. Hence, we focus on constructing sequences of runs. In addition, let us consider the stacks of runs created by the main loop of Java's TimSort on a sequence of runs P1, . . . , Pn. We say below that the sequence P1, . . . , Pk produces a stack of runs S = (R1, . . . , Rh) if the stack S is obtained after each of the runs P1, . . . , Pn has been pushed; observe that the sequence P1, . . . , Pn produces exactly one stable stack. We also say that a stack of runs is producible if it is produced by some sequence of runs. Finally, in what follows, we are only concerned with run sizes. Hence, we abusively identify runs with their sizes. For instance, in Figure 6, the sequence (109, 83, 25, 16, 8, 7, 26, 2, 27) produces the stacks (27, 2, 26, 56, 83, 109) and (27, 28, 56, 83, 109); only the latter stack is stable. We review now several results that will provide us with convenient and powerful ways of constructing producible stacks. ◮ Lemma 39. Let S = (r1, . . . , rh) be a stable stack produced by a sequence of runs p1, . . . , pn. Assume that n is minimal among all sequences that produce S. Then, when producing S, no merging step #3 or #4 was performed. Moreover, for all k 6 n − 1, after the run pk+1 has been pushed onto the stack, the elements coming from pk will never belong to the topmost run of the stack. Proof. We begin by proving the first statement of Lemma 39 by induction on n, which is immediate for n = 1. Hence, we assume that n > 2, and we further assume, for the sake of contradiction, that some merging step #3 or #4 took place. Let S ′ = (r′ ℓ) be the stable stack produced by the sequence p1, . . . , pn−1. By construction, this sequence is as short as possible, and therefore no merging step #3 or #4 was used so far. Hence, consider the last merging step #3 or #4, which necessarily appears after pn was pushed onto the stack. Just after this step has occurred, we have a stack S ′′ = (r′′ m), with r′ 1 was obtained by merging the runs pn, r′ i = r′′ 1, . . . , r′ Let p1, . . . , pk be the runs that had been pushed onto the stack when the run r′′ j whenever j > 2 and i + m = j + ℓ, and the run r′′ ℓ+1−m. 1 , . . . , r′′ 1, . . . , r′ 2 = r′ 2 , and therefore the sequence P#1 = (p1, . . . , pk, r′′ m+2−ℓ was created. This creation was the result of either a push step or a merging step #2. In both cases, and until S ′ is created, no merging step #3 or #4 ever involves any element placed within or below r′′ 2 . Then, in the case of a push step, we have pk = r′′ 1 ) also produces the stack S ′. In the case of a merging step #2, it is the sequence P#2 = (p1, . . . , pk−1, r′′′) that also produces the stack S ′′, where r′′′ is obtained by merging the runs pk, . . . , pn. In both cases, since the sequences P#1 and P#2 produce S ′′, they also produce S. It follows that k + 1 > n (in the first case) or k > n (in the second case). Moreover, the run r′′ 2 was not modified between pushing the run pn and before obtaining the stack S ′′, hence k 6 n − 1. This proves that k = n − 1 and that the run r′′ 1 may contain elements of pn only, hence is not the result of a merging step #3 or #4: this disproves our assumption and proves the first statement of Lemma 39. 2 was obtained through a push step, i.e. pn−1 = r′′ 2 . But then, the run r′′ Finally, observe that push steps and merging steps #2 never allow a run in 2nd-to-top position or ◭ below to go to the top position. This completes the proof of Lemma 39. ◮ Lemma 40. Let S = (r1, . . . , rh) be a stable stack produced by a sequence of runs p1, . . . , pn. Assume that n is minimal among all sequences that produce S. There exist integers i0, . . . , ih such that 0 = ih < ih−1 < . . . < i0 = n and such that, for every integer k 6 h, (a) the runs pik+1, . . . , pik−1 were merged into the run rk, and (b) ik−1 = ik + 1 if and only if k + 2 is not an obstruction index. N. Auger, V. Jugé, C. Nicaud, and C. Pivoteau 21 Proof. The existence (and uniqueness) of integers i0, . . . , ih satisfying (a) is straightforward, hence we focus on proving (b). That property is immediate if h = 1, hence we assume that 2 6 h 6 n. Checking that the sequence rh, rh−1, pih−2+1, pih−2+2, . . . , pn produces the stack S is immediate, and therefore ih−1 = 1 and ih−2 = 2, i.e., rh = p1 and rh−1 = p2. Consider now some integer k 6 h − 2, and let S ′ be the stable stack produced by p1, . . . , pik+1. From that point on, the run pik−1+1 will never be the topmost run, and the runs pj with j 6 ik−1, which can never be merged together with the run pik−1+1, will never be modified again. This proves that S ′ = (pik−1+1, rk+1, . . . , rh). Then, assume that ik−1 = ik + 1, and therefore that pik−1+1 = rk. Since S ′ is stable, we know that rk + rk+1 < rk+2, which means that k + 2 is not an obstruction index. Conversely, if k + 2 is not an obstruction index, both sequences p1, . . . , pik+1+1 and p1, . . . , pik−1, rk, pik+1+1 produce the stack (pik+1+1, rk, . . . , rh) and, since n is minimal, ik−1 = ik + 1. ◭ ◮ Lemma 41. Let S = (r1, . . . , rh) be a producible stable stack of height h > 3. There exists an integer κ ∈ {1, 4} and a producible stable stack S ′ = (r′ ℓ−1 and r1 + . . . + rh−2 = r′ ℓ) such that ℓ > 2, rh = r′ ℓ, rh−1 = r′ 1, . . . , r′ 1 + . . . + r′ ℓ−2 + κ. Proof. First, Lemma 41 is immediate if h = 3, since the sequence of runs (r3, r2, r1 − 1) produces the stack (r1 − 1, r2, r3). Hence, we assume that h > 4. Let p1, . . . , pn be a sequence of runs, with n minimal, that produces S. We prove Lemma 41 by induction on n. If the last step carried when producing S was pushing the run Pn onto the stack, then the sequence p1, . . . , pn−1, pn − 1 produces the stack r1 − 1, r2, . . . , rh, and we are done in this case. Hence, assume that the last step carried was a merging step #2. Let S ′ = (q1, . . . , qm) be the stable stack produced by the sequence p1, . . . , pn−1, and let i be the largest integer such that qi < pn. After pushing pn, the runs q1, . . . , qi are merged into one single run r2, and we also have pn = r1 and qi+j = r2+j for all j > 1. Incidentally, this proves that m = h + i − 2 and, since h > 4, that i 6 m − 2. We also have i > 2, otherwise, if i = 1, we would have had a merging step #3 instead. If r1 = pn > qi+2, then the sequence p1, . . . , pn−1, pn−1 also produces the stack (r1−1, r2, . . . , rh), and we are done in this case. Hence, we further assume that r1 = pn = qi +1. Since qi−1 +qi 6 r2 < r3 = qi+1, we know that i + 1 is not an obstruction index of S. Let a 6 n − 1 be a positive integer such that p1 + . . . + pa = qi + qi+1 + . . . + qm. Lemma 40 states that pa+1 = qi−1, and therefore that the sequence of runs p1, . . . , pa+1 produces the stack (qi−1, . . . , qm). If i = 2 and if q1 > 3, then (q1 − 1) + q2 > q2 + 2 > r1, and therefore the sequence of runs p1, . . . , pa, q1 − 1, r1 produces the stable stack (r1, r2 − 1, r3, . . . , rh). However, if i = 2 and q1 6 2, then the sequence of runs p1, . . . , pa, r1 − 2 produces the stable stack (r1 − 2, r2 − 2, . . . , rh). Hence, in both cases, we are done, by choosing respectively κ = 1 and κ = 4. Les us now assume that i > 3. Observe that n > a + i > 3 since, after the stack (qi−1, . . . , qm) has been created, it remains to create runs q1, . . . , qi−2 and finally, r1, which requires pushing at least i − 1 runs in addition to the a + 1 runs already pushed. Therefore, we must have q1 + . . . + qi−1 > qi, unless what the sequence p1, . . . , pa, q1 + . . . + qi−1, pn would have produced the stack S, despite being of length a + 2 < n. In particular, since q1 + q2 < q3, it follows that i > 4. Consequently, we have q1 > 1, q2 > 2, q3 > 4, and therefore q1 + . . . + qi−1 > 7, i.e. r2 > q2 + 7 = r1 + 6. 1, . . . , q′ 3, . . . , p′ 1, . . . , q′ v) such that q′ Finally, by induction hypothesis, there exists a sequence p′ u, with u minimal, that produced the stack (q′ v = qi, q′ v−2 + κ for some κ ∈ {1, 4}. Lemma 40 also states that p′ 2 = qi−1. It is then easy to check that the sequence of runs p1, . . . , pb+1, p′ v−2, qi−1, qi, . . . , qm). Since j < qi−1 < qi < r1 < r3 = qi+1 for all j 6 v − 2, pushing the run pn = r1 onto that stack and q′ letting merging steps #2 occur then gives the stack (r1, r2 − κ, r3, . . . , rh), which completes the proof since r1 6 r2 − 6 < r2 − κ. v−1 = qi−1 and q1 + . . . + qi−2 = q′ 1 = qi and that p′ u produces the stable stack (q′ 1 + . . . + q′ 1, . . . , p′ ◭ In what follows, we will only consider stacks that are producible and stable. Hence, from this point on, we omit mentioning that they systematically must be producible and stable, and we will say that "the stack S exists" in order to say that "the stack S is producible and stable". 22 On the Worst-Case Complexity of TimSort ◮ Lemma 42. Let S = (r1, . . . , rh) and S ′ = (r′ a stack (r1, . . . , ri), and (b) if rh−1 = r′ 1, . . . , r′ ℓ) be two stacks. Then (a) for all i 6 h, there exists 1 and rh = r′ 2, then there exists a stack (r1, . . . , rh, r′ 3, . . . , r′ ℓ). 1, . . . , p′ n be two sequences that respectively produce S and S ′. Let us Proof. Let p1, . . . , pm and p′ further assume that m is minimal. First, consider some integer i 6 h, and let a be the integer such that p1 + . . . + pa = ri+1 + . . . + rh. It comes at once that the sequence pa+1, . . . , pm produces the stack 2 and that p2 = rh−1 = r′ (r1, . . . , ri). Second, since m is minimal, Lemma 40 proves that p1 = rh = r′ 1 and, once again, the sequence p′ ℓ), which is also stable. ◭ n, p3, . . . , p3 produces the stack (r1, . . . , rh, r′ 1, . . . , p′ 3, . . . , r′ ◮ Lemma 43. For all positive integers k and ℓ such that k 6 ℓαℓ, there exists a stack (r1, . . . , rh) such that rh = ℓ, k − 3 6 r1 + . . . + rh−1 6 k, and r1 + . . . + rh−1 = k if k = ℓαℓ. Proof. First, if ℓ = 1, then αℓ = 0, and therefore Lemma 43 is vacuously true. Hence, we assume that ℓ > 2. Let Ω be the set of integers k for which some sequence of runs p1, . . . , pm produces a stack S = (r1, . . . , rh) such that r1 +. . .+rh−1 = k and rh = ℓ. First, if k 6 ℓ−1, the sequence ℓ, k produces the stack (ℓ, k), thereby proving that {1, 2, . . . , ℓ − 1} ∈ Ω. Second, it follows from Lemma 42 that ℓαℓ ∈ Ω. Finally, consider some integer k ∈ Ω such that k > ℓ, and let p1, . . . , pm be a sequence of runs that produces a stack (r1, . . . , rh) such that r1 + . . . + rh−1 = k and rh = ℓ. Since k > ℓ = rh > rh−1, we know that h > 3. Hence, due to Lemma 41, either k − 1 or k − 4 (or both) belongs to Ω. This completes the proof of Lemma 43. ◭ ◮ Lemma 44. For all positive integers k and ℓ such that k 6 ℓ, we have αℓ > (1−k/ℓ)αk and αℓ > kαk/ℓ. Proof. Let n = ⌊ℓ/k⌋. Using Lemma 43, there exists a sequence of runs p1, . . . , pm that produces a stack (r1, . . . , rh) such that rh = k and r1 + . . . + rh−1 = kαk. By choosing m minimal, Lemma 40 further proves that p1 = rh = k. Consequently, the sequence of runs np1, . . . , npm−1, ℓ produces the stack (nr1, . . . , nrh−1, ℓ), and therefore we have ℓαℓ > n(r1 + . . . + rh−1) = nkαk > max{1, ℓ/k − 1}kαk = ℓ max{k/ℓ, 1 − k/ℓ}αk. ◭ A first intermediate step towards proving that limn→∞ αn = α∞ is the following result, which is a consequence of the above Lemmas. ◮ Proposition 45. Let α = sup{αn n ∈ N∗}. We have 1 + α∞/2 < α 6 α∞, and αn → α when n → +∞. Proof. Let α = sup{αn n ∈ N∗}. Lemma 35 proves that α 6 α∞. Then, let ε be a positive real number, and let k be a positive integer such that αk > α − ε. Lemma 44 proves that lim inf αn > αk > α− ε, and therefore lim inf αn > α. This proves that αn → α when n → +∞. Finally, it is tedious yet easy to verify that the sequence 360, 356, 3, 2, 4, 6, 10, 2, 1, 22, 4, 2, 1, 5, 1, 8, 4, 2, 1, 73, 4, 2, 5, 7, 2, 16, 3, 2, 4, 6, 21, 4, 2, 22, 4, 2, 1, 5, 8, 3, 2, 79, 3, 2, 4, 6, 2, 10, 6, 3, 2, 33, 4, 2, 5, 7, 1, 13, 4, 2, 1, 5, 1, 80, 4, 2, 5, 7, 1, 95, 3, 2, 4, 6, 10, 20, 4, 2, 5, 7, 3, 2, 26, 6, 3, 1, 31, 3, 2, 4, 6, 2, 1, 12, 4, 2, 5 produces the stack (5, 6, 12, 18, 31, 36, 68, 95, 99, 195, 276, 356, 360). Moreover, since (20√7)2 = 2800 < 2809 = 532, it follows that 80 + 20√7 < 133, i.e., that 1 + α∞/2 = 2 +√7/2 < 133/40. This proves that α > α360 > 5 + 6 + 12 + 18 + 31 + 36 + 68 + 95 + 99 + 195 + 276 + 356 360 = 133 40 > 1 + α∞/2. ◭ ◮ Lemma 46. There exists a positive integer N such that, for all integers n > N and k = ⌊(n−6)/(α+2)⌋, the stack (k + 1, k+, αk, n − 4, n) exists. Proof. Proposition 45 proves that there exists a positive real number ν > 1 + α∞/2 and a positive integer L > 256 such that αℓ > ν for all ℓ > L. Then, we set N = ⌈(α + 2)L⌉ + 6. Consider now some integer n > N , and let k = ⌊(n − 6)/(α + 2)⌋. By construction, we have k > L, and therefore αk > ν. N. Auger, V. Jugé, C. Nicaud, and C. Pivoteau 23 Let p1, . . . , pm be a sequence of runs that produces a stack (r1, . . . , rh) such that rh = k and r1 + . . . + rh−1 = kαk. Lemma 35 proves that αk 6 f (rh−1/k), where f is the expansion function of Definition 32. Since αk > ν > 1 + α∞/2 = f (1/2), it follows that k > rh−1 > θk. Assuming that m is minimal, Lemma 40 proves that p1 = rh = k and that p2 = rh−1. Now, let k′ = ⌊k/2⌋ + 1, and let ℓ be the largest integer such that 2ℓ+4 6 k′. Since k > L > 256, we know that k′ > 128, and therefore that ℓ > 3. Observe also that, since θ = α∞/(2α∞ − 1) > 11/20 and k′ > 20, we have rm−1 > θk > ⌊k/2⌋+ k/20 > k′. We build a stack of runs p2, k, n− 4, n by distinguishing several cases, according to the value of k′/2ℓ. If 16 × 2ℓ 6 k′ 6 24 × 2ℓ + 1, let x be the smallest integer such that x > 2 and k′ < 2(9 × 2ℓ + x + 1). Since k′ 6 24 × 2ℓ + 1, we know that x 6 3 × 2ℓ, and that x = 2 if k 6 18 × 2ℓ + 1. Therefore, the sequence of runs (n, n − 4, 3, 2, 4, 6, 10, 3 × 8, 3 × 16, . . . , 3 × 2ℓ, 3 × 2ℓ + x) produces the stack (3×2ℓ +x, 3×2ℓ+1 +1, n−4, n). Moreover, observe that (3×2ℓ+1 +1)+(9×2ℓ +x+1) = 15×2ℓ+4 < k′ if 16 × 2ℓ 6 k′ 6 18 × 2ℓ + 1, and that (3 × 2ℓ+1 + 1) + (9 × 2ℓ + x + 1) 6 18 × 2ℓ + 1 < k′ if 18 × 2ℓ + 2 6 k′. Since, in both cases, we also have k′ < 2(9 × 2ℓ + x + 1), it follows that 3 × 2ℓ+1 + 1 < k′ − (9 × 2ℓ + x + 1) < 9 × 2ℓ + x + 1. Consequently, pushing an additional run of size k′ − (9 × 2ℓ + x + 1) produces the stack k′ − (9 × 2ℓ + x + 1), 9 × 2ℓ + x + 1, n − 4, n. Finally, the inequalities 2k′ > k, k − k′ > k/2 − 1 > k′ − 2 > 18 × 2ℓ and x 6 3 × 2ℓ prove that 9 × 2ℓ + x + 1 6 12 × 2ℓ + 1 < 16 × 2ℓ − 2 6 k − k′ < k′. Recalling that k > p2 > k′, it follows that pushing additional runs of sizes k − k′ and p2 produces the stack (p2, k, n − 4, n). If 24 × 2ℓ + 2 6 k′ < 32 × 2ℓ, let x be the smallest integer such that x > 2 and k′ < 2(12 × 2ℓ + x + 1). Since k′ < 32 × 2ℓ, we know that x + 1 6 2ℓ+2. Therefore, the sequence of runs n, n − 4, 3, 2, 4, 8, 16, 32, . . . , 2ℓ+2, 2ℓ+2 + x produces the stack (2ℓ+2 + x, 2ℓ+3 + 1, n − 4, n). Moreover, the inequalities (2ℓ+3 + 1) + (3 × 2ℓ+2 + x + 1) 6 6 × 2ℓ+2 + 1 < k′ < 2(3 × 2ℓ+2 + x + 1) prove that 2ℓ+3 + 1 < k′ − (3 × 2ℓ+2 + x + 1) < 3 × 2ℓ+2 + x + 1. Consequently, pushing an additional run of size k′−(3×2ℓ+2+x+1) produces the stack (k′−(3×2ℓ+2+ x + 1), 3× 2ℓ+2 + x + 1, n− 4, n). Finally, the inequalities 2k′ > k, k − k′ > k/2− 1 > k′ − 2 > 6× 2ℓ+2 and x + 1 6 2ℓ+2 prove that 3 × 2ℓ+2 + x + 1 6 4 × 2ℓ+2 < 6 × 2ℓ+2 6 k − k′ < k′. Recalling once again that k > p2 > k′, it follows that pushing additional runs of sizes k − k′ and p2 produces the stack (p2, k, n − 4, n) in this case too. Finally, after having obtained the stack (p2, k, n−4, n), let us add the sequence of runs p3, . . . , pm, k+1. Since k(1 + αk) + (k + 1) 6 k(α + 2) + 1 6 n − 6 + 1 < n − 4, adding these runs produces the stack (k + 1, k + kαk, n − 4, n), which completes the proof. ◮ Lemma 47. For all integers n > N and k = ⌊(n − 6)/(α + 2)⌋ there exists a stack (k + 3, k(αk − 1) − 7 − x − y, kαk − 3 − x, k(1 + αk), n − 4, n) for some integers x, y ∈ {0, 1, 2, 3}. Proof. Consider some integer n > N , and let k = ⌊(n− 6)/(α∞ + 2)⌋. By Lemma 46, there exists a stack (k + 1, k + kαk, n − 4, n). Lemma 44 proves then that kαk > (k + 1)αk+1. Therefore, Lemma 43 proves that there exists a stack (r1, . . . , rh) such that rh = k + 1 and r1 + . . . + rh−1 = k(αk − 1) − 4 − x for some integer x ∈ {0, 1, 2, 3}. By construction, we have r1 < r2 < . . . < rh, hence rh−1 + rh < 2(k + 1) < k(1 + αk). Consequently, there also exists a stack (r1, r2, . . . , rh−1, k + 1, k(1 + αk), n − 4, n). Then, k + 2 + r1 + . . . + rh 6 k + 2 + k(αk − 1) − 4 + k + 1 = k(1 + αk) − 1 < k(1 + αk), and therefore pushing an additional run of size k + 2 produces a stack (k + 2, kαk − 3 − x, k(1 + αk), n − 4, n). ◭ 24 On the Worst-Case Complexity of TimSort 1, . . . , r′ h′) such that r′ Once again, there exists a stack (r′ h′−1 = k(αk − 1 + . . . + r′ h′ = k + 2 and r′ 2) − 9 − x − y for some integer y ∈ {0, 1, 2, 3}. By construction, we have r′ 1 < r′ h′ , hence h′ < 2(k + 2) < kαk − 3 − x, and therefore there exists a stack (r′ h′−1, k + 2, kαk − r′ h′−1 + r′ 1, r′ 3 − x, k(1 + αk), n − 4, n). Then, k + 3 + r′ h′ 6 k + 3 + k(αk − 2) − 9 − x − y + k + 2 = kαk − 4 − x − y < kαk − 3 − x, and therefore pushing an additional run of size k + 3 produces a stack (k + 3, k(αk − 1) − 7 − x − y, kαk − 3 − x, k(1 + αk), n − 4, n). 1 + . . . + r′ 2 < . . . < r′ 2, . . . , r′ ◭ We introduce now a variant of the real numbers αn and βn, adapted to our construction. ◮ Definition 48. Let n be a positive integer. We denote by γn the smallest real number m such that, in every stack S = (r1, . . . , rh) such that h > 2, rh = n and rh−1 = n − 4, we have r1 + . . . + rh−1 6 m × n. If no such real number exists, we simply set γn = +∞. ◮ Lemma 49. Let γ = lim inf γn. We have γ > (αγ + 9α − γ + 3)/(2α + 4). Proof. Let ε be a positive real number, and let Nε > N be an integer such that αℓ > α− ε and γℓ > γ− ε for all ℓ > ⌊(N − 6)/(α∞ + 2)⌋. Since α > 3, and up to increasing the value of Nε, we may further assume that ℓ(αℓ − 3) > 30 for every such integers ℓ. Then, consider some integer n > Nε, and let k = ⌊(n − 6)/(α + 2)⌋. By Lemma 47, there exists a stack (k + 3, k(αk − 1) − 7 − x − y, kαk − 3 − x, k(1 + αk), n − 4, n) for some integers x, y ∈ {0, 1, 2, 3}. Let also k′ = ⌊(k(αk − 1) − 7 − x − y)/2⌋. Since k(αk − 3) > 30, it follows that 2(k′ − 4) > k(αk − 1) − 7 − x − y − 2 − 8 > k(αk − 1) − 23 > 2k + 7 > 2(k + 3). Similarly, and since αk 6 α∞ < 5, we have k′ 6 k(αk − 1)/2 < 2k < 2(k + 3). Consequently, pushing additional runs of sizes k′ − (k + 3) and k′ − 4 produces the stack (k′ − 4, k′, k(αk − 1) − 7 − x − y, kαk − 3 − x, k(1 + αk), n − 4, n). Finally, by definition of γn, there exists a sequence of runs p1, . . . , pm that produces a stack (r1, . . . , rh) such that p1 = rh = k′, p2 = rh−1 = k′−4 and r1 +. . .+rh−1 = k′γk′ . Hence, pushing the runs p3, . . . , pm produces the stack (r1, . . . , rh−1, k′, k(αk − 1) − 7 − x − y, kαk − 3 − x, k(1 + αk), n − 4, n). It follows that k > (n − 6)/(α + 2) − 1 > n/(α + 2) − 3 and that k′ > (k(αk − 1) − 7 − x − y)/2 − 1 > k(αk − 1)/2 − 8. This proves that Then, recall that that γ 6 α, that 3 < α 6 α∞ < 5 and that 0 6 x, y 6 3. nγn > r1 + . . . + rh−1 + k′ + k(αk − 1) − 7 − x − y + kαk − 3 − x + k(1 + αk) + n − 4 > k′γk′ + k′ + k(αk − 1) − 13 + kαk − 6 + k(1 + αk) + n − 4 > k′(1 + γ − ε) + 3kαk + n − 23 > (k(αk − 1)/2 − 8)(1 + γ − ε) + 3kαk + n − 23 > k(3αk + (1 + γ − ε)(αk − 1)/2) + n − 23 − 8 × 6 nγn > (n/(α + 2) − 3)(3α − 3ε + (1 + γ − ε)(α − ε − 1)/2) + n − 71 > (cid:0)6α − 6ε + (1 + γ − ε)(α − ε − 1) + 2α + 4(cid:1) n/(2α + 4)− 3(3α + (1 + γ)(α − 1)/2) − 71 > (cid:0)αγ + 9α − γ + 3 − (α + γ − ε)ε(cid:1) n/(2α + 4) − 152. Hence, by choosing n arbitrarily large, then ε arbitrarily small, Lemma 49 follows. ◭ From Lemma 49, we derive the asymptotic evaluation of the sequence (αn), as announced at the beginning of Section A.1.3. ◮ Proposition 50. We have α = α∞ = 2 + √7. Proof. Lemma 49 states that γ > (αγ + 9α − γ + 3)/(2α + 4) or, equivalently, that γ > (9α + 3)/(α + 5). Since α > γ, it follows that α > (9α + 3)/(α + 5), i.e., that α > 2 + √7 or that α 6 2 − √7 < 0. The latter case is obviously impossible, hence α = α∞ = 2 + √7. ◭ N. Auger, V. Jugé, C. Nicaud, and C. Pivoteau 25 Finally, we may prove that the constant ∆ of Theorem 27 is optimal, as a consequence of the following result. ◮ Lemma 51. For all real numbers Λ > ∆, there exists a positive real number KΛ such that, for all h > 1, there is a stack (r1, . . . , rh) for which rh 6 KΛΛh. Proof. Let ε be an arbitrarily small real number such that 0 < ε < Λ/∆− 1, and let Nε be a large enough integer such that αℓ > α∞ − ε and for all ℓ > ⌊(N − 6)/(α∞ + 2)⌋. Then, consider some integer n0 > Nε, and let k = ⌊(n − 6)/(α∞ + 2)⌋. As shown in the proof of Lemma 49, there are integers x, y ∈ {0, 1, 2, 3}, and n1 = ⌊(k(αk − 1) − 7 − x − y)/2⌋, such that there exists a stack (n1 − 4, n1, k(αk − 1) − 7 − x − y, kαk − 3 − x, k(1 + αk), n0 − 4, n0). Since α∞ 6 5, we have then ∆5n1 > ∆5(k(α∞ − 1 − ε)/2 − 8) > ∆5 ((α∞ − 1 − ε)/(2α∞ + 4)n0 − 16) > (α∞ − 1 − ε)/(α∞ − 1)n0 − 16∆5. It follows that n0 6 ∆5(n1 + 16)(α∞ − 1)/(α∞ − 1 − ε) 6 ∆5(1 + ε)2n1 6 Λ5n1. Then, we repeat this construction, but replacing n0 by n1, thereby constructing a new integer n2, then replacing n0 by n2, and so on, until we construct an integer nℓ such that nℓ < Nε. Doing so, we built a stack (nℓ − 4, nℓ, . . . , n0 − 4, n0) of size 5ℓ + 2, and we also have Λ5ℓNε > Λ5ℓnℓ > Λ5(ℓ−1)nℓ−1 > . . . > n0. Choosing KΛ = Nε completes the proof. ◭ Proof of Theorem 27. We focus here on proving the second part of Theorem 27. Consider a real constant ∆′ > ∆, and let Λ = (∆ + ∆′)/2. If h is large enough, then hKΛΛh 6 (∆′)h−4. Then, let (r1, . . . , rh) be a stack such that rh 6 KΛΛh, and let n be some integer such that (∆′)h−4 6 n < (∆′)h−3, if any. Considering the stack (r1, . . . , rh + m), where m = n − (r1 + r2 + . . . + rh), we deduce that hmax > h > 3 + log∆′ (n). Therefore, if n is large enough, we complete the proof by choosing h = ⌊log∆′ (n)⌋ + 3. ◭
1405.5919
2
1405
2016-05-23T17:04:14
Two simple full-text indexes based on the suffix array
[ "cs.DS" ]
We propose two suffix array inspired full-text indexes. One, called SA-hash, augments the suffix array with a hash table to speed up pattern searches due to significantly narrowed search interval before the binary search phase. The other, called FBCSA, is a compact data structure, similar to M{\"a}kinen's compact suffix array, but working on fixed sized blocks. Experiments on the Pizza~\&~Chili 200\,MB datasets show that SA-hash is about 2--3 times faster in pattern searches (counts) than the standard suffix array, for the price of requiring $0.2n-1.1n$ bytes of extra space, where $n$ is the text length, and setting a minimum pattern length. FBCSA is relatively fast in single cell accesses (a few times faster than related indexes at about the same or better compression), but not competitive if many consecutive cells are to be extracted. Still, for the task of extracting, e.g., 10 successive cells its time-space relation remains attractive.
cs.DS
cs
TWO SIMPLE FULL-TEXT INDEXES BASED ON THE SUFFIX ARRAY Szymon Grabowski, Marcin Raniszewski Institute of Applied Computer Science Lodz University of Technology Al. Politechniki 11 90 -- 924 L´od´z, Poland e-mail: [email protected], [email protected] Abstract. We propose two suffix array inspired full-text indexes. One, called SA- hash, augments the suffix array with a hash table to speed up pattern searches due to significantly narrowed search interval before the binary search phase. The other, called FBCSA, is a compact data structure, similar to Makinen's compact suffix array, but working on fixed sized blocks. Experiments on the Pizza & Chili 200 MB datasets show that SA-hash is about 2 -- 3 times faster in pattern searches (counts) than the standard suffix array, for the price of requiring 0.2n − 1.1n bytes of extra space, where n is the text length, and setting a minimum pattern length. FBCSA is relatively fast in single cell accesses (a few times faster than related indexes at about the same or better compression), but not competitive if many consecutive cells are to be extracted. Still, for the task of extracting, e.g., 10 successive cells its time-space relation remains attractive. Keywords: Suffix array, compressed indexes, compact indexes, hashing 1 INTRODUCTION The field of text-oriented data structures continues to bloom. Curiously, in many cases several years after ingenious theoretical solutions their more practical (which means: faster and/or simpler) counterparts are presented, to mention only recent advances in rank/select implementations [1] or the FM-index reaching the compres- sion ratio bounded by k-th order entropy with very simple means [2]. 2 Sz. Grabowski, M. Raniszewski Despite the great interest in compact or compressed1 full-text indexes in re- cent years [3], we believe that in some applications search speed is more important than memory savings, thus different space-time tradeoffs are worth being explored. The classic suffix array (SA) [4], combining speed, simplicity and often reasonable memory use, may be a good starting point for such research. In this paper we present two SA-based full-text indexes, combining effectiveness and simplicity. One augments the standard SA with a hash table to speed up searches, for a moderate overhead in the memory use, the other is a byte-aligned variant of Makinen's compact suffix array [5, 6]. A preliminary version of this article appeared in Proc. PSC 2014 [7]. 2 PRELIMINARIES We use 0-based sequence notation, that is, a sequence S of length n is written as S[0 . . . n − 1], or equivalently as s0s1 . . . sn−1. One may define a full-text index over text T of length n as a data structure supporting at least two basic types of queries, both with respect to a pattern P of length m, where T and P share an integer alphabet of size σ. One query type is count: return the number occ ≥ 0 of occurrences of P in T . The other query type is locate: for each pattern occurrence report its position in T , that is, such j that P [0 . . . m − 1] = T [j . . . j + m − 1]. The suffix array SA[0 . . . n − 1] for text T is a permutation of the indexes {0, 1, . . . , n−1} such that T [SA[i] . . . n−1] ≺ T [SA[i+1] . . . n−1] for all 0 ≤ i < n−1, where the "≺" relation is the lexicographical order. The inverse suffix array SA−1 is the inverse permutation of SA, that is, SA−1[j] = i ⇔ SA[i] = j. If not stated otherwise, all logarithms throughout the paper are in base 2. 3 RELATED WORK The full-text indexing history starts with the suffix tree (ST) [8], a trie whose string collection is the set of all the suffixes of a given text, with an additional requirement that all non-branching paths of edges are converted into single edges. Typically, each ST path is truncated as soon as it points to a unique suffix. A leaf in the suffix tree holds a pointer to the text location where the corresponding suffix starts. As there are n leaves, no non-branching nodes and edge labels represented with pointers to the text, the suffix tree takes O(n) words of space, which is in turn O(n log n) bits. Although initially the suffix tree was known to be constructible in linear time only for constant alphabets, later an ingenious O(n)-time algorithm for integer al- 1 By the latter we mean indexes with space use bounded by O(nH0) or even O(nHk) bits, where n is the text length, and H0 and Hk respectively the order-0 and the order-k entropy. The former term, compact full-text indexes, is less definite, and, roughly speaking, may fit any structure with less than n log2 n bits of space, at least for "typical" texts. Two simple full-text indexes based on the suffix array 3 phabets was found [9]. Moreover, the linear-time construction algorithms can be fast not only in theory, but also in practice [10]. Assuming constant-time access to any child of a given node, the search in the ST takes only O(m + occ) time in the worst case. In practice, this is cumbersome for a large alphabet, of size nω(1), as it requires using perfect hashing, which also makes the construction time linear only in expectation. A small alphabet is easier to handle, which goes in line with the wide use of the suffix tree in bioinformatics. The main problem with the suffix tree is its large space requirement. Even in the most economical version [11] the ST space use reaches almost 9n bytes on average and 16n in the worst case, plus the text, for σ ≤ 256, and even more for large alphabets. Most implementations need 20n bytes or more. An important alternative to the suffix tree is the suffix array (SA) [4]. It is an array of n pointers to all text suffixes sorted according to the lexicographic order of these suffixes. The SA needs n log n bits for its n suffix pointers (indexes), plus n log σ bits for the text, which typically translates to 5n bytes in total. The pattern search time is O(m log n) in the worst case and O(m logσ n+log n) on average, which can be improved to O(m + log n) in the worst case using the longest common prefix (lcp) table. Alternatively, the O(m+log n) time can be reached even without the lcp, in a more theoretical solution with a specific suffix permutation [12]. Yet Manber and Myers in their seminal paper [4] presented a nice trick saving several first steps in the binary search: if we know the SA intervals for all the possible first k symbols of the pattern, we can immediately start the binary search in a corresponding interval. We can set k close to logσ n, with O(n log n) extra bits of space, but constant expected size of the interval, which leads to O(m) average search time and only O(⌈m/CL⌉) cache misses on average, where CL is the cache line length expressed in symbols, typically 64 symbols/bytes in a modern CPU. Unfortunately, real texts are far from random, hence in practice, if text symbols are bytes, we can use k up to 3, which offers a limited (yet, non-negligible) benefit. This idea, later denoted as using a lookup table (LUT), is fairly well known, see e.g. its impact in the search over a suffix array on words [13]. The suffix array can be built from the suffix tree by visiting its leaves in order (hence preserving O(n) construction time), yet this approach is impractical. Only in 2003 several algorithms building the SA directly in linear time were presented, e.g., [14], and currently the fastest O(n)-time construction algorithm is the one given by Nong [15]. A number of suffix tree or suffix array inspired indexes have been proposed as well, including the suffix cactus [16] and the enhanced suffix array (ESA) [17], with space use usually between SA and ST, but according to our knowledge they generally are not faster than their famous predecessors in the count or locate queries. On a theoretical front, the suffix tray by Cole et al. [18] allows to achieve O(m + log σ) search time, with O(n) worst-case time construction and O(n log n) bits of space, which was recently improved by Fischer and Gawrychowski [19] to O(m + log log σ) deterministic time, with preserved construction cost complexities. The common wisdom about the practical performance of ST and SA is that they 4 Sz. Grabowski, M. Raniszewski are comparable, but Grimsmo in his interesting experimental work [10] showed that a careful ST implementation may be up to about 50% faster than SA if the number of matches is very small (in particular, one hit), but if the number of hits grows, the SA becomes more competitive, sometimes being even about an order of magnitude faster. Another conclusion from Grimsmo's experiments is that the ESA may also be moderately faster than SA if the alphabet is small (say, up to 8 symbols) but SA easily wins for a large alphabet. Since around 2000 we can witness a great interest in succinct data structures, in particular, text indexes. Two main ideas that deserve being mentioned are the compressed suffix array (CSA) [20, 21] and the FM-index [22]; the reader is referred to the survey [3] for an thorough coverage of the area. It was noticed in extensive experimental comparisons [23, 1] that compressed indexes are not much slower, and sometimes comparable, to the suffix array in count queries, but locate is 2 -- 3 orders of magnitude slower if the number of matches is large. This instigated researchers to follow one of two paths in order to mitigate the locate cost for succinct indexes. One, pioneered by Makinen [5, 6] and addressed in a different way by Gonz´alez et al. [24, 25], exploits repetitions in the suffix array (the idea is explained in Section 5). The other approach is to build semi-external data structures (see [26, 27] and references therein). 4 SUFFIX ARRAY WITH DEEP BUCKETS The mentioned idea of Manber and Myers with precomputed interval (bucket) boundaries for k starting symbols tends to bring more gain with growing k, but also precomputing costs grow exponentially. Obviously, σk integers are needed to be kept in the lookup table. Our proposal is to apply hashing on relatively long strings, with an extra trick to reduce the number of unnecessary references to the text. We start with building the hash table HT (Fig. 1). The hash function is cal- culated for the distinct k-symbol (k ≥ 2) prefixes of suffixes from the (previously built) suffix array. That is, we process the suffixes in their SA order and if the current suffix shares its k-long prefix with its predecessor, it is skipped (line 08). The value written to HT (line 11) is a pair: (the position in the SA of the first suffix with the given prefix, the position in the SA of the last suffix with the given prefix). Linear probing is used as the collision resolution method. As for the hash function, we used xxhash (https://code.google.com/p/xxhash/). We tested also a few alternatives: MurmurHash (http://en.wikipedia.org/wiki/MurmurHash) is practically as good as xxhash, CRC (http://rosettacode.org/wiki/CRC-32) is slightly slower overall (with up to about 3% slower searches), while the loss of sdbm (http://www.cse.yorku.ca/~oz/hash.html) is greater, often exceeding 10%. Fig. 2 presents the pattern search (locate) procedure. It is assumed that the pattern length m is not less than k. First the range of rows in the suffix array corresponding to the first two symbols of the pattern is found in a "standard" lookup Two simple full-text indexes based on the suffix array 5 HT build(T [0 . . . n − 1], SA[0 . . . n − 1], k, z, h(.)) Precondition: k ≥ 2 allocate HT [0 . . . z − 1] for j ← 0 to z − 1 do HT [j] ← N IL prevStr ← ε j ← N IL lef t ← N IL; right ← N IL for i ← 0 to n − 1 do if SA[i] ≥ n − k then continue if T [SA[i] . . . SA[i] + k − 1] 6= prevStr then (01) (02) (03) (04) (05) (06) (07) (08) (09) (10) (11) (12) (13) (14) (15) (16) (17) (18) (19) (20) HT [j] ← (lef t, n − 1) (21) return HT until false if j 6= N IL then right ← i − 1 HT [j] ← (lef t, right) j ← h(T [SA[i] . . . SA[i] + k − 1]) prevStr ← T [SA[i] . . . SA[i] + k − 1] repeat if HT [j] = N IL then lef t ← i break else j ← (j + 1) % z Fig. 1. Building the hash table of a given size z table (line 1); an empty range immediately terminates the search with no matches returned (line 2). Then, the hash function over the pattern prefix is calculated and a scan over the hash table performed until no extra collisions (line 5; return no matches) or found a match over the pattern prefix, which give us information about the range of suffixes starting with the current prefix (line 6). In this case, the binary search strategy is applied to narrow down the SA interval to contain exactly the suffixes starting with the whole pattern. (As an implementation note: the binary search could be modified to ignore the first k symbols in the comparisons, but it did not help in our experiments, due to specifics of the used A strcmp function from the asmlib library2). 4.1 Reducing the memory for the hash table Each slot in the hash table (HT) contains two 32-bit integers, for the start and the end position of the range of suffixes starting with the corresponding prefix of length 2 http://www.agner.org/optimize/asmlib.zip, v2.34, by Agner Fog. 6 Sz. Grabowski, M. Raniszewski Pattern search(T [0 . . . n − 1], SA[0 . . . n − 1], HT [0 . . . z − 1], k, h(.), P [0 . . . m − 1]) Precondition: m ≥ k ≥ 2 (1) (2) (3) (4) (5) (6) beg, end ← LU T2[p0, p1] if end < beg then report no matches; return j ← h(P [0 . . . k − 1]) repeat if HT [j] = N IL then report no matches; return if (beg ≤ HT [j].lef t ≤ end) and (T [SA[HT [j].lef t] . . . SA[HT [j].lef t] + k − 1] = P [0 . . . k − 1]) then binSearch(P [0 . . . m − 1], HT [j].lef t, HT [j].right); return (7) (8) (9) until false j ← (j + 1) % z Fig. 2. Pattern search with SA-hash k. Yet, it is possible in practice to reduce the second value to 16 bits. To this end, we make use of a lookup table over pairs of symbols (LUT2) to initially narrow down the interval related to which the range in the HT will be encoded. Then the actual range will be written approximately, with quantized right boundary of the range. For clarity, let us denote the new hash table with HTapprox. The code for building HTapprox is shown in Fig. 3. Let us explain why a similar saving cannot be applied also to the start position of the range. This is because a collision which (unluckily) points to a subrange of the actual HT range that we are looking for could not be detected. Here is an example. Let us assume that we have two k-long prefixes: "somethin" and "once in", which have the same hash value (collision). The SA range for "something" is [30200, 30700] and LUT2 stores (for "so") the range [30000, 31000]. The SA range for "once in" is [10300, 10600] and LUT2 table stores (for "on") the range [10000, 11000]. Now we are decoding the range of "somethin" suffixes and there is a collision with "once in". Hence we obtained the SA range [30300, 30600] which is a subrange of [30200, 30700] and we cannot detect a collision. We are searching in narrower range, so the results may be wrong. Quantizing only the right boundary of the range does not imply a similar problem. 5 FIXED BLOCK BASED COMPACT SUFFIX ARRAY Makinen's compact suffix array [5, 6] finds and succinctly represents repeating suffix areas. We propose a variant of this index whose key feature is finding approximate repetitions of suffix areas of predefined size. Choosing the fixed area size allows to maintain a byte-aligned data layout, beneficial for speed and simplicity. Even more, by setting a natural restriction on one of the key parameters we force the structure's Two simple full-text indexes based on the suffix array 7 HT approx build(T [0 . . . n − 1], SA[0 . . . n − 1], k, z, h(.)) Precondition: k ≥ 2 if SA[i] ≥ n − k then continue if T [SA[i] . . . SA[i] + k − 1] 6= prevStr then if j 6= N IL then allocate HTapprox[0 . . . z − 1] for j ← 0 to z − 1 do HTapprox[j] ← N IL prevStr ← ε j ← N IL lef t ← N IL; right ← N IL; beg ← N IL; end ← N IL for i ← 0 to n − 1 do (01) (02) (03) (04) (05) (06) (07) (08) (09) (10) (11) (12) (13) (14) (15) (16) (17) (18) (19) (20) (21) (22) HTapprox[j] ← (lef t, ⌈(n − 1 − beg)/step⌉) (23) if HTapprox[j] = N IL then beg, end ← LU T2[p0, p1] step ← ⌈(end + 1 − beg)/216⌉ lef t ← i break right ← ⌈(i − 1 − beg)/step⌉ HTapprox[j] ← (lef t, right) j ← h(T [SA[i] . . . SA[i] + k − 1]) prevStr ← T [SA[i] . . . SA[i] + k − 1] repeat else j ← (j + 1) % z until false return HT Fig. 3. Building the hash table with reduced memory building bricks to be multiples of 32 bits, which prevents misaligned access to data. Makinen's index was the first opportunistic scheme for compressing a suffix array, that is such that uses less space on compressible texts. The key idea was to exploit runs in the SA, that is, maximal segments SA[i . . . i + ℓ − 1] for which there exists another segment SA[j . . . j + ℓ − 1], such that SA[j + s] = SA[i + s] + 1 for all 0 ≤ s < ℓ. This structure still allows for binary search, only the accesses to SA cells require local decompression. In our approach we take suffix areas of fixed size, e.g., 32 bytes: SA[i . . . i + 31], and find for them other suffix array segments SA[j . . . j+ℓ−1] such that for each s ∈ {0, 1, . . . , ℓ−1} there exists m ∈ {0, 1, . . . , 31} such that SA[j + s] + 1 = SA[i + m]. Moreover, the sequence of chosen values of m is ascending. The construction algorithm for our structure, called fixed block based compact suffix array (FBCSA), is presented in Fig. 4. As a result, we obtain two arrays, arr1 and arr2, which are empty at the beginning, and their elements are always appended at the end during the construction. The elements appended to arr1 are 8 Sz. Grabowski, M. Raniszewski FBCSA build(SA[0 . . . n − 1], T BW T , bs, ss) /* assume n is a multiple of bs */ (01) (02) (03) arr1 ← [ ]; arr2 ← [ ] j ← 0 repeat (04) /* current block of the suffix array is SA[j . . . j + bs − 1] */ find 3 most frequent symbols in T BW T [j . . . j + bs − 1] and store them in MF S[0 . . . 2] /* if there are less than 3 distinct symbols in T BW T [j . . . j + bs − 1], the trailing cells of MF S[0 . . . 2] are set to N IL) */ for i ← 0 to bs − 1 do if T BW T [j + i] = MF S[0] then arr1.append(00) else if T BW T [j + i] = MF S[1] then arr1.append(01) else if T BW T [j + i] = MF S[2] then arr1.append(10) else arr1.append(11) pos0 = T BW T [j . . . j + bs − 1].pos(MF S[0]) pos1 = T BW T [j . . . j + bs − 1].pos(MF S[1]) /* set N IL if MF S[1] = N IL */ pos2 = T BW T [j . . . j + bs − 1].pos(MF S[2]) /* set N IL if MF S[2] = N IL */ a2s = arr2 arr2.append(SA−1[SA[j + pos0] − 1]) arr2.append(SA−1[SA[j + pos1] − 1]) /* append −1 if pos1 = N IL */ arr2.append(SA−1[SA[j + pos2] − 1]) /* append −1 if pos2 = N IL */ for i ← 0 to bs − 1 do if (T BW T [j + i] 6∈ {MF S[0], MF S[1], MF S[2]}) or (SA[j + i] % ss = 0) then arr1.append(1); arr2.append(SA[j + i]) (05) (06) (07) (08) (09) (10) (11) (12) (13) (14) (15) (16) (17) (18) (19) (20) (21) (22) (23) (24) until false (25) else arr1.append(0) arr1.append(a2s) j ← j + bs if j = n then break return (arr1, arr2) Fig. 4. Building the fixed block based compact suffix array (FBCSA) single bits or pairs of bits while arr2 stores suffix array indexes (32-bit integers). The construction makes use of the suffix array SA of text T , the inverse suffix array SA−1 and T BW T (which can be obtained from T and SA, that is, T BW T [i] = T [(SA[i] − 1) mod n]). Additionally, there are two construction-time parameters: block size bs and sampling step ss. The block size tells how many successive SA indexes are encoded together and is assumed to be a multiple of 32, for int32 alignment of the structure layout. The parameter ss means that every ss-th SA index will be represented verbatim. This sampling parameter is a time-space tradeoff; using larger ss reduces Two simple full-text indexes based on the suffix array 9 the overall space but decoding a particular SA index typically involves more recursive invocations. Let us describe the encoding procedure for one block, SA[j . . . j + bs − 1], where j is a multiple of bs. First we find the three most frequent symbols in T BW T [j . . . j + bs − 1] and store them (in arbitrary order) in a small helper array M F S[0 . . . 2] (line 04). If the current block of T BW T does not contain three different symbols, the N IL value will be written in the last one or two cell(s) of M F S. Then we write information about the symbols from M F S in the current block of T BW T into arr1: we append 2-bit combination (00, 01 or 10) if a given symbol is from M F S and the remaining combination (11) otherwise (lines 05 -- 09). We also store the positions of the first occurrences of the symbols from M F S in the current block of T BW T , using the variables pos0, pos1, pos2 (lines 10 -- 12); again N IL values are used if needed. These positions allow to use links to runs of suffixes preceding subsets of the current ones marked by the respective symbols from M F S. We believe that a small example will be useful here. Let bs = 8 and the current block be SA[400 . . . 407] (note this is a toy example and in the real implementation bs must be a multiple of 32). The SA block contains the indexes: 1000, 522, 801, 303, 906, 477, 52, 610. Let their preceding symbols (from T BW T ) be: a, b, a, c, d, d, b, b. The three most frequent symbols, written to M F S, are thus: b, a, d. The first occurrences of these symbols are at positions: pos0 = 1, pos1 = 0 and pos2 = 4. We conclude that SA has the following groups of suffix offsets: [521, 51, 609] (as there are three symbols b in the current block of T BW T ), [999, 800] and [905, 476] and they start at positions: SA−1[521], SA−1[999] and SA−1[905]. We come back to the pseudocode. The described (up to three) links are obtained thanks to SA−1 (lines 14 -- 16) and are written to arr2. Finally, the offsets of the suffixes preceded with a symbol not from M F S (if any) have to be written to arr2 explicitly. Additionally, the sampled suffixes (i.e., those whose offset modulo ss is 0) are handled in the same way (line 18). To distinguish between referrentially encoded and explicitly written suffix offsets, we spent a bit per suffix and append them to arr1 (lines 19 -- 20). To allow for easy synchronization between the portions of data in arr1 and arr2, the size of arr2 (in bytes) as it was before processing the current block is written to arr1 (line 21). Fig. 5 presents the function Find(i), which returns SA[i]. The helper arrays bBits and dBits contain respectively bits and pairs of bits (extracted from one or several integers). The function popcc (popcount) returns the number of occurrences of symbol (integer) c in the given array of symbols (integers). In modern CPUs popc1 for a bit-vector of size e.g. 64 is usually available as a single op-code. 6 EXPERIMENTAL RESULTS All experiments were run on a machine equipped with a 6-core Intel i7 CPU (4930K) clocked at 3.4 GHz, with 64 GB of RAM, running Ubuntu 14.04 LTS 64-bit. The 10 Find(arr1, arr2, bs, i) Sz. Grabowski, M. Raniszewski of1 ← bs/16 of2 ← (bs/16) + (bs/32) cbstart ← ⌊i/bs⌋ ∗ (of2 + 1) cbcurrpos ← i % bs d0 ← ⌊cbcurrpos/32⌋ c ← arr1[cbstart + of2] bBits ← int2bits(arr1[cbstart + of1 . . . cbstart + of1 + d0]) if bBits[cbcurrpos] = 1 then /* assume bs is a multiple of 32 */ (01) (02) (03) (04) (05) (06) (07) (08) (09) (10) (11) (12) (13) (14) d1 ← ⌊cbcurrpos/16⌋ dBits ← int2dibits(arr1[cbstart . . . cbstart + d1]) sym ← dBits[cbcurrpos] return Find(arr1, arr2, bs, return arr2[c + 3 + popc1(bBits[0 . . . cbcurrpos − 1])] else arr2[c + int(sym)] + popcsym(dBits[0 . . . cbcurrpos − 1])) + 1 Fig. 5. Find(i) extracts SA[i] from the FBCSA structure RAM modules were 8 × 8 GB DDR3-1600 with the timings 11-11-11 (Kingston KVR16R11D4K4/64). The CPU cache sizes were: 6 × 32 KB (data) and 6 × 32 KB (instructions) in the L1 level, 6 × 256 KB in L2 and 12 MB in L3. One CPU core was used for the computations. All codes were written in C++ and compiled with 64-bit gcc 4.8.2, with -O3 option (and for the FBCSA search algorithms with the additional -mpopcnt option). The source codes for the FBCSA algorithm can be downloaded from http://ranisz.iis.p.lodz.pl/indexes/fbcsa/. The test datasets were taken from the popular Pizza & Chili site (http://pizzachili.dcc.uchile.cl/). For most experiments we used the 200- megabyte versions of the files dna, english, proteins, sources and xml. Only to compare search times of FBCSA variants against Makinen's CSA we used 50- megabyte datasets, due to text size limitations of the CSA implementation. In order to test the search algorithms, we generated 500 thousand patterns for each used pattern length; the patterns were extracted randomly from the corre- sponding datasets (i.e., each pattern returns at least one match). In the first experiment we compared pattern search (count) speed using the following indexes: • plain suffix array (SA), • suffix array with a lookup table over the first 2 symbols (SA-LUT2), • suffix array with a lookup table over the first 3 symbols (SA-LUT3), Two simple full-text indexes based on the suffix array 11 • the proposed suffix array with deep buckets, with hashing the prefixes of length k = 8 (only for dna k = 12 and for proteins k = 5 is used); the load factor α in the hash table was set to 90% (SA-hash), • a more compact variant of SA-hash, with 6 bytes rather than 8 bytes per entry in the hash table (SA-hash-dense), • the proposed fixed block based compact suffix array with parameters bs = 32 and ss = 5 (FBCSA), • FBCSA (parameters as before) with a lookup table over the first 2 symbols (FBCSA-LUT2), • FBCSA (parameters as before) with a lookup table over the first 3 symbols (FBCSA-LUT3), • FBCSA (parameters as before) with a hash of prefixes of length k = 8 (only for dna k = 12 and for proteins k = 5 is used); the load factor in the hash table was set to 90% (FBCSA-hash), • a more compact variant of FBCSA-hash, with 6 bytes rather than 8 bytes per entry in the hash table (FBCSA-hash-dense). The results are presented in Fig. 6 (faster indexes) and Fig. 7 (FBCSA variants). As expected, SA-hash is the fastest index among the tested ones. The reader may also look at Table 1 with a rundown of the achieved speedups, where the plain suffix array is the baseline index and its speed is denoted with 1.00. m = 16 SA SA-LUT2 SA-LUT3 SA-hash SA-hash-dense m = 64 SA SA-LUT2 SA-LUT3 SA-hash SA-hash-dense dna english proteins sources xml 1.00 1.21 1.28 3.26 2.63 1.00 1.21 1.28 3.36 2.64 1.00 1.38 1.51 2.79 2.46 1.00 1.37 1.49 2.78 2.45 1.00 1.37 1.59 2.74 2.44 1.00 1.37 1.56 2.74 2.44 1.00 1.44 1.62 2.76 2.47 1.00 1.42 1.60 2.77 2.47 1.00 1.39 1.52 2.14 1.95 1.00 1.37 1.46 1.81 1.69 Table 1. Speedups with regard to the search speed of the plain suffix array, for the five 200 MB datasets and pattern lengths m = 16 and m = 64 The SA-hash index has two drawbacks: it requires significantly more space than the standard SA and we assume (at construction time) a minimal pattern length mmin. The latter issue may be eliminated, but for the price of even more space use; namely, we can build one hash table for each pattern length from 1 to mmin 12 Sz. Grabowski, M. Raniszewski (counting queries for those short patterns do not ever need to perform binary search over the suffix array). For the shortest lengths ({1, 2} or {1, 2, 3}) lookup tables may be alternatively used. We have not implemented this "all-HT" variant, but it is easy to estimate the memory use for each dataset. To this end, one needs to know the number of distinct q-grams for q ≤ mmin (Table 2). Note that the alphabet size, i.e., the number of 1-grams, for the DNA and proteins datasets is 16 and 25, respectively. These surprisingly large values are explained by the content of the files in the corpus, "polluted" slightly with textual headers, End-of-Line symbols, etc. q 1 2 3 4 5 6 7 8 9 10 dna 16 152 683 2,222 5,892 12,804 28,473 80,397 279,680 1,065,613 english 225 10,829 102,666 589,230 2,150,525 5,566,993 11,599,445 20,782,043 33,143,032 48,061,001 proteins 25 607 11,607 224,132 3,623,281 36,525,895 94,488,651 112,880,347 117,199,335 119,518,691 sources 230 9,525 253,831 1,719,387 5,252,826 10,669,627 17,826,241 26,325,724 35,666,486 45,354,280 xml 96 7,054 141,783 908,131 2,716,438 5,555,190 8,957,209 12,534,152 16,212,609 20,018,262 Table 2. The number of distinct q-grams (1 . . . 10) in the 200 MB datasets. The number of distinct 12-grams for dna is 13,752,341. An obvious space-time factor in a hash table with open addressing is its load factor α. We checked several values of α on two datasets (Table 3) to conclude that using α = 90% is a reasonable alternative to α = 50%, as the pattern search times grow by only about 10% or less. The number of bytes for one hash table with z entries and 0 < α ≤ 1 load factor is, in our implementation of SA-hash, z × 8 × (1/α), since each entry contains two 4-byte integers. For example, in our experiments the hash table for english with α = 90% needed 20,782,043 ×(8/0.9) = 184,729,272 bytes, i.e., 88.1% of the size of the text itself. Note that the overhead in the SA-hash-dense variant with the same α is 20,782,043 ×(6/0.9) = 138,546,954 bytes, i.e., 66.1% of the text size. Finally, in Table 4 we present the overall space use for the five non-compact SA variants: plain SA, SA-LUT2, SA-LUT3, SA-hash and SA-hash-dense, plus SA- allHT(-dense), which is a (not implemented) structure comprising a suffix array, a LUT2 and one hash table for each k ∈ {3, 4, . . . , mmin}. The space is expressed as a multiple of the text length n (including the text), which is for example 5.000 for the plain suffix array. We note that the lookup table structures become a relatively smaller fraction when larger texts are indexed. For the variants with hash tables we take two load factors: 50% and 90%. In the next set of experiments we evaluated the FBCSA index. Its properties Two simple full-text indexes based on the suffix array 13 25 0.625 0.807 0.781 0.791 0.734 1.024 1.013 1.035 50 0.636 0.817 0.792 0.802 0.740 1.026 1.019 1.040 HT load factor (%) 80 60 0.672 0.643 0.855 0.825 0.806 0.829 0.837 0.814 0.754 0.744 1.039 1.034 1.023 1.036 1.053 1.043 70 0.655 0.836 0.809 0.819 0.749 1.034 1.027 1.047 90 0.717 0.903 0.877 0.883 0.769 1.053 1.042 1.063 95 0.789 0.978 0.953 0.966 0.782 1.064 1.057 1.079 dna, 12 dna, 16 dna, 32 dna, 64 english, 8 english, 16 english, 32 english, 64 Table 3. Average pattern search times (in µs) in function of the HT load factor α for the SA-hash algorithm (xxhash function used). Each 200-megabyte dataset name followed with the pattern length (m). SA SA-LUT2 SA-LUT3 SA-hash-50 SA-hash-90 SA-hash-dense-90 SA-allHT-50 SA-allHT-90 SA-allHT-dense-90 dna 5.000 5.001 5.320 6.050 5.583 5.438 6.472 5.818 5.613 english 5.000 5.001 5.320 6.587 5.882 5.661 8.114 6.730 6.298 proteins 5.000 5.001 5.320 5.278 5.154 5.116 5.296 5.164 5.123 sources 5.000 5.001 5.320 7.010 6.117 5.838 9.736 7.631 6.973 xml 5.000 5.001 5.320 5.958 5.532 5.399 7.353 6.307 5.980 Table 4. Space use for the non-compact data structures as a multiple of the indexed text size (including the text), with the assumption that text symbols are represented in 1 byte each and SA offsets are represented in 4 bytes. The datasets have 200 MB in size. The value of mmin for SA-hash-50 and SA-hash-90, used in the construction of these structures and affecting their size, is like in the experiments from Fig. 6. The index SA-allHT-* contains LUT2 and one hash table for each k ∈ {3, 4, . . . , mmin}, when mmin depends on the current dataset, as explained. The -50 and -90 suffixes in the structure names denote the hash load factors (in percent). of interest, for various block size (bs) and sampling step (ss) parameters, are: the space use, pattern search times, times to access (extract) one random SA cell, times to access (extract) multiple consecutive SA cells. For bs we set the values 32 and 64. The ss was tested in a wider range ({3, 4, 5, 8, 12, 16, 32}). Using bs = 64 results in better compression but decoding a cell is also slightly slower (see Fig. 9). We tried to compare FBCSA against its competitors. Unfortunately, we were unable to run LCSA / LCSA-Psi [25] (in spite of contacting its authors) and MakCSA [6] cannot (directly) access single SA cells. From the comparison with the results presented in [25, Sect. 4] we conclude that FBCSA is a few times faster 14 Sz. Grabowski, M. Raniszewski in single cell access than the other related algorithms, MakCSA [6] (augmented with a compressed bitmap from [28] to extract arbitrary ranges of the suffix array) and LCSA / LCSA-Psi [25], at similar or better compression. Extracting c consecutive cells is not however an efficient operation for FBCSA (as opposed to MakCSA and LCSA / LCSA-Psi, see Figs 5 -- 7 in [25]), yet for small ss the time growth is slower than linear, due to a few sampled (and thus written explicitly) SA offsets in a typical block (Fig. 10). Therefore, in extracting only 5 or 10 successive cells our index is still competitive. We also compared FBCSA variants against MakCSA in search (count) queries. Alas, it was possible to use MakCSA only for 50-megabyte datasets. The results of our comparison are shown in Fig. 8. MakCSA wins on proteins50 and english50, is comparable to our variants on dna50, and clearly loses on sources50 and xml50 (note the logarithmic scale for the last dataset). Also, we can add two remarks. First, the relative overhead of the lookup tables (LUT2 and LUT3) is roughly 4 times smaller for 200-megabyte datasets, yet (as mentioned) MakCSA does not support such large datasets. Second, the hash component of the index may be optimized for the FBCSA indexes, with hopefully more competitive space-time tradeoffs. 7 CONCLUSIONS We presented two simple full-text indexes. One, called SA-hash, speeds up standard suffix array searches with reducing significantly the initial search range, thanks to a hash table storing range boundaries of all intervals sharing a prefix of a specified length. Despite its simplicity, we are not aware of such use of hashing in exact pattern matching, and the approximately 3-fold speedups compared to a standard SA may be worth the extra space in many applications. The other presented data structure is a compact variant of the suffix array, related to Makinen's compact SA [6]. Our solution works on blocks of fixed size, which provides int32 alignment of the layout. This index is rather fast in single cell access, but not competitive if many (e.g., 100) consecutive cells are to be extracted. Several aspects of the presented indexes require further study. In the SA-hash scheme collisions in the HT may be eliminated with perfect hashing. This should also reduce the overall space use. In case of plain text, the standard suffix array component may be replaced with a suffix array on words [13], with possibly new interesting space-time tradeoffs. The idea of deep buckets may be incorporated into some compressed indexes, e.g., to save on the several first LF-mapping steps in the FM-index. 8 ACKNOWLEDGEMENT The work was supported by the Polish National Science Centre under the project DEC-2013/09/B/ST6/03117 (both authors). Two simple full-text indexes based on the suffix array 15 REFERENCES [1] Gog, S. -- Petri, M.: Optimized succinct data structures for massive data. Software -- Practice and Experience, Vol. 44, 2014, No. 11, pp. 1287 -- 1314. [2] Karkkainen, J. -- Puglisi, S. J.: Fixed block compression boosting in FM-indexes. In: R. Grossi, F. Sebastiani and F. Silvestri (Eds.): String Processing and Information Retrieval, Proceeding of the 18th International Symposium, SPIRE'11, Pisa, Italy, October 2011, Vol. 7024 of Lecture Notes in Computer Science, Springer, pp. 174 -- 184. [3] Navarro, G. -- Makinen, V.: Compressed full-text indexes. ACM Computing Sur- veys, Vol. 39, 2007, No. 1, article 2. [4] Manber, U. -- Myers, G.: Suffix arrays: a new method for on-line string searches. In: D. S. Johnson (Ed.): Discrete Algorithms, Proceedings of the First Annual ACM- SIAM Symposium, SODA'90, San Francisco, CA, USA, January 1990, ACM/SIAM, pp. 319 -- 327. [5] Makinen, V.: Compact suffix array. In: R. Giancarlo and D. Sankoff (Eds.): Com- binatorial Pattern Matching, Proceeding of the 11th Annual Symposium, CPM'00, Montreal, Canada, June 2000, Vol. 1848 of Lecture Notes in Computer Science, Springer, pp. 305 -- 319. [6] Makinen, V.: Compact suffix array -- a space-efficient full-text index. Fundamenta Informaticae, Vol. 56, 2003, No. 1 -- 2, pp. 191 -- 210. [7] Grabowski, S. -- Raniszewski, M.: Two simple full-text indexes based on the suffix array. In: J. Holub and J. Zd´arek (Eds.): Proceedings of the Prague Stringology Conference (PSC) 2014, Czech Technical University in Prague, Czech Republic, 2014, pp. 179 -- 191. [8] Weiner, P.: Linear pattern matching algorithm. In: Proceedings of the 14th Annual IEEE Symposium on Switching and Automata Theory, Washington, DC, 1973, pp. 1 -- 11. [9] Farach, M.: Optimal suffix tree construction with large alphabets. In: Foundations of Computer Science, Proceedings of the 38th IEEE Annual Symposium, FOCS'97, Miami Beach, FL, USA, October 1997, IEEE Computer Society, pp. 137 -- 143. [10] Grimsmo, N.: On performance and cache effects in substring indexes. Tech. Rep. IDI-TR-2007-04, NTNU, Department of Computer and Information Science, Sem Salands vei 7-9, NO-7491 Trondheim, Norway (2007). [11] Kurtz, S. -- Balkenhol, B.: Space efficient linear time computation of the Bur- rows and Wheeler transformation. In: Numbers, Information and Complexity, Kluwer Academic Publishers, 2000, pp. 375 -- 383. [12] Franceschini, G. -- Grossi, R.: No sorting? Better searching! ACM Transactions on Algorithms, Vol. 4, 2008, No. 1, pp. 2:1 -- 2:13. [13] Ferragina, P. -- Fischer, J.: Suffix arrays on words. In: B. Ma and K. Zhang (Eds.): Combinatorial Pattern Matching, Proceeding of the 18th Annual Sympo- sium, CPM'07, London, Canada, July 2007, Vol. 4580 of Lecture Notes in Computer Science, Springer, pp. 328 -- 339. [14] Karkkainen, J. -- Sanders, P.: Simple linear work suffix array construction. In: J. C. M. Baeten, J. K. Lenstra, J. Parrow and G. J. Woeginger (Eds.): Automata, 16 Sz. Grabowski, M. Raniszewski Languages and Programming, Proceeding of the 30th International Colloquium, ICALP'03, Eindhoven, The Netherlands, June 2003, Vol. 2719 of Lecture Notes in Computer Science, Springer, pp. 943 -- 955. [15] Nong, G. -- Zhang, S. -- Chan, W. H.: Two efficient algorithms for linear time suffix array construction. IEEE Transactions on Computers, Vol. 60, 2011, No. 10, pp. 1471 -- 1484. [16] Karkkainen, J.: Suffix cactus: A cross between suffix tree and suffix array. In: Z. Galil and E. Ukkonen (Eds.): Combinatorial Pattern Matching, Proceedings of the Sixth Annual Symposium, CPM'95, Espoo, Finland, July 1995, Vol. 937 of Lecture Notes in Computer Science, Springer, pp. 191 -- 204. [17] Abouelhoda, M. I. -- Kurtz, S. -- Ohlebusch, E.: The enhanced suffix array and its applications to genome analysis. In: Algorithms in Bioinformatics, Proceedings of the Second International Workshop, WABI'02, Rome, Italy, September 2002, Vol. 2452 of Lecture Notes in Computer Science, Springer, pp. 449 -- 463. [18] Cole, R. -- Kopelowitz, T. -- Lewenstein, M.: Suffix trays and suffix trists: structures for faster text indexing. In: M. Bugliesi, B. Preneel, V. Sassone and I. Wegener (Eds.): Automata, Languages and Programming, Proceeding of the 30th International Colloquium, Part I, ICALP'06, Vol. 4051 of Lecture Notes in Com- puter Science, Springer, 2006, pp. 358 -- 369. [19] Fischer, J. -- Gawrychowski, P.: Alphabet-dependent string searching with wex- ponential search trees. In: Combinatorial Pattern Matching (CPM), 2015, to appear. [20] Grossi, R. -- Vitter, J. S.: Compressed suffix arrays and suffix trees with appli- cations to text indexing and string matching. In: F. F. Yao and E. M. Luks (Eds.): Theory of Computing, Proceedings of the 32nd ACM Symposium, STOC'00, Port- land, OR, USA, May 2000, ACM Press, pp. 397 -- 406. [21] Sadakane, K.: Succinct representations of lcp information and improvements in the compressed suffix arrays. In: D. Eppstein (Ed.): Discrete Algorithms, In: Proceedings of the 13th Annual ACM-SIAM Annual Symposium, SODA'02, San Francisco, CA, USA, January 2002, ACM/SIAM, pp. 225 -- 232. [22] Ferragina, P. -- Manzini, G.: Opportunistic data structures with applications. In: Foundations of Computer Science, Proceedings of the 41st IEEE Annual Symposium, FOCS'00, Redondo Beach, CA, USA, November 2000, IEEE Computer Society, pp. 390 -- 398. [23] Ferragina, P. -- Gonz´alez, R. -- Navarro, G. -- Venturini, R.: Compressed text indexes: From theory to practice. Journal of Experimental Algorithms, Vol. 13, 2009, pp. 12:1.12 -- 12:1.31. [24] Gonz´alez, R. -- Navarro, G.: Compressed text indexes with fast locate. In: B. Ma and K. Zhang (Eds.): Combinatorial Pattern Matching, Proceeding of the 18th An- nual Symposium, CPM'07, London, Canada, July 2007, Vol. 4580 of Lecture Notes in Computer Science, Springer, pp. 216 -- 227. [25] Gonz´alez, R. -- Navarro, G. -- Ferrada, H.: Locally compressed suffix arrays. ACM Journal of Experimental Algorithmics, Vol. 19, 2014, No. 1, article 1. [26] Gog, S. -- Moffat, A.: Adding compression and blended search to a compact two- level suffix array. In: O. Kurland, M. Lewenstein and E. Porat (Eds.): String Pro- Two simple full-text indexes based on the suffix array 17 cessing and Information Retrieval, Proceeding of the 20th International Symposium, SPIRE'13, Jerusalem, Israel, October 2013, Vol. 8214 of Lecture Notes in Computer Science, Springer, pp. 141 -- 152. [27] Gog, S. -- Moffat, A. -- Culpepper, J. S. -- Turpin, A. -- Wirth, A.: Large- scale pattern search using reduced-space on-disk suffix arrays. IEEE Transactions on Knowledge and Data Engineering, Vol. 26, 2014, No. 8, pp. 1918 -- 1931. [28] Raman, R. -- Raman, V. -- Rao, S. S.: Succinct indexable dictionaries with ap- plications to encoding k-ary trees and multisets. In: D. Eppstein (Ed.): Discrete Algorithms, Proceedings of the 13th Annual ACM-SIAM Symposium, SODA'02, San Francisco, CA, USA, January 2002, ACM/SIAM, pp. 233 -- 242. 18 Sz. Grabowski, M. Raniszewski ) s u ( n r e t t a p / e m i t h c r a e s ) s u ( n r e t t a p / e m i t h c r a e s 5 4 3 2 1 0 5 4 3 2 1 0 dna200 SA SA-LUT2 SA-LUT3 SA-hash SA-hash-dense 10 20 30 40 50 60 70 m proteins200 10 20 30 40 50 60 70 ) s u ( n r e t t a p / e m i t h c r a e s ) s u ( n r e t t a p / e m i t h c r a e s 5 4 3 2 1 0 5 4 3 2 1 0 english200 10 20 30 40 50 60 70 m sources200 10 20 30 40 50 60 70 m m ) s u ( n r e t t a p / e m i t h c r a e s 5 4 3 2 1 0 xml200 10 20 30 40 50 60 70 m Fig. 6. Pattern search time (count query). All times are averages over 500K random patterns of the same length m = {mmin, 16, 32, 64}, where mmin is 8 for most datasets except for dna (12) and proteins (5). The patterns were extracted from the respective texts. Two simple full-text indexes based on the suffix array 19 ) s u ( n r e t t a p / e m i t h c r a e s ) s u ( n r e t t a p / e m i t h c r a e s 25 20 15 10 5 0 25 20 15 10 5 0 dna200 FBCSA FBCSA-LUT2 FBCSA-LUT3 FBCSA-hash FBCSA-hash-dense 10 20 30 40 50 60 70 m proteins200 10 20 30 40 50 60 70 ) s u ( n r e t t a p / e m i t h c r a e s ) s u ( n r e t t a p / e m i t h c r a e s 25 20 15 10 5 0 25 20 15 10 5 0 english200 10 20 30 40 50 60 70 m sources200 10 20 30 40 50 60 70 m m ) s u ( n r e t t a p / e m i t h c r a e s 25 20 15 10 5 0 xml200 10 20 30 40 50 60 70 m Fig. 7. Pattern search time (count query). All times are averages over 500K random patterns of the same length m = {mmin, 16, 32, 64}, where mmin is 8 for most datasets except for dna (12) and proteins (5). The patterns were extracted from the respective texts. Sz. Grabowski, M. Raniszewski dna50 english50 FBCSA FBCSA-LUT2 FBCSA-LUT3 FBCSA-hash MakCSA 2.5 3.0 3.5 4.0 4.5 5.0 5.5 size (multiple of the text size) proteins50 2.5 3.0 3.5 4.0 4.5 5.0 5.5 size (multiple of the text size) ) s u ( y r e u q r e p e m i t 30 25 20 15 10 5 0 ) s u ( y r e u q r e p e m i t 140 120 100 80 60 40 20 0 xml50 2.5 3.0 3.5 4.0 4.5 5.0 5.5 size (multiple of the text size) sources50 2.5 3.0 3.5 4.0 4.5 5.0 5.5 size (multiple of the text size) 20 ) s u ( y r e u q r e p e m i t ) s u ( y r e u q r e p e m i t 45 40 35 30 25 20 15 10 5 0 20 15 10 5 0 103 ) s u ( y r e u q r e p e m i t 102 101 100 2.5 3.0 3.5 4.0 4.5 5.0 5.5 size (multiple of the text size) Fig. 8. Pattern search time (count query) for FBCSA variants (bs = 32) and Makinen's CSA. The different results in a series are obtained from varying the sampling parameter ss in {3, 4, 5, 8, 12, 16, 32}. All times are averages over 500K random patterns of the same length m = 16. The patterns were extracted from the respective texts. Note the logarithmic scale for the xml50 dataset. Two simple full-text indexes based on the suffix array 21 FBCSA (bs = 64), extracting 1 random cell 2.0 ) s u ( y r e u q r e p e m i t 1.5 1.0 0.5 FBCSA (bs = 32), extracting 1 random cell dna200 english200 proteins200 sources200 xml200 2.0 ) s u ( y r e u q r e p e m i t 1.5 1.0 0.5 0.0 2.0 2.5 size (multiple of the text size) 3.0 3.5 4.0 4.5 0.0 2.0 2.5 size (multiple of the text size) 3.0 3.5 4.0 4.5 Fig. 9. FBCSA index sizes and cell access times with varying ss parameter ({3, 4, 5, 8, 12, 16, 32}). The parameter bs was set to 32 (left figure) or 64 (right figure). The times are averages over 10M random cell accesses. FBCSA (bs = 32), extracting 5 consecutive cells FBCSA (bs = 64), extracting 5 consecutive cells ) s u ( y r e u q r e p e m i t 5 4 3 2 1 0 ) s u ( y r e u q r e p e m i t 10 8 6 4 2 0 dna200 english200 proteins200 sources200 xml200 4.0 4.5 2.0 2.5 size (multiple of the text size) 3.0 3.5 FBCSA (bs = 32), extracting 10 consecutive cells 2.0 2.5 size (multiple of the text size) 3.0 3.5 4.0 4.5 ) s u ( y r e u q r e p e m i t 5 4 3 2 1 0 ) s u ( y r e u q r e p e m i t 10 8 6 4 2 0 2.0 2.5 size (multiple of the text size) 3.0 3.5 4.0 4.5 FBCSA (bs = 64), extracting 10 consecutive cells 2.0 2.5 size (multiple of the text size) 3.0 3.5 4.0 4.5 Fig. 10. FBCSA, extraction time for c = 5 (top figures) and c = 10 (bottom figures) consecutive cells, with varying ss parameter ({3, 4, 5, 8, 12, 16, 32}). The parameter bs was set to 32 (left figures) or 64 (right figures). The times are averages over 1M random cell run extractions.
1812.05306
1
1812
2018-12-13T08:04:09
Optimal Algorithm for Profiling Dynamic Arrays with Finite Values
[ "cs.DS", "cs.CC", "cs.SI" ]
How can one quickly answer the most and top popular objects at any time, given a large log stream in a system of billions of users? It is equivalent to find the mode and top-frequent elements in a dynamic array corresponding to the log stream. However, most existing work either restrain the dynamic array within a sliding window, or do not take advantages of only one element can be added or removed in a log stream. Therefore, we propose a profiling algorithm, named S-Profile, which is of $O(1)$ time complexity for every updating of the dynamic array, and optimal in terms of computational complexity. With the profiling results, answering the queries on the statistics of dynamic array becomes trivial and fast. With the experiments of various settings of dynamic arrays, our accurate S-Profile algorithm outperforms the well-known methods, showing at least 2X speedup to the heap based approach and 13X or larger speedup to the balanced tree based approach.
cs.DS
cs
Optimal Algorithm for Profiling Dynamic Arrays with Finite Values Dingcheng Yang, Wenjian Yu, Junhui Deng BNRist, Dept. Computer Science & Tech., Tsinghua Univ., Beijing, China [email protected],[email protected], [email protected] Shenghua Liu CAS Key Lab. Network Data Science & Tech., Inst. Computing Technology, Chinese Academy of Sciences, Beijing, China [email protected] 8 1 0 2 c e D 3 1 ] S D . s c [ 1 v 6 0 3 5 0 . 2 1 8 1 : v i X r a ABSTRACT How can one quickly answer the most and top popular objects at any time, given a large log stream in a system of billions of users? It is equivalent to find the mode and top-frequent elements in a dynamic array corresponding to the log stream. However, most existing work either restrain the dynamic array within a sliding window, or do not take advantages of only one element can be added or removed in a log stream. Therefore, we propose a profil- ing algorithm, named S-Profile, which is of O(1) time complexity for every updating of the dynamic array, and optimal in terms of computational complexity. With the profiling results, answering the queries on the statistics of dynamic array becomes trivial and fast. With the experiments of various settings of dynamic arrays, our accurate S-Profile algorithm outperforms the well- known methods, showing at least 2X speedup to the heap based approach and 13X or larger speedup to the balanced tree based approach. KEYWORDS Data structure, log stream, mode of an array, O(1)-complexity algorithm, profiling dynamic array. 1 INTRODUCTION Many online systems, especially with billions of users, are gener- ating a large stream of logs [6], recording users' dynamics in the systems, e.g. users (un)follow other users, "(dis)like" objects, en- ter (exit) live video channels, and click objects. Then, a question is raised: How can we efficiently know the most popular objects (include users), i.e. mode, top-K popular ones, and even the distribution of frequency in a fast and large log stream at any time? Mathematically, the questions converge to calculate and up- date the statistics of a dynamic array of finite values. Thus the existing fast algorithms on the statistics are as follows: Mode of an array. The mode of an array and its corresponding frequency can be calculated by sorting the array (if it's of numeric value) and scanning the sorted array in O(n log n) time, where n is the length of array [7]. Notice that through judging the frequency of mode we can solve the element distinctness problem, which was proven to have to be solved with Ω(n log n) time complexity [12, 15]. Therefore, calculating the mode of an array has the lower bound of Ω(n log n) as well. If the elements of array can only take finite values, the complexity of calculating the mode can be reduced. Suppose they can only take m values. One can use m buckets to store the frequency of each distinct element. Then, the mode can be calculated in O(n + m) time by scanning the m buckets. © 2018 Association for Computing Machinery. Published in Proceedings of the ACM Conference, July 2017, ISBN 978-x-xxxx-xxxx-x/YY/MM on OpenProceedings.org. Distribution of this paper is permitted under the terms of the Creative Commons license CC-by-nc-nd 4.0. The problem of range mode query, which calculates the mode of a sub-array A[i . . . j] for a given array A and a pair of indices (i, j), has also been investigated [4, 10, 13]. The array with finite values was considered. With a static data structure, the range mode query can be answered in O((cid:112)n/log n) time [4]. Majority and frequency approximation. The majority is the ele- ment whose frequency is more than half of n. An algorithm was proposed to find majority in O(n) time and O(1) space [3]. Many work on the statistics like frequency count and quantiles, are un- der a setting of sliding window [1, 2, 5, 8, 11]. They consider the most recently observed data elements (within the window) and calculate the statistics. Space-efficient algorithms were proposed to maintain the statistics over the sliding window on a stream. However, those existing work slow down their algorithms without considering that the increase and decrease of object frequency are always 1 at a time in log streams. Therefore, we propose an algorithm S-Profile to keep profiling the dynamic array. With such a profile, we can answer the queries of the statistics: mode, top-K and frequency distributions. In summary, S-Profile has the following advantages: - Optimal efficiency: S-Profile needs O(1) time complex- ity and O(m) space complexity to profile dynamic arrays, where m is the maximum number of objects. - Querying Statistics: With the profiling, we have sorted frequency-object pairs, and can simply answer the queries on mode, top-K, majority and other statistics in O(1). - Applicable: Our S-Profile can be plugged into most of log streams in many systems, and profiling objects of interest. In experiments, S-Profile compares with the existing methods in various settings of dynamic arrays, and shows its performance and robustness. 2 AN O(1)-COMPLEXITY ALGORITHM FOR UPDATING THE MODE AND STATISTICS We define tuples (xi , ci) as a log stream, where xi and ci is the object id and action in the i-th tuple. Action ci can be either "add" or "remove", which, for example, can indicate object xi is "liked" or "disliked", or user xi is followed or unfollowed. Conceptually, we could imagine a dynamic array A of objects associated with a log stream, by appending object xi into A if ci is "add", and deleting object xi from A if ci is "remove". Dynamic array A is not necessarily generated and stored, which is defined for convenient description of our algorithm. Therefore, our problem can be described as follows: Problem 1 (Profiling dynamic array). Given: a log stream of tuples (xi , ci) adding and removing an object each time, - To find: fast profiling of dynamic array A of objects at any time, - Such that: answering the queries on mode, top-K and other statistics of objects is trivial and fast. Let m be the maximum number of distinct objects in a log stream or dynamic array A. Without loss of generality, we assume id xi ∈ [1, m], i.e. integers between 1 and m. For any m distinct objects, we can map them into the integers from 1 to m as ids. We can use m buckets to store the frequency of each distinct object. Let F be such a frequency array with length m. F[i] ∈ F is the frequency of object with id i. With F, most statistics of A can be calculated without visiting A itself. For example, the mode of A refers to locations in F where the element has the maximum value. Although updating F with each tuple of a log stream trivial and costs O(1), finding the maximum value in F at each time is still time consuming. Therefore, we first introduce a proposed data structure of a profile, named "block set", which can answer the statistical queries in a trivial cost. And we show later that we can maintain such a profile in O(1) time complexity and O(m) space complexity. 2.1 Proposed data structure for profiling In order to find the mode of A, we just need to care about the maximum in F. If only integers are added to A, the maximum ele- ment of F can be easily updated. However, in Problem 1 removing integer is also allowed. This complicates the calculation of mode and other statistics of A. So, the sorted array T must be employed and maintained. To facilitate the queries, T can be implemented as a binary tree. The heap and balanced tree are two kinds of binary tree, and are widely used for efficiently maintaining an sorted array. Upon a modification on A, they both can be updated in O(log m) time. The root node of a heap is the array element with the extreme value. This means the heap is only suitable for producing the A's elements with either maximum frequency (the mode) or the minimum frequency. The balanced tree is good at answering the query of median of A, and can also output the mode and top-K elements, etc. It should be pointed out, these general algorithms do not take the particularity of Problem 1 into account (the modification on F is restricted to plus 1 or minus 1). By the way, no one can maintain the sorted array under an arbitrary modification with a time complexity below O(log m), because it can be regarded as a sorting problem which has been proven to have Ω(m log m) time complexity. We use Figure 1 as an example to illustrate the proposed data structure for maintaining T . Suppose T has frequency values in ascending order. In order to locate the index of the i-th ele- ment of T in F and vice verse, two conversion arrays are defined: T toF and FtoT . In other words, we have T[i] = F[T toFi] and F[i] = T[FtoTi]. Here, we use both the subscript and bracket notation to specify an element of array. As shown in Figure 1(c), we can partition T into nonoverlapped segments according to its elements. Each such segment is called block here and represented by an integer triple (l, r , f ), where l and r are starting and ending indices respectively, and f is the element value (frequency). So, a block b = (l, r , f ) always satisfies: • 1 ≤ l ≤ r ≤ m • Ti = f , • Tl > Tl−1, • Tr < Tr +1, ∀i ∈ [l, r] if l > 1 if r < m There are at most m blocks, which form a block set. It fully cap- tures the information in the sorted array T . An array of pointers called PtrB is also needed to make a link from each element in T to its relevant block. According to the definition of block, we always have: Ti = PtrB[i].f , and PtrB[i].l ≤ i ≤ PtrB[i].r . (1) Figure 1: Illustration of the proposed block set for main- taining array T . (a) The initial F and T . (b) When "1"is added to A, a brute-force approach to maintain T includes four swaps of "1" rightwards and updates of FtoT and T toF. (c) The initial F andT , and the block set. F andT are up to be modified. (d) With the information of block, the swapping destination in T can be easily determined. Here we use ".l" to denote the member l of a block, and so on. The block set B represents the sorted frequency array T , while with arrays FtoS, StoF and PtrB we no longer need to store F and T . These proposed new data structure well profile the dynamic array A. The remaining thing is to maintain them and answer the statistical queries on A in an efficient manner. 2.2 S-Profile: the O(1)-Complexity Updating Algorithm We first consider the situation where an integer is added to A. As shown in Figure 1(a) and 1(b), a brute-fore approach to update T is swapping the updated frequency to its right-hand neighbor one by one, until T is in the appropriate order again. Now, with the proposed PtrB and the block it points to, we can easily determine the index of T which is the destination of swapping the updated frequency. Then, we can update the relevant two blocks and pointer arrays (see Figure 1(d)). Now, based on the situation shown as Figure 1(d), we assume a "4" is removed from A. As shown in Figure 2, we first locate the updated element in T . Then, with the information in its corre- sponding block we know with which it should be swapped. We further check if the updated frequency exists in T before. If it does not we need to create a new block (the case in Figure 2(b)), otherwise another block is modified. Figure 2: Illustration of the proposed data structure for a "remove" action on A. (a) The initial F and T , and the block set. A "4" is going to be deleted from A. (b) With the infor- mation of block and the pointer arrays, the block set can be easily updated to reflect the ordered T . 03130000freq00000133sortedfreq13130000freq10000133sortedfreq(a)(b)(c)(d)03130000freq00000133sortedfreq(1,5,0)(6,6,1)(7,8,3)1313000freq00001133sortedfreq(5,6,1)(7,8,3)(1,4,0)blockblock013130000freq00001133sortedfreq(5,6,1)(7,8,3)13120000freq00001123sortedfreq(1,4,0)(5,6,1)(8,8,3)(7,7,2)(a)(b)(1,4,0)blockblock The whole details of the algorithm for updating the data struc- ture and returning the mode of A is described as Algorithm 1. We assume the data structures (B, FtoS, StoF and PtrB) have been initialized, while Algorithm 1 responds to an event in the log stream and returns the updated mode and frequency. r ← b.r; b.r ← b.r − 1 if b.r < b.l then Delete b end if if r < m and b.f + 1 = PtrB[r + 1].f then PtrB[r] ← PtrB[r + 1] PtrB[r].l ← PtrB[r].l − 1 Create a new block in B and assign it to PtrB[r] PtrB[r] ← (r , r , b.f + 1) Algorithm 1 S-Profile for updating the mode of array Input: A tuple (x, c) in log stream, block set B, pointer arrays FtoT , T toF and PtrB, the length of sorted frequency array m Output: The mode M, and the frequency v. 1: rank ← FtoT[x] 2: b ← PtrB[rank] 3: l ← b.l ; 4: if c is an "add" action then 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: else 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: end if 29: M ← T toF[PtrB[m].l . . . PtrB[m].r] 30: v ← PtrB[m].f PtrB[l] ← PtrB[l − 1] PtrB[l].r ← PtrB[l].r + 1 Create a new block in B and assign it to PtrB[l] PtrB[l] ← (l, l, b.f − 1) end if if l > 1 and b.f − 1 = PtrB[l − 1].f then else end if else end if b.l ← b.l + 1 if b.r < b.l then Delete b /* It's a "remove" action */ As the proposed data structure maintains the sorted frequency array, it can be utilized to calculate the object with the minimum frequency (maybe a negative number) as well. We just need to replace Step 29 and 30 in Algorithm 1 with the following steps. 29a: M ← T toF[PtrB[1].l . . . PtrB[1].r] 30a: v ← PtrB[1].f We can observe that the time complexity of the S-Profile algo- rithm is O(1), as there is no iteration at all. The space complexity is O(m), where m is the maximum number of objects in the log stream. Precisely, it needs 3m integers to store the pointer arrays and an additional storage for B. In the worst case B includes m blocks, but usually this number is much smaller than m. Other queries on statistics of objects can also be answered. For example, the top-K order element is that whose frequency is the K-th largest. We can just use PtrB[m − K + 1] to locate the block. Then, the frequency and object id can be obtained with block's member and the T toF array. Especially, the median in frequency can be located with the K/2-th element of the PtrB array. 2.3 Possible Applications For some mission-critical tasks (e.g., fraud detection) in big graphs, the efficiency to make decisions and infer interesting patterns is crucial. As a result, recent years have witnessed an increasing in- terest in heuristic "shaving" algorithms with low computational complexity [9, 14]. A critical step of them is to keep finding low- degree nodes at every time of shaving nodes from a graph. Thus, S-Profile can be plugged into such algorithms for further speedup, by treating a node as an object and its degree as frequency. Furthermore, S-Profile can also deal with a sliding window on a log stream, by letting every tuple (xi , ci) outdated from the window be a new incoming tuple (xi , ¯ci), where ¯ci is the opposite action of ci. 3 EXPERIMENTAL RESULTS We have implemented the proposed S-Profile algorithm and its counterparts in C++, and tested them with randomly generated log streams. The streams are produced with the following steps. We first randomly generate an "add" or "remove" action, with 70% and 30% probabilities respectively. Then, for each "add" ac- tion we randomly choose an object id according to a probability distribution (called posPDF). For each "remove" action another distribution (called negPDF) is used to randomly choose an object id. With this procedure, we obtained three test log streams: • Stream1: both posPDF and negPDF are uniform random distribution on [1, m]. • Stream2: both posPDF and negPDF are normal distribu- tions with µ = 2m/3, m/3 and σ = m/6, m/6, respectively. • Stream3: posPDF is a normal distribution (µ = 4m/5, σ = m), while negPDF is a lognormal distribution (µ = 3m/5, σ = m). In the following subsections, we first compare the proposed S-Profile with the heap based approach, for updating the mode and frequency. Then, the comparison with the balanced tree is presented for calculating the median. All experiments are carried out on a Linux machine with Intel Xeon E5-2630 CPUs (2.30 GHz). The CPU time (in second) of different algorithms are reported. 3.1 Comparison with the Heap Heap is a kind of binary tree where the value in parent node must be larger or equal to the values in its children. Used to maintain the sorted frequency array, it is easy to obtain the mode (the root has the largest frequency). Noticed the balanced tree is inferior to the heap for calculating the mode. In Figure 3, we show the CPU time consumed for updating the mode with the heap based method and our S-Profile. The x-axis means the number of Figure 3: CPU time of the heap based method and our method for calculating the mode (m = 108). processed tuples (n). From the results we see that our method is at least 2.2X faster than the heap based method. Another experiment is carried out to fix n = 108 while varying m. The results shown in Figure 4 also reveal that our S-Profile is at least 2X faster. Figure 4: CPU time of the heap based method and our method for calculating the mode (n = 108). Figure 5: The trends of CPU time for varied m (n = 108). For different kind of log stream, the performance of the heap based method varies a lot. For the worst case updating the heap needs O(log m) time, despite this rarely happens in our tested screams. On the contrary, S-Profile needs O(1) time for updating the data structure. This advantage is verified by the rather flat trend shown in Figure 5. It should be emphasized that, in addition to the speedup to the heap based method, our S-Profile possesses the advantage of wider applicability. Our method is not restricted to calculating the mode and corresponding frequency. As it well profiles the sorted frequency array, with it answering the queries on top-K and other statistics of objects is trivial and fast. 3.2 Comparison with the Balanced Tree The proposed S-Profile can also calculate the median of the dy- namic array. We compare it with the balanced tree based method implemented in the GNU C++ PBDS [16], which is more efficient than our implementation of balanced tree. The trends of CPU time are shown in Figure 6. They show that the runtime of the proposed S-Profile increases much less than that of the balanced tree based method when m increases. We can observe that the time of S-Profile is linearly depends on n, the number of modi- fications on array A, and hardly varies with different m. On the contrary, the balanced tree based method exhibits superlinearly increase whether with n or m. Overall, the test results show that S-Profile is from 13X to 452X faster than the balanced tree based method on updating the median of the dynamic array. Figure 6: Comparison of the balanced tree based method and the proposed algorithm for calculating the median. Left: Trend of CPU time vs. n (m = 106). Right: Trend of CPU time vs. m (n = 106). 4 CONCLUSIONS We propose an accurate algorithm, S-Profile, to fast keep profiling the dynamic array from online systems. It has the following advantages: - Optimal efficiency: S-Profile needs O(1) time complexity for every updating of a dynamic array, and totally linear complexity in memory. - Querying Statistics: With profiling, we can answer the statistical queries in a trivial and fast way. - Applicable: S-Profile can be plugged into most of log streams, and heuristic graph mining algorithms. REFERENCES [1] A. Arasu and G. S. Manku. 2004. Approximate counts and quantiles over sliding windows. In Proceedings of the 23 ACM Symposium on Principles of Database Systems (PODS). 286 -- 296. [2] B. Babcock, M. Datar, and R. Motwani. 2002. Sampling from a moving window over streaming data. In Proceedings of the 13th annual ACM-SIAM Symposium on Discrete Algorithms (SODA). 633 -- 634. [3] R. S. Boyer and J. S. Moore. 1991. MJRTY -- A fast majority vote algorithm. In Automated Reasoning. Springer, 105 -- 117. [4] T. M. Chan, S. Durocher, K. G. Larsen, J. Morrison, and B. T. Wilkinson. 2014. Linear-space data structures for range mode query in arrays. Theory of Com- puting Systems 55, 4 (2014), 719 -- 741. [5] M. Datar, A. Gionis, P. Indyk, and R. Motwani. 2002. Maintaining stream statistics over sliding windows. SIAM J. Comput. 31, 6 (2002), 1794 -- 1813. [6] M. Dietz and G. Pernul. 2018. Big log data stream processing: Adapting an anomaly detection technique. In International Conference on Database and Expert Systems Applications. 159 -- 166. [7] D. Dobkin and J. I. Munro. 1980. Determining the mode. Theoretical Computer Science 12, 3 (1980), 255 -- 263. [8] P. B. Gibbons and S. Tirthapura. 2002. Distributed streams algorithms for sliding windows. In Proceedings of the 14th annual ACM Symposium on Parallel Algorithms and Architectures (SPAA). 63 -- 72. [9] B. Hooi, H. A. Song, A. Beutel, N. Shah, K. Shin, and C. Faloutsos. 2016. Fraudar: Bounding graph fraud in the face of camouflage. In Proceedings of International Conference on Knowledge Discovery and Data Mining (KDD). 895 -- 904. [10] D. Krizanc, P. Morin, and M. Smid. 2005. Range mode and range median queries on lists and trees. Nordic Journal of Computing 12, 1 (2005), 1 -- 17. [11] X. Lin, H. Lu, J. Xu, and J. X. Yu. 2004. Continuously maintaining quantile summaries of the most recent n elements over a data stream. In Proceedings of the 20th International Conference on Data Engineering (ICDE). 362. [12] A. Lubiw and A. Rácz. 1991. A lower bound for the integer element distinctness problem. Information and Computation 94, 1 (1991), 83 -- 92. [13] H. Petersen and S. Grabowski. 2009. Range mode and range median queries in constant time and sub-quadratic space. Inform. Process. Lett. 109, 4 (2009), 225 -- 228. [14] K. Shin, B. Hooi, J. Kim, and C. Faloutsos. 2017. DenseAlert: Incremental dense-subtensor detection in tensor streams. In Proceedings of International Conference on Knowledge Discovery and Data Mining (KDD). 1057 -- 1066. [15] J. M. Steele and A. C. Yao. 1982. Lower bounds for algebraic decision trees. Journal of Algorithms 3, 1 (1982), 1 -- 8. https://gcc.gnu.org/onlinedocs/libstdc++/ext/pb_ds/ [16] A. Tavory, V. Dreizin, and B. Kosnik. [n. d.]. Policy-Based Data Structures. 246810m107020406080100time (s)Heap (stream1)Ours (stream1)105106107108n10-210-1100101102time (s)Balanced treeOursO(n)105106107108m10-210-1100101102time (s)Balanced treeOursO(m)
1207.5722
1
1207
2012-07-24T15:20:22
Approximating Minimum-Cost Connected T-Joins
[ "cs.DS" ]
We design and analyse approximation algorithms for the minimum-cost connected T-join problem: given an undirected graph G = (V;E) with nonnegative costs on the edges, and a subset of nodes T, find (if it exists) a spanning connected subgraph H of minimum cost such that every node in T has odd degree and every node not in T has even degree; H may have multiple copies of any edge of G. Two well-known special cases are the TSP (|T| = 0) and the s-t path TSP (|T| = 2). Recently, An, Kleinberg, and Shmoys [STOC 2012] improved on the long-standing 5/3-approximation guarantee for the latter problem and presented an algorithm based on LP rounding that achieves an approximation guarantee of (1+sqrt(5))/2 < 1.6181. We show that the methods of An et al. extend to the minimum-cost connected T-join problem. They presented a new proof for a 5/3-approximation guarantee for the s-t path TSP; their proof extends easily to the minimum-cost connected T-join problem. Next, we improve on the approximation guarantee of 5/3 by extending their LP-rounding algorithm to get an approximation guarantee of 13/8 = 1.625 for all |T| >= 4. Finally, we focus on the prize-collecting version of the problem, and present a primal-dual algorithm that is "Lagrangian multiplier preserving" and that achieves an approximation guarantee 3 - 2/(|T|-1) when |T| >= 4. Our primal-dual algorithm is a generalization of the known primal-dual 2-approximation for the prize-collecting s-t path TSP. Furthermore, we show that our analysis is tight by presenting instances with |T| >= 4 such that the cost of the solution found by the algorithm is exactly 3 - 2/(|T|-1) times the cost of the constructed dual solution.
cs.DS
cs
Approximating Minimum-Cost Connected T -Joins Joseph Cheriyan∗ Zachary Friggstad† Zhihan Gao‡ May 23, 2018 Abstract We design and analyse approximation algorithms for the minimum-cost connected T -join problem: given an undirected graph G = (V, E) with nonnegative costs on the edges, and a set of nodes T ⊆ V , find (if it exists) a spanning connected subgraph H of minimum cost such that every node in T has odd degree and every node not in T has even degree; H may have multiple copies of any edge of G. Two well-known special cases are the TSP (T = ∅) and the s, t path TSP (T = {s, t}). Recently, An, Kleinberg, and Shmoys [STOC 2012] improved on the long-standing 5 3 approximation guarantee for the latter problem and presented an algorithm based on LP rounding that achieves an approximation guarantee of 1+√5 2 ≈ 1.61803. We show that the methods of An et al. extend to the minimum-cost connected T -join prob- lem. They presented a new proof for a 5 3 approximation guarantee for the s, t path TSP; their proof extends easily to the minimum-cost connected T -join problem. Next, we improve on the approximation guarantee of 5 3 by extending their LP-rounding algorithm to get an approxima- tion guarantee of 13 8 = 1.625 for all T ≥ 4. Finally, we focus on the prize-collecting version of the problem, and present a primal-dual algorithm that is "Lagrangian multiplier preserving" and that achieves an approximation guar- antee of 3 − 2 T−1 when T ≥ 4. Our primal-dual algorithm is a generalization of the known primal-dual 2-approximation for the prize-collecting s, t path TSP. Furthermore, we show that our analysis is tight by presenting instances with T ≥ 4 such that the cost of the solution found by the algorithm is exactly 3 − 2 T−1 times the cost of the constructed dual solution. Keywords: approximation algorithms, LP rounding, primal-dual method, prize-collecting problems, T -joins, Traveling Salesman Problem, s, t-path TSP. 2 1 0 2 l u J 4 2 ] S D . s c [ 1 v 2 2 7 5 . 7 0 2 1 : v i X r a ∗([email protected]) Dept. of Comb. & Opt., University of Waterloo, Waterloo, Ontario N2L3G1, Canada. †([email protected]) Dept. of Comb. & Opt., University of Waterloo, Waterloo, Ontario N2L3G1, Canada. ‡([email protected]) Dept. of Comb. & Opt., University of Waterloo, Waterloo, Ontario N2L3G1, Canada. 1 Introduction The Traveling Salesman Problem (TSP) and its variants, especially the s, t path TSP, are currently attracting substantial research interest. We focus on a generalization that captures the TSP and the s, t path TSP. Let G = (V, E) be an undirected graph with nonnegative costs ce on the edges e ∈ E and let T be a subset of V . A T -join is a multiset of edges J of G such that the set of nodes with odd degree in the graph H = (V, J) is precisely T , that is, a node v ∈ V has degJ (v) odd if and only if v ∈ T , [7, 16]. A (spanning) connected T -join is a multiset of edges F of G such that the graph H = (V, F ) is connected and T is the set of nodes with odd degree in H, that is, a node v ∈ V has degF (v) odd if and only if v ∈ T . Clearly, we may (and we shall) assume that G is connected and that T is even, otherwise, no connected T -join exists; moreover, we may assume that each edge of G occurs with multiplicity zero, one, or two in H, otherwise, we may remove two copies of an edge from H while preserving the connected T -join property. In the minimum-cost connected T -join problem, the goal is to find a connected T -join of minimum cost. Two well-known special cases are the TSP (T = ∅), and the s,t path TSP (T = {s, t}). By a metric graph G we mean a complete graph on V (G) such that the edge costs satisfy the triangle inequality. The metric completion of a graph G is given by the complete graph on V (G) with the cost of any edge vw equal to the cost of a shortest v, w path of G. It can be seen that G has a connected T -join of cost at most γ if and only if the metric completion has a connected T -join of cost at most γ. Thus, we may assume that the given graph G is a metric graph. Christofides presented an algorithm for the (metric) TSP that achieves an approximation guar- antee of 3 2 , [6], and this is the best result known for this problem. Hoogeveen [10] extended the algorithm and its analysis to the s, t path TSP, and proved an approximation guarantee of 5 3 . Re- cently, An, Kleinberg, and Shmoys [1] improved on this long-standing 5 3 approximation guarantee and presented an algorithm that achieves an approximation guarantee of 1+√5 2 ≈ 1.61803. To the best of our knowledge, there is only one previous result on approximating min-cost connected T -joins: Sebo and Vygen [15] present a very nice 3 2 -approximation algorithm for unweighted graphs (each edge has unit cost); in this context, we mention that the input graph cannot be assumed to be a metric graph. Sebo and Vygen [15] were motivated in part by previous advances on the special case of T = ∅ (namely, the graphic TSP) by Oveis Gharan, Saberi and Singh [14], Momke and Svensson [12], and Mucha [13]; in fact, Sebo and Vygen [15] achieve an approximation guarantee of 7 5 = 1.4 for this special case. All of our algorithms follow the plan of Christofides' algorithm: first, compute an appropriate tree, then, compute a D-join of minimum cost, where D denotes the set of nodes that have the "wrong degree" in the tree; finally, return the union of the tree and the D-join. (Here, a D-join means a multiset of edges E′ such that D is the set of nodes of odd degree in (V, E′); throughout the paper, we use "T " and "T -join" as in the abstract, that is, T denotes a set of nodes specified in the input; we use a symbol different from T for a join with respect to some auxiliary set of nodes.) We show that the methods of An et al. extend to the minimum-cost connected T -join problem. They presented a new proof for a 5 3 approximation guarantee for the s, t path TSP; in Section 3, we show that their proof extends easily to the minimum-cost connected T -join problem. More interestingly, in Section 4, we generalize the main result of An et al. to obtain an approximation guarantee of 13 3 for T ≥ 4. Our analysis uses some new methods over that of An et al. and we elaborate in the next subsection. 8 = 1.625 < 5 1 Our second batch of results pertain to the following prize-collecting version of the problem: in addition to the graph G = (V, E) and the edge costs c, there is a nonnegative penalty π(v) for each node v ∈ V \ T ; the goal is to find I ⊆ V \ T and a connected T -join F of the graph G \ I such that c(F ) + π(I) is minimized. The special case of the prize-collecting TSP (T = ∅) has been extensively studied for over 20 years, starting with Balas [3], and an approximation guarantee of 1.91457 has been presented by Goemans [8]; also see Archer et al. [2]. The special case of the prize-collecting s, t path TSP (T = {s, t}) has also been studied, and An et al. [1] present an approximation guarantee of 1.9535. We focus on the general problem (prize-collecting connected T -join) and present a primal-dual algorithm that achieves an approximation guarantee of 3 − 2 T−1 when T ≥ 4. Our primal-dual algorithm may be viewed as a generalization of the known primal-dual 2-approximation for the prize-collecting s, t path TSP by Chaudhuri et al. [5], and we also match their approximation guarantee of 2 for T = 2. Furthermore, we show that our analysis is tight by presenting instances with T ≥ 4 such that the cost of the solution found by the algorithm is exactly 3 − 2 T−1 times the cost of the constructed dual solution. In fact, the total penalty of the set of isolated nodes I in the solution found by our algorithm is at most one times the penalty incurred by the LP solution. Thus, our algorithm has the "Lagrangian Multiplier Preserving" property; this property is useful for the design and analysis of approximation algorithms for cardinality-constrained versions of problems. Our algorithm and analysis follow Chaudhuri et al. [5], and also we follow the well-known method of Goemans and Williamson [9] for the prize-collecting Steiner tree problem. One key difference comes from the cost analysis for the D-join, where D denotes the set of nodes that have the wrong degree in the tree computed by the algorithm. A simple analysis of the cost of this D-join results in an approximation guarantee of 4 − O(T −1). To get the improved approximation guarantee, our analysis has to go beyond the standard methods used for analysing the approximation guarantee of primal-dual algorithms. Most of our notation is standard, and follows Schrijver [16]; Section 2 has a summary of our notation. 1.1 New Contributions on Min-Cost Connected T -Joins This subsection discusses the main points of difference between our analysis and that of An et al. Our algorithm and analysis follow that of An et al. at a high level. The algorithm solves an LP relaxation, and using the optimal solution x∗ of the LP, it samples a random spanning tree J, and then computes a min-cost D-join, where D is the set of nodes of the wrong degree in J. The analysis hinges on constructing a fractional D-join (a solution to an LP formulation of the D-join problem) of low cost to "fix" the wrong-degree nodes in J. We construct the fractional D-join as y := α · χ(J) + β · x∗ + z where χ(J) is the 0-1 incidence vector for the edges of J, z is some "correction" vector (described in Section 4.4), and α and β are carefully chosen (scalar) values. By the integrality of the D-join polyhedron, the cheapest D-join has cost at most the cost of y. By linearity of expectation, the expected cost of y is less than or equal to α + β times the cost of x∗ plus the expected cost of z. It turns out that the correction vector z is needed only for a special type of cut, the so-called τ -narrow cuts: these are given by T -odd sets U such that x∗(δ(U )) < 1 + τ . When T = 2, as in An et al. [1], it turns out that (the node sets of) the τ -narrow cuts form a nested family U1 ⊂ U2 ⊂ · · · ⊂ Ui ⊂ . . . . This is no longer 2 true for T ≥ 4, and hence, the analysis of the correction vectors by An et al. does not apply when T ≥ 4. We prove that the τ -narrow cuts form a laminar family when T ≥ 4. Moreover, in contrast with An et al., our analysis hinges on the "partition inequalities" that are satisfied by spanning trees and fractional spanning trees such as x∗, namely, every partition P = {P1, . . . , Pk} of the node set into nonempty sets satisfies x∗(δ(P1, . . . , Pk)) ≥ k − 1. In our application, we are given a subfamily of τ -narrow cuts from the laminar family of τ -narrow cuts, and we have to obtain a partition of the nodeset V into nonempty sets that correspond to the given subfamily. It is not clear that this holds for τ close to 1, but, we prove that it holds for τ ≤ 1 2 . To complete the analysis, we have to fix α, β and τ subject to several constraints, and we have 2 , and this gives α = 1 5 , 8 cost(x∗) on the expected cost of the fractional D-join, and 8 = 1.625. We have an example for T = 4 showing to minimize the expected cost of the fractional D-join. We choose τ = 1 β = 2 thus we get an approximation guarantee of 13 that 1 2 is the optimal value for τ for our methods; see Section 4.3. 5 ; moreover, we get a bound of 5 2 Preliminaries We first establish some notation. Given a multiset of edges F , we use c(F ) to denote the cost of e ce; here, µF e denotes the number of copies of the edge e in F . F ; thus, c(F ) =Pe µF For any set of edges F of G, we use χ(F ) to denote the zero-one incidence vector of F , thus, χ(F ) ∈ {0, 1}E, and we use V (F ) to denote the set of incident nodes. For any set of edges F of G and any subset of nodes S, we use F (S) to denote the set of edges of F that have both endpoints in S, and we use δF (S) to denote the set of edges of F that have exactly one endpoint in S. We use the same notation for a multiset of edges. For any set of nodes S, let S denote the complement V \ S. A set of nodes S is called T -even if S ∩ T is even, and it is called T -odd if S ∩ T is odd. Also, we say that a cut δF (S) is T -even (respectively, T -odd) if S is T -even (respectively, S is T -odd). We say that two subsets of nodes R and S cross if R ∩ S, R ∪ S, R \ S and S \ R are all non-empty, proper subsets of V . A family of subsets of V is called laminar if no two of the subsets in the family cross. Equivalently, a family of subsets of V is laminar if for any two subsets R, S in the family, either R and S are disjoint or one contains the other. Let P = {P1, . . . , Pk} be a partition of the nodes of G into nonempty sets P1, . . . , Pk. Then δ(P) denotes the set of edges that have endpoints in different sets in P. For ease of notation, we often identify a tree with its edge-set, e.g., we may use J ⊆ E(G) to denote a spanning tree. Moreover, we may use relaxed notation for singleton sets, e.g., for a node t, we may use V − t instead of V \ {t}. We use the the next fact throughout the paper. It relates the number of odd-degree nodes in a set U ⊆ V and the parity of the cut δ(U ). Lemma 2.1 Let G = (V, E) be a graph, and let T ⊆ V have even size. Let F be a multiset of edges of G, and let D be the set of wrong-degree nodes w.r.t. F , that is, D consists of nodes v ∈ T with degF (v) even and nodes v ∈ V \ T with degF (v) odd. Then, for any U ⊆ V we have (i) δF (U ) ≡ U ∩ D ∩ T + U ∩ D ∩ T (mod 2); (ii) moreover, if U is both T -odd and D-odd, then δF (U ) is even. 3 Proof. First, we prove (i). Summing over the degrees in F of all nodes in U we have the equation Xv∈U∩D∩T δF (v) + Xv∈U∩D∩T δF (v) + Xv∈U∩D∩T δF (v) + Xv∈U∩D∩T δF (v) = 2F (U ) + δF (U ), since each edge in δF (U ) is counted once and each edge in F (U ) is counted twice. Now, the degree, in F , of each node in U ∩ D ∩ T and U ∩ D ∩ T is even and the degree of each node in U ∩ D ∩ T and U ∩ D ∩ T is odd. Then (i) follows by reducing modulo 2. Now, consider (ii). Since U is both T -odd and D-odd, it can be seen that U ∩ D ∩ T and (cid:3) U ∩ D ∩ T have the same parity. Then, by (i), δF (U ) is even. 2.1 An LP Relaxation We will assume that G is a metric graph for both the 5/3-approximation and its improvement. If T = ∅, then any solution F forms an Eulerian graph H = (V, F ); then the standard argument of following an Eulerian walk and shortcutting past repeated nodes yields a Hamiltonian cycle of no greater cost. Otherwise, if T 6= ∅, then the next result shows that there is a minimum-cost solution subgraph H = (V, F ) that is a spanning tree; the proof follows by generalizing the notion of shortcutting an Eulerian walk. Proposition 2.2 Let G = (V, E) be a metric graph, and let T ⊆ V have even cardinality. Assume that T 6= ∅. Given a connected T -join F , we can efficiently find a spanning tree of G of cost ≤ c(F ) that is also a connected T -join. Proof. Let F be a connected T -join in G. Suppose that either F has multiple copies of an edge of G or F is not acyclic. Then we give a procedure for finding a connected T -join of smaller size and no greater cost. This procedure can be repeated until we find a connected T -join that is simple and has no cycles. Let C := v1v2, v2v3, . . . , vk−1vk, vkv1 be a cycle in F for k ≥ 2, where the case k = 2 means we are considering two copies of an edge v1v2 in F . We first claim that there is another edge in F apart from v1v2, . . . , vk−1vk, vkv1 that has at least one of these vi as its end node. If V \ {v1, . . . , vk} 6= ∅ then this is true because F is a connected T -join. Otherwise, vi ∈ T for some 1 ≤ i ≤ k since T 6= ∅. But vi has degree two using the edges in C and odd degree in the T -join F , so there is some edge in F incident to vi that has not been included in C. Suppose uvi is an edge in F that is not listed among the edges in C. Remove uvi and vivi+1 from F and add uvi+1 to F (where we let vi+1 denote v1 if i = k). If u = vi+1, then we simply remove uvi and vivi+1 without adding any edges. Denote the resulting multiset of edges by F ′. By the triangle inequality, we have c(F ′) ≤ c(F ). The parity of the degrees of the nodes does not change, so F ′ is still a T -join. Furthermore, we claim that the graph H = (V, F ′) is connected. To see this, observe that H = (V, F ′) has a walk W ′ between a pair of nodes v, w if and only if (V, F ) has a walk W between v, w, because any occurrence of vivi+1 in W could be replaced by the sequence of edges given by C \ {vivi+1}, similarly, uvi could be replaced by uvi+1, C \ {vivi+1}, and any occurrence of uvi+1 in W ′ could be replaced by uvi, vivi+1. This completes the proof: in a metric graph, given a connected T -join that has cycles or multi- (cid:3) edges, we can find a connected T -join of smaller size and no greater cost, assuming T 6= ∅. 4 Let F be a connected T -join and consider any T -even subset of nodes S. Observe that δF (S) is even; this follows by applying Lemma 2.1 to F and noting that the set of wrong-degree nodes D is empty. This fact and Proposition 2.2 lead to our linear programming relaxation (L.P.1) for the minimum-cost connected T -join problem. The optimal value of (L.P.1) gives a lower bound on the minimum cost of a connected T -join, because there exists an optimal connected T -join whose incidence vector satisfies all the constraints of (L.P.1). (L.P.1) minimize : Pe∈E cexe subject to : x(E(S)) ≤ S − 1 ∀S ( V, S ≥ 2 x(E(V )) = V − 1 x(δ(S)) ≥ 2 xe ≥ 0 ∀∅ ( S ( V, S ∩ T even ∀e ∈ E The preceding discussion shows that the optimal value of this linear program is a lower bound for the optimal cost for the connected T -join problem when T 6= ∅. Using the ellipsoid method, we can solve this linear program efficiently. The first two constraints assert that a feasible solution x must be in the spanning tree polytope and these can be separated over efficiently (see [11]). The last constraints say that the total x-value assigned to edges crossing any particular T -even cut should be at least 2. An efficient separation oracle for these constraints was developed by Barahona and Conforti [4]. Finally, we recall a linear programming formulation for the minimum cost T -join problem, assuming nonnegative costs. The extreme points of this LP are integral, see [16], meaning that the optimal value of this LP is equal to the minimum cost of a T -join. We call any feasible solution to the following linear program a fractional T -join. (L.P.2) minimize : Pe∈E cexe subject to : x(δ(U )) ≥ 1 ∀U ⊆ V, U ∩ T odd xe ≥ 0 ∀e ∈ E 3 A 5 3-Approximation Algorithm Hoogeveen [10] showed that Christofides' 3/2-approximation algorithm for the TSP (the case when T = ∅) extends to give a 5/3-approximation algorithm for the s, t path TSP (the case when T = {s, t}). Later, An, Kleinberg, and Shmoys (AKS) [1] proved that the 5/3-approximation guarantee holds with respect to (the optimal value of) an LP relaxation for the s, t path TSP. It turns out that Christofides' algorithm generalizes to give a 5/3-approximation algorithm for the min-cost connected T -join problem; this is observed in [15]. The (generalized) algorithm first computes a minimum spanning tree J ⊆ E(G). Then let D denote the set of "wrong degree" nodes in J. That is, D consists of the nodes in T that have even degree in J and the nodes in V \ T that have odd degree in J. Let M ⊆ E(G) be a minimum-cost D-join. Then the multiset F = J ∪ M (F has two copies of each edge in J ∩M ) forms a connected T -join. Thus the algorithm is combinatorial and does not require solving any linear programs. The next result uses the method of An et al. to show that the algorithm achieves an approximation guarantee of 5/3 w.r.t. the optimal value of the LP relaxation (L.P.1); we include the proof, since it serves as an introduction to our improved approximation algorithm that is presented in the next section. Theorem 3.1 (An, Kleinberg, and Shmoys [1]) Let x∗ be an optimal solution for the linear programming relaxation of the connected T -join problem, (L.P.1), and let OP TLP denote the opti- mal value Pe∈E cex∗e. Then the solution F computed by the algorithm has cost ≤ 5 3 OP TLP . 5 Let y := 1 3 χ(J) + 1 3 OP TLP . The first two constraints of the linear program ensure that any feasible solution x Proof. is contained in the spanning tree polytope of G, that is, x is a convex combination of zero-one incidence vectors of spanning trees of G, [16]. Let J be a minimum spanning tree; then, we have c(J) ≤ OP TLP . polyhedron, this would show that the cost of the D-join M is ≤ 2 F is ≤ 5 3 x∗; we claim that y is a fractional D-join. By the integrality of the D-join 3 OP TLP , and hence, the cost of To see that y is a fractional D-join, consider any set of nodes U that is D-odd. If U is also T -odd, then Lemma 2.1 part (ii) implies that δJ (U ) is even; moreover, J is connected, hence, δJ (U ) has size ≥ 2. Also, we have x∗(δ(U )) ≥ 1, hence, we have y(δ(U )) ≥ 1. Otherwise, if U is T -even, then x∗(δ(U )) ≥ 2 by the last constraints of the linear program, and J ∩ δ(U ) has size ≥ 1 since J is connected. Thus we have y(δ(U )) ≥ 1 in this case as well. Hence, y(δ(U )) ≥ 1 holds for every D-odd set U ⊆ V , therefore, by (L.P.2), y is a fractional D-join. (cid:3) 4 An Improved Approximation For T ≥ 4 In this section, we improve on the approximation guarantee of 5/3 for the mincost connected T -join problem, by extending the approximation algorithm and analysis by An et al. [1], for the s, t path TSP. We assume T ≥ 4, and we prove an approximation guarantee of 13 8 = 1.625. (We note that the analysis in [1] for the case T = 2 applies also to the linear program (L.P.1); there is a minor difference between the two LP relaxations since (L.P.1) does not have degree constraints for the nodes; but, the degree constraints in their LP are only required in their analysis to show that their LP solution is a convex combination of spanning trees.) Theorem 4.1 There is an algorithm (described in Section 4.1) that finds a connected T -join F of cost at most 13 8 times the optimum value of linear program (L.P.1). 4.1 The Algorithm J1, . . . , Jk and non-negative values λ1, . . . , λk summing to 1 such that x∗ = Pk Let x∗ denote an optimal solution to the linear programming relaxation for the minimum-cost connected T -join problem. The first two constraints of the LP allow us to decompose x∗ as a convex combination of incidence vectors of spanning trees. That is, there exist spanning trees i=1 λi χ(Ji). By Caratheodory's theorem, we may assume k ≤ E + 1 and it is possible to find these spanning trees in polynomial time, [16]. For each spanning tree Ji, let Di denote the set of nodes that have the "wrong" degree in Ji, that is, Di consists of the nodes in T that have even degree in Ji and the nodes in V \ T that have odd degree in Ji. Let Mi be a minimum cost Di-join and let Fi be the multiset formed by the union of Mi and Ji. Clearly, each Fi is a connected T -join. We output the cheapest of these solutions. It is easier to analyze a related randomized algorithm. Rather than trying every tree Ji, our algorithm randomly selects a single tree J by choosing Ji with probability λi. Since the deterministic algorithm tries all such trees, the cost of the solution found by the deterministic algorithm is at most the expected cost of the solution found by this randomized algorithm. Let D denote the set of nodes of wrong degree in J, M denote the minimum-cost D-join, and F denote the (multiset) union of M and J. The randomized algorithm returns F . 6 The expected cost of F is the expected cost of J plus the expected cost of the D-join M . The expected cost of the tree J is precisely the cost of x∗ since each edge e has probability precisely x∗e of appearing in J. We will show that the expected cost of M is at most 5 8 times the cost of x∗. 4.2 Constructing the Fractional D-Join 3 of χ(J) and 1 As in the proof of the 5/3-approximation guarantee, we will construct a fractional D-join. However, instead of using exactly 1 3 of x∗, we will construct the fractional D-join as y := α · χ(J) + β · x∗ + z where x∗ ∈ IRE, z is some "correction" vector in IRE to be described below, and α and β are values which will be specified shortly. Again, by the integrality of the T -join polyhedron, the cost of M will be at most the cost of y. By linearity of expectation, the expected cost of y will be exactly α + β times the cost of x∗ plus the expected cost of z. The following lemma shows that for certain α and β, the correction vector is not needed for many cuts. The proof is similar to a result in [1]. Lemma 4.2 Suppose α + 2β ≥ 1. Then (α · χ(J) + β · x∗)(δ(U )) ≥ 1 if U is either (i) T -even, or (ii) T -odd and D-odd, with x∗(δ(U )) ≥ 1−2α β . First, suppose U is T -even. Then x∗(δ(U )) ≥ 2 by the LP constraints. Since J is Proof. connected, then J ∩ δ(U ) ≥ 1. Therefore, we have α · χ(J)(δ(U )) ≥ α and β · x∗(δ(U )) ≥ 2β; the sum of the two terms is ≥ α + 2β ≥ 1. Now, consider part (ii). Suppose that U is T -odd with x∗(δ(U )) ≥ 1−2α β . Since U is both T -odd and D-odd, Lemma 2.1 part (ii) implies that J ∩ δ(U ) is even; moreover, J is a spanning tree, hence, J has ≥ 2 edges in δ(U ). Consequently, we have α · χ(J)(δ(U )) ≥ 2α, and moreover, β · x∗(δ(U )) ≥ 1 − 2α by the assumption on x∗(δ(U )); the lemma follows, since the sum of the two terms is ≥ 1. (cid:3) It will be convenient to fix a particular nodebt ∈ T . Unless otherwise specified, when discussing a cut of the graph we will take the set S ⊆ V representing the cut to be such that bt 6∈ S, thus the cut will be denoted δ(S), S ⊆ V −bt. As T -odd cuts of the graph that have small x∗ capacity will be used frequently in our analysis, we employ the following definition. Definition 4.3 Let τ ≥ 0. A T -odd subset of nodes S is called τ -narrow if x∗(δ(S)) < 1 + τ . Using this definition, Lemma 4.2 says that if α + 2β ≥ 1 with both α, β ≥ 0, then the vector α·χ(J)+β·x∗ satisfies all constraints defining the D-join polyhedron except, perhaps, the constraints corresponding to T -odd, τ -narrow cuts for τ ≥ 1−2α β − 1. An et al. in [1], proved that if R and S are distinct τ -narrow, T -odd cuts then either S ⊂ R or R ⊂ S. A generalization of this result to connected T -joins is the following. Lemma 4.4 If τ ≤ 1 and R and S are distinct τ -narrow cuts, then R and S do not cross. Proof. Assume, for the sake of contradiction, that R and S cross. There are two cases to consider, depending on the cardinality of R ∩ S ∩ T . If R ∩ S ∩ T is odd, then R \ S and S \ R are nonempty, proper subsets of V that have even intersection with T . But then we have 2 + 2τ > x∗(δ(R)) + x∗(δ(S)) ≥ x∗(δ(R \ S)) + x∗(δ(S \ R)) ≥ 2 + 2, 7 where the last inequality follows from the LP constraints applied to the T -even sets R \ S and S \ R. However, this contradicts τ ≤ 1. If, on the other hand, R ∩ S ∩ T is even, then R ∩ S and R ∪ S are nonempty, proper subsets of V that have even intersection with T . A similar contradiction can be reached in this case using the inequality x∗(δ(R)) + x∗(δ(S)) ≥ x∗(δ(R ∩ S)) + x∗(δ(R ∪ S)), where we have ∅ 6= R ∩ S, R ∪ S 6= V because R, S cross. (cid:3) Another way to state Lemma 4.4 is that the τ -narrow, T -odd cuts of the graph form a laminar family L of nonempty subsets of V \ {bt}. The correction vector z that we add to α · χ(J) + β · x∗ for the T -odd, τ -narrow cuts can be constructed from the following lemma. The main difference from the analogous result in [1] is that we require a further restriction on the size of τ . Lemma 4.5 Let L = {Ui} be the laminar family of T -odd, τ -narrow cuts. For τ ≤ 1 vectors f U ∈ IRE, one for each cut Ui ∈ L, such that the following three conditions hold. 2 there exists 1. For each U ∈ L, f U ≥ 0 2. PU∈L f U ≤ x∗ 3. For each U ∈ L, f U (δ(U )) ≥ 1 The proof of this lemma is deferred to the next section. Assuming this lemma, we will now 5 and show how to complete the analysis of the algorithm. We now fix τ to be 1 5 . For these choices of parameters, we have α + 2β ≥ 1 and τ = 1−2α β := 2 2 . We also set α := 1 β − 1. We construct the correction vector z by including an appropriate multiple of f U for each D-odd cut U ∈ L. Formally, z = XU∈L (1 − 2α − βx∗(δ(U ))) · f U . U∩D odd Since x∗(δ(U )) < 1 + τ and τ = 1−2α β − 1, we have 1 − 2α − βx∗(δ(U )) ≥ 0 for each U ∈ L which shows z ≥ 0. From this, Lemma 4.2 shows that y(δ(U )) ≥ 1 for each D-odd, T -even cut U and each D-odd, T -odd cut U that is not τ -narrow. Finally, if U is D-odd, T -odd and τ -narrow (so U ∈ L), then f U (δ(U )) ≥ 1 so y(δ(U )) ≥ 2α + βx∗(δ(U )) + (1 − 2α − βx∗(δ(U ))) = 1. Thus, we have proved the next result. Lemma 4.6 The vector y is a fractional D-join. We conclude the analysis by bounding the expected cost of y. The next result states that the probability that a T -odd cut U is also D-odd is ≤ x∗(δ(U )) − 1; this is an immediate extension of a similar statement in [1]. Fact 4.7 Let U be a T -odd set. Suppose that J is a random spanning tree (obtained from x∗ by choosing Ji with probability λi). Then Pr[D ∩ U is odd] ≤ x∗(δ(U )) − 1. Therefore, E[cost(y)] = (α + β) cost(x∗) + XU∈L (1 − 2α − βx∗(U )) · Pr[D ∩ U is odd] · cost(f U ). 8 Now, for each U ∈ L we can bound (1−2α−βx∗(δ(U )))·Pr[D∩U is odd] by (1−2α−βx∗(δ(U )))· (x∗(δ(U )) − 1). This is −2x∗(δ(U ))2+5x∗(δ(U ))−3 2 , the maximum value of this function is achieved at x∗(δ(U )) = 5 . For x∗(δ(U )) bound between 1 and 3 4 and its value is 1 40 . 5 So, the expected cost of y is at most (α+β)·cost(x∗)+ 1 we have the final bound on the expected cost of y being (α + β + 1 expected cost of J, we have that the expected cost of the connected T -join is at most 13 Note that this is strictly less than 5 3 . 40 ) cost(x∗). Adding this to the 8 cost(x∗). 40 ·PU∈L cost(f U ). SincePU∈L f U ≤ x∗, 4.3 Tight Example for τ Here, we present an example for T = 4 showing that 1 2 is the optimal value for τ for our methods. Let G = (V, E) be the complete graph on four nodes K4, and let T = V . It can be seen that 2 , ∀e ∈ E, satisfies all the constraints of the LP relaxation (L.P.1). Choose any x ∈ IRE with xe = 1 one node to be bt; recall that for any cut δ(S) of the graph, we assume that the set S representing the cut is a subset of V −bt. Suppose that we choose a value strictly greater than 1 have four T -odd, τ -narrow cuts, namely, the cuts of the three singletons S = {v}, v ∈ V −bt, and the cut of S = V −bt; each of these cuts δ(S) has x(δ(S)) = 3 2 < 1 + τ . Clearly, Lemma 4.5 does not apply, because the sum of f S(δ(S)) over the four τ -narrow cuts has to be ≥ 4, but we have x(E) = 3, hence, part 2 of Lemma 4.5 cannot hold. On the other hand, the lemma holds for τ = 1 2 . 2 for τ . Then we 4.4 The Correction Vector We complete the analysis by proving Lemma 4.5. As in [1], we set up a flow network and use the max-flow/min-cut theorem to ensure a flow exists with the desired properties. However, our analysis is complicated by the fact that the sets in L are laminar rather than simply nested. Our argument on the existence of the desired flow uses the following inequality for spanning trees. For a connected graph H and a partition of V (H) into k non-empty sets, P = {P1, . . . , Pk}, the number of edges that have endpoints in different sets in P is at least k − 1, that is, δE(H)(P) ≥ k − 1. Thus, as our vector x∗ is a convex combination of (incidence vectors of) spanning trees, we have x∗(δ(P1, . . . , Pk)) ≥ k − 1, for any partition P1, . . . , Pk of V (G) into nonempty sets. Let L′ be a subfamily of L. For U ∈ L′, let gL′(U ) be the nodes in U that are not found in any smaller subset in L′. That is, gL′(U ) = {v ∈ U : v 6∈ W for any W ∈ L′ with W ( U }. The following result is the key to generalizing the argument in [1] to our setting. Proof. Lemma 4.8 Suppose that τ ≤ 1 2 . Let L′ be any subfamily of L. The family of subsets {gL′(U ) : By construction, the sets are disjoint. It remains to prove that each of the sets is nonempty. U ∈ L′} ∪ {V \SW∈L′ W } forms a partition of V , and each such subset is nonempty. Each node v in some subset in the family L′ is in gL′(U ) for some U ∈ L′ since v is "assigned" to the smallest subset of L′ containing v. All other nodes appear in the set V \SW∈L′ W . Sincebt is not in any subset in the family L′, it must be that V \SW∈L′ W 6= ∅. For a set U ∈ L′, let mL′(U ) be the maximal proper subsets of U in the subfamily L′. That is, W ∈ L′ is in mL′(U ) if W ( U and no other subset W ′ ∈ L′ satisfies W ( W ′ ( U . Note that gL′(U ) = U \SW∈mL′ (U ) W and the sets in mL′(U ) are disjoint. 9 For the sake of contradiction, suppose that gL′(U ) = ∅. Then U is the disjoint union of the sets in mL′(U ). Since every set in L′ is T -odd, then mL′(U ) is also odd and we let 2k + 1 = mL′(U ). Note that 2k + 1 ≥ 3 which implies k ≥ 1. Now we examine the quantity X = x∗(δ(U )) +PW∈mL′ (U ) x∗(δ(W )). One the one hand, since U and each W ∈ mL′(U ) are τ -narrow cuts, then X < (1 + τ ) + (2k + 1)(1 + τ ) = (2k + 2)(1 + τ ). On the other hand, we consider the partition P = {W : W ∈ mL′(U )} ∪ {V \ U } of V . We claim that 2x∗(δ(P)) ≤ X. To see this, notice that any edge e with ends in V \ U and W0 for some W0 ∈ mL′(U ) is counted twice in X. (Once for δ(U ) and once for δ(W0).) Similarly, for any edge e with ends in different subsets W0, W1 in mL′(U ) is also counted twice.(Once for δ(W0) and once for δ(W1).) By the partition inequality, we have 2(2k + 1) ≤ 2x∗(δ(P)) ≤ X < (2k + 2)(1 + τ ). Thus, 2(2k + 1) < (2k + 2)(1 + τ ) which implies τ > k (cid:3) Proof of Lemma 4.5 We now finish construction of the vectors f U , U ∈ L by describing the flow network. Create a directed graph with 4 layers of nodes, where the first layer has a single source node vs and the last layer has a single sink node vt. We have a node vU for each τ -narrow cut U ∈ L in the second layer, and a node ve for each edge e ∈ E(G) in the third layer. For each U ∈ L, there is an arc from vs to vU with capacity 1. For each edge e of G, there is an arc from ve to vt with capacity x∗e. Finally, for each U ∈ L and each e ∈ δ(U ) we have an arc from vU to ve with capacity ∞. 2 since k ≥ 1. This contradicts τ ≤ 1 2 . k+1 ≥ 1 We claim that there is a flow from vs to vt that saturates each of the arcs originating from vs; e to e = 0 if e 6∈ δ(U )). We have this is proved below. From such a flow, we construct the vectors f U for U ∈ L by setting f U be the amount of flow sent on the arc from vU to ve (where we use f U f U ≥ 0 and, by the capacities of the arcs entering vt, PU∈L f U ≤ x∗. Finally, since each U ∈ L has the arc from vs to vU saturated by one unit of flow, we have f U (δ(U )) ≥ 1. Thus, the vectors f U , U ∈ L satisfy the requirements of Lemma 4.5. We prove the existence of this flow by the max-flow/min-cut theorem. Let S be any cut with vs ∈ S, vt 6∈ S. If S contains some node vU for U ∈ L but not ve for some e ∈ δ(U ), then the capacity of S is ∞. Otherwise, let LS denote the subfamily of sets U ∈ L such that the node vU representing U is in S. Then the total capacity of the arcs leaving S is at least L − LS + Xe∈δ(U ) for some U∈LS x∗e. each set in PS is nonempty and the sets of PS form a partition of V . Next, we claim that e ∈ δ(PS ) if and only if e ∈ δ(U ) for some U ∈ LS. Consider an edge Consider the collection of sets PS := {gLS (U ), U ∈ LS} ∪ {V \SW∈LS W }. From Lemma 4.8, e ∈ δ(PS ). If one endpoint of e is in V \SW∈LS W , then the other endpoint lies in gLS (U ) where U is the smallest set in LS containing this endpoint. But then e ∈ δ(U ) because e has exactly one endpoint in U . Otherwise, e = uv has u ∈ gLS (U ) and v ∈ gLS (W ) for distinct sets U, W ∈ LS. Suppose, without loss of generality, that either U ( W or U ∩ W = ∅. Then by definition of gLS (W ), we cannot have v ∈ U . Therefore, e ∈ δ(U ). Conversely, if e = uv ∈ δ(U ) for some U ∈ LS with, say, u ∈ U , then u lies in gLS (W ) where W is the smallest set in LS containing u. Since W ⊆ U and v 6∈ U , then v must lie in a different set in PS. Thus, e ∈ δ(PS ). 10 This shows Xe∈δ(U ) for some U∈LS x∗e = x∗(PS) ≥ LS, where the inequality holds since PS = LS + 1. Therefore, the capacity of the cut S is at least L. Since this holds for all vs,vt cuts S, then the maximum flow is at least L. Finally, the cut S = {vs} has capacity precisely L so the maximum vs,vt flow saturates all of the arcs exiting vs. (cid:3) 5 Prize-Collecting Connected T -Joins We start with a linear programming relaxation of the prize-collecting problem. For notational convenience, we define a large penalty for each node in T . We also designate an arbitrary node t⋆ ∈ T as the root node. The LP has a variable ZX for each set X ⊆ V − t⋆ such that ZX = 1 indicates that X is the set of isolated nodes of an optimal integral solution; moreover, we have a cut constraint for each nonempty subset S of V − t⋆; the requirement (r.h.s. value) of a cut constraint is 1 or 2, depending on whether the set S is T -odd or T -even. Let Q denote the T -odd subsets of V − t⋆ and let R denote the non-empty, T -even subsets of V − t⋆. Our LP relaxation is stated below. (L.P.3) minimize : Xe subject to : π(X)ZX cexe + XX⊆V −t⋆ x(δ(R)) + XX:X⊇R,X⊆V −t⋆ x(δ(Q)) ≥ 1 ∀ Q ∈ Q 2ZX ≥ 2 ∀ R ∈ R x, Z ≥ 0 Consider any solution to the prize-collecting connected T -join problem. Let I ⊆ V − t⋆ denote the set of isolated nodes and let F denote the connected T -join of G \ I; thus this solution incurs a total cost of c(F ) for the edges in F plus π(I) for the penalties of the nodes in I. We define an integral solution to (L.P.3) by taking ZI = 1, ZS = 0 for all other subsets S ⊆ V − t⋆, and moreover, for each edge e, we take xe to be the number of copies of e used in F . By construction, the cost of this solution (x, Z) is equal to c(F ) + π(I). For every Q ∈ Q, observe that at least one edge of δ(Q) is in F (since F connects the nodes in T ); this justifies the first set of constraints in the LP relaxation. Now, focus on the second set of constraints in the LP relaxation, and consider any one set R ∈ R and its constraint in (L.P.3). If R ⊆ I, then the constraint is satisfied due to the term 2ZI (in the left-hand side of the constraint). Otherwise, if R 6⊆ I then at least one edge in δ(R) is in F (since F connects the nodes in {bt} ∪ R \ I); moreover, by Lemma 2.1, δF (R) is even, so at least two edges of δ(R) are in F ; hence, the constraint is satisfied if R 6⊆ I. The above discussion is summarized by the next result. Fact 5.1 The optimal value of (L.P.3) is at most the optimal cost of a prize-collecting connected T -join. The dual of (L.P.3) has a variable yQ for each primal-constraint of the first type, and a variable yR for each primal-constraint of the second type; thus, each T -odd set Q ⊆ V − t⋆ has a dual variable yQ, and each T -even set ∅ ( R ( V − t⋆ has a dual variable yR. 11 (L.P.4) maximize : XQ∈Q subject to : yS ≤ ce ∀ e ∈ E 2yR ≤ π(X) ∀ X ⊆ V − t⋆ 2yR yQ + XR∈R XS∈Q∪R:e∈δ(S) XR⊆X,R∈R y ≥ 0 Consider the dual LP and a feasible solution y; we call an edge e tight if the constraint for e holds with equality, and we call a set of nodes X π-tight if the constraint for X holds with equality. 5.1 The Primal-Dual Algorithm The algorithm proceeds in phases. In each phase, a partition P of V (G) is maintained; some sets in this partition are active and some are inactive. Throughout, the set containing the root, t⋆, is taken to be inactive. The initial partition consists of singletons {v} for every v ∈ V . Each of the sets {v}, v ∈ V − t⋆, is designated as active. We initialize yS := 0 for every subset S of V . Let F denote the set of edges chosen during the growing phase of the algorithm; we initialize F := ∅. Each phase proceeds as follows. We simultaneously raise yS for every active set S in the current (Recall that sets containing t⋆ have no dual variables. Since the partition at a uniform rate. algorithm designates such sets as inactive, it never uses dual variables of such sets.) The phase ends when either (i) an edge becomes tight or (ii) an active subset of nodes S becomes π-tight. If the former occurs, then we pick any edge e = vw that becomes tight; its endpoints v and w must be in different components of the current partition; we add e to F , and we merge the components in the current partition containing v and w; we call the resulting new component inactive if it contains the root, otherwise, we call the new component active. If the latter occurs, that is, if an active subset S ⊆ V in the partition becomes π-tight, then S becomes inactive. The algorithm terminates when there are no remaining active sets. Standard arguments show that the dual solution at the end of the algorithm is feasible and that the set of edges F chosen throughout the algorithm is acyclic. We prune our solution F in the usual way. Namely, we iteratively discard any edge e such that there exists an inclusion-wise maximal set X that was inactive at some point of the algorithm and δ(X) = {e}; moreover, after this stage of pruning, we discard all remaining edges that are not in the component of t⋆. Let J denote the remaining subset of edges. The subgraph that remains after discarding the isolated nodes is a tree J containing the root t⋆. Furthermore, since each node in T has a large penalty, then J contains all nodes in T . Finally, let D ⊆ V (J) denote the set of nodes that have the wrong degree in the tree J. We compute a minimum-cost D-join M and finally, we output J ∪ M as a connected T -join on V (J). Let I denote the set of nodes not included in J, thus I = V \ V (J). 5.2 Analysis of the Primal-Dual Algorithm Our argument for bounding the cost of the tree J and the penalties of the nodes in I is similar to known arguments. A simple way to bound the cost of the D-join M would be to pair the nodes in D using edge-disjoint paths in J, so that adding M to J at most doubles the cost of the set of edges used. However, we can improve on this simple analysis of the cost of the D-join by scrutinizing the analysis of the dual growing phase. The following theorem summarizes the cost bounds. 12 Theorem 5.2 The penalty of the nodes in I is exactly 2XX⊆I yX, the cost of the tree J is ≤(cid:18)2 − 1 T − 1(cid:19) XQ∈Q yQ + 2 XR∈R,R*I yR, and the cost of the D-join M is ≤(cid:18)1 − 1 T − 1(cid:19) XQ∈Q yQ + 2 XR∈R,R*I yR. Let ρ(T ) denote the approximation guarantee of our algorithm; below, we show that ρ(T ) = 3 − 2 T−1 for T ≥ 4, and ρ(2) = 2. Before presenting the proof, we remark that this shows cost(J ∪ M ) + ρ(T ) · π(I) is at most ρ(T ) times the cost of the dual solution y. Proof. The equation for the penalty is standard and follows by construction since I (being the union of the π-tight inactive components that were pruned) is π-tight. The analysis for the cost of J is nearly identical to Goemans and Williamson's analysis [9] and is included in Appendix A for completeness. One minor difference in our analysis comes from the fact that there are at most T components that are T -odd at any point in the execution, and we exploit this fact to derive an approximation guarantee that is tight on some examples. To bound the cost of the D-join M , we consider a possibly different D-join M′ obtained by pairing the nodes in D with edge-disjoint paths in J. Clearly c(M ) ≤ c(M′) so it suffices to bound the cost of M′. Let bJ be the subset of J consisting of edges e such that J \ {e} consists of two D-even components. Note that M′ ∩ bJ = ∅ since, by parity arguments, any D-join must have an even number of edges crossing any D-even cut, and each edge of J is used at most once in M′. The next claim is the key to the improved cost analysis for minimal D-joins. Claim 5.3 Let Q be a T -odd component from any step in the execution of the algorithm. Then at least one of the edges in δJ (Q) belongs to bJ. That is, δM ′(Q) is a proper subset of δJ (Q). Proof of Claim We have two cases to consider, either Q is D-odd or it is D-even. First, suppose Q is D-odd. Then, by Lemma 2.1 part (ii), δJ (Q) is even. Focus on J \ δJ (Q) and observe that it has an odd number of connected components, so at least one of them, say S, must be D-even. Similarly, if Q is D-even, then δJ (Q) is odd. Then J \ δJ (Q) has an even number of connected components, hence, there is another connected component that is D-even, call it S, S 6= Q. Then, (cid:3) Using this, we can bound the cost of M′ in the following way. Thus, the edge in δJ (Q) connecting Q to S is in bJ. the edge between Q and S is in bJ . Xe∈M ′ yQ + XR∈R   XQ∈Qe∈δ(Q) (δJ (Q) − 1)yQ + XR∈R,R*I ce = Xe∈M ′ ≤ XQ∈Q R*I,e∈δ(R) yR   = XQ∈Q δJ (R)yR ≤(cid:18)1 − δM ′(Q)yQ + XR∈R,R*I T − 1(cid:19) XQ∈Q 1 δM ′ (R)yR yQ + 2 XR∈R,R*I yR 13 The first inequality follows from the claim for the T -odd sets in Q and the simple fact that δM ′(R) ⊆ δJ (R) for R ∈ R. The second inequality follows from our analysis of the cost of J in Appendix A. (cid:3) This completes the analysis of the primal-dual algorithm. Our algorithm and analysis are also valid in the case T = 2, and it can be seen that our approximation guarantee for T = 2 is ρ(2) = 2. In fact, our algorithm in this case is essentially identical to the 2-approximation for the prize-collecting s, t path TSP presented in [5]. Our analysis is tight even up to lower-order terms when T ≥ 4. This is realized by a cycle on T , that is, G = (T, E) consists of an even-length cycle with at least 4 nodes. Let t⋆ ∈ T be a designated node and let the edges incident to it have cost 1 2 while all other edges have cost one. The dual growth phase grows y{v} to 1/2 for every singleton v ∈ T − t⋆. The algorithm could find a tree of cost T − 3 2 (by picking all edges of G except one of the two edges incident to t⋆), and then find a D-join of cost T−2 , whereas the connected T -join constructed by the algorithm has cost 3T−5 ; the ratio of these two quantities is exactly 3 − 2 . Observe that the cost of the dual solution is T−1 2 2 2 T−1. 6 Conclusions We presented a 13 8 = 1.625 approximation algorithm for the mincost connected T -join problem whose analysis closely followed the analysis of the s, t path TSP algorithm in [1]. Furthermore, we presented a max{3 − 2 T−1 , 2}-approximation algorithm for a prize-collecting version of the problem; this algorithm is based on the primal-dual method [9] and it is Lagrangian multiplier preserving. Our algorithms in Sections 4 and 5 are based on the LP relaxations (L.P.1) in Section 2 and (L.P.3) in Section 5, respectively. Unfortunately, we do not have tight bounds on the integrality ratios of these LP relaxations. As far as we know, the best lower bound on the integrality ratio of (L.P.1) is 3 2 , and this follows from an example for the s, t path TSP in [1, Figure 1]. Acknowledgements: We thank a number of colleagues for useful discussions; in particular, we thank Jochen Konemann and Chaitanya Swamy. References [1] H.-C.An, R.Kleinberg, and D.B.Shmoys, Improving Christofides' algorithm for the s-t path TSP, In Proc. ACM STOC, 2012. CoRR, abs/1110.4604v2, 2011. [2] 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. [3] E.Balas, The prize-collecting traveling salesman problem, Networks, 19(6):621–636, 1989. [4] F.Barahona and M.Conforti, A construction for binary matroids, Discrete Mathematics, 66(3):213–218, 1987. [5] K.Chaudhuri, B.Godfrey, S.Rao, and K.Talwar, Paths, trees, and minimum latency tours, In Proc. IEEE FOCS, 36–45, 2003. 14 [6] N.Christofides, Worst-case analysis of a new heuristic for the travelling salesman problem, Technical report, Graduate School of Industrial Administration, Carnegie Mellon University, Pittsburgh, PA, 1976. [7] J.Edmonds and E.Johnson, Matching: A well-solved class of integer linear programs, in Pro- ceedings of the Calgary International Conference on Combinatorial Structures and Their Ap- plications, R.Guy et al., eds., Gordon and Breach, 82–92, 1970. [8] M.X.Goemans, Combining aproximation algorithms for the prize-collecting TSP, CoRR, abs/0910.0553, 2009. [9] M.X.Goemans and D.P.Williamson, A general approximation technique for constrained forest problems, SIAM J. Comput., 24(2):296–317, 1995. [10] J.A.Hoogeveen, Analysis of Christofides' heuristic: Some paths are more difficult than cycles, Operations Research Letters, 10:291–295, 1991. [11] L.C.Lau, R.Ravi, and M.Singh, Iterative Methods in Combinatorial Optimization, Cambridge University Press, 2011. [12] T.Momke and O.Svensson, Approximating graphic TSP by matchings, In Proc. IEEE FOCS, 560–569, 2011. [13] M.Mucha, 13/9-approximation for graphic TSP, STACS 2012: 30–41. Improved analysis for graphic TSP approximation via matchings, CoRR abs/1108.1130, 2011. [14] S.Oveis Gharan, A.Saberi, and M.Singh, A randomized rounding approach to the Traveling Salesman Problem, In Proc. IEEE FOCS, 550–559, 2011. [15] A.Sebo and J.Vygen, Shorter tours by nicer ears: 7/5-approximation for graphic TSP, 3/2 for the path version, and 4/3 for two-edge-connected subgraphs, CoRR, abs/1201.1870v2, 2012. [16] A. Schrijver, Combinatorial Optimization: Polyhedra and Efficiency, Algorithms and Combi- natorics, Vol.24, Springer, Berlin, 2003. [17] D.P.Williamson and D.B.Shmoys, The Design of Approximation Algorithms, Cambridge Uni- versity Press, New York, NY, 2011. 15 A Appendix: Analysis of the Dual Growing Phase We bound the cost of J as follows. Xe∈J ce =Xe∈J   XQ∈Qe∈δ(Q) yQ + XR∈R R*I,e∈δ(R) yR   = XQ∈Q δJ (Q)yQ + XR∈RR*I δJ (R)yR The first equation holds because the edges in J are tight. That the inner sum over subsets R ∈ R can be restricted to subsets * I follows because no subset of nodes contributing to the dual constraint for an edge e ∈ J is contained in I. The second equation follows by rearranging the sums. Now consider a step in the execution with corresponding partition P of V (G). Add the edges of J to the graph (V, ∅), and then contract each of the sets S belonging to the partition P. The resulting graph is a tree plus some isolated nodes, because each contracted set S of P induces a tree of (V, F ) and so the subgraph of (V, J) induced by S consists of a tree plus some isolated nodes, inactive sets B with δJ (B) = ∅, but such sets are not relevant for the arguments below). We can see [9, 17]. Let C denote the T -odd active sets in P, let bC denote the T -even active sets in P which are not contained in I, and let bI denote the inactive sets B ∈ P with δJ (B) 6= ∅ (P could contain identify these sets with nodes in the contracted graph. It can be seen that each B ∈ bI, except for one, has degree at least 2 in this contracted graph by our pruning phase; if a set in bI contains the root, then its degree could be one, see [17, Chapter 14.1]. Notice also that C ≤ T − 1 because each T -odd active set must contain a node in T − t⋆. By counting degrees, we have 2C + 2bC + 2bI − 2 = XQ∈C ≥ XQ∈C δJ (Q) +XR∈ bC δJ (Q) +XR∈ bC δJ (R) ≤ 2C + 2bC − 1 ≤(cid:18)2 − δJ (R) + XB∈bI δJ (R) + 2bI − 1, T − 1(cid:19) · C + 2bC, hence, XQ∈C δJ (Q) +XR∈ bC δJ (B) 1 where the last inequality holds because C ≤ T − 1. Suppose that the dual variables of the active sets were raised by ∆ during this phase. Then XQ∈C ∆δJ (Q) +XR∈ bC ∆δJ (R) ≤(cid:18)2 − 1 T − 1(cid:19) ∆C + 2∆bC. Since this holds over each phase of the primal-dual algorithm, then by applying induction on the number of phases in the execution, we have XQ∈Q δJ (Q)yQ + XR∈R,R*I δJ (R)yR ≤(cid:18)2 − 1 T − 1(cid:19) XQ∈Q yQ + 2 XR∈R,R*I yR. This proves the bound on the cost of J. 16
1009.2452
1
1009
2010-09-13T17:04:34
Facility Location with Client Latencies: Linear-Programming based Techniques for Minimum-Latency Problems
[ "cs.DS" ]
We introduce a problem that is a common generalization of the uncapacitated facility location and minimum latency (ML) problems, where facilities need to be opened to serve clients and also need to be sequentially activated before they can provide service. Formally, we are given a set \F of n facilities with facility-opening costs {f_i}, a set of m clients, and connection costs {c_{ij}} specifying the cost of assigning a client j to a facility i, a root node r denoting the depot, and a time metric d on \F\cup{r}. Our goal is to open a subset F of facilities, find a path P starting at r and spanning F to activate the open facilities, and connect each client j to a facility \phi(j)\in F, so as to minimize \sum_{i\in F}f_i +\sum_{clients j}(c_{\phi(j),j}+t_j), where t_j is the time taken to reach \phi(j) along path P. We call this the minimum latency uncapacitated facility location (MLUFL) problem. Our main result is an O(\log n\max{\log n,\log m})-approximation for MLUFL. We also show that any improvement in this approximation guarantee, implies an improvement in the (current-best) approximation factor for group Steiner tree. We obtain constant approximations for two natural special cases of the problem: (a) related MLUFL (metric connection costs that are a scalar multiple of the time metric); (b) metric uniform MLUFL (metric connection costs, unform time-metric). Our LP-based methods are versatile and easily adapted to yield approximation guarantees for MLUFL in various more general settings, such as (i) when the latency-cost of a client is a function of the delay faced by the facility to which it is connected; and (ii) the k-route version, where k vehicles are routed in parallel to activate the open facilities. Our LP-based understanding of MLUFL also offers some LP-based insights into ML, which we believe is a promising direction for obtaining improvements for ML.
cs.DS
cs
Facility Location with Client Latencies: Linear-Programming based Techniques for Minimum-Latency Problems Deeparnab Chakrabarty∗ Chaitanya Swamy† Abstract We introduce a problem that is a common generalization of the uncapacitated facility location (UFL) and minimum latency (ML) problems, where facilities not only need to be opened to serve clients, but also need to be sequentially activated before they can provide service. This abstracts a setting where inventory demanded by customers needs to be stocked or replenished at facilities from a depot or warehouse. Formally, we are given a set F of n facilities with facility-opening costs {fi}, a set D of m clients, and connection costs {cij} specifying the cost of assigning a client j to a facility i, a root node r denoting the depot, and a time metric d on F ∪ {r}. Our goal is to open a subset F of facilities, find a path P starting at r and spanning F to activate the open facilities, and connecting each client j to a facility φ(j) ∈ F , P . We call this the minimum latency uncapacitated facility location (MLUFL) problem. so as to minimize Pi∈F fi + Pj∈D(cφ(j),j + tj), where tj is the time taken to reach φ(j) along path Our main result is an O(cid:0)log n max{log n, log m}(cid:1)-approximation for MLUFL. Via a reduction to the group Steiner tree (GST) problem, we show this result is tight in the sense that any improvement in the approximation guarantee for MLUFL, implies an improvement in the (currently known) approximation factor for GST. We obtain significantly improved constant approximation guarantees for two natural special cases of the problem: (a) related MLUFL, where the connection costs form a metric that is a scalar multiple of the time metric; (b) metric uniform MLUFL, where we have metric connection costs and the time-metric is uniform. Our LP-based methods are fairly versatile and are easily adapted with minor changes to yield approximation guarantees for MLUFL (and ML) in various more general settings, such as (i) the setting where the latency-cost of a client is a function (of bounded growth) of the delay faced by the facility to which it is connected; and (ii) the k-route version, where we can dispatch k vehicles in parallel to activate the open facilities. Our LP-based understanding of MLUFL also offers some LP-based insights into ML. We obtain two natural LP-relaxations for ML with constant integrality gap, which we believe shed new light upon the problem and offer a promising direction for obtaining improvements for ML. 1 Introduction Facility location and vehicle routing problems are two broad classes of combinatorial optimization problems that have been widely studied in the Operations Research community (see, e.g., [25, 32]), and have a wide range of applications. Both problems can be described in terms of an underlying set of clients that need to be serviced. In facility location problems, there is a candidate set of facilities that provide service, and the goal is to open some facilities and connect each client to an open facility so as to minimize some combination of the facility-opening and client-connection costs. Vehicle routing problems consider the setting where a vehicle (delivery-man or repairman) provides service, and the goal is to plan a route that visits (and hence services) the clients as quickly as possible. Two common objectives considered are: (i) minimize the total ∗[email protected]. Dept. of Computer and Information Science, Univ. of Pennsylvania, Philadelphia, PA 19104. Most of the work was done as a postdoctoral fellow at the Dept. of Combinatorics and Optimization, Univ. Waterloo. †[email protected]. Dept. of Combinatorics and Optimization, Univ. Waterloo, Waterloo, ON N2L 3G1. Supported in part by NSERC grant 327620-09 and an Ontario Early Researcher Award. 1 length of the vehicle's route, giving rise to the traveling salesman problem (TSP), and (ii) (adopting a client- oriented approach) minimize the sum of the client delays, giving rise to minimum latency (ML) problems. These two classes of problems have mostly been considered separately. However, various logistics problems involve both facility-location and vehicle-routing components. For example, consider the follow- ing oft-cited prototypical example of a facility location problem: a company wants to determine where to open its retail outlets so as to serve its customers effectively. Now, inventory at the outlets needs to be replenished or ordered (e.g., from a depot); naturally, a customer cannot be served by an outlet unless the outlet has the inventory demanded by it, and delays incurred in procuring inventory might adversely impact customers. Hence, it makes sense for the company to also keep in mind the latencies faced by the customers while making its decisions about where to open outlets, how to connect customers to open outlets, and in what order to replenish the open outlets, thereby adding a vehicle-routing component to the problem. We propose a mathematical model that is a common generalization of the uncapacitated facility location (UFL) and minimum latency (ML) problems, and abstracts a setting (such as above) where facilities need to be "activated" before they can provide service. Formally, as in UFL, we have a set F of n facilities, and a set D of m clients. Opening facility i incurs a facility-opening cost fi, and assigning a client j to a facility i incurs connection cost cij. Taking a lead from minimum latency problems, we model activation delays as follows. We have a root (depot) node r, and a time metric d on F ∪ {r}. A feasible solution specifies a subset F ⊆ F of facilities to open, a path P starting at r and spanning F along which the open facilities are activated, and assigns each client j to an open facility φ(j) ∈ F . The cost of such a solution is Xi∈F fi + Xj∈D(cid:0)cφ(j)j + tj(cid:1) (1) where tj = dP (r, φ(j)) is the time taken to reach facility φ(j) along path P . We refer to tj as client j's latency cost. The goal is to find a solution with minimum total cost. We call this the minimum-latency uncapacitated facility location (MLUFL) problem. Apart from being a natural problem of interest, we find MLUFL appealing since it generalizes, or is closely-related to, various diverse problems of interest (in addition to UFL and ML); our work yields new insights on some of these problems, most notably ML (see "Our results"). One such problem, which captures much of the combinatorial core of MLUFL is what we call the minimum group latency (MGL) problem. Here, we are given an undirected graph with metric edge weights {de}, subsets {Gj } of vertices called groups, and a root r; the goal is to find a path starting at r that minimizes the sum of the cover times of the groups, where the cover time of Gj is the first time at which some i ∈ Gj is visited on the path. Observe that MGL can be cast as MLUFL with zero facility costs (where F = node-set \ {r}), where for each group Gj, we create a client j with cij = 0 if i ∈ Gj and ∞ otherwise. Note that we may assume that the groups are disjoint (by creating multiple co-located copies of a node), in which case these cijs form a metric. MGL itself captures various other problems. Clearly, when each Gj is a singleton, we obtain the minimum latency problem. Also, given a set-cover instance, if we consider a graph whose nodes are (r and) the sets, create a group Gj for each element j consisting of the sets containing it, and consider the uniform metric, then this MGL problem is simply the min-sum set cover (MSSC) problem [16]. Our results and techniques. Our main result is an O(cid:0)log n max{log m, log n}(cid:1)-approximation algorithm for MLUFL (Section 2.1), which for the special case of MGL, implies an O(log2 n) approximation. Com- plementing this result, we prove (Theorem 2.9) that a ρ-approximation algorithm (even) for MGL yields an O(ρ log m)-approximation algorithm for the group Steiner tree (GST) problem [17] on n nodes and m groups. Thus, any improvement in our approximation ratio for MLUFL would yield a corresponding improvement of GST, whose approximation ratio has remained at O(log2 n log m) for a decade [17]. More- over, combined with the result of [22] on the inapproximability of GST, this shows that MGL, and hence MLUFL with metric connection costs cannot be approximated to better than a Ω(log m)-factor unless NP ⊆ ZTIME (npolylog(n)). 2 Given the above hardness result, we investigate certain well-motivated special cases of MLUFL and obtain significantly improved performance guarantees. In Section 2.2, we consider the case where the connection costs form a metric, which is a scalar multiple of the d-metric (i.e., duv = cuv/M, where M ≥ 1; the problem is trivial if M < 1). For example, in a supply-chain logistics problem, this models a natural setting where the connection of clients to facilities, and the activation of facilities both proceed along the same transportation network. We obtain a constant-factor approximation algorithm for this problem. In Section 2.3, we consider the uniform MLUFL problem, which is the special case where the time- metric is uniform. Uniform MLUFL already generalizes MSSC (and also UFL). For uniform MLUFL with metric connection costs (i.e., metric uniform MLUFL), we devise a 10.78-approximation algorithm. (Without metricity, the problem becomes set-cover hard, and we obtain a simple matching O(log m)-approximation.) The chief novelty here lies in the technique used to obtain this result. We give a simple generic reduction (Theorem 2.12) that shows how to reduce the metric uniform MLUFL problem with facility costs to one without facility costs, in conjunction with an algorithm for UFL. This reduction is surprisingly robust and versatile and has other applications. For example, the same reduction yields an O(1)-approximation for metric uniform k-median (i.e., metric uniform MLUFL where at most k facilities may be opened), and the same ideas lead to improved guarantees for the k-median versions of connected facility location [31], and facility location with service installation costs [28]. We obtain our approximation bounds by rounding the optimal solution to a suitable linear-programming (LP) relaxation of the problem. This is interesting since we are not aware of any previous LP-based methods to attack ML (as a whole). In Section 3, we leverage this to obtain some interesting insights about ML, which we believe cast new light on the problem. In particular, we present two LP-relaxations for ML, and prove that these have (small) constant integrality gap. Our first LP is a specialization of our LP-relaxation for MLUFL. Interestingly, the integrality-gap bound for this LP relies only on the fact that the natural LP relaxation for TSP has constant integrality gap (i.e., a ρ-integrality gap for the natural TSP LP relaxation translates to an O(ρ)-integrality gap). In contrast, the various known algorithms for ML [7, 10, 1] all utilize algorithms for the arguably harder k-MST problem or its variants. Our second LP has exponentially-many variables, one for every path (or tree) of a given length bound, and the separation oracle for the dual problem is a rooted path (or tree) orienteering problem: given rewards on the nodes and metric edge costs, find a (simple) path rooted at r of length at most B that gathers maximum reward. We prove that even a bicriteria approximation for the orienteering problem yields an approximation for ML while losing a constant factor. This connection between orienteering and ML is known [14]. But we feel that our alternate proof, where the orienteering problem appears as the separation oracle required to solve the dual LP, offers a more illuminating explanation of the relation between the approximability of the two problems. (In fact, the same relationship also holds between MGL and "group orienteering.") We believe that the use of LPs opens up ML to new venues of attack. A good LP-relaxation is beneficial because it yields a concrete, tractable lower bound and handle on the integer optimum, which one can exploit to design algorithms (a point repeatedly driven home in the field of approximation algorithms). Also, LP-based techniques tend to be fairly versatile and can be adapted to handle more general variants of the problem (more on this below). Our LP-rounding algorithms exploit various ideas developed for scheduling and facility-location problems (e.g., α-points) and polyhedral insights for TSP, which suggests that the wealth of LP-based machinery developed for these problems can be leveraged to obtain improvements for ML. We suspect that our LP-relaxations are in fact better than what we have accounted for, and consider them to be a promising direction for making progress on ML. Section 4 showcases the flexibility afforded by our LP-based techniques, by showing that our algorithms and analyses extend with little effort to handle various generalizations of MLUFL (and hence, ML). For exam- ple, consider the setting where the latency-cost of a client j is λ(time taken to reach the facility serving j), for some non-decreasing function λ(.). When λ is convex and has "growth" at most p (i.e., λ(cx) ≤ cpλ(x)), we derive an O(cid:0)max{(p log2 n)p, p log n log m}(cid:1)-approximation for MLUFL, an O(cid:0)2O(p)(cid:1)-approximation 3 for related MLUFL and ML, and an O(1)-approximation for metric uniform MLUFL. (Concave λs are even easier to handle.) This in turn leads to approximation guarantees for the Lp-norm generalization of MLUFL, where instead of the sum (i.e., L1-norm) of client latencies, the Lp-norm of the client latencies appears in the objective function. The spectrum of Lp norms tradeoff efficiency with fairness, making the Lp-norm problem an appealing problem to consider. We obtain an O(cid:0)p log n max{log n, log m}(cid:1)-approximation for MLUFL, and an O(1)-approximation for the other special cases. Another notable extension is the k-route version of the problem, where we may use k paths starting at r to traverse the open facilities. With one sim- ple modification to our LPs (and algorithms), all our approximation guarantees translate to this setting. As a corollary, we obtain a constant-factor approximation for the Lp-norm version of the k-traveling repairmen problem [14] (the k-route version of ML). Related work. To the best of our knowledge, MLUFL and MGL are new problems that have not been studied previously. There is a great deal of literature on facility location and vehicle routing problems (see, e.g., [25, 32]) in general, and UFL and ML, in particular, which are special cases of our problem, and we limit ourselves to a sampling of some of the relevant results. The first constant approximation guarantee for UFL was obtained by Shmoys, Tardos, and Aardal [29] via an LP-rounding algorithm, and the current state-of-the-art is 1.5-approximation algorithm due to Byrka [8]. The minimum latency (ML) problem seems to have been first introduced to the computer science community by Blum et al. [7], who gave a constant- factor approximation algorithm for it. Goemans and Kleinberg [19]improved the approximation factor to 10.78, using a "tour-concatenation" lemma, which has formed a component of all subsequent algorithms and improvements for ML. The current-best approximation factor for ML is 3.59 due to Chaudhuri, Godfrey, Rao and Talwar [10]. As mentioned earlier, MGL with a uniform time metric captures the min-sum set cover (MSSC) problem. This problem was introduced by Feige, Lovasz and Tetali [16], who gave a 4- approximation algorithm for the problem and a matching inapproximability result. Recently, Azar et al. [2] introduced a generalization of MSSC, for which Bansal et al. [5] obtained a constant-factor approximation. If instead of adding up the latency cost of clients, we include the maximum latency cost of a client in the objective function of MLUFL, then we obtain the min-max versions of MGL and MLUFL, which have been studied previously. The min-max version of MGL is equivalent to a "path-variant" of GST: we seek a path starting at r of minimum total length that covers every group. Garg, Konjevod, and Ravi [17] devised an LP-rounding based O(log2 n log m)-approximation for GST, where n is the number of nodes and m is the number of groups. Charikar et al. [9] gave a deterministic algorithm with the same guarantee, and Halperin and Krauthgamer [22] proved an Ω(log2 m)-inapproximability result. The rounding technique of [17] and the deterministic tree-embedding construction of [9] (rather its improvement by [15]) are key ingredients of our algorithm for (general) MLUFL. The min-max version of MLUFL can be viewed a path- variant of connected facility location [27, 20]. The connected facility location problem, in its full generality, is essentially equivalent to GST [27]; however, if the connection costs form a metric, and the time- and the connection-cost metrics are scalar multiples of each other, then various constant-factor approximations are known [20, 31, 13]. Very recently, we have learnt that, independent of, and concurrent with, our work, Gupta et al. [21] also propose the minimum group latency (MGL) problem (which they arrive at in the course of solving a different problem), and obtain results similar to ours for MGL. They also obtain an O(log2 n)-approximation for MGL, and the reduction from GST to MGL with a log m-factor loss (see also [26]), and relate the approximability of the MGL and "group orienteering" problems. Their techniques are combinatorial and not LP-based, and it is not clear how these can be extended to handle facility-opening costs. 4 2 LP-rounding approximation algorithms for MLUFL We can express MLUFL as an integer program and relax the integrality constraints to obtain a linear program as follows. We may assume that dii′ is integral for all i, i′ ∈ F ∪ {r}. Let E denote the edge-set of the com- plete graph on F ∪ {r} and let dmax := maxe∈E de. Let T ≤ min{n, m}dmax be a known upper bound on the maximum activation time of an open facility in an optimal solution. For every facility i, client j, and time t ≤ T, we have a variable yi,t indicating if facility i is opened at time t or not, and a variable xij,t indicating whether client j connects to facility i at time t. Also, for every edge e ∈ E and time t, we introduce a vari- able ze,t which denotes if edge e has been traversed by time t. Throughout, we use i to index the facilities in F, j to index the clients in D, t to index the time units in [T] := {1, . . . , T}, and e to index the edges in E. s.t. xij,t ≥ 1 min Xi,t fiyi,t +Xj,i,t(cid:0)cij + t(cid:1)xij,t Xi,t Xe Xe∈δ(S) ze,t ≥ Xi∈S,t′≤t deze,t ≤ t xij,t′ for all j; xij,t ≤ yi,t for all i, j, t for all t for all t, S ⊆ F, j (P) (2) (3) xij,t, yi,t, ze,t ≥ 0 for all i, j, t, e; yi,t = 0 for all i, t with dir > t. The first two constraints encode that each client is connected to some facility at some time, and that if a client is connected to a facility i at time t, then i must be open at time t. Constraint (2) ensures that by time t no more than t "distance" is covered by the tour on facilities, and (3) ensures that if a client is connected to i by time t, then the tour must have visited i by time t. We assume for now that T = poly(m), and show later how to remove this assumption (Lemma 2.7, Theorem 2.8). Thus, (P) can be solved efficiently since one can efficiently separate over the constraints (3). Let (x, y, z) be an optimal solution to (P), and OPT denote its objective value. For a client j, define C ∗ approximation algorithms for MLUFL by rounding (x, y, z) to an integer solution. j = Pi,t txij,t. We devise various j = Pi,t cijxij,t, and L∗ In Section 2.1, we give a polylogarithmic approximation algorithm for (general) MLUFL (where the cijs need not even form a metric). Complementing this result, we prove (Theorem 2.9) that a ρ-approximation algorithm (not necessarily LP-based) for MLUFL yields an O(ρ log m)-approximation algorithm for the GST problem on n nodes and m groups. In Sections 2.2 and 2.3, we obtain significantly-improved approximation guarantees for various well-motivated special cases of MLUFL. Section 2.2 obtains a constant-factor approx- imation algorithm in the natural setting where the connection costs form a metric that is a scalar multiple of the time-metric. Section 2.3 considers the setting where the time-metric is the uniform metric. Our main result here is a constant-factor approximation for metric connection costs, which is obtained via a rather versatile reduction of this uniform MLUFL problem to UFL and uniform MLUFL with zero-facility costs. We first give an overview. Let Nj = {i ∈ F : cij ≤ 4C ∗ 2.1 An O(cid:0)log n · max{log n, log m}(cid:1)-approximation algorithm as the earliest time t such that Pi∈Nj ,t′≤t xij,t′ ≥ 2 j } be the set of facilities "close" to j, and define τj 3. By Markov's inequality, we have Pi∈Nj Pt xij,t ≥ 3 4 and τj ≤ 12L∗ j . It is easiest to describe the algorithm assuming first that the time-metric d is a tree metric. Our algorithm runs in phases, with phase ℓ corresponding to time tℓ = 2ℓ. In each phase, we compute a random subtree rooted at r of "low" cost such that for every client j with τj ≤ tℓ, with constant probability, this tree contains a facility in Nj. To compute this tree, we utilize the rounding procedure of Garg-Konjevod- Ravi (GKR) for the group Steiner tree (GST) problem [17] (see Lemma 2.4), by creating a group for each 5 client j with τj ≤ tℓ comprising of, roughly speaking, the facilities in Nj. We open all the facilities included in the subtree, and obtain a tour via the standard trick of doubling all edges and performing an Eulerian tour with possible shortcutting. The overall tour is a concatenation of all the tours obtained in the various phases. For each client j, we consider the first tree that contains a facility from Nj (which must therefore be open), and connect j to such a facility. Given the result for tree metrics, an oft-used idea to handle the case when d is not a tree metric is to approximate it by a distribution of tree metrics with O(log n) distortion [15]. Our use of this idea is however more subtle than the typical applications of probabilistic tree embeddings. Instead of moving to a distribution over tree metrics up front, in each phase ℓ, we use the results of [9, 15] to deterministically obtain a tree Tℓ with edge weights {dTℓ (e)}, such that the resulting tree metric dominates d and Pe=(i,i′) dTℓ (i, i′)ze,tℓ = O(log n)Pe deze,tℓ. As we show in Section 4, this deterministic choice allows to extend our algorithm and analysis effortlessly to the setting where the latency-cost in the objective function is measured by a more general function (e.g., the Lp-norm) of the client-latencies. The algorithm is described in detail as Algorithm 1, and utilizes the following results. Let τmax = maxj τj. Theorem 2.1 ([9, 15]) Given any edge weights {ze}e∈E, one can deterministically construct a weighted tree T having leaf-set F ∪ {r}, leading to a tree metric, dT (·), such that, for any i, i′ ∈ F ∪ {r}, we have: (i) dT (i, i′) ≥ di,i′, and (ii) Pe=(i,i′)∈E dT (i, i′)zi,i′ = O(log n)Pe deze. Theorem 2.2 ([17]) Consider a tree T rooted at r with n leaves, subsets G1, . . . , Gp of leaves, and frac- tional values ze on the edges of T satisfying z(δ(S)) ≥ νj for every group Gj and node-set S such that Gj ⊆ S, where νj ∈ (cid:2) 1 2 , 1(cid:3). There exists a randomized polytime algorithm, henceforth called the GKR algorithm, that returns a rooted subtree T ′′ ⊆ T such that (i) Pr[e ∈ T ′′] ≤ ze for every edge e ∈ T ; and (ii) Pr[T ′′ ∩ Gj = ∅] ≤ exp(cid:0)− νj 64 log2 n(cid:1) for every group Gj. Algorithm 1 Given: a fractional solution (x, y, z) to (P) (with C∗ A1. In each phase ℓ = 0, 1, . . . , N := ⌈log2(2τmax) + 4 log2 m⌉, we do the following. Let tℓ = min{2ℓ, T}. A1.1. Use Theorem 2.1 with edge weights {ze,tℓ} to obtain a tree Tℓ = (cid:0)V (Tℓ), E(Tℓ)(cid:1). Extend Tℓ to a tree T ′ adding a dummy leaf edge (i, vi) of cost fi to Tℓ for each facility i. Let E′ = {(i, vi) : i ∈ F}. j , Nj, and τj defined as above for each client j). j , L∗ ℓ by A1.2. Map the LP-assignment {ze,tℓ}e∈E to an assignment z on the edges of T ′ A1.3. Define Dℓ = {j : τj ≤ tℓ}. For each client j ∈ Dℓ, we define the group N ′ ℓ as follows. We obtain N := log2 m subtrees T ′′ ℓ by setting ze = Pe lies on the unique i-i′ path in Tℓ zii′,tℓ for all e ∈ E(Tℓ), and ze = Pt≤tℓ yi,t for all e = (i, vi) ∈ E′. Note that Pe∈E(Tℓ) dTℓ(e)ze = Pe=(i,i′) dTℓ(i, i′)ze,tℓ = O(log n)Pe deze,tℓ = O(log n)tℓ. j = {vi : i ∈ Nj}. We N . Each tree T ′′ 1 , . . . , T ′′ j}j∈Dℓ, and r . Set ℓ ) fi ≤ 40 · 192 log2 nP(i,vi)∈E ′ fizi,vi and (ii) ℓ, open all the facilities in the resulting tree, and convert the resulting tree into a tour Tourℓ traversing all the opened facilies. For every unconnected client j, we connect j to a facility in Nj if some such facility is open (and hence part of Tourℓ). now compute a subtree T ′ is obtained by executing the GKR algorithm 192 log2 n times on the tree T ′ taking the union of all the subtrees returned. Note that we may assume that i ∈ T ′′ ℓ to be any tree in {T ′′ T ′ Pe∈E(T ′ ℓ )\E ′ dTℓ(e) ≤ 40 · 192 log2 nPe∈E(Tℓ) dTℓ(e)ze; if no such tree exists, the algorithm fails. N } satisfying (i) P(i,vi)∈E(T ′ A1.4. Now remove all the dummy edges from T ′ 1 , . . . , T ′′ ℓ of T ′ ℓ with groups {N ′ r iff (i, vi) ∈ T ′′ r A2. Return the concatenation of the tours Tourℓ for ℓ = 0, 1, . . . , N shortcutting whenever possible. This induces an ordering of the open facilities. If some client is left unconnected, we say that the algorithm has failed. Analysis. The algorithm may fail in steps A.1.3 and A2. Lemmas 2.4 and 2.5 bound the failure probability in each case by 1/ poly(m). To bound the expected cost conditioned on success, it suffices to bound the expectation of the random variable that equals the cost incurred if the algorithm succeeds, and is 0 otherwise. 6 Since each client j is connected to a facility in Nj, the total connection cost is at most 4Pj C ∗ j . To bound the remaining components of the cost, we first show that in any phase ℓ, the z-assignment defined j}j∈Dℓ to an extent of at least 2 above "covers" each group in {N ′ 3 (Claim 2.3). Next, we show in Lemma 2.4 that for every client j ∈ Dℓ, the probability that a facility in Nj is included in the tree T ′ ℓ, and hence opened in phase ℓ, is at least 5 9. The facility-cost incurred in a phase is O(log n)Pi,t fiyi,t, and since τmax ≤ T = poly(m), the number of phases is O(log m), so this bounds the facility-opening cost incurred. Also, since the probability that j is not connected (to a facility in Nj) in phase ℓ decreases geometrically (at a rate less than 1/2) with ℓ when tℓ ≥ τj, one can argue that (a) with very high probability (i.e., 1 − 1/ poly(m)), each client j is connected to some facility in Nj, and (b) the expected latency-cost of j is 3 = 5 6 · 2 at most O(log n)Pe∈E(Tℓ) dTℓ(e)ze = O(log2 n)τj. Claim 2.3 Consider any phase ℓ. For any subset S of nodes of the corresponding tree T ′ any N ′ xij,t ≥ 2/3 (where δ(S) denotes δT ′ j ⊆ S where j ∈ Dℓ, we have z(δ(S)) ≥ Pi∈Nj ,t≤tℓ ℓ ℓ with r /∈ S, and (S)). Proof : Let R = S ∩ V (Tℓ), and Y ⊆ F be the set of leaves in R. Then δ(S) = δTℓ(R) ∪ (cid:0)δ(S) ∩ E′(cid:1). Let δE(Y ) = {(i, i′) ∈ E : {i, i′} ∩ Y = 1}. Observe that z(δTℓ(R)) ≥ Pe∈δE (Y ) ze,tℓ. This is simply because if we send zii′,tℓ flow along the unique (i, i′) path in Tℓ for every (i, i′) ∈ δE(Y ), then we obtain a flow between Y and F ∪ {r} \ Y respecting the capacities {ze}e∈E(Tℓ), and of value equal to the RHS above. Thus, the inequality follows because the capacity of any cut containing Y must be at least the value of the flow. Since (x, y, z) satisfies (3), we further have that Pe∈δE(Y ) ze,tℓ ≥ Pi∈Y,t≤tℓ xij,t. So z(δ(S)) ≥ Xe∈δTℓ (R) ze,tℓ + X(i,vi)∈δ(S):i /∈Y(cid:0)Xt≤tℓ yi,t(cid:1) ≥ Xi∈Y,t≤tℓ xij,t + Xi∈Nj\Y,t≤tℓ xij,t ≥ Xi∈Nj ,t≤tℓ xij,t ≥ 2 3 . Lemma 2.4 In any phase ℓ, with probability 1 − 1/ poly(m), we obtain the desired tree T ′ Moreover, Pr[T ′ j 6= ∅] ≥ 5/9 for all j ∈ Dℓ. ℓ ∩ N ′ ℓ in step A1.3. r ). For j ∈ Dℓ, let Er Proof : Consider any tree T ′′ r obtained by executing the GKR algorithm 192 log2 n times and taking the r )\E′ dTℓ(e) union of the resulting subtrees. For brevity, we denote P(i,vi)∈E(T ′′ by dℓ(T ′′ 1 − exp(cid:0)− νj 192 log2 nP(i,vi)∈E′ fizi,vi and E(cid:2)dℓ(T ′′ j is non-empty. By Theorem 2.2, we have Pr[Er 64 log2 n · 192 log n(cid:1) ≥ 1 − e−3νj ≥ (1 − e−3)νj ≥ 11/18. We also have that E(cid:2)F (T ′′ j ] ≥ r )(cid:3) ≤ r )(cid:3) ≤ 192 log2 nPe∈E(Tℓ) dTℓ(e)ze. Let Fr and Dr denote respec- tively the events that F (T ′′ By Markov's inequality each event happens with probability at least 39/40. Thus, for any j ∈ Dℓ, we get that r ) ≤ 40·192 log2 nP(i,vi)∈E′ fizi,vi, and dℓ(T ′′ r ) ≤ 40·192 log2 nPe∈E(Tℓ) dTℓ(e)ze. r ), and Pe∈E(T ′′ j denote the event that T ′′ r ) fi by F (T ′′ r ∩ N ′ Pr[Er j (Fr ∧ Dr)] ≥ Pr[Er j ∧ Fr ∧ Dr] ≥ 1 − (7/18 + 1/40 + 1/40) > 5/9. (4) Now the probability that (Fr ∧ Dr)c happens for all r = 1, . . . , N is at most (2/40)N ≤ 1/m4. Hence, ℓ := Tr such that both Fr and Dr hold, and (4) shows that with high probability, there is some tree T ′ Pr[T ′ j 6= ∅] ≥ 5/9 for all j ∈ Dℓ. ℓ ∩ N ′ Lemma 2.5 The probability that a client j is not connected by the algorithm is at most 1/m4. Let Lj be the random variable equal to j's latency-cost if the algorithm succeeds and 0 otherwise. Then E(cid:2)Lj(cid:3) = O(log2 n)tℓj , where ℓj (= ⌈log2 τj⌉) is the smallest ℓ such that tℓ ≥ τj. 7 Proof : Let Pj be the random variable denoting the phase in which j gets connected; let Pj := N + 1 if j remains unconnected. We have Pr[Pj ≥ ℓ] ≤ (cid:0) 4 4 log2 m phases after phase ℓj, so Pr[j is not connected after N phases] ≤ 1/m4. Now, Lj ≤ Xℓ≤Pj 9(cid:1)(ℓ−ℓj) for ℓ ≥ ℓj The algorithm proceeds for at least dTℓ (e) = O(log n) Xℓ≤Pj Xe∈E(Tℓ) d(Tourℓ) ≤ 2 Xℓ≤Pj Xe∈E(T ′ ℓ)\E′ tℓ dTℓ(e)ze = O(log2 n) Xℓ≤Pj 9(cid:19)(ℓ−ℓj )(cid:21) = O(log2 n)tℓj . tℓ ·(cid:18) 4 so E(cid:2)Lj(cid:3) = O(log2 n) N Xℓ=0 Pr[Pj ≥ ℓ] · tℓ ≤ O(log2 n)(cid:20) ℓj Xℓ=0 tℓ + Xℓ>ℓj Theorem 2.6 Algorithm 1 succeeds with probability 1−1/ poly(m), and returns a solution of expected cost O(cid:0)log n · max{log n, log m}(cid:1) · OPT . Proof : Lemmas 2.4 and 2.5 show that the failure probability is 1/ poly(m). Let Y denote the cost incurred if the algorithm succeeds, and 0 otherwise. Since tℓj ≤ 2τj = O(L∗ O(cid:0)log n · max{log n, log m}(cid:1) · OPT by Lemma 2.5 and the preceding arguments. j ) for each j, we have E(cid:2)Y(cid:3) = Removing the assumption T = poly(m). We first argue that although (P) has a pseudopolynomial number of variables, one can compute a near-optimal solution to it in polynomial time (Lemma 2.7) by con- sidering only (integer) time-values that are powers of (1 + ǫ) (rouhgly speaking). Given ǫ > 0, define Tr = ⌈(1 + ǫ)r⌉, and let TS := {T0, T1, . . . , Tk} where k is the smallest integer such that Tk ≥ min{n, m}dmax. Define T−1 = 0. Let (P)TS denote (P) when t ranges over TS. Lemma 2.7 For any ǫ > 0, we can obtain a solution to (P) of cost at most (1+ǫ)OPT in time poly(input size, 1/ǫ). Proof : We prove that the optimal value of (P)TS is at most (1 + ǫ)OPT . Since the size of (P)TS is poly(input size, 1/ǫ) this proves the lemma. i,Tℓ = PTℓ t=Tℓ−1+1 yi,t. It is clear that Pt∈TS x′ i,1 = yi,1 for all i and j. For each ℓ = 1, . . . , k, facility i, client j, we set x′ ij,t = Pt xij,t and Pt∈TS y′ i,t = Pi,t fiyi,t, Pj,i,t∈TS cijx′ We transform (x, y, z), an optimal solution to (P) to a feasible solution (x′, y′, z′) to (P)TS of cost at most (1+ǫ)OPT . (In fact, the facility-opening and connection-costs remain unchanged, and the latency-cost blows up by a (1+ǫ)-factor.) z′ is simply a restriction of z to the times in TS, that is, z′ e,t = ze,t for each e, t ∈ TS. Set x′ = i,t = xij,t. It fol- ij,t = ij,1 = xij,1, y′ PTℓ t=Tℓ−1+1 xij,t and y′ Pt yi,t for all i and j, and moreover for any Tℓ ∈ TS, we have Pt∈TS:t≤Tℓ lows that (x′, y′, z′) is a feasible solution to (P)TS and Pi,t∈TS fiy′ Pj,i,t cijxij,t. To bound the latency cost, note that for any t > Tℓ−1, we have Tℓ ≤ (1 + ǫ)t, so for any client j and facility i, Pt∈TS tx′ ij,t ≤ xij,1 + (1 + ǫ)Pt>1 txij,t ≤ (1 + ǫ)Pt txij,t. Thus, Pj,i,t∈TS tx′ Let (x′, y′, z′) denote an optimal solution to (P)TS. The only changes to Algorithm 1 are in the definition of the time tℓ and the number of phases N . (Of course we now work with (x′, y′, z′), and C ∗ j are defined in terms of (x′, y′, z′) now.) The idea is to define tℓ so that one can "reach" the τj of every client j in O(log m) phases; thus, one can terminate in O(log m) phases and thereby obtain the same approximation on the facility-opening cost. Let L = (Pj L∗ ij,t)/m. For x ≤ Tk, define TS(x) to be the earliest time in TS that is at least x; if x ≥ Tk, define TS(x) := Tk. Note that TS(x) ≤ (1 + ǫ)x for all x ≥ 0. We now define tℓ = TS(L · 2ℓ), and set the number of phases to N := (cid:6)log2(2τmax/L) + 4 log2 m(cid:7). Note that since τj = O(L∗ ij,t ≤ (1 + ǫ)Pj,i,t txij,t. j )/m = (Pj,i,t∈TS tx′ j ), we have N = O(log m). x′ ij,t = Pt≤Tℓ ij,Tℓ j , L∗ Theorem 2.8 For any ǫ > 0, Algorithm 1 with the above modifications succeeds with high probability and returns a solution of expected cost O(cid:0)log n max{log n, log m}(cid:1)(1 + ǫ)OPT . 8 Proof : The analysis of the facility-opening and connection-cost is exactly as before (since N = O(log m)). Define ℓj as the smallest ℓ such that tℓ ≥ τj. Note that ℓj ≤ (cid:4)log2(2τj/L)(cid:5) (this holds even when τj ≤ L). Hence, the probability that j is not connected after N phases is at most 1/m4. So as before, the 2ℓ ≤ 2(1 + ǫ)tℓj , and failure probability is at most 1/ poly(m). We have Pℓ≤ℓj Pℓ>ℓj and we obtain the same bound on E(cid:2)Lj(cid:3) as in Lemma 2.5. Note that tℓj ≤ 2(1 + ǫ)τj = O(L∗ τj ≥ L. Thus, Pj E(cid:2)Lj(cid:3) ≤ O(log2 n)(cid:2)m · L +Pj:τj>t0 9(cid:1)(ℓ−ℓj) = O(tℓj ). Thus, the inequalities involving Lj and E(cid:2)Lj(cid:3) in Lemma 2.5 are still valid, tℓ(cid:0) 4 j ) when tℓ ≤ (1 + ǫ)LPℓ≤ℓj O(L∗ j )(cid:3) = O(log2 n)L∗. Inappproximability of MLUFL. We argue that any improvement in the guarantee obtained in Theorem 2.6 would yield an improvement in the approximation factor for GST. We reduce GST to MGL, the special case of MLUFL mentioned in Section 1, where we have groups Gj ⊆ F and the goal is to order the the facilities so as to minimize the sum of the covering times of the groups. (Note that Theorem 2.6 implies an O(log2 n)- approximation for MGL.) Recall that we may assume that the groups in MGL are disjoint, in which case the connection costs form a metric. Theorem 2.9 Given a ρn,m-approximation algorithm for MGL with (at most) n nodes and m groups, we can obtain an O(ρn,m log m)-approximation algorithm for GST with n nodes and m groups. Thus, the polylogarithmic inapproximability of GST [22] implies that MGL, and hence MLUFL even with metric con- nection costs, cannot be approximated to a factor better than Ω(log m), even when the time-metric arises from a hierarchically well-separated tree, unless NP ⊆ ZTIME (npolylog(n)). Our proof of the above theorem is LP-based and is deferred to Appendix A. Gupta et al. [21] indepen- dently arrived at the above theorem via a combinatorial proof. 2.2 MLUFL with related metrics Here, we consider the MLUFL problem when the facilities, clients, and the root r are located in a common metric space that defines the connection-cost metric (on F ∪ D ∪ {r}), and we have duv = cuv/M for all u, v ∈ F∪D∪{r}. We call this problem, related MLUFL, and design an O(1)-approximation algorithm for it. The algorithm follows a similar outline as Algorithm 1. As before, we build the tour on the open facilities by concatenating tours obtained by "Eulerifying" trees rooted at r of geometrically increasing length. At a high level, the improvement in the approximation arises because one can now obtain these trees without resorting to Theorems 2.1 and 2.2 and losing O(log n)-factors in process. Instead, since the d- and c- metrics are related, we can obtain a group Steiner tree on the relevant groups by using a Steiner tree algorithm (in a manner similar to the LP-rounding algorithms in [27, 20]). We now define j . Ideally, in each phase ℓ, we want to connect the Nj groups for all j such that τj ≤ tℓ := 2ℓ. But to obtain a low-cost solution, we do a facility-location-style clustering of the set of clients with τj ≤ tℓ and build a tree Tℓ that connects the Njs of only the cluster centers: we contract these Njs and build an MST (in the d-metric) on them, and then connect each Nj internally (in the d-metric) using intracluster edges incident on j. Here we crucially exploit the fact that the d- and c-metrics are related. Nj = {i : Pt xij,t > 0, cij ≤ 3C ∗ j }, and τj = 6L∗ Deciding which facilities to open is tricky because groups Nj and Nk created in different phases could overlap, and we could have C ∗ k but τj ≫ τk; so if we open i ∈ Nj and use this to also serve k, then we must connect i to some Tℓ (without increasing its d-cost by much) where tℓ = O(τk). We consider the collection C of cluster centers created in all the phases, and pick a maximal subset C′ ⊆ C that yields disjoint clusters by greedily considering clusters in increasing C ∗ j order. We open the cheapest facility in Nj for all j ∈ C′, and attach it to the tree Tℓ, where ℓ is the earliest phase such that there is some cluster Nk created j ≪ C ∗ 9 in that phase that was removed (from C) when Nj was included in C′ (because Nk ∩ Nj 6= ∅). Since d and c are related, one can bound the resulting increase in the d-cost of Tℓ. Finally, we convert these augmented Tℓ-trees to tours and concatenate these tours. We now describe the algorithm in detail. We have not sought to optimize the approximation ratio. When we refer to an edge or a node below, we mean an edge or node of the complete graph on F ∪ D ∪ {r}. Recall xij,t ≥ that Nj = {i : Pt xij,t > 0, cij ≤ 3C ∗ 1 2. R1. For each time tℓ = 2ℓ, where ℓ = 0, 1, . . . , ⌈log T⌉, we do the following. Define Dℓ = {j : τj ≤ j . So Pi∈Nj Pt xij,t ≥ 2 3 , and Pi∈Nj ,t≤τj j }, and τj = 6L∗ tℓ} \(cid:0)S0≤ℓ′<ℓ Cℓ′(cid:1) (where the union of an empty collection is ∅). • (Clustering) We cluster the facilities inSj∈Dℓ j value and form a cluster around j consisting of the facilities in Nj. For every client k ∈ Dℓ (including j) such that cjk ≤ 30C ∗ k ≥ C ∗ j ), we remove k from Dℓ, set σ(k) = j, and recurse on the remaining clients in Dℓ until no client is left in Dℓ. Let Cℓ denote the set of cluster centers (i.e., {j ∈ Dℓ : σ(j) = j}). Note that for two clients j and j′ in Cℓ, Nj ∩ Nj′ is ∅. Nj as follows. We pick j ∈ Dℓ with smallest C ∗ k (note that C ∗ • (Building a group Steiner tree Tℓ on {Nj}j∈Cℓ) We contract the clusters Nj for j ∈ Cℓ into supern- odes, and build a minimum spanning tree (MST) T ′′ ℓ connecting r and these supernodes. Next, we uncontract the supernodes, and for each j ∈ Cℓ, we add edges joining j to every facility i ∈ Nj that has an edge incident to it in T ′′ ℓ . This yields the tree Tℓ. R2. (Opening facilities) Let C = Sℓ Cℓ. (Note that a client appears in at most one of the Cℓ sets.) We cannot open a facility in every cluster centered around a client in C, since for j ∈ Cℓ and k ∈ Cℓ′, Nj and Nk need not be disjoint. So we select a subset C′ ⊆ C such that for any two j, k in C′, the sets Nj and Nk are disjoint. This is done as follows. We initialize C′ ← ∅. Pick the client j ∈ C with smallest C ∗ j value and add it to C′. We delete from C every client k ∈ C (including j) such that Nk ∩ Nj 6= ∅, setting nbr(k) = j, and recurse on the remaining set of clients until no client is left in C. Consider each j ∈ C′. We open the facility i ∈ Nj with smallest fi. Let ℓ be the smallest index such that there is some k ∈ Cℓ with nbr(k) = j. We connect i to Tℓ by adding the facility edge (i, k) to it. Let T ′ ℓ denote Tℓ augmented by all such facility edges. R3. We obtain a tour connecting all the open facilities, by converting each tree T ′ ℓ into a tour, and concate- nating the tours for ℓ = 0, . . . , ⌈T⌉ (in that order). R4. For every client j ∈ C, we assign j to the facility opened from Nnbr(j). For every client j /∈ C, we assign j to the same facility as σ(j). Theorem 2.10 For related MLUFL, one can round (x, y, z) to get a solution with facility-opening cost at most 3 j and latency-cost at most 64τj = 384L∗ 2 Pi,t fiyi,t, where each client j incurs connection-cost at most 39C ∗ j . Thus, we obtain an O(1)-approximation algorithm for related MLUFL. Proof : The clusters Nj for clients j ∈ C′ are disjoint; each such cluster has facility weightPi∈Nj Pt yi,t ≥ 2 3, and we open the cheapest facility in the cluster. Consider a client j, and let it be assigned to facility i. If j ∈ C′, then i ∈ Nj, and we have cij ≤ 3C ∗ j . If j ∈ C \ C′ with nbr(j) = k, then i ∈ Nk and there is some facility i′ ∈ Nj ∩ Nk. So cij ≤ cik + ci′k + ci′j ≤ 2 · 3C ∗ j . Finally, if j /∈ C and j′ = σ(j), then σ(j′) is also assigned to i, so j′ + 30C ∗ cij ≤ cij′ + cjj′ ≤ 9C ∗ We next bound d(Tℓ) and d(T ′ we have Pe∈δ(S) ze,tℓ ≥ Pi∈S,t≤tℓ j ≤ 39C ∗ j . ℓ ) for any phase ℓ. For any client j ∈ Dℓ and any node-set S ⊇ Nj, r /∈ S, 2 . Therefore, (2ze,tℓ ) forms a fractional xij,t ≥ Pi∈Nj ,t≤τj j ≤ 9C ∗ k + 3C ∗ xij,t ≥ 1 10 j , C ∗ ℓ . Observe that if e is an edge of T ′′ ℓ k}, since 30 max{C ∗ is at most 1 M ·Pj∈Cℓ Steiner tree of cost at most 2tℓ on the supernodes and r, and hence, d(T ′′ ℓ ) ≤ 4tℓ since it is well known that the cost of an MST is at most twice the cost of a fractional solution to the Steiner-tree LP. For j ∈ Cℓ, let degj denote the degree of the cluster Nj in T ′′ joining Nj and Nk (so j, k ∈ Cℓ), then ce ≥ 24 max{C ∗ j , C ∗ j + ce + 3C ∗ k. So the (d-) cost of adding the additional edges to T ′′ ℓ )/4, and hence, d(Tℓ) ≤ 5tℓ. ℓ Now consider the cost of adding facility edges to Tℓ in step R2. For each facility edge (i, k) added, we know that i ∈ Nnbr(k), k ∈ Cℓ, and k is assigned to i. So we have cik ≤ 9C ∗ k. Observe that each client k ∈ Cℓ is responsible for at most one such facility edge. So the d-cost of these facility edges is at most 1 ℓ ) ≤ 8tℓ. M ·Pj∈Cℓ j . Let j be assigned to facility i. Let ℓ be the smallest index such that j ∈ Dℓ, so tℓ ≤ 2τj. We first argue that if i is part ℓ′, then ℓ′ ≤ ℓ. If j ∈ C, this follows since we know that i ∈ Nnbr(j) and ℓ′ = min{r : of the tree T ′ ∃k ∈ Cr with nbr(k) = nbr(j)}. If j /∈ C, then we know that σ(j) ∈ Cℓ is also assigned to i, and so by the preceding argument, we again have that ℓ′ ≤ ℓ. Thus, the latency-cost of j is bounded by 4 · d(T ′′ Finally, we prove that the latency cost of any client j is at most 64τj = 384L∗ M Pj∈Cℓ k} ≤ cjk ≤ 3C ∗ j ≤ d(T ′′ degj ·3C ∗ ℓ ) ≤ d(Tℓ) + 3 4 · d(T ′′ ℓ ). Thus, d(T ′ degj ·9C ∗ j ≤ 3 9C ∗ j ≤ 1 Pℓ′ r=0 2d(T ′ r ) ≤ 16Pℓ′ r=0 tr ≤ 32tℓ′ ≤ 64τj. 2.3 MLUFL with a uniform time-metric We now consider the special case of MLUFL, referred to as uniform MLUFL, where the time-metric d is uniform, that is, dii′ = 1 for all i, i′ ∈ F ∪ {r}. When the connection costs form a metric, we call it the metric uniform MLUFL. We consider the following simpler LP-relaxation of the problem, where the time t now ranges from 1 to n. xij,t ≥ 1 ∀j; Xi,t (cij + t)xij,t fiyi,t +Xj,i,t min Xi,t xij,t ≤ yi,t ∀i, j, t; Xi subject to (Unif-P) yi,t ≤ 1 ∀t; xij,t, yi,t ≥ 0 ∀i, j, t. j = Pi,t cijxij,t, L∗ j = Let (x, y) be an optimal solution to (Unif-P), and OPT be its value. Let C ∗ Pi,t txij,t. As stated in the introduction, uniform MLUFL generalizes: (i) set cover, when the facility and connection costs are arbitrary; (ii) MSSC, when the facility costs are zero (ZFC MLUFL); and (iii) metric UFL, when the connection costs form a metric. We obtain approximation bounds for uniform MLUFL, ZFC MLUFL, and metric MLUFL (Theorems 2.11 and 2.14) that complement these observations. The main result of this section is Theorem 2.12, which shows that a ρUFL-approximation algorithm for UFL and a γ-approximation algorithm for ZFC MLUFL (with metric connection costs) can be combined to yield a (ρUFL + 2γ)-approximation algorithm for metric uniform MLUFL. Taking ρUFL = 1.5 [8] and γ = 9 (part (ii) of Theorem 2.11), we obtain a 19.5-approximation algorithm. We improve this to 10.773 by using a more refined version of Theorem 2.12, which capitalizes on the asymmetric approximation bounds that one can obtain for different portions of the total cost in UFL and ZFC MLUFL. We note that by considering each (i, t) as a facility, since the connection costs cij + t form a metric, one can view metric MLUFL as a variant of metric UFL, and use the ideas in [3] to devise an O(1)-approximation for this variant. We instead present our alternate algorithm based on the reduction in Theorem 2.12, because this reduction is quite robust and versatile. In particular, it allows us to: (a) handle certain extensions of the problem, e.g., the setting where we have non-uniform latency costs (see Section 4), for which the above reduction fails since we do not necessarily obtain metric connection costs, and (b) devise algorithms for the uniform latency versions of other facility location problems, where the cost of a facility does not depend on the client-set assigned to it (so one can assign a client to any open facility freely without affecting the facility costs). For instance, consider uniform MLUFL with the restriction that at most k facilities may be 11 opened: our technique yields a (ρkMed + 2γ) approximation for this problem, using a ρkMed-approximation for k-median. Theorem 2.11 One can obtain: (i) an O(ln m)-approximation algorithm for uniform MLUFL with arbitrary facility- and connection- costs. j for ZFCMLUFL, for any parameter α ∈ (0, 1). (ii) a solution of cost at most Thus, setting α = 8 α(cid:7)Pj L∗ 9, yields solution of cost at most 9 · OPT . 1−α Pj C ∗ α (cid:6) 1 j + 4 1 We defer the proof of Theorem 2.11 to the end of the section, and focus first on detailing the aforemen- tioned reduction. Theorem 2.12 Given a ρUFL-approximation algorithm A1 for UFL, and a γ-approximation algorithm A2 for uniform ZFC MLUFL, one can obtain a (ρUFL +2γ)-approximation algorithm for metric uniform MLUFL. fi +Pj cσ1(j)j ≤ ρUFL ·O∗ Proof : Let I denote the metric uniform MLUFL instance, and O∗ denote the cost of an optimal integer solution. Let IUFL be the UFL instance obtained form I by ignoring the latency costs, and IZFC be the ZFC UFL and O∗ MLUFL instance obtained from I by setting all facility costs to zero. Let O∗ ZFC denote respectively ZFC ≤ O∗. We UFL, O∗ the cost of the optimal (integer) solutions to these two instances. Clearly, we have O∗ use A1 to obtain a near-optimal solution to IUFL: let F1 be the set of facilities opened and let σ1(j) denote UFL. We use A2 the facility in F1 to which client j is assigned. So we havePi∈F1 to obtain a near-optimal solution to IZFC: let F2 be the set of open facilities, σ2(j) be the facility to which client j is assigned, and π(i) be the position of facility i. So we have Pj(cid:0)cσ2(j)j + π(σ2(j))(cid:1) ≤ γ · O∗ ZFC. We now combine these solutions as follows. For each facility i ∈ F2, let µ(i) ∈ F1 denote the facility in F1 that is nearest to i. We open the set F = {µ(i) : i ∈ F2} of facilities. The position of facility i ∈ F is set to mini′∈F2:π(i′)=i π(i′). Each facility in F is assigned a distinct position this way, but some positions may be vacant. Clearly we can always convert the above into a proper ordering of F where each facility i ∈ F occurs at position κ(i) ≤ mini′∈F2:π(i′)=i π(i′). Finally, we assign each client j to the facility φ(j) = µ(σ2(j)) ∈ F . Note that κ(φ(j)) ≤ π(σ2(j)) (by definition). For a client j, we now have cφ(j)j ≤ cσ2(j)µ(σ2(j)) + cσ2(j)j ≤ cσ2(j)σ1(j) + cσ2(j)j ≤ cσ1(j)j + 2cσ2(j)j. Thus, the total cost of the resulting solution is at most Pi∈F1 We call an algorithm a (ρf , ρc)-approximation algorithm for UFL if given an LP-solution to UFL with facility- and connection- costs F ∗ and C ∗ respectively, it returns a solution of cost at most ρf F ∗ + ρcC ∗. Similarly, we say that an algorithm is a (γc, γl)-approximation algorithm for uniform ZFC MLUFL if given a solution to (P) with connection- and latency- costs C ∗ and L∗ respectively, it returns a solution of cost at most γcC ∗ + γlL∗. The proof of Theorem 2.12 easily yields the following more general result. fi +Pj(cid:0)cσ1(j)j + 2cσ2(j)j + π(σ2(j))(cid:1) ≤ (ρUFL + 2γ) · O∗. Corollary 2.13 One can combine a (ρf , ρc)-approximation algorithm for UFL, and a (γc, γl)-approximation algorithm for uniform ZFC MLUFL, to obtain a solution of cost at most max{ρf , ρc + 2γc, γl} · OPT . Proof : The proof mimics the proof of Theorem 2.12. The only new observation is that (x, y) yields an LP-solution to (i) IUFL with facility cost Pi,t fiyi,t and connection cost Pj,i,t cijxij,t; and (ii) IZFC with connection cost Pj,i,t cijxij,t and latency cost Pj,i,t txij,t. Thus, applying the construction in the proof of Theorem 2.12 yields a solution of total cost at most ρf Xi,t fiyi,t + (ρc + 2γc)Xj,i,t cijxij,t + γlXj,i,t txij,t ≤ max{ρf , ρc + 2γc, γl} · OPT . algorithm for ZFC MLUFL (part (ii) of Theorem 2.11) gives the following result. 1−β(cid:1)-approximation algorithm for UFL [29] with the(cid:0) 1 Combining the(cid:0) ln(1/β) 1−β , 3 1−α , 4 α (cid:6) 1 α(cid:7)(cid:1)-approximation 12 Theorem 2.14 For any α, β ∈ (0, 1), one can obtain a solution of cost max(cid:8) ln(1/β) 1−β + 2 OPT . Thus, taking α = 0.7426, β = 0.000021, we obtain a 10.773-approximation algorithm. 1−β , α(cid:6) 1 1−α , 4 α(cid:7)(cid:9) · 3 2.3.1 Proof of Theorem 2.11 The following lemma will often come in handy. ij,t ≤ k ·Pj,i,t txij,t. i,t = Pi,t fi yi,t; (ii) Pj,i,t cijx′ ij,t = Pj,i,t cij xij,t; and (iii) Pj,i,t tx′ all the other constraints of (Unif-P). Then, one can obtain a feasible solution (x′, y′) to (Unif-P) such that T0 groups as follows. Initialize ℓ ← 1, S ← S0. For a set A of (i, t) pairs, we define the y-weight of A as Lemma 2.15 Let (x, y) be a solution satisfying Pi yi,t ≤ k for every time t, where k ≥ 0 is an integer, and (i) Pi,t fiy′ Proof : For each time t, define St = {(i, t) : yi,t > 0}. The idea is to simply "spread out" the St sets. Let S0 = St St be an ordered list where all the (·, t) pairs are listed before any (·, t + 1) pair, and the pairs for a given t (i.e., (i, t) ∈ St) are listed in arbitrary order. Let T0 = lPi,t yi,tm. We divide the pairs in S0 into y(A) = P(i,t)∈A yi,t, and the xj-weight of A as P(i,t)∈A xij,t. If 0 < y(S) ≤ 1, then we set Gℓ = S to end the grouping process. Otherwise, group Gℓ includes all pairs of S, taken in order starting from the first pair, stopping when the total y-weight of the included pairs becomes at least 1; all the included pairs are also deleted from S. If the y-weight of Gℓ now exceeds 1, then we split the last pair (i, t) into two copies: we include the first copy in Gℓ and retain the second copy in S, and distribute yi,t across the y-weight of the two copies so that y(Gℓ) is now exactly 1. (Thus, the new y-weight of S is precisely its old y-weight −1.) Also, for each client j, we distribute xij,t across the xj-weight of the two copies arbitrarily while maintaining that the xj-weight of each copy is at most its y-weight. We update ℓ ← ℓ + 1, and continue in this fashion with the current (i.e., ungrouped) list of pairs S. Note that an (i, t) pair in S0 may be split into at most two copies above (that lie in consecutive groups). To avoid notational clutter, we call both these copies (i, t) and use yℓ i,t to denote the y-weight of the copy in group Gℓ (which is equal to the original yi,t if (i, t) is not split). Analogously, we use xℓ ij,t to denote the xj-weight of the copy of (i, t) in group Gℓ. For every facility i, client j, and ℓ = 1, . . . , T0, we set y′ xℓ ij,t, so we have x′ ij,ℓ = Pt xij,t for every facility i and client j. Thus, (x′, y′) is feasible to (Unif-P), and parts (i) and (ii) of the lemma hold. To prove part (iii), t′=1 St′ and so i,ℓ. It is clear that Pℓ y′ i,ℓ = Pt yi,t and Pℓ x′ ij,ℓ = Pt:(i,t)∈Gℓ i,ℓ = Pt:(i,t)∈Gℓ i,t and x′ yℓ ij,ℓ ≤ y′ ℓ − 1 < kt. Thus, for any client j, we have note that if (some copy of) (i, t) is in Gℓ, then ℓ ≤ kt, since then we have (cid:0)Sℓ−1 kt Xℓ:(i,t)∈Gℓ ij,t(cid:1) = Xi,t Xℓ:(i,t)∈Gℓ ij,ℓ = Xi,ℓ ℓx′ ij,t ≤ Xi,t ℓxℓ ℓ(cid:0) Xt:(i,t)∈Gℓ r=1 Gr(cid:1) ⊂ St ij,t = k ·Xi,t xℓ txij,t. Xi,ℓ xℓ Proof of part (i) of Theorem 2.11 : We round the LP-optimal solution (x, y) by using filtering followed by standard randomized rounding. Clearly, we may assume thatPi′,t xi′j,t = 1 and yi,t = maxj xij,t for every i, j, t. Also, we may assume that if Pi yi,t+1 > 0, then Pi yi,t = 1, because otherwise for some facility i and some ǫ > 0, we may decrease yi,t+1 by ǫ and increase yi,t by ǫ, and modify the {xij,t+1, xij,t}j values appropriately so as to maintain feasibility, without increasing the total cost. Define Nj = {(i, t) : cij + t ≤ 2(C ∗ j )} for a client j. The algorithm is as follows. j + L∗ U1. For each (i, t), we set Yi,t = 1 independently with probability min{4 ln m · yi,t, 1}. U2. Considering each client j, if {(i, t) ∈ Nj : Yi,t = 1} = ∅, then set Yij ,1 = 1 where ij is such that fij = min(i,t)∈Nj fi (note that (ij, 1) ∈ Nj). Let Sj = {(i, t) ∈ Nj : Yi,t = 1} (which is non-empty). Assign each client j to the (i, t) pair in Sj with minimum cij + t value, i.e., set Xij,t = 1. 13 U3. Let K = maxtPi Yi,t. Use Lemma 2.15 to convert (X, Y ) into a feasible integer solution to (Unif-P). Let Cj and Lj denote respectively the connection cost and latency cost of client j in (X, Y ). We argue that (i) E(cid:2)Pi,t fiYi,t(cid:3) = O(ln m) · Pi,t fiyi,t, (ii) with probability 1, Cj + Lj ≤ 2(C ∗ j ) for every client j, and (iii) K = O(ln m) with high probability, and in expectation. The theorem then follows from Lemma 2.15. j + L∗ For any client j, we have P(i,t)∈Nj xij,t ≥ 1 Yi,t = 0] is at most e−4 ln m· 1 2 (by Markov's inequality). Thus, fij ≤ 2P(i,t)∈Nj fiyi,t 2 = 1/m2. The expected cost of opening facilities in and Pr[P(i,t)∈Nj step U1 is clearly at most 4 ln m · Pi,t fiyi,t. The expected facility-opening cost in step U2 is at most Pr[facility is opened in step U2]·Pj fij ≤ m· 1 m2 ·2mPi,t fiyi,t. So E(cid:2)Pi,t fiYi,t(cid:3) = O(ln m)·Pi,t fiyi,t. Since we always open some (i, t) pair in Nj, we have Cj + Lj ≤ 2(C ∗ Let S = {t : Pi yi,t > 0}. Note that S ≤ 1 + Pi,t yi,t ≤ 1 + Pj,i,t xij,t = m + 1. After step U1, we have E(cid:2)Pi Yi,t(cid:3) ≤ 4 ln m for every time t ∈ S. Since the Yi,t random variables are independent, we also have Pr[Pi Yi,t > 8 ln m] ≤ 1/m2 for all t ∈ S (and also, E(cid:2)maxt∈S Pi Yi,t(cid:3) = O(ln m)). Thus, after step U2, we have Pr[Pi Yi,1 > 8 ln m] ≤ 1/m2 + 1/m and Pr[Pi Yi,t > 8 ln m] ≤ 1/m2 for all t ∈ S, t > 1. Hence, Pr[K > 8 ln m] ≤ 2/m. (This also shows that E(cid:2)K(cid:3) = O(ln m).) j ) for every client j. Proof of part (ii) of Theorem 2.11 : We round (x, y) by applying filtering [23] followed by Lemma 2.15 to reduce the problem to a MSSC problem, and then use the result of Feige et al. [16] to obtain a near-optimal solution to this MSSC problem. Let j + L∗ min Xj,t txj,t s.t. Xt xj,t ≥ 1 ∀j, xj,t ≤ XS:j∈S yS,t ∀j, t, XS yS,t ≤ 1 ∀t, x, y ≥ 0. (P1) denote the standard LP-relaxation of MSSC [16] (here j indexes the elements, S indexes the sets, and t indexes time). Feige et al. showed that given a solution (x, y) to (P1), one can obtain in polytime an integer The rounding algorithm for ZFC MLUFL is as follows. Define Nj = {i : cij ≤ C ∗ solution of cost at most 4 ·Pj,t txj,t. j /(1 − α)}, so Pi∈Nj ,t xij,t ≥ α. For all i, j, t, set yi,t = yi,t/α, and xij,t = xij,t/α if i ∈ Nj and xij,t = 0 otherwise. It is easy to see that (x, y) satisfies Pi yi,t ≤ 1 α for all t, and all the other constraints of (Unif-P). We use Lemma 2.15 to convert (x, y) to a feasible solution (x′, y′) to (Unif-P). Next, we extract a solution to (P1) x′ ij,t. Now (¯x, y′) is a from (x′, y′). We identify facility i with the set {j : i ∈ Nj}, and set ¯xj,t = Pi∈Nj feasible solution to (P1). Finally, we round (¯x, y′) to an integer solution. This yields the ordering y = (yi,t) of the facilities. For each client j, if j is first covered by set i (so i ∈ Nj) at time (or position) t in the MSSC solution, then we set xij,t = 1. Analysis. Since a client j is always assigned to a facility in Nj, the connection cost of j is bounded by C ∗ j /(1 − α). To bound the latency cost, first we bound the cost of (x, y). Since we modify the assign- ment of a client j by transferring weight from farther facilities to nearer ones, it is clear that Pi,t cij xij,t ≤ Pi,t cijxij,t. Also, clearly Pj,i,t txij,t ≤ 1 α · Pj,i,t txij,t. and Pi yi,t ≤ 1 α. Thus, applying Lemma 2.15 α(cid:7) 1 ij,t ≤ (cid:6) 1 yields (x′, y′) satisfying Pj,i,t tx′ α · Pj,i,t txij,t. The result of [16] now implies that ij,t ≤ 4 α (cid:6) 1 Pj,i,t txij,t ≤ 4Pj,t t¯xj,t = 4Pj,i,t tx′ α(cid:7)Pj txij,t. 3 LP-relaxations and algorithms for the minimum-latency problem In this section, we consider the minimum-latency (ML) problem and apply our techniques to obtain LP- based insights and algorithms for this problem. We give two LP-relaxations for ML with constant integrality 14 gap. The first LP (LP1) is a specialization of (P) to ML, and to bound its integrality gap, we only need the fact that the natural subtour elimination LP for TSP has constant integrality gap. The second LP (LP2P) has exponentially-many variables, one for every path (or tree) of a given length bound, and the separation oracle for the dual problem corresponds to an (path- or tree-) orienteering problem. We prove that even a bicriteria approximation for the orienteering problem yields an approximation for ML while losing a constant factor. (The same relationship also holds between MGL and "group orienteering".) As mentioned in the Introduction, we believe that our results shed new light on ML and opens up ML to new venues of attack. Moreover, as shown in Section 4 these LP-based techniques can easily be used to handle more general variants of ML, e.g., k-route ML with Lp-norm latency-costs (for which we give the first approximation algorithm). We believe that our LP-relaxations are in fact (much) better than what we have accounted for, and conjecture that the integrality gap of both (LP1) and (LP2P) is at most 3.59, which is the currently best known approximation factor for ML. Let G = (D ∪ {r}, E) be the complete graph on N = D + 1 nodes with edge weights {de} that form a metric. Let r be the root node at which the path visiting the nodes must originate. We use e to index E and j to index the nodes. In both LPs, we have variables xj,t for t ≥ djr to denote if j is visited at time t (where t ranges from 1 to T); for convenience, we think of xj,t as being defined for all t, with xj,t = 0 if djr > t. (As in Section 2.1, one can move to a polynomial-size LP losing a (1 + ǫ)-factor.) A compact LP. As before, we use a variable ze,t to denote if e has been traversed by time t. min Xj,t txj,t subject to (LP1) Xt xj,t ≥ 1 ∀j; Xe deze,t ≤ t ∀t; Xe∈δ(S) ze,t ≥ Xt′≤t xj,t′ ∀t, S ⊆ D, j; x, z ≥ 0. Theorem 3.1 The integrality gap of (LP1) is at most 10.78. Proof : Let (x, z) be an optimal solution to (LP1), and L∗ j = Pt txj,t. For α ∈ [0, 1], define the α-point of j, τj(α), to be the smallest t such that Pt′≤t xjt′ ≥ α. Let Dt(α) = {j : τj(α) ≤ t}. We round (x, z) as follows. We pick α ∈ (0, 1] according to the density function q(x) = 2x. At each time t, we utilize the 3 2-integrality-gap of the subtour-elimination LP for TSP and the parsimonious property (see [33, 30, 18, 6]), to round 2z α . We now use Lemma 3.2 to combine these tours. α and obtain a tour on {r} ∪ Dt(α) of cost Ct(α) ≤ 3 α ·Pe deze,t ≤ 3t Lemma 3.2 ([19] paraphrased) Let Tour1, . . . , Tourk be tours containing r, with Touri having cost Ci and containing Ni nodes, where N0 := 1 ≤ N1 ≤ . . . ≤ Nk = N . One can find a subset Touri1, . . . , Tourib=k of tours, and a way of concatenating them that gives total latency at most 3.59 2 Pi Ci(Ni − Ni−1). The tours we obtain for the different times are nested (as the Dt(α)s are nested). SoPt≥1 Ct(α)(Dt(α)− τj (α) α . Thus, using Lemma 3.2, and Dt−1(α)) = Pj Pt:j∈Dt(α)\Dt−1(α) Ct(α) = Pj Cτj (α)(α) ≤ 3Pj taking expectation over α (note that E(cid:2) τj (α) j ), we obtain that the total latency-cost is at most (3.59 · 3)Pj L∗ j . Note that in the above proof we did not need any procedure to solve k-MST or its variants, but rather just needed the integrality gap for the subtour-elimination LP to be a constant. Also, we can modify the rounding procedure to ensure that (latency-cost of j) ≤ 18τj(0.5) for each client j, as follows. (Such a guarantee is useful to bound the total cost when its measured as an Lp norm for p > 1; see Section 4.) We now only consider times tℓ = 2ℓ. Recall that for any α ∈ (0, 1), at each time t, we can obtain a tour on {r} ∪ Dt(α) of cost Ct(α) ≤ 3t α . We take this tour for tℓ, and traverse the resulting tour randomly clockwise or anticlockwise (this choice can easily be derandomized), and concatenate all these tours. Let α (cid:3) ≤ 2L∗ 15 ℓj(α) be the smallest ℓ such that tℓ ≥ τj(α). So the (expected) latency-cost of j is at most Pℓ<ℓj (α) 1 2 · that (latency-cost of j) ≤ 18τj(0.5) for each j. 3tℓ α + α . Fixing α = 0.5, we obtain a 36-approximation with the per-client guarantee ≤ 9τj (α) α ≤ 4.5tℓj (α) 3tℓj (α) α An exponential-size LP: relating the orienteering and latency problems. Let Pt and Tt denote respec- tively the collection of all (simple) paths and trees rooted at r of length at most t. For each path P ∈ Pt, we introduce a variable zP,t that indicates if P is the path used to visit the nodes with latency-cost at most t. min s.t. txj,t Xj,t Xt XP ∈Pt XP ∈Pt:j∈P xj,t ≥ 1 zP,t ≤ 1 zP,t ≥ Xt′≤t xj,t′ x, z ≥ 0. (LP2P) ∀j ∀t ∀j, t (5) (6) max Xj s.t. βt αj −Xt αj ≤ t +Xt′≥t (LD2) θj,t′ ∀j, t (7) θj,t ≤ βt Xj∈P α, β, θ ≥ 0. ∀t, P ∈ Pt (8) (9) (5) and (6) encode that at most one path may be chosen for any time t, and that every node j visited at time t′ ≤ t must lie on this path. (LD2) is the dual LP with exponentially many constraints. Let (LP2T ) be the analogue of (LP2P) with tree variables, where we have variables zQ,t for every Q ∈ Tt, and we replace all occurrences of zP,t in (LP2P) with zQ,t. Separating over the constraints (8) involves solving a (rooted) path-orienteering problem: for every t, given rewards {θj,t}, we want to determine if there is a path P rooted at r of length at most t that gathers reward more than βt. A (ρ, γ)-{path, tree} approximation algorithm for the path-orienteering problem is an algorithm that always returns a {path, tree} rooted at r of length at most γ(length bound) that gathers reward at least (optimum reward)/ρ. Chekuri et al. [11] give a (2+ǫ, 1)-path approximation algorithm, whereas [10] design a (1 + ǫ, 1 + ǫ)-tree approximation for orienteering (note that weighted orienteering can be reduced to unweighted orienteering with a (1+ǫ)-factor loss). We prove that even a (ρ, γ)-tree approximation algorithm for orienteering can be used to obtain an O(ργ)-approximation for ML. First, we show how to compute a near-optimal LP-solution. Typically, one argues that, scaling the solution computed by the ellipsoid method run on the dual with the approximate separation oracle yields a feasible and near-optimal dual solution, and this is then used to obtain a near-optimal primal solution (see, e.g., [24]). However, in our case, we have negative terms in the dual objective function, which makes our task trickier: if our (unicriteria) ρ- approximate separation oracle determines that (α, β, θ) is feasible, then although (α, ρβ, θ) is feasible to (LD2), one has no guarantee on the value of this dual solution. Instead, the notion of approximation we obtain for the primal solution computed involves bounded violation of the constraints. Let (cid:0)LP2(a,b) P (cid:1) be (LP2P) where we replace Pt by Pbt, and the RHS of (5) is now a. Let (cid:0)LP2(a,b) defined analogously. Let OPT P be the optimal value of (LP2P) (i.e., (cid:0)LP2(1,1) lower bound on the optimum latency. (cid:1) be (cid:1)). Note that OPT P is a P T Lemma 3.3 Given a (ρ, γ)-tree approximation for the orienteering problem, one can compute a feasible solution (x, z) to (cid:0)LP2(ρ,γ) T (cid:1) of cost at most OPT . 16 Proof : Lemma 3.3 Define Pfeas(ν; a, b) Tfeas(ν; a, b) := n(α, β, θ) : := n(α, β, θ) : (7), (7), (9), Xj∈P (9), Xj∈Q θj,t ≤ βt ∀P ∈ Pbt, Xj θj,t ≤ βt ∀Q ∈ Tbt, Xj αj − aXt αj − aXt βt ≥ νo, βt ≥ νo. Note that OP TP is the largest value of ν such that Pfeas(ν; 1, 1) is feasible. Given ν, (α, β, θ), if there was an algorithm to either show (α, β, θ) ∈ Pfeas(ν; 1, 1) or exhibit a separating hyperplane, then using the ellipsoid method we could optimally solve for OP TP. However, such a separation oracle would solve orienteering exactly. We use the (ρ, γ)-tree approximation algorithm to give an approximate separation oracle in the following sense. Given ν, (α, β, θ), we either show (α, ρβ, θ) ∈ Pfeas(ν; 1, 1), or we exhibit a hyperplane separating (α, β, θ) and Tfeas(ν; ρ, γ). Note that Tfeas(ν; ρ, γ) ⊆ Pfeas(ν; 1, 1). Thus, for a fixed ν, the ellipsoid method in polynomial time, either certifies that Tfeas(ν; ρ, γ) is empty or returns a point (α, β, θ) with (α, ρβ, θ) ∈ Pfeas(ν; 1, 1). Let us describe the approximate separation oracle first, and then use the above appropriate inequality as the separating hyperplane between (α, β, θ) and Tfeas(ν; ρ, γ). Next, for each t, fact to prove the lemma. First, check if (Pj αj − ρβt ≥ ν), (7), and (9) hold, and if not, we use the we run the (ρ, γ)-tree approximation on the orienteering problem specified by (cid:0)G, {de}(cid:1), root r, rewards {θj,t}, and budget t. If for some t, we obtain a tree Q ∈ Tγt with reward greater than βt, then we return Pj∈Q θj,t ≤ βt as the separating hyperplane. If not, then for all paths P of length at most t in G, we have Pj∈P θj,t ≤ ρβt and thus (α, ρβ, θ) ∈ Pfeas(ν; 1, 1). We find the largest ν∗ (via binary search) such that the ellipsoid method run for ν∗ with our separation oracle returns a solution (α∗, β∗, θ∗) with (α∗, ρβ∗, θ∗) ∈ Pfeas(ν∗; 1, 1); hence, we have ν∗ ≤ OPT P (by duality). Now for ǫ > 0, the ellipsoid method run for ν∗ + ǫ terminates in polynomial time certifying the infeasibility of Tfeas(ν∗ + ǫ; ρ, γ). That is, it generates a polynomial number of inequalities of the form (7), constitute an infeasible system. Applying Farkas' lemma, equivalently, we get a polynomial sized solution (9), and (Pj∈Q θj,t ≤ βt) where Q ∈ Tγt, which together with the inequality Pj αj − ρPt βt ≥ ν∗ + ǫ (x, z) to (cid:0)LP2(ρ,γ) (cid:1) that has cost at most ν∗ + ǫ. Taking ǫ small enough (something like 1/ exp(input size) so that ln(1/ǫ) is still polynomially bounded), this also implies that (x, z) has cost at most ν∗ ≤ OPT P. This completes the proof of the lemma. T P T 17 Proof : We prove part (i) first. (Note that for ML, the analysis leading to Theorem 3.1 already implies that (cid:1) can be rounded to obtain a solution of cost at most (3.59 · 2)ργ Pj,t txj,t. Theorem 3.4 (i) A feasible solution (x, z) to(cid:0)LP2(ρ,γ) (cid:1) (or the corresponding LP-relaxation for MGL) can be rounded to obtain a solution of expected cost at most O(ργ) ·Pj,t txj,t; (ii) A feasible solution (x, z) to (cid:0)LP2(ρ,γ) one can obtain a solution of cost at most 10.78ργ Pj,t txj,t, because setting ze,t = PQ∈Tγt:e∈Q zQ,t yields a solution (x, z) that satisfies Pe deze,t ≤ ργt and all other constraints of (LP1).) We sketch a (randomized) rounding procedure that also works for MGL and yields improved guarantees. We may assume that each zQ,t ∈ [0, 1]. At each time tℓ = 2ℓ, ℓ = ⌈log2 T + 4 log2 m⌉, we select at most ⌈wtℓ⌉ trees from Tbtℓ, picking each Q ∈ Tγtℓ with probability zQ,tℓ. (We can always do this (efficiently) since for every time t, the polytope {z ∈ [0, 1]Tbt Note that expected cost of the resulting subgraph is at most wtγtℓ ≤ ργtℓ. We "Eulerify" the resulting subgraph to obtain a tour for tℓ of cost at most 2ργtℓ, and concatenate these tours. The probability that xj,t, which implies that with high : PQ zQ,t ≤ lPQ zQ,tm} is integral.) We take the union of all these trees. j is not visited (or covered) by the tour for tℓ is at most 1 − Pt≤tℓ probability, we obtain a tour spanning all nodes. Letting τj = tj(cid:0) 2 most 2ργ(cid:0)2τj + 2τj Pk≥0( 2 3 )k(cid:1) ≤ 16ργτj. 3(cid:1), the expected latency-cost of j is at To prove part (ii), we adopt a rounding procedure that again utilizes Lemma 3.2, and yields the stated bound (deterministically). Recall that τj(α) denotes the α-point of j. Let Dt(α) = {j : τj(α) ≤ t}. For any α ∈ (0, 1), and time t, we now show to obtain a tour spanning Dt(α) ∪ {r} of cost at most 2ργt α . We can then proceed as in the rounding procedure for Theorem 3.1 to argue that, for the tours we obtain, the tj (α) α . Hence, choosing α as before according to the distribution q(x) = 2x and taking expectations, we obtain a solution with the stated cost. quantity Pi Ci(Ni − Ni−1) appearing in Lemma 3.2 is bounded by 2ργPj Let K be such that Kα, {KzP,t}P ∈Pγt are integers. For each P with zP,t > 0, we create KzP,t copies of each edge on P , and direct the edges away from r. Let AP,t denote the resulting arc-set. Note that in At := UP :zP,t>0 AP,t, every node j ∈ D has in-degree at least its out-degree, and there are Kα arc- disjoint paths from r to j for each j ∈ Dt(α). So applying Theorem 2.6 in Bang-Jensen et al. [4], one can obtain Kα arc-disjoint out-arborescences rooted at r, each containing all nodes of Dt(α). Thus, if we pick the cheapest such arborescence and "Eulerify" it, we obtain a tour spanning Dt(α) ∪ {r} of cost at most 2 · Kργt · 1 Kα = 2ργt α . In Appendix A, we prove an analogue of Lemma 3.3 for MGL. Combined with part (i) of Theorem LP2P, this shows that (even) a bicriteria approximation for "group orienteering" yields an approximation for MGL while losing a constant factor. 4 Extensions We now consider various well-motivated extensions of MLUFL, and show that our LP-based techniques and algorithms are quite versatile and extend with minimal effort to yield approximation guarantees for these more general MLUFL problems. Our goal here is to emphasize the flexibility afforded by our LP-based techniques, and we have not attempted to optimize the approximation factors. Monotone latency-cost functions with bounded growth, and higher Lp norms. Consider the general- ization of MLUFL, where we have a non-decreasing function λ(.) and the latency-cost of client j is given by λ(time taken to reach the facility serving j); the goal, as before, is to minimize the sum of the facility- opening, client-connection, and client-latency costs. Say that λ has growth at most p if λ(cx) ≤ cpλ(x) for all x ≥ 0, c ≥ 1. It is not hard to see that for concave λ, we obtain the same performance guarantees as those obtained in Section 2 (for λ(x) = x). So we focus on the case when λ is convex, and obtain an O(cid:0)max{(p log2 n)p, p log n log m}(cid:1)-approximation algorithm for convex latency functions of growth p. As a corollary, we obtain an O(cid:0)p log n max{log n, log m}(cid:1)-approximation for Lp-MLUFL, where we seek to minimize the facility-opening cost + client-connection cost + the Lp-norm of client-latencies. Theorem 4.1 There is an O(cid:0)max{(p log2 n)p, p log n log m}(cid:1)-approximation algorithm for MLUFL with convex monotonic latency functions of growth (at most) p. Proof : We highlight the changes to the algorithm and analysis in Section 2.1. We again assume that T = poly(m) for convenience. This assumption can be dropped by proceeding as in Theorem 2.8; we do after proving the theorem. The objective of (P) now changes to min Pi,t fiyi,t +Pj,i,t(cid:0)cij +λ(t)(cid:1)xij,t. The only change to Algorithm 1 is that we now define tℓ = min{2ℓ/p, T} and set N := (cid:6)p log2(21/pτmax) + 4 log2 m(cid:7) = O(p log m). Define Lcostj = Pi,t λ(t)xij,t. Note that we now have λ(τj) ≤ 12Lcostj. Define ℓj to be the first phase ℓ such that tℓ ≥ τj. Let the random variable Pj be as defined in Lemma 2.5. The failure probabil- ity of the algorithm is again at most 1/ poly(m). The facility-cost incurred in O(p log n log m)Pi,t fiyi,t, 18 and the connection cost of client j is at most 4C ∗ O(cid:0)(p log2 n)p(cid:1)λ(tℓj ) ≤ O(cid:0)(2p log2 n)p(cid:1) · λ(τj), which yields the desired approximation. We have j . We generalize Lemma 2.5 below to show that E(cid:2)Lj(cid:3) = Lj ≤ λ(cid:0)Xℓ≤Pj d(Tourℓ)(cid:1) ≤ λ(cid:0)O(log2 n) Xℓ≤Pj tℓ(cid:1) ≤ O(log2p n)λ(cid:0)Xℓ≤Pj tℓ(cid:1), so E(cid:2)Lj(cid:3) ≤ O(log2p n)hλ(cid:0)Pℓ≤ℓj 9(cid:1)k, Pℓ≤ℓj+k tℓ ≤ tℓj · (cid:0) 4 tℓ(cid:1) +Pk≥1 Pr[Pj ≥ ℓj + k]λ(cid:0)Pℓ≤ℓj+k tℓ(cid:1)i. Now, Pr[Pj ≥ ℓj + k] ≤ 2k/p 1−2−1/p , and (21/p − 1) ≥ ln 2 p . Plugging these in gives, E(cid:2)Lj(cid:3) = O(log2p n) · 2 (21/p − 1)p · λ(tℓj ) ·Xk≥0(cid:16) 4 9(cid:17)k 2k = O(cid:0)(p/ ln 2)p log2p n(cid:1)λ(tℓj ). Removing the assumption T = poly(m) in Theorem 4.1. As in the case of Theorem 2.8, to drop the as- sumption that T = poly(m), we (a) solve the LP considering only times in TS = {T0, . . . , Tk} (where Tr = ⌈(1 + ǫ)r⌉); and (b) set tℓ = TS(L·2ℓ/p) and the number of phases to N := (cid:6)p log2(21/pτmax/L) + 4 log2 m(cid:7), where L = (Pj,i,t txij,t)/m. Note that N = O(p log m), and λ(L) ≤ (Pj,i,t λ(t)xij,t)/m = (Pj Lcostj)/m, which shows that the expected latency cost incurred for clients j with τj ≤ t0 is at most Pj Lcostj. Corollary 4.2 One can obtain an O(cid:0)p log n max{log n, log m}(cid:1)-approximation algorithm for Lp-MLUFL. Proof : As is standard, we enumerate all possible values of the Lp-norm of the optimal client latencies in powers of 2, losing potentially another factor of 2 in the approximation factor. To avoid getting into issues about estimating the solution-cost for a given guess (since our algorithms are randomized), we proceed as follows. For a given guess Lat, we solve (P) modifying the objective to be min Pi,t fiyi,t +Pj,i,t cijxij,t, and we adding the constraint Pj,i,t tpxij,t ≤ Latp. Among all such guesses and corresponding optimal solutions, let (x, y, z) be the solution that minimizes Pi,t fiyi,t + Pj,i,t cijxij,t + Lat. Let OPT denote this minimum value. Note that OPT ≤ 2O∗, where O∗ is the optimum value of the Lp-MLUFL instance. We apply Theorem 4.1 (with λ(x) = xp) to round (x, y, z). Let F , C, and L = Pj Lj, denote respectively rem 4.1 imply that E(cid:2)(Pj Lj)1/p(cid:3) ≤ (cid:0)E(cid:2)Pj Lj(cid:3)(cid:1)1/p ≤ O(p log2 n)Lat, which combined with the bounds on E(cid:2)F(cid:3) and E(cid:2)C(cid:3), shows that the expected total cost is O(cid:0)p log n max{log n, log m}(cid:1)OPT . the (random) facility-opening, connection-, and latency- cost of the resulting solution. The bounds in Theo- We obtain significantly improved guarantees for related MLUFL, metric uniform MLUFL, and ML with (convex) latency functions of growth p. For related MLUFL and ML, the analyses in Sections 2.2 and 3 directly yield an O(cid:0)2O(p)(cid:1)-approximation guarantee since for both problems, we can (deterministically) bound the delay of client j by O(cid:0)α-point of j(cid:1) (for suitable α). For metric uniform MLUFL, we obtain an O(1)-approximation bound as a consequence of Theorem 2.12: this follows because one can devise an O(1)-approximation algorithm for the zero-facility-cost version of the problem by adapting the ideas used in [3]. Thus, we obtain an O(1)-approximation for the Lp-versions of related-MLUFL, metric uniform MLUFL, and ML. k-route MLUFL with length bounds. All our algorithms easily generalize to k-route length-bounded MLUFL, where we are given a budget B and we may use (at most) k paths starting at r of (d-) length at most B to traverse the open facilities and activate them. This captures the scenario where one can use k vehicles in parallel, each with capacity B, starting at the root depot to activate the open facilities. Observe that with B = ∞, we obtain a generalization of the k-traveling repairmen problem considered in [14]. We modify (P) by setting T = B and setting the RHS of (3) to kt. In Algorithm 1, we now obtain a yi,t > 0, tour Tourℓ in phase ℓ of (expected length) O(log2 n)ktℓ. Each facility i ∈ Tourℓ satisfies Pt≤tℓ 19 so d(i, r) ≤ tℓ, and we may therefore divide Tourℓ into k tours of length at most O(log2 n)tℓ. Thus, we obtain the same guarantee on the expected cost incurred, and we violate the budget by an O(log2 n)-factor, that is, we get a bicriteria (cid:0)polylog, O(log2 n)(cid:1)-approximation. Similarly, for related MLUFL and ML, we obtain an (cid:0)O(1), O(1)(cid:1)-approximation. For ML, we may again use either (LP1) or (LP2P): in both LPs we set T = B; in (LP1), we now have the constraint Pe deze,t ≤ kt, and in (LP2P), the RHS of (5) is now k. For metric uniform MLUFL, we modify (Unif-P) in the obvious way: we now have Pt yi,t ≤ k for each time t, and t now ranges from 1 to B. We can again apply Theorem 2.12 here to obtain a (unicriteria) O(1)-approximation algorithm: for the zero-facility-location problem (where we may now "open" at most kB facilities), we can adapt the ideas in [3] to devise an O(1)-approximation algorithm. Finally, these guarantees extend to latency functions of bounded growth (in the same way that guar- antees for MLUFL extend to the setting with latency functions). Thus, in particular, we obtain an O(1)- approximation algorithm for the Lp-norm k-traveling repairmen problem; this is the first approximation guarantee for this problem. Non-uniform latency costs. We consider here the setting where each client j has a (possibly different) time-to-cost conversion factor λj, which measures j's sensitivity to time delay (vs. connection cost); so the latency cost of a client j is now given by λjtj, where tj is the delay faced by the facility serving j. All our guarantees in Sections 2.2, 2.3, and 3 continue to hold in this non-uniform latency setting. In particular, we obtain a constant approximation guarantee for related metric MLUFL, metric uniform MLUFL, and ML. Notice that the metric uniform MLUFL problem cannot now be solved via a reduction to the metric-UFL variant discussed in Section 2.3; however we can still use Corollary 2.13 to obtain a 10.773-approximation. For general MLUFL, it is not hard to see that our analysis goes through under the the assumption T = poly(m). However, the scaling trick used to bypass this assumption leads to an extra λmin )(cid:1) factor in the approximation. O(cid:0)log( λmax Recall that the scaling factor L (in the definition of tℓ) in Section 2.1 was defined as Pj L∗ j /m, where j = Pi,t txij,t. Now, L∗ j /Pj λj. One can again argue that the expected latency-cost of each client j is at most λj ·O(log2 n)·max(cid:8)L, τj}, so we incur an O(log2 n)-factor in the latency-cost. The number of phases, however, is N := (cid:6)log2(2τmax/L) + 4 log2 m(cid:7), and 2τmax/L = O(cid:0) τmax Pj λj j = Pi,t λjtxij,t, and we set L = Pj L∗ ), which gives an extra log2(λmax/λmin) factor in the facility-opening cost. Finally, as before, these guarantees also translate to the k-route length-bounded versions of our problems. L∗ Pj L∗ j ) ≤ O(cid:0) mλmax λmin References [1] A. Archer, A. Levin, and D. Williamson. A faster, better approximation algorithm for the minimum latency problem. SIAM J. Comput., 37(5):1472 -- 1498, 2008. [2] Y. Azar, I. Gamzu, and X. Yin. Multiple intents re-ranking. In Proceedings of 41st STOC, pages 669 -- 678, 2009. [3] I. Baev, R. Rajaraman, and C. Swamy. Approximation algorithms for data placement problems. SIAM Journal on Computing, 38(4):1411 -- 1429, 2008. [4] J. Bang-Jensen, A. Frank, and B. Jackson. Preserving and increasing local edge-connectivity in mixed graphs. SIAM Journal on Discrete Mathematics, 8(2):155 -- 178, 1995. [5] N. Bansal, A. Gupta, and R. Krishnaswamy. A constant factor approximation algorithm for generalized min-sum set cover. In Proceedings of 21st SODA, pages 1539 -- 1545, 2010. 20 [6] D. Bienstock, M. Goemans, D. Simchi-Levi, and D. Williamson. A note on the prize collecting travel- ing salesman problem. Math. Program., 59:413 -- 420, 1993. [7] A. Blum, P. Chalasani, D. Coppersmith, B. Pulleyblank, P. Raghavan, and M. Sudan. The Minimum Latency Problem. In Proceedings of 26th STOC, pages 163 -- 171, 1994. [8] J. Byrka. An optimal bifactor approximation algorithm for the metric uncapacitated facility location problem. In Proceedings of the 10th APPROX, pages 29 -- 43, 2007. [9] M. Charikar, C. Chekuri, A. Goel, and S. Guha. Rounding via trees: deterministic approximation algorithms for Group Steiner Trees and k-median. In Proeedings of the 30th STOC, pages 114 -- 123, 1998. [10] K. Chaudhuri, P. B. Godfrey, S. Rao, and K. Talwar. Paths, Trees and Minimum Latency Tours. In Proceedings of 44th FOCS, pages 36 -- 45, 2003. [11] C. Chekuri, N. Korula, and M. P´al. Improved algorithms for orienteering and related problems. In Proceedings of 19th SODA, pages 661 -- 670, 2008. [12] F. Chudak and D. Shmoys. Improved approximation algorithms for the uncapacitated facility location problem. SIAM Journal on Computing, 33(1):1 -- 25, 2003. [13] F. Eisenbrand, F. Grandoni, T. Rothvoss, and G. Schafer. Approximating connected facility location problems via random facility sampling and core detouring. In Proceedings of 19th SODA, pages 1174 -- 1183, 2008. [14] J. Fakcharoenphol, C. Harrelson, and S. Rao The k-travelling repairman problem. ACM Trans. on Alg., Vol 3, Issue 4, Article 40, 2007. [15] J. Fakcharoenphol, S. Rao, and K. Talwar. A tight bound on approximating arbitrary metrics by tree metrics. In Proceedings of 35th STOC, pages 448 -- 455, 2003. [16] U. Feige, L. Lov´asz, and P. Tetali. Approximating min sum set cover. Algorithmica, 40(4):219 -- 234, 2004. [17] N. Garg, G. Konjevod, and R. Ravi. A polylogarithmic approximation algorithm for the group Steiner tree problem. Journal of Algorithms, 37(1):66 -- 84, 2000. [18] M. Goemans and D. Bertsimas. Survivable networks, linear programming relaxations and the parsi- monious property. Mathematical Programming, 60:145 -- 166, 1993. [19] M. Goemans and J. Kleinberg. An improved approximation ratio for the minimum latency problem. In Proceedings of 7th SODA, pages 152 -- 158, 1996. [20] A. Gupta, J. Kleinberg, A. Kumar, R. Rastogi, and B. Yener. Provisioning a virtual private network: A network design problem for multicommodity flow. In Proceedings of the 33rd Annual ACM Symposium on Theory of Computing, pages 389 -- 398, 2001. [21] A. Gupta, R. Krishnaswamy, V. Nagarajan, and R. Ravi. Approximation Algorithms for Optimal Deci- sion Trees and Adaptive TSP Problems. arXiv:1003.0722, to appear in ICALP 2010. [22] E. Halperin and R. Krauthgamer. Polylogarithmic inapproximability. In Proceedings of 35th STOC, pages 585 -- 594, 2003. 21 [23] J. H. Lin and J. S. Vitter. ǫ-approximations with minimum packing constraint violation. In Proceedings of the 24th Annual ACM Symposium on Theory of Computing, pages 771 -- 782, 1992. [24] K. Jain, M. Mahdian, and M. Salavatipour. Packing Steiner trees. In Proceedings of 14th SODA, pages 266 -- 274, 2003. [25] P. Mirchandani and R. Francis, eds. Discrete Location Theory. John Wiley and Sons, Inc., New York, 1990. [26] V. Nagarajan. Approximation Algorithms for Sequencing Problems. Ph.D. thesis, Tepper School of Business, Carnegie Mellon University, 2009. [27] R. Ravi and F. S. Selman. Approximation algorithms for the traveling purchaser problem and its variants in network design. In Proceedings of the 7th Annual European Symposium on Algorithms, pages 29 -- 40, 1999. [28] D. Shmoys, R. Levi, and C. Swamy. Facility location with service installation costs. In Proceedings of 15th SODA, pages 1081 -- 1090, 2004. [29] D. B. Shmoys, ´E. Tardos, and K. I. Aardal. Approximation algorithms for facility location problems. In Proceedings of the 29th Annual ACM Symposium on Theory of Computing, pages 265 -- 274, 1997. [30] D. Shmoys and D. Williamson. Analyzing the Held-Karp TSP bound: a monotonicity property with application. Inf. Process. Lett., 35(6):281 -- 285, 1990. [31] C. Swamy and A. Kumar. Primal-dual algorithms for connected facility location problems. Algorith- mica, 40(4):245 -- 269, 2004. [32] P. Toth and D. Vigo, eds. The Vehicle Routing Problem. SIAM Monographs on Discrete Mathematics and Applications, Philadelphia, 2002. [33] L. Wolsey. Heuristic analysis, linear programming and branch and bound. Mathematical Programming Study, 13:121-134, 1980. A Proofs omitted from the main body Proof of Theorem 2.9 : Consider a GST instance (cid:0)H = (V, E), r, {de}e∈E, {Gj ⊆ V }m j=1). Let n = V . We may assume that H is the complete graph, d is a metric, and the groups are disjoint. We abbreivate ρn,m to ρ below. Let Q denote the collection of all solutions to the path-variant of GST; that is, Q consists of all paths starting at r that visit at least one node of each group. For a path Q ∈ Q and a group Gj, define de be the length of Qj; that is, dj(Q) is the latency of group j along path Q. Consider the following LP-relaxation for the path-variant of GST, and its dual. We have a variable xQ for every Q ∈ Q indicating if path Q is chosen. We use Q below to index the paths in Q. Qj to be the portion of Q from r to the first node of Gj lying on Q. Let dj(Q) = Pe∈Qj min M (P') max α s.t. XQ dj(Q)xQ ≤ M ∀j s.t. Xj λjdj(Q) ≥ α ∀Q (D') (10) xQ ≥ 1 XQ x ≥ 0. λj ≤ 1 Xj α, λ ≥ 0. 22 (P') has an exponential number of variables. But observe that separating over the constraints (10) in the dual involves solving an MGL problem. The minimum value (over all Q ∈ Q) of the LHS of (10) is the optimal value of the MGL problem defined by {(Gj, λj)}, where we seek to minimize the weighted sum of client latency costs. (This weighted group latency problem can be reduced to the unweighted problem by "creating" λj copies of each group Gj (we can scale the λjs so that they are integral); equivalently (instead of explicitly creating copies), one can simulate this copying-process in whatever algorithm one uses for (unweighted) MGL.) Thus, a ρ-approximation algorithm for MGL yields a ρ-approximate separation oracle for (D'). Now, applying an argument similar to the one used by Jain et al. [24] shows that one can use this to (also) obtain a ρ-approximate solution (x, M ) to (P'). We now use randomized rounding to round (x, M ) and obtain a group Steiner tree of cost at most O(log m)M. We pick path Q independently with probability min{4 log m · xQ, 1}. Let Q′ ⊆ Q denote the collection of paths picked. Note that for every group Gj, we have PQ∈Q:dj(Q)≤2M xQ ≥ 1 2 . So a standard set-cover argument shows that with probability at least 1 − 1/m, for every j, there is some path Q(j) ∈ Q′ such that dj(Q(j)) ≤ 2M. We may assume that PQ xQ = 1, so Chernoff bounds show that Q′ = O(log m) with overwhelming probability. The group Steiner tree T consists of the union of all the Q(j) (sub)paths (deleting edges to remove cycles as necessary). Clearly, the cost of T is at most j Q′ · 2M = O(log m)M. Note that T also yields a path of length O(log m)M starting at r and visiting all groups, so the integrality gap of (P') is O(log m). Extension of Lemma 3.3 to MGL. Notice that we did not use anything specific to the minimum-latency problem in the proof, and so essentially the same proof also applies to MGL. Recall that in MGL, we have a set F of facilities and a d-metric on F ∪ {r}, and a collection of m groups {Gj ⊆ F}. Analogous to (cid:0)LP2(a,b) P (cid:1), the LP-relaxation with path variables for MGL and its dual are as follows. min s.t. Xj,t Xt XP ∈Pbt XP ∈Pbt:Gj∩P 6=∅ txj,t xj,t ≥ 1 zP,t ≤ a zP,t ≥ Xt′≤t x, z ≥ 0. (LP'(a,b) P ) max s.t. ∀j ∀t xj,t′ ∀j, t Xj βt αj − aXt αj ≤ t +Xt′≥t θj,t′ ∀j, t (LD'P (a, b)) Xj:Gj∩P 6=∅ θj,t ≤ βt α, β, θ ≥ 0. ∀t, P ∈ Pbt (11) The LP-relaxation (cid:0)LP'(a,b) T (cid:1) with tree variables is obtained by replacing Pbt with Tbt in (LP'(a,b) P ). The orienteering problem that we need to solve now to separate over the constraints (11) is group orienteering: given a reward θj,t for each group Gj, we want to determine if there is a path (or tree) rooted at r of length at most bt such that the total reward of the groups covered by it is more than βt. Given these changes, the proof (cid:1) is (cid:1) of cost at most the optimal value of (cid:0)LP'(1,1) that one can obtain a feasible solution (x, y) to (cid:0)LP'(a,b) as in the proof of Lemma 3.3. P T 23
1911.09165
1
1911
2019-11-20T20:38:24
The Karger-Stein Algorithm is Optimal for $k$-cut
[ "cs.DS" ]
In the $k$-cut problem, we are given an edge-weighted graph and want to find the least-weight set of edges whose deletion breaks the graph into $k$ connected components. Algorithms due to Karger-Stein and Thorup showed how to find such a minimum $k$-cut in time approximately $O(n^{2k-2})$. The best lower bounds come from conjectures about the solvability of the $k$-clique problem and a reduction from $k$-clique to $k$-cut, and show that solving $k$-cut is likely to require time $\Omega(n^k)$. Our recent results have given special-purpose algorithms that solve the problem in time $n^{1.98k + O(1)}$, and ones that have better performance for special classes of graphs (e.g., for small integer weights). In this work, we resolve the problem for general graphs, by showing that for any fixed $k \geq 2$, the Karger-Stein algorithm outputs any fixed minimum $k$-cut with probability at least $\hat{O}(n^{-k})$, where $\hat{O}(\cdot)$ hides a $2^{O(\ln \ln n)^2}$ factor. This also gives an extremal bound of $\hat{O}(n^k)$ on the number of minimum $k$-cuts in an $n$-vertex graph and an algorithm to compute a minimum $k$-cut in similar runtime. Both are tight up to $\hat{O}(1)$ factors. The first main ingredient in our result is a fine-grained analysis of how the graph shrinks---and how the average degree evolves---under the Karger-Stein process. The second ingredient is an extremal result bounding the number of cuts of size at most $(2-\delta) OPT/k$, using the Sunflower lemma.
cs.DS
cs
The Karger-Stein Algorithm is Optimal for k-cut Anupam Gupta∗ Euiwoong Lee† CMU NYU Jason Li‡ CMU Abstract In the k-cut problem, we are given an edge-weighted graph and want to find the least-weight set of edges whose deletion breaks the graph into k connected components. Algorithms due to Karger-Stein and Thorup showed how to find such a minimum k-cut in time approximately O(n2k−2). The best lower bounds come from conjectures about the solvability of the k-clique problem and a reduction from k-clique to k-cut, and show that solving k-cut is likely to require time Ω(nk). Our recent results have given special-purpose algorithms that solve the problem in time n1.98k+O(1), and ones that have better performance for special classes of graphs (e.g., for small integer weights). In this work, we resolve the problem for general graphs, by showing that for any fixed k ≥ 2, the Karger-Stein algorithm outputs any fixed minimum k-cut with probability at least (cid:98)O(n−k), where (cid:98)O(·) hides a 2O(ln ln n)2 factor. This also gives an extremal bound of (cid:98)O(nk) on the number similar runtime. Both are tight up to (cid:98)O(1) factors. of minimum k-cuts in an n-vertex graph and an algorithm to compute a minimum k-cut in The first main ingredient in our result is a fine-grained analysis of how the graph shrinks -- and how the average degree evolves -- under the Karger-Stein process. The second ingredient is an extremal result bounding the number of cuts of size at most (2 − δ)OP T /k, using the Sunflower lemma. ∗ [email protected]. Supported in part by NSF award CCF-1907820, and the Indo-US Joint Center for Algo- rithms Under Uncertainty. † ‡ [email protected]. Supported in part by the Simons Collaboration on Algorithms and Geometry. [email protected]. Supported in part by NSF award CCF-1907820. 1 Introduction We consider the k-Cut problem: given an edge-weighted graph G = (V, E, w) and an integer k, delete a minimum-weight set of edges so that G has at least k connected components. This problem generalizes the global min-cut problem, where the goal is to break the graph into k = 2 pieces. It was unclear that the problem admitted a polynomial-time algorithm for fixed values of k, until the work of Goldschmidt and Hochbaum, who gave a runtime of O(n(1/2−o(1))k2) [GH94]. (Here and subsequently, the o(1) in the exponent indicates a quantity that goes to 0 as k increases.) The randomized minimum-cut algorithm of Karger and Stein [KS96], based on random edge con- tractions, can be used to solve k-Cut in O(n2(k−1)) time. For deterministic algorithms, there have been improvements to the Goldschmidt and Hochbaum result [KYN07, Tho08, CQX18]: no- tably, the tree-packing result of Thorup [Tho08] was sped up by Chekuri et al. [CQX18] to run in O(mn2k−3) time. Hence, until recently, randomized and deterministic algorithms using very different approaches achieved O(n(2−o(1))k) bounds for the problem. On the hardness side, one can reduce Max-Weight (k − 1)-Clique to k-Cut. It is conjectured that solving Max-Weight (k − 1)-Clique requires Ω(n(1−o(1))k) time when weights are integers in the range [1, Ω(nk)], and Ω(n(ω/3)k) time for unit weights; here ω is the matrix multiplication constant. Hence, these runtime lower bounds also extend to the k-Cut, suggesting that Ω(nk) may be the optimal runtime for general weighted k-cut instances. There has been recent progress on this problem, showing the following results: 1. We showed an O(n(1.98+o(1))k)-time algorithm for general k-Cut [GLL19]. This was based on giving an extremal bound on the maximum number of "small" cuts in the graph, and then using a bounded-depth search approach to guess the small cuts within the optimal k-cut and make progress. This was a proof-of-concept result, showing that the bound of n(2−o(1))k was not the right bound, but it does not seem feasible to improve that approach to exponents considerably below 2k. 2. For graphs with polynomial integer weights, we showed how to solve the problem in time approximately kO(k) n(2ω/3+o(1))k [GLL18]. And for unweighted graphs we showed how to get the kO(k)n(1+o(1)k runtime [Li19]. Both these approaches were based on obtaining a spanning tree cut by a minimum k-cut in a small number of edges, and using involved dynamic programming methods on the tree to efficiently compute the edges and find the k-cut. The former relied on matrix multiplication ideas, and the latter on the Kawarabayashi-Thorup graph decomposition, both of which are intrinsically tied to graphs with small edge-weights. In this paper, we show that the "right" algorithm, the original Karger-Stein algorithm, achieves the "right" bound for general graphs. Our main result is the following. Theorem 1 (Main). Given a graph G and a parameter k ≥ 2, the Karger-Stein algorithm outputs any fixed minimum k-cut in G with probability at least n−k · (k ln n)−O(k2 ln ln n). For any fixed constant k ≥ 2, the above bound becomes nk · 2O(ln ln n)2. This immediately implies the following two corollaries, where (cid:98)O(·) hides a quasi-logarithmic factor 2O(ln ln n)2: k-cuts in a graph is at most (cid:98)O(nk). Corollary 2 (Number of Minimum k-cuts). For any fixed k ≥ 2, the number of minimum-weight 1 This bound significantly improves the previous best bound n(1.98+o(1))k [GLL19]. It is also almost tight because the cycle on n vertices has Ω(nk) minimum k-cuts. Corollary 3 (Faster Algorithm to Find a Minimum k-cut). For any fixed k ≥ 2, there is a randomized algorithm that computes a minimum k-cut of a graph with high probability in time (cid:98)O(nk).1 This improves the running time n(1.98+o(1))k for the general weighted case [GLL19] and even the running time n(1+o(1))k for the unweighted case [Li19], where the extra no(k) term is still at least polynomial for fixed k. It is also almost tight under the hypothesis that Max-Weight (k − 1)- Clique requires Ω(n(1−o(1))k) time. 1.1 Our Techniques Let us first recall the Karger-Stein algorithm: Algorithm 1 Karger-Stein Algorithm 1: procedure Karger-Stein(G = (V, E, w), k ∈ N) while V > k do 2: 3: 4: 5: Sample an edge e ∈ E with probability proportional to w(e). Contract two vertices in e and remove self-loops. (cid:46) V decreases by exactly 1 (cid:46) Compute a minimum k-cut of G end while Return the k-cut of the original graph by expanding the vertices of V . 6: 7: end procedure In the spirit of [GLL19], our proof consists of two main parts: (i) a new algorithmic analysis (this time for the Karger-Stein algorithm), and (ii) a statement on the extremal number of "small" cuts in a graph. In order to motivate the new analysis of Karger-Stein, let us first state a crude version of our extremal result. Define λk as the minimum k-cut value of the graph. Think of λk := λk/k as the average contribution of each of the k components to the k-cut. Loosely speaking, the extremal bound says the following: ((cid:63)) There are a linear number of cuts of a graph of size at most 1.99λk. To develop some intuition for this claim, we make two observations about the cycle and clique graphs, two graphs where the number of minimum k-cuts is indeed Ω(nk). Firstly, in the n-cycle, λk = 1 = λ/2 for any value of k, and since 1.99λk = 1.99 < 2 = λ, so there are no cuts in the graph with size at most 1.99λk, hence ((cid:63)) holds. However, it breaks if 1.99λk is replaced by 2λk, since (cid:1) many cuts of size 2λk = 2 = λ. Secondly, for the n-clique we have λk ≈ k(n − 1), there are (cid:0)n since the minimum k-cut chops off k − 1 singleton vertices. (We assume k (cid:28) n, and ignore the(cid:0)k (cid:1) 2 double-counted edges for simplicity.) We have λk ≈ n − 1 = λ instead for the n-clique, and there are exactly n cuts of size at most 1.99λk (the singletons), so our bound ((cid:63)) holds. And again, ((cid:63)) fails when 1.99λk replaced by 2. Therefore, in both the cycle and the clique, the bound 1.99λk is almost the best possible. Moreover, the linear bound in the number of cuts is also optimal in 2 1While naively implementing the Karger-Stein algorithm takes time O(n2) per iteration, the well-known trick of reducing the number of vertices by a factor 1/21/(2k−2) and recursively running the algorithm twice is known to reduce the total running time to (cid:101)O(n2k−2). Since our result is just an improved analysis of the same algorithm, we can still apply the same trick to reduce the total running time to (cid:98)O(nk). 2 spectrum in the context of graph cuts, since one graph has n minimum cuts and the other has(cid:0)n the clique. In general, it is instructive to consider the cycle and clique as two opposite ends of the (cid:1). 2 1.1.1 Algorithmic Analysis. To analyze Karger-Stein, we adopt an exponential clock view of the process: fix an infinitesimally small parameter δ, and on each timestep of length δ, sample each edge with an independent prob- ability δ/λk and contract it. If δ is small enough, then we can disregard the event that more than one edge is sampled on a single timestep. This perspective has a distinct advantage over the classical random contraction procedure that contracts one edge at a time: we can analyze whether each edge is contracted independently. At the same time, we reemphasize it is just another view of the same process; conditioned on the number of vertices n(cid:48) in the remaining graph, the outcome of the exponential clock procedure has exactly the same distribution as the standard Karger-Stein procedure that iteratively contracted n − n(cid:48) edges. Let us first translate the classical Karger-Stein analysis in the exponential clock setting. Suppose that we run the process for 2 ln n units of time (that is, 2 ln n timesteps of length δ each). The probability that a fixed minimum k-cut remains at the end (i.e., has no edge contracted) is roughly δ (cid:18) 1 − λk · δ λk (cid:19)(2 ln n)/δ ≈ exp (cid:18) (cid:19) −λk · δ λk · 2 ln n δ = exp(2k ln n) = n−2k. How many vertices are there remaining after 2 ln n units of time? On each δ-timestep, consider the graph before any edges are contracted on this timestep. If there are currently r ≥ k − 1 vertices, then the sum of the degrees of the vertices must be at least rλk; otherwise, we can cut out k − 1 random singletons to obtain a k-cut of size at most (k − 1) · λk < λk (which corresponds to a k-cut of the same size in the original graph once we "uncontract" each edge), contradicting the definition of λk as the minimum k-cut. Therefore, the graph has at least rλk/2 edges, which means that we contract at least rλk/2 · δ/λk = rδ/2 edges in expectation. We now claim that as δ → 0, this is essentially equivalent to contracting at least rδ/2 vertices in expectation, since we should not contract more than one edge at any timestep. That is, we contract a δ/2 fraction of the vertices per timestep, in expectation. Therefore, after 2 ln n units of time (which is 2 ln n timesteps), assuming that there are always at least k − 1 vertices remaining, the expected number of vertices remaining is at most δ (cid:18) n · 1 − δ 2 (cid:19)(2 ln n)/δ ≈ n · exp (cid:18) (cid:19) − δ 2 · 2 ln n δ = n · 1 n = 1. Informally, we should expect to be done at around time 2 ln n. This argument is not rigorous, since we cannot take a naıve union bound over the two successful events (namely, that no edge in the fixed k-cut is contracted, and there are k − 1 vertices remaining at the end). We elaborate on how to handle this issue later on. At any given step of the Karger-Stein process, the bound of rλk/2 edges can be tight in the worse case. So instead of improving the analysis in a worst-case scenario, the main insight to our improvement is a more average-case improvement. At a high level, as the process continues, we expect more and more vertices in the contracted graph to have degree much higher than λk. In fact, we show that the fraction of vertices with degree at most 1.99λk is expected to shrink significantly throughout the process. Consequently, the total sum of degrees becomes much larger than rλk, from which we obtain an improvement. 3 How do we obtain such a guarantee? Observe that every vertex of degree at most 1.99λk in the graph at some intermediate stage of the process corresponds to a (2-)cut in the original graph of size at most 1.99λk. Recall that by our extremal bound, we start off with only Ok(n) many such cuts. Some of these cuts can have size less than λk, but we show that there cannot be too many: at most 2k−1 of them. The more interesting case is cuts of size in the range [λk, 1.99λk]: since each of these cuts has size at least λk, the probability that we contract an edge in a fixed cut is at least λk · δ/λk = δ. This means that after just ln n units of time (and not 2 ln n), the cut remains intact only with probability (1 − δ)(ln n)/δ ≈ 1/n. Taking an expectation over all Ok(n) cuts, we expect only Ok(1) of them to remain after ln n time, which means we expect only Ok(1) many vertices of degree at most 1.99λk in the contracted graph after ln n time has passed. This analysis works for any time t: we expect only Ok(n) · (1 − δ)t/δ vertices of degree at most 1.99λk in the contracted graph after time t. is perfect, since a fixed minimum k-cut survives with probability n−k by this time! To finish off This upper bound on the number of small-degree vertices lower bounds the number of edges in the graph, which in turn governs the rate at which the graph shrinks throughout the process. To obtain the optimal bounds, we model the expected rate of decrease as a differential equation. In expectation, we find that by time ln n (not 2 ln n), we expect only (cid:98)Ok(1) vertices remaining. This the analysis from (cid:98)Ok(1) vertices down to (k − 1) vertices, we use the regular Karger-Stein analysis, Lastly, the issue of the (cid:98)Ok(1) vertices bound holding only in expectation requires some technical We then union-bound over the event of (cid:98)Ok(1) vertices remaining and the event that the minimum k- work to handle. In essence, we strengthen the expectation statement to one with high probability. cut survives -- which only holds with probability n−k. This requires us to use concentration bounds combined with a recursive approach; the details appear in §2.2 and §2.3. (cid:16)(cid:98)Ok(1) (cid:17)k = (cid:98)Ok(1). picking up an extra factor of 1.1.2 Extremal Result. Recall our target extremal statement ((cid:63)): there are Ok(n) many cuts of a graph of size at most 1.99λk. Suppose for contradiction that there are ωk(n) such cuts, and assume for simplicity that k is even. Our goal is to select k/2 of these cuts that "cross in many ways": namely, there are at least k nonempty regions in their Venn diagram (see Figure 1 left). This gives a k-cut with total cost k/2 · 1.99λk < λk, contradicting the definition of λk as the minimum k-cut. To find such a collection of crossing cuts, one approach is to treat each cut as a subset of vertices (the vertices on one side of the cut), and tackle the problem from a purely extremal set-theory perspective, ignoring the underlying structure of the graph. The statement becomes: given a family of ωk(n) many distinct subsets of [n], there exist some k/2 subsets whose Venn diagram has at least k nonempty atoms. In [GLL19], we tackled a similar problem from this point of view. However, for our present problem, the corresponding extremal set theory statement is too good (cid:1) sets, but no k/2 = 3 sets can possibly form k = 6 to be true. The set system ([n],(cid:0)[n] (cid:1)) has (cid:0)n 2 2 regions. Hence, we need the additional structure of cuts in a graph to formulate an extremal set theoretic statement that holds. Our key observation is that the cut structure of the graph forbids large sunflowers with nonempty core in the corresponding set family. To see why, consider a 401-sunflower of sets S1, S2, . . . , S401 with nonempty core C, and suppose in addition that the core C and each petal Si \ C is a cut of size at least λk. (Handling cuts of size less than λk is a technical detail, so we omit it here.) 4 Figure 1: Left: For a contradiction, suppose all (cid:0)n (cid:1) cuts of the cycle have size at most 1.99λk. Then, we 2 select k/2 = 4 many such cuts as shown. Their Venn diagram has 8 nonempty atoms and form an 8-cut with cost 4 · 1.99λk = 7.92λk < 8λk = λk, contradicting the definition of λk as the minimum k-cut. Right: A 401-sunflower with nonempty core, with the core and all petals contracted to single vertices, each of degree at least λk. Each bolded edge must have total weight at least 0.005λk for the corresponding cut to have size at most 1.99λk. However, the 400 many bolded edges excluding the blue one give total weight at least 400 · 0.005λk = 2λk, and each of them crosses the blue cut, contradicting the assumption that the blue cut has size at most 1.99λk. For simplicity, consider contracting the core C and petals Si \ C into single vertices c and pi, respectively. For each i ∈ [401], the vertices c and pi each have degree at least λk, and yet the cut {c, pi} has size at most 1.99λk; a simple calculation shows that there must be at least 0.005λk edges between c and pi. Equivalently, in the weighted case, the edge (c, pi) has weight at least 0.005λk (see Figure 1 right). Now observe that the edges (c, p2), (c, p3), . . . , (c, p401) all cross the cut {c, p1}, and together, they have total weight 400 · 0.005λk = λk. Hence, the cut {c, p1} must have weight at least 2λk, contradicting the assumption that it has size at most 1.99λk. With this insight in mind, our modified extremal set theory statement is as follows (when k is even): given a family of ωk(n) many distinct subsets of [n] that do not contain a 401-sunflower with nonempty core, there exist some k/2 many subsets whose Venn diagram has at least k nonempty atoms. This statement turns out to be true, and we provide a clean inductive argument that uses the Sunflower Lemma as a base case. (Our actual extremal statement is slightly different to handle the cuts of size less than λk as well as odd k.) 1.2 Preliminaries A weighted graph is denoted by G = (V, E, w) where w : E → Q+ gives positive rational weights on edges. Let λk be the weight of a minimum k-cut, and λk := λk/k. We use different logarithms to naturally present different parts of our analysis. We use ln to denote loge and lg to denote log2. 2 Random Graph Process In this section, we analyze the exponential clock viewpoint of the Karger-Stein algorithm to prove our main result Theorem 1, assuming the bound on the number of small cuts (Theorem 10) proved in Section 3. For the sake of exposition, throughout this section, we assume G is an unweighted multigraph, 5 ≥0.005λk≤0.995λk≤0.995λk···≥0.005λk where the number of edges between a pair (u, v) is proportional to its weight. Note that while it changes the number of edges m and λk, the resulting exponential clock procedure is still exactly equivalent to the standard Karger-Stein procedure in the original weighted graph, and the final bounds in the main lemmas (Lemma 4 and Lemma 6) only involve n, k, t. 2.1 Expectation In this section, we bound the number of vertices (in expectation) at some point in the random contraction process: Lemma 4. Suppose G has at most βn many cuts with weight in the range [λk, γλk) for some constant 1 ≤ γ < 2. Fix a parameter t ≥ 0, and suppose we contract every edge in G with independent probability 1 − e−t/λk . Then, the expected number of vertices in the contracted graph is at most O( β+1 2−γ )ne−(γ/2)t + γ 2 (k − 1)t. Consider the following exponential clock process: let each edge e of the graph independently sample a random variable x(e) from an exponential distribution with mean λk, which has c.d.f. 1 − e−t/λk at value t. We say that the edge is sampled at time x(e). Observe that for any t ≥ 0, every edge is sampled by time t with probability exactly 1 − e−t/λk , so this process models exactly the one in the lemma. For a given t ≥ 0 and δ > 0, the probability that an edge e is sampled before time t + δ, given that it is sampled after time t, is Pr[t ≤ x(e) ≤ t + δ] Pr[t ≤ x(e)] = Pr[x(e) ≤ δ] = 1 − e−δ/λk = − Oλk (δ2), δ λk (·) hides the dependence on λk. Therefore, at the loss of the Oλk where the first equality uses the memoryless property of exponential random variables, and the (δ2) factor (which we will later Oλk show to be negligible), we can imagine the "discretized" process at a small timestep δ: the times t are now integer multiples of δ, and each edge e is sampled at the (discrete) time t if t ≤ e < t + δ. Again, the probability that an edge is sampled at (discrete) time t + δ, given that it is sampled (δ2) ≈ δ/λk. For technical purposes, we will not assume that t is always after time t, is δ/λk + Oλk a multiple of δ in our formal argument. Consider the graph at a given (discrete) time t, where we have contracted all edges sampled before time t (but not those sampled at time t). Suppose that there are r = r(t) vertices in the contracted graph and s = s(t) of them have degree in the range [λk, γλk). Note that at all times, at most k− 1 vertices have degree < λk, since otherwise, we could take (k − 1) of those vertices (leaving at least one vertex remaining) and form a k-cut of weight less than (k − 1)λk < λk. Therefore, there are at least r − s − (k − 1) vertices with degree greater than γλk, so the number of edges is at least s · λk + (r − s − (k − 1)) · γλk 2 γr − γs + s − γ(k − 1) 2 = λk = r − γ − 1 2 s − γ 2 (cid:18) γ 2 (cid:19) (k − 1) λk. For now, fix δ > 0, where t is not necessarily an integer multiple of δ, and consider the time interval [t, t + δ), where we contract all edges e with x(e) ∈ [t, t + δ). Each edge in the current contracted 6 graph is contracted with probability δ/λk − Oλk (cid:18) γ (cid:18) δ (cid:19) (cid:19) (k − 1) λk · − Oλk (δ2) = λk r − γ − 1 2 2 s − γ 2 (cid:18) γ 2 (δ2) in this time interval, so we expect at least r − γ − 1 2 s − γ 2 (k − 1) δ − Oλk,m,n(δ2) (1) edges to be contracted, where Oλk,m,n(·) hides dependence on λk, m, n (note that r, s ≤ n). Ideally, we now want to argue that every edge that is contracted in this interval reduces the number of remaining vertices by 1. In general, this is not true if we contract a subset of edges that contain a cycle. However, if δ is small enough (say, δ (cid:28) 1/poly(n)), then in most cases, there is at most one edge contracted at all, in which case our desired argument holds. More formally, let Bt be the (bad) event that more than one edge is contracted in the time interval [t, t + δ). Then, by a union bound over all pairs of edges, we have (cid:18)m (cid:19) 2 · (cid:18) δ λk (cid:19)2 Pr[Bt] ≤ − Oλk (δ2) = Oλk,m,n(δ2). If the event Bt holds, we will apply the trivial bound E[r(t + δ)] ≤ n, and otherwise, we will use (1). We obtain (cid:19) (cid:19) E[r(t + δ)] ≤ (1 − Pr[Bt]) · (cid:18) γ r − γ − 1 (cid:19) 2 (cid:19) (k − 1) 2 s − γ 2 (k − 1) s − γ 2 (cid:18) ≤ r − = r − (cid:18) (cid:18) γ r − r − γ − 1 (cid:18) γ r − γ − 1 (cid:18) γ 2 2 2 2 (cid:19) (cid:19) s − γ 2 (k − 1) δ + Oλk,m,n(δ2) + Pr[Bt] · n δ + Oλk,m,n(δ2) + Oλk,m,n(δ2) · n δ + Oλk,m,n(δ2). Taking the expectation at time t and using linearity of expectation, we obtain E[r(t + δ)] ≤ E[r(t)] − E[r(t)] − γ − 1 2 E[s(t)] − γ 2 2 (k − 1) δ + Oλk,m,n(δ2). We now bound s = s(t) in terms of t. Every vertex whose degree is in the range [λk, γλk) must correspond to a cut in G with weight in [λk, γλk), and by assumption, there are at most βn of them for some fixed constant β > 0. The probability that a cut of size c ≥ λk has all its edges remaining up to time t is e−ct/λk ≤ e−t, so we expect at most e−t · βn of these cuts to survive by time t. Therefore, E[s(t)] ≤ e−tβn, and E[r(t + δ)] ≤ E[r(t)] − E[r(t)] − γ − 1 2 e−tβn − γ 2 (k − 1) δ + Oλk,m,n(δ2). E(cid:104) Subtracting γ 2 (k − 1)(t + δ) from both sides, we obtain r(t + δ) − γ 2 (k − 1)(t + δ) r(t) − γ 2 (k − 1)t (cid:105) − (cid:18) γ 2 E[r(t)] − γ − 1 2 (cid:19) e−tβn δ + Oλk,m,n(δ2). (cid:18) γ (cid:105) ≤ E(cid:104) 2 (cid:19) (cid:19) 7 f (t + δ) − f (t) ≤ − We now solve for E[r(t)]. Define f (t) := E[r(t) − γ (cid:2)f (t)+ f (t) − γ − 1 Taking δ → 0, we obtain the differential equation f (t + δ) − f (t) ≤ − γ 2 (cid:18) γ (cid:18) γ 2 2 2 f(cid:48)(t) = lim δ→0 δ (k − 1)t(cid:3) − γ − 1 2 (k − 1)t], so that e−tβn (cid:19) (cid:19) 2 e−tβn δ + Oλk,m,n(δ2). δ + Oλk,m,n(δ2) ≤ − γ 2 f (t) + γ − 1 2 e−tβn. Set B := γ−1 2 β, so we instead have f(cid:48)(t) ≤ − γ 2 Observe that if we had f(cid:48)(t) = − γ 2 f (t) instead, then that would solve to f (t) ≤ e−(γ/2)tn, but there's the additional Be−tn term to deal with. However, e−t drops much faster than e−(γ/2)t (since γ < 2 by assumption), so intuitively, the Be−tn factor doesn't affect us asymptotically. We now formalize our intuition. f (t) + Be−tn. (2) To upper bound f (t), we will solve the differential equation (2) where we pretend the inequality in (2) is actually an equality. More formally, define A := B B + 1 − γ/2 , which satisfies A < 1 since γ < 2, and define f (t) := 1 1 − A n(e−(γ/2)t − Ae−t). The following is a simple exercise in differential equations which we defer to the appendix. Claim 5. The function f (t) satisfies f (0) = f (0) and f(cid:48)(t) = − γ 2 f (t) + Be−tn, which is the differential equation (2) with equality (where f is replaced by f ). f (t) ≥ f (t) for all t ≥ 0. It follows that Following Claim 5, we have E(cid:104) (cid:105) r(t) − γ 2 (k − 1)t = f (t) ≤ f (t) ≤ 1 ≤ 1 n(e−(γ/2)t − Ae−t) ne−(γ/2)t 1 − A 1 − A B + 1 − γ/2 ne−(γ/2)t 1 − γ/2 γ−1 2 β + 1 − γ/2 1 − γ/2 ne−(γ/2)t = = 8 (cid:18) γ − 1 (cid:18) β + 1 2 − γ 2 − γ (cid:19) = O = β + 1 (cid:19) ne−(γ/2)t ne−(γ/2)t. Adding γ 2 (k − 1)t to each side finishes the proof of Lemma 4. 2.2 Concentration In this section, we prove that for any graph with bounded number of edges, if we sample each edge independently with probability p = 1 − e−t/λk , the number of connected components is at most n) plus the expected value with high probability. It will be subsequently used in the recursive √ (cid:101)O( analysis in Section 2.3. Lemma 6. Let α ≥ 1, t ≥ Ω(1), and N ≥ n be parameters. Let G be a graph with at most αλkn edges. Suppose we sample every edge in G with independent probability 1 − e−t/λk ; let the random variable f denote the number of connected components in the sampled graph. Then, with probability at least 1 − N−2k, we have f ≤ E[f ] + O(k ln N Proof. Let e1, . . . , em be the edges of G, arbitrarily ordered. For each i ∈ [m], let Xi ∈ {0, 1} be the random variable indicating that ei is sampled. Then each Xi is independent and Pr[Xi = 1] = p where p = 1 − e−t/λk . Let f (X1, . . . , Xm) be the number of components of the graph whose edge set is {ei : Xi = 1}. For each i ∈ [m], let αtn). √ Yi := E[f (X1, . . . , Xm)X1, . . . , Xi], Zi := Yi − Yi−1, Wi := E[Z2 j X1, . . . , Xj−1]. i(cid:88) j=1 Together with Y0 = E[f ], the sequence {Y0, . . . , Ym} forms a Doob martingale. Since the existence of one edge changes the number of connected components by at most 1, Zi ≤ 1 always for every i ∈ [m]. For every j ∈ [m] and X1, . . . , Xj−1 (which determines Yj−1), let yb := E[fX1, . . . , Xj−1, Xj = b] for b ∈ {0, 1}. By the same argument, y0 − y1 ≤ 1, y1 ≤ Yi−1 ≤ y0, and Yi−1 := py1 + (1 − p)y0, so that j X1, . . . , Xj−1] = p(cid:0)(1 − p)(y1 − y0)(cid:1)2 + (1 − p)(cid:0)p(y0 − y1)(cid:1)2 ≤ p(1 − p). E[Z2 In particular, Wi ≤ pi for every i ∈ [m] with probability 1. We use the following concentration inequality for martingales, due to Freedman. Theorem 7. [Fre75] Let {Y0, . . . , Ym} be a martingale with associated differences Zi := Yi − Yi−1, and such that Zi ≤ R and Wi ≤ σ2 for every i with probability 1. Then for all t ≥ 0, Pr[Ym − Y0 ≥ s] ≤ exp − σ2 + Rs/3 . (3) i(cid:88) j=1 Wi := E[Z2 i Y1, . . . , Yk−1], (cid:18) s2/2 (cid:19) 9 Plugging in R = 1, σ2 = pm, s = O(k ln N √ αtn) gives s2/2 ≥ s2/2 pm + s/3 ≥ s2/2 ≥ Ω(min(s2/(αtn), s)) ≥ min(2k2 ln2 N, 2k ln N αtn) ≥ 2k ln N. σ2 + Rs/3 where the second inequality used the fact that p = 1−exp(−t/λk) ≤ t/λk and m ≤ αλkn. Plugging in this bound to (3) proves the lemma. αtn + s/3 √ How large do we have to set α in Lemma 6? We show that α := k suffices by first applying the graph sparsification routine of Nagamochi and Ibaraki, reducing its number of edges to at most λkn while maintaining all minimum k-cuts. Theorem 8 (Nagamochi-Ibaraki [NI92]). Given an unweighted graph G and parameter λ, there exists a subgraph H with at most λn edges such that all k-cuts of size ≤ λ are preserved. More formally, all sets S with ∂GS ≤ λ satisfy ∂GS = ∂H S. Proof. For i = 1, 2, . . . , λ, let Fi be a maximal forest in G \(cid:83) G − H = G \(cid:83) j<i Fj. For any edge (u, v) in i Fi, there must be an (u, v) path in each Fi, otherwise we would have added edge (u, v) to Fi. These λ paths, along with edge (u, v), imply that every cut that separates u and v has size ≥ λ + 1. Therefore, u and v must lie in the same component of any k-cut of size ≤ λ, so removing edge (u, v) cannot affect any such k-cut. With Theorem 8 in hand, we now prove the following corollary which we will use in the next section, which combines Lemma 6 and the expectation statement of Lemma 4. Corollary 9. Let t ≥ Ω(1) and N ≥ n be parameters. Suppose G has at most βn many cuts with weight in the range [λk, γλk) for some constant 1 ≤ γ < 2. Suppose we contract every edge in G with independent probability 1− e−t/λk . Then, with probability at least 1− N−2k, number of vertices in the contracted graph is at most O( β+1 √ ktn). 2 (k − 1)t + O(k ln N 2−γ )ne−(γ/2)t + γ Proof. First, apply Theorem 8 to the input graph G, obtaining a graph H of at most λkn edges with the same minimum k-cut value λk. We can imagine contracting the graph G by first contracting each edge in H with independent probability 1 − e−t/λk , and then contracting each edge in G − H with the same probability. Applying Lemma 4 and Lemma 6 with α := k on the graph H, we obtain that contracting the edges in H alone gives us at most O( β+1 ktn) with probability at least 1− N−2k. Contracting the edges in G− H afterwards can only reduce the number of remaining vertices, so we are done. 2 (k−1)t+O(k ln N 2−γ )ne−(γ/2)t + γ √ 2.3 Recursion In this section, we finish the proof of the main theorem, restated below: Theorem 1 (Main). Given a graph G and a parameter k ≥ 2, the Karger-Stein algorithm outputs any fixed minimum k-cut in G with probability at least n−k · (k ln n)−O(k2 ln ln n). probability p = 1 − et/λk , the number of remaining vertices becomes at most (cid:101)O( We will proceed by a recursive analysis: Lemma 4 (expectation) and Lemma 6 (concentration), packaged together in Corollary 9, show that if we let t = 1 2 ln n and contract each edge with n) with high probability. Also note that any fixed minimum k-cut C survives (i.e., no edge in C is contracted) with probability exactly (1 − p)λk = n−k/2. √ 10 2 ln ni−1 and contract each edge of Gi−1 with probability p = 1 − eti/λk . The above analysis We then recursively call Corollary 9 on the contracted graph until the number of vertices becomes smaller than some threshold. Formally, let n0 := n and G0 := G. In the ith iteration, we set shows that with probability at least (ni−1)−k/2, no edge in C is contracted and ni ≤ (cid:101)O( ti := 1 If the second guarantee was precisely ni ≤ √ ni−1, iterating at most T = lg lg n steps ensures that nT ≤ O(1), and the final probability that C survives at the end is roughly at least n−k/2 · n−k/4 · n−k/8 ··· ≈ n−k. When the number of vertices becomes small, the naive Karger-Stein analysis can ni ≤ (cid:101)O( be applied. The proof below formalizes this intuition and accounts the fact that we can only ensure ni−1) in each iteration. ni−1). √ √ Proof. We prove the theorem by recursively applying Corollary 9 to reduce the number of vertices. Given a graph G with n vertices, let γ := 2 − 1/ ln n, and apply the following extremal theorem proved in Section 3. Theorem 10 (Extremal Theorem). For any γ < 2, there are at most (max( 1 cuts with weight less than γλk. 2−γ , k))O(k)n many Let β = (max( 1 2−γ , k))O(k) = (max(ln n, k))O(k) so that there are at most βn many cuts with weight less than γλk. The parameters β and γ will not change throughout the proof. Fix a minimum k-cut C of G so that C = λk. Let n0 =(cid:98)n0 = n and G0 = G. For each i = 1, 2, . . . , T where T = (lg lg n0 − O(1)), the ith iteration involves setting parameters ti := 1 to be determined later, and contracting each edge in Gi−1 with probability pi := 1 − e−ti/λk to obtain Gi. Let ni be the number of vertices of Gi. In each iteration i, we want to ensure that the following events happen with high probability in each iteration, given that the same events happened in the previous iteration. i−1 for some M = O 2 ln(cid:98)ni−1,(cid:98)ni := M(cid:98)n1/2 (cid:16) β+1 (cid:17) 2−γ 1. No edge in C is contracted. 2. ni ≤(cid:98)ni. For the event 1, the probability that no edge in C is contracted is exactly (1 − pi)λk = e−kti = ((cid:98)ni−1)−k/2. k-cut of Gi−1, the minimum k-cut value of Gi−1 is still λk. Applying Corollary 9 to Gi with same For the event 2, we use Corollary 9 on Gi−1 with parameter N ←(cid:98)ni−1. Since C is still a minimum β and γ ensures that with probability at least 1 − ((cid:98)ni−1)−2k, ni is at most k ln(cid:98)ni−1 (cid:112)kt(cid:98)ni−1 (cid:18) β + 1 (k − 1)ti + O (cid:16)− γ ni−1 exp (cid:19) (cid:17) (cid:17) (cid:16) + O ti . 2 − γ 2 γ 2 (cid:16) β+1 (cid:17) ((cid:98)ni−1)1/2 using the fact that (k ln(cid:98)ni−1 √ kt) ≤ The last term in the above expression is at most O O((β + 1)/(2 − γ)). The first three terms can be upper bounded by 2−γ (cid:19) (cid:19) (cid:18) β + 1 (cid:18) β + 1 2 − γ 2 − γ O ≤ O (cid:16)− γ (cid:16)− γ 2 2 (cid:17) (cid:17) ti ti ni−1 exp ni−1 exp (k − 1)ti + γ 2 (cid:18) γ 2 11 (k − 1)ti ≤ k ln n0 ≤ O (cid:19)(cid:19) (cid:18) β + 1 2 − γ (cid:19) (cid:19) (cid:18) β + 1 (cid:18) β + 1 2 − γ 2 − γ ≤ O ≤ O ni−1((cid:98)ni−1)−γ/4 ((cid:98)ni−1)1/2 (definition of ti) (((cid:98)ni−1)−γ/4 = ((cid:98)ni−1)−1/2+1/4(ln n0) = O((cid:98)ni−1)). (4) It follows that with probability at least 1 − ((cid:98)ni−1)−2k, we have (cid:98)ni ≤ M ((cid:98)ni−1)1/2 2−γ (cid:17) (cid:16) β+1 ((cid:98)ni−1)−k/2 − ((cid:98)ni−1)−2k = ((cid:98)ni−1)−k/2 · (1 − ((cid:98)ni−1)−3k/2). . for large enough M = O Taking a union bound, the probability that events 1 and 2 both happen is at least 1 1 2 1 4 (5) 1 + + T(cid:89) (cid:16) Let(cid:98)xi := lg(cid:98)ni for all i ≥ 0, so that from (4), we obtain 2(cid:98)xi−1, (cid:98)xi ≤ lg M + (cid:19) + 2−i(cid:98)x0 ≤ 2 lg M + 2−i(cid:98)x0, which implies that(cid:98)xi ≤ lg M · so with T := lg(cid:98)x0 − O(1) = lg lg n0 − O(1) steps,(cid:98)xT = O(lg M ), which translates to(cid:98)nT = M O(1). + ··· + 2−i+1 (cid:18) (cid:33) (1 − ((cid:98)ni−1)−3k/2) (cid:17) ((cid:98)ni−1)−k/2 · (1 − ((cid:98)ni−1)−3k/2) We finally compute the probability that both events happen for each i = 1, . . . , T = lg lg n0 − O(1). (cid:32) T(cid:89) ((cid:98)ni−1)−k/2 For the second product, the recursive definition (cid:98)ni := M(cid:98)n1/2 i−1 also implies (cid:98)ni ≥ n2−i, so we can choose O(1) in the definition T = lg lg n0 − O(1) to ensure(cid:98)nT−1 ≥ 5. Then the second product can be shown to be at least Ω(1), as(cid:32) T(cid:89) ≥ 1 − T(cid:88) and the sequence {((cid:98)ni)−3k/2} is at least exponentially increasing with the last term at most 5−3 For the first product of (6), we use the fact(cid:98)xi ≤ 2 lg M + 2−i(cid:98)x0 to bound (1 − ((cid:98)ni−1)−3k/2) ((cid:98)ni−1)−3k/2, (since k ≥ 2). (cid:32) T(cid:89) (cid:33) (cid:33) (6) = i=1 · i=1 i=1 i=1 i=1 T(cid:88) (cid:98)xi−1 ≤ 2T lg M + 2(cid:98)x0, i=1 12 which leads to (cid:32) T(cid:89) i=1 ((cid:98)ni−1)−k/2 (cid:33)−k/2 (cid:33) = (cid:32) T(cid:89) i=1 ((cid:98)ni−1) ≤ 2((cid:80)T i=1((cid:98)xi−1))·(−k/2) =(cid:0)n2M 2T(cid:1)−k/2 = n−k · M−T k. Therefore, with probability at least Ω(n−k · M−T k), events 1 and 2 happen for i = 1, . . . , T which means that no edge in C is contracted and nT ≤ M O(1). After this point, we can switch the standard Karger-Stein analysis of the same process where exactly one edge is contracted in each iteration. It shows that if C will be output with at least M−O(k). Altogether, the minimum k-cut C survives with probability at least (using M ≤ (max(ln n, k))O(k)·ln n ≤ (k ln n)O(k) and T ≤ lg lg n), n−k · M−O(T k) = n−k · (k ln n)−O(k2 ln ln n). This completes the proof. 3 Cuts and Sunflowers In this section, we prove that for any γ < 2, every graph has a small number of cuts whose weight is γλk. Our main result in this section is: Theorem 10 (Extremal Theorem). For any γ < 2, there are at most (max( 1 cuts with weight less than γλk. 2−γ , k))O(k)n many 3.1 The Sunflower Lemma, and Refinements Recall that given a set system F over a universe U , an r-sunflower is a collection of r subsets F1, . . . , Fr ∈ F such that their pairwise intersection is the same: there exists a core S ⊆ U such that Fi ∩ Fj = S for all i, j, and hence ∩iFi = S. Let sf(d, r) be the smallest number such that any set system with n elements and more than sf(d, r) sets of cardinality d must have an r-sunflower. The classical bound of Erdos and Rado [ER60] shows that sf(d, r) ≤ d!(r − 1)d. A recent breakthrough by Alweiss et al. [ALWZ19] proves that sf(d, r) ≤ (lg d)d(r · lg lg d)O(d). Corollary 11. Let F be a family of sets over some universe, where every set has size at most d. If F > (d + 1) · sf(d, r), then F contains an r-sunflower. Proof. Group the sets in F by their sizes, which range from 0 to d. For some d(cid:48) ∈ [0, d], there are more than ·(cid:0)(d + 1) sf(d, r)(cid:1) ≥ sf(d(cid:48), r) sets of size exactly d(cid:48), since sf(d, r) is monotone in d. The result follows from applying the definition of sf(d(cid:48), r) on the sets in F of size d(cid:48). 1 d + 1 For our applications for cuts, we want a sunflower with nonempty core. In this case, the bound must depend on the size of the universe n, since the set system with n singleton sets does not contain a sunflower with nonempty core. The following lemma proves that the above bound, multiplied by ≈ nd, can guarantee a sunflower with nonempty core. Lemma 12. Let F be a family of sets over a universe of n elements, where every set has size at most d. If F > (d + 2) sf(d, r)n, then F contains an r-sunflower with nonempty core. 13 Proof. We prove the contrapositive: suppose that F does not have an r-sunflower with nonempty core. For each element v ∈ U , consider the set Fv := {F ∈ F : F (cid:51) v}. If there exists an r- sunflower in Fv for any v ∈ U , then this sunflower has a nonempty core (since the core contains v), contradicting our assumption. Therefore, by Corollary 11, Fv ≤ (d + 1) · sf(d, r) for each v ∈ U . Every set in F is included in some Fv except possibly ∅, so F ≤ (d + 1) sf(d, r) · n + 1 ≤ (d + 2) sf(d, r)n, proving the contrapositive. Additionally we want multiple sunflowers, each with distinct, nonempty nonempty core. Note that the sunflower cores may intersect, even though they are distinct. The following lemma shows we can also achieve this. Lemma 13. Let F be a family of sets over a universe of n elements, where every set has size at most d. If F > s(d + 2)sf(d, r)n, then F contains s many r-sunflowers, each with distinct, nonempty cores. Proof. We iteratively construct s sunflowers with distinct cores. Initialize F(cid:48) := F, and on each iteration, consider a maximal set C such that there exists an r-sunflower in F(cid:48) with core C. Inductively we ensure that such a set C (cid:54)= ∅ exists; this holds for the base case by Lemma 12. C := {F ∈ F(cid:48) : F ⊇ C} has size at most (d + 2)sf(d, r)n. Indeed, Moreover, we claim that the set F(cid:48) if not, then applying Lemma 12 on the set system {F \ C : F ∈ F(cid:48), F ⊇ C} (which has the same cardinality as F(cid:48)), we obtain an r-sunflower with sets S1, . . . , Sr and nonempty core C(cid:48). Then, the sets S1 ∪ C, . . . , Sr ∪ C ∈ F(cid:48) form an r-sunflower with core C ∪ C(cid:48), contradicting the maximality of the set C. We now remove the sets in F(cid:48) C). Now the core on any subsequent iteration cannot be C, since we have removed all the sets that contained C. The size of F(cid:48) drops C ≤ (d + 2) sf(d, r)n each iteration, so if F > s(d + 2) sf(d, r)n to begin with, then by at most F(cid:48) we can proceed for s iterations, obtaining s many r-sunflowers with distinct, nonempty cores. C from F(cid:48) (i.e., update F(cid:48) ← F(cid:48)\F(cid:48) 3.2 Removing the Size Restriction: Venn Diagrams The above sunflower lemmas proved that a sunflower-free set system F must have few sets, as long as each set in the system has bounded size. The following lemma replaces the assumption on the bounded size by the assumptions that (a) every k sets in the system have small number of occupied regions in their Venn diagram, and (b) the set system of the complements of the sets do not contain many sunflowers either. To make this formal, we introduce some notation. Given k sets F1, . . . , Fk, we denote their Venn diagram by Venn(F1, . . . , Fk). An atom denotes a nonempty region of the diagram. Formally, an atom is a nonempty set that can be expressed as G1 ∩ . . .∩ Gk, where for each i, the set Gi is either the set Fi, or its complement Fi. Also, let F := {F : F ∈ F} be the collection of complements of the sets in F. Lemma 14. Let F be a set system on n elements satisfying the following: i. For every k sets F1, . . . , Fk ∈ F, their Venn diagram Venn(F1, . . . , Fk) has less than 2k atoms. ii. Each of F and F does not contain s many r-sunflowers, each with distinct, nonempty cores. 14 Figure 2: The Venn diagram above has eight atoms. Figure 3: Construction of the set systems (X,Fa) (middle) and (Y,Fb) (right) given the set system on the left and S, T1, T2, T3. The purple set can be added to either (X,Fa) or (Y,Fb). Then, F ≤ 10s · k(5k + 2) · sf(5k, r) · n. Proof. For fixed r, k, s, let ex(n) (ex for extremal) be the maximum size of a set F on n elements satisfying conditions (i) and (ii). We prove by induction on n that ex(n) ≤ 10s · k(5k + 2) · sf(5k, r) · max{1, n − 4k}, with the base cases n ≤ 5k. Base case: n ≤ 5k. In this case, each set has size at most n ≤ 5k, so using Lemma 13, so the number of sets in F is at most s(5k + 2)sf(5k, r) · 5k ≤ 10s · k(5k + 2) · sf(5k, r) · max{1, n − 4k} = ex(n). Inductive step: n > 5k. First, suppose that every set F ∈ F satisfies either F ≤ 5k or F ≥ n−5k. By Lemma 13 on F and F respectively, there are at most s(5k + 2) · sf(5k, r) · n many sets of size at most 5k, and also at most s(5k + 2) · sf(5k, r) · n many sets of size at least n − 5k. Applying the bound n ≤ 5(n − 4k) and using that k ≥ 1, we obtain F ≤ 2s(5k + 2) · sf(5k, r) · n ≤ 2s · k(5k + 2) · sf(5k, r) · 5 max{1, n − 4k} = ex(n), as desired. 15 A1A2A3A4B1B2B3B4ST1T2T3b1b2b3b4a1a2a3a4 Otherwise, there exists a set S with 5k < S < n − 5k. For i = 1, 2, . . . , k − 1, while there exists a set Ti ∈ F such that the Venn diagram Venn(S, T1, T2, . . . , Ti) on the i + 1 sets contains at least 2(i + 1) atoms, choose an arbitrary such set Ti. Suppose this process continues until the index i reaches value (cid:96) ∈ [k − 1]. If (cid:96) = k − 1, then Venn(S, T1, . . . , T(cid:96)) is composed of k sets and has at least 2k atoms, which cannot happen by assumption. Therefore, (cid:96) < k − 1. We say that a set F cuts another set F (cid:48) if both the regions F ∩ F (cid:48) and F (cid:48)\ F are non-empty. By our stopping condition, every set F ∈ F cuts at most one atom in Venn(S, T1, . . . , T(cid:96)); indeed, if a set F cuts two atoms or more, we would have added it as T(cid:96)+1 and continued. Let the atoms of Venn(S, T1, . . . , T(cid:96)) inside S be A1, . . . , Ai, so that A1 ∪ . . . ∪ Ai = S; and let the atoms outside S be B1, . . . , Bj, so that B1 ∪ . . . ∪ Bj = U \ S. Define two new collections of elements Ea := {a1, . . . , ai} and Eb := {b1, . . . , bj}, and define X := S ∪ Eb and Y := (U \ S) ∪ Ea. We build two set systems (X,Fa) and (Y,Fb) as follows (see Figure 3). Initialize Fa = Fb := ∅; for each set F ∈ F, we have three cases: 1. If F cuts an atom Ah inside S, then add the set (F ∩ S) ∪ {bh h ∈ [j], F ⊇ Bh} into Fa. 2. Else, if F cuts an atom Bh outside S, then add the set (F \ S) ∪ {ah h ∈ [i], F ⊇ Ah} into Fb. 3. Else, F does not cut any atom. Execute either step (1) or step (2). Here's another equivalent way to look at this process. For Fa, we can think taking the set system (U,F), removing the sets that cut an atom outside S, and then contracting the atoms B1, . . . , Bj into b1, . . . , bj, respectively. We can also think of Fb analogously, by throwing away the sets that cut atoms inside S, and then contacting atoms A1, . . . , Ai. Through this contraction viewpoint, it is clear that if the set system (U,F) satisfy conditions (i) and (ii), then so do the set systems (X,Fa) and (Y,Fb). Moreover, since 5k < S < n − 5k, we have X = S + Eb ≤ S + 2k ≤ (n − 5k) + 2k < U and Y = V \ S + Ea ≤ n − S + 2k ≤ (n − 5k) + 2k < U, so we can apply induction on n, obtaining F = Fa + Fb ≤ ex(n − S + 2k) + ex(S + 2k) ≤ 10s · k(5k + 2) · sf(5k, r) ·(cid:16) = 10s · k(5k + 2) · sf(5k, r) ·(cid:16) max{1, (n − S + 2k) − 4k} + max{1, (S + 2k) − 4k}(cid:17) (n − S + 2k) − 4k + (S + 2k) − 4k (cid:17) = 10s · k(5k + 2) · sf(5k, r) · (n − 4k) = ex(n), completing the induction. Later when we apply the above lemma to k-cut, the number of atoms becomes k, so it is sufficient for even k. For odd k, we can slightly strengthen Lemma 14 as follows. Corollary 15. Let F be a set system on n elements satisfying the following: 16 i. There do not exist sets S1, . . . , Sk−1 such that Venn(S1, . . . , Sk−1) has at least 2(k − 1) + 1 atoms. i'. There do not exist sets S1, . . . , Sk such that Venn(S1, . . . , Sk−1) has exactly 2(k − 1) atoms, and the set Sk cuts at least two atoms in Venn(S1, . . . , Sk−1). ii. Each of F and F does not contain s many r-sunflowers, each with distinct, nonempty cores. Then, F ≤ 10s · k(5k + 2) · sf(5k, r) · n. Proof. The proof is identical; the only additional observation is that when we iteratively construct S, T1, . . . , T(cid:96) for (cid:96) ≤ k − 1, observe that the set T(cid:96) cuts at least two atoms of Venn(S, T1, . . . , T(cid:96)−1) by construction. In particular, if the construction continued until (cid:96) = k − 1, then either the sets S, T1, . . . , Tk−2 violate condition (i), or the sets S, T1, . . . , Tk−1 violate condition (i'). Therefore, every time we carry out this process, we must stop at (cid:96) < k − 1. When we stop, the condition (i), though it is slightly more relaxed than the condition (i) of Lemma 14, still ensures that Ea,Eb ≤ 2k, so the same inductive argument works. components as Venn(S1, . . . , Si−1) are sets of the form(cid:83) 3.3 Relating Cuts and Sunflowers Recall that λk is the size of the minimum k-cut divided by k, and γ ∈ [1, 2) is a fixed parameter. In this section, we use the previous tools for sunflowers to bound the number of small cuts (of size ≤ γλk) in a graph. First, the following lemma, independent of sunflowers, shows that there cannot be many tiny cuts (of size < λk) in a graph. Lemma 16. There are at most 2k−1 many cuts with weight less than λk. Proof. Suppose, otherwise, that there are more than 2k−1 sets; let S be the collection of these sets. We will iteratively construct a k-cut of size less than kλk = λk contradicting the definition of λk, the size of the minimum k-cut. Begin with an arbitrary set S1 ∈ S, and while Venn(S1, . . . , Si−1) has less than k components, choose an arbitrary set Si ∈ S such that Venn(S1, . . . , Si) has at least one more component than Venn(S1, . . . , Si−1). We show that such a set Si always exists. Let A1, . . . , A(cid:96) be the atoms of Venn(S1, . . . , Si−1); the only sets T ∈ S such that Venn(S1, . . . , Si−1, T ) has the same number of i∈I Ai for some subset I ⊆ [(cid:96)]. Since there are at most 2(cid:96) ≤ 2k−1 such sets and S > 2k−1, a satisfying set Si always exists. At the end, we have at most k − 1 sets S1, . . . , Si such that Venn(S1, . . . , Si) has at least k compo- nents. Therefore, the edge set ∂S1∪···∪ ∂Si is a k-cut, and it has weight less than iλk < kλk = λk, achieving the desired contradiction. Finally, the following lemma proves that many sunflowers consisting of cuts of size ≤ γλk will lead to a better k-cut than kλk, leading to contradiction. Lemma 17. Fix a constant 1 ≤ γ < 2, and let F be the family of sets {S ⊆ V : w(∂S) ≤ γλk}. 2−γ + 1, both F and F do not contain 2k many (r + k − 2)-sunflowers with Then, for any r > 2γ distinct, nonempty cores. Proof. Since w(∂S) ≤ γλk ⇐⇒ w(∂(V \ S)) ≤ γλk, we have F = F, so it suffices to only consider F. Suppose, otherwise, that there are 2k many (r +k−2)-sunflowers with distinct, nonempty cores. Let Fsmall := {S ∅ (cid:40) S (cid:40) V, w(∂S) < λk}, so that Lemma 16 implies that Fsmall ≤ 2k−1. Then, 17 S1, . . . , Sr+k−2 ∈ F be the sets of this (r + k − 2)-sunflower with petals Pi := Si \(cid:83) nonempty core C := (cid:84) there must exist at least one sunflower in this collection whose core does not belong to Fsmall. Let j(cid:54)=r Sj and i Si /∈ Fsmall. Since the petals Pi are disjoint, at most k − 2 of them are in Fsmall, since otherwise, we get k − 1 disjoint sets in Fsmall which together form a k-cut with weight less than (k − 1)λk < λk. Therefore, without loss of generality (by reordering the sets Si), assume that P1, . . . , Pr /∈ Fsmall. Since C and P1, . . . , Pr are all cuts in the graph (in particular, ∅ (cid:54)= C (cid:54)= V and ∅ (cid:54)= Pi (cid:54)= V ) and are not in Fsmall, we have w(∂C) ≥ λk and w(∂Pi) ≥ λk for each i ∈ [r]. For each i ∈ [r], we have γλk ≥ w(∂Si) = w(∂(C ∪ Pi)) = w(∂C) + w(∂Pi) − 2w(E[C, Pi]) ≥ 2λk − 2w(E[C, Pi]), so w(E[C, Pi]) ≥ (2 − γ)λk/2. Now observe that the edges in E[C, Pi] for i = 2, . . . , r are included in ∂(C ∪ P1). It follows that γλk ≥ w(∂(C ∪ P1)) ≥ w(E[C, P2] ∪ ··· ∪ E[C, Pr]) = r(cid:88) i=2 w(E[C, Pi]) ≥ (r − 1) (2 − γ)λk 2 , so r − 1 ≤ 2γ 2−γ , contradicting the assumption that r > 2γ 2−γ + 1. We are finally ready to prove Theorem 10, which we restate here for convenience. Theorem 10 (Extremal Theorem). For any γ < 2, there are at most (max( 1 cuts with weight less than γλk. Proof. Let F be the set of such cuts, and let k(cid:48) := (cid:100)k/2(cid:101). We first show that if k is even, then condition (i) of Lemma 14 is satisfied when the parameter k in the lemma is k(cid:48) instead, and if k is odd, then conditions (i) and (i') of Corollary 15 are satisfied, again with k(cid:48) for the parameter k. Then, we show that condition (ii) of both Lemma 14 and Corollary 15 are satisfied for parameters s and r that we choose later. 2−γ , k))O(k)n many First, consider the case when k is even. Suppose, otherwise, that condition (i) of Lemma 14 is false: there are sets S1, . . . , Sk(cid:48) such that Venn(S1, . . . , Sk(cid:48)) has at least 2k(cid:48) = k atoms. Then, 2 · 2λk = λk, contradicting the definition of λk, ∂S1 ∪ ··· ∪ ∂Sk(cid:48) is a k-cut with weight k(cid:48) · γλk < k the minimum k-cut. Now consider the case when k is odd. If condition (i) of Corollary 15 is false, then there are sets S1, . . . , Sk(cid:48)−1 such that Venn(S1, . . . , Sk(cid:48) has at least 2(k(cid:48)−1)−1 = k atoms. Then, ∂S1∪···∪∂Sk(cid:48)−1 is a k-cut with weight (k(cid:48) − 1)· γλk < k 2 · 2λk = λk, contradicting the definition of λk, the minimum k-cut. Otherwise, if condition (i') of Corollary 15 is false, then the set of edges ∂S1 ∪···∪ ∂Sk(cid:48)−1 is a (k− 1)-cut with weight (k(cid:48) − 1)· γλk < k−1 2 · 2λk = (k− 1)λk. Let A1, . . . , A(cid:96) ⊆ V be the atoms in Venn(S1, . . . , Sk(cid:48)−1) that are cut by Sk(cid:48), with (cid:96) ≥ 2 by assumption. Since ∂Sk(cid:48) ∩ E[Ai] are disjoint for i ∈ [(cid:96)], there exists one atom Ai such that w(∂Sk(cid:48) ∩ E[Ai]) ≤ 1 (cid:96) w(∂Sk(cid:48)) ≤ 1 (cid:96) 1 2 · γλk < · 2λk = λk. Thus, ∂S1 ∪ ··· ∪ ∂Sk(cid:48)−1 ∪ (∂Sk(cid:48) ∩ E[Ai]) is a k-cut with weight less than (k − 1)λk + λk = λk, a contradiction. Thus, conditions (i) and (i') of Corollary 15 are satisfied. Now, fix the parameters s := 2k, r := (cid:100) 2γ 2−γ +2(cid:101), r(cid:48) := r+k−2, and k(cid:48) := (cid:100)k/2(cid:101). By Lemma 17, both F and F do not contain s many r(cid:48)-sunflowers with distinct, nonempty cores, fulfilling condition (ii) 18 of Lemma 14 and Corollary 15 (with r(cid:48) in place of r). Therefore, by Lemma 14 or Corollary 15 when k is even or odd respectively, and using sf(d, r) ≤ (lg d)d(r·lg lg d)O(d) ≤ (r lg d lg lg d)O(d) [ALWZ19], F ≤ 10s · k(cid:48)(5k(cid:48) + 2) · sf(5k(cid:48), r(cid:48)) · n ≤ 2O(k) · (r(cid:48) lg k(cid:48) lg lg k(cid:48))O(k(cid:48))n (cid:18) 1 (cid:19)(cid:19)O(k) · n , k max 2 − γ (cid:18)(cid:18) (cid:19) lg k(cid:48) lg lg k(cid:48)(cid:19)O(k(cid:48)) · n ≤ (cid:18) = 2O(k) · (cid:100) 2γ 2 − γ (cid:101) + k as desired. As an aside, using the classical Erdos-Rado bound [ER60] of sf(d, r) ≤ d!(r − 1)d gives the same result, up to a constant in the O(k) exponent, as does the conjectured optimal bound of sf(d, f ) ≤ (Cr)d. References [ALWZ19] Ryan Alweiss, Shachar Lovett, Kewen Wu, and Jiapeng Zhang. Improved bounds for the sunflower lemma. arXiv preprint arXiv:1908.08483, 2019. [CQX18] Chandra Chekuri, Kent Quanrud, and Chao Xu. LP relaxation and tree packing for minimum k-cuts. In 2nd Symposium on Simplicity in Algorithms (SOSA 2019). Schloss Dagstuhl-Leibniz- Zentrum fuer Informatik, 2018. [ER60] [Fre75] [GH94] P. Erdos and R. Rado. Intersection theorems for systems of sets. J. London Math. Soc., 35:85 -- 90, 1960. David A Freedman. On tail probabilities for martingales. the Annals of Probability, 3(1):100 -- 118, 1975. Olivier Goldschmidt and Dorit S. Hochbaum. A polynomial algorithm for the k-cut problem for fixed k. Math. Oper. Res., 19(1):24 -- 37, 1994. [GLL18] Anupam Gupta, Euiwoong Lee, and Jason Li. Faster exact and approximate algorithms for k-cut. In Foundations of Computer Science (FOCS), 2018 IEEE 59th Annual Symposium on, 2018. [GLL19] Anupam Gupta, Euiwoong Lee, and Jason Li. The number of minimum k-cuts: improving the karger-stein bound. In Proceedings of the 51st Annual ACM SIGACT Symposium on Theory of Computing, pages 229 -- 240. ACM, 2019. [KS96] David R. Karger and Clifford Stein. A new approach to the minimum cut problem. Journal of the ACM (JACM), 43(4):601 -- 640, 1996. [KYN07] Yoko Kamidoi, Noriyoshi Yoshida, and Hiroshi Nagamochi. A deterministic algorithm for finding all minimum k-way cuts. SIAM J. Comput., 36(5):1329 -- 1341, 2006/07. [Li19] [NI92] Jason Li. Faster minimum k-cut of a simple graph. In Foundations of Computer Science (FOCS), 2019 IEEE 60th Annual Symposium on, 2019. Hiroshi Nagamochi and Toshihide Ibaraki. Computing edge-connectivity in multigraphs and capacitated graphs. SIAM J. Discrete Math., 5(1):54 -- 66, 1992. [Tho08] Mikkel Thorup. Minimum k-way cuts via deterministic greedy tree packing. In Proceedings of the fortieth annual ACM symposium on Theory of computing, pages 159 -- 166. ACM, 2008. A Omitted Proofs Proof of Claim 5. We have f (0) = 1 1 − A n(1 − A) = n = f (0) 19 and f(cid:48)(t) = (cid:17) e−t(cid:17) e−tn A A − γ 2 A − (γ/2)A 1 − A n(− γ 2 (cid:16)− γ n (cid:16) e−(γ/2)t + Ae−t) e−(γ/2)t + Ae−t + 2 n(e−(γ/2)t − Ae−t) + A − (γ/2)A γ 2 e−tn. 1 1 − A f (t) + 1 − A f (t) + Be−tn, 1 1 1 − A 1 − A · = = − γ 2 = − γ 2 = − γ 2 where the last equality holds because A = B B + 1 − γ/2 ⇐⇒ BA + A − γ 2 ⇐⇒ A − γ 2 ⇐⇒ A − (γ/2)A 1 − A A = B = B. A = B − BA = B(1 − A) Since f (0) = f (0) and f (t) satisfies (2) with equality, we have f (t) ≥ f (t) for all t ≥ 0. 20
1706.05628
1
1706
2017-06-18T10:01:12
An improved kernel for the cycle contraction problem
[ "cs.DS" ]
The problem of modifying a given graph to satisfy certain properties has been one of the central topics in parameterized tractability study. In this paper, we study the cycle contraction problem, which makes a graph into a cycle by edge contractions. The problem has been studied {by Belmonte et al. [IPEC 2013]} who obtained a linear kernel with at most $6k+6$ vertices. We provide an improved kernel with at most $5k+4$ vertices for it in this paper.
cs.DS
cs
An improved kernel for the cycle contraction problem Bin Sheng ∗a and Yuefang Sunb aDepartment of Computer Science, Royal Holloway, University of London, Egham, Surrey, TW20 0EX, UK bDepartment of Mathematics, Shaoxing University, Shaoxing, Zhejiang 312000, PR China July 26, 2018 Abstract The problem of modifying a given graph to satisfy certain properties has been one of the central topics in parameterized tractability study. In this paper, we study the cycle contraction problem, which makes a graph into a cycle by edge contractions. The problem has been studied by Belmonte et al. [IPEC 2013] who obtained a linear kernel with at most 6k + 6 vertices. We provide an improved kernel with at most 5k + 4 vertices for it in this paper. 1 Introduction Parameterized computation is a new approach to tackle NP-hard problems, it has successful applications in many fields, including Combinatorial Op- timization, Artificial Intelligence, Computational Biology, and so on. A parameterized problem is a subset L ⊆ Σ∗ × N over a finite alphabet Σ. The problem L is said to be fixed-parameter tractable (FPT) if the member- ship of its instance (x, k) in Σ∗ × N can be decided in time f (k)xO(1), where f is a computable function depending on the parameter k only. Given a param- eterized problem L, a kernelization of L is a polynomial time algorithm that shrinks an instance (x, k) into a smaller instance (x′, k′) (the kernel) such that (x, k) ∈ L if and only if (x′, k′) ∈ L and k′ + x′ ≤ g(k) for some function g. It is well-known that a decidable parameterized problem L is fixed-parameter tractable if and only if it has a kernel. Kernels of small size are of the main research interest, due to application needs. Thus, we have particular interests ∗Corresponding author. Email: [email protected] 1 in kernels whose sizes are bounded by a polynomial function of the parame- ter. For a more thorough introduction to FPT and Kernelization, we refer the readers to the excellent books [4, 5, 6] and surveys [13, 15]. Graph theory has been a rich source of research problems from the param- eterized complexity perspective. Among them, there is a large set of research studying the distance of a graph to a certain property, that is, the minimum number of operations that make the graph satisfy the required property. Most common graph modification operations include deleting (or adding) vertices (or edges). Vertex Cover, Feedback Vertex Set, Multiway Cut, Minimum Fill-in and Cluster Editing are just a few of the extensively studied topics in this research framework. Recently, people start to look at the effect of edge contraction on a given graph, and study it in the setting of parameterized tractability. The param- eterized complexity of the contractibility problem has been investigated for various specific classes of graphs, such as making a graph planar [8], split [10], bipartite [9, 11], or more specifically into a tree or a path [12]. We have also seen study of contracting edges to satisfy certain degree bounds [7, 17] or to eliminate small induced subgraphs [16]. This paper follows this line of research by providing an improvement for the cycle contraction problem, which asks to do minimum number of edge contractions on a given graph and make it into a cycle. The cycle contraction problem has been studied in [2], where the authors obtained a linear kernel with at most 6k + 6 vertices. We provide an improved kernel for the problem with at most 5k + 4 vertices in this paper. 2 Notations and Terminology For most of the graph theoretical concepts used in this paper, we follow the notations and terminology in [3]. An undirected graph is denoted by an ordered pair G = (V, E), where E is a set of unordered pairs of elements in V . The elements of V are the vertices of G and the elements of E are the edges of G. Two vertices u, v ∈ V are adjacent if u 6= v and {u, v} ∈ E, and we say they are neighbour of each other. An edge {u, v} is normally written as uv for short, thus u and v are adjacent if and only if uv ∈ E. And in this case we say u is incident with the edge uv. We denote the degree of u in G by dG(u), which is the number of edges incident with u. A graph H = (V ′, E ′) is a subgraph of G if V ′ ⊆ V and E ′ ⊆ E. H = (V ′, E ′) is an induced subgraph of G if V ′ ⊆ V and E ′ = {uv ∈ Eu, v ∈ V ′}. For a set of vertices X ⊆ V (G), we use G[X] to denote the induced subgraph of G with vertex set X. 2 A path is a non-empty graph P = (V, E) with vertex set V = {u0, u1, . . . , uk} and edge set E = {u0u1, u1u2, . . . , uk−1uk}, where ui are all distinct. And we say it is a path between u0 and uk, which are called the endvertices of P . If P = u0u1 . . . uk is a path and k ≥ 2, then the graph we obtain by adding the edge uku0 to P is called a cycle. The length of a path (or a cycle) is the number of edges in it. A path with at least one edge is called a nontrivial path. A non-empty graph G is connected if there is a path between any two of its vertices. A cut set in a connected graph is a set of vertices whose deletion results in a disconnected graph. A connected graph G is said to be k-connected if every cut set of it has size at least k. A connected graph G is k-edge-connected if G remains connected whenever less than k edges are deleted from it. An edge e ∈ E(G) in a connected graph G is called a bridge if G − e = (V (G), E(G) − e) is disconnected. A block in a graph is a maximal 2-connected subgraph. The contraction of an edge uv in G removes u and v from G, and replaces them by a new vertex adjacent to exactly all the neighbours of u and v in G. Note that, by definition, edge contractions create neither self-loops nor multiple edges. The following notions come from [2, 12]. Let H be a graph. A graph G is k-contractible to H if we can obtain a copy of H by at most k edge contractions on G. And we say G is contractible to H if there is some k such that G is k-contractible to H. The contraction is actually defined by a surjection φ : V (G) → V (H), where W (h) = {v ∈ V (G), φ(v) = h} is the set of vertices contracted into h ∈ V (H). The surjection satisfies the following conditions. 1. For every vertex h ∈ V (H), G[W (h)] is a connected subgraph of G, 2. For every pair of vertices in {hi, hj } ⊆ V (H), hihj ∈ E(H) if and only if there is an edge between W (hi) and W (hj), 3. ∪h∈V (H)W (h) = V (G) and W (hi) ∩ W (hj) = ∅ if i 6= j. We call W = {W (h), h ∈ V (H)} an H-witness structure of G. And for each h ∈ V (H), W (h) is called a witness set of W. A witness set W (h) is big (small, respectively) if W (h) ≥ 2 (W (h) = 1, respectively), and we denote it by Wb(h) (Ws(h), respectively). 3 Main Result First let us give the formal definition of the parameterized Cycle Contraction problem. 3 Cycle Contraction [2] Instance: A connected graph G and an integer k. Parameter: k. Output: Decide if one can do at most k edge contractions on G to modify it into a cycle. In this section, we prove that the problem of Cycle Contraction admits a kernel with at most 5k + 4 vertices, which is an improvement over the 6k + 6 kernel bound in [2]. Without loss of generality, we assume that the graphs we consider are connected, as there is no way to edge contract a disconnected graph into a cycle or a path. We also assume that the parameter k ≥ 12 (which implies 5k + 4 ≥ 4.5k + 10), as for the smaller k, the kernel size is at most 4.5k + 10. In [14], the authors study the following parameterized Path Contraction problem and obtain a kernel with at most 3k + 4 vertices. Path Contraction [14] Instance: A connected graph G and an integer k. Parameter: k. Output: Decide if one can do at most k edge contractions on G to modify it into a path. Theorem 1. [14] The parameterized Path Contraction problem admits a ker- nel with at most 3k + 4 vertices. We add some descriptions of the reduction rules in [14] here, to help explain how we make use of their result. Their kernel is obtained by exhaustively applying the following two reduction rules. Note that both reduction rules do not decrease the value of the parameter k. Lemma 1. [14] For any 2-edge-connected graph G = (V, E), if G is con- tractible to a path P by q edge contractions, then q ≥ (V − 1)/3. The authors implicitly use the following reduction rule, which is implied by Lemma 1. Rule A [14] If G is a 2-edge-connected graph and V (G) > 3k + 1, then G is a NO instance for Path Contraction with parameter k. For a connected graph G = (V, E) , let C be a 2-edge-connected component or a single vertex such that each edge between V (C) and V \ V (C) is a bridge. Let G − V (C) = {B1, . . . , Bh} be the set of all connected components in G[V \ V (C)], where h ≥ 1 and V (Bi) ≥ V (Bj) if 1 ≤ i < j ≤ h. Rule B [14] Let e be the bridge of G between C and B1. If V \ V (B1) ≥ k + 2 and one of the following inequalities is satisfied: 4 u′ P1 u G v v′ P2 Figure 1: Construction of the graph H = G + P1 + P2. 1. V (B1) + (V (C) − 1)/3 ≥ k + 2, if 1 ≤ h ≤ 3; 2. V (B1) + (V (C) − 1)/3 + Σh i=4V (Bi) ≥ k + 2, if h ≥ 4. then return (G′, k), where G′ is the graph obtained by contracting e. We will make use of their result to obtain our result on Cycle Contrac- tion. Firstly, we will introduce the problem of Path Contraction with Fixed Endvertices (PCFE), which has the requirement of fixed endvertices. Path Contraction with Fixed Endvertices (PCFE) Instance: A connected graph G, an integer k and two vertices u, v ∈ V (G). Parameter: k. Output: Decide if one can do at most k edge contractions on G and make it into a path between two vertices u0 and v0, such that u ∈ W (u0) and v ∈ W (v0). We will show that PCFE also admits a kernel with at most 3k + 4 vertices. We prove it by reducing an instance of PCFE to an instance (H, k) of the Path Contraction problem. Theorem 2. PCFE admits a kernel with at most 3k + 4 vertices. Proof. Given an instance (G, u, v, k) of PCFE, where G is a connected graph with {u, v} ⊆ V (G). We construct a new graph H = G + P1 + P2, where P1 is a path with length k + 1 between u and u′, and P2 is a path with length k + 1 between v and v′. An example is shown in Figure 1. Note that V (P1) ∩ V (G) = {u}, V (P2) ∩ V (G) = {v}. Now we prove that (G, u, v, k) is a YES instance of PCFE if and only if (H, k) is a YES instance of Path Contraction. Moreover, we show that if (K, k) is the kernel we get for Path Contraction on (H, k) according to the argument in Theorem 1, then (K, u′, v′, k) is a kernel for PCFE on (G, u, v, k). On the one hand, it is obvious to see that if (G, u, v, k) is a YES instance of PCFE, then we can do the same (at most k) edge contractions on H, which would result in a path with endvertices u′ and v′. On the other hand, suppose (H, k) is a YES instance of Path Contraction. Let Φ be a minimum set of edges contracted that modifies H into a path P . 5 A path of length k + 1 will still be a nontrivial path after at most k edge contractions. As both P1 and P2 have length k + 1, the path P must have endvertices s and t where s ∈ P1 and t ∈ P2. Actually we must have s = u′ and t = v′ by the minimality of Φ. The path P must pass through some u0 and v0, where u ∈ W (u0) and v ∈ W (v0). It is easy to see that when we contract those edges in Φ ∩ E(G) on G, we will make G into a path between u0 and v0. By the above argument, we know that (G, u, v, k) is a YES instance of PCFE if and only if (H, k) is a YES instance of Path Contraction. Now we show how to get a kernel for PCFE on (G, u, v, k) from a kernel for Path Contraction on (H, k). Let (K, k) be a kernel for Path Contraction on (H, k) according to the argument in Theorem 1. Since both the lengths of P1 and P2 in H are k + 1, V (Pi) < k + 3, no edge on them satisfies the condition in Rule B. So the kernelization does not contract any edge in P1 and P2, we must have u′, v′ ∈ V (K). Moreover, it is not hard to see that (K, k) is a YES instance for Path Contraction if and only if (K, u′, v′, k) is a YES instance for PCFE, thus (K, u′, v′, k) is a kernel for PCFE on (G, u, v, k). Since V (K) ≤ 3k + 4, we get a kernel for PCFE on (G, u, v, k) as we want. Now we are ready to prove our kernel bound for the Cycle Contraction problem. We adopt the following reduction rules from [2]. Reduction Rule 1 [2] If G is 3-connected and V (G) > 2k + 4, then return NO. Reduction Rule 2 [2] If G contains a block B on at least k + 2 vertices and V (G) \ V (B) 6= ∅, then return NO if V (G) \ V (B) ≥ k + 1, and return the instance (G′, k − V (G) \ V (B)) otherwise, where G′ is the graph obtained from G by exhaustively contracting a vertex of V (G) \ V (B) onto one of its neighbours. Reduction Rule 3 [2] If G contains a block B on at most k + 1 vertices and V (G) \ V (B) ≥ k + 2, then return the instance (G′, k − V (B)), where G′ is the graph obtained from G by exhaustively contracting a vertex of V (B) onto one of its neighbours. Note that any connected graph that is not a tree can be contracted to a cycle. We call a cycle C optimal for G if C is the longest cycle to which G can be contracted. Lemma 2. [2] Let (G, k) be a YES instance of Cycle Contraction, C be an optimal cycle for G, and W be a C-witness structure of G. If G is 2-connected and contains two vertices u and v such that dG(u) = dG(v) = 2 and G − {u, v} has exactly two connected components G1 and G2, then the following three statements hold: 6 H2 u2 v2 G2 x H1 u1 G1 v1 y Figure 2: Constructions of H1 and H2. 1. Either {u} and {v} are small witness sets of W , or u and v belong to the same big witness set of W ; 2. If u and v belong to the same big witness set W ∈ W , then W contains all the vertices of G1 or all the vertices of G2; 3. If G1 and G2 contain at least k + 1 vertices each, then {u} and {v} are small witness sets of W . Based on the observation in Lemma 2, we introduce a novel reduction rule which is the key to make the improvement. Reduction Rule 4 Let (G, k) be an instance of Cycle Contraction, where G is 2-connected. If G contains two vertices x and y such that dG(x) = dG(y) = 2, and the graph G − {x, y} has exactly two connected components G1 and G2, such that V (G1) ≥ k + 2 and V (G2) ≥ k + 2. Then we can obtain a kernel (K, k) for (G, k) with V (K) ≤ 4.5k + 10. We now prove the correctness of Reduction Rule 4. Lemma 3. Reduction Rule 4 is safe. Proof. Let's construct two graphs H1 = G − V (G2), H2 = G − V (G1), see Figure 2 for an illustration. Both x and y have degree 2, let NG(x) = {u1, u2} and NG(y) = {v1, v2} with {u1, v1} ⊆ V (G1), {u2, v2} ⊆ V (G2). Since G is 2-connected, we know u1 6= v1 and u2 6= v2. By statement 3 in Lemma 2, we know that both {x} and {y} should be small witness sets, thus the problem of contracting G into a cycle is equivalent to doing at most k edge contractions that make both H1 and H2 into paths between x and y. Note that one can contract Hi into a path between x and y where both {x} and {y} are small witness sets with at most ki edge contractions if and only if (Gi, ui, vi, ki) is a YES instance for PCFE with i ∈ {1, 2}. 7 Let's consider the following two instances of PCFE, (G1, u1, v1, ⌊k/2⌋) and (G2, u2, v2, ⌊k/2⌋). If the answers to both (G1, u1, v1, ⌊k/2⌋) and (G2, u2, v2, ⌊k/2⌋) are NO, then we know that (G, k) is a No instance for Cycle Contrac- tion. If either enquiry gives a kernel, then we know it should have at most 3⌊k/2⌋ + 4 vertices by Theorem 2. Without loss of generality, assume that (G1, u1, v1, ⌊k/2⌋) gives a kernel (K1, u′ 1, ⌊k/2⌋) following the argument in Theorem 2. We further look at (G2, u2, v2, k) as an instance of PCFE. If the answer to (G2, u2, v2, k) is NO, then we know that (G, k) is also a No instance for Cycle Contraction. Otherwise, we get a kernel (K2, u′ 2, k) for (G2, u2, v2, k) with at most 3k + 4 vertices by Theorem 2. 2, v′ 1, v′ Let R be the graph obtained from K1 and K2 by adding edges {xu′ 2} 2}, which implies that V (R) = V (K1) + V (K2) + {x, y} ≤ 1, xu′ and {yv′ 3⌊k/2⌋ + 4 + 3k + 4 + 2 ≤ 4.5k + 10. 1, yv′ 1, v′ Claim: (R, k) is a kernel for Cycle Contraction on (G, k). Observe that G can be contracted into a cycle by at most k edge contrac- tions, if and only if there exist two non-negative integers k1 and k2 such that k1 + k2 = k, and (Gi, ui, vi, ki) is a YES instance for PCFE with i ∈ {1, 2}. Recall that (K1, u′ 1, ⌊k/2⌋) is a kernel for (G1, u1, v1, ⌊k/2⌋), and the two pendent paths P1 and P2 in K1 constructed according to the argument of Theorem 2 have total length 2(⌊k/2⌋ + 1) > k1. So (G1, u1, v1, k1) is a YES instance for PCFE if and only if K1 can be contracted into a path between u′ 1 and v′ 2, k) is a kernel for (G2, u2, v2, k), (G2, u2, v2, k2) is a YES instance for PCFE if and only if K2 can be contracted into a path between u′ 2 by at most k2 (≤ k) edge contractions. Thus (R, k) is a kernel for Cycle Contraction on (G, k). 1 by at most k1 edge contractions. And (K2, u′ 2 and v′ 2, v′ Theorem 3. The Cycle Contraction problem admits a kernel with at most 5k + 4 vertices. Proof. We describe our algorithm to obtain the claimed kernel for the Cycle Contraction problem. The correctness of the algorithm follows from the cor- rectness of the reduction rules. Given an instance (G, k) of Cycle Contraction, the algorithm begins with applications of Reduction Rules 1-4 we listed above. Let K be the resulting instance after all possible applications of the reduc- tion rules. If K is 3-connected, then we must have that V (K) ≤ 2k + 3, as otherwise Reduction Rule 1 could be applied. If K is not 2-connected, then K has at least two blocks as K is connected by assumption. Let B be any block of K. Then V (B) ≤ k +1, as otherwise Rule 2 could be applied. Moreover, V (K) \ V (B) ≤ k + 1 due to the assumption that Rule 3 cannot be applied. Hence V (K) ≤ 2k + 2. In the following, we assume that K is 2-connected and will prove the following claim. 8 D1 v0 W (w) v1 w v0 v1 vi+1 vi vi+1 vi C D2 K Figure 3: The kernel K and its optimal cycle C. Claim: If K is 2-connected and V (K) ≥ 5k+4, then we can safely return NO. To see why the claim is correct, suppose, on the contrary, that (K, k) is a YES instance of Cycle Contraction such that K is a 2-connected graph with at least 5k + 4 vertices after all applications of Reduction Rules 1-4. Let C be an optimal cycle for K and let W be a C-witness structure of K. We know that V (K) = V1 ∪ V2 ∪ V3, where V1 = {v ∈ Wb(u)u ∈ C}, V2 = {udC (u) = 2, dK (u) = 2} and V3 = {udC (u) = 2, dK (u) > 2}. There are at most k big witness sets in W , which in total contains at most 2k vertices, thus V1 ≤ 2k. Any vertex v ∈ V3 must be adjacent to vertices in V1 as dK(v) > dC (v) = 2 and it is in a small witness set, so V3 ≤ 2k. Thus we know V2 = V (K) − V1 − V3 ≥ 5k + 4 − 2k − 2k = k + 4. Let's call any vertex in V2 a small-witness vertex. In the following, we will prove that there must be two small-witness vertices x and y such that K − {x, y} has two components each of which contains at least k + 2 vertices, thus Reduction Rule 4 can be applied, a contradiction. Choose a small-witness vertex v0, and let w be the neighbour of v0 clock- wisely in C, as shown in Figure 3. We want to find another small-witness vertex v in the cycle C such that K − {v0, v} contains two connected com- ponents, each of which has size at least k + 2. Starting at v0, let's look at the small-witness vertices in C one by one clockwisely. And denote these vertices by vi with i = 0, 1, 2, . . . , V2. Let i ≥ 0 be the smallest subscript such that the component containing W (w) in K − {v0, vi+1} contains at least k + 2 vertices. If K − {v0, vi+1} contains two connected components each of which has size at least k + 2, then we are done. Otherwise, we know the number of vertices in the component not containing W (w) in K − {v0, vi+1} 9 is less than k + 2. Denote the two components of K − {vi, vi+1} by D1 and D2, where W (w) ⊆ V (D1). Since V (K) ≥ 5k + 4 and the component in K − {v0, vi} containing W (w) has less than k + 2 vertices by the choice of i, we have V (D2) ≥ 5k + 4 − 2(k + 1) − 3 = 3k − 1 ≥ k + 2. As there is no small-witness vertex in D2, there are at least k + 4 − {vi, vi+1} = k + 2 small-witness vertices in D1, thus V (D1) ≥ k + 2. Let x = vi and y = vi+1, then K − {x, y} has two components each of which contains at least k + 2 vertices. Thus we have found two vertices with the requested properties. It remains to observe that our kernelization algorithm can be run in poly- nomial time. For Reduction Rule 1, it takes O(n3) steps to check if a graph is 3-connected. And for Reduction Rule 2 or 3, it takes O(n2) steps to decide if they are applicable. And each application of Reductions 2 and 3 either returns NO or decreases the number of vertices, they can be exhaustively applied in polynomial time. As for Reduction Rule 4, note that the kernelization for PCFE can be run in polynomial time, since the kernelization for Path Con- traction can be applied in polynomial time. Thus Reduction Rule 4 can also be applied in polynomial time, by simply checking all possible pairs of vertices with degree 2 in the graph to see if we need to apply the kernelization for PCFE. 4 Conclusion In the past decade, much effort has been put into obtaining better parameter dependence in the running time for all kinds of classical parameterized prob- lems, like Vertex Cover, Feedback Vertex Set, Multiway Cut and so on. There are mainly two directions of algorithmic improvement for a problem that has been proved to be FPT, to obtain a better running time and to obtain a better kernel. In this paper, we provide a kernel for the Cycle Contraction problem with at most 5k + 4 vertices, which is a non-trivial improvement over the 6k + 6 kernel in [2]. Our improvement relies on observing the connection between Path Contraction and Cycle Contraction, which allows us to utilize an existing result on Path Contraction problem. In directed graphs, there are two types of contractions, i.e. the set contrac- tion and path contraction, see the definitions in [1]. It would be interesting to see whether the paramterized tractability results of the contraction problems can be generalized to the directed case. 5 Acknowledgement The research of Bin Sheng was partially supported by China Scholarship Coun- cil (No. 201306140052). Yuefang Sun was supported by National Natural 10 Science Foundation of China (No. 11401389), China Scholarship Council (No. 201608330111) and Zhejiang Provincial Natural Science Foundation of China (No. LY17A010017). References [1] Jørgen Bang-Jensen and Gregory Z Gutin. Digraphs: theory, algorithms and applications. Springer Science & Business Media, 2 edition, 2009. [2] R´emy Belmonte, Petr A Golovach, Pim van't Hof, and Daniel Paulusma. Parameterized complexity of two edge contraction problems with degree constraints. In International Symposium on Parameterized and Exact Computation, pages 16 -- 27. Springer, 2013. [3] B´ela Bollob´as. Modern graph theory, volume 184. Springer Science & Business Media, 2013. [4] Marek Cygan, Fedor V Fomin, Lukasz Kowalik, Daniel Lokshtanov, D´aniel Marx, Marcin Pilipczuk, Micha l Pilipczuk, and Saket Saurabh. Parameterized Algorithms, volume 4. Springer, 2015. [5] Rodney G Downey and Michael R Fellows. Fundamentals of parameter- ized complexity, volume 4. Springer, 2013. [6] J. Flum and M. Grohe. Parameterized Complexity Theory (Texts in Theo- retical Computer Science. An EATCS Series). Springer-Verlag New York, Inc., Secaucus, NJ, USA, 2006. [7] Petr A Golovach, Marcin Kami´nski, Daniel Paulusma, and Dimitrios M Thilikos. Increasing the minimum degree of a graph by contractions. In International Symposium on Parameterized and Exact Computation, pages 67 -- 79. Springer, 2011. [8] Petr A Golovach, Pim van't Hof, and Daniel Paulusma. Obtaining pla- narity by contracting few edges. Theoretical Computer Science, 476:38 -- 46, 2013. [9] Sylvain Guillemot and D´aniel Marx. A faster fpt algorithm for bipartite contraction. Information Processing Letters, 113(22):906 -- 912, 2013. [10] Chengwei Guo and Leizhen Cai. Obtaining split graphs by edge contrac- tion. Theoretical Computer Science, 607:60 -- 67, 2015. [11] Pinar Heggernes, Pim van't Hof, Daniel Lokshtanov, and Christophe Paul. Obtaining a bipartite graph by contracting few edges. SIAM Jour- nal on Discrete Mathematics, 27(4):2143 -- 2156, 2013. 11 [12] Pinar Heggernes, Pim van't Hof, Benjamin L´eveque, Daniel Lokshtanov, and Christophe Paul. Contracting graphs to paths and trees. Algorith- mica, 68(1):109 -- 132, 2014. [13] Stefan Kratsch. Recent developments in kernelization: A survey. Bulletin of EATCS, 2(113), 2014. [14] Wenjun Li, Qilong Feng, Jianer Chen, and Shuai Hu. Improved kernel results for some fpt problems based on simple observations. Theoretical Computer Science, 2016. [15] Daniel Lokshtanov, Neeldhara Misra, and Saket Saurabh. Kernelization- preprocessing with a guarantee. In The Multivariate Algorithmic Revolu- tion and Beyond, pages 129 -- 161. Springer, 2012. [16] Daniel Lokshtanov, Neeldhara Misra, and Saket Saurabh. On the hard- ness of eliminating small induced subgraphs by contracting edges. In In- ternational Symposium on Parameterized and Exact Computation, pages 243 -- 254. Springer, 2013. [17] Luke Mathieson and Stefan Szeider. Editing graphs to satisfy degree constraints: A parameterized approach. Journal of Computer and System Sciences, 78(1):179 -- 191, 2012. 12
1308.5207
4
1308
2015-10-06T20:07:56
Approximating the Little Grothendieck Problem over the Orthogonal and Unitary Groups
[ "cs.DS", "math.OC" ]
The little Grothendieck problem consists of maximizing $\sum_{ij}C_{ij}x_ix_j$ over binary variables $x_i\in\{\pm1\}$, where C is a positive semidefinite matrix. In this paper we focus on a natural generalization of this problem, the little Grothendieck problem over the orthogonal group. Given C a dn x dn positive semidefinite matrix, the objective is to maximize $\sum_{ij}Tr (C_{ij}^TO_iO_j^T)$ restricting $O_i$ to take values in the group of orthogonal matrices, where $C_{ij}$ denotes the (ij)-th d x d block of C. We propose an approximation algorithm, which we refer to as Orthogonal-Cut, to solve this problem and show a constant approximation ratio. Our method is based on semidefinite programming. For a given $d\geq 1$, we show a constant approximation ratio of $\alpha_{R}(d)^2$, where $\alpha_{R}(d)$ is the expected average singular value of a d x d matrix with random Gaussian $N(0,1/d)$ i.i.d. entries. For d=1 we recover the known $\alpha_{R}(1)^2=2/\pi$ approximation guarantee for the classical little Grothendieck problem. Our algorithm and analysis naturally extends to the complex valued case also providing a constant approximation ratio for the analogous problem over the Unitary Group. Orthogonal-Cut also serves as an approximation algorithm for several applications, including the Procrustes problem where it improves over the best previously known approximation ratio of~$\frac1{2\sqrt{2}}$. The little Grothendieck problem falls under the class of problems approximated by a recent algorithm proposed in the context of the non-commutative Grothendieck inequality. Nonetheless, our approach is simpler and it provides a more efficient algorithm with better approximation ratios and matching integrality gaps. Finally, we also provide an improved approximation algorithm for the more general little Grothendieck problem over the orthogonal (or unitary) group with rank constraints.
cs.DS
cs
Approximating the Little Grothendieck Problem over the Orthogonal and Unitary Groups Afonso S. Bandeira∗ Christopher Kennedy† Amit Singer‡ October 8, 2015 Abstract (cid:1) The little Grothendieck problem consists of maximizing(cid:80) C ∈ Rdn×dn a positive semidefinite matrix, the objective is to maximize(cid:80) ij Cijxixj for a positive semidef- inite matrix C, over binary variables xi ∈ {±1}. In this paper we focus on a natural gener- alization of this problem, the little Grothendieck problem over the orthogonal group. Given ijOiOT restricting Oi to take values in the group of orthogonal matrices Od, where Cij denotes the j (ij)-th d × d block of C. We propose an approximation algorithm, which we refer to as Orthogonal-Cut, to solve the little Grothendieck problem over the group of orthogonal matrices Od and show a constant approximation ratio. Our method is based on semidefinite programming. For a given d ≥ 1, we show a constant approximation ratio of αR(d)2, where αR(d) is the expected average singular value of a d × d matrix with random Gaussian N(cid:0)0, 1 ij tr(cid:0)C T (cid:1) i.i.d. entries. For d = 1 we d recover the known αR(1)2 = 2/π approximation guarantee for the classical little Grothendieck problem. Our algorithm and analysis naturally extends to the complex valued case also providing a constant approximation ratio for the analogous little Grothendieck problem over the Unitary Group Ud. Orthogonal-Cut also serves as an approximation algorithm for several applications, in- cluding the Procrustes problem where it improves over the best previously known approx- imation ratio of . The little Grothendieck problem falls under the larger class of prob- lems approximated by a recent algorithm proposed in the context of the non-commutative Grothendieck inequality. Nonetheless, our approach is simpler and provides better approxi- mation with matching integrality gaps. √ 1 2 2 Finally, we also provide an improved approximation algorithm for the more general little Grothendieck problem over the orthogonal (or unitary) group with rank constraints, recov- ering, when d = 1, the sharp, known ratios. Keywords: Approximation algorithms, Procrustes problem, Semidefinite programming. ∗Department of Mathematics, Massachusetts Institute of Technology, Cambridge, Masachusetts 02142, USA ([email protected]). Most of this work was done while ASB was at Princeton University. †Department of Mathematics, The University of Texas at Austin, Austin, Texas 78712, USA ([email protected]). ‡Department of Mathematics and PACM, Princeton University, Princeton, New Jersey 08544, USA ([email protected]). 1 1 Introduction The little Grothendieck problem [AN04] in combinatorial optimization is written as Cijxixj, (1) where C is a n × n positive semidefinite matrix real matrix. Problem (1) is known to be NP-hard. In fact, if C is a Laplacian matrix of a graph then (1) is equivalent to the Max-Cut problem. In a seminal paper in the context of the Max-Cut problem, Goemans and Williamson [GW95] provide a semidefinite relaxation for (1): n(cid:88) n(cid:88) i=1 j=1 max xi∈{±1} n(cid:88) n(cid:88) i=1 j=1 sup m∈N max Xi∈Rm (cid:107)Xi(cid:107)2=1 CijX T i Xj. (2) It is clear that in (2), one can take m = n. Furthermore, (2) is equivalent to a semidefinite program and can be solved, to arbitrary precision, in polynomial time [VB96]. In the same paper [GW95] it is shown that a simple rounding technique is guaranteed to produce a solution whose objective value is, in expectation, at least a multiplicative factor 2 0.878 of the optimum. π for the general case of an arbitrary positive semidefinite C (cid:23) 0 using the same relaxation as [GW95]. This implies, in particular, that the value of (1) can never be smaller than 2 π times the value of (2). Interestingly, such an inequality was already known from the influential work of Grothendieck on norms of tensor products of Banach spaces [Gro96] (see [Pis11] for a survey on this). A few years later, Nesterov [Nes98] showed an approximation ratio of 2 π min0≤θ≤π 1−cos θ ≈ θ Several more applications have since been found for the Grothendieck problem (and variants), and its semidefinite relaxation. Alon and Naor [AN04] showed applications to estimating the cut-norm of a matrix; Ben-Tal and Nemirovski [BTN02] showed applications to control theory; Briet, Buhrman, and Toner [BBT11] explored connections with quantum non-locality; and many more (see [AMMN05]). In this paper, we focus on a natural generalization of problem (1), the little Grothendieck problem over the orthogonal group, where the variables are now elements of the orthogonal group Od, instead of {±1}. More precisely, given C ∈ Rdn×dn a positive semidefinite matrix, we consider the problem n(cid:88) n(cid:88) tr(cid:0)CT i=1 j=1 ijOiOT j max O1,...,On∈Od where Cij denotes the (i, j)-th d× d block of C, and Od is the group of d× d orthogonal matrices (i.e., O ∈ Od if and only if OOT = OT O = Id×d). We will also consider the unitary group variant, where the variables are now elements of the unitary group Ud (i.e., U ∈ Ud if and only if U U H = U H U = Id×d). More precisely, given C ∈ Cdn×dn a complex valued positive semidefinite matrix, we consider the problem (3) (4) (cid:1) , (cid:1) . n(cid:88) n(cid:88) tr(cid:0)CH ij UiU H j max U1,...,Un∈Ud i=1 j=1 2 Since C is Hermitian positive semidefinite, the value of the objective function in (4) is always real. Note also that when d = 1, (3) reduces to (1). Also, since U1 is the multiplicative group of the complex numbers with unit norm, (4) recovers the classical complex case of the little Grothendieck problem. In fact, the work of Nesterov was extended [SZY07] to the complex plane (corresponding to U1, or equivalently, the special orthogonal group SO2) with an approximation 4 for C (cid:23) 0. As we will see later, the analysis of our algorithm shares many ideas with ratio of π the proofs of both [Nes98] and [SZY07] and recovers both results. As we will see in Section 2, several problems can be written in the forms (3) and (4), such as the Procrustes problem [Sch66, Nem07, So11] and Global Registration [CKS15]. Moreover, the approximation ratio we obtain for (3) and (4) translates into the same approximation ratio for these applications, improving over the best previously known approximation ratio of in the real case and 1 2 in the complex case, given by [NRV13] for these problems. Problem (3) belongs to a wider class of problems considered by Nemirovski [Nem07] called QO-OC (Quadratic Optimization under Orthogonality Constraints), which itself is a subclass of QC-QP (Quadratically Constrainted Quadratic Programs). Please refer to Section 2 for a more detailed comparison with the results of Nemirovski [Nem07]. More recently, Naor et al. [NRV13] propose an efficient rounding for the non commutative Grothendieck inequality that provides an approximation algorithm for a vast set of problems involving orthogonality constraints, including problems of the form of (3) and (4). We refer to Section 1.2 for a comparison between this approach and ours. √ 1 2 2 Similarly to (2) we formulate a semidefinite relaxation we name the Orthogonal-Cut SDP: n(cid:88) n(cid:88) tr(cid:0)CT i=1 j=1 ijXiX T j n(cid:88) n(cid:88) tr(cid:0)CH i=1 j=1 ij YiY H j (cid:1) . (cid:1) . (5) (6) Analogously, in the unitary case, we consider the relaxation sup m∈N max i =Id×d XiX T Xi∈Rd×m sup m∈N max i =Id×d YiY H Yi∈Cd×m Since C is Hermitian positive semidefinite, the value of the objective function in (6) is guaranteed to be real. Note also that we can take m = dn as the Gram matrix [XiX T j ]i,j does not have a rank constraint for this value of m. In fact, both problems (5) and (6) are equivalent to the semidefinite program max G∈Kdn×dn Gii=Id×d, G(cid:23)0 tr(CG), (7) for K respectively R and C, and so can be solved, up to arbitrary precision, in polynomial time1 [VB96]. At first glance, one could think of problem (5) as having d2n variables and that we would have to take m = d2n for (5) to be tractable (in fact, this is the size of the SDP considered by Nemirovski [Nem07]). The savings in size (corresponding to number of variables) of our proposed SDP relaxation come from the group structure of Od (or Ud). One of the main contributions of this paper is showing that Algorithm 3 (Section 1.1) gives a constant factor approximation to (3), and its unitary analog (4), with an optimal approximation 1We also note that these semidefinite programs satisfy Slater’s condition as the identity matrix is a feasible point. This ensures strong duality, which can be exploited by many semidefinite programming solvers. 3 ratio for our relaxation (Section 6). in [GW95] applied to (5), or (4). Theorem 1 Let C (cid:23) 0 and real. Let V1, . . . , Vn ∈ Od be the (random) output of the orthogonal version of Algorithm 3. Then It consists of a simple generalization of the rounding  n(cid:88) E n(cid:88) tr(cid:0)CT i=1 j=1 ijViV T j (cid:1) ≥ αR(d)2 max O1,...,On∈Od n(cid:88) n(cid:88) tr(cid:0)CT i=1 j=1 ijOiOT j (cid:1) , Analogously, in the unitary case, if W1, . . . , Wn ∈ Ud are the (random) output of the unitary where αR(d) is the constant defined below. version of Algorithm 3, then for C (cid:23) 0 and complex,  n(cid:88) E n(cid:88) tr(cid:0)CH i=1 j=1 ij WiW H j (cid:1) ≥ αC(d)2 max U1,...,Un∈Ud n(cid:88) n(cid:88) i=1 j=1 tr(cid:0)CH ij UiU H j (cid:1) , where αC(d) is defined below. Definition 2 Let GR ∈ Rd×d and GC ∈ Cd×d be, respectively, a Gaussian random matrix with i.i.d real valued entries N(cid:0)0, d−1(cid:1) and a Gaussian random matrix with i.i.d complex valued entries N(cid:0)0, d−1(cid:1). We define  1  and αC(d) := E αR(d) := E  , d(cid:88) σj(GR) σj(GC)  1 d j=1 d(cid:88) j=1 d where σj(G) is the jth singular value of G. Although we do not have a complete understanding of the behavior of αR(d) and αC(d) as functions of d, we can, for each d separately, compute a closed form expression (see Sec- tion 4). For d = 1 we recover the sharp αR(1)2 = 2 4 results of, respectively, Nesterov [Nes98] and So et al. [SZY07]. One can also show that limd→∞ αK(d)2 = (cid:0) 8 π and αC(1)2 = π (cid:1)2, for 3π both K = R and K = C. Curiously, (cid:18) 8 (cid:19)2 3π αR(1)2 = 2 π < < π 4 = αC(1)2. Our computations strongly suggest that αR(d) is monotonically increasing while its complex analog αC(d) is monotonically decreasing. We find the fact that the approximation ratio seems to get, as the dimension increases, better in the real case and worse in the complex case quite intriguing. One might naively think that the problem for a specific d can be formulated as a degenerate problem for a larger d, however this does not seem to be true, as evidenced by the fact that α2R(d) is increasing. Another interesting point is that αR(2) (cid:54)= αC(1) which suggests that the little Grothendieck problem over O2 is quite different from the analog in U1 (which is isomorphic to SO2). Unfortunately, we were unable to provide a proof for the monotonicity of αK(d) (Conjecture 8). Nevertheless, we can show lower bounds for both α2R(d) and α2C(d) that 4 have the right asymptotics (see Section 4). In particular, we can show that our approximation ratios are uniformly bounded below by the approximation ratio given in [NRV13]. In some applications, such as the Common Lines problem [SS11] (see Section 5), one is interested in a more general version of (3) where the variables take values in the Stiefel manifold O(d,r), the set of matrices O ∈ Rd×r such that OOT = Id×d. This motivates considering a generalized version of (3) formulated as, for r ≥ d, n(cid:88) n(cid:88) tr(cid:0)CT i=1 j=1 (cid:1) , ijOiOT j max O1,...,On∈O(d,r) (8) for C (cid:23) 0. The special case d = 1 was formulated and studied in [BBT11] and [BFV10] in the context of quantum non-locality and quantum XOR games. Note that in the special case r = nd, (8) reduces to (5) and is equivalent to a semidefinite program. We propose an adaption of Algorithm 3, Algorithm 9, and show an approximation ratio of αR(d, r)2, where αR(d, r) is also defined as the average singular value of a Gaussian matrix (see Section 5). For d = 1 we recover the sharp results of Briet el al. [BFV10] giving a simple interpretation for the approximation ratios, as α(1, r) is simply the mean of a normalized chi- distribution with r degrees of freedom. As before, the techniques are easily extended to the complex valued case. In order to understand the optimality of the approximation ratios αR(d)2 and αC(d)2 we provide an integrality gap for the relaxations (5) and (6) that matches these ratios, showing that they are tight. Our construction of an instance having this gap is an adaption of the classical construction for the d = 1 case (see, e.g., [AN04]). As it will become clear later (see Section 6), there is an extra difficulty in the d > 1 orthogonal case which can be dealt with using the Lowner-Heinz Theorem on operator convexity (see Theorem 13 and the notes [Car09]). Besides the monotonicity of α2K(d) (Conjecture 8), there are several interesting questions raised from this work, including the hardness of approximation of the problems considered in this paper (see Section 7 for a discussion on these and other directions for future work). Organization of the paper: The paper is organized as follows. In Section 1.1 below we present the approximation algorithm for (3) and (4). In Section 1.2, we compare our results with the ones in [NRV13]. We then describe a few applications in Section 2 and show the analysis for the approximation ratio guarantee in Section 3. In Section 4 we analyze the value of the approximation ratio constants. Section 5 is devoted to a more general, rank constrained, version of (4). We give an integrality gap for our relaxation in Section 6 and discuss open problems and future work in Section 7. Finally, we present supporting technical results in the Appendix. 1.1 Algorithm We now present the (randomized) approximation algorithm we propose to solve (3) and (4). Algorithm 3 Compute X1, . . . , Xn ∈ Rd×nd (or Y1, . . . , Yn ∈ Cd×nd) a solution to (5) (or (6)). Let R be a nd × d Gaussian random matrix whose entries are real (or complex) i.i.d. N (0, 1 d ). The approximate solution for (3) (or (4)) is now computed as where P(X) = argminZ∈Od (or Y ∈ Cd×d) and XF =(cid:112)tr (XX T )(Y F =(cid:112)tr (Y Y H )) is the Frobenius norm. (cid:107)Z − X(cid:107)F (or P(Y ) = argminZ∈Ud (cid:107)Z − Y (cid:107)F ), for any X ∈ Rd×d Vi = P(XiR), 5 Note that (5) and (6) can be solved with arbitrary precision in polynomial time [VB96] as they are equivalent to a semidefinite program (followed by a Cholesky decomposition) with a, respectively real and complex valued, matrix variable of size dn× dn, and d2n linear constraints. In fact, this semidefinite program has a very similar structure to the classical Max-Cut SDP. This may allow one to adapt specific methods designed to solve the Max-Cut SDP such as, for example, the row-by-row method [WGS12] (see Section 2.4 of [Ban15]). Moreover, given X a d × d matrix (real or complex), the polar component P(X) is the orthogonal (or unitary) matrix part of the polar decomposition, that can be easily computed via the singular value decomposition of X = U ΣV H as P(X) = U V H (see [FH55, Kel75, Hig86]), rendering Algorithm 3 efficient. The polar component P(X) = U V H is the analog in high 2 . dimensions of the sign in O1 and the angle in U1 and can also be written as P(X) = X(cid:0)X H X(cid:1)− 1 1.2 Relation to non-commutative Grothendieck inequality The approximation algorithm proposed in [NRV13] can also be used to approximate problems (3) and (4). In fact, the method in [NRV13] deals with problems of the form (cid:88) pqkl sup X,Y ∈ON MpqklXpqYkl, (9) where M is a N × N × N × N real valued 4-tensor. Problem (3) can be encoded in the form of (9) by taking N = dn and having the d× d block of M , obtained by having the first two indices range from (i − 1)d + 1 to id and the last two from (j − 1)d + 1 to jd, equal to Cij, and the rest of the tensor equal to zero [NRV13]. More explicitly, the nonzero entries of M are given by M(i−1)d+r,(i−1)d+r,(j−1)d+s,(j−1)d+s = [Cij]rs, for each i, j and r, s = 1, . . . , d. Since C is positive semidefinite, the supremum in (9) is attained at a pair (X, Y ) such that X = Y . In order to describe the relaxation one needs to first define the space of vector-valued or- thogonal matrices ON (m) = {X ∈ RN×N×m : XX T = X T X = IN×N} where XX T and pq = r=1 XpkrXqkr and (cid:0)X T X(cid:1) (cid:80)m k=1 X T X are N × N matrices defined as (cid:0)XX T(cid:1) pq = (cid:80)N (cid:80)N (cid:88) ified as above) is given by r=1 XkprXkqr. k=1 The relaxation proposed in [NRV13] (which is equivalent to our relaxation when M is spec- (cid:80)m (10) sup m∈N sup U,V ∈ON (m) pqkl MpqklUpqVkl, and there exists a rounding procedure [NRV13] that achieves an approximation ratio of . 2 Analogously, in the unitary case, the relaxation is essentially the same and the approximation ratio is 1 2 . We can show (see Section 4) that the approximation ratios we obtain are larger than these for all d ≥ 1. Interestingly, the approximation ratio of 1 2 , for the complex case in [NRV13], is tight in the full generality of the problem considered in [NRV13], nevertheless αC(d)2 is larger than this for all dimensions d. √ 1 2 Note also that to approximate (3) with this approach one needs to have N = dn in (10). This means that a naıve implementation of this relaxation would result in a semidefinite program with a matrix variable of size d2n2 × d2n2, while our approach is based on semidefinite programs with matrix variables of size dn× dn. It is however conceivable that when restricted to problems 6 of the type of (3), the SDP relaxation (10) may enjoy certain symmetries or other properties that facilitate its solution. 2 Applications Problem (3) can describe several problems of interest. As examples, we describe below how it encodes a complementary version of the orthogonal Procrustes problem and the problem of Global Registration over Euclidean Transforms. Later, in Section 5, we briefly discuss yet an- other problem, the Common Lines problem, that is encoded by a more general rank constrained version of (3). 2.1 Orthogonal Procrustes Given n point clouds in Rd of k points each, the orthogonal Procrustes problem [Sch66] consists If of finding n orthogonal transformations that best simultaneously align the point clouds. the points are represented as the columns of matrices A1, . . . , An, where Ai ∈ Rd×k then the orthogonal Procrustes problem consists of solving Since OT as the complementary version of the problem F = (cid:107)Ai(cid:107)2 i Ai − OT j Aj2 n(cid:88) i,j=1 min O1,...,On∈Od F − 2 tr F + (cid:107)Aj(cid:107)2 n(cid:88) max O1,...,On∈Od i,j=1 j Aj2 F . j )T OiOT j OT i Ai − OT (cid:16) tr(cid:0)(AiAT (AiAT j )T OiOT j (cid:17) (11) , (11) has the same solution (cid:1) . (12) Since C ∈ Rdn×dn given by Cij = AiAT j is positive semidefinite, problem (12) is encoded by (3) and Algorithm 3 provides a solution with an approximation ratio guaranteed (Theorem 1) to be at least αR(d)2. The algorithm proposed in Naor et al. [NRV13] gives an approximation ratio of , smaller than αR(d)2, for (12). As discussed above, the approach in [NRV13] is based on a semidefinite relaxation with a matrix variable of size d2n2 × d2n2 instead of dn× dn as in (5) (see Section 1.2 for more details). Nemirovski [Nem07] proposed a different semidefinite relaxation (with a matrix variable of size d2n × d2n instead of dn × dn as in (5)) for the orthogonal Procrustes problem. In fact, his algorithm approximates the slightly different problem 2 √ 1 2 tr(cid:0)(AiAT (cid:88) i(cid:54)=j (cid:1) , j )T OiOT j max O1,...,On∈Od proximation ratio for this semidefinite relaxation, due to So [So11], is O(cid:16) which is an additive constant (independent of O1, . . . , On) smaller than (12). The best known ap- . Although an approximation to (13) would technically be stronger than an approximation to (12), the two quantities are essentially the same provided that the point clouds are indeed perturbations of log(n+k+d) (cid:17) 1 (13) 7 orthogonal transformations of the same original point cloud, as is the case in most applications (see [NRV13] for a more thorough discussion on the differences between formulations (12) and (13)). Another important instance of this problem is when the transformations are elements of SO2 (the special orthogonal group of dimension 2, corresponding to rotations of the plane). Since SO2 is isomorphic to U1 we can encode it as an instance of problem (4), in this case we recover the previously known optimal approximation ratio of π 4 [SZY07]. Note that, since all instances of problem (3) can be written as an instance of orthogonal Procrustes, the integrality gap we show (Theorem 14) guarantees that our approximation ratio is optimal for the natural semidefinite relaxation we consider for the problem. 2.2 Global Registration over Euclidean Transforms The problem of global registration over Euclidean rigid motions is an extension of orthogonal Procrustes. In global registration, one is required to estimate the positions x1, . . . , xk of k points in Rd and the unknown rigid transforms of n local coordinate systems given (perhaps noisy) measurements of the local coordinates of each point in some (though not necessarily all) of the local coordinate systems. The problem differs from orthogonal Procrustes in two aspects: First, for each local coordinate system, we need to estimate not only an orthogonal transformation but also a translation in Rd. Second, each point may appear in only a subset of the coordinate systems. Despite those differences, it is shown in [CKS15] that global registration can also be reduced to the form (3) with a matrix C that is positive semidefinite. More precisely, denoting by Pi the subset of points that belong to the i-th local coordinate system (i = 1 . . . n), and given the local coordinates x(i) l = OT i (xl − ti) + ξil of point xl ∈ Pi (where Oi denotes an unknown orthogonal transformation, ti an unknown translation and ξil a noise term). The goal is to estimate the global coordinates xl. The idea is to minimize the function φ = l + ti) , (cid:13)(cid:13)(cid:13)xl − (Oix(i) (cid:18)(cid:104) BL†BT(cid:105) tr n(cid:88) (cid:88) i=1 l∈Pi n(cid:88) n(cid:88) i=1 j=1 max Oi∈Od (cid:13)(cid:13)(cid:13)2 (cid:19) over xl, ti ∈ Rd, Oi ∈ Od. It is not difficult to see that the optimal x(cid:63) i can be written in terms of O1, . . . , On. Substituting them back into φ, the authors in [CKS15] reduce the previous optimization to solving l and t(cid:63) OiOT j ij , (14) where L is a certain (n + k) × (n + k) Laplacian matrix, L† is its pseudo inverse, and B is a (dn)× (n + k) matrix (see [CKS15]). This means that BL†BT (cid:23) 0, and (14) is of the form of (3). 3 Analysis of the approximation algorithm In this Section we prove Theorem 1. As (5) and (6) are relaxations of, respectively, problem (3) and problem (4) their maximums are necessarily at least as large as the ones of, respectively, (3) and (4). This means that Theorem 1 is a direct consequence of the following Theorem. 8 Theorem 4 Let C (cid:23) 0 and real. Let X1, . . . , Xn be a feasible solution to (5). Let V1, . . . , Vn ∈ Od be the output of the (random) rounding procedure described in Algorithm 3. Then  n(cid:88) E n(cid:88) tr(cid:0)CT ijViV T j (cid:1) ≥ αR(d)2 n(cid:88) n(cid:88) tr(cid:0)CT i=1 j=1 i=1 j=1 (cid:1) , ijXiX T j where αR(d) is the constant in Definition 2. Analogously, if C (cid:23) 0 and complex and Y1, . . . , Yn is a feasible solution of (6) and W1, . . . , Wn ∈ Ud the output of the (random) rounding procedure described in Algorithm 3. Then  n(cid:88) E n(cid:88) tr(cid:0)CH ij WiW H j (cid:1) ≥ αC(d)2 n(cid:88) n(cid:88) tr(cid:0)CT ijYiY H j (cid:1) , i=1 j=1 i=1 j=1 where αC(d) is the constant in Definition 2. E(cid:104)(cid:80)n In Section 6 we show that these ratios are optimal (Theorem 14). Before proving Theorem 4 we present a sketch of the proof for the case d = 1 (and real). The argument is known as the Rietz method (See [AN04]) 2: i = 1. Let R ∈ Let X1, . . . , Xn ∈ R1×n be a feasible solution to (5), meaning that XiX T Rn×1 be a random matrix with i.i.d. standard Gaussian entries. Our objective is to compare j . The main observation is that although j , the expectation E [sign(XiR)XjR] is. E [sign(XiR)sign(XjR)] is not a linear function of XiX T In fact E [sign(XiR)XjR] = αR(1)XiX T j — which follows readily by thinking of Xi and Xj as vectors in the two dimensional plane that they span. We use this fact (together with the positiveness of C) to show our result. The idea is to build the matrix S (cid:23) 0, with (cid:80)n i,j Cijsign(XiR)sign(XjR) i,j CijXiX T (cid:113) 2 π XiX T j = (cid:105) Sij = XiR − sign(XiR) XjR − sign(XjR) . (cid:19)(cid:18) (cid:114) π 2 (cid:19) Since both C and S are PSD, tr(CS) ≥ 0, which means that 0 ≤ E Cij(XiR − sign(XiR))(XjR −  . sign(XjR)) (cid:114) π 2 (cid:114) π 2 (cid:114) π 2 (cid:18) (cid:88) n(cid:88) ij E i,j Combining this with the observation above and the fact that E [XiRXjR] = XiX T j , we have Cijsign(XiR)sign(XjR) ≥ 2 π CijXiX T j . n(cid:88) i,j Proof. [of Theorem 4] For the sake of brevity we restrict the presentation of the proof to the real case. Nevertheless, it is easy to see that all the arguments trivially adapt to the complex case by, essentially, replacing all transposes with Hermitian adjoints and αR(d) with αC(d). 2These ideas also play a major role in the unidimensional complex case treated by So et al [SZY07]. 9 Let R ∈ Rnd×d be a Gaussian random matrix with i.i.d entries N(cid:0)0, 1 (cid:1). We want to provide a lower bound for  n(cid:88) E n(cid:88) tr(cid:0)CT ijViV T j (cid:1) = E  n(cid:88) n(cid:88) d ijP(UiR)P(UjR)T(cid:1) . tr(cid:0)CT i=1 j=1 i=1 j=1 Similarly to the d = 1 case, one of the main ingredients of the proof is the fact given by the lemma below. Lemma 5 Let r ≥ d. Let M, N ∈ Rd×nd such that M M T = N N T = Id×d. Let R ∈ Rnd×d be a Gaussian random matrix with real valued i.i.d entries N(cid:0)0, 1 (cid:1). Then Gaussian random matrix with complex valued i.i.d entries N(cid:0)0, 1 E(cid:2)P(M R)(N R)T(cid:3) = E(cid:2)(M R)P(N R)T(cid:3) = αR(d)M N T , (cid:1), then E(cid:2)P(M R)(N R)H(cid:3) = E(cid:2)(M R)P(N R)H(cid:3) = αC(d)M N H , where αR(d) is constant in Definition 2. d d Analogously, if M, N ∈ Cd×nd such that M M H = N N H = Id×d, and R ∈ Cnd×r is a where αC(d) is constant in Definition 2. given by We have ESij = Before proving Lemma 5 we use it to finish the proof of Theorem 4. Just as above, we define the positive semidefinite matrix S ∈ Rdn×dn whose (i, j)-th block is Sij =(cid:0)UiR − αR(d)−1P(UiR)(cid:1)(cid:0)UjR − αR(d)−1P(UjR)(cid:1)T = E(cid:2)UiR(UjR)T − αR(d)−1P(UiR)(UjR)T − αR(d)−1UiRP(UjR)T + αR(d)−2P(UiR)P(UjR)T(cid:3) j − αR(d)−1E(cid:2)P(UiR)(UjR)T(cid:3) − αR(d)−1E(cid:2)UiRP(UjR)T(cid:3) + αR(d)−2E(cid:2)ViV T = UiE(cid:2)RRT(cid:3) U T (cid:3) j + αR(d)−2E(cid:2)ViV T (cid:3) − UiU T = αR(d)−2E(cid:2)ViV T j − UiU T j − UiU T = UiU T (cid:3) . j j j . j By construction S (cid:23) 0. Since C (cid:23) 0, tr(CS) ≥ 0, which means that 0 ≤ E [tr (CS)] = tr (CE[S]) = Thus,  n(cid:88) n(cid:88) i=1 j=1 E tr(cid:0)CT ijViV T j ij n(cid:88) n(cid:88) tr(cid:0)CT (cid:1) ≥ αR(d)2 j=1 i=1 (cid:0)αR(d)−2E(cid:2)ViV T n(cid:88) n(cid:88) tr(cid:0)CT j j (cid:3) − UiU T (cid:1) . ijUiU T j (cid:1)(cid:1) . i=1 j=1 (cid:3) We now present and prove an auxiliary lemma, needed for the proof of Lemma 5. 10 and let αR(d) as defined in Definition 2. Then, Lemma 6 Let G be a d × d Gaussian random matrix with real valued i.i.d. N(cid:0)0, 1 Furthermore, if G is a d× d Gaussian random matrix with complex valued i.i.d. N(cid:0)0, 1 E(cid:0)P(G)GT(cid:1) = E(cid:0)GP(G)T(cid:1) = αR(d)Id×d. E(cid:0)P(G)GH(cid:1) = E(cid:0)GP(G)H(cid:1) = αC(d)Id×d. and αC(d) the analogous constant (Definition 2), then d (cid:1) entries (cid:1) entries d Proof. We restrict the presentation to the real case. All the arguments are equivalent to the complex case, replacing all transposes with Hermitian adjoints and αR(d) with αC(d). Let G = U ΣV T be the singular value decomposition of G. Since GGT = U Σ2U T is a Wishart matrix, it is well known that its eigenvalues and eigenvectors are independent and U is distributed according to the Haar measure in Od (see e.g. Lemma 2.6 in [TV04]). To resolve ambiguities, we consider Σ ordered such that Σ11 ≥ Σ22 ≥ ... ≥ Σdd. Let Y = P(G)GT . Since P(G) = P(U ΣV T ) = U Id×dV T , we have Y = P(U ΣV T )(U ΣV T )T = U Id×dV T V ΣU T = U ΣU T . Note that GP(G)T = U ΣU T = Y . Denoting u1, . . . , ud the rows of U , since U is distributed according to the Haar measure, we have that uj and −uj have the same distribution conditioned on Σ and ui, for any i (cid:54)= j. This implies that if i (cid:54)= j, Yij = uiΣuT is a symmetric random variable, and so EYij = 0. Also, ui ∼ uj implies that Yii ∼ Yjj. This means that EY = cId×d for some constant c. To obtain c, j n(cid:88) k=1 c = c 1 d tr(Id×d) = E tr(Y ) = 1 d 1 d E tr(U ΣU T ) = E 1 d σk(G) = αR(d), which shows the lemma. (cid:3) Proof. [of Lemma 5] We restrict the presentation of proof to the real case. Nevertheless, as before, all the arguments trivially adapt to the complex case by, essentially, replacing all transposes with Hermitian adjoints and αR(d) with αC(d). an orthogonal matrix and B ∈ Rnd×2d upper triangular with non-negative diagonal entries; note that only the first 2d rows of B are nonzero. We can write Let A =(cid:2)M T N T(cid:3) ∈ Rdn×2d and A = QB be the QR decomposition of A with Q ∈ Rnd×nd  B11 B12 0d B22 0d 0d ... ... 0d 0d  ∈ Rdn×2d, QT A = B = where B11 ∈ Rd×d and B22 ∈ Rd×d are upper triangular matrices with non-negative diagonal entries. Since (QT M T )T 11(QT M T )11 = (QT M T )T (QT M T ) = M QQT M T = M Ind×ndM T = M M T = Id×d, 11 Since M Q = [BT B11 = (QT M T )11 is an orthogonal matrix, which together with the non-negativity of the diagonal entries (and the fact that B11 is upper-triangular) forces B11 to be B11 = Id×d. 11, 0d×d,··· , 0d×d] = [Id×d, 0d×d,··· , 0d×d] and N Q = [BT Since R is a Gaussian matrix and Q is an orthogonal matrix, QR ∼ R which implies E(cid:2)P(M R)(N R)T(cid:3) = E(cid:2)P(M QR)(N QR)T(cid:3) . 22R2)T(cid:3) , E(cid:2)P(M R)(N R)T(cid:3) = E(cid:2)P(R1)(BT (cid:3) B12. The Lemma now follows from using Lemma 6 to obtain E(cid:2)P(R1)RT (cid:3) = αR(d)Id×d and noting The same argument, with Q(cid:48)B(cid:48) the QR decomposition of A(cid:48) =(cid:2)N T M T(cid:3) ∈ Rdn×2d instead, where R1 and R2 are the first two d × d blocks of R. Since these blocks are independent, the second term vanishes and we have E(cid:2)P(M R)(N R)T(cid:3) = E(cid:2)P(R1)RT that B12 = (QT M T )T (QT N T ) = M N T . 12, BT 22, 0d×d,··· , 0d×d], 12R1 + BT 1 1 E(cid:2)(M R)P(N R)T(cid:3) = E(cid:2)R1P(R1)T(cid:3) M N T = αR(d)M N T . shows (cid:3) 4 The approximation ratios αR(d)2 and αC(d)2 The approximation ratio we obtain (Theorem 1) for Algorithm 3 is given, in the orthogonal case, by αR(d)2 and, in the unitary case, by αC(d)2. αR(d) and αC(d) are defined as the average singular value of a d × d Gaussian matrix G with, respectively real and complex valued, i.i.d N (0, 1 d ) entries. These singular values correspond to the square root of the eigenvalues of a Wishart matrix W = GGT , which are well-studied objects (see, e.g., [She01] or [CD11]). For d = 1, this corresponds to the expected value of the absolute value of standard Gaussian (real or complex) random variable. Hence, (cid:114) 2 π (cid:114) π , 4 αR(1) = and αC(1) = meaning that, for d = 1, we recover the approximation ratio of 2 real case, and the approximation ratio of π π , of Nesterov [Nes98] for the For any d ≥ 1, the marginal distribution of an eigenvalue of the Wishart matrix W = GGT the marginal distribution for is known [LV11, CD11, Lev12] (see Section B). Denoting by p(K) K = R and K = C, we have 4 of So et al. [SZY07] in the complex case. d In the complex valued case, p(C) Lev12] and αC(d) is given by αK(d) = 1 d1/2 0 x1/2p(K) d (x)dx. (15) d (x) can be written in terms of Laguerre polynomials [CD11, (cid:90) ∞ (cid:90) ∞ d−1(cid:88) n=0 0 12 αC(d) = d−3/2 x1/2e−xLn(x)2dx, (16) Where Ln(x) is the nth Laguerre polynomial. In Section B we give a lower bound to (16). The real case is more involved [LV11], nevertheless we are able to provide a lower bound for αR(d) as well. Theorem 7 Consider αR(d) and αC(d) as defined in (2). The following holds, αC(d) ≥ 8 3π − 5.05 d and αR(d) ≥ 8 3π − 9.07 d . Proof. These bounds are a direct consequence of Lemmas 20 and 21. One can easily evaluate limd→∞ αK(d) (without using Theorem 7) by noting that the distri- bution of the eigenvalues of the Wishart matrix we are interested in, as d → ∞, converges in probability to the Marchenko-Pastur distribution [She01] with density (cid:112)x(4 − x)1[0,4], (cid:112)x(4 − x)dx = 1 2πx 8 3π . mp(x) = 1 2πx √ x (cid:90) 4 0 for both K = R and K = C. This immediately gives, d→∞ αK(d) = lim We note that one could also obtain lower bounds for α2K(d) from results on the rate of convergence to mp(x) [GT11]. However this approach seems to not provide bounds with explicit constants and to not be as sharp as the approach taken in Theorem 7. Figure 1: Plot showing the computed values of αK(d)2, for d ≤ 44, the limit of αK(d)2 as d → ∞, the lower bound for αK(d)2 given by Theorem 7 as function of d, and the approximation ratio of and 1 2 obtained in [NRV13]. √ 1 2 2 13 For any d, the exact value of αK(d) can be computed, by (15), using Mathematica (See table below). Figure 1 plots these values for d = 1, . . . , 44. We also plot the bounds for the real and complex case obtained in Theorem 7, and the approximation ratios obtained in [NRV13], for comparison. (cid:113) 2 αR(d) π √ π √ 2−1 2 √ 4 √ 2+3π 2 3π 6 8 3π d 1 2 3 ∞ αC(d) αR(d) ≈ αR(d)2 ≈ αC(d) ≈ αC(d)2 ≈ √ π √ π 0.7854 2 √ π 0.8862 0.6366 0.8617 0.6564 0.7979 0.8102 0.7424 11 2 16 3 0.8188 0.8488 0.6704 0.7205 0.8554 0.8488 0.7312 0.7205 107 128 8 3π The following conjecture is suggested by our analysis and numerical computations. i.i.d., respectively real valued and complex valued, N(cid:0)0, 1 Conjecture 8 Let αR(d) and αC(d) be the average singular value of a d× d matrix with random all d ≥ 1, (cid:1) entries (see Definition 2). Then, for d αC(d + 1) ≤ αC(d) and αR(d + 1) ≥ αR(d), 5 The little Grothendieck problem over the Stiefel manifold In this section we focus on a generalization of (3), the little Grothendieck problem over the Stiefel manifold O(d,r), the set of matrices O ∈ Rd×r such that OOT = Id×d. In this exposition we will restrict ourselves to the real valued case but it is easy to see that the ideas in this Section easily adapt to the complex valued case. We consider the problem max O1,...,On∈O(d,r) n(cid:88) n(cid:88) tr(cid:0)CT i=1 j=1 ijOiOT j (cid:1) , (17) for C (cid:23) 0. The special case d = 1 was formulated and studied in [BBT11] and [BFV10] in the context of quantum non-locality and quantum XOR games. Note that, for r = d, problem (17) reduces to (3) and, for r = nd, it reduces to the tractable relaxation (5). As a solution to (3) can be transformed, via zero padding, into a solution to (17) with the same objective function value, Algorithm 3 automatically provides an approximation ratio for (17), however we want to understand how this approximation ratio can be improved using the extra freedom (in particular, in the case r = nd, the approximation ratio is trivially 1). Below we show an adaptation of Algorithm 3, based on the same relaxation (5), for problem (17) and show an improved approximation ratio. Algorithm 9 Compute X1, . . . , Xn ∈ Rd×nd a solution to (5). Let R be a nd × r Gaussian random matrix whose entries are real i.i.d. N (0, 1 r ). The approximate solution for (17) is now computed as Vi = P(d,r)(XiR), where P(d,r)(X) = argminZ∈O(d,r) component to the Stiefel manifold O(d,r). (cid:107)Z − X(cid:107)F , for any X ∈ Rd×r, is a generalization of the polar 14 Below we show an approximation ratio for Algorithm 9. Theorem 10 Let C (cid:23) 0. Let V1, . . . , Vn ∈ O(d,r) be the (random) output of Algorithm 9. Then, tr(cid:0)CT ijViV T j (cid:1) ≥ αR(d, r)2 n(cid:88) n(cid:88) tr(cid:0)CT i=1 j=1 ijOiOT j (cid:1) , max O1,...,On∈O(d,r) where αR(d, r) is the defined below (Definition 11). Definition 11 Let r ≥ d and G ∈ Rd×r be a Gaussian random matrix with i.i.d real entries n(cid:88) j=1 E  n(cid:88) (cid:1). We define i=1 N(cid:0)0, 1 r  1 d d(cid:88) j=1  , αR(d, r) := E σj(G) where σj(G) is the jth singular value of G. We investigate the limiting behavior of αR(d, r) as r → ∞ and as r, d → ∞ at a proporitional rate in Section 6.2. For the sake of brevity we omit the proof of this Theorem. We do state and prove Lemmas 17 and 18 on the Appendix, which are the analogous, to this setting, of Lemmas 6 and 5. It is then not difficult to see that the arguments in the proof of Theorem 4 trivially adapt to this case and that the proof of Theorem 10 is completely analogous to the one of Theorem 1. Besides the applications, for d = 1, described in [BBT11] and [BFV10], Problem (17) is also motivated by an application in molecule imaging, the common lines problem. 5.1 The common lines problem The common lines problem arises in three-dimensional structure determination of biological molecules using Cryo-Electron Microscopy [SS11], and can be formulated as follows. Consider n rotation matrices O1, . . . , On ∈ SO3. The three columns of each rotation matrix form a orthonormal basis to R3. In particular, the first two columns of each rotation matrix span a two-dimensional subspace (a plane) in R3. We assume that no two planes are parallel. Every pair of planes intersect at a line, called the common-line of intersection. Let bij ∈ R3 be a unit vector that points in the direction of the common-line between the planes corresponding to Oi and Oj. Hence, there exist unit vectors cij and cji with vanishing third component (i.e., cij = (xij, yij, 0)T ) such that Oicij = Ojcji = bij. The common lines problem consists of estimating the rotation matrices O1, . . . , On from (perhaps noisy) measurements of the unit vectors cij and cji. The least-squares formulation of this problem is equivalent to max O1,...,On∈SO3 tr(cjicT ijOT i Oj) (18) However, since cij has zero in the third coordinate, the common-line equations Oicij = Ojcji do not involve the third columns of the rotation matrices. The optimization problem (18) is therefore equivalent to max OT 1 ,..., OT n ∈O(2,3) tr(Π(cji)Π(cij)T OT i Oj), (19) n(cid:88) i,j=1 n(cid:88) i,j=1 15 where Π : R3 → R2 is a projection discarding the third component (i.e., Π(x, y, z) = (x, y)) and i ∈ O(2,3). The coefficient matrix in (19), Cij = Π(cij)Π(cji)T , is not positive semidefinite. OT However, one can add a diagonal matrix with large enough values to it in order to make it PSD. Although this does not affect the solution of (19) it does increase its function value by a constant, meaning that the approximation ratio obtained in Theorem 10 does not directly translate into an approximation ratio for Problem (19); see Section 7 for a discussion on extending the results to the non positive semidefinite case. 5.2 The approximation ratio αR(d, r)2 In this Section we attempt to understand the behavior of αR(d, r)2, the approximation ratio obtained for Algorithm 9. Recall that αR(d, r) is defined as the average singular value of G ∈ For d = 1 this simply corresponds to the average length of a Gaussian vector in Rr with i.i.d. (cid:1). This means that αR(1, r) is the mean of a normalized chi-distribution, Rd×r, a Gaussian random matrix with i.i.d. entries N(cid:0)0, 1 entries N(cid:0)0, 1 Γ(cid:0) r+1 (cid:1) Γ(cid:0) r (cid:1) . (cid:114) 2 αR(1, r) = (cid:1). r 2 r r 2 In fact, this corresponds to the results of Briet el al [BFV10], which are known to be sharp [BFV10]. to provide a lower bound for it by a function approaching 1 as r → ∞. For d > 1 we do not completely understand the behavior of αR(d, r), nevertheless it is easy Proposition 12 Consider αR(d, r) as in Definition 11. Then, αR(d, r) ≥ 1 − . (20) (cid:114) (cid:114) d r Esmin(G) ≥ 1 − d r , Proof. Gordon’s theorem for Gaussian matrices (see Theorem 5.32 in [Ver12]) gives us bound holds [BFV10]. As we are bounding αR(d, r) by the expected value of the smallest singular value of a Gaussian where smin(G) is the smallest singular value. The bound follows immediately from noting that the average singular value is larger than the expected value of the smallest singular value. (cid:1) matrix, we do not expect (20) to be tight. In fact, for d = 1, the stronger αR(1, r) ≥ 1 − O(cid:0) 1 (cid:0) 1 r , r(cid:1). Let us set r = ρd, for ρ ≥ 1. The distribution (cid:16) 1 Similarly to αR(d), we can describe the behavior of αR(d, r) in the limit as d → ∞ and d → ρ. More precisely, the singular values of G correspond to the square root of the eigenvalues of the Wishart matrix [CD11] GGT ∼ Wd , as d → ∞ are known to converge to the of the eigenvalues of a Wishart matrix Wd Marchenko Pastur distribution (see [CD11]) given by ρd , d (cid:17) r r (cid:113) ((1 + dν(x) = 1 2π where λ = 1 ρ . √ λ)2 − x)(x − (1 − √ λ)2) λx 16 1[(1−√ √ λ)2,(1+ λ)2]dx, Hence, we can define φ(ρ) as φ(ρ) := lim d→∞ αR(d, ρd) = (cid:90) (cid:16) (cid:17)2 (cid:113) 1 (cid:17)2 (cid:16) 1−(cid:113) 1 1+ ρ ρ (cid:114) ( (cid:16) 1 + (cid:113) 1 ρ (cid:17)2 − x)(x −(cid:16) 1 −(cid:113) 1 ρ (cid:17)2 ) 1 ρ x dx. √ x 1 2π Although we do not provide a closed form solution for φ(ρ) the integral can be easily computed numerically and we plot it below. It shows how the approximation ratio improves as ρ increases. Figure 2: Plot of φ(ρ) = limd→∞ αR(d, ρd) for ρ ∈ [1, 5]. 6 Integrality Gap In this section we provide an integrality gap for relaxation (5) that matches our approximation ratio αR(d)2. For the sake of the exposition we will restrict ourselves to the real case, but it is not difficult to see that all the arguments can be adapted to the complex case. Our construction is an adaption of the classical construction for the d = 1 case (see, e.g., [AN04]). As it will become clear below, there is an extra difficulty in the d > 1 orthogonal case. In fact, the bound on the integrality gap of (5) given by this construction is α∗ R(d)2, defined as d(cid:88) where G is a Gaussian matrix with i.i.d. real entries N(cid:0)0, 1 max F =d, D(cid:23)0 α∗ R(d) = E 1 d D diagonal (cid:107)D(cid:107)2 (cid:1). d σi(GD), i=1 (21) Fortunately, using the notion of operator concavity of a function and the Lowner-Heinz Theorem [Car09], we are able to show the following Theorem. Theorem 13 Let d ≥ 1. Also, let αR(d) be as defined in Definition 2 and α∗ in (21). Then, R(d) as defined α∗ R(d) = αR(d). 17 E(cid:88) σi(GD) = E(cid:88) σi(G), Proof. We want to show that max D diagonal (cid:107)D(cid:107)2 F =d D(cid:23)0 i=1 where G is a d× d matrix with i.i.d. entries N(cid:0)0, 1 (cid:20)(cid:0)GV GT(cid:1) 1 (cid:21) Claim 6.1 E tr max d 2 V diagonal tr(V )=d V (cid:23)0 nition of singular value, we obtain the following claim (which immediately implies Theorem 13) i=1 (cid:1). By taking V = D2, and recalling the defi- (cid:20)(cid:0)GGT(cid:1) 1 2 (cid:21) . = E tr Proof. We will proceed by contradiction, suppose (6.1) does not hold. Since the optimization space is compact and the function continuous it must have a maximum that is attained by a certain V (cid:54)= Id×d. Out of all maximizers V , let V (∗) be the one with smallest possible Frobenius norm. The idea will be to use concavity arguments to build an optimal V (card) with smaller Frobenius norm, arriving at a contradiction and hence showing the theorem. Since V (∗) is optimal we have (cid:20)(cid:16) GV (∗)GT(cid:17) 1 2 (cid:21) E tr = α∗ R(d). Furthermore, since V (∗) (cid:54)= Id×d, it must have two different diagonal elements. Let V (∗∗) be in V (∗), two of its non-equal diagonal elements. Clearly, a matrix obtained by swapping, (cid:107)V (∗∗)(cid:107)F = (cid:107)V (∗)(cid:107)F and, because of the rotation invariance of the Gaussian, it is easy to see that (cid:20)(cid:16) GV (∗∗)GT(cid:17) 1 2 (cid:21) E tr = α∗ R(d). Since V (∗) (cid:23) 0, these two matrices are not multiples of each other and so V (card) = V (∗) + V (∗∗) 2 , has a strictly smaller Frobenius norm than V (∗). It is also clear that V (card) is a feasible solution. We conclude the proof by showing (cid:21) 2 (cid:20)(cid:16) GV (card)GT(cid:17) 1 (cid:32) 2 E tr tr E GV (∗)GT + GV (∗∗)GT (cid:18) ≥ 1 2 E tr (cid:21) 2 (cid:20)(cid:16) GV (∗)GT(cid:17) 1  − 1 (cid:20)(cid:16) (cid:18) tr 2 (cid:33) 1 2 + E tr GV (∗)GT(cid:17) 1 2 (cid:21)(cid:19) (cid:20)(cid:16) 2 GV (∗∗)GT(cid:17) 1 (cid:20)(cid:16) (cid:21) + tr By linearity of expectation and construction of V (card), (22) is equivalent to = α∗ R(d). (22) GV (∗∗)GT(cid:17) 1 2 (cid:21)(cid:19) ≥ 0. 18 This inequality follows from the stronger statement: Given two d× d matrices A (cid:23) 0 and B (cid:23) 0, the following holds 2 − A 1 2 + B 1 2 2 (cid:23) 0. (23) (cid:18) A + B (cid:19) 1 2 Finally, (23) follows from the Lowner-Heinz Theorem, which states that the square root func- tion is operator concave (See these lecture notes [Car09] for a very nice introduction to these inequalities). Theorem 13 guarantees the optimality of the approximation ratio obtained in Section 3. In fact, we show the theorem below. Theorem 14 For any d ≥ 1 and any ε > 0, there exists n for which there exists C ∈ Rdn×dn such that C (cid:23) 0, and n(cid:88) n(cid:88) tr(cid:0)CT n(cid:88) n(cid:88) tr(cid:0)CT j=1 i=1 i=1 j=1 ijOiOT j ijXiX T j (cid:1) (cid:1) ≤ αR(d)2 + ε. max O1,...,On∈Od max i =Id×d XiX T Xi∈Rd×dn (24) n2 ViV T n(cid:88) n(cid:88) wr = max i =Id×d XiX T Xi∈Rd×dn tr(cid:0)CT We will construct C randomly and show that it satisfies (24) with positive probability. Given p an integer we consider n i.i.d. matrix random variables Vk, with k = 1, . . . , n, where each Vk is a d× dp Gaussian matrix whose entries are N (0, 1 dp ). We then define C as the random matrix with d × d blocks Cij = 1 j . The idea now is to understand the typical behavior of both (cid:1) and wc = max n(cid:88) n(cid:88) (cid:13)(cid:13)(cid:13)(cid:13)(cid:13) 1 (cid:13)(cid:13)(cid:13)(cid:13)(cid:13)2 n(cid:88) i=1 tr(cid:0)P(ViDT )T ViDT(cid:1). i ViDT(cid:1) =(cid:80)n i=1 tr(cid:0)P(ViDT )T ViDT(cid:1) The idea is that, given a fixed (direction unit frobenius-norm matrix) D,(cid:80)n (cid:88) tr(cid:0)(ViV T (cid:1) = max i=1 tr(cid:0)maxOi∈Od OT wc =(cid:80)n tr(cid:0)CT For wc, we can rewrite O1,...,On∈Od O1,...,On∈Od i=1 OT i=1 OT i Vi i Vi(cid:107)F O1,...,On∈Od wc = max (cid:80)n (cid:80)n j )T OiOT j If D = 1 n2 √ ijXiX T j ijOiOT j (cid:1) . n i=1 1 n (cid:107) 1 n OT i Vi . F i=1 j=1 i=1 j=1 then i,j converges to the expected value of one of the summands and, by an -net argument (since the dimension of the space where D is depends only on d and p and the number of summands is n which can be made much larger than d and p) we can argue that the sum is close, for all D’s simultaneously, to that expectation. It is not hard to see that we can assume that D = 1√ [D 0] where D is diagonal and non-negative d × d matrix with (cid:107)D(cid:107)2 F = d. In that case (see (21)), d (cid:115) E tr(cid:0)P(ViDT )T ViDT(cid:1) = E 1√ d(cid:88) where G is a Gaussian matrix with i.i.d. real entries N(cid:0)0, 1 gives E tr(cid:0)P(ViDT )T ViDT(cid:1) ≤(cid:113) d k=1 pd d σk(GD) ≤ α∗ R(d), d p (cid:1). This, together with Theorem 13, p αR(d). All of this is made precise in the following lemma 19 Lemma 15 For any d and ε > 0 there exists p0 and n0 such that, for any p > p0 and n > n0, (cid:13)(cid:13)(cid:13)(cid:13)(cid:13) 1 n n(cid:88) i=1 max O1,...,On∈Od OT i Vi ≤ d p αR(d)2 + ε, F (cid:13)(cid:13)(cid:13)(cid:13)(cid:13)2 (cid:13)(cid:13)(cid:13)(cid:13)(cid:13) 1 with probability strictly larger than 1/2. Proof. Let us define A(V ) := max O1,...,On∈Od We have A(V ) = max D∈Rd×pd:(cid:107)D(cid:107)F =1 = = max D∈Rd×pd:(cid:107)D(cid:107)F =1 max D∈Rd×pd:(cid:107)D(cid:107)F =1 1 n 1 n For D with (cid:107)D(cid:107)F = 1, we define AD(V ) = n(cid:88) i=1 1 n tr (cid:33) i ViDT O1,...,On∈O(d) . n tr i=1 1 n OT OT i Vi max n(cid:88) (cid:13)(cid:13)(cid:13)(cid:13)(cid:13)F (cid:32) n(cid:88) i ViDT(cid:1) tr(cid:0)OT ViDT(cid:17) (cid:16)P(cid:0)ViDT(cid:1)T ViDT(cid:17) n(cid:88) n(cid:88) (cid:16)P(cid:0)ViDT(cid:1)T max Oi∈O(d) i=1 i=1 i=1 tr . . Let D = UL[Σ 0]U T We proceed by understanding the behavior of AD(V ) for a specific D. R , where Σ is a d × d non-negative diagonal matrix, be the singular value decomposition of D. For each i = 1, . . . , n, we have (using rotation invariance of the Gaussian distribution): (cid:16)P(cid:0)ViDT(cid:1)T ViDT(cid:17) ∼ tr tr ∼ tr ∼ tr 1√ ∼ dp 0 0 L Vi(UL[Σ 0]UR)T(cid:17) (cid:16)P(cid:0)Vi(UL[Σ 0]UR)T(cid:1)T (cid:17) (cid:16) (cid:2)Σ (cid:2)Σ (cid:3)(cid:1)T Vi (cid:3) U T ULP(cid:0)Vi (cid:3)(cid:17) (cid:16)P(cid:0)Vi (cid:2)Σ (cid:2)Σ (cid:3)(cid:1)T Vi (cid:19) (cid:18) (cid:17)T P(cid:16) n(cid:88) d ) entries. √ G √ G dΣ dΣ tr 0 0 , where G is a d × d Gaussian matrix with N (0, 1 This means that with Xi i.i.d. distributed as 1√ dp tr (cid:18) P(cid:16) AD(V ) = √ G dΣ Xi, (cid:19) dΣ . i=1 √ G 1 n (cid:17)T 20 Since (cid:107)√ dΣ(cid:107)2 F = d, by (21), we get (cid:18) P(cid:16) √ G E tr (cid:19) dΣ √ ≤ dα∗ R(d). This, together with Theorem 13, gives dΣ G (cid:17)T (cid:115) EXi ≤ αR(d). d p (cid:80)n (25) (cid:115) (cid:115) d p In order to give tail bounds for AD(V ) = 1 n i=1 Xi we will show that Xi is subgaussian tr (cid:19) (cid:17)T Note that √ G dΣ √ G dΣ ≤ 1√ p (cid:107)G(cid:107)F . d p (cid:107)GD(cid:107)F ≤ Xi ∼ 1√ dp (cid:107)P (GΣ)(cid:107)F(cid:107)GΣ(cid:107)F = and use Hoeffding’s inequality (see Vershynin’s notes [Ver12]). In fact, (cid:18) P(cid:16) (cid:113) d p(cid:107)G(cid:107)F is a subgaussian random variable as (cid:107)G(cid:107)F is smaller than the entry wise (cid:96)1 norm of G which is the sum of d2 half-normals (more specifically, the absolute value of a N (0, 1 d ) random variable). Since half-normals are subgaussian and the sum of subgaussian random variables is a subgaussian random variable with subgaussian norm at most the sum (cid:113) d2 of the norms (see the Rotation invariance Lemma in [Ver12]) we get that Xi is subgaussian. Furthermore, the subgaussian norm of Xi, which we define as (cid:107)Xi(cid:107)ψ2 = supp≥1 p−1/2(EXp)1/p, is bounded by (cid:107)Xi(cid:107)ψ2 ≤ C (cid:35) Hence, we can use Hoeffding’s inequality (see [Ver12]) and get, since EXi ≤(cid:113) d (cid:34) (cid:18) p , for some universal constant C. p = C d√ p αR(d), (cid:115) (cid:32) (cid:33) Prob AD ≥ αR(d) + t ≤ Prob [AD − EXi ≥ t] ≤ exp 1 − c2t2n (cid:107)Xi(cid:107)2 ψ2 ≤ 3 exp −c1 t2p d2 n d p (cid:19) , where ci are universal constants. To find an upper bound for A = maxD∈Rd×pd:(cid:107)D(cid:107)F =1 AD we use a classicl -net argument. There exists a set N of matrices Dk ∈ Rd×pd satisfying (cid:107)Dk(cid:107)F = 1, such that for any D ∈ Rd×pd with Frobenius norm 1, there exists an element Dk ∈ N such that D − DkF ≤ . N is called an -net, and it’s known (see [Ver12]) that there exists such a set with size By the union-bound, with probability at least 1 − N Prob AD ≥ αR(d) + t ≥ 1 − 1 + (cid:34) (cid:115) d p (cid:19)d2p 2  3 exp (cid:18) −c1 t2n d3 (cid:19)(cid:35) , all the Dk’s in N satisfy ADk ≤ N ≤ 1 + 2  . (cid:19)d2p (cid:34)(cid:18) (cid:18) (cid:35) (cid:115) α∗ R(d) + t. d p 21 If D is not in N , there exists Dk ∈ N such that (cid:107)D − Dk(cid:107)F ≤ . This means that AD ≤ 1 n ≤ 1 n n(cid:88) n(cid:88) (cid:115) i=1 i=1 d p (cid:16)P(cid:0)ViDT(cid:1)T (cid:16)P(cid:0)ViDT∗(cid:1)T (cid:32) tr tr (cid:17) (cid:17) ViDT∗ + ViDT∗ + 1 n n(cid:88) n(cid:88) (cid:33) i=1 i=1 1 n (cid:16)P(cid:0)ViDT(cid:1)T (cid:107)P(cid:0)ViDT(cid:1)T tr (cid:17) Vi(DT∗ − DT ) Vi(cid:107)F(cid:107)D∗ − D(cid:107)F (cid:107)Vi(cid:107)F n(cid:88) (cid:1) by Hoeffding’s inequality as well (see [Ver12]). Using i=1 . √ ≤ α∗ R(d) + t +  We can globally bound(cid:0) 1 1 (cid:80)n n i=1 (cid:107)Vi(cid:107)F the same argument as above, it is easy to see that (cid:107)Vi(cid:107)F has subgaussian norm bounded by and an explicit computation shows its mean is follows from lemma 20. d, d, where the inequality √ 2 Γ((d2p+1)/2) 1√ dp √ n This means that by Hoeffding’s inequality (see [Ver12]) (cid:34) n(cid:88) i=1 1 n Prob √ (cid:107)Vi(cid:107)F ≥ 2 d + t (cid:35) (cid:33) Γ(d2p/2) ≤ 2 (cid:32) (cid:18) 1 − c4t2n (cid:107)(cid:107)Vi(cid:107)F(cid:107)2 t2n d −c3 (cid:19) , ψ2 ≤ exp ≤ 3 exp (cid:19) (cid:115) d p with ci universal constants. By union-bound on the two events above, with probability at least (cid:18) (cid:34)(cid:18) (cid:19)d2p (cid:18) 1 − 3 exp −c3 t2n d − 1 + 2  3 exp −c1 t2n d3 (cid:19)(cid:35) , we have A ≤ α∗ R(d) + t + (2d + t). Choosing t = 1 2p and  = 1 6dp we get A ≤ (cid:115) α∗ R(d) + d p 1 p , with probability at least (cid:18) −c3 n 4p2 (cid:19) − (cid:20) (cid:18) 1 − 3 exp (cid:20) (1 + 12dp)d2p 3 exp (cid:19)(cid:21) = 1 − 6 (1 + 12dp)d2p 3 exp −c1 n 4p2d3 (cid:19)(cid:21) (cid:18) −c1 n 4p2d3 which can be made arbitrarily close to 1 by taking n large enough. 22 This means that max O1,...,On∈Od n(cid:88) (cid:13)(cid:13)(cid:13)(cid:13)(cid:13) 1 (cid:13)(cid:13)(cid:13)(cid:13)(cid:13)2 OT i Vi ≤ d p αR(d)2 + 1 p , with high probability, proving the lemma. F n i=1 (cid:16) (ViV T i ≈ Id×d we essentially have wr (cid:38) 1 (cid:80)n (cid:17) (cid:80)n j )T XiX T j j (cid:107)2 i,j (cid:107)ViV T i,j tr (cid:3) for Xi = F which Regarding wr, we know that it is at least the value of 1 n2 P(Vi). Since, for p large enough, ViV T should approximate E(cid:107)ViV T Lemma 16 For any d and ε > 0 there exists p0 and n0 such that, for any p > p0 and n > n0, p . This is made precise in the following lemma: F ≈ d n2 j (cid:107)2 n(cid:88) i,j 1 n2 tr(cid:0)(ViV T j )TP(d,dp)(Vi)P(d,dp)(Vj)T(cid:1) ≥ d − ε, p with probability strictly larger than 1/2. Proof. Recall that P(d,dp)(Vi) is the d × dp matrix polar component of Vi, meaning that d(cid:88) (cid:1) = tr(cid:0)P(d,dp)(Vi)T Vi (cid:13)(cid:13)(cid:13)(cid:13)(cid:13) 1 j )TP(d,dp)(Vi)P(d,dp)(Vj)T(cid:1) = k=1 n n(cid:88) i=1 σk(Vi). Hence, 1 n2 n(cid:88) i,j tr(cid:0)(ViV T (cid:13)(cid:13)(cid:13)(cid:13)(cid:13)2 n(cid:88) tr(cid:0)P(Vi)T ViIdp×dp (cid:35)2 i=1 F (cid:1)(cid:35)2 P(Vi)T Vi (cid:34) d(cid:88) 1 n σk(Vi) . i=1 k=1 ≥ = (cid:107)Idp×dp(cid:107)2 F n(cid:88) 1 (cid:34) 1 n 1 dp We proceed by using a lower bound for the expected value of the smallest eigenvalue E σk(Vi) ≥ d Eσmin(Vi) = d 1 − 1√ p (cid:18) (cid:19) . d(cid:88) k=1 (see [Ver12]), and get Since(cid:80)d k=1 σk(Vi) ≤ √ (cid:34) d(cid:88) n(cid:88) (cid:18) (cid:19) (cid:35) Prob 1 n σk(Vi) ≤ d 1 − 1√ p − t i=1 k=1 d(cid:107)Vi(cid:107)F , it has subgaussian norm smaller than Cd, with C an universal constant (using the same argument as in Lemma 15). Therefore, by Hoeffding’s inequality (see [Ver12]), 1 − (cid:18) (cid:13)(cid:13)(cid:13)(cid:80)d k=1 σk(Vi) c1t2 (cid:19) , 1 − c2 t2 d2 n  n (cid:13)(cid:13)(cid:13)2 ψ2 ≤ exp ≤ exp 23 where ci are universal constants. By setting t = d√ p , we get n(cid:88) i,j 1 n2 tr(cid:0)(ViV T j )TP(d,dp)(Vi)P(d,dp)(Vj)T(cid:1) ≥ d (cid:16) (cid:17) p (cid:18) 1 − 2 (cid:19)2 , 1√ p with probability at least 1 − exp 1 − c2 1 p n = 1 − on(1), proving the Lemma. (cid:3) Theorem 14 immediately follows from these two lemmas. We note that these techniques are quite general. It is not difficult to see that these arguments, establishing integrality gaps that match the approximation ratios obtained, can be easily adapted for both the unitary case and the rank constrained case introduced in Section 5. For the sake of exposition we omit the details in these cases. 7 Open Problems and Future Work Besides Conjecture 8, there are several extensions of this work that the authors consider to be interesting directions for future work. A natural extension is to consider the little Grothendieck problem (3) over other groups of matrices. One interesting extension would be to consider the special orthogonal group SOd and the special unitary group SUd, these seem more difficult since they are not described by quadratic constraints. 3 In some applications, like Synchronization [BSS13, Sin11] (a similar problem to Orthogonal Procrustes) and Common Lines [SS11], the positive semidefiniteness condition is not natural. It would be useful to better understand approximation algorithms for a version of (3) where C is not assumed to be positive semidefinite. Previous work in the special case d = 1, [NRT99, CW04, AMMN05] for O1 and [SZY07] for U1, suggest that it is possible to obtain an approximation ratio for (3) depending logarithmically on the size of the problem. Moreover, for O1, the logarithmic term is known to be needed in general [AMMN05]. It would also be interesting to understand whether the techniques in [AN04] can be adapted to obtain an approximation algorithm to the bipartite Grothendieck problem over the orthogonal group; this would be closer in spirit to the non commutative Grothendieck inequality [NRV13]. Another interesting question is whether the approximation ratios obtained in this paper cor- respond to the hardness of approximation of the problem (perhaps conditioned on the Unique- Games conjecture [Kho10]). Our optimality conditions are restricted to the particular relaxation we consider and do not exclude the existence of an efficient algorithm, not relying on the same relaxation, that approximates (3) with a better approximation ratio. Nevertheless, Raghaven- dra [Rag08] results on hardness for a host of problems matching the integrality gap of natural SDP relaxations suggest that our approximation ratios might be optimal (see also the recent results in [BRS15]). 3The additional constraint that forces a matrix to be in the special orthogonal or unitary group is having determinant equal to 1 which is not quadratic. 24 Acknowledgments The authors would like to thank Moses Charikar for valuable guidance in context of this work and Jop Briet, Alexander Iriza, Yuehaw Khoo, Dustin Mixon, Oded Regev, and Zhizhen Zhao for insightful discussions on the topic of this paper. Special thanks to Johannes Trost for a very useful answer to a Mathoverflow question posed by the first author. Finally, we would like to thank the reviewers for numerous suggestions that helped to greatly improve the quality of this paper. A. S. Bandeira was supported by AFOSR Grant No. FA9550-12-1-0317. 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 C. Kennedy’s senior thesis at Princeton University. References [AMMN05] N. Alon, K. Makarychev, Y. Makarychev, and A. Naor. Quadratic forms on graphs. Invent. Math, 163:486–493, 2005. [AN04] [AS64] [Ban15] [BBT11] [BFV10] [BRS15] [BSS13] [BTN02] N. Alon and A. Naor. Approximating the cut-norm via Grothendieck’s inequality. In Proc. of the 36 th ACM STOC, pages 72–80. ACM Press, 2004. M. Abramowitz and I. A. Stegun. Handbook of Mathematical Functions with For- mulas, Graphs, and Mathematical Tables. Dover, New York, 1964. A. S. Bandeira. Convex relaxations for certain inverse problems on graphs. PhD thesis, Program in Applied and Computational Mathematics, Princeton University, 2015. J. Briet, H. Buhrman, and B. Toner. A generalized Grothendieck inequality and nonlocal correlations that require high entanglement. Communications in Mathe- matical Physics, 305(3):827–843, 2011. J. Briet, F. M. O. Filho, and F. Vallentin. The positive semidefinite Grothendieck problem with rank constraint. In Automata, Languages and Programming, volume 6198 of Lecture Notes in Computer Science, pages 31–42. Springer Berlin Heidelberg, 2010. J. Briet, O. Regev, and R. Saket. Tight hardness of the non-commutative Grothendieck problem. FOCS 2015, to appear, 2015. A. S. Bandeira, A. Singer, and D. A. Spielman. A Cheeger inequality for the graph connection Laplacian. SIAM J. Matrix Anal. Appl., 34(4):1611–1630, 2013. A. Ben-Tal and A. Nemirovski. On tractable approximations of uncertain linear matrix inequalities affected by interval uncertainty. SIAM Journal on Optimization, 12:811–833, 2002. 25 [Car09] [CD11] [CKS15] [CW04] [FH55] [GR94] [Gro96] [GT11] [GW95] [Hig86] [Kel75] [Kho10] [Lev12] [LV11] E. A. Carlen. Trace inequalities and quantum entropy: An introductory course. available at http://www.ueltschi.org/azschool/notes/ericcarlen.pdf, 2009. R. Couillet and M. Debbah. Random Matrix Methods for Wireless Communications. Cambridge University Press, New York, NY, USA, 2011. K. N. Chaudhury, Y. Khoo, and A. Singer. Global registration of multiple point clouds using semidefinite programming. SIAM Journal on Optimization, 25(1):126– 185, 2015. M. Charikar and A. Wirth. Maximizing quadratic programs: Extending Grothendieck’s inequality. In Proceedings of the 45th Annual IEEE Symposium on Foundations of Computer Science, FOCS ’04, pages 54–60, Washington, DC, USA, 2004. IEEE Computer Society. K. Fan and A. J. Hoffman. Some metric inequalities in the space of matrices. Proceedings of the American Mathematical Society, 6(1):pp. 111–116, 1955. I. S. Gradshteyn and I. M. Ryzhik. Table of Integrals, Series, and Products, Fifth Edition. Academic Press, 5th edition, January 1994. A. Grothendieck. Resume de la theorie metrique des produits tensoriels topologiques (french). Reprint of Bol. Soc. Mat. Sao Paulo, page 179, 1996. F. Gotze and A. Tikhomirov. On the rate of convergence to the Marchenko–Pastur distribution. arXiv:1110.1284 [math.PR], 2011. Improved apprximation algorithms for M. X. Goemans and D. P. Williamson. maximum cut and satisfiability problems using semidefine programming. Journal of the Association for Computing Machinery, 42:1115–1145, 1995. N. J. Higham. Computing the polar decomposition – with applications. SIAM J. Sci. Stat. Comput., 7:1160–1174, October 1986. J. B. Keller. Closest unitary, orthogonal and hermitian operators to a given operator. Mathematics Magazine, 48(4):pp. 192–197, 1975. S. Khot. On the unique games conjecture (invited survey). In Proceedings of the 2010 IEEE 25th Annual Conference on Computational Complexity, CCC ’10, pages 99–121, Washington, DC, USA, 2010. IEEE Computer Society. O. Leveque. Random matrices and communication systems: Wishart random ma- trices: marginal eigenvalue distribution. Available at: http: // ipg. epfl. ch/ ~ leveque/ Matrix/ , 2012. G. Livan and P. Vivo. Moments of Wishart-Laguerre and Jacobi ensembles of random matrices: application to the quantum transport problem in chaotic cavities. Acta Physica Polonica B, 42:1081, 2011. [Nem07] A. Nemirovski. Sums of random symmetric matrices and quadratic optimization under orthogonality constraints. Math. Program., 109(2-3):283–317, 2007. 26 [Nes98] Y. Nesterov. Semidefinite relaxation and nonconvex quadratic optimization. Opti- mization Methods and Software, 9(1-3):141–160, 1998. [NRT99] [NRV13] [Pis11] [Rag08] [Sch66] [She01] [Sin11] [So11] [SS11] A. Nemirovski, C. Roos, and T. Terlaky. On maximization of quadratic form over in- tersection of ellipsoids with common center. Mathematical Programming, 86(3):463– 473, 1999. A. Naor, O. Regev, and T. Vidick. Efficient rounding for the noncommutative Grothendieck inequality. In Proceedings of the 45th annual ACM symposium on Symposium on theory of computing, STOC ’13, pages 71–80, New York, NY, USA, 2013. ACM. G. Pisier. Grothendieck’s theorem, past and present. Bull. Amer. Math. Soc., 49:237323, 2011. P. Raghavendra. Optimal algorithms and inapproximability results for every CSP. In In Proc. 40 th ACM STOC, pages 245–254, 2008. P. H. Schonemann. A generalized solution of the orthogonal procrustes problem. Psychometrika, 31(1):1–10, 1966. J. Shen. On the singular values of gaussian random matrices. Linear Algebra and its Applications, 326(13):1 – 14, 2001. A. Singer. Angular synchronization by eigenvectors and semidefinite programming. Appl. Comput. Harmon. Anal., 30(1):20 – 36, 2011. A.-C. So. Moment inequalities for sums of random matrices and their applications in optimization. Mathematical Programming, 130(1):125–151, 2011. A. Singer and Y. Shkolnisky. Three-dimensional structure determination from com- mon lines in Cryo-EM by eigenvectors and semidefinite programming. SIAM J. Imaging Sciences, 4(2):543–572, 2011. [SZY07] A. So, J. Zhang, and Y. Ye. On approximating complex quadratic optimization problems via semidefinite programming relaxations. Math. Program. Ser. B, 2007. [TV04] [VB96] [Ver12] [WGS12] A. M. Tulino and S. Verd´u. Random matrix theory and wireless communications. Commun. Inf. Theory, 1(1):1–182, June 2004. L. Vanderberghe and S. Boyd. Semidefinite programming. SIAM Review, 38:49–95, 1996. R. Vershynin. Introduction to the non-asymptotic analysis of random matrices. Chapter 5 of: Compressed Sensing, Theory and Applications. Edited by Y. Eldar and G. Kutyniok. Cambridge University Press, 2012. Z. Wen, D. Goldfarb, and K. Scheinberg. Block coordinate descent methods for semidefinite programming. In Handbook on Semidefinite, Conic and Polynomial Optimization, volume 166 of International Series in Operations Research & Man- agement Science, pages 533–564. Springer US, 2012. 27 fold setting A Technical proofs - analysis of algorithm for the Stiefel Mani- entries and let αR(d, r) as defined in Definition 11. Then, Lemma 17 Let r ≥ d. Let G be a d×r Gaussian random matrix with real valued i.i.d. N(cid:0)0, 1 (cid:1) (cid:1) entries Furthermore, if G is a d× r Gaussian random matrix with complex valued i.i.d. N(cid:0)0, 1 E(cid:0)Pd,r(G)GT(cid:1) = E(cid:0)GPd,r(G)T(cid:1) = αR(d, r)Id×d. E(cid:0)Pd,r(G)GH(cid:1) = E(cid:0)GPd,r(G)H(cid:1) = αC(d, r)Id×d. and αC(d, r) the analogous constant (Definition 11), then r r The proof of this Lemma is a simple adaptation of the proof of Lemma 6. Proof. We restrict the presentation to the real case. As before, all the arguments are equivalent to the complex case, replacing all transposes with Hermitian adjoints and αR(d, r) with αC(d, r). Let G = U [Σ 0]V T be the singular value decomposition of G. Since GGT = U Σ2U T is a Wishart matrix, it is well known that its eigenvalues and eigenvectors are independent and U is distributed according to the Haar measure in Od (see e.g. Lemma 2.6 in [TV04]). To resolve ambiguities, we consider Σ ordered such that Σ11 ≥ Σ22 ≥ ... ≥ Σdd. Let Y = P(d,r)(G)GT . Since P(d,r)(G) = P(d,r)(U [Σ 0]V T ) = U [Id×d 0]V T , we have Y = P(d,r)(U [Σ 0]V T )(U [Σ 0]V T )T = U [Id×d 0]V T V ΣU T = U ΣU T . Since Yij = uiΣuT Note that GP(d,r)(G)T = U ΣU T = Y . j , where u1, . . . , ud are the rows of U , and U is distributed according to the Haar measure, we have that uj and −uj have the same distribution conditioned on any ui, for i (cid:54)= j, and Σ. This implies that, if i (cid:54)= j, Yij = uiΣuT is a symmetric random variable, and so EYij = 0. Also, ui ∼ uj implies that Yii ∼ Yjj. This means that EY = cId×d for some constant c. To obtain c, j n(cid:88) k=1 c = c 1 d tr(Id×d) = E tr(Y ) = 1 d 1 d E tr(U ΣU T ) = E 1 d σk(G) = αR(d, r), (cid:3) which shows the lemma. Lemma 18 Let r ≥ d. Let M, N ∈ Rd×nd such that M M T = N N T = Id×d. Let R ∈ Rnd×r be a Gaussian random matrix with real valued i.i.d entries N(cid:0)0, 1 E(cid:2)P(d,r)(M R)(N R)T(cid:3) = E(cid:2)(M R)P(d,r)(N R)T(cid:3) = αR(d, r)M N T , E(cid:2)P(d,r)(M R)(N R)H(cid:3) = E(cid:2)(M R)P(d,r)(N R)H(cid:3) = αC(d, r)M N H , Gaussian random matrix with complex valued i.i.d entries N(cid:0)0, 1 where αR(d, r) is the constant in Definition 11. Analogously, if M, N ∈ Cd×nd such that M M H = N N H = Id×d, and R ∈ Cnd×r is a (cid:1). Then (cid:1), then r r where αC(d, r) is the constant in Definition 11. 28 Let A =(cid:2)M T N T(cid:3) ∈ Rdn×2d and A = QB be the QR decomposition of A with Q ∈ Rnd×nd Similarly to above, the proof of this Lemma is a simple adaptation of the proof of Lemma 5. Proof. We restrict the presentation of proof to the real case. Nevertheless, all the argu- ments trivially adapt to the complex case by, essentially, replacing all transposes with Hermitian adjoints and αR(d) and αR(d, r) with αC(d) and αC(d, r). an orthogonal matrix and B ∈ Rnd×2d upper triangular with non-negative diagonal entries; note that only the first 2d rows of B are nonzero. We can write  B11 B12 0d B22 0d 0d ... ... 0d 0d  ∈ Rdn×2d, QT A = B = where B11 ∈ Rd×d and B22 ∈ Rd×d are upper triangular matrices with non-negative diagonal entries. Since (QT M T )T 11(QT M T )11 = (QT M T )T (QT M T ) = M QQT M T = M Ind×ndM T = M M T = Id×d, Since M Q = [BT 11, 0d×d,··· , 0d×d] = [Id×d, 0d×d,··· , 0d×d] and N Q = [BT B11 = (QT M T )11 is an orthogonal matrix, which together with the non-negativity of the diagonal entries (and the fact that B11 is upper-triangular) forces B11 to be B11 = Id×d. Since R is a Gaussian matrix and Q is an orthogonal matrix, QR ∼ R which implies E(cid:2)P(d,r)(M R)(N R)T(cid:3) = E(cid:2)P(d,r)(M QR)(N QR)T(cid:3) . 22R2)T(cid:3) , E(cid:2)P(d,r)(M R)(N R)T(cid:3) = E(cid:2)P(d,r)(R1)(BT (cid:3) B12. The Lemma now follows from using Lemma 17 to obtain E(cid:2)P(d,r)(R1)RT (cid:3) = αR(d, r)Id×d and The same argument, with Q(cid:48)B(cid:48) the QR decomposition of A(cid:48) =(cid:2)N T M T(cid:3) ∈ Rdn×2d instead, where R1 and R2 are the first two d × r blocks of R. Since these blocks are independent, the second term vanishes and we have E(cid:2)P(d,r)(M R)(N R)T(cid:3) = E(cid:2)P(d,r)(R1)RT noting that B12 = (QT M T )T (QT N T ) = M N T . 22, 0d×d,··· , 0d×d], E(cid:2)(M R)P(d,r)(N R)T(cid:3) = E(cid:2)R1P(d,r)(R1)T(cid:3) M N T = αR(d, r)M N T . 1 1 12R1 + BT 12, BT shows (cid:3) B Bounds for the average singular value Lemma 19 Let GC ∈ Cd×d be a Gaussian random matrix with i.i.d. complex valued N (0, d−1) entries and define αC(d) := E(cid:104) 1 . We have the following bound (cid:80)d (cid:105) j=1 σj(GC) d αC(d) ≥ 8 3π − 5.05 d . 29 Proof. We express αC(d) as sums and products of Gamma functions and then use classical bounds to obtain our result. Recall that from equation (16), d−1(cid:88) n=0 Tn, (26) αC(d) = d−3/2 (cid:90) ∞ where Tn = x1/2e−xLn(x)2dx, and Ln(x) is the nth Laguerre polynomial, 0 Ln(x) = (cid:18)n k n(cid:88) k=0 This integral can be expressed as (see [GR94] section 7.414 equation 4(1)) xk. (cid:19) (−1)k (cid:1) (cid:0)−1 k! n(cid:88) m=0 m (−n)m (m!)2(−n − 1 2 )m 2 Tn = Γ(n + 3/2) Γ(n + 1) where (x)m is the Pochhammer symbol , (27) (x)m = Γ(x + m) Γ(x) . The next lemma states a couple basic facts about the Gamma function that we will need in the subsequent computations. Lemma 20 The Gamma function satisfies the following inequalities: ≤ 1√ n Γ(n) Γ(n + 1/2) √ n ≤ Γ(n + 1) Γ(n + 1/2) Proof. See [AS64] page 255. ≤ 1(cid:112)n − 1/2 ≤(cid:112)n + 1/2. We want to bound the summation in (27), which we rewrite as (cid:0)−1 (cid:1) n(cid:88) m=0 m (−n)m (m!)2(−n − 1 2 )m 2 = (−1 2 )2 (m!)2 − m ∞(cid:88) m=0 (m!)2 − n(cid:88) (−1 2 )2 m m=0 (cid:32) 1 − (−n)m (−n − 1 2 )m (cid:33) . (−1 2 )2 m (m!)2 For simplicity define ∞(cid:88) ∞(cid:88) m=n+1 m=0 30 (I) := (−1 2 )2 m (m!)2 (−1 2 )2 m (m!)2 ∞(cid:88) (cid:32) 1 − (−n)m (−n − 1 2 )m m=n+1 (cid:33) , (II) := n(cid:88) (−1 2 )2 m (m!)2 (III) := so that (27) becomes m=0 Tn = Γ(n + 3/2) Γ(n + 1) ((I) + (II) + (III)). The first term we can compute explicitly (see [GR94]) as (I) = 4 π . For the second term we use the fact that (−1 ∞(cid:88) m=n+1 (II) = 1 Γ(−1/2)2 2 )m = Γ(m − 1/2)/Γ(−1/2) to get Γ(m − 1/2)2 Γ(m + 1)2 . Γ(m − 1/2)2 Γ(m + 1)2 = ∞(cid:88) 1 4π m=n+1 Using the first inequality in Lemma 20 and the multiplication formula for the Gamma function, Γ(m − 1/2) Γ(m + 1) = 1 m − 1/2 Γ(m + 1/2) Γ(m + 1) ≤ 1 √ (m − 1/2) m so we have ∞(cid:88) m=n+1 (II) ≤ 1 4π 1 (m − 1/2)2m ≤ 1 4π (cid:90) ∞ n−1/2 1 x3 dx = 1 2π(2n − 1)2 . For the third term, we use the formula (x)m = Γ(x+n) Γ(x) to deduce (cid:32) (cid:33) n(cid:88) m=0 1 4π (III) = = = (−1 2 )2 m (m!)2 n(cid:88) 1 − (−n)m (cid:18) (−n − 1 2 )m 1 − Γ(n + 1)Γ(n − m + 3/2) Γ(n + 3/2)Γ(n − m + 1) Γ(m − 1/2)2 Γ(m + 1)2 (cid:19) m=0 Γ(n + 1) Γ(n + 3/2) 1 4π Γ(m − 1/2)2 Γ(m + 1)2 n(cid:88) m=0 (cid:18) Γ(n + 3/2) Γ(n + 1) (cid:19) . − Γ(n − m + 3/2) Γ(n − m + 1) Using the second bound in Lemma 20, Γ(n − m + 3/2) Γ(n − m + 1) and also ≥(cid:112)n − m + 1/2, ≤ √ n + 1, Γ(n + 3/2) Γ(n + 1) 31 (cid:17) . (cid:32) (cid:33)2(cid:16)√ 1 m=0 √ n(cid:88) n + 1 −(cid:112)n − m + 1/2 (m − 1/2)(cid:112)m + 1/2 n + 1 +(cid:112)n − m + 1/2 and use the fact that n + 1 +(cid:112)n − m + 1/2 n(cid:88) 4π(cid:112)n + 1/2 n(cid:88) (m − 1/2)2(m + 1/2) √ ≤ m + 1/2 n + 1 √ m + 1/2 n + 1 m + 1/2 √ m=0 1 1 1 1 , 2π(n + 1) m=0 (m − 1/2)2 so that (III) ≤ 4π(cid:112)n + 1/2 1 If we multiply top and bottom by then (III) ≤ ≤ ≤ 1 ≤ 3 n + 1 n + 1 8 + π2 2π . Combining our bounds for (I), (II) and (III), and by (26), The term 1 d3/2 αC(d) ≥ 1 d3/2 n=1 4(cid:112)n + 1/2/π is the main term and can be bounded below by (cid:80)d−1 n + 1 n=1 . Tn = [(I) − (II) − (III)] π π − Γ(n + 3/2) (cid:18) 4 (cid:18) 4 (cid:112)n + 1/2 Γ(n + 1) ≥ Γ(n + 3/2) Γ(n + 1) ≥(cid:112)n + 1/2 d−1(cid:88) 4(cid:112)n + 1/2 d−1(cid:88) 1 d3/2 n=1 π ≥ 1 d3/2 8 3π (cid:19) (cid:19) , n + 1 1 1 − 2π(2n − 1)2 − 3 2π(2n − 1)2 − 3 (cid:18) 4 n + 1 (cid:19) 1 π − 2π(2n − 1)2 − 3 (cid:16) (d − 1/2)3/2 − (1/2)3/2(cid:17) (cid:18) 8 − (2d)−3/2 d−1. (cid:19) + ≥ (1 − (2d)−1) ≥ 8 3π − 3π 8 3π 1 2 32 The other error terms are at most (cid:18) (cid:112)n + 1/2 d−1(cid:88) n=1 d−3/2 1 2π(2n − 1)2 + 3 n + 1 (cid:19) ≤ 1 d3/2 (cid:112)n + 1/2 d−1(cid:88) d−1(cid:88) n=1 4 π(n + 1) 4 ≤ 1 d3/2 ≤ 4 πd3/2 n=1 π(n + 1)1/2 √ 2 d + 1. (cid:3) Combining the main and error term bounds, the lemma follows. Lemma 21 For GK ∈ Kd×d a Gaussian random matrix with i.i.d. K valued N (0, d−1) entries, define αK(d) := E(cid:104) 1 (cid:80)d j=1 σj(GK) d . The following holds (cid:105) αC(d) − αR(d) ≤ 4.02d−1. Proof. To find an explicit formula for αR(d), we need an expression for the spectral distribution of R the wishart matrix dGRGTR, which we call p d (x), given by equation (16) in [LV11]: (cid:33) (cid:1) (cid:1) Ld−1(x){ψ1 (x) − ψ2 (x)} , R d (x) = p 1 2d where 2 2 + 1 (cid:32) 2Rd(x) − Γ(cid:0) d Γ(cid:0) d (κ+d−2)/2(cid:88) (cid:34) ψ1(x) = e−x (cid:17)−1/2 (cid:16) x 2 e− x 2 ψ2(x) = 2 δkL2k+1−κ(x), (cid:35) (cid:1) (cid:1) + 2κ − 1 2 2 , x , 2 k=0 (1 − κ) 2Γ(cid:0) 1 Γ(cid:0) 1 d−1(cid:88) (cid:1) Γ(cid:0)k + 1 − κ Γ(cid:0)k + 3 (cid:1) , 2 − κ m=0 2 2 Rd(x) = e−x (Lm(x))2 , κ = d mod 2 and Γ(a, y) =(cid:82) ∞ y δk = ta−1e−tdt is the incomplete Gamma function. This means that αR(d) = d−1/2 x1/2p R d (x)dx (cid:90) ∞ (cid:90) ∞ 0 1 = d3/2 0 x1/2Rd(x)dx − 1 2d3/2 (cid:90) ∞ 0 x1/2 Γ(cid:0) d Γ(cid:0) d 2 2 + 1 2 (cid:1) (cid:1) Ld−1(x){ψ1 (x) − ψ2 (x)} dx. 33 We are especially interested in the following terms which appear in the full expression for αR(d): Recall that (see section 5) αC(d) = d−3/2 x1/2e−xLn(x)2dx which implies αR(d) = αC(d) − 1 2d3/2 (cid:1) (cid:1) Ld−1(x){ψ1 (x) − ψ2 (x)} dx. 2 + 1 2 0 n=0 (cid:90) ∞ d−1(cid:88) x1/2 Γ(cid:0) d (cid:90) ∞ Γ(cid:0) d (cid:90) ∞ 2 0 x1/2e−xLm(x)Lk(x)dx. Q(m, k) = 0 min{m,k}(cid:88) From [GR94] section 7.414 equation 4(1), we have Q(m, k) = 1 4π Γ(i + 3/2) Γ(i + 1) Γ(m − i − 1/2) Γ(m − i + 1) Γ(k − i − 1/2) Γ(k − i + 1) . The following lemma deals with bounds on sums involving Q(m, k) terms. Lemma 22 For Q(m, k) as defined in (29) we have the following bounds (28) (29) (30) (31) i=0 m(cid:88) k=0 2k(cid:88) i=0 m(cid:88) k=1 Proof. Note that in (30), Q(2m, 2k) = 1 4π Γ(k + 1/2) Γ(k + 1) Q(2m, 2k) ≤ 2.8 Γ(k + 3/2) Γ(k + 1) Q(2m − 1, 2k − 1) ≤ 5.6 Γ(i + 3/2) Γ(i + 1) Γ(2m − i − 1/2) Γ(2m − i + 1) Γ(2k − i − 1/2) Γ(2k − i + 1) since m ≥ k. For 0 < i < 2k − 1, the ith term in the summation of Q(2m, 2k) can be bounded above by Γ(i + 3/2) Γ(2m − i − 1/2) Γ(2m − i + 1) Γ(2k − i − 1/2) Γ(2k − i + 1) Γ(i + 1) ≤ √ ≤ √ i + 1 (2k − i) √ 1 2k − i − 1 (2m − i) √ 1 2m − i − 1 i + 1 (2k − i − 1)3/2(2m − i − 1)3/2 1 . This means that √ Q(2m, 2k) ≤ 1 8 Γ(2m − 1/2)Γ(2k − 1/2) Γ(2m + 1)Γ(2k + 1) √ 1 π 2k−1(cid:88) i=1 √ π max + + + 1 4π 1 4π 1 4π i + 1 (2k − i − 1)3/2(2m − i + 1)3/2 Γ(2k + 1/2) (cid:18) Γ(2k + 3/2) Γ(2k) Γ(2m − 2k + 1/2) Γ(2m − 2k + 2) Γ(2m − 2k − 1/2) Γ(2m − 2k + 1) (cid:19) π), 0 . √ (−2 Γ(2k + 1) 34 We bound the sum from i = 1 to 2k − 3 by √ i + 1 (2k − i − 1)3/2(2m − i + 1)3/2 1 ≤ 1 4π 2k−3(cid:88) i=1 1 4π 2k−3(cid:88) i=0 √ i + 1 (2k − i − 1)3/2 1 (cid:90) 2k−2 (cid:32)√ 0 (2m − 2k + 1)3/2 √ x + 1 (2k − x − 1)3/2 dx √ 4k 2k − 1 8k + 1 (cid:33) , ≤ ≤ 1 4π(2m − 2k + 1)3/2 1 4π(2m − 2k + 1)3/2 so that for k ≥ 1, √ Q(2m, 2k) ≤ 1 8 π Γ(2m − 1/2)Γ(2k − 1/2) Γ(2m + 1)Γ(2k + 1) (cid:32)√ 8k + (cid:33) √ 4k 2k − 1 + + 1 √ 2k − 1 (2m − 2k + 3)3/2 √ Γ(2k + 1/2) 4π(2m − 2k + 1)3/2 1 4π 1 4π 1 4π π + Γ(2k) (cid:18) Γ(2k + 3/2) We now turn our attention to the full sum (cid:80)m For k = 0, Q(2m, 0) < 0 except for the term Q(0, 0) = the full sum, so we ignore these terms. Γ(2k + 1) max + √ Γ(2m − 2k + 1/2) Γ(2m − 2k + 2) Γ(2m − 2k − 1/2) Γ(2m − 2k + 1) (cid:19) π), 0 . √ (−2 π/2 which also becomes negative in Γ(k+1/2) Γ(k+1) Q(2m, 2k). As before, we define for k=0 clarity (I) := (II) := (III) := (IV ) := (V ) := √ 1 8 1 4π 1 4π √ 1 4 1 4π π k=1 k=1 m(cid:88) m(cid:88) m(cid:88) m(cid:88) m(cid:88) k=1 k=1 π Γ(k + 1/2) Γ(k + 1) Γ(2m − 1/2)Γ(2k − 1/2) Γ(2m + 1)Γ(2k + 1) Γ(k + 1/2) Γ(k + 1) 1 (2m − 2k + 1)3/2 8k + √ 2k − 1 Γ(k + 1/2) Γ(k + 1) (2m − 2k + 3)3/2 (cid:32)√ (cid:33) √ 4k 2k − 1 Γ(k + 1/2) Γ(k + 1) Γ(2k + 1/2) Γ(2k) (cid:18) Γ(2k + 3/2) Γ(k + 1/2) Γ(k + 1) k=1 max Γ(2m − 2k + 1/2) Γ(2m − 2k + 2) Γ(2m − 2k − 1/2) Γ(2m − 2k + 1) √ (−2 (cid:19) π), 0 . Γ(2k + 1) 35 Using the bounds in lemma 20, 32 k=1 k=1 1 − (I) ≤ m(cid:88) m(cid:88) (cid:18) m(cid:88) (cid:32) m(cid:88) (II) ≤ 1 4π ≤ 1 π (III) ≤ 1 4π ≤ 1√ 24π √ (IV ) ≤ 1 4 ≤ 1 2π 1 √ 4π 2m + 1√ (V ) = ≤ 4π k=1 + π , m (2k)1/2 k1/2 , k=1 1 2 Γ(2m + 3/2) Γ(2m + 1) √ 3. ≤ √ 1 πk1/2 √ 1 mk √ 1 2m − 1 √ ≤ 1 32 π , 2k − 1 √ (4 k) 1 (cid:19) k1/2(2m − 2k + 1)3/2 1√ 2m − 1 √ ≤ 1 , π 2k − 1 1 (2m − 2k + 3)3/2 k1/2 (cid:33) √ π 1 (2m − 2k + 1) √ 2m − 2k + Γ(m + 1/2) Γ(m + 1) Finally, m(cid:88) k=0 Γ(k + 1/2) Γ(k) Q(2m, 2k) ≤ (I) + (II) + (III) + (IV ) + (V ) ≤ 2.8. To deduce the inequality (31), we use the previously derived bounds to show that Q(2m − 1, 2k − 1) ≤ 1 4π √ i + 1 1 (2k − i − 2)3/2(2m − i)3/2 + + 1 4π 1 4π Γ(2k − 1/2) Γ(2k − 1) (cid:18) Γ(2k + 1/2) Γ(2m − 2k + 1/2) Γ(2m − 2k + 2) Γ(2m − 2k + 1/2) Γ(2m − 2k + 2) Γ(2k) (cid:19) π), 0 , √ (−2 so that Q(2m − 1, 2k − 1) ≤ Q(2m, 2k). Now it suffices to note that in the full sum, (cid:80)m k=1 Γ(k+1) Q(2m − 1, 2k − 1) ≤ 2(cid:80)m Γ(k+3/2) k=1 Γ(k+1/2) Γ(k) Q(2m − 1, 2k − 1) and we get 2k−3(cid:88) i=1 √ π max m(cid:88) k=1 m(cid:88) k=1 Γ(k + 3/2) Γ(k + 1) Q(2m − 1, 2k − 1) ≤ 2 36 Γ(k + 1/2) Γ(k) Q(2m, 2k) ≤ 5.6. (cid:3) We now return our focus to finding a bound on the expression for αR(d) given in (28). Since ψ1, ψ2 depend on the parity of d, we split in to two cases. Odd d = 2m + 1 From (see [GR94] section 7.414 equation 6), (cid:90) ∞ thus equation (28) becomes αC(2m + 1) − αR(2m + 1) = e−x/2L2m(x)dx = 2, 0 (cid:32) m(cid:88) αC(2m + 1) − αR(2m + 1) ≤ 2.8(cid:112)m + 1/2 Γ(m + 1) Γ(m + 1/2) (2m + 1)3/2 k=0 1 and using the first bound in Lemma 22, Γ(k + 1/2) Γ(k) Q(2m, 2k) − 21/2 (cid:33) , 1 ≤ m−1. (2m + 1)3/2 Even d = 2m For d = 2m, we have αR(2m) = αC(2m) − We split the integral into two parts, 1 2(2m)3/2 x1/2 Γ(m + 1/2) Γ(m) L2m−1(x){ψ1(x) − ψ2(x)}dx. 1 2(2m)3/2 −1 (I) := (II) := 2(2m)3/2 0 x1/2 Γ(m + 1/2) Γ(m) x1/2 Γ(m + 1/2) Γ(m) L2m−1(x)ψ1(x)dx L2m−1(x)ψ2(x)dx. 0 (cid:90) ∞ (cid:90) ∞ (cid:90) ∞ 0 m(cid:88) k=1 Expanding from the definition of ψ1 above, we have (cid:90) ∞ (I) = 1 Γ(m + 1/2) 2(2m)3/2 0 Γ(m) x1/2L2m−1(x)e−x = 1 Γ(m + 1/2) 2(2m)3/2 Γ(m) so by Lemma 22, Γ(k + 3/2) Γ(k + 1) Q(2m − 1, 2k − 1), m−1(cid:88) k=0 Γ(k) Γ(k + 1/2) L2k−1(x)dx (I) ≤ 1 Γ(m + 1/2) 2(2m)3/2 Γ(m) 5.6 ≤ 1 m1/2 . The other part of the integral is (cid:90) ∞ (cid:90) ∞ −1 2(2m)3/2 −1 4m1/2 0 (II) = = x1/2 Γ(m + 1/2) L2m−1(x)(x/2)−1/2e−x/2 0 Γ(m + 1/2) Γ(m) L2m−1(x)e−x/2 2Γ(1/2, x/2) dx + Γ(m) Γ(1/2) 2m3/2 Γ(m) (cid:20) 2Γ(1/2, x/2) (cid:21) − 1 Γ(1/2) 1 Γ(m + 1/2) dx , 37 where we use the fact that for odd 2m − 1 (see [GR94] section 7.414 equation 6), 0 (cid:90) ∞ (cid:12)(cid:12)(cid:12)(cid:12) ≤ L2m−1(x)e−x/2dx = −2. 0 (cid:18)(cid:90) ∞ (cid:34)(cid:90) ∞ (cid:34)(cid:90) 1 (cid:18) 0 0 (cid:18)(cid:90) ∞ (cid:18)(cid:90) ∞ x x Γ(1/2)2 + (cid:19)1/2 0 Γ(1/2, x/2)2dx (cid:19)1/2(cid:18)(cid:90) ∞ (cid:35)1/2 (cid:19)2 (cid:19)2 (cid:90) ∞ (cid:19)1/2 ≤ (π + e−2/2)1/2, (cid:18)(cid:90) ∞ dx + dx x 1 t−1/2e−tdt t−1/2e−tdt t−1/2e−tdt (cid:90) ∞ (e−x)2dx (cid:19)2 (cid:35)1/2 dx (cid:3) We can bound the first integral in the expression of (II) by L2m−1(x)e−x/2Γ(1/2, x/2)dx e−xL2m−1(x)2dx (cid:12)(cid:12)(cid:12)(cid:12)(cid:90) ∞ 0 = = ≤ so finally 1 Γ(m + 1/2) Γ(m) + m1/2 2m3/2 (II) ≤ (π + 1/2e−2)1/2 √ 2 πm3/2 ≤ 1.01m−1. Combining the above bounds we see that in the case of even d = 2m, αC(2m) − αR(2m) = (I) + (II) ≤ 2.01m−1. 38
1206.5335
2
1206
2012-06-26T19:49:14
The McDougal Cave and Counting issues
[ "cs.DS" ]
In this paper I investigate the problem of tagging elements of a set, and the elements of those elements, uniquely, when they admit an order, and two boundary elements are tagged. A heuristic sorting algorithm is also investigated. (Updated grammar and spellings.)
cs.DS
cs
The McDougal Cave and Counting issues Sayandeep Khan, Synergy Moon LLC September 26, 2018 Abstract In this paper I investigate the problem of tagging elements of a set, and the elements of those elements, uniquely, when they admit an order, and two boundary elements are tagged. A heuristic sorting algorithm is also investigated. 1 Introduction 1.1 The initial problem I will begin by investigating an imaginary problem, and then show the use of the solution in practical issues. The problem goes as follows. Problem 1.1. Tom Sawyer is in the McDougal Cave. The cave is a system of interconnected tunnels, and rooms. Each room is connected to each other via tunnels, and inside every room, is a self-contained tunnel system. Each tunnel, may contain smaller rooms, and mazes. Tom wants to systematically inspect the cave system to find his treasure, however, he need not inspect every chamber, every tunnel and every room, and similarly, he can choose in which order he would explore. Nonetheless, he can be in only one position at a time. In order to mark which room he is in, with respect to which tunnel, and in which larger room, in turn, the tunnel itself is, Tom needs to assign a number to his location. How could such a numbering scheme work, is the question I would attempt to answer. We will see, that this problem is similar to some issues encountered in mod- eling and simulation, especially, those which use blocks (assigned with certain tasks, selected from a pallet) connected to each other. I will also present yet another solution of the classic sorting problem. 1.2 Conway's Numbers - primary decisions Conway presented a number system [1] which can be used for arbitrary counting. This system is the obvious choice for the counting problem is because it permits assignment of new tags between any two, and the construction itself admits an ordered structure which can be extended to infinity. 1 However, this number system does not permit too much freedom of tagging, then only one number can be created between two, and nor is this number unique to the generation, nor is the generation independent to order of generation. Moreover, it is considered that such numbers already exists. Therefore, we consider a different counting system. 2 Beyond Conway's Numbers In this section, I propose an extension of the usual Conway's Numbers, and investigate the algebraic structure of them. Numbers generated this way will be called, in this context, "Extended Conway's Number"-s, or "ECN"-s 2.1 Axioms Before further discussion, it is necessary to declare a few axioms. Axiom 1. The Axiom of Sets: Sets exist, and any set, including the null set has a few attributes, such as size etc. Sets are collection of mathematical objects, and are objects themselves. Sets can be assigned with natural attributes, such as size, disjoint element count, as well as synthetic attributes, e.g. position in a sequence, morphism, etc. These attributes are used for ordering sets. Axiom 2. The Axiom of ordering: A collection of Sets can be ordered. That is, comparative relations between sets and their properties exist. The number of possible ordering is not restricted. It is possible, two or more orderings can coincide (i.e. at this point, the requirement for unique ordering is omitted). If two or more orderings coincide, then they are equivalent, and existence of one implies the existence of the other. Two orderings, a < b < ... < c and d < e < ... < f are equivalent if f a ≡ d, b ≡ e, ..., c ≡ f etc. At this moment, the notion of index is not yet defined. Here the symbol ≡ implies "the same as" (dasselbe, exactly the same, of course the exactness of similarity depends on the context). There exists the following order relations: 1. ≡: exactly the same 2. =: equivalent. less strict similarity than previous 3. <: not (necessarily) similar 4. >: not (necessarily) similar, antisymmetric to the previous 5. ≤: not > 6. ≥: not < 2 The third and fourth relations are transformable to each other, so are the fifth and sixth. Axiom 3. Axiom of Numbers: Numbers are symbolic representation of proper- ties of sets, and they exist, and can be constructed from sets. Each set has at least one number associated with it. If the same number can be constructed from two or more sets, then they are equivalent in that context, and vice versa. A collection of Number can form a set. Numbers can be constructed from other numbers. Axiom 4. Axiom of Construction: A number can be constructed from a set in different ways using well behaved functions. A number N , constructed from set S, using construction method C, can be written as N = C(S). This axiom forms the basis of the rest of the analysis, where we attempt to construct numbers, from properties of sets, which assign an order to them. Axiom 5. Axiom of Repetition: Any operation can be applied on any object, an unlimited number of times, but the outcome may be undefined. This axiom requires immediately the following axiom: Axiom 6. Axiom of Operation: Set operations, including but not limited to Union, Subtraction, Intersection etc. exists. The behavior of these operations are defined in the Euclidean axioms. Axiom 7. The Euclidean Axioms apply. The Euclidean axioms deal with the "largeness" of an object. Largeness can have different meanings on different contexts. However, axiom of sets assume that "size", in its intuitive sense, is a natural property of a set. 2.2 Ordering and Counting Ordering is a natural process, therefore, the analysis can start from ordered sequence of sets. 2.2.1 Ordered Sequence of Sets and Comparison to Set From Axiom of Ordering, sets assume ordering. Such an ordering constructs a sequence. The elements of a sequence are disjoint. The construction of a se- quence does not depend on the operations described on the axiom of operations. A sequence does not admit a size, it admits a count. A count will be defined in due course. An uniquely defined sequence is always ordered, and assumes an "ordering rule". An ordering rule can be an enumeration, or, alternatively an (well behaved) function. 3 Definition 2.1. A collection of objects, brought together without those opera- tions, which is not a sequence, is a disarray, or an unordnung. An unordnung, can be converted to a sequence, with a function (which is an ordering rule). Such functions are called ordering f unctions, or ordnungsregel-s Two ordered sequences are equivalent, if f they are constructed from two disarrays, that contain pairwise equivalent elements, and same ordnungsregel apply on them. A set, however is constructed using set operations. Definition 2.2. If a set is to be constructed from elements which admit the = relation under certain contexts, yet are distinct elements in a sequence, then they are handled as distinct elements under set operations. This condition is called otherness condition or alteritaet condition. 2.2.2 Order Label Since each of the ordered sets has a number associated to it, from Axiom of Numbers, those numbers are also therefore ordered. The same ordering, there- fore can be achieved by ordering the numbers associated with the sets too. Therefore: Lemma 2.1. Numbers are Order Labels of sets. They generate an unique or- dering. That is, numbers label sets, and those labels can determine the ordering. Proof. The term "Order Label", in this context, means a symbol, which can be ordered to achieve the same ordering as the ordering of sets themselves. To prove, that numbers are Order Labels, it is sufficient to show that, O{N = C(S)} ≡ O{S}. Here, O is an ordering, and ≡is the equivalence relation. Take a collection of sets Sa, ...., So. Let two orderings be Si < Sj < ... < Sl, and Se < Sf < ... < Sg. The two are equivalent iff Si ≡ Se, Sj ≡ Sf , Sk ≡ Sg. From axiom of numbers, each set can generate an unique number, and if two sets produce the same number, then they are equivalent, and vice-versa. That is, C(Si) = C(Se), etc implies Si ≡ Se, Sj ≡ Sf , Sk ≡ Sg. Therefore the two orderings are equivalent, if C(Si) = C(Se), etc holds. Under that condition, C(Si) can be generated from both Si, and Se. Consider the order sequence C(Si) < C(Sj) < ... < C(Sl). This sequence implies therefore both the sequences Si < Sj < ... < Sl, and Se < Sf < ... < Sg. Therefore, if the order sequence C(Si) < C(Sj) < ... < C(Sl) implies two se- quences, then both are equivalent. In other words, all order sequences generated by a number sequence are equivalent. QED. The order labels can be used to assign an index to the elements of a sequence. 4 2.2.3 Count Label A sequence admits another measure, namely Definition 2.3. The Order Label of the last element of an ordered sequence is called the count of the sequence. The count is useful to determine the size of set that is constructed from the sequence, but this will be explicitly defined later. A count label is used for extracting subsequences of a sequence, then the order label of the last element of the target subsequence is the count of it. In certain cases, enumerating the order labels of the each individual element is to be avoided, and is done using count labels. A count label is used, among other things, to assign a measure to the itera- tions of a repetitive operation. 2.2.4 Code Sequences and Groups Numbers are symbols. Definition 2.4. A string of symbols is called a codeword. A codeword can be constructed from set S of symbols, taking the elements of the set, possibly repeated, and composing them together. The complete set of such words is called language. Usually, the symbol Σ is used instead of S, but here to avoid confusion with the summation sign, we use the symbol S. Definition 2.5. The construction of a code sequence is given by a formal grammar, a set of rules, which transfers one word to another. If the words are given, and a grammar exists that transfers two words to a third, then we arrive at the notion of Groups, and similar structures. Such structures will tell as important details of the set of numbers under investigation. 2.3 Consistence to Euclidean Axioms The above discussion defines numbers as (symbols to) labels. However, with labels, operations can not be defined. It is therefore, necessary to unify the labels with size. Immediately it is clear that size offers a natural way of ordering sets, with the previous element of the ordered sequence being of smaller size than the next one. 2.3.1 Zahlenaufbau Before the discussion may proceed further, certain more analysis is to be con- sidered. This analysis will be called Zahlenaufbau in this context. Consider the fifth axiom of Euclid: any object is larger than any part of itself, or, any part of an object is smaller than the whole. An important corollary is: 5 Corollary 2.1. Since the null set is a subset ("part") of any set, it is the smallest set. Axiomatically, it is proposed that any part of any object is included in the whole. So, if an object oa contains another object ob, then we write, ob ⊂ oa, ob < oa. If o1 ⊂ o2, o1 ⊃ o2, then o1 = o2. Now, from the notion of union, one can write, ob ∪ oc = oa. Consider the general sequence : o ∪ k = ok, ok ∪ k′ = ok′ , ok′ ∪ k′′ = ok′′ ... ad petitum. Obviously, oq ∪r {z} t times os =⇒ oq < os. = Now, let k = k′ = k′′ = K 6= φ, o = φ, the Null set. Obviously, the largeness of the Null set is an absolute minimum. The largeness, or "size" is represented by the number Zero. K is called einheit from German for unitness, the property of being one. The number immediately constructed after the nullset is One, w.r.t. K, the next number is Two, w.r.t. K , et cetra. The size of each Sk is therefore is a number, by definition. The underscore indicates the sequence is of finite length. If a number does not have a name, one can call it (N1 union N2), where Nk is named. Consider for example, the the number 39, which an be called Thirty union Nine. Notice, that here one is not dealing with positional value of a digit of a representation system. Definition 2.6. N atural count is defined in the context of constant einheit. Consider the minimal set, which is the null set. If the elements are ordered, call the count zero. Increment this set, by repeating the union operation, to s = o ∪ k ∪ k ∪ k ∪ ... ∪ k. The set of the all k-s has the size of N , (in specific cases, same as the size of the resultant set s). If elements of this set is labeled and ordered, such that the count is N , then it is called a natural count. The numbers constructed, ∀N , thereby are natural numbers. Remark 2.1. In this definition, the size of a set is identified with the Natural count of the einheit -s that construct the set. Natural counts are always defined w.r.t. an einheit. A natural count n with einheit u implies the possible existence of a set, which is constructed from Su, and the set of all u -s used for this construction has size n. Any value, while assigned an einheit, can become a natural count. The einheit of a natural count may be replaced with another, using certain operations. Definition 2.7. An einheit is a constant set, used in repeated union to con- struct other sets. A natural einheit is the set which has the size one. Here the "one" identifies to the standard, everyday meaning of the word "one", as in one llama, or one submarine or one Tom Sawyer. 2.3.2 Variable Einheit Of course the choice of einheit is arbitrary. This leads to the following remarks: 6 Remark 2.2. The same number can be generated by different combinations of different einheit. Proof. Since it is a claim of a possibility, the proof can be simply illustrated by an example. Consider the number N = k ∪ k ∪ ... ∪ k. Let k = kx ∪ kx. Hence N = (kx ∪ kx) ∪ (kx ∪ kx) ∪ ... ∪ (kx ∪ kx). This is a different combination, that represents the same N . Notice that there is no boundary on the sequence length that constructs N . QED. Corollary 2.2. All numbers can be represented via different combinations of different einheits. Remark 2.3. One number can be a combination of unlimitedly many different einheits. Proof. From the axioms, union between any sets is possible. Hence, any sets of any einheits exist. QED. Remark 2.4. There total set of numbers is unlimitedly large. Proof. ∀SK = ok, ∃ok ∪ kk 6= φ. Hence, it is possible to create unlimitedly many numbers. QED. Remark 2.5. There exists unlimitedly many numbers between any two given numbers. Proof. Assume the numbers are 0 and 0 ∪ K. ∀K, ∃K′ ⊂ K. Therefore, ∀o, o ∪ K > o ∪ K′ > o, and similarly, there exists a number be- tween o ∪ K′ and o, and also between o ∪ K and o ∪ K′, and ad infinitum. QED. Remark 2.6. The set of all numbers is closed. Proof. Any number, and any set, in this system is dealt as a set. That is, what in other system is a number, in this system is a set. Singleton elements automatically assume the status of a set. An operation on a set produces, therefore another set. Since any set can be represented in this system as a combination of different einheits, any set is a valid member of the class this system represents. Therefore, the set of all numbers (or the class of all sets) is closed, under any operation. QED. 7 2.3.3 Number Line, Number Plane and Others The number line is an ordered sequence of all numbers generated by all einheits, that are comparable to each other. Obviously, since each einheit can generate infinite numbers, one line can contain only (strictly) two types of einheits, be- cause, it can be expanded to infinity in two directions. The next pair of comparable einheit can be placed along a different line, independent to the all previous lines. Hence pairwise, the einheits define a set of basis, which can be used to describe a N -dimensional space. Example 2.1. The Positive and Negative Reals are comparable, under certain conditions, and form one number line. Positive and Negative Imaginary numbers are also under similar conditions comparable to each other, but not comparable to Reals. Therefore, the real line and the imaginary line define a number plane. This is the Argand Plane. The comparison between any two points in a general N -dimensional space is therefore not simple. There exist N pairs of coordinates. An order relation may, however, be constructed from a particular pair. Therefore, the order relation is not unique. An unknown number, is therefore a point in the space of unknown size. The size of real numbers are therefore real size, and the imaginaries have imaginary sizes. 2.4 Operations The set of ECN is a formal field, with operations defined on it. We primarily define two order preserving operations, namely addition and multiplication. 2.4.1 Order Similar Consider an order sequence a > b > c > ... > d, and an operation f , such that f (a, w) = p, f (b, w) = q, f (c, w) = r, f (d, w) = s, for some w. If p < q < r < ... < s or p > q > r > ...s, then call the function an order similar one. Given the sequence a > b > c > ... > d, if p > q > r... etc, then it is a monotonic operation, otherwise it is an antitonic operation. Remark 2.7. On a given set, a monotonic operation and an antitonic operation is isomorphic. An order similar operation implies its inverse is also order similar. The proof is trivial. We investigate the invariant(s) of order similar operations. It is trivially clear that Remark 2.8. The closure, and the initial (resp. final) segments are not necessar- ily invariants to a order similar operation. They are invariants for a monotonic operation. In order theory, the monotonic operation is known as order preserv- ing. However, isomorphism implies, that the range and image of the operation has the same natural count of elements. Formally: 8 Remark 2.9. The height, defined as the natural count of the sequence (resp. subsequence) − einheit, of the sequence (resp. subsequence) is an invariant, under order similar operations. Other invariants may be found from the definition of order similar operations. Here we consider the concept of neighborhood, and introduce the concept of zwischenraum. Consider a sequence S = a, b, c, ..., d, such that, a < b < c < ... < d apply. Assign order labels α, β, γ, ..., δ on them respectively to represent them using a graph. A subsequence s of S is a, b, c. If we represent s with a graph g, then it is trivially clear that the neighbors of b are a and c. Similar statements apply for every subsequence of length 3 in S. Under an order similar operation, f , f (b) has the neighbors (in a graph-representation with graph g ′) f (a) and f (c). From remark 3.13, it is trivially clear that g and g ′are isomorphic, specifically, b and f (b) are. Hence they have isomorphic neighborhood. Same applies for any subsequence in S. Hence the neighborhood matrix is invariant. Definition 2.8. This permits to define a property of such 3-tuples, which we will call Zwischenraum (from German "space in-between") invariance. Consider a sequence S : a, b, c, d, ..., z. Let a < b < c, such that, ∄da < d < b ∨ b < d < c. Then , b is said to occupy the Zwischenraum of a and c, symbolically, b ∈ Z(a, c). Clearly, f (b) is occupying the zwischenraum of f (a) and f (c), if f is an order preserving operation. Therefore, the zwischenraum for each 2-tuple, constructed from an ordered sequence, if uniquely defined by a single element e, the the zwischenraum of the image of the 2-tuple is uniquely defined with the image of e. This property is called Zwischenraum Invariance. We try to generalize this for cases, where the zwischenraum of two elements will consist of an ordered set s consisting of more than one elements. The zwischenraum of the image of the two bounding elements consist of the image of s. This is the sought generalization. Moreover, the set s itself is also subject to zwischenraum invariance, and so is any subset of s. Formally: Theorem 2.1. Any sequence with natural count larger than 2, if admits a zwischenraum invariance, then any subsequence of it of length having natural count 2 admits zwischenraum invariance to the same operation. 2.4.2 Addition and Multiplication Addition Addition is a monotonic binary operation, symbolized with +, with following properties. • If A < B < C < ... < D, then A + k < B + k < C + k < ... < D + k, for all A, B, C, ..., D, k • (p + k)\p does not depend on p, but on k, for all p, k • a + p is either < a or > a, both may hold. This is applicable for all a, p • Axiom of associativity and axiom of commutativity holds. 9 Lemma 2.2. The addition operation may be represented by set union. Immediately, one realizes, that there exists at least one p, for which a + p = a. Such p-s are called neutral to addition. The addition operation, from Euclidean axioms, is comparable to set unions. Let u be the einheit. a + p is defined as the size of a∪Su, where the count of Su is p. Multiplication Multiplication, an order similar operation, is similarly de- fined, symbolized with × or ∗, where • If A < B < C < ... < D, then either A ∗ k < B ∗ k < C ∗ k < ... < D ∗ k, or A ∗ k > B ∗ k > C ∗ k > ... > D ∗ k for all A, B, C, ..., D, k • (p ∗ k)\p depends on both p, and k, for all p, k • (a ∗ p) is either < a or > a, both may hold. This is applicable for all a, p • Axiom of associativity and axiom of commutativity and axiom of distribu- tivity holds. There also exists neutral to multiplication, such that a ∗ p = a. Further, a ∗ p is the size of Sa, where, count of Sa is p. Both operations will be extended in forthcoming discussion to account for different types of einheit. Claim 2.1. The total set of all numbers, written n, is a group. Proof. n is a set, with two operations defined on it, and is closed, by definition, and from remark 3.11 to both. Both operations agree to the axiom of associa- tivity, and assume an identity element. In next sections, the inverses will be discussed. Hence group axioms are fulfilled. QED. 2.4.3 Operands of + and × Above the operations are described in terms of Order Labels, which are sizes of sets. The size of sets are identified with the natural count of einheits that construct the set. Sets need not be collection of disjoint elements, the elements may touch (in a topological sense) or overlap each other. In practicality, it is more often the case than not, that, the elements are not disjoint. The addition operation deals with the size of the sets, which is intuitively clear, and is supported by Euclidean axioms. If both operands possess the same einheit, then the result also has the same einheit as well. Otherwise, either one einheit is transformed (we will use the term transcribed, i.e. represented differently, instead) to the other, and then the result is computed, or they are left as disjoint union. 10 Example 2.2. Assume the addition between a and b is performed (which is the union of two underlying sets having natural counts a and b), where a is imaginary, and the other is real (the imaginaries are not yet defined explicitly). Recall each natural count is defines w.r.t. a constant einheit. In this particular case the sum is left as a + b, because the real and the imaginary einheit is separate. Had they both the same einheit, then the result would be represented by c, which is the natural count of the set A∪B, A and B having natural counts a and b respectively. The natural count c will be defined w.r.t. the same einheit as both a and b. The multiplication operation is however, slightly more complex. If the op- eration is performed on two operands, with two (not necessarily same) einheits, for example to calculate a × b, a set A set with size a is constructed, w.r.t the einheit of a. b is now defined as a natural count, w.r.t. its own einheit. A sequence S, each of its element being a, is constructed with count b. The count labeling need not be dependent on the size. Another set R is constructed by repeated union of elements of S. Then R is the result of the multiplication operation. 2.4.4 Further Operations on n Although the purpose of n here is to serve simply as a tagging system, that permits somewhat flexible re-tagging system, and possibility to generate new numbers between any two in a comprehensive way. It is now of interest, to investigate, if n assumes a algebraic structure that can be exploited. Length of a Line Segment Given two points p1 and p2 in the number line l, where p1 < p2 holds, assume there exists a third number p3p1 + p3 = p2, where the + operation is defined above. Since p3 is also a number, it exists in n. p3is called the length of line segment between p1 and p2. Now, to calculate p3, we need ∽ p1, the inverse of p1w.r.t addition with p2. We have p1 + p3 = p2. From previous discussion, the operands are sizes, hence the Euclidean axioms apply. Hence we add ∽ p1 to both sides. RHS is the p3+ neutral to addition, which is just p3 and LHS is p2 + (∽ p1). This discussion leads to the length operation. The length operation is written as a − b. It is defined as a + (∽ b), if f a < b, b + (∽ a) otherwise. Remark 2.10. The outcome of this operation has the same einheit as the operands. The definition of a subtraction operation follows immediately. The Euclidean axioms uses the notion of "taking away", which is comparable to set exclusion operation. Translated to notion of order labels, a − b , where the − symbol designates the subtraction. Remark 2.11. From Euclidean axioms, subtraction is only then defined, when a 6> b. a − b therefore is the size of the set A\B, where A has the size a, and B the size b. If the under-laying sets have similar einheit, then the result is also the same unity. 11 For any a, it is immediately clear, that a−a = 0, the size of the null set. The 0 is again the neutral to addition. So, a − a = 0 = a+ ∽ a. Now, again, from Euclidean axioms, adding any b to both sides, preserve the equality relation. Therefore, the subtraction operation is same as adding the inverse. Negative Numbers and Extension A negative numbers may be treated as the inverse to a given number in a group under addition. The definition is rather synthetic, that it does not immediately follow from Euclidean axioms. Inverses of negatives ((a−1)−1 = a holds) are called positives. Claim 2.2. Each set has an inverse of it, such that set + inverse of it = φ. Those inverses follow the Euclidean axiom. These inverses may be just mathematical concepts. Proposition 2.1. In this context, we define the the order relation as follows. Let ∽ a and ∽ b be two negative numbers. ∽ a >∽ b if f a > b. Definition 2.9. Call the numbers with natural einheits U niversal P ositives, and the corresponding negatives U niversal N egatives. Remark 2.12. In particular einheit scheme, negatives has the same einheit as the corresponding positives, then they are inverses to each other, and results in a neutral, under addition. Proposition 2.2. Sometimes, it is necessary to order the positives and the negatives (or other pairs) in the same sequence. For that purpose, the number line is constructed. Universally, assign ∼ a < a. Start ∼ 0, and continue till ∼ ∞, then the sequence is ∼ 0 < 0 < ... <∼ a < a < ... <∼ ∞ < ∞. This ordering permits a semi infinite line to be constructed. If, however, ∽ a >∽ b if f a < b is used, together with ∼ a < 0 if ∼ a is a universal negative, then we arrive at the usual positive-negative ordering. Division as Multiplication with Inverses Division operation is defined for multiplication. If a × b = neutral of multiplication, then, c ÷ a = c × b. Division operation is therefore also order similar. The division operation splits the set c in parts, the set of which admits a count. The count is a. 2.4.5 The Algebraic Structure of n Quasigroups of n Theorem 2.2. A subset s ⊂ n that contains all numbers of same einheit, and only numbers of same einheit is a group, under the addition operation. 12 Proof. Assume a, b ∈ s. The addition operation results in c. c has the same einheit as a and b. Therefore, c ∈ s. this holds ∀a, b ∈ s. Therefore a, b ∈ s =⇒ a + b ∈ s. Hence s is a magma. ∀a, c, we have b = c − a. Note that although the subtraction operation requires the presence of an inverse, we do not require the inverse to be present in s itself. s is therefore a quasigroup. 0 is the element which is the neutral to addition, and 0 ∈ s.Therefore s is a loop. Associativity of addition holds. Hence s is a group. This theorem can be trivially extended to : Theorem 2.3. A subset s ∈ n which contains all numbers of a particular ein- heit, and all it's inverses, and only the mentioned numbers, is a group. Then we consider the segment length operation. The length segment op- eration in general is not associative, nor does it admit an unique definition of division. Therefore it does not admit a group-like structure. Construction of a Finite Group Given a, b, c ∈ s ⊂ n, we consider if s can be constructed in a group, based on the order properties. The addition operation automatically admits a group structure. The multiplication operation depends on the assignment of count. It can be trivially shown that : Theorem 2.4. If the subset s ⊂ n contains only positives, then it admits a group structure. If the subset contains only negatives, then assigning negative counts to multiplication admits a group structure. If s ⊂ n contains both positives and negatives, then under the usual multiplication scheme, it admits a group structure. Same applies for division operation. Now consider the transformation group containing the operations defined above. Trivial investigation shows: Theorem 2.5. The sets of operations addition, multiplication (division), re- spectively, and count assignment all admit a group structure. Obviously each of them are infinite groups. The composition is simply the convolution of two operations. Such groups are extremely simple in structure, and of less interest in this context. We next consider groups whose elements take the form `a, where ` is a operation, and a is a number. If ` is the addition operation, then the structures are similar to what is seen with the addition group already. However, interesting observations can be made if ` : ×. This groups contains a subgroup, which is constructed of non-prime multiples of natural einheits and their inverses. This subgroup is also a normal subgroup. A series of quotient groups to this is immediately generated. Each of them is also abelian. These groups however does not admit a soluable structure. Nonetheless, we consider the order properties. 13 Theorem 2.6. Each such normal subgroup p ⊳ n is n orderable, then they admit an order which is invariant under npn−1∀n ∈ n The proof is trivial. Further investigation shows p does not contain any subgroup. 2.5 Generation of Numbers and Different Einheits Armed with the definitions of numbers and usual operations, the next section is dedicated to the original question. 2.5.1 Generation Assuming two non-neighboring elements are tagged, of extreme interest is to find a method to tag the elements in between the tagged ones. For that, the set inbetween the two tagged elements is split, at will, and split sequence is assigned with a count. Therefore, there are two steps inherent to the process. The splitting opera- tion and the count assignment operation, from theorem 3.5 assumes a structure of a finite group. Formally, assume a chain a1 ∈ a2 ∈ a3 ∈ ... ∈ an. Assume further that b1, b2 ∈ an are tagged,and they are NOT neighboring elements. Then, we want to tag all elements in a1. Trivially, and using the discussions above, it is clear that sets may be tagged independent to each other. Uniqueness Requirements We consider the uniqueness of each tagging. Clearly, each ai has a different einheit. However, the tagging of objects be- tween ba, bb ∈ ai is definitely different than ba, bb ∈ aj. Therefore ba, bb ∈ ai must be different numbers than ba, bb ∈ aj. This difference is created by differ- ent einheits of aiand aj. Assume b, c ∈ ai are tagged. ai has einheit ui. Splitting b − c results in einheit uj. Then db < d < c has einheit ui + uj. 2.5.2 Construction of Finite Group and Consequences We consider the division (splitting) operations that take the form × 1 is a number with a natural, positive, einheit. p , where p It has been shown in the previous discussion that if p is not a prime number, then the set of the said operations form a normal subgroup, and there exists quotient groups to this. Therefore, the tagging algorithm can take the advantage of creating a quo- tient group, which still preserves the ordering, the einheit, yet accommodates for newer symbols than the original group. That is, the measure of b − c is changed, and is a natural multiple of of the original value. If the original tagging had a natural count, is not however preserved. Therefore, a new natural count can be 14 assigned with elements, making place inserting new symbols. One can trivially show that: Theorem 2.7. (An operation from) The quotient group preserves the order. If a triple is considered, with the initial elements that serve as the boundary, and the set whose elements are to be ordered in between, then this triple is also preserved. Since there exists normal subgroups, and the elements ai-s of the subset chain can be accessed independently to each other, the splitting operation, as the tagging also, can be done independent to each other. The result can be uniquely determined if the respective einheit is known. Ordering of numbers having composite einheit in form u1 + u2 + ... + un is done as follows. Rewrite the two comparable numbers as s1u1 + s2u2 + ...snun, such that v : u1 > u2 > ... > un holds. Then let ui be the first einheit in v, where the corresponding si is different in the two numbers. Order the s1, that is the order of the two numbers 3 Solution to the Original Problem and Applica- tion 3.1 Solution of the McDougal Problem Now, the McDougal cave problem admits a trivial solution. Attach a different einheit to each cave and chamber and tunnel. Require the einheit corresponding to one object that is included in another be lesser than that of later. If an object, inbetween two is to be tagged, while the both of them are already tagged, then tag them with a number generated from that of the former two. The application of this system finds use in controlling the execution of any computer simulation, and in database manipulation. Indeed it is possible to tag a sequence of similar objects in McDougal cave as 21,22,23,...35... etc, but the change of the second digit from right may make the fact less obvious that the ob- jects are actually the same. Therefore proposed tagging is 2⊕1,2⊕2,...,2⊕267,... etc, where ⊕ designates the addition of different einheits, and the tagging implies that all of them belongs to the zwischenraum between 2 and 3, (with einheit larger than the objects in consideration). If there are n such object, then the tag for the m-th one can be generated from 2, 3, {n, m} using the method illustrated above. If, a new object between two tagged one is to be inserted, then, the problem is a bit complex, because m is a natural count. Therefore, a re-tagging is necessary. However, a quotient group sorts the issue - for example, you can insert an object in the second place, in the sequence, 2⊕1, 2⊕2,3⊕1,3⊕3, by re-tagging the first and second, to 2⊕1 and 2⊕3, where the second tagging is an operation in a quotient group of the group in which the first tagging belongs. The quotient group preserved the ordering, and the terminal tags. This greatly simplifies the process for block based heuristic simulation algorithms. 15 3.2 Sorting We consider the sorting problem. Here, sorting is done heuristically, and an element from the unsorted sequence is inserted in the sorted sequence, in it's place. The algorithm measures the rate of change of values as it progress along the sequence starting from a particular boundary. Then it predicts a location where a new, known element can be inserted. If the insertion does not disrupt the order, then insertion is followed by algorithm termination. Otherwise, taking the predicted location as a boundary, the algorithm repeats itself. Infinity loops are not avoidable. In case of an infinity loop, the algorithm fails. This algorithm, is works at the worst case, is of complexity O(n). References: [1]: Gonsor, H. An introduction to the theory of Surreal Numbers, Cambridge University Press, 1986 16
1701.03308
2
1701
2017-09-06T09:47:15
Sampling and Reconstruction Using Bloom Filters
[ "cs.DS" ]
In this paper, we address the problem of sampling from a set and reconstructing a set stored as a Bloom filter. To the best of our knowledge our work is the first to address this question. We introduce a novel hierarchical data structure called BloomSampleTree that helps us design efficient algorithms to extract an almost uniform sample from the set stored in a Bloom filter and also allows us to reconstruct the set efficiently. In the case where the hash functions used in the Bloom filter implementation are partially invertible, in the sense that it is easy to calculate the set of elements that map to a particular hash value, we propose a second, more space-efficient method called HashInvert for the reconstruction. We study the properties of these two methods both analytically as well as experimentally. We provide bounds on run times for both methods and sample quality for the BloomSampleTree based algorithm, and show through an extensive experimental evaluation that our methods are efficient and effective.
cs.DS
cs
Sampling and Reconstruction Using Bloom Filters Neha Sengupta IIT-Delhi Amitabha Bagchi Srikanta Bedathur IIT-Delhi IBM-IRL [email protected] [email protected] [email protected] Maya Ramanath IIT-Delhi [email protected] Abstract In this paper, we address the problem of sampling from a set and reconstructing a set stored as a Bloom filter. To the best of our knowledge our work is the first to address this question. We introduce a novel hierarchical data structure called BloomSampleTree that helps us design efficient algorithms to extract an almost uniform sample from the set stored in a Bloom filter and also allows us to reconstruct the set efficiently. In the case where the hash functions used in the Bloom filter implementation are partially invertible, in the sense that it is easy to calculate the set of elements that map to a particular hash value, we propose a second, more space-efficient method called HashInvert for the reconstruction. We study the properties of these two methods both analytically as well as experimentally. We provide bounds on run times for both methods and sample quality for the BloomSampleTree based algorithm, and show through an extensive experimental evaluation that our methods are efficient and effective. 1 Introduction Bloom filters, introduced by Bloom in the 1970's [1], are space-efficient structures for the set- membership problem. They have found numerous applications in a diverse array of settings because of the tremendous advantages they offer in terms of space. Broder and Mitzenmacher surveyed a host of these applications in 2003 [2], and, since then, the usage of Bloom filters has grown and diversified. Typically, these applications rely on the set-membership query being answered correctly with good probability, and are able to deal with the drawback that with some probability a false positive will occur. However, one fundamental question has not yet been addressed: How do we sample an element from a set stored in a Bloom filter? A related question – How do we retrieve the set stored in the Bloom filter? – has also not been addressed. We believe addressing these two problems will open up the possibility of using Bloom filters in applications that need to store, retrieve and/or sample from a large number of sets. For example, storing and subsequently sampling from a large number of dynamic, online communities that form on social networks such as Twitter, Flickr, etc. ([3], [4], [5]), that could help advertisers determine where to target their products. Or storing and retrieving all call records associated with specific locations in crime-related investigations [6]. We note that other compact structures, such as sketches, have been used as compact storage structures from which samples can later be obtained [7, 8, 9]. However, a limitation of this approach is that the sketches that are proposed to be created are specifically for the problem of sampling and tend to be output sensitive in their design (and do not support reconstruction). Our work, on the other hand, shows how to draw samples as well as reconstruct sets from a widely-used generic synopsis structure, the Bloom filter, that is also useful for several other applications. Problem Statement. Formally speaking, if we are given a set S, drawn from a universe or name space U , that is stored in a Bloom filter B (referred to as the query Bloom filter ), if we denote by 1 S(B) those elements of U \ S that are false positives of B (i.e., the query "Is x ∈ S?" answered by B returns YES for all x ∈ S ∪ S(B)), then: 1. an algorithm that samples from B is one that returns an element chosen uniformly at random from S ∪ S(B), and, 2. an algorithm that reconstructs the set stored in B returns the set S ∪ S(B). Since Bloom filters hide information about the elements stored in them providing only (partially correct) answers to membership queries, the natural way of trying to sample from a set stored in a Bloom filter is to fire membership queries with different elements of the name space at the Bloom filter. Such a method, referred to as a Dictionary Attack is not scalable since its running time is linear in the size of the name space, which may be huge. Solution Overview. In this paper, we outline a method that approaches this task much more effi- ciently. Conceptually, we design a data structure, the BloomSampleTree, that organizes the names- pace as a binary search tree. That is, each node of the tree stores a subset of the namespace, but at each level of the tree, the union of these subsets yields the entire namespace. While the root of the tree, by itself, stores all the elements of the namespace, each leaf stores only a small subset of this namespace. Once this binary search tree is constructed, the key idea is to now locate only those leaves which potentially contain elements present in the given query Bloom filter B. This is done by intersecting B starting from the root of the search tree and working our way towards the leaves. Entire subtrees are pruned away because they yield empty intersections, thus eliminating large parts of the namespace. Once we identify the relevant leaves, we can efficiently sample or reconstruct the original set using the dictionary attack method explained above. Note that this search tree needs to be constructed only once and will be repeatedly used for different query Bloom filters. A drawback in this approach is that we are storing the entire namespace in the BloomSampleTree, even though only a small part of it may be actually occupied. Sparse occupancy of a namespace is a regular occurence, especially when we consider non-numeric keys such as strings, where the namespace is typically of the order of 264, but the actual occupancy is likely to be of the order of 230 (a little over 1 billion) or perhaps less. Therefore, it is space-inefficient to construct a tree for the entire namespace, when a large number of the nodes are going to be empty. In order to address this we present a dynamic version of the BloomSampleTree, we call it Pruned-BloomSampleTree which takes into account the occupancy and can dynamically change its size and structure as the occupancy changes. The BloomSampleTree-based algorithms we provide for sampling and reconstruction have one very important feature: they do not require the hash functions used by the Bloom filter to be invertible. Our method only needs to be able to use those hash functions and will work if we are given the implementation of the Bloom filter used to store the set. It is also important to note that we do not distinguish between true elements of the set stored in the Bloom filter and the false positives that are created in the process of insertion. We approach the Bloom filter as is without any prior knowledge of what has been inserted in it, and without any method of distinguishing true elements from false positives. In summary, our method is designed to work efficiently in a scenario where: i) the namespace is potentially large, even dynamic, ii) the no. of interesting subsets is large (in the millions or billions) and may continue to grow indefinitely, iii) we need to either sample from or reconstruct a subset(s) from the set of interesting subsets, stored in the form of Bloom filters (specifically, these are our query Bloom filters). We present our methods as an aid to the engineer who has chosen to use Bloom filters for a particular application and has optimised parameters to achieve a given level of accuracy (ie. ratio of true elements to all the elements that return a true answer to a membership query) and who has a way of dealing with false positives. (i) We introduce a novel data-structure called BloomSampleTree that can be used Contributions sample from a set stored in a Bloom filter as well as reconstruct that set. The BloomSampleTree takes into account the occupancy of the namespace and can change size as the occupancy changes, 2 (ii) We provide theoretical bounds on the runtime and on the quality of samples generated by our BloomSampleTree-based algorithm, show them to be near-uniform. (iii) We show through exten- sive evaluations that our BloomSampleTree-based algorithms are efficient and provide good quality samples. Organization In Section 2 we review the literature. We provide a brief background on Bloom filters and outline the framework in which our methods operate in Section 3. Section 4 outlines two baseline techniques for sampling from Bloom filters, along with a discussion on their limitations and the need for our BloomSampleTree method. The BloomSampleTree for sampling and reconstruction are described in detail in Sections 5 and 6. The results of our detailed experimental analysis are presented in Sections 7 and 8. 2 Related Work Bloom filters are one of the most widely used data structures for approximately answering set membership queries. Their compact storage and efficient querying through simple bit operators has made them valuable in many different settings. A thorough survey of Bloom filters and their applications are available in [2, 10]. Despite their widespread use, we are not aware of any work that systematically addresses the problems of generating provably uniform samples using Bloom filters and reconstruct the original set at a given level of accuracy in an efficient way. The problem of identifying at least one true positive from the Bloom filter has been considered in an adverserial setting to study how resilient the Bloom filters are for dictionary-based attacks [11, 12]. Given a Bloom filter, an adversary can mount an attack to obtain some elements of the original set by repeatedly posing queries on the Bloom filter – potentially obtaining a large number of false positives, but also some true positive elements. In our work, we do not operate in an adversarial setting–we assume complete knowledge of the domain of values represented by the Bloom filter and the hash functions used. Given an accuracy level, our aim is to efficiently generate provably uniform random samples from the original set as well as to reconstruct the set as per the accuracy requirements. We systematically solve these problems and back up our solutions with detailed analysis of time complexity and accuracy. Sketches for Handling Large Datasets Bloom filters belong to a general class of approximation datastructures called sketches or data synopses, which compactly represent massive volumes of data while preserving some vital properties of the data needed for further analysis [13]. Some of the sketches used frequently in databases community include histograms, wavelets, samples, frequency and distinct-value based sketches, and so on. However, most of these synopses datastructures are used under the assumption that the underly- ing database is always accessible (e.g., in the case of histograms and samples) or not required (e.g., streaming scenarios). Reconstructing the underlying set of data values at a given level of accuracy in an efficient manner is not their objective to begin with. Only recently, there have been some results which show how sketches can be used for generating samples, called Lp-samplers [8, 9] which generalize earlier work on inverse sampling [7]. In these, the goal is to maintain a synopses structure for a stream of updates (i.e., addition and deletion of counts) over a given domain of size M , such that at any time it is possible to sample with high accuracy the elements in probability proportional to their number of occurrances. Unlike these techniques, our approaches are not focused on streaming setting, and are not de- signed for specific forms of sampling. The proposed BloomSampleTree approach can be used to generate uniform samples from Bloom filters, a widely-used and generic synopsis structure. In this paper we present the BloomSampleTree that comprises a com- Trees and Bloom filters plete binary tree with Bloom filters stored in every node for the purposes of sampling and recon- struction. Yoon et. al. [14] also propose a structure that comprises a complete d-ary tree with Bloom 3 filters at every node to address the multiset membership problem. Similar in flavor to Yoon et. al.'s structure is Bloofi proposed by Crainiceanu and Lemire who also address the multiset membership problem by representing each set as a Bloom filter stored at a leaf of a tree, and building the tree by combining these Bloom filters hierarchically [15]. While the flavour of both these structures is similar to our BloomSampleTree but their concern is the problem of multiset membership testing and so the principle on which their trees are built is completely different from the principle on which we build our tree and the contents of the Bloom filters stored at each node both bear no relationship to what we store in each node. Another work that combines Bloom filters and trees is by Athanassoulis and Ailamaki [16] where the authors modify B+-trees by placing Bloom filters at their leaves to create approximate tree indexes that seek to exploit data ordering to improve storage performance. Their structure is completely different from ours in intent and design. 3 Preliminaries In this section, we briefly provide the necessary background in Bloom filters, and subsequently describe the framework which our methods operate in. 3.1 Bloom Filters A Bloom filter is a probabilistic data structure used to space-efficiently store the elements of a set. It comprises a bit array of m bits, along with k independent hash functions, h1 . . . hk. An empty set is represented by a Bloom filter each of whose bits is 0. For each element x in a non-empty set, the k array positions indicated by h1(x) . . . hk(x) are set to 1. A Bloom filter supports membership queries, i.e. a Bloom filter B(S) storing a set S can answer queries of the form "is x ∈ S" for any x, with a false positive probability that depends on the number of bits in B(S) and S. x is hashed using each of the k hash functions to obtain k array positions. If the bit at each of these positions is set, then the result is positive. Since these bits could have been set due to the insertion of other elements, the probability of a false positive is non-zero and evaluates to ≈ (1 − e(−kn/m))k. A Bloom filter is incapable of false negatives. Other than the membership query, the operation of union and intersection on a pair of Bloom filters is also supported and can be implemented using bitwise OR and AN D operations respectively. If B(A), B(B), and B(A∪ B) use the same m, the same set of hash functions, and are over the same namespace of values then, B(A ∪ B) = B(A) ∪ B(B). Also, if B(A), B(B), and B(A ∩ B) use the same m and the same set of hash functions, then B(A ∩ B) = B(A) ∩ B(B), with probability (1 − 1 m )k2A−A∩BB−A∩B [17]. For two fixed, disjoint sets S1, S2 ⊂ U , each represented by Bloom filters of m bits and hash functions h, the false set overlap predicate F SO∩(S1, S2, h) is true if B(S1)∩B(S2) (cid:54)= φ even though S1 ∩ S2 = φ. A false set overlap of S1 and S2 by Bloom filter intersection of B(S1) and B(S2) is reported with probability [18], (cid:18) (cid:19)k2S1S2 P[F SO∩h] = 1 − 1 − 1 m (1) 3.2 Framework Our methods operate on a database D = {Xi i = 1, . . .} of Xi = {xjxj ∈ M} which are subsets of elements drawn from a namespace M of size M . Instead of operating on the D directly,we assume we are only given with a compact approximation ¯D where each Xi is represented by a Bloom filter B(Xi), for a given length of the filter (in bits), m, and the set of hash functions used in its construction, H. Such collections of subsets of elements are commonly seen in many application settings including graph databases – to represent the adjacency list of each vertex, information retrieval – to represent the list of documents where a keyword occurs, etc. 4 The first task we are interested in tackling in this setting is that of generating a random sample given ¯D. Specifically, given information about other parameters used in building this approximation viz., m, H and M, we would like to obtain a provably uniform random sample from a given X ∈ D - the original database. Since we are operating on an approximate representation, it is also expected that a fixed amount of inaccuracy (measured as the probability of sampling an element which is not in X) is tolerable and is specified as an input to the system to begin with. It should be noted that this inaccuracy is naturally linked to the probability of false positives in Bloom filters, and thus for a given level of inaccuracy (or accuracy) the Bloom filters used in D have to be designed. The second task, a natural extension of the above, is to reconstruct the original entry X in the database with high accuracy. 4 Sampling and Reconstruction We describe two approaches to sample an element from a set and reconstruct a set stored as a Bloom filter. The first of these is a simple "dictionary attack"-based method (DictionaryAttack). The second uses the weakly invertible property of certain types of hash functions to do sampling (HashInvert). While both methods can be used to sample from as well as reconstruct a Bloom filter, the DictionaryAttack method suffers from high runtime inefficiencies, while the HashInvert method provides no guarantees on the quality of the sample. We compare our BloomSampleTree algorithm against these two baselines and highlight the advantages and disadvantages of each approach in detail in Section 7. DictionaryAttack: Sampling with Membership Queries The DictionaryAttack algorithm relies on reservoir sampling to guarantee a uniform sample. This is equivalent to reconstructing the input set and sampling an element from it. It proceeds as follows. A membership query is fired on the input set for each element in the namespace. When a positive is reported for an element, that element is retained as the sample with diminishing probability proportional to the size of the set reconstructed so far [19]. In particular, if n(cid:48) is the number of positives reported until now, then the (n(cid:48) + 1)th positive is retained as the sample with probability 1/(n(cid:48) + 1). Clearly, the complexity of this algorithm is O(M ), where M is the size of the namespace. Note that it is straightforward to use this method to reconstruct the original set. HashInvert - Sampling with Invertible Hash Functions This method assumes that the hash functions are weakly invertible. A hash function h is weakly invertible if given the value of h(x), one can find a set of values S such that ∀y ∈ S, h(y) = h(x). An example of a weakly invertible hash function is h(x) = (ax + b)%c, where a, b, and c are constants. Knowing the namespace M , it is straightforward to find a set of elements that all hash to h(x). Given a Bloom filter B, it exploits the weak invertibility of the hash functions to invert a randomly sampled SET bit s into k candidate sets P1(s), P2(s) . . . Pk(s), each obtained using a different hash function. The k candidate sets are subsequently pruned using the membership queries on the Bloom filter to obtain 1(s), P (cid:48) P (cid:48) i (s) is the final sample returned. k(s). A value sampled uniformly at random from (cid:83)k 2(s) . . . , P (cid:48) i=1 P (cid:48) Analysis When sampling from the obtained candidate sets is done using a method such as reservoir sampling, the HashInvert method occupies no extra space. Sampling a set bit takes O(m) time, where m is the size of the Bloom filter. Once a set bit is (cid:1) time. The overall time taken for sampling is chosen, inversion using a hash function takes O(cid:0) M O(cid:0)m + k M m (cid:1). m Note that, in contrast to DictionaryAttack, which provides uniformly random samples, no bounds are given regarding the quality of the samples in the case of HashInvert. However, the algorithm can be used to reconstruct the original set by exhaustively running the HashInvert algorithm on all set bits of the Bloom filter. 5 A simple trick gives us more benefits from the HashInvert algorithm. If the Bloom filter is dense, then the number of UNSET bits (0-bits) are potentially less than the number of SET bits. Therefore, instead of inverting the set bits, we can invert the unset bits. This results in a set of elements which are not present in the original set. Therefore, the original set can be recovered from a set difference operation. 5 Bloom Sample Tree In this section we define the BloomSampleTree data structure that will help us sample from and reconstruct a set stored in a Bloom filter. The BloomSampleTree basically organises the entire namespace. Note that the BloomSampleTree is built once and is then used repeatedly to sample from any given query Bloom filter B. 5.1 Definition The BloomSampleTree is a complete binary tree, denoted as T , with log M/M⊥ levels, where M⊥ is a threshold whose choice we discuss later in this section. Every node in the BloomSampleTree has a Bloom filter that stores a subset of the namespace. Every level of the tree contains the entire namespace partitioned uniformly amongst the nodes of that level. Hierarchically speaking the organisation is laminar in the sense that the union of the subsets of the namespace stored in two sibling nodes gives us the set stored in their parent node. All the Bloom filters used in the BloomSampleTree have the same parameters – viz., m, the number of bits and, H, the set of hash functions, as the Bloom filters used for the sets we are sampling from (or trying to reconstruct). The reason for this is that we will be frequently intersecting the Bloom filter B of the set of interest with the Bloom filters Bi stored at various nodes in the BloomSampleTree. We now present a more formal definition. Definition 5.1. Given a namespace M of size M , the size of the Bloom filter m, a set of hash functions used for construction H of the form h : M → {0, 1, . . . , m − 1}, and an integer parameter M⊥ < M the BloomSampleTree, T (M, m, H, M⊥), is a collection of Bloom filters (cid:26) (cid:26) (cid:27) , (cid:27) . such that each of these Bloom filters uses a bit vector of size m and the hash functions H, and with the property that the Bloom filter Bi,j stores the elements Bi,j : 0 ≤ i ≤ log , 0 ≤ j < 2i M M⊥ (cid:96) : j · M 2i ≤ (cid:96) < (j + 1) · M 2i Note that, • The collection of Bloom filters forms a tree structure. Since the portion of the name space stored in Bi,j is partitioned equally amongst the nodes Bi+1,2j and Bi+1,2j+1, Bi,j is the parent of these two nodes in the tree. • The leaves of the tree all store sets of size M⊥. The namespace is not further subdivided. Figure 1 shows an example BloomSampleTree for a namespace of M = 16. Each node in the tree, except for the root, consist of Bloom filters of size m = 10 storing the range of elements depicted at the node. A set S = {4, 6}, stored as Bloom filter b is the query set that we need to sample from or reconstruct. Note that the Bloom filters in T are constructed with the same m and H as the Bloom filter b for set S. 6 Figure 1: A BloomSampleTree T with 3 levels and the query Bloom filter b representing the set S from which we want to sample 5.2 Pruned-BloomSampleTree As mentioned in the introduction, even though the namespace itself may be large, it is likely that only a small portion of it is occupied. Therefore, building a complete BloomSampleTree as explained in the previous section potentially wastes a huge amount of space. For example the real-world data set on which we experimented (see Section 8) is taken from Twitter and contains 7.2 million user ids distributed in a namespace of size 2.2 billion, i.e., the fraction of the namespace occupied is of the order of 10−1. Therefore, in practice we build the tree only for those portions of the namespace that are actually occupied; we call this condensed version the "Pruned-BloomSampleTree". This tree can dynamically change its structure, based on the change in the occupancy of the namespace. That is, if more of the namespace is assigned, then the tree potentially contains more nodes to reflect that. An overview of the algorithm to build this tree is as follows: Let M(cid:48) ⊆ M be the set of identifiers that are currently in use (M is the namespace, M(cid:48) = M(cid:48) ). • Initialise queue with Node(0, log M ). • Repeat until the queue is empty – Dequeue Node(a, b). /* b is the level, a is the offset within that level */ – Check if the range (a, a + 2b − 1) has a non-empty intersection with M(cid:48). 7 (0..15)(0..7)(8..15)(0..3)(4..7)(8..11)(12..15)1111101101111111111011011011001011011001011011101010000111000011100001Bloom Sample Tree bT (M = 16, m = 10, k = 2)Bloom filter bS = {4,6} ∗ If yes, then create Bb,a/2b and attach in the tree; insert elements from M(cid:48) in the range (a, b) in Bb,a/(2b); if b > log M⊥ then enqueue Node(a, b − 1), Node((a + 2b−1), b − 1). /* Create the Bloom filter corresponding to the subrange and grow the next level at this point */ ∗ If no, then do nothing. The above algorithm essentially goes down the tree building subtrees where required to accommo- date elements of M(cid:48) and ignoring subtrees corresponding to ranges that have no overlap with M(cid:48). Although this algorithm constructs the search tree when the M(cid:48) is known ahead of time, it is easy to see how to evolve the Pruned-BloomSampleTree when M(cid:48) grows (e.g. when new Twitter accounts are made)–either we need to insert this new element into already existing nodes in the tree, or we need to create a new node (and potentially its subtree). The time taken to build the Pruned-BloomSampleTree offline is proportional to the size of the final tree constructed multiplied by the time for the range query on M(cid:48). The time taken to update the tree is proportional to the height of the tree. 5.3 Sampling with the BloomSampleTree following recursive manner and relies on the pruning of the search space for performance gains. Given a query Bloom filter B to sample from, the algorithm proceeds from the root in the • At a given (non-leaf) node, compute the intersection of the Bloom filters stored in the left and right children of this node with b. If for both child nodes, the intersection is empty, then b does not contain any element belonging in the range associated with this node. Therefore the subtree rooted at this node is pruned from the search. • If intersection with only one child is non empty, then the search proceeds along that child • If intersection with both child nodes is non empty, then one of the child nodes is selected with probability directly proportional to the estimated number of elements in their corresponding intersections and the search proceeds along that child. Note that it is possible that the intersection was a false positive and this is discovered further down this subtree. In that case, the search then backtracks and proceeds along the other child node. The estimated number of elements in the intersection of two Bloom filters B1 and B2 is given by the following expression [20]: node. The other child node and the subtree rooted at it are pruned from the search. (cid:17) − ln(m) (cid:1) m − t∧×m−t1×t2 m−t1−t2+t∧ k × ln(cid:0)1 − 1 m (cid:16) S−1(t1, t2, t∧) = ln where t1 is the number of bits set in B1, t2 is the number of bits set in B2, m is the size of both Bloom filters, k is number of hash functions used in both, and t∧ is the number of bits set in the bitwise AND of B1 and B2. We recall that Equation (1) gives us the probability that this intersection is incorrectly estimated to be non-empty when the two sets stored in B1 and B2 are disjoint. We discuss this issue further in Section 5.6. • At a leaf node, every element in the range of the node is checked for membership in b. The sample at this leaf node is a value sampled uniformly at random from the set of values that satisfy the membership test of b. If none of the elements within this range satisfy the membership query it indicates that the search has reached this leaf node due to a (string of) false set overlap(s). In this case, the sample at this node is N U LL. This algorithm is called BSTSample, and a formal description is in Algorithm 1 Figure 2 shows a typical scenario that is encountered when sampling with the BloomSampleTree. The numbers to the side of the node indicate the order in which the nodes are traversed. As shown, the algorithm ultimately generates a sample from a leaf node by following one "true" path out of several false positive paths that may branch out at multiple places. Note, for example, that node 7, is ultimately determined to have led to several false positive paths discovered subsequently in 8 Figure 2: A typical scenario: Sampling with BloomSampleTree. A False Positive Path is chosen because of errors in determining the empty intersection. The Empty Intersection immediately results in the pruning of a subtree. Potential paths are left unexplored when there is choice of following either subtree. The True Path is the path actually taken by the algorithm to generate the sample. its subtree. In contrast, the whole subtree at node 4 is immediately pruned from the search space. Once the search reaches a leaf, a brute force search is conducted and there is no scope of a false set overlap due to Bloom filter intersection. Sampling multiple items The algorithm presented for sampling outputs a single sample. To sample multiple items we could run this algorithm multiple times. However, these multiple runs can be done together in one pass down the BloomSampleTree as we now explain. Given an integer r that is less than the size of the set stored, we send r independent search paths down the BloomSampleTree according to the algorithm BSTSample. These paths are sent down the BloomSampleTree in a single pass since all the paths arriving at any internal node or leaf can be processed at the node or leaf before we move on. If at a node we find that the Bloom filters at both its children intersect with the query Bloom filter, we take each of these r paths and, independently of the other paths choose one of the children at random as in BSTSample and send the path down to that child. This continues till each of the r paths reaches a leaf. Let us take a concrete example to illustrate this process: Assume we are given a query Bloom filter B and r = 3. We intersect B with the Bloom filters B1,1 and B1,2 stored in the left and right child of the root of BloomSampleTree and estimate the size of both intersections, let us say they are k1 and k2. Now throw three independent coins biased to come up heads with probability k1/(k1 + k2). Suppose two of these coins come up heads and one comes up tails, recursively call two instances of the multiple sampling method with B on B1,1 with r = 2 and on B1,2 with r = 1. It is easy to see that given the tree structure of the BloomSampleTree, such an extension of the algorithm BSTSample will, in general, perform better than r times the running time for the case when we ask for a single sample as output. Since all the paths behave like a single sampling path of BSTSample the guarantee on sample quality is maintained. Finally, if two or more paths happen to reach the same leaf we can sample at that leaf with or without replacement depending on whether the r samples are to be generated with or without replacement. 5.4 Summary of Analyses Given the BloomSampleTree structure and the algorithm for sampling, we briefly summarise the analyses we performed and the effect of the various parameters. Quality of samples The first question we answer is whether our method generates a uniformly random sample. The answer is that a uniformly random sample in indeed generated with high probability. We prove this property in Section 5.5 and show this empirically as well in Section 7.2. 9 Subtree not visited at allSubtree pruned from searchFalse Positive PathTrue PathEmpty IntersectionPotential Path(1 ... 10M)125463789111213102515373814 Accuracy Given that Bloom filters are approximate data structures, it is possible that the samples we generate do not actually belong to the original set (recall that a sample is generated by membership queries at a leaf). We quantify the accuracy of our samples as follows: acc = n n + (M − n) ∗ F P where n is the number of elements in the query set, M is the size of the namespace and F P is the probability of false positives in our Bloom filter implementation. The accuracy defined here simply computes the ratio of correct outcomes to all potential outcomes of the algorithm. Clearly the size of the Bloom filter m has an effect on accuracy and we can determine m based on the desired accuracy. We show the performance of our method for various values of accuracy in Section 7. Runtime analysis The runtime of the algorithm depends on the number of false paths it may follow. We analytically show the expected number of nodes visited in Section 5.5, given a Bloom- SampleTree. However, we also address a practical issue here with regard to runtime – the cost of performing intersections at a node as opposed to the cost of performing a number of membership queries. Note that it is possible that based on the hash function used, the cost of membership queries may be cheaper or more expensive than the cost of intersections. These two costs are directly related to the no. of elements stored at the leaf, M⊥ and the height of the BloomSampleTree is log M M⊥ . We tradeoff the costs as follows: If mcost is the cost of one membership query to a Bloom filter of size m with k hash functions, and icost is the cost of an intersection between a pair of bloom filters of size m, then, at a current node N , storing N⊥ values, we would like to determine whether it is better to perform membership queries over N or perform intersections until the leaf which is at most at level log N⊥ below N . If performing membership queries is preferred over traversing further down in the tree, we can truncate the tree such that N is the leaf of the tree. Hence, we determine M⊥ = max N⊥, such that N⊥ log N⊥ ≤ icost mcost . We empirically show the runtime costs throughout Section 7. Memory requirements The memory required to store the BloomSampleTree (which is con- structed only once and used repeatedly) depends on the size of the Bloom filter m and the number of levels in the tree, log M M⊥ . An interesting observation here is that, in our framework, there is no tradeoff between memory and accuracy or memory and runtime. The tradeoff is between accuracy and runtime, as explained in the previous paragraphs. Therefore, while we set the best possible m and log M M⊥ in order to optimize the runtime, the memory required may actually reduce for in- creased accuracy. The cause for this is that while we will need to use a larger Bloom filter in the BloomSampleTree for increased accuracy, we would potentially reduce the number of levels so as to reduce the intersection cost (as described in the previous paragraph). The effect of this is that we end up reducing the space used, while increasing accuracy, but also increasing the runtime. We discuss empirical results about this in more detail in Section 7.2. 5.5 Sample quality and running time The first question that arises is: what is the distribution of samples BSTSample produces? Our aim is to produce a uniform distribution from the set stored in the Bloom filter. We present a theoretical result that shows that the samples produced are near uniform. We first state the result and then discuss its implications. Proposition 5.2. Given a set S with S = n taken from a name space of size M , if we run BSTSample on S with a BloomSampleTree T (M, m, H, M⊥) such that H = k, define (m) = √ . Then the probability that the sampling algorithm finally samples from an L ⊆ S of size (cid:96) that is stored in a Bloom filter in a leaf of the BloomSampleTree lies between 2nk(log m+log log m+log n) m 10 (1−(m))· (cid:96) as m → ∞. n and (1+(m))· (cid:96) Proof. Probability of a bit being zero after insertion of n elements =(cid:0)1 − 1 n with probability at least 1− 4 (cid:1)n log m , as long as f (m) = 2·(m)·log M M⊥ → 0 . Let z be a random m variable indicating the number of zero bits. We have that, (cid:18) (cid:19)nk E(z) = m 1 − 1 m or that, E(z) = mp, where p =(cid:0)1 − 1 m (cid:1)nk √ . From Theorem 1 of [21], we have that P [z − mp > m] < 2e −2m2 2nk 2nk(log m+log log m+log n) We set  = nm log m = o(1). The estimated size of the population of a bloom filter is n = log (z/m) k log(1− 1 m ) , or n = c log(z/m), where . Also, from the above bound, we have that with probability at least 1 − 2/nm log m, m 1 c = . Then P[z − mp > m] < 2 k log(1− 1 m ) mp − m ≤ z ≤ mp + m. Therefore, with probability at least 1 − 2/nm log m, c log(p − ) ≤ n ≤ c log(p + ). For small values of , Substituing c = 1 k log(1− 1 m ) c (1 − ) log p ≤ n ≤ c(1 + ) log p. , and p = log(cid:0)1 − 1 (cid:1)nk , m with probability at least 1 − 2/nm log m. n (1 − ) ≤ n ≤ n (1 + ) , Returning to the setting of the BloomTree, let the number of elements in the intersection of the query Bloom filter with the root node be K. Similarly, let the number of elements in the intersection of the query Bloom filter with the left and right child of the root node be K1 and K−K1 respectively. In the sampling process, the probability of proceeding along the left child is directly proportional to the estimated number of elements in the intersection of the left child and the query Bloom filter. Let nl and nr be the estimated number of elements in the left and right child of the root node respectively. With probability at least 1 − 4/nm log m, P[selecting the left child] = nl nl + nr and i.e., (1 − ) K1 (1 + ) K1 + (1 + ) (K − K1) ≤ nl nl + nr nl nl + nr ≤ (1 + ) K1 (1 − ) K1 + (1 − ) (K − K1) (1 − ) K1 (1 + ) K ≤ nl nl + nr ≤ (1 + ) K1 (1 − ) K . , , 11 Now, for  < 1/2, (1 − )/(1 + ) ≥ 1 − 2 and (1 + )(1 − ) ≤ 1 + 4 and so (1 − 2) ≤ K1 K nl nl + nr ≤ (1 + 4) K1 K Consider now a given leaf node L of the Bloom Tree that contains a subset S(cid:48) of size (cid:96). The probability that an unbiased process of sampling should reach this leaf is (cid:96)/n. We now estimate what the probability of reaching this leaf is in the BloomTreeSample method. Consider the path down the BloomTree to the given leaf: L0, L1, . . . Llog M/M⊥ = L and the sequence of subsets of S stored in these nodes be S = S0, S1, . . . , Slog M/M⊥ = S(cid:48). Then we have that S1 S0 · S2 S1 ··· Slog M/M⊥ Slog M/M⊥−1 = (cid:96) n . Now, using the analysis done above, we can argue that for the choice of  above, the probability of moving from Si to Si+1 is at least (1− 2)Si+1/Si and at most (1 + 4)Si+1/Si with probability 1 − 4/nm log m. Repeating this argument over log M/M⊥ levels we get that ≤ P[BloomTreeSample reaches L], (1 − 2)log M/M⊥ · (cid:96) n and P[BloomTreeSample reaches L] ≤ (1 + 4)log M/M⊥ · (cid:96) n , with probability at least 1 − 4 log M/M⊥ nm log m ≥ 1 − 4 . n log m , where the last inequality applies because log M/M⊥ < m whenever f (m) → 0 as m → ∞. Since the set S can be present in at most n such leaf nodes, hence for any leaf node containing an element of S, the probability that BloomTreeSample reaches that leaf node is at least 1 − 4 log m . Now, we recall that (1 + x) < ex and for x < 1/2, e−x/2 < (1 − x) and so In other words, with high probability e− log M/M⊥ · (cid:96) n ≤ P[BloomTreeSample reaches L], and P[BloomTreeSample reaches L] ≤ e4 log M/M⊥ · (cid:96) n , for any leaf L that contains an element of S. Now, whenever  log M/M⊥ is o(1), i.e., it goes to 0 as m grows, both the bounds go to 1 proving the result. Discussion on sample quality We note that since f (m) grows faster than (m), the condition that f (m) → 0 as m → ∞ implies that (m) → 0 as m → ∞. The import of Proposition 5.2 is that the eventual leaf that BSTSample selects for sampling is chosen with probability that is very close to being proportional to the number of elements of the set S that belong to the segment of the name space stored in that leaf. In the absence of false positives, which happens in the limit as the size of the Bloom filter m → ∞, this would lead to perfectly uniform sampling. We now move on to analysing the running time of the algorithm. Clearly the running time depends on a number of factors. We provide a theoretical analysis of the number of nodes that BSTSample visits as it moves down the tree to reach a leaf from where it generates a sample. Clearly the lower bound for this number is the height of the tree, i.e., log M/M⊥. We are not able to match 12 this lower bound but we are able to control the number of extra nodes visited and give a result which can guide us on how to choose our system's parameters to ensure a good asymptotic running time. We show the following result: Proposition 5.3. The expected number of BloomSampleTree nodes visited by the algorithm BSTSample when sampling from a set of size n using a BloomSampleTree T (M, m, H, M⊥) where H = k is (cid:18) O log M M⊥ + M k2n m (cid:19) . of Proposition 5.3. The path BloomTreeSample takes down to the leaf node from which it generates a sample has length equal to the height of the tree, i.e., log(M/M⊥). Along this way, there are many branches that are caused by false set overlaps, i.e., the intersection Bloom filter has at least k bits set but no element of the name space has all k of its bits set in this Bloom filter. These branches need to be followed since it is not possible to distinguish them from the branch that takes us to genuine true or false positives of the set stored in the Bloom filter that we are sampling from. In order to estimate the number of nodes visited over and above the log(M/M⊥) in the true path, we need to estimate how many such false set overlap nodes we visit. We proceed by showing that below a certain depth in the BloomTree a false set overlap branch leads to a constant number of false set overlap nodes being visited below it. Hence, below that depth the number of extra nodes being visited is just a constant factor more than the necessary nodes being visited along the true path. Above that level, however, we cannot make any such claim so we just assume we visit every node. Formally, we proceed by making the following claim: Claim 5.4. Given a node u of depth d in a BloomTree T in which M⊥ names are stored at every leaf, and a query set S such that S ∩ M [u] = ∅ where M [u] denotes the subset of the namespace M that is represented in the subtree of T rooted at u, if the probability that the intersection of two Bloom filters of size m containing S and M [u], i.e., the quantity (cid:18) (cid:19)k2nM [u] , αS(d) = 1 − 1 − 1 m is at most 1/2, and if L(d) is the number of nodes that algorithm BloomTreeSample visits in the subtree of u conditioned on the event that it reaches u, then E(L(d)) = αS(d) 1 − 2αS(d) . Proof. The proof of the claim follows by noting that if αS(d) = 1 − x, then αS(d − 1) = 1 − √ x, since the number of names stored in any node of a child is exactly half of those stored by its parent in the BloomTree. Noting further that it is only if the sampling algorithm finds an overlap at u that it goes into the subtrees of u's children, we get Taking expectations repeatedly we get E(L(d)) = αS(d) [1 + 2L(d − 1)] , 2 ) + 4(1 − x)(1 − x summed till the leaf level, where x = 1 − αS(d). Since x < 1, 1 − √ E[L(d)] = (1 − x) + 2(1 − x)(1 − x 1 1 1 4 ) . . . , 2 )(1 − x x < 1 − x, which allows us to say that E[L(d)] = 1 2 log(M/M⊥)−d(cid:88) i=1 (2αS(d))i, from where the result follows whenever αS(d) < 1/2. Note that this argument is basically the same as saying that the sampling algorithms visits to nodes below a level d for which αS(d) < 1/2 is dominated by a subcritical branching process, which goes extinct with probability 1 and yields 1/(1 − µ) nodes in expectation, where µ is the mean of the progeny distribution (c.f. [22]) 13 Noting that since M [u] = M/2d whenever the depth of u is d, the condition that αS(d) < 1/2 is satisfied whenever d > d∗ = log (cid:18) M k2n (cid:19) m ln 2 , and that the BloomTree up to d∗ levels contains 2d∗+1 − 1 nodes, we get the result. Discussion on running time Looking at the result we note that the ratio of name space to Bloom filter size is a critical element in the number of nodes visited, i.e., raising the number of bits in the Bloom filter will benefit the running time (at least up to the point where the second term in the running time analysis continues to dominate the first term). The number of hash functions used and the size of the set being sampled from are also correlated with the running time, which follows intuition. 5.6 Determining the empty intersection The BloomSampleTree data structure and the algorithm for sampling are both straightforward to implement. However, one practical problem we encounter is that at each node that the algorithm visits, a set intersection needs to be performed that determines whether to prune that branch or not. Unfortunately, there is no reliable way to determine that the size of a set intersection is empty, since even a single set bit results in a non-zero size estimation. Therefore, we use thresholding to overcome this problem. That is, if the estimated size of the set intersection is below a particular threshold, we consider the intersection to be NULL. Note that this heuristic can potentially affect the theoretical guarantee offered in Proposition 5.2, but in effect it will not since the probability of making a wrong decision here, i.e. assuming a set if empty when in fact it is not, is very small if we choose the correct threshold. A wrong decision here implies that certain elements of the set are never presented as samples, but, as we see in Section 7.2, this does not happen in practice. 6 Reconstruction with BloomSampleTree A recursive traversal of the tree results in a reconstruction of the set. Given a Bloom filter B, if the intersection with B at a non-leaf node is empty, then the reconstructed set at this node is the empty set, and the subtree rooted at this node can be pruned from the search. However, if the intersection is not empty, then the search continues along the left and the right children and the final reconstructed set at this node is the UNION of the reconstructed sets obtained from the two child nodes. If the intersection with B at a leaf node is not empty, we conduct a brute force search on the range of this node as before. However, instead of sampling a value from the set of elements thus obtained, we return the set itself as the reconstructed set at this node. We note that the expected number of nodes of the BloomSampleTree visited by the reconstruction algorithm can be analysed in a manner similar to BloomTreeSample. This expected number will come to (cid:19)(cid:19) . (cid:18) (cid:18) n · O log M M⊥ + M⊥k2 m We note that extracting a single element of a set from the treelike structure of the BloomSampleTree would take log M/M⊥ and, in the worst case, assuming the different elements of the set are widely distributed in the name space, the worst case number of nodes visited for reconstruction will be n log M/M⊥ at least. Our algorithm is, unlike in the case of sampling, able to meet this lower bound exactly in an asymptotic sense. Also, since the second term above is directly proportional to k2 and M⊥ and inversely proportional to the size of the Bloom filters used, m, we can choose these parameters appropriately to minimize the time taken. 14 7 Experimental Evaluation with Static Namespace In this section, we describe several experiments that we conducted to determine the effectiveness In of our techniques for both sampling as well as reconstruction when the namespace is static. Section 8, we describe our experiments where only a fraction of the namespace is actually used. 7.1 Setup We experimented with both synthetic as well as real datasets. We made extensive use of synthetic datasets to generate controlled micro-benchmarks. We varied the namespace size (M ), from which the elements are drawn, between 105-107. We also varied the size of the sets (n) between 100 to 50, 000, and generated them either by uniformly sampling from the namespace or by forming random local clusters (details below). As we pointed out earlier in Section 5.4, the desired accuracy levels can be used to determine the size of the Bloom filter m to construct the BloomSampleTree. We varied the accuracy requirements between 0.5 – 1.0 and accordingly designed the Bloom filters. For simplicity of experiments we kept the number of hash functions to 3, although we experimented with different classes of hash functions viz., simple, Murmur3 and MD5. Table 1 summarizes the parameter choices used in our experiments. Unless mentioned explicitly, the default values of parameters mentioned in this table were used in our experimental evaluations. Generating clustered and uniform query sets We report results on two kinds of randomly generated query sets. Uniform sets are constructed by generating elements uniformly at random, without replacement, from a given range. The idea for generating clustered query sets comes from the observations in Web graphs where neighbour sets of vertices typically have their ids clustered around a few nodes [23]. To generate clustered query sets, n elements were iteratively sampled from the namespace using a pdf that is updated after each sample is drawn. Initially, the pdf begins as that of the uniform distribution. After a sample s is drawn, we identify x = max{ii < s, pdf (i) > 0} and y = min{ii > s, pdf (i) > 0} as the neighbors of s. We divide the pdf (s) equally into pdf (x) and pdf (y), and set pdf (s) = 0. To generate more aggressively clustered sets, one can subtract p% from the probability of each element and equally divide the accumulated probability into x and y. Here, p controls the degree of clustering. For our experiments, we have used p = 10. Algorithms Our baseline method is the brute-force dictionary attack (referred to as DA). Addi- tionally, for evaluating the performance of set reconstruction we use HashInvert (HI). Both these baselines are described in Section 4. These methods are compared against our BloomSampleTree (BST ) approach. Metrics and Methodology We report on the following: • Number of intersections and set membership operations: This is our main metric of interest. We compute the depth of BloomSampleTree and the size of the Bloom filters based on accuracy and the relative costs of intersection and membership operations, as discussed in Section 5.4. For uniform and clustered query sets, we report the average number of intersection and membership operations on Bloom filters over 10, 000 samples. • Average time taken: With the same setup as above, we report on the average time over • Memory: We analytically computed the overall size required by the BloomSampleTree based • Quality of uniform samples: We report the χ2-statistic for the samples generated. on the size of the Bloom filters used and the tree depth. 10, 000 samples. addition, we also show the empirically observed distribution of samples. 15 In 7.2 Sampling Experiments Figures 3 and 4 show the number of intersections and membership operations over uniformly random and clustered query sets respectively. The DA method always uses M membership operations and no intersection operations. On the other hand, BloomSampleTrees try to offset a large number of membership operations with few intersections of Bloom filters. Note that as the sampling accuracy increases, the size of Bloom filters, m, increases as well resulting in more expensive intersection operations. Runtime Performance Both intersection and membership operations become more expensive – intersections more so than membership operations – as the Bloom filter size increases. The Bloom filter size, in turn, is determined by the namespace size as well as the accuracy requirements. Thus, the overall efficiency of BloomSampleTree depends on careful balance of the number of these operations. Figure 5 shows the average time taken by BloomSampleTree and DA methods, for a namespace size of 10-million. As these plots show, BloomSampleTrees achieve improvements in efficiency over DA for a single sampling round. Another implementation choice which can significantly affect the performance numbers is that of hash functions. Figure 7 shows the time taken to generate samples with different hash function families. The Dictionary Attack suffers most when the cost of computing the hash function increases – for instance with MD5-based hash functions the performance goes down by almost an order of magnitude. On the other hand, the BloomSampleTree sampling procedure defers membership queries to lower levels of the tree, by which time most of the tree has already been pruned from the search. When using fast hash functions like Murmur3 or Simple, BloomSampleTree automatically leverages their efficiency to reduce the overall time taken. Memory requirement Finally, we turn our attention to the amount of memory footprint needed by each method. The memory requirements (in MBs) are shown in Tables 2 and 3 when the number of elements in the query set is n = 103. In the Tables 2 and 3, Depth is log M/M⊥ where M⊥ is computed as discussed in Section 5.4, and memory is analytically computed using m∗ number of nodes in the BloomSampleTree. The memory of the BloomSampleTree thus computed was further affirmed by empirical measurement during program execution. It is evident from this table that memory requirement might actually reduce with increasing accuracy. This is primarily because when the depth of the BloomSampleTree decreases, the total memory occupied reduces. This is in spite of increased Bloom filter sizes, since lower levels have much larger memory footprint than higher ones. Since memory can reduce with increasing accuracy, the overall trade-off is between accuracy and memory on one hand, and running time on the other. While the BloomSampleTree allows for very fast sampling, it requires small additional storage than the other methods described in this paper. Moreover, one does not need to store a BloomSampleTree for each possible query set. There is only one BloomSampleTree for a given size of namespace, Bloom filter size, and choice of hash functions. random variable Q =(cid:80)n Quality of Sampling We use the Pearson's chi-squared test, which we briefly describe here, to empirically validate the sample quality. We conduct T sampling rounds from a Bloom filter B storing a set S = (S1, S2, . . . Sn). Now, ∀i ∈ [1, n], let oi be the number of times element Si is sampled. Similarly, let ei be the expected number of times element Si should be sampled. Our null hypothesis, H0, is that the sampling is uniform, or restated, that ∀i ∈ [1, n], ei = T n . The goal of the chi-squared test would be to see if the null hypothesis should be rejected given the observations oi. We define a . Then Q follows a χ2 distribution with n− 1 degrees of freedom. Given an observation (o1, o2, . . . on), we compute the value of Q. Let this value be q. The p-value is defined as P (Q ≥ qH0). Clearly, smaller the p-value, higher is the value of q, indicating greater deviation from the expectation. In other words, a smaller p-value indicates that the observation has lesser support for H0. If the p-value falls below a threshold s, known as the significance level, then (oi−ei)2 i=1 ei 16 H0 is rejected, otherwise it is not. The significance level is typically set around 0.05. We set it to 0.08 and use T = 130× n, the recommended sample size for this significance level [24]. For M = 106, the p-values thus obtained are reported for sets of different sizes in Table 5. All of the entries in this table are > 0.08, and therefore the null hypothesis is not rejected in any case. For higher values of accuracy, it is clear that the distribution of the elements is close to the uniform distribution. Accuracy While the value of m was determined based on accuracy, we verified the accuracy obtained from the sampling process using the expression for measured accuracy in Table 1. For all cases, measured accuracy was found to be close to the expected value. Table 6 shows measured accuracy values for n = 1000. Creation Time: In Table 4, we measure the time taken to create the BloomSampleTree for different sizes of the namespace and desired accuracy. Note, for the case of M = 105, with increased accuracy from 0.5 to 0.6, the required value of m increases, resulting in a decreased depth of the BloomSampleTree (Section 5.4), and consequently lower creation time. For M = 107 and desired accuracy 0.9, creation takes < 2.5s. In the application scenarios the BloomSampleTree works with, the number of sets that must be constructed in Bloom filters is assumed to be massive, and changing Bloom filter parameters requires creating each of the sets in the database again which is prohibitively expensive, overshadowing the time taken to create the BloomSampleTree. 17 Algorithm 1: Sampling with BloomTrees 1 Algorithm BSTSample(bST :BloomSampleTree, b:Query Bloom filter ) 2 [s, e] ← bST.range; /* At a leaf, exhaustively check the interval of the leaf for membership in */ if bST is leaf then b S ← φ ; for i in (s, e) do if i ∈ b then 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 S ← S ∪ {i} ; end else end x ← uniformly sampled from S ; return x ; lFlag = EstimatedSize(bST.lef t ∩ b); rFlag = EstimatedSize(bST.right ∩ b); /* If no child intersects, we have reached here due to a false positive and should return N U LL if (not lFlag and not rFlag) then return N U LL ; else /* Randomly select one to proceed search along, with probability proportional to estimated number of elements z = uniform(0, 1); if z < lF lag/(lF lag + rF lag) then sample ← BSTSample(bST.lef t, b) ; /* In case no sample is found from that child, search along the if sample = N U LL then other child - Backtracking sample ← BSTSample(bST.right, b); else return sample; sample ← BSTSample(bST.right, b) ; if sample = N U LL then sample ← BSTSample(bST.lef t, b); return sample; end end */ */ */ Table 1: Parameters of our experiments Parameter Size of the namespace (M ) Size of the query set (n) Sampling accuracy(s) Hash families Range (Default value) 105 – 107 (107) 100 – 50, 000 (1000) 0.5 – 1.0 (0.9) Simple ((ax + b)%m), Mur- mur3, MD5 18 (a) M = 105 (b) M = 106 (c) M = 107 Figure 3: No. of intersections and set membership queries for uniformly random query sets. XXX- BST in the legend refers to the cardinality of the query sets. 19 0 5 10 150.50.60.70.80.91.0Membership(x103)100-BST1K-BST10K-BST50K-BST 990 1000 1010Sampling AccuracyDA 0 20Intersection 0 100.50.60.70.80.91.0100-BST1K-BST10K-BST50K-BST 990 1000 1010Membership(x103)Sampling AccuracyDA 0 10 20 30 40Intersection 0 100.50.60.70.80.91.0100-BST1K-BST10K-BST50K-BST 990 1000 1010Membership(x104)Sampling AccuracyDA 0 100 200 300 400Intersection (a) M = 105 (b) M = 106 (c) M = 107 Figure 4: No. of intersections and set membership queries for clustered query sets. XXX-BST in the legend refers to the cardinality of the query sets. 20 00.50.60.70.80.91.0100-BST1K-BST10K-BST50K-BST 990 1000 1010100-BST1K-BST10K-BST50K-BST 990 1000 1010Membership(x103)Sampling AccuracyDA 0 50Intersection 0 10 200.50.60.70.80.91.0100-BST1K-BST10K-BST50K-BST 990 1000 1010Membership(x103)Sampling AccuracyDA 0 50 100Intersection 0 10 200.50.60.70.80.91.0100-BST1K-BST10K-BST50K-BST 990 1000 1010Membership(x104)Sampling AccuracyDA 0 100 200 300 400 500Intersection (a) Uniformly random query set (b) Clustered query set Figure 5: Avg. time taken for sampling with M = 107 Accuracy m 0.5 0.6 0.7 0.8 0.9 1 28465 32808 38259 46000 60870 137230 Depth M⊥ Memory= m∗ #nodes 10 10 10 9 9 6 976 976 976 1953 1953 15625 3.467 3.997 2.326 2.706 3.7 1.03 Table 2: Various parameters settings in Bloom Sample Tree implementation for n = 103 and M = 106 (Memory in MBs) Accuracy m 0.5 0.6 0.7 0.8 0.9 1.0 63120 72475 84215 101090 132933 297485 Depth M⊥ Memory= m∗ #nodes 13 13 13 13 12 10 61.62 70.75 82.22 98.69 64.87 36.27 1220 1220 1220 1220 2441 9765 Table 3: Various parameters settings in Bloom Sample Tree implementation for n = 103 and M = 107 (Memory in MBs) 21 1.05.025.0125.0625.00.50.60.70.80.91.0Time (ms)Sampling Accuracy100-BST1K-BST10K-BST50K-BST100-DA1K-DA10K-DA50K-DA1.05.025.0125.0625.00.50.60.70.80.91.0Time (ms)Sampling Accuracy100-BST1K-BST10K-BST50K-BST100-DA1K-DA10K-DA50K-DA (a) Uniformly random query set (b) Clustered query set Figure 6: Avg. time taken for sampling with M = 106 Figure 7: Effect of different hash function families on performance 22 0.00.21.05.025.0125.0625.00.50.60.70.80.91.0Time (ms)Sampling Accuracy100-BST1K-BST10K-BST50K-BST100-DA1K-DA10K-DA50K-DA0.00.21.05.025.0125.0625.00.50.60.70.80.91.0Time (ms)Sampling Accuracy100-BST1K-BST10K-BST50K-BST100-DA1K-DA10K-DA50K-DA1.05.025.0125.0625.00.50.60.70.80.91.0Time (mS)Sampling AccuracyBST-MurmurDA-MurmurBST-MD5DA-MD5 a 0.5 0.6 0.7 0.8 0.9 M=105 M=106 M=107 m #Levels STime UTime m #Levels STime Utime m #Levels Stime Utime 12317 14334 16863 20494 27340 4 3 3 3 3 0.12 0.04 0.28 0.12 0.12 18.4 14.4 14.8 15.6 15.9 28464 32807 38258 46090 60869 6 6 6 5 5 0.96 0.68 0.64 0.72 0.56 156.5 161.7 165.2 158.9 163.4 63119 72474 84214 101088 132932 8 8 8 8 8 78.72 223.52 311 426.52 590.64 1603.8 1625 1616.3 1646.3 1720.2 Table 4: System and User Time taken (in mS) to create BloomSampleTree for different values of M and desired accuracy Accuracy / n 0.5 0.6 0.7 0.8 0.9 1.0 100 1 1 0.99 0.93 0.93 0.84 1K 10K 50K 0.78 0.99 0.92 0.88 0.63 0.15 0.12 0.49 0.47 0.75 0.48 0.64 0.52 0.75 0.87 0.51 0.28 0.43 Table 5: p-values for M = 106 7.3 Reconstruction Experiments The setup of the reconstruction experiments follow that of the sampling experiments only adding HashInvert as a baseline. Figures 9 and 10 show the number of intersections and set membership queries to reconstruct sets which are uniformly random and clustered, drawn from namespaces of size M = 106 and M = 107 respectively. For the number of intersections with sampling accuracy, we see a trend that is similar to the ones in the sampling experiments, and for the same reasons. One may note that the HashInvert procedure performs more membership queries than the BloomSampleTree, but fewer than the Dictionary Attack. Despite this, the overall cost for HashInvert is the most as can be seen in Figures 11 and 12, which show the time taken for reconstruction. The overall cost for HashInvert essentially depends on the number of set or reset bits in the Bloom filter. If the Bloom filter is extremely dense, then reconstructing with the help of only reset bits efficiently reconstructs the set, whereas if it is very sparse, then one can reconstruct using the set bits. However, HashInvert is inefficient if neither of these cases apply, as is evident from the line for 'HI-10K', which sets about 50% of the bits in the Bloom Filter. The cause for this is the fact that HashInvert iterates through an inverted set for each set or reset bit in the Bloom filter. Since some of these values may already have been checked, it does save some membership queries. However, given that the membership query is very fast for simple hash functions, this does not directly translate into smaller running times. Accuracy / M 105 0.522 0.692 0.710 0.823 0.921 0.970 0.5 0.6 0.7 0.8 0.9 1.0 106 0.497 0.621 0.691 0.793 0.907 0.997 107 0.535 0.591 0.696 0.810 0.906 0.948 Table 6: Measured Accuracies for Uniform query sets of size n = 103 23 (a) Uniformly Random Query Set (b) Clustered Query Set Figure 8: Avg. No. of operations in reconstructing for M = 105 8 Experiments with Real-world Data with Low-Occupancy Namespace So far we presented results for the settings when the namespace is a contiguous and fixed. Now we turn our attention to more practical settings where the size of the namespace we need to handle is only a small fraction of a much larger domain and potentially spread throughout it. 8.1 Setup total of 7.2 million user ids in this tweet set, but they are distributed in a namespace of(cid:2)0, 2 × 109(cid:3) Dataset We made use of a 34-day Twitter crawl consisting of 144 million tweets. There are a (a little over 2.2 billion). Varying the namespace fractions Note that even though there are only 7.2 million unique ids in our dataset, they could be distributed across the entire namespace of 2.2 billion. Suppose, for example, we built a BloomSampleTree with 256 leaves – that is, the range of 2.2 billion is effectively divided into 256 equal-sized ranges (of which some could be empty depending on the distribution of the unique ids). From this hypothetical BloomSampleTree, we construct namespaces of different namespace fractions as follows: 24 0 40.50.60.70.80.91.0Membership(x105)Precision100-BST1K-BST10K-BST50K-BSTHI-100HI-1KHI-10KHI-50KDA 0 10Intersection(x100) 0 30 60 90 1200.50.60.70.80.91.0Membership(x103)Precision100-BST1K-BST10K-BST50K-BSTHI-100HI-1KHI-10KHI-50KDA 0 100 200 300 400 500Intersection (a) Uniformly Random Query Set (b) Clustered Query Set Figure 9: Avg. No. of operations in reconstructing for M = 106 • Uniform Namespace: Following our example above, suppose we want to construct a names- pace of namespace fraction 0.2, we uniformly sample 52 of 256 leaves. This gives us a set of ranges, the union of which only occupy 0.2 fraction of the total namespace. • Clustered Namespace: Again, for a namespace fraction of 0.2, we need to sample 52 of 256 leaves, but in a clustered way. We use the same technique as explained in Section 7 (in that case, we were generating clustered query sets). We fixed the desired accuracy, as discussed in section 5.4, at 0.8. Therefore, our hypothetical BloomSampleTree has a depth of 7, with a Bloom filter size m = 1.2 × 106. Correspondingly, the pruned-BloomSampleTree has the same depth and Bloom filter size, but the number of nodes (and therefore the space occupancy) is much smaller. Query Bloom filters We identified 24, 000 unique hash tags that occurred at least 1, 000 times in our dataset. The sets of users tweeting a particular hashtag is used to construct a query Bloom filter. We therefore constructed 24,000 query Bloom filters. However, when experimenting with varying namespace fractions, we simply ignore ids which do not belong in the namespace currently under consideration and construct query Bloom filters without them. Metrics We report the following metrics. 25 0 5 10 150.50.60.70.80.91.0Membership(x105)Precision100-BST1K-BST10K-BST50K-BSTHI-100HI-1KHI-10KHI-50KDA 0 10 20 30 40Intersection(x100) 0 5 10 150.50.60.70.80.91.0Membership(x105)Precision100-BST1K-BST10K-BST50K-BSTHI-100HI-1KHI-10KHI-50KDA 0 10 20 30 40Intersection(x100) (a) Uniformly Random Query Set (b) Clustered Query Set Figure 10: Avg. No. of operations in reconstructing for M = 107 • Average Time taken. At each namespace fraction, we run 1,000 sampling rounds on ran- domly chosen query Bloom filters and report the average time taken to generate a sample. • Memory. The Pruned-BloomSampleTree occupies much less space than the full BloomSam- pleTree. We report on space usage at each namespace fraction. • Accuracy. While the value of m, the Bloom filter size, was based on a desired accuracy for the BloomSampleTree, the actual accuracy in a Pruned-BloomSampleTree is expected to be better, since only those elements which occupy the namespace are stored. We report this accuracy for various namespace fractions. 8.2 Sampling Experiments Average time taken Figure 13 shows the average time taken to generate samples from our query Bloom filters. At namespace fractions less than 0.1, the time taken is an order of magnitude smaller than at full namespace occupancy. It is also expected that the sampling time in case of the clustered namespace is smaller, since more leaves share common ancestors and there are far less paths in the BloomSampleTree for the sampling algorithm to follow. The Dictionary Attack requires 100 seconds on average for one sample to be drawn. This is natural since the size of the namespace is extremely large in this case. As a result, we have not included the result of DA in Figure 13 to ensure that the finer variations in the sampling time taken for random and clustered namespaces are clearly visible. 26 0 5 10 150.50.60.70.80.91.0Membership(x106)Precision100-BST1K-BST10K-BST50K-BSTHI-100HI-1KHI-10KHI-50KDA 0 30 60 90Intersection(x100) 0 5 10 150.50.60.70.80.91.0Membership(x106)Precision100-BST1K-BST10K-BST50K-BSTHI-100HI-1KHI-10KHI-50KDA 0 30 60 90Intersection(x100) (a) Uniform Random Query Set (b) Clustered Query Set Figure 11: Avg. time taken for reconstruction with M = 106 for uniformly random and clustered query sets. Memory Figure 14 shows the memory usage at varying namespace fractions. Note that, if we built the full BloomSampleTree for a namespace of 2.2 billion, the memory required would be approximately 36M B. In contrast, at a lower namespace fraction of 0.5, the memory usage of the BloomSampleTree is about 71% for the uniform case, and much lower at 21.7% for the clustered case. For the same reason as for sampling time, we expect the memory requirement of the BloomSampleTree to be smaller for a clustered namespace. Accuracy Figure 15 shows the sampling accuracy at various namespace fractions. Recall that we had optimized the BloomSampleTree for an accuracy of 0.8. But, with our Pruned-BloomSampleTree, we uniformly see a higher accuracy. Accuracy depends on the size of the namespace, as mentioned in section 5.4, and the size of the effective namespace at a lower namespace fraction is smaller. This shows that the BloomSampleTree is capable of producing higher accuracy results when the overall namespace is large but the actually occupied effective namespace is small. 9 Conclusions In this paper we described an efficient method to do sampling and reconstruction of sets stored in Bloom filters. In particular, we described the BloomSampleTree data structure and analyzed its 27 0 100 200 300 400 500 6000.50.60.70.80.91.0Time (ms)PrecisionBST-100BST-10KHI-100HI-10KDA-100DA-10K 0 100 200 300 400 500 6000.50.60.70.80.91.0Time (ms)PrecisionBST-100BST-10KHI-100HI-10KDA-100DA-10K (a) Uniform Random Query Set (b) Clustered Query Set Figure 12: Avg. time taken for reconstruction with M = 107 for uniformly random and clustered query sets. properties both theoretically and experimentally. We compared our technique to the brute force approach (Dictionary Attack) as well as HashInvert (useful when using invertible hash functions to reconstruct sets). An extensive evaluation of our algorithm in various settings demonstrated its wide applicability and significant advantages. References [1] B. H. Bloom, "Space/time trade-offs in hash coding with allowable errors," Commun. ACM, vol. 13, no. 7, pp. 422–426, 1970. [2] A. Z. Broder and M. Mitzenmacher, "Network applications of bloom filters: A survey," Internet Math., vol. 1, no. 4, pp. 485–509, 2003. [3] D. M. Romero, B. Meeder, and J. Kleinberg, "Differences in the mechanics of information diffusion across topics: idioms, political hashtags, and complex contagion on twitter," in WWW, 2011. [4] R. Ghosh and K. Lerman, "A framework for quantitative analysis of cascades on networks," in WSDM, 2011. 28 0 500 1000 1500 2000 25000.50.60.70.80.91.0Time (ms)PrecisionBST-100BST-10KHI-100HI-10KDA-100DA-10K 0 500 1000 1500 2000 25000.50.60.70.80.91.0Time (ms)PrecisionBST-100BST-10KHI-100HI-10KDA-100DA-10K Figure 13: Time taken to generate a uniform sample for varying namespace fractions Figure 14: Memory usage at varying namespace fractions Figure 15: Sampling accuracy at varying namespace fractions 29 -4 0 4 8 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9Time(s)Namespace FractionUniformClustered 0 4 8 12 16 20 24 28 32 36 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9Memory (MB)Namespace FractionUniformClustered 0.5 0.6 0.7 0.8 0.9 1 1.1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9AccuracyNamespace FractionUniformClustered [5] J. Cheng, L. A. Adamic, P. A. Dow, J. M. Kleinberg, and J. Leskovec, "Can cascades be predicted?" in WWW, 2014. [6] J. E. R. MacMillan, W. B. Glisson, and M. Bromby, "Investigating the increase in mobile phone evidence in criminal activities," in HICSS, 2013, pp. 4900–4909. [7] G. Cormode, S. Muthukrishnan, and I. Rozenbaum, "Summarizing and mining inverse distri- butions on data streams via dynamic inverse sampling," in VLDB, 2005. [8] M. Monemizadeh and D. P. Woodruff, "1-pass relative-error lp-sampling with applications," in SODA, 2010. [9] H. Jowhari, M. Saglam, and G. Tardos, "Tight bounds for lp samplers, finding duplicates in streams, and related problems," in PODS, 2011. [10] S. Tarkoma and C. E. Rothenberg and E. Lagerspetz, "Theory and Practice of Bloom Filters for Distributed Systems," IEEE Comm. Surveys and Tutorials, vol. 14, no. 1, 2012. [11] S. Bellovin and W. Cheswick, "Privacy-Enhanced Searches using Encrypted Bloom Filters," Columbia University, Tech. Rep. CUCS-034-07, 2007. [12] M. Naor and E. Yogev, "Bloom filters in adversarial environments," CoRR, vol. abs/1412.8356, 2014. [Online]. Available: http://arxiv.org/abs/1412.8356 [13] G. Cormode, M. N. Garofalakis, P. J. Haas, and C. Jermaine, "Synopses for massive data: Samples, histograms, wavelets, sketches," Found. Trends. Databases, vol. 4, no. 1-3, 2012. [14] M. Yoon, J. Son, and S.-H. Shin, "Bloom tree: A search tree based on Bloom filters for multiple- set membership testing," in Proc. 2014 IEEE Conference on Computer Communications (IN- FOCOM '14), 2014, pp. 1429–1437. [15] A. Crainiceanu and D. Lemire, "Bloofi: Multidimensional bloom filters," Inf. Syst., vol. 54, pp. 311–324, 2015. [16] M. Athanassoulis and A. Ailamaki, "Bf-tree: approximate tree indexing," Proc. VLDB, vol. 7, no. 14, pp. 1881–1892, October 2014. [17] D. Guo, J. Wu, H. Chen, Y. Yuan, and X. Luo, "The dynamic bloom filters," IEEE Trans. Knowl. Data Eng., vol. 22, no. 1, pp. 120–133, 2010. [18] M. C. Jeffrey and J. G. Steffan, "Understanding bloom filter intersection for lazy address-set disambiguation," in SPAA. New York, NY, USA: ACM, 2011, pp. 345–354. [19] J. Vitter, "Random sampling with a reservoir," ACM Trans. Math. Softw., vol. 11, no. 1, pp. 37–57, 1985. [Online]. Available: http://doi.acm.org/10.1145/3147.3165 [20] O. Papapetrou, W. Siberski, and W. Nejdl, "Cardinality estimation and dynamic length adap- tation for bloom filters," Dist. and Parallel Databases, vol. 28, no. 2-3, pp. 119–156, 2010. [Online]. Available: http://dx.doi.org/10.1007/s10619-010-7067-2 [21] M. Mitzenmacher, "Compressed bloom filters," in PODC. New York, NY, USA: ACM, 2001. [22] K. B. Athreya and P. E. Ney, Branching Processes. Springer, 1972. [23] P. Boldi, "Algorithmic gems in the data miner's cave," in Proc. Fun with Algorithms. Springer, 2014, pp. 1–15. [Online]. Available: http://dx.doi.org/10.1007/978-3-319-07890-8_1 [24] D. H. Stamatis, Six sigma and beyond: design for six sigma. CRC Press, 2002, vol. 6. 30
1305.0110
1
1305
2013-05-01T07:10:01
Combinatorial Pair Testing: Distinguishing Workers from Slackers
[ "cs.DS" ]
We formalize a problem we call combinatorial pair testing (CPT), which has applications to the identification of uncooperative or unproductive participants in pair programming, massively distributed computing, and crowdsourcing environments. We give efficient adaptive and nonadaptive CPT algorithms and we show that our methods use an optimal number of testing rounds to within constant factors. We also provide an empirical evaluation of some of our methods.
cs.DS
cs
Combinatorial Pair Testing: Distinguishing Workers from Slackers David Eppstein, Michael T. Goodrich, and Daniel S. Hirschberg Dept. of Computer Science, University of California, Irvine, CA 92697 USA 3 1 0 2 y a M 1 ] S D . s c [ 1 v 0 1 1 0 . 5 0 3 1 : v i X r a Abstract. We formalize a problem we call combinatorial pair testing (CPT), which has applications to the identification of uncooperative or unproductive participants in pair programming, massively distributed computing, and crowdsourcing environments. We give efficient adaptive and nonadaptive CPT algorithms and we show that our methods use an optimal number of testing rounds to within constant factors. We also provide an empirical evaluation of some of our methods. 1 Introduction Pair programming [19] is a software development paradigm where programmers are teamed in pairs and write software together using a single workstation. This paradigm is said to produce fewer software bugs and shorter programs than when programmers work alone [20]. Consequently, it is often used to teach software design in introductory programming courses [15], including courses at the authors' institution [13], the University of California, Irvine. This design paradigm presents an additional challenge, however, for evaluative purposes. Namely, if programmers are always working in pairs, how can a manager or instructor evaluate the performance of programmers as individuals? For instance, suppose 100 students enroll in an introductory programming course, among whom 80 are conscientious and 20 are lazy. We will call the conscientious students workers and the lazy ones slackers. In order to assign final grades to these students, the instructor would like to distinguish the workers from the slackers, but whenever she pairs a worker and a slacker on a project, the worker will do the assignment individually and the project will be completed successfully in spite of the slacker's laziness. Based on their performances, the instructor can only detect slackers when two slackers are paired together. Therefore, it would be useful for her to have systematic and effective strategies for pairing the students in order to distinguish workers from slackers. Motivated by this evaluation problem, we are interested in this paper in the design of efficient algorithms for generating testing schemes that can distinguish workers from slackers. We formulate such problems in a general framework, which we call combinatorial pair testing (CPT), and we consider a number of different assessment settings, such as whether all tests must be specified in advance or whether tests may be determined adaptively. This approach allows us to focus on natural performance characteristics of such problems and provides a general framework that unifies other diagnosis problems under the CPT heading. 1.1 Combinatorial Pair Testing Suppose we are given a set X of n individuals, n of whom are slackers and (1 − )n of whom are workers, where  may or may not be known in advance. A pairwise test is a function T (x, y) that takes as its arguments two members x and y of X, and produces as output a Boolean value, the result of a test performed for x and y based solely on the worker/slacker status of x and y. Naturally, although this framework allows for T to be any Boolean function, some Boolean functions will be more interesting than others. In this paper, we are particularly interested in the following type of test: -- Performance-based testing: In a performance-based test, we pair two individuals, x and y, and evaluate their output performance as a team. Thus, if both x and y are slackers, then T (x, y) = false, indicating that the two slackers, x and y, have been paired together and didn't complete the assigned project. If, on the other hand, x, y, or both, are workers, then T (x, y) = true, indicating that the project was completed. Performance-based testing is symmetric, so T (x, y) = T (y, x), and, indeed, this test is equivalent to a Boolean OR of x and y, where a slacker corresponds to a 0 and a worker corresponds to a 1. Moreover, by De Morgan's laws, any CPT algorithm that uses OR for T (x, y) can be easily modified to produce a CPT algorithm that uses AND for T (x, y). In combinatorial pair testing (CPT), only pairwise tests are allowed. The tests are organized in a sequence of rounds, in which each member of X may be tested at most once, so up to (cid:98)n/2(cid:99) pairwise tests can be performed in a single round. The choices made by CPT algorithms can be determined adaptively or non-adaptively and may be based on decisions that are either deterministic or randomized. In some cases we will also require some prior knowledge of the relative numbers of slackers and workers; for instance, using only performance-based tests, it is not possible to distinguish the case of there being only one slacker in X from that of there being none. Moreover, the efficiency of a given testing scheme may depend on assumptions about the number of slackers. Because our intended applications may involve sensitive information about individual misbe- havior, we may also desire CPT algorithms to have additional security or privacy guarantees. For instance, we may want our algorithms to be implementable in a way that allows an instructor to outsource the evaluation of the tests without revealing the input data [1]. Such an approach is common in privacy-preserving computations (e.g., see [21]). One additional security condition that we study in this paper, which appears to be novel, is that of a detection algorithm that is participant oblivious. A detection algorithm is participant oblivious if an individual cannot detect whether he has been identified by the evaluator as a worker or slacker based only on the pairings to which he has been assigned (without knowing the status of his or her partners or the outcome of their tests). A nonadaptive algorithm must be participant oblivious, but we show that some adaptive algorithms can also be participant oblivious. The advantage of a participant-oblivious algorithm is that it allows the evaluator to impose penalties to slackers or rewards to workers after the completion of the tests without tipping off a participant during the testing process that the evaluator might already know his or her status. 1.2 Prior Related Work Combinatorial pair testing is related to combinatorial group testing [6]. In combinatorial group testing, we are given a set, S, of n items, at most d of which are "defective." A test consists of selecting a subset, T , and determining whether T contains any defective items. Thus, combinatorial pair testing with performance-based testing is a restricted type of combinatorial group test in which every subset is a pair. There are many known results and applications for algorithmic problems in combinatorial group testing (e.g., see [6, 9, 11]), but we are not aware of any results for the case where every subset must be a pair and in which tests are issued in groups of O(n) independent tests. The closest previous analysis is by Hwang [12], who analyzes random size-k tests that are issued independently (that is, not in groups). Instead, insisting that every test to be a pair and that the pairs are issued in groups, as is required in combinatorial pair testing, goes against a standard approach in combinatorial group testing, according to which one performs tests to limit the defective items to a subset of size at most O(d log n) and then tests each such item individually. Combinatorial pair testing is also a generalization of processor fault diagnosis. In this problem, we are given a set of n processors, each of which can be either faulty or good. One processor can 2 check another, but the result of this check can only be trusted if the processor doing the testing is good. Often, in fact, one assumes that faulty processors deliberately misidentify the ones they are testing [5, 17]. Beigel et al. [2 -- 4] show that if the number of faulty processors is sufficiently far below n/2, then O(n) tests can be organized into a sequence of O(1) parallel testing rounds, where each processor tests at most one other in each round, so as to identify all faulty processors. Thus, processor fault diagnosis forms a type of combinatorial pair testing problem where the tests are based on queries and, in the case when faulty processors deliberately misidentify the ones they are testing, the Boolean function that determines the outcome of a test is the exclusive-or function. In addition, combinatorial pair testing can be applied to cheater detection in massively dis- tributed computations [10], such as SETI@home and distributed.net. These systems break very large computations into independent tasks, which are then sent out to be executed to participants of the system (typically by using the idle time of individual personal computers). The problem is that some participants cheat: instead of performing the requested tasks, they rig their computers to return false or partial results, often merely for the sake of appearing on a leader board of top participants. To deal with this problem, these distributed systems often will send out the same task to two participants at the same time, and if they both return the same answer, then the output is accepted and the participants are labeled as being honest (e.g., see [7]). One challenge is that when two answers don't agree, the system doesn't immediately know which participant(s) cheated. The problem of identifying all the honest participants (and, hence, all the cheaters) in a distributed computing environment can be formulated using the approach of this paper, and solved, using com- binatorial pair testing with performance-based tests based on the AND function. Previous work on cheater-detection in distributed computations does not take this approach, however, and is instead based on ad hoc solutions or reductions to processor fault diagnosis (e.g., see [7, 8, 10]). Along these same lines, combinatorial pair testing also has applications to crowdsourcing, where complex, independent tasks, such as labeling images, is farmed out to a large set of individuals to perform. One challenge in this case is that the group of individuals contains both "experts," who are competent and diligent with their work, and "spammers," whose performance is no better than a random oracle [14]. Combinatorial pair testing can be applied in this context to weed out the spammers, much in the same way as it applies to cheater detection for massively distributed computations. 1.3 Our Results Given a set, X, of n individuals such that n of them are slackers, we formalize the combinatorial pair testing (CPT) problem, and we present and analyze several efficient CPT algorithms for identifying the slackers in X. For the adaptive case, we give an algorithm that uses O(1/) testing rounds, and we show this to be optimal to within constant factors. Moreover, we show that our algorithm is participant oblivious and we extend our algorithm to work in O(1/) testing rounds even if we don't know the value of  in advance. We also give both deterministic and randomized nonadaptive CPT algorithms, and we show that the performance of these algorithms is optimal to within constant factors. For example, our randomized nonadaptive CPT algorithm uses O((1/) log n) testing rounds and succeeds in identifying all slackers with high probability. Our analysis of this algorithm is based on an extension to the coupon collectors problem, which we call the coupon packet collectors problem. In addition, we give an empirical study of our randomized CPT algorithm that provides experimental bounds for the number of tests needed to identify various percentages of the slackers in X. 3 2 Adaptive Algorithms In this section, we describe an adaptive participant-oblivious algorithm for identifying all the slack- ers in a performance-based testing problem. 2.1 The Two-Phase Algorithm Assume that we know there are n slackers. In phase one, we perform the following computation: -- Phase One: We group the individuals into (cid:98)n/2(cid:99) "bins" of size at most (cid:100)2/(cid:101) each. We then do (cid:100)2/(cid:101) "round-robin" rounds of testing to compare all pairs of items in the same bin as each other, across all bins in parallel. This completes phase one, and gives us the following. Lemma 1. After phase one completes, we will have identified all the slackers in each bin that has at least 2 slackers. Proof: If a bin contains 0 or 1 slackers, then each pairing of two individuals in that bin will contain a worker. Thus, every test for that bin has the same outcome (true). If, on the other hand, a bin contains 2 or more slackers, then each slacker in that bin will eventually be paired with another slacker; hence, we discover each slacker in that bin. More importantly, we also have the following. Lemma 2. After phase one completes, we will have identified at least (cid:100)n/2(cid:101) slackers. Proof: By the previous lemma, a slacker can go undiscovered only if he is the sole slacker assigned to a given bin. Since there are (cid:98)n/2(cid:99) bins, then, by a generalized pigeonhole argument, there has to be at least n−(cid:98)n/2(cid:99) = (cid:100)n/2(cid:101) slackers that are assigned to bins that each contain at least two slackers. Given that we now have identified at least (cid:100)n/2(cid:101) slackers, in phase two we perform the following computation. -- Phase Two: We choose (cid:100)n/2(cid:101) known slackers and assign one of them to each bin randomly. We assign the remaining individuals to bins, while keeping the bins to be of size at most (cid:100)2/(cid:101). Moreover, we choose these assignments uniformly at random, subject to the rule that each bin contains a slacker and that no two individuals who were paired in round one are assigned to the same bin as each other. We then do (cid:100)2/(cid:101) "round-robin" rounds of testing to compare all pairs of items in the same bin as each other, across all bins in parallel. This completes phase two. From the perspective of any individual, their bin assignment is done at random, with every bin being equally likely, and the people they are paired with are equally likely to come from any other bin from phase one. Moreover, the only nonadaptive step is the assignment of known slackers to bins in phase two, which is done via a random permutation, similar to how elements not known to be slackers are assigned. Thus, so long as individuals in our group do not collude, this algorithm is participant oblivious. Note, in addition, that any bin that now contains a previously undiscovered slacker, will necessarily contain at least two slackers. Thus, by Lemma 1, we will discover this (and all other) remaining slackers in phase two. 4 Theorem 1. Given a set, X, of n workers and slackers, such that n of the individuals in X are known to be slackers, we can identify all the slackers in X in O(1/) rounds of disjoint pairwise tests, in a participant-oblivious adaptive fashion. This bound is optimal, to within constant factors, as the following theorem establishes. Theorem 2. Given a set, X, of n workers and slackers, such that n of the individuals in X are slackers, then identifying all the slackers in X (either deterministically in the worst case or randomly with success probability ≥ 1/2) requires at least Ω(1/) rounds of disjoint pairwise tests. Proof: We consider the randomized case first, and we assume a randomized input distribution in which all permutations of workers and slackers are equally likely. Let x be a random variable whose value is one of the slackers in the input, chosen uniformly at random among the slackers. In the first 1/(2) rounds of testing, at most n/2 of the members of X may become identified. In any given round of testing in which x has not already been identified as a slacker, at most n − 1 of the unidentified members of X can be paired with (identified or unidentified) slackers other than x, and x is equally likely to be any one of the ≥ n/2 unidentified members, so the probability that x becomes identified by being paired with a slacker is at most (n − 1)/(n/2) < /2. By the union bound, after 1/(4) = Ω(1/) rounds, x will remain unidentified with probability greater than 1/2, so the probability that all slackers are identified is less than 1/2. Since this randomized input distribution fools even a randomized algorithm with probability at least 1/2, after Ω(1/) rounds, it follows that for every deterministic algorithm there exists an input in this distribution that is certain to fool the algorithm with the same number of rounds. 2.2 Estimating Epsilon Suppose now that there are n slackers, but we do not know the value of . Instead, let us assume we have an estimate, (cid:48), and our goal is to use O(1/(cid:48)) rounds, and either find all n slackers, with (cid:48) ≤ 2, or determine that (cid:48) > . Consider again the above two-phase algorithm, but now assume that it is calibrated for (cid:48) instead of . One possible outcome of phase one, is that we discover at least (cid:100)(cid:48)n/2(cid:101) slackers, which then allows us to discover all the slackers in phase two. In this case, n ≥ (cid:48)n/2, hence, (cid:48) ≤ 2. Alternatively, phase one may discover fewer than (cid:100)(cid:48)n/2(cid:101) slackers. Since a bin that appears to hold no slackers can hold at most one, this implies that  < (cid:48)/2 + (cid:48)/2 = (cid:48). Thus, our two-phase algorithm achieves our goal. We can therefore now use our two-phase algorithm in an iterative fashion. We start with (cid:48) = 1/2, and use the two-phase algorithm with this estimate for . If we discover all the slackers, then we are done. Otherwise, we determine that  < (cid:48). In this case, we set (cid:48) ← (cid:48)/2 and we repeat the process with this estimate. Eventually, we will reach a point where we discover all the slackers, with (cid:48) ≤ 2. Moreover, since the previous iteration, if there is one, would have failed, we also know that  < 2(cid:48), that is, (cid:48) > /2. The number of testing rounds is therefore proportional to 2 + 4 + 8 + ··· + 1/(cid:48) ≤ 2 + 4 + 8 + ··· + 2/ ≤ 4/. 5 Therefore, even without knowing the value of , the number of rounds is O(1/), which implies the following. Theorem 3. Given a set, X, of n workers and slackers, such that n of the individuals in X are slackers, we can identify all the slackers in X in O(1/) rounds of O(n) pairwise tests per round, in a participant-oblivious adaptive algorithm, without knowing  in advance. In Section 4, we explore optimizations to the constant factors in the above bounds, in adaptive CPT algorithms for the case when δ = 1 −  ≤ 1/2, that is, when at least half of the individuals are slackers. Such instances of the combinatorial pair testing problem arise naturally in massively distributed and crowdsourcing applications, for example, where the roles of slackers and workers are reversed and the testing function, T , is Boolean AND instead of OR. 3 Nonadaptive Pair Testing In this section, we study nonadaptive algorithms for combinatorial pair testing, to identify n slackers in a group of n individuals. In this case, if we assume that we do not know the value of , then the only valid algorithm is the trivial brute-force algorithm that compares every pair of individuals, since a nonadaptive algorithm must specify all its tests in advance and it is possible that  = 2/n. Therefore, we assume that we know in advance that there are n slackers. 3.1 Deterministic Nonadaptive Pair Testing Unfortunately, nonadaptive deterministic pair testing is not very interesting, because it requires a linear number of rounds. The argument is simple: suppose a deterministic nonadaptive pair testing algorithm could use at most (1 − )n/2 rounds. Then, in the graph of pairs that are tested by the algorithm, each vertex would have at most (1 − )n/2 neighbors. An adversary could choose one edge of the graph, make one of its two endpoints a slacker and the other endpoint a worker, set all neighbors of these two vertices to be workers, and fill out the rest of the graph arbitrarily to fit whatever number of slackers and workers is desired. From the set of tests that are performed, there is no way to distinguish which of the two endpoints of the chosen edge is the slacker and which is the worker. Therefore, there must be at least Ω((1 − )n) rounds in a deterministic nonadaptive CPT algorithm, which, for any fixed  < 1, is asymptotically not any better than the brute-force algorithm that tests every pair. This bound can be achieved as an upper bound, as well, using an algorithm that pairs each individual, x, with at least (1 − )n + 1 other distinct individuals, using O((1 − )n) rounds. For this algorithm, at least one of the individuals paired with each such x must be a slacker. 3.2 Randomized Nonadaptive Pair Testing Despite the nonexistence of efficient deterministic nonadaptive pair testing algorithms, there is a simple randomized algorithm for nonadaptive randomized testing, which succeeds with high probability using many fewer tests than the deterministic nonadaptive solution. In particular, let us repeatedly choose a random matching of all the members of the set, X, for some value, k, number of rounds. Each matching corresponds to a round of testing. For instance, for k = (c/) log n, for a sufficiently large constant, c ≥ 1, then this scheme uses O((1/) log n) rounds and O((n/) log n) tests in total. 6 Relation to the coupon collector's problem. The expected performance of the nonadaptive randomized algorithm described above can be analyzed precisely using a variant of the classical coupon collector's problem. In the coupon collector's problem, a collector wishes to collect a set of n trading cards, by randomly acquiring one card at a time, and the problem is to calculate the number of steps that are required until, with high probability, all cards have been collected. Now consider a slight variation, which we call the coupon packet collector's problem: instead of buying one card at a time, the collector buys the cards in packets of m cards [18]. Each packet of trading cards is guaranteed to have no duplicates, and is uniformly random among all m-card samples of the whole set of cards. How does this affect the total time required for the collector? If m is much smaller than n, the difference between this problem and the standard coupon collector's problem is very small: a random sample of m cards, each independently and uniformly randomly sampled, is very likely to be duplicate-free. But if m is a constant fraction of n, then the avoidance of duplicates in each packet is very likely to cause the number of packets that the collector needs to collect to be smaller by a constant fraction than the number that a one-at-a-time collector would need. But what is the fraction? In the coupon packet collector's problem, the probability that a card remains uncollected after k rounds is (1− m/n)k. So, after k rounds, by the linearity of expectation, the expected number of uncollected cards is n(1− m/n)k. Thus, for k = (1 + α) log1/(1−m/n) n rounds, the expected number of uncollected cards is 1/nα; hence, by Markov's inequality, with very high probability, 1 − 1/nα, all the cards are collected. In the pair testing problem, observe that a slacker's status is identified whenever the slacker is paired with another slacker, and a student's status is identified whenever that student is paired with a known slacker. If we allow these identifications to be made retroactively (i.e., once we find a known slacker we use that identity to confirm as workers all the other students the slacker has already been paired with) then there is a very simple criterion for whether we have identified everybody: we have done so if and only if all students have been paired at least once with a slacker. More weakly, we have identified all slackers whenever the slackers have all been paired with another slacker in some round of testing. Suppose that there are m slackers and n total students. In each round, exactly m students will be paired with slackers, so it is very much like the coupon packet collector's problem, where the trading cards in a packet correspond to the students that are paired with slackers. There is a small complication, however: in the pair testing problem the sets of students that are identified are not quite uniformly random over all m-element subsets of students. In particular, the slackers are slightly less likely to be paired with other slackers than the workers, because there are fewer other slackers for them to be paired with. To be precise, in the case that there are an even number of students, a slacker has probability exactly (n− m)/(n− 1) of remaining unidentified after one round, because there are n− 1 students the slacker could be paired with, each of which is equally likely, and n − m of which (the workers) fail to identify the slacker. The probability that a specific student is identified in any one round is independent of the same probability for the same student in a different round, so after k = (1 + α) log n−1 n−m m rounds, the probability that an individual slacker remains unidentified is 1/m1+α. Similarly, a worker has probability exactly (n − m − 1)/(n − 1) of not having been paired with a slacker after one round, and probability 1/(n − m)1+α of never having been paired with a slacker after k = (1 + α) log n−1 n−m−1 (n − m) 7 rounds. Different students have probabilities that are not independent of each other, but by linearity of expectation after (cid:26) (cid:27) (n − m)) k = (1 + α) max log n−1 n−m m, log n−1 n−m−1 rounds the expected number of students who have not been paired with a slacker is min{1/mα, 1/(n− m)α}, so by Markov's inequality, with high probability all students will be identified. In the case that there are an odd number of students, there are n alternatives for each student in each round rather than n − 1, so the number of rounds needed is instead k = (1 + α)(log n n−m+1 m + log n n−m (n − m)). In either case, for m = n slackers, if we extend the above two bounds so that the number of rounds is increased to k = (1 + α) log1/(1−) n, then the expected number of unclassified students is 1/nα. Thus, by Markov's inequality, there are no unclassified students with high probability, 1 − 1/nα. Choosing α ≥ 1 to be a fixed constant, and using the inequality, x < − ln(1 − x), for 0 < x < 1, we get the following result. Theorem 4. Given a set, X, of n individuals, such that n ≥ 2 of them are slackers and the rest are workers, we can distinguish the workers and slackers using O((1/) log n) rounds of random performance-based tests, with O(n) tests per round, with high probability, 1−1/nc, in a nonadaptive fashion, for any fixed constant c ≥ 1. In a nonadaptive randomized strategy, the most information is gathered by randomly matching of the members of X and testing each matched pair. Thus, for any slacker, s, the probability s is not paired with another slacker is at least (1 − ). So, after k independent rounds of testing, the probability s has not been discovered to be a slacker is at least (1 − )k, which we can bound as (cid:18) 1 −  (cid:19)k , e (1 − )k ≥ by an inequality due to Niculescu and Vernescu [16]. Thus, we have the following. Theorem 5. For 2/n ≤  ≤ 1/2, we require Ω((1/) log n) rounds of testing for each slacker to be identified, with probability at least 1 − 1/n, in a nonadaptive randomized testing scheme for a set of n members having n slackers. Therefore, the above analysis is tight to within constant factors. 3.3 Experimental Results To get a better handle on the expected number of tests needed to identify various percentages of slackers, we performed an experimental study of the above nonadaptive randomized CPT algorithm. We performed tests for values of n ranging from 100 to 10000, with percentage of slackers ranging from 5% to 90%. We then performed tests to determine the average number of tests required in order to identify 50%, 80%, 90%, and 100% of the slackers. We show the results in Figure 1. 8 Fig. 1. Results for number of random tests needed to identify various percentages of slackers, for various values of the set size, n, and slacker percentage, . 9 05101520253035020406080100Iterations% of students who are SlackersAvg iterations to identify 80% of slackers, n=100Avg iterations to identify 80% of slackers, n=300Avg iterations to identify 80% of slackers, n=1000Avg iterations to identify 80% of slackers, n=3000Avg iterations to identify 80% of slackers, n=10000Avg iterations to identify 50% of slackers, n=100Avg iterations to identify 50% of slackers, n=300Avg iterations to identify 50% of slackers, n=1000Avg iterations to identify 50% of slackers, n=3000Avg iterations to identify 50% of slackers, n=10000020406080100120140020406080100Iterations% of students who are SlackersAvg iterations to identify all slackers, n=100Avg iterations to identify all slackers, n=300Avg iterations to identify all slackers, n=1000Avg iterations to identify all slackers, n=3000Avg iterations to identify all slackers, n=10000Avg iterations to identify 90% of slackers, n=100Avg iterations to identify 90% of slackers, n=300Avg iterations to identify 90% of slackers, n=1000Avg iterations to identify 90% of slackers, n=3000Avg iterations to identify 90% of slackers, n=10000 4 Improved Bounds for Testing with Many Slackers In this section, we consider the case when the number of workers, δn = (1− )n, is relatively small, that is, when δ ≤ 1/2. We show that we can design a non-trivial adaptive testing scheme that has a guaranteed small number of rounds of tests. In general, if there are δn workers then, after one round of tests, at most δn slackers will be paired with workers and, therefore, the other at least n − 2δn slackers will have been identified. In the next rounds, these known slackers can be paired with unknown students, thereby identifying them (some of whom may be identified as slackers and others as workers). 4.1 Two rounds If there are very few workers, say δ ≤ 1/4, then in one round of tests at most n/4 slackers will be paired with workers and, therefore, the other (at least n/2) slackers will be identified. In a second round, we can pair n/2 known slackers with the other n/2 students and thereby be able to identify all other students. 4.2 Three rounds If 1/4 < δ ≤ 1/3 then at least n/3 slackers will be identified in the first round and at most two more rounds of tests suffice to identify all other students. But we can do better. If 1/4 < δ ≤ 5/14, then at least 2n/7 slackers will be identified in the first round. In this case, we can conduct a second round of tests in which 2n/7 known slackers are paired with unknown students. There are at least 9n/14 slackers altogether and so there will be at least 5n/14 other slackers. There are only n/2 pairs of which 2n/7 are populated with known slackers, so there are 3n/14 pairs not populated with known slackers. Therefore, after placing 3n/14 of the other slackers in unoccupied pairs, the remaining n/7 other slackers will be paired with slackers (known or unknown). So, the second round of tests identifies at least n/7 slackers and, since there had been 2n/7 known slackers in separate pairs during this second round, at least n/7 other students will also have been identified. Therefore, after the second round of tests, there will have been identified a total of at least 3n/7 slackers and at least n/7 other students, say x other identified slackers and n/7 − x identified workers. If x ≥ n/14 then at least n/2 slackers will have been identified and a third round of tests suffices to identify all other students. Otherwise, place the 3n/7 + x known slackers in separate pairs and fill the remaining n/14 − x pairs with n/7 − 2x identified workers. Again, a third round of tests suffices to identify all remaining students. 4.3 Four rounds Similarly, if 5/14 < δ ≤ 19/46 then at least 4n/23 slackers will be identified in the first round. Following an analagous procedure and analysis, a second round of tests identifies at least 2n/13 slackers and at least 2n/13 other students. Proceed with a third round of tests in which all identified slackers are placed in separate pairs and, to the extent possible, all identified workers are paired with each other. Using a similar analysis, at least an additional 3n/23 slackers and at least 3n/23 other students will be identified. Finally, a fourth round of tests using the same placement strategy will suffice to identify all remaining students. 10 4.4 Five rounds If δ ≤ 1/2 then another approach enables all slackers to be identified using at most five rounds of tests. Partition the n students into n/4 groups of four students each. In three rounds of testing, each member of each group can have been paired with each of the other members of that member's group. If a group contains two or more slackers then the results of these three rounds of tests will have enabled all members of that group to be identified. If a group contains zero or one slacker then no members of the group will have been identified. If there are δn workers, then there are n slackers, where  = 1 − δ ≥ 1/2. Lemma 3. There are at most x = (1 − )n/3 groups whose members will not have been identified and therefore at most x remaining unidentified slackers. Proof: The lemma can be proven by counting the slackers. Each of the x unidentified groups has at most one slacker and the other (n/4) − x groups can each have at most four slackers. The total number of slackers is n ≤ x + 4((n/4) − x), which directly proves the lemma. So, after three rounds of testing, at most x slackers will not have been identified and therefore at least n − x = (4 − 1)n/3 ≥ n/3 slackers will have been identified. Conduct a fourth round of testing in which each of n/3 identified slackers is placed in a separate pair, thereby identifying n/3 of the other students. A fifth round of testing will identify all remaining unknown students. We have provided algorithms enabling identification of all the slackers in 2, 3, 4, or 5 rounds, depending on the value of δ ≤ 1/2. We leave open the problem of establishing whether these algorithms are optimal. 5 Conclusion In this paper, we have given efficient algorithms for solving combinatorial pair testing problems, along with lower bounds showing that our algorithms are optimal to within constant factors. All of our algorithms assume we are using performance-based tests. Therefore, one possible direction for future work would be to explore CPT algorithms and applications for other kinds of tests (other than the exclusive-or tests used in processor fault diagnosis [2 -- 5, 17]). Another direction would be to enlarge the size of tested groups beyond two and explore the effect of different group sizes on the numbers of rounds needed for testing. Acknowledgments This research was supported in part by the National Science Foundation under grants 1011840, 1217322, and 1228639, and by the Office of Naval Research under MURI grant N00014-08-1-1015. References 1. M. J. Atallah, K. B. Frikken, M. Blanton, and Y. Cho. Private combinatorial group testing. In ACM Symp on Information, Computer and Communications Security (ASIACCS), pages 312 -- 320, 2008. 2. R. Beigel, W. Hurwood, and N. Kahale. Fault diagnosis in a flash. In Proc. IEEE Foundations of Computer Science (FOCS), pages 571 -- 580, October 1995. 3. R. Beigel, S. R. Kosaraju, and G. F. Sullican. Locating faults in a constant number of parallel testing rounds. In ACM Symp. on Parallel Algorithms and Architectures (SPAA), pages 189 -- 198, 1989. 4. R. Beigel, G. Margulis, and D. A. Spielman. Fault diagnosis in a small constant number of parallel testing rounds. In ACM Symp. on Parallel Algorithms and Architectures (SPAA), pages 21 -- 29, 1993. 11 5. P. M. Blecher. On a logical problem. Discrete Mathematics, 43(1):107 -- 110, 1983. 6. D.-Z. Du and F. Hwang. Combinatorial Group Testing and Its Applications. Series on Applied Mathematics. World Scientific, 2000. 7. W. Du and M. T. Goodrich. Searching for high-value rare events with uncheatable grid computing. In J. Ioannidis, A. Keromytis, and M. Yung, editors, Applied Cryptography and Network Security (ACNS), volume 3531 of LNCS, pages 122 -- 137. Springer, 2005. 8. W. Du, J. Jia, M. Mangal, and M. Murugesan. Uncheatable grid computing. In 24th Int. Conf. on Distributed Computing Systems (ICDCS), pages 4 -- 11, 2004. 9. D. Eppstein, M. T. Goodrich, and D. S. Hirschberg. Improved combinatorial group testing algorithms for real-world problem sizes. SIAM J. Comput., 36(5):1360 -- 1375, 2006. 10. M. T. Goodrich. Pipelined algorithms to detect cheating in long-term grid computations. Theoretical Computer Science, 408(2/3):199 -- 207, 2008. 11. M. T. Goodrich, M. J. Atallah, and R. Tamassia. Indexing information for data forensics. In J. Ioannidis, A. Keromytis, and M. Yung, editors, Applied Cryptography and Network Security (ACNS), volume 3531 of LNCS, pages 206 -- 221. Springer, 2005. 12. F. K. Hwang. Random k-set pool designs with distinct columns. Probab. Eng. Inf. Sci., 14(1):49 -- 56, Jan. 2000. 13. N. Jacobson and S. K. Schaefer. Pair programming in CS1: overcoming objections to its adoption. SIGCSE Bull., 40(2):93 -- 96, June 2008. 14. Q. Liu, J. Peng, and A. Ihler. Variational inference for crowdsourcing. In P. Bartlett, F. C. N. Pereira, C. J. C. Burges, L. Bottou, and K. Q. Weinberger, editors, Advances in Neural Information Processing Systems (NIPS), pages 701 -- 709, 2012. 15. N. Nagappan, L. Williams, M. Ferzli, E. Wiebe, K. Yang, C. Miller, and S. Balik. Improving the CS1 experience with pair programming. In Proc. 34th SIGCSE Technical Symp. on Computer Science Education (SIGCSE '03), volume 35.1 of SIGCSE Bulletin, pages 359 -- 362, 2003. 16. C. P. Niculescu and A. Vernescu. A two-sided estimate of ex − (1 + x/n)n. Journal of Inequalities in Pure and Applied Mathematics, 5(3), 2004. 17. A. Pelc and E. Upfal. Reliable fault diagnosis with few tests. Comb. Probab. Comput., 7(3):323 -- 333, 1998. 18. W. Stadje. The collector's problem with group drawings. Advances in Applied Probability, 22(4):866 -- 882, 1990. 19. L. Williams and R. R. Kessler. Pair Programming Illuminated. Addison-Wesley, 2003. 20. L. Williams, R. R. Kessler, W. Cunningham, and R. Jeffries. Strengthening the case for pair programming. IEEE Software, 17(4):19 -- 25, 2000. 21. A. C. Yao. How to generate and exchange secrets. In Proceedings of the 27th Annual Symposium on Foundations of Computer Science, pages 162 -- 167, Washington, DC, USA, 1986. IEEE Computer Society. 12
1605.04491
1
1605
2016-05-15T02:16:05
Improved distance sensitivity oracles via tree partitioning
[ "cs.DS" ]
We introduce an improved structure of distance sensitivity oracle (DSO). The task is to pre-process a non-negatively weighted graph so that a data structure can quickly answer replacement path length for every triple of source, terminal and failed vertex. The previous best algorithm constructs in time $\tilde{O}(mn)$ a distance sensitivity oracle of size $O(n^2\log n)$ that processes queries in $O(1)$ time. As an improvement, our oracle takes up $O(n^2)$ space, while preserving $O(1)$ query efficiency and $\tilde{O}(mn)$ preprocessing time. One should notice that space complexity and query time of our novel data structure are asymptotically optimal.
cs.DS
cs
Improved distance sensitivity oracles via tree partitioning Ran Duan1 and Tianyi Zhang2 1Institute for Interdisciplinary Information Science, Tsinghua University, China, 2Institute for Interdisciplinary Information Science, Tsinghua University, China, [email protected] [email protected] Abstract We introduce an improved structure of distance sensitivity oracle (DSO). The task is to pre-process a non-negatively weighted graph so that a data structure can quickly answer replacement path length for every triple of source, terminal and failed vertex. The previous best algorithm constructs in time 1 O(mn) a distance sensitivity oracle of size O(n2 log n) that processes queries in O(1) time. As an improvement, our oracle takes up O(n2) space, while preserving O(1) query efficiency and O(mn) preprocessing time. One should notice that space complexity and query time of our novel data structure are asymptotically optimal. Introduction 1 Let G = (V, E) be a directed graph with n vertices and m edges, and edge weights ω : E → R+ ∪ {0}. We wish to pre-process the graph and build a distance sensitivity oracle that answers for every triple of (s, t, f ) the length of replacement path from s to t that circumvents the assumed failed vertex f. We call any data structure that answers such queries distance sensitivity oracle (DSO). A close relative of this DSO problem is that we consider edge failures instead of vertex failures. In this paper, we are only concerned with failed vertices, though all our structures can be easily extended (see [9]) to handle edge-failure queries without any loss in space / time efficiency. Motivation for vertex failures is routing where network nodes occasionally undergo crash failures. In the face of single node-failures, we might not afford to re-compute all-pair shortest paths from scratch before the failed node comes back on-line. A distance sensitivity oracle may lend us help in the sense that re-computing APSP becomes unnecessary. Motivation for edge failures comes from in Vickery pricing [18], where one wishes to measure, for every pair of source and target as well as a failed edge, by how much the shortest distance would rise if this designated edge were to shut down. 1.1 Existing algorithms The naive approach is that we pre-compute and store the length of all O(n3) possible replacement path lengths, which incurs intolerable space complexity. [11] proposes the first DSO that occupies only near-quadratic space. More specifically, [11]'s DSO has space complexity O(n2 log n) and O(1) query time. Space complexity of constant query time DSO has not been improved ever since. DSO in [11] demands a somewhat high preprocessing time complexity of O(mn2), which was improved 2 ) in the journal version [9] while the space complexity was blown up to O(n2.5). Cubic time to O(mn 3 preprocessing algorithm was first obtained by [5] and shortly improved from O(n2√ m) to O(mn) in [6], while maintaining O(n2 log n) space and O(1) query time. Note that O(n2 log n) and O(mn) are basically optimal up to poly-logarithmic factors, as discussed in [6]. Therefore, surpassing [6]'s construction time has been deemed hard from then. 1 O(·) suppresses poly-logarithmic factors. 1 Since the publication of [6], the community's interest has diverged to seeking truly sub-cubic preprocessing time algorithms. F. Grandoni and V. Williams ([14]) obtained truly sub-cubic preprocessing time bound O(M n2.88), if one should tolerate a sub-linear query time of O(n0.7); here all edge weights are assumed to be integers within interval [−M, M ]. 1.2 Our contributions In this paper we present a DSO construction that improves upon [6]. Theorem 1.1. For any directed non-negatively weighted graph G = (V, E, ω), a DSO with O(n2) space complexity and O(1) query time exists. Also, such DSO can be preprocessed in time O(mn). In Bernstein & Karger's work ([6]), the space / query time was O(n2 log n) and O(1). So compared with [9]'s result, our construction shaves off the last log n factor in the space complexity, leading to a quadratic space consumption, while preserving constant time query efficiency. Plus, our DSO can also be constructed in O(mn) time as in [6], which is nearly optimal. One should notice that the space complexity of our DSO is asymptotically optimal. To see that, we argue that merely answering all-pairs distances requires Ω(n2) space. Consider when G is a complete directed graph with distinct edge weights drawn from (1, 2]. In this case, for any s, t ∈ V , the shortest path from s to t is simply the edge (s, t) ∈ E. Hence, to answer the distance from s to t, the data structure can do nothing but store ω(s, t); otherwise ω(s, t) can never be precisely known. Thereby, the total storage is at least E = Ω(n2). For other lower bounds in undirected graphs, see [20]. The observation comes from Demetrescu's original work. [11]'s construction basically applies the idea of sparse table, where each pair of source and target are associated with O(log n) sparse table entries, thus resulting in a total storage of O(n2 log n). The preliminary idea is that we do not store sparse table entries at every source-terminal pair. More specifically, for each single source shortest path tree (SSSP), we designate only a proportion of all tree vertices which are associated with sparse table entries, hence making our data structure even sparser. The set of all designated vertices should be carefully chosen with respect to the topological structure of the SSSP tree. With the sparser data structure, we can answer queries (s, t, f ) when f keeps distance from both of s and t. So the bottleneck lies in degenerated cases where f is very close to one of the endpoints s or t. For degenerated cases, we can use much smaller sparse tables to cover short paths, resulting in a DSO that only occupies O(n2 log log n) space. To obtain an optimum of O(n2) space complexity, we would need to apply a tabulation technique (more known as the "Four Russians" [3]). Our preprocessing algorithm heavily relies on the notion of admissible functions from [5]. The idea is that we substitute "bottleneck" vertices for intervals in the original construction, without harming the correctness of query algorithm. In this way, we make the DSO easier to initialize. 1.3 Related work There are several generalizations of the distance sensitivity problem. In [12], the authors considered the scenario where two instead of one vertices could fail. The paper presented a distance oracle with O(n2 log3 n) space complexity and O(log n) query time. As it turned out, things got far more complicated than single vertex-failures, and sadly no non-trivial polynomial preprocessing algorithms were known. There are works (e.g., [21][8][10][2]) mainly concerned with dynamically maintaining all pairs shortest paths (APSP). Such data structures can solve distance problems if subsequent failures are cumulative, but update time would be as large as O(n2.75). If one should sacrifice preciseness for space efficiency, one may consider approximate distance oracles for vertex failures. [19] considered approximating the replacement path lengths where a single vertex could crash. In [7], the authors focused on data structures that approximately answer minimal distance of constrained paths that do not pass through a designated set of failed edges. For fully dynamic approximate APSP, one can refer to [15]; especially, for planar graphs, [1] may provide useful results. There are remotely related problems such as (partially) dynamic single-source shortest paths and reacha- bility. Papers [17] and [16] discussed these topics in depth. Some other loosely related work concerns the construction of spanners and distance preservers resilient to one edge / node failure. 2 2 Preliminaries Suppose we are given a directed graph G = (V, E, ω) with non-negative edge weights ω : E → R+ ∪ {0}. In this section, we summarize the notations or assumptions that are used throughout this paper. More or less, we inherit the conventions from [12]. • Our data structures & algorithms are implemented on Ω(log n)-word RAM machines. We will leverage its strength in computing the most significant set bit ([13]). Although in previous works on DSO ([8], [9], [5], [6]) Ω(log n)-word RAM model was not explicitly assumed, this assumption was not expendable since their algorithms required memory indexing and computing logarithms in constant time. • We call a data structure (cid:104)f (n), g(n)(cid:105), if its space complexity is at most f (n) and its query time is at most g(n). • For each pair of s, t ∈ V , the weighted shortest path from s to t is unique. This assumption is without loss of generality since we can add small perturbations to break ties (e.g., [9], [6]). • For each pair of s, t ∈ V , let st denote the shortest path from s to t. • Let p be a simple path. Denote by (cid:107)p(cid:107) and p the weighted and un-weighted length of path p. • For each s ∈ V , let Ts be the single-source shortest path tree rooted at s; let (cid:98)Ts be the single-source shortest path tree rooted at s in the reverse graph (cid:98)G where every directed edge in G is reversed. • For each query (s, t, f ), we only consider the case when f lies on the path st, because verification can be done by checking whether (cid:107)st(cid:107) = (cid:107)sf(cid:107) + (cid:107)f t(cid:107). • For each vertex set A, let st (cid:5) A denote the shortest path from s to t that avoids the entire set A. For instance, st (cid:5) {f} (abbreviated as st (cid:5) f) denotes the replacement path, and st (cid:5) [u, v] refers to the shortest path that skips over an entire interval [u, v] ⊆ st. Here for [u, v] to be a properly defined interval on st, it is required that both of u and v are on st, and either u = v, or u lying between s and v. • Let s ⊕ i and s (cid:9) i be the ith vertex after and before s on some path that can be learnt from context. By uniqueness of shortest paths, it is easy to verify that any path of the form st (cid:5) f or st (cid:5) [u, v] must diverge from and converge with st for once ([9]), with divergence on path sf and convergence on f t. Let ∆s,t,f and ∇s,t,f be the vertices at which divergence and convergence take place, respectively. More often than not, we ignore those indices s, t, f and simply write ∆,∇. 3 The sparse table technique In this section, we review the (cid:104)O(n2 log n), O(1)(cid:105) DSO devised in [9]. Basically, its design utilizes the idea of sparse table. 3.1 Data structure For every pair of s, t ∈ V , build the following. Note. Indices i, j are non-negative integers throughout this paper. (i) The values of (cid:107)st(cid:107) and st. (ii) For every s, t and 2i < st, the value of (cid:107)st (cid:5) (s ⊕ 2i)(cid:107) and (cid:107)st (cid:5) (t (cid:9) 2i)(cid:107). (iii) For every s, t and 2i+1 < st, the value of (cid:107)st (cid:5) [s ⊕ 2i, s ⊕ 2i+1](cid:107) and (cid:107)st (cid:5) [t (cid:9) 2i+1, t (cid:9) 2i](cid:107). (iv) Level ancestor data structures ([4]) for every Ts and (cid:98)Ts. 3 Briefly discuss the space complexity. Evidently (i) takes O(n2) space; both of (ii) and (iii) have space complexity O(n2 log n); for (iv), by linear space construction of level ancestor data structure from [4], each Ts ((cid:98)Ts) arouses a storage of O(n), leading to a total space complexity of O(n2) ranging over all s. Thus, the overall space is O(n2 log n). 3.2 Query algorithm For each query (s, t, f ), without loss of generality assume that sf ≤ f t. If sf or f t is a power of 2, then (cid:107)st (cid:5) f(cid:107) has already been computed during preprocessing (ii). Otherwise, let i, j be the maximum non-negative integers such that 2i < sf, 2j < f t. Note. Both of i, j can be computed in constant time on Ω(log n)-word RAM machines: i (j) is equal to the index of the most significant set bit of sf − 1 (f t − 1), and according to [13] the most significant set bit can be computed in constant time on a Ω(log n)-word RAM. Consider the following cases. (1) st (cid:5) f skips the entire [s ⊕ 2i, s ⊕ 2i+1] which contains f. As we know from (iii), (cid:107)st (cid:5) [s ⊕ 2i,⊕2i+1](cid:107) can be directly retrieved. (2) st (cid:5) f passes through s ⊕ 2i. By definition of i, it must be that f (cid:9) 2i lies between s and s ⊕ 2i. So in the case that st (cid:5) f passes through s ⊕ 2i, it must also pass through f (cid:9) 2i. Thereby, (cid:107)st (cid:5) f(cid:107) = (cid:107)s(f (cid:9) 2i)(cid:107) + (cid:107)(f (cid:9) 2i)t (cid:5) f(cid:107); both terms are retrievable from storage in constant time. (3) st (cid:5) f passes through s ⊕ 2i+1. By definition of i, j, 2j+1 ≥ f t ≥ sf > 2i, which leads to j ≥ i. Therefore, because f comes after s⊕ 2i, f ⊕ 2j lies in range [s⊕ 2i+1, t). Since st(cid:5) f passes through s⊕ 2i+1, it is guaranteed to also pass through f ⊕ 2j. Decomposing (cid:107)st (cid:5) f(cid:107) = (cid:107)s(f ⊕ 2j) (cid:5) f(cid:107) + (cid:107)(f ⊕ 2j)t(cid:107), both terms are already pre-computed. So far we have completed discussion of the (cid:104)O(n2 log n), O(1)(cid:105) DSO in [9]. 4 Admissible functions and the triple path lemma Our query algorithms will be frequently using the triple path lemma from [5]. This lemma is based on the notion of admissible functions. is admissible if ∀f ∈ [u, v], we have (cid:107)st (cid:5) [u, v](cid:107) ≥ F [u,v] s,t ≥ (cid:107)st (cid:5) f(cid:107). s,t s,t , (cid:107)st (cid:5) f(cid:107) = min{(cid:107)su(cid:107) + (cid:107)ut (cid:5) f(cid:107),(cid:107)sv (cid:5) f(cid:107) + (cid:107)vt(cid:107), F [u,v] s,t }. Definition 4.1 ([5]). A function F [u,v] Definition 4.2 ([5]). Two important admissible functions are maxf∈[u,v]{(cid:107)st (cid:5) f(cid:107)} and (cid:107)st (cid:5) [u, v](cid:107). We call them bottleneck and interval admissible functions, respectively. Lemma 4.1 (The triple path lemma ([5])). Let [u, v] be an interval on st, and f ∈ [u, v] be a vertex. For any admissible function F [u,v] Proof. On the one hand, (cid:107)st (cid:5) f(cid:107) is always smaller or equal to min{(cid:107)su(cid:107) + (cid:107)ut (cid:5) f(cid:107),(cid:107)sv (cid:5) f(cid:107) + (cid:107)vt(cid:107), F [u,v] s,t }. s,t ≥ (cid:107)st (cid:5) f(cid:107); also it is easy to see that both of (cid:107)su(cid:107) + (cid:107)ut (cid:5) f(cid:107) and This is because, by definition 3.1 F [u,v] (cid:107)sv (cid:5) f(cid:107) + (cid:107)vt(cid:107) are ≥ (cid:107)st (cid:5) f(cid:107). s,t }. If st (cid:5) f passes through either u or v, then (cid:107)st (cid:5) f(cid:107) would be equal to either (cid:107)su(cid:107) + (cid:107)ut (cid:5) f(cid:107) or (cid:107)sv (cid:5) f(cid:107) + (cid:107)vt(cid:107), which is ≥ min{(cid:107)su(cid:107) + (cid:107)ut (cid:5) f(cid:107),(cid:107)sv (cid:5) f(cid:107) + (cid:107)vt(cid:107), F [u,v] s,t }. Otherwise st (cid:5) f skips over the entire interval [u, v] and thus (cid:107)st (cid:5) f(cid:107) = (cid:107)st (cid:5) [u, v](cid:107) ≥ F [u,v] On the other hand, we argue (cid:107)st (cid:5) f(cid:107) ≥ min{(cid:107)su(cid:107) + (cid:107)ut (cid:5) f(cid:107),(cid:107)sv (cid:5) f(cid:107) + (cid:107)vt(cid:107), F [u,v] s,t ≥ min{(cid:107)su(cid:107) + (cid:107)ut (cid:5) f(cid:107),(cid:107)sv (cid:5) f(cid:107) + (cid:107)vt(cid:107), F [u,v] s,t }. 4 5 The tree partition lemma Our novel DSO begins with the following lemma. This lemma also appeared in [14]. Lemma 5.1 (Tree partition). Given a rooted tree T , and any integer 2 ≤ k ≤ n = V (T ), there exists a subset of vertices M ⊆ V (T ), M ≤ 3k − 5, such that after removing all vertices in M, the tree T is partitioned into sub-trees of size ≤ n/k. We call every u ∈ M an M-marked vertex, and M a marked set. Plus, such M can be computed in O(n log k) time. Proof. We prove this claim by an induction on k. • Basis k = 2. We argue that deleting one vertex from T can decompose the entire tree into sub-trees of size ≤ n/2. First, we can compute the size of sub-tree rooted at every vertex by a traversal, which takes linear time. Then, consider the following procedure. To locate the one that needs to be deleted, start the search at root and travel down the tree. We will be met with two possible cases. (1) If the sizes of all the sub-trees rooted immediately below our current position are < n/2, then we stop and return with the vertex at current position. (2) Otherwise, we step onto the child whose corresponding sub-tree has ≥ n/2 vertices. The procedure is guaranteed to terminate since the maximum sub-tree size rooted below the current position always decreases every time we step onto a child. Correctness is also ensured because during the process we maintain the invariant that if the current vertex is deleted from tree, the component containing the parent vertex is of size ≤ n/2. Time complexity of this procedure is O(n), because the searching visits every vertex no more than once. • Induction for k ≥ 3. 2(cid:101) − 1 + 3(cid:100) k 2(cid:101) ∈ [2, k), and the tree T is broken into sub-trees of size ≤ n/(cid:100) k Apply the lemma with parameter (cid:100) k 2(cid:101). The total number of sub-trees whose sizes are > n/(2(cid:100) k 2(cid:101) − 1. Applying the base case with parameter 2, we can further decompose all those "larger" sub-trees into sub-trees of size ≤ n/(2(cid:100) k 2(cid:101) − 1 deletions. The total number of deletions would thus be ≤ 2(cid:100) k Running time of this algorithm for general k satisfies recursion T (k) = T ((cid:100)k/2(cid:101)) + O(n), which leads to T (k) = O(n log k). 2(cid:101) − 5 ≤ 3k − 5; the last inequality holds for all k ≥ 3. 2(cid:101)) ≤ n/k with no more than 2(cid:100) k 2(cid:101)) is at most 2(cid:100) k The high-level idea of our data structure is that we reduce the computation of an arbitrary (cid:107)st (cid:5) f(cid:107) to a "shorter" (cid:107)uv (cid:5) f(cid:107); here we say "short" in the sense that either uf or f v is small. The tree partition lemma helps us with the reduction. Basically, we apply the lemma twice with different parameters so that either uf or f v becomes "short" enough, and then we can directly retrieve the length of replacement path from storage. For the rest of this paper, we say a replacement path st (cid:5) f is L-short with respect to marked set M and Ts ((cid:98)Tt), if t (s) and f lie within the same sub-tree after we remove the entire marked vertex set M; here M discussing L-shortness, and nor do we specify which tree, Ts or (cid:98)Tt, is being partitioned. These conditions are guarantees that each sub-tree has size < L. Sometimes we don't explicitly refer to the corresponding M when supposed to be easily learnt from context. 6 Reducing to log2 n-short paths We devise an O(n2)-space data structure that computes all non-log2 n-short paths in constant time. 5 6.1 Data structure Just like in section 3, our DSO first pre-computes all values of (cid:107)st(cid:107) and st, which accounts for O(n2) space. Then, for each s ∈ V , apply lemma 5.1 in Ts ((cid:98)Ts) to obtain a marked set Ms ((cid:99)Ms) with parameter (cid:100)n/(L − 1)(cid:101), where 2 ≤ L ≤ n is an integer to be set later. So Ms ((cid:99)Ms) is of size O(n/L), and the size of Note. The un-weighted distances between two adjacent marked vertices in Ts ((cid:98)Ts) are ≤ L. each sub-tree is < L. Consider the following structures. Note that we always build same structures in the reverse graph. For any pair of s, t such that t ∈ Ms, suppose we are met with Ms-marked vertices u1 → u2 → ······ → uk = t along the path st in Ts. Our data structure consists of several parts. (i) For each k − 2i ∈ [1, k − 1], the value of (cid:107)st (cid:5) uk−2i(cid:107). (ii) For each k − 2i ∈ [1, k − 2], the value of (cid:107)st (cid:5) [uk−2i, uk−2i+1](cid:107). (iii) Let vl → ······ → v1 be the sequence of all (cid:99)Mt-marked vertices along the path st. Then for each properly defined interval [vl−2i, uk−2j ] on the path st, store the value of (cid:107)st (cid:5) [vl−2i, uk−2j ](cid:107). (iv) For each f such that f t ≤ 2L or sf ≤ 2L, the value of (cid:107)st (cid:5) f(cid:107). From now on we drop the assumption that t is Ms-marked. (v) For every pair (s, t) of different vertices, let x be t's nearest Ms-marked Ts-ancestor, and y be s's nearest (cid:99)Mt-marked (cid:98)Tt-ancestor. If intervals (s, x] and [y, t) intersect, then we pre-compute and store (cid:107)st(cid:5) [y, x](cid:107). Also, store addresses of x, y, if such ancestors exist. (vi) Build a tree upon all Ms ∪ {s}'s vertices as follows. In this tree, u is v's parent if and only if in Ts u is v's nearest ancestor that belongs to Ms ∪ {s}. Then pre-compute and store the level-ancestor data structure of this tree. Note again that we also build similar structures for (cid:99)Ms ∪ {s} in the reverse graph. Conduct a simple space complexity analysis for each part of the data structure. (i) takes up space O( n2 log n L ) since we have O(log n) choices for the index i, and every Ms = O(n/L). (ii) uses O( n2 log n L ) for a similar reason in the previous part. (iii) demands O( n2 log2 n L ) space since we have O(log2 n) choices for the pair of (i, j). (iv) entails an O(n2) space consumption since each Ms-marked t is associated with O(L) entries, and there are O(n/L) Ms-marked vertices t. (v) induces O(n2) space complexity. (vi) takes O(n2/L) total space, each tree of size O(n/L). Therefore, the overall space complexity from (i) through (vi) is equal to O( n2 log2 n + n2). Taking L L = log2 n, it becomes O(n2). 6.2 Query algorithm We prove the following reduction lemma in this sub-section. Lemma 6.1. The data structure specified in section 6.1 can compute (cid:107)st (cid:5) f(cid:107) in O(1) time if st (cid:5) f is not L-short with respect to Ms or (cid:99)Mt. 6 Proof. A constant time verification for L-shortness is easy: we check if f lies below the nearest Ms-marked Ts-ancestor of t, and similarly if f lies below the nearest (cid:99)Mt-marked (cid:98)Tt-ancestor of s. proceeds as follows. Firstly we argue that it is without loss of generality to assume that t is Ms-marked. The reduction Let x and y be vertices defined as in (v). Since st (cid:5) f is not L-short, f ∈ (s, x] ∩ [y, t), and thus [y, x] is a properly defined interval on path st. By the triple path lemma, one has: (cid:107)st (cid:5) f(cid:107) = min{(cid:107)sx (cid:5) f(cid:107) + (cid:107)xt(cid:107),(cid:107)sy(cid:107) + (cid:107)yt (cid:5) f(cid:107),(cid:107)st (cid:5) [y, x](cid:107)} Here we use the interval admissible function (cid:107)st (cid:5) [y, x](cid:107). Noticing that the third term (cid:107)st (cid:5) [y, x](cid:107) is already covered in (v) from 6.1, we are left with (cid:107)sx (cid:5) f(cid:107) and (cid:107)yt (cid:5) f(cid:107). By definition, x is Ms-marked and y is (cid:99)Mt-marked, and thus we complete our reduction. Let u1 → u2 → ······ → up = t be the sequence of all Ms-marked vertices along st. We can assume that p > 1; otherwise (cid:107)st (cid:5) f(cid:107) has already been computed in structure (iv). Let vq → vq−1 → ······ → v1 be the sequence of all (cid:99)Mt-marked vertices on st. It is also safe to assume It is not hard to find the interval [ua, ua+1) that contains f. On the one hand, ua is easily retrieved: if f not Ms-marked, then ua is its nearest marked ancestor stored in (v); otherwise, ua = f. On the other hand, ua+1 can be found by querying the level-ancestor data structure (vi) at node t in tree rooted at s. q > 1; otherwise, we have st ≤ 2L and then using (iv) we can directly compute (cid:107)st (cid:5) f(cid:107). Similar to the previous paragraph, locate the interval (vb+1, vb] that includes f. We only need to consider the case when a + 1 < p and b + 1 < q, since otherwise (cid:107)st (cid:5) f(cid:107) can be directly retrieved from structure (iv). Find maximum indices i, j ≥ 0 such that q − 2i ≥ b + 1, p− 2j ≥ a + 1. Applying the triple path lemma with respect to [vq−2i, up−2j ] in terms of interval admissible function, (cid:107)st (cid:5) f(cid:107) must be the minimum among the following three distances. (1) (cid:107)st (cid:5) [vq−2i , up−2j ](cid:107). This value is directly retrievable from (iii) in section 6.1. (2) (cid:107)sup−2j (cid:5) f(cid:107) + (cid:107)up−2j t(cid:107). Note that since we are interested in the minimum among (1)(2)(3) which gives us (cid:107)st (cid:5) f(cid:107), we can substitute any value for (2) that lies in range [(cid:107)st (cid:5) f(cid:107),(cid:107)sup−2j (cid:5) f(cid:107) + (cid:107)up−2j t(cid:107)]. By definition of j, ua+2j lies between up−2j and t, and hence we know that the concatenation of paths sup−2j (cid:5) f and up−2j t passes through ua+2j . Thus, it must be (cid:107)sup−2j (cid:5) f(cid:107) + (cid:107)up−2j t(cid:107) ≥ (cid:107)sua+2j (cid:5) f(cid:107) + (cid:107)ua+2j t(cid:107) ≥ (cid:107)st (cid:5) f(cid:107) So instead of computing the original (2), we are actually calculating (cid:107)sua+2j (cid:5) f(cid:107) + (cid:107)ua+2j t(cid:107). We focus on the case when f (cid:54)= ua; the case where f = ua is easy in that we can directly query (cid:107)sua+2j (cid:5) ua(cid:107) using (i). Applying the triple path lemma for a third time to sua+2j (cid:5) f and interval [ua, ua+1], we further divide it into three cases. (a) (cid:107)sua+2j (cid:5) [ua, ua+1](cid:107) + (cid:107)ua+2j t(cid:107). This can be computed by a single table lookup in (ii). (b) (cid:107)sua+1 (cid:5) f(cid:107) + (cid:107)ua+1t(cid:107). Since ua+1 is Ms-marked, (cid:107)sua+1 (cid:5) f(cid:107) is stored in structure (iv), and thereby (cid:107)sua+1 (cid:5) f(cid:107) + (cid:107)ua+1t(cid:107) is computed effortlessly. If ua itself is (cid:99)Mt marked, then (iv) directly help us out since (cid:107)uat (cid:5) f(cid:107) is already pre-computed as (c) (cid:107)sua(cid:107) + (cid:107)uat (cid:5) f(cid:107). uaf ≤ L. 7 Otherwise, suppose v is ua's nearest (cid:99)Mt-marked ancestor in Ts (if any). To locate such v, we can try If such v does not exist, then s and ua lie in the same sub-tree of (cid:98)Tt after removing (cid:99)Mt. Noticing to find the interval (vc+1, vc] that contains ua, in a similar fashion of finding intervals [ua, ua+1) and (vb+1, vb]; after that we assign v ← vc+1. that sf < sua+1 = sua + uaua+1 ≤ 2L, (iv) can finish up (cid:107)st (cid:5) f(cid:107) by a single table look-up. If v exists, then by (cid:107)sua(cid:107) + (cid:107)uat (cid:5) f(cid:107) ≥ (cid:107)sv(cid:107) + (cid:107)vt (cid:5) f(cid:107) ≥ (cid:107)st (cid:5) f(cid:107), it suffices to compute (cid:107)vt (cid:5) f(cid:107), which also has already been pre-computed in (iv) due to vf = vua + uaf ≤ 2L. (3) (cid:107)svq−2i(cid:107) + (cid:107)vq−2it (cid:5) f(cid:107). The only difficult part is (cid:107)vq−2it (cid:5) f(cid:107). Similar arguments in the previous case (2) will still work. 7 An (cid:104)O(n2 log log n), O(1)(cid:105) construction In this section, we present an ordinary way of handling L-short paths, resulting in an (cid:104)O(n2 log log n), O(1)(cid:105) DSO. On a high level, we directly apply the sparse table construction as in section 3, which is from [9]. But since the sparse table only needs to cover L-short paths, the space requirement shrinks to O(log L) = O(log log n) for every pair of s, t ∈ V . Hence the total space complexity would be O(n2 log log n). 7.1 Data structure For any pair of s, t ∈ V , besides (cid:107)st(cid:107),st, build the following structures. (i) For every 2i ≤ min{4L,st}, store (cid:107)st (cid:5) (s ⊕ 2i)(cid:107) and (cid:107)st (cid:5) (t (cid:9) 2i)(cid:107). (ii) For every 2i+1 ≤ min{4L,st}, store (cid:107)st (cid:5) [s ⊕ 2i, s ⊕ 2i+1](cid:107) and (cid:107)st (cid:5) [t (cid:9) 2i+1, t (cid:9) 2i](cid:107). (iii) Level ancestor data structures of Ts and (cid:98)Ts. Since L = log2 n, the total space of this structure is equal to O(n2 log L) = O(n2 log log n). Note that this structure is basically identical to the one from section 3, except for the additional bound 4L on the power-of-two's 2i. Therefore, when st ≤ 4L, (cid:107)st (cid:5) f(cid:107) can be retrieved in O(1) time according to the correctness guaranteed by [9]. 7.2 Query algorithm We prove the following lemma, showing how our data structure covers all L-short paths. Lemma 7.1. For any st (cid:5) f such that sf ≤ L or f t ≤ L, (cid:107)st (cid:5) f(cid:107) can be computed in O(1) time by the data structure presented in section 7.1. Proof. By the symmetry of our data structure, we can assume without loss of generality that sf ≤ L. It is also convenient to suppose that sf is not a power of 2, otherwise (cid:107)st (cid:5) f(cid:107) is directly retrievable from (i) in 7.1. If st ≤ 4L, then query algorithm in section 3 can answer (cid:107)st (cid:5) f(cid:107) in constant time. Now let us assume st > 4L. Let i be the largest index such that 2i < sf. Apply the triple path lemma for replacement path st (cid:5) f and interval [s ⊕ 2i, s ⊕ 2L] and consider the following three distances. Note that since 2i < sf ≤ L < 2L, f lies between s ⊕ 2i and s ⊕ 2L. (1) (cid:107)s(s ⊕ 2i)(cid:107) + (cid:107)(s ⊕ 2i)t (cid:5) f(cid:107). By definition of i, f (cid:9) 2i lies between s and s ⊕ 2i. Then we have (cid:107)s(s ⊕ 2i)(cid:107) + (cid:107)(s ⊕ 2i)t (cid:5) f(cid:107) ≥ (cid:107)s(f (cid:9) 2i)(cid:107) + (cid:107)(f (cid:9) 2i)t (cid:5) f(cid:107) ≥ (cid:107)st (cid:5) f(cid:107) Thereby it is legal to substitute (cid:107)s(f (cid:9) 2i)(cid:107) + (cid:107)(f (cid:9) 2i)t (cid:5) f(cid:107) for (1). According to the construction in 7.1, both terms can be retrieved from memory in constant time. 8 (2) (cid:107)s(s ⊕ 2L) (cid:5) f(cid:107) + (cid:107)(s ⊕ 2L)t(cid:107). The former term is computable in constant time because s(s ⊕ 2L) = 2L < 4L. (3) (cid:107)st (cid:5) [s ⊕ 2i, s ⊕ 2L](cid:107). Since 2i+1 < 2sf ≤ 2L, st (cid:5) f actually skips over the interval f ∈ [s ⊕ 2i, s ⊕ 2i+1]. Therefore, (cid:107)st (cid:5) [s ⊕ 2i, s ⊕ 2L](cid:107) ≥ (cid:107)st (cid:5) [s ⊕ 2i, s ⊕ 2i+1](cid:107) ≥ (cid:107)st (cid:5) f(cid:107) Substituting (cid:107)st (cid:5) [s ⊕ 2i, s ⊕ 2i+1](cid:107) for (3), we retrieve it via a single table look-up in (ii) in constant time. By definition, every L-short path st (cid:5) f satisfies sf ≤ L or f t ≤ L. So by the above lemma, data structure introduced in section 7.1 answers every L-short path query. Together with the structures in section 6.1, it makes an (cid:104)O(n2 log log n), O(1)(cid:105) DSO. 8 Two-level partition In this section, we obtain an (cid:104)O(n2), O(1)(cid:105) construction of DSO. The high-level idea is that we further partition every sub-tree into even smaller ones, and then we apply a tabulation ("Four Russians") technique to store all answers. More specifically, we apply the tree-partitioning lemma for the second time and break each SSSP tree into sub-trees of size ≤ log log2 n. Then we devise data structures to reduce log2 n-short paths to log log2 n-short paths. Finally, the tabulation technique kicks in when it comes to log log2 n-short paths. 8.1 Data structure Let L(cid:48) ≤ L be a parameter to be set later. For each SSSP tree Ts ((cid:98)Ts), compute its tree partition with same sub-tree of (cid:98)Tt. parameter (cid:100)n/(L(cid:48) − 1)(cid:101) by Lemma 5.1, and let M(cid:48) s) be the corresponding marked set. For any L-short path st (cid:5) f, without loss of generality assume that t, f lie in the same sub-tree of Ts after removing Ms, and let r be the root of this sub-tree. Note that similar structures are also built for the case when s, f lie in the s ((cid:99)M(cid:48) (i) If t is not M(cid:48) s-marked. Let u be t's nearest M(cid:48) s-marked ancestor below r (if such u exists), and store the value of (cid:107)st (cid:5) [r, u](cid:107). (ii) If t is M(cid:48) s-marked. Let u1 → u2 → ······ → uk = t be the sequence of all M(cid:48) s-marked ancestor along the directed path rt. Note that k < L = O(log2 n). Then for each k − 2i ∈ [1, k − 1], store the value of (cid:107)st (cid:5) [r, uk−2i](cid:107). After that, for each f ∈ [uk−1, uk) (define u0 = r), store the value of (cid:107)st (cid:5) f(cid:107). (iii) Build upon the marked set M(cid:48) s all structures from (i) to (vi) in section 6.1. The only difference is that we impose an additional constraint that st ≤ L on structures (i) through (iii). It is not hard to verify + n2). So if st (cid:5) f is that the space complexity of this part becomes O( n2 log2 L non-L(cid:48)-short, with st ≤ L, then applying lemma 6.1, (cid:107)st (cid:5) f(cid:107) can be answered in constant time. L(cid:48) + n2) = O( n2 log log2 n L(cid:48) Note that the space complexity of (i) and (ii) in section 8.1 is equal to O( n2 log log n with (iii), the overall space complexity of the data structure is O(n2 + n2 log log n L(cid:48) = log log2 n, the space becomes O(n2). L(cid:48) L(cid:48) + n2 log log2 n + n2). Together ). Taking L(cid:48) 8.2 Reduction algorithm We prove the following lemma. Lemma 8.1. Given an L-short replacement path st (cid:5) f, the data structure in sections 8.1 and 6.1 can reduce (cid:107)st (cid:5) f(cid:107) to a constant number of (cid:107)uv (cid:5) f(cid:107)'s, where uv (cid:5) f's are L(cid:48)-short with respect to M(cid:48) u or (cid:99)M(cid:48) v. 9 We first argue that we will only need to concentrate on situations where t is M(cid:48) Proof. Constant time verification of L(cid:48)-shortness is easy. So we only need to consider when st (cid:5) f is not L(cid:48)-short. s-marked. Here is the reduction. If t is not M(cid:48) s-marked ancestor u below f. Vertex u must exist, since otherwise st (cid:5) f itself would become an L(cid:48)-short path. Recall that r is the root of the sub-tree after removing Ms, and since st (cid:5) f is L-short, f must be after r in st. We apply the triple path lemma on st (cid:5) f and interval [r, u]. s-marked, locate t's nearest M(cid:48) (1) (cid:107)sr(cid:107) + (cid:107)rt (cid:5) f(cid:107). In this case, we only need to consider (cid:107)rt (cid:5) f(cid:107). If rt(cid:5) f is not L(cid:48)-short, then since rt is guaranteed to be ≤ L, similar to the proof of lemma 6.1, (cid:107)rt(cid:5) f(cid:107) can be computed in O(1) time by (iii). If rt (cid:5) f is L(cid:48)-short, then we deliver rt (cid:5) f as one result of the reductions. Note. Here rt (cid:5) f's L(cid:48)-shortness is defined by M(cid:48) t, with respect to tree Tr or (cid:98)Tt. r or (cid:99)M(cid:48) (2) (cid:107)st (cid:5) [r, u](cid:107). We retrieve this distance directly from (i) in section 8.1. (3) (cid:107)su (cid:5) f(cid:107) + (cid:107)ut(cid:107). The reduction ends here. Next we will continue to work out (cid:107)su (cid:5) f(cid:107). Now we can assume without loss of generality that t is M(cid:48) s-marked. Let u1 → u2 → ······ → up = t s-marked vertices along the path rt. Suppose f ∈ [ua, ua+1), a ≥ 0 (u0 = r). If be the sequence of all M(cid:48) a + 1 = p, then (ii) enables us to directly query (cid:107)st (cid:5) f(cid:107). Otherwise, let i be the maximum index such that p − 2i ≥ a + 1. Invoke again the triple path lemma on st (cid:5) f and interval [r, up−2i]. (1) (cid:107)sr(cid:107) + (cid:107)rt (cid:5) f(cid:107). This can be solved in a similar fashion as in the previous case (1). (2) (cid:107)st (cid:5) [r, up−2i](cid:107). (ii) gives us (cid:107)st (cid:5) [r, up−2i](cid:107) in constant time. (3) (cid:107)sup−2i (cid:5) f(cid:107) + (cid:107)up−2it(cid:107). Such a replacement path is guaranteed to pass through ua+2i+1. Thereby, (cid:107)sup−2i (cid:5) f(cid:107) + (cid:107)up−2it(cid:107) ≥ (cid:107)sua+2i+1 (cid:5) f(cid:107) + (cid:107)ua+2i+1t(cid:107) ≥ (cid:107)st (cid:5) f(cid:107) So it suffices to compute (cid:107)sua+2i+1 (cid:5) f(cid:107) +(cid:107)ua+2i+1t(cid:107). Invoking the triple path lemma on sua+2i+1 (cid:5) f and interval [r, ua+1], we divide it into the following three cases. (a) (cid:107)sua+1 (cid:5) f(cid:107) + (cid:107)ua+1ua+2i+1(cid:107). (cid:107)sua+1 (cid:5) f(cid:107) can be retrieved from (ii). (b) (cid:107)sr(cid:107) + (cid:107)rua+2i+1 (cid:5) f(cid:107). If rua+2i+1 (cid:5) f is not L(cid:48)-short, then by rua+2i+1 ≤ L, (cid:107)rua+2i+1 (cid:5) f(cid:107) can be calculated in O(1) time by (iii) in section 8.1, similar to the proof of lemma 6.1. If rua+2i+1 (cid:5) f is L(cid:48)-short, then we deliver it as one result of the reductions. Note. Here rua+2i+1 (cid:5) f's L(cid:48)-shortness is defined by M(cid:48) , with respect to tree Tr or r or (cid:99)M(cid:48) ua+2i+1 (cid:98)Tua+2i+1 . (c) (cid:107)sua+2i+1 (cid:5) [r, ua+1](cid:107). (cid:107)sua+2i+1 (cid:5) [r, ua+1](cid:107) can be found from memory storage of (ii) in section 8.1. 10 8.3 Tabulation In this sub-section, we handle all L(cid:48)-short paths. Recall that the notation ∆s,t,f ,∇s,t,f refers to divergence and convergence of replacement path st (cid:5) f. We will simply write ∆,∇ because indices s, t, f can be learnt from context. Let st (cid:5) f be an L(cid:48)-short path; without loss of generality assume that t, f lie in the same sub-tree, the s. One observation is that we only need to focus on cases where s∆ ≤ L: corresponding marked set being M(cid:48) nearest (cid:99)Mt-marked ancestor in tree (cid:98)Tt. Since f t ≤ L(cid:48) < L < 2L, (cid:107)ut (cid:5) f(cid:107) can be found in (iv) from section if the divergence comes after s ⊕ L, then it admits the decomposition (cid:107)st (cid:5) f(cid:107) = (cid:107)su(cid:107) + (cid:107)ut (cid:5) f(cid:107), u being s's For each sub-tree T partitioned by marked set M(cid:48) 6.1. s, we in-order sort all its vertices. The aggregate divergence / convergence information within this sub-tree can be summarized as an L(cid:48) × L(cid:48) matrix, each element being a pair (s∆,∇t) corresponding to a replacement path st (cid:5) f, ∀t, f ∈ V (T ). Since we only consider the case when s∆ ≤ L, the total number of choices for this matrix is no more than (L · L(cid:48))(L(cid:48))2 Construct an indexable table of all possible configurations of such matrices. The space of this table is ≤ O(n · (L(cid:48))2) = o(n1.1). Then associate each sub-tree with an index of its corresponding matrix in the table, which demands a storage of O(n/L(cid:48)) indices, totalling o(n) space for every s. Thus the overall space complexity associated with tabulation is o(n2). Now the L(cid:48)-short (cid:107)st (cid:5) f(cid:107) can be computed effortlessly. After indexing the corresponding matrix in the table, we can extract (s∆,∇t) directly from this matrix, and then recover ∆,∇ from level-ancestor data structures. Finally, decompose the replacement path as (cid:107)st (cid:5) f(cid:107) = (cid:107)s∆(cid:107) + (cid:107)∆∇ (cid:5) (∆,∇)(cid:107) + (cid:107)∇t(cid:107). Noticing that ∆∇ (cid:5) f = ∆∇ (cid:5) (∆,∇), thereby the value of (cid:107)∆∇ (cid:5) f(cid:107) is equal to any admissible function value F [∆⊕1,∇(cid:9)1] . Hence, storing a (cid:107)uv (cid:5) [u ⊕ 1, v (cid:9) 1](cid:107) for every pair of u, v will suffice for querying (cid:107)st (cid:5) f(cid:107) once ∆,∇ divergence and convergence vertices are known. < L2(L(cid:48))2 = 24 log log5 n < O(2log n) = O(n). 9 Concluding remarks It is also convenient to slightly extend our data structure to retrieve the entire replacement path in O(st (cid:5) f) time, for any query (s, t, f ): for each entry in our DSO of the form (cid:107)st (cid:5) A(cid:107), A being a vertex set, store the first edge of the path st (cid:5) A. This adjustment does not affect our asymptotic space complexity. In this way, for any (s, t, f ), the DSO can answer not only (cid:107)st (cid:5) f(cid:107), but also the first edge, say (s, s(cid:48)) ∈ E, of replacement path st (cid:5) f. To recover the entire st (cid:5) f, we recur on s(cid:48)t (cid:5) f. Since each iteration reveals a single edge, the total time would be O(st (cid:5) f). So far we have devised an (cid:104)O(n2), O(1)(cid:105) DSO. Clearly both of the space complexity and query efficiency have reached asymptotic optima; also its preprocessing time is O(mn) (see appendix), which is nearly optimal. References [1] Ittai Abraham, Shiri Chechik, and Cyril Gavoille. Fully dynamic approximate distance oracles for planar graphs via forbidden-set distance labels. In Proceedings of the Forty-fourth Annual ACM Symposium on Theory of Computing, STOC '12, pages 1199 -- 1218, New York, NY, USA, 2012. ACM. [2] Ittai Abraham, Shiri Chechik, and Kunal Talwar. Fully dynamic all-pairs shortest paths: Breaking the o(n) barrier. In APPROX-RANDOM, pages 1 -- 16, 2014. [3] V. L. Arlazarov, E. A. Dinic, M. A. Kronrod, and I. A. Faradžev. On economical construction of the transitive closure of a directed graph. Soviet Mathematics -- Doklady, 11(5):1209 -- 1210, 1970. [4] M. A. Bender and M. Farach-Colton. The level ancestor problem simplified. Theoretical Computer Science, 321(1):5 -- 12, 2004. [5] A. Bernstein and D. Karger. Improved distance sensitivity oracles via random sampling. In Proceedings 19th ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 34 -- 43, 2008. 11 [6] A. Bernstein and D. Karger. A nearly optimal oracle for avoiding failed vertices and edges. In Proceedings 41st Annual ACM Symposium on Theory of Computing (STOC), pages 101 -- 110, 2009. [7] Shiri Chechik, Michael Langberg, David Peleg, and Liam Roditty. f-sensitivity distance oracles and routing schemes. Algorithmica, 63(4):861 -- 882, August 2012. [8] C. Demetrescu and G. F. Italiano. A new approach to dynamic all pairs shortest paths. J. ACM, 51(6):968 -- 992, 2004. [9] C. Demetrescu, M. Thorup, R. A. Chowdhury, and V. Ramachandran. Oracles for distances avoiding a failed node or link. SIAM J. Comput., 37(5):1299 -- 1318, 2008. [10] Camil Demetrescu and Giuseppe F. Italiano. Fully dynamic all pairs shortest paths with real edge weights. J. Comput. Syst. Sci., 72(5):813 -- 837, August 2006. [11] Camil Demetrescu and Mikkel Thorup. Oracles for distances avoiding a link-failure. In Proceedings of the Thirteenth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA '02, pages 838 -- 843, Philadelphia, PA, USA, 2002. Society for Industrial and Applied Mathematics. [12] R. Duan and S. Pettie. Dual-failure distance and connectivity oracles. In Proceedings 20th ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 506 -- 515, 2009. [13] M. L. Fredman and D. E. Willard. Surpassing the information-theoretic bound with fusion trees. J. Comput. Syst. Sci., 47(3):424 -- 436, 1993. [14] Fabrizio Grandoni and Virginia Vassilevska Williams. Improved distance sensitivity oracles via fast single-source replacement paths. In FOCS, pages 748 -- 757. IEEE Computer Society, 2012. [15] Monika Henzinger, Sebastian Krinninger, and Danupon Nanongkai. Dynamic approximate all-pairs shortest paths: Breaking the o(mn) barrier and derandomization. In FOCS 2013 54th Annual IEEE Symposium on Foundations of Computer Science, Proceedings 2013 IEEE 54th Annual Symposium on Foundations of Computer Science FOCS 2013, pages 538 -- 547, Los Alamitos, CA, October 2013. IEEE. [16] Monika Henzinger, Sebastian Krinninger, and Danupon Nanongkai. Sublinear-time decremental algo- rithms for single-source reachability and shortest paths on directed graphs. In 46th ACM Symposium on Theory of Computing (STOC 2014), June 2014. [17] Monika Henzinger, Sebastian Krinninger, and Danupon Nanongkai. A subquadratic-time algorithm for decremental single-source shortest paths. In SODA 2014, Philadelphia, January 2014. SIAM. [18] J. Hershberger and S. Suri. Vickrey prices and shortest paths: what is an edge worth? In Proceedings 42nd IEEE Symposium on Foundations of Computer Science (FOCS), pages 252 -- 259, 2001. Erratum, Proc. 43rd FOCS, p. 809, 2002. [19] Neelesh Khanna and Surender Baswana. Approximate shortest paths avoiding a failed vertex: Optimal size data structures for unweighted graphs. In 27th International Symposium on Theoretical Aspects of Computer Science, STACS 2010, March 4-6, 2010, Nancy, France, pages 513 -- 524, 2010. [20] Mihai Patrascu and Liam Roditty. Distance oracles beyond the thorup-zwick bound. In Proceedings of the 2010 IEEE 51st Annual Symposium on Foundations of Computer Science, FOCS '10, pages 815 -- 823, Washington, DC, USA, 2010. IEEE Computer Society. [21] M. Thorup. Worst-case update times for fully-dynamic all-pairs shortest paths. In Proceedings 37th ACM Symposium on Theory of Computing (STOC), pages 112 -- 119, 2005. 12 A Preprocessing algorithm In this section, we present a preprocessing algorithm that runs in O(mn) time. Basically, computing replacement path that skips an entire interval is hard. To eschew such hardness, we employ the idea of admissible functions [5] and change replacement paths of the form st (cid:5) [u, v] to certain st (cid:5) f ones without harming the correctness of query algorithms. Indeed, the data structure we constructs here is not exactly the one we have described, but an equivalent one. Then, to build our DSO, we first apply the randomized preprocessing algorithm from [6] that runs in time O(mn log n + n2 log2 n) to obtain a less space-efficient DSO. Finally, using this intermediate DSO we can compute the (cid:104)O(n2), O(1)(cid:105) DSO in O(mn) time. Note. Although invoking [6]'s algorithm as a black-box may introduce randomness, rest are entirely determin- istic. So if we apply the deterministic but slightly less efficient preprocessing algorithm that also appeared in [6], our initializing algorithm can then become deterministic, still with O(mn) time bound. A.1 Preliminary Values of (cid:107)st(cid:107) and st can be handled by invoking standard all-pairs shortest paths (APSP) algorithms, which will not be our bottleneck. Computing Interval admissible function values is time consuming. In our preprocessing algorithm, instead of computing entry values of the form (cid:107)st (cid:5) [u, v](cid:107), we compute maxf∈[u,v]{(cid:107)st(cid:5)f(cid:107)}; namely we replace every interval admissible function value demanded by our DSO with its bottleneck counterpart. For example, in (ii) from 6.1, what we actually compute is maxf∈[uk−2i ,uk−2i+1] (cid:107)st (cid:5) f(cid:107). All the query / reduction algorithms need to be adapted accordingly. This is not hard because the triple path lemma holds for arbitrary admissible functions. Hence, our (cid:104)O(n2), O(1)(cid:105) DSO is mostly composed of entries of the form maxf∈[u,v] (cid:107)st (cid:5) [u, v](cid:107). Once all such entries are computed, other parts (say, tabulation) become easy. Therefore we only need to deal with entries that take the form of maxf∈[u,v] (cid:107)st (cid:5) [u, v](cid:107). The idea is to build an oracle that answers any query maxf∈[u,v] (cid:107)st (cid:5) f(cid:107) in O(log n) time; note that this oracle is more powerful than ordinary DSO. As we will see, this stronger oracle can be constructed in time O(mn). Firstly we invoke [6]'s algorithm that builds an (cid:104)O(n2 log n), O(1)(cid:105) DSO in O(mn) time, by which queries of (cid:107)st (cid:5) f(cid:107) can be computed in constant time. However, we cannot afford to peek every value of (cid:107)st (cid:5) f(cid:107), f ∈ [u, v] in order to obtain maxf∈[u,v] (cid:107)st (cid:5) f(cid:107), since otherwise the preprocessing time would be blown up to an undesirable Ω(n3). Fortunately, an important sub-routine from [6]'s algorithm directly helps us out: instead of grid-searching along the interval [u, v], one can perform a certain kind of binary search on [u, v] to identify the bottleneck f that maximizes (cid:107)st (cid:5) f(cid:107). failed vertex f ∈ [u, v], define: We inherit some notations from [6]. For any interval [u, v] on the shortest path st, as well as a presumably M T C(s, t, f, u, v) ∆= min{(cid:107)su(cid:107) + (cid:107)ut (cid:5) f(cid:107),(cid:107)sv (cid:5) f(cid:107) + (cid:107)vt(cid:107)} So by the triple path lemma, (cid:107)st (cid:5) f(cid:107) = min{M T C(s, t, f, u, v),(cid:107)st (cid:5) [u, v](cid:107)}. A key observation from [6] is that, the bottleneck vertex f always maximizes the first term M T C(s, t, f, u, v), because the second term (cid:107)st (cid:5) [u, v](cid:107) is independent of f. Therefore, in order to locate bottleneck vertex f, it is equivalent to maximizing M T C(s, t, f, u, v). The following lemma will also be useful. Lemma A.1 ([6]). If (cid:107)su(cid:107) + (cid:107)ut (cid:5) f(cid:107) > (cid:107)sv (cid:5) f(cid:107) + (cid:107)vt(cid:107), then sv (cid:5) f skips over u. A.2 Data structure In this section, we introduce the structures of our stronger oracle that answers any queries of form maxf∈[u,v] (cid:107)st (cid:5) f(cid:107). 1 ≤ i ≤ log2 n, For every reverse SSSP tree (cid:98)Tt, apply the tree partition lemma 5.1 with L = 2i and obtain a Generally speaking, we apply a scaling technique that deals with intervals [u, v] of different sizes. For any marked set Bi t, construct an array of length 2i+2, for each f ∈ (s, s⊕ 2i+1] fill in the sfth entry with value (cid:107)st(cid:5) f(cid:107) (again note that this value is retrievable in constant t = O(n/2i). For any marked vertex s ∈ Bi t, Bi 13 in constant time on any interval within (s, s ⊕ 2i+2]. Symmetrically, we compute set marked (cid:98)Bi time via the intermediate DSO from [6]). If st ≤ 2i+2, we simply cover the entire st. After that, build a range maximum query data (RMQ) structure on this array, which allows us to locate the bottleneck vertex s associated For each i, the construction time is only O(n · n/2i · 2i+2) = O(n2). So the overall construction time is with each SSSP tree Ts and build a similar RMQ. O(n2). A.3 Query algorithm In this section, we show how bottleneck vertices can be efficiently computed using data structures in the previous section. Suppose we wish to compute a bottleneck vertex in [u, v] on st. Assume 2i+1 ≤ uv < 2i+2, i > 0. Since t ∩ [u, (u + v)/2] are non-empty. Using level ancestor data uv ≥ 2i+1, both of (cid:98)Bi structures we can locate a vertex u(cid:48) ∈ Bi To finish up, now we can directly apply the poly-log time sub-routine from [6] to locate the bottleneck vertex on interval [u(cid:48), v], as described in a recursive procedure FindBot below, where s, t, u(cid:48), v are deemed global parameters, and the input [x, y] ⊆ [u(cid:48), v] is a sub-interval. The bottleneck vertex on interval [u, v(cid:48)] can be computed in a symmetrical way. s ∩ ((u + v)/2, v]. s ∩ ((u + v)/2, v] and Bi t ∩ [u, (u + v)/2] and v(cid:48) ∈ (cid:98)Bi compute the botttleneck vertex in the trivial way and return; Algorithm 1: FindBot([x, y]) from [6] 1 if xy ≤ 2 then 2 3 q ← (x + y)/2, namely the mid-vertex on xy; 4 b ← the bottleneck vertex with respect to interval [q, y] on u(cid:48)t, using RMQ; 5 if (cid:107)su(cid:48)(cid:107) + (cid:107)u(cid:48)t (cid:5) b(cid:107) ≤ (cid:107)sv (cid:5) b(cid:107) + (cid:107)vt(cid:107) then 6 7 8 else 9 w ← FindBot([x, q)); return arg maxb,w{M T C(s, t, b, u(cid:48), v), M T C(s, t, w, u(cid:48), v)}; return FindBot([q, y]); from exactly the same arguments as in [6], but for completeness we restate the proof below. Clearly the running time is O(log n). Therefore, our query algorithm is O(log n). Correctness follows We show that FindBot([u(cid:48), v]) finds a vertex f that maximizes M T C(s, t, f, u(cid:48), v). Consider an arbitrary level of recursion with input [x, y]. Let's focus on line-5. If the branching condition holds true, then it suffices to prove that the bottleneck vertex with respect to interval [q, y] is b itself. In fact, for any f ∈ [q, y], we have: M T C(s, t, f, u(cid:48), v) ≤ (cid:107)su(cid:48)(cid:107) + (cid:107)u(cid:48)t (cid:5) f(cid:107) ≤ (cid:107)su(cid:48)(cid:107) + (cid:107)u(cid:48)t (cid:5) b(cid:107) = M T C(s, t, b, u(cid:48), v) The second inequality is guaranteed by the function of RMQ. the bottleneck vertex cannot be in interval [x, q). For any f ∈ [x, q), we have: Alternatively, if the branching condition is false, namely (cid:107)su(cid:48)(cid:107) + (cid:107)u(cid:48)t (cid:5) b(cid:107) > (cid:107)sv (cid:5) b(cid:107) + (cid:107)vt(cid:107), we argue that M T C(s, t, f, u(cid:48), v) ≤ (cid:107)sv (cid:5) f(cid:107) + (cid:107)vt(cid:107) ≤ (cid:107)sv (cid:5) b(cid:107) + (cid:107)vt(cid:107) = M T C(s, t, b, u(cid:48), v) The second inequality holds because according to lemma A.1, sv (cid:5) b skips over u(cid:48), thus the entire interval [u(cid:48), q] which subsumes f, and this yields (cid:107)sv (cid:5) f(cid:107) ≤ (cid:107)sv (cid:5) b(cid:107). 14
1710.04376
2
1710
2017-10-23T16:42:58
On the Power of Tree-Depth for Fully Polynomial FPT Algorithms
[ "cs.DS", "cs.CC", "cs.DM" ]
There are many classical problems in P whose time complexities have not been improved over the past decades. Recent studies of "Hardness in P" have revealed that, for several of such problems, the current fastest algorithm is the best possible under some complexity assumptions. To bypass this difficulty, Fomin et al. (SODA 2017) introduced the concept of fully polynomial FPT algorithms. For a problem with the current best time complexity $O(n^c)$, the goal is to design an algorithm running in $k^{O(1)}n^{c'}$ time for a parameter $k$ and a constant $c'<c$. In this paper, we investigate the complexity of graph problems in P parameterized by tree-depth, a graph parameter related to tree-width. We show that a simple divide-and-conquer method can solve many graph problems, including Weighted Matching, Negative Cycle Detection, Minimum Weight Cycle, Replacement Paths, and 2-hop Cover, in $O(\mathrm{td}\cdot m)$ time or $O(\mathrm{td}\cdot (m+n\log n))$ time, where $\mathrm{td}$ is the tree-depth of the input graph. Because any graph of tree-width $\mathrm{tw}$ has tree-depth at most $(\mathrm{tw}+1)\log_2 n$, our algorithms also run in $O(\mathrm{tw}\cdot m\log n)$ time or $O(\mathrm{tw}\cdot (m+n\log n)\log n)$ time. These results match or improve the previous best algorithms parameterized by tree-width. Especially, we solve an open problem of fully polynomial FPT algorithm for Weighted Matching parameterized by tree-width posed by Fomin et al.
cs.DS
cs
On the Power of Tree-Depth for Fully Polynomial FPT Algorithms Yoichi Iwata ∗†‡ Tomoaki Ogasawara §¶ Naoto Ohsaka §k Abstract There are many classical problems in P whose time complexities have not been improved over the past decades. Recent studies of "Hardness in P" have revealed that, for several of such problems, the current fastest algorithm is the best possible under some complexity assumptions. To bypass this difficulty, Fomin et al. (SODA 2017) introduced the concept of fully polynomial FPT algorithms. For a problem with the current best time complexity O(nc), the goal is to design an algorithm running in kO(1)nc′ time for a parameter k and a constant c′ < c. In this paper, we investigate the complexity of graph problems in P parameterized by tree- depth, a graph parameter related to tree-width. We show that a simple divide-and-conquer method can solve many graph problems, including Weighted Matching, Negative Cycle Detection, Minimum Weight Cycle, Replacement Paths, and 2-hop Cover, in O(td · m) time or O(td · (m + n log n)) time, where td is the tree-depth of the input graph. Because any graph of tree-width tw has tree-depth at most (tw + 1) log2 n, our algorithms also run in O(tw · m log n) time or O(tw · (m + n log n) log n) time. These results match or improve the previous best algorithms parameterized by tree-width. Especially, we solve an open problem of fully polynomial FPT algorithm for Weighted Matching parameterized by tree-width posed by Fomin et al. 1 Introduction There are many classical problems in P whose time complexities have not been improved over the past decades. For some of such problems, recent studies of "Hardness in P" have provided evidence of why obtaining faster algorithms is difficult. For instance, Vassilevska Williams and Williams [33] and Abboud, Grandoni and Vassilevska Williams [1] showed that many problems including Minimum Weight Cycle, Replacement Paths, and Radius are equivalent to All Pair Shortest Paths (APSP) under subcubic reductions; that is, if one of them admits a subcubic-time algorithm, then all of them do. One of the approaches to bypass this difficulty is to analyze the running time by introducing another measure, called a parameter, in addition to the input size. In the theory of parameterized complexity, a problem with a parameter k is called fixed parameter tractable (FPT) if it can be solved in f (k) · IO(1) time for some function f (k) that does not depend on the input size I. While the main aim of this theory is to provide fine-grained analysis of NP-hard problems, it is ∗National Institute of Informatics 2-1-2 Hitotsubashi, Chiyoda-ku, Tokyo, Japan †[email protected] ‡Supported by JSPS KAKENHI Grant Number JP17K12643 §The University of Tokyo 7-3-1, Hongo, Bunkyo-ku, Tokyo, Japan ¶[email protected] [email protected] 1 also useful for problems in P. For instance, a simple dynamic programming can solve Maximum Matching in O(3twm) time, where m is the number of edges and tw is a famous graph parameter called tree-width which intuitively measures how much a graph looks like a tree (see Section 2 for the definition). Therefore, it runs in linear time for any graph of constant tree-width, which is faster than the current best O(√nm) time for the general case [5, 31, 15]. When working on NP-hard problems, we can only expect superpolynomial (or usually expo- nential) function f (k) in the running time of FPT algorithms (unless k is exponential in the input size). On the other hand, for problems in P, it might be possible to obtain a kO(1)IO(1)-time FPT algorithm. Such an algorithm is called fully polynomial FPT. For instance, Fomin, Lokshtanov, Pilipczuk, Saurabh and Wrochna [11] obtained an O(tw4 · n log2 n)-time (randomized) algorithm for Maximum Matching and left as an open problem whether a similar running time is possible In contrast to the O(3twm)-time dynamic programming, this algo- for Weighted Matching. 8 −ǫ). rithm is faster than the current best general-case algorithm already for graphs of tw = O(n In general, for a problem with the current best time complexity O(nc), the goal is to design an algorithm running in O(kdnc′ ) time for some small constants d and c′ < c. Such an algorithm is faster than the current best general-case algorithm already for inputs of k = O(n(c−c′)/d−ǫ). On the negative side, Abboud, Vassilevska Williams and Wang [2] showed that Diameter and Radius do not admit 2o(tw)n2−ǫ-time algorithms under some plausible assumptions. In this paper, we give new or improved fully polynomial FPT algorithms for several classical graph problems. Especially, we solve the above open problem for Weighted Matching. 1 Our approach. Before describing our results, we first give a short review of existing work on fully polynomial FPT algorithms parameterized by tree-width and explain our approach. There are roughly three types of approaches in the literature. The first approach is to use a polynomial-time dynamic programming on a tree-decomposition, which has been mainly used for problems related to shortest paths [7, 27, 4, 32]. The second approach is to use an O(tw3·n)-time Gaussian elimination of matrices of small tree-width developed by Fomin et al. [11]. The above-mentioned O(tw4· n log2 n)- time algorithm for Maximum Matching was obtained by this approach. The third approach is to apply a divide-and-conquer method exploiting the existence of small balanced separators. This approach was first used for planar graphs by Lipton and Tarjan [21]. Using the existence of O(√n)- size balanced separators, they obtained an O(n1.5)-time algorithm for Maximum Matching and an O(n1.5 log n)-time algorithm for Weighted Matching for planar graphs. For graphs of bounded tree-width, Akiba, Iwata and Yoshida [3] obtained an O(tw · (m + n log n) log n)-time algorithm for 2-hop Cover, which is a problem of constructing a distance oracle, and Fomin et al. [11] obtained an O(tw · m log n)-time1 algorithm for Vertex-disjoint s− t Paths. We obtain fully polynomial FPT algorithms for a wide range of problems by using this approach. Our key observation is that, when using the divide-and-conquer approach, another graph parameter called tree-depth is more powerful than the tree-width. A graph G of tree-width tw admits a set S of tw + 1 vertices, called a balanced separator, such that each connected component of G − S contains at most n 2 vertices. In both of the above- mentioned divide-and-conquer algorithms for graphs of bounded tree-width by Akiba et al. [3] and 1While the running time shown in [11] is O(tw2 · n log n), we can easily see that it also runs in O(tw · m log n) time. Because m = O(tw · n) holds for any graphs of tree-width tw, the latter is never worse than the former. Note that tw · n in the running time of other algorithms cannot be replaced by m in general; e.g., we cannot bound the running time of the Gaussian elimination by O(tw2 · m), where m is the number of non-zero elements. 2 Table 1: Comparison of previous results and our results. n and m denotes the number of vertices and edges, w denotes the width of the given tree-decomposition, and d denotes the depth of the given elimination forest. The factor d in our results can be replaced by w · log n. Our result O(dm) O(d(m + n log n)) O(d(m + n log n)) O(d(m + n log n)) O(d(m + n log n)) O(w(m + n log n) log n) [3] O(d(m + n log n)) Problem Maximum Matching Weighted Matching Negative Cycle Detection O(w2n) [27] Minimum Weight Cycle Replacement Paths 2-hop Cover Previous result O(w4n log2 n) [11] Open problem [11] - - Fomin et al. [11], after the algorithm recursively computes a solution for each connected component of G− S, it constructs a solution for G in O(tw· (m + n log n)) time or O(tw· m) time, respectively. Because the depth of the recursive calls is bounded by O(log n), the total running time becomes O(tw · (m + n log n) log n) or O(tw · m log n), respectively. Here, we observe that, by using tree-depth, this kind of divide-and-conquer algorithm can be simplified and the analysis can be improved. Tree-depth is a graph parameter which has been studied under various names [29, 19, 6, 25]. A graph has tree-depth td if and only if there exists an elimination forest of depth td. See Section 2 for the precise definition of the tree-depth and the elimination forest. An important property of tree-depth is that any connected graph G of tree-depth td can be divided into connected components of tree-depth at most td − 1 by removing a single vertex r. Therefore, if there exists an O(m)-time or O(m + n log n)-time incremental algorithm, which constructs a solution for G from a solution for G − r, we can solve the problem in O(td · m) time or O(td · (m + n log n)) time, respectively. Now, the only thing to do is to develop such an incremental algorithm for each problem. We present a detailed discussion of this framework in Section 3. Because any graph of tree-width tw has tree-depth at most (tw + 1) log2 n [24], the running time can also be bounded by O(tw · m log n) or O(tw · (m + n log n) log n). Therefore, our analysis using tree-depth is never worse than the existing results directly using tree-width. On the other hand, there are infinitely many graphs whose tree-depth has asymptotically the same bound as tree-width. For instance, if every N -vertex subgraph admits a balanced separator of size O(N α) for some constant α > 0 (e.g., α = 1 2 for H-minor free graphs), both tree-width and tree-depth are O(nα). Hence, for such graphs, the time complexity using tree-depth is truly better than that using tree-width. Our results. Table 1 shows our results and the comparison to the existing results on fully polynomial FPT algorithms parameterized by tree-width. The formal definition of each problem is given in Section 4. Because obtaining an elimination forest of the lowest depth is NP-hard, we assume that an elimination forest is given as an input and the parameter for our results is the depth d of the given elimination forest. Similarly, for the existing results, the parameter is the width w of the given tree-decomposition. Note that, because a tree-decomposition of width w can be converted into an elimination forest of depth O(w · log n) in linear time [29], we can always replace the factor d in our running time by w · log n. The first polynomial-time algorithms for Maximum Matching and Weighted Matching 3 were obtained by Edmonds [10], and the current fastest algorithms run in O(√nm) time [5, 31, 15] and O(n(m + n log n)) time [5], respectively. Fomin et al. [11] obtained the O(w4n log2 n)- time randomized algorithm for Maximum Matching by using an algebraic method and the fast computation of Gaussian elimination. They left as an open problem whether a similar running time is possible for Weighted Matching. The general-case algorithms for these problems compute a maximum matching by iteratively finding an augmenting path, and therefore, they are already incremental. Thus, we can easily obtain an O(dm)-time algorithm for Maximum Matching and an O(d(m + n log n))-time algorithm for Weighted Matching. Note that the divide-and- conquer algorithms for planar matching by Lipton and Tarjan [21] also uses this augmenting-path approach, and our result can be seen as extension to bounded tree-depth graphs. Our algorithm for Maximum Matching is always faster2 than the one by Fomin et al. and is faster than the general- 2 −ǫ). Our algorithm for Weighted Matching settles the case algorithm already when d = O(n open problem and is faster than the general-case algorithm already when d = O(n1−ǫ). 1 The current fastest algorithm for Negative Cycle Detection is the classical O(nm)-time Bellman-Ford algorithm. Planken et al. [27] obtained an O(w2n)-time algorithm by using a Floyd- Warshall-like dynamic programming. In this paper, we give an O(d(m + n log n))-time algorithm. While the algorithm by Planken et al. is faster than the general-case algorithm only when w = O(m 2 −ǫ), our algorithm achieves a faster running time already when d = O(n1−ǫ). 1 Both Minimum Weight Cycle (or Girth) and Replacement Paths are subcubic-equivalent to APSP [33]. A naive algorithm can solve both problems in O(n3) time or O(n(m + n log n)) time. For Minimum Weight Cycle of directed graphs, an improved O(nm)-time algorithm was recently obtained by Orlin and Sedeno-Noda [26]. For Replacement Paths, Malik et al. [22] obtained an O(m + n log n)-time algorithm for undirected graphs, and Roditty and Zwick [28] obtained an O(√nm · polylog n)-time algorithm for unweighted graphs. For the general case, Gotthilf and Lewenstein [16] obtained an O(n(m + n log log n))-time algorithm, and there exists an Ω(√nm)- time lower bound in the path-comparison model [18] (whenever m = O(n√n)) [17]. In this paper, we give an O(d(m + n log n))-time algorithm for each of these problems, which is faster than the general-case algorithm already when d = O(n1−ǫ). This result shows the following contrast to the known result of "Hardness in P": Radius is also subcubic-equivalent to APSP [1] but it cannot be solved in a similar running time under some plausible assumptions [2]. 2-hop cover [8] is a data structure for efficiently answering distance queries. Akiba et al. [3] obtained an O(w(m + n log n) log n)-time algorithm for constructing a 2-hop cover answering each distance query in O(w log n) time. In this paper, we give an O(d(m + n log n))-time algorithm for constructing a 2-hop cover answering each distance query in O(d) time. Related work. Coudert, Ducoffe and Popa [9] have developed fully polynomial FPT algo- rithms using several other graph parameters including clique-width. In contrast to the tree-depth, their parameters are not polynomially bounded by tree-width, and therefore, their results do not imply fully polynomial FPT algorithms parameterized by tree-width. Mertzios, Nichterlein and Niedermeier [23] have obtained an O(m + k1.5)-time algorithm for Maximum Matching parame- terized by feedback edge number k (= m−n+1 when the graph is connected) by giving a linear-time kernel. 2Note that for any graph of tree-width or tree-depth k, we have m = O(kn). 4 2 Preliminaries Let G = (V, E) be a directed or undirected graph, where V is a set of vertices of G and E is a set of edges of G. When the graph is clear from the context, we use n to denote the number of vertices and m to denote the number of edges. All the graphs in this paper are simple (i.e., they have no multiple edges nor self-loops). Let S ⊆ V be a subset of vertices. We denote by E[S] the set of edges whose endpoints are both in S and denote by G[S] the subgraph induced by S (i.e., G[S] = (S, E[S])). A tree decomposition of a graph G = (V, E) is a pair (T, B) of a tree T = (X, F ) and a collection of bags {Bx ⊆ V x ∈ X} satisfying the following two conditions. • For each edge uv ∈ E, there exists some x ∈ X such that {u, v} ⊆ Bx. • For each vertex v ∈ V , the set {x ∈ X v ∈ Bx} induces a connected subtree in T . The width of (T, B) is the maximum of Bx − 1 and the tree-width tw(G) of G is the minimum width among all possible tree decompositions. An elimination forest T of a graph G = (V, E) is a rooted forest on the same vertex set V such that, for every edge uv ∈ E, one of u and v is an ancestor of the other. The depth of T is the maximum number of vertices on a path from a root to a leaf in T . The tree-depth td(G) of a graph G is the minimum depth among all possible elimination forests. Tree-width and tree-depth are strongly related as the following lemma shows. Lemma 1 ([24, 29]). For any graph G, the following holds. tw(G) + 1 ≤ td(G) ≤ (tw(G) + 1) log2 n. Moreover, given a tree decomposition of width k, we can construct an elimination forest of depth O(k log n) in linear time. 3 Divide-and-conquer framework In this section, we propose a divide-and-conquer framework that can be applicable to a wide range of problems parameterized by tree-depth. Theorem 1. Let G = (V, E) be a graph and let f be a function defined on subsets of V . Suppose that f (∅) can be computed in a constant time and we have the following two algorithms Increment and Union with time complexity T (n, m)(= Ω(n + m)). • Increment(X, f (X), x) 7→ f (X ∪ {x}). Given a set X ⊆ V , its value f (X), and a vertex x 6∈ X, this algorithm computes the value f (X ∪ {x}) in T (X ∪ {x},E[X ∪ {x}]) time. • Union((X1, f (X1)), . . . , (Xc, f (Xc))) 7→ f (Si Xi). Given disjoint sets X1, . . . , Xc ⊆ V such that G has no edges between Xi and Xj for any i 6= j, and their values f (X1), . . . , f (Xc), this algorithm computes the value f (Si Xi) in T (Si Xi,E[Si X]) time. Then, for a given elimination forest of G of depth k, we can compute the value f (V ) in O(k·T (n, m)) time. 5 Algorithm 1 Algorithm for computing f (V ). 1: procedure Compute(S, TS) 7→ f (S) ⊲ TS is an elimination forest of G[S]. 2: 3: 4: 5: 6: 7: 8: if S = ∅ then return f (∅) T1, . . . , Tc ← the connected trees of TS X1, . . . , Xc ← the sets of vertices of T1, . . . , Tc for i ∈ {1, . . . , c} do xi ← the root of Ti fi ← Increment(Xi \ {xi}, Compute(X \ {xi}, Ti − xi), xi) return Union((X1, f1), . . . , (Xc, fc)) Proof. Algorithm 1 describes our divide-and-conquer algorithm. We prove that for any set S and any elimination forest TS of G[S] of depth kS, the procedure Compute(S, TS ) correctly computes the value f (S) in (2kS + 1) · T (S,E[S]) time by induction on the size of S. The claim trivially holds when S = ∅. For a set S 6= ∅, let T1, . . . , Tc be the connected trees of TS (c = 1 if TS is connected). For each i, let Xi be the set of vertices of Ti. From the definition of the elimination forest, G has no edges between Xi and Xj for any i 6= j. For each i, we compute the value f (Xi) as follows. Let xi be the root of Ti. By removing xi from Ti, we obtain an elimination forest of G[Xi \ {xi}] of depth at most kS − 1. Therefore, by the induction hypothesis, we can correctly compute the value f (Xi \ {xi}) in (2kS − 1) · T (Xi,E[Xi]) time. Then, by applying Increment(Xi \ {xi}, f (Xi \ {xi}), xi), we obtain the value f (Xi) in 2kS · T (Xi,E[Xi]) time. Because S =Pi Xi and E[S] =Pi E[Xi] hold, the total running time of these computations is 2kS ·Pi T (Xi,E[Xi]) ≤ 2kS · T (S,E[S]). Finally, by applying the algorithm Union, we obtain the value f (S) in (2kS + 1) · T (S,E[S]) time. Note that the algorithm Union is trivial in most applications. We have only one non-trivial case in Section 4.5 in this paper. From the relation between tree-depth and tree-width (Lemma 1), we obtain the following corollary. Corollary 1. Under the same assumption as in Theorem 1, for a given tree decomposition of G of width k, we can compute the value f (V ) in O(k · T (n, m) log n) time. 4 Applications 4.1 Maximum matching For an undirected graph G = (V, E), a matching M of G is a subset of E such that no edges in M share a vertex. In this section, we prove the following theorem. Theorem 2. Given an undirected graph and its elimination forest of depth k, we can compute a maximum-size matching in O(km) time. As mentioned in the introduction, we use the augmenting-path approach, which is also used for planar matching [21]. Let M be a matching. A vertex not incident to M is called exposed. An M - alternating path is a (simple) path whose edges are alternately out of and in M . An M -alternating path connecting two different exposed vertices is called an M -augmenting path. If there exists an M -augmenting path P , by taking the symmetric difference M ∆E(P ), where E(P ) is the set of 6 edges in P , we can construct a matching of size M + 1. In fact, M is the maximum-size matching if and only if there exist no M -augmenting paths. Edmonds [10] developed the first polynomial- time algorithm for computing an M -augmenting path by introducing the notion of blossom, and an O(m)-time algorithm was given by Gabow and Tarjan [14]. Lemma 2 ([14]). Given an undirected graph and its matching M , we can either compute a matching of size M + 1 or correctly conclude that M is a maximum-size matching in O(m) time. For S ⊆ V , we define f (S) as a function that returns a maximum-size matching of G[S]. We now give algorithms Increment and Union. Increment(X, f (X), x). Because the size of the maximum matching of G[X ∪ {x}] is at most the size of the maximum matching of G[X] plus one, we can compute a maximum matching of G[X ∪{x}] in O(E[X ∪{x}]) time by a single application of Lemma 2. Union((X1, f (X1)), . . . , (Xc, f (Xc))). Because there exist no edges between Xi and Xj for any i 6= j, we can construct a maximum matching of G[Si Xi] just by taking the union of f (Xi). Proof of Theorem 2. The algorithm Increment(X, f (X), x) correctly computes f (X ∪ {x}) in O(E[X ∪ {x}]) time and the algorithm Union((X1, f (X1)), . . . , (Xc, f (Xc))) correctly computes f (Si Xi) in O(Si Xi) time. Therefore, from Theorem 1, we can compute a maximum-size match- ing of G in O(km) time. 4.2 Weighted matching Let G = (V, E) be an undirected graph with an edge-weight function w : E → R. A weight of a matching M , denoted by w(M ), is simply defined as the total weight of edges in M . A matching M of G is called perfect if G has no exposed vertices (or equivalently M = n 2 ). A perfect matching is called a maximum-weight perfect matching if it has the maximum weight among all perfect matchings of G. We can easily see that other variants of weighted matching problems can be reduced to the problem of finding a maximum-weight perfect matching even when parameterized by tree-depth (see Appendix A). In this section, we prove the following theorem. Theorem 3. Given an edge-weighted undirected graph admitting at least one perfect matching and its elimination forest of depth k, we can compute a maximum-weight perfect matching in O(k(m + n log n)) time. In our algorithm, we use an O(n(m + n log n))-time primal-dual algorithm by Gabow [12]. In this primal-dual algorithm, we keep a pair of a matching M and dual variables (Ω, y, z), where Ω is a laminar3 collection of odd-size subsets of V and y and z are functions y : V → R and z : Ω → R≥0, 3A collection Ω of subsets of a ground set V is called laminar if for any X, Y ∈ Ω, one of X ∩ Y = ∅, X ⊆ Y , or X ⊆ Y holds. When Ω is laminar, we have Ω = O(V ). 7 satisfying the following conditions: cyz(uv) := y(u) + y(v) + XB∈Ω:u,v∈B z(B) ≥ w(uv) cyz(uv) = w(uv) 2 (cid:23) {uv ∈ M u, v ∈ B} =(cid:22)B for every uv ∈ E, for every uv ∈ M, for every B ∈ Ω. (1) (2) (3) From the duality theory (see e.g. [13]), a perfect matching M is a maximum-weight perfect matching if and only if there exist dual variables (Ω, y, z) satisfying the above conditions. Gabow [12] obtained the O(n(m + n log n))-time algorithm by iteratively applying the following lemma. Lemma 3 ([12]). Given an edge-weighted undirected graph and a pair of a matching M and dual variables (Ω, y, z) satisfying the conditions (1)–(3), we can either compute a pair of a matching M ′ of cardinality M + 1 and dual variables (Ω′, y′, z′) satisfying the conditions (1)–(3) or correctly conclude that M is a maximum-size matching4 in O(m + n log n) time. For S ⊆ V , we define f (S) as a function that returns a pair of a maximum-size matching MS of G[S] and dual variables (ΩS, yS, zS ) satisfying the conditions (1)–(3). We now give algorithms Increment and Union. Increment(X, f (X), x). Let W be a value satisfying W + yX(v) ≥ w(xv) for every xv ∈ E[X ∪{x}]. Let y : X ∪{x} → R be a function defined as y(x) := W and y(v) := yX(v) for v ∈ X. In the subgraph G[X ∪{x}], a pair of the matching MX and dual variables (ΩX , y, zX ) satisfies the conditions (1)–(3). Therefore, we can apply Lemma 3. If MX is a maximum-size matching of G[X ∪{x}], we return MX and (ΩX , y, zX ). Otherwise, we obtain a matching M ′ of size MX + 1 and dual variables (Ω′, y′, z′) satisfying the conditions (1)–(3). Because the cardinality of maximum-size matching of G[X ∪ {x}] is at most the cardinality of maximum-size matching of G[X] plus one, the obtained M ′ is a maximum-size matching of G[X ∪ {x}]. Therefore, we can return M ′ and (Ω′, y′, z′). Union((X1, f (X1)), . . . , (Xc, f (Xc))). Because there exist no edges between Xi and Xj for any i 6= j, we can simply return a pair of a maximum-size matching obtained by taking the union Si MXi and dual variables (Ω, y, z) such that Ω :=Si ΩXi, y(v) := yXi(v) for v ∈ Xi, and z(B) = zXi(B) for B ∈ ΩXi. Proof of Theorem 3. The algorithm Increment(X, f (X), x) runs in O(E[X ∪ {x}] + X log X) time and the algorithm Union((X1, f (X1)), . . . , (Xc, f (Xc))) runs in O(S Xi) time. Therefore, from Theorem 1, we can compute f (V ) in O(k(m + n log n)) time. From the duality theory, the perfect matching obtained by computing f (V ) is a maximum-weight perfect matching of G. 4Note that when M is not a perfect matching, this does not imply that M has the maximum weight among all the maximum-size matchings. 8 4.3 Negative cycle detection and potentials Let G = (V, E) be a directed graph with an edge-weight function w : E → R. For a function p : V → R, we define an edge-weight function wp as wp(uv) := w(uv) + p(u) − p(v). If wp becomes non-negative for all edges, p is called a potential on G. Lemma 4 ([30]). There exists a potential on G if and only if G has no negative cycles. In this section, we prove the following theorem. Theorem 4. Given an edge-weighted directed graph and its elimination forest of depth k, we can compute either a potential or a negative cycle in O(k(m + n log n)) time. Suppose that we have a potential p. Because wp is non-negative, we can compute a shortest-path tree rooted at a given vertex s under wp in O(m + n log n) time by Dijkstra's algorithm. For any s− t path, its length under wp is exactly the length under w plus a constant p(s)− p(t). Therefore, the obtained tree is also a shortest-path tree under w. Thus, we obtain the following corollary. Corollary 2. Given an edge-weighted directed graph without negative cycles, a vertex s, and its elimination forest of depth k, we can compute a shortest-path tree rooted at s in O(k(m + n log n)) time. For S ⊆ V , we define f (S) as a function that returns either a potential pS : S → R on G[S] or a negative cycle contained in G[S]. We now give algorithms Increment and Union. Increment(X, f (X), x). If f (X) is a negative cycle, we return it. Otherwise, let G′ = (X ∪ {x}, E′) be the graph obtained from G[X ∪ {x}] by removing all the edges incoming to x. Let W be a value satisfying w(xv) + W − pX(v) ≥ 0 for every xv ∈ E′. Let p′ : X ∪ {x} → R be a function defined as p′(x) := W and p′(v) := pX(v) for v ∈ X. Because x has no incoming edges in G′, p′ is a potential on G′. Therefore, we can compute a shortest-path tree rooted at x under wp′ in O(E[X] + X log X) time by Dijkstra's algorithm. Let R be the set of vertices reachable from x in G′ and let d : R → R be the shortest-path distance from x under wp′. If there exists an edge vx ∈ E[X ∪ {x}] such that v ∈ R and d(v) + wp′(vx) < 0, G[X ∪ {x}] contains a negative cycle starting from x, going to v along the shortest-path tree, and coming back to x via the edge vx. Otherwise, let D be a value satisfying wp′(uv) + D − d(v) ≥ 0 for every uv ∈ E[X ∪ {x}] with u ∈ X \ R and v ∈ R. Then, we return a function p : X ∪ {x} → R defined as p(v) := p′(v) + d(v) if v ∈ R and p(v) := p′(v) + D if v ∈ X \ R. Claim 1. p is a potential on G[X ∪ {x}]. Proof. For every edge uv ∈ E[X ∪ {x}], we have wp(uv) =  wp′(uv) + d(u) − d(v) ≥ 0 if u, v ∈ R, wp′(uv) + D − d(v) ≥ 0 wp′(uv) + D − D ≥ 0 if u ∈ X \ R, v ∈ R, if u ∈ X \ R, v ∈ X \ R. Note that there are no edges from R to X \ R. 9 Union((X1, f (X1)), . . . , (Xc, f (Xc))). If at least one of f (Xi) is a negative cycle, we return it. Otherwise, we return a potential p defined as p(v) := pXi(v) for v ∈ Xi. Proof of Theorem 4. The algorithm Increment(X, f (X), x) correctly computes f (X ∪ {x}) in O(E[X]+X log X) time and the algorithm Union((X1, f (X1)), . . . , (Xc, f (Xc))) correctly com- putes f (Si Xi) in O(Si Xi) time. Therefore, from Theorem 1, we can compute f (V ), i.e., either a potential on G or a negative cycle contained in G, in O(k(m + n log n)) time. 4.4 Minimum weight cycle In this section, we prove the following theorem. Theorem 5. Given a non-negative edge-weighted undirected or directed graph and its elimination forest of depth k, we can compute a minimum-weight cycle in O(k(m + n log n)) time. Note that when the graph is undirected, a closed walk of length two using the same edge twice is not considered as a cycle. Therefore, we cannot simply reduce the undirected version into the directed version by replacing each undirected edge by two directed edges of both directions. Let G = (V, E) be the input graph with an edge-weight function w : E → R≥0. For S ⊆ V , we define f (S) as a function that returns a minimum-weight cycle of G[S]. We describe Increment and Union below. Increment(X, f (X), x). Because we already have a minimum-weight cycle f (X) of G[X], we only need to find a minimum- weight cycle passing through x. First, we construct a shortest-path tree of G[X ∪ {x}] rooted at x and let d : X ∪ {x} → R be the shortest-path distance. When the graph is undirected, we find an edge uv ∈ E[X ∪ {x}] not contained in the shortest- path tree minimizing d(u) + w(uv) + d(v). If this weight is at least the weight of f (X), we return f (X). Otherwise, we return the cycle starting from x, going to u along the shortest-path tree, jumping to v through the edge uv, and coming back to x along the shortest-path tree. Note that this always forms a cycle because otherwise, it induces a cycle contained in G[X] that has a smaller weight than f (X), which is a contradiction. We can prove the correctness of this algorithm as follows. Let W be the weight of the cycle obtained by the algorithm and let C be a cycle passing through x. Let v0 = x, v1, . . . , vℓ−1, vℓ = x the vertices on C in order. Because a tree contains no cycles, there exists an edge vivi+1 not j=0 w(vj vj+1) + w(vivi+1) + contained in the shortest-path tree. Therefore, the weight of C is Pi−1 Pℓ−1 j=i+1 w(vj vj+1) ≥ d(vi) + w(vivi+1) + d(vi+1) ≥ W . When the graph is directed, we find an edge ux ∈ E[X∪{x}] with the minimum d(u)+w(ux). If this weight is at least the weight of f (X), we return f (X). Otherwise, we return the cycle starting from x, going to u along the shortest-path tree, and coming back to x through the edge ux. Union((X1, f (X1)), . . . , (Xc, f (Xc))). We return a cycle of the minimum weight among f (X1), . . . , f (Xc). 10 Proof of Theorem 5. The algorithm Increment(X, f (X), x) correctly computes f (X ∪ {x}) in O(E[X] +X log X) time and the algorithm Union((X1, f (X1)), . . . , (Xc, f (Xc)) correctly com- putes f (Si Xi) in O(Si Xi) time. Therefore, from Theorem 1, we can compute a minimum-weight cycle in O(k(m + n log n)) time. 4.5 Replacement paths Fix two vertices s and t. For an edge-weighed directed graph G = (V, E) and an edge e ∈ E, we denote the length of the shortest s − t path avoiding e by rG(e). In this section, we prove the following theorem. Theorem 6. Given an edge-weighted directed graph G = (V, E), a shortest s − t path P , and its elimination forest of depth k, we can compute rG(e) for all edges e on P in O(k(m + n log n)) time. Let v0(= s), v1, . . . , vℓ−1, vℓ(= t) be the vertices on the given shortest s− t path P in order. For i ∈ {0, . . . , ℓ}, we denote the length of the prefix v0v1 . . . vi by pref(vi) and the length of the suffix vivi+1 . . . vℓ by suf(vi). These can be precomputed in linear time. For S ⊆ V , we define G[S] ∪ P as a graph consisting of vertices S ∪ {v0, . . . , vℓ} and edges E[S] ∪ {v0v1, . . . , vℓ−1vℓ}, and define G[S] \ P as a graph consisting of vertices S and edges E[S] \ {v0v1, . . . , vℓ−1vℓ}. We denote the shortest-path length from u to v in G[S] \ P by dS(u, v). For convenience, we define dS(u, v) = ∞ when u 6∈ S or v 6∈ S. We use the following lemma. Lemma 5. For any S ⊆ V and any i ∈ {0, . . . , ℓ−1}, rG[S]∪P (vivi+1) is the minimum of pref(va)+ dS(va, vb) + suf(vb) for a ≤ i < b. Proof. Any s − t path avoiding vivi+1 in G[S] ∪ P can be written as, for some a ≤ i < b, a concatenation of s− va path Q1, va − vb path Q2 that is contained in G[S] \ P , and vb − t path Q3. Because P is a shortest s− t path in G, we can replace Q1 by the prefix v0 . . . va, Q2 by the shortest va − vb path in G[S] \ P , and Q3 by the suffix vb . . . vℓ without increasing the length. Therefore, the lemma holds. We want to define f (S) as a function that returns a list of rG[S]∪P (vivi+1) for all i ∈ {0, . . . , ℓ− 1}; however, we cannot do so because the length of this list is not bounded by S. Instead, we define f (S) as a function that returns a list of rG[S]∪P (vivi+1) for all i with vi ∈ S. This succinct representation has enough information because, for any vi 6∈ S, we have rG[S]∪P (vivi+1) = rG[S]∪P (vi−1vi) (or ∞ when i = 0). We describe Increment and Union below. Increment(X, f (X), x). By running Dijkstra's algorithm twice, we can compute dX∪{x}(x, v) and dX∪{x}(v, x) for all v ∈ X∪{x} in O(E[X]+X log X) time. For vi ∈ X∪{x}, we define Li := mina≤i,va∈X∪{x}(pref(va)+ d(va, x)) and Ri := minb>i,vb∈X∪{x}(d(x, vb) + suf(vb)). By a standard dynamic programming, we can compute Li and Ri for all i with vi ∈ X ∪ {x} in O(X) time. From Lemma 5, rG[X∪{x}]∪P (vivi+1) = pref(va) + dX∪{x}(va, vb) + suf(vb) holds for some a ≤ i < b. If dX∪{x}(va, vb) = dX (va, vb) holds, we have rG[X∪{x}]∪P (vivi+1) = rG[X]∪P (vivi+1), and otherwise, we have dX∪{x}(va, vb) = dX∪{x}(va, x) + dX∪{x}(x, vb). Therefore, we can compute rG[X∪{x}]∪P (vivi+1) by taking the minimum of rG[X]∪P (vivi+1) and mina≤i<b(pref(va) + d(va, x) + d(x, vb) + suf(vb)) = Li + Ri. 11 Union((X1, f (X1)), . . . , (Xc, f (Xc))). Let X := Si Xi. Because there exist no edges between Xi and Xj for any i 6= j, we have dX (u, v) = mini dXi(u, v) for any u, v ∈ X. Therefore, from Lemma 5, we have rG[X]∪P (vivi+1) = minj rG[Xj]∪P (vivi+1). For efficiently computing rG[X]∪P (vivi+1) for all i with vi ∈ X, we do as follows in increasing order of i. For each Xj, we maintain a value rj so that rj = rG[Xj]∪P (vivi+1) always holds. Initially, these values are set to ∞. We use a heap for computing minj rj and updating rj in O(log c) time. For processing i, we first update rj ← rG[Xj]∪P (vivi+1) for the set Xj containing vi. We do not need to update rj′ for any other set Xj′ because rG[Xj′ ]∪P (vivi+1) = rG[Xj′ ]∪P (vi−1vi) holds. Then, we compute rG[X]∪P (vivi+1) = minj rj. Proof of Theorem 6. The algorithm Increment(X, f (X), x) correctly computes f (X ∪ {x}) in O(E[X]+X log X) time and the algorithm Union((X1, f (X1)), . . . , (Xc, f (Xc))) correctly com- putes f (Si Xi) in O(Si Xi log c) = O(Si Xi log Si Xi) time. Therefore, from Theorem 1, we can compute f (V ), i.e., rG∪P (e) = rG(e) for all edges e on P , in O(k(m + n log n)) time. 4.6 2-hop cover Let G = (V, E) be a directed graph with an edge-weight function w : E → R≥0. A 2-hop cover of G is the following data structure (L+, L−) for efficiently answering distance queries. For each vertex u ∈ V , we assign a set L+(u) of pairs (v, d+ vu) ∈ V × R≥0. We require that, for every pair of vertices s, t ∈ V , the shortest-path distance from s to t is exactly the minimum of d+ ht) ∈ L−(t). The size of the 2-hop cover is defined as Pu∈V L+(u) + L−(u), and the maximum label size is defined as maxu∈V L+(u) +L−(u). Using a 2-hop cover of maximum label size T , we can answer a distance query in O(T ) time. In this section, we prove the following theorem. uv) ∈ V × R≥0 and a set L−(u) of pairs (v, d− sh) ∈ L+(s) and (h, d− sh + d− ht among all pairs (h, d+ Theorem 7. Given a non-negative edge-weighted directed graph and its elimination forest of depth k, we can construct a 2-hop cover of maximum label size 2k in O(k(m + n log n)) time. For S ⊆ V , we define f (S) as a function that returns a 2-hop cover of G[S]. We denote the shortest-path distance from s to t in G[S] by dS(s, t). We denote the result of the distance query from s to t for f (S) by qS(s, t). We now describe algorithms Increment and Union. Increment(X, f (X), x). Let (L+, L−) be the 2-hop cover of G[X]. By running Dijkstra's algorithm twice, we compute the shortest-path distances from x and to x in G[X ∪ {x}]. Then, for each u ∈ X ∪ {x}, we insert (x, dX∪{x}(u, x)) into L+(u) and (x, dX∪{x}(x, u)) into L−(u). Finally, we return the updated (L+, L−) as f (X ∪ {x}). Claim 2. f (X ∪ {x}) is a 2-hop cover of G[X ∪ {x}]. Proof. It suffices to show that qX∪{x}(s, t) = dX∪{x}(s, t) holds for every s, t ∈ X ∪ {x}. The claim clearly holds when s = x or t = x. For s, t ∈ X, let δ := dX∪{x}(s, x) + dX∪{x}(x, t). Then, we have dX∪{x}(s, t) = min(dX (s, t), δ). From the construction of f (X ∪ {x}), we have qX∪{x} = min(qX(s, t), δ) = min(dX (s, t), δ). Therefore, the claim holds. 12 Union((X1, f (X1)), . . . , (Xc, f (Xc))). Because there exist no paths connecting Xi and Xj for any i 6= j, we can construct a 2-hop cover of G[Si Xi] by simply concatenating the 2-hop covers f (X1), . . . , f (Xc). Proof of Theorem 7. The algorithm Increment(X, f (X), x) correctly computes f (X ∪ {x}) in O(E[X] +X log X) time and the algorithm Union((X1, f (X1)), . . . , (Xc, f (Xc)) correctly com- putes f (Si Xi) in O(Si Xi) time. Therefore, from Theorem 1, we can compute a 2-hop cover in O(k(m + n log n)) time. Let (L+, L−) be the 2-hop cover obtained by computing f (V ). For each vu) ∈ L−(u), v is located on the path from u to the root in the element (u, d+ elimination forest. Therefore, we have L+(u) + L−(u) ≤ 2k for every vertex u ∈ V . uv) ∈ L+(u) or (u, d− Acknowledgement We would like to thank Hiroshi Imai for pointing out to us the reference [21]. References [1] Amir Abboud, Fabrizio Grandoni, and Virginia Vassilevska Williams. Subcubic equivalences between graph centrality problems, APSP and diameter. In SODA, pages 1681–1697, 2015. [2] Amir Abboud, Virginia Vassilevska Williams, and Joshua R. Wang. Approximation and Fixed Parameter Subquadratic Algorithms for Radius and Diameter in Sparse Graphs. In SODA, pages 377–391, 2016. [3] Takuya Akiba, Yoichi Iwata, and Yuichi Yoshida. Fast exact shortest-path distance queries on large networks by pruned landmark labeling. In SIGMOD, pages 349–360, 2013. [4] Takuya Akiba, Christian Sommer, and Ken-ichi Kawarabayashi. Shortest-path queries for complex networks: exploiting low tree-width outside the core. In EDBT, pages 144–155, 2012. [5] Norbert Blum. A new approach to maximum matching in general graphs. In ICALP, pages 586–597, 1990. [6] Hans L. Bodlaender, Jitender S. Deogun, Klaus Jansen, Ton Kloks, Dieter Kratsch, Haiko Muller, and Zsolt Tuza. Rankings of Graphs. SIAM J. Discrete Math., 11(1):168–181, 1998. [7] Shiva Chaudhuri and Christos D. Zaroliagis. Shortest paths in digraphs of small treewidth. part I: sequential algorithms. Algorithmica, 27(3):212–226, 2000. [8] Edith Cohen, Eran Halperin, Haim Kaplan, and Uri Zwick. Reachability and Distance Queries via 2-Hop Labels. SIAM J. Comput., 32(5):1338–1355, 2003. [9] David Coudert, Guillaume Ducoffe, and Alexandru Popa. Fully polynomial FPT algorithms for some classes of bounded clique-width graphs. CoRR, abs/1707.05016, 2017. [10] Jack Edmonds. Paths, trees, and flowers. Canad. J. Math., 17(3):449–467, 1965. 13 [11] Fedor V. Fomin, Daniel Lokshtanov, Micha l Pilipczuk, Saket Saurabh, and Marcin Wrochna. Fully polynomial-time parameterized computations for graphs and matrices of low treewidth. In SODA, pages 1419–1432, 2017. [12] Harold N. Gabow. Data Structures for Weighted Matching and Nearest Common Ancestors with Linking. In SODA, pages 434–443, 1990. [13] Harold N. Gabow. Data Structures for Weighted Matching and Extensions to b-matching and f -factors. CoRR, abs/1611.07541, 2016. [14] Harold N. Gabow and Robert Endre Tarjan. A Linear-Time Algorithm for a Special Case of Disjoint Set Union. J. Comput. Syst. Sci., 30(2):209–221, 1985. [15] Harold N. Gabow and Robert Endre Tarjan. Faster Scaling Algorithms for General Graph- Matching Problems. J. ACM, 38(4):815–853, 1991. [16] Zvi Gotthilf and Moshe Lewenstein. Improved algorithms for the k simple shortest paths and the replacement paths problems. Inf. Process. Lett., 109(7):352–355, 2009. [17] John Hershberger, Subhash Suri, and Amit M. Bhosle. On the difficulty of some shortest path problems. ACM Trans. Algorithms, 3(1):5:1–5:15, 2007. [18] David R. Karger, Daphne Koller, and Steven J. Phillips. Finding the hidden path: Time bounds for all-pairs shortest paths. SIAM J. Comput., 22(6):1199–1217, 1993. [19] Meir Katchalski, William McCuaig, and Suzanne M. Seager. Ordered colourings. Discrete Mathematics, 142(1-3):141–154, 1995. [20] Matthias Kriesell. Disjoint A-paths in digraphs. J. Comb. Theory, Ser. B, 95(1):168–172, 2005. [21] Richard J. Lipton and Robert Endre Tarjan. Applications of a planar separator theorem. SIAM J. Comput., 9(3):615–627, 1980. [22] Kavindra Malik, Ashok K. Mittal, and Santosh K. Gupta. The k most vital arcs in the shortest path problem. Oper. Res. Lett., 8(4):223–227, 1989. [23] George B. Mertzios, Andr´e Nichterlein, and Rolf Niedermeier. The power of data reduction for matching. CoRR, abs/1609.08879, 2016. [24] Jaroslav Nesetril and Patrice Ossona de Mendez. Sparsity: Graphs, Structures, and Algorithms, volume 28 of Algorithms and Combinatorics. Springer, 2012. [25] Jaroslav Nesetril and Patrice Ossona de Mendez. Tree-depth, subgraph coloring and homo- morphism bounds. Eur. J. Comb., 27(6):1022–1041, 2006. [26] James B. Orlin and Antonio Sedeno-Noda. An O(nm) time algorithm for finding the min length directed cycle in a graph. In SODA, pages 1866–1879, 2017. [27] L´eon Planken, Mathijs de Weerdt, and Roman van der Krogt. Computing all-pairs shortest paths by leveraging low treewidth. J. Artif. Intell. Res., 43:353–388, 2012. 14 [28] Liam Roditty and Uri Zwick. Replacement paths and k simple shortest paths in unweighted directed graphs. ACM Trans. Algorithms, 8(4):33:1–33:11, 2012. [29] Alejandro A. Schaffer. Optimal Node Ranking of Trees in Linear Time. Inf. Process. Lett., 33(2):91–96, 1989. [30] Alexander Schrijver. Combinatorial Optimization: Polyhedra and Efficiency, volume 24 of Algorithms and Combinatorics. Springer, 2003. [31] Vijay V. Vazirani. A theory of alternating paths and blossoms for proving correctness of the O(√V E) general graph maximum matching algorithm. Combinatorica, 14(1):71–109, 1994. [32] Fang Wei. TEDI: efficient shortest path query answering on graphs. In SIGMOD, pages 99–110, 2010. [33] Virginia Vassilevska Williams and Ryan Williams. Subcubic Equivalences between Path, Ma- trix and Triangle Problems. In FOCS, pages 645–654, 2010. A Reductions to weighted matching We present standard reductions from several problems to Maximum-weight Perfect Matching. Given a graph of n vertices, m edges, and tree-depth k, each of these reductions constructs a graph of O(n) vertices, O(m) edges, and tree-depth O(k) in linear time. Therefore, the problem can be solved in O(k(m + n log n)) time. First, we present a reduction from Maximum-weight Matching. Given an undirected graph G = (V, E) with an edge-weight function w : E → R, our task is to find a maximum-weight matching of G (which does not need to have the maximum cardinality). We create a copy G′ = (V ′, E′) of G and connect each vertex v ∈ V and its copy v′ ∈ V ′ by an edge of weight 0. Let M be a maximum- weight matching of the original graph. We can construct a perfect matching M ′ of the reduced graph of weight 2w(M ) by taking M , the copy of M in G′, and the edge vv′ for every exposed vertex v. Any perfect matching of the reduced graph consists of a matching of G, a matching of G′, and edges of weight zero, and therefore, it has weight at most 2w(M ). Thus, by computing a maximum-weight perfect matching of the reduced graph, we can compute a maximum-weight matching of the original graph. The reduced graph has 2n vertices and 2m + n edges. From a given elimination forest of depth k for the original graph, we can construct an elimination forest of depth 2k for the reduced graph by replacing each vertex v in the forest by a path vv′. Next, we present a reduction from Maximum-weight Maximum-size Matching, which is a problem of finding a matching of maximum weight subject to the constraint that it has the maximum cardinality. We only modify the edge-weight function without modifying the graph. From the edge- weight function w : E → R of the input graph, we construct an edge-weight function w′ such that w′(e) := w(e) + W for a large value W satisfying W > Pe∈E w(e). For any matchings M and M ′ with M > M ′, we have w′(M ) − w′(M ′) ≥ W −Pe∈E w(e) > 0, and for any matchings M and M ′ of the same cardinality, we have w′(M ) − w′(M ′) = w(M ) − w(M ′). Therefore, M is a maximum-weight maximum-size matching under w if and only if M is a maximum-weight matching under w′. Finally, we present a reduction from Minimum-weight Disjoint A-Paths. For a set of terminals A ⊆ V , a path is called an A-path if it connects two distinct vertices in A and has no 15 internal vertex in A. A set of A-paths is called disjoint if no two paths share a vertex (including the terminals A). Given a directed graph G = (V, E) with an edge-weight function w : E → R≥0 and a set of terminals A ⊆ V , our task is to find disjoint A-paths of the minimum total weight subject to the constraint that the number of paths is maximized. Note that we can easily reduce the problem of finding a minimum-weight vertex-disjoint S − T paths to this problem by removing all the edges incoming to S or outgoing from T and setting A = S ∪ T . The following reduction to Minimum-weight Maximum-size Matching is based on the re- duction for the unweighted version by Kriesell [20]. We construct a graph G′ as follows. For each vertex v ∈ V \ A, we create two vertices {v+, v−} and an edge v+v− of weight 0. For each terminal a ∈ A, we create a single vertex a = a+ = a−. For each edge uv ∈ E, we insert an edge u+v− of weight w(uv). G′ has at most 2n vertices and 2m + n edges. From a given elimination forest of depth k for G, we can construct an elimination forest of depth 2k for G′ by replacing each vertex v ∈ V \ A in the forest by a path v+v−. Finally, we prove the correctness of the reduction. From a set P of d disjoint A-paths in G, we can construct a matching of cardinality V \ A + d of the same weight in G′ by taking u+v− for each uv ∈ E used in P and v+v− for each v ∈ V \ A not used in P. From a matching M of cardinality V \ A + d in G′, we can construct a set P of d disjoint A-paths of the same or smaller weight in G as follows. If one of v+ and v− is exposed for some v ∈ V \ A, we obtain another matching without increasing the weight by discarding the edge in M incident to v+ or v− and by including the edge v+v−. Now we can assume that every exposed vertex is in A, and therefore the set of edges {uv u+v− ∈ M, u 6= v} induces a set P of d disjoint A-paths and some cycles. Because w is non-negative, we can discard the cycles without increasing the weight. Therefore, from the minimum-weight maximum-size matching of G′, we can construct a minimum-weight disjoint A-paths of G in linear time. 16
1101.2245
3
1101
2015-10-04T00:10:28
Invertible Bloom Lookup Tables
[ "cs.DS", "cs.DB" ]
We present a version of the Bloom filter data structure that supports not only the insertion, deletion, and lookup of key-value pairs, but also allows a complete listing of its contents with high probability, as long the number of key-value pairs is below a designed threshold. Our structure allows the number of key-value pairs to greatly exceed this threshold during normal operation. Exceeding the threshold simply temporarily prevents content listing and reduces the probability of a successful lookup. If later entries are deleted to return the structure below the threshold, everything again functions appropriately. We also show that simple variations of our structure are robust to certain standard errors, such as the deletion of a key without a corresponding insertion or the insertion of two distinct values for a key. The properties of our structure make it suitable for several applications, including database and networking applications that we highlight.
cs.DS
cs
Invertible Bloom Lookup Tables Michael T. Goodrich Dept. of Computer Science University of California, Irvine http://www.ics.uci.edu/goodrich/ Michael Mitzenmacher Dept. of Computer Science Harvard University http://www.eecs.harvard.edu/michaelm/ Abstract We present a version of the Bloom filter data structure that supports not only the insertion, deletion, and lookup of key-value pairs, but also allows a complete listing of the pairs it contains with high probability, as long the number of key- value pairs is below a designed threshold. Our structure allows the number of key- value pairs to greatly exceed this threshold during normal operation. Exceeding the threshold simply temporarily prevents content listing and reduces the probability of a successful lookup. If entries are later deleted to return the structure below the threshold, everything again functions appropriately. We also show that simple variations of our structure are robust to certain standard errors, such as the deletion of a key without a corresponding insertion or the insertion of two distinct values for a key. The properties of our structure make it suitable for several applications, including database and networking applications that we highlight. 1 Introduction The Bloom filter data structure [5] is a well-known way of probabilistically supporting dynamic set membership queries that has been used in a multitude of applications (e.g., see [8]). The key feature of a standard Bloom filter is the way it trades off query accuracy for space efficiency, by using a binary array T (initially all zeroes) and k random hash functions, h1, . . . , hk, to represent a set S by assigning T [hi(x)] = 1 for each x ∈ S. To check if x ∈ S one can check that T [hi(x)] = 1 for 1 ≤ i ≤ k, with some chance of a false positive. This representation of S does not allow one to list out the contents of S given only T . This aspect of Bloom filters is sometimes viewed as a feature, in settings where some degree of privacy protection is desired (e.g., see [2, 3, 18, 27, 30]). Still, in many domains one would benefit from a similar set representation that would also allow listing out the set’s contents [17]. 1 In this paper, we are interested not in simply representing a set, but instead in meth- ods for probabilistically representing a lookup table (that is, an associative memory) of key-value pairs, where the keys and values can be represented as fixed-length integers. Unlike previous approaches (e.g., see [6, 9]), we specifically desire a data structure that supports the listing out of all of its key-value pairs. We refer to such a structure as an invertible Bloom lookup table (IBLT). 1.1 Related Work Our work can be seen as an extension of the invertible Bloom filter data structure of Eppstein and Goodrich [17], modified to store key-value pairs instead of only keys. Our analysis, however, supersedes the analysis of the previous paper in several re- spects, in terms of efficiency and tightness of the analysis (as well as correcting some small deficiencies). In particular, our analysis demonstrates the natural connection be- tween these data structures and cores of random hypergraphs, similar to the connection found previously for cuckoo hashing and erasure-correcting codes (e.g., see [16, 23]). This provides both a significant constant factor reduction in the required space for the data structure, as well as an important reduction in the error probability (to inverse polynomial, from constant in [17]). In addition, our IBLT supports some usage cases and applications (discussed later in this section) that are not supported by a standard invertible Bloom filter. Given its volume, reviewing all previous work on Bloom filters is, not surprisingly, beyond the scope of this paper (e.g., see [7, 8, 33] for some excellent surveys). Never- theless, two closely related works include Bloomier filters [9] and Approximate Con- current State Machines (ACSMs) [6], which are structures to store and track key-value pairs. Song et al. [35] store elements in a Bloom-like hash table in a fashion that is somewhat similar to that of a cuckoo hash table [15, 26, 29]. Cohen and Matias [12] de- scribe an extended Bloom filter that allows for multiplicity queries on multisets. While an IBLT is not intended for changing values, it can be used in such settings where a key-value pair can be explicitly deleted and a new value for the key re-inserted. Again, an IBLT has additional features, including listing, graceful handling of data exceed- ing the listing threshold, and counting multiplicities, which make it useful for several applications where these other structures are insufficient. Another similar structure is the recently developed counter braid architecture [22], which keeps an updatable count field for a set of flows in a compressed form, with the compressed form arising by a careful use of hashing and allowing reconstruction of the count for each flow. Unlike an IBLT, however, the flow list must be kept explicitly to read out the flow counts, and such lists do not allow for direct lookups of individ- ual values. There are several other differences from our work due to their focus on counters, but perhaps most notable is their decoding algorithm, which utilizes belief propagation. Additional work in the area of approximate counting of a similar flavor but with very different goals from the IBLT includes the well-known CM-sketch [13] and recent work by Price [32]. 2 1.2 Our Results We present a deceptively simple variation of the Bloom filter data structure that is designed for key-value pairs and further avoids the limitation of previous structures (such as [6, 9]) that do not allow the listing of contents. As mentioned above, we call our structure an invertible Bloom lookup table, or IBLT for short. Our IBLT supports insertions, deletions, and lookups in O(k) time, where k is the number of random hash functions used (which will typically be a constant in practice). Just as Bloom filters have false positives, our lookup operation works only with constant probability, although this probability can be made quite close to 1. Our data structure also allows for a complete listing of the key-value pairs the structure contains, with high probability, whenever the current number, n, of such pairs lies below a certain threshold capacity, t, a parameter that is part of the structure’s design. This listing takes O(t) time. In addition, because the content-listing operation succeeds with high probability, one can also use it as a backup in the case that a standard lookup fails—namely, if a lookup fails, perform a listing of key-value pairs until one can retrieve a value for the desired key. Our IBLT construction is also space-efficient, requiring space1 at most linear in t, the threshold number of keys, even if the number, n, of stored key-value pairs grows well beyond t (for example, to polynomial in t) at points in time. One could of course instead keep an actual list of key-value pairs with linear space, but this would require space linear in n, i.e., the maximum number of keys, not the target number, t, of keys. Keeping a list also necessarily requires more computationally expensive lookup opera- tions than our approach supports. We further show that with some additional checksums we can tolerate various nat- ural errors in the system. For example, we can cope with key-value pairs being deleted without first being inserted, or keys being inserted with the same value multiple times, or keys mistakenly being inserted with multiple values simultaneously. Interestingly, together with its contents-listing ability, this error tolerance leads to a number of appli- cations of the IBLT, which we discuss next. 1.3 Applications and Usage Cases There are a number of possible applications and usage cases for invertible Bloom lookup tables, some of which we explore here. Database Reconciliation Suppose Alice and Bob hold distinct, but similar, copies, DA and DB, of an indexed database, D, and they would like to reconcile the differ- ences between DA and DB. For example, Alice could hold a current version of D and Bob could hold a backup, or Alice and Bob could represent two different copies of someone’s calendar database (say, respectively on a desktop computer and a smart- phone) that now need to be symmetrically synchronized. Such usage cases are natural in database systems, particularly for systems that take the approach advocated in an 1As in the standard RAM model, we assume in this paper that keys and values respectively fit in a single word of memory (which, in practice, could actually be any fixed number of memory words), and we characterize the space used by our data structure in terms of the number of memory words it uses. 3 interesting recent CACM article by Stonebraker [36] that argues in favor of sacrific- ing consistency for the sake of availability and partition-tolerance, and then regaining consistency by performing database reconciliation computations whenever needed. In- cidentally, in a separate work, Eppstein et al.2 are currently empirically exploring a similar application of the invertible Bloom table technology for the reconciliation of two distributed mirrors of a filesystem (say, in a peer-to-peer network). To achieve such a reconciliation with low overhead, Alice constructs an IBLT, B, for DA, using indices as keys and checksums of her records as values. She then sends the IBLT B to Bob, who then deletes index-checksum pairs from B corresponding to all of his entries in DB. The remaining key-value pairs corresponding to insertions with- out deletions identify records that Alice has that Bob doesn’t have, and the remaining key-value pairs corresponding to deletions without insertions identify records that Bob has that Alice doesn’t have. In addition, as we show, Bob can also use B to identify records that they both possess but with different checksums. In this way, Alice needs only to send a message B of size O(t), where t here is an upper bound on the num- ber of differences between DA and DB, for Bob to determine the identities of their differences (and a symmetric property holds for a similar message from Bob to Alice). Tracking Network Acknowledgments As another example application, consider a router R that would like to track TCP sessions passing through R. In this case, each session corresponds to a key, and may have an associated value, such as the source or the destination, that needs to be tracked. When such flows are initiated in TCP, particular control messages are passed that can be easily detected, allowing the router to add the flow to the structure. Similarly, when a flow terminates, control messages ending the flow are sent. The IBLT supports fast insertions and deletions and can be used to list out the current flows in the system at various times, as long as the number of flows is less than some preset threshold, t. Note this work can be offloaded simply by sending a copy of the IBLT to an offline agent if desired. Furthermore, the IBLT can return the value associated with a flow when queried, with constant probability close to 1. Finally, if at various points, the number of flows spikes above its standard level to well above t, the IBLT will still be able to list out the flows and perform lookups with the appropriate probabilities once the total load returns to t or below. Again, this is a key feature of the IBLT; all keys and values can be reconstructed with high probability whenever the number of keys is below a design threshold, but if the number of keys temporarily exceeds this design threshold and later returns to below this threshold, then the functionality will return at that later time. In this networking setting, sometimes flows do not terminate properly, leaving them in the data structure when they should disappear. Similarly, initialization messages may not be properly handled, leading to a deletion without a corresponding insertion. We show that the IBLT can be modified to handle such errors with minimal loss in performance. Specifically, we can handle keys that are deleted without being inserted, or keys that erroneously obtain multiple values. Even with such errors, we provide conditions for which all valid flows can still all be listed with high probability. Our experimental results also highlight robustness to these types of errors. (Eventually, of 2Personal communication. 4 course, such problematic keys should be removed from the data structure. We do not concern ourselves with removal policies here; see [6] for some possibilities based on timing structures.) Oblivious Selection from a Table As a final motivating application, consider a sce- nario where Alice has outsourced her data storage needs, including the contents of an important indexed table, T , of size n, to a cloud storage server, Bob, because Alice has very limited storage capacity (e.g., Alice may only have a smartphone). Moreover, be- cause her data is sensitive and she knows Bob is honest-but-curious regarding her data, she encrypts each record of T using a secret key, and random nonces, so that Bob can- not determine the contents of any record from its encryption alone. Such encryptions are not sufficient, however, to fully protect the privacy of Alice’s data, as recent attacks show that the way Alice accesses her data can reveal its contents (e.g., see [10]). Alice needs a way of hiding any patterns in the way she accesses her data. Suppose now that Alice would like to do a simple SELECT query on T and she is confident that the result will have a size at most t, which is much less than n but still more than she can store locally. Thus, she cannot use techniques from private information retrieval [11, 37], as that would either require storing results back with Bob in a way that could reveal selected indices or using yet another server besides Bob. She could use techniques from recent oblivious RAM simulations [19, 20, 31] to obfuscate her access patterns, but doing so would require O(n log2 n) I/Os. Therefore, using existing techniques would be inefficient. By using an IBLT, on the other hand, she can perfrom her SELECT query much more efficiently. The advantage comes from the fact that an insertion in an IBLT accesses a random set of cells (that is, memory locations) whose addresses depend (via random hash functions) only on the key of the item being inserted. Alice thus uses all the indices for T as keys, one for each record, and accesses memory as though inserting each record into an IBLT of size O(t). In fact, Alice only inserts those records that satisfy her SELECT query. However, since Alice encrypts each write using a secret key and random nonces, Bob cannot tell when Alice’s write operations are actually changing the records stored in the IBLT, and when a write operation is simply rewriting the same contents of a cell over again re-encrypted with a different nonce. In this way Alice can obliviously create an IBLT of size O(t) that contains the result of her query and is stored by Bob. Then, using existing methods for oblivious RAM simulation [20], she can subsequently obliviously extract the elements from her IBLT using O(t log2 t) I/Os. With this approach Bob learns nothing about her data from her access pattern. In addition, the total number of I/Os for her to perform her query is O(n + t log2 t), which is linear (and optimal) for any t that is O(n/ log2 n). We are not currently aware of any other way that Alice can achieve such a result using a structure other than an IBLT. 5 2 A Simple Version of the Invertible Bloom Lookup Ta- ble In this section, we describe and analyze a simple version of the IBLT. In the sections that follow we describe how to augment and extend this simple structure to achieve various additional performance goals. The IBLT data structure, B, is a randomized data structure storing a set of key-value pairs. It is designed with respect to a threshold number of keys, t; when we say the structure is successful for an operation with high probability it is under the assumption that the actual number of keys in the structure at that time, which we henceforth denote by n, is less than or equal to t. Note that n can exceed t during the course of normal operation, however. As mentioned earlier, we assume throughout that, as in the standard RAM model, keys and values respectively fit in a single word of memory (which, in practice, could actually be any fixed number of memory words) and that each such word can alter- natively be viewed as an integer, character string, floating-point number, etc. Thus, without loss of generality, we view keys and values as positive integers. In many cases we take sums of keys and/or values; we must also consider whether word-value overflow when trying to store these sums in a memory word. (That is, the sum is larger than what fits in a data word.) As we explain in more detail at appropriate points below, such considerations have minimal effects. In most situations, with suit- ably sized memory words, overflow may never be a consideration. Alternatively, if we work in a system that supports graceful overflows, so that (x + y) − y = x even if the first sum results in an overflow, our approach works with negligible changes. Finally, we can also work modulo some large prime (so that vaues fit within a memory word) to enforce graceful overflow. These variations have negligible effects on the analysis. However, we point out that in many settings (except in the case where we may have duplicate copies of the same key-value pair), we can use XORs in place of sums in our algorithms, and avoid overflow issues entirely. 2.1 Operations Supported Our structure supports the following operations: • INSERT(x, y): insert the key-value pair, (x, y), into B. This operation always succeeds, assuming that all keys are distinct. • DELETE(x, y): delete the key-value pair, (x, y), from B. This operation always succeeds, provided (x, y) ∈ B, which we assume for the rest of this section. • GET(x): return the value y such that there is a key-value pair, (x, y), in B. If y = null is returned, then (x, y) (cid:54)∈ B for any value of y. With low (but constant) probability, this operation may fail, returning a “not found” error condition. In this case there may or may not be a key-value pair (x, y) in B. • LISTENTRIES(): list all the key-value pairs being stored in B. With low (inverse polynomial in t) probability, this operation may return a partial list along with an 6 “list-incomplete” error condition. When an IBLT B is first created, it initializes a lookup table T of m cells. Each of the cells in T stores a constant number of fields, each of which corresponds to a single memory word. We emphasize that an important feature of the data structure is that at times the number of key-value pairs in B can be much larger than m, but the space used for B remains O(m) words. (We discuss potential issues with word-value overflow where appropriate.) The INSERT and DELETE methods never fail, whereas the GET and LISTENTRIES methods, on the other hand, only guarantee good probabilistic success when n ≤ t. For our structures we shall generally have m = O(t), and often we can give quite tight analyses on the constants required, as we shall see below. 2.2 Data Structure Architecture Like a standard Bloom filter, an IBLT uses a set of k random3 hash functions, h1, h2, . . ., hk, to determine where key-value pairs are stored. In our case, each key-value pair, (x, y), is placed into cells T [h1(x)], T [h2(x)], . . . T [ht(x)]. In what follows, for technical reasons4, we assume that the hashes yield distinct locations. This can be accomplished in various ways, with one standard approach being to split the m cells into k subtables each of size m/k, and having each hash function choose one cell (uniformly) from each subtable. Such splitting does not affect the asymptotic behavior in our analysis and can yield other benefits, including ease of parallelization of reads and writes into the hash table. (Another approach would be to select the first k distinct hash values from a specific sequence of random hash functions.) Each cell contains three fields: • a count field, which counts the number of entries that have been mapped to this cell, • a keySum field, which is the sum of all the keys that have been mapped to this cell, • a valueSum field, which is the sum of all the values that have been mapped to this cell. Given these fields, which are initially 0, performing the update operations is fairly straightforward: • INSERT(x, y): for each (distinct) hi(x), for i = 1, . . . , k do 3We assume, for the sake of simplicity in our analysis, that the hash functions are fully random, but this does not appear strictly required. For example, the techniques of [24] can be applied if the data has a sufficient amount of entropy. For worst-case data, we are not aware of any results regarding the 2-core of a random hypergraph where the vertices for each edge are chosen according to hash functions with limited independence, which, as we will see, would be needed for such a result. Similar graph problems with limited independence have recently been studied in [1]. It is an interesting theoretical question to obtain better bounds on the randomness needed for our proposed IBLT data structure. 4Incidentally, this same technicality can be used to correct a small deficiency in the paper of Eppstein and Goodrich [17]. 7 add 1 to T [hi(x)].count add x to T [hi(x)].keySum add y to T [hi(x)].valueSum end for • DELETE(x, y): for each (distinct) hi(x), for i = 1, . . . , k do subtract 1 from T [hi(x)].count subtract x from T [hi(x)].keySum subtract y from T [hi(x)].valueSum end for 2.3 Data Lookups We perform the GET operation in a manner similar to how membership queries are done in a standard Bloom filter. The details are as follows: • GET(x): for each (distinct) hi(x), for i = 1, . . . , k do if T [hi(x)].count = 0 then return null else if T [hi(x)].count = 1 then if T [hi(x)].keySum = x then return T [hi(x)].valueSum else end if return null end if end for return “not found” Recall that for now we assume that all insertions and deletions are done correctly, that is, no insert will be done for an existing key in B and no delete will be performed for a key-value pair not already in B. With this assumption, if the above operation returns a value y or the null value, then this is the correct response. This method may fail, returning “not found,” if it can find no cell that x maps to that holds only one entry. Also, as a value is returned only if the count is 1, overflow of the sum fields is not a concern. For a key x that is in B, consider the probability p0 that each of its hash locations contains no other item. Using the standard analysis for Bloom filters (e.g., see [8]), we find p0 is: (cid:18) (cid:19)(n−1) ≈ e−kn/m. p0 = 1 − k m That is, assuming the table is split into k subtables of size m/k (one for each hash function), each of the other n − 1 keys misses the location independently with proba- bility 1 − k/m. One nice interpretation of this is that the number of keys that hash to 8 the cell is approximately a Poisson random variable with mean kn/m, and e−kn/m is the corresponding probability a cell is empty. The probability that a GET for a key that is in B returns “not found” is therefore approximately (1 − p0)k ≈(cid:16) 1 − e−kn/m(cid:17)k , which corresponds to the false-positive rate for a standard Bloom filter. As is standard for these arguments, these approximations can be readily replaced by tight concentra- tion results [8]. The probability that a GET for a key that is not in B returns“not found” instead of null can be found similarly. Here, however, note that every cell hashed to by that key must be hashed to by at least two other keys from B. This is because an empty cell would lead to a null return value, and a cell with just one key hashed to it would yield the corresponding true key value, and hence also lead to a null return value for a key not in B. Using the same approximation – specifically, that the number of keys from B that land in a cell is approximately distributed as a discrete Poisson random variable with mean kn/m – we find this probability is (cid:18) 1 − e−kn/m − kn m e−kn/m (cid:19)k . 2.4 Listing Set Entries Let us next consider the method for listing the contents of B. We describe this method in a destructive fashion—if one wants a non-destructive method, then one should first create a copy of B as a backup. • LISTENTRIES(): end while while there’s an i ∈ [1, m] with T [i].count = 1 do add the pair (T [i].keySum , T [i].valueSum) to the output list call DELETE(T [i].keySum , T [i].valueSum) It is a fairly straightforward exercise to implement this method in O(m) time, say, by using a link-list-based priority queue of cells in T indexed by their count fields and modifying the DELETE method to update this queue each time it deletes an entry from B. If at the end of the while-loop all the entries in T are empty, then we say that the method succeeded and we can confirm that the output list is the entire set of entries in B. If, on the other hand, there are some cells in T with non-zero counts, then the method only outputs a partial list of the key-value pairs in B. This process should appear entirely familiar to those who work with random graphs and hypergraphs. It is exactly the same procedure used to find the 2-core of a random hypergraph (e.g., see [16, 25]). To make the connection, think of the cells as being ver- tices in the hypergraph, and the key-value pairs as being hyperedges, with the vertices for an edge corresponding to the hash locations for the key. The 2-core is the largest 9 sub-hypergraph that has minimum degree at least 2. The standard “peeling process” finds the 2-core: while there exists a vertex with degree 1, delete it and the corre- sponding hyperedge. The equivalence between the peeling process and the scheme for LISTENTRIES is immediate. We note that this peeling process is similarly used for var- ious erasure-correcting codes, such as Tornado codes and its derivatives (e.g., see [23]), that have, in some ways, the same flavor as this construction5. Assuming that the cells associated with a key are chosen uniformly at random, we use known results on 2-cores of random hypergraphs. In particular, tight thresholds are known; when the number of hash values k of each is at least 2, there are constants ck > 1 such that if m > (ck + )n for any constant  > 0, LISTENTRIES succeeds with high probability, that is with probability 1− o(1). Similarly, if m < (ck − )n for any constant  > 0, LISTENTRIES succeeds with probability o(1). Hence t = m/ck is (approximately) the design threshold for the IBLT. As can be found in for example [16, 25], these values are given by (cid:110) (cid:111) < x . c−1 k = sup α : 0 < α < 1;∀x ∈ (0, 1), 1 − e−kαxk−1 It is easy to check from this definition that ck ≤ k, as for α = 1/k we immediately have 1 − e−xk−1 < x. In fact ck grows much mor slowly with k, as shown in Table 1, which gives numerical values for these thresholds for 3 ≤ k ≤ 7. Here we are not truly concerned with the exact values ck; it is enough that only linear space is required. It is worthwhile noting that ck is generally close to 1, while to obtain successful GET operations we require a number of cells which is a significant constant factor larger than n. Therefore, in practice the choice of the size of the IBLT will generally be determined by the desired probability for a successful GET operation, not the need for listing. (For applications where GET operations are unimportant and listing is the key feature, further improvements can be had by using irregular IBLTs.) k ck 3 4 5 6 7 1.222 1.295 1.425 1.570 1.721 Table 1: Thresholds for the 2-core rounded to four decimal places. When we design our IBLT, depending on the application, we may want a target probability for succeeding in listing entries. Specifically, we may desire failure to occur with probability O(t−c) for a chosen constant c (whenever n ≤ t). By choosing k sufficiently large and m above the 2-core threshold, we can ensure this; indeed, standard results give that the bottleneck is the possibility of having two edges with the same collection of vertices, giving a failure probability of O(t−k+2). The following theorem follows from previous work but we provide it for completeness. Theorem 1: As long as m is chosen so that m > (ck + )t for some  > 0, LISTEN- TRIES fails with probability O(t−k+2) whenever n ≤ t. 5Following this analogy, one could for example, consider irregular versions of the IBLT, where different keys utilize a different number of hash values; such a variation could use less space while allowing LISTEN- TRIES to succeed, or could be used to allow some keys with more hash locations to obtain a better likelihood of a successful lookup. These variations are straightforward and we do not consider the details further here. 10 Proof: We describe the result in terms of the 2-core. In what follows we assume n ≤ t. The probability that j hyperedges form a non-empty 2-core is dominated by the probability that these edges utilize only jk/2 vertices. This probability is at most (cid:17)j(cid:18) 2m (cid:19)jk/2(cid:18) jk (cid:19)jk (cid:18) jke (cid:19)j (cid:19)jk/2(cid:18) e 2m jk e nj . mjk/2 m j (cid:18)n (cid:19)(cid:18) m (cid:19)(cid:18) jk j jk/2 2m (cid:19)jk ≤ (cid:16) n = For k constant, m > (ck + )n, and j ≤ γn for some constant γ, the sum of these probabilities is dominated by the term where j = 2, which corresponds to a failure probability of O(n−k+2). To deal separately with the case of j > γn, we note that standard analysis of the peeling process shows that, as long as m is above the decoding threshold, the probability that the peeling process fails before reaching a core of size δn for any constant δ is asymptotically exponentially small in n. (See, e.g., [14].) By this argument the case of j > γn adds a vanishing amount to the failure probability, completing the proof of the theorem. 3 Adding Fault Tolerance to an Invertible Bloom Lookup Table For cases where there can be deletions for key-value pairs that are not already in B, or values can be inserted for keys that are already in B, we require some fault tolerance. We can utilize a standard approach of adding random checksums to get better fault tolerance. Extraneous Deletions Let us first consider a case with extraneous deletions only. Specifically, we assume a key-value pair might be deleted without a corresponding insertion; however, in this first setting we still assume each key is associated with a single value, and is not inserted or deleted multiple times at any instant. This causes a variety of problems for both the GET and LISTENTRIES routines. For example, it is possible for a cell to have an associated count of 1 even if more than one key has hashed to it, if there are corresponding extraneous deletions; this causes us to re-evaluate our LISTENTRIES routine. To help deal with these issues, we add to our IBLT structure. We assume that each key x has an additional hash value given by a hash function G1(x), which in general we assume will take on uniform random values in a range [1, R]. We then require each cell has the following additional field: • a hashkeySum field, which is the sum of the hash values, G1(x), for all the keys that have been mapped to this cell. The hashkeySum field must be of sufficiently many bits and the hash function must be sufficiently random to make collisions sufficiently unlikely; this is not hard to achieve 11 in practice. Our insertion and deletion operations must now change accordingly, in that we now must add G1(x) to each T [hi(x)].hashkeySum on an insertion and subtract G1(x) during a deletion. The pseudocode for these and the other operations is given in Figure 3 at the end of this paper. The hashkeySum field can serve as an extra check. For example, to check when a cell has a count of 1 that it corresponds to a cell without extraneous deletions, we check G1(x) field against the hashkeySum field. For an error to occur, we must have that a deletion has caused a count of 1 where the count should be higher, and the hashed key values must align so that their sum causes a false check. This probability is clearly at most 1/R (using the standard principle of deferred decisions, the “last hash” must take on the precise wrong value for a false check). We will generally assume that R is chosen large enough that we can assume a false match does not occur throughout the lifetime of the data structure, noting that only O(log n) bits are needed to handle lifetimes that are polynomial in n. Notice that even if sum fields overflow, as long as they overflow gracefully, the probability of a false check is still 1/R. Let us now consider GET operations. The natural approach is to assume that the hashkeySum field will not lead to a false check, as above. In this case, on a GET of a key x, if the count field is 0, and the keySum and hashkeySum are also 0, one should assume that the cell is in fact empty, and return null. Similarly, if the count field is 1, and the keySum and hashkeySum match x and G1(x), respectively, then one should assume the cell has the right key, and return its value. In fact, if the count field is −1, and after negating keySum and hashkeySum the values match x and G1(x), respectively, one should assume the cell has the right key, except that it has been deleted instead of inserted! In our pseudocode we return the value, although one could also flag it as an extraneous deletion as well. Note, however, that we can no longer return null if the count field is 1 but the keySum field does not match x; in this case, there could be, for example, an additional key inserted and an additional key extraneously deleted from that cell, which would cause the field to not match even if x was hashed to that cell. If we let n be the number of keys either inserted or extraneously deleted in the IBLT, then this reduces the probability of returning null for a key not in B to(cid:0)1 − e−kn/m(cid:1)k. That is, to return null we must have at least one cell with zero key-value pairs from B hashing to it, which occurs (approximately) with the given probability (using our Poisson approximation). For the LISTENTRIES operation, we again use the hashkeySum field to check when a cell has a count of 1 that it corresponds to a cell without extraneous deletions. Note here that an error in this check will cause the entire listing operation to fail, so the probability of a false check should be made quite low—certainly inverse polynomial in n. Also note, again, that we can make progress in recovering keys with cells with a count of −1 as well, if the cell contains only one extraneously deleted key and no inserted keys. That is, if a cell contains a count of −1, we can negate the count, keySum, and hashkeySum fields, check the hash value against the key to prevent a false match, and if that check passes recover the key and remove it (in this case, add it back in) to the other associated cells. Hence, a cell cannot yield a key during the listing process only if more than one key, either inserted or deleted, has hashed to that cell. This is now exactly the same setting as in the original case of no extraneous deletions, 12 and hence (assuming that no false checks occur!) the same analysis applies, with n representing the number of keys either inserted or extraneously deleted. We give the revised pseudo-code descriptions in Figure 3. Multiple Values A more challenging case for fault tolerance occurs when a key can be inserted multiple times with different values, or inserted and deleted with different values. If a key is inserted multiple times with different values, not only can that key not be recovered, but every cell associated with that key has been poisoned, in that it will not be useful for listing keys, as it cannot have a count of 1 even as other values are recovered. (A later deletion of a key-value pair could correct this problem, of course, but the cell is poisoned at the time.) The same is true if a key is inserted and deleted with different values, and here the problem is potentially even worse: if a single other key hashes to that cell, the count may be 1 and the keySum and hashkeySum fields will be correct even though the valueSum field will not match the other key’s value, causing errors. Correspondingly, we introduce an additional check for the sum of the values at a cell, using a hash function G2(y) for the values, and adding the following field: • a hashvalueSum field, which is the sum of the hash values G2(y) for all the values that have been mapped to this cell. One can then check that the hash of the keySum and valueSum take on the appropriate values when the count field of a cell is 1 (or −1) in order to see if listing the key-value pair is appropriate. The question remains whether the poisoned cells will prevent recovery of key val- ues. Here we modify the goal of LISTENTRIES to return all key-value pairs for all valid keys with high probability—that is, all keys with a single associated value at that time. We first claim that if the invalid keys make up a constant fraction of the n keys that this is not possible under our construction with linear space. A constant fraction of the cells would then be poisoned, and with constant probability each valid key would then hash solely to poisoned cells, in which case the key could not be recovered. However, it is useful to consider these probabilities, as in practical settings these quantities will determine the probability of failure. For example, suppose γn keys are invalid for some constant γ. By our previous analysis, the fraction of cells that are poisoned is concentrated around(cid:0)1 − e−kγn/m(cid:1), and hence the probability that any specific valid key has all of its cells poisoned is(cid:0)1 − e−kγn/m(cid:1)k. (While there are other possible ways a key could not be recovered, for example if two keys have all but one of their cells poisoned and their remaining cell is the same, this gives a good first approximation for reasonable values, as other terms will generally be lower order when these probabilities are small.) For example, in a configuration we use in our experiments below, we choose k = 5, m/n = 8, and γ = 1/10; in this case, the probability of a specific valid key being unrecoverable is approximately 8.16 · 10−7, which may be quite suitable for practice. For a more theoretical asymptotic analysis, suppose instead that there are only n1−β invalid keys. Then if each key uses at least (cid:100)1/β(cid:101) + 1 hash functions, with high prob- ability every valid key will have at least one hash location that does not coincide with 13 a invalid cell. This alone does not guarantee reconstructing the valid key-value pairs, but we can extend this idea to show LISTENTRIES can provably successfully obtain all valid keys even with n1−β invalid keys; by using k = (cid:100)1/β(cid:101) + 4 hash functions, we can guarantee with high probability that every valid key has at least 3 hash locations without an invalid cell. (One can raise the probability to any inverse polynomial in n by changing the constant 4 as desired.) Indeed, we can determine the induced distri- bution for the number of neighbors that are unpoisoned cells for the valid keys, but the important fact is that the number of keys with k hashes to unpoisoned cells in n− o(n). It follows from the standard analysis of random cores (e.g., see Molloy [25]) that the same threshold as for the original setting with k hash functions applies. Hence the number of cells needed will again be linear in n (with the coefficient dependent on β) in order to guarantee successful listing of keys with high probability. This yields the following theorem: Theorem 2: Suppose there are n1−β invalid keys. Let k = (cid:100)1/β(cid:101) + 4. Then if m > (ck + )n for some  > 0, LISTENTRIES succeeds with high probability. While this asymptotic analysis provides some useful insights, namely that full re- covery is practical, in practice we expect the analysis above based on setting γ so that the number of invalid keys is γn will prove more useful for parameter setting and pre- dicting performance. Extensions to Duplicates Interestingly, using the same approach as for extraneous deletions, our IBLT can handle the setting where the same key-value pair is inserted multiple times. Essentially, this means the IBLT is robust to duplicates, or can also be used to obtain a count for key-value pairs that are inserted multiple times. We again use the additional hashkeySum and valueSum fields. When the count field is j for the cell, we take the keySum, hashkeySum, and valueSum fields and divide them by j to obtain the proposed key, value, and corresponding hash. (Here, note we cannot use XORs in place of sums in our algorithms.) If the key hash matches, we assume that we have found the right key and return the lookup value or list the key-value pair accordingly, depending on whether a GET or LISTENTRIES operation is being performed. If it is possible to have the same key appear with multiple values, as above, then we must also make use of the hashvalueSum fields, dividing it by j and using it to check that the value is correct as well. For the listing operation, the IBLT deletes j copies of the key-value pair from the other cells.6 The point here is that a key that appears multiple times, just as a key that is deleted rather than inserted, can be handled without significant change to the decoding approach. The one potential issue with duplicate key-value pairs is in the case of word-value overflow for the memory locations containing the sum; in case of overflow, it may be that one does not detect that the key hash matches (and similarly for the hashvalue- Sum fields). In practice this may limit the number of duplicates that can be tolerated; however, for small numbers of duplicates and suitably sized memory fields, overflow 6Note that here we are making use of the assumption that the hash locations are distinct for a key; otherwise, the count for the number of copies at this location might not match the number of copies of the key in all the other locations. 14 will be a rare occurrence (that would require large numbers of keys to hash to the same cell, a provably probabilistically unlikely event). Fault Tolerance to Lost Memory Subblocks We offer one additional way this struc- ture proves resilient to various possible faults. Suppose that the structure is indeed set up with k different memory subblocks, one for each hash function. Conceivably, one could lose an entire subblock, and still be able to recover all the keys in a listing with high probability, with only a reduction in the success probability of a GET (as long as k − 1 hashes with a smaller range space remains sufficient for listing). In some sense, this is because the system is arguably overdesigned; obtaining high lookup success probability when n is less than the threshold t requires a large number of empty cells, and this space is far more than is needed for decoding. An Example Application As an example of where these ideas might be used, we return to our mirror site application. An IBLT B from Alice can be used by Bob to find filename-checksum (key-value) pairs where his filename has a different checksum than Alice’s. After deleting all his key-value pairs, he lists out the contents of B to find files that he or Alice has that the other does not. The IBLT might not be empty at this point, however, as the listing process might not have been able to complete due to poisoned cells, where deletions were done for keys with values different than Alice’s values. To discover these, Bob can re-insert each of his key-value pairs, in turn, to find any that may unpoison a cell in B (where he immediately deletes ones that don’t lead to a new unpoisoned cell). If a new unpoisoned cell is found found (using the G1 hash function as a check), then Bob can then remove a key-value pair with the same key as his but with a different value (that is, with Alice’s value). Note Bob may then also be able to possibly perform more listings of keys that might have been previously unrecovered because of the poisoned cells. Repeating this will discover with high probability all the key-value pairs where Alice and Bob differ. 4 Space-Saving for an Invertible Bloom Lookup Table Up to this point, we have not been concerned with minimizing space for our IBLT structure, noting that it can be done in linear space. Nevertheless, there are a variety of techniques available for reducing the space required, generally at the expense of additional computation and shuffling of memory, while still keeping constant amortized or worst-case time bounds on various operations. Whether such efforts are worthwhile depends on the setting; in some applications space may be the overriding issue, while in others speed or even simplicity might be more relevant. We briefly point to some of the previous work that can offer further insights. IBLTs, like other Bloom filter structures, often have a great deal of wasted space corresponding to zero entries that can be compressed or fixed-length space required for fields like the count field that can be made variable-length depending on the value. This wasted space can be compressed away using techniques for keeping compressed forms of arrays, including those for storing arrays of variable-length strings. Such mechanisms are explored in for example [4, 28, 34] and can be applied here. 15 A simpler, standard approach (saving less space) is to use quotienting, whereby the hash value for a key determines a bucket and an additional quotient value that can be stored. Quotienting can naturally be used with the IBLT to reduce the space used for storing for example the keySum or the hashkeySum values. Also, as previously mentioned, in settings without multiple copies of the same key-value pair, we can use XORs in place of sums to save space. Finally, we recall that the space requirements arise because of the desire for high accuracy for GET operations, not because of the LISTENTRIES operation. If one is willing to give up lookup accuracy—which may be the case if, for example, one expects the system to be overloaded much of the time—then less space is needed to maintain successful listing. 5 Simulations and Experiments We have run a number of simulations to test the IBLT structure and our analysis. In these experiments we have not focused on running time; a practical implementation could require significant optimization. Also, we have not concerned ourselves with issues of word-value overflow. Because of this, there is no need to simulate the data structure becoming overloaded and then deleting key-value pairs, as the state after dele- tions would be determined entirely by the key-value pairs in the system. Instead, we focus on the success probability of the listing of keys and, to a lesser extent, on the success probability for a GET operation. Overall, we have found that the IBLT works quite effectively and the performance matches our theoretical analysis. We provide a few example results. In all of the experiments here, we have chosen to use five hash functions. First, our calculated asymptotic thresholds for decoding from Table 1 are quite ac- curate even for reasonably small values. For example, in the setting where there are no duplicate keys or extraneous deletions of keys, we repeatedly performed 20,000 simula- tions with 10,000 keys, and varied the number of cells. Table 1 suggests an asymptotic threshold for listing all entries near 14,250. As shown in Figure 1(a), around this point we see a dramatic increase in the average number of key-value pairs recovered when performing our LISTENTRIES operation. In fact, at 14,500 cells only two trials failed to recover all key-value pairs, and with 14,600 cells or more all trials successfully recover all key-value pairs. We performed an additional 200,000 trials with 14,600 cells, and again all trials succeeded. In Figure 1(b), we consider 20,000 simulations with 100,000 keys, where the corresponding threshold should be near 142,500. With more keys, we expect tighter concentration around the threshold, and indeed with 144,000 cells or more all trials successfully recover all key-value pairs. We performed an additional 200,000 trials with with 144,000 cells, and again all trials succeeded. We acknowledge that more simulations would be required to obtain detailed bounds on the probability of failure to recover all key-value pairs for specific values of the number of key-value pairs and cells. This is equivalent to the well-studied problem of “finite-length analysis” for related families of error-correcting codes. Dynamic pro- gramming techniques, as discussed in [21] and subsequent follow-on work, can be applied to obtain such bounds. 16 Our next tests of the IBLT allow duplicate keys with the same value and extrane- ous deletions, but without keys with multiple values. Our analysis suggests this should work exactly as with no duplicate or extraneous deletions, and our simulations verify this. In these simulations, we had each key result in a duplicate with probability 1/5, and each key result in a deletion in place of an insertion with probability 1/5. Using a check on key and value fields, in 20,000 simulations with 10,000 keys, 80,000 cells, and 5 hash functions, a complete listing was obtained every time, and GET operations were successful on average for 97.83 percent of the keys, matching the standard anal- ysis for a Bloom filter. Results were similar with 20,000 runs with 100,000 keys and 800,000 cells, again with complete recovery each time and GET operations successful on average for 97.83 percent of the keys. Finally, we tested the IBLT with keys that erroneously obtain multiple values. As expected, these keys can prevent recovery of other key-value pairs during listing, but do not impact the success probability of GET operations for other keys. For example, again using a check on key and value fields, in 20,000 simulations with 10,000 keys of which 500 had multiple values, 80,000 cells, and 5 hash functions, the 9500 remaining key-value pairs were recovered 19,996 times; the remaining 4 times all but one of the 9500 key-value pairs was recovered. With 1000 keys with multiple values, the remain- ing key-value pairs were recovered 19,872 times, and again the remaining 128 times all but one of the 9000 key-value pairs was recovered. The average success rate for GET operations remained 97.83 percent on the valid keys in both cases, as would be expected. We note that with 10,000 keys with 1,000 with multiple values, our previous back-of-the-envelope calculation showed that each valid key would fail with probabil- ity roughly 8.16·10−7; hence, with 9,000 other keys, assuming independence we would estimate the probability of complete recovery at approximately 0.9927, closely match- ing our experimental results. More detailed results are give in Figures 2(a) and 2(b), where we vary the number keys with multiple values for two settings: 10,000 keys and 80,000 cells, and 100,000 keys and 800,000 cells. The results are based on 20,000 trials. As can be seen complete recovery is possible with large numbers of multiple- valued keys in both cases, but naturally the probability of complete recovery becomes worse with larger numbers of keys even if the percentage of invalid keys is the same. We emphasize that even when complete recovery does not occur in this setting, generally almost all keys with a single value can be recovered. For example, in Table 2 we consider three experiments. The first is for 10,000 keys, 80,000 cells, and 1,000 keys with duplicate values. The second is the same but with 2,000 keys with duplicate values. The third is for 100,000 keys, 800,000 cells, and 10,000 keys with duplicate values. Over all 20,000 trials for each experiment, in no case were more than 3 valid keys unrecovered. The main point of Table 2 is that with suitable design parameters, even when complete recovery is not possible because of invalid keys, the degradation is minor. We suspect this level of robustness may be useful for some applications where almost-complete recovery is acceptable. 17 Unrecovered Keys 0 99.360 83.505 92.800 1 0.640 14.885 6.915 2 0.000 1.520 0.265 3 0.000 0.090 0.020 Experiment 1 Experiment 2 Experiment 3 Table 2: Percentage of trials where 1, 2, and 3 keys are left unrecovered. 6 Conclusion and Future Work We have given an extension to the Bloom filter data structure to key-value pairs and the ability to list out its contents. This structure is deceptively simple, but is able to achieve functionalities and efficiencies that appear to be unique in many respects, based on our analysis derived from recent results on 2-cores in hypergraphs. One possible direction for future work includes whether one can easily include methods for allowing for multiple values as a natural condition instead of an error. Acknowledgments Michael Goodrich was supported in part by the National Science Foundation under grants 0724806, 0713046, 0847968, and 0953071. Michael Mitzenmacher was sup- ported in part by the National Science Foundation under grants IIS-0964473, CCF- 0915922 and CNS-0721491, and in part by grants from Yahoo! Research, Cisco, Inc., and Google. References [1] N. Alon and A. Nussboim. k-wise independent random graphs. In Proceedings of the 49th Annual IEEE Symposium on Foundations of Computer Science, pages 813–822, 2008. [2] M. Bawa, R. J. Bayardo, Jr, R. Agrawal, and J. Vaidya. Privacy-preserving indexing of documents on the network. The VLDB Journal, 18(4):837–856, 2009. [3] S. M. Bellovin and W. R. Cheswick. Privacy-enhanced searches using encrypted Bloom filters. Technical Report CUCS-034-07, Columbia University, Dept. of Computer Science, 2007. [4] D. Blandford and G. Blelloch. Compact dictionaries for variable-length keys and data with applications. ACM Transactions on Algorithms (TALG), 4(2):1–25, 2008. [5] B. Bloom. Space/time trade-offs in hash coding with allowable errors. Communications of the ACM, 13(7):422–426, 1970. 18 [6] F. Bonomi, M. Mitzenmacher, R. Panigrahy, S. Singh, and G. Varghese. Beyond Bloom filters: From approximate membership checks to approximate state machines. ACM SIGCOMM Computer Communication Review, 36(4):326, 2006. [7] F. Bonomi, M. Mitzenmacher, R. Panigrahy, S. Singh, and G. Varghese. An improved construction for counting Bloom filters. In Proceedings of the European Symposium on Algorithms (ESA), volume 4168 of LNCS, pages 684–695, 2006. [8] A. Broder and M. Mitzenmacher. Network applications of Bloom filters: A survey. Internet Mathematics, 1(4):485–509, 2004. [9] B. Chazelle, J. Kilian, R. Rubinfeld, and A. Tal. The Bloomier filter: an efficient data structure for static support lookup tables. In Proceedings of the Fifteenth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 30–39, 2004. [10] S. Chen, R. Wang, X. Wang, and K. Zhang. Side-channel leaks in web applications: a reality today, a challenge tomorrow. In Proceedings of the 31st IEEE Symposium on Security and Privacy, 2010. [11] B. Chor, E. Kushilevitz, O. Goldreich, and M. Sudan. Private information retrieval. J. ACM, 45:965–981, November 1998. [12] S. Cohen and Y. Matias. Spectral Bloom filters. In Proceedings of the 2003 ACM SIGMOD International Conference on Management of Data, pages 241–252, 2003. [13] G. Cormode and S. Muthukrishnan. An improved data stream summary: the count-min sketch and its applications. J. Algorithms, 55:58–75, April 2005. [14] R. Darling and J. Norris. Differential equation approximations for Markov chains. Probability Surveys, 5:37–79, 2008. [15] L. Devroye and P. Morin. Cuckoo hashing: further analysis. Inf. Process. Lett., 86(4):215–219, 2003. [16] M. Dietzfelbinger, A. Goerdt, M. Mitzenmacher, A. Montanari, R. Pagh, and M. Rink. Tight thresholds for cuckoo hashing via XORSAT. In Proceedings of ICALP, pages 213–225, 2010. [17] D. Eppstein and M. T. Goodrich. Straggler identification in round-trip data streams via Newton’s identities and invertible Bloom filters. IEEE Transactions on Knowledge and Data Engineering, to appear. [18] E.-J. Goh. Secure indexes. Cryptology ePrint Archive, Report 2003/216, 2003. http://eprint.iacr.org/2003/216/. [19] O. Goldreich and R. Ostrovsky. Software protection and simulation on oblivious RAMs. J. ACM, 43(3):431–473, 1996. 19 [20] M. T. Goodrich and M. Mitzenmacher. MapReduce parallel cuckoo hashing and oblivious RAM simulations. CoRR, abs/1007.1259, 2010. [21] R. Karp, M. Luby, and A. Shokrollahi. Finite length analysis of LT codes. In Proceedings of the International Symposium on Information Theory, page 39, 2004. [22] Y. Lu, A. Montanari, B. Prabhakar, S. Dharmapurikar, and A. Kabbani. Counter braids: a novel counter architecture for per-flow measurement. In Proceedings of the 2008 ACM SIGMETRICS International Conference on Measurement and Modeling of Computer Systems, pages 121–132, 2008. [23] M. Luby, M. Mitzenmacher, M. Shokrollahi, and D. Spielman. Efficient erasure correcting codes. IEEE Transactions on Information Theory, 47(2):569–584, 2001. [24] M. Mitzenmacher and S. Vadhan. Why simple hash functions work: exploiting the entropy in a data stream. In Proceedings of the Nineteenth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 746–755, 2008. [25] M. Molloy. The pure literal rule threshold and cores in random hypergraphs. In Proceedings of the fifteenth annual ACM-SIAM symposium on Discrete algorithms, pages 672–681. Society for Industrial and Applied Mathematics, 2004. [26] M. Naor, G. Segev, and U. Wieder. History-independent cuckoo hashing. In Proceedings of ICALP, pages 631–642, 2008. [27] R. Nojima and Y. Kadobayashi. Cryptographically secure Bloom-filters. Trans. Data Privacy, 2(2):131–139, 2009. [28] A. Pagh, R. Pagh, and S. Rao. An optimal Bloom filter replacement. In Proceedings of the Sixteenth Annual ACM-SIAM Symposium on Discrete Algorithms, page 829, 2005. [29] R. Pagh and F. F. Rodler. Cuckoo hashing. J. Algorithms, 51(2):122–144, 2004. [30] J. J. Parekh, K. Wang, and S. J. Stolfo. Privacy-preserving payload-based correlation for accurate malicious traffic detection. In LSAD ’06: Proceedings of the 2006 SIGCOMM Workshop on Large-scale Attack Defense, pages 99–106, 2006. [31] B. Pinkas and T. Reinman. Oblivious RAM revisited. In T. Rabin, editor, Advances in Cryptology (CRYPTO), volume 6223 of Lecture Notes in Computer Science, pages 502–519. Springer, 2010. [32] E. Price. Efficient sketches for the set query problem. CoRR, abs/1007.1253, 2010. [33] F. Putze, P. Sanders, and J. Singler. Cache-, hash-, and space-efficient Bloom filters. J. Exp. Algorithmics, 14:4.4–4.18, 2009. 20 [34] R. Raman and S. Rao. Succinct dynamic dictionaries and trees. In Proceeding of ICALP, pages 357–368, 2003. [35] H. Song, S. Dharmapurikar, J. Turner, and J. Lockwood. Fast hash table lookup using extended Bloom filter: An aid to network processing. In Proceedings of SIGCOMM, pages 181–192, 2005. [36] M. Stonebraker. In search of database consistency. Commun. ACM, 53:8–9, October 2010. [37] S. Yekhanin. Private information retrieval. Commun. ACM, 53:68–73, April 2010. 21 (a) 10,000 keys (b) 100,000 keys Figure 1: Percentage of key-value pairs recovered around the threshold. Slightly over the theoretical asymptotic threshold, we obtain full recovery of all key-value pairs with LISTENTRIES on all simulations. Each data point represents the average of 20,000 simulations. 22 0 20 40 60 80 100 13800 14000 14200 14400 14600 14800Avg. Percentage RecoveredSize of TableRecovery for 10000 Keys 0 20 40 60 80 100 138000 140000 142000 144000 146000 148000Avg. Percentage RecoveredSize of TableRecovery for 100000 Keys (a) 10,000 keys (b) 100,000 keys Figure 2: Percentage of trials with incomplete recovery with “damaged” keys that have multiple values. Each data point represents the average of 20,000 simulations. 23 0 0.2 0.4 0.6 0.8 1 0 200 400 600 800 1000Percentage Incomplete RecoveryDamaged KeysRecovery with Damaged Keys 0 2 4 6 8 10 0 2000 4000 6000 8000 10000Percentage Incomplete RecoveryDamaged KeysRecovery with Damaged Keys • INSERT(x, y): for each hi(x) value, for i = 1, . . . , k do add 1 to T [hi(x)].count add x to T [hi(x)].keySum add y to T [hi(x)].valueSum add G1(x) to T [hi(x)].hashkeySum end for • DELETE(x, y): for each hi(x) value, for i = 1, . . . , k do subtract 1 from T [hi(x)].count subtract x from T [hi(x)].keySum subtract y from T [hi(x)].valueSum subtract G1(x) to T [hi(x)].hashkeySum end for • GET(x): for each hi(x) value, for i = 1, . . . , k do if T [hi(x)].count = 0 and T [hi(x)].keySum = 0 and T [hi(x)].hashkeySum = 0 then return null else if T [hi(x)].count = 1 and T [hi(x)].keySum = x and T [hi(x)].hashkeySum = G1(x) then else if T [hi(x)].count = −1 and T [hi(x)].keySum = −x and T [hi(x)].hashkeySum = −G1(x) then return T [hi(x)].valueSum return −T [hi(x)].valueSum end if end for return “not found” • LISTENTRIES(): while there is an i ∈ [1, m] such that T [i].count = 1 or T [i].count = −1 do 1 and T [hi(x)].hashkeySum = if T [hi(x)].count G1(T [hi(x)].keySum) then = add the pair, (T [i].keySum , T [i].valueSum), to the output list call DELETE(T [i].keySum, T [i].valueSum) else if T [hi(x)].count = −1 and −T [hi(x)].hashkeySum = G1(−T [hi(x)].keySum) then add the pair, (−T [i].keySum , −T [i].valueSum), to the output list call INSERT(−T [i].keySum,−T [i].valueSum) end if end while Figure 3: Revised pseudo-code for tolerating extraneous deletions. 24
1608.04759
1
1608
2016-08-16T20:03:58
Faster Sublinear Algorithms using Conditional Sampling
[ "cs.DS", "cs.LG" ]
A conditional sampling oracle for a probability distribution D returns samples from the conditional distribution of D restricted to a specified subset of the domain. A recent line of work (Chakraborty et al. 2013 and Cannone et al. 2014) has shown that having access to such a conditional sampling oracle requires only polylogarithmic or even constant number of samples to solve distribution testing problems like identity and uniformity. This significantly improves over the standard sampling model where polynomially many samples are necessary. Inspired by these results, we introduce a computational model based on conditional sampling to develop sublinear algorithms with exponentially faster runtimes compared to standard sublinear algorithms. We focus on geometric optimization problems over points in high dimensional Euclidean space. Access to these points is provided via a conditional sampling oracle that takes as input a succinct representation of a subset of the domain and outputs a uniformly random point in that subset. We study two well studied problems: k-means clustering and estimating the weight of the minimum spanning tree. In contrast to prior algorithms for the classic model, our algorithms have time, space and sample complexity that is polynomial in the dimension and polylogarithmic in the number of points. Finally, we comment on the applicability of the model and compare with existing ones like streaming, parallel and distributed computational models.
cs.DS
cs
Faster Sublinear Algorithms using Conditional Sampling Themistoklis Gouleakis Christos Tzamos Manolis Zampetakis EECS, MIT [email protected] EECS, MIT EECS, MIT [email protected] [email protected] Abstract A conditional sampling oracle for a probability distribution D returns samples from the conditional distribution of D restricted to a specified subset of the domain. A recent line of work [CFGM13, CRS14] has shown that having access to such a conditional sampling oracle requires only polylogarithmic or even constant number of samples to solve distribution testing problems like identity and uniformity. This significantly improves over the standard sampling model where polynomially many samples are necessary. Inspired by these results, we introduce a computational model based on conditional sampling to develop sublinear algorithms with exponentially faster runtimes compared to standard sub- linear algorithms. We focus on geometric optimization problems over points in high dimensional Euclidean space. Access to these points is provided via a conditional sampling oracle that takes as input a succinct representation of a subset of the domain and outputs a uniformly random point in that subset. We study two well studied problems: k-means clustering and estimating the weight of the minimum spanning tree. In contrast to prior algorithms for the classic model, our algorithms have time, space and sample complexity that is polynomial in the dimension and polylogarithmic in the number of points. Finally, we comment on the applicability of the model and compare with existing ones like streaming, parallel and distributed computational models. 6 1 0 2 g u A 6 1 ] S D . s c [ 1 v 9 5 7 4 0 . 8 0 6 1 : v i X r a Introduction 1 Consider a scenario where you are given a dataset of input points X , from some domain Ω, stored in a random access memory and you want to estimate the number of distinct elements of this (multi-)set. One obvious way to do so is to iterate over all elements and use a hash table to find duplicates. Although simple, this solution becomes unattractive if the input is huge and it is too expensive to even parse it. In such cases, one natural goal is to get a good estimate of this number instead of computing it exactly. One way to do that is to pick some random numbers from X and estimate, based on those, the total number of distinct elements in the set. This is equivalent to getting samples from a probability distribution where the probability of each element is proportional to the number of times it appears in X . In the context of probability distributions, this is a well understood problem, called support estimation, and tight bounds are known for its sampling complexity. More specifically, in [VV11], it is shown that the number of samples needed is Θ(n/ log n) which, although sublinear, still has a huge dependence on the input size n = X. In several situations, more flexible access to the dataset might be possible, e.g. when data are stored in a database, which can significantly reduce the number of queries needed to perform support estimation or other tasks. One recent model, called conditional sampling, introduced by [CFGM13, CRS14] for distribution testing, describes such a possibility. In that model, there is an underlying distribution D, and a conditional sampling oracle takes as input a subset S of the domain and produces a sample from D conditioned to a set S. [CFGM13] and [CRS14] study several problems in distribution testing obtaining surprising results: Using conditional queries it is possible to avoid polynomial lower bounds that exist for the sampling complexity in the standard distribution testing framework and get testers with only polylogarithmic or even constant query requirements. In follow up work, Acharya, Cannone and Kamath [ACK15b] consider the support estimation problem we described above and prove that the support estimation problem can be solved using only O(poly log log n) conditional samples. This is a doubly exponentially better guarantee compared to the optimal classical algorithm which requires Θ(n/ log n) samples [VV11]. Inspired by the power of these results, we introduce a computational model based on conditional sampling where the dataset is provided as a distribution and algorithms have access to a conditional sampling oracle that returns datapoints at random from a specified set. More precisely, an algorithm is given access to an oracle Cond(C) that takes as input a function C : Ω → {0, 1} and returns a tuple (i, xi) with C(xi) = 1 with i chosen uniformly at random from the subset {j ∈ [n] C(xj) = 1}. If no such tuple exists the oracle returns ⊥. The function C is represented as a binary circuit. We assume that queries to the conditional sampling oracle Cond take time linear in the circuit size. Equivalently, we could assume constant time, as we are already paying linear cost in the size of the circuit to construct it. Most works in conditional sampling, measure the performance of algorithms only by their query complexity. The work of [CRS14] considers the description complexity of the query set S by examining restricted conditional queries that either specify pairs of points or intervals. However, in many cases, such simple queries might not be sufficient to obtain efficient algorithms. We use the circuit size of a set's description as a measure of simplicity to allow for richer queries which is naturally counted towards the runtime of our algorithms. Except from its theoretical interest, it is practically useful to consider algorithms that perform well in the conditional sampling model. This is because efficient algorithms for the conditional sampling model can directly be implemented in a number of different computational models that arise when we have to deal with huge amount of data. In particular, let's assume that we have an algorithm A that solves a problem P using q conditional queries where the description of the sets used has size s and the additional computational time needed is r. 1 Parallel Computing: We notice that the computation of one conditional sample can be very easily parallelized because it suffices to assign to each processor a part of the input and send to each of them the description of the circuit. Each processor can compute which of its points satisfy the circuit and pick one at random among them. Then, we can select as output the sample of one processor chosen at random. The probability of choosing one processor in this phase is proportional to the number of points in the input assigned to this processor that belong to the conditioning set. This way we can implement in just a few steps a conditional sampling query. If the input is divided evenly among m processors the load on each of them is n/m. Combining the answers can be done in log m steps and therefore, the running time of A in the parallel computation model is O(q · s· (n/m + log m) + r) which gives a non-trivial parallelization of the problem P . Except from the running time, one important issue that can decrease the performance of a parallel algorithm is the communication that is needed among the processors as described in the work of Afrati et. al. [ABS+12]. This communication cost can be bounded by the size s of the circuit at each round plus the communication for the partition of the input that happens only once in the beginning. Streaming Algorithms: The implementation of a conditional query in the streaming model where we want to minimize the number of passes of the input is pretty straightforward. With one pass of the input we can select one point uniformly at random from the points that belong to the conditioning set using standard streaming techniques. The space that we need for each of these passes is just s and we need q passes of the input. Distributed Computing: The implementation of a conditional query in the distributed com- putational model can follow the same ideas as in the parallel computational model. The surprising result in all the above cases is that one has to deal with transferring appropriately the conditional sampling model to the wanted computational model and then we can get high performance algorithms once q, s and r are small. In this work we design algorithms that achieve all these quantities to be only polylogarithmic in the size of the input, which leads to very efficient algorithms in all the above models. 1.1 Previous Work on Sublinear Algorithms We consider two very well studied combinatorial problems: k-means clustering and minimum span- ning tree. For these problems we know the following about the sublinear algorithms in the classical setting. 1.1.1 k-means Clustering Sublinear algorithms for k-median and k-means clustering first studied by Indyk [Ind99]. In this work, given a set of n points from a metric space, an algorithm is given that computes a set of size O(k) that approximates the cost of the optimal clustering within a constant factor and runs in time O(nk). Notice that the algorithm is sublinear as the input contains all the pairwise distances between the points which have total size O(n2). In followup work, Mettu and Plaxton [MP04] gave a randomized constant approximation al- gorithm for the k-median problem with running time O(n(k + log n)) subject to the constraint R ≤ 2O(n/ log(n/k)), where R denotes the ratio between the maximum and the minimum distance between any pair of distinct points in the metric space. Also Meyerson et. al. [MOP04] presented a sublinear algorithm for the k-median problem with running time O((k2/ε) log(k/ε)) under the assumption that each cluster has size Ω(nε/k). In a different line of work Mishra, Oblinger and Pitt [MOP01] and later Czumaj and Sohler [CS07] assume that the diameter ∆ of the set of points is bounded and known. The running time of the algorithm by Mishra et. al. [MOP01] is only logarithmic in the input size n but is polynomial 2 in ∆. Their algorithm is very simple since it just picks uniformly at random a subset of points and solves the clustering problem on that subset. Following similar ideas, Czumaj and Sohler [CS07] gave a tighter analysis of the same algorithm proving that the running time depends only on the diameter ∆ and is independent of n. The dependence on ∆ is still polynomial in this work. The guarantee in both these works is a constant multiplicative approximation algorithm with an additional additive error term. 1.1.2 Minimum Spanning Tree in Euclidean metric space There is a large body of work on sublinear algorithms for the minimum spanning tree. In [Ind99], given n points in a metric space Ω an algorithm is provided that outputs a spanning tree in time O(n/δ) achieving a (1/2 − δ)-approximation to the optimum. When considering only the task of estimating of the weight of the optimal spanning tree, Czumaj and Sohler [CS04] provided an algorithm that gets an (1+ε)-approximation. The running time of this algorithm is O(n·poly(1/ε)). To achieve better guarantees several assumptions could be made. One first assumption is that we are given a graph that has bounded average degree deg and the weights of the edges are also bounded by W . For this case, the work of Chazelle et. al. [CRT05] provides a sublinear algorithm with running time O(deg · W · 1/ε2) that returns the weight of the minimum spanning tree with relative error ε. Although the algorithm completely gets rid of the dependence in the number of points n it depends polynomially in the maximum weight W . Also in very dense graphs deg is polynomial in n and therefore we also have a polynomial dependence on n. Finally, another assumption that we could make is that the points belong to the d-dimensional [CEF+05] provide an (1 + ε)- Euclidean space. For this case, the work of Czumaj et. approximation algorithm that requires time O(√n · (1/ε)d). Note that in this case the size of the input is O(n) and not O(n2) since given the coordinates of the n points we can calculate any distance. Therefore, the algorithms described before that get running time O(n) are not sublinear [CEF+05] manage to achieve a sublinear algorithm in this anymore. Although Czumaj et. al. case they cannot escape from the polynomial dependence on n. Additionally, their algorithm has exponential dependence on the dimension of the Euclidean space. al. 1.2 Our Contribution The main result of our work is that on the conditional sampling framework we can get exponentially faster sublinear algorithms compared to the sublinear algorithms in the classical framework. We first provide some basic building blocks – useful primitives for the design of algorithms. These building blocks are: a. Compute the size of a set given its description, Section 3.1. b. Compute the maximum of the weights of the points of a set given the description of the set and the description of the weights, Section 3.2. c. Compute the sum of the weights of the points of a set given the description of the set and the description of the weights, Section 3.3. d. Get a weighted conditional sample from the input set of points given the description of the weights, Section 3.4. e. Get an ℓ0-sample given the description of labels to the points Section 3.5. For all these primitives, we give algorithms that run in time polylogarithmic in the domain size and the value range of the weights. We achieve this by querying the conditional sampling oracle with random subsets produced by appropriately chosen distribution on the domain. Intuitively, this helps to estimate the density of the input points on different parts of the domain. One important issue of conditioning on random sets in that the description complexity of the set can be almost linear 3 on the domain size. To overcome this difficulty we replace the random sets with pseudorandom ones based on Nisan's pseudorandom generator [Nis90]. The implementation of these primitives is of independent interest and especially the fourth one since it shows that the weighted conditional sample, which is similar to sampling models that have been used in the literature [ACK15a], can be simulated by the conditional sampling model with only a polylogarithmic overhead in the query complexity and the running time. After describing and analyzing these basic primitives, we use them to design fast sublinear algorithms for the k-means clustering and the minimum spanning tree. 1.2.1 k-means Clustering Departing from the works of Mishra, Oblinger and Pitt [MOP01] and Czumaj and Sohler [CS07] where the algorithms start by choosing a uniform random subset, we start by choosing a random subset based on weighted sampling instead of uniform. In the classical computational model we need at least linear time to get one conditional sample and thus it is not possible to use the power of weighted sampling to get sublinear time algorithms for the k-means problem. But when we are working in the conditional sampling model, then the adaptive sampling can be implemented in polylogarithmic time and queries. This enables us to use all the known literature about the ways to get efficient algorithms using conditional sampling [AV07]. Quantitatively the advantage from the use of the weighted sampling is that we can get sublinear algorithms with running times O(poly(log ∆, log n)) where ∆ is the diameter of the metric space and n the number of points on the input. This is exponentially better from Indyk [Ind99] in terms of n and exponentially better from Czumaj and Sohler [CS07] in terms of ∆. This shows the huge advantage that one can get from the ability to use or implement conditional sampling queries. We develop and analyze these ideas in detail in Section 4. 1.2.2 Minimum Spanning Tree in Euclidean metric space Based on the series of works on sublinear algorithms for minimum spanning trees, we develop algorithms that exploit the power of conditional sampling and achieve polylogarithmic time with respect to the number of input points n and only polynomial with respect to the dimension of the Euclidean space. This is very surprising since in the classical model it seems to exist a polynomial barrier that we cannot escape from. Compared to the algorithm by Czumaj et. al. [CEF+05], we get running time O(poly(d, log n, 1/ε)) which is exponential improvement with respect to both the parameters n and d. We present our algorithm at Section 5. From a technical point of view, we use a gridding technique similar to [CEF+05] but prove that using a random grid can significantly reduce the runtime of the algorithm as we avoid tricky configurations that can happen in worst case. 2 Model and Preliminaries Notation For m ∈ N we denote the set {1,··· , m} by [m]. We use O(N ) to denote O(N logO(1) N ) algorithms. Given a function f that takes values over the rationals we use Cf to denote the binary circuit that takes as input the binary representation of the input x of f and outputs the binary representation of the output f (x). If the input or the output are rational numbers then the representation is the pair (numerator, denominator). Suppose we are given an input ~x = (x1, x2,··· , xn) of length n, where every xi belongs in some set Ω. In this work, we will fix Ω = [D]d for some D = nO(1) to be the discretized d-dimensional Euclidean space. Our goal is to compute the value of a symmetric function f : Ωn → R+ in input ~x ∈ Ωn. We assume that all xi are distinct and define X ⊆ Ω as the set X = {xi : i ∈ [n]}. Since we 4 consider symmetric functions f , it is convenient to extend the definition of f to sets f (X ) = f (x). A randomized algorithm that estimates the value f (x) is called sublinear if and only if its running time is o(n). We are interested in additive or multiplicative approximation. A sublinear algorithm Alg for computing f has (ε, δ)-additive approximation if and only if and has (ε, δ)-multiplicative approximation if and only if P [Alg(x) − f (x) ≥ ε] ≤ δ P [(1 − ε)f (x) ≤ Alg(x) ≤ (1 + ε)f (x)] ≤ δ. We usually refer to (ε, δ)-approximation and is clear from the context if we refer to the additive or the multiplicative one. 2.1 Conditional Sampling as Computational Model The standard sublinear model assumes that the input is stored in a random access memory that has no further structure. Since f is symmetric in the input points, the only reasonable operation is to uniformly sample points from the input. Equivalently, the input can be provided by an oracle Sub that returns a tuple (i, xi) where i is chosen uniformly at random from the set [n] = {1, . . . , n}. When the input has additional structure (i.e. points stored in a database), more complex queries can be performed. The conditional sampling model allows such queries of small description complexity to be performed. In particular, the algorithm is given access to an oracle Cond(C) that takes as input a function C : Ω → {0, 1} and returns a tuple (i, xi) with C(xi) = 1 with i chosen uniformly at random from the subset {j ∈ [n] C(xj) = 1}. If no such tuple exists the oracle returns ⊥. The function C is represented as a sublinear sized binary circuit. All the results presented in this paper use polylogarithmic circuit sizes. We assume that queries to the conditional sampling oracle Cond take time linear in the circuit size. Equivalently, we could assume constant time, as we are already paying linear cost in the size of the circuit to construct it. k-means Clustering 2.2 Let d(·,·) be distance metric function d : Ω × Ω → R, i.e. d(x, y) represents the distance between x and y. Given a set of centers P we define the distance of a point x from P to be d(x, P ) = minc∈P d(x, c). Now given a set of n input points X ⊆ Ω and a set of centers P ⊆ Ω we define the cost of P for X to be d(X , P ) =Px∈X d(x, P ). The k-means problem is the problem of minimizing the squared cost d2(X , P ) = Px∈X d2(x, P ) over the choice of centers P subject to the constraint P = k. We assume that the diameter of the metric space is ∆ = maxx,y∈X d(x, y). 2.3 Minimum spanning tree in Euclidean space Given a set of points X in d dimensions, the minimum spanning tree problem in Euclidean space ask to compute the a spanning tree T on the points minimizing the sum of weights of the edges. The weight of an edge between two points is equal to their Euclidean distance. We will focus on a simpler variant of the problem which is to compute the weight of the best possible spanning tree, i.e. estimate the quantity mintree T P(x,x′)∈T kx − x′k2. 3 Basic Primitives In this section, we describe some primitive operations that can be efficiently implemented in this model. We will use these primitives as black boxes in the algorithms for the combinatorial problems we consider. We make this separation as these primitives are commonly used building blocks and will make the presentation of our algorithms cleaner. 5 A lot of the algorithmic primitives are based on constructing random subsets of the domain and querying the random oracle Cond with a description of this set. A barrier is that such subsets have description complexity that is linear in the domain size. For this reason, we will use a pseudorandom set whose description is polylogarithmic in the domain size. The main tool to do this is Nisan's pseudorandom generator [Nis90] which produces pseudorandom numbers that appear as perfectly random to algorithms running in polylogarithmic time. Theorem 1 (Nisan's Pseudorandom Generator [Nis90]). Let UN and Uℓ denote uniformly random binary sequences of length N and ℓ respectively. There exists a map G : {0, 1}ℓ → {0, 1}N such that for any algorithm A : {0, 1}N → {0, 1}, with A ∈ SPACE(S), where S = S(N ), it holds that P(A(UN ) = 1) − P(A(G(Uℓ)) = 1) ≤ 2−S for ℓ = Θ(S log N ). Nisan's pseudorandom generator is a simple recursive process that starts with Θ(S log N ) ran- dom bits and generates a sequence of N bits. The sequence is generated in blocks of size S and every block can be computed given the seed of size Θ(S log N ) using O(log N ) multiplications on S bit numbers. The overall time and space complexity to compute the k-th block of S bits is O(S log N ) and there exists a circuit of size O(S log N ) that performs this computation. Using Nisan's theorem, we can easily obtain pseudorandom sets for conditional sampling. We are interested in random sets where every element appears with probability g(x) for some given function g. Corollary 1 (Pseudorandom Subset Construction). Let R be a random set, described by a circuit CR, that is generated by independently adding each element x ∈ Ω with probability g(x), where g is described by a circuit Cg. For any δ ≥ Ω−1, there exists a random set R′ described by a O(Cg + log Ω log(1/δ))-sized circuit CR′ such that P(Cond(C ∧ CR) = x) − P(Cond(C ∧ CR′) = x) ≤ δ for all circuits C and elements x ∈ Ω. Proof. The corollary is an application of Nisan's pseudorandom generator for conditional sampling. A simple linear time algorithm that performs conditional sampling based on a random set R as follows. We keep two variables, cntmatched the number of elements that pass the criteria of selection which is initialized at value 0, and the selected element. For every element x in the domain Ω in order, we perform the following: 1. Draw k random bits ~b ∈ {0, 1}k and check whether the number b · 2−k > g(x). 2. If yes, skip x and continue in the next element. 3. Otherwise if C(x) = 1, increment cntmatched and with probability cnt−1 matched change the selected element to x. Note that here, we have truncated the probabilities g(x) to 2−k accuracy, so the random set ¯R used is slightly different than R. However, picking k = O(log(Ω/δ)), we have that P(Cond(C ∧ CR) = x) − P(Cond(C ∧ C ¯R) = x) ≤ δ 2 for all circuits C and elements x ∈ Ω. 6 To prove the statement, we will use Nisan's pseudorandom generator to generate the sequence of bits for the algorithm. The algorithm requires only memory to store the two variables which is equal to Θ(log Ω) ≤ k. Moreover, the total number of random bits used is kΩ and thus by Nisan's pseudorandom generator we can create a sequence of random bits R′ based on a seed of size O(log(kΩ) and give them to the algorithm. This sequence can be computed in blocks of size k using a circuit C r of size O(log(kΩ) log(1/δ)) = O(log(Ω) log(1/δ)). We align blocks of bits with points x ∈ Ω and thus the circuit C r gives for input x the k bits needed in the first step of the above algorithm. This implies that the circuit CR′ that takes the output of C r and compares them with Cg satisfies: P(Cond(C ∧ C ¯R) = x) − P(Cond(C ∧ CR′) = x) ≤ δ 2 for all circuits C and elements x ∈ Ω. By triangular inequality, we get the desired error probability with respect to the circuit CR. The total size of the circuit CR′ is O(Cg + log Ω log(1/δ)) which completes the proof. 3.1 Point in Set and Support Estimation 3.1.1 Point in Set The point in set function takes a set S ⊆ Ω given as a circuit C and returns one point x ∈ S or ⊥ if there is no such point in the set of input points, i.e. X ∩ S = ∅. The notation that we use for this function is EP(·) and takes as input the description C of S. Obviously the way to implement this function in the conditional sampling model is trivial. Since the point in set returns any point in the described set S a random point also suffices. Therefore we just call the oracle Cond(C) and we return this as a result to EP(C). We can test whether there is a unique point in a set by setting x∗ = EP(C) and querying EP(C∧ Ix6=x∗). Similarly, if the set has k points, we can get all points in the set in time O(Ck +k2) by querying k times, excluding every time the points that have been found. 3.1.2 Support Estimation The support estimation function takes as input a description C of a set S ⊆ Ω and outputs an estimation for the size of the set SX = S ∩ X . We call this function SE(C). The first step is to define a random subset R ⊆ Ω by independently adding every element x ∈ Ω with probability 1 α for some integer parameter α that corresponds to a guess of the support size. Let CR be the description of R. We will later use Corollary 1 to show that an approximate version of CR can be efficiently constructed. We then use the Point-In-Set primitive and we query EP(C ∧ CR). This tests whether SX ∩ R ?= ∅ which happens with probability P[SX ∩ R = ∅] = P[(s1 /∈ R) ∧ (s2 /∈ R) ∧ ··· ∧ (sk /∈ R)] =(cid:18)1 − α(cid:19)k 1 . Using this query, we can distinguish whether SX ≤ (1−ε)α or SX ≥ (1+ε)α. The probabilities respectively. The total variation distance in the two cases is of these events are P1 ≥ (cid:0)1 − 1 and P2 ≤ (cid:0)1 − 1 α(cid:19)α(1−ε) 1 −(cid:18)1 − where for the second to last inequality we assumed α ≥ 21. α(cid:1)α(1+ε) P1(cid:19) ≥(cid:18)1 − P1 − P2 = P1(cid:18)1 − P2 1 α(cid:1)α(1−ε) α(cid:19)α·2ε! ≥(cid:18) 1 1 1The case a = 1 can be trivially handled by listing few points from SX . 4(cid:19)1−ε (cid:0)1 − e−2ε(cid:1) ≥ ε 2e 7 We can therefore conclude that for we can distinguish with probability δ between S ≤ (1− ε)α and S ≥ (1+ε)α using O(log 1 δ /ε2) queries of the form EP(C∧CR). Binary searching over possible α's, we can compute an (1 ± ε) approximation of the support size by repeating O(log n) times, as there are n possible values for α. A more efficient estimator, since we care about multiplicative approximation, only considers values for α of the form (1 + ε)i. There are are log1+ε n = O( 1 ε log n) possible such values, so doing a binary search over them takes O(log 1 ε + log log n) iterations. Thus, overall, the total number of queries is O(log 1 δ log log n/ε2). To efficiently implement each query, we produce a circuit CR′ using Corollary 1 with parameter δ′ for error and a constant function g(x) = 1/2. The only change is that at every comparison the probabilities P1 and P2 are accurate to within δ′. Choosing δ′ = ε implies that P1 − P2 Ω is still Ω(ε) and thus the same analysis goes through. The circuit C ∧ CR′ has size O(C + log2(Ω) + log(Ω) log(1/ε)) which implies that the total runtime for O(log 1 δ log log n/ε2) queries is O(cid:0)(C + log2(Ω)) log 1 Using our conditional sampling oracle, we are able to obtain the following lemma: δ /ε2(cid:1) as n = O(Ω). Lemma 1. There exists a procedure SE(C) that takes as input the description C of a set S and computes an (ε, δ)-multiplicative approximation of the size of S using O(log log n log(1/δ)/ε2) con- ditional samples in time O(cid:0)(C + log2 Ω) log(1/δ)/ε2(cid:1). 3.1.3 Distinct Values One function that is highly related to support estimation is the distinct values function, which we denote by DV. The input of this function is a description C of a set S together with a function f : Ω → [M ] described by a circuit Cf . The output of DV is the total number of distinct values taken by f on the subset SX = S ∩ X , i.e. DV(C, Cf ) = {f (x) x ∈ SX} To implement the distinct values function we perform support estimation on the range [M ] of the function f . This is done as before by computing random sets R ⊆ [M ] and performing the queries EP(C ∧ (CR ◦ Cf )), where CR is the circuit description of the set R and the circuit CR ◦ Cf takes value 1 on input x if f (x) ∈ R and 0 otherwise. Lemma 2. There exists a procedure DV(C, f ) that takes as input the description C of a set S and a function f : Ω → [M ] given as a circuit Cf and computes an (ε, δ)-multiplicative approximation to the number of distinct values of f on the set S ∩X in time O((C +Cf + log2 M ) log(1/δ)/ε2). The number of conditional samples used is O(log log n log(1/δ)/ε2). 3.2 Point of Maximum Weight The point of maximum weight function takes as input a description C of a set S together with a function f : Ω → [M ] given by a circuit Cf . Let SX = S ∩ X . The output of the function is the value maxx∈SX f (x). We call this function Max(C, Cf ). Sometimes we are interested also in finding a point where this maximum is achieved, i.e. arg maxx∈SX f (x) which we call ArgMax(C, Cf ). This is simple to implement by binary search for the value Max(C, Cf ). At every step, we make a guess m for the answer and test whether there exists a point in the set SX ∩ {f (x) ≥ m}. This requires log M queries and the runtime is O((C + Cf) log M ). Lemma 3. There exists a procedure Max(C, Cf ) that takes as input the description C of a set S and a function f : Ω → [M ] given as a circuit Cf and computes the value maxx∈SX f (x) using O(log M ) conditional samples in time O((C + Cf) log M ). 8 An alternative algorithm solves this task in O(log n log(1/δ)) queries with probability δ. The algorithm starts with the lowest possible value m for the answer, i.e. m = 1. At every step, it asks the Cond oracle for a random point with f (x) > m. If such a point x∗ exists, the algorithm updates the estimate by setting m = f (x∗). Otherwise, if no such point exists, the guessed value of m is optimal. It is easy to see that every step, with probability 1/2, half of the points are discarded. Repeating log(log n/δ) times we get that the points are halfed with probability 1 − δ/ log n. Thus after O(log n log(log n/δ)) steps, the points will be halfed log n times and the maximum will be identified with probability 1 − δ. Thus, the total number of queries is O(log n log(1/δ)) and we obtain the following lemma. Lemma 4. There exists a procedure Max(C, Cf ) that takes as input the description C of a set S and a function f : Ω → [M ] given as a circuit Cf and computes the value maxx∈SX f (x) using O(log n log(1/δ)) conditional samples in time O((C +Cf) log n log(1/δ)) with probability of error δ. 3.3 Sum of Weights of Points The sum of weights of points function takes as input a description C of a set S together with a function f : Ω → [M ]. The output of the function is an (1 ± ε) approximation of the sum of all f (x) for every x in SX = S ∩ X , i.e. Px∈SX To implement this function in the conditional sampling model, we first compute Max = Max(C, Cf ) (Lemma 4). We then create k = log1+ε(n/ε) = O(log n/ε) sets Si = {x ∈ S : f (x) ∈ ((1 + ε)−i, (1 + ε)1−i] · Max} for i ∈ [k], by grouping together points whose values are close. Let CSi denote the circuit description of every set Si. We can get an estimate for the overall sum as f (x). We call this function Sum(C, Cf ). Sum(C, Cf ) = SE (CSi) Max (1 + ε)i−1 k Xi=1 To see why this is an accurate estimate we rewrite the summation in the following form: f (x) = Xx∈SX Xx∈SX : f (x)≤Max·(1+ε)−k f (x) + k Xi=1 Xx∈Si∩X f (x) (1) To bound the error for the second term of (1), notice that for every i ∈ [k] and x ∈ Si, we have that f (x) ∈ ((1 + ε)−i, (1 + ε)1−i]· Max. Thus, the value Si ∩X Max (1+ε)i−1 is a (1 + ε)-approximation to the sumPx∈Si∩X f (x). Since the primitive SE (CSi) returns a (1 + ε)-approximation to Si ∩X, we get that the second term of (1) is approximated by Sum(C, Cf ) multiplicatively within (1+ε)2 ≤ 1 + 3ε. The first term introduces an additive error of at most n·Max·(1+ε)−k = ε·Max ≤ ε·Sum(C, Cf ) which implies that Sum(C, Cf ) gives (1 ± 4ε)-multiplicative approximation to the sum of weights. Rescaling ε by a constant, we get the desired guarantee. Thus, we can get the estimate by using one query to the Max primitive and k = O(log n/ε) queries to SE. For the process to succeed with probability δ, we require that all k of the SE queries to succeed with probability δ′ = δ/k. Plugging in the corresponding guarantees of Lemmas 1 and 4, we obtain the following: Lemma 5. There exists a procedure Sum(C, Cf ) that takes as input the description C of a set S and a function f : Ω → [M ] given by a circuit Cf and computes an (ε, δ)-multiplicative f (x) using O(log n log(1/δ)/ε3) conditional samples in time approximation of the value Px∈SX O(cid:0)(C + Cf + log2 Ω) log n log(1/δ)/ε3(cid:1). 9 3.4 Weighted Sampling The weighted sampling function gets as input a description C of a set S together with a function f : Ω → [M ] given as a circuit Cf . The output of the function is a point x in the set SX = S ∩ X chosen with probability proportionally to the value f (x). Therefore, we are interested in creating an oracle WCond(C, Cf ) that outputs element x ∈ SX with probability To implement the weighted sampling in the conditional sampling model, we use a similar idea as in support estimation. First we compute Sum = Sum(C, Cf ) and then we define a random set H that contains independently every element x with probability f (x) Py∈SX f (y) . P[x ∈ H] = f (x) 2Sum (2) Let CH be the description of H. We will later use Corollary 1 in order to build a pseudorandom set H′ with small circuit description CH ′ that approximately achieves the guarantees of CH. Based on the random set H, we describe Algorithm 1 which performs weighted sampling ac- cording to the function f . Algorithm 1 Sampling elements according to their weight. 1: selected ← ⊥ 2: while selected = ⊥ and #iterations ≤ k do Construct the random set H and CH as described by the equation (2) Check if there exists a unique point x ∈ SX in the set H. if such unique point x exists then With probability 1 − f (x) 2Sum , set selected ← x 7: return selected 3: 4: 5: 6: We argue the correctness of this algorithm. Given a purely random H, we first show that at every iteration, the probability of selecting each point x ∈ SX is proportional to its weight. This implies that the same will be true for the final distribution as we perform rejection sampling on ⊥ outcomes. The probability that in one iteration the algorithm will return the point x ∈ S is the probability that x has been chosen in H and that H ∩ SX = 1, i.e. it is the unique point of the input set X that lies in set S and was not filtered by H. For every x ∈ SX , this probability is equal to P[x ∈ H] Yy∈SX ,y6=x 2Sum(cid:19) ·(cid:18)1 − f (y) = f (x) 2Sum Yy∈SX ,y6=x(cid:18)1 − P[y /∈ H] · P[keep x] = f (x) 2Sum(cid:19) = f (x) 2Sum Yy∈SX(cid:18)1 − f (y) 2Sum(cid:19) and it is easy to see that this probability is proportional to f (x) as all other terms don't depend on x. We now bound the probability of selecting a point at one iteration. This is equal to f (x) Px∈SX 2Sum Yy∈SX(cid:18)1 − f (y) 2Sum(cid:19) ≥ 1 2 1 1 + ε exp(cid:18)−2Py∈S f (y) 2Sum (cid:19) ≥ 1 2 1 1 + ε exp(cid:18)− 1 1 − ε(cid:19) which is at least 1/4 for a small enough parameter ε > 0 chosen in our estimation Sum of the total sum of f (x). Thus at every iteration, there is a constant probability of outputing a point. By repeating k = Θ(log(1/δ)) times we get that the algorithm outputs a point with probability δ/2. 10 Summarizing, if we assume a purely random set H, the probability that the above procedure will fail in O(log(1/δ)) is at most δ/2 plus the probability that the computation of the sum will fail which we can also make to be at most δ/2, for a total probability δ of failure. Since we need only a constant multiplicative approximation to the sum, using Lemma 5 the total number of queries that we need for the probability of failure to be at most δ/2 is O(log n log(1/δ)). Since the random set H can have very large description complexity, we use Corollary 1 to generate a pseudorandom set H′. If we apply the corollary for error δ′ we get that the total variation distance between the output distribution in one step when using H′ with the distribution when using H is at most: P(Cond(C ∧ CH) = x) − P(Cond(C ∧ CH ′) = x) ≤ nδ′ Xx∈SX Since we make at most k = Θ(log(1/δ)) queries the oracle Cond, we get that the total variation distance between the two output distributions is O(nδ′ log(1/δ)). Setting δ′ = O( Ω log(1/δ) ) we get that this distance is at most ε. Computing the total runtime and number of samples, we obtain the following lemma. ε Lemma 6. There exists a procedure WCond(C, Cf ) that takes as input the description C of a set S and a function f given by a circuit Cf and returns a point x ∈ SX from a probability distribution that is at most ε-far in total variation distance from the probability distribution that selects each element x ∈ SX proportionally to f (x). The procedure fails with probability at most δ, uses O(log n log(1/δ)) conditional samples and takes time O((C+Cf+log2 Ω) log n log(1/δ)+log Ω log (1/ε) log(1/δ)). 3.5 Distinct Elements Sampling – ℓ0 Sampling The distinct elements sampling function gets as input a description C of a set S together with a function f : Ω → [M ] described by a circuit Cf . It outputs samples from a distribution on the set SX = S ∩ X such that the distribution of values f (x) is uniform over the image space f (SX ). We thus want that for every y ∈ f (SX ), P[x ∈ f−1(y)] = f (SX )−1. We first explain the implementation of the algorithm assuming access to true randomness. Assume therefore that we have a circuit Ch that describes one purely random hash function h : [M ] → [M ]. Then argmaxx∈SX h(f (x)) will produce a uniformly random element as long as the maximum element is unique. This means that if we call the procedure ArgMax to find a point x∗ = ArgMax(C, Ch ◦ Cf ) and check that no point x ∈ SX exists such that f (x) 6= f (x∗) and h(f (x)) = h(f (x∗)) then the result will be a point distributed with the correct distribution. Repeating O(log(1/δ)) times guarantees that we get a valid point with probability at least 1 − δ. Therefore the only question is how to replace h with a pseudorandom h′. We can apply Nisan's pseudorandom generator. Consider an algorithm that for every point y ∈ [M ] in order, draws a random sample s uniformly at random from [M ] and checks if y ∈ f (SX ) and whether s is the largest value seen so far. This algorithm computes argmaxy∈P h(y) while only keeping track of the largest sample s and the largest point y. This algorithm uses Θ(log M ) bits of memory and O(M log M ) random bits. Therefore we can apply Nisan's theorem (Theorem 1) for space Θ(log(1/ε)) for ε > M−1 and we can replace h with h′ that uses only O(log M log(1/ε)) random bits whose circuit representation is only O(log M log(1/ε)). This means that we can use the Lemma 4 and Theorem 1 to get the following lemma about the ℓ0-sampling. Lemma 7. There exists a procedure DES(C, Cf ) that takes as input the description C of a set S and a function f : Ω → [M ] given by a circuit Cf and returns a point x ∈ SX from a probability 11 distribution that is at most ε-far in total variation distance (for ε ≤ M−1) from a probability to every set f−1(y) for y ∈ f (SX ). This procedure fails distribution that assigns probability with probability at most δ, uses O(log n log(1/δ)) conditional samples and takes time O((C+Cf+ log M log(1/ε)) log n log(1/δ)). f (SX ) 1 4 k-means clustering In this section we describe how known algorithms for the k-means clustering can be transformed to sublinear time algorithms in the case that we have access to conditional samples. The basic tool of this algorithms was introduced by Arthur and Vassilvitskii [AV07]. D2-sampling: This technique provides some very simple algorithms that can easily get a constant factor approximation to the optimal k-means clustering, like in the work of Aggarwal et. al. [ADK09]. Also if we allow exponential running time dependence on k then we can also get a PTAS like in the work of Jaiswal et. al. [JKS14]. The drawback of this PTAS is that it works only for points in the d dimensional euclidean space. When working in arbitrary metric spaces, inspired by Aggarwal et. al. [ADK09] we use adaptive sampling to get a constant factor approximation to the k-means problem. Now we describe how all these steps can be implemented in sublinear time using the primitives that we described in the previous section. The steps of the algorithm are: 1. Pick a set P of O(k) points according to D2-sampling. For O(k) steps, let Pi denote the set of samples that we have chosen in the i step. We pick the (i + 1)th point according to the following distribution P(probability of picking ~xk) = d2(~xk, Pi) Pj d2(~xj, Pi) Implementation: To implement this step we simply use the primitive WCond(C, f ) where C is the constant true circuit and f (x) = d2(x, Pi) = minp∈Pi d2(x, p). The circuit to im- plement the function d2(·,·) has size O(log Ω) where ∆ is the diameter of the space. Now since Ci ≤ O(k) we can also implement the minimum using a tournament with only O(k) comparisons each of which has size O(log Ω). This means that the size of the circuit of f is bounded by Cf ≤ O(k log Ω). Therefore we can now use the Lemma 6 and get that we need O(k log n log(1/δ)) queries and running time O((k log Ω + log2 Ω) log n log(1/δ) + log Ω log(1/ε) log(1/δ)) to get the O(k) needed samples from a distribution that is ε1 in total variation distance from the correct distribution and has probability of error δ for each sample. 2. Weight the points of P according to the number of points that each one represents. For any point p ∈ P we set wp =(cid:12)(cid:12)(cid:8)x ∈ Ω ∀p′(6= p) ∈ P d(x, p′) < d(x, p)(cid:9)(cid:12)(cid:12) Implementation: To implement this step given the previous one we just iterate over all the points in P and for each one of these points p we compute the weight wp using the procedure Sum as described in Lemma 5. Similarly to the previous step we have that C is the constant 1 circuit and fp(x) is equal to 1 if the closest point to x in P is p and zero otherwise. To describe this function we need as before O(k log Ω) sized circuit. Therefore for this step we need O(log n log(1/δ)/ε3 2) conditional samples and running time O((k log Ω + log2 Ω) log n log(1/δ)/ε3 2) in order to get an (ε2, δ)−multiplicative approximation of every wp. 12 3. Solve the weighted k-means problem in with the weighted points of P. This can be done using an arbitrary constant factor approximation algorithm for k-means since the size of P is O(k) and therefore the running time will be just poly(k) which is already sublinear in n. To prove that this algorithm gets a constant factor approximation we use Theorem 1 and Theorem 4 of [ADK09]. From the Theorem 1 of [ADK09] and the fact that we sample from a distribution that is ε-close in total variation distance to the correct one we conclude that the set P that we chose satisfies Theorem 1 of [ADK09] with probability of error at most ε1 + O(k)δ. Then it is easy to see at Theorem 4 of [ADK09] that when we have a constant factor approximation of the weights, we lose only a constant factor in the approximation ratio. Therefore we can choose ε2 to be constant. Finally for the total probability of error to be constant, we have to pick ε1 to be constant. Combining all these with the description of the step that we have above we get the following result. Theorem 2. There exists an algorithm that computes an O(1)-approximation to the k-means clus- tering and uses only O(k2 log n log(k/δ)) conditional queries and has running time O(poly(k) log2 Ω log n log(1/δ)). Remark 1. The above algorithm could be extended to an arbitrary metric space where we are given a circuit Cd that describes the distance metric function. In this case the running time will also depend on Cd. Remark 2. In this case that the points belong to d dimensional space, we can also use the Find-k-means(X ) algorithm by [JKS14] to get (1 + ε)-approximation instead of constant. This algorithm iterates over a number of subsets of the input of specific size that have been selected using D2-sampling. Then from all these different solution it selects the one with the minimum cost. We can implement this algorithm using our WCond and Sum primitives to get a sublinear (ε, δ)- multiplicative approximation algorithm that uses O(cid:16)2 O(k2/ε) · log n · log(1/δ)(cid:17) conditional samples and has running time O(cid:16)2 O(k2/ε) · log2 Ω · log n · log(1/δ)(cid:17). 5 Euclidean Minimum Spanning Tree In this section we are going to discuss how to use the primitives that we described earlier in order to estimate the weight of the minimum spanning tree of n points in euclidean space. More specifically, suppose that we have a d-dimensional discrete euclidean space Ω = {1, . . . , ∆}d and a set of n points X = {x1, . . . , xn}, where xi ∈ Ω. We assume that ∆ = poly(n) which is a reasonable assumption to make when bounded precision arithmetic is used. This means that each coordinate of our points can be specified using O(log n) bits. In what follows, we are going to be using the following formula that relates the weight of an MST to the number of connected components of certain graphs. Let W denote the maximum distance between any pair of points in Ω. Moreover, let G(i) be the graph whose vertices correspond to points in X and the is an edge between two vertices if and only if the distance of the corresponding points is at most (1 + ε)i. By ci we denote the number of connected components of the graph G(i). In [CS04], it is shown that the following quantity leads to an (1 + ε)-multiplicative approximation of the weight of the minimum spanning tree: n − W + ε · (1 + ε)i · ci log1+ε W−1 Xi=0 13 (3) The quantity would be equal to the weight of the minimum spanning tree if all pairwise distances between points were (1 + ε)i for some i ∈ N. In order to estimate the weight of the MST, we need to estimate the number of connected components ci for each graph G(i). As shown in [FIS08], for every i, we can equivalently focus on performing the estimation task after rounding the coordinates of all points to an arbitrary grid of size ε(1 + ε)i/√d. This introduces a multiplicative error of at most 1 + O(ε) which we can ignore by scaling ε by a constant. We thus assume that every point is at a center of a grid cell when performing our estimation. We perform a sampling process which samples uniformly from the occupied grid cells (regardless of the number of points in each of them) and estimates the number of cells covered by the connected component j of G(i) that the sampled cell belongs to. Comparing that estimate to an estimate for the total number of occupied grid cells, we obtain an estimate for the total number of connected components. In more detail, if the sampled component covers a ρ fraction of the cells, the guess for the number of components is 1 ρ . For that estimator to be accurate, we need to make sure that the total expected number of occupied grid cells is comparable to the total number of components without blowing up in size exponentially with the dimension d of the Euclidean space. We achieve this by choosing a uniformly random shifted grid. This random shift helps us avoid corner cases where a very small component spans a very large number of cells even when all its contained points are very close together. With a random shift, such cases have negligible probability. We will first use the following lemma to get an upper bound on the number of occupied cells Rd which holds with high probability: Lemma 8. Let C ⊆ Rd be a 1-D curve of length L, a grid G ⊆ Rd of side length R and random vector ~v distributed uniformly over [0, R]d. Then, the expected number of grid cells of G + ~v that contain some point of the curve is vol([0,R]d+C) , where "+" denotes the Minkowski sum of the two sets. Proof. Consider the grid G = {R~z : ~z ∈ Zd} ⊆ Rd shifted by a random vector ~v ∈ [0, R]d to obtain a grid Gv = ~v + G. We associate every point ~z ∈ Gv with a cell ~z + [0, R]d. Observe that a cell corresponding to a grid point ~z intersects the curve C if (~z + [0, R]d) ∩ C 6= ∅, or equivalently if ~z ∈ C + [−R, 0]d. The expected number of occupied grid cells is thus equal to the expected number of grid points of Gv, which lie in the Minkowski sum of C and [−R, 0]d. Note that each of the original grid points ~z ∈ G can move inside a d-dimensional hypercube of side length R and all those hypercubes are pairwise disjoint and span the whole d-dimensional space. Now let I~z be the indicator random variable for the event that ~z ∈ C + [−R, 0]d. Clearly, E[I~z] = Pr[~z ∈ C + [−R, 0]d] = vol((C + [−R, 0]d) ∩ (~z + [0, R]d)) Rd So the expected number of points in C + [−R, 0]d is: E[♯points] = E"X~z∈G I~z# = vol(C + [−R, 0]d) Rd = vol(C + [0, R]d) Rd The following lemma bounds the volume of the required Minkowski sum. Lemma 9. Let C ⊆ Rd be a 1-D curve of length L. The volume of the Minkowski sum C + [0, R]d is at most Rd + √d · L. 14 Proof. We can think of the Minkowski sum as the set of points spanned by the d-dimensional hypercube [0, R]d as it travels along the curve C. Now suppose that we move the hypercube for a very small distance dL along an arbitrary unit vector ~r = (a1, . . . , ad) with positive coordinates (we assume this wlog since all other cases are symmetric). Also, let e1, . . . , ed be the standard basis vectors (i.e ei = (0, . . . , 0, 1, 0 . . . , 0) where the "1" is at the i-th coordinate). Note that each of those vectors is orthogonal to a facet of the hypercube and the total volume spanned by each facet during the movement is equal to the absolute value of the inner product ~r · ~ei scaled by dL where ei is the standard basis vector orthogonal to that facet. The volume spanned by this displacement is equal to the sum of the volumes spanned by each of the facets and is given by the following formula: dV = dL · Rd−1 · d Xi=1 ~r · ~ei = dL · Rd−1 · d Xi=1 ai = dL · Rd−1 · krk1 So in the worst case the curve C is a straight line segment along the all ones unit vector ~w = 1√d (1, 1, . . . , 1), since this is the unit vector that has the maximum l1 norm. In this case, the total volume spanned during the movement along C is: So, the volume of the Minkowski sum C + [0, R]d is: VC = L · Rd−1 · krk1 = √d · Rd−1 · L vol(C + [0, R]d) = Rd + VC = Rd + √d · Rd−1 · L and this is an upper bound for the general case. We can view the minimum spanning tree as a 1-D curve considering its Euler tour. The length of this Euler tour is 2 · M ST since each edge is traversed exactly twice. For the same reason, each point in the Minkowski sum is "covered by" at least two points in the curve. So, effectively, the length of the curve can be divided by 2. Thus, the volume of the Minkowski sum T + [0, R]d is at most Rd + √d · Rd−1 · M ST . Therefore, by lemma 8, we get that: E[♯cells] = 1 + Using Markov's inequality, we get that √d · M ST R Pr"♯cells > 2 · (1 + √d · M ST R )# < 1 2 Finally, we can use our support estimation primitive of Lemma 1 to estimate the number of occupied grid cells after a random shift which enables us to amplify the success probability to 1− δ by picking the random shift with the smallest number of cells after O(log(1/δ)) repetitions. We immediately get the following corollary: Corollary 2. We can find a grid of side length R, such that the number of grid cells that contain ) using O(log log n log2(1/δ)) conditional samples while the failure points is at most 2 · (1 + probability is at most δ. The total running time is O(log2 n log2(1/δ)). √d·M ST R 15 5.1 Computing the size of small connected components As we have said earlier, we will use (3) in order to estimate the weight of the MST. For every i, we estimate the number of connected components ci in the graph G(i) assuming that the points are in the center of a given grid with side length R = ε(1 + ε)i/√d and that the total number of grid cells is at most 2· (1 + ε(1+ε)i ). For that purpose, we will sample grid cells uniformly at random and estimate the size of the connected that we hit during our sampling procedure. ) = 2· (1 + d·M ST √d·M ST R In order to do this, we first sample a uniformly random grid cell using the Distinct Elements Sampling procedure of Lemma 7 and then perform a BFS-like search starting from that cell to count the number of cells in that connected component. More specifically, at every iteration, we ask for a uniformly random cell that is adjacent in G(i) to one of the cells we have already visited, using our conditional sampling oracle. If we visit more than t distinct cells (for some threshold t) during this search, we will stop and output that the connected component is "big". Otherwise, we stop when we completely explore the connected component and output its size. Since there cannot be too many "big" connected components, ignoring them is not going to affect our final estimate and note that there can be at most ♯cells/t too much. More specifically, we will set t = "big" connected components. So, by ignoring them we introduce at an additive error of at most ♯cells/t. d log1+ε W ε 5.2 Algorithm for estimating the number of connected components Now, we can continue with the main part of the algorithm which shows how to estimate the number of connected components of the graph G(i). Let s1, . . . , sk be the number of cells each of the k connected components of G(i) occupies respectively and X be the random variable for the index of the connected component our sample hits (in number of cells). Also, let S be the total number of occupied grid cells, and S be our estimate for that using the SE primitive from Lemma 1. Algorithm 2 Estimating ci 1: x0 ← uniformly random occupied cell using l0 sampling. 2: U ← {x0} 3: s ← 1 4: while (CU 6≡ 0) ∧ (s < 1 ε ) do 5: 6: x ← CON D(CU ), where the circuit CU requires the output to have a neighbor in he set U . U ← U ∪ {x} s ← s + 1 return ci = SE(C) d log1+ε W then 7: 8: if s < t = ε s 9: 10: else 11: return ci = 1 Our estimator which comes from Algorithm 2 is the following: I[X = j] S sj k Xj=1 where sj = sj when sj < t and sj = S otherwise (i.e ci = 1). Note that sj is always overestimating the true value of sj and an lower bound for this expectation 16 is the same sum if we exclude the "big" connected components. This means that: Pr[X = j] E[ S] sj ≤ E[ci] ≤ k Xj=1 sj <t Pr[X = j] E[ S] sj k Xj=1 sj <t + {j : sj > t} ⇔ {j : sj ≤ t} · E[ S] S ≤ E[ci] ≤ {j : sj ≤ t} · E[ S] S + {j : sj > t} where we substituted P r[X = j] = {j : sj ≤ t} /S since every component is selected with proba- bility proportional to the number of cells it contains. From the SE primitive, we have that Pr[S − S > ε · S] < δ So, by conditioning on the support estimation procedure succeeding (which happens with prob- ability 1 − δ) we get that: {j : sj ≤ t} · (1 − ε) ≤ E[ci] ≤ {j : sj ≤ t} · (1 + ε) + {j : sj > t} Thus, we have that E[ci], is an accurate approximation of ci with probability at least 1 − δ. In particular, since {j : sj > t} < S/t we get: (1 − ε)ci − S/t ≤ E[ci] ≤ (1 + ε)ci + S/t with probability at least 1 − δ. We are going to repeat the above estimation m times independently and keep the average which, as we are going to show, will be very well concentrated around its mean µi = E[ci]. To show that, we can use Hoefding's inequality since our trials are independent and trivially the value of each individual estimate is lower and upper bounded by 1 and S respectively. Let µi denote the estimated average. From Hoefding's inequality we get: Pr[µi − µi > S/t] < e −2m2 S2 t2 S2 m·S2 = e−2m/t2 If we set m = O(t2) we get the above guarantee with probability at least 1 − δ. This means that with probability 1 − δ we get: (1 − ε)ci − 2S/t ≤ µi ≤ (1 + ε)ci + 2S/t This means that µi = (1 ± ε)ci ± 4 · (1 + d·M ST following estimator for the weight of the MST: ε(1+ε)i )/t and applying it to equation (3), we get the \M ST = n − W + ε · l=log1+ε W−1 Xi=0 (1 + ε)i · µi = (1 ± ε)M ST ± 4ε l=log1+ε W−1 Xi=0 (1 + ε)i · d · M ST tε(1 + ε)i The last term is bounded by approximation to M ST . 4·d·log1+ε W t M ST which for t = d log1+ε W ε gives an (1 + ε)-multiplicative The total runtime requires log1+ε W iterations to estimate every ci by µi. In every iteration a random shifting is performed and the total number of occupied grid cells are counted using the SE primitive. Moreover, for the estimation O(t2) samples are required using Distinct Element 17 Sampling (ℓ0-sampling) of the occupied grid cells. Finally for each such sample, a BFS procedure is performed for at most t iterations. The circuit complexity of the conditional sampling queries that are required is negligible in most cases as it is subsumed by the runtime of the corresponding algorithmic primitive used. Only queries performed during the BFS have large circuit size as the circuit requires to keep all grid cells that have been visited. The size in that case is bounded by O(t log Ω) = O(t·d·log n). The number of samples is bounded by O(log1+ε W t3) = O(d3 log4 n/ε7) and the total runtime is bounded by O(log1+ε W t4d log n) = O(d5 log6 n/ε9) if we require constant success probability. Repeating log(1/δ) times we can amplify the total success probability to 1− δ. The following theorem shows the dependence of the running time and query complexity on the parameters n, d, ε, δ: Theorem 3. It is possible to compute an (ε, δ)-multiplicative approximation to the weight of the Euclidean minimum spanning tree using O(d3 log4 n/ε7) · log(1/δ) conditional queries in time O(d5 log6 n/ε9) · log(1/δ). 6 Conclusions and Future Directions In this work we introduced a computational model based on conditional sampling and showed how various combinatorial optimization tasks can be performed efficiently with very limited access to the input through the conditional oracle. This provides a generic way to design algorithms for several other models such as parallel computation, streaming and distributed. In terms of future research it is interesting to explore what other tasks are approachable using this computational model and to understand its powers and limitations. A more concrete question is whether we can avoid the dependence of the running time on the domain size under a slight variation of our model where the description of the sets are given by arithmetic circuits. This dependence is necessary in our model since specifying a single point in the input uses at least log Ω bits. References [ABS+12] Foto N. Afrati, Magdalena Balazinska, Anish Das Sarma, Bill Howe, Semih Salihoglu, and Jeffrey D. Ullman. Designing good algorithms for mapreduce and beyond. In ACM Symposium on Cloud Computing, SOCC '12, San Jose, CA, USA, October 14-17, 2012, page 26, 2012. [ACK15a] Jayadev Acharya, Cl´ement L. Canonne, and Gautam Kamath. Adaptive estimation in weighted group testing. In IEEE International Symposium on Information Theory, ISIT 2015, Hong Kong, China, June 14-19, 2015, pages 2116–2120, 2015. [ACK15b] Jayadev Acharya, Cl´ement L. Canonne, and Gautam Kamath. A chasm between iden- tity and equivalence testing with conditional queries. In Approximation, Randomiza- tion, and Combinatorial Optimization. Algorithms and Techniques, APPROX/RAN- DOM 2015, August 24-26, 2015, Princeton, NJ, USA, pages 449–466, 2015. [ADK09] Ankit Aggarwal, Amit Deshpande, and Ravi Kannan. Adaptive sampling for k-means clustering. In Approximation, Randomization, and Combinatorial Optimization. Algo- rithms and Techniques, 12th International Workshop, APPROX 2009, and 13th Inter- national Workshop, RANDOM 2009, Berkeley, CA, USA, August 21-23, 2009. Pro- ceedings, pages 15–28, 2009. 18 [AV07] David Arthur and Sergei Vassilvitskii. k-means++: the advantages of careful seeding. In Proceedings of the Eighteenth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2007, New Orleans, Louisiana, USA, January 7-9, 2007, pages 1027–1035, 2007. [CEF+05] Artur Czumaj, Funda Ergun, Lance Fortnow, Avner Magen, Ilan Newman, Ronitt Rubinfeld, and Christian Sohler. Approximating the weight of the euclidean minimum spanning tree in sublinear time. SIAM J. Comput., 35(1):91–109, 2005. [CFGM13] Sourav Chakraborty, Eldar Fischer, Yonatan Goldhirsh, and Arie Matsliah. On the power of conditional samples in distribution testing. In Proceedings of the 4th conference on Innovations in Theoretical Computer Science, pages 561–580. ACM, 2013. [CRS14] Cl´ement Canonne, Dana Ron, and Rocco A Servedio. Testing equivalence between distributions using conditional samples. In Proceedings of the Twenty-Fifth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 1174–1192. Society for Industrial and Applied Mathematics, 2014. [CRT05] Bernard Chazelle, Ronitt Rubinfeld, and Luca Trevisan. Approximating the minimum spanning tree weight in sublinear time. SIAM Journal on Computing, 34(6):1370–1379, 2005. [CS04] [CS07] [FIS08] [Ind99] Artur Czumaj and Christian Sohler. Estimating the weight of metric minimum spanning trees in sublinear-time. In Proceedings of the Thirty-sixth Annual ACM Symposium on Theory of Computing, STOC '04, pages 175–183, New York, NY, USA, 2004. ACM. Artur Czumaj and Christian Sohler. Sublinear-time approximation algorithms for clus- tering via random sampling. Random Struct. Algorithms, 30(1-2):226–256, 2007. Gereon Frahling, Piotr Indyk, and Christian Sohler. Sampling in dynamic data streams and applications. Int. J. Comput. Geometry Appl., 18(1/2):3–28, 2008. Piotr Indyk. Sublinear time algorithms for metric space problems. In Proceedings of the Thirty-first Annual ACM Symposium on Theory of Computing, STOC '99, pages 428–434, New York, NY, USA, 1999. ACM. [JKS14] Ragesh Jaiswal, Amit Kumar, and Sandeep Sen. A simple D 2-sampling based PTAS for k-means and other clustering problems. Algorithmica, 70(1):22–46, 2014. [MOP01] Nina Mishra, Daniel Oblinger, and Leonard Pitt. Sublinear time approximate clustering. In Proceedings of the Twelfth Annual Symposium on Discrete Algorithms, January 7-9, 2001, Washington, DC, USA., pages 439–447, 2001. [MOP04] Adam Meyerson, Liadan O'Callaghan, and Serge A. Plotkin. A k -median algorithm with running time independent of data size. Machine Learning, 56(1-3):61–87, 2004. [MP04] [Nis90] Ramgopal R. Mettu and C. Greg Plaxton. Optimal time bounds for approximate clustering. Machine Learning, 56(1-3):35–60, 2004. N. Nisan. Pseudorandom generators for space-bounded computations. In Proceedings of the Twenty-second Annual ACM Symposium on Theory of Computing, STOC '90, pages 204–212, New York, NY, USA, 1990. ACM. 19 [VV11] Gregory Valiant and Paul Valiant. Estimating the unseen: an n/log(n)-sample estimator for entropy and support size, shown optimal via new clts. In Proceedings of the 43rd ACM Symposium on Theory of Computing, STOC 2011, San Jose, CA, USA, 6-8 June 2011, pages 685–694, 2011. 20
1902.07928
2
1902
2019-04-27T09:39:03
Locality
[ "cs.DS" ]
The performance of modern computation is characterized by locality of reference, that is, it is faster to access data that is close in address space to data that been accessed recently than a random piece of data. This is due to many architectural features including caches, lookahead, address translation and the physical properties of a hard disk drive; attempting to model all the components that constitute the performance of a modern machine is impossible, especially for general algorithm design purposes. What if one could prove an algorithm is asymptotically optimal on all systems that reward locality of reference, no matter how it manifests itself within reasonable limits? We show that this is possible, and that excluding some pathological cases, algorithms that are asymptotically optimal in the cache-oblivious model are asymptotically optimal in any reasonable locality-of-reference rewarding setting. This is surprising as the cache-oblivious model envisions a particular architectural model involving blocked memory transfer into a multi-level hierarchy of caches of varying sizes, and was not designed to directly model locality-of-reference correlated performance.
cs.DS
cs
Locality John Iacono Université libre de Bruxelles, Belgium New York University http://www.johniacono.com [email protected] Varunkumar Jayapaul Université libre de Bruxelles, Belgium Ben Karsin Université libre de Bruxelles, Belgium http://www.benkarsin.com [email protected] Abstract The performance of modern computation is characterized by locality of reference, that is, it is faster to access data that is close in address space to data that been accessed recently than a random piece of data. This is due to many architectural features including caches, lookahead, address translation and the physical properties of a hard disk drive; attempting to model all the components that constitute the performance of a modern machine is impossible, especially for general algorithm design purposes. What if one could prove an algorithm is asymptotically optimal on all systems that reward locality of reference, no matter how it manifests itself within reasonable limits? We show that this is possible, and that excluding some pathological cases, algorithms that are asymptotically optimal in the cache-oblivious model are asymptotically optimal in any reasonable locality-of-reference rewarding setting. This is surprising as the cache-oblivious model envisions a particular architectural model involving blocked memory transfer into a multi-level hierarchy of caches of varying sizes, and was not designed to directly model locality-of-reference correlated performance. 2012 ACM Subject Classification Theory of computation → Models of computation; Theory of computation → Design and analysis of algorithms; Theory of computation → Caching and paging algorithms Keywords and phrases Models of computation, external memory, cache-oblivious Introduction 1 1.1 Modeling Computation There is an interplay between the design of algorithms, modeling computation, algorithm implementation, and actual hardware. An algorithm is a high level description of a way of solving a problem, and we use a model of computation to measure the quality of an algorithm. The goal of the model of computation is that it is general enough to reason well with, and the runtime predicted by the model correlates well with the actual runtime on a computer. However, as computers evolve, hardware advances to the point where existing models of computation may no longer accurately predict runtimes on real computers, thus rendering so-call optimal algorithms as less than optimal. RAM. The majority of research on algorithms and data structures is done with what is known as the RAM model [10]. This models a computer as something that can do computation on a constant number of data items at unit cost. For example, two numbers can be added to yield another in unit time. This is also the model taught to students: you break down the algorithm into constant-cost chunks and count the number of chunks executed. 9 1 0 2 r p A 7 2 ] S D . s c [ 2 v 8 2 9 7 0 . 2 0 9 1 : v i X r a 2 Locality DAM. It was realized long ago that the RAM model is ill-suited to modeling computation when the data did not reside in memory. The Disk-Access model (DAM) [3], also known as the external memory model, is the archetypical model of a two-level memory hierarchy; there is a computer with memory size M and a disk which stores data in blocks of size B, and blocks of data can be read or written to the disk from the memory at unit cost. The underlying premise is that since a disk is so much slower than internal memory, counting the number of block transfers and ignoring all else is a good model of runtime. The classic data structure in the DAM model is the B-tree [9]. This model ignores the fact that accessing adjacent blocks on a disk is in real life much faster than two random blocks [15]. Cache-oblivious. As the modern computer has evolved, it has become not just a two-level hierarchy but a multi-level hierarchy, from the registers to the disk or SSD there can easily be seven or more levels of cache. Each level typically has a smaller amount of faster memory than the previous one. The most successful attempt to model this hierarchy to date has been the cache-oblivious model [11]. In this model, analysis is done with the same method as in the DAM model, except that the values of B and M are unknown to the algorithm but are used in the analysis. Some DAM model algorithms are trivially cache-oblivious, for example scanning an array of size N takes time N/B ± 1 in both models. Other DAM-model structures, such as the B-tree, are completely dependent on the provision of a single B to the algorithm and thus cache-oblivious searching requires completely different methods [6, 7]. Locality of reference. The cache-oblivious model tries to capture one view of a modern machine. However, a disk does not actually have blocks of fixed size that are moved in at unit cost, where accessing two neighboring blocks cost the same as accessing two random blocks. Instead, the performance of a disk can be characterized by locality of reference, where accessing adjacent items costs much less than random items. Additionally, the performance of a computer is not just about cache hits and misses, there are numerous additional hardware features such as address translation and prefetching that affect runtime, typically in ways that reward locality of reference [15]. The importance of locality of reference stems from the large disparity between the time to perform a memory access and the time to perform a computation [12]. Poor locality results in many slow accesses to memory, which can result in performance loss for a range of reasons including instruction pipeline stalls and memory bandwidth bottlenecks. While a number of low-level optimizations, such as prefetching and branch prediction, aim to combat these issues, locality remains an important aspect of computer performance. But yet, despite oversimplifying the interplay between locality of reference and perfor- mance, the cache-oblivious model is a success, and has become the leading "realistic" model of computation used by algorithms researchers for non-parallel algorithm design. The central advice when designing algorithms in the cache-oblivious model is to maximize locality of reference. Algorithms designed in the cache-oblivious model also tend to be quite beautiful, with recursive constructions ensuring locality at different levels of granularity. The central idea of this work is to turn the design principle on its head. What if "maximize locality of reference" is not simply a design principle, but the formal goal? We show how to formalize locality of reference, and show that broad classes of asymptotically optimal cache-oblivious algorithms and algorithms that maximize locality of reference are one and the same. Thus, optimal cache-oblivious algorithms are asymptotically optimal for not only hardware consisting of multi-level caches as envisioned by the model, but on any hardware that rewards locality of reference, under some reasonable assumptions. John Iacono, Varunkumar Jayapaul and Ben Karsin 3 1.2 Motivation The underlying thesis of the cache-oblivious model and this work is that there is some one-dimensional address space that a program reads and writes data from, and that the cost (runtime) is a function of the sequence of the locations accessed in this address space. This is also how one typically programs, we allocate memory and read and write to it, but we let the compiler and operating system manage exactly how this is optimized. In the RAM model, the runtime is simply the number of accesses performed (we use the word access to denote either a read or a write). Call the memory locations accessed by the running of a program on an input an execution sequence. Let E = (e1, e2, . . . eE) denote such an execution sequence, where ei is the memory location of the i-th access of E. In the RAM model we would say that E takes time E, since each access has cost 1, regardless of location. In the cache-oblivious and DAM models, however, the cost of an access ei depends on the memory size, M, the block size, B, and the locations of accesses prior to ei. When accessing element ei, if the memory block of size B containing ei is already in memory, then it costs 0 (and costs 1 otherwise). In this discussion (and in Section 2) we assume that the accesses of E are in strictly non-decreasing memory locations (i.e., ei−1 ≤ ei), and we call these query-type sequences. This lets us ignore the role of the memory size, and simplifies the discussion by making the resulting cache-oblivious cost depend only on block size, B. In Section 3, we remove this assumption and consider algorithms that make use of memory. However, we note that query-type sequences are not uncommon in data structures, as one can view many structures as a topological sort into memory of some abstract DAG or tree. For example, searching in one dimension has an optimal cache-oblivious cost of O(logB N), which is independent of M. The cache-oblivious/DAM cost (runtime) of a non-decreasing execution sequence, E, is COB(E) = EX i=2 sgn(cid:16)(cid:12)(cid:12)(cid:12)j ei B k −j ei−1 B k(cid:12)(cid:12)(cid:12)(cid:17) where sgn denotes the sign function which is 0 for 0 and 1 for all positive values. This formula simply computes the block number of the current and previous access, and charges 0 if they are the same and 1 if they are different. Let's make some simplifying assumptions to try to obtain something more elegant and without ceilings and floors. Instead of computing the cache-oblivious cost for a single block size B, which represents the runtime on a two-level memory hierarchy with block size B, we consider total cost over all levels of a multi-level memory hierarchy. This gives rise to the questions: what are the sizes of the levels, and what is the relative cost of a cache miss at each level? To keep things simple (but unrealistic), we start by assuming that our memory hierarchy, B = (B0, B1, B2, . . .), is a sequence of block sizes, Bl, such that there is a block size for every power of two (i.e., Bl = 2l). We also assume that a cache miss at any level has equal unit cost. So, with all of these assumptions, what is the total cost of execution sequence E? EX ∞X i=2 l=0 (1 0 if ei and ei−1 are in different blocks of size 2l otherwise Finally, to simplify this expression, we assume that at each level, the blocks are not aligned so that memory locations B −1 and B are in different blocks, but are rather randomly shifted so that any two adjacent memory locations have a 1 B chance of being in different blocks of size B. At step i, location ei is being accessed and the previously accessed location is ei−1. 4 Locality Let d = ei − ei−1 be the distance between ei−1 and ei. For all block sizes Bl ≤ d, there will be a cache miss and the access will have cost 1. If Bl > d then the chance of a cache miss is simply d Bl . This gives blog(ei−ei−1)cX EX z 1 + i=2 l=0 l=blog(ei−ei−1)c+1 } ≤2 ∞X { ! ei − ei−1 2l EX i=2 = (log(ei − ei−1) + O(1)) √ log N to optimize O( log2 N N, 4 jumps of size ≤ N 1/4 . . . ). This is truly simple. If we call the the distance in memory between two accesses a jump, then the runtime is simply the sum of the logarithms of the jump distances. Doing algorithm analysis with such a formula is easy. For example, binary search would cost Θ(log2 N) worst-case in this model, a B-tree Θ(log 3 2 N) (assuming binary search within a node, and B chosen to be 2 log B + log N log B)) and performing a predecessor search on a cache-oblivious Van Emde Boas layout would cost Θ(log n log log n) (1 jump of size ≤ N, 2 jumps of size ≤ √ What about all of the assumptions that led to the above simplification? Changing the block sizes from the powers of two to some other geometric progression will just change the base of the logarithm. The assumption that cache misses at all levels incur the same cost, however, is very unrealistic. A more realistic assumption is that the costs would also form a geometric sequence, and if one follows through with the math, one obtains a total cost that is also a function of jump distances, but instead of a logarithm it is a root. But is this the right answer? We don't attempt to answer that. However, the above exercise does inspire us to believe that the runtime should be given as some function of the jump distances, which we call the locality function, '. Thus using ' we define the total locality of reference (LoR) cost of execution sequence E as EX LoR'(E) = '(ei − ei−1) i=1 √ If the function '(d) = 1,then this is just the RAM model. If the function '(d) = d then this gives us a simplified model of the runtime on a tape drive. And, as we saw above, different assumptions could give '(d) = log d or '(d) = d. We place several restrictions on the locality functions we consider. The locality functions should be non-negative, non-decreasing, and subadditiveThese restrictions follow naturally from hardware that rewards locality of reference where big jumps do not cost less than small ones and accessing locations (with increasing values) e1, e2, e3 should cost no less than e1, e3. We claim that, for the appropriate choice of locality function, this is the proper way to model a computer that rewards locality of reference. But what is the right locality function to perform analysis on? We avoid this question by allowing the possibility that an algorithm can be optimal for all valid locality functions; call such algorithms locality-of-reference optimal (LoR optimal). Such algorithms would be asymptotically optimal for all computers that reward locality of reference, regardless of specifics. For example, to sum all the numbers in an array, scanning it sequentially rather than any other way (such as via a randomly chosen permutation) is clearly the optimal way no matter what the specifics of how locality of reference is rewarded. The central result of this work is that an algorithm is LoR optimal if and only if it is optimal in the cache-oblivious model, for a broad class of non-pathological problems. This implies that all optimal cache-oblivious algorithms are optimal not just in the originally envisioned scenario of a multi-level memory hierarchy but, in fact, on any hardware whose performance is characterized by locality of reference. John Iacono, Varunkumar Jayapaul and Ben Karsin 5 1.3 Summary of Results The central focus of this work is presenting the locality of reference (LoR) model, a compu- tational model that looks at memory in a new way: the cost of a memory access is based on the proximity from a prior access via what we call a locality function. A wide range of locality functions can be used to compute the cost, and certain locality functions correspond to well-known models (e.g., RAM, DAM, etc.). We first consider in Section 2 the LoR model in the context of algorithms that do not rely on memory, which we call "query-type" algorithms. We prove that for a broad class of non-pathological problems any query-type algorithm that is asymptotically cache-obliviously optimal is asymptotically optimal for all subadditive locality functions, and vise-versa. Thus, cache obliviously optimal query-type algorithms have asymptotically optimal cost on any system that reasonably awards locality of reference. In Section 3 we generalize the LoR model to apply to algorithms that make use of locality with relation to not just the last access, but where an access should be fast if it is close in address space to an item that has been accessed recently (in time). To do so we extend the idea to a locality function to a bidimensional locality function that includes both spatial and temporal components. We propose a model that computes the cost of an access by considering the cost of a jump from the two previous accesses with maximal locality (temporal and spatial) to the left and right. We prove that, when using a specific locality function, this cost equates to the number of cache misses with the least recently used cache replacement policy, which is within a factor two of the cache oblivious cost with half the memory size. Thus, we prove that, for algorithms with are not drastically effected by memory size, optimal cache-oblivious cost implies optimality in the LoR model, and vice-versa. The cache-oblivious model analyzes algorithms in terms of a two-level system and does not look at the memory hierarchy as whole. However, the LoR model is easily extended to multi-level hierarchies of caches. In Section 3.8, we define general classes of memory hierarchies and prove that, under some reasonable assumptions, the LoR model cost is asymptotically equivalent to the cache-oblivious cost in a multi-level hierarchy of caches, for any execution sequence (even those that are heavily impacted by memory size). 1.4 Related work One related attempt, besides the previously described cache-oblivious model is the Hierarchical Memory Model [1]. In this model, accessing memory location x takes time f(x). This was extended to a blocked version where accessing k memory locations takes times f(x) + k [2]. In particular the case where f(k) = log x was studied and optimality obtained for a number of problems. This model, through its use of the memory cost function f, bears a number of similarities to ours, and it meant to represent a multi-level cache where the user manually controls the movement of data from slow to fast memory. However, while it is able to capture temporal coherence well, even in the blocked version it does not capture fully the idea of spatio-temporal locality of reference, where an access is fast because it was close to something accessed recently. Another model that proposed analyzing algorithm performance on a multi-level memory hierarchy is the Uniform Memory Hierarchy model (UMH) [4]. The UMH model is a multi- level variation of the DAM that simplifies analysis by assuming that the block size increases by a fixed factor at each level and that there is a uniform ratio between block and memory size at each level of the hierarchy. In Section 3.8, we show how similar assumptions can be applied to the LoR model as well, although the LoR model provides a general framework 6 Locality that extends to arbitrary hierarchies or systems that reward locality of reference. 2 Query-type algorithms We first consider algorithms that generate execution sequences that operate on strictly non-decreasing memory locations. These types of execution sequences are indicative of query or search algorithms, as queries often can make little use of memory accessed in recent queries. Here we introduce the Locality of Reference (LoR) model in this simplified, yet practical, context, and extend the model to the general case of algorithms that make use of memory in Section 3. 2.1 Query-type LoR model The query-type LoR model of computation assumes that, given an infinite array of memory and a sequence of accesses that are in non-decreasing memory locations E = (e0, e1, . . .) (an execution sequence), the cost to access a memory location ei immediately after accessing location ei−1 is a function of the spatial distance ei − ei−1. The model uses a locality function, denoted as ', which maps the spatial distance to a cost. The cost to execute the sequence E in the query-LoR model with locality function ' is denoted as LoR'(E) and is i=1 '(ei − ei−1). We define the class of all locality functions, L, as all subadditive functions with '(0) = 0. The restriction that functions be subadditive captures the idea that spatial locality of reference reduces the cost of an access. simplyPE 2.2 External memory and cache-oblivious Given an execution sequence E, what is the cost in the cache-oblivious model? Recall that in this model, memory is split into blocks of size B, and that when a block not in memory is encountered it is brought into memory at unit cost. In the query-type setting, this happens only when the block currently being accessed differs from the previously accessed block. Let COB(E) denote the cache-oblivious cost to execute E with block size B, this is . Note that the external memory (DAM) cost and cache oblivious cost to execute E has the same definition; the only difference is that B can be used in the definition of an external memory algorithm, and cannot for a cache oblivious algorithm. if b ei otherwise B c 6= b ei−1 B c PE i=1 (1 0 2.3 Optimality for query-type algorithms To discuss optimality in the context of the query-LoR model, we first provide formal definitions of problems, algorithms, and optimality. We define a problem P to have a set of problem instances P = {I1, I2, . . . ,}, where each instance corresponds to some input sequence for which the problem can be solved. We further define I P n to be the set of instances of P that correspond to inputs of size n. An algorithm A is a method to turn an instance I into an execution sequence E(A, I). We say that algorithm A solves P if, for every instance I ∈ P, the algorithm A generates an execution sequence E(A, I) that correctly solves (i.e., generates the correct output for) instance I. We define the set of all algorithms that correctly solve P as AP . For any algorithm A that solves problem P, we define the worst-case LoR model (LoR'(E(A, I))). runtime for input size n and locality function ' as W'(P, A, n) = maxI∈IP We say that an algorithm is LoR optimal if, for every locality function, the worst-case cost is within a constant factor of the optimal: n John Iacono, Varunkumar Jayapaul and Ben Karsin 7 (cid:73) Definition 1. Algorithm ALoR is asymptotically LoR optimal for problem P iff, ∃c,n0∀n>n0∀A∈AP ∀'∈L h W'(P, ALoR, n) ≤ c · W'(P, A, n)i The notion of a LoR optimal algorithm seems to be very powerful, as such an algorithm would be asymptotically optimal on any computing device that rewards locality of reference. Similarly, we formally define a cache-oblivious optimality (CO optimal) for query-type (COB(E(A, I))) is the worst-case cache-oblivious algorithms. We say WB(P, A, n) = maxI∈IP cost of algorithm A on problem instances of size n of problem P, for a specific block size B. (cid:73) Definition 2. Algorithm ACO-Opt is asymptotically CO optimal iff, n h WB(P, ACO-Opt, n) ≤ c · WB(P, A, n)i ∃c,n0∀n>n0∀B≥1∀A∈AP Many algorithms are known to be asymptotically cache-obliviously optimal [11]. For example, performing a predecessor query on a van Emde Boas layout is a CO optimal query-type algorithm. 2.4 B-stable problems To show the equivalence between LoR optimal and CO optimal algorithms, we must avoid pathological problems with worst-case behavior that varies dramatically with different instances of the problem, for different block sizes. We say that a problem is B-stable if, for any algorithm A that solves P, there is some "worst-case" instance Iw that, for every B, has CO cost asymptotically no less than the optimal worst-case cost for that B, over all instances. Formally, (cid:73) Definition 3. Problem P is B-stable if, for any algorithm A that solves P, h min A0∈AP n WB(P, A0, n) ≤ c · COB(E(A, Iw))i ∃c,n0∀n>n0∃Iw∈IP n ∀B≥1 Intuitively, for any algorithm that solves a B-stable problem, there must be a single instance that, for all block sizes, has cost no less than the asymptotically worst-case optimal cost. By Definition 2, this implies that, if P is B-stable and ACO-Opt solves it CO-optimally, h WB(P, ACO-Opt, n) ≤ c · COB(E(A, Iw))i ∃c,n0∀n>n0∀A∈AP ∃Iw∈IP n ∀B≥1 That is, every algorithm must have an instance on which it performs no better, asymptotically, than ACO-Opt on every B. In Appendix A we show that there are non-B-stable algorithms and that our main result does not hold for them; this justifies our classification and exclusion of these pathological cases. 2.5 Main result We will find it useful to define a smoothed version of an execution sequence. Given a sequence E, let EB−smooth be the sequence derived from E where a shift s is added to every element of E; s is a uniform random integer in the range [0, B). We define SCOB(E) to be E[COB(EB−smooth)]. Then: (cid:73) Lemma 4. COB(E) and SCOB(E) are within a factor of two of each other, for any query-type execution sequence, E. 8 Locality Proof. Shifting the execution sequence may cause accesses that were in one block to now be in two consecutive blocks, and accesses that were in two consecutive block to be in one block. (cid:74) Thus that cost may grow or shrink by a factor of two, but not more. The use of the smoothed version of E allows us to show that there is a locality function that yields the same runtime in the LoR model as the cache oblivious model for a single B. (cid:1), which is a valid locality function. Then: Let 'B(d) = min(cid:0)1, d B (cid:73) Lemma 5. For any query-type execution sequence E and block size B, SCOB(E) = LoR'B(E) Proof. Consider a single access ei ∈ E. Let d = ei − ei−1. If d ≥ B then by definition B c for all 0 ≤ s < B. If 'B(d) = 1, and the ith term of COB(E) is also 1 as b ei+s B c 6= d < B then by definition 'B(d) = d b ei−1+s (cid:74) (cid:73) Corollary 6. If query-type algorithm A is asymptotically LoR optimal for problem P, then it is asymptotically CO optimal for P. Proof. Since A is LoR optimal, then it within a constant factor of optimal for all locality (cid:1). Thus Lemma 5 with Lemma 4 proves the corollary. functions, including 'B(d) = min(cid:0)1, d B c for d of the possible shifts s ∈ [0, B). B , and the ith term of COB(E) is also d B c 6= b ei−1+s B as b ei+s B (cid:74) While the above relies on specific 'B(d) functions, we now show that any locality function can be represented as a linear combination of 'B(d), for various B: (cid:73) Lemma 7. For every locality function '(d) ∈ L there exist nonnegative positive constants α1, α2 . . . αN and β1, β2 . . . βN such that '(d) =PN i=1 αi'βi(d) for integers d in [1..N). Proof. Let γi = 2'(i) − '(i + 1) − '(i − 1), αi = iγi, and βi = i. As γi is nonnegative given ' is a convex function, α and β values are all nonnegative. Thus: NX i=1 (cid:18) min i=1 NX NX Az } { x−1X i=1 iγi + αi'βi(x) = = = (cid:19) αi, αix βi min(iγi, γix) z } NX C { γix Bz}{γxx + We first simplify the A term gives us i=1 i=x+1 i=1 x−1X x−1X x−2X i=1 h2'(i)i − '(i − 1)i − '(i + 1)i i '(i)(i + 1) − xX 2'(i)i − x−2X h '(i)(2i − (i − 1) − (i + 1))i i=2 i=0 A = = '(i)(i − 1) = + 2'(1) + 2'(x − 1)(x − 1) − 1'(0) − 2'(1) − '(x − 1)(x − 2) − '(x)(x − 1) i=2 John Iacono, Varunkumar Jayapaul and Ben Karsin 9 Assuming that '(0) = 0, we get = '(x − 1)(2x − 2 − x + 2) − '(x)(x − 1) = '(x − 1)x − '(x)(x − 1) We now simplify the C term from above γix i>x C =X NX NX N−1X = = = i=x+1 i=x+1 i h2'(i)x − '(i + 1)x − '(i − 1)x 2'(i)x − N+1X '(i)x − N−1X h2'(i)x − '(i)x − '(i)x i=x+2 '(i)x i=x i + 2'(x + 1)x − '(x)x − '(x + 1)x i=x+2 + 2'(N)x − '(N)x − '(N + 1)x Since we are only considering '(d) such that d ∈ [1 . . . N), we say that '(N + 1) = '(N), thus C = '(x + 1)x − '(x)x Combining the simplified terms, we get NX i=1 αi'βi(x) = A } z = '(x − 1)x − '(x)(x − 1) +(cid:16)2'(x)x − '(x + 1)x − '(x − 1)x '(x − 1)x − '(x)(x − 1) + '(x + 1)x − '(x)x Bz}{γxx + } { { z C + '(x + 1)x − '(x)x = 2'(x)x − '(x)x − '(x)(x − 1) = '(x) (cid:17) (cid:74) (cid:73) Corollary 8. For every locality function '(d) ∈ L there exists a sets of n nonnegative constants α1, α2 . . . αn, and β1, β2 . . . βn such that, for any execution sequence E, nX i=1 αiLoR'βi (E) = LoR'(E) Proof. The proof follows naturally from Lemma 7. (cid:74) (cid:73) Lemma 9. If query-type algorithm ACO-Opt is asymptotically CO optimal for a problem P that is B-stable, then it is asymptotically LoR optimal for P. Proof. Consider some algorithm A that solves P. Since P is B-stable, by Definition 3, ∃c,n0∀n>n0∃Iw∈IP n ∀B≥1 h WB(P, ACO-Opt, n) ≤ c · COB(E(A, Iw))i 10 Locality Using the definition of the worst-case cost WB, we get ∃c,n0∀n>n0∃Iw∈IP n ∀B≥1 By Lemma 4, we get ∃c,n0∀n>n0∃Iw∈IP n ∀B≥1 ∃c,n0∀n>n0∃Iw∈IP n ∀B≥1 n I∈IP h max h max h max I∈IP I∈IP n n COB(E(ACO-Opt, I)) ≤ c · COB(E(A, Iw))i SCOB(E(ACO-Opt, I)) ≤ 4c · SCOB(E(A, Iw))i LoR'B(E(ACO-Opt, I)) ≤ 4c · LoR'B(E(A, Iw))i and since, by Lemma 5, for any B the smoothed CO cost is equivalent to the LoR cost with the corresponding 'B function, This inequality holds for all B and thus all linear combinations of various B. For any locality function ' in the set of valid locality functions, L, consider α'1, α'2, . . . , α' n and β'1, β'2, . . . , β' given by Lemma 7. We use the β's as the B values and the α's as the coefficients in the linear combination to get n h nX ∃c0,n0∀n>n0∃Iw∈IP LoR'β' (cid:16) α' k max I∈IP n k n k=1 ∀'∈L (E(ACO-Opt, I))(cid:17) ≤ c0 nX (cid:16) α' k LoR'β' k (E(A, Iw))(cid:17)i k=1 Iw is a single instance of P, therefore it cannot have a greater total cost than the single instance that maximizes the cost ∃c0,n0∀n>n0∀'∈L (cid:16) h nX k=1 max I∈IP n α' k LoR'β' k (E(ACO-Opt, I))(cid:17) ≤ c0 max I∈IP n nX (cid:16) k=1 α' k LoR'β' k (E(A, I))(cid:17)i Moving the max outside the summation can only decrease the overall cost of the left side of the inequality, thus ∃c0,n0∀n>n0∀'∈L h max I∈IP n nX (cid:16) k=1 α' k LoR'β' Using Corollary 8, we get ∃c0,n0∀n>n0∀'∈L nX (cid:16) k=1 α' k (E(ACO-Opt, I))(cid:17) ≤ c0 max h max I∈IP n k (LoR'(E(ACO-Opt, I))) ≤ c0 max I∈IP n I∈IP n LoR'β' (E(A, I))(cid:17)i (LoR'(E(A, I)))i k We are considering an arbitrary algorithm A that solves P, so this applies to all A ∈ AP . By the definition of worst-case LoR cost, ∃c0,n0∀n>n0∀'∈L∀A∈AP h W'(P, ACO-Opt, n) ≤ c0W'(P, A, n)i (cid:74) Thus, by Definition 1, ACO-Opt is asymptotically LoR optimal. (cid:73) Theorem 10. Any query-type algorithm A that solves a B-stable problem P is LoR optimal if and only if it is CO optimal. John Iacono, Varunkumar Jayapaul and Ben Karsin 11 Proof. The proof follows naturally from Corollary 6 and Lemma 9. (cid:74) In §A of appendix we prove and discuss the following which justifies the restriction to B-stable problems: (cid:73) Lemma 11. There exists a problem P which is not B-stable and which has a CO optimal algorithm which is not LoR optimal. Thus theorem 10 would not hold if the restriction to B-stable algorithms were to be removed. General models for algorithms with memory 3 In the previous section, we considered execution sequences that were unidirectional and thus the size of internal memory was irrelevant. Now we generalize the model and apply it to execution sequences that are not necessarily unidirectional. This requires that we consider the size and contents of internal memory when computing the expected cost of an access. B 3.1 Cache-oblivious model and related memory models The general cache-oblivious model uses M as the size of internal memory, with M B blocks being stored in internal memory at a given time, which we call the working set. The working set is made up of blocks of contiguous memory, each containing B elements. For a given block size, B, we enumerate the blocks of memory by defining the block containing element (cid:5)-th block). Formally, we define the working set after the i-th access of e as {e}B (the(cid:4) e execution sequence E on a system with memory size M, block size B, and cache replacement policy P (formally defined below) as WM,B,P(E, i). For simplicity of notation, we refer to the working set after the i-th access simply as Wi when the other parameters (M, B, P, and E) are unambiguous. When we access an element ei, if the block containing ei is in the working set (i.e., {ei}B ∈ Wi−1), it is a cache hit and, in the cache-oblivious model, it has a cost of 0. However, if {ei}B is not in the working set, it is a cache miss, resulting in a cost of 1. On a cache miss, the accessed block, {ei}B is loaded into memory, replacing an existing block, which is determined by cache replacement policy. We define a general cache replacement policy as a function that selects the block of the working set to evict when a cache miss occurs, i.e., for memory size M and block size B: ({ek}B ∅ PM,B(E,W, i) = if W = M otherwise B and {ei}B 6∈ W where W is the working set, ei and ek are the i-th and k-th accesses in sequence E, respectively, k < i, and {ek}B ∈ W. For a given cache replacement policy and execution sequence, E, we define the working set after access i ∈ E as Wi = (Wi−1\PM,B(E,Wi−1, i)) ∪ {ei}B where PM,B(E,Wi−1, i) defines the block to be evicted and {ei}B is the new block being added to the working set. Since a cache miss results in a cost of 1 and a cache hit has cost 0, the total cost of execution sequence E is simply: (0 1 EX i=1 CM,B,P(E) = if {ei}B ∈ WM,B,P(E, i−1) otherwise 12 Locality For this work, we focus on the following cache replacement policies: Popt M,B(E,W, i): The ideal cache replacement policy with internal memory size M and block size B. The number of evictions (and cache misses) over execution sequence E is minimized. This is equivalent to Belady's algorithm [5] that evicts the block {ek}B that is accessed the farthest in the future among all blocks in W. Plru M,B(E,W, i): The least recently used (LRU) cache replacement policy with internal memory size M and block size B. The evicted block, {ek}B, is the "least recently used" block in W. That is, {ek}B is selected such that no element in {ek}B has been accessed more recently than the most recently accessed element of any other block in W. We define Wopt M,B(E, i) and Wlru (0 if {ei}B ∈ Wopt M,B(E, i) as the working sets after the i-th access of sequence E, when using the ideal and LRU cache replacement policies, respectively. Thus, the cache- oblivious cost (using the ideal cache replacement policy) of performing the i-th access of on a M,B(E, i−1) system with memory size M and block size B is COM,B(E, i) = and the total cost for the entire execution sequence E is COM,B(E) =PE i=1 COM,B(E, i). We similarly define the cost with the LRU cache replacement policy for a single access ei and a total execution sequence E as LRUM,B(E, i) and LRUM,B(E), respectively. (cid:73) Theorem 12. For any execution sequence, E, memory size M, and block size B, the total cache misses using the LRU cache replacement policy with a memory twice the size (2M) is 2-competitive with number of cache misses using the ideal cache replacement policy, i.e., LRU2M,B(E) ≤ 2 · COM,B(E). Proof. It follows from the work of Sleator and Tarjan [14]. 1 otherwise (cid:74) As we did with the unidirectional cache-oblivious cost in Section 2.2, we define smoothed versions of these cost functions using EB−smooth, which is execution sequence E with a uniform random shift in the range [0, B) applied to every access. Specifically, we define SCOM,B(E) = E[COM,B(EB−smooth)] and SLRUM,B(E) = E[LRUM,B(EB−smooth)]. 3.2 General LoR model To capture the concept of the working set for algorithms that use internal memory, we define bidimensional locality functions that compute LoR cost based on two dimensions: distance and time. This bidimensional locality function, '(d, δ) represents the cost of a jump from a source element, s, to a target element, t, where d and δ are the spatial distance and temporal distance, respectively, between s and t. This captures the concept of the working set by using "time" to determine if the source element is in memory or not. If the source is temporally close (was accessed recently) and spatially close to the target, t, the resulting locality cost of the jump is small. (0 if 0 ≤ δ ≤ x For the general LoR model, we define a class of bidimensional locality functions as functions of the form '(d, δ) = max(f(d), g(δ)), where f(d) is subadditive and g(δ) is a 0-1 , for some value x. For any k ≤ i, threshold function. That, is, g(δ) = the bidimensional locality cost of a jump from source element ek to target ei in execution sequence E is '(ei − ek, t(E, i) − t(E, k)), where t(E, i) is the time of the i-th access. For simplicity of notation, we define δt(E, k, i) to be the temporal distance between the i-th 1 otherwise John Iacono, Varunkumar Jayapaul and Ben Karsin 13 access (ei) and k-th access (ek), i.e., δt(E, k, i) = t(E, i) − t(E, k). Intuitively, we can think of δt(E, k, i) as the time from access ek to "present" when accessing ei. We add the additional restriction to our definition of bidimensional locality functions that they cannot be more "sensitive" to temporal locality than spatial locality, i.e., for any locality function '(d, δ) = max(f(d), g(δ)), ∀x[f(x) ≥ g(x)]. This corresponds to the tall cache assumption that is typically used with the cache-oblivious model [8, 13]. A more in-depth discussion of the tall cache assumption and how it relates to the LoR model is in Section 3.3. z min ∀L<i s.t. eL≤ei } left side { z min ∀R<i s.t. eR≥ei } right side ! { the i-th access of E, for the given locality function ' to be t'(E, i) =Pi−1 We form our definition of time based on the amount of change that occurs to the working set. For example, if an access causes a block of B elements to be evicted, we say that time increases by 1. Thus, time depends on the locality function, so we define the time of k=1(LoR'(E, k)). That is, the time of access ei ∈ E is simply the sum of costs of all accesses prior to ei in sequence E. We note that the time after the last access of E is the total LoR cost (i.e., LoR'(E) = t'(E,E + 1)). Unlike the query-type LoR cost, we cannot simply compute the cost of access ei using the distance from the previous access, ei−1, since any of the prior accesses may be in the working set when accessing ei. Furthermore, since we no longer consider only non-decreasing execution sequences, when accessing ei, there may be accesses to both the left and right that could be in the same block as ei. Therefore, computing LoR'(E, i) using the locality function from a single source is insufficient to capture the idea of the working set, and a detailed example showing why this is the case is included in Section 3.4. We define the general LoR cost of access ei ∈ E as LoR'(E, i) = max '(ei − eL, δt(E, i, L)) + '(eR − ei, δt(E, i, R))−1, 0 Intuitively, the LoR cost of access ei ∈ E is computed from the minimum cost jumps from both the left side and right side of ei. We note that this generalizes the query-type LoR cost definition, as the locality function from source eR will always evaluate to 1 for non- decreasing accesses. This formulation has the added benefit that it lets us easily visualize an execution sequence in a graphical representation. We include a discussion of this graphical representation in Section 3.5. 3.3 On the tall cache assumption Cache-oblivious algorithms are analyzed for memory size M and block size B and the tall cache assumption simply assumes that M ≥ B2. This assumption is required by many cache-obliviously optimal algorithms because many require that at least B blocks can be loaded into internal memory at a time. It has been proven that without the tall cache assumption, one cannot achieve cache-oblivious optimality for several fundamental problems, including matrix transposition [13] and comparison-based sorting [8]. Thus, we consider how this assumption is reflected in the LoR model, and whether we can gain insight into the underlying need for the tall cache assumption. Recall that our class of bidimensional locality functions are of the form '(d, δ) = (f(d), g(δ)), where f is subadditive and g is a 0-1 threshold function. In Section 3.6 we define the locality function that corresponds to a memory system with memory size M and block 14 Locality (cid:18) (cid:18) size B to be (cid:18) thus, for this function, f(d) = min(cid:0)1, d 'M,B(d, δ) = max , min (cid:19) min d B 1, 1, (cid:23)(cid:19)(cid:19) (cid:22) δ (cid:1) and g(δ) = min(cid:16)1, M/B B j δ M/B k(cid:17). The tall cache assumption states that M ≥ B2, or M B > B. This is reflected in our locality function as the requirement that ∀k≥0[f(k) ≥ g(k)]. This restriction between f and g implies that ' cannot be more "sensitive" to temporal locality than spatial locality. That is, the LoR cost when spatial and temporal distance are equal will be computed from the spatial distance (i.e., '(d, δ) = f(d) if d ≥ δ). Additionally, this implies that '(x, x) is subadditive. Intuitively, this tells us that, with the tall cache assumption, any algorithm that balances spatial and temporal locality of reference will not have performance limited by temporal locality. Many cache-obliviously optimal algorithms aim to balance spatial and temporal locality, thus requiring the tall cache assumption to achieve optimality. 3.4 A single LoR source does not represent the working set In this section, we show that computing the general LoR cost using only a single source (with the minimum cost) is insufficient to represent the working set. Specifically, we show the potential discrepancy between such a formulation of LoR cost and the smooth LRU cost. We formally define this single-source definition of LoR cost of accessing ei as (cid:91)LoR'(E, i) = k=1 '(ei − ek, δt(E, k, i)). To show the discrepancy between this formulation and the mini−1 LRU cost, we consider the specific locality function that corresponds to the LRU cost for a specific memory size M and block size B: 'M,B(d, δ) = max(cid:16)min(cid:0)1, d (cid:1) , min(cid:16)1, k(cid:17)(cid:17). j δ B M/B Given an array of elements, a, located in contiguous memory, we define a[i] as the i-th element in array a. Consider an execution sequence E that first accesses a[0] and a[B], then performs a series of stages of accesses of elements within the range [0, B]. At the first stage, a[B/2] is accessed. At the second stage, a[B/4] and a[3B/4] are accessed. At stage 3, a[B/8], a[3B/8], a[5B/8] and a[7B/8] are accessed, and so on for log B stages. By tall cache, we know that M > 2B, so at any stage k, the blocks containing elements accessed during the previous stage are in the working set. Thus, the LRU cost of execution sequence E is SLRUM,B(E) = stages accesses z } { log B−1X z}{ 2k−1X 1 B k=0 i=0 0 1 B−1X s=0 if n (2i+1)·B 2k+1 +s o otherwise =(cid:16)(cid:8) 2i·B 2k+1 +s(cid:9) B or n (2i+2)·B 2k+1 +s o B (cid:17) B For every access, all elements element between a[0] and a[B] will always be in the working set, for every shift value s. Thus, the cost is 0 at each stage after the first two accesses, so SLRUM,B(E) = 2. The single-source LoR cost, (cid:91)LoR'M,B(E), however, depends only on the single access in the working set with the smallest spatial distance (i.e., minimum LoR cost). Since, at each stage, the accesses from the previous stage have temporal distance < M B , the temporal B dictates the cost of each access. At component of the locality function is always 0 and d John Iacono, Varunkumar Jayapaul and Ben Karsin 15 each stage, the spatial distance, d, decreases by a factor 2, thus stages z } { log B−1X log B−1X k=0 accesses z}{ 2k−1X (cid:18) 'M,B i=0 2k · 'M,B (cid:91)LoR'M,B(E) = = (cid:19) (cid:18) B 2k+1 , 1 (cid:18) B (cid:19)(cid:19) 2k+1 , 1 (cid:19) using the locality function, 'M,B(d, δ) defined above, we get (cid:91)LoR'M,B(E) = (cid:18) 2k · B/2k+1 B 1 2 k=0 k=0 log B−1X log B−1X = = log B 2 k=0 Thus, the single-source cost formulation does not generalize the LRU cost, while using two sources does (as we prove in Lemma 13). 3.5 Graphical visualization One additional benefit of using the bidimensional locality function based on spatial and temporal distance is that it allows us to visualize an execution sequence graphically. We consider a series of accesses in execution sequence E as points in a 2-dimensional plane. The point representing access ei is plotted with the x and y coordinates corresponding to the spatial position, ei, and the temporal position, t(E, i), respectively. Figure 1 illustrates this visualization for a series of accesses with locality function 'M,B(d, δ) (defined in Section 3.6). The cost of access ei is simply computed from the LoR cost with sources eL and eR (the previous access with the minimum locality function cost to the left and right, respectively). We can visually determine which previous accesses correspond to eL and eR: if a previous access is outside the gray region (i.e., δ > M B or d > B), the cost is 1. Otherwise, it is simply B . d 3.6 Equivalence to cache-oblivious cost As with the query-type LoR model, we can define a specific class of locality functions that correspond to the cost in the cache-oblivious model. For the general LoR model we define k(cid:17)(cid:17) to be the bidimensional locality function 'M,B(d, δ) = max(cid:16)min(cid:0)1, d (cid:1) , min(cid:16)1, j δ B M/B that correspond to the cache-oblivious cost with memory size M and block size B. (cid:73) Theorem 13. For any execution sequence E, LoR'M,B(E) = SLRUM,B(E), thus SCOM,B(E) ≤ LoR'M,B(E) ≤ 2 · SCO M 2 ,B(E) Proof. To prove that LoR'M,B(E) = SLRUM,B(E), we consider the cost of performing access ei ∈ E. Assume that, when accessing ei, eL is the nearest element to the left of ei (eL ≤ ei) that is in the working set, i.e., L < i, eL ∈ Wlru M,B(E, i−1), and ei − eL is minimized. If there is no such element to the left of ei in the working set, then we say that eL = −∞. 16 Locality Figure 1 Graphical visualization of accesses in the general LoR model with locality function 'M,B. At time of access ei, all prior accesses within the past time M B (above the dashed horizontal line) have g(δ) = 0. The locality cost to jump from any element outside the gray region has the maximum cost of 1. In this example, there is both an eL and eR with cost < 1. Similarly, assume that eR is the nearest element in Wlru M,B(E, i−1) to the right of ei (ei ≤ eR), and if there is no such element, then eR = +∞. By this definition, for any access ei, we can simply consider the spatial components, because, if no element is within temporal distance B , the spatial distance is ∞ and the 'M,B cost is 1. We consider three possible cases for the spatial distance of eL and eR from access ei: M Case 1: (ei − eL) ≥ B AND (eR − ei) ≥ B shifts, 0 ≤ s < B, we know that ei 6∈ Wlru M,B(E, i − 1). Thus, There is no element in the working set within distance B of ei, then, for all alignment SLRUM,B(E, i) = E[COM,B(EB−smooth, i)] B−1X s=0 1 = 1 B = 1 and the LoR model cost is LoR'M,B(E, i) = max ('M,B(ei − eL, δt(E, i, L)) + 'M,B(eR − ei, δt(E, i, R)) − 1, 0) = max(1 + 1 − 1, 0) = 1 We note that this includes the cases where eL and/or eR do not exist, since, we set eL = −∞ and/or eR = ∞, respectively, in such cases. Case 2: (ei − eL) < B OR (eR − ei) < B Only one side (left or right) is within distance B of ei. W.l.o.g, assume that (eR − ei) < B and (ei − eL) ≥ B. Since (ei − eL) ≥ B, for all shifts 0 ≤ s < B − 1, we know that Position(inmemory)Time(t(E,i))Beiei−1MBeLcost=1eR John Iacono, Varunkumar Jayapaul and Ben Karsin 17 0 B s=0 (1 B−1X = eR − ei (cid:18) (cid:18) B = max eL 6∈ Wlru M,B(E, i − 1). Thus, the smoothed LRU cost is simply SLRUM,B(E, i) = 1 B c 6= b ei+s B c if b eR+s otherwise The LoR cost is LoR'M,B(E, i) = max (cid:19) (cid:18) ei − eL min 1 + (eR − ei) 1, B B (cid:18) eR − ei = (eR − ei) 1, B B + min (cid:19) − 1, 0 (cid:19) (cid:19) − 1, 0 A symmetric argument holds in the case where (ei − eL) < B and (eR − ei) ≥ B. Case 3: (ei − eL) < B AND (eR − ei) < B Both eL and eR are within distance B of ei, so the smoothed LRU cost depends on the number of alignment shifts, s, for which ei is not in the same block as either eL or eR, i.e., SLRUM,B(E, i) = 1 B B c 6= b eR+s B c and b ei+s B c 6= b eL+s B c if b ei+s otherwise (1 0 B−1X s=0 For simplicity, assume that at alignment shift s = 0, ei is in the last location of the block of size B. Thus, the shifts from s = 0 to s = (B − 1) define a 2B range around ei (i.e., [ei − B, ei + B]). We define p(eL) and p(eR) to be the indexes of eL and eR in this 2B range, respectively. For all 0 ≤ s ≤ p(eL), ei is in the same block as eL. Similarly, for all (p(eR) − B) ≤ s < B, ei is in the same block as eR Thus, the cost is simply the number of shifts, s, where the entire block of size B containing ei is strictly between p(eL) and p(eR), i.e., SLRUM,B(E, i) = 1 B p(eR)−BX s=p(eL) 1 and, since the cost cannot be negative, this becomes We know that p(eR) = B + eR − ei and p(eL) = B − (ei − eL), thus − 1, 0 SLRUM,B(E, i) = max (cid:19) B B (cid:19) = max − 1, 0 = p(eR) − B − p(eL) (cid:18) p(eR) − p(eL) (cid:18)(B + eR − ei) − (B − (ei − eL)) (cid:18) eR − ei (cid:18) (cid:18) (cid:18) ei − eL + ei − eL (cid:19) ei − eL + eR − ei (cid:19) (cid:18) (cid:19) − 1, 0 − 1, 0 = max = max + min min 1, 1, B B B B B B Since both eL and eR are within distance B of ei, this is equal to LoR cost, i.e., LoR'M,B(E, i) = max (cid:19) (cid:19) eR − ei B − 1, 0 18 Locality Thus, for any access access, ei ∈ E, LoR'M,B(E, i) = SLRUM,B(E, i) where 'M,B(d, δ) = max(cid:16)min(cid:0)1, d (cid:1) , min(cid:16)1, access, ei ∈ E, then for any execution sequence E, j δ B M/B k(cid:17)(cid:17). Since they are equivalent for any LoR'M,B(E) = SLRUM,B(E) Since the cache-oblivious cost is computed assuming ideal cache replacement, and LRU cache replacement with twice the memory is 2-competitive with ideal cache, we have 2 ,B(E) SCOM,B(E) ≤ SLRUM,B(E) ≤ LoR'M,B(E) ≤ SLRUM,B(E) ≤ 2 · SCO M (cid:74) While the above theorem gives us a relation between the cache-oblivious cost and LoR cost, it does not give us an asymptotic equivalence for the same M. This stems from the discrepancy between the CO cost and LRU cost for the same memory size and is due to the cache-oblivious model using ideal cache replacement. We define a class of algorithms that we call memory-smooth, for which this issue does not impact asymptotic cost. Intuitively, the class of memory-smooth algorithms excludes those that are tuned for a particular memory size. (cid:73) Definition 14. Algorithm A is memory-smooth if and only if increasing the memory size by a constant factor does not asymptotically change the runtime. That is, for any execution sequence EA generated by A, hSCOM,B(EA) = Θ(SCOc·M,B(EA))i ∀c>0∀B≥1∀M≥B2 (cid:73) Lemma 15. If algorithm A is memory-smooth, then for any M, B, and execution sequence EA generated by A, LoR'M,B(EA) = Θ(SCOM,B(EA)). Proof. If A is memory-smooth, then SCOM,B(EA) = Θ(SCO M rem 13, LoR'M,B(EA) = Θ(SCOM,B(EA)). 2 ,B(EA)). Thus, by Theo- (cid:74) 3.7 Algorithm optimality We can extend our definitions of optimality from Section 2.3 to include algorithms that use memory. We simply say that Definition 1 applies to bidimensional locality functions as well. For general definitions of LRU optimality and cache-oblivious optimality, we (SLRUM,B(E(A, I))) to be the worst-case LRU cost and define W (SCOM,B(E(A, I))) to be the worst-case cache-oblivious cost of WM,B(P, A, n) = maxI∈IP algorithm A on problem instances of size n of problem P, for specific block size B and memory size M. (cid:73) Definition 16. Algorithm ACO-Opt is asymptotically CO-optimal iff, LRU M,B(P, A, n) = maxI∈IP n n WM,B(P, ACO-Opt, n) = c · WM,B(P, A, n)i h ∃c,n0∀n>n0∀B≥1∀M≥B2∀A∈AP We note the restriction that M ≥ B2 corresponds to the "tall-cache" assumption that is typical of cache-obliviously optimal algorithms [13, 8]. John Iacono, Varunkumar Jayapaul and Ben Karsin 19 (cid:73) Definition 17. Algorithm ALRU-Opt is asymptotically LRU-optimal iff, ∃c,n0∀n>n0∀B≥1∀M≥B2∀A∈AP M,B(P, ALRU-Opt, n) = c · W LRU W M,B(P, A, n)i LRU h (cid:73) Theorem 18. Algorithm A that solves B-stable problem P is LRU optimal if and only if it is LoR optimal. Proof. If algorithm ALoR is optimal for all bidimensional locality functions, then it is optimal for locality functions 'M,B, for any M and B. By Theorem 13, it follows that ALoR is LRU optimal for any M and B. To prove that LRU optimal algorithms are also LoR optimal, we consider problem P and algorithm ALRU that solves P with optimal LRU cost, i.e., M,B(P, ALRU, n) = c · W LRU M,B(P, A, n)i ∃c,n0∀n>n0∀B≥1∀M≥B2∀A∈AP h LRU W And by the definition of the worst-case cost W, h max I∈IP n ∃c,n0∀n>n0∀B≥1∀M≥B2∀A∈AP (LRUM,B(E(ALRU, I))) ≤ c · max I∈IP Since P is B-stable, there is some instance Iw ∈ I P (LRUM,B(E(A, I)))i (LRUM,B(E(ALRU, I))) ≤ c(LRUM,B(E(A, Iw)))i n for each A such that n h max I∈IP n ∃c,n0∀n>n0∀B≥1∀M≥B2∀A∈AP and by Lemma 4, h1 ∃c,n0∀n>n0∀B≥1∀M≥B2∀A∈AP 2 max I∈IP (SLRUM,B(E(ALRU, I))) ≤ 2c(SLRUM,B(E(A, Iw)))i n therefore, by Lemma 13 ∃c,n0∀n>n0∀B≥1∀M≥B2∀A∈AP h max I∈IP n (LoR'M,B(E(ALRU, I))) ≤ 4c(LoR'M,B(E(A, Iw)))i Since this inequality holds for all 'M,B functions, we define a series of such functions that we use to represent any bidimensional locality function. Recall that 'M,B functions are of the form (cid:18) (cid:19) (cid:18) 1, d B (cid:18) (cid:22) δ (cid:23)(cid:19)(cid:19) M/B 'M,B(d, δ) = max min , min 1, where B ≥ 1 and M ≥ B2. Consider an arbitrary bidimensional locality function '(d, δ) = max(f(d), g(δ)). By Lemma 7, we can represent the f(d) component by a linear combination of n query-type 'B functions (and therefore using the spatial component of 'M,B functions). By our definition of bidimensional locality functions, g(δ) =(cid:4) δ (cid:5), for some integer x. Thus, we simply set the temporal component of every one of our 'M,B functions to be g(δ). For a given bidimensional locality function ', we define '' k to be the k-th such 'M,B function that x 20 Locality we use to represent it, i.e., '' k = max(α' ∃c0,n0∀n>n0∀A∈AP ∀'∈L h nX k=1 max I∈IP n k k'β' (cid:16)LoR , g(δ)).1 Thus, we have (E(ALRU, I))(cid:17) ≤ c0 nX '' k (cid:16)LoR '' k (E(A, Iw))(cid:17)i k=1 Instance Iw cannot result in greater cost than the instance that maximizes the total cost, so ∃c0,n0∀n>n0∀A∈AP ∀'∈L (cid:16)LoR '' k (E(ALRU, I))(cid:17) ≤ c0 max h nX k=1 max I∈IP n I∈IP n (cid:16)LoR '' k (E(A, I))(cid:17)i nX k=1 Moving the max outside of the summation can only decrease the cost of the left hand side of the inequality, thus The proof of Corollary 8 applies, giving us ∃c0,n0∀n>n0∀A∈AP ∀'∈L h max I∈IP n nX k=1 (cid:16)LoR '' k ∃c00,n0∀n>n0∀A∈AP ∀'∈L (E(A, I))(cid:17)i n '' k k=1 I∈IP nX (cid:16)LoR (E(ALRU, I))(cid:17) ≤ c0 max h max W'(P, ALRU, n) ≤ c00 · W'(P, A, n)i h (LoR'(E(ALRU, I))) ≤ c00 · max I∈IP I∈IP n n Using our definition of the worst-case LoR cost, ∃c00,n0∀n>n0∀A∈AP ∀'∈L (LoR'(E(A, I)))i Therefore, any LRU optimal algorithm is also LoR optimal. (cid:73) Theorem 19. If algorithm A is memory-smooth and solves B-stable problem P, then it is CO optimal if and only if it is LoR optimal. Proof. Since the cache-oblivious model assumes ideal cache replacement, for any execution sequence E, (cid:74) SCOM,B(E) ≤ SLRUM,B(E) ≤ 2 · SCO M 2 ,B(E) Assume algorithm A is memory-smooth and solves problem P. Then for any execution sequence EA generated by A, SCO M 2 ,B(EA) = Θ(SCOM,B(EA)) Therefore, SLRUM,B(EA) = Θ(SCOM,B(EA)) Since the LRU cost and CO cost are asymptotically equivalent for every execution sequence generated by A, then A is asymptotically LRU optimal if and only if it is asymptotically CO (cid:74) optimal and, by Theorem 18, A is LoR optimal if and only if it is CO optimal. 1 We note that, because we are limited to M ≥ B2 for our 'M,B functions, we can only construct functions where f(k) ≥ g(k), for all k > 0. However, our definition of bidimensional locality functions includes this restriction, as it corresponds to the tall cache assumption (discussed in Section 3.2). John Iacono, Varunkumar Jayapaul and Ben Karsin 21 3.8 Modeling a multi-level memory hierarchy We define a memory hierarchy H = (H1, H2, . . . , HH) to be a sequence of triples, where each triple represents a level of the memory hierarchy. The i-th triple, Hi = (Mi, Bi, Ci) represents the memory size, block size, and relative cost of an access at the i-th level of the memory hierarchy, respectively. Thus, the total cache-oblivious cost of execution sequence E Hi∈H(Ci · SCOMi,Bi(E)), and we similarly define SLRUH(E) to be the LRU cost of E on memory hierarchy H. (cid:73) Theorem 20. If algorithm ACO-Opt is CO optimal and solves B-stable problem P, then it is asymptotically optimal for any memory hierarchy, H, i.e., on memory hierarchy H is SCOH(E) =P (SCOH(E(A, I)))i h max I∈IP n ∃c,n0∀n>n0∀H∀A∈AP (SCOH(E(ACO-opt, I))) ≤ c · max I∈IP n Proof. If ACO-Opt is asymptotically CO optimal, then by definition, ∃c,n0∀n>n0∀B≥1∀M≥B2∀A∈AP (COM,B(E(ACO-Opt, I))) ≤ c · max I∈IP n (COM,B(E(A, I)))i And by Lemma 4, ∃c,n0∀n>n0∀B≥1∀M≥B2∀A∈AP (SCOM,B(E(ACO-Opt, I))) ≤ 4c · max I∈IP n (SCOM,B(E(A, I)))i h max I∈IP n h max I∈IP n h max I∈IP n (SCOH(E(A, I)))i It follows from the proof of Theorem 18 that if P is B-stable, ACO-Opt is also asymptotically optimal for a weighted maximum of CO costs, for different M and B values. Therefore, ∃c,n0∀n>n0∀H∀A∈AP (SCOH(E(ACO-opt, I))) ≤ 4c · max I∈IP n (cid:74) In the LoR model, all features of a single level of a memory hierarchy are represented by a bidimensional locality function, '. Thus, in the LoR model we define a memory hierarchy as a set of weighted locality functions, LH, i.e., LH = {C · 'M,B(M, B, C) ∈ H} The LoR cost of '∈LH(LoR'(E)). execution sequence E on a hierarchy represented by LH is LoRLH(E) =P (cid:73) Theorem 21. For any execution sequence E., SLRUH(E) = LoRLH(E) Proof. It follows from Lemma 13 that, if the cost at every level is equal, the total cost for any memory hierarchy H must be equal. (cid:74) 3.8.1 Geometrically increasing hierarchy On modern computers, the block size, memory size, and cost per access increases by an order of magnitude or more at each level of the memory hierarchy. Thus, we consider the family of hierarchies that have geometrically increasing parameters. Specifically, we consider hierarchies such that, for all Hi ∈ H, Bi+1 = c· Bi, where c ≥ 2. We define functions relating memory and cost to the block size: Mi = µ(Bi) and Ci = γ(Bi), where µ(B) and γ(B) are non-decreasing for all levels of the hierarchy. 22 Locality (cid:73) Lemma 22. For any execution sequence E and geometrically increasing memory hierarchy H, the maximum cost difference between any two levels of the memory hierarchy bounds the difference between the cache-oblivious cost and LoR cost, i.e., LoRLH(E) = O · SCOH(E)) (cid:18) Hmax i=2 (cid:18) Ci Ci−1 (cid:19)(cid:19) Proof. By Theorem 13, we have that LoR'M,B(E) ≤ 2 · SCO M only increase the total cost, so 2 ,B(E). Decreasing B can LoR'M,B(E) ≤ 2 · SCO M 2 , B 2 (E) Since H is a memory hierarchy with B and M increasing geometrically with each level, LoR'Mi+1,Bi+1 (E) ≤ 2 · SCOMi,Bi(E) Using the total cost including the relative cost of each level of the hierarchy (Ci = γ(Bi)), we get = 'i∈LH (E)(cid:1) i=1 ≤ 2 · (LoR'i(E)) LoRLH(E) = X HX (cid:0)Ci · LoR'Mi,Bi HX (cid:0)Ci · SCOMi−1,Bi−1(E)(cid:1) (cid:18) Ci HX (cid:18) Ci (cid:18) Ci (cid:18) Ci (cid:18) Hmax · SCOH(E)) · SCOH(E)) Hmax i=2 ≤ 2 · i=2 Hmax i=2 Ci−1 ≤ 2 · ≤ 2 · = O Ci−1 i=2 Ci−1 l=2 (cid:19) (cid:19)(cid:19) i=2 Ci−1 (cid:19) · Ci−1 · SCOMi−1,Bi−1(E) (cid:19) HX (cid:0)Ci−1 · SCOMi−1,Bi−1(E)(cid:1) · (cid:74) (cid:73) Theorem 23. For any geometrically increasing memory hierarchy, H, if γ(B) = Bc for any constant c, then LoRLH(E) = Θ(SCOH(E)), for any execution sequence E. Proof. By Lemma 22, LoRLH(E) = O (cid:19)(cid:19) i=2 (cid:18) γ(Bi) γ(Bi−1) · SCOH(E)) (cid:19) (cid:18) Hmax (cid:18) γ(BH) γ(BH−1) · SCOH(E)) = O If γ(B) = Bc for some constant c, then the largest two levels of the hierarchy maximize the difference, so John Iacono, Varunkumar Jayapaul and Ben Karsin 23 Since H is geometrically increasing, BH = d·BH−1 for some constant d. Thus, if γ(B) = Bc for some constant c, then γ(BH) γ(BH−1) ≤ (BH)c (BH−1)c (d · BH−1)c (BH−1)c = = dc d and c are constants, so dc is also a constant, therefore, LoRLH(E) = O(dc · SCOH(E)) = O(SCOH(E)) The cache-oblivious cost is computed assuming ideal cache replacement, so it cannot be greater than the LoR cost, therefore LoRLH(E) = Θ(SCOH(E)) (cid:74) Conclusion 4 Despite the increasing complexity of modern hardware architectures, the goal of many design and optimization principles remain the same: maximize locality of reference. Even many of the optimization techniques used by modern compilers, such as branch prediction or loop unrolling [15], can be seen as methods of increasing spatial and/or temporal locality. As we demonstrated in this work, cache-oblivious algorithms do just that, suggesting that the performance benefits of such algorithms extend beyond what was originally envisioned. References 1 Alok Aggarwal, Bowen Alpern, Ashok K. Chandra, and Marc Snir. A model for hierarchical memory. In Alfred V. Aho, editor, Proceedings of the 19th Annual ACM Symposium on Theory of Computing, 1987, New York, New York, USA, pages 305 -- 314. ACM, 1987. URL: https://doi.org/10.1145/28395.28428, doi:10.1145/28395.28428. 2 Alok Aggarwal, Ashok K. Chandra, and Marc Snir. Hierarchical memory with block transfer. In 28th Annual Symposium on Foundations of Computer Science, Los Angeles, California, USA, 27-29 October 1987, pages 204 -- 216. IEEE Computer Society, 1987. URL: https: //doi.org/10.1109/SFCS.1987.31, doi:10.1109/SFCS.1987.31. SIAM J. Comput., 35(2):341 -- 358, 2005. 4 3 Alok Aggarwal and Jeffrey Scott Vitter. The input/output complexity of sorting and related problems. Commun. ACM, 31(9):1116 -- 1127, 1988. URL: http://doi.acm.org/10.1145/ 48529.48535, doi:10.1145/48529.48535. Bowen Alpern, Larry Carter, and Ephraim Feig. Uniform memory hierarchies. In 31st Annual Symposium on Foundations of Computer Science, St. Louis, Missouri, USA, October 22-24, 1990, Volume II, pages 600 -- 608, 1990. URL: https://doi.org/10.1109/FSCS.1990.89581, doi:10.1109/FSCS.1990.89581. L. A. Belady. A study of replacement algorithms for a virtual-storage computer. IBM Syst. J., 5(2):78 -- 101, June 1966. URL: http://dx.doi.org/10.1147/sj.52.0078, doi:10.1147/ sj.52.0078. 6 Michael A. Bender, Erik D. Demaine, and Martin Farach-Colton. Cache-oblivious b-trees. 5 24 Locality 7 Michael A. Bender, Ziyang Duan, John Iacono, and Jing Wu. A locality-preserving cache- oblivious dynamic dictionary. J. Algorithms, 53(2):115 -- 136, 2004. 8 Gerth Stølting Brodal and Rolf Fagerberg. On the limits of cache-obliviousness. In STOC, pages 307 -- 315. ACM, 2003. 9 Douglas Comer. The ubiquitous b-tree. ACM Comput. Surv., 11(2):121 -- 137, 1979. URL: https://doi.org/10.1145/356770.356776, doi:10.1145/356770.356776. 10 Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. Introduction to Algorithms, 3rd Edition. MIT Press, 2009. 11 Matteo Frigo, Charles E. Leiserson, Harald Prokop, and Sridhar Ramachandran. Cache- 12 13 oblivious algorithms. ACM Trans. Algorithms, 8(1):4:1 -- 4:22, 2012. John L. Hennessy and David A. Patterson. Computer Architecture, Fifth Edition: A Quanti- tative Approach. Morgan Kaufmann Publishers Inc., San Francisco, CA, USA, 5th edition, 2011. Francesco Silvestri. On the limits of cache-oblivious rational permutations. Theor. Comput. Sci., 402(2-3):221 -- 233, 2008. 14 Daniel Dominic Sleator and Robert Endre Tarjan. Amortized efficiency of list update and paging rules. Commun. ACM, 28(2):202 -- 208, 1985. URL: http://doi.acm.org/10.1145/2786.2793, doi:10.1145/2786.2793. 15 William Stallings. Computer Organization and Architecture - Designing for Performance (7. ed.). Pearson / Prentice Hall, 2006. A Necessity of B stability (cid:73) Lemma 24. There exists a problem P which is not B-stable and which has a CO optimal algorithm which is not LoR optimal. Thus theorem 10 would not hold if the restriction to B-stable algorithms were to be removed. Proof. Here we demonstrate a toy problem that meets the requirements of the lemma while also illustrating the unnaturalness of such problems. It has two candidate algorithms, one which has the same runtime on each instance, and a second one that for each instance has some values of B that it runs faster than the first algorithm, and some that it runs more slowly than the first algorithm on, asymptotically. Thus for each B the worst-case time of the first algorithm is better than the second, but there is no single bad instance for the second algorithm. n, has a set of n instances In = I n1 , I n2 , . . . I n follows: Consider a problem P and a set A of two algorithms A1 and A2. The problem, given an n. The runtimes of the algorithms are given as (cid:19)(cid:19) i · n log n log log n B log i , COB(E(A1), I n i ) = Θ COB(E(A2), I n i ) = Θ (cid:18) (cid:18) n log n log log n (cid:19) (cid:18) n log n log log log n log i min log B These runtimes can be realized through an appropriately twisted problem definition that forces an algorithm for each instance to read all elements in one of two sets of memory locations in order to be considered a valid algorithms. In particular our problem admits two algorithms, one of which, A2, can solve any instance by performing n log n log log log n reads in memory generated by n log log log n searches in a van Emde Boas search structure, and the other, A1, by reading at memory locations generated by an arithmetic progression, where the step and number of locations depends on the instance. John Iacono, Varunkumar Jayapaul and Ben Karsin Accessing k memory locations evenly spaced σ apart takes time Θ(1 + min(cid:0)k, kσ (cid:1)) in the CO model; thus the desired runtime of algorithm A1 on instance I n the algorithm A1 instance Ii read n log n log log n memory locations evenly spaced i apart. i can be forced by having B log i What are the worst-case runtimes of these algorithms? 25 WB(P, A1, n) = max i ∈In I n COB(E(A1, I n i ) z (cid:18) n log n log log n } Equal when i = B i · n log n log log n { (cid:19) log i , B log i min = max i ∈In I n = n log n log log n log B WB(P, A2, n) = n log n log log log n log B So, looking at these two algorithms, A2 is clearly the worst-case optimal in the CO model. Now,Recall the definition of B-stable: Problem P is B-stable if, for any algorithm A that solves P, ∃c,d∀n>d∃Iw∀B≥1 WB(P, A0, n) ≤ c · COB(E(A, Iw))i . Applying this to our problem gives: ∃c,d∀n>d∃I n i ∈In∀B≥1 ∃c,d∀n>d∃I n i ∈In∀B≥1 (cid:19) (cid:19)(cid:21) , n log n log log log n log B (cid:18) n log n log log n (cid:18) n log n log i log log n √ log i in log n log log n B log i , (cid:19)(cid:21) in log n log log n √ B log i , n A0∈AP h min (cid:18) n log n log log n (cid:20) (cid:20)log n log log log n log B ≤ c · min min log B ≤ c · min (cid:18) n log n √ log i log log n log log n ≤ c · min √ ≤ c · n log n log i √ ≤ c · n log n = c · n log n log log n √ log log n This is false for all choices of I n i ∈ In. Specifically, if i ≥ log N, then setting B = 2 and using the first term of the min gives the following contradiction for any c as n grows: n log n log log log n log 2 log log n in log n log log n , √ B log i (cid:19) And, if i ≤ log N, then setting B = N and using the second term on the right gives the 26 Locality following contradiction: n log n log log log n log n = n log log log n ≤ c · min (cid:18) n log n ≤ c · n log n log n log log n √ log i √ log log n n log log n = c · √ log2 n log log n (cid:19) in log n log log n √ B log i , This concludes the proof that P is not B stable. We now argue that while A2 is CO optimal for P, and A1 is not, with locality function '(d) = log(d) the reverse is true as A1 will have the asymptotically better runtime with this locality function in the LoR model. In the introduction we mentioned that the LoR runtime with locality function '(d) = log d for searching in a VeB structure is Θ(log n log log n), thus since A2 does this n log log log n times its cost is Θ(n log n log log n log log log n). Algorithm A1 is easy to analyze as on memory locations evenly spaced i apart, thus its cost is instance I n it accesses n log n log log n i log i n log n log log n log i · log i = log n log log n. Thus the CO-optimal A2 has a LoR runtime (with '(d) = log d) of Θ(log n log log n log log log n) which is a Θ(log log log) factor worse than the non-CO-optimal A1 with LoR runtime of log n log log n. Since A2 is not optimal for one locality function, it can not be optimal for all valid locality functions. (cid:74) What made this problem not B-stable? It was the fact that every instance was constructed to be faster for one algorithm for some values of B and slower for others than the optimal worst-case algorithm. In this example A1 ran instance I n i slower than A2 for B close to i and faster than A2 for B far from i. However, this is far from natural, to have an instance in effect encode faster-than-worse-case performance on selected B's. In a standard data structure query, such as "what is the predecessor of a given item in an ordered set," the query item itself has nothing that combined with the problem definition that allows a query to encode a preference for fast execution for certain B's in a non-optimal algorithm. We note that this is very different than some algorithms which may "hard-code" some instances and make them fast; this does not pose a problem with regards to B-stability as this makes this instance fast for all values of B.
1807.11711
1
1807
2018-07-31T09:17:43
Inserting an Edge into a Geometric Embedding
[ "cs.DS", "cs.CG" ]
The algorithm of Gutwenger et al. to insert an edge $e$ in linear time into a planar graph $G$ with a minimal number of crossings on $e$, is a helpful tool for designing heuristics that minimize edge crossings in drawings of general graphs. Unfortunately, some graphs do not have a geometric embedding $\Gamma$ such that $\Gamma+e$ has the same number of crossings as the embedding $G+e$. This motivates the study of the computational complexity of the following problem: Given a combinatorially embedded graph $G$, compute a geometric embedding $\Gamma$ that has the same combinatorial embedding as $G$ and that minimizes the crossings of $\Gamma+e$. We give polynomial-time algorithms for special cases and prove that the general problem is fixed-parameter tractable in the number of crossings. Moreover, we show how to approximate the number of crossings by a factor $(\Delta-2)$, where $\Delta$ is the maximum vertex degree of $G$.
cs.DS
cs
Inserting an Edge into a Geometric Embedding(cid:63) Marcel Radermacher1 and Ignaz Rutter2 1 Department of Computer Science, Karlsruhe Institute of Technology, Germany 2 Department of Computer Science and Mathematics, University of Passau, Germany [email protected], [email protected] 8 1 0 2 l u J 1 3 ] S D . s c [ 1 v 1 1 7 1 1 . 7 0 8 1 : v i X r a Abstract. The algorithm to insert an edge e in linear time into a planar graph G with a minimal number of crossings on e [10], is a helpful tool for designing heuristics that minimize edge crossings in drawings of general graphs. Unfortunately, some graphs do not have a geometric embedding Γ such that Γ + e has the same number of crossings as the embedding G + e. This motivates the study of the computational complexity of the following problem: Given a combinatorially embedded graph G, compute a geometric embedding Γ that has the same combinatorial embedding as G and that minimizes the crossings of Γ + e. We give polynomial-time algorithms for special cases and prove that the general problem is fixed- parameter tractable in the number of crossings. Moreover, we show how to approximate the number of crossings by a factor (∆ − 2), where ∆ is the maximum vertex degree of G. 1 Introduction Crossing minimization is an important task for the construction of readable drawings. The problem of minimizing the number of crossings in a given graph is a well-known NP-complete problem [8]. A very successful heuristic for mini- mizing the number of crossings in a topological drawing of a graph G is to start with a spanning planar subgraph H of G and to iteratively insert the remaining edges into a drawing of H. The edge insertion problem for a planar graph G and two vertices s, t ∈ V (G) asks to find a drawing Γ + st of G + st with the minimum number of crossings such that the induced drawing Γ of G is planar. The problem comes with several variants depending on whether the drawing Γ can be chosen arbitrarily or is fixed [9,10]. In the planar topological case both problems can be solved in linear time. More general problems such as insert- ing several edges simultaneously [2] or inserting a vertex together with all its incident edges [1] have also been studied. All these approaches have in common that they focus on topological drawings where edges are represented as arbitrary curves between their endpoints. By con- trast, we focus on geometric embeddings, i.e., planar straight-line drawings, and the corresponding rectilinear crossing number. In this scenario we are only aware of a few heuristics that compute straight-line drawings of general graphs [12,13]. (cid:63) Work was partially supported by grant WA 654/21-1 of the German Research Foun- dation (DFG). 2 Marcel Radermacher and Ignaz Rutter Fig. 1: (a) The extended dual (red + blue) of the primal graph (grey) and the red vertices corresponding to s and t. (b) Labeling induced by the blue path. Clearly, if a geometric embedding Γ of the input graph G is provided as part of the input, there is no choice left; we can simply insert the straight-line segment from s to t into the drawing and count the number of crossings it produces. If, however, only the combinatorial embedding is specified, but one may still choose the outer face and choose the vertex positions so that this results in a straight- line drawing with the given combinatorial embedding, then the problem becomes interesting and non-trivial. We call this problem geometric edge insertion. Contribution and Outline. We show several results on the complexity of geometric edge insertion with a fixed combinatorial embedding. Namely, we give a linear-time algorithm for the case that the maximum degree ∆ of G is at most 5 (Sec. 3). For the general case, we give a (∆− 2)-approximation that runs in linear time. Moreover, we give an efficient algorithm for testing in special cases whether there exists a way to insert the edge st so that it does not produce more crossings than when we allow to draw it as an arbitrary curve (Sec. 4). Finally, we give a randomized FPT algorithm that tests in O(4kn) time whether an edge can be inserted with at most k crossings (Sec. 5). 2 Preliminaries Let G = (V, E) be a planar graph with a given combinatorial embedding where only the choice of the outer face is free. Additionally, let s and t be two distinct vertices with st (cid:54)∈ E. Denote by G + st the graph G together with the edge st. We want to insert the edge st into the embedded graph G. That is, we seek a straight-line drawing Γ of G (with the given embedding) such that st can be inserted into Γ with a minimum number of crossings. In Γ , the edge st starts at s, traverses a set of faces and ends in t. Topologically, this corresponds to a path p(Γ ) from s to t in the extended dual G(cid:63) st of G, i.e., in the dual graph G(cid:63) plus s and t connected to all vertices of their dual faces; see Fig. 1a. The number of crossings in Γ + st corresponds to the length of the path minus two. However, not all st-paths in G(cid:63) st are of the form p(Γ ) for a straight-line drawing Γ of G. A labeling of G is a mapping l : V → {L, R} that labels vertices as either left or right. Consider an edge uv of G that is crossed by a path p such that u and v are to the left and to the right of p, respectively. The edge uv is compatible ee(cid:63)LRLR(b)(a) Inserting an Edge into a Geometric Embedding 3 Fig. 2: Ratio between length of the shortest st path and the length of a shortest consistent st-path. The solid black edges induce a graph of maximum degree 6. Red vertices have label L, blue vertices have label R. (a) The shortest path from s to t in G(cid:63) st is not consistent. with a labeling l if l(u) = L and l(v) = R. A path p of G(cid:63) st and a labeling l of G are compatible if l is compatible with each edge that is crossed by p. A path p is consistent if there is a labeling of G that is compatible with p. Eades et al. [4] show the following result. Proposition 1 (Eades et al. [4], Theorem 1). An st-path in G(cid:63) st is of the form p(Γ ) if and only if it is consistent, where Γ is a geometric embedding of G. In order to minimize the number of crossings of Γ +st, we look for a consistent st. Given a path p, it is easy to check whether p st-path of minimum length in G(cid:63) is consistent. Fig. 2 shows that the ratio between the length of a shortest st-path and the length of a shortest consistent st-path can be arbitrarily large. Thus, our goal is to find short consistent st-paths. Let H = (V (cid:48), E(cid:48)) be a directed acyclic graph. A path p = (cid:104)v1, v2, . . . , vk(cid:105) is a directed path if for each 1 ≤ i < k, vivi+1 ∈ E(cid:48). It is undirected if for each 1 ≤ i < k, either vivi+1 ∈ E(cid:48) or vi+1vi ∈ E(cid:48). We refer to the number p of edges of a path as the length of p. Two paths p and p(cid:48) are edge-disjoint if they do not share an edge. Two paths p and p(cid:48) of an embedded graph are non-crossing if at each common vertex v, the edges of p and p(cid:48) incident to v do not alternate in the cyclic order around v in the graph induced by p and p(cid:48). We denote by p[u, v] the subpath of a path p from u to v. 3 Bounded Degree The shortest st-path of the graph in Fig. 2a is not consistent. Note that the maximum vertex degree is 6. In this section, we show that every shortest st-path in graphs of bounded degree 3 is consistent, and that in each planar graph with vertex degree at most 5, there is a shortest st-path that is consistent. Finally, we prove that there is a consistent st-path of length (∆ − 2)l in a graph with maximum vertex degree ∆ and a shortest st-path of length l in G(cid:63) st. Let p be an st-path in G(cid:63) st and let e(cid:63) be an edge of p. An endpoint u of the primal edge e of e(cid:63) is left of e(cid:63) if it is locally left of p on e (Fig. 1b). A vertex v of G is left (right) of p if v is left (right) of an edge of p. We now consider a labeling svtstv(a)(b) 4 Marcel Radermacher and Ignaz Rutter Fig. 3: Inconsistent path around (a) a degree-4 vertex and (b,c) a degree-5 vertex. extended by two more labels LR,⊥. We define the labeling lp induced by p as follows. Each vertex that is left and right of p gets the label LR. The remaining vertices that are either left or right of p get labels L and R, respectively. Vertices neither left nor right of p get the label ⊥. Obviously, there is a labeling l of G compatible with p if and only if lp does not use the label LR. Theorem 2. Let G be a planar embedded graph of degree at most 3. Then every shortest st-path in G(cid:63) st is consistent. Theorem 3. Let G be a planar embedded graph with maximum degree 5. Then there is a shortest st-path in G(cid:63) st that is consistent. Proof. Let p be a shortest st-path in G(cid:63) st. We call an edge e of p good if the vertices left and right of it do not have label LR in the labeling lp induced by p. If p is not consistent, then let e denote the last edge of p that is not good. Then an endpoint v of the primal edge corresponding to e has label LR. Without loss of generality, we may assume that v lies left of e. Since lp(v) = LR, there is an edge e(cid:48) of p that has v to its right. By the choice of e, it follows that e(cid:48) lies before e on p. We now distinguish cases based on the degree of v. If deg(v) ≤ 3, then we find that p enters or leaves a face twice, which con- tradicts the assumption that it is a shortest st-path. If deg(v) = 4, we denote the edges around v in clockwise order as e1, . . . , e4 such that e(cid:48) crosses e1. Moreover, we denote the faces incident to v in clockwise order as f1, . . . , f4 where f1 is the starting face of e(cid:48). Since no face has two incoming or two outgoing edges of p, it follows that e(cid:48) = f1f2 crosses e1 and e = f4f3 crosses e3; see Fig. 3a. Let p(cid:48) be the path obtained from p by replacing the subpath p[f1, f4] by the edge f1f4 that crosses e4. Since p is a shortest path, it follows that f2 = f4. By construction, it is lp(cid:48)(v) = L. Observe that p(cid:48)[f4, t] = p[f4, t] lies inside the region ρ bounded by p[f1, f4] and a curve connecting f1 and f4 that crosses e4. The only vertex inside this region whose label changed is v. Therefore, the path p(cid:48)[f1, t] consists of good edges, and we have thus increased the length of the suffix of the shortest path that consists of good edges. Now assume that deg(v) = 5. We denote the edges around v as e1, . . . , e5 in clockwise order such that e(cid:48) crosses e1. We further denote the faces incident to e1e2e3e4f1f2f3f4vtse(cid:48)ee1e4vte(cid:48)ee2e3e5f1f2f3f4f5(a)(b)e1e2e4e5vtse(cid:48)ee3f1f2f3f4f5(c) Inserting an Edge into a Geometric Embedding 5 Fig. 4: Inconsistent path around a degree k vertex. v in clockwise order as f1, . . . , f5 such that e(cid:48) starts in f1. Since no face has two incoming or two outgoing edges, it follows that either e crosses e4 from f5 to f4 or e crosses e3 from f4 to f3. If e crosses e3, then we consider the path p(cid:48) obtained from p by replacing the subpath p[f2, f3] by the edge that crosses e3; see Fig. 3b. As above, it follows that f2 = f4 and v is a cutvertex and that p(cid:48)[f1, t] consists of good edges. If e crosses e4, then we obtain p(cid:48) by replacing p[f1, f5] by the single edge that crosses e5; see Fig. 3c. As above, we find that f2 = f5 and v is a cutvertex and that p(cid:48)[f1, t] consists of good edges. Thus, in all cases, we increase the length of the suffix of the shortest path consisting of good edges. Eventually, we thus arrive at a shortest path whose (cid:3) edges are all good and that hence is consistent. Theorem 4. Let G = (V, E) a planar embedded graph with maximum vertex- st with s, t ∈ V . Then there is a degree ∆ and let p be a shortest st-path in G(cid:63) consistent path of length at most (∆ − 2)p. Proof. Let p be an st-path in G(cid:63) st. Assume that p is not consistent. Then there is a shortest prefix p2 = p[s, f2] = p[s, f1] · f1f2 of p that is not consistent; refer to Fig. 4. Let v be a vertex incident to the primal edge of f1f2 with lp2 (v) = LR. Without loss of generality let f1, f2, . . . , fk be the faces around v in counterclockwise order, i.e., v lies left of f1f2. Since p2 is not consistent, there is a second edge of p2 that crosses a primal edge incident to v. Let e be the last edge of p[s, f1] that crosses a primal edge incident to v. Since p2 is the shortest inconsistent prefix of p, v lies right of e, i.e., e = fi+1fi for some i with 2 < i ≤ k − 1. Moreover, let fj be the first vertex in clockwise order from fi that lies on the path p[f2, t]. Note that such a vertex fj exists, since at the latest f2 satisfies the condition. Let q be the path fifi−1 ··· fj. We obtain a path p(cid:48) from p by replacing p[fi, fj] by q, i.e., p(cid:48) = p[s, fi]· q · p[fj, t]. Note that, since fj is the first vertex in clockwise order on p[f2, t], p(cid:48) is a simple path. Since q does not contain the edges fkf1 and f1f2, and p[fi, fj] contains at least one edge, the path p(cid:48) has length at most p + (k − 2) − 1. We claim that the prefix p(cid:48) Then, since p(cid:48)[fj, t] is a subpath of p[f2, t] and p(cid:48)[s, fj] is consistent, it follows that we have decreased the maximum length of a suffix of the path whose removal j = p(cid:48)[s, fj] is consistent. tfi+1fisfjf2f1fkyρv 6 Marcel Radermacher and Ignaz Rutter results in an inconsistent path. Since this suffix has initially length at most p, we inductively find a consistent st-path of length at most (∆ − 2)p. It remains to prove that p(cid:48)[s, fj] is consistent. Since p[s, f2] is the shortest inconsistent prefix of p, the prefix p[s, f1] is consistent. Therefore, v is right of p[s, fi] = p(cid:48)[s, fi]. By construction, v is right of q. Thus, we have lp(cid:48) (v) = R. (w) = LR can be neighbors of v, as otherwise The only vertices w of G with lp(cid:48) p[s, f1] would not be consistent. Consider the region ρ enclosed by the path p[fi, f1] and f1, fk, . . . , fi that contains v; refer to Fig. 4. The prefix p[s, f1] = p(cid:48)[s, f1] lies outside of ρ and the path q lies entirely in ρ. Moreover, in case that vw is crossed by p(cid:48)[s, fi], w lies outside of ρ. On the other hand, if q crosses an edge vw, then w lies inside ρ. (w) = L. Therefore, the prefix Thus, in both cases we immediately get that lp(cid:48) (cid:3) p(cid:48)[s, fj] is consistent. j j j 4 Consistent Shortest st-paths In Section 3 we showed that every shortest st-path in the extended dual G(cid:63) st of a graph G with vertex degree at most 3 is consistent. For every graph of st that is consistent. On the maximum degree 5, there is a shortest st-path G(cid:63) other hand, Fig. 2 shows that, starting from degree 6, there are graphs whose shortest st-paths are not consistent. In this section we investigate the problem of deciding whether G(cid:63) st contains a consistent shortest st-path. As a consequence of Proposition 1 this problem is in NP. In Lemma 5 we show that finding a consistent st-path p in G(cid:63) st is closely related to finding two edge-disjoint paths in G. Especially, we are interested in two edge-disjoint paths where the length of one is minimized. Eilam-Tzoreff [5] proved that this problem is in general NP-complete. In planar graphs the sum of the length of two vertex-disjoint paths can be minimized efficiently [11]. In general directed graphs the problem is NP-hard [7]. Finding two edge-disjoint paths in acyclic directed graphs is NP-complete [6]. The closest relative to our problem is certainly the work of Eilam-Tzoreff. In fact their result can be modified to show that it is NP-hard to decide whether a graph contains two edge-disjoint st-paths such that one of them is a shortest path. We study this problem in the planar setting with the additional restriction that s and t lie on a common face of the subgraph Gsp of G(cid:63) st that contains all shortest paths from s to t. st is consistent if and only if there is an st-path st that is edge-disjoint from p and that does not cross p. Lemma 5. An st-path p in G(cid:63) p(cid:48) in G(cid:63) Proof. The paths p and p(cid:48) define a set of regions in the plane. Since p and p(cid:48) are non-crossing, each region is bounded by one maximal subpath of p and one maximal subpath of p(cid:48) (Fig. 5). We label each region ρ with either L or R, depending on whether ρ lies left or right of the unique maximal subpath of p on its boundary. We define a labeling l of G by giving each vertex v the label of the region ρ that contains it. We claim that l is compatible with p. Inserting an Edge into a Geometric Embedding 7 Fig. 5: (a) The green regions are right of p (blue) and the blue left of p. (b) The outer region that is not bounded by maximal subpaths of p and p(cid:48). Fig. 6: (a) The line g through the segment st induces a path in G(cid:63) cation of the undirected path p(cid:48) edge-disjoint from p. st. (b) Modifi- Since p and p(cid:48) are edge-disjoint, every primal edge connects vertices of the same or adjacent regions. Moreover, by construction, vertices of adjacent regions have different labels. Thus all vertices left of p have label L and all vertices right of p have label R. That is l is compatible with p, i.e., p is consistent. Conversely, assume that p is consistent. By Proposition 1 there is a straight- line drawing of G such that the segment st intersects the same edges as p and in the same order (Fig. 6a). Let g be the line that contains the segment st. Each edge of G intersects g at most once. Thus, the complement of st in g defines a (cid:3) path from s to t in G(cid:63) st that is edge-disjoint from p and does not cross p. Thus, we now consider the problem of finding a consistent shortest st-path as an edge-disjoint path problem in G(cid:63) st. Our proof strategy consists of three steps. Step 1) We first show that the problem is equivalent to finding two edge-disjoint −→ paths p and q in a directed graph G st such that p is directed and q is undirected. −→ G st such that p is a path in a specific subgraph Gsp and q Step 2) We modify lies in the subgraph Gsp. These two graphs may share an edge set E such that each edge in E can be an edge of p or of q. Moreover, we find pairs of edges e and e(cid:48) in E such that the path p in Gsp (the path q in Gsp) contains either e or e(cid:48). Step 3) Finally, we use these properties to reduce our problem to 2-SAT. −→ G st = (V (cid:48)∪{s, t}, E(cid:48)) is st-friendly if We begin with Step 1. A directed graph −→ st contains a consistent shortest st-path if and only if G st contains a directed G(cid:63) st-path p and an undirected st-path p(cid:48) that is edge-disjoint from p and does −→ −→ not cross p. We obtain an st-friendly graph st as follows. E ) from G(cid:63) V , Denote by Gsp the directed acyclic graph that contains all shortest paths from −→ G st. s to t in G(cid:63) st = (V, E). If an edge uv ∈ E is an edge of Gsp, we add it to −→ G st = ( stst(a)(b)stgs(cid:48)t(cid:48)uvpp(cid:48)p(cid:48)[u,v]pµ[u,v](a)(b) 8 Marcel Radermacher and Ignaz Rutter Let p be a consistent shortest st-path in G(cid:63) −→ G st and add the For all remaining edges uv, we add a subdivision vertex x to −→ −→ G st is st-friendly. directed edges xu, xv to G st in this direction. We claim that st. By Lemma 5 there is a path p(cid:48) in G(cid:63) st that is edge-disjoint from p and does not cross p. By construction p corresponds to a directed path in Gsp and p corresponds to an undirected path in −→ G st. Conversely, due to the directions of the edges xv, xu, every directed st-path −→ q in G st is a directed path in Gsp, and therefore it is a shortest st-path in G(cid:63) st. If there is an undirected path q(cid:48) that is edge-disjoint from q and does not cross q, we obtain a path p(cid:48) from q(cid:48) by contracting edges incident to split vertices x. Hence, −→ G st is st-friendly. We consider the following special case, where s and t lie on a common face −→ G st. Without loss of generality, let o be the outer face o of the subgraph Gsp of −→ G st. We denote by pµ and pλ the upper of Gsp and let t lie on the outer face of and lower st-path of Gsp on the boundary of o. A vertex v of Gsp is an interior vertex if v does not lie on o. An edge uv of Gsp is an interior edge if u and v are interior vertices. An edge e of Gsp is a chord if both its endpoints lie on o but e is not an edge on the boundary of o. Lemma 6. For a directed st-path p and an undirected st-path p(cid:48), that are edge- disjoint and non-crossing, there is an undirected st-path p(cid:48)(cid:48) that is edge-disjoint from p, does not cross p, and that does not use interior vertices of Gsp. Proof. Since p and p(cid:48) are non-crossing, there are two distinct vertices u, v on pλ or on pµ, say pµ, such that the inner vertices of p(cid:48)[u, v] lie in the interior of Gsp; refer to Fig. 6b. Moreover, since p(cid:48) and p are non-crossing, the region enclosed by p(cid:48)[u, v] and pµ[u, v] does not contain a vertex of p in its interior. Therefore, we obtain p(cid:48)(cid:48) by iteratively replacing pieces in the form of p(cid:48)[u, v] by pµ[u, v]. (cid:3) Fig. 7: (a) The red directed path can be circumvented with the blue directed path via vertex v. (b) The red path consists of avoidable edges. This finishes Step 1, and we continue with Step 2. In the following, we it- −→ eratively simplify the structure of Gsp while preserving st-friendliness of G st. Due to Lemma 6, the graph Gsp/e, obtained from contracting an edge e of Gsp, is st-friendly, if e is an interior edge. This may generate a separating triangle xyz. Let v be a vertex in the interior of xyz and let p be a directed st-path vv(cid:48)stxzypµpλvstxzpλpµabc(a)(b) Inserting an Edge into a Geometric Embedding 9 Fig. 8: (a) Interior partners decoded by color of 2-edge connected component of Gsp. (b) Split a vertex x on the boundary of H (cid:63) st. that contains v. Then, p contains at least two vertices of x, y, z. Hence, p can be rerouted using an edge of xyz. Thus, the graph after removing all vertices in the interior of xyz is st-friendly. After contracting all interior edges of Gsp, each neighbor of an interior vertex of Gsp lies either on pλ or on pµ. The remaining edges are edges on pλ ∪ pµ and chords. Consider three vertices x, y, z that lie in this order on pλ (pµ) and two interior vertices v and v(cid:48), with xv, v(cid:48)y, vz ∈ −→ E ; refer to Fig. 7a. Note that v and v(cid:48) can coincide. Then, every directed st-path p that contains y also contains x and z. Hence, p can be rerouted through the edges xv, vz and as a consequence of Lemma 6, the graph Gsp − v(cid:48)y is st-friendly. Analogously, if Gsp contains the edge yv(cid:48), Gsp − yv(cid:48) remains st-friendly. We call such edges circumventable. We refer to edges of a subpath pλ[x, z] (pµ[x, z]) as avoidable if there exists an interior vertex v with xv, vz ∈ −→ E (Fig. 7b). If there exists a directed path p that uses an avoidable edge ab it can be rerouted by replacing the corresponding path pλ[x, z] with the edges xv, vz. Thus, we can split the edge ab with a vertex c and we direct the resulting edges from c towards a and b, respectively, and −→ remove the edge ab from G st. Finally, we iteratively contract edges incident to vertices with in- and out-degree 1, and we iteratively remove vertices of degree at most 1, except for s and t. Since all interior edges of Gsp are contracted, circumventable interior edges are removed and avoidable edges are replaced, each 2-edge connected component of Gsp is an outerplanar graph whose weak dual (excluding the outer face) is a path; compare Fig. 8a. Each face f of Gsp, with f (cid:54)= o, contains at least one edge eλ of pλ and one edge eµ on pµ. Moreover, every directed st-path contains either eλ or eµ. We refer to the edge sets Ef,λ = E(f ) ∩ E(pλ) and Ef,µ = E(f ) ∩ E(pµ) as interior partners. Property 7. Choosing a directed st-path in Gsp is equivalent to choosing for each face f of Gsp one of the interior partners Ef,µ or Ef,λ such that the following condition holds. Let f1, f2 be two adjacent faces that are separated by a chord e that ends at pλ (pµ) such that f1 is right of e (left of e), then the choice of Ef2,µ (Ef2,λ) implies the choice of Ef1,µ (Ef1,λ). −→ G st, i.e., Gsp = −→ G st − E(Gsp), with the aim to obtain an analog property for the choice of the undirected path. In the following, we modify the exterior of xu1u2u3xu1u2u3y(a)(b)f1f2f(cid:48)1f(cid:48)2 10 Marcel Radermacher and Ignaz Rutter Fig. 9: (a) If the undirected path contains z, it can be rerouted to use vertex v. (b) The color coding of the faces indicate the exterior partners. We refer to edges of Gsp as exterior edges. A vertex in V (Gsp) \ V (Gsp) is an exterior vertex. Since the undirected path is not allowed to cross the directed path, we split each cut vertex x into an upper copy xµ and a lower copy xλ. We reconnect edges of pλ and pµ incident to x to xλ and xµ, respectively. Exterior edges incident to x that are embedded to the right of pλ are reconnected to xλ. Likewise, edges embedded to the left of pµ are reconnected to xµ. Note that this operation duplicates bridges of Gsp. Thus, we forbid the undirected path to traverse these duplicates. Observe that after this operation the outer face o of Gsp is bounded by a simple cycle. −→ G st and we remove each exterior edge ux from Let x be a vertex on o that is incident to an exterior edge. In this case, we −→ insert a vertex y to G st and insert as a replacement edges yx and yu; see Fig. 8b. We refer to the edge yx as a barrier. Since the barrier yx is directed from y to x, the modification preserves −→ the st-friendliness of G st. We now exhaustively contract exterior edges that are not barrier edges, and remove vertices in the interior of separating triangles. Recall that s and t lie on a common face o of the subgraph Gsp of −→ G st and t lies on the outer face of Gsp. Let v be an exterior vertex such that its neighbor x comes before its neighbor y on pi, i = λ, µ, refer to Fig. 9a. Let z be a vertex between x and y on pi that is connected to a vertex v(cid:48) such that the edge v(cid:48)z (zv(cid:48)) lies in the interior of the region bounded by yvx and pi[x, y]. Consider a directed −→ st-path p in Gsp and an undirected st-path p(cid:48) in G st that is edge-disjoint from p, that does not cross p and that contains v(cid:48). Due to Lemma 6 we can assume, that p(cid:48) does not contain an interior vertex of Gsp. Thus, it contains x and y. We obtain a new path p(cid:48)(cid:48) by replacing the subpath p(cid:48)[x, y] by vx, vy. Since vx, vy are exterior edges, p(cid:48)(cid:48) and p are edge-disjoint and non-crossing. Thus, the graph −→ −→ G st − zv(cid:48)) is st-friendly. After removing all such edges, for any two G st − v(cid:48)z ( neighbors x and y of an exterior vertex v, the paths o[x, y] and o[y, x] each contains either s and t. Hence, the region bounded by yvx and o[x, y] contains a second exterior vertex v(cid:48) if and only if o[x, y] contains either s or t. Hence, the dual of Gsp, with the dual vertex of o removed, is a caterpillar C, refer to Fig. 9b. In case that s or t is incident to an exterior vertex v, we can vv(cid:48)xyzststo(a)(b) Inserting an Edge into a Geometric Embedding 11 assume that the undirected path p(cid:48) contains the edge sv (vt). Thus, for simplicity, we now assume that neither s nor t is connected to an exterior vertex. Let a and b be the vertices in C whose primal faces are incident to s and t, respectively. Then every undirected st-path in Gsp from s to t traverses the primal faces of the simple path q from a to b in C. Let f be a primal face of a vertex on q. Since we −→ G st, every face contains at least one edge eλ of pλ inserted the barrier edges to and one edge eµ of pµ. Therefore, every undirected st-path in Gsp either contains eλ or eµ. We refer to the sets Ef,λ = E(f ) ∩ E(pλ) and Ef,µ = E(f ) ∩ E(pµ) as exterior partners. Property 8. Choosing an undirected st-path in Gsp is equivalent to choosing for each face f (cid:54)= o of Gsp one of the exterior partners Ef,λ or Ef,µ. This finishes Step 2, and we proceed to Step 3. The problem of finding a −→ directed st-path p and an undirected st-path p(cid:48) in G st reduces to a 2-SAT instance as follows. For each exterior and interior partner we introduce variables xf and xg, respectively, where f and g correspond to the faces of the partners. If xf is true, p(cid:48) contains the edge of Ef,λ, otherwise it contains Ef,µ. The conditions on the choice of p in Property 7 can be formulated as implications. Let Ef,µ an Ef,λ be exterior partners and let Eg,µ and Eg,λ be interior partners. In case that Ef,λ ∩ Eg,λ (cid:54)= ∅, either p can contain edges of Eg,λ or p(cid:48) can contains edges of Ef,λ but not both. Thus, xf and xg are not allowed to be true at the same time, i.e., xf = xg. Hence, we have the following Theorem. Theorem 9. If s and t lie on a common face of Gsp, it is decidable in polynomial −→ time whether G st has a directed st-path and an undirected st-path that are edge- disjoint and non-crossing. Corollary 10. If s and t lie on a common face of Gsp, it is decidable in poly- nomial time whether G(cid:63) st contains a consistent shortest st-path. 5 Parametrized Complexity of Short Consistent st-Paths In this section we show that edge insertion can be solved in FPT time with respect to the minimum number of crossings of a straight-line drawing of G + st where G is drawn without crossings and has the specified embedding. Let l be an arbitrary labeling of G. Observe that l defines a directed subgraph of G(cid:63) st by removing each edge whose dual edge has endpoints with the same label and by directing all other edges e such that the endpoint of its primal edge left of e has label L and its other endpoint has label R. We denote this graph by G(cid:63) st(l) is compatible with l, and thus a corresponding drawing exists. Clearly, given the labeling l a shortest st-path in G(cid:63) st(l). Obviously, a shortest st-path in G(cid:63) st(l) can be computed in linear time by a BFS. Now assume that the length of a shortest consistent path in G(cid:63) st is k. We propose a randomized FPT algorithm with running time O(4kn) for finding a shortest consistent path in G(cid:63) st, based on the color-coding technique [3]. 12 Marcel Radermacher and Ignaz Rutter The algorithm works as follows. First, we pick a random labeling of G by labeling each vertex independently with L or R with probability 1/2. We then compute a shortest path in G(cid:63) st(l). We repeat this process 4k times and report the shortest path found in all iterations. Clearly the running time is O(4kn). Moreover, each reported path is consis- tent, and therefore the algorithm outputs only consistent paths. It remains to show that the algorithm finds a path of length k with constant probability. Consider a single iteration of the procedure. If the random labeling l is compatible with p, then the algorithm finds a path of length k. Therefore the probability that our algorithm finds a consistent path of length k is at least as high as the probability that p is compatible with the random labeling l. Let VL, VR ⊆ V denote the vertices of V that are left and right of p, respectively. Clearly it is VL,VR ≤ k. A random labeling l is consistent with p if it labels all vertices in VL with L and all vertices in VR with R. Since vertices are la- beled independently with probability 1/2, it follows that Pr[p is consistent with l] = (1/2)VL · (1/2)VR ≥ (1/2)2k = (1/4)k. Therefore, the probability that no path of length k is found in 4k iterations is at most (1 − (1/4)k)4k, which is monotonically increasing and tends to 1/e ≈ 0.368. Thus the algorithm succeeds with a probability of 1 − 1/e ≈ 0.632. The success probability can be increased arbitrarily to 1 − δ, δ > 0 by repeating the algorithm log(1/δ) times. The probability that each iteration fails is then bounded from above by (1/e)log 1/δ = 1/elog 1/δ = δ. E.g., to reach a success probability of 99%, it suffices to do log 100 ≤ 5 repetitions. The algorithm can be derandomized with standard techniques [3]. Theorem 11. There is a randomized algorithm A that computes a consistent path of length k if one exists with a success probability of 1 − δ. The running time of A is O(log(δ−1)4kn). 6 Conclusion We have shown that the problem of finding a short consistent st-paths in G(cid:63) st is tractable in special cases and fixed-parameter tractable in general. Whether st has a short consistent st-path is equivalent to the question of whether G(cid:63) G(cid:63) st has two edge-disjoint and non-crossing st-paths, where the length of one path is minimized. Surprisingly, this is related to yet another purely graph theoretic problem: does a directed graph G have two edge-disjoint paths where one is directed and the other is only undirected? By the result of Eilam-Tzoreff [5] the former problem is in general NP-hard. For planar graphs the computational complexity of these problems remains an intriguing open question. In this paper, we only considered planar graphs with a fixed combinatorial embedding. Allowing for arbitrary embeddings opens new perspectives on the problem and is interesting future work. Inserting an Edge into a Geometric Embedding 13 References 1. Chimani, M., Gutwenger, C., Mutzel, P., Wolf, C.: Inserting a Vertex into a Planar Graph. In: Proceedings of the 20th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA'09). pp. 375 -- 383 (2009) 2. Chimani, M., Hlinený, P.: Inserting Multiple Edges into a Planar Graph. In: Fekete, S., Lubiw, A. (eds.) Proceedings of the 32nd Annual Symposium on Computational Geometry (SoCG'16). Leibniz International Proceedings in Informatics (LIPIcs), vol. 51, pp. 30:1 -- 30:15. Schloss Dagstuhl -- Leibniz-Zentrum fuer Informatik (2016). https://doi.org/10.4230/LIPIcs.SoCG.2016.30 3. Cygan, M., Fomin, F.V., Kowalik, L., Lokshtanov, D., Marx, D., Pilipczuk, M., Pilipczuk, M., Saurabh, S.: Parameterized Algorithms. Springer-Verlag Springer International Publishing (2015). https://doi.org/10.1007/978-3-319-21275-3 4. Eades, P., Hong, S.H., Liotta, G., Katoh, N., Poon, S.H.: Straight-Line Drawability of a Planar Graph Plus an Edge. In: Dehne, F., Sack, J.R., Stege, U. (eds.) Pro- ceedings of the 14th International Symposium on Algorithms and Data Structures (WADS'15). pp. 301 -- 313 (2015). https://doi.org/0.1007/978-3-319-21840-3_25 6. Even, S., 5. Eilam-Tzoreff, T.: The Disjoint Shortest Paths Problem. Discrete Applied Mathe- matics 85(2), 113 -- 138 (1998). https://doi.org/10.1016/S0166-218X(97)00121-2 time table and In: 16th Annual Symposium on Foun- 1975). Itai, A., Shamir, A.: On the complexity of (SFCS 1975). pp. multi-commodity flow problems. dations https://doi.org/10.1109/SFCS.1975.21 of Computer Science 184 -- 193 (Oct 7. Fortune, S., Hopcroft, J., Wyllie, J.: The directed subgraph homeomor- phism problem. Theory of Computing Systems 10(2), 111 -- 121 (1980). https://doi.org/https://doi.org/10.1016/0304-3975(80)90009-2 8. Garey, M.R., Johnson, D.S.: Crossing Number is NP-Complete. SIAM Journal on Algebraic and Discrete Methods 4(3), 312 -- 316 (1983) 9. Gutwenger, C., Klein, K., Mutzel, P.: Planarity Testing and Optimal Edge Inser- tion with Embedding Constraints. Journal of Graph Algorithms and Applications 12(1), 73 -- 95 (2008). https://doi.org/10.7155/jgaa.00160 10. Gutwenger, C., Mutzel, P., Weiskircher, R.: Inserting an Edge into a Planar Graph. Algorithmica 41(4), 289 -- 308 (2005). https://doi.org/10.1007/s00453-004-1128-8 11. Kobayashi, Y., Graphs. nar 234 https://doi.org/https://doi.org/10.1016/j.disopt.2010.05.002 Optimization Sommer, C.: On Discrete Shortest Disjoint Paths 245 7(4), -- in Pla- (2010). 12. Kobourov, S.G.: Force-Directed Drawing Algorithms. In: Tamassia, R. (ed.) Hand- book of Graph Drawing and Visualization, pp. 383 -- 408. Chapman and Hall/CRC (2013) 13. Radermacher, M., Reichard, K., Rutter, I., Wagner, D.: A Geometric Heuristic for Rectilinear Crossing Minimization. In: Pagh, R., Venkatasubramanian, S. (eds.) Proceedings of the 20th Workshop on Algorithm Engineering and Experiments (ALENEX'18). pp. 129 -- 138 (2018). https://doi.org/10.1137/1.9781611975055.12 14 Marcel Radermacher and Ignaz Rutter Fig. 10: Inconsistent path around a degree-3 vertex. A Proof of Theorem 2 Theorem 2. Let G be a planar embedded graph of degree at most 3. Then every shortest st-path in G(cid:63) st is consistent. Proof. Let p be a shortest path in G(cid:63) st. Assume that p is not consistent. Then there is a vertex v that left and right of p. Let f g be the first edge of p that crosses a primal edge incident to v. If the degree of v is at most 2, then p contains either a loop or a double edge, contradicting the assumption that p is a shortest path. Therefore, assume that the degree of v is 3. Without loss of generality, let f, g and h be the faces around v in clockwise order (Fig. 10b). Since v is left and right of p, p contains either the edge f h or hg. Thus, p contains either f or g (cid:3) twice. This contradicts the assumption that p is a shortest path. fgvh
1007.4011
1
1007
2010-07-22T21:14:40
On the (non-)existence of polynomial kernels for Pl-free edge modification problems
[ "cs.DS" ]
Given a graph G = (V,E) and an integer k, an edge modification problem for a graph property P consists in deciding whether there exists a set of edges F of size at most k such that the graph H = (V,E \vartriangle F) satisfies the property P. In the P edge-completion problem, the set F of edges is constrained to be disjoint from E; in the P edge-deletion problem, F is a subset of E; no constraint is imposed on F in the P edge-edition problem. A number of optimization problems can be expressed in terms of graph modification problems which have been extensively studied in the context of parameterized complexity. When parameterized by the size k of the edge set F, it has been proved that if P is an hereditary property characterized by a finite set of forbidden induced subgraphs, then the three P edge-modification problems are FPT. It was then natural to ask whether these problems also admit a polynomial size kernel. Using recent lower bound techniques, Kratsch and Wahlstrom answered this question negatively. However, the problem remains open on many natural graph classes characterized by forbidden induced subgraphs. Kratsch and Wahlstrom asked whether the result holds when the forbidden subgraphs are paths or cycles and pointed out that the problem is already open in the case of P4-free graphs (i.e. cographs). This paper provides positive and negative results in that line of research. We prove that parameterized cograph edge modification problems have cubic vertex kernels whereas polynomial kernels are unlikely to exist for the Pl-free and Cl-free edge-deletion problems for large enough l.
cs.DS
cs
On the (non-)existence of polynomial kernels for Pl-free edge modification problems ∗ Sylvain Guillemot1 Christophe Paul2 Anthony Perez2 1 Lehrstuhl fur Bioinformatik, Friedrich-Schiller Universitat Jena 2 Universit´e Montpellier II - CNRS, LIRMM Abstract Given a graph G = (V, E) and an integer k, an edge modification problem for a graph property Π consists in deciding whether there exists a set of edges F of size at most k such that the graph H = (V, E (cid:77) F ) satisfies the property Π. In the Π edge-completion problem, the set F of edges is constrained to be disjoint from E; in the Π edge-deletion problem, F is a subset of E; no constraint is imposed on F in the Π edge-edition problem. A number of optimization problems can be expressed in terms of graph modification problems which have been extensively studied in the context of parameterized complexity. When parameterized by the size k of the edge set F , it has been proved that if Π is an hereditary property characterized by a finite set of forbidden induced subgraphs, then the three Π edge-modification problems are FPT [4]. It was then natural to ask [4] whether these problems also admit a polynomial size kernel. Using recent lower bound techniques, Kratsch and Wahlstrom answered this question negatively [15]. However, the problem remains open on many natural graph classes characterized by forbidden induced subgraphs. Kratsch and Wahlstrom asked whether the result holds when the forbidden sub- graphs are paths or cycles and pointed out that the problem is already open in the case of P4-free graphs (i.e. cographs). This paper provides positive and negative results in that line of research. We prove that parameterized cograph edge modifi- cation problems have cubic vertex kernels whereas polynomial kernels are unlikely to exist for the Pl-free and Cl-free edge-deletion problems for large enough l. 1 Introduction An edge modification problem aims at changing the edge set of an input graph G = (V, E) in order to get a certain property Π satisfied (see [16] for a recent study). Edge modification problems cover a broad range of graph optimization problems among which completion problems (e.g. minimum fill-in, a.k.a chordal graph comple- tion [19, 21]), edition problems (e.g. cluster editing [20]) and edge deletion problems (e.g. maximum planar subgraph [10]). In a completion problem, the set F of mod- ified edges is constrained to be disjoint from E; in an edge deletion problem, F has to be a subset of E; and in an edition problem, no restriction applies to F . These ∗Research supported by the AGAPE project (ANR-09-BLAN-0159). 1 problems are fundamental in graph theory and play an important role in computational complexity theory (indeed they represent a large number of the earliest NP-Complete problems [10]). Edge modification problems are also relevant in the context of appli- cations as graphs are often used to model data sets which may contain errors. Adding or deleting an edge thereby corresponds to fixing some false negatives or false positives (see e.g. [20] in the context of cluster editing). Different variants of edge modifica- tion problems have been studied in the literature such as graph sandwich problems [11]. Most of the edge modification problems turns out to be NP-Complete [16] and approx- imation algorithms exist for some known graph properties (see e.g. [14, 22]). But for those who want to compute an exact solution, fixed parameter algorithms [5, 8, 17] are a good alternative to cope with such hard problems. In the last decades, edge modi- fication problems have been extensively studied in the context of fixed parameterized complexity (see [4, 7, 13]). A parameterized problem Q is fixed parameter tractable (FPT for short) with respect to parameter k whenever it can be solved in time f (k).nO(1), where f (k) is an arbitrary computable function [5, 17]. In the context of edge modification problems, the size k of the set F of modified edges is a natural parameterization. The generic question is thereby whether a given edge modification problem is FPT for this parameterization. More formally: Parameterized Π edge–modification Problem Input: An undirected graph G = (V, E). Parameter: An integer k (cid:62) 0. Question: Is there a subset F ⊆ V × V with F (cid:54) k such that the graph H = (V, E (cid:77) F ) satisfies Π. A classical result of parameterized complexity states that a parameterized problem Q is FPT if and only if it admits a kernelization. A kernelization of a parameterized problem Q is a polynomial time algorithm K that given an instance (x, k) computes an equivalent instance K(x, k) = (x(cid:48), k(cid:48)) such that the size of x(cid:48) and k(cid:48) are bounded by a computable function h() depending only on the parameter k. The reduced instance (x(cid:48), k(cid:48)) is called a kernel and we say that Q admits a polynomial kernel if the function h() is a polynomial. The equivalence between the existence of an FPT algorithm and the existence of a kernelization only yields kernels of (at least) exponential size. Deter- mining whether an FPT problem has a polynomial (or even linear) size kernel is thus an important challenge. Indeed, the existence of such polynomial time reduction algo- rithm (or pre-processing algorithm or reduction rules) really speed-up the resolution of the problem, especially if it is interleaved with other techniques [18]. However, recent results proved that not every fixed parameter tractable problem admits a polynomial kernel [1]. Cai [4] proved that if Π is an hereditary graph property characterized by a finite set of forbidden subgraphs, then the parameterized Π modification problems (edge- completion, edge-deletion and edge-edition) are FPT. It was then natural to ask [4] whether these Π edge-modification problems also admit a polynomial size kernel. Us- ing recent lower bound techniques, Kratsch and Wahlstrom answered negatively this question [15]. However, the problem remains open on many natural graph classes char- acterized by forbidden induced subgraphs. Kratsch and Wahlstrom asked whether the result holds when the forbidden subgraphs are paths or cycles and pointed out that the 2 problem is already open in the case of P4-free graphs (i.e. cographs). In this paper, we prove that parameterized cograph edge modification problems have cubic ver- tex kernels whereas polynomial kernels are unlikely to exist for Pl-free and Cl-free edge deletion problems for large enough l. The NP-Completeness of the cograph edge-deletion and edge-completion problems have been proved in [6]. Outline of the paper. We first establish structural properties of optimal edge- modification sets with respect to modules of the input graph (Section 2). These prop- erties allow us to design general reduction rules (Section 3.1). We then establish cubic kernels using an extra sunflower rule (Section 3.2 and 3.3). Finally, we show it is un- likely that the Cl-free and the Pl-free edge-deletion problems have polynomial kernels (Section 4). 2 Preliminaries 2.1 Notations We only consider finite undirected graphs without loops nor multiple edges. Given a graph G = (V, E), we denote by xy the edge of E between the vertices x and y of V . We set n = V and m = E (subscripts will be used to avoid possible confusion). The neighbourhood of a vertex x is denoted by N (x). If S is a subset of vertices, then G[S] is the subgraph induced by S (i.e. any edge xy ∈ E between vertices x, y ∈ S belongs to EG[S]). Given a set of pairs of vertices F and a subset S ⊆ V , F [S] denotes the pairs of F with both vertices in S. Given two sets S and S(cid:48), we denote by S (cid:77) S(cid:48) their symmetric difference. 2.2 Fixed parameter complexity and kernelization We let Σ denote a finite alphabet and N the set of natural numbers. A (classical) problem Q is a subset of Σ∗, and a string x ∈ Σ∗ is an input of Q. A parameterized problem Q over Σ is a subset of Σ∗ × N. The second component of an input (x, k) of a parameterized problem is called the parameter. Given a parameterized problem Q, one can derive its unparameterized (or classical) version Q by Q = {x#1k : (x, k) ∈ Q}, where # is a symbol that does not belong to Σ. A parameterized problem Q is fixed parameter tractable (FPT for short) if there is an algorithm which given an instance (x, k) ∈ Σ∗ × N decides whether (x, k) ∈ Q in time f (k).nO(1) where f (k) is an arbitrary computable function (see [5, 8, 17]). A kernelization of a parameterized problem Q is a polynomial time algorithm K : Σ∗×N → Σ∗ × N which given an instance (x, k) ∈ Σ∗ × N outputs an instance (x(cid:48), k(cid:48)) ∈ Σ∗ × N such that 1. (x, k) ∈ Q ⇔ (x(cid:48), k(cid:48)) ∈ Q and 2. x(cid:48), k(cid:48) (cid:54) h(k) for some computable function h : N → N. The reduced instance (x(cid:48), k(cid:48)) is called a kernel and we say that Q admits a polynomial kernel if the function h() is a polynomial. It is well known that a parameterized problem Q is FPT if and only if it has a kernelization [17]. But this equivalence only yields (at 3 least) exponential size kernels. Recent results proved that it is unlikely that every fixed parameter tractable problem admits a polynomial kernel [1]. These results rely on the notion of (or-)composition algorithms for parameterized problems, which together with a polynomial kernel would imply a collapse on the polynomial hierarchy [1]. An or- composition algorithm for a parameterized problem Q is an algorithm that receives as input a sequence of instances (x1, k) . . . (xt, k) with (xi, k) ∈ Σ∗ × N for 1 (cid:54) i (cid:54) t, runs in time polynomial in(cid:80)t i=1 xi + k and outputs an instance (y, k(cid:48)) of Q such that: 1. (y, k(cid:48)) ∈ Q ⇔ (xi, k) ∈ Q for some 1 (cid:54) i (cid:54) t and 2. k(cid:48) is polynomial in k. A parameterized problem admitting an or-composition algorithm is said to be or- compositional. Theorem 2.1 [1, 9] Let Q be an or-compositional parameterized problem whose un- parameterized version Q is NP-complete. The problem Q does not admit a polynomial kernel unless N P ⊆ coN P/P oly. Let P and Q be parameterized problems. A polynomial time and parameter trans- formation from P to Q is a polynomial time computable function T : Σ∗ × N → Σ∗ × N which given an instance (x, k) ∈ Σ∗ × N outputs an instance (x(cid:48), k(cid:48)) ∈ Σ∗ × N such that 1. (x, k) ∈ P ⇔ (x(cid:48), k(cid:48)) ∈ Q and 2. k(cid:48) (cid:54) p(k) for some polynomial p. Theorem 2.2 [2] Let P and Q be parameterized problems and let P and Q be their unparameterized versions. Suppose that P is NP-complete and Q belongs to NP. If there is a polynomial time and parameter transformation from P to Q and if Q admits a polynomial kernel, then P also admits a polynomial kernel. 2.3 Modular decomposition and cographs A module in a graph G = (V, E) is a set of vertices M ⊆ V such that for any x /∈ M either M ⊆ N (x) or M ∩ N (x) = ∅. Clearly if M = V or M = 1, then M is a trivial module. A graph without any non-trivial module is called prime. For two disjoint modules M and M(cid:48), either all the vertices of M are adjacent to all the vertices of M(cid:48) or none of the vertices of M is adjacent to any vertex of M(cid:48). A partition P = {M1, . . . Mk} of the vertex set V (G) whose parts are modules is a modular partition. A quotient graph G/P is associated with any modular partition P: its vertices are the parts of P and there is an edge between Mi and Mj iff Mi and Mj are adjacent in G. A module M is strong if for any module M(cid:48) distinct from M , either M ∩ M(cid:48) = ∅ or M ⊂ M(cid:48) or M(cid:48) ⊂ M . It is clear from definition that the family of strong modules ar- ranges in an inclusion tree, called the modular decomposition tree and denoted M D(G). Each node N of M D(G) is associated with a quotient graph GN whose vertices corre- spond to the children N1, . . . Nk of N . (see Figure 1 for an example). We say that a node N of M D(G) is parallel if GN has no edge, series if GN is complete, and prime otherwise. For a survey on modular decomposition theory, refer to [12]. 4 Figure 1: A graph G and its modular decomposition tree M D(G). The root of M D(G) is prime and its quotient graph is the 5 vertex graph depicted eside. Every other node is either parallel or series. Definition 2.3 Let G1 = (V1, E1) and G2 = (V2, E2) be two vertex disjoint graphs. The series composition of G1 and G2 is the graph G1 ⊗ G2 = (V1 ∪ V2, E1 ∪ E2 ∪ V1 × V2). The parallel composition of G1 and G2 is the graph G1 ⊕ G2 = (V1 ∪ V2, E1 ∪ E2) Parallel and series nodes in the modular decomposition tree respectively correspond to a parallel and series composition of their children. Cographs are commonly known as P4-free graphs (a P4 is an induced path on four vertices). However, they were originally defined as follows: Definition 2.4 ([3]) A graph is a cograph if it can be constructed from single vertex graphs by a sequence of parallel and series composition. In particular, this means that the modular decomposition tree of a cograph does It follows that cographs are also known as the totally not contain any prime node. decomposable graphs for the modular decomposition. 3 Polynomial kernels for cograph modification problems 3.1 Modular decomposition based reduction rules Since cographs correspond to P4-free graphs, cograph edge-modification problems con- sist in adding or deleting at most k edges to the input graph in order to make it P4-free. The use of the modular decomposition tree in our algorithms follows from the following observation: Observation 3.1 [Folklore] Let M be a module of a graph G = (V, E) and {a, b, c, d} be four vertices inducing a P4 of G, then M ∩ {a, b, c, d} (cid:54) 1 or {a, b, c, d} ⊆ M . This means that given a modular partition P of a graph G, any induced P4 of G is either contained in a part of P or intersects the parts of P in at most one vertex. This observation allows us to show that a cograph edge-modification problem can be solved independently on modules of the partition P and on the quotient graph G/P , as stated by the following results: 5 1 2 3 4 5 6 7 8 9 10 11 123456789101119852436711108 9 10 112 32 3 46 710 11 Observation 3.2 Let M be a non-trivial module of a graph G = (V, E). Let FM be an optimal edge-deletion (resp. edge-completion, edge-edition) set of G[M ] and let Fopt be an optimal edge-deletion (resp. edge-completion, edge-edition) set of G. Then F = (Fopt \ Fopt[M ]) ∪ FM is an optimal edge-deletion (resp. edge-completion, edge-edition) set of G. Proof: By Observation 3.1, it follows that H = (V, E (cid:77) F ) is P4-free, thereby F is an edge-deletion set. As being a cograph is an hereditary property, Fopt[M ] is an edge- deletion set of G[M ]. Now observe that F = Fopt since otherwise FM > Fopt[M ], which would contradict the optimality of FM . The same argument holds for edge- (cid:3) completion and edge-edition sets. Lemma 3.3 Let M be a module of a graph G = (V, E). There exists an optimal edge- deletion (resp. edge-completion, edge-edition) set F such that M is a module of the cograph H = (V, E (cid:77) F ). Proof: Let Fopt be an optimal edge-deletion set and denote Hopt = (V, E (cid:77) Fopt). Let x be a vertex of M such that {xy ∈ F : y /∈ M} is minimum. We argue that the following set of edges is an optimal edge-deletion set: F = Fopt[M ] ∪ Fopt[V \ M ] ∪ {zy : z ∈ M, y /∈ M, xy ∈ Fopt} First observe that by construction M is a module in the graph H = (V, E (cid:77) F ) and that by the choice of x, F (cid:54) Fopt. Let us prove that H is P4-free. As H[M ] and H[V \ M ] are respectively isomorphic to Hopt[M ] and Hopt[V \ M ], they are P4-free. So if H contains an induced P4, its vertices {a, b, c, d} intersect M and V \ M . As M is a module of H it follows by Observation 3.1 that M ∩ {a, b, c, d} = 1 (say a ∈ M ∩ {a, b, c, d}). It follows by construction of F , that {x, b, c, d} also induces a P4 in Hopt, contradicting the assumption that Fopt is an edge-deletion set. So we proved that F is an edge-deletion set of G which preserves the module M and is not larger (cid:3) than Fopt. The same proof holds for edge-completion and edge-edition sets. Lemma 3.4 Let G = (V, E) be an arbitrary graph. There exists an optimal edge- deletion (resp. edge-completion, edge-edition) set F such that every module M of G is module of the cograph H = (V, E (cid:77) F ). Proof: We prove the statement for edge-deletion sets by induction on the number of modules of a graph. The same proof applies for edge-completion and edge-edition sets. Observe that the result trivially holds if G is a prime graph and follows from Lemma 3.3 if G contains a unique non-trivial module. Let us now assume that the property holds for every graph with at most t non-trivial modules. Let G be a graph with t + 1 non-trivial modules and let M be a non-trivial module of G which is minimal for inclusion. By induction hypothesis, the statement holds on G[M ] (since it is prime) and on the graph GM→x where M has been contracted to a single vertex x (since it contains at most t non-trivial modules). The conclusion (cid:3) follows from Observation 3.2. 6 We now present three reduction rules which apply to the three cograph edge- modification problems we consider. The second reduction rule is not required to obtain a polynomial kernel for each of these problems. However, it will ease the analysis of the structure of a reduced graph. Rule 1 Remove the connected components of G which are cographs. Rule 2 If C = G1 ⊗ G2 is a connected component of G, then replace C by G1 ⊕ G2. Rule 3 If M is a non-trivial module of G which is strictly contained in a connected component and is not an independent set of size at most k + 1, then return the graph G(cid:48) ⊕ G[M ] where G(cid:48) is obtained from G by replacing M by an independent set module of size min{M, k + 1}. Observe that if G[M ] is a cograph, adding a disjoint copy to the graph is useless since it will then be removed by Rule 1. Lemma 3.5 The reduction rules 1, 2 and 3 are safe and can be carried out in linear time. Proof: The three rules can be computed in linear time using any linear time modular decomposition algorithm [12]. The first rule is trivially safe. The second rule is safe by Lemma 3.4. The safeness of Rule 3 also follows from Lemma 3.4: there always exists an optimal solution that updates all or none of the edges between any two disjoint modules. Thereby if a module M has size larger than k + 1, none of the edges (or non-edges) xy with x ∈ M , y /∈ M can be changed in such a solution. Shrinking M into an independent set of size k + 1 and adding a disjoint copy of G[M ] (to keep track (cid:3) of the edge modification inside the module) is thereby safe. The analysis of the size of the kernel relies on the following structural property of the modular decomposition tree of an instance reduced under Rule 1, Rule 2 and Rule 3. Observation 3.6 Let G be a graph reduced under Rule 1, Rule 2 and Rule 3. If C is a non prime connected component of G, then the modules of C are independent sets of size at most k + 1. Proof: By Rule 2, none of the connected components of G results from a series com- position. By Rule 3, a module which is not the union of some connected components of (cid:3) G has size at most k + 1 and is an independent set. Observe that these three reduction rules preserve the parameter. However, Rule 3 increases the number of vertices of the instance. Nevertheless, we will be able to bound the number of vertices of a reduced instance. It remains to show that computing a reduced graph requires polynomial time. Let us mention that it is safe to apply Rule 2 and Rule 3 only on strong modules (in Rule 2, G1 can be chosen as a strong module). 7 Lemma 3.7 Given a graph G = (V, E), computing a graph reduced under Rule 1, Rule 2 and Rule 3 requires polynomial time. Let us say that a module M of G is reduced if it is an independent set of Proof: size at most k + 1 or the disjoint union of some connected components of G (observe that connected components of G are also modules of G). By Observation 3.6, if G is reduced under Rule 1, Rule 2 and Rule 3, then every module of G is reduced. Notice that if every strong module of G is reduced, then every module of G is reduced. So to prove the statement, we count the number of strong modules (i.e. nodes of the modular decomposition tree M D(G)) which are not reduced. Let us also remark that if a connected component C is a cograph with at least two vertices, then a series of applications of Rule 2 eventually transforms C in a set of isolated vertices. This means that we can assume that the applications of Rule 1 is postponed to the end of the reduction process. This will ease the argument below. When Rule 3 is applied, then by definition the number of non-reduced strong mod- ules decreases by one. When Rule 2 is applied, unless G1 is an independent set of size at most k + 1, then the number of non-reduced strong modules also decreases by one. But observe that if G1 is an independent set of size at most k + 1, then its vertices will be removed by Rule 1 as they will become isolated vertices. As the number of strong modules of a graph is bounded by the number of vertices, this proves that a series of at (cid:3) most n applications of Rule 2 and Rule 3 is enough to compute a reduced graph. 3.2 Cograph edge-deletion (and edge-completion) In addition to the previous reduction rules, we need the classical sunflower rule to obtain a polynomial kernel for the parameterized cograph edge-deletion problem. Rule 4 If e is an edge of G that belongs to a set P of at least k + 1 P4's such that e is the only common edge of any two distinct P4's of P, then remove e and decrease k by one. Observation 3.8 The reduction rule 4 is safe and can be carried out in polynomial time. Proof: It is clear that the edge e has to be deleted as otherwise at least k + 1 edge deletions would be required to break all the P4's of the set P. Such an edge, if it exists, can be found in polynomial time if one computes the set of all P4's of the input graph (cid:3) (which can be done in O(n4) time). To analyse the size of a reduced graph G = (V, E), we study the structure of the cograph H = (V, E (cid:77) F ) resulting from the removal of an optimal (of size at most k) edge-deletion set F . The modular decomposition tree (or cotree) is the appropriate tool for this analysis. 8 Theorem 3.9 The parameterized cograph edge-deletion problem admits a cubic vertex kernel. Proof: Let G = (V, E) be a graph reduced under Rule 1, Rule 2, Rule 3 and Rule 4 that can be turned into a cograph by deleting at most k edges. Let F be an optimal edge-deletion set and denote by H = (V, E (cid:77) F ) the cograph resulting from the deletion of F and by T its cotree. We will count the number of leaves of T (or equivalently of vertices of G and H). Observe that since a set of k edges covers at most 2k vertices, T contains at most 2k affected leaves (i.e. leaves corresponding to a vertex incident to a removed edge). We say that an internal node of the cotree T is affected if it is the least common ancestor of two affected leaves. Notice that there are at most 2k affected nodes. We first argue that the root of T is a parallel node and is affected. Assume that the root of T is a series node: since no edges are added to G, this would imply that G is not reduced under Rule 2, a contradiction. Moreover, since G is reduced under Rule 1, none of its connected components is a cograph. It follows that every connected component of G contains a vertex incident to a removed edge, and thus that every subtree attached to the root contains an affected leaf as a descendant. Hence the root of T is an affected node. Claim 3.10 Let p be an affected leaf or an affected node different from the root, and q be the least affected ancestor of p. The path between p and q has length at most 2k + 3. Proof. Observe first that the result trivially holds if q is the root of T and p one of its children. In all other cases, let M be the set of leaves descendant of p in T . We claim that M contains a leaf x which is incident to a removed edge xy, with y /∈ M . If p is an affected leaf then this is true by definition. Otherwise, if p is an affected node different from the root, assume by contradiction that all the removed edges in M are of the form uv with u, v ∈ M . In particular, this implies that M is a module of G strictly contained in a connected component. By Observation 3.6, it follows that M is an independent set and hence contains no edges, a contradiction. Let t be the least common ancestor of x and y. The node t is a parallel node which is an ancestor of p and q (observe that we may have t = q). Assume by contradiction that the path between x and t in T contains a sequence of 2k + 3 consecutive non-affected nodes. The type of these nodes is alternatively series and parallel. So we can find a sequence s1, p1 . . . sk+1, pk+1 of consecutive non-affected nodes with si (resp. pi) being the father of pi (resp. si+1) and with si's being series nodes and the pi's being parallel node. Now each of the si's (resp. pi) has a non-affected leaf ai (resp. bi) which is not a descendant of pi (resp. si+1). Observe that for every i ∈ [1, k + 1] the vertex set {bi, ai, x, y} induces a P4 in G. Thereby we found a set of k + 1 P4's in G pairwise intersecting on the edge xy. It follows that G is not reduced by the Rule 4: contradiction. This implies that the path (cid:5) between p and q contains at most 2k + 3 non-affected nodes. Since there are at most 2k affected nodes and 2k affected leaves, T contains at most (4k− 1)(2k + 3) + 2k internal nodes. As G is reduced, Observation 3.6 implies that each of these O(k2) nodes is attached to a set of at most k + 1 leaves or a parallel node with k + 1 children. It follows that T contains at most 2k + (k + 1)[(4k − 1)(2k + 3) + 2k] (cid:54) 8k3 + 20k2 + 11k leaves, which correspond to the number of vertices of G. 9 We now conclude with the time complexity needed to compute the kernel. Since the application of Rule 4 decreases the value of the parameter (which is not changed by the other rules), Rule 4 is applied at most k (cid:54) n2 times. It then follows from Lemma 3.7 (cid:3) that a reduced instance can be computed in polynomial time. The following corollary simply follows from the observation that the family of cographs is closed under complementation (since the complement of a P4 is a P4). Corollary 3.11 The parameterized cograph edge-completion problem admits a cubic vertex kernel. 3.3 Cograph edge-edition The lines of the proof for the cubic kernel of the edge-edition problem are essentially the same as for the edge-deletion problem. But since edges can be added and deleted, the reduction Rule 4 has to be refined in order to avoid that a single edge addition breaks an arbitrary large set of P4's. Rule 5 If {x, y} is a pair of vertices of G that belongs to a set S of t (cid:62) k +1 quadruples Pi = {x, y, ai, bi} such that for 1 (cid:54) i (cid:54) t, every Pi induces a P4 and for any 1 (cid:54) i < j (cid:54) t, Pi ∩ Pj = {x, y}, then change E into E (cid:77) {xy} and decrease k by one. As for reduction Rule 4, it is clear that reduction Rule 5 is safe and can be applied in polynomial time. The kernelization algorithm of cograph edge-edition consists of an exhaustive application of Rules 1, 2, 3 and 5. Theorem 3.12 The parameterized cograph edge-edition problem has a cubic vertex ker- nel. Proof: Let G = (V, E) be a graph reduced under Rule 1, Rule 2, Rule 3 and Rule 5 that can be turned into a cograph by editing at most k edges. Let H be the cograph obtained by an optimal edge-edition. The cotree of H is denoted by T . Unlike in the edge-deletion problem, the root of T is not necessary a parallel node. However it is still true that the root of T is affected. Indeed, assume first that the root of T is a series node. Then it is affected since otherwise G would not be reduced under Rule 2. Now, assume that the root is a non affected parallel node. This means that at most one of its children contains an affected leaf as descendant, and hence that G is not reduced under Rule 1: contradiction. In the following we assume w.l.o.g. that the root of T is a parallel node. We prove that Claim 3.10 still holds in this case. Let p be an affected leaf or an affected node different from the root, and q be the least affected ancestor of p. Observe that the result is trivially true if q is the root of T and p one of its children. In all other cases, let M be the set of leaves descendant of p in T . As in the proof of Theorem 3.9, there must exist an edited edge xy with x ∈ M, y /∈ M (otherwise M would be a module of G, i.e. an independent set by Observation 3.6 and would thus not be edited by Observation 3.2). Now the proof follows the arguments of the proof of Theorem 3.9, if one can find in T a path of 2k + 3 consecutive non-affected nodes between p and q, then G is not reduced under Rule 5. Proving that T contains O(k2) nodes and thereby O(k3) leaves. 10 The fact that a reduced instance can be computed in polynomial time follows from Lemma 3.7 and the observation that Rule 5 decreases the value of the parameter and (cid:3) requires polynomial time. For the deletion (resp. edition) problem there exists a graph reduced under Rule 1, Rule 2, Rule 3 and Rule 4 (resp. Rule 5) that achieves the cubic bound (see Figure 2). Figure 2: A reduced graph G with k(k + 1)2 + k vertices for which k edge deletions, namely the xiyi's for i ∈ [1, k], are required to obtain a cograph H. The cotree T of H is represented. Each parallel node of T which is not the root has k + 2 children, k + 1 of which are leaves. The root of T has 2k children. 4 Kernel lower bounds for Pl-free edge-deletion problems In [15], Kratsch and Wahlstrom show that the Not-1-in-3-sat problem has no poly- nomial kernelization under a complexity-theoretic assumption (N P (cid:42) coN P/poly). We observe that their argument still applies to a graph restriction of Not-1-in-3-sat where the constraints arise from the triangles of an input graph. 4.1 A graphic version of the Not-1-in-3-sat problem For a graph G = (V, E), an edge-bicoloring is a function B : E → {0, 1}. A partial edge-bicoloring of G is an edge-bicoloring of a subset of edges of E. An edge colored 1 (resp. 0) is called a 1-edge (resp. 0-edge). We say that the edge-bicoloring B(cid:48) extends a partial edge-bicoloring B if for every e ∈ E colored by B, then B(e) = B(cid:48)(e). The weight of an edge-bicoloring is the number ω(B) of 1-edges. An edge-bicoloring is valid if every triangle of G contains either zero, two or three 1-edges. We consider the following problem: 11 kS//S////SS//S////SS//S////S//yyxxx1y2k12kaaabbb12k12 Not-1-in-3-edge-triangle Input: An undirected graph G = (V, E) and a partial edge-bicoloring B : E → {0, 1}. Parameter: An integer k ∈ N. Question: Can we extend B to a valid edge-bicoloring B(cid:48) of weight at most k? Proposition 4.1 Not-1-in-3-edge-triangle is NP-complete and or-compositional. Proof: The NP-hardness follows from a reduction from Vertex Cover. Let (G, k) be an instance of Vertex Cover [10], where G = (V, E). We create an instance (G(cid:48), B, k(cid:48)) of Not-1-in-3-edge-triangle as follows. The graph G(cid:48) is obtained from G by adding a dominating vertex q, the partial edge-bicoloring B is such that B(e) = 1 for every e ∈ E, and we let k(cid:48) = E + k. As the triangles of G are monochromatic, the constraints to obtain a valid extension of B are carried by the triangles of the form quv with uv ∈ E. It is easy to observe that (G(cid:48), B, k(cid:48)) has a valid edge-bicoloring extension of weight k(cid:48) iff G has a vertex cover of size k. As Not-1-in-3-edge-triangle clearly belongs to NP, the NP-completeness follows. We now show that Not-1-in-3-edge-triangle is or-compositional. The proof closely follows the proof of [15] for Not-1-in-3-sat. We first need the following result: Claim 4.2 Given an instance (G, B, k) of Not-1-in-3-edge-triangle, and two pos- itive integers r and k(cid:48) such that k(cid:48) ≥ k +r, we can compute in polynomial time an equiv- alent instance (G(cid:48), B(cid:48), k(cid:48)) of Not-1-in-3-edge-triangle such that ω(B(cid:48)) = ω(B) + r. Proof. To build G(cid:48), we first add to G a set F of r new isolated edges e1 . . . er such that B(cid:48)(ei) = 1 for all i ∈ [r]. Then we add to the resulting graph k(cid:48) − (k + r) gadgets as follows: let ej = ujvj (with j ∈ [k(cid:48) − (k + r)]) be an arbitrary 1-edge of G; add the triangles ujvjxj, vjxjyj with B(cid:48)(vjyj) = B(cid:48)(xjyj) = 0. The edges ej's are not necessar- ily distinct. Observe that in any valid edge-bicoloring of G(cid:48) extending B(cid:48), the edge vjxj (for every j ∈ [k(cid:48) − (k + r)]) is a 0-edge while the edge ujxj is a 1-edge. It follows that (G, B, k) is a positive instance if and only if (G(cid:48), B(cid:48), k(cid:48)) is a positive instance as the set (cid:5) F increases the weight by r and the added triangles by k(cid:48) − (k + r). Consider a sequence (G1, B1, k) . . . (Gt, Bt, k) of instances of Not-1-in-3-edge- triangle. We denote by E1(j) the set of 1-edges of (Gj, Bj, k). By Claim 4.2, we can assume w.l.o.g. that E1(j) = s (cid:54) k, for 1 (cid:54) j (cid:54) t. We can also assume that t (cid:54) 3k since otherwise an exact branching algorithm could solve the problem. Moreover, for the sake of the construction, we assume t = 2l (duplicating some instance (Gi, Bi, k) if necessary). Intuitively, the graph G of the composed instance (G, B, k(cid:48)) is built on the disjoint union of the Gj's, 1 (cid:54) j (cid:54) t. Then, as a selection gadget, we add a "tree-like graph" T connecting a "root edge" r to edges ej for j = 1, ..., t. Finally, for every 1 (cid:54) j (cid:54) t, the 1-edges of the graph Gj are connected via a propagation gadget to the edge ej in T . The root edge is the unique 1-edge of G. The copies of the Gj's inherit the 0-edges of the Gj's. The idea is that the selection gadget guarantees that at least one of the ej's edge gets colored 1. Then the propagation gadgets attached to that edge ej transmit color 1 to the copies of every 1-edge of Gj. 12 Formally, we do the following: (i) we start with a complete binary tree T0 with t leaves; (ii) to each node u of T0, we associate an edge eu in T as follows: if u is associated to the edge xy and if u has two children v, v(cid:48), we create a new vertex z and we let ev = xz, ev(cid:48) = yz. The leaves of T0 are then associated to edges e1, ..., et. Now, for every 1 (cid:54) j (cid:54) t, the propagation gadget Sj consists of vertex-disjoint graphs Sj,e for every edge e of E1(j). If e = uv and ej = xy, then Sj,e consists of four triangles uva, vab, abx, bxy, with edges ua, vb, ax, by colored 0 by B (the other edges remain uncolored). Again the unique 1-edge of B is the root edge of T , in particular the edges of the E1(j) are uncolored by B. However, the 0-edge sets of the Gj's are inherited by B. (see Figure 3) Figure 3: The instance (G, B, k(cid:48)) built from a sequence (G1, B1, k), . . . , (Gt, Bt, k) with t = 23. The unique 1-edge is r. Every "leaf edge" ej of T is linked to the copies of the 1-edges of (Gj, Bj, k) via the propagation gadget. The 0-edges are depicted as dotted lines: they either belong to a propagation gadget or correspond to a 0-edge of some (Gj, Bj, k). Observe first that every valid edge-bicoloring extending B has to assign color 1 to at least one edge ej, for 1 (cid:54) j (cid:54) t. Then the edges of E1(j) and the 3s non 0-edges of Sj are also assigned color 1. It follows that if we choose k(cid:48) = k + 3s + l, then (G, B, k(cid:48)) is a positive instance if and only if there exists 1 (cid:54) j (cid:54) t such that (Gj, Bj, k) is a positive (cid:3) instance. The following corollary follows from Theorem 2.1: Corollary 4.3 The Not-1-in-3-edge-triangle problem does not admit a polynomial kernel unless N P ⊆ coN P/poly. The problem Tripartite-Not-1-in-3-edge-triangle is the restriction of Not- 1-in-3-edge-triangle where the input graph G is 3-colorable. The hardness results obtained for Not-1-in-3-edge-triangle carry over to this restriction: 13 Treeeeeeee12345678GGGGGGGG12345678 Lemma 4.4 The Tripartite-Not-1-in-3-edge-triangle problem does not admit a polynomial kernel unless N P ⊆ coN P/poly. The proof uses Theorem 2.2, that is we provide a polynomial parameter- Proof: preserving transformation from Not-1-in-3-edge-triangle to Tripartite-Not-1- in-3-edge-triangle. By Proposition 4.1, Not-1-in-3-edge-triangle is NP-complete. Observe that Tripartite-Not-1-in-3-edge-triangle clearly belongs to NP. Let (G, B, k) be an instance of Not-1-in-3-edge-triangle. We build an instance (G(cid:48), B(cid:48), 6k) of Tripartite-Not-1-in-3-edge-triangle in the following way. Suppose that G = (V, E), then G(cid:48) has vertex set V (cid:48) = {v1, v2, v3 : v ∈ V }, and has edge set E(cid:48) = {u1v2, u1v3, u2v3 : u = v or uv ∈ E}. The partial edge-bicoloring B(cid:48) is defined as follows: B(cid:48)(uiuj) = 0 for 1 (cid:54) i < j (cid:54) 3; if the edge uv of G is colored, then B(cid:48)(uivj) = B(uv) for 1 (cid:54) i, j (cid:54) 3; the other edges of G(cid:48) are uncolored. Observe that every valid edge-bicoloring extending B(cid:48) assigns the same color to the six edges of G(cid:48) associated with an edge uv of G: indeed, given uivj, ukvl 1 (cid:54) i, j, k, l (cid:54) 3, if i = j this holds since B(cid:48)(vkvl) = 0, if k = l this holds since B(cid:48)(uiuj) = 0, and otherwise this follows by transitivity. It is then easy to see that solutions of (G, B, k) and solutions of (G(cid:48), B(cid:48), 6k) are in one-to-one correspondence. (cid:3) 4.2 Negative results for Γ-free edge deletion problems In this section, we show that unless N P ⊆ coN P/poly, the Cl-free edge-deletion and the Pl-free edge-deletion problems have no polynomial kernel for large enough l ∈ N. To that aim, we provide polynomial time and parameter transformations from Tripartite-Not-1-in-3-edge-triangle to the Annotated Cl-free edge- deletion problem and to the Annotated Pl-free edge-deletion problem. For a graph Γ, the Annotated Γ-free edge-deletion problem is defined as follows: Annotated Γ-free edge-deletion Input: An undirected graph G = (V, E) and a subset S of vertices. Parameter: An integer k ∈ N. Question: Is there a subset F ⊆ E ∩ (S × S) such that H = (V, E \ F ) is Γ-free? Observe that the Annotated Γ-free edge-deletion problem reduces to the (unannotated) Γ-free edge-deletion problem whenever Γ is closed under twin addi- tion: it suffices to add for every vertex v ∈ V \ S a set of k + 1 twin vertices. Clearly this transformation also preserves the parameter. Observe also that we can restrict the Tripartite-Not-1-in-3-edge-triangle problem to instances (G, B, k) not containing any 0-edge (i.e. B(e) = 1 whenever it is defined). The reason is that any uncolored edge e = uw of G can be forced to be assigned color 0 in every valid edge-bicoloring extending B by adding to G k + 1 new vertices v1, . . . , vk such that uviw, 1 (cid:54) i (cid:54) k, is an uncolored triangle. Clearly if e is a 1-edge of an edge-bicoloring B(cid:48) extending B, B(cid:48) needs at least k + 1 1-edges to be valid: e plus one edge per triangle. The same argument was used in [15] for the Not-1-in-3-sat problem. 14 Theorem 4.5 The Cl-free edge-deletion problem has no polynomial kernel for any l (cid:62) 12, unless N P ⊆ coN P/poly. Proof: We describe a polynomial time and parameter transformation from the re- striction of Tripartite-Not-1-in-3-edge-triangle without 0-edges to Annotated Cl-free edge-deletion. The statement then follows from Theorem 2.2 and the fact that Annotated Cl-free edge-deletion reduces to Cl-free edge-deletion. Let (G, B, k) be an instance of the Tripartite-Not-1-in-3-edge-triangle prob- lem, where V1, V2, V3 are disjoint independent sets of G = (V, E). The construction of the instance (H, S, k(cid:48)) of Annotated Cl-free edge-deletion works as follows. First the sets V1, V2 and V3 are turned into cliques and the 1-edges of G are removed. In ad- dition to V , the graph H contains a set U of new vertices. For each pair t = (e, v) with e = uw an edge of G and v a vertex of G, such that {u, v, w} induces a triangle in G, we create a path Pt of length l− 1 between u and w in H (the internal vertices of Pt are added to U ). Notice that each triangle of G generates three such paths in H. It remains to add some safety edges incident to the vertices of U . Every two vertices x and y of U that do not belong to the same path are made adjacent. In every path Pt, we select an internal vertex ct, called its centre, at distance (l − 1)/2 from u. Every centre vertex ct is made adjacent to V \ {u, v, w}. We denote by H = (VH , EH ) the resulting graph. To complete the description of (H, S, k(cid:48)) we set S = V and the parameter k(cid:48) = k − k1 where k1 is the number of 1-edges of (G, B, k). Figure 4: The graph H = (VH , EH ) built from an instance (G, B, k) of the Tripartite- Not-1-in-3-edge-triangle problem for l = 12. The white and the square vertices form the set U of new vertices. The independent sets V1, V2 and V3 of G are turned into cliques. The thick dotted edges are the removed 1-edges of (G, B, k). The non 1-edges of (G, B, k) are preserved in H. Claim 4.6 A subset of vertices C ∈ VH induces a cycle of length l iff G contains a triangle uvw, with e = uw a 1-edge and uv, vw uncolored edges, such that C = Pt ∪{v} with t = (e, v). 15 3vwuPtctPPt't"111VVV21 Proof. By construction, if G contains a triangle uvw with a unique 1-edge e = uw, then C = Pt ∪ {v} (with t = (e, v)) induces a cycle of length l in H (keep in mind that the 1-edges of G are removed from H). Let C be an induced Cl in H. Observe that as V1, V2 and V3 are turned into cliques, C ∩ V (cid:54) 6. Thereby C intersects the vertex set U . We now argue that there exists a path Pt, with t = (e, v) and e = uw, containing the vertices of C ∩ U . Otherwise, since every pair of vertices of U belonging to two distinct paths Pt and Pt(cid:48) (with t (cid:54)= t(cid:48)) are adjacent, we would have C ∩ U (cid:54) 4 and thus C (cid:54) 4 + 6 < l. It follows that u or w belongs to C. We prove that they both belong to C. Assume w /∈ C, then C uses a safety edge incident to the centre vertex ct and half of the internal vertices of Pt does not belong to C. Thereby C (cid:54) 6 + (l − 3)/2 + 1: contradiction with the hypothesis l (cid:62) 12. Finally as Pt contains l − 1 vertices, C con- tains an extra vertex and uw are not adjacent. As ct is adjacent to every vertex of V except u, v and w, we have that C = Pt ∩ {v} as announced and uv, wv ∈ EH . Now the existence of Pt witnesses the existence of the triangle uvw in G. As uv, wv ∈ EH and uw /∈ EH , uw is the only 1-edge of the triangle uvw. (cid:5) We now argue for the correctness of the transformation. Suppose that there exists a set F of allowed edges of size at most k(cid:48) such that H(cid:48) = (VH , EH \ F ) is Cl-free. Define the edge-bicoloring B(cid:48) of E as follows: B(cid:48)(e) = 1 if e ∈ F , B(cid:48)(e) = 0 otherwise. As by assumption B does not assign color 0 to any edge, B(cid:48) extends B and has weight at most F + k1 (cid:54) k(cid:48) + k1 = k. Besides, B(cid:48) is a valid edge-bicoloring of G. Let t = (e, v) with e = uw be a pair such that {u, v, w} induces a triangle in G. If we had B(uw) = 1, B(cid:48)(uv) = B(cid:48)(vw) = 0, we would obtain that Pt ∪ {v} induces a Cl in H(cid:48), impossible. Conversely, suppose that B(cid:48) is valid edge-bicoloring of weight at most k of G which extends B. Let F ⊆ E be the set of edges such that B(cid:48)(e) = 1 but are uncolored by B. By construction F is a set of allowed edges of H of size at most k − k1. Since B(cid:48) is a valid edge-bicoloring of G, Claim 4.6 implies that H(cid:48) = (VH , EH\F ) is Cl-free. (cid:3) A slight modification of the above construction yields the following: Theorem 4.7 The Pl-free edge-deletion problem has no polynomial kernel for any l (cid:62) 13, unless N P ⊆ coN P/poly. Proof: Let (G, B, k) be an instance of the Tripartite-Not-1-in-3-edge-triangle problem not containing any 0-edge and such that V1, V2, V3 are disjoint independent sets of G = (V, E). We modify the construction given in Theorem 4.5 to obtain an instance (H, S, k(cid:48)) of Annotated Pl-free edge-deletion problem. The vertex set VH of H consists of the union of V and a set U of new vertices. The sets V1, V2 and V3 are again turned into cliques and the 1-edges of E are not duplicated in EH . But for each pair t = (e, v), with e = uw ∈ E and v ∈ V such that {u, v, w} is a triangle of G, the associated gadget Qt is no longer a path. Instead, Qt consist of two paths Qu t and Qw t : Qu is a path of length t 2(l − 1)/3 containing w as extremity. The vertices of Qt \ {u, w} are added to U . As before for every t (cid:54)= t(cid:48) we add all the edges between vertices of Qt and Qt(cid:48). The centre t at distance (l − 1)/3 from w. The centre vertex is vertex ct of Qt is the vertex of Qw made adjacent to every vertex of V except u, v and w. To complete the description of (H, S, k(cid:48)) we set S = V and k(cid:48) = k − k1 where k1 is the number of 1-edges of (G, B, k). is a path of length (l − 1)/3 containing u as extremity and Qw t 16 The correctness proof of the construction follows the same lines than the proof of It now relies on the following claim that characterizes the possible Proposition 4.5. induced Pl's. Claim 4.8 A subset of vertices Q ∈ VH induces a path of length l iff G contains a triangle uvw, with e = uw a 1-edge and uv, vw uncolored edges, such that Q = Qt ∪{v} with t = (e, v). Proof. By construction, if G contains a triangle uvw with a unique 1-edge e = uw, then Q = Qt ∪ {v} (with t = (e, v)) induces a path of length l in H (keep in mind that the 1-edges of G are removed from H). Let Q be an induced Pl in H. As in the proof of Claim 4.6, observe that Q ∩ V (cid:54) 6 and thereby Q intersects the vertex set U and that there exists a unique pair t = (e, v) with e = uw such that Qt contains Q ∩ U . By the choice of the length of Qu t . It follows that u and w belongs to Q. Assume that Q uses an edge xct such that x /∈ Qt. Then half of the vertices of Qw t does not belong to Q, which would contradict the hypothesis l (cid:62) 13. Finally as by construction Qt contains l − 1 vertices, we need at least one extra vertex from V . Since ct is adjacent to all vertices of V except u, v and v, that extra vertex can only be v. Moreover the chord uw cannot exist in H, meaning that uw is a (cid:3) 1-edge of (G, B, k). t , Q ∩ U intersects both Qu t and Qw t and Qw 5 Conclusion In this paper we have shown that the parameterized cograph edge modification problems admit vertex cubic kernels. Moreover, we provide evidence that the Cl-free edge-deletion and the Pl-free edge-deletion problems do not admit polynomial kernels for large enough l (under a complexity-theoretic assumption [1]). These problems were left open by Kratsch and Wahlstrom in [15]. The value of l being respectively (at least) 12 and 13, one remaining question is thus to determine whether the Cp-free edge-deletion and the Pp-free edge-deletion problems admit polynomial kernels for 4 (cid:54) p < 12 in the former case, and 4 < p < 13 in the latter. References [1] H. Bodlaender, R. Downey, M. Fellows, and D. Hermelin. On problems without polynomial kernels. In ICALP, number 5125 in LNCS, pages 563–574, 2008. [2] H. L. Bodlaender, S. Thomass´e, and A. Yeo. Kernel bounds for disjoint cycles and disjoint paths. In ESA, volume 5757 of LNCS, pages 635–646, 2009. [3] A. Brandstadt, V. B. Le, and J. P. Spinrad. Graph Classes: A Survey. SIAM Monographs on Discrete Mathematics and Applications. 1999. [4] L. Cai. Fixed-parameter tractability of graph modification problems for hereditary properties. Information Processing Letters, 58(4):171–176, 1996. [5] R. Downey and M. Fellows. Parameterized complexity. Springer, 1999. 17 [6] E. S. El-Mallah and C. Colbourn. The complexity of some edge deletion problems. IEEE Transactions on Circuits and Systems, 35(3):354–362, 1988. [7] M. Fellows, M. Langston, F. Rosamond, and P. Shaw. Efficient parameterized preprocessing for cluster editing. In Fundamentals of Computation Theory, 16th International Symposium, (FCT), number 4639 in LNCS, pages 312–321, 2007. [8] J. Flum and M. Grohe. Parameterized complexity theorey. Texts in Theoretical Computer Science. Springer, 2006. [9] L. Fortnow and R. Santhanam. Infeasibility of instance compression and succinct PCPs for NP. In STOC, pages 133–142, 2008. [10] M. Garey and S. Johnson. Computers and intractability: a guide to the theory of NP-completeness. Freeman, 1978. [11] M. Golumbic, H. Kaplan, and R. Shamir. Graph sandwich problems. Journal of Algorithms, 19:449–473, 1995. [12] M. Habib and C. Paul. A survey on algorithmic aspects of modular decomposition. Computer Science Review, 4(1):41–59, 2010. [13] P. Heggernes, C. Paul, J. A. Telle, and Y. Villanger. Interval completion with few edges. In STOC, pages 374–381, 2007. [14] C. Kenyon-Mathieu and W. Schudy. How to rank with few errors. In Annual ACM Symposium on Theory of Computing (STOC), pages 95–103, 2007. [15] S. Kratsch and M. Wahlstrom. Two edge modification problems without polynomial kernels. In IWPEC, volume 5917 of LNCS, pages 264–275, 2009. [16] A. Natanzon, R. Shamir, and R. Sharan. Complexity classification of some edge modification problems. Discrete Applied Mathematics, 113(1):109 – 128, 2001. [17] R. Niedermeier. Invitation to fixed parameter algorithms, volume 31 of Oxford Lectures Series in Mathematics and its Applications. Oxford University Press, 2006. [18] R. Niedermeier and P. Rossmanith. A general method to speed up fixed-parameter- tractable algorithms. Information Processing Letters, 73(3-4):125–129, 2000. [19] D. Rose. A graph-theoretic study of the numerical solution of sparse positive systems of linear equations. Graph Theory and Computing, pages 183–217, 1972. [20] R. Shamir, R. Sharan, and D. Tsur. Cluster graph modification problems. Discrete Applied Mathematics, 144(1-2):173–182, 2004. [21] R. Tarjan and M. Yannakakis. Simple linear-time algorithms to test chordality of graphs, test acyclicity of hypergraphs, and selectively reduce acyclic hypergraphs. SIAM journal of Computing, 13:566–579, 1984. [22] A. van Zuylen and D. Williamson. Deterministic algorithms for rank aggragation In WAOA, volume 4927 of LNCS, and other ranking and clustering problems. pages 260–273, 2008. 18
1505.05825
1
1505
2015-05-21T18:24:03
Graph colouring algorithms
[ "cs.DS" ]
This chapter presents an introduction to graph colouring algorithms. The focus is on vertex-colouring algorithms that work for general classes of graphs with worst-case performance guarantees in a sequential model of computation. The presentation aims to demonstrate the breadth of available techniques and is organized by algorithmic paradigm.
cs.DS
cs
13 Graph colouring algorithms Thore Husfeldt 1. Introduction 2. Greedy colouring 3. Local augmentation 4. Recursion 5. Subgraph expansion 6. Vector colouring 7. Reductions References This chapter presents an introduction to graph colouring algorithms.1 The fo- cus is on vertex-colouring algorithms that work for general classes of graphs with worst-case performance guarantees in a sequential model of computa- tion. The presentation aims to demonstrate the breadth of available tech- niques and is organized by algorithmic paradigm. 1. Introduction A straightforward algorithm for finding a vertex-colouring of a graph is to search systematically among all mappings from the set of vertices to the set of colours, a technique often called exhaustive or brute force: Algorithm X (Exhaustive search) Given an integer q ≥ 1 and a graph G with vertex set V, this algorithm finds a vertex-colouring using q colours if one exists. X1 [Main loop] For each mapping f : V → {1, 2, . . . , q}, do Step X2. X2 [Check f ] If every edge vw satisfies f (v) , f (w), terminate with f as the result. This algorithm has few redeeming qualities, other than its being correct. We consider it here because it serves as an opportunity to make explicit the framework in which we present more interesting algorithms. 1 Appears as Thore Husfeldt, Graph colouring algorithms, Chapter XIII of Topics in Chromatic Graph Theory, L. W. Beineke and Robin J. Wilson (eds.), Encyclopedia of Mathematics and its Applications, Cambridge University Press, ISBN 978-1-107-03350-4, 2015, pp. 277 -- 303. 1 CHAPTER13. GRAPHCOLOURINGALGORITHMS 2 Model of computation If G has n vertices and m edges, then the number of operations used by Algorithm X can be asymptotically bounded by O(qn(n + m)), which we call the running time of the algorithm. To make such a claim, we tacitly assume a computational model that includes primitive operations, such as iterating over all mappings from one finite set A to another finite set B in time O(BA) (Step X1), or iterating over all edges in time O(n + m) (Step X2). For instance, we assume that the input graph is represented by an array of sequences indexed by vertices; the sequence stored at vertex v contains the neighouring vertices N(v), see Fig. 1. This representation allows us to iterate p v z t a u m r b s g d l i c e a m b c m c e s b d t i l z l d g z e c i s i s e d p v r s t m t m r d s c e i r u v m p z m d g m a b r t z v Fig. 1: A graph and its representation as an array of sequences over the neighbours of a vertex in time O(deg v). (An alternative representation, such as an incidence or adjacency matrix, would not allow this.) Note that detecting whether two graphs are isomorphic is not a primitive operation. The convention of expressing computational resources using asymptotic notation is consistent with our somewhat cavalier attitude towards the details of our computational model. Our assumptions are consistent with the behaviour of a modern computer in a high- level programming language. Nevertheless, we will explain our algorithms in plain English. Worst-case asymptotic analysis Note that we could have fixed the colouring of a specific vertex v as f (v) = 0, reducing Algorithm X's running time to O(qn−1(n + m)). A moment's thought shows that this reasoning can then be extended to cliques of size r ≥ 1: search through all (cid:16)n r(cid:17) induced subgraphs until a clique of size r is found, arbitrarily map these vertices to {1, 2, . . . , r} and then let Algorithm X colour the remaining vertices. This reduces the running time to O(qn−ω(G)nω(G)(n + m)), where ω(G) is the clique CHAPTER13. GRAPHCOLOURINGALGORITHMS 3 size. This may be quite useful for some graphs. Another observation is that in the best case, the running time is O(n + m). However, we will normally not pursue this kind of argument. Instead, we are maximally pessimistic about the input and the algorithm's underspecified choices. In other words, we understand running times as worst-case performance guarantees, rather than 'typical' running times or average running times over some distribution. Sometimes we may even say that Algorithm X requires time qn poly(n), where we leave the polynomial factor unspecified in order to signal the perfunctory atten- tion we extend to these issues. Overview and notation Straightforward variants of Algorithm X can be used to solve some other graph colouring problems. For instance, to find a list-colouring, we restrict the range of values for each f (v) to a given list; to find an edge-colouring, we iterate over all mappings f : E → {1, 2, . . . , q}. Another modification is to count the number of colourings instead of finding just one. These extensions provide baseline algorithms for list-colouring, edge- colouring, the chromatic polynomial, the chromatic index, and so forth. However, for purposes of exposition, we present algorithms in their least general form, em- phasizing the algorithmic idea rather than its (sometimes quite pedestrian) general- izations. The algorithms are organized by algorithmic technique rather than prob- lem type, graph class, optimality criterion, or computational complexity. These sections are largely independent and can be read in any order, except perhaps for Algorithm G in Section 2. The final section takes a step back and relates the various colouring problems to each other. 2. Greedy colouring The following algorithm, sometimes called the greedy or sequential algorithm, con- siders the vertices one by one and uses the first available colour. Algorithm G (Greedy vertex-colouring) Given a graph G with maximum degree ∆ and an ordering v1, v2, . . . , vn of its vertices, this algorithm finds a vertex-colouring with maxi { j < i: v jvi ∈ E } + 1 ≤ ∆ + 1 colours. G1 [Initialize] Set i = 0. G2 [Next vertex] Increment i. If i = n + 1, terminate with f as the result. G3 [Find the colours N(vi)] Compute the set C = S j<i f (v j) of colours already assigned to the neighbours of vi. CHAPTER13. GRAPHCOLOURINGALGORITHMS 4 G4 [Assign the smallest available colour to vi] For increasing c = 1, 2, . . . , check whether c ∈ C. If not, set f (vi) = c and return to Step G2. For the number of colours, it is clear that in Step G4, the value of c is at most C, which is bounded by the number of neighbours of vi among v1, v2, . . . , vi−1. In particular, Algorithm G establishes that χ(G) ≤ ∆(G) + 1. For the running time, note that both Steps G3 and G4 take at most O(1 + deg vi) operations. Summing over all i, the total time spent in Steps G3 and G4 is asymp- totically bounded by n + (deg v1 + deg v2 +· · · + deg vn) = n + 2m. Thus, Algorithm G takes time O(n + m). Optimal ordering The size of the colouring computed by Algorithm G depends heavily on the vertex ordering. Its worst-case behaviour is poor. For instance, it spends 1 2 n colours on the 2-colourable crown graph shown in Fig. 2. v1 v3 v5 v2 v4 v6 vn−1 vn · · · · · · Fig. 2: The crown graph On the other hand, for every graph there exists an ordering for which Algo- rithm G uses an optimal number of colours; indeed, any ordering that satisfies f (vi) ≤ f (vi+1) for an optimal colouring f has this property. Since there are n! different orderings, this observation is algorithmically quite useless. An ordering is perfect for a graph if, for every induced subgraph, Algorithm G results in an op- timal colouring; triangulated graphs and comparability graphs always admit such an ordering, as shown by Chvátal [11]. Randomness Algorithm G performs quite well on random graphs, whatever the vertex order- ing. For almost all n-vertex graphs, it uses n/(log n − 3 log log n) colours, which is roughly twice the optimum value (see [15]). This suggests the following randomized algorithm. For a graph G, choose a vertex ordering at random and then execute Algorithm G. For many problems, it is a sound algorithmic design strategy to trade good average-case behaviour for good (expected) worst-case behaviour in this way. However, for Algorithm G the result is quite poor: for every ε > 0 there exist graphs with chromatic number nε for CHAPTER13. GRAPHCOLOURINGALGORITHMS 5 which the randomized algorithm uses Ω(n/ log n) colours with high probability, as shown by Kucera [26]. Other orderings In the largest-first vertex-degree ordering introduced by Welsh and Powell [38], the vertices are ordered such that deg v1 ≥ deg v2 ≥ · · · ≥ deg vn. This establishes the bound χ(G) ≤ 1 + maxi min{deg vi, i− 1}, which is sometimes better than 1 + ∆, such as in Fig. 3. v3 v2 v1 v6 v4 v5 Fig. 3: Closely related in spirit is Matula's smallest-last ordering [32], given as fol- lows: choose as the last vertex vn a vertex of minimum degree in G, and proceed recursively with G − vn, see Fig. 4. With this ordering, the size of the resulting colouring is be bounded by the Szekeres -- Wilf bound [36], χ(G) ≤ dgn(G) + 1 , where the degeneracy dgn(G) is the maximum over all subgraphs H of G of the minimum degree δ(H). This ordering optimally colours crown graphs and many other classes of graphs, and uses six colours on any planar graph. largest-first: v6 v1 v4 v3 v2 v5 smallest-last: v6 v4 v2 v1 v3 v5 Fig. 4: Other orderings are dynamic in the sense that the ordering is determined during the execution of the algorithm, rather than in advance. For example, Brélaz [6] sug- gests choosing the next vertex from among those adjacent to the largest number of different colours. Many other orderings have been investigated (see the surveys of Kosowski and Manuszewski [25] and Maffray [31]). Many of them perform quite well on instances that one may encounter 'in practice', but attempts at formalizing what this means are quixotic. CHAPTER13. GRAPHCOLOURINGALGORITHMS 6 2-colourable graphs Of particular interest are those vertex orderings in which every vertex vi is adjacent to some vertex v j with j < i. Such orderings can be computed in time O(m + n) using basic graph-traversal algorithms. This algorithm is sufficiently important to be made explicit. Algorithm B (Bipartition) Given a connected graph G, this algorithm finds a 2-colouring if one exists. Otherwise, it outputs an odd cycle. B1 [Initialize] Let f (v1) = 1 and let Q (the 'queue') be an empty sequence. For each neighbour w of v1, set p(w) = v1 (the 'parent' of w) and add w to Q. B2 [Next vertex] If Q is empty, go to Step B3. Otherwise, remove the first vertex v from Q and set f (v) to the colour not already assigned to p(v). For each neighbour w of v, if w is not yet coloured and does not belong to Q, then set p(w) = v and add w to the end of Q. Repeat Step B2. B3 [Verify 2-colouring] Iterate over all edges to verify that f (v) , f (w) for every edge vw. If so, terminate with f as the result. B4 [Construct odd cycle] Let vw be an edge with f (v) = f (w) and let u be the nearest common ancestor of v and w in the tree defined by p. Output the path w, p(w), p(p(w)), . . . , u, followed by the reversal of the path v, p(v), p(p(v)), . . . , u, followed by the edge vw. Fig. 5 shows an execution of Algorithm B finding a 2-colouring. Fig. 5: Execution of Algorithm B Algorithm B is an example of a 'certifying' algorithm: an algorithm that pro- duces a witness to certify its correctness, in this case an odd cycle if the graph is not 2-colourable. To see that the cycle constructed in Step B4 has odd length, note that on the two paths w, p(w), p(p(w)), . . . , u and v, p(v), p(p(v)), . . . , u, each vertex has a different colour from its predecessor. Since the respective endpoints of both paths have the same colour, they must contain the same number of edges modulo CHAPTER13. GRAPHCOLOURINGALGORITHMS 7 2. In particular, their total length is even. With the additional edge vw, the length of the resulting cycle is odd. The order in which the vertices are considered by Algorithm B depends on the first-in first-out behaviour of the queue Q. The resulting ordering is called breadth- first. An important variant uses a last-in first-out 'stack' instead of a queue; the resulting ordering is called depth-first. Fig. 6 shows the resulting behaviour on the graph from Fig. 5. Fig. 6: Execution of Algorithm B using depth-first search Algorithm B works also for the list-colouring problem, provided that for each vertex v, the available list of colours L(v) has size at most 2. This observation leads to a simple, randomized, exponential-time algorithm for 3-colouring due to Beigel and Eppstein [1]. Algorithm P (Palette restriction) Given a graph, this algorithm finds a 3-colouring if one exists. P1 [Forbid one colour at each vertex] For each vertex v, select a list L(v) of colours available at v uniformly and independently at random from the three lists {1, 2}, {2, 3}, and {1, 3}. P2 [Attempt 2-colouring] Try to solve the list-colouring instance given by L using Algorithm B, setting f (v1) = min L(v1) in Step B1. If successful, terminate with the resulting colouring. Otherwise, return to Step P1. To analyse the running time, consider a 3-colouring f . For each vertex v, colour f (v) belongs to L(v) with probablity 2 3)n, the list colouring instance constructed in step P1 has a solution. It follows that the expected number of repetitions is ( 3 3. Thus, with probability at least ( 2 2 )n, each of which takes polynomial time. Wigderson's algorithm Algorithms B and G appear together in Wigderson's algorithm [40]: CHAPTER13. GRAPHCOLOURINGALGORITHMS 8 Algorithm W (Wigderson's algorithm) Given a 3-chromatic graph G, this algo- rithm finds a vertex-colouring with O(√n) colours. W1 [Initialize] Let c = 1. W2 [∆(G) ≥ ⌈√n⌉] Consider a vertex v in G with deg v ≥ ⌈√n⌉; if no such ver- tex exists, go to Step W3. Use Algorithm B to 2-colour the neighbourhood G[N(v)] with colours c and c + 1. Remove N(v) from G and increase c by χ(G[N(v)]). Repeat Step W2. W3 [∆(G) < ⌈√n⌉] Use Algorithm G to colour the remaining vertices with the colours c, c + 1, . . . , c + ⌈√n⌉. Fig. 7 shows an execution of Algorithm W finding a 5-colouring of the 16- vertex instance from Fig. 1. 3 3 v 3 3 1 3 1 1 2 3 4 3 4 3 5 3 4 1 1 4 3 4 4 1 2 1 v 1 1 2 Fig. 7: Execution of Algorithm W The running time is clearly bounded by O(n + m). To analyse the number of colours, we first need to verify Step W2. Since G is 3-colourable, so is the subgraph induced by N(v) ∪ {v}. Now, if G[N(v)] requires 3 colours, then G[N(v) ∪ {v}] requires 4, so G[N(v)] is 2-colourable and therefore Step W2 is correct. Note that Step W2 can be run at most O(√n) times, each using at most two colours. Step W3 expends another ⌈√n⌉ colours according to Algorithm G. Algorithm W naturally extends to graphs with χ(G) > 3. In this case, Step W2 calls Algorithm W recursively to colour (χ(G)− 1)-colourable neighbourhoods. The resulting algorithm uses O(n1−1/(1−χ(G))) colours. 3. Recursion Recursion is a fundamental algorithmic design technique. The idea is to reduce a problem to one or more simpler instances of the same problem. CHAPTER13. GRAPHCOLOURINGALGORITHMS 9 Contraction The oldest recursive construction for graph colouring expresses the chromatic poly- nomial P(G, q) and the chromatic number χ(G) in terms of edge-contractions: For non-adjacent vertices v, w and integer q = 0, 1, . . . , n, P(G, q) = P(G + vw, q) + P(G/vw, q) , χ(G) = min{χ(G + vw), χ(G/vw)} , see Chapter 3, Section 2.1. These 'addition -- contraction' recurrences immediately imply a recursive algorithm. For instance, P( , q) = P( , q) + P( , q) = P(K4, q) + P(K3, q) = q(q − 1)(q − 2)(cid:0)(q − 3)(q − 4) + 1(cid:1) . Note that the graphs at the end of the recursion are complete. For sparse graphs, it is more useful to express the same idea as a 'deletion -- contraction' recurrence, which deletes and contracts edges until the graph is empty: P(G, q) = P(G/e, q) − P(G − e, q) (e ∈ E) . Many other graph problems beside colouring can be expressed by a deletion -- contraction recurrence. The most general graph invariant that can be defined in this fashion is the Tutte polynomial (see [5] and [18] for its algorithmic aspects). The algorithm implied by these recursions is sometimes called Zykov's algo- rithm [42]. Here is the deletion -- contraction version. Algorithm C (Contraction) Given a graph G, this algorithm returns the sequence of coefficients (a0, a1, . . . , an) of the chromatic polynomial P(G, q) = Pn C1 [Base] If G has no edges then return the coefficients (0, 0, . . . , 0, 1), correspond- i=0 aiqi. ing to the polynomial P(G, q) = qn. C2 [Recursion] Pick an edge e and construct the graphs G′ = G/e and G′′ = G − e. Call Algorithm C recursively to compute P(G′, q) and P(G′′, q) as sequences of coefficients (a′0, a′1, . . . , a′n) and (a′′0 , a′′1 , . . . , a′′n ). Return (a′0 − a′′0 , a′1 − a′′1 , . . . , a′n − a′′n ), corresponding to the polynomial P(G/e, q) − P(G − e, q). To analyse the running time, let T (r) be the number of executions of Step C1 for graphs with n vertices and m edges, where r = n + m. The two graphs constructed in Step C2 have size n − 1 + m − 1 = r − 2 and n + m − 1 = r − 1, respectively, CHAPTER13. GRAPHCOLOURINGALGORITHMS 10 so T satisfies T (r) = T (r − 1) + T (r − 2). This is a well-known recurrence with 2(1 + √5) is the golden ratio. Thus, Algorithm solution T (r) = O(ϕr), where ϕ = 1 C requires ϕn+m poly(n) = O(1.619n+m) time. A similar analysis for the algorithm implied by the deletion -- addition recursion gives ϕn+m poly(n), where m = (cid:16)n 2(cid:17) − m is the number of edges in the complement of G. These worst-case bounds are often very pessimistic. They do not take into account that recurrences can be stopped as soon as the graph is a tree (or some other easily recognized graph whose chromatic polynomial is known as a closed formula), or that P factorizes over connected components. Moreover, we can use graph isomorphism heuristics and tabulation to avoid some unnecessary recompu- tation of isomorphic subproblems (see [18]). Thus, Algorithm C is a more useful algorithm than its exponential running time may indicate. Vertex partitions and dynamic programming We turn to a different recurrence, which expresses χ(G) in terms of induced sub- graphs of G. By taking S to be a colour class of an optimal colouring of G, we observe that every graph has an independent set of vertices S for which χ(G) = 1 + χ(G − S ). Thus, we have χ(G) = 1 + min χ(G − S ) , (1) where the minimum is taken over all non-empty independent sets S in G. The recursive algorithm implied by (1) is too slow to be of interest. We expedite it using the fundamental algorithmic idea of dynamic programming. The central observation is that the subproblems χ(G−S ) for various vertex-subsets S appearing in (1) are computed over and over again. It thus makes sense to store these 2n values in a table when they are first computed. Subsequent evaluations can then be handled by consulting the table. We express the resulting algorithm in a bottom-up fashion: Algorithm D (Dynamic programming) Given a graph G, this algorithm computes a table T with T (W) = χ(G[W]), for each W ⊆ V. D1 [Initialize] Construct a table with (initially undefined) entries T (W) for each W ⊆ V. Set T (∅) = 0. order of their size. Do Step D3 for W = W2, W3, . . . , W2n, then terminate. D2 [Main loop] List all vertex-subsets W1, W2, . . . , W2n ⊆ V in non-decreasing D3 [Determine T (W)] Set T (W) = 1 + min T (W \ S ), where the minimum is taken over all non-empty independent sets S in G[W]. CHAPTER13. GRAPHCOLOURINGALGORITHMS 11 The ordering of subsets in the main loop D2 ensures that each set is handled before any of its supersets. In particular, all values T (W \S ) needed in Step D3 will have been previously computed, so the algorithm is well defined. The minimization in Step D3 is implemented by iterating over all 2W subsets of W. Thus, the total running time of Algorithm D is within a polynomial factor of 2W = XW⊆V n Xk=0 n k!2k = 3n . (2) This rather straightforward application of dynamic programming already pro- vides the non-trivial insight that the chromatic number can be computed in time exponential in the number of vertices, rather than depending exponentially on m, χ(G), or a superlinear function of n. Maximal independent sets To pursue this idea a little further we notice that S in (1) can be assumed to be a maximal independent set -- that is, not a proper subset of another independent set. To see this, let f be an optimal colouring and consider the colour class S = f −1(1). If S is not maximal, then repeatedly pick a vertex v that is not adjacent to S , and set f (v) = 1. By considering the disjoint union of 1 3k triangles, we see that there exist k- vertex graphs with 3k/3 maximal independent sets. It is known that this is also an upper bound, and that the maximal independent sets can be enumerated within a polynomial factor of that bound (see [7], [34] and [37]). We therefore have the following result: Theorem 3.1 The maximal independent sets of a graph on k vertices can be listed in time O(3k/3) and polynomial space. We can apply this idea to Algorithm D. The minimization in Step D3 now takes the following form: D3′ [Determine T (W)] Set T (W) = 1 + min T (W\S ), where the minimum is taken over all maximal independent sets S in G[W]. Using Theorem 3.1 with k = W for the minimization in Step D3′, the total running time of Algorithm D comes within a polynomial factor of n Xk=0 n k!3k/3 = (1 + 31/3)n = O(2.443n) . For many years, this was the fastest known algorithm for the chromatic number. CHAPTER13. GRAPHCOLOURINGALGORITHMS 12 3-colouring Of particular interest is the 3-colouring case. Here, it makes more sense to let the outer loop iterate over all maximal independent sets and check whether the complement is bipartite. Algorithm L (Lawler's algorithm) Given a graph G, this algorithm finds a 3- colouring if one exists. L1 [Main loop] For each maximal independent set S of G, do Step L2. L2 [Try f (S ) = 3] Use Algorithm B to find a colouring f : V \ S → {1, 2} of G− S if one exists. In that case, extend f to all of V by setting f (v) = 3 for each v ∈ S , and terminate with f as the result. The running time of Algorithm L is dominated by the number of executions of L2, which, according to Theorem 3.1, is 3n/3. Thus, Algorithm L decides 3- colourability in time 3n/3 poly(n) = O(1.442n) and polynomial space. The use of maximal independent sets goes back to Christofides [10], while Algorithms D and L are due to Lawler [28]. A series of improvements to these ideas have further reduced these running times. At the time of writing, the best- known time bound for 3-colouring is O(1.329n) by Beigel and Eppstein [1]. 4. Subgraph expansion The Whitney expansion [39] of the chromatic polynomial is P(G, q) = XA⊆E (−1)Aqk(A) ; It expresses the chromatic polynomial as see Chapter 3, Section 2 for a proof. an alternating sum of terms, each of which depends on the number of connected components k(A) of the edge-subset A ⊆ E. Determining k(A) is a well-studied algorithmic graph problem, which can be solved in time O(n + m) (for example, by depth-first search). Thus, the Whitney expansion can be evaluated in time O(2m(n + m)). A more recent expression (see [2]) provides an expansion over induced sub- graphs: CHAPTER13. GRAPHCOLOURINGALGORITHMS 13 Theorem 4.1 For W ⊆ V, let g(W) be the number of non-empty independent sets in G[W]. Then G can be q-coloured if and only if XW⊆V (−1)V\W(cid:0)g(W)(cid:1)q > 0 . (3) Proof. For each W ⊆ V, the term (cid:0)g(W)(cid:1)q counts the number of ways of selecting q non-empty independent sets S 1, S 2, . . . , S q, where S i ⊆ W. For U ⊆ V, let h(U) be the number of ways of selecting q non-empty independent sets whose union is U. Then (g(W))q = PU⊆W h(U), so XW⊆V (−1)V\W(cid:0)g(W)(cid:1)q = XW⊆V = XU⊆V (−1)V\W XU⊆W h(U) XW⊇U h(U) (−1)V\W = h(V) . For the last step, note that the inner sum (over W, with U ⊆ W ⊆ V) vanishes except when U = V, because there are as many odd-sized as even-sized sets sandwiched between different sets, by the principle of inclusion -- exclusion. If h(V) is non-zero, then there exist independent sets S 1, S 2, . . . , S q whose union is V. These sets correspond to a colouring: associate a colour with the vertices in each set, breaking ties arbitrarily. For each W ⊆ V, we can compute the value g(W) in time O(2Wm) by con- structing each non-empty subset of W and testing it for independence. Thus, the total running time for evaluating (3) is within a polynomial factor of 3n, just as in the analysis (2) for Algorithm D; however, the space requirement here is only poly- nomial. We can further reduce the running time to O(2.247n) by using dedicated algorithms for evaluating g(W) from the literature (see [3]). If exponential space is available, we can do even better. To that end, we first introduce a recurrence for g. Theorem 4.2 Let W ⊆ V. We have g(∅) = 0, and, for every v ∈ W, g(W) = g(W \ {v}) + g(W \ N[v]) + 1 . (4) Proof. Fix v ∈ W. The non-empty independent sets S ⊆ W can be partitioned into two classes with v < S and v ∈ S . In the first case, S is a non-empty independent set with S ⊆ W \ {v} and thus accounted for by the first term of (4). Consider the second case. Since S contains v and is independent, it contains no vertex from N(v). Thus, S is a non-empty independent set with {v} ⊆ S ⊆ W \ N(v). The number of such sets is the same as the number of (not necessarily non-empty) independent CHAPTER13. GRAPHCOLOURINGALGORITHMS 14 sets S ′ with S ′ ⊆ W \ N[v], because of the bijective mapping S 7→ S ′ where S ′ = S \ {v}. By induction, the number of such sets is g(W \ N[v]) + 1, where the '+1' term accounts for the empty set. This leads to the following algorithm, due to Björklund et al. [3]: Algorithm I (Inclusion -- exclusion) Given a graph G and an integer q ≥ 1, this algorithm determines whether G can be q-coloured. I1 [Tabulate g] Set g(∅) = 0. For each non-empty subset W ⊆ V in inclusion I2 [Evaluate (3)] If PW⊆V(−1)V\W(cid:0)g(W)(cid:1)q > 0 output 'yes', otherwise 'no'. order, pick v ∈ W and set g(W) = g(W \ {v}) + g(W \ N[v]) + 1. Both Steps I1 and I2 take time 2n poly(n), and the algorithm requires a table with 2n entries. Fig. 8 shows the computations of Algorithm I on a small graph for q = 2 and q = 3, with aq(W) = (−1)V\W(cid:0)g(W)(cid:1)q. The sum of the entries in column a2 is 0, so there is no 2-colouring. The sum of the entries in column a3 is 18, so a 3-colouring exists. v x w u g W ∅ 4 4 4 a2 0 a3 0 0 1 −1 −1 1 −1 −1 1 −1 −1 1 −1 −1 8 2 8 2 2 8 {u} {v} {w} {x} {u, v} {u, w} {u, x} Fig. 8: Execution of Algorithm I W {v, w} {v, x} {w, x} {u, v, w} {u, v, x} {u, w, x} {v, w, x} V g a3 a2 8 4 2 27 9 3 27 9 3 −27 −9 3 −64 4 −16 4 −16 −64 5 −25 −125 216 36 6 With slight modifications, Algorithm I can be made to work for other colouring problems such as the chromatic polynomial and list-colouring, also in time and space 2n poly(n) (see [3]); currently, this is the fastest known algorithm for these problems. For the chromatic polynomial, the space requirement can be reduced to O(1.292n), while maintaining the 2n poly(n) running time (see [4]). 5. Local augmentation Sometimes, a non-optimal colouring can be improved by a local change that re- colours some vertices. This general idea is the basis of many local search heuristics and also several central theorems. CHAPTER13. GRAPHCOLOURINGALGORITHMS 15 Kempe changes An important example, for edge-colouring, establishes Vizing's theorem, ∆(G) ≤ χ′(G) ≤ ∆(G) + 1. Chapter 5 gives a modern and more general presentation of the underlying idea, and our focus in the present chapter is to make the algorithm explicit. A colour is free at v if it does not appear on an edge at v. (We consider an edge-colouring with ∆(G) + 1 colours, so every vertex has at least one free colour.) A (Vizing) fan around v is a maximal set of edges vw0, vw1, . . . , vwr, where vw0 is not yet coloured and the other edges are coloured as follows. For j = 0, 1, . . . , r, no colour is free at both v and w j. For j = 1, 2, . . . , r, the jth fan edge vw j has colour j and the colours appearing around w j include 1, 2, . . . , j but not j + 1 (see Fig. 9(a)). Such a fan allows a recolouring by moving colours as follows: remove the colour from vw j and set f (vw0) = 1, f (vw1) = 2, . . . , f (vw j−1) = j. This is called downshifting from j (see Fig. 9(b)). 1 2 w3 1 w2 1 2 3 2 3 1 v w4 4 5 w5 w1 w0 1 2 3 4 w1 w0 (a) w2 w3 w4 w2 w1 w j 0 w5 w0 3 2 1 v 4 5 (b) 2 j 1 r v r + 1 wr+1 (c) 0 j wr 0 j 0 Fig. 9: (a) A fan (b) Downshifting from 3 (c) Step V7: colour j is free at wr+1 Algorithm V (Vizing's algorithm) Given a graph G, this algorithm finds an edge colouring with at most ∆(G) + 1 colours in time O(nm). V1 [Initialize] Order the edges arbitrarily e1, e2, . . . , em. Let i = 0. V2 [Extend colouring to next edge] Increment i. If i = m + 1 then terminate. Otherwise, let vw = ei. V3 [Easy case] If a colour c is free at both v and w, then set f (vw) = c and return to Step V2. V4 [Find w0 and w1] Let w0 = w. Pick a free colour at w0 and call it 1. Let vw1 be the edge incident with v coloured 1. (Such an edge exists because 1 is not also free at v.) CHAPTER13. GRAPHCOLOURINGALGORITHMS 16 V5 [Find w2] Pick a free colour at w1 and call it 2. If 2 is also free at v, then set f (vw0) = 1, f (vw1) = 2, and return to Step V2. Otherwise, let vw2 be the edge incident with v coloured 2. Set r = 2. V6 [Extend fan to wr+1] Pick a free colour at wr and call it r + 1. If r + 1 is also free at v then downshift from r, recolour f (vwr) = cr+1 and return to Step V2. Otherwise, let vwr+1 be the edge incident with v coloured r + 1. If each colour 1, 2, . . . , r appears around wr+1, then increment r and repeat Step V6. V7 [Build a {0, j}-path from w j or from wr+1] Let j ∈ {1, 2, . . . , r} be a free colour at wr+1 and let 0 be a colour free at v and different from j. Construct two maximal {0, j}-coloured paths P j and Pr+1 from w j and wr+1, respectively, by following edges of alternating colours 0, j, 0, j, . . . (see Fig. 9(c)). (The paths cannot both end in v.) Let k = j or r + 1 so that Pk does not end in v. V8 [Flip colours on Pk] Recolour the edges on Pk by exchanging 0 and j. Down- shift from k, recolour f (vwk) = 0, and return to Step V2. To see that this algorithm is correct, one needs to check that the recolourings in Steps V6 and V8 are legal. A careful analysis is given by Misra and Gries [33]. For the running time, first note that Step V6 is repeated at most deg v times, so the algorithm eventually has to leave that step. The most time-consuming step is Step V7; a {0, j}-path can be constructed in time O(n) if for each vertext we maintain a table of incident edges indexed by colour. Thus the total running time of Algorithm V is O(mn). Another example from this class of algorithms appears in the proof of Brooks's theorem (see Chapter 2 and [8]), which relies on an algorithm that follows Algo- rithm G but attempts to re-colour the vertices of bichromatic components whenever a fresh colour is about to be introduced. Random changes There are many other graph colouring algorithms that fall under the umbrella of local transformations. Of particular interest are local search algorithms that re- colour individual vertices at random. This idea defines a random process on the set of colourings called the Glauber or Metropolis dynamics, or the natural Markov chain Monte Carlo method. The aim here is not merely to find a colouring (since q > 4∆, this would be easily done by Algorithm G), but to find a colouring that is uniformly distributed among all q-colourings. Algorithm M (Metropolis) Given a graph G with maximum degree ∆ and a q- colouring f0 for q > 4∆, this algorithm finds a uniform random q-colouring fT in polynomial time. CHAPTER13. GRAPHCOLOURINGALGORITHMS 17 terminate. M1 [Outer loop] Set T = ⌈qn ln 2n/(q− 4∆)⌉. Do Step M2 for t = 1, 2, . . . , T , then M2 [Recolour a random vertex] Pick a vertex v ∈ V and a colour c ∈ {1, 2, . . . , q} uniformly at random. Set ft = ft−1. If c does not appear among v's neighbours, then set ft(v) = c. An initial colouring f0 can be provided in polynomial time because q > ∆ + 1 -- for example, by Algorithm G. To see that the choice of initial colouring f0 has no influence on the result fT , we consider two different initial colourings f0 and f ′0 and execute Algorithm M on both, using the same random choices for v and c in each step. Let dt = { v: ft(v) , f ′t (v)} be the number of disagreeing vertices after t executions of Step M2. Each step can change only a single vertex, so dt − dt−1 = 1, 0, or −1. We have dt = dt−1 + 1 only if ft−1(v) = f ′t−1(v) but ft(v) , f ′t (v), In particular, v so exactly one of the two processes rejects the colour change. must have a (disagreeing) neighbour w with c = ft−1(w) , f ′t−1(w) or ft−1(w) , f ′t−1(w) = c. There are dt−1 choices for w and therefore 2∆dt−1 choices for c and v. Similarly, we have dt = dt−1 − 1 only if ft−1(v) , ft−1(v) and c does not appear in v's neighbourhood in either ft−1 or f ′t−1. There are at least (q−2∆)dt−1 such choices for c and v. Thus, the expected value of dt can be bounded as follows: E[dt] ≤ E[dt−1] + (q − 2∆)E[dt−1] 2∆E[dt−1] qn Iterating this argument and using d0 ≤ n, we have qn − = E[dt−1](cid:18)1 − q − 4∆ qn (cid:19) . E[dT ] ≤ n(cid:18)1 − T q − 4∆ qn (cid:19) ≤ n exp(cid:18)− T (q − 4∆) qn (cid:19) ≤ n exp(− ln 2n) = 1 2 . By Markov's inequality, and because dT is a non-negative integer, we conclude that Pr( fT = f ′T ) = Pr(dT = 0) ≥ 1 − Pr(dT ≥ 1) ≥ 1 − E[dT ] ≥ 1 2 . We content ourselves with this argument, which shows that the process is 'suf- ficiently random' in the sense of being memoryless. Informally, we can convince ourselves that fT is uniformly distributed because we can assume that f ′0 in the above argument was sampled according to such a distribution. This intuition can be formalized using standard coupling arguments for Markov chains; our calcula- tions above show that the 'mixing time' of Algorithm M is O(n log n). Algorithm M and its variants have been well studied, and the analysis can be much improved (see the survey of Frieze and Vigoda [13]). Randomized lo- cal search has wide appeal across disciplines, including simulations in statistical physics and heuristic methods in combinatorial optimization. CHAPTER13. GRAPHCOLOURINGALGORITHMS 18 6. Vector colouring We now turn to a variant of vertex-colouring that is particularly interesting from an algorithmic point of view. Vector chromatic number Let S d−1 = { x ∈ Rd : kxk = 1}. A vector q-colouring in d ≤ n dimensions is a mapping x: V → S d−1 from the vertex-set to the set of d-dimensional unit vectors for which neighbouring vectors are 'far apart', in the sense that their scalar product satisfies hx(v), x(w)i ≤ − , for vw ∈ E. 1 q − 1 The smallest such number q is called the vector chromatic number ~χ(G), which need not be an integer. For instance, the vertices of the 3-chromatic cycle graph C5 can be laid out on the unit circle in the form of a pentagram . Then the angle between vectors corresponding to neighbouring vertices is 4 5 π, corresponding to the scalar product −1/(√5 − 1), so ~χ(C5) ≤ √5 < 3. Theorem 6.1 If G has clique number ω(G), then ω(G) ≤ ~χ(G) ≤ χ(G). Proof. For the first inequality, let W be a clique in G of size r = ω(G) and consider a vector q-colouring x of G. Let y = Pv∈W x(v). Then 0 ≤ hy, yi ≤ r · 1 + r(r − 1) ·(cid:18)− 1 q − 1(cid:19) , which implies that r ≤ q. For the second inequality, place the vertices belonging to each colour class at the corners of a (q−1)-dimensional simplex. To be specific, let f : V → {1, 2, . . . , q} be an optimal q-colouring and define x(v) = (x1, x2, . . . , xn) by (cid:0)(q − 1)/q(cid:1)1/2 , −(cid:0)q(q − 1)(cid:1)−1/2 , 0 , if i = f (v) ; if i , f (v) and i ≤ q ; if i > q . xi =  Then we have hx(v), x(v)i = q − 1 q + q − 1 q(q − 1) = 1 , and for v and w with f (v) , f (w) we have hx(v), x(w)i = 2(cid:18) q − 1 q (cid:19) 1/2 1/2 (cid:18)−(cid:18) q q − 1(cid:19) (cid:19) + q − 2 q(q − 1) = − 1 q − 1 . CHAPTER13. GRAPHCOLOURINGALGORITHMS 19 Thus, x is a vector q-colouring, so ~χ(G) is at most q. What makes vector colourings interesting from the algorithmic point of view is that they can be found in polynomial time, at least approximately, using algorithms based on semidefinite programming. The details behind those constructions lie far outside the scope of this chapter (see Gärtner and Matoušek [14]). Theorem 6.2 Given a graph G with ~χ(G) = q, a vector (q + ε)-colouring of G can be found in time polynomial in n and log(1/ε). For a graph with ω(G) = χ(G), Theorem 6.1 shows that the vector chromatic number equals the chromatic number. In particular, it is an integer, and can be determined in polynomial time using Theorem 6.2 with ε < 1 2. This shows that the chromatic numbers of perfect graphs can be determined in polynomial time. The theory behind this result counts as one of the highlights of combinatorial optimiza- tion (see Grötschel, Lovász and Schrijver [16]). How does the vector chromatic number behave for general graphs? For q = 2, the vectors have to point in exactly opposite directions. In particular, there can be only two vectors for each connected component, so vector 2-colouring is equivalent to 2-colouring. But already for q = 3, the situation becomes more interesting, since there exist vector 3-colourable graphs that are not 3-colourable. For instance, the Grötzsch graph, the smallest triangle-free graph with chromatic number 4, admits the vector 3-colouring shown in Fig. 10 as an embedding on the unit sphere. More com- v8 v7 v6 v3 v4 v1 v5 v2 v9 v10 v11 v10 v8 v9 v7 v1 v11 v2 v3 v4 v5 v2 v6 Fig. 10: Left: the Grötzsch graph Middle and right: a vector 3-colouring plicated constructions (that we cannot visualize) show that there exist vector 3- colourable graphs with chromatic number at least n0.157 (see [12] and [22]). CHAPTER13. GRAPHCOLOURINGALGORITHMS 20 Randomized rounding Even though the gap between ~χ and χ can be large for graphs in general, vector colouring turns out to be a useful starting point for (standard) colouring. The next algorithm, due to Karger, Motwani and Sudan [22], translates a vector colouring into a (standard) vertex-colouring using random hyperplanes. Algorithm R (Randomized rounding of vector colouring) Given a 3-chromatic graph G with maximum degree ∆, this algorithm finds a q-colouring in polynomial time, where the expected size of q is E[q] = O(∆0.681 log n). R1 [Vector colour] Set ε = 2 · 10−5 and compute a vector (3 + ε)-colouring x of G using semidefinite programming. Let α ≥ arccos(−1/(2 + ε)) be the minimum angle in radians between neighbouring vertices. R2 [Round] Set r = ⌈logπ/(π−α)(2∆)⌉ and construct r random hyperplanes H1, H2, . . . , Hr in Rn. For each vertex v, let f (v) be the binary number brbr−1 · · · b1, where bi = 1 if and only if x(v) is on the positive side of the ith hyperplane Hi. R3 [Handle monochromatic edges recursively] Iterate over all edges to find the set of monochromatic edges M = { vw ∈ E : f (v) = f (w)}. Recolour these vertices by running Algorithm R recursively on G[M], with fresh colours. Figure 11 illustrates the behaviour of Algorithm R on the vector 3-colouring of the Grötzsch graph from Fig. 10. Two hyperplanes separate the vertices into four parts. The resulting vertex-colouring with colours from {0, 1}2 is shown to the right. In this example, the set M of monochromatic edges determined in Step M3 contains only the single edge v10v11, drawn bold in the figure. 01 11 00 00 00 11 00 10 11 11 01 00 00 Fig. 11: Left and middle: two hyperplanes Right: the corresponding colouring Algorithm R algorithm runs in polynomial time, because Theorem 6.2 ensures that Step R1 can be performed in polynomial time. CHAPTER13. GRAPHCOLOURINGALGORITHMS 21 We proceed to analyze the size of the final colouring. Step R2 uses the colours {0, 1, . . . , 2r−1}, so the number of colours used in each Step R2 is 2r ≤ (2∆)−1/ log(π/(π−α)) < (2∆)0.631 , (5) what is more difficult is to bound the total number of recursive invocations. To this end, we need to understand how fast the instance size, determined by the size of M in Step R3, shrinks. Let e be an edge whose endpoints received the vector colours x and y. Elemen- tary geometrical considerations establish the following result. Theorem 6.3 Let x, y ∈ Rd with angle ϕ (in radians). A random hyperplane in Rd fails to separate x and y with probability 1 − ϕ/π. The angle between the vectors x and y is at most α. (To gain some intuition of this, if we ignore the error term ε, Theorem 6.3 shows that x and y end up on the same side of a random hyperplane with probability 1 − α/π ≤ 1 − arccos(− 1 2 )/π = 1 − 2π/3π = 1 3 .) The edge e is monochromatic if all r independent random hyper- planes fail to separate x and y in Step R2. Thus, Pr(e ∈ M) ≤ (1 − α/π)r ≤ (π/(π − α))−r ≤ 1/2∆ . By linearity of expectation, the expected size of M is E[M] = Xe∈E Pr(e ∈ M) ≤ m/2∆ ≤ 1 4n . Since each edge has two vertices, the expected number of vertices in the recursive instance G[M] is at most 1 2n, and in general, for i > 2, the expected number of vertices ni in the ith instance satisfies ni ≤ 1 2ni−1. In particular, nt ≤ 1 after t = O(log n) rounds, at which point the algorithm terminates. With the bound (5) on the number of colours used per round, we conclude that the total number of colours used is O(∆0.631 log n) in expectation. In terms of ∆, Algorithm R is much better than the bound of ∆ + 1 guaranteed by Algorithm G. For an expression in terms of n, we are tempted to bound ∆ by O(n), but that just shows that the number of colours is O(n0.631 log n), which is worse than the O(√n) colours from Algorithm W. Instead, we employ a hybrid approach. Run Steps W1 and W2 as long as the maximum degree of the graph G is larger than some threshold d, and then colour the remaining graph using Algorithm R. The number of colours used by the combined algorithm is of the order of (2n/d) + (2d)0.631 log n, which is minimized around d = n1/1.631 with value O(n0.387). CHAPTER13. GRAPHCOLOURINGALGORITHMS 22 Variants of Algorithm R for general q-colouring and with intricate rounding schemes have been investigated further (see Langberg's survey [27]). The current best polynomial-time algorithm for colouring a 3-chromatic graph based on vector colouring uses O(n0.208) colours, due to Chlamtac [9]. 7. Reductions The algorithms in this chapter are summarized in Table 1. Algorithm Time Problem B Bipartition C Contraction D Dynamic programming G Greedy I Inclusion -- exclusion L Lawler's algorithm M Metropolis dynamics P Palette restriction R Rounded vector colouring V Vizing's algorithm W Wigderson's algorithm X Exhaustive search O(n + m) O(1.619n+m) 3n poly(n) O(n + m) 2n poly(n) O(1.443n) poly(n) 1.5n poly(n) poly(n) O(mn) O(n + m) qn poly(n) 2-colouring P(G, q) χ(G) (∆(G) + 1)-colouring χ(G) 3-colouring random q-colouring (q > 4∆) 3-colouring O(∆0.681 log n)-colouring for χ(G) = 3 edge (∆(G) + 1)-colouring O(√n)-colouring for χ(G) = 3 P(G, q) Table 1: Algorithms discussed in this survey Not only do these algorithms achieve different running times and quality guar- antees, they also differ in which specific problem they consider. Let us now be more precise about the variants of the graph colouring problem: Decision Given a graph G and an integer q, decide whether q can be q-coloured. Chromatic number Given a graph G, compute the chromatic number χ(G). Construction Given a graph G and an integer q, construct a q-colouring of G. Counting Given a graph G and an integer q, compute the number P(G, q) of q- colourings of G. Sampling Given a graph G and an integer q, construct a random q-colouring of G. Chromatic polynomial Given a graph G, compute the chromatic polynomial -- that is, the coefficients of the integer polynomial q 7→ P(G, q). CHAPTER13. GRAPHCOLOURINGALGORITHMS 23 Some of these problems are related by using fairly straightforward reductions. For example, the decision problem is easily solved using the chromatic number by comparing q with χ(G); conversely, χ(G) can be determined by solving the decision problem for q = 1, 2, . . . , n. It is also clear that if we can construct a q- colouring, then we can decide that one exists. What is perhaps less clear is the other direction. This is seen by a self-reduction that follows the contraction algorithm, Algorithm C. Reduction C (Constructing a colouring using a decision algorithm). Suppose that we have an algorithm that decides whether a given graph G can be q-coloured. If G = Kn and n ≤ q, give each vertex its own colour and terminate. Otherwise, select two non-adjacent vertices v and w in G. If G + vw cannot be q-coloured, then every q-colouring f of G must have f (v) = f (w). Thus we can identify v and w and recursively find a q-colouring for G/vw. Otherwise, there exists a q-colouring of G with f (v) , f (w), so we recursively find a colouring for G + vw. Some of our algorithms work only for a specific fixed q, such as Algorithm B for 2-colourability or Algorithm L for 3-colourability. Clearly, they both reduce to the decision problem where q is part of the input. But what about the other direction? The answer turns out to depend strongly on q: the decision problem reduces to 3-colorability, but not to 2-colorability. Reduction L (q-colouring using 3-colouring). Given a graph G = (V, E) and an integer q, this reduction constructs a graph H that is 3-colourable with colours {0, 1, 2} if and only if G is q-colourable with colours {1, 2, . . . , q}. 0, 1, 2. We assume that vertex i has colour i, for i = 0, 1, 2. First, to fix some colour names, the graph H contains a triangle with the vertices For each vertex v ∈ V, the graph H contains 2q vertices v1, v2, . . . , vq and v′1, v′2, . . . , v′q. Our intuition is that the vis act as indicators for a colour in G in the following sense: if vi has colour 1 in H then v has colour i in G. The vertices are arranged as in Fig. 12(a); the right-most vertex is 1 or 2, depending on the parity of q. The vertices v1, v2, . . . , vq are all adjacent to 2, and so must be coloured 0 or v1 v2 v′1 v′2 · · · · · · 2 vq v′q (a) 2 − q (mod 2) Fig. 12: 1 vi wi (b) CHAPTER13. GRAPHCOLOURINGALGORITHMS 24 1. Moreover, at least one of them must be coloured 1, since otherwise, the colours for v′1, v′2, . . . , v′q are forced to alternate as 1, 2, 1, . . ., conflicting with the colour of the right-most vertex. Now consider an edge vw in G. Let v1, v2, . . . , vq and w1, w2, . . . , wq be the corresponding 'indicator' vertices in H. For each colour i = 1, 2, . . . , q, the vertices vi and wi are connected by a 'fresh' triangle as shown in Fig. 12(b). This ensures that vi and wi cannot both be 1. In other words, v and w cannot have received the same colour. The above reduction, essentially due to Lovász [30], can easily be extended to a larger, fixed q > 3, because G is q-colourable if and only if G with an added 'apex' vertex adjacent to all other vertices is (q + 1)-colourable. For instance, 4- colourability is not easier than 3-colourability for general graphs. Thus, all q-colouring problems for q ≥ 3 are (in some sense) equally difficult. This is consistent with the fact that the case q = 2 admits a very fast algorithm (Algorithm B), whereas none of the others does. Many constructions have been published that show the computational difficulty of colouring for restricted classes of graphs. We will sketch an interesting example due to Stockmeyer [35]: the restriction of the case q = 3 to planar graphs. Consider the subgraph in Fig. 13(a), called a planarity gadget. One can check that this W E N S (a) w w v v ↓ (b) Fig. 13: A planarity gadget subgraph has the property that every 3-colouring f satisfies f (E) = f (W) and f (N) = f (S). Moreover, every partial assignment f to {N, S, E, W} that satisfies f (E) = f (W) and f (N) = f (S) can be extended to a 3-colouring of the entire subgraph. The gadget is used to transform a given (non-planar) graph G as follows. Draw G in the plane and for each edge vw replace each edge intersection by the planarity gadget. The outer vertices of neighbouring gadgets are identified, and v is iden- tified with W in its neighbouring gadget (see Fig. 13(b)). The resulting graph is CHAPTER13. GRAPHCOLOURINGALGORITHMS 25 planar, and it can be checked that it is 3-chromatic if and only if G is 3-chromatic. Thus, the restriction to planar instances does not make 3-colourability computa- tionally easier. Unlike the case for non-planar graphs, this construction cannot be generalized to larger q > 3, since the decision problem for planar graphs and every q ≥ 4 has answer 'yes' because of the four-colour theorem. Computational complexity The field of computational complexity relates algorithmic problems from various domains to one another in order to establish a notion of computational difficulty. The chromatic number problem was one of the first to be analysed in this fashion. The following reduction, essentially from the seminal paper of Karp [23], shows that computing the chromatic number is 'hard for the complexity class NP' by reducing from the NP-hard satisfiability problem for Boolean formulas on conjunc- tive normal form (CNF). This implies that all other problem in the class NP reduce to the chromatic number. The input to CNF-Satisfiability is a Boolean formula consisting of s clauses C1, C2, . . . , Cs. Each clause C j consists of a disjunction C j = (l j1 ∨ l j2 ∨· · ·∨ l jk) of literals. Every literal is a variable x1, x2, . . . , xr or its negation x1, x2, . . . , xr. The problem is to find an assignment of the variables to 'true' and 'false' that makes all clauses true. Reduction K (Satisfiability using chromatic number). Given an instance C1, C2, . . . , Cs of CNF-Satisfiability over the variables x1, x2, . . . , xr, this reduction con- structs a graph G on 3r + s + 1 vertices such that G can be coloured with r + 1 colours if and only the instance is satisfiable. The graph G contains a complete subgraph on r + 1 vertices {0, 1, . . . , r}. In any colouring, these vertices receive different colours, say f (i) = i. The intuition is that the colour 0 represents 'false', while the other colours represent 'true'. For each variable xi (1 ≤ i ≤ r) the graph contains two adjacent 'literal' vertices vi and vi, both adjacent to all 'true colour' vertices {1, 2, . . . , r} except i. Thus, one of the two vertices vi, vi must be assigned the 'true' colour i, and the other must be coloured 0. The construction is completed with 'clause' vertices w j, one for each clause C j (1 ≤ j ≤ s). Let xi1 , xi2, . . . , xik be the variables appearing (positively or negatively) in C j. Then w j is adjacent to {0, 1, . . . , r} \ {i1, i2, . . . , ik}. This ensures that only the 'true' colours {i1, i2, . . . , ik} are available at w j. Furthermore, if xi appears positive in C j, then w j is adjacent to vi; if xi appears negated in C j, then w j is adjacent to vi. Figure 14 shows the reduction for a small instance consisting of just the clause C1 = (x1 ∨ x2 ∨ x3) and a valid colouring corresponding to the CHAPTER13. GRAPHCOLOURINGALGORITHMS 26 assignment x1 = x3 = true, x2 = false; the edges of the clique on {0, 1, 2, 3} are not shown. Thus, the only colours available to w j are those chosen by its literals. 11 22 33 w1 2 0 0 1 v1 0 v1 0 v2 2 v2 3 v3 0 v3 Fig. 14: A 4-colouring instance corresponding to C1 = (x1 ∨ x2 ∨ x3) Edge-colouring A mapping f : E → {1, 2, . . . , q} is an edge-colouring of G if and only if it is a vertex-colouring of the line graph L(G) of G. In particular, every vertex-colouring algorithm can be used as an edge-colouring algorithm by running it on L(G). For instance, Algorithm I computes the chromatic index in time 2m poly(n), which is the fastest currently known algorithm. Similarly, Algorithm G finds an edge- colouring with (2∆ − 1) colours, but this is worse than Algorithm V. In fact, since ∆ ≤ χ′(G) ≤ ∆ + 1, Algorithm V determines the chromatic index within an addi- tive error of 1. However, deciding which of the two candidate values for χ′(G) is correct is an NP-hard problem, as shown by Holyer [19] for χ′(G) = 3 and Leven and Galil [29] for χ′(G) > 3. Approximating the chromatic number Algorithm V shows that the chromatic index can be very well approximated. In contrast, approximating the chromatic number is much harder. In particular, it is NP-hard to 4-colour a 3-chromatic graph (see [17]). This rules out an approximate vertex-colouring algorithm with a performance guarantee as good as Algorithm V, but is far from explaining why the considerable machinery behind, say, Algorithm R results only in a colouring of size nc for 3-chromatic graphs. The best currently known exponent is c = 0.204 (see [24]). For sufficiently large fixed q, it is NP-hard to find an exp(Ω(q1/3))-colouring for a q-colourable graph. If q is not fixed, even stronger hardness results are known. We saw in Section 6 that the polynomial-time computable function ~χ(G) is a lower bound on χ(G), even though the gap can sometimes be large, say χ(G) ≥ n0.157~χ(G) CHAPTER13. GRAPHCOLOURINGALGORITHMS 27 for some graphs. Can we guarantee a corresponding upper bound for ~χ? If not, maybe there is some other polynomial-time computable function g so that we can guarantee, for example, g(G) ≤ χ(G) ≤ n0.999g(G)? The answer turns out to be 'no' under standard complexity-theoretic assumptions: For every ε > 0, it is NP-hard to approximate χ(G) within a factor n1−ε, as shown by Zuckerman [41]. Counting The problem of counting the q-colourings is solved by evaluating P(G, q). Con- versely, because the chromatic polynomial has degree n, it can be interpolated using Lagrangian interpolation from the values of the counting problem at q = 0, 1, . . . , n. Moreover, note that χ(G) ≥ q if and only if P(G, q) > 0, so it is NP-hard to count the number of q-colourings simply because the decision problem is known to be hard. In fact, the counting problem is hard for Valiant's counting class #P. On the other hand, an important result in counting complexity [21] relates the estimation of the size of a finite set to the problem of uniformly sampling from it. In particular, a uniform sampler such as Algorithm M serves as a 'fully polynomial randomized approximation scheme' (FPRAS) for the number of colours. Thus, provided that q > 4∆, Algorithm M can be used to compute a value g(G) for which (1 − ε)g(G) ≤ P(G, q) ≤ (1 + ε)g(G) with high probability in time polynomial in n and 1/ε for any ε > 0. Much better bounds on q are known (see the survey of Frieze and Vigoda [13]). Without some bound on q, such an FPRAS is unlikely to exist because, with ε = 1 2 , it would constitute a randomized algorithm for the decision problem and would therefore imply that all of NP can be solved in randomized polynomial time. Conclusion Together, the algorithms and reductions presented in this survey give a picture of the computational aspects of graph colouring. For instance, 2-colouring admits a polynomial time algorithm, while 3-colouring does not. In the planar case, 4- colouring is trivial, but 3-colouring is not. An almost optimal edge-colouring can be found in polynomial time, but vertex-colouring is very difficult to approximate. If q is sufficiently large compared to ∆(G) then the set of colourings can be sampled and approximately counted, but not counted exactly. Finally, even the computation- ally hard colouring problems admit techniques that are much better than our initial Algorithm X. None of these insights is obvious from the definition of graph colouring, so the algorithmic perspective on chromatic graph theory has proved to be a fertile source REFERENCES 28 of questions with interesting answers. References 1. R. Beigel and D. Eppstein, 3-coloring in time O(1.3289n), J. Algorithms 111 (2005), 168 -- 204. 2. A. Björklund and T. Husfeldt, Exact algorithms for exact satisfiability and number of perfect matchings. Algorithmica 52 (2008), 226 -- 249. 3. A. Björklund, T. Husfeldt and M. Koivisto, Set partitioning via inclusion -- exclusion, SIAM J. Comput. 39 (2009), 546 -- 563. 4. A. Björklund, T. Husfeldt, P. Kaski and M. Koivisto, Covering and packing in linear space, Inform. Process. Lett. 111 (2011), 1033 -- 1036. 5. A. Björklund, T. Husfeldt, P. Kaski and M. Koivisto, Computing the Tutte polynomial in vertex-exponential time, Proc. 49th Annual IEEE Symposium on Foundations of Computer Science (FOCS 2008), IEEE Computer Society (2008), 677 -- 686. 6. D. Brélaz, New methods to color the vertices of a graph, Comm. Assoc. Comput. Mach. 22 (1979), 251 -- 256. 7. C. Bron and J. Kerbosch, Algorithm 457: finding all cliques of an undirected graph, Comm. Assoc. Comput. Mach. 16 (1973), 575 -- 577. 8. R. L. Brooks, On colouring the nodes of a network, Math. Proc. Cambridge Philos. Soc. 37 (1941), 194 -- 197. 9. E. Chlamtac, Approximation Algorithms Using Hierarchies of Semidefinite Program- ming Relaxations, in Proc. 48th Annual IEEE Symposium on Foundations of Com- puter Science (FOCS 2007), IEEE Computer Society (2007), 691 -- 701. 10. N. Christofides, An algorithm for the chromatic number of a graph. Comput. J. 14 (1971), 38 -- 39. 11. V. Chvátal, Perfectly ordered graphs, Topics on Perfect Graphs (eds. C. Berge and V. Chvátal), Ann. Discrete Math. 21 (1984), 63 -- 68. 12. U. Feige, M. Langberg and G. Schechtman, Graphs with tiny vector chromatic num- bers and huge chromatic numbers, SIAM J. Comput. 33 (2004), 1338 -- 1368. 13. A. Frieze and E. Vigoda, A survey on the use of Markov chains to randomly sample colorings, Combinatorics, Complexity and Chance, Oxford University Press, 2007. 14. B. Gärtner and J. Matoušek, Approximation Algorithms and Semidefinite Program- ming, Springer, 2012. 15. G. Grimmett and C. McDiarmid, On colouring random graphs, Math. Proc. Cam- bridge Philos. Soc. 77 (1975), 313 -- 324. 16. M. Grötschel, L. Lovász and A. Schrijver, Geometric Algorithms and Combinatorial Optimization, Springer, 1988. 17. V. Guruswami and S. Khanna, On the hardness of 4-coloring a 3-colorable graph, SIAM J. Discrete Math. 18 (2004), 30 -- 40. 18. G. Haggard, D. J. Pearce and G. Royle, Computing Tutte polynomials, Assoc. Comput. Mach. Math. Software 37 (2010), Article 24. REFERENCES 29 19. I. Holyer, The NP-completeness of edge-coloring, SIAM J. Comput. 10 (1981), 718 -- 720. 20. S. Huang, Improved hardness of approximating chromatic number, Approxima- tion, Randomization, and Combinatorial Optimization. Algorithms and Techniques, Springer Lect. Notes Comput. Sci. 8096 (2013), 233 -- 243. 21. M. Jerrum, L. G. Valiant and V. V. Vazirani, Random generation of combinatorial structures from a uniform distribution, Theor. Comput. Sci. 43 (1986), 169 -- 188. 22. D. R. Karger, R. Motwani and M. Sudan, Approximate graph coloring by semidefinite programming, J. Assoc. Comput. Mach. 45 (1998), 246 -- 265. 23. R. M. Karp, Reducibility among combinatorial problems, Complexity of Computer Computations (eds. R. E. Miller and J. W. Thatcher), Plenum (1972), 85 -- 103. 24. K. Kawarabayashi and M. Thorup, Combinatorial coloring of 3-colorable graphs, Proc. 53rd Annual IEEE Symposium on Foundations of Computer Science (FOCS 2012), IEEE Computer Society (2012), 68 -- 75. 25. A. Kosowski and K. Manuszewski, Classical coloring of graphs, Graph Colorings (ed. M. Kubale), Amer. Math. Soc. Contemp. Math. 352 (2004), 1 -- 20. 26. L. Kucera, The greedy coloring is a bad probabilistic algorithm, J. Algorithms 12 (1991), 674 -- 684. 27. M. Langberg, Graph coloring, Encyclopedia of Algorithms (ed. M. Kao), Springer (2008), 368 -- 371. 28. E. L. Lawler, A note on the complexity of the chromatic number problem, Inform. Process. Lett. 5 (1976), 66 -- 67. 29. D. Leven and Z. Galil, NP completeness of finding the chromatic index of regular graphs, J. Algorithms 4 (1983), 35 -- 44. 30. L. Lovász, Coverings and coloring of hypergraphs, Proc. Fourth Southeastern Confer- ence on Combinatorics, Graph Theory, and Computing, Boca Raton, Congr. Numer. 8 (1973), 3 -- 12. 31. F. Maffray, On the coloration of perfect graphs, Recent Advances in Algorithms and Combinatorics, CMS Books Math., Springer (2003), 65 -- 84. 32. D. W. Matula, A min -- max theorem for graphs with applications to graph coloring, SIAM Rev. 10 (1968), 481 -- 482. 33. J. Misra and D. Gries , A constructive proof of Vizing's Theorem, Inform. Proc. Lett. 41 (1992), 131 -- 133. 34. J. W. Moon and L. Moser, On cliques in graphs, Israel J. Math. 3 (1965), 23 -- 28. 35. L. Stockmeyer, Planar 3-colorability is polynomial complete, Assoc. Comput. Mach. SIGACT News 5 (1973), 19 -- 25. 36. G. Szekeres and H. S. Wilf, An inequality for the chromatic number of a graph, J. Combin. Theory 4 (1968), 1 -- 3. 37. E. Tomita, A. Tanaka and H. Takahashi, The worst-case time complexity for gener- ating all maximal cliques and computational experiments, Theor. Comput. Sci. 363 (2006), 28 -- 42. 38. D. J. A. Welsh, and M. B. Powell, An upper bound for the chromatic number of a graph and its application to timetabling problems, Comput. J. 10 (1967), 85 -- 86. REFERENCES 30 39. H. Whitney, A logical expansion in mathematics, Bull. Amer. Math. Soc. 38 (1932), 572 -- 579. 40. A. Wigderson, Improving the performance guarantee for approximate graph coloring, J. Assoc. Comput. Mach. 30 (1983), 729 -- 735. 41. D. Zuckerman, Linear degree extractors and the inapproximability of Max Clique and Chromatic Number, Theory of Computing 3 (2007), 103 -- 128. 42. A. A. Zykov, On some properties of linear complexes (Russian), Math. Sbornik 24 (1949), 163 -- 188.
1907.02900
1
1907
2019-07-05T15:44:27
HashGraph -- Scalable Hash Tables Using A Sparse Graph Data Structure
[ "cs.DS", "cs.DB", "cs.DC" ]
Hash tables are ubiquitous and used in a wide range of applications for efficient probing of large and unsorted data. If designed properly, hash-tables can enable efficients look ups in a constant number of operations or commonly referred to as O(1) operations. As data sizes continue to grow and data becomes less structured (as is common for big-data applications), the need for efficient and scalable hash table also grows. In this paper we introduce HashGraph, a new scalable approach for building hash tables that uses concepts taken from sparse graph representations--hence the name HashGraph. We show two different variants of HashGraph, a simple algorithm that outlines the method to create the hash-table and an advanced method that creates the hash table in a more efficient manner (with an improved memory access pattern). HashGraph shows a new way to deal with hash-collisions that does not use "open-addressing" or "chaining", yet has all the benefits of both these approaches. HashGraph currently works for static inputs, though recent progress with dynamic graph data structures suggest that HashGraph might be extended to dynamic inputs as well. We show that HashGraph can deal with a large number of hash-values per entry without loss of performance as most open-addressing and chaining approaches have. Further, we show that HashGraph is indifferent to the load-factor. Lastly, we show a new probing algorithm for the second phase of value lookups. Given the above, HashGraph is extremely fast and outperforms several state of the art hash-table implementations. The implementation of HashGraph in this paper is for NVIDIA GPUs, though HashGraph is not architecture dependent. Using a NVIDIA GV100 GPU, HashGraph is anywhere from 2X-8X faster than cuDPP, WarpDrive, and cuDF. HashGraph is able to build a hash-table at a rate of 2.5 billion keys per second and can probe at nearly the same rate.
cs.DS
cs
HashGraph - Scalable Hash Tables Using A Sparse Graph Data Structure Oded Green NVIDIA Computational Science and Engineering, Georgia Institute of Technology 9 1 0 2 l u J 5 ] S D . s c [ 1 v 0 0 9 2 0 . 7 0 9 1 : v i X r a ABSTRACT Hash tables are ubiquitous and used in a wide range of applica- tions for efficient probing of large and unsorted data. If designed properly, hash-tables can enable efficients look ups in a constant number of operations or commonly referred to as O(1) operations. As data sizes continue to grow and data becomes less structured (as is common for big-data applications), the need for efficient and scalable hash table also grows. In this paper we introduce Hash- Graph, a new scalable approach for building hash tables that uses concepts taken from sparse graph representations -- hence the name HashGraph. We show two different variants of HashGraph, a simple algorithm that outlines the method to create the hash-table and an advanced method that creates the hash table in a more efficient manner (with an improved memory access pattern). HashGraph shows a new way to deal with hash-collisions that does not use "open-addressing" or "chaining", yet has all the benefits of both these approaches. HashGraph currently works for static inputs, though recent progress with dynamic graph data structures suggest that HashGraph might be extended to dynamic inputs as well. We show that HashGraph can deal with a large number of hash-values per entry without loss of performance as most open-addressing and chaining approaches have. Further, we show that HashGraph is indifferent to the load-factor. Lastly, we show a new probing algorithm for the second phase of value lookups. Given the above, HashGraph is extremely fast and outperforms several state of the art hash-table implementations. The implementation of HashGraph in this paper is for NVIDIA GPUs, though HashGraph is not ar- chitecture dependent. Using a NVIDIA GV100 GPU, HashGraph is anywhere from 2X-8X faster than cuDPP, WarpDrive, and cuDF. HashGraph is able to build a hash-table at a rate of 2.5 billion keys per second and can probe at nearly the same rate. 1 INTRODUCTION Hash tables can be used for inner join [11], group-by and aggrega- tion [18], query processing [9], looking up kmers in DNA sequenc- ing [26], intersecting voxel geometric objects [2], and counting triangles in graphs [10]. In some cases a dynamic hash-table is needed though for many of these applications a static hash-table is enough (where static refers to the fact that the input data is known a-priori before the construction of the hash-table). Hashing is a major building block for numerous applications requiring lookups, such as associative arrays. One widely used case is for set intersection, which are also used in database join and group-by operations. While many of these lookup operations can be implemented by first sorting the data, this can in fact lead to significant overheads. Thus, when the input data is sorted it is quite likely that the sorted intersection will outperform building a hash-table followed by probing. However, when the data is not sorted, which is very common, then hashing can prove to be more effective. In fact, the question of which method, sorting vs. hashing, is preferable is one that has received significant attention [20]. To some degree, this question still remains open with new algorithms being developed on both fronts to improve the performance of both. For sorting, this includes new scalable algorithms which have better load-balancing, use more threads, and fully utilized new vector instruction sets. For hashing, new algorithms find better ways to reduce the number of conflicts, improve spatial locality while removing random accesses, and reducing storage overhead. In this paper, we present HashGraph. HashGraph is a scalable hashing algorithm for massively multi-threaded systems. We show two simple algorithms for creating a hash-table based on the widely used CSR (Compressed Sparse Row) data structure. CSR is used for representing sparse graphs and matrices -- hence the term "graph" in HashGraph. Specifically, we show that it is possible to create a hash-table by visually thinking about the result of the hash as a graph. Contributions In this paper we introduce two novel algorithms for creating a static hash table. Both these algorithms are simple, straightforward, and give the same output. The first algorithm consists of five par- allel for loops and one parallel prefix operation. The second and more efficient algorithm consists of eight parallel for loops and two parallel prefix operations. The straightforwardness of these algorithms, unlike many previous hashing algorithms, also means that they can be easily taught, adopted, and used by non expert programmers. Specifically, HashGraph is currently designed for applications requiring static data sets such as inner join, SpMV, and set intersections. We show that HashGraph has all the benefits of chaining and open-hashing without their downsides. By using atomic instruc- tions (namely an Atomic-Add operation), which is supported on most modern processors, we can build the hash-table by pre-processing the data. Specifically, in a first sweep across the data we are able to determine the exact number of elements that will be hashed to a specific index. With this information, we can then allocate the exact amount of memory for each index. This effectively removes our need to deal with collisions. Thus, we get a benefit similar to chaining but with much better locality (chaining requires random memory accesses). We get improved locality over open-hashing as the arrays have better locality and we are not required to iterate the table until an empty entry is found. Further, a unique feature of HashGraph is its insensitivity to load factor: we show that we do not need to increase the size of the hash-table to have double the number of input entries, as is typically required by open-hashing based approaches to ensure that insertion can be achieved in O(1). From a performance standpoint, HashGraph is able to hash in- puts at a rate of 2.5 billion keys per second. This is almost twice as fast as several leading implementations for the simplest case where the input is the sequence of unique keys. When the keys are not unique and duplicates appear multiple times, then HashGraph can be as much as 40× faster. HashGraph also closes the performance gap between hash based implementations and sorting based im- plementations. Using HashGraph we introduce a new method for hash table probing and set intersection that can work at nearly the same rate as our table building. 2 BACKGROUND Hash tables are used across a wide range of application for effi- ciently looking up the existence of values in unsorted data. Given an input array of length N , building a hash-table typically takes O(N) of operations. Given a good hashing function, ideally looking up a value takes O(1) operations. In contrast sorting the input can take either O(N) or O(N · loд(N)) operations (depending if a radix- sort or merge-sort is used, respectively). Looking up values, using a binary search, then requires an O(loд(N)) operations. These the- oretical bounds discuss the number of operations needed to create the data structure used for looking up values, but they do not cover the amount of locality in the memory accesses or the available parallelism. These tend to be dependent on a specific algorithm and implementation. Hashing. As a preliminarily we define a hash function as fol- lows: hash(a) ∈ N → b ∈ {0, .., N/CV − 1} (1) , where N is in the length of the input. These functions take the original input and transforms them to numbers in the range of {0, .., N/CV }. These values are the entries of the hash-table. In practice, most hash(a) functions return values in N, yet these values are divided by N/CV and the remainder is taken to ensure that range is reduced to a reasonable size -- crucial for efficient memory utilization. Murmur hash [3] is one such func- tion that meets this criteria. CV is typically referred to as the load factor of the hash-table. The load factor is referred to as C, we have replaced this with CV as V is used to represent "vertices" used by our HashGraph. To reduce the storage overhead of the hash-table, CV can be set to values close to 1. However, this causes many challenging performance problems, including collision management and performance problems. As such CV is typically set in the range of [0.5, 0.8]. The following lists several approaches for dealing with conflicts: Separate Chaining - each entry in the hash table maintains a linked-lists of values that have been hashed to it. For small CV = 1, the linked lists tend to get longer as there are fewer hash values and the likelihood of a collision increases. This reduces performance due to an increased number of linked-list traversals and random memory access. Open Addressing - hash-values are stored directly within the table itself. For each hashed value, the table is scanned from the initial hash value until an empty spot within the table is found. While open-addressing has better caching than chaining, finding an empty spot can be costly. Open addressing is extremely costly when the number of duplicates is high or if a hash-value is used by numerous input values. Thus, if a value in the input exists d times, finding an empty spot for each requires O(d 2) operations. 2 To reduce the likelihood of collisions for differnt input values, the load factor is typically set to C = 0.5. Coalesced Hashing - uses a mix of separate chaining and open addressing. Rather than using a linked list for storing the elements, entries in the hash-table are used for storing elements and an addi- tional pointer is used for storing the location of the next entry in a given chain. This typically gives improved locality over chaining and it can reduce the number of lookups for finding an unoccu- pied entry. This comes at the cost of additional storage (for pointer storage). In practice, our new HashGraph algorithm is closer to coalesced hashing though it does not store additional pointers for finding the next empty entry. 2-Choice Hashing - is an approach that uses two different hash functions with two tables. The hashed value is placed into the table with fewer entries. This can lead to better balancing [27]. Cuckoo Hashing [25] is similar to 2-Choice Hashing and can be extended to use more than one hash functions. However, un- like 2-Choice Hashing when a collision occurs across all the hash- functions one of the previous hash values is removed from the table and hashed using a different hash function. This is repeated until there are no more collisions. Thus, collisions can be quite costly. Minwise Hashing - is an approach for reducing the storage cost by using fewer bits [21]. Parallel Hashing Algorithms. One of the first parallel hash- tables for the GPUS was first introduced in [9]. The table is split into multiple smaller tables that can be managed within smaller shared memory. Not long after this, a newer GPU algorithm was introduced in [2] based on Cuckoo hashing. The cuDPP [15] library is based on [2]. Like most Cuckoo hashing approaches, the table building phase is greatly impacted by the appearance of duplicate values and results in a longer build time. Ashkiani et al. [5] show a scalable approach of hashing using dynamic hash-tables for the GPU called SlabHash. Specifically, Slab- Hash is based on blocked linked-lists such that the payload of each node of the linked-list can hold multiple keys (or key-value pairs). SlabHash's performance is nearly equal to that of cuDPP [15]. WarpDrive [17] is a new hashing algorithm for the GPU. Warp- Drive scales to multiple devices due to the multi-split algorithm that they have developed. Currently WarpDrive can only work on building hash tables where the input is unique. An extensive review of multi-split approaches for the GPU can be found [4]. Stadium Hashing [19] is another hashing algorithm designed for GPU systems. Specifically, Stadium Hashing can work both in-core and out-of-core. This means that the hash-table can be larger than the physical memory of the GPU, which is prohibitive in some instances. Stadium hashing is based on Cuckoo hashing. Its performance is similar to cuDPP [15]. Stadium Hashing is at it best when the hash table is larger than GPU's memory. In [23] the "Folklore" hashing algorithm for the CPU is presented. Folklore is able to build the hash table at a rate of 300 millions keys per second on a 24 core (48 thread) processor and outperforms Intel's Threading Building Block Library. Folklore has the ability to support dynamically growing tables, though this brings a significant performance penalty. A hardware optimized hash-join algorithm is given [7]. Specifically, this algorithm targets hardware features such as SIMD instruction and is able to build and probe a hash-table at 200 million keys per second. This was later improved to 700 million keys per second at its peak rate in [6], though on average the rate was close to 450 million keys per second. While faster than Folklore [23] , which reports the build rate and not the join rate as [6, 7], these rates are still significantly slower than current hash-table build rates on current GPU systems. In [1, 11] a thorough review of hash-join algorithms and opti- mizations for multi-threaded CPU processors is given. Many CPU implementations [6, 7, 11, 20] focus on reducing the number of cache misses. These tend to use some sort of data partitioning which is part of a pre-processing phase. Both [20] and [11] give each thread its own set of partitions which will later be merged with the results of the partitions . Thus, as the number of threads and partition grows, this can prove to be expensive. Unlike the GPU which requires tens of thousands of software threads to keep the device busy, most modern CPU systems only require fewer than a hundred threads to keep the processor fully utilized. This leads to very different partitioning approaches as well as optimizations. Many CPU optimizations for hash tables are not effective on the GPU. Lastly, several algorithms have been designed for scalable dis- tributed hash tables that can be used across thousands of CPUs cores and processors. This includes [26] and [8]. Both were tested on a CPU cluster with four thousand CPU cores. These distributed joins used different hashing functions to manage collisions. 3 HASHGRAPH In this section we introduce HashGraph, a new and scalable ap- proach for building hash tables that uses a sparse graph-like data structure for static data sets, specifically compressed sparse row (CSR). In our CSR representations the vertices represent the hash values and the edges point to the original (pre-hashed) input. Hash- Graph is especially efficient for the hash table building phase, though it can also be used for the probing phase. We show two variations of the building phase using HashGraph. The first version, called HashGraph-V1, (Sec. 3.2) introduces a sim- ple version of the HashGraph concept and is implemented with a handful of parallel for-loops. Using this version we highlight key features of the HashGraph. We then present a second optimized variation, denoted HashGraph-V2, that reduces the number of cache misses and increases performance. We show that by adding an addi- tional preprocessing phases and several additional parallel for-loops we improve the performance over the first algorithm by roughly 4×. HashGraph can utilize conventional probing mechanisms, yet, the uniqueness of the sparse graph data structure enables us to introduce a new probing method that benefits from an increased amount of locality. Specifically, this probing mechanism is unique to HashGraph. 3.1 Hashing Using a Graph Data Structure As a first step, we show the relationship between hashing and graphs -- this resembles a bipartite graph which can also be repre- sented using CSR. The following subsections cover how to actually build the CSR-like data structure in an efficient manner whereas this section focuses on explaining why that representation is cor- rect. Fig. 1 (a) depicts an example of input array with 5 inputs that are hashed into a range of 10 values. In this example the number 3 appears twice and is hashed to the same value as the value 10121. 3 Algorithm 1: HashGraph-V1 - simple algorithm for building hash table. Note V = N/CV . for i = 0 : 1 : N − 1 do in parallel // These are the vertices of the graph HA[i] = hash(A[i]) mod V for i = 0 : 1 : V − 1 do in parallel Counter Arr ay[i] ← 0 for i = 0 : 1 : N − 1 do in parallel AtomicAdd(Counter Arr ay[HA[i]], 1) // The offset array is not used in the computation. Rather it is stored for the probing phase s.t. the lengths of each hash table entry is known. Of f setArr ay ← Pr ef ixSum(Counter Arr ay) for i = 0 : 1 : V − 1 do in parallel Counter Arr ay[i] ← 0 for i=0:1:N-1 do in parallel pos ← AtomicAdd(Counter Arr ay[HA[i]], 1) E[pos] ← (A[i], i) This results in one of the hash values corresponding to three in- puts. Note that the result of the hash is essentially a bipartite graph. Going from the input to the hash is trivial (simply use the hash func- tion). The reverse direction is achieve by having the hash-values point back to the inputs that were hashed into them. For most hash tables, where the input is of size N , the size of the hash range is N . Typically CV = 0.5 for open-addressing based CV methods (to reduce collisions and to ensure O(1) access time). For Hash Graph, we will show in Section 5 that CV = 1 gives better performance than CV = 0.5 despite common intuition that a lower load-factor makes it easier to hash and place keys into the hash. Compressed Sparse Row. CSR is a widely used data structure to represent sparse datasets for both matrix and graph based problem. CSR stores only non-zero values of the input. For each row, the non- zero values are "compressed" such that the value and the column of the value are stored. In graph terminology, each of these rows is the adjacency array of a given vertex also referred to as the edges of the vertex. CSR uses a small number of arrays 1) for storing the vertex sizes (array length is V + 1) and 2) an array for the edges (an array of size of E elements). The vertex adjacency array sizes are in fact stored via an offset array which points to the starting point of a vertex's adjacency array. The end of the adjacency array is the offset to the next vertex. Thus, the size of a vertex's adjacency array is the difference in the position of two consecutive vertices: v and v + 1. The edges are stored as either a single array of tuples (column, value) or via two arrays (one for columns and one for values). Fig. 1 (b) depicts how to represent the reverse relationship from hash-values to the inputs using CSR for the example in Fig. 1 (b). Note, some hash entries might not have inputs that are hashed into them, as such their adjacency array length is zero. 3.2 HashGraph Version 1.0 In this subsection we introduce a simple approach for creating the HashGraph data structure. Pseudo code for this can be found in Alg. 1. Note, that algorithm for building HashGraph is fairly straightforward and consists of five simple parallel for-loops and one parallel prefix sum operation. In contrast many parallel hash- table implementations consist of either one large monolithic code section or an advanced parallel sections that includes numerous barriers and synchronizations. In most cases, it is the fact that these algorithms are so complex that they are designed for a specific processing system. For example, cuDF's [24] hash table uses a (a) Simple Hashing (b) Hashing Using CSR fig. 1: (a) Input array with corresponding hash values. This is a bipartite graph with input values on one side and hash values on the other side. (b) Using a CSR-like data structure, a bipartite graph where the hash values point to the inputs. single GPU kernel to build the a hash table. In contrast, HashGraph uses a large number of simple kernels. The following explains the process for building a HashGraph. 1) Each value in the input is hashed into the range of the hash- table. This operation is highly parallel and uses a sequential memory access pattern making it cache-friendly. 2) For each vertex in the graph, aka the set of possible hash values, the number of instances of that entry is set to zero. This phase is also cache friendly due to its sequential memory access. 3) For each of the hash values, computed 1) , we proceed to count the number of instances that each hash value appears in the origi- nal input. When this for-loop is completed, we know how many elements will belong to each vertex in the CSR data structure. This parallel for-loop loop is computationally more expensive than the first for-loop even though both loops iterate over an equal number of elements. Specifically, this for-loop uses atomic instructions for counting the number of instances and writes to random places in memory. 4) A prefix sum array is computed. Parallel prefix sum operations are well studied [12, 16, 29]. The result of the prefix sum operation is the offset array found in CSR. Through this offset array we can now partition the edge array based on the number of values hashed to each entry. 5) For each entry in the table, the number of instances of that array is reset to zero. This array is used in the final phase for maintaining the relative position of hashed elements with in the list that the have been assigned to. This phase is cache friendly due to its sequential memory access. Note, the O f f SetArray is stored and used for the probing phase. 6) In the last and final phase, the hashed values are actually placed in the HashGraph. Specifically, each hash-value is placed in the element list that it belongs to by getting the position from the offset array and the relative position within that array using atomic instructions. Collision Management. The performance of traditional hashing tables is highly dependent on the load factor and the hash range. As traditional hash table becomes denser, the overhead of finding an empty spot in an open-addressing based hash table becomes more expensive. This is problematic for chaining based hash tables and will results in longer lists ("chains") and will make probing significantly slower. HashGraph Collision Management. Recall, the load factor for HashGraph is different than it is for open-addressing based methods. In HashGraph the load factor states how many "vertices" will be in the graph or what is the range of the hash values in the hash table and not the size of the table. In HashGraph the table size is exactly the size of the input size. Unlike open-addressing which requires searching for an empty spot in the hash table to find the end of a "value-chain", in HashGraph the entries for a specific hash value are in consecutive memory. Further, the length of that chain is known and as such only the relevant values are accessed. Lastly, as the HashGraph building phase includes a preprocessing for counting the number of entries hashed to a specific value, the performance of HashGraph does not degrade if an entry exists numerous times. This will be discussed in more detail in Sec. 5.1 (Fig. 3). Work and Time Complexity For Building HashGraph-V1. The fol- lowing analyzes the work complexity for Alg. 1. First, note all for-loops iterate over N or CV elements. Only the first for-loop re- quires special attention as the work complexity is dependent on the cost of doing the hashing, namely O(N · Hash). For the remaining ). In [16, 29] it for-loops work complexity is either O(N) or O( N CV was shown that a parallel prefix sum operation can be work efficient (linear amount of work with respect to the array size), O( N ). This CV + N · hash). When leads to a total time complexity of O(N + N CV Hash O(1) (which is the case for many hash functions), the overall work complexity can be simplified to O(N + N ). CV Given P cores and the above work complexity, we can evaluate the time complexity for HashGraph as follows. All five for-loops are embarrassingly parallel and are easily partitioned across P cores, as their time complexities is either O(N/P) or O( N CV ·P ). The time complexity of the prefix operation is O(N/P + loд(P)) [16, 29]. As such the time complexity can be written as O(N/P + N +loд(P)). CV ·P In practice loд(P) will be significantly smaller than the other com- ponents and will be negligible for most inputs. Storage Complexity. In the following storage complexity analysis we avoid using the standard O() notation as the constants matter. Instead, we offer a complexity analysis that states the array sizes, in number of elements. For the sake of breivity, we do not consider the actual bit and byte representation. The size of the table is exactly N elements. The table itself can store either only the unhashed value or the unhashed value and the index of that value in the input array (this is needed for join operations). Further, we use two additional arrays of size N for the counter and the prefix sum CV array. In practice, HashGraph works well with CV = 2. a large table with N CV In contrast, other open-addressing hash tables typically require elements and CV = 0.5 for performance 4 Index01234Value3127431012Hash0123456789Edge10234Value1237431012Vertex0123456789Offset00114444455 Algorithm 2: HashGraph-V2 - cache efficient algorithm for building hash. Note V = N/CV . // Phase 1: Bin Counting BinSize ← V Bins for i = 0 : 1 : Bins − 1 do in parallel BinCounter Arr ay[i] ← 0; for i = 0 : 1 : N − 1 do in parallel bin ← hash(A[i]) mod V ; AtomicAdd(BinCounter Arr ay[bin], 1); BinSize ; BinSize // Phase 2: Bin Placement and Data Reorganization BinOf f setArr ay ← Pr ef ixSum(BinCounter Arr ay); for i = 0 : 1 : Bins − 1 do in parallel BinCounter Arr ay[i] ← 0; for i = 0 : 1 : N − 1 do in parallel bin ← hash(A[i]) mod V ; pos ← atomicAdd(BinCounter Arr ay[bin], 1) + BinOf f setArr ay[bin]; ReorдA[pos] ← {A[i], i }; // Phase 3: HashGraph Creation for i = 0 : 1 : V − 1 do in parallel Counter Arr ay[i] ← 0; for i = 0 : 1 : N − 1 do in parallel pos ← hash(ReorдA[i].val) mod V ; atomicAdd(Counter Arr ay[pos], 1); // The offset array is not used in the computation. Rather it is stored for the probing phase s.t. the lengths of each hash table entry is known. Of f setArr ay ← Pr ef ixSum(Counter Arr ay); for i = 0 : 1 : V − 1 do in parallel Counter Arr ay[i] ← 0; for i=0:1:N-1 do in parallel pos ← AtomicAdd(Counter Arr ay[HA[i]], 1); E[pos] ← (A[i], i); reason. Due to the difference values of CV used by the hash tables, HashGraph requires a similar number of elements. 3.3 HashGraph Version 2.0 We introduce a modified version of HashGraph that is more memory subsystem friendly: cache efficient and with improved memory locality. HashGraph-V2 (Alg. 2) increases the number of parallel for- loops from five loops to eight loops and uses two parallel prefix sum operations instead of just one. Yet, all these for-loops are friendly to the memory subsystem and have good spatial and temporal memory accesses. HashGraph-V2 consists of three phases, two of them reorganize the input in a cache friendly manner. Intuition for two phase of data movement. - in a preliminary phase, we count the number of hash values that fall in a specific range. This is done by binning hash values together. The number of bins is dictated by the bin-size and the cache size. Ideally, the number of elements in each bin ("bin size") should also fit into the cache. Thus we want to avoid small bins (equivalent to HashGraph-V1) or a large bins (that are too large to be cached). In practice, for hash tables with hundreds of millions of entries1 we found that a good number of bins is roughly 32k. For these sizes, the bins on average have a few hundreds of thousands of elements and as such each bin can fit in the last level cache (referred to as the LLC). This allows us to bring one bin at a time in the LLC and then reorganize the bin efficiently within the cache. The three phases found in Alg. 2 are as follows: Phase 1: Bin Counting - given an array of Bins where each each bin is of size BinSize, we count the number of elements hashed into each range. Specifically, the bin ranges are from (0...BinSize − 1), (BinSize...2 · BinSize − 1), ..., and so forth. Also, the array Bins is 1We tested up to 512M entries Algorithm 3: HashGraph-Probe-New - New hash table prob- ing algorithm that uses two HashGraph for the probing. IntersectAdjacencyArray receives two lists and their lists. // Create two HashGraph HGA ← H ashGr aph_V 2(A, NA, V ); HGB ← H ashGr aph_V 2(B, NB, V ); // Intersection for i = 0 : 1 : V − 1 do in parallel IntersectAd jacencyArr ay(HGA[i], HGB[i]) cache-able making this operation efficient. Once the hash values have been counted, a prefix is computed across the bins. The parallel for-loops in this phase have good spatial locality. Phase 2: Bin Placement and Data Reorganization - the original input A is re-ordered into a new array ReorдA. The new array is a tuple of two values: the value of A[i] and its index i (needed for the hash-table itself) -- this doubles the memory footprint; however, it improves the spatial and temporal locality of the memory accesses. Note, as the number of Bins is relatively smaller, the cache line that each of these bins points to is also cache-able -- this means that writing the values of ReorдA is cache efficient. Phase 3: HashGraph Creation - the final phase takes the reorga- nized data and creates the HashGraph in a second sweep over the data. The data is moved into its final position by counting the number elements that will be hashed into each element. Similar to the previous phase, this phase also has good spatial and temporal locality. Larger Inputs. For the sake of simplicity in HashGraph-V2 and its pseudo code (Alg. 2), we focused on only one iteration of relabeling. However, for data sets with billions and trillions of records in the input it is very likely that either the number of bins needed for the efficient relabeling will be so high that it cannot fit into the LLC. As it might be necessary to use multiple iterations of relabeling, thought its quite likely for the trillion of inputs no more than two or three phases of re-ordering will be needed or perhaps a cache oblivious algorithm. Such approaches have already been investigated for large shared-memory systems. This paper does attempt to solve this problem, yet we do not ignore the fact that this could be a problem for larger inputs. We think that a multiple tier HashGraph could be useful. Work and Time Complexity For Building HashGraph-V2. For the sake of brevity, we reuse the analysis used for the first algorithm. First note that all the for-loops go over: Bins, N , or N elements. CV The complexities of these loops are identical to those found in the HashGraph-V1 algorithm. While the number of for-loops has increased, we can still write the work complexity as: O(Bins + ). As Bins << N we can rewrite the work complexity as N + N CV O(N + N ) similar to the first algorithm. The time complexity is CV CV ·P ), similar to the first algorithm. O(N/P + N Storage Complexity. HashGraph-V2 has a larger memory foot- print that HashGraph-V1. Specifically, the relabeled array doubles it foot print. 3.4 Probing Using HashGraph The probing process in a hash-table is the phase in which the values from a second input are looked up within the hash table created from the first input. In the case of set intersection, all the values of 5 the second set are looked up inside the hash-table to find common elements. Give the fact that HashGraph shares structural similarities with open-addressing, this enables using the probing mechanism of open-addressing for HashGraph. We refer to this approach as HashGraph − Probe − Standard. An interesting artifact of using this probing mechanism with HashGraph is that it will have better performance with HashGraph than it will with open-addressing. Specifically, HashGraph will iterate over fewer entries than open- addressing (as different hash-values can create a longer chain of entries within the table due to local collisions). The uniqueness of HashGraph allows designing a new and cache efficient probing mechanism. We refer to this approach as HashGraph− Probe − N ew. This approach can be especially efficient for join operations in databases. Pseudo code for our new probing mech- anism can be found in Alg. 3 -- note the simplicity of this prob- ing algorithm. Specifically, given two input sets we create two HashGraphs -- one for each input. We can the proceed to intersect the adjacency arrays for the corresponding lists in each of the table. The benefit of doing these list intersections is cache locality. For simplicity, assume that the first hash-table, A, has a set of elements Ax = Ax,1, Ax,2, Ax,3, ... that have been hashed to the value x. Now assume that the input B has the following Bx = Bx,1, Bx,2, Bx,3, ... set of values of hashed to x. By using HashGraph−Probe−Standard, for each element in Bx , the elements of Ax need to be fetched in the memory. In contrast, by using HashGraph − Probe − N ew we can fetch in Ax only once into the cache and reuse that data. In Sec. 5 we show that the cache reuse is substantial. We believe that the new probing function will be useful some applications such as SpGEMM where the cost of building the second hash table gets amortized by re-use. Specifically, consider the need to intersect multiple rows and columns in a sparse setting. The HashGraph for each of these rows or columns needs to be built once but can be used in multiple intersections. With HashGraph-V2, we showed how to create the hash table in a cache efficient manner. Thus, the new probing approach is also cache efficient. The benefit of our new probing approach is that if we can further improve the building phase, then probing itself can also become faster and less dependent on random memory accesses. The trade off of HashGraph−Probe−N ew is that we need to build an additional HashTable to get is performance. Thus, the decision on using HashGraph − Probe − Standard vs. HashGraph − Probe − N ew could very much depend on the data and the application and available storage. In Sec. 5, we show several instances that HashGraph−Probe−N ew is faster in the context of join operations. 4 EXPERIMENTAL SETUP System and Configuration. Our implementation of HashGraph is in CUDA and targets NVIDIA'sGPU. The GPU used in this experi- ment is the NVIDIA Quadro GV100. The GV100 is a Volta (micro- architecture) based GPU with 80 SMs (streaming multi-processors) and 64 SPs (streaming processors) per SM, for a total of 5120 SPs. The SPs are lightweight hardware threads that are sometimes referred to as CUDA threads. In practice, roughly 40K software threads are required for fully utilizing the GPU. The GV100 has a total of 32GB of HBM2 memory and 6MB of shared-cache between the SMs. Each SM also has a configurable shared memory of 96KB. The GV100 6 has 640 tensor cores, though these are not used in our experiments. The GV100 has two variants, PCI-E and SXM2, form factors. Our GV100 is the PCI-E variant that has a peak power consumption of 250 watts. The GV100 is connected to an Intel i7 − 7800X (6 cores with 12 threads) running at 3.5 GHz with a 8.5MB last-level cache. Lastly, to benchmarking the hashing functionality on a CPU sys- tem we use a dual-processor Intel Xeon Platimun 8168 system. This system has 48-cores with 96 threads with a frequency of 2.7GHz, and 1.5 TB of DRAM. Frameworks. As our implementation targets the GPU, we primar- ily compare against other leading GPU implementation though we also compare to one of the fastest CPU based hash tables used for inner joins. To compare fairly against all the GPU implementations, we benchmark the table creation and table probing processes sepa- rately. We do this as the GPU implementations clearly distinguish between these phases in the implementations. Further, this allows better performance analysis to see if one of the phases is a per- formance bottleneck. For the CPU implementation found in [6, 7], which was designed for inner joins, we were not able to separate the building and probing phases, as such we compare the total time. cuDPP [15] is one of the first hast table implementations for the GPU and is also one of the best performing. cuDPP uses a Cuckoo based hashing and uses open addressing. The hash table built by cuDPP is static. It does not support insertions or deletions. WarpDrive [17] is a GPU specific hash table that gets good performance by utilizing several hardware features such as warp synchronization operations and warp groups. Note, WarpDrive currently only works with hash-tables were all in the values in the input are unique -- this is a big restriction for real data sets. The hash table built by WarpDrive is static. It supports insertions but does not support deletions (as this requires adding a special marker for deleted elements. cuDF [24] is a framework for GPU dataframes. cuDF supports a wide range of ETL (Extract, Transform, Load) functionality on the GPU. cuDF uses a linear based open addressing approach for its hash table. The hash table built by cuDPP is static. It does not support insertions or deletions. MC-Hash [6, 7] MC-Hash (multi-core hashing) is one of the fastest hash-tables on CPU systems. Specifically, MC-Hash targets join operations commonly used in data-bases, though it can also be utilization for other use-cases. The GPU implementations use open address based tables. As such their performance is highly dependent on the load factor. By default we set the load factor to 50% and allocate twice as many entries in the hash table then those found in the input. For the prob- ing phase, we focus on probing the hash table with a secondary input array (similar to the process found in joins or list intersec- tions). Note, several of these frameworks support insert operations into the hash-table before it fills up. They do not support deletions. In contrast, HashGraph can easily support deletions by storing the number of elements per hash. See Sec. 6 for a discussion for insertion operations for HashGraph. Chaining based hash table on the GPU are challenging due to memory management and performance. The recent SlabHash [5] is the closest to a chaining based hash-table on the GPU; however, we do not compare against SlabHash [5] as it is out performed by cuDPP [15]. Input sizes & Key Distribution. In many data base application where hash-table are used, typically one of the tables is much smaller than the other. For data sciences, it is customary to have inputs with similar dimensions. For the sake of simplicity, we pri- marily focus on the later case. We report performance in throughput (keys per second) rather than absolute times as is common with hash table operations. As the table creation and probing processes are separated, times can be inferred for both these operations based on the input size divided by the throughput. By default, both input arrays will have 32M keys unless men- tioned otherwise and the input across the frameworks is identical ([1, 2, 3, 4, ..., 225]) to ensure fair evaluation across the implemen- tations. We report for 32M keys as we found that several of the frameworks were unable to scale to large data sets. We chose the simple sequence of number as it ensures that all frameworks get the same input, especially as WarpDrive [17] is unable to deal with duplicate values. For HashGraph and cuDF we test the performance across a wider range of input sizes as well as random inputs (controlling the aver- age number of appearances of each value in the input). For Hash- Graph, we were able to build a hash table on a single GPU with 229 = 512M entries. Beyond that size, we ran out of memory. From a performance perspective, HashGraph's throughput is roughly within a 5% range of its performance with 32M entries as the input is increased to 512M entries. 5 EMPIRICAL PERFORMANCE 5.1 Hash-Table Building In the following subsection we show the performance of our new HashGraph algorithms for building a hash-table. We show several interesting performance findings with respect to collision and hash- value duplications that are contrary to intuition and the typical performance found in existing hash values. Framework Comparison. Fig. 2 depicts the performance of the various implementations. The input is identical for all the frame- works: N = 225 = 32M and the input is the sequence [1, 2, 3, .., 225]. The x-axis represents the load of the table, such that that the num- ber of entries within the hash table is N . Larger loads mean load denser tables and can impact performance. Recall, that the load for HashGraph is different, specifically, the load represents the number of "vertices" or unique set of hash values. Also, the number of "edges" (the hash-table size) is constant in our approach and is equal to the input size. Fig. 2 (a) depicts the hash table build in terms of billions of keys per second -- higher is better. Fig. 2 (b) depicts the speedup of the various algorithms in comparison with cuDPP which is a de-facto hash-table implemen- tation for the GPU. Key observations: • HashGraph-V2 (Alg. 2) is roughly 4× faster than HashGraph- V1 (Alg. 1). Recall, that both HashGraph-V1 and HashGraph-V2 both create the same output (though the order of the entries in the hash tables might be different). HashGraph-V2 uses an additional preprocessing phase with radix binning that improves the cache efficiency as there are fewer cache misses. • HashGraph-V2 is significantly faster than the other frameworks. Even for the lowest load factor, 0.5,(default load factor for these frameworks), HashGraph-V2 is faster than cuDPP by as much as 1.6×, WarpDrive by 1.8×, and cuDF by over 1.3×. • For higher load factors HashGraph-V2 outperforms cuDPP by as much as 5×, WarpDrive by 2.5× times, and cuDF by over 8× times. • The performance of HashGraph-V2 actually improves as the load- factor is reduced! This is in contrast with most other hash table building functionality. Note that all of them show reduced per- formance at load factor 0.9. For HashGraph-V2 the performance actually increases by roughly 10% − 15%. Recall in HashGraph-V2 (Alg. 2) there are several loops that are dependent on the number of vertices (denoted as CV ). By increasing the load factor, we in fact decrease the size of CV (the set of vertices). This leads to fewer iterations for several of the parallel f or loops and a faster prefix summation operation. • For HashGraph, we can increase the load factor beyond 1 to further improve performance (Fig. 8. Thus, if we compare HashGraph-V2's best performance with the best performance of the other frame- works, HashGraph-V2 is faster than cuDPP by as much as 2×, Warp- Drive by 2.2× times, and cuDF by over 1.5× times. Collision Management. A key feature of a hash table is how good it performs when there are collisions in the hash table. In this subsection we evaluate cuDF and HashGraph for various collision rates (which are controlled by the average number of appearances of each input value). We did not collect these numbers for cuDPP and WarpDrive. Specifically, WarpDrive is unable to deal with duplicate keys in the hash table creation phase. Fig. 3 depicts the performance, in keys per second, for building a hash table as a function of the average number of times each key appears in the input (going from a small number of times to a large number of times). For cuDF we collected results for two different load factors: 50% and 80%. Inputs were created using a uni- form random number generator. The x-axis represents the average time each key appears on average in the input. For example, given an input with 32M keys and an average of four appearances, the keys are generated from numbers in the range of [1, ..., 8M]. Note, as the average number of appearances increases, the cost of colli- sion management with open-addressing increased in a quadratic manner. In contrast, the performance of HashGraph barely changes with the increase in the number of average values. HashGraph offers a new and efficient approach for dealing with collisions with little over head. In comparison with cuDF, when a key appears on av- erage 2, 8, and 32 times, our new HashGraph-V2 approach is 2×, 4×, and 40× faster, respectively, than the fastest of the two cuDF implementations. Bin Count Selection. Fig. 4 and Fig. 5 depict the performance of HashGraph-V2 for different bin sizes and input sizes. For both plots, the x-axis depicts the average number of times each elements ap- pears in the input. Fig. 4 depicts the performance of HashGraph-V2 for different bins sizes. Each of the subplots depicts the performance for a different input sizes: 2M, 8M, and 32M. For all these input sizes, selecting 214 or 215 bins gives the best performance. Note, that the performance for a given bin count stays constant as the number of average appearances grows. Fig. 5 shows the performance of HashGraph-V2 for several different input sizes. Intuitively, using a very large number of bins decreases the per- formance as this becomes very close to HashGraph-V1. In contrast 7 (a) Keys Per Second (b) Normalized Speedup fig. 2: Performance of building a hash-table. X-axis represents the load factor of hash table and y-axis represents the (a) billion of keys per second (higher is better) and (b) the normalized speedup in comparison with cuDPP (higher than is better performance). Input for all table is identical and is the sequence [1, 2, 3, ..., 225]. For HashGraph, increasing the load factor actually reduces the number of vertices improves the performance of the hash-table creation. This is in contrast to the typical behavior of hash-table creation. WarpDrive's probing algorithms finds the first instance of a hashed value and stops; whereas the other implementations find all the instances (and they do a deeper scan). Furthermore, WarpDrive's inability to deal with duplicate key values means that it cannot be used for join operations. The HashGraph-Probe-Standard probing approach has near constant performance as a function of the load factor. In contrast, for our new probing the approach the perfor- mance increases as the load is increased -- this is due to the fact that we build a second hash table for the probing input. Recall, this behavior was also seen in the HashGraph building phase. At peak, HashGraph can probe at a rate of 1.8 billion keys per second. In an execution breakdown of our the HashGraph-Probe-New probing mechanism, roughly 75% of our probing time is spent building the second hash-table. The remaining time is spent on intersecting the lists. This is highly motivating for two reasons :1) it confirms that our new intersection is fast and cache efficient and 2) if we can further improve the performance of building the hash table we can further improve the performance of the probing. Fig. 7 depicts the performance of the probing functionality as a function of the average number of times that each key appears in the input. For both cuDF curves, the performance clearly drops off as the number of appearances increases. This is not surprising as open-addressing becomes more expensive as the table becomes denser and more duplicates are added. In contrast, the probe rate for HashGraph decreases at a much slower rate. Especially for the new approach that has better cache utilization and reuse. The new probing algorithm is roughly 100× faster than cuDF when the number of duplicates is 32. 5.3 Hash Table Ranges, Load Factors, and Vertex Counts In this last subsection, we analyze the impact of changing the range of the hash table. Typically this is referred to as the load-factor in open-addressing based approaches and its also well established that decreasing the range increases the number of collisions and re- duces the performance. However, for our new HashGraph approach the range refers to the number of vertices (and edge lists) in the HashGraph. And we showed that HashGraph actually gains some performance by reducing the range (vertices) as there are several parallel for loops that are dependent on this size. Lastly, recall 8 fig. 3: Billion of keys per second (higher is better) for building a hash table HashGraph and cuDF with two load-factors as a function of the average number appearance per key in the input. Keys are generated using a random number generator and a prede- termined key range. Everything to the right of x = 0, the key range is smaller than the number of inputs N/R meaning that the average number of appearances grows with range R. Left of the x = 0, the key range is N · R, meaning that the average time a key appears is smaller. The performance of HashGraph is almost indifferent to the number of appearances whereas for cuDF the performance deteriorates with the increase. When the average number appearances is 8×, the performance of HashGraph is anywhere from 4× to40× faster. increasing the number of bins beyond a certain point also reduces the performance as it increases hot-spotting and increases serializa- tion of the reads and writes. Another problem of having too many bins is that might not fit in the cache. At the far extreme where the number of bins is equal to the input size, we are once again stuck with random memory accesses (similar to that found in most open-hashing based approaches). 5.2 Hash-Table Probing In this subsection we evaluate the performance of probing. Again to ensure a fair evaluation across the implementations we use the sequence 1, 2, .., N as our input. Typically, the probing phase is faster than the table building phase is it only requires random read operations in contrast to random writes (and atomic instructions). Fig. 6 depicts the performance of the hash tables as a function of the load factor. For both cuDF and Warpdrive, as the load factor increases hash table becomes denser the performance decreases. 0.50.60.70.80.91.0Load Factor0.00.51.01.52.02.53.03.5Billion Keys Per SecondHashGraph-V1HashGraph-V2WarpDrivecuDPPcuDF0.50.60.70.80.91.0Load Factor01234567SpeedupHG-V2 vs HG-V1HG-V2 vs WarpDriveHG-V2 vs cuDPPHG-V2 vs. cuDF252321212325Average Time Key Appears0.00.51.01.52.02.53.03.5Billion Keys Per SecondHashGraph-V1HashGraph-V2cuDF-Load=50%cuDF-Load=80% (a) Input size - 221 (b) Input size - 223 (c) Input size - 225 fig. 4: Billions of keys per second of our HashGraph 2.0 as a function of the number of times each key appears in the input. The size of the input is (a) 221, (b) 223, and (c) 225 elements, respectively. The different curves are for a different number of bins. Best performance is achieved for 214 and 215 bins due to caching. At peak, HashGraph is able to build the hash table at a rate of 2.5 billions keys per second. (a) Bins - 214 (b) Bins - 215 (c) Bins - 216 fig. 5: Billions of keys per second of our HashGraph 2.0 as a function of the number of times each key appears in the input. The number of bins is (a) 214, (b) 215, and (c) 215, respectively. The different curves are for different input sizes. On average the best performance of each input size can be found in (a) 214 and (b) 215. fig. 6: Performance of probing. There are two curves for HashGraph, one for a standard probing algorithm that can be also used for open-addressing based tables and the other curve for a new probing that intersects the adjacency lists for the different hash entries. WarpDrive's probing is faster as it finds only the first instance of value whereas the others find all instances. that the number of edges (which are hashed inputs) does not change. Fig. 8 depicts the performance of HashGraph for both the build- ing and probing as a function of the hash range. As the load is increased, from left to right, the effective number of vertices is de- creased from being twice the size of the input to being one quarter the size of the input -- this is 8× difference in the hash range. The building rate increases from about 1.6 billion keys per second to roughly 2.4 billion keys per second. Though the build rate does not fig. 7: Performance comparison of probing of HashGraph with cuDF. The new HashGraph probing algorithm is slightly slower when the number of unique keys is small. However, 10× faster than the standard probing algorithm and roughly 100× faster than cuDF when the number of duplicates is high. increase much beyond the point that the hash-range is half the size of the input (marked at load factor 2). In contrast, the performance of the probing function peaks within the load-factor of 1 to 2. Be- yond this load, the performance of probing goes down as the lists become longer and the hash lists are longer. Within the aforemen- tioned load-factor range there is a good balance between slightly improving hash table building vs. probing. Altogether, it seems that any load between the range of 1 and 2 will give good performance for HashGraph and these can also be decided at runtime based on the properties of the input. 9 2422202224Average Time Key Appears0.51.01.52.02.53.03.5Billion Keys Per SecondBins=2^8Bins=2^10Bins=2^12Bins=2^14Bins=2^15Bins=2^16Bins=2^182422202224Average Time Key Appears0.51.01.52.02.53.03.5Billion Keys Per SecondBins=2^8Bins=2^10Bins=2^12Bins=2^14Bins=2^15Bins=2^16Bins=2^182422202224Average Time Key Appears0.51.01.52.02.53.03.5Billion Keys Per SecondBins=2^8Bins=2^10Bins=2^12Bins=2^14Bins=2^15Bins=2^16Bins=2^182422202224Average Time Key Appears1.501.752.002.252.502.753.003.253.50Billion Keys Per SecondSizes=2^19Sizes=2^20Sizes=2^21Sizes=2^22Sizes=2^23Sizes=2^24Sizes=2^252422202224Average Time Key Appears1.501.752.002.252.502.753.003.253.50Billion Keys Per SecondSizes=2^19Sizes=2^20Sizes=2^21Sizes=2^22Sizes=2^23Sizes=2^24Sizes=2^252422202224Average Time Key Appears1.501.752.002.252.502.753.003.253.50Billion Keys Per SecondSizes=2^19Sizes=2^20Sizes=2^21Sizes=2^22Sizes=2^23Sizes=2^24Sizes=2^250.50.60.70.80.91.0Load Factor0.00.51.01.52.02.53.03.5Billion Keys Per SecondHashGraph-Probe-StandardHashGraph-Probe-NewWarpDrivecuDF252321212325Average Time Key Appears0.00.51.01.52.02.53.03.5Billion Keys Per SecondHashGraph-Probe-StandardHashGraph-Probe-NewcuDF-Load=50%cuDF-Load=80% a lot of time and memory would be spent on creating the lists and would make a comparison of the building and probing more challenging. Further, MC-Hash does not create these list as well. 6 SUMMARY In this paper we presented HashGraph a new approach for both building a hash table and for probing values. The HashGraph ap- proach shows a relationship between building a hash table and creating a sparse graph data structure. Unlike past approaches which typically build a hash table in a single sweep over the data, our two new algorithms actually sweep over the data multiple times. By using multiple sweeps, including a pre-processing sweep, we are able to create a very efficient hash table that can deal with colli- sions in a simple manner. Our second algorithm uses an additional sweep over the data that is both cache friendly and bandwidth friendly removing the penalty of random memory accesses. Our second algorithm is anywhere from 50% − 100% faster than several state-of-the-art hash table implementations. HashGraph shows a new way to manage collisions that takes the best of open-addressing and chaining, without any of their downsides. First, we showed that we can place colliding elements in the same spatial locality array without gaps or different hashed values as required in open-addressing or random memory accesses as required with chaining. Second, using our preprocessing sweep we are able to determine in advance the exact number of elements that will be placed in each of the so called temporal chains. This removes the need for finding an empty spot in the table. This is important for inputs with a large number of duplicates and overcomes many of the problems with elaborate methods such as Cuckoo hashing. Thus, we showed a new collision management type for hashing. Third, the performance of HashGraph is mostly invariant to the key distributions and the number of times each key appears in contrast to most hash table. In the experiment section we showed that the performance of building a table went down by less than 15% even when each key appeared on average 32×. Performance for past approaches went down by more than 10×. Fourth, past approaches have typically required roughly 1.5 × −2× more entries than the original input to avoid the problems associated with conflicts. Reducing this storage overhead has typi- cally led to reduced performance. In contrast, HashGraph separates the load factor (which can also be viewed as the number of possi- ble hash entries) with the actual hash table size. With HashGraph the range of the entries can be reduced to the exact number of entries. Surprisingly, decreasing the load factor actually improves the performance of HashGraph. This is in stark contrast to past approaches. Fifth, we showed a new approach for probing the hash table. Specifically, for list intersections operations (such as those founds in inner joins), we show that we can create a second hash table for both the input lists and then we can intersect the lists of each value in a method that is cache friendly (no random accesses as found in chaining) and also efficient (searches through only relevant values unlike open-addressing). The uniqueness of this new prob- ing approach is makes this phase more cache friendly. This could be important for future processors where the memory subsystem (bandwidth, cache size, memory channels, latencies) is different. fig. 8: Performance comparison of HashGraph as a function of the hash table range, starting on the left where the range is twice as big as the input size and all the way to the right where the range is a quarter of the input size (meaning that there will be many more collisions). fig. 9: Performance comparison (higher is better) of HashGraph with one of the fastest known CPU hash algorithms [6, 7] for an inner-join. The execution time includes both the hash table creation and the probing phases. The lists with the result of the inner join are not actually created or timed. The size of the two inputs is 32M elements. 5.4 HashGraph Vs. CPU HashTables In [6, 7] one of the fastest known CPU hash tables implementations is presented. MC-Hash was designed for inner-joins of two relations. MC-Hash times the execution for both building the hash-table as well as its probing with one timer. Using this single timer, we are able to evaluate and compare the performance of this implementa- tion with HashGraph. We use two input arrays of 32M elements that are generated randomly using MC-Hash's generator and bench- mark the algorithms with a varying number of average appearance for the keys. To compute the number of keys per second, we take into account the size of both inputs (meaning we diving 64M by the execution time). Performance of MC-Hash and HashGraph for a join operation are depicted in Fig. 9. For Hash-Graph we calculated the sum of the time for hash-table building and probing. Hash-Graph, using a single GPU, is 3× faster than a 48-core (96-thread) system processor when the number of appearances per key is small. However, when the average number of keys is high, HashGraph outperforms MC-Hash by as much as 10×. Note, the lists with the results of the intersection are not instan- tiated.The size of such lists would be fairly large especially when the number of duplicates is high. Specifically, for the uniformly randomly generated numbers used in our experiments the output size could easily be one to two orders of magnitude larger than the inputs -- especially when the number of duplicates are high. Thus, 10 0.51.01.52.02.53.03.54.0Hash Range Load Factor0.00.51.01.52.02.53.03.5Billion Keys Per SecondHashGraph-BuildHashGraph-Probe252321212325Average Time Key Appears0.00.51.01.52.02.53.03.5Billion Keys Per SecondMC-Hash - CPU (48 cores/96 threads)HashGraph (GPU) Dynamic HashGraph As mentioned earlier in this paper, hashing is used in a wide range applications. In some applications the hash table is created from a static data set and in other cases the hash table changes by other adding or removing values. These can be referred to as incremental or decremental operations. In this work we primarily focused on creating a table for static data hash tables such as those required for inner join operations and SpGEMM. While we do not discuss this in detail, HashGraph can easily support decremental operations simply by storing an additional length array in addition to the offset array. Thus, HashGraph can support deletions whereas open-addressing methods are not able to support deletion without adding a special deletion "marker" to the hash table. We believe that recent work on developing efficeint dynamic graph data structures might be of great use for HashGraph. While a handful of such data structures have been developed in the last decade [13, 14, 22, 28, 30], we believe that Hornet data structure [13] can be adapted for a dynamic version of HashGraph. This in part due to the fact that Hornet is a dynamic version of CSR. We have started to investigate how to implement HashGraph within Hornet and believe that with some modification made to Hornet's initilization process this will possible. Specififically, Hornet initializes process needs to be parallelized as it is currently sequential. While we have yet to develop a dynamic version of HashGraph, it would seem that the table building process would be the same. They key difference would be is supporting dynamic operations, with an emphasis on insertions. Conclusions In summary, in this paper we presented a novel approach for build- ing and a new approach for probing hash tables. Our analysis in- cludes theoretical complexities as well as empirical performance analysis. Our new hash table building algorithm is faster than ex- isting state-of-the-art hash tables from 2 × −8× when the number of unique keys is high and up-to 40× faster when the number of unique key is small. Our new probing algorithm can be as much as 100× faster when the number of duplicates is high. We also showed that a single NVIDIA V100 GPU can significantly outperform a 48-core (96 thread) CPU system for an inner-join. We showed that our the process of building a hash table with HashGraph introduces a new and more efficient collision manage- ment that has all the benefits of open-addressing and chaining, but without the drawbacks of these two approaches. We primarily focused on static data hash tables in this paper, though our goal is to investigate how to implement HashGraph for dynamic graphs as well. REFERENCES [1] R. Albert, H. Jeong, and A.-L. Barabási. 1999. Internet: Diameter of the World- Wide Web. Nature 401 (Sept. 1999), 130 -- 131. [2] Dan A Alcantara, Andrei Sharf, Fatemeh Abbasinejad, Shubhabrata Sengupta, Michael Mitzenmacher, John D Owens, and Nina Amenta. 2009. Real-time parallel hashing on the GPU. ACM Transactions on Graphics (TOG) 28, 5 (2009), 154. [3] Austin Appleby. 2008. Murmurhash 2.0. (2008). [4] Saman Ashkiani, Andrew Davidson, Ulrich Meyer, and John D Owens. 2016. GPU Multisplit. In ACM SIGPLAN Notices, Vol. 51. ACM, 12. [5] Saman Ashkiani, Martin Farach-Colton, and John D Owens. 2018. A dynamic hash table for the GPU. In 2018 IEEE International Parallel and Distributed Processing Symposium (IPDPS). IEEE, 419 -- 429. 11 [6] Cagri Balkesen, Gustavo Alonso, Jens Teubner, and M Tamer Özsu. 2013. Multi- Core, Main-Memory Joins: Sort vs. Hash Revisited. Proceedings of the VLDB Endowment 7, 1 (2013), 85 -- 96. [7] Cagri Balkesen, Jens Teubner, Gustavo Alonso, and M Tamer Özsu. 2013. Main- Memory Hash Joins on Multi-Core CPUs: Tuning to the Underlying Hardware. In IEEE 29th International Conference on Data Engineering (ICDE). IEEE, 362 -- 373. [8] Claude Barthels, Ingo Müller, Timo Schneider, Gustavo Alonso, and Torsten Hoefler. 2017. Distributed Join Algorithms on Thousands of Cores. Proceedings of the VLDB Endowment 10, 5 (2017), 517 -- 528. [9] Edward W Bethel, Luke J Gosink, Kesheng Wu, Edward Wes Bethel, John D Owens, and Kenneth I Joy. 2008. Bin-Hash Indexing: A Parallel Method for Fast Query Processing. Technical Report. Lawrence Berkeley National Lab.(LBNL), Berkeley, CA (United States). [10] Mauro Bisson and Massimiliano Fatica. 2017. High Performance Exact Triangle Counting on GPUs. IEEE Transactions on Parallel and Distributed Systems 28, 12 (2017), 3501 -- 3510. [11] Spyros Blanas, Yinan Li, and Jignesh M Patel. 2011. Design and Evaluation of Main Memory Hash Join Algorithms for Multi-Core CPUs. In Proceedings of the 2011 ACM SIGMOD International Conference on Management of data. ACM, 37 -- 48. [12] Guy E Blelloch. 1990. Prefix Sums and Their Applications. Technical Report. [13] F. Busato, O. Green, N. Bombieri, and D.A. Bader. 2018. Hornet: An Efficient Data Structure for Dynamic Sparse Graphs and Matrices on GPUs. In IEEE Proc. High Performance Extreme Computing (HPEC). Waltham, MA. [14] O. Green and D.A. Bader. 2016. cuSTINGER: Supporting Dynamic Graph Algo- rithms for GPUS. In IEEE Proc. High Performance Extreme Computing (HPEC). Waltham, MA. [15] Mark Harris, John Owens, Shubho Sengupta, Yao Zhang, and Andrew Davidson. Citeseer. 2007. CUDPP: CUDA Data Parallel Primitives library. (2007). [16] Mark Harris, Shubhabrata Sengupta, and John D Owens. 2007. Parallel prefix sum (scan) with CUDA. GPU gems 3, 39 (2007), 851 -- 876. [17] Daniel Jünger, Christian Hundt, and Bertil Schmidt. 2018. WarpDrive: Massively Parallel Hashing on Multi-GPU Nodes. In 2018 IEEE International Parallel and Distributed Processing Symposium (IPDPS). IEEE, 441 -- 450. [18] Tomas Karnagel, Rene Mueller, and Guy M Lohman. 2015. Optimizing GPU- accelerated Group-By and Aggregation. ADMS at VLDB 8 (2015), 20. [19] Farzad Khorasani, Mehmet E Belviranli, Rajiv Gupta, and Laxmi N Bhuyan. 2015. Stadium Hashing: Scalable and Flexible Hashing on Gpus. In International Conference on Parallel Architecture and Compilation (PACT). IEEE, 63 -- 74. [20] Changkyu Kim, Tim Kaldewey, Victor W Lee, Eric Sedlar, Anthony D Nguyen, Nadathur Satish, Jatin Chhugani, Andrea Di Blas, and Pradeep Dubey. 2009. Sort vs. Hash Revisited: Fast Join Implementation on Modern Multi-Core CPUs. Proceedings of the VLDB Endowment 2, 2 (2009), 1378 -- 1389. [21] Ping Li, Anshumali Shrivastava, and Christian A Konig. 2012. GPU-based Minwise Hashing. In Proceedings of the 21st International Conference on World Wide Web. ACM, 565 -- 566. [22] Peter Macko, Virendra J Marathe, Daniel W Margo, and Margo I Seltzer. 2015. LLAMA: Efficient Graph Analytics Using Large Multiversioned Arrays. In 31st IEEE Int'l Conf. on Data Engineering (ICDE). 363 -- 374. [23] Tobias Maier, Peter Sanders, and Roman Dementiev. 2016. Concurrent Hash Tables: Fast and General?(!). In ACM SIGPLAN Notices, Vol. 51. ACM, 34. [24] NVIDIA. 2018. CUDF. (2018). [25] Rasmus Pagh and Flemming Friche Rodler. 2004. Cuckoo Hashing. Journal of Algorithms 51, 2 (2004), 122 -- 144. [26] Tony C Pan, Sanchit Misra, and Srinivas Aluru. 2018. Optimizing High Perfor- mance Distributed Memory Parallel Hash Tables for DNA k-mer Counting. In Optimizing High Performance Distributed Memory Parallel Hash Tables for DNA k-mer Counting. IEEE, 0. [27] Andrea W Richa, M Mitzenmacher, and R Sitaraman. 2001. The Power of Two Ran- dom Choices: A Survey of Techniques and Results. Combinatorial Optimization 9 (2001), 255 -- 304. [28] Dipanjan Sengupta, Narayanan Sundaram, Xia Zhu, Theodore L Willke, Jeffrey Young, Matthew Wolf, and Karsten Schwan. 2016. Graphin: An Online High Performance Incremental Graph Processing Framework. In European Conference on Parallel Processing. Springer, 319 -- 333. [29] Shubhabrata Sengupta, Mark Harris, Yao Zhang, and John D Owens. 2007. Scan Primitives for GPU Computing. In Graphics hardware. 97 -- 106. [30] Martin Winter, Rhaleb Zayer, and Markus Steinberger. 2017. Autonomous, Inde- pendent Management of Dynamic Graphs on GPUs. In International Supercom- puting Conference. Springer, 97 -- 119.
1104.1044
2
1104
2011-04-08T10:51:21
Fixed Parameter Tractable Algorithm for Firefighting Problem
[ "cs.DS" ]
The firefighter problem is defined as below. A fire initially breaks out at a vertex r on a graph G. In each step, a firefighter chooses to protect one vertex, which is not yet burnt. And the fire spreads out to its unprotected neighboring vertices afterwards. The objective of the problem is to choose a sequence of vertices to protect, in order to save maximum number of vertices from the fire. In this paper, we will introduce a parameter k into the firefighter problem and give several FPT algorithms using a random separation technique of Cai, Chan and Chan. We will prove firefighter problem is FPT on general graph if we take total number of vertices burnt to be a parameter. If we parameterize the number of protected vertices, we discover several FPT algorithms of the firefighter problem on degree bounded graph and unicyclic graph. Furthermore, we also study the firefighter problem on weighted and valued graph, and the problem with multiple fire sources on degree-bounded graph.
cs.DS
cs
Fixed Parameter Tractable Algorithm for Firefighting Problem Ming Lam Leung∗ October 22, 2018 Abstract The firefighter problem is defined as below. A fire initially breaks out at a vertex r on a graph G. In each step, a firefighter chooses to protect one vertex, which is not yet burnt. And the fire spreads out to its unprotected neighboring vertices afterwards. The objective of the problem is to choose a sequence of vertices to protect, in order to save maximum number of vertices from the fire. In this paper, we will introduce a parameter k into the firefighter problem and give several FPT algorithms using a random separation technique of Cai, Chan and Chan. We will prove firefighter problem is FPT on general graph if we take total number of vertices burnt to be a parameter. If we parameterize the number of protected vertices, we discover several FPT algorithms of the firefighter problem on degree bounded graph and unicyclic graph. Further- more, we also study the firefighter problem on weighted and valued graph, and the problem with multiple fire sources on degree-bounded graph. 1 Introduction The firefighter problem is a discrete-time game on a graph G defined as below. Initially, a fire breaks out at a vertex r of G. For each time step, a firefighter choose one vertex not yet on fire to protect it (that vertex remains protected thereafter), and then the fire spreads from the vertices on fire to all of their unprotected neighbours. This process continues round by round. The game ends when the fire cannot spread anymore, i.e. all of the neighbours of the burnt vertices are already protected. Then the vertices not on fire are considered saved. The objective of the problem is to choose a sequence of vertices to protect, in order to save maximum number of vertices in the graph from the fire. The firefighter problem is introduced by Hartnell [Har95] in 1995 and can be used to model the spread of fire, diseases, computer viruses in a marco-control level. The firefighter problem is shown to be NP-complete even for trees of maximum degree 3 by Finbow et al. [FKMR07] Actu- ally, Hartnell and Li [HL00] proved that a simple greedy method for trees is a 0.5-approximation algorithm, and MacGillivray and Wang [MW03] have solved the problem in polynomial time in some subclass of trees. Recently, Cai, Verbin and Yang [CVY08] have obtained a (1-1/e)- approximation algorithm for trees based on a linear programming relaxation and randomized rounding, and they have also considered fixed parameter tractability of the problem on trees. Besides, Cai and Wang [CW09] also study the defending ability of a graph as a whole by consid- ering the average percentage of vertices the firefighter can save. Furthermore, various aspects of the problem for d-dimensional grids have been considered by Develin and Hartke [DH07], ∗Department of Computer Science and Engineering, The Chinese University of Hong Kong, Shatin, Hong Kong SAR, China 1 Fogarty [Fog03], Wang and Moeller [WM02], and Cai and Wang [CW09], among others. In this report, we consider fixed parameter tractability of the firefighter problem on various graphs other than trees or d-dimensional-grid. We establish several FPT algorithms of the problem, either use number of vertices burnt or number of vertices protected to be parameter. Our main results are: 1. Parameter k on number of vertices burnt (a) Firefighter problem on general graph is FPT 2. Parameter k on number of vertices protected (i.e. k = no. of rounds) (a) Firefighter problem on degree-bounded graph is FPT (b) Firefighter problem on unicyclic graph is FPT 3. Reduction of Firefighter problem on weighted and valued graph 4. Firefighter problem with multiple fire sources, multiple protection and multiple burning can be reduced to the original firefighter problem The main tool we use is the random separation method of Cai, Chan and Chan [CCC06]. In the rest of the paper, we fix our notations and give definitions in Section 2. We then show that the parameterized firefighter problem with number of vertices burnt as parameter is FPT. We then establish FPT algorithms on degree bounded graph (Section 4) and unicyclic graph (Section 5). We also study the possibility of generalizing the algorithm on unicyclic graph to the family of tree+b edges. In Section 6, we will discuss the possibility of finding a solution in the general firefighter problem on the weighted and unequal valued graph, using local replacement. Finally, we will explore further in the firefighter problem with multiple fire sources, multiple protection and multiple burning in Section 7. 2 Definitions and Notation Here we define some terms. Let G be a undirected graph with a source vertex s, which is the origin of the fire. A vertex is burnt once it is on fire, and protected once it is protected by the firefighter, and saved if it is not burnt at the end of the game. We assume the game ends at time step t, which means that the fire can no longer spread to any unburnt vertices after the firefighter protected t vertices. A strategy for the F iref ighter problem is a se- quence {v1, v2, ..., vt} of protected vertices of G such that vertex vi is protected at time i, where 1 ≤ i ≤ t. An optimal strategy of a F iref ighter problem is a strategy maximizing the total number of vertices saved on the graph G. We let V and E be the vertex set and edge set of graph G, and we let n and m be the number of vertices and edges of the graph G respectively, i.e. n = V , m = E. For any set of ver- tices V (cid:48), We denote N (V (cid:48)) to be the set of neighbours of V (cid:48). We also define N [V (cid:48)] = N (V (cid:48))∪V (cid:48). Define E(V (cid:48)) be the set of edges in the induced subgraph containing vertices V (cid:48), and E(V1, V2) be the set of cross edges linking the vertex set V1 and V2. Define E[V1, V2] = E(V1, V2) ∪ E(V1) ∪ E(V2). We define merge(G; V (cid:48)) to be a graph G(cid:48) constructed by merging the vertices in set V (cid:48) in G into one single vertex. For example, merge(G;{u,v}) is a graph constructed by merging the vertices u and v into one vertex. A graph G is said to be degree bounded if the degree of each vertex on G is bounded by a fixed constant d. A graph G is a unicyclic graph if the graph contains only 1 cycle, i.e. it has n vertices and n edges. Note that a unicyclic graph can also be seen as a tree plus one extra edge. 2 In this paper, we mainly consider FPT algorithms for the following three versions of the F iref ighter problem. 1. At Most k Vertices Burnt: At most k vertices are burnt at the end of the game. We ask if there is a strategy saving at least n − k vertices. 2. Exactly k Vertices Burnt: The parameter k is the number of vertices burnt at the end of the game. We ask if there is a strategy saving at least n − k vertices. 3. Maximum k-Vertex Protection: The parameter k is the upper bound of number of protected vertices. We need to find a strategy to protect at most k vertices in order to maximize the number of vertices saved. The main tool we use is the random separation method of Cai, Chan and Chan [CCC06]. This technique produces randomized algorithms in FPT time. We can derandomize the al- gorithms using universal sets [NSS95]. Naor et al. give a construction of a (n,t)-universal set of cardinality 2ttO(log t) log n in time 2ttO(log t)n log n. A (n,t)-universal set is a set of binary vectors of length n while all the 2t configurations appear in the set for every subset of size t of the indices. We are going to construct a FPT algorithm to solve the problems At Most k Vertices Burnt and Exactly k Vertices Burnt on general graph in Section 3. And then we will focus on the problem Maximum k-Vertex Protection in Section 4 and 5, which is proven to be W[1]- hard in general graph. We will introduce FPT algorithm to solve it on degree bounded graph in Section 4, and show that it is FPT on unicyclic graph in Section 5. Besides, we study the reduction of the problem on weighted and valued graph and discuss about the case with multiple fire sources, multiple protection and multiple burning in Section 6 and 7. The complexity of all FPT algorithms introduced in this report are summarized in Table 1. Table 1: Summary of FPT algorithms Problem At Most k Vertices Burnt Exactly k Vertices Burnt Maximum k-Vertex Protection Degree-Bounded Graph Unicyclic Graph Tree+b edges Randomised O(4kn) O(4kn) Deterministic 2O(k)n log n 2O(k)n log n O(3k2(d+1)(n + m)) k−O(k)n3 k−O(k)n(2b+1) -- k−O(k)n3 log n k−O(k)n(2b+1) log n 3 At Most k Vertices Burnt on general graph In this section, we are considering the At Most k Vertices Burnt problem on general graph. We call a strategy S satisfying if it saves at least n− k vertices, i.e. the total number of vertices burnt is at most k. The goal of the problem is to find a satisfying strategy if one exists. The algorithm first colors each vertex of G randomly and independently by either green or red with probability 1/2. We call a coloring of G a good coloring if there exists a satisfying strategy S(cid:48) such that all vertices in S(cid:48) are green, and all the burnt vertices are red. 3 Figure 1: A good coloring example of At Most k Vertices Burnt Given a good coloring of G, we can find the specific satisfying strategy S(cid:48) as the following. First, starting from the source s, do breath-first-search only on the red vertices to get a red subtree V (cid:48) rooted at s. It takes linear time on number of vertices and edges of the subgraph V (cid:48). After the BFS, all of the neighbours of V (cid:48) have to be green, and V ∗ = N (V (cid:48)) must be a satisfying strategy if the coloring is good. If V (cid:48) ≤ k, we check if the green vertex set V ∗ = N (V (cid:48)) is a valid strategy set for the problem using the procedure below: Procedure for verifying if V ∗ is a satisfying strategy set Input: graph G, source s, vertex set V ∗ to be verified, and burnt vertex set V (cid:48) Output: If true, output the sequence of satisfying strategy in correct order. If false, output "no". 1. Do BFS on the subgraph V (cid:48) starting from s, find the distance d[s, v] of the each vertices v on V ∗ from the source s on the subgraph G(cid:48) = {N [V (cid:48)], E(V (cid:48))∪ E(V (cid:48), V ∗)}. 2. Sort the vertices V ∗ according to d[s, v] in ascending order. Store the sorted sequence in an array {vi} 3. for i = 1 to V ∗ do If the distance from the source of the i-th vertex d[s, vi] < i, then the solution is not valid, output "no" and halt. 4. Output the sequence {vi} as the corresponding firefighting strategy in correct order. Notice that N [V (cid:48)] = V (cid:48) ∪ N (V (cid:48)) = V (cid:48) ∪ V ∗ in the context here. Therefore, the subgraph G(cid:48) = {N [V (cid:48)], E(V (cid:48)) ∪ E(V (cid:48), V ∗)} in step 1, is nothing but the induced subgraph V (cid:48) ∪ V ∗ with the edge set E(V ∗) removed. The above procedure is correct based on the following fact. Fact 1 If S∗ = {vi} is a satisfying strategy in correct order, the distance between the source s and the i-th protected vertices vi on the subgraph G(cid:48) = {V (cid:48) ∪ S∗, E(V (cid:48)) ∪ E(V (cid:48), S∗)} has to be at least i. Fact 1 is obviously true as the fire will spread out by one unit in the subgraph G(cid:48), after the firefighter protect one vertex at each time step. If the distance between s and the i-th protected vertices vi on the subgraph G(cid:48) is less than i, the vertex vi will be burnt by the fire before time step i. 4 Before calculating the complexity of the above algorithm, we have the following observation. Observation 1 If the number of the vertices burnt is upper bounded by k, there exists a satis- fying strategy S(cid:48) with at most k protected vertices. i.e. S(cid:48) ≤ k. The above statement is true because the number of protected vertices is equal to the total time step t. Moreover, each time step at least one vertex is burnt if the game is not ended. Therefore, S(cid:48) = t ≤ k. Since the size of V (cid:48) and S(cid:48) are both bounded by k, we have a good coloring with V (cid:48) colored red and S(cid:48) colored green with probability at least 2−2k. Since the BFS algorithm and distance finding is of linear time, and the sorting procedure in step 2 of the verifying procedure takes only O(k log k) time, therefore the Procedure for verifying if V ∗ is a satisfying strategy set takes linear time. After all, there exists a randomized FPT algorithm solving the problem in O(22k(n + m)) time. Moreover, we can use {n, 2k} universal set to derandomize it and get a deterministic FPT algorithm in O(22k(n + m) log(n + m)) time. This result matches the previous result of the model Saving All But k Vertices in the special case of firefighter on tree [CVY08], which gives us a result of 2O(k)n log n time as m = n − 1 for trees. Furthermore, we can modify the above algorithm a little bit to solve the Exactly k Vertices Burnt problem with the same time complexity. In the above algorithm, we run the Procedure for verifying if V ∗ is a satisfying strategy set if V (cid:48) ≤ k. If we modify the algorithm as we run the procedure only if V (cid:48) = k, then we can solve the Exactly k Vertices Burnt problem on general graph with the same time complexity. 4 Maximum k-Vertex Protection on degree bounded graphs In this section, we are considering the Maximum k-Vertex Protection problem on degree bounded graphs. For the Maximum k-Vertex Protection problem, we call a strategy S satisfying if the strategy S contains at most k vertices, and it saves maximum vertices on the graph G from the fire. Note that the fire can no longer spread at time step t+1 after the firefighter protects the last vertex vt, therefore Maximum k-Vertex Protection can be also regarded as a parameterized version of the firefighter problem when we bound the total number of time step t ≤ k. First, we define a type of subgraph called BF S Burning T ree. Given the firefighter prob- lem on a graph G with a strategy S with a sequence of protected vertices V ∗, interconnect the source s and vertex set V ∗ by a tree T of shortest tree weight, where the tree weight is defined as the sum over the pairwise distances between the source s and each vertex vi ∈ V ∗ on the subgraph G − V ∗ ∪ {vi}, with constraint that all vertices V ∗ have to be a leaf of the tree T . Then T is known as the BF S Burning T ree of the strategy S. If the source s and the vertex set V ∗ are given, the BF S Burning T ree of the strategy S can be found in linear time by doing Breath-First Search starting from the source s, until all the vertices V ∗ are reached. A M inimum BF S Burning T ree of a strategy S on the graph G is the BF S Burning T ree with minimum number of vertices. Therefore, on a M inimum BF S Burning T ree of a strategy S(cid:48), all the unnecessary edges and vertices which helps nothing on connecting the source s with S(cid:48) have to be removed from the tree. From this definition, we can see that a M inimum BF S Burning T ree of a strategy S(cid:48) is consist of either S(cid:48) + 1 or S(cid:48) leaves. Given that the number of protected vertices of an optimal strategy S0 is at most k, we have the following lemma: 5 Lemma 1 In the firefighter problem with an optimal strategy S0 of at most k vertices, the number of vertices of the M inimum BF S Burning T ree of S0 is at most k2 + 1. Proof Since S0 is an optimal strategy with at most k vertices, for each vertex vi ∈ S0, the distance from the source s to vi on the subgraph G − S0 ∪ {vi} is at most k. Otherwise the fire cannot reach vi before time step k+1, so the firefighter does not need to protect vi before time step k+1. Then the firefighter can earn one more turn to protect an extra vertex v(cid:48) /∈ S0 on the i-th round, and protect vi on the k + 1-th round, which contradicts with the assumption that S0 is an optimal strategy. Since a M inimum BF S Burning T ree of S0 is a tree minimizing the tree weight, which is the sum over all pairwise distances between the source s and each vertex vi ∈ S0 on the subgraph G − S0 ∪ {vi}. As the distance from the source s to vi on the subgraph G − S0 ∪ {vi} is at most k, the tree weight is at most kS0 ≤ k2. And the number of edges of the M inimum BF S Burning T ree is upper bounded by the tree weight, so the number of vertices of it is at most k2 + 1. (cid:3) Using Lemma 1, we can design a randomized FPT algorithm for the Maximum k-Vertex Protection on degree bounded graph using random separation. The main idea of the algorithm is to randomly separate the graph G into 3 parts, one part contains the optimal strategy S0, one part contains the source s and all the internal nodes of the M inimum BF S Burning T ree of S0, the third part contains the neighbours of (M inimum BF S Burning T ree of S0 − S0). The algorithm first colors the source s red, then colors each vertex of G randomly and independently by either green, red or yellow with probability 1/3. We call a coloring of G a good coloring if there exists a maximum k-vertex optimal strategy S0 such that all vertices in S0 are green, and the tree T (cid:48) = (M inimum BF S Burning T ree of S0 − S0) are red and the neighbours of the tree T (cid:48) are yellow. Notice that the number of vertices in S0 is at most k. By Lemma 1, we also know that the number of vertices in T (cid:48) is at most k2 − k + 1. If the graph G is a degree bounded graph with degree at most d, then N (T (cid:48)) ≤ k2d. By random separation, we can have a good coloring with probability at least 2−k2(d+1). Figure 2: A good coloring example on degree bounded graph Given a good coloring of G, we can find the specific satisfying strategy S0 as the following. First, starting from the source s, do breath-first-search only on the red vertices to get a red subgraph V (cid:48) rooted at s. Since T (cid:48) is a red tree containing the source s, and all the neighbour of 6 this red tree T (cid:48) are either yellow or green, but not red. Therefore, doing BFS from s can help us to locate the tree T (cid:48), i.e. V (cid:48) = T (cid:48). It takes linear time on number of vertices and edges of the subgraph T (cid:48). After the BFS, all of the green neighbours of T (cid:48) must be a satisfying strategy if the coloring is good, as all the non-solution neighbours of the red tree N (T (cid:48))− S0 are all colored yellow. Let V ∗ be the green neighbours of T'. If V ∗ ≤ k, we check if the green vertex set V ∗ is a valid strategy set for the problem using the Procedure for verifying if V ∗ is a satisfying strategy set introduced in Section 3, with the input burnt vertex set V (cid:48) = T (cid:48). If the color- ing is good, this procedure will output V ∗ in correct order as the optimal firefighting strategy S0. Similar to the time complexity analysis in Section 3, we can easily show the complexity of the above randomized algorithm is O(3k2(d+1)(n + m)). 5 Maximum k-Vertex Protection on unicyclic graphs In this Section, we are considering the Maximum k-Vertex Protection problem on unicyclic graphs. A unicyclic graph is a graph containing only 1 cycle. A unicyclic graph can also be seen as a tree plus one extra edge. Given a unicyclic graph G with a fire source s, let n be the number of vertices and edges of G. We would like to locate the optimal strategy S0 with at most k vertices which saves maximum number of vertices. In order to solve the problem on unicyclic graphs, we need to refer to a previous result of Maximum k-Vertex Protection problem on trees, given by Cai, Verbin and Yang[CVY08]. In their paper, they introduce a FPT algorithm using random separation to solve the Max- imum k-Vertex Protection firefighter problem on trees. Their algorithm randomly and independently colors each vertex into either green or red. For a good coloring, all vertices in the satisfying strategy S0 are green and all of their ascendants of vertices in S0 on the tree are red. Given a good coloring, they can use greedy method to locate the k solution one-by-one in correct order by considering each level of the tree. They proved that this randomized algo- rithm runs in time k−O(k)n. And it can be derandomized using asymmetric universal sets introduced by Verbin [Ver], which helps us to get a deterministic algorithm that runs in time k−O(k)n log n. We are going to use their result to show the Maximum k-Vertex Protection firefighter problem on unicyclic graphs are also FPT. The main idea of our algorithm is to separate the original problem into three cases, and handle them one by one. In each case, by observing the sequence of vertices being burnt, we find to transform the unicyclic graph G to a tree T (cid:48) by removing vertices and edges on the cycle. Finally we can use the FPT algorithm given by Cai, Verbin and Yang to solve the firefighter problem on tree T (cid:48) and get the optimal solution of the graph G. In the beginning, we need to find the cycle C by doing Depth-First-Search from the source s. It takes only linear time. Then we can locate the vertex set C of the cycle and the minimum distance from s to cycle C. Let l be the minimum distance from s to cycle C. Generally, the fire source does not have to locate on the cycle, i.e. l ≥ 0. Let c0 be the vertex on the cycle C which is nearest to the source s. Notice that c0 is unique. If l = 0, then the fire source s locate on the cycle and c0 = s. Define path P to be the path connecting the source s to c0, where path P contains l edges and l + 1 vertices, including s and c0. Let C contains r+1 vertices, where 2 ≤ r ≤ n− 1. (If r = 0 or r = 1, then G is not a simple graph. It contains either a loop or multiple edges.) We name the sequence of vertices on cycle C to be {c0, c1, c2, ..., cr}, starting with c0 with clockwise direction. Among all the vertices on the cycle C, c0 is the one closest to the fire. If c0 is saved, all 7 the ci can be saved as c0 block the only route that the fire can enter cycle C. It means that the fire can enter cycle C only if c0 is burnt. Therefore, we try to use two FPT algorithms to consider the problem in the 3 cases below separately, and then combine them to get the optimal solution. Case 1 c0 and the whole cycle C will be saved at the end of the game. In case 1, we assume c0 and the whole cycle C will be saved at the end no matter what happens. To satisfy the criteria of this case, we modify graph G into a graph T1, by replacing the whole cycle C by a single vertex c(cid:48) 0, linking to 2n individual vertices by 2n edges. Therefore, if G contains n vertices and n edges, T1 is a tree containing 3n− r vertices and 3n− r− 1 edges. Then we have to use the following fact: Fact 2 The optimal solution S0 of Maximum k-Vertex Protection firefighter problem on unicyclic graphs G, with constraint that c0 has to be saved at the end of the game, is equivalent to the optimal solution S1 of Maximum k-Vertex Protection firefighter problem on tree T1. Fact 2 is obviously true as c(cid:48) 0 in T1 is so important that a firefighter must keep it away from the fire, otherwises at least 2n vertices will be burnt. Therefore the 2 situations is totally equivalent. By solving the Maximum k-Vertex Protection on the tree T1 using Cai, Verbin and Yang's FPT algorithm, we can get the solution S0 of the problem on unicyclic graph G based on the requirement of case 1. Figure 3: Whole cycle C will be burnt Case 2 c0 and the whole cycle C will be burnt at the end of the game. In case 2, we assume the whole cycle C will be burnt at the end, therefore the firefighter should not protect any vertices on path P and cycle C. Since the fire will reach cycle C starting from c0, and none of the vertices on cycle C get protected, so we have the following fact: Fact 3 If the fire burnt all the vertices on cycle C, the last vertex being burnt on cycle C, is either c(cid:98)r/2(cid:99) or c(cid:98)r/2(cid:99)+1. Let e(cid:48) be the edge on the cycle C connecting the 2 vertices c(cid:98)r/2(cid:99) and c(cid:98)r/2(cid:99)+1. When the fire pass along edge e(cid:48), the whole cycle C is completely burnt already. Therefore, we can first transform G to a tree T2 by deleting edge e(cid:48). Then we use random separation method to solve the Maximum k-Vertex Protection firefighter problem on the tree T2. To guarantee the whole cycle C will be burnt at the end, we colors all the vertices on the path P and cycle C 8 red, before randomly coloring all the other vertices in green or red. Then the optimal solution S2 of the problem on the tree T2 is exactly the optimal solution S0 of the problem on the graph G based on the requirement of case 2. Case 3 c0 will be burnt but at least one vertex on the cycle C will be saved at the end of the game. This is the most complicated case to consider among all the cases. As c0 will be burnt, which means the whole path P will be burnt, and the fire can enter cycle C and burn some of the vertices on C. However, the criteria "at least one vertex on the cycle C will be saved" tells us that there exists at least one protected vertex on the cycle C, unless no other protected vertices can save vertices on C from the fire. The main idea to solve this case is to exhaust all the possible combinations of protected vertices located on cycle C in the optimal solution S0, then we can figure out which vertices on cycle C will be saved, and delete them from the graph to get a tree. To ensure the algorithm runs in FPT time, we need the following important fact: Fact 4 Let S0 be the optimal strategy of the problem on the unicyclic graph G with a cycle C, then the number of vertices in C ∩ S0 is at most 2. Proof If c0 is saved, we only need to protect one vertex on the path P in order to save the whole cycle C, therefore we never need to protect any vertices on C except for c0, then at most one protected vertex on C would be enough. Consider the case that c0 is burnt. Let q be the number of vertices in S0 located on cycle C. We call those vertices U = {u1, u2, ..., uq} ⊆ S0. Assume q ≥ 3. We can always find two vertices in U , say u1 and u2, cut the cycle C into two half. Let's call these two half Cup and Cdown, with Cup contain the vertex c0. Consider another vertex u3, if u3 is on Cdown, then u3 is already saved by the 2 protected vertices u1 and u2 as they block the only two route that the fire can enter Cdown. It is no point for the firefighter to include u3 as a protected vertex in the optimal strategy. If u3 is on Cup, then either u3 and u1 save u2, or u3 and u2 save u1 from the fire, either u1 or u2 becomes pointless and can be removed from the optimal strategy S0. i.e. the set U should contain at most 2 vertices. (cid:3) Fact 4 tells us that only 2 protected vertices on the cycle C is sufficient for us to construct an optimal strategy S0. Besides, by the requirement of case 3, at least one vertex on the cycle C has to be protected. Exhaust for all pairs of vertices u1 and u2 on the cycle C, where u1 can be equal to u2. We assume u1 and u2 are the only protected vertices in S0 on the cycle C, and they cut the cycle C into two half Cup and Cdown, with c0 located on the half Cup. We can easily see that the vertices on Cup will be all burnt and the vertices on Cdown will be all saved. For each pair of u1, u2,transform the graph G to a tree T3(u1, u2) by removing all the vertices and edge on Cdown, and also all the subtrees originally rooted at the vertices on Cdown. Then we can use random separation to solve the problem on the graph T3(u1, u2), by pre-coloring the paths P and Cup to red, and u1, u2 to blue. Then the optimal strategy S3(u1, u2) of the problem on T3(u1, u2) is exactly the optimal strategy of the problem on graph G, condition on the criteria of case 3 and both u1 and u2 are the element of S0. 9 Figure 4: Exhaustion for vertex u1 and u2 In the exhaustion in case 3 , the choices of u1 and u2 are both bounded by the size of the cycle. Therefore we need to use Cai, Verbin and Yang's FPT algorithm O(n2) times in each choice of u1, u2. As all the transformations from a graph G to a tree T (cid:48) mentioned above take only linear time. Combining the algorithms in all 3 cases, finally we construct a FPT algorithm runs in time k−O(k)n3. And it can be derandomized using asymmetric universal sets to get a deterministic algorithm that runs in time k−O(k)n3 log n. Actually, the algorithm above can be generalized to solve the firefighter problem in the family of graph tree + b edges, for any small constant b. In unicyclic graph, b = 1, and the randomized FPT algorithm runs in time k−O(k)n3. Generally, one can use a similar approach to construct an algorithm solving the firefighter problem on tree + b edges in time k−O(k)n(2b+1). Unfortunately, it is not FPT time if both k and b are parameters of problem, as the complexity depends on n(2b+1), but the algorithm is also efficient when b is a small fixed constant. Here we omit the details on constructing algorithm of the Maximum k-Vertex Protection firefighter problem on tree + b edges in k−O(k)n(2b+1) log n time. The main idea is to modify the exhaustion in case 3, from 2 vertices u1, u2 on cycle C to 2b vertices u1, u2, ..., u2b on the cyclic subgraph based on the fact below: Fact 5 Let S0 be the optimal strategy of the problem on the tree + b edges graph G, there exists a subgraph G(cid:48) where G − G(cid:48) is a forest, and the number of vertices in G(cid:48) ∩ S0 is at most 2b. The above fact can be deduced by fact 4 by considering the b smallest cycles induced by the extra b edges. As Cai, Verbin and Yang show in their paper that the Saving k Vertices firefighter problem on trees has a polynomial kernel of size k2 [CVY08], one may be curious if the problem on tree + b edges graph also has a polynomial kernel or not. If there exists a polynomial kernel, we can reduce the complexity of the above algorithm to FPT time even for large b. However, since both the Saving k Vertices and Maximum k-Vertex Protection firefighter problem on general were proven to be W[1]-hard, and any general graph can be consider as a tree + b edges graph if b is not bounded, therefore it seems very uneasy to find a polynomial kernel in this situation. 10 6 Weighted and unequal valued graph In the previous discussion, we only consider the firefighter problem on unweighted graph, i.e. all the edges have equal distance, therefore the fire spreads out uniformly to the unprotected neighbours of the burnt vertices at each time step. Besides, all the vertices are assumed to be equally valuable, and all the edges are set to have no values. In this section, we will focus on the firefighter problem on weighted graph and unequal valued graph. We define the weighted firefighter problem as follow: A fire initially breaks out at a vertex r on a weighted graph G. In each time step i, a firefighter chooses to protect one vertex vi, which is not yet burnt. Then for each edge e(cid:48) = (u, v) with an integral edge weight we(cid:48), where u is already on fire at time i − we(cid:48) and v is not yet on fire, the fire spreads out from u to v along the edge e and burn v at time i. The objective of the problem is to choose a sequence of vertices {vi} to protect, in order to save maximum number of vertices from the fire. The original firefighter problem on unweighted graph is the weighted firefighter problem with all the edge weights equal to 1. For any weighted graph G of maximum weight wm, we try to transform G to an unweighted graph G(cid:48) by local replacement. For each edge e = (u, v) with edge weight we = 0, we contracts these edges and combine each (u,v) pair to be a single vertex. For each edge e = (u, v) with edge weight we > 1, we replace it by a path P of we edges by adding we− 1 vertices between u and v. If G(cid:48) follows certain properties, for instance, G(cid:48) is degree bounded or unicyclic, then we can try to find the solution of the problem on graph G(cid:48) using random separation by pre-coloring all the newly-added vertices to yellow (or red in unicyclic case). Then we can apply the known FPT algorithm on unweighted graph to the weighted firefighter problem, where the time complexity would be almost the same (with a multiplication factor of wm). Now we consider the case that each vertices on the graph G have unequal value, i.e. some vertices are more valuable that we have more motivation to save them from the fire. Also, we assumes the edges contain values too, therefore we are motivated to save valuable edges. A edge e = (u, v) is said to be saved if both vertices u and v are saved, otherwises it is a burnt edge. This model is more realistic in the application of firefighter problem on diseases or computer-viruses control. Here we assign each vertex v a "value" zv, each edge e a "value" ze, and the objective of the valued − f iref ighter problem is to choose a sequence of vertices {vi} to protect, in order to maximize the total value Z of saved vertices and saved edges. The original equally valued firefighter problem is the valued firefighter problem with all the vertex values equal to 1 and all the edge values equal to 0. For any valued graph G of maximum value zm, we try to transform G to an equally valued graph G(cid:48) by local replacement. For each edge e = (u, v) with edge value ze ≥ 1, we replace it by a path P of ze + 1 "value 0" edges by adding ze "value 1" vertices between u and v. For each vertex v with value zv > 1, we replace it by a path P of zv "value 1" vertices by adding zv − 1 "value 0" edges. After all, we can also try to find the solution of the problem on graph G(cid:48) using random separation by pre-coloring all the newly-added vertices to yellow (or red in unicyclic case), which runs in the same time complexity of the originally problem (with a multiplication factor of zm), similar to what we mention above in the weighted graph case. Notice that the above algorithm does not work if there exists vertex with value 0. Actually, in the special case of firefighter problem on trees, the well-known Saving k Leaves problem is special case of firefighter problem on valued graph where internal vertices have value 0. And the parametric dual Saving all But k Leaves is NP-complete even for k=0, shown by Finbow et. al. [FKMR07], so there is no FPT algorithm for the problem Saving all But k Leaves unless P=NP. In Section 3 of this report, we show that k Vertices Burnt of equally valued firefighter problem on general graph is FPT. If there exists a reduction method to reduce any 11 valued graph G with 0-value vertices to an equally valued graph, then we show Saving all But k Leaves is FPT and prove P=NP. Therefore, it is not surprising that the above algorithm cannot reduce a valued graph with 0-value vertices to equal valued graph. 7 Multiple fire sources, multiple protection and multiple burning In this final section, we are considering the firefighter problem with multiple fire sources and multiple firefighters. Multiple fire sources means that there are more than one sources (say g sources) on fire initially. Multiple protection means that the firefighter can protect more than one vertices, say p vertices, before the fire spreads out in each time step. Multiple protection means that the fire spreads out by several units length, say h units, after firefighter's action in each time step. The firefighter problem with multiple fire sources on general graph is nothing but just an ordinary firefighter problem by combining all the g fire sources into one single source. Let S = {s1, s2, ..., sg} be the g sources on the graph G, we define G(cid:48) = merge(G; S). The result of At Most k Vertices Burnt problem on general graph G(cid:48) in Section 3 is the same in the result of the problem on graph G. For the Maximum k-Vertex Protection problem on degree bounded graph, we can also combine all the g fire sources into one single source. The only difference is the maximum degree of the source in G' is no longer d, but becomes gd. Therefore the complexity of the randomized algorithm is O(3(k2+g)(d+1)(n + m)). Figure 5: Transformation from 2 fire sources on tree to 1 fire source on unicyclic graph 12 Similarly, by combining all the g fire sources into one single source, the firefighter prob- lem with multiple fire sources on trees or unicyclic graphs can be transform to the ordinary firefighter problem on tree + (g − 1) edges and tree + g edges graph respectively. For ex- ample, consider the firefighter problem with 2 fire sources on a tree T, by combining the two fire sources s1 and s2 into a single vertex, the tree T is transform to be an unicyclic graph G(cid:48) = merge(G;{s1, s2}). Then we can use the FPT algorithm mentioned in Section 5 to solve it in k−O(k)n3 time. If g is a small fixed constant, the firefighter problem with multiple fire sources on tree + b edges can be transformed to the firefighter problem with single fire source on tree + (b + g − 1) edges, and there exists an algorithm runs in k−O(k)n(2b+2g−1) time. The firefighter problem with multiple protection and multiple burning is also very sim- ple. By changing the parameter k to be total number of rounds, we define a firefighter problem called Maximum k-Step Protection with multiple protection and multiple burning as follow: We want to find an optimal strategy S0 = {{v11, ..., v1p}, ...,{vk1, ..., vkp}}, where k is the total number of time steps of the game and p is the number of vertices a firefighter can protect in each time step. This optimal strategy S0 can save maximum number of the vertices from the fire, where the fire burns h layers of neighbours of the vertices on fire in each time step. Without multiple protection and multiple burning, the problem Maximum k-Step Pro- tection can be reduced to Maximum k-Vertex Protection. Otherwise, we can solve this problem in FPT time using the similar strategy as above. For example, considering the Maxi- mum k-Step Protection firefighter problem with multiple protection and multiple burning on degree bounded graphs, we can treat the problem as an ordinary Maximum (cid:100)kp/h(cid:101)-Vertex Protection firefighter problem. Using the algorithm provided on Section 4, with (cid:100)kp/h(cid:101) strat- egy vertices green, (cid:100)kp/h(cid:101)2 BFS Burning Tree vertices red, and (cid:100)kp/h(cid:101)2d neighbouring vertices yellow as good coloring. Then we can do a BFS from the source s, and check if all the green leaves satisfy the criteria of optimal strategy or not. Notice that the Procedure for verifying if V ∗ is a satisfying strategy set given in Section 3 also has to be modified a little bit as below: Modified Procedure for verifying if V ∗ is a satisfying strategy set for multiple protection and burning Input: graph G, source s, integer p and h, vertex set V ∗ to be verified, and burnt vertex set V (cid:48) Output: If true, output the sequence of satisfying strategy in correct order. If false, output "no". 1. Do BFS on the subgraph V (cid:48) starting from s, find the distance d[s, v] of the each vertices v on V ∗ from the source s on the subgraph G(cid:48) = {N [V (cid:48)], E(V (cid:48))∪ E(V (cid:48), V ∗)}. 2. Sort the vertices V ∗ according to d[s, v] in ascending order. Store the sorted sequence in an array {vi} 3. for i = 1 to V ∗ do If the distance from the source of the i-th vertex satisfies the relation (cid:100)d[s, vi]/h(cid:101) < (cid:100)i/p(cid:101), then the solution is not valid, output "no" and halt. 4. Output the sequence {vi} as the corresponding firefighting strategy in correct order. Therefore, we can solve the Maximum k-Step Protection firefighter problem with mul- tiple protection and multiple burning in the degree bounded graph in FPT time. Similarly, by modifying the algorithm in Section 5, one can also construct an FPT algorithm for the Maximum k-Step Protection in the unicyclic graph. 13 8 Acknowledgments I gratefully acknowledge the support of Computer Science and Engineering Department, the Chinese University of Hong Kong. I have to thank Professor Leizhen Cai, for the innoviative teaching and offering continuing advice and guidance. I am also thankful to my master super- visor, Professor Shengyu Zhang, who have been giving me much support and encouragement on my study and research. References [CCC06] [CVY08] [CW09] [DH07] L. Cai, S.M. Chan, and S.O. Chan. Random separation: A new method for solving fixed-cardinality optimization problems. Bodlaender, H.L., Langston, M.A. (eds.) IWPEC 2006. LNCS, 4169:239 -- 250, 2006. Springer, Heidelberg. L. Cai, E. Verbin, and L. Yang. Firefighting on trees: (1-1/e)-approximation, fixed parameter tractability and a subexponential algorithm. S.H. Hong, H. Hagamochi, and T. Fukunaga (Eds.) ISAAC, LNCS 5369:258 -- 269, 2008. L. Cai and W. Wang. The surviving rate of a graph for the firefighter problem. SIAM Journal on Discrete Mathematics, 2009. M. Develin and S.G. Hartke. Fire containment in grids of dimension three and higher. Discrete Applied Mathematics, 155(17):2257 -- 2268, 2007. [FKMR07] S. Finbow, A. King, G. MacGillivray, and R. Rizzi. The firefighter problem for graphs of maximum degree three. Discrete Mathematics, 307(16):2094 -- 2105, 2007. [Fog03] [Har95] [HL00] [MW03] P. Fogarty. Catching the fire on grids. M.Sc. Thesis, Department of Mathematics, University of Vermont, 2003. B. Hartnell. Firefighter! an application of domination. 24th Manitoba Conference on Combinatorial Mathematics and Computing, pages 4 -- 27, 1995. 24th Manitoba Conference on Combinatorial Mathematics and Computing, University of Minitoba, Winnipeg, Canada. B. Hartnell and Q. Li. Firefighting on trees: how bad is the greedy algorithm? Congr. Numer, 145:187 -- 192, 2000. G. MacGillivray and P. Wang. On the firefighter problem. J. Combin. Math. Combin. Comput., 47:83 -- 96, 2003. [NSS95] M. Naor, L.J. Schulman, and A. Srinivasan. Splitters and near-optimal derandom- ization. IEEE Symposium on Foundations of Computer Science, pages 182 -- 191, 1995. [Ver] E. Verbin. Asymmetric universal sets (in preparation). [WM02] P. Wang and S. Moeller. Fire control on graphs. Journal of Combinatorial Mathe- matics and Combinatorial Computing, 41:19 -- 34, 2002. 14
1712.04217
2
1712
2017-12-15T12:39:02
Dynamic Discrete Tomography
[ "cs.DS", "math.CO" ]
We consider the problem of reconstructing the paths of a set of points over time, where, at each of a finite set of moments in time the current positions of points in space are only accessible through some small number of their X-rays. This particular particle tracking problem, with applications, e.g., in plasma physics, is the basic problem in dynamic discrete tomography. We introduce and analyze various different algorithmic models. In particular, we determine the computational complexity of the problem (and various of its relatives) and derive algorithms that can be used in practice. As a byproduct we provide new results on constrained variants of min-cost flow and matching problems.
cs.DS
cs
DYNAMIC DISCRETE TOMOGRAPHY ANDREAS ALPERS AND PETER GRITZMANN Abstract. We consider the problem of reconstructing the paths of a set of points over time, where, at each of a finite set of moments in time the current positions of points in space are only accessible through some small number of their X-rays. This particular particle tracking problem, with applica- tions, e.g., in plasma physics, is the basic problem in dynamic discrete tomography. We introduce and analyze various different algorithmic models. In particular, we determine the computational complex- ity of the problem (and various of its relatives) and derive algorithms that can be used in practice. As a byproduct we provide new results on constrained variants of min-cost flow and matching problems. 1. Introduction In the following, the goal is to determine the paths P1, . . . ,Pn of n particles in space over a period of t ∈ N moments in time from images taken by a a fixed number m of cameras. Each spot in each camera image is the projection of a particle perpendicular to the plane of the corresponding camera. The number of particles that project on the same spot can be detected from the brightness of the image. Hence, in effect, for each moment in time we have the information how many particles lie on each line perpendicular to the planes of the cameras. We will refer to this information as the X-ray images of the set of particles in m directions; details will be given in Section 2. This problem lies at the core of dynamic discrete tomography, and we will refer to it as tomographic point tracking or tomographic particle tracking. As it turns out, the problem comprises two different but coupled basic underlying tasks, the reconstruction of a finite set of points from few of their X-ray images (discrete tomography) and the identification of the points over time (tracking). For surveys on various aspects of discrete tomography see [28, 31, 32, 34, 35]. Tracking is known in the literature as data association or object tracking and, for more specific applications, as multi-target tracking, multisensor surveillance or, in physics, as particle tracking; see [14, 21, 41, 42, 43, 44, 45, 50] and, e.g., [1, 16, 18] for surveys. Tomographic particle tracking was already considered in [24, 26, 38, 40, 54] and [8]. In fact the linear programming based heuristic introduced in [8] was successfully applied to determine 3D-slip velocities of a gliding arc discharge in [56]. Another linear programming approach, different from [8, 56], was recently proposed in [24]. In the present paper we study the problem from a mathematical and algorithmic point of view with a special focus on the interplay between discrete tomography and tracking. Therefore we will distinguish the cases that for none, some or all of the t moments τ1, . . . , τt in time, a solution of the discrete tomography task at time τ1, . . . , τt is explicitly available (and is then considered the correct solution regardless whether it is uniquely determined by its X-rays). For d ≥ 3, two (affine) lines in Rd in general position are disjoint. Hence, generically, X-ray lines meet only in points of the underlying set. Therefore even the latter situation is of considerable practical relevance. We will refer to it as the 7 1 0 2 c e D 5 1 ] S D . s c [ 2 v 7 1 2 4 0 . 2 1 7 1 : v i X r a Zentrum Mathematik, Technische Universität München, D-85747 Garching bei München, Germany E-mail address: [email protected], [email protected]. The authors gratefully acknowledge support through the German Research Foundation Grant GR 993/10-2 and the European COST Network MP1207. NOTICE: THIS IS AN AUTHOR-CREATED, UN-COPYEDITED VERSION OF AN ARTICLE AC- CEPTED FOR PUBLICATION/PUBLISHED IN INVERSE PROBLEMS. IOP PUBLISHING LTD IS NOT RESPONSIBLE FOR ANY ERRORS OR OMISSIONS IN THIS VERSION OF THE MANUSCRIPT OR ANY VERSION DERIVED FROM IT. THE VERSION OF RECORD IS AVAILABLE ONLINE AT HTTPS://DOI.ORG/10.1088/1361-6420/AAA202. 1 2 DYNAMIC DISCRETE TOMOGRAPHY positionally determined case while, in the more general situation, we will speak of the (partially) or (totally) tomographic case of point tracking. In the following, we discuss several models for dynamic discrete tomography, give various algorithms and complementing NP-hardness results. In particular, we show for the positionally determined case that the tracking problem can be solved in polynomial time if it exhibits a certain Markov-type property (which, effectively, allows only dependencies between any two consecutive time steps); see Theorem 1. The partially tomographic case, however, is NP-hard even for t = 2; see Theorem 2. Complementing this result, we consider the tomographic tracking problem for two directions where a so-called dis- placement field is assumed to be given (the displacement field uniquely determines the particle's next position). Again, this problem turns out to be NP-hard already for t = 2 and certain realistic classes of displacement fields; see Theorem 3. We then turn to the rolling horizon approach introduced in [8] which proceeds successively from step to step. After giving a short account of this method in Section 3.4 we will show that, while being quite successful in practice, it is not guaranteed to always yield the correct solution; see Example 1. Then, in Section 3.5 we study the issue of of how to incorporate additional prior knowledge of particle history into the models. Under rather general assumptions we show that already in the positionally determined case the tracking problems becomes NP-hard for t > 2; see Theorem 4. In particular, we show that even if the particles are known to move along straight lines, this prior knowledge cannot efficiently be exploited algorithmically (unless P = NP); see Theorem 5 and Corollary 3 and 4. We proceed by introducing three algorithms that can be viewed as rather general paradigms of heuristics that involve prior knowledge about the movement of the particles and which can be used in the tomographic case. We then discuss combinatorial models. In these models the positions of the particles in the next time step are assumed to be known approximatively in the sense that the candidate positions are confined to certain windows, which are finite subsets of positions. Again, under rather general conditions, we show NP-hardness of the respective tomographic tracking tasks; see Theorem 8. However, we also identify polynomial-time solvable special cases of practical relevance; see Theorem 9 and 10. The paper is organized as follows: Section 2 will introduce the relevant notation, provide some basic background, discuss various modeling issues including the question of how to rigorously incorporate a notion of 'physically most likely' solution, and state our main results. Then main focus of the present paper lies on optimization models. They are studied in quite some detail in Section 3. In particular, we consider Markov-type integer programming and rolling horizon models and discuss the issue of utilizing the particle history from a structural algorithmic point of view. Also, we determine the computational complexity of the problems. We prove various NP-hardness results, both, for the partially tomographic and the totally tomographic case, in the latter, even when the displacement field is known. Then we give various heuristic algorithms (or, to be more precise, classes of algorithmic paradigms) which are designed with a view towards balancing the running time and the achieved quality of the solutions. In the prevailing presence of NP-hardness such a balancing is mandatory for a successful use in practical applications (of realistic size). Section 4 deals with a different way of encoding a priori information about the movement of the particles. The studied combinatorial models utilize such information in terms of bounds on the number of particles in certain windows. We provide NP-hardness results but also identify polynomially solvable classes of instances. The paper concludes with some final remarks in Section 5. 2. Notation, basics and main results 2.1. Discrete Tomography. Let R, Q, Z, and N denote the set of reals, rational numbers, integers, and natural numbers, respectively. For q ∈ N, let [q] = {1, . . . , q} and [q]0 = [q] ∪ {0}. With 11 we denote the all-ones vector. Further, let d, m ∈ N, d ≥ 2, and set F d = {F : F ⊆ Qd ∧ F is finite}. DYNAMIC DISCRETE TOMOGRAPHY 3 The point sets F ∈ F d model the sets of particles (in a static environment). Let us point out that, mathematically, the restriction to Qd is merely a tribute to the model of computation that we are going to apply. In fact, we will use the binary Turing machine model where each element is encoded in binary and hence its size is the number of binary digits needed for this representation; see e.g. [30]. (The binary size of a positive integer q is therefore essentially log(q).) Note that this restriction is also in accordance with standard practical measurements which do not allow infinite precision. With S d we denote the set of all lattice lines, i.e., the set of 1-dimensional linear subspaces of Rd that are spanned by vectors from Zd. (Note that as S d coincides with the set of lines spanned by rational vectors, there is no further restriction here.) The lines in S d are (in a slight abuse of language) often referred to as directions. In fact, in an experimental environment, these lines are the 'viewing directions' under which the cameras 'see' the particles i.e., they are perpendicular to the image planes of the cameras. For S ∈ S d, we set A(S) = {v+S : v ∈ Qd}. Then, for F ∈ F d and S ∈ S d, the (discrete 1-dimensional) X-ray of F parallel to S is the function XSF : A(S) → N0 = N ∪ {0} defined by XSF (T ) = F ∩ T = χF (x) (cid:88) x∈T for each T ∈ A(S), where, as usual, F ∩ T denotes the cardinality of F ∩ T and χF is the characteristic function of F . Let us point out that this definition is the basis of the paramount grid model of discrete tomography (see [28, 31, 32, 34, 35] which we will use throughout the paper. Of course, the term X-ray is meant generically here, i.e., does not necessarily refer to a specific imaging technique. However, the main motivation underlying the present paper is that of tracking physical particles which are 'visible' only through the camera image of their projections. Two sets F1, F2 ∈ F d are called tomographically equivalent with respect to S1, . . . , Sm ∈ S d if for all i ∈ [m]. Given m different lines S1, . . . , Sm ∈ S d, the X-ray data is given in terms of functions XSiF1 = XSiF2, fi : A(Si) → N0 (i ∈ [m]), with finite support Ti ⊆ A(Si), represented by appropriately chosen data structures; see [29]. Suppose, we are given an instance (f1, . . . , fm) of measurements of an otherwise unknown set F ∈ F d. Then, of course, F = (cid:107)f1(cid:107)(1) = . . . = (cid:107)fm(cid:107)(1), where (cid:107) · (cid:107)(1) is the usual 1-norm. From the data functions we can infer that F must be contained in the grid m(cid:92) (cid:91) i=1 T∈Ti G = T of candidate points. Note that, in general, even when the given instance has a unique solution F, the grid G can be a proper superset of F. 2.2. Dynamic Discrete Tomography. In tomographic point tracking, we consider t consecutive moments in time. Hence, in particular, we are interested in the sets F (τ ) of particles at each moment in time τ ∈ [t]. Since, in general, these sets are accessible only through their X-rays taken from a given finite set of directions, they represent t uncoupled instances of discrete tomography. Of course, we also need to track the particles over time. Let P = {p1, . . . , pn} denote the (abstract) set of n particles. Then, for each τ ∈ [t], we are actually interested in a one-to-one mapping π(τ ) : P → F (τ ) that identifies the points of F (τ ) with the particles. Hence, the particle tracks are given by Pi = (π(1)(pi) . . . , π(t)(pi)), i ∈ [n]. We will refer to this identification as coupling. 4 DYNAMIC DISCRETE TOMOGRAPHY Note that the coupling between two consecutive moments in time bears the character of a matching in a bipartite graph. In tomographic point tracking, however, the tasks of discrete tomography and matching strongly interact. As it is well-known that for m ≥ 3 already the static reconstruction problem of discrete tomography is NP-hard [29] (see also [15]), highly instable [3, 9], and since in practical experiments space for installing cameras is typically strictly limited (see, e.g, [8]) we will mainly focus on the case m = 2. In real-world particle tracking this corresponds to images taken from two cameras which may be regarded as two planes in R3 orthogonal to two different directions S1, S2, respectively. For m = 2, a set F (τ ) satisfying the X-ray constraints with respect to the two given directions S1 and S2 can be efficiently determined for each τ ∈ [t]; see [27, 46]. Also, it can be checked efficiently, whether each F (τ ) is unique. (For related stability results see [4, 51].) Since a set is only very rarely uniquely determined by just two of its X-rays, the reconstruction will typically rely on additional physical knowledge. (For various uniqueness results the reader is referred to [33] and the literature quoted therein.) But even if we know for each τ ∈ [t] the correct set F (τ ), we still have to identify the paths of all individual particles over time. This turns the t otherwise uncoupled systems into a single coupled system. Here we will in particular discuss the question of how to utilize additional information via the coupling, which thus might reduce the ambiguity of the uncoupled tomographic tasks. But how can the goal of determining a 'physically most likely' solution be modeled? Let Π(n, t) denote the set of all n-tuples (P1, . . . ,Pn) of potential particle tracks over t moments of time for fixed point sets F (τ ). If the given tomographic particle tracking data is feasible there may, of course, exist many different but tomographically equivalent solutions for each τ. In any case, Π(n, t) is then still a lower bound for the number of different potential solutions. Now note that Π(n, t) = (n!)t, and even if the order of the individual paths is irrelevant, this number reduces only to (n!)t−1, which is still exponential in n and t. Of course, this means that any enumerative algorithm will fail in practice even for quite moder- ate numbers of particles and time steps. But even worse, we cannot encode as input the 'physical costs' c(P1, . . . ,Pn) of all (P1, . . . ,Pn) explicitly. Even if we assume that all sets F (τ ) are given and such costs can be computed as a simple function of the costs w(Pi) of the individual paths, e.g., as n(cid:88) i=1 w(Pi) or w(Pi), max i∈[n] the number of different costs w(P) of a particle path (which still need to be available to determine the cost of a solution(P1, . . . ,Pn)) reduces only to nt. In the following we will therefore in general refrain from assuming that such values are explicit parts of the input. We will instead assume that an algorithm is available which computes for any solu- tion (P1, . . . ,Pn) its cost c(P1, . . . ,Pn) in time that is polynomial in all the other input data. In some situations such an algorithm will be based on additional specific data which reflect how appropriate certain (local) choices are and which will then be regarded as be part of the input, too. Such an algo- rithm O will be called an objective function oracle. In the special case that O provides the values w(Pi) i=1 w(Pi), the oracle will be referred to as path value oracle. and c(P1, . . . ,Pn) =(cid:80)n For all practical algorithms, such an oracle will of course be specified explicitly. (It will typically be based on weights on grid points or pairs of grid points which augment the input of our problem.) 2.3. Basic algorithmic problems. Algorithmically, our general problem of tomographic particle tracking for m given different directions S1, . . . , Sm ∈ S d, and based on an objective function oracle O, can now be formulated as follows. DYNAMIC DISCRETE TOMOGRAPHY 5 TomTrac(O; S1, . . . , Sm). Instance: m (cid:107)(1) = n. Task: , . . . , f (τ ) 1 t ∈ N, X-ray data functions f (τ ) (cid:107)f (τ ) Decide whether, for each τ ∈ [t], there exists a set F (τ ) ∈ F d such that XSiF (τ ) = f (τ ) for all i ∈ [m]. If so, find particle tracks P1, . . . ,Pn of minimal cost for O among all couplings of all tomographic solutions F (1), . . . , F (t). m for τ ∈ [t] with (cid:107)f (τ ) 1 (cid:107)(1) = . . . = Let us add a remark concerning the assumption, that the 1-norms of the X-ray data functions in TomTrac(O; S1, . . . , Sm) are known and assumed to coincide. First, note that the latter condition is quite natural if all particles are detected at each moment in time. Also, both conditions can be checked in polynomial time. Since in practice, cameras have a finite field of view it may, however, happen in an experimental setting that several previously detected particles may move out of the field of view of the camera. Also particles may appear (or reappear) during the measurements. In this situation we might at least aim at obtaining partial results by reconstructing partial tracks or by including dummy nodes, which account for invisible particles (for a discussion, see, e.g., [36]). In the following, our prime focus will lie, however, on the case that all n particles are recorded at each moment in time τ ∈ [t]. In the following we will distinguish the cases that for none, some or all τ ∈ [t], the correct solution F (τ ) is explicitly given. The former will be referred to as the (partially) or (totally) tomographic case while we speak of the latter as positionally determined. In the positionally determined case the problem TomTrac(O; S1, . . . , Sm) reduces to the following problem. Trac(O; d). Instance: Task: t ∈ N, sets F (1), . . . , F (t) ∈ F d with F (1) = . . . = F (t) = n. Find particle tracks P1, . . . ,Pn of minimal cost for O among all couplings of the sets F (1), . . . , F (t). Note that each instance of Trac(O; d) can be viewed as a t-dimensional assignment problem. For a comprehensive survey on assignment problems see [16] and the references quoted therein. As pointed out before, for d ≥ 3, the positionally determined case is the generic situation even for m = 2 as two lines parallel to S1 and S2 do only meet in points of F (τ ). However, for d = 2, any two non- parallel lines in the plane meet in a point, whence forming a candidate grid G(τ ) of size O(n2). (Note that, generally, no fixed number m of X-ray images suffices for unique determination.) Also, even in Rd with d ≥ 3, there are particle constellations for which the candidate grids G(τ ) do not consist of just n points. And, of course, if the resolution of the images is low, such constellations become relevant even in practice. In some applications, there is strong prior knowledge about the possible couplings available. Most notably is the case where a displacement field is prescribed. Formally a particle displacement field (for the time step τ → τ + 1) is a pair (p, ϕ(τ )(p)− p) with ϕ(τ ) : Qd → Qd denoting a map where ϕ(τ )(p)− p denotes the displacement vector for a particle located at position p at time τ. In particular, if π(τ )(pi) denotes the position of the i-th particle at time τ, then π(τ +1)(pi) = ϕ(τ )(π(τ )(pi)), for i ∈ [n] and τ ∈ [t−1]. Now, the tomographic tasks for the time step τ → τ +1 consists of determining the positions of the particles at time τ such that the solution at time τ + 1 determined by the displacement field matches the tomographic data for τ + 1. We say that F (τ ) and F (τ +1) are ϕ(τ )-compatible if both sets satisfy the corresponding tomographic constraints and ϕ(τ )(F (τ )) = F (τ +1). For the following problem we suppose that a for any τ ∈ [t − 1] a displacement field (p, ϕ(τ )(p) − p), p ∈ Qd, is known. While for our main NP-hardness result, the displacement field is given explicitly, all that our model of computation actually requires is that for any τ ∈ [t − 1] and p ∈ G(τ ), either a point q ∈ G(τ +1) is provided such that ϕ(τ )(p) = q or it is reported that no such point exists. (It is not difficult to model this formally again as some displacement field oracle). With this understanding, the tomographic point tracking problem with given displacement field by the oracle O is as follows. 6 DYNAMIC DISCRETE TOMOGRAPHY TomDisplaceTrac(O; S1, . . . , Sm). Instance: Task: , . . . , f (τ ) m (cid:107)(1) = n; displacement field ϕ(τ ) for τ ∈ [t − 1]. t ∈ N, X-ray data functions f (τ ) (cid:107)f (τ ) Find sets F (1), . . . , F (t) ∈ F d such that XSiF (τ ) = f (τ ) for all i ∈ [m], and such that F (τ ) and F (τ +1), are ϕ(τ )-compatible for all τ ∈ [t − 1], or decide that no such sets exist. m for τ ∈ [t] with (cid:107)f (τ ) 1 (cid:107)(1) = . . . = 1 2.4. Main results. Our main results are as follows. First, we consider TomTrac(O; S1, . . . , Sm) for Markov-type models, i.e., for objective function oracles O that can be given explicitly as the sum of all costs of assigning points between consecutive moments in time. We show that the corresponding version of TomTrac(O; S1, . . . , Sm) for the positionally determined case, called Trac(d), can be solved in polynomial time (Theorem 1). For the tomographic case, we show that even if all instances are restricted to t = 2, and the solution F (1) is given explicitly, TomTrac(S1, S2) is NP-hard (Theorem 2). (Also the corresponding uniqueness problem is NP-hard and the counting problem is #P-hard.) This result is complemented by Theorem 3, which shows that TomDisplaceTrac(O; S1, S2) is NP-hard for t = 2 and certain conditions imposed on the specified displacement field. Theorem 4 shows that the problem Trac(O; d) is NP-hard, even if all instances are restricted to a fixed t ≥ 3, and O is a path value oracle. Also in the case of straight line movement and fixed d ≥ 2, t ≥ 3 it is NP-complete problem to decide whether a solution of Trac(O; d) exists where all particles move along straight lines (Corollary 3). We conclude Section 3 by introducing and discussing algorithmic paradigms that allow to include prior knowledge of the possible particle tracks. Section 4 then studies combinatorial models. In particular, we discuss Tomography under Window Constraints, which, under rather mild conditions, turns out to be NP-hard (Theorem 8). On the other hand, we show in Theorem 9 that it is in P if all windows are disjoint horizontal and vertical windows of width 1. Another polynomial-time solvable variant of Tomography under Window Constraints, which arises in super-resolution imaging applications, is discussed in Theorem 10. 3. Optimization Models In the following we assume that we have X-ray measurements from two different directions S1, S2 ∈ S d at t moments in time. As before, G(τ ) will denote the corresponding grid at τ ∈ [t]. While the grids G(τ ) are subsets of Rd, we need to distinguish a point g(τ1) ∈ G(τ1) from a point g(τ2) ∈ G(τ2) when τ1 (cid:54)= τ2 even if, physically, both points occupy exactly the same position in Rd. So, formally, g(τ ) must be regarded as a point (g, τ ) ∈ Rd × [t]. In the following, however, we will not always 'verbally' distinguish between the interpretations G(τ ) ⊆ Rd and G(τ ) ⊆ Rd × [t] if there is no risk of confusion. In the positionally determined case where the correct sets F (τ ) are known, we can, of course, directly work with F (τ ). Hence, whenever we speak of the positionally determined case, it is in the following tacitly assumed that G(τ ) = F (τ ). 3.1. A Markov-type integer programming model. In this section we will consider the prob- lem TomTrac(O; S1, . . . , Sm) for objective function oracles O that can be given explicitly since their values are just the sums of all costs of assigning points between consecutive moments in time. We call these models Markov-type since the objective function reflects only dependencies that occur between neighboring layers. In Section 3.5 we will discuss more general models. Let us now present an integer linear programming (Ilp) model for this problem. In order to make the for i ∈ I (τ ) = [G(τ ) ]. notation as transparent as possible we number the points of each grid G(τ ) as g(τ ) Also, we set e(τ ) ), and refer to such pairs as tracking edges. The objective function will , g(τ +1) i i,j = (g(τ ) i j DYNAMIC DISCRETE TOMOGRAPHY 7 then depend only on weights ω(τ ) assigning a point g(τ ) i ∈ G(τ ) to a point g(τ +1) j i,j , associated with the tracking edges, which measure the cost of ∈ G(τ +1). Explicitly expressed, we have c(P1, . . . ,Pn) = n(cid:88) (cid:88) (cid:88) k=1 τ∈[t] i,j ∈Pk e(τ ) ω(τ ) i,j . for e = e(τ ) Setting w(e) = ω(τ ) i,j , we will refer to w as the weight function realizing the Markov-type i,j objective function oracle O. Here, of course, the full list of all weights w(e) is part of the input of our problem. Note that the number of entries in this list is bounded from above by (t − 1)n4 even in the totally tomographic case. Hence there are at most polynomially many rational numbers to be presented. With this specification we refer to our respective problems as TomTrac(S1, . . . , Sm) and Trac(d). Note that the weights w(e) can be used to model additional 'local' physical knowledge such as infor- mation about the potential ranges of velocities or directions of the particles. Now, we introduce two sets of 0-1-variables associated with the grid points and the tracking edges, respectively. More precisely, for τ ∈ [t] and i ∈ I (τ ), the variable ξ(τ ) i while the variable η(τ ) corresponds to g(τ ) i,j is associated with e(τ ) i,j . i i i will be used to describe the tomographic constraints; ξ(τ ) i = 1 signifies is actually present in the computed solution F (τ ). The tracking variable η(τ ) i,j . For a compact G(τ ))T , write A(τ ) for the corresponding coefficient matrix, and The tomographic variables ξ(τ ) that the grid point g(τ ) has value 1 if, and only if, the particle that, at time τ is located at g(τ ) notation, we set x(τ ) = (ξ(τ ) encode the X-ray information in the 'right-hand side vector' b(τ ). With this notation we can in principle solve the problem as an Ilp. Algorithm 1 (Tomographic Tracking-Ilp). Solve the following integer linear program: , moves to g(τ +1) 1 , . . . , ξ(τ ) j i s. t. τ∈[t−1] i∈I (τ ) j∈I (τ +1) A(τ )x(τ ) = b(τ ), min (cid:88) i − (cid:88) − (cid:88) j∈I (τ +1) ξ(τ ) ξ(τ +1) j i∈I (τ ) (cid:88) (cid:88) ω(τ ) i,j η(τ ) i,j η(τ ) i,j = 0, η(τ ) i,j = 0, ∈ {0, 1}, η(τ ) i,j x(τ ) ∈ {0, 1}G(τ ), (τ ∈ [t]), (i ∈ I (τ ), τ ∈ [t − 1]), (j ∈ I (τ +1), τ ∈ [t − 1]), (i ∈ I (τ ), j ∈ I (τ +1), τ ∈ [t − 1]), (τ ∈ [t]). (3.1) Note that the coefficient matrices A(τ ) are totally unimodular (see, e.g., [2, 31]) and the first set of equality constraints contains only the tomographic variables. The second and third set of equalities in (3.1) couple the tomographic and the tracking variables. As the tomographic variables are 0-1 they guarantee two properties: (1) A tracking edge can only connect grid points that are present in the tomographic solution. The second set of constraints corresponds to the edges 'leaving' time τ while the third set corresponds to those 'entering' time τ + 1. (2) From each point g(τ ) in a considered solution, i.e., when ξ(τ ) = 1, there must be exactly one 'entering' tracking edge. Note that by adding the two constraints i = 1, exactly one 'leaving' tracking edge is selected. Similarly, when ξ(τ +1) i i ξ(τ +1) i η(τ +1) j,l = 0 and − ξ(τ +1) i + η(τ ) j,i = 0, − (cid:88) j∈I (τ +1) (cid:88) j∈I (τ ) 8 DYNAMIC DISCRETE TOMOGRAPHY for i ∈ I (τ ) and τ ∈ {2, . . . , t − 1}, we derive the set of constraints (cid:88) j,i − (cid:88) η(τ ) j∈I (τ ) j∈I (τ +1) η(τ +1) i,j = 0, (3.2) i which express that, if a particle enters g(τ ) it must exit it again, and vice versa. Hence, the equa- tions (3.2) can be viewed as path or flow constraints, and the corresponding coefficient matrix is again totally unimodular. When we replace appropriate conditions in (3.1) by these flow constraints, we ob- tain an equivalent but different Ilp-formulation which decomposes into two totally unimodular parts and a reduced set of coupling constraints which, however, still destroy the total unimodularity of the whole system. As it will turn out in the next subsection, this is not merely a nuisance but a severe obstacle for efficient algorithms. We prefer the formulation (3.1) because it reveals the uncoupled structure in the positionally determined case and leads to the following result for Trac(d). (Recall that now O is a Markov-type objective function oracle which is realized by a rational weight function w.) Theorem 1. Trac(d) decomposes into uncoupled minimum weight perfect bipartite matching problems and can hence be solved in polynomial time. Proof. Under the assumptions of this theorem, (3.1) reads (cid:88) (cid:88) (cid:88) τ∈[t−1] i∈I (τ ) j∈I (τ +1) ω(τ ) i,j η(τ ) i,j min s. t. (cid:88) (cid:88) j∈I (τ +1) i∈I (τ ) η(τ ) i,j = 1, η(τ ) i,j = 1, η(τ ) i,j ∈ {0, 1}, (i ∈ I (τ ), τ ∈ [t − 1]), (j ∈ I (τ +1), τ ∈ [t − 1]), (i ∈ I (τ ), j ∈ I (τ +1), τ ∈ [t − 1]). (3.3) Note that, here, in the positionally determined case, we have I (τ ) = G(τ ) = F (τ ) = n. Hence we need to solve the t − 1 independent minimum weight perfect bipartite matching tasks (cid:88) i,j∈[n] ω(τ ) i,j η(τ ) i,j min s. t. (cid:88) (cid:88) j∈[n] i∈[n] η(τ ) i,j = 1, η(τ ) i,j = 1, i,j ≥ 0, η(τ ) (i ∈ [n]), (j ∈ [n]), (i, j ∈ [n]). (3.4) i,j ∈ {0, 1} has been replaced by the non-negativity constraints η(τ ) i,j ≥ 0. Since, In (3.4) the condition η(τ ) i,j ≤ 1, we have just switched to the Lp-relaxation. The feasible points by the other constraints, η(τ ) of this Lp-relaxation form a polytope with integral vertices [12] (see also [31]), hence each of these (cid:3) problems can be solved in polynomial time; see, e.g., [47, Sect. 16 and 19]. Let us close this section by turning again to the ILP (3.1). Clearly, the ILP contains O(tn2) constraints and O(tn4) binary variables, which, in the positionally determined case, reduces to O(tn) constraints and O(tn2) binary variables. As the computation time depends strongly on the structure of the problem instance, it is not clear which computation times will occur for a given practical instance. For the positionally determined case, however, the computational study in [48] shows that random instances with n up to 20, 000 and t = 2 can be solved with state-of-the-art algorithms in reasonable time. Note, however, that without resorting to sparsity and advanced optimization techniques it seems hopeless to solve instances in the tomographic case with n = t = 30 as the coefficient matrix can 9 involve 54, 000 × 23, 517, 000 entries (amounting to more than 1 Terabyte of storage space). Of course, it is always possible to resort to LP relaxations of (3.1), see [24]. In general, however, the returned solutions will then not be binary. DYNAMIC DISCRETE TOMOGRAPHY 3.2. On the complexity of the partially tomographic case. We consider the question of when, for m = 2, the tomographic case can be solved efficiently. The following result shows the limitations already for the following quite restricted partially tomographic case. There is only one time step, i.e., t = 2, and F (1) is known while the set F (2) of particle positions for τ = 2 is only accessible through its two X-rays XS1F (2) and XS2 F (2). Theorem 2. Even if all instances are restricted to the case t = 2, where the solution F (1) is given explicitly, TomTrac(S1, S2) is NP-hard. Also the corresponding uniqueness problem is NP-complete and the counting problem is #P-complete. Proof. We use a reduction from the following problem, where S1, S2, S3 are three different lattice lines. ConsistencyF d (S1, S2, S3). Instance: Data functions f1, f2, f3. Question: Does there exist a set F ∈ F d such that XSiF = fi for all i ∈ [3]? This problem and its uniqueness and counting versions have been shown in [29] to be NP-complete or #P-complete, respectively. In fact, the proof of [29] reveals, that ConsistencyF d (S1, S2, S3) remains NP-complete even if all instances are restricted to those, where, for two directions, say S2, S3, the nonzero X-rays are all 1 and for each of these X-ray lines the grid G contains exactly two candidate points. So, let (f1, f2, f3) be the data functions of such an instance, and let n = (cid:107)f1(cid:107)(1) = (cid:107)f2(cid:107)(1) = (cid:107)f3(cid:107)(1). Let F (1) consist of n points p1, . . . , pn on a line parallel to S1. Hence the support of XS1F (1) is a single line, and the corresponding value is n, while the support of XS2F (1) consists of n lines, and the corresponding values are 1. Note that F (1) is uniquely determined by its X-rays XS1 F (1) and XS2F (1). Now, we consider the given (restricted) instance (f1, f2, f3) of ConsistencyF d (S1, S2, S3) as 'living' at time τ = 2, regard the first two data functions as the input (f (2) 2 ) at τ = 2 of our dynamic 2- direction X-ray problem, and introduce an objective function that allows to model the X-ray information in the third direction via a minimum weight bipartite matching of cardinality n. So, let G(2) be the grid coming from the data function f (2) 2 = f2. Further, let T1, . . . , Tn be the lines parallel to S3 that meet the candidate grid G of (f1, f2, f3), and let gi,j, i = 1, 2, denote the corresponding two grid points on Tj, j ∈ [n]. Finally, for j ∈ [n] and g ∈ G(2), we define the objective function vector w = (ωpj ,g) by setting 1 = f1 and f (2) 1 , f (2) (cid:40) ωpj ,g = 0 for g ∈ {g1,j, g2,j}; 1 otherwise. Now consider a minimum weight bipartite matching of cardinality n on the complete bipartite graph with the partition (F (1), G(2)) of the vertex set F (1) ∪ G(2) and edge costs ωpj ,g for any edge {pj, g} ∈ F (1) × G(2). In this matching let F (2) denote the endpoints of the tracking edges that are not in F (1). Then, of course, each point pj ∈ F (1) is assigned to exactly one point of G(2). If the objective function value of the given matching is 0 then pj must be assigned to g1,j or g2,j for each j ∈ [n]. Hence XS3F (2) = f3. On the other hand, if F (2) satisfies XSiF (2) = fi, for i ∈ [3], then, in particular, for each j ∈ [n], the set F (2) contains exactly one of the points g1,j or g2,j. Hence there is a matching of cardinality n with objective function value 0. 10 DYNAMIC DISCRETE TOMOGRAPHY Thus, the given instance (f1, f2, f3) is feasible if, and only if, there exist a set F (2) satisfying the X-ray constraints with respect to S1 and S2 that allows a perfect matching between F (1) and F (2) of weight 0. (cid:3) Of course, the transformation runs in polynomial-time and is parsimonious. The following corollary is merely a reformulation of Theorem 2 highlighting its interpretation in terms of matchings. Corollary 1. Min weight max cardinality bipartite Matching under totally unimodular con- straints for one set of the bipartition is NP-hard. Also the corresponding uniqueness problem is NP- complete while the counting problem is #P-complete. It is clear that Theorem 2 can also be interpreted as a non-approximability result. In fact, since, in the case of feasibility, the optimal objective function value is 0, the NP-hardness of the problem trivially means that, unless P = NP, there is no polynomial-time approximation algorithm of relative accuracy at most α for any factor α. Note, however, that the definition of the objective function in the proof of Theorem 2 can be altered in order to guarantee that the objective function is bounded away from 0. Simply set ωpj ,g = 1 for j ∈ [n] and g ∈ {g1,j, g2,j}, and let all other values be sufficiently large. This fact can be used to interpret the previous result in the context of approximation complexity even if we assume that the optimum is bounded away from 0 from below. Corollary 2. Unless P = NP, there is no polynomial-time algorithm that solves the following problem up to any polynomial-space multiplicative constant in polynomial-time. Given F (1), f (2) 2 , let G(2) 2 , and let w ≥ 1 encode the edge weights of the complete bipartite be the grid associated with f (2) graph with bipartition (F (1), G(2)). Find a cardinality F (1) matching of F (1) and a set F (2) ⊆ G(2) with XS1F (2) = f (2) 2 , that is minimal with respect to w for all such sets F (2). 1 , f (2) 1 , f (2) 1 , XS2 F (2) = f (2) In view of the comments after Corollary 1, this result may seem somewhat artificial. It does, however, allow for non approximability results that are rather close to the observed practical difficulty. In fact, the objective function in the proof of Theorem 2, and hence for obtaining the result of Corollary 2, can be adapted so as to accommodate different experimental settings. This can be combined with different choices of F (1). For instance, if we choose the points pj ∈ F (1) in such a way that they have equal Euclidean distance to g1,j and g2,j but different distance to all other grid points, then the objective function can be interpreted as rewarding conformity with certain known velocities of the particles. Hence the hardness proof does to a certain extent reflect practical difficulties in tracking the particles. We remark that, in contrast to Corollary 2, there are several approximability results for the positionally determined case and specific types of cost functions, see, e.g., [10, 22, 25, 39]. 3.3. On the complexity of the tomographic case when the displacement field is known. Let us now turn to the other extreme, assuming that the F (1), . . . , F (t) are unknown, but the particle displacement field is given for all τ ∈ [t]. Note that this is quite different from the setting considered in the proof of Theorem 2. In fact, in the proof of Theorem 2 we make explicit use of the fact that there are two possible next positions for each particle, which renders the problem NP-hard. If, on the other hand, F (1) and the displacement field are known, then F (2), . . . , F (t) and the particle tracks can be determined in polynomial time. In general, however, we will show that the reconstruction problem with a given displacement field is again NP-hard. Particle displacement fields are often (approximatively) known in experimentally controlled environ- ments (for instance, when charged particles in a particle accelerator or plasma fusion device move in the presence of experimentally controlled electromagnetic fields; see, e.g., [13, 53]). The particle tracking task reduces in this case to that of reconstructing the particle positions from the measurements. Of course, the general aim is to reduce ambiguities by taking several time steps into account. For instance, in [24] this problem is considered for t = 2 in the context of compressed motion sensing. Our next theorem shows, however, that, unless P = NP, there is generally no algorithm that can make efficient use of the additional data. In order to state the theorem we introduce the following notion. Given S1, S2 ∈ S d, we call a dis- placement field (p, ϕ(p) − p), p ∈ Qd, proper (for S1 and S2) if ϕ is an affine transformation with DYNAMIC DISCRETE TOMOGRAPHY 11 ϕ(Qd) ⊆ Qd and ϕ(Si) − ϕ(0) (cid:54)∈ {S1, S2}, i = 1, 2. Note that, in particular, this notion of proper- √ ness encompasses several different types of circular displacements; for instance, ϕ might represent a 45◦-rotation in the (S1, S2)-plane that is followed by a factor 2/ Theorem 3. Let ϕ denote the affine transformation (encoded by a rational matrix and a rational translation vector) of a proper displacement field. Then, the problem TomDisplaceTrac(O; S1, S2) is NP-hard, even if all instances are restricted to the case t = 2. Also the corresponding uniqueness problem is NP-hard and the counting problem is #P-hard. 2 dilation. Proof. We construct a parsimonious transformation from ConsistencyF d (S1, S2, S3, S4) for certain lattice lines S1, S2, S3, S4. This problem is the analogue to ConsistencyF d(S1, S2, S3) and involves four given data functions f1, f2, f3, f4. The task is to decide whether there exist a set F ∈ F d such that XSiF = fi for all i ∈ [4]. Again, this problem and its uniqueness and counting versions have been shown in [29] to be NP-complete or #P-complete, respectively for any four different different lattice lines S1, S2, S3, S4. Now, let S1, S2 ∈ S d with S1 (cid:54)= S2,, and set S3 = ϕ(S1)− ϕ(0) and S4 = ϕ(S2)− ϕ(0). Since the given displacement field is proper, S1, S2, S3, S4 are four different lattice lines. Hence, the hardness results of [29] do apply to ConsistencyF d (S1, S2, S3, S4). So, suppose, we are given an instance of this problem by means of the X-ray functions (f1, f2, f3, f4), and let G be the corresponding candidate grid. By associating a binary variable with each point g1, . . . , gG of G we can formulate the task as deciding feasibility of the ILP Ax = b A(cid:48)x = b(cid:48) x ∈ {0, 1}G, where A and A(cid:48) encode the point-line incidences along {S1, S2} and {S3, S4}, respectively, while b and b(cid:48) encode the data functions f1, f2, and f3, f4, respectively. Setting A(1) = A, A(2) = A(cid:48), b(1) = b, b(2) = b(cid:48), this problem is, of course, equivalent to the ILP A(1)x(1) = b(1), A(2)x(2) = b(2), x(1) − x(2) = 0, x(1) ∈ {0, 1}G, x(2) ∈ {0, 1}G. (3.5) , i ∈ [G], the point ϕ−1(gi) ∈ Qd. This does not Now, suppose we associate with each variable ξ(2) change the ILP, but only its geometric interpretation. The problem A(2)x(2) = b(2) can now be viewed as to involve only X-rays taken from the directions i ϕ−1(Si+2) − ϕ−1(0) = ϕ−1(ϕ(Si) − ϕ(0)) − ϕ−1(0) = Si, (i ∈ [2]). Consider now the ILP (3.1) for t = 2 and the following settings. Let G(1) denote the grid defined by the data functions f1, f2 (along S1, S2), and let G(2) = ϕ−1(G(cid:48)) where G(cid:48) denotes the grid defined by for i ∈ I (τ ) = the data functions f3, f4 (along S3, S4). Let the points of each grid G(τ ) be labeled g(τ ) [G(τ )], τ ∈ [t], and set i (cid:26) 0 1 ω(1) i,j = ) = g(1) i ∈ G, for ϕ(g(2) otherwise, j for every (i, j) ∈ I (1) × I (2). An optimal solution to this ILP (3.1) has the objective function value 0 if, and only if, the ILP (3.5) is feasible. As the transformation runs in polynomial-time and is parsimonious, we have thus completed (cid:3) the proof of this theorem. While Theorem 3 shows the general intractability, there are specific types of displacements for which the corresponding problem TomTrac(S1, S2) turns out to be in P. This is trivially the case if the 12 DYNAMIC DISCRETE TOMOGRAPHY particle displacement is known to be zero. Examples, some non trivial, will be given in Theorem 9 and 10. 3.4. A rolling horizon model. Even though Theorem 2 was not available then, in retrospective the rolling horizon approach of [8] for dynamic discrete tomography can be viewed as an attempt to 'bypass' the NP-hardness result of Theorem 2. In fact, the core of [8]'s polynomial-time algorithm is based on a different modeling for the case t = 2. Unlike (3.1), the quality of the tracking is not encoded in terms of weights on the tracking edges, but rather through weights on the grid points. Before we analyze the price that has to be paid for such a simplification let us recall the relevant details of the rolling horizon algorithm of [8] as a service to the reader. The time step from τ to τ + 1 is modeled as a linear program. It is based on the knowledge of a solution F (τ ), hence in effect dealing with the partially tomographic case. The constraints encode the X-rays provided by the data functions f (τ +1) . The variables correspond to the points in the grid G(τ +1) and are again collected in a vector x(τ +1). The X-ray information is encoded by means of a totally unimodular matrix A(τ +1) and a right-hand side vector b(τ +1). Further, each point g(τ +1) which reflects the 'distance' to a closest ∈ F (τ ) (which is a likely 'predecessor'). Let a(τ +1) be the corresponding weight vector. point g(τ ) Various weight functions are discussed in [8]. For instance, if the particles move slowly, a reasonable choice for a(τ ) is (a finite precision approximation of) ∈ G(τ +1) carries a weight α(τ +1) , f (τ +1) 1 2 i i i (cid:8)(cid:107)g(τ +1) i j (cid:107)(cid:9), − g(τ ) α(τ ) i = min j:ξ(τ ) j =1 where again (cid:107)·(cid:107) denotes some suitable norm. Clearly, this choice of weights prefers positions of particles close to those from the previous time step. The algorithm Rolling Horizon Tomography is now as follows: Algorithm 2 (Rolling Horizon Tomography). Given F (1) perform successively for τ = 1, . . . , t−1 min(cid:0)a(τ +1)(cid:1)T x(τ +1) s. t. A(τ +1)x(τ +1) = b(τ +1), x(τ +1) ≤ 11, x(τ +1) ≥ 0, (3.6) to determine F (τ +1) (corresponding to the incidence vector 0-1 of a basic feasible solution of the linear program). Finally the paths P1, . . . ,Pn are obtained by a routine that computes a perfect bipartite matching in the graph with vertices F (τ )∪ F (τ +1) and edges corresponding to the pairs of vertices which realize the distances α(τ ) . i The rationale behind the rolling horizon model seems quite similar to that analyzed in Theorem 2. The two models are, however, fundamentally different. This is obvious from the fact that the former can be handled in polynomial time while the latter leads to an NP-hard problem. So, why are we not fully satisfied with Rolling Horizon Tomography? After all, it is exact in the sense that it is guaranteed to yield a solution which matches the data. It also allows to incorporate physical knowledge and is reported to work quite well in practice (see [8, 56]). There is, however, a price to pay. In fact, as the following example shows, this algorithm is only a heuristic. In general, one cannot expect to obtain the most realistic paths that way. The reason is that the weights used to measure the quality of an assignment do not incorporate the requirement that no two particles can have originated from the same location at the previous moment in time. Of course, Theorem 2 shows that, unless P = NP, there will never be a full remedy, i.e., there does not exist a polynomial-time algorithm that is also exact in that second sense even in this restricted case. DYNAMIC DISCRETE TOMOGRAPHY 13 Example 1. Figure 1 shows an example of n = 3 points at time τ = 1 in the plane (black dots) and the grid obtained from the X-ray measurements in the coordinate directions at time τ = 2. The weight of each of the nine grid points is given by its Euclidean distance to the closest black point. (a) (b) Figure 1. The black dots indicate the solution at time τ = 1. The white dots in (a) give a solution at time τ = 2 found by Rolling Horizon Tomography, i.e., with the LP (3.6), while the white dots in (b) show the solution at time τ = 2 that is closest to that at time τ = 1 (the arrows indicate the displacement, each within a radius equal to that of the dotted circle). The white dots on the left give a solution F (2) obtained by the rolling horizon Lp (3.6) for these weights. The best (and quite different) assignment is depicted on the right. The reason for the failure of the algorithm is that the weights assigned to the four grid points g1, g2, g3, g4 in the left lower corner all stem from just one black point. Since the top black point has minimal distance to four grid points (three of which are different from the gi), any minimal solution of (3.6) does contain two of the grid points g1, g2, g3, g4. Obviously, the particle paths indicated in the right-hand side figure are shorter. 3.5. Models involving particle history. The models in the previous subsections are memory-less in the sense that the estimation of where a particle p ∈ P should move in the time step from τ to τ + 1 depend only on its position at time τ but not on other, earlier positions. In view of the tractability and intractability results of Theorem 1 and Theorem 2, respectively, let us first consider the coupling in the positionally determined case for t ≥ 3. Of course, if we are interested in particle tracks P1, . . . ,Pn whose total length (cid:88) (cid:88) (cid:88) c(P1, . . . ,Pn) = w(e) i∈[n] τ∈[t] e∈Pi is minimal, we can find one in polynomial time by Theorem 1. The following example shows, however, that such an optimal assignment of positions to particles for every moment in time does not necessarily guarantee 'overall reasonable' particle tracks even if there are only two time steps involved. Example 2. Figure 2 shows for the positionally determined case two particles (black dots) at times τ = 1, 2, 3 (dashed lines). Figure 2 (a) is obtained by assigning each of the two points at time τ to their nearest neighbor at time τ + 1, for τ = 1, 2. This is optimal if we are aiming at paths of shortest total length but leads to a kink at τ = 2. Figure 2 (b) depicts slightly longer paths, which, on the other hand, correspond to movements along straight lines. It is not clear upfront which of the two particle tracks might be more realistic. This assessment will certainly depend on prior knowledge. The case at the left might be more realistic if there is, say, a magnetic force affecting the particles at τ = 2, which pushes them apart. If there is no indication of an external force, then the paths on the right appear to be more appropriate. It seems quite natural to aim at incorporating general prior knowledge about 'reasonable' paths in the following way. First an expert would compile a list of most appropriate paths or give at least parametric descriptions of reasonable trajectories; then an algorithm should compute solutions whose paths do not deviate too much from a closest one from the list. It turns out that there are serious limitations to this approach. 14 DYNAMIC DISCRETE TOMOGRAPHY (a) (b) Figure 2. The black dots indicate the solutions F (τ ) at times τ = 1, 2, 3. Depicted are: (a) particle paths with the shortest total length, and (b) straight line particle paths. Theorem 4. The problem Trac(O; d) is NP-hard, even if all instances are restricted to a fixed t > 2, and O is a path value oracle. The NP-hardness persists if the objective function values provided by O are all encoded explicitly. Proof. It suffices to prove the result for t = 3. We use a transformation from the NP-complete problem 3D-Matching. Instance: n ∈ N, finite disjoint sets X, Y , Z, and W ⊆ X × Y × Z. Question: Does there exist a set M ⊆ W with M ≥ n such that the following holds: Let pi = (xi, yi, zi) ∈ M, i = 1, 2, p1 (cid:54)= p2, then x1 (cid:54)= x2, y1 (cid:54)= y2, and z1 (cid:54)= z2? In fact, 3D-Matching was already contained in Karp's original list [37] of NP-complete problems and was shown there to be NP-complete even for restricted instances where n = X = Y = Z. Further note that the NP-completeness persists if we assume in addition that X, Y, Z ⊆ Zd for some fixed d ∈ N. Further details on the computational complexity and connections to assignment problems can be found in [30] and [17], respectively. For additional results on variants of 3D-Matching with different cost functions see [10, 22, 23, 39, 52]; for a polynomial-time solvable variant, where the cost function has the so-called Monge property, see [11] (for applications, see [19]). Now, suppose we are given such a (restricted) instance (n; X, Y, Z; W ) of 3D-Matching. We set F (1) = X, F (2) = Y, F (3) = Z. The matching condition means that we need to select n disjoint paths P1, . . . ,Pn. The set W will now be encoded in a corresponding instance of Trac(O; d) by means of an objective function c defined on the set of all paths. For every path P = (g(1), g(2), g(3)), where g(τ ) ∈ F (τ ) for τ ∈ [3], we define (cid:40) w(P) = The cost c(P1, . . . ,Pn) of any n paths P1, . . . ,Pn is given by c(P1, . . . ,Pn) =(cid:80)n 0 if (g(1), g(2), g(3)) ∈ W , 1 otherwise. i=1 w(Pi). Then, there exists a matching of cardinality n in W if, and only if, there exists a solution to the Trac(O; d) instance with cost 0. Of course, the transformation runs in polynomial time. The second statement follows from the fact that there are only O(nt) different paths whose costs 0 or 1 (cid:3) need to be encoded. Let us point out that Theorem 4 applies to the situation that an expert has provided an explicit list of all paths that are regarded physically reasonable, and the task is simply to determine whether there exists a solution (P1, . . . ,Pn) that consists entirely of paths from that list. Again we can adapt the objective function in the proof of Theorem 4 to show that it is also an NP-hard task to find particle tracks that are within a certain specified distance from tracks of such a list. DYNAMIC DISCRETE TOMOGRAPHY 15 The following theorem makes use of a result of [49] on a variant of 3D-Matching. Theorem 5. For d = 2 and t = 3 the NP-hardness of Theorem 4 persists if the weight of P = (g(1), g(2), g(3)) is given by Even checking whether a solution of weight 0 exists is NP-complete. w(P) = det(g(2) − g(1), g(3) − g(1)). 1 2 (3.7) Proof. The assertion follows from the result of [49] that states that the problem A3ap is NP-hard (and its respective decision version is NP-complete). Here disjoint sets X, Y, Z ∈ Z2 of cardinality n are given, and the goal is to find n disjoint subsets {x, y, z} with x ∈ X, y ∈ Y , z ∈ Z of minimal weight. For A3ap the weight is defined as the sum of the areas of the triangles. Now, recall that the area of the triangle conv {x, y, z} is given by 1 (cid:3) Corollary 3. For every fixed d ≥ 2 and t ≥ 3 it is an NP-complete problem to decide whether a solution of Trac(O; d) exists where all particles move along straight lines. 2 det(y − x, z − x). Proof. The result for d = 2 and t = 3 was given in Theorem 5. As every planar instance can be viewed as an instance in Qd, d ≥ 2, the NP-hardness carries immediately over to any d ≥ 2. Further, as any instance for t = 3 can be viewed as a special case of an instance for t ≥ 3 where the particles do not move after τ = 3, the NP-hardness persists for any t ≥ 3. (cid:3) Clearly, for non-negative weights w(Pk) we have n(cid:88) k=1 w(Pk) = 0 ⇔ w(Pk) = 0. max k∈[n] Hence, Theorem 5 implies the following result (see also [25]). Corollary 4. Already for d = 2 and t = 3 it is NP-hard to find a solution of Trac(O; d), which minimizes the objective function c(P1, . . . ,Pn) = max i∈[n] w(Pk). Comparing the results from Theorem 5 with that from Theorem 1 it seems interesting to note that the former problem is NP-hard while its Markov-type counterpart is polynomial-time solvable. Results similar to Theorem 5 for other types of weights can be found in [23, 49]. In view of the discouraging results above one cannot expect to be able to incorporate too much of the individual particles' history or information about reasonable trajectories without sacrificing efficiency. In fact, unless P = NP, any algorithm for that task must either fail to produce an optimal solution (at least under specific circumstances) or must have a super-polynomial running time. In other words, any such algorithm bears, for a given practical instance, the risk of not returning a solution within an acceptable time. With this warning we introduce new polynomial-time heuristics, which favor paths that are regarded 'reasonable.' The algorithms can be seen as examples of more general paradigms. In order to keep the exposition simple we describe only basic prototypes. Let us point out first that, of course, the rolling horizon Algorithm 2 can be modified in such a way that it allows to utilizes even 'intuitive' knowledge of how the current particles tracks determined up to the moment τ in time should possibly be extended to τ + 1. All that is needed is to quantify this knowledge and use it to define the weights for the next time step. If the previous knowledge is restricted to a fixed number k of the last past moments we arrive at a k-Rolling Horizon algorithm. This may be a promising method if the correct sets F (1), . . . , F (k) are known. If this is not the case, k-Rolling Horizon may run into problems. In fact, for the tomographic construction of the first set F (1) no other than the X-ray information is available. The determination of F (2) is then also based on F (1) etc. But this means that the choices in the previous steps cannot be revised later anymore. Hence there may be other sets, tomographically equivalent to the choice of F (1) 16 DYNAMIC DISCRETE TOMOGRAPHY made by the algorithm, which allow much more realistic paths. If, at some moment τ the deviation from realistic shapes is noticed, k-Rolling Horizon does, however, not provide any remedy. We will therefore pursue now an approach that is capable of using background knowledge in a more global and balanced way. We begin by introducing a mathematical setting for regarding a particle path P = (g(1), . . . , g(t)) of I = (G(1), . . . , G(t)) as reasonable. Let, again, (cid:107) · (cid:107) be a norm in Rd, let h : [0,∞[→ [0,∞[ be strictly monotone such that h((cid:107)x(cid:107)) ∈ Q for every x ∈ Qd and such that size (h((cid:107)x(cid:107))) is bounded by a polynomial in size (x). Examples for pairs ((cid:107) · (cid:107), h) include ((cid:107) · (cid:107)(∞), id) and ((cid:107) · (cid:107)(p), (· )p) for p ∈ N. For k ∈ N, any k-tuple C = (g(τ1), . . . , g(τk)) with 1 ≤ τ1 < τ2 < . . . < τk ≤ t and g(τi) ∈ G(τi), for i ∈ [k], is called a k-sample of I. Let C(I) denote the set of all k-samples of I. Further, if Q is a set of grid points, we write C(I; Q) for the subset of those C that contain all elements of Q. Also, if the τi ∈ [t] are fixed we speak of a k-sample for (τ1, τ2, . . . , τk). Let C(I; Q; τ1, . . . , τk) denote the set of all k-samples of C ∈ C(I; Q) for (τ1, . . . , τk). Now, let k ∈ N and let Rk(I) be a family of curves r : [0, t] → Qd with the following properties: For any k-sample C = (g(τ1), . . . , g(τk)) of I there is a unique rC ∈ Rk(I) such that rC(τi) = g(τi) for i ∈ [k]. Further, rC(τ ) and h((cid:107)rC(τ ) − g(τ )(cid:107)) can be computed in polynomial time for τ ∈ [t] \ {τ1, . . . , τk}. The function r will be called sample fit. As an example, we may choose R2(I) to consist of all lines through two grid points at two different moments in time. Such a choice would favor straight line movements of particles. Generalizing this, we may consider Rk(I) to consist of all polynomial curves ϕ of degree k − 1 or less, i.e., ϕ : Q → Qd, τ (cid:55)→ a0 + a1τ + ··· + ak−1τ k−1, with a1, . . . , ak−1 ∈ Qd. Quadratic curves, for instance, are often used to describe trajectories of objects that move under the action of gravity; see, e.g., [20, 55]. The sample fits will be regarded as representing the a priori knowledge about the shapes and other properties of the particle paths. This knowledge can be incorporated in various ways. Let us begin with the positionally determined case, i.e., we assume G(τ ) = F (τ ) for τ ∈ [t]. So, suppose, that for some fixed k ∈ N sample fits Rk(I) are (implicitly) available as specified above. Then the following algorithm prefers particle tracks that are close to curves of Rk(I). Algorithm 3 (Path Fitting). Let I = (F (1), . . . , F (t)) be given. Choose τ1, . . . , τk with 1 ≤ τ1 < τ2 < . . . < τk ≤ t. Then, for every i ∈ I (τ1) and j ∈ I (τk), set Qi,j = {g(τ1) } and compute , g(τk) h((cid:107)rC(τ ) − g(τ )(cid:107)). j i (3.8) γi,j = min C∈C(I;Qi,j ;τ1,...,τk) max τ∈[t] min g(τ )∈G(τ ) i , g(τk) Next compute a minimum weight perfect bipartite matching M for G(τ1), G(τk) with weights γi,j for ), i ∈ I (τ1), j ∈ I (τk), and with ri,j denoting a corresponding sample fit for which the edges (g(τ1) ) ∈ M, the points the minimum in (3.8) is attained. Finally, assign to the n curves ri,j, (g(τ1) of F (τ ) for τ ∈ [t] \ {τ1, . . . , τk} according to the (lexicographical) nearest neighbor rule with respect to their reference points ri,j(τ ). , g(τk) j j i As described, there is still ample freedom for specifying or varying Algorithm 3. We can, for instance, replace the weights (3.8) in various ways. For instance, another natural choice is (cid:88) (cid:16) h((cid:107)rC(τ ) − g(τ )(cid:107)(cid:17)2 . γi,j = min C∈C(I;Qi,j ;τ1,...,τk) τ∈[t]\{τ1,...,τk} min g(τ )∈G(τ ) Another option is to average over a prescribed number of near best sample fits. Further, the exact condition rC(τi) = g(τi) for i ∈ [k] can be replaced by an approximate sample fit. Hence Path Fitting can be considered as a class of algorithms, and the various specifications need to be comprehensively evaluated on real-world data. In any case, the framework is algorithmically efficient. DYNAMIC DISCRETE TOMOGRAPHY 17 Theorem 6. Path Fitting runs in polynomial time. Proof. Simply observe that we need n2 · nk−2 · (t − k) · n = O(nk+1t), i.e., polynomially many, compu- tations to determine all γi,j, i, j ∈ [n]. Further, all other computations can be performed in polynomial (cid:3) time. Note that for k = 2 and lines as sample fits, when applied to Example 2, Path Fitting produces the solution shown in Figure 2(b). In general, however, it follows from Theorem 5 that, unless P = NP, Path Fitting will not always return optimal solutions even with lines as sample fits. In fact, the existence of lines as sample fits corresponds to the weights (3.7) in Theorem 5. It is possible to use the above framework also in the fully tomographic case, particularly, to reduce the ambiguity in the determination of the tomographic solutions F (τ ) for τ ∈ [t]. Algorithm 4 (Tomographic Fitting). Let, for τ ∈ [t], data functions (f (τ ) denoting the corresponding grid. Further, let I = (G(1), . . . , G(t)). For τ ∈ [t], g(τ ) ) be given with G(τ ) , f (τ ) 1 2 i } set i = {g(τ ) i ∈ G(τ ) and Q(τ ) min ) = α(g(τ ) i C∈C(I;Q(τ ) ) i max τ(cid:48)∈[t] min g(τ(cid:48) )∈G(τ(cid:48) ) h((cid:107)rC(τ(cid:48)) − g(τ(cid:48))(cid:107)). (3.9) Now, with a(τ ) being the vector with components α(g(τ ) uncoupled linear programs ) and A(τ ), x(τ ), and b(τ ) as before, solve the t i min(cid:0)a(τ )(cid:1)T x(τ ) s. t. A(τ )x(τ ) = b(τ ) x(τ ) ≤ 11 x(τ ) ≥ 0 (3.10) to determine sets F (τ ) which are consistent with the X-ray information. Finally the paths P1, . . . ,Pn are obtained by t − 1 calls to a routine for minimum weight perfect bipartite matching with weights ω(τ ) i,j = α(g(τ ) ) + α(g(τ +1) ). j i There are, again, various other reasonable ways to define the weights α and w. Of course, the final matching part in Tomographic Fitting can be replaced by Path Fitting. This leads to the algorithm Tomographic Path Fitting, which uses the former to produce F (1), . . . , F (t) and subsequently the latter to identify the paths. Clearly, they both run in polynomial time. Theorem 7. Tomographic Fitting and Tomographic Path Fitting run in polynomial time. Let us now turn to another algorithmic paradigm. It can be viewed as a rolling horizon method augmented by some 'clamping' strategy for improvement. For the sake of simplicity, the method will in the following be specified for the case t = 3 and k = 2 where straight line tracks are desired. Algorithm 5 (Two-way Fitting). Construct a set F (1) and apply Algorithm 2 with a chosen objective function to compute F (2) I (1) × I (2) such that g(1) Then, by using velocity information, if available, compute a subset Bi,j of the affine hull Li,j = aff {g(1) (on which, if the line would represent the real particle path, the next point would be expected). If no velocity information is available, take Bi,j = Li,j. Note that Li,j is a line unless g(1) Then, compute for each point g(3) ∈ G(3) its weight 1 which satisfies the tomography constraints, denote the pairs (i, j) ∈ j } for (i, j) ∈ M 1,2 , g(2) is matched to g(2) i = g(2) . Let M 1,2 . 1 1 1 . j j i i w(g(3)) = min (i,j)∈M 1,2 1 min x∈Bi,j (cid:107)g(3) − x(cid:107)2 (2), and apply again Algorithm 2, yielding F (3) 1 and a set M 2,3 1 ⊆ I (2) × I (3) of matching index pairs. 18 DYNAMIC DISCRETE TOMOGRAPHY Next, apply Algorithm 4 for k = 2 and R2(I) parametrizing the lines through F (3) for τ = 2 and weights (3.9) a tomographically feasible set F (2) with weights computed as in the first part of the algorithm to obtain a solution F (1) is iterated. The algorithm terminates if in the next round the same triple (F (1) , F (2) and F (1) to obtain and, subsequently, apply Algorithm 2 . Then, the procedure ) of sets is repeated. , F (3) 2 1 1 2 l l l As pointed out before, none of these algorithms can circumvent the NP-hardness of the problem it addresses. Therefore all such methods are either only heuristics and may fail to produce a reasonable solution or they have a super-polynomial running time. This is a worst-case analysis. Nevertheless, the introduced paradigms offer a variety of different approaches that can be tested and compared on any given real-world data set at hand. The application in [56] demonstrates a case where at least one of the approaches performed successfully on a given real-word data set. 4. Combinatorial models The main part of the algorithm Tomographic Fitting was to reduce the ambiguity that is present in our tomographic tasks (particularly for just two directions) by utilizing a priori knowledge within an optimization routine. In the following we will pursue a similar idea, which, however, is based now on combinatorial requirements. We restrict the exposition to the case d = m = 2 with S1, S2 denoting the coordinate directions in R2. Using the same notation as before, the set of solutions of the X-ray problems A(τ )x(τ ) = b(τ ) x(τ ) ∈ {0, 1}G(τ ) (τ ∈ [t]), (τ ∈ [t]), will now be restricted by incorporating prior knowledge about the potential movement of particles as hard combinatorial requirements. More precisely, we assume that for τ ∈ [t] we are given lτ ∈ N0 non-empty windows together with some information about the number of grid points contained in them. For each window, this knowledge is presented by a pair W (τ ) 1 , . . . , W (τ ) lτ ⊆ G(τ ) (∼(τ ) i , k(τ ) i ) ∈ {≤, =,≥} × N0. If there is no risk of confusion we identify each window W (τ ) Then the window constraints are of the form(cid:88) j ∼(τ ) ξ(τ ) i k(τ ) i . j∈W (τ ) i i with the set of indices {j : g(τ ) j ∈ W (τ ) i }. Note that the variables ξ(τ ) raphy under Window Constraints can be formulated as the following Ilps. are the same as before and hence binary. Therefore the tasks of Tomog- j (cid:80) j∈W (τ ) A(τ )x(τ ) ξ(τ ) j x(τ ) i = ∼(τ ) ∈ i b(τ ) k(τ ) i {0, 1}G(τ ) , (τ ∈ [t]), (τ ∈ [t], i ∈ [lτ ]), (τ ∈ [t]). (4.1) While the window constrains allow to model a priori knowledge, the t Ilps (4.1) are uncoupled. As it turns out, even so, the possibilities of making efficient use of such knowledge are rather limited. Theorem 8. Tomography under Window Constraints is NP-hard even if all instances are restricted to t = 1 and if the window constraints are alternatively of one of the following forms: (i) (cid:88) (ii) (cid:88) i j∈W (1) j∈W (1) i ξ(1) j = k(1) i with k(1) i ∈ {0, 2}; j ≤ k(1) ξ(1) i with k(1) i ∈ {0, 2}. DYNAMIC DISCRETE TOMOGRAPHY 19 Proof. In [6] a problem of Double Resolution under Noise, called nDR(4), was introduced. There X- ray constraints for the two coordinate directions in R2 are given, but also equality constraints for all disjoint 2 × 2 windows of the form a + [1]0 × [1]0 with a ∈ (2N0 + 1)2 need to be satisfied, with the i ∈ [4]0. Further, for some of the windows, errors of up to 4 points are permitted, right hand sides k(1) which, of course, makes the corresponding constraints void. In [6] it is shown that nDR(4) is NP-hard. The NP-hardness proof involves, apart from void constraints, only constraints of the form (i). As this restricted nDR(4) problem is a special case of Tomography under Window Constraints with all constraints of the form (i), this proves the first assertion. In [7] a problem of reconstruction under block constraints, called Rec(2, 2, 0), was introduced, where again X-ray constraints for the two coordinate directions in R2 are given. But, differently from nDR(4), only ≤-constraints are present. They are defined for all disjoint 2× 2 windows of the form a + [1]0× [1]0 i ∈ {0, 2}. As this is an NP-hard with a ∈ (2N0 + 1)2, and the corresponding right hand sides are k(1) problem and a special case of Tomography under Window Constraints with all constraints of (cid:3) the form (ii), this implies the second assertion. There are, however, special classes of instances of Tomography under Window Constraints is polynomial-time solvable. We give two examples. In the tracking Our first example deals with disjoint horizontal and vertical windows of width 1. context, such windows W (τ ) can be viewed as to restrict the potential position of the j-th particle at time τ. For each particle the positional uncertainty at time τ is allowed to extend only in either horizontal or vertical direction. These are, of course, rather special assumptions. They can be realistic, for instance, in cases where external forces generate a particle displacement field that contains only vectors orthogonal to one of the detector planes. Theorem 9. Tomography under Window Constraints is polynomial-time solvable if the in- stances are restricted to satisfy the following two properties: j (i) For every τ ∈ [t] and i ∈ [lτ ], i ⊆ Z × {pi,τ} W (τ ) i ⊆ {pi,τ} × Z, (ii) For every τ ∈ [t] and i (cid:54)= j ∈ [lτ ] it holds that W (τ ) or W (τ ) for some pi,τ ∈ G(τ ); j = ∅. i ∩ W (τ ) Proof. Consider a fixed τ ∈ [t], and let again A(τ )x(τ ) = b(τ ), x(τ ) ∈ {0, 1}G(τ ) denote the correspond- ing X-ray system for the directions S1, S2. Further, let H (τ )x(τ ) ∼(τ ) k(τ ) with a binary matrix H (τ ) and right-hand side vector k(τ ) encode the window constraints. It is well known that A(τ ) is the node-edge incidence matrix of a (simple) bipartite graph, (4.2) simply consider the graph with vertex bipartition V = {vi : (i, j) ∈ G(τ )} ∪ {wj : (i, j) ∈ G(τ )} and edge set E = {(vi, wj) : (i, j) ∈ G(τ )}. Consider now a row vector hT = (h1, . . . , hG(τ )) of H (τ ). The support supp(hT ) = {j : hj (cid:54)= 0} of hT corresponds to the set of indices j of the pj ∈ W (τ ) i ⊆ G(τ ) lie, by property (i), on a line parallel to S1 or S2, hence there exists a row aT of A(τ ) with for some i ∈ lτ . These pj ∈ W (τ ) i Further, by property (ii) we have supp(hT ) ⊆ supp(aT ). supp(h(cid:48)T ) ∩ supp(hT ) = ∅ for any two different row vectors h(cid:48)T and hT of H (τ ). In Lemma 3.2 of [7] it was shown that any matrix(cid:18) A(τ ) (cid:19) H (τ ) (4.3) (4.4) 20 DYNAMIC DISCRETE TOMOGRAPHY with A(τ ) satisfying (4.2) and the binary matrix H (τ ) satisfying (4.3) and (4.4) is totally unimodular. Hence, the 0/1-solutions of the linear program A(τ )x(τ ) =(τ ) H (τ )x(τ ) ∼(τ ) x(τ ) ≤(τ ) x(τ ) ≥(τ ) b(τ ), k(τ ), 11, 0, can be determined in polynomial time (see, e.g., [47, Thm. 16.2]). (cid:3) Our second example deals with instances that arise particularly in the context of superresolution imaging (see [6]). The setting is similar as in nDR(4) and Rec(2, 2, 0), which have been considered in the proof of Theorem 8. Theorem 10. Tomography under Window Constraints is polynomial-time solvable if the in- stances are restricted to those which have the following properties: (i) G(1) = ··· = G(t) = [2q]2, for some q ∈ N, and (ii) for each τ ∈ [t] and (i, j) ∈ [q]2 there is a window constraint (cid:88) p∈(2i−1,2j−1)+[1]2 0 p = k(τ ) ξ(τ ) i,j with k(τ ) i,j ∈ [4]0. This theorem is a restatement of Theorem 2.1 from [6]. Additional results for combinatorial models can be found in [6, 7]. 5. Conclusion We have shown that even in fairly 'simple' cases, the basic problems of dynamic discrete tomography are algorithmically hard. Of course, the NP-hardness results are worst-case statements. Therefore many real-world instances may turn out to be tractable in practice. Hence we believe that it is worthwhile to test, optimize, and compare the given algorithms on data sets obtained from experimental measurements. A reassuring example of an efficient handling for experimental gliding arc data can be found in [56]. It is clear that additional issues will need to be addressed to deal with noise in the measurement. This does, in particular, bring up the need to handle the lurking problems due to the inherent ill-posedness of the tomographic tasks; see [5, 9]. Also, one has to model the disappearing from and (re-)entering of particles into the camera range. On the positive side, we believe that the analysis of the present paper and the given algorithmic paradigms can be used to develop customized methods for given experimental data that provide useful insight into the movement of particles in many challenging applications. References [1] R. J. Adrian and J. Westerweel. Particle Image Velocimetry. Cambridge Aerospace Series. Cambridge University [2] R. Aharoni, G. T. Herman, and A. Kuba. Binary vectors partially determined by linear equation systems. Discrete Press, New York, 2010. Math., 171(1-3):1–16, 1997. [3] A. Alpers. Instability and Stability in Discrete Tomography. PhD dissertation, Technische Universität München, Department of Mathematics, December 2003. (published by Shaker Verlag, ISBN 3-8322-2355-X). [4] A. Alpers and S. Brunetti. Stability results for the reconstruction of binary pictures from two projections. Image [5] A. Alpers and P. Gritzmann. On stability, error correction, and noise compensation in discrete tomography. SIAM [6] A. Alpers and P. Gritzmann. On double-resolution imaging and discrete tomography. submitted, http://arxiv. [7] A. Alpers and P. Gritzmann. Reconstructing binary matrices under window constraints from their row and column sums. Fund. Informaticae, 155(4):321–340, 2017. Vision Comput., 25(10):1599–1608, 2007. J. Discrete Math., 20(1):227–239, 2006. org/abs/1701.04399, 2017. DYNAMIC DISCRETE TOMOGRAPHY 21 [8] A. Alpers, P. Gritzmann, D. Moseev, and M. Salewski. 3D particle tracking velocimetry using dynamic discrete tomography. Comput. Phys. Commun., 187(1):130–136, 2015. [9] A. Alpers, P. Gritzmann, and L. Thorens. Stability and instability in discrete tomography. LNCS 2243: Digital and Image Geometry, pages 175–186, 2001. [10] H. J. Bandelt, Y. Crama, and F. C. R. Spieksma. Approximation algorithms for multi-dimensional assignment problems with decomposable costs. Discrete Appl. Math., 49(1-3):25–50, 1994. [11] W. Bein, P. Brucker, J. K. Park, and P. K. Pathak. A Monge property for the d-dimensional transportation problem. Discrete Appl. Math., 58(2):97–110, 1995. [12] G. Birkhoff. Tres observaciones sobre el algebra lineal. Univ. Nac. Tucumán (A), 5(1):147–151, 1946. [13] J. A. Bittencourt. Fundamentals of Plasma Physics. Springer, New York, 2004. [14] A. G. Bors and I. Pitas. Prediction and tracking of moving objects in image sequences. IEEE Trans. Image Process., 9(8):1441–1445, 2000. [15] S. Brunetti, A. Del Lungo, P. Gritzmann, and S. de Vries. On the reconstruction of binary and permutation matrices under (binary) tomographic constraints. Theor. Comput. Sci., 406(1-2):63–71, 2008. [16] R. Burkard, M. Dell'Amico, and S. Martello. Assignment problems. Society for Industrial and Applied Mathematics (SIAM), Philadelphia, USA, 2009. [17] R. Burkard, M. Dell'Amico, and S. Martello. Assignment Problems. SIAM, Philadelphia, 2009. [18] R. E. Burkard and E. Çela. Linear assignment problems and extensions. In Handbook of combinatorial optimization, Supplement Vol. A, pages 75–149. Kluwer Acad. Publ., Dordrecht, 1999. [19] R. E. Burkard, B. Klinz, and R. Rudolf. Perspectives of Monge properties in optimization. Discrete Appl. Math., 70(2):95–161, 1996. [20] H. T. Chen, M. C. Tien, Y. W. Chen, W. J. Tsai, and W. J. Lee. Physics-based ball tracking and 3D trajectory recon- struction with applications to shooting location estimation in basketball video. J. Vis. Commun. Image Represent., 20(3):204–216, 2009. [21] R. T. Collins, A. J. Lipton, H. Fujiyoshi, and T. Kanade. Algorithms for cooperative multisensor surveillance. Proc. IEEE, 89(10):1456–1477, 2001. [22] Y. Crama and F. C. R. Spieksma. Approximation algorithms for three-dimensional assignment problems with triangle inequalities. European J. Oper. Res., 60(3):273–279, 1992. [23] A. Ćustić, B. Klinz, and G. J. Woeginger. Geometric versions of the three-dimensional assignment problem under general norms. Discrete Optim., 18:38–55, 2015. [24] R. Dalitz, S. Petra, and C. Schnörr. Compressed Motion Sensing. In Proc. SSVM, volume 10302 of LNCS, pages [25] T. Dokka, A. Kouvela, and C. R. Spieksma. Approximating the multi-level bottleneck assignment problem. Oper. [26] G. E. Elsinga, F. Scarano, B. Wieneke, and B. W. Oudheusden. Tomographic particle image velocimetry. Exp. 602–613. Springer, 2017. Res. Lett., 40(4):282–286, 2012. Fluids, 41(6):933–947, 2006. [27] D. Gale. A theorem on flows in networks. Pacific J. Math., 7:1073–1082, 1957. [28] R. J. Gardner and P. Gritzmann. Uniqueness and complexity in discrete tomography. In Discrete tomography: Foundations, algorithms, and applications, (ed. by G.T. Herman and A. Kuba), pages 85–113. Birkhäuser, Boston, 1999. [29] R. J. Gardner, P. Gritzmann, and D. Prangenberg. On the computational complexity of reconstructing lattice sets from their X-rays. Discrete Math., 202(1-3):45–71, 1999. [30] M. R. Garey and D. S. Johnson. Computers and Intractability. W. H. Freeman and Co., San Francisco, USA, 1979. [31] P. Gritzmann. On the reconstruction of finite lattice sets from their X-rays. In Discrete Geometry for Computer Imagery (Eds.: E. Ahronovitz and C. Fiorio), DCGI'97, Lecture Notes on Computer Science 1347, Springer, pages 19–32, 1997. [32] P. Gritzmann and S. de Vries. Reconstructing crystalline structures from few images under high resolution trans- mission electron microscopy. In Mathematics: Key Technology for the Future, (ed. by W. Jäger and H.-J. Krebs), pages 441–459. Springer, 2003. [33] P. Gritzmann, B. Langfeld, and M. Wiegelmann. Uniqueness in discrete tomography: Three remarks and a corollary. SIAM J. Discrete Math., 25(4):1589–1599, 2011. [34] G. T. Herman and A. Kuba, editors. Discrete Tomography: Foundations, Algorithms, and Applications. Birkhäuser, [35] G. T. Herman and A. Kuba, editors. Advances in Discrete Tomography and Its Applications. Birkhäuser, Boston, Boston, 1999. 2007. [36] H. Jiang, J. Wang, Y. Gong, N. Rong, Z. Chai, and N. Zheng. Online multi-target tracking with unified handling of complex scenarios. IEEE Trans. Image Process., 24(11):3464–3477, 2015. [37] R. M. Karp. Reducibility among combinatorial problems. In Complexity of Computer Computations, (ed. by R.E. Miller and J.W. Thatcher), pages 85–103. Plenum Press, New York, 1972. [38] J. Kitzhofer and C. Brücker. Tomographic particle tracking velocimetry using telecentric imaging. Exp. Fluids, 49(6):1307–1324, 2010. [39] Y. Kuroki and T. Matsui. An approximation algorithm for multidimensional assignment problems minimizing the sum of squared errors. Discrete Appl. Math., 157(9):2124–2135, 2009. [40] M. Novara, K. J. Batenburg, and F. Scarano. Motion tracking-enhanced MART for tomographic PIV. Meas. Sci. Technol., 21(3):035401, 2010. 22 DYNAMIC DISCRETE TOMOGRAPHY [41] A. B. Poore. Multidimensional assignment formulation of data association problems arising from multitarget and multisensor tracking. Comput. Optim. Appl., 3(1):27–57, 1994. [42] A. B. Poore and S. Gadaleta. Some assignment problems arising from multiple target tracking. Math. Comput. Modelling, 43(9-10):1074–1091, 2006. [43] A. B. Poore and N. Rijavec. A Lagrangian relaxation algorithm for multidimensional assignment problems arising from multitarget tracking. SIAM J. Optim., 3(3):544–563, 1993. [44] J. F. Pusztaszeri, P. E. Rensing, and T. M. Liebling. Tracking elementary particles near their primary vertex: A combinatorial approach. J. Global Optim., 9(1):41–64, 1996. [45] P. Ruhnau, C. Guetter, T. Putze, and C. Schnörr. A variational approach for particle tracking velocimetry. Meas. Sci. Technol., 16(7):1449–1458, 2005. [46] H. J. Ryser. Combinatorial properties of matrices of zeros and ones. Canad. J. Math., 9(1):371–377, 1957. [47] A. Schrijver. Theory of linear and integer programming. Wiley, Chichester, 1986. [48] J. Schwartz, A. Steger, and A. Weissl. Fast algorithms for weighted bipartite matching. LNCS, 3503:476–487, 2005. [49] F. C. R. Spieksma and G. J. Woeginger. Geometric three-dimensional assignment problems. European J. Oper. Res., 91(3):611–618, 1996. [50] P. P. A. Storms and F. C. R. Spieksma. An LP-based algorithm for the data association problem in multitarget tracking. Comput. Oper. Res., 30(7):1067–1085, 2003. [51] B. Van Dalen. Stability results for uniquely determined sets from two directions in discrete tomography. Discrete Math., 309(12):3905–3916, 2009. [52] J. L. Walteros, C. Vogiatzis, E. L. Pasiliao, and P. M. Pardalos. Integer programming models for the multidimensional assignment problem with star costs. European J. Oper. Res., 235(3):553–568, 2014. [53] H. Wiedemann. Particle Accelerator Physics. Springer, New York, 2015. [54] J. Williams. Application of tomographic particle image velocimetry to studies of transport in complex (dusty) plasma. [55] L. A. Zarrabeitia, F. Z. Qureshi, and D. A. Aruliah. Stereo reconstruction of droplet flight trajectories. IEEE Trans. Phys. Plasmas, 18(5):050702, 2011. Pattern Anal. Mach. Intell., 37(4):847–861, 2015. [56] J. Zhu, J. Gao, A. Ehn, M. Aldén, Z. Li, D. Moseev, Y. Kusano, M. Salewski, A. Alpers, P. Gritzmann, and M. Schwenk. Measurements of 3D slip velocities and plasma column lengths of a gliding arc discharge. Appl. Phys. Lett., 106(4):044101–1–4, 2015.
1208.1248
1
1208
2012-08-06T19:23:26
On fixed-parameter algorithms for Split Vertex Deletion
[ "cs.DS" ]
In the Split Vertex Deletion problem, given a graph G and an integer k, we ask whether one can delete k vertices from the graph G to obtain a split graph (i.e., a graph, whose vertex set can be partitioned into two sets: one inducing a clique and the second one inducing an independent set). In this paper we study fixed-parameter algorithms for Split Vertex Deletion parameterized by k: we show that, up to a factor quasipolynomial in k and polynomial in n, the Split Vertex Deletion problem can be solved in the same time as the well-studied Vertex Cover problem. Plugging the currently best fixed-parameter algorithm for Vertex Cover due to Chen et al. [TCS 2010], we obtain an algorithm that solves Split Vertex Deletion in time O(1.2738^k * k^O(log k) + n^O(1)). To achieve our goal, we prove the following structural result that may be of independent interest: for any graph G we may compute a family P of size n^O(log n) containing partitions of V(G) into two parts, such for any two disjoint subsets X_C, X_I of V(G) where G[X_C] is a clique and G[X_I] is an independent set, there is a partition in P which contains all vertices of X_C on one side and all vertices of X_I on the other.
cs.DS
cs
On fixed-parameter algorithms for SPLIT VERTEX DELETION Marek Cygan ∗ Marcin Pilipczuk † Abstract In the SPLIT VERTEX DELETION problem, given a graph G and an integer k, we ask whether one can delete k vertices from the graph G to obtain a split graph (i.e., a graph, whose vertex set can be partitioned into two sets: one inducing a clique and the second one inducing an independent set). In this paper we study fixed-parameter algorithms for SPLIT VERTEX DELETION parameterized by k: we show that, up to a factor quasipolynomial in k and polynomial in n, the SPLIT VERTEX DELETION problem can be solved in the same time as the well-studied VERTEX COVER problem. Plugging the currently best fixed-parameter algorithm for VERTEX COVER due to Chen et al. [TCS 2010], we obtain an algorithm that solves SPLIT VERTEX DELETION in time O(1.2738k kO(log k) + nO(1)). To achieve our goal, we prove the following structural result that may be of independent interest: for any graph G we may compute a family P of size nO(log n) containing partitions of V (G) into two parts, such for any two disjoint sets XC , XI ⊆ V (G) where G[XC ] is a clique and G[XI ] is an independent set, there is a partition in P which contains all vertices of XC on one side and all vertices of XI on the other. 1 Introduction The family of vertex deletion, or, more generally, graph modification problems, has been studied very intensively, both in theory and in practice. As in many cases we expect the number of allowed modifications to be small, compared to the size of the input graph, and most graph modification problems turned out to be NP-hard (e.g., all vertex deletion problems for nontrivial hereditary graph classes, by the classical result of Lewis and Yannakakis [9]), it is natural to study these problems from the parameterized point of view, considering parameterization by the solution size (the number of allowed modifications). In the parameterized setting we assume that each instance is equipped with an addi- tional value k -- a parameter which aims to reflect the instance complexity. The goal is ∗IDSIA, University of Lugano, Switzerland, [email protected]. Partially supported by the ERC Start- ing Grant NEWNET 279352 and Foundation for Polish Science. †Institute of Informatics, University of Warsaw, Poland, [email protected], Partially supported by NCN grant N206567140 and Foundation for Polish Science. 1 to provide an algorithm (called a fixed-parameter algorithm) with f (k)nO(1) time com- plexity, where n is the instance size and f is a function independent of n. Observe that such an algorithm is polynomial for any constant value of k and moreover the degree of the polynomial is independent of the parameter value. For more information about the parameterized complexity in general, we refer to three monographs [5, 6, 11]. In this paper we focus on one particular graph modification problem, namely the SPLIT VERTEX DELETION problem (SPLITVD for short). Here, we are given an n- vertex graph G and an integer k and the task is to delete k vertices from G to obtain a split graph: a graph H is called a split graph if V (H) can be partitioned into two parts XC and XI, such that H[XC ] is a clique and H[XI ] is an independent set.1 Note that the partition (XC , XI) does not need to be unique; for example, an n-vertex clique is a split graph with n + 1 different valid partitions. As the class of split graphs is hereditary, by the result of Lewis and Yannakakis [9], SPLITVD is NP-hard. Foldes and Hammer [7] proved that the class of split graphs is exactly the class of {2K2, C4, C5}-free graphs; by the general result of Cai [2], this observation yields a fixed-parameter algorithm with running time O(5knO(1)). The dependency on k has been subsequently improved to O(2.32knO(1)) by Lokshtanov et al. [10] and O(2knO(1)) by Ghosh et al. [8]. In this paper we show that SPLITVD can be solved essentially in the same time as the well-studied VERTEX COVER problem. Theorem 1.1. If there exists an algorithm that solves the VERTEX COVER problem parameterized by the solution size k on n-vertex graphs in f (k, n) time and g(k, n) space, then the SPLIT VERTEX DELETION problem on n-vertex graphs can be solved in O(f (k, n)kO(log k) + nO(1)) time and O(g(k, n) + nO(1)) space. By plugging in the currently fastest known algorithm for VERTEX COVER [3], we obtain the following. Corollary 1.2. The SPLIT VERTEX DELETION problem can be solved in O(1.2738kkO(log k) + nO(1)) time and polynomial space. Note that there exists a straightforward reverse reduction: given a VERTEX COVER instance (G, k) (i.e., we ask for a vertex cover of size k in the graph G), it is easy to see that an equivalent SPLITVD instance (G′, k) can be created by defining the graph G′ to be a disjoint union of the graph G and a clique on k + 2 vertices. Thus, we obtain that -- up to a factor quasipolynomial in k and polynomial in n -- the optimal time complexities of fixed-parameter algorithms for VERTEX COVER and SPLITVD are equal. The core difficulty of the proof of Theorem 1.1 lies in the following structural result that may be of independent interest. Theorem 1.3. For any n-vertex graph G there exists a family P of partitions (VC , VI ) of the vertex set V (G), such that the following holds. 1Through the paper we use standard graph notation, see e.g. [4]. In particular, for a given graph G, by V (G) and E(G) we denote its vertex and edge set, respectively. For a set X ⊆ V (G), G[X] is a subgraph induced by X. For a vertex v ∈ V (G), NG(v) denotes the set of neighbours of v and NG[v] = NG(v) ∪ {v}. 2 1. For any set X ⊆ V (G) such that G[X] is a split graph, and any partition (XC , XI ) of X, such that G[XC ] is a clique and G[XI ] is an independent set, there exists a partition (VC , VI ) ∈ P such that XC ⊆ VC and XI ⊆ VI . 2. P ≤ 4 · (2n)2⌊log n⌋+1. Moreover, there exists an algorithm that enumerates (with possible repetitions) the family P and runs in time O(n2⌊log n⌋+O(1)) and polynomial space. Theorem 1.3 is proven in Section 2. Equipped with this structural result, in Sec- tion 3 we show that Theorem 1.1 follows easily by combining an already known pre- processing routine for SPLITVD that outputs an equivalent instance of size polynomial in k (called a polynomial kernel), Theorem 1.3 and a simple observation that, if we seek for a resulting split induced subgraph that is covered by a fixed partition (VC , VI ) ∈ P, SPLITVD naturally reduces to a VERTEX COVER instance with the same parameter. 2 Small family of reasonable partitions: proof of Theo- rem 1.3 C , V 0 C , V 0 C , V 0 C and V 0 I ) and (V 0 I and A; intuitively, the vertices of V 0 In this section we prove Theorem 1.3. To this end, we describe a branching algorithm that computes the family P. The algorithm maintains a partition (called a state) of V (G) into three parts V 0 I are already assigned to VC and VI , whereas the set A consists of remaining (active) vertices. At each step, given a state S = (V 0 C ∪ I ∪ A) and branches (calls itself recursively) into 2A subcases, A, V 0 creating two new states for each v ∈ A: a state Sv→C = (V 0 C ∪ {v}, V 0 I ∪ (A \ NG[v]), A ∩ NG(v)) and a state Sv→I = (V 0 I ∪ {v}, A \ NG[v]). C ∪ (A ∩ NG(v)), V 0 Informally speaking, in the first branch the vertex v is assigned to the clique part; consequently, all its non-neighbours are assigned to the independent set part, as they cannot be together with v in the clique part of a split induced subgraph of G. The second branch symmetrically assigns v to the independent set part and all neighbours of v to the clique part. I , A), the algorithm outputs two partitions (V 0 Moreover, the recurrence is trimmed at depth 2⌊log n⌋ + 1. The algorithm is de- scribed on Pseudocode 1. Function Generator(G, d, S = (V 0 C , V 0 I , A)) {n = V (G) and S = (V 0 C , V 0 I , A) is a partition of V (G)} C ∪ A, V 0 C , V 0 I ∪ A). I ) and (V 0 for all vertices v ∈ A do 1: output (V 0 2: if d < 2⌊log n⌋ + 1 then 3: 4: 5: Function GeneratePartitions(G) 6: Generator(G, 0, (∅, ∅, V (G))). Generator(G, d + 1, Sv→C = (V 0 Generator(G, d + 1, Sv→I = (V 0 C ∪ {v}, V 0 C ∪ (A ∩ NG(v)), V 0 I ∪ (A \ NG[v]), A ∩ NG(v))) I ∪ {v}, A \ NG[v])) Pseudocode 1: Algorithm that generates the family P from Theorem 1.3. 3 Since the algorithm trims the recurrence at depth 2⌊log n⌋ + 1, the bounds on the running time and the size of the family P follow: at each step, 2A ≤ 2n new subcases are created, the search tree contains at most (2n)2⌊log n⌋+1 leaves and less than twice as much vertices, and each call to the procedure Generator outputs two partitions. To finish the proof of Theorem 1.3, we need to show the computed family P admits the first property of Theorem 1.3. To this end, let us fix a set X ⊆ V (G) that induces a split graph in G and a partition (XC , XI) of X such that G[XC ] is a clique and G[XI ] is an independent set. We show that the algorithm outputs a partition (VC , VI ) with XC ⊆ VC and XI ⊆ VI. We say that a state S = (V 0 C ∪ A and XI ⊆ I ∪ A; note that this is a necessary condition to output a desired partition in any V 0 subcase generated from the state S. Moreover, note that the initial state (∅, ∅, V (G)) is clearly promising. I , A) is promising if XC ⊆ V 0 C , V 0 Consider a promising state S = (V 0 C , V 0 I , A). Denote X A XI ∩ A. Note that if X A Symmetrically, if X A these partitions are output by the algorithm. I = ∅, then the partition (V 0 C = ∅, then the partition (V 0 C , V 0 C ∪ A, V 0 C = XC ∩ A and X A I = I ∪ A) is a desired partition. I ) is a desired partition; both C and X A Consider now the remaining case where X A I are nonempty. Note that C , the state Sv→C is also promising, as G[XC] is a clique and XC ⊆ for v ∈ X A {v} ∪ NG(v). Symmetrically, for any v ∈ X A I , the state Sv→I is also promising, as G[XI ] is an independent set and XI ⊆ V (G) \ NG(v). However, our recurrence is trimmed at depth 2⌊log n⌋ + 1. To cope with this obstacle, we show that there exists a choice of v ∈ A that efficiently reduces the sizes of X A I . C and X A C and second endpoint Let F be the set of edges of G that have one endpoint in X A I . If F > X A I than in X A C and X A I such non-edges) then, by standard averaging argument, there exists a vertex v ∈ X A C are neighbours that NG(v)∩X A C such that of v) Otherwise, if F ≤ X A I are not neighbours X A C is reduced of v). In the first case, in the promising state Sv→I the size of the set X A by at least half; in the second case, in the promising state Sv→C the size of the set X A is reduced by at least half. At the beginning, X A I ≤ n, thus the recurrence reaches a promising state where X A I is empty at depth at most 2⌊log n⌋ + 1. This finishes the proof of Theorem 1.3. C /2 (i.e., more than half of the vertices of X A I /2 (i.e., there are more edges between X A I /2 (i.e., at least half of the vertices of X A I /2, then there exists a vertex v ∈ X A I \ NG(v) ≥ X A C > X A C or X A C · X A C · X A C , X A I 3 The algorithm: proof of Theorem 1.1 Equipped with Theorem 1.3, we are now ready to show the proof of Theorem 1.1. Consider a SPLITVD instance (G, k). First, we invoke one of the known preprocessing (kernelization) routines for SPLITVD that reduces the number of vertices of the graph to a polynomial in k, without increasing the parameter. Here, we can either use the generic framework of the d-HITTING SET problem [1] (recall that the class of split graphs has a finite set of forbidden induced subgraphs) or use the recent O(k3)-vertex kernel by Ghosh et al. [8]. This step adds an additive factor of polynomial order in V (G) both to time and space complexity of the algorithm. 4 Second, we invoke Theorem 1.3 and process the output partitions one by one. For a given partition (VC , VI ), we seek for a set X ⊆ V (G), such that G[VC ∩ X] is a clique, G[VI ∩ X] is an independent set and V (G) \ X ≤ k. By Theorem 1.3 this is sufficient to solve the initial SPLITVD instance (G, k), and this step adds an kO(log k) multiplicative factor to the time complexity and a polynomial in k additive factor to the space complexity. Fix a partition (VC , VI ). We are to delete at most k vertices from the graph G to make G[VC ] a clique and G[VI ] an independent set. Let G′ be defined as a disjoint union of G[VI ] and a complement of G[VC ]. Note that our task becomes the classical vertex cover problem in the graph G′ with parameter k: we need to cover all edges of G[VI ] and non-edges of G[VC ]. Therefore, for a fixed partition (VC , VI ), the problem can be solved in the same time as the VERTEX COVER problem for a graph of the same size and parameter k. This finishes the proof of Theorem 1.1. 4 Conclusions We have shown that the dependencies on the parameter k in the optimal time complex- ity of fixed-parameter algorithms for VERTEX COVER and SPLIT VERTEX DELETION are essentially equal. This result can be considered as a tight bound on the time com- plexity of fixed-parameter algorithms for SPLIT VERTEX DELETION. However, note that our reduction adds a polynomial in the size of the input graph additive factor to the time complexity that results from the application of a kernelization algorithm. The algorithm of Chen et al. [3] for the VERTEX COVER problem has linear dependency on n. We leave as an open problem to obtain a linear-time polynomial kernel for SPLITVD; such a result would automatically yield a linear-time dependency on n in our algorithm. References [1] Faisal N. Abu-Khzam. A kernelization algorithm for d-hitting set. J. Comput. Syst. Sci., 76(7):524 -- 531, 2010. [2] Leizhen Cai. Fixed-parameter tractability of graph modification problems for hereditary properties. Inf. Process. Lett., 58(4):171 -- 176, 1996. [3] Jianer Chen, Iyad A. Kanj, and Ge Xia. Improved upper bounds for vertex cover. Theor. Comput. Sci., 411(40-42):3736 -- 3756, 2010. [4] Reinhard Diestel. Graph Theory. Springer, 2005. [5] Rodney G. Downey and Michael R. Fellows. Parameterized Complexity. Springer, 1999. [6] Jorg Flum and Martin Grohe. Parameterized Complexity Theory. 2006. [7] S. Foldes and P. Hammer. Split graphs. Congressus Numerantium, 19:311 -- 315, 1977. 5 [8] Esha Ghosh, Sudeshna Kolay, Mrinal Kumar, Pranabendu Misra, Fahad Panolan, Ashutosh Rai, and M. S. Ramanujan. Faster parameterized algorithms for deletion to split graphs. In Fedor V. Fomin and Petteri Kaski, editors, SWAT, volume 7357 of Lecture Notes in Computer Science, pages 107 -- 118. Springer, 2012. [9] John M. Lewis and Mihalis Yannakakis. The node-deletion problem for hered- Journal of Computer and System Sciences, itary properties is NP-complete. 20(2):219 -- 230, 1980. [10] Daniel Lokshtanov, N. S. Narayanaswamy, Venkatesh Raman, M. S. Ramanujan, and Saket Saurabh. Faster parameterized algorithms using linear programming. CoRR, abs/1203.0833, 2012. [11] Rolf Niedermeier. Invitation to Fixed-Parameter Algorithms, volume 31 of Ox- ford Lecture Series in Mathematics and its Applications. Oxford University Press, 2006. 6
1802.06204
3
1802
2018-06-15T03:52:43
Approximate Set Union Via Approximate Randomization
[ "cs.DS", "cs.CC", "cs.CG", "cs.DM" ]
We develop an randomized approximation algorithm for the size of set union problem $\arrowvert A_1\cup A_2\cup...\cup A_m\arrowvert$, which given a list of sets $A_1,...,A_m$ with approximate set size $m_i$ for $A_i$ with $m_i\in \left((1-\beta_L)|A_i|, (1+\beta_R)|A_i|\right)$, and biased random generators with $Prob(x=\randomElm(A_i))\in \left[{1-\alpha_L\over |A_i|},{1+\alpha_R\over |A_i|}\right]$ for each input set $A_i$ and element $x\in A_i,$ where $i=1, 2, ..., m$. The approximation ratio for $\arrowvert A_1\cup A_2\cup...\cup A_m\arrowvert$ is in the range $[(1-\epsilon)(1-\alpha_L)(1-\beta_L), (1+\epsilon)(1+\alpha_R)(1+\beta_R)]$ for any $\epsilon\in (0,1)$, where $\alpha_L, \alpha_R, \beta_L,\beta_R\in (0,1)$. The complexity of the algorithm is measured by both time complexity, and round complexity. The algorithm is allowed to make multiple membership queries and get random elements from the input sets in one round. Our algorithm makes adaptive accesses to input sets with multiple rounds. Our algorithm gives an approximation scheme with $O(\setCount\cdot(\log \setCount)^{O(1)})$ running time and $O(\log m)$ rounds, where $m$ is the number of sets. Our algorithm can handle input sets that can generate random elements with bias, and its approximation ratio depends on the bias. Our algorithm gives a flexible tradeoff with time complexity $O\left(\setCount^{1+\xi}\right)$ and round complexity $O\left({1\over \xi}\right)$ for any $\xi\in(0,1)$.
cs.DS
cs
Approximate Set Union via Approximate Randomization ∗ Bin Fu1, Pengfei Gu1, and Yuming Zhao2 1Department of Computer Science University of Texas - Rio Grande Valley, Edinburg, TX 78539, USA Zhaoqing University, Zhaoqing, Guangdong 526061, P.R. China 2School of Computer Science Abstract Ai , 1+αR We develop a randomized approximation algorithm for the size of set union problem A1 ∪ A2 ∪ ... ∪ Am, which is given a list of sets A1, ..., Am with approximate set size for Ai with mi ∈ ((1 − βL)Ai, (1 + βR)Ai), and biased random generators with mi Ai i for each input set Ai and element x ∈ Ai, Prob (x = RandomElement(Ai)) ∈ h 1−αL where i = 1, 2, ..., m. The approximation ratio for A1 ∪ A2 ∪ ... ∪ Am is in the range [(1 − ǫ)(1 − αL)(1 − βL), (1 + ǫ)(1 + αR)(1 + βR)] for any ǫ ∈ (0, 1), where αL, αR, βL, βR ∈ (0, 1). The complexity of the algorithm is measured by both time complexity and round com- plexity. The algorithm is allowed to make multiple membership queries and get random elements from the input sets in one round. Our algorithm makes adaptive accesses to input sets with multiple rounds. Our algorithm gives an approximation scheme with O(m · (log m)O(1)) run- ning time and O(log m) rounds, where m is the number of sets. Our algorithm can handle input sets that can generate random elements with bias, and its approximation ratio depends on the bias. Our algorithm gives a flexible tradeoff with time complexity O(cid:0)m1+ξ(cid:1) and round complexity O(cid:16) 1 ξ(cid:17) for any ξ ∈ (0, 1). We prove that our algorithm runs sublinear in time under certain condition that each element in A1 ∪ A2 ∪ ... ∪ Am belongs to ma for any fixed a > 0. A O(cid:0)r(r + lλ)3l3d4(cid:1) running time dynamic programming algorithm is proposed to deal with an interesting problem in number theory area that is to count the number of lattice points in a d−dimensional ball Bd(r, p, d) of radius r with center at p ∈ D(λ, d, l), where D(λ, d, l) = {(x1, · · · , xd) : (x1, · · · , xd) with xk = ik + jkλ for an integer jk ∈ [−l, l], and another arbitrary integer ik for k = 1, 2, ..., d}. We prove that it is #P-hard to count the number of lattice points in a set of balls, and we also show that there is no polynomial time algorithm to approximate the number of lattice points in the intersection of n-dimensional balls unless P=NP. 1. Introduction Computing the cardinality of set union is a basic algorithmic problem that has a simple and natural definition. It is related to the following problem: given a list of sets A1, ..., Am with set size Ai, ∗This research is supported in part by National Science Foundation Early Career Award 0845376 and Bensten Fellowship of the University of Texas - Rio Grande Valley. 1 and random generators RandomElement(Ai) for each input set Ai, where i = 1, 2, ..., m, compute A1 ∪ A2 ∪ ... ∪ Am. This problem is #P-hard if each set is 0, 1-lattice points in a high dimensional cube [35]. Karp, Luby, and Madras [29] developed a (1 + ǫ)-randomized approximation algorithm to improve the runnning time for approximating the number of distinct elements in the union A1 ∪ ··· ∪ Am to linear O((1 + ǫ)m/ǫ2) time. Their algorithm is based on the input that provides the exact size of each set and an uniform random element generator of each set. Bringmann and Friedrich [8] applied Karp, Luby, and Madras' algorithm in deriving approximate algorithm for high dimensional geometric object with uniform random sampling. They also proved that it is #P- hard to compute the volume of the intersection of high dimensional boxes, and showed that there is no polynomial time 2d1−ǫ -approximation unless NP=BPP. In the algorithms mentioned above, some of them were based on random sampling, and some of them provided exact set sizes when approximating the cardinalities of multisets of data and some of them dealt with two multiple sets. However, in realty, it is really hard to give an uniform sampling or exact set size especially when deal with high dimensional problems. A similar problem has been studied in the streaming model: given a list of elements with mul- tiplicity, count the number of distinct items in the list. This problem has a more general for- m nk mat to compute frequency moments Fk = i , where ni denotes the number of occurrences of i in the sequence. This problem has received a lot of attention in the field of streaming algo- rithms [2, 4, 5, 7, 14, 15, 18, 19, 20, 21, 25, 28]. Pi=1 Motivation: The existing approximate set union algorithm [29] needs each input set has a uniform random generator. In order to have approximate set union algorithm with broad application, it is essential to have algorithm with biased random generator for each input set, and see how approximation ratio depends on the bias. In this paper, we propose a randomized approximation algorithm to approximate the size of set union problem by extending the model used in [29]. In order to show why approximate randomization method is useful, we generalize the algorithm that was designed by Karp, Luby, and Madras [29] to an approximate randomization algorithm. A natural problem that counting of lattice points in d-dimensional ball is discussed to support the useful of approximate randomization algorithm. In our algorithm, each input set Ai is a black box that can provide its size Ai, generate a random element RandomElement(Ai) of Ai, and answer the membership query (x ∈ Ai?) in O(1) time. Our algorithm can handle input sets that can generate random elements with bias with Prob(x = RandomElement(Ai)) ∈h 1−αL Ai i for each input set Ai and approximate set size mi for Ai with mi ∈ [(1 − βL)Ai, (1 + βR)Ai]. As the communication complexity is becoming important in distributed environment, data trans- mission among variant machines may be more time consuming than the computation inside a single machine. Our algorithm complexity is also measured by the number of rounds. The algorithm is allowed to make multiple membership queries and get random elements from the input sets in one round. Our algorithm makes adaptive accesses to input sets with multiple rounds. The round complexity is related a distributed computing complexity if input sets are stored in a distributed environment, and the number of rounds indicates the complexity of interactions between a central server, which runs the algorithm to approximate the size of set union, and clients, which save one set each. , 1+αR Ai Computation via bounded queries to another set has been well studied in the field of structural complexity theory. Polynomial time truth table reduction has a parallel way to access oracle with all queries to be provided in one round [9]. Polynomial time Turing reduction has a sequential way to access oracle by providing a query and receiving an answer in one round [12]. The constant-round truth table reduction (for example, see [16]) is between truth table reduction, and Turing reduction. Our algorithm is similar to a bounded round truth table reduction to input sets to approximate the size set union. Karp, Luby, and Madras [29]'s algorithm runs like a Turing reduction which has the number of adaptive queries proportional to the time. We design approximation scheme for the number of lattice points in a d-dimensional ball with its center in D(λ, d, l), where D(λ, d, l) to be the set points pd = (x1, ··· , xd) with xi = i + jλ 2 1+α for an integer j ∈ [−l, l], another arbitrary integer i, and an arbitrary real number l. It returns β , l, λ(cid:17), an approximation in the range [(1 − β)C(r, p, d), (1 + β)C(r, p, d)] in a time poly(cid:16)d, 1 where C(r, p, d) is the number of lattice points in a d-dimensional ball with radius r and center p ∈ D(λ, d, l). We also show how to generate a random lattice point in a d-dimensional ball with its center at D(λ, d, l). It generates each lattice point inside the ball with a probability in h 1−α α , l, λ, log r(cid:1), where the d-dimensional ball has radius r C(r,p,d) , and center p ∈ D(λ, d, l). Without the condition that a ball center is inside D(λ, d, l), counting the number of lattice points in a ball may have time time complexity that depends on dimension number d exponentially even the radius is as small as d. Counting the number of lattice points inside a four dimensional ball efficiently implies an efficient algorithm to factorize the product of C(r,p,d)i in a time poly(cid:0)d, 1 two prime numbers (n = pq) as C(√n, (0, ..., 0), 4) − C(√n − 1, (0, ..., 0), 4) = 8(1 + pA + q + n) (see [3, 27]). Therefore, a fast exact counting lattice points inside a four dimensional ball implies a fast algorithm to crack RSA public key system. This gives a natural example to apply our approximation scheme to the number of lattice points in a list of balls. We prove that it is #P-hard to count the number of lattice points in a set of balls, and we also show that there is no polynomial time algorithm to approximate the number of lattice points in the intersection n-dimensional balls unless P=NP. We found that it is an elusive problem to develop a poly(cid:0)d, 1 points of d-dimensional ball with a small radius. We are able to handle the case with ball centers in D(λ, d, l), which can approximate an arbitrary center by adjusting parameters λ and l. This is our main technical contributions about lattice points in a high dimensional ball. ǫ(cid:1) time (1 + ǫ)-approximation algorithm for the number of lattice d It is a classical problem in analytic number theory for counting the number of lattice points in d-dimensional ball, and has been studied in a series of articles [1, 6, 10, 11, 13, 22, 23, 26, 30, 31, 33, 34, 36, 37, 39, 38, 40] in the field of number theory. Researchers are interested in both 2 d + 1)−1rd, where upper bounds and lower bounds for the error term Ed(r) = Nd(r) − π Nd(r) = #{x ∈ Zd : x ≤ r} is the number of lattice points inside a sphere of radius r centered at 2 d + 1)−1rd (where Γ(.) is Gamma Function) is the volume of a d− dimensional the origin and π sphere of radius r. When d = 2, the problem is called "Gauss Circle Problem"; Gauss proved that E2(r) ≤ r. Gauss's bound was improved in papers [13, 22, 26]. Walfisz [38] showed that Ed(r) = Ω±(rd−2) and Ed(r) ≤ rd−2, where f (x) = Ω+(F (x))(f (x) = Ω−(F (x))) as x → ∞ if there exist a sequence {xn} → ∞ and a positive number C, such that for all n ≥ 1, f (xn) > CF (xn) (f (xn) < −CF (xn)). Most of the above results focus on the ball centered at the origin, and few papers worked on variable centers but also consider fixed dimensions and radii going to infinity [6, 10, 36, 40]. 2 Γ( 1 2 Γ( 1 d Our Contributions: We have the following contributions to approximate the size of set union. 1. It has constant number of rounds to access the input sets. This reduces an important complexity in a distributed environment where each set stays a different machine. It is in contrast to the existing algorithm that needs Ω(m) rounds in the worst case. 2. It handles the approximate input set sizes and biased random sources. The existing algorithms assume uniform random source from each set. Our approximation ratio depends on the approximation ratio for the input set sizes and bias of random generator of each input set. The approximate ratio for A1 ∪ A2 ∪ ··· ∪ Am is controlled in the range in [(1 − ǫ)(1 − αL)(1 − βL), (1 + ǫ)(1 + αR)(1 + βR)] for any ǫ ∈ (0, 1), where αL, αR, βL, βR ∈ (0, 1). 3. It runs in sublinear time when each element belongs to at least ma sets for any fixed a > 0. We have not seen any sublinear results about this problem. 4. We show a tradeoff between the number of rounds, and the time complexity. It takes log m rounds with time complexity O(cid:0)m(log m)O(1)(cid:1), and takes O(cid:16) 1 ξ(cid:17) rounds, with a time complexity O(cid:0)m1+ξ(cid:1). We still maintain the time complexity nearly linear time in the classical model. Our algorithm is based on a new approach that is different from that in [29]. 5. We identify two additional parameters zmin and zmax that affect both the complexity of rounds and time, where zmin is the least number of sets that an element belongs to, and zmax is the largest number of sets that an element belongs to. Our algorithm developed in the randomized model only accesses a small number of elements from 3 the input sets. The algorithm developed in the streaming model algorithm accesses all the elements from the input sets. Therefore, our algorithm is incomparable with the results in the streaming model [2, 4, 5, 7, 14, 15, 18, 19, 20, 21, 25, 28]. Organization: The rest of paper is organized as follows. In Section 2, we define the compu- tational model and complexity. Section 3 presents some theorems that play an important role in accuracy analysis. In Section 4, we give a randomized approximation algorithm to approximate the size of set union problem; time complexity and round complexity also analysis in Section 4. Section 5 discusses a natural problem that counting of lattice points in high dimensional balls to support the useful of approximation randomized algorithm. An application of high dimensional balls in Maximal Coverage gives in Section 6. In Section 7, we summarize with conclusions. 2. Computational Model and Complexity In this section, we show our model of computation, and the definition of complexity. 2.1. Model of Randomization Definition 1. Let A be a set of elements. i. A α-biased random generator for set A is a generator that each element in A is generated with ii. A (αL, αR)-biased random generator for set A is a generator that each element in A is generated , 1+α probability in the range h 1−α A i. with probability in the range h 1−αL A A , 1+αR A i. Definition 2. Let L be a list of sets A1, A2, ··· , Am such that each supports the following opera- tions: i. The size of Ai has an approximation mi ∈ [(1 − βL)Ai, (1 + βR)Ai] for i = 1, 2, ··· , m. m Both M = mi and m are part of the input. Pi=1 ii. Function RandomElement(Ai) returns a (αL, αR)-biased approximate random element x from Ai for i = 1, 2, ··· , m. iii. Function query(x, Ai) function returns 1 if x ∈ Ai, and 0 otherwise. Definition 3. For a list L of sets A1, A2, ··· , Am and real numbers αL, αR, βL, βR ∈ [0, 1), it is called ((αL, αR), (βL, βR))-list if each set Ai is associated with a number mi with (1 − βL)Ai ≤ mi ≤ (1 + βR)Ai for i = 1, 2, ··· , m, and the set Ai has a (αL, αR)-biased random generator RandomElement(Ai). Definition 4. The model of randomized computation for our algorithm is defined below: i. The input is a list L defined in Definition 2. ii. It allows all operations defined in Definition 2. 4 2.2. Round and Round Complexity The round complexity is the total number of rounds used in the algorithm. Our algorithm has several rounds to access input sets. At each round, the algorithm send multiple requests to random generators, and membership queries, and receives the answers from them. Our algorithm is considered as a client-server interaction (see Fig. 1). The algorithm is controlled by the server side, and each set is a client. In one round, the server asks some questions to clients which are selected. Figure 1: Client-server Interaction The parameters m, ǫ, γ may be used to determine the time complexity and round complexity, where ǫ controls the accuracy of approximation, γ controls the failure probability, and m is the number of sets. 3. Preliminaries During the accuracy analysis, Hoeffiding Inequality [24] and Chernoff Bound (see [32]) play an important role. They show how the number of samples determines the accuracy of approximation. Theorem 5 ([24]). Let X1, . . . , Xm be m independent random variables in [0, 1] and X = Xi. i. If Xi takes 1 with probability at most p for i = 1, . . . , m, then for any ǫ > 0, Pr(X > m Pi=1 pm + ǫm) < e− ǫ2m 2 . ii. If Xi takes 1 with probability at least p for i = 1, . . . , m, then for any ǫ > 0, Pr(X < pm − ǫm) < e− ǫ2m 2 . Theorem 6. Let X1, . . . , Xm be m independent random 0-1 variables, where Xi takes 1 with prob- Xi, and µ = E[X]. Then for any δ > 0, ability at least p for i = 1, . . . , m. Let X = Pr(X < (1 − δ)pm) < e− 1 2 δ2pm. m Pi=1 Theorem 7. Let X1, . . . , Xm be m independent random 0-1 variables, where Xi takes 1 with prob- ability at most p for i = 1, . . . , m. Let X = Xi. Then for any δ > 0, Pr(X > (1 + δ)pm) < eδ (1+δ)(1+δ)ipm h . 2 δ2 Define g1(δ) = e− 1 and g2(δ) = (1+δ)(1+δ) . Define g(δ) = max (g1(δ), g2(δ)). We note that g1(δ) and g2(δ) are always strictly less than 1 for all δ > 0. It is trivial for g1(δ). For g2(δ), this can be verified by checking that the function f (x) = (1 + x) ln(1 + x) − x is increasing and f (0) = 0. This is because f′(x) = ln(1 + x) which is strictly greater than 0 for all x > 0. eδ m Pi=1 5 We give a bound for eδ (1+δ)(1+δ) . Let u(x) = ex (1+x)(1+x) . We consider the case x ∈ [0, 1]. We have ln u(x) = x − (1 + x) ln(1 + x) ≤ x − (1 + x)(x − x2 2 ) = x − (x + x2 2 − x3 3 ) ≤ − x2 6 . Therefore, for all x ∈ [0, 1]. We let u(x) ≤ e− x2 6 g∗(x) = e− x2 6 . (1) (2) We have g(x) ≤ g∗(x) for all x ∈ [0, 1]. A well known fact, called union bound, in probability theory is the inequality Pr(E1 ∪ E2 . . . ∪ Em) ≤ Pr(E1) + Pr(E2) + . . . + Pr(Em), where E1, E2, . . . , Em are m events that may not be independent. In the analysis of our randomized algorithm, there are multiple events such that the failure from any of them may fail the entire algorithm. We often characterize the failure probability of each of those events, and use the above inequality to show that the whole algorithm has a small chance to fail after showing that each of them has a small chance to fail. 4. Algorithm Based on Adaptive Random Samplings In this section, we develop a randomized algorithm for the size of set union when the approximate set sizes and biased random generators are given for the input sets. We give some definitions before the presentation of the algorithm. The algorithm developed in this section has an adaptive way to access the random generators from the input sets. All the random elements from input sets are generated in the beginning of the algorithm, and the number of random samples is known in the beginning of the algorithm. The results in this section show a tradeoff between the time complexity and the round complexity. Definition 8. Let L = A1, A2,··· , Am be a list of finite sets. ii. For an element x, and a subset of indices with multiplicity H of {1, 2,··· , m}, define S(x, H) = i. For an element x, define T (x, L) =(cid:12)(cid:12){i : 1 ≤ i ≤ m and x ∈ Ai}(cid:12)(cid:12). (cid:12)(cid:12){i : i ∈ H and x ∈ Ai}(cid:12)(cid:12). iii. Define minThickness(L) = min{T (x, L) : x ∈ A1 ∪ A2 ∪ ··· ∪ Am}. iv. Define maxThickness(L) = max{T (x, L) : x ∈ A1 ∪ A2 ∪ ··· ∪ Am}. v. Let W be a subset with multiplicity of A1 ∪ ··· ∪ Am, define F (W, h, s) = s F ′(W ) = Px∈W vi. For a δ ∈ (0, 1), partition A1 ∪ A2 ∪···∪ Am into A′1,··· , A′k such that A′i = {x : x ∈ A1∪ A2 ∪ ··· ∪ Am and T (x, L) ∈ [(1 + δ)i−1, (1 + δ)i)} where i = 1, 2, ..., k. Define v(δ, z1, z2, L) = k, which is the number of sets in the partition under the condition that z1 ≤ T (x, L) ≤ z2. h Px∈W s F (W, h, s). 1 T (x,L) = h 1 T (x,L) , and 6 4.1. Overview of Algorithm We give an overview of the algorithm. For a list L of input sets A1,··· , Am, each set Ai has an approximate size mi and a random generator. It is easy to see that A1 ∪ A2 ∪ ··· ∪ Am = Pi=1 Px∈Ai T (x,L) . The first phase of the algorithm generates a set R1 of sufficient random samples from the list of input sets. The set R1 has the property that m1+···+mm T (x,L) is close to m 1 1 m 1 T (x,L) . We will use the variable sum with initial value zero to approximate it. Each stage Pi=1 Px∈Ai i removes the set Vi of elements from Ri that each element x ∈ Vi satisfies T (x, L) ∈ h and all elements x ∈ Ri with T (x, L) ∈ h Ti and f1(m) is a function at least 8, which will determine the number of rounds, and the trade off between the running time and the number of rounds. In phase i, we choose a set Hi of ui (to be large enough) of indices from 1,··· , m, and use S(x,Hi)m to approximate T (x, L). It is accurate enough if ui is large enough. The elements left in Ri − Vi will have smaller T (x, L). The set Ri+1 will be built for the next stage i + 1. When Ri − Vi is shrinked to Ri+1 by random sampling in Ri − Vi, each element in Ri+1 will have its weight to be scaled by a factor Ri−Vi . When an element x is hi+1 put into Vi, it is removed from Ri, and an approximate value of T (x,L) multiplied by its weight is 4f1(m) , Tii, f1(m) , Tii are in Vi, where Ti = max{T (x, L) : x ∈ Ri} ui Ti 1 R1 · Px∈R1 m added to sum. Finally, we will prove that sum · (m1 + ··· + mm) is close to is equal to A1 ∪ A2 ∪ ··· ∪ Am. Example 1. Let L be a list of 10 sets A1, A2, ··· , A10, where Ai = Bi ∪ C with C = 1000 and Bi = 100 for i = 1, 2, ··· , 10. In the beginning of the algorithm, we generate a set R1 of h1 = 220 random samples from list L, where there are 200 random samples with higher thickness T (x, L), namely, these 200 random samples locate in C and 20 random samples with lower thickness T (x, L), say, these 20 random samples locate in Bi. At the first round, we only need select sets A1, A3, and A6 to approximate the thickness T (x, L) of the 200 random samples locating at C. Then at the second round, we have to select all the sets A1, A2, ··· , A10, to approximate the thickness T (x, L) of the 20 random samples coming from Bi (See Fig. 2). Pi=1 Px∈Ai T (x,L) , which 1 7 Figure 2: Set Union of Ten Sets 4.2. Algorithm Description Before giving the algorithm, we define an operation that selects a set of random elements from a list L of sets A1,··· , Am. We always assume m ≥ 2 throughout the paper. Definition 9. Let L be a list of m sets A1, A2,··· , Am with mi ∈ [(1 − βL)Ai, (1 + βR)Ai] and (αL, αR)-biased random generator RandomElement(Ai) for i = 1, 2,··· , m, and M = m1 + m2 + ··· + mm. A random choice of L is to get an element x via the following two steps: i. With probability mi M , select a set Ai among A1,··· , Am. ii. Get an element x from set Ai via RandomElement(Ai). We give some definitions about the parameters and functions that affect our algorithm below. We assume that ǫ ∈ (0, 1) is used to control the accuracy of approximation, and γ ∈ (0, 1) is used to control the failure probability. Both parameters are from the input. In the following algorithm, the two integer parameters zmin and zmax with 1 ≤ zmin ≤ minThickness(L) ≤ maxThickness(L) ≤ zmax ≤ m can help speed up the computation. The algorithm is still correct if we use default case with zmin = 1 and zmax = m. i. The following parameters are used to control the accuracy of approximation at different stages of algorithm: ǫ0 = δ = , ǫ1 = ǫ 9 ǫ2 2 . ǫ0 6(log m) , ǫ2 = ǫ1 4 , ǫ3 = ǫ0 3 , (3) (4) ii. The following parameters are used to control the failure probability at several stages of the algorithm: , γ2 = γ 6 log m . γ1 = γ 3 8 (5) iii. Function f1(.) is used to control the number of rounds of the algorithm. Its growth rate is mainly determined by the parameter c1 that will be determined later: f1(m) = 8mc1 with c1 ≥ 0, (6) iv. Function f2(.) is used to check the number of random samples in A′j of Stage 1 in the algorithm. We will use different ways to control the accuracy of approximation between the case Ai ≤ A1∪A2∪···∪Am It is mainly used in the proof of Lemma 15 that shows it keeps the accuracy of approximation when algorithm goes from Stage i to Stage i + 1. and the other case Ai > A1∪A2∪···∪Am f2(m) f2(m) . f2(m) = 2v(δ, zmin, zmax, L) ǫ3 + 2 log m zmin ǫ3 log(1 + δ) . (7) v. Function f3(.) is used as a threshold to count the number ti,j of random samples in Ri ∩ A′j of Stage i in the algorithm. We will use different ways to control the accuracy of approximation between the case ti,j ≤ f3(m) and the other case ti,j > f3(m). It is mainly used in the proof of Lemma 12 that shows that the number of random samples at Stage 1 will provide enough accuracy of approximation. f3(m) = f1(m) · 6 ln 2 γ2 ǫ2 2 . (8) vi. Function f4(.) is used to determine the growth rate of function Function f5(.), which is defined by equation (10). f4(m) = f2(m) log m2 ǫ1 6ǫ2 1 + f3(m) ǫ2f1(m) . (9) vii. Function f5(.) determines the number of random samples from the input sets in the beginning of the algorithm: f5(m) = mf4(m) zmin . (10) viii. The following parameter is also used to control failure probability in a stage of the algorithm: γ3 = γ2 2f5(m) . (11) ix. Function f6(.) affects the number of random indices in the range {1, 2,··· , m}. Those random indices will be used to choose input sets to detect the approximate T (x, L) for those random samples x: f6(m) = f1(m)(cid:18) 24 1 · ln ǫ2 2 γ3(cid:19) . (12) 9 Algorithm 1 ApproximateUnion(L, zmin, zmax, M, γ, ǫ) Input : L is a list of m sets A1, A2,··· , Am with m ≥ 2, mi ∈ [(1 − βL)Ai, (1 + βR)Ai] and (αL, αR)-biased random generator RandomElement(Ai) for i = 1, 2,··· , m, integers zmin and zmax with 1 ≤ zmin ≤ minT hickness(L) ≤ maxT hickness(L) ≤ zmax ≤ m, parameter γ ∈ (0, 1) to control the failure probability, parameter ǫ ∈ (0, 1) to control the accuracy of approximation, and M = m1 + m2 + ··· + mm as the sum of sizes of input sets. Output : sum · M. Let h1 = f5(m) Let i = 1 Let currentThickness1 = zmax Let s1 = Let s′1 = 1 Let sum = 0 Obtain a set R1 of h1 random choices of L (see Definition 9) Stage i currentT hickness1 m 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: Let ui = si · f6(m) Select ui random indices Hi = {k1,··· , kui} from {1, 2,··· , m} Compute S(x, Hi) for each x ∈ Ri Let Vi be the subset of Ri with elements x satisfying S(x, Hi) ≥ currentT hicknessi Let sum = sum + s′i Px∈Vi 2f1(m)·m S(x,Hi)m ui · ui m f1(m) currentT hicknessi+1 Let currentT hicknessi+1 = currentT hicknessi Let si+1 = Let hi+1 = h1 si+1 If (Ri − Vi < hi+1) Then { Let Ri+1 = Ri − Vi Let ai = 1 } Else { Let Ri+1 be a set of random hi+1 samples from Ri − Vi Let ai = Ri−Vi hi+1 } Let s′i+1 = s′i · ai Let i = i + 1 If (currentT hicknessi < zmin) Else Return sum · M and terminate the algorithm Enter the next Stage i We let M = m1 + m2 + ··· + mm and zmin be part of the input of the algorithm. It makes the algorithm be possible to run in a sublinear time when zmin ≥ ma for a fixed a > 0. Otherwise, the algorithm has to spend Ω(m) time to compute M . 4.3. Proof of Algorithm Performance The accuracy and complexity of algorithm ApproximateUnion(.) will be proven in the following lem- mas. Lemma 10 gives some basic properties of the algorithm. Lemma 12 shows that R1 has random 10 samples are used so that F (R1, h1, 1)(cid:18) m Pi=1 mi(cid:19) is an accurate approximation for Lemma 10. The algorithm ApproximateUnion(.) has the following properties: m Pi=1 Px∈Ai 1 T (x,L) . i. g∗(ǫ1) f4 (m) f2 (m) ≤ ǫ1 m2 . ii. v(δ, zmin, zmax, L) = O(cid:18) log zmax zmin δ (cid:19). iii. 2v(δ,zmin,zmax,L) f2(m) ≤ ǫ3 and f2(m) = O(cid:16) log m δǫ3 (cid:17). zmin iv. Ri contains at most hi items. ǫ4 (cid:16)log m zmin(cid:17) · log m · (log m)2(log 2 ǫ3 ǫ · (log m)3 + γ + log m + log f4(m))(cid:17). (log m)3(ln 1 γ +log m) (cid:19). f3 (m) v. g∗(ǫ2) f1 (m) ≤ γ2 2 . vi. f4(m) = O(cid:18) 1 vii. f6(m) = O(cid:16) mc1 ǫ2 Proof: The statements are easily proven according to the setting in the algorithm. Statement i: It follows from equations (2) and (9). Statement ii: By Definition 8, we need v(δ, zmin, zmax, L) with zmin(1 + δ)v(δ,zmin,zmax,L) ≥ zmax. Thus, we have v(δ, zmin, zmax, L) ≤ 2(cid:18) log zmax log(1+δ)(cid:19) = O(cid:18) log zmax δ (cid:19) since log(1 + δ) = Θ(δ). zmin zmin iii: It is easy to see that log(1 + δ) = Θ(δ) and 1 ≤ zmax ≤ m. It follows from Statement equation (7), and Statement ii. Statement iv: It follows from lines 19 to 27 in the algorithm. Statement v: It follows from equation (8). Statement vi: By equation (9), Statement iii and equation (3), we have f4(m) = f2(m) log m2 ǫ1 6ǫ2 1 + f3(m) ǫ2f1(m) f3(m) ǫ2f1(m)! 2 ! 1 ǫ2 · ln 2 γ2 ǫ2 + + m2 m2 ǫ2 ≤ 6f2(m) · log = O f2(m) · log = O 1 = O 1 = O 1 ǫ4 (cid:18)log ǫ0 (cid:19)2 ǫ1 ·(cid:18) log m ǫ0 (cid:19)2 1 ·(cid:18) log m m ǫ1 · (log m)2 + ) · log m ǫ1 · (log m)2 + m ǫ · (log m)3 + ) · log zmin(cid:19) · log m zmin m zmin δǫ3ǫ2 0 δǫ3ǫ2 0 (log (log m log m ǫ0 log m ǫ0 · · ln 2 γ2 ǫ2 ln 2 γ2 ǫ2 2 ! 2 ! (log m)3(ln 1 ǫ3 γ + log m) ! . 11 Statement vii: By equation (12), we have 2 ǫ2 1 γ3(cid:19) f6(m) = f1(m)(cid:18) 24 1 · ln ǫ2 = O(cid:18) mc1 γ3(cid:19) 2 · ln = O(cid:18) mc1 · (log m)2(log = O(cid:18) mc1 · (log m)2(log = O(cid:18) mc1 · (log m)2(log = O(cid:18) mc1 · (log m)2(log ǫ2 ǫ2 ǫ2 ǫ2 (13) (14) (15) (16) (17) (18) 2 γ2 2 γ2 2 γ2 2 γ + ln f5(m))(cid:19) + ln m + ln f4(m))(cid:19) + log m + log f4(m))(cid:19) + log m + log f4(m))(cid:19) . Lemma 11 gives an upper bound for the number of rounds for the algorithm. It shows how round complexity depends on zmax, zmin and f1(.). log f1(m)(cid:19). Lemma 11. The number of rounds of the algorithm is O(cid:18) log zmax zmin By line 3 of the algorithm, we have currentThickness1 = zmax. Variable Proof: currentThicknessi is reduced by a factor f1(m) each phase as currentThicknessi+1 = currentThicknessi by line 14 of the algorithm. By the termination condition of line 30 of the algorithm, if y is the number of phases of the algorithm, we have y ≤ y′, where y′ is any integer with zmax f1(m)y′ < zmin. Thus, y = O(cid:18) log zmax log f1(m)(cid:19). f1(m) zmin Lemma 12 shows the random samples, which are saved in R1 in the beginning of the algorithm, will be enough to approximate the size of set union via F (R1, h1, 1)M . In the next a few rounds, algorithm will approximate F (R1, h1, 1). Lemma 12. With probability at least 1−γ1, F (R1, h1, 1)M ∈ [ (1−ǫ0)(1−αL)(1−βL) ǫ0)(1 + αR)(1 + βR)(1 + δ)A1 ∪ ··· ∪ Am]. Let A = A1 ∪ ··· ∪ Am and U = A1 + A2 + ··· + Am. For an arbitrary set Ai in Proof: the list L, and an arbitrary element x ∈ Ai, with at least the following probability x is selected via RandomElement(Ai) at line 7 of Algorithm ApproximateUnion(.), A1∪···∪Am, (1+ 1+δ mi m1 + m2 + ··· + mm 1 − αL Ai ≥ = M (1 − βL)Ai 1 − αL Ai (1 − βL)(1 − αL) . M Similarly, with at most the following probability x is chosen via RandomElement(Ai) at line 7 of Algorithm ApproximateUnion(.), mi m1 + m2 + ··· + mm 1 + αR Ai ≤ = 12 (1 + βR)Ai 1 + αR Ai (1 + βR)(1 + αR) . M M Define ρL = 1 − (1 − βL)(1 − αL) and ρR = (1 + βR)(1 + αR) − 1. Each element x in A1 ∪ A2 ∪ ··· ∪ Am is selected with probability in h (1−ρL)T (x,L) Define T1 = nA′j : A′j ≤ A f2(m)o (see vi of Definition 8). Let tj = min(cid:8)T (x, L) : x ∈ A′j(cid:9). We discuss two cases: Case 1: A′j ∈ T1. When one element x is chosen, the probability that x ∈ A′j is in the range h (1−ρL)tjA′ . Since zmin ≤ minThickness(L), we have zmin ≤ minThickness(L) ≤ tj. It is easy to see that mA ≥ U . We have f2(m)o, and T2 = nA′j : A′j > A i. Let pj = (1+ρR)(1+δ)tj· A (1+ρR)(1+δ)tjA′ j , (1+ρR)T (x,L) i. f2 (m) j M M M M M , pjh1 = ≥ ≥ ≥ = (1 + ρR)(1 + δ)tj · A · (1 + ρR)(1 + δ) · f4(m)mA f2(m) M f2(m)M mf4(m) zmin (1 + ρR)(1 + δ) · f4(m)U f2(m)M (1 + ρR)(1 + δ) · f4(m) f2(m)(1 + βR) (1 + αR)(1 + δ) · f4(m) f2(m) . (19) Let ω1(m) = (1+αR)(1+δ)·f4(m) f2(m) . Thus, pjh1 ≥ ω1(m). Let R1,j be the elements of R1 and also in A′j . By Theorem 7, with probability at most Pj = 2 (by equation (7), equation (9) and inequality (19)), there are more f2 (m) g∗(1)pj·h1 ≤ g∗(1)ω1(m) ≤ γ1 2(1+ρR)(1+δ)tj· A than 2pjh1 = · h1 elements to be chosen from A′j into R1. Thus, M F ′(R1,j) ≤ 2pjh1 tj = 2(1 + ρR)(1 + δ) · A f2(m)M · h1, (20) with probability at most Pj to fail. Case 2: A′j ∈ T2. When h1 elements are selected to R1, let vj be the number of elements selected in A′j . When one element x is chosen, the probability that x ∈ A′j is in the range h (1−ρL)tjA′ (1+ρR)(1+δ)tjA′ j i. (1+ρR)(1+δ)tjA′ j (1−ρL)tjA′ j j M M , M and pj,2 = M . Let pj,1 = We have pj,1h1 = > ≥ (1 − ρL)tjA′j M (1 − ρL)tj M · h1 A f2(m) · h1 ≥ (1 − ρL)zminA · h1 f2(m)M = (1 − ρL)zminA · mf4(m) zminf2(m)M (1 − ρL)f4(m) f2(m)(1 + βR) . (21) 13 We have pj,2h1 = > ≥ = ≥ ≥ (1 + ρR)(1 + δ)tjA′j (1 + ρR)(1 + δ)tj · A M f2(m) · h1 M (1 + ρR)(1 + δ)zmin · A f2(m)M (1 + ρR)(1 + δ)zmin · A f2(m)M (1 + ρR)(1 + δ) · f4(m) f2(m)(1 + βR) · h1 · h1 mf4(m) · zmin (1 + αR)(1 + δ) · f4(m) f2(m) . (22) With probability at most g∗(ǫ3)pj,1·h1 ≤ γ1 (1 − ǫ3)(1 − ρL)tjA′j vj < M · h1 = (1 − ǫ3)(1 − ρL)tjh1 · A′j M . 4 (by equation (7), equation (9) and inequality (21)), With probability at most g∗(ǫ3)pj,2·h1 ≤ γ1 4 (by equation (7), equation (9) and inequality (22)), vj > (1 + ǫ3)(1 + ρR)(1 + δ)tjA′j M · h1 = (1 + ǫ3)(1 + ρR)(1 + δ)tj h1 · A′j M . Therefore, with probability at least 1 − γ1/2, we have vj ∈(cid:20)(1 − ǫ3)(1 − ρL)tjh1 · A′j M , (1 + ǫ3)(1 + ρR)(1 + δ)tjh1 · A′j M (cid:21) . (23) Thus, we have that there are sufficient elements of A′j to be selected with high probability, which follows from Theorem 6 and Theorem 7. In the rest of the proof, we assume that inequality (20) holds if the condition of Case 1 holds, and inequality (23) holds if the condition of Case 2 holds. 14 Now we consider F (R1, h1, 1) = j∈T2 Xx∈R1,j + XR1,j with A′ · h1 1 T (x, L)  vj tj  · h1 + XR1,j with A′ · h1(cid:19) j∈T2 1 T (x, L) 1 h1 Xx∈R1 j∈T1 Xx∈R1,j 1 1 1 + 1 1 h1 T (x, L) T (x, L) f2(m)M j∈T2 Xx∈R1,j h1   XR1,j with A′ 2(1 + ρR)(1 + δ)v(δ, zmin, zmax, L) · A h1 XR1,j with A′ h1   h1 (cid:18) 2(1 + ρR)(1 + δ)v(δ, zmin, zmax, L) · A h1   XR1,j with A′ 2(1 + ρR)(1 + δ)v(δ, zmin, zmax, L) · A 2(1 + ρR)(1 + δ)v(δ, zmin, zmax, L) · A f2(m)M f2(m)M 1 1 j∈T2 1 + f2(m)M = ≤ ≤ ≤ = M  (1 + ǫ3)(1 + ρR)(1 + δ)h1 · A′j  + XR1,j with A′ j∈T2 (1 + ǫ3)(1 + ρR)(1 + δ) · A′j M f2(m) 2v(δ, zmin, zmax, L) ≤ (cid:18) 2(1 + ρR)(1 + δ)v(δ, zmin, zmax, L) = (cid:18)1 + ǫ3 + A ≤ (1 + 2ǫ3)(1 + ρR)(1 + δ) M A ≤ (1 + ǫ0)(1 + ρR)(1 + δ) M f2(m) . + (1 + ǫ3)(1 + ρR)(1 + δ)(cid:19) A M (cid:19) (1 + ρR)(1 + δ) A M (24) (25) The transition from (24) to (25) is by Statement iii of Lemma 10. For the lower bound part, we have the following inequalities: 15 1 T (x, L) 1 h1 Xx∈R1 j∈T2 Xx∈R1,j 1 T (x, L)  vj (1 + δ)tj  (1 + δ)M A′j  (1 − ǫ3)(1 − ρL)h1 · A′j  (1 − ǫ3)(1 − ρL) A′j + (1 + δ)M j∈T1 j∈T2  XR1,j with A′ XR1,j with A′ XR1,j with A′ A − XR1,j with A′ j∈T1 A′j j∈T1 A′j  (cid:19) v(δ, zmin, zmax, L)A f2(m) (cid:19) (1 − ǫ3)(1 − ρL) (1 + δ) A M F (R1, h1, 1) = j∈T2 1 1 h1   XR1,j with A′ h1   XR1,j with A′ h1   XR1,j with A′ (1 + δ)M  (1 − ǫ3)(1 − ρL) (1 − ǫ3)(1 − ρL) 1 (1 + δ)M j∈T2 (1 − ǫ3)(1 − ρL) (1 + δ)M − ≥ ≥ ≥ = = = (1 + δ)M  (1 − ǫ3)(1 − ρL) (1 + δ)M (cid:18)A − (1 − ǫ3)(1 − ρL) v(δ, zmin, zmax, L) ≥ = (cid:18)1 − ≥ (1 − ǫ3) f2(m) (1 − ǫ3)(1 − ρL) A M (1 − ǫ0)(1 − ρL) (1 + δ) ≥ (1 + δ) A M . XR1,j with A′ j∈T2 A′j (26) (27) The transition from (26) to (27) is by Statement 3 of Lemma 10. Therefore, F (R1, h1, 1)M ∈ h (1−ǫ0)(1−ρL) (1+δ) A, (1 + ǫ0)(1 + ρR)(1 + δ)Ai. Lemma 13 shows that at stage i, it can approximate T (x, L) for all random samples with highest T (x, L) in Ri. Those random elements with highest T (x, L) will be removed in stage i so that the algorithm will look for random elements with smaller T (x, L) in the coming stages. Lemma 13. After the execution of Stage i, with probability at least 1 − γ2, we have the following three statements: i. Every element x ∈ Ri with T (x, L) ≥ currentThicknessi h(1 − ǫ1) T (x,L) ii. Every element x ∈ Vi with T (x, L) ≥ currentThicknessi m ui, (1 + ǫ1) T (x,L) m uii. 4f1(m) f1(m) algorithm. has S(x, Hi) ∈ , it satisfies the condition in line 12 of the 16 iii. Every element x ∈ Vi with T (x, L) < currentThicknessi 4f1(m) of the algorithm. , it does not satisfy the condition in line 12 It follows from Theorem 6 and Theorem 7. There are ui = sif6(m) indices are selected Proof: among {1, 2,··· , m}. Let p = T (x,L) m . Statment i: We have pui = T (x,L) m · sif6(m) ≥ currentThicknessi 4f1(m) m · sif6(m) = currentThicknessi · 1 4f1(m) · 1 m · m currentThicknessi · f6(m) = f6(m) 4f1(m) . ǫ1) T (x,L) (1 + ǫ1) T (x,L) With probability at most P1 = g∗(ǫ1)pui ≤ γ3 m ui. With probability at most P2 = g∗(ǫ1)pui ≤ γ3 There are at most hi elements in Ri by Statement iv of Lemma 10. Therefore, with probability 2 (by equations (8), and (12)), S(x, Hi) < (1 − 2 (by equations (8) and (12)), S(x, Hi) > m ui. at most hi(P1 + P2) ≤ h1(P1 + P2) ≤ h1 · γ3 = γ2 2 , S(x, Hi) 6∈(cid:20)(1 − ǫ1) T (x, L) m ui, (1 + ǫ1) T (x, L) m ui(cid:21) . Statement ii: This statement of the lemma follows from Statement i. Statement iii: This part of the lemma follows from Theorem 6 and Theorem 7. For x ∈ Vi . With probability at most g∗(1)pui ≤ γ3 with T (x, L) < currentThicknessi (by equations (8), and (12)), we have S(x, Hi) ≥ 2pui. There are at most hi elements in Ri by Statement iv of Lemma 10. Therefore, with probability at most h1 · γ3 ≤ γ2 2 , there exists one x ∈ Vi with T (x, L) < currentThicknessi , let p = currentThicknessi 4f1(m) 4f1(m) 2 4f1(m) to satisfy S(x, Hi) ≥ 2pui. Lemma 14. Let x and y be positive real numbers with 1 ≤ y. Then we have: i. 1 − xy < (1 − x)y. ii. If xy < 1, then (1 + x)y < 1 + 2xy. By Taylor formula, we have (1 − x)y = 1 − xy + y·(y−1) iii. If x1, x2 ∈ [0, 1), then 1 − x1 − x2 ≤ (1 − x1)(1 − x2), and (1 + x1)(1 + x2) ≤ 1 + 2x1 + x2. Proof: have (1 − x)y ≥ 1 − yx. Note that the function (1 + 1 We also have (1 + x)y ≤ (1 + x) 1 + x1 + x2 + x1x2 ≤ 1 + 2x1 + x2. It is trivial to verify Statement iii. 1 − x1 − x2 ≤ (1 − x1)(1 − x2). Clearly, (1 + x1)(1 + x2) = θ2 for some θ ∈ [0, x]. Thus, we z )z = e. x ·xy ≤ exy ≤ 1 + xy + (xy)2 ≤ 1 + 2xy. z )z is increasing, and limz→+∞(1 + 1 2 1 Lemma 15 shows that how to gradually approximate F (R1, h1, 1)M via several rounds. It shows that the left random samples stored in Ri+1 after stage i is enough to approximate F ′(Ri − Vi). Lemma 15. Let y be the number of stages. Let Vi be the set of elements removed from Ri in Stage i. Then we have the following facts: F (R1, h1, 1). i. With probability at least 1 − γ2, aiF ′(Ri+1) ∈ [(1 − ǫ1)F ′(Ri − Vi), (1 + ǫ1)F ′(Ri − Vi)], and ii. With probability at least 1 − 2yγ2, Py i=1 s′iF ′(Vi) ∈ [(1 − yǫ1)S, (1 + 2yǫ1)S], where S = Proof: Let h′i = hi −Vi. If an local is too small, it does not affect the global sum much. In Ri+1, we deal with the elements x of T (x, L) < currentThicknessi . By Lemma 13, with probability at least 1 − γ2, Ri − Vi does not contain any x with T (x, L) ≥ currentThicknessi in both Ri and A′j with multiplicity. Let ti,j be the number of elements of A′j in Ri with multiplicity. Let Bi,j be the set of elements f1(m) f1(m) . Statement i: We discuss two cases: 17 algorithm (line (19) to line (22)). Case 1: Ri − Vi < hi+1. This case is trivial since Ri+1 = Ri − Vi and ai = 1 according to the In the following Case 2, we assume the condition of Case 1 is false. Thus, h′i ≥ hi+1. Case 2: Ri − Vi ≥ hi+1. We have F ′(Ri − Vi) ≥ currentThicknessi currentThicknessi hi+1 ≥ h′i f1(m) f1(m) = h1 si+1 · f1(m) currentThicknessi = f4(m) zmin . (28) Two subcases are discussed below. Subcase 2.1: ti,j ≤ f3(m), in this case, Bi,j has a small impact for the global sum. Let p = f3(m) . By Theorem 6 and Theorem 7, with probability at least 1 − g∗(1)phi+1 = h′ i 1 − g∗(1) f3 (m) f1 (m) ≥ 1 − γ2 2 (by equation (8)), f3(m) Bi+1,j ≤ 2phi+1 = 2 · h′i We assume Bi+1,j ≤ 2f3(m) hi h′i ≤ f1(m)2 . We have F ′(Bi+1,j ) ≤ Bi+1,j zmin ≤ 2f3(m) 2f3(m) f1(m) · 2f3(m) f1(m) · f1(m) hi = · hi hi+1 ≤ 2f3(m) f1(m)2 . zminf1(m)2 . Clearly, ai ≤ f1(m). Thus, aiF ′(Bi+1,j) ≤ f1(m) · 2f3(m) zminf1(m) 2f3(m) zminf1(m)2 = f4(m) zmin 2f3(m) 2f3(m) f4(m)f1(m) · f1(m)f4(m) · F ′(Ri − Vi) 2ǫ2 · F ′(Ri − Vi) v(δ, zmin, zmax, L) . = ≤ ≤ (29) (30) (31) The transition from (29) to (30) is by inequality (28). The transition from (30) to (31) is by inequality (9). Subcase 2.2: ti,j > f3(m) in Ri, in this case, B′j does not lose much accuracy. From Ri to Ri+1, hi+1 = hi f1(m) elements are selected. Let q = ti,j h′ i . We have qhi+1 = ti,j h′i · hi+1 = ti,j · hi+1 h′i ≥ ti,j · hi+1 hi ≥ f3(m) f1(m) . (32) With probability at most g∗(ǫ2)qhi+1 ≤ γ2 2 (by inequality (32) and Statement v of Lemma 10), we have that Bi+1,j < (1− ǫ2)qhi+1. With probability at most g∗(ǫ2)qhi+1 ≤ γ2 2 (by inequality (32) and Statement v of Lemma 10), we have that Bi+1,j > (1 + ǫ2)qhi+1. They follow from Theorem 6 and Theorem 7. We assume Bi+1,j ∈ [(1 − ǫ2)qhi+1, (1 + ǫ2)qhi+1]. Thus, aiF ′(Bi+1,j ) ∈ [(1−ǫ2)ti,j , (1+ǫ2)ti,j ]. So, aiF ′(Bi+1,j ) ∈h (1−ǫ2)F ′(Ri,j ) We have 1+δ , (1 + ǫ2)F ′(Ri,j)(1 + δ)i. 18 aiF ′(Ri+1) = ai Xj F ′(Bi+1,j )  ≤ (1 + ǫ2)(1 + δ)F ′(Ri − Vi) + ≤ ((1 + ǫ2)(1 + δ) + 2ǫ2)F ′(Ri − Vi) ≤ (1 + 4ǫ2)F ′(Ri − Vi) ≤ (1 + ǫ1)F ′(Ri − Vi). 2ǫ2F ′(Ri − Vi) v(δ, zmin, zmax, L) · v(δ, zmin, zmax, L) The transition from (33) to (34) is by inequality (31). The transition from (35) to (36) is based on equation (4). The transition from (36) to (37) is based on equations (3). We have (33) (34) (35) (36) (37) (38) (39) (40) (41) (42) aiF ′(Ri+1) = ai Xj F ′(Bi+1,j)  (1 − ǫ2)F ′(Ri − Vi) − (1 + δ) − 2ǫ2(cid:19) F ′(Ri − Vi) ≥ ≥ (cid:18) (1 − ǫ2) ≥ (1 − 4ǫ2)F ′(Ri − Vi) ≥ (1 − ǫ1)F ′(Ri − Vi). (1 + δ) 2ǫ2F ′(Ri − Vi) v(δ, zmin, zmax, L) · v(δ, zmin, zmax, L) The transition from (38) to (39) is based on inequality (31). The transition from (41) to (42) is based on equations (3). Statement ii: In the rest of the proof, we assume that if Ri − Vi ≥ hi+1, then F ′(Ri+1) = F ′(Ri − Vi), and if Ri − Vi < hi+1, then aiF ′(Ri+1) ∈ [(1 − ǫ1)F ′(Ri − Vi), (1 + ǫ1)F ′(Ri − Vi)]. In order to prove Statement ii, we give an inductive proof that s′k+1F ′(Rk+1) +Pk i=1 s′iF ′(Vi) ∈ [(1 − ǫ1)kS, (1 + ǫ1)kS]. It is trivial for k = 0. Assume that s′kF ′(Rk) +Pk−1 i=1 s′iF ′(Vi) ∈ [(1 − Since F ′(Rk) = F ′(Rk − Vk) + F ′(Vk), we have akF ′(Rk+1) + F ′(Vk) ∈ [(1 − ǫ1)F ′(Rk), (1 + Thus, we have ǫ1)k−1S, (1 + ǫ1)k−1S]. ǫ1)F ′(Rk)]. s′k+1F ′(Rk+1) + k Xi=1 s′iF ′(Vi) = s′k+1F ′(Rk+1) + s′kF ′(Vk) + = s′k(akF ′(Rk+1) + F ′(Vk)) + siF ′(Vi) siF ′(Vi) k−1 Xi=1 Xi=1 k−1 Xi=1 ≤ (1 + ǫ1)s′kF ′(Rk) + ≤ (1 + ǫ1) s′kF ′(Rk) + Xi=1 ≤ (1 + ǫ1)kS. k−1 k−1 siF ′(Vi) siF ′(Vi)! 19 Similarly, we have s′k+1F ′(Rk+1) + k Xi=1 s′iF ′(Vi) = s′k+1F ′(Rk+1) + skF ′(Vk) + = s′k (akF ′(Rk+1) + F ′(Vk)) + s′iF ′(Vi) s′iF ′(Vi) k−1 Xi=1 Xi=1 k−1 Xi=1 ≥ (1 − ǫ1)s′kF ′(Rk) + ≥ (1 − ǫ1) s′kF ′(Rk) + Xi=1 ≥ (1 − ǫ1)kS. Thus, we have s′k+1F ′(Rk+1) +Pk Therefore, with probability at least 1 − yγ2 − yγ2, Py [(1 − ǫ1y)S, (1 + 2ǫ1y)S] by Lemma 14. i=1 s′iF ′(Vi) ∈ [(1 − ǫ1)kS, (1 + ǫ1)kS]. k−1 k−1 s′iF ′(Vi) s′iF ′(Vi)! i=1 s′iF ′(Vi) ∈ [(1 − ǫ1)yS, (1 + ǫ1)yS] ⊆ Lemma 16 gives the time complexity of the algorithm. The running time depends on several parameters. Lemma 16. The algorithm ApproximateUnion(.) runs in O(cid:18) mf4(m)f6(m) log f1(m)(cid:19)(cid:19) time. ·(cid:18) log zmax log f1(m)(cid:19). Let y be the total number of stages. By Lemma 11, we have y = O(cid:18) log zmax Proof: zmin zmin zmin The time of each stage is ti = hi · ui = h1f6(m) = m ti ≤ m of the algorithm. Therefore, the total time is y zmin zmin · f4(m)f6(m)y. f4(m)f6(m), which is mainly from line 12 Pi=1 We have Theorem 17 to show the performance of the algorithm. The algorithm is sublinear if minThickness(L) ≥ ma for a fixed a > 0, and has a zmin with minThickness(L) ≥ zmin ≥ mb for a positive fixed b (b may not be equal to a) to be part of input to the algorithm. log f1(m)(cid:19)(cid:19) time and ·(cid:18) log zmax Theorem 17. The algorithm ApproximateUnion(.) takes O(cid:18) mf4(m)f6(m) O(cid:18) log zmax log f1(m)(cid:19) rounds such that with probability at least 1 − γ, it gives a sum · M ∈ [(1 − ǫ)(1 − αL)(1 − βL) · A1 ∪ ··· ∪ Am, (1 + ǫ)(1 + αR)(1 + βR) · A1 ∪ ··· ∪ Am], where zmin and zmax are parameters with 1 ≤ zmin ≤ minThickness(L) ≤ maxThickness(L) ≤ zmax ≤ m, where functions f1(.), f4(.), and f6(.) are defined in equations (9), (6), and (12), respectively. zmin zmin zmin Proof: Let y be the number of stages. By Lemma 13, with probability at least 1 − yγ2, sum ∈"(1 − ǫ1) y Xi=1 s′iF ′(Vi), (1 + ǫ1) s′iF ′(Vi)# . y Xi=1 By Lemma 15, with probability at least 1 − 2yγ2, y s′iF ′(Vi) ∈ [(1 − yǫ1) F (R1, h1, 1), (1 + 2yǫ1) F (R1, h1, 1)] . Xi=1 20 By Lemma 12, with probability at least 1 − γ1, F (R1, h1, 1) m Xi=1 mi! ∈ [ (1 − ǫ0)(1 − αL)(1 − βL) 1 + δ A1 ∪ ··· ∪ Am, (1 + ǫ0)(1 + αR)(1 + βR)(1 + δ)A1 ∪ ··· ∪ Am]. Therefore, with probability at least 1 − γ1 − 2yγ2, sum · M ∈ [ (1 − yǫ1)(1 − ǫ0)(1 − ǫ1)(1 − αL)(1 − βL) 1 + δ · A1 ∪ ··· ∪ Am, (1 + 2yǫ1)(1 + ǫ0)(1 + ǫ1)(1 + αR)(1 + βR)(1 + δ)A1 ∪ ··· ∪ Am]. Now assume sum · M ∈ [ (1 − yǫ1)(1 − ǫ0)(1 − ǫ1)(1 − αL)(1 − βL) (1 + 2yǫ1)(1 + ǫ0)(1 + ǫ1)(1 + αR)(1 + βR)(1 + δ)A1 ∪ ··· ∪ Am]. · A1 ∪ ··· ∪ Am, 1 + δ By Statement iii of Lemma 14, we have 1 − ǫ ≤ 1 − yǫ1 − ǫ0 − 9 8 ǫ1 ≤ (1 − yǫ1)(1 − ǫ0)(cid:18)1 − 9 8 ǫ1(cid:19) ≤ (1 − yǫ1)(1 − ǫ0) (1 − ǫ1) 1 + δ , and (1 + 2yǫ1)(1 + ǫ0)(1 + ǫ1)(1 + δ) ≤ (1 + 2yǫ1)(1 + 2ǫ0 + ǫ1)(1 + δ) ≤ (1 + 2yǫ1)(1 + 4ǫ0 + 2ǫ1 + δ) ≤ (1 + 8ǫ0 + 4ǫ1 + 2δ + 2yǫ1) ≤ (1 + 8ǫ0 + 4ǫ1 + ǫ2 + 2yǫ1) ≤ (1 + 8ǫ0 + ǫ0 3 ) ≤ 1 + 9ǫ0 ≤ 1 + ǫ. Therefore, 3 + ǫ0 3 + ǫ0 sum · M ∈ [(1 − ǫ)(1 − αL)(1 − βL) · A1 ∪ ··· ∪ Am, (1 + ǫ)(1 + αR)(1 + βR) · A1 ∪ ··· ∪ Am]. The algorithm may fail at the case after selecting R1, or one of the stages. By the union bound, the failure probability is at most γ1 + 2γ2 · log m ≤ γ. We have that with probability at least 1 − γ to output the sum that satisfies the accuracy described in the theorem. The running time and the number of rounds of the algorithm follow from Lemma 16 and Lemma 11, respectively. Since 1 ≤ zmin ≤ minThickness(L) ≤ maxThickness(L) ≤ zmax ≤ m, we have the following Corollary 18. Its running time is almost linear in the classical model. ǫ , log 1 Corollary 18. There is a O(poly( 1 γ ) · m · (log m)O(1)) time and O(log m) rounds algo- rithm for A1 ∪ A2 ∪ ··· Am such that with probability at least 1 − γ, it gives a sum · M ∈ [(1 − ǫ)(1 − αL)(1 − βL) · A1 ∪ ··· ∪ Am, (1 + ǫ)(1 + αR)(1 + βR) · A1 ∪ ··· ∪ Am]. Proof: We let f1(m) = 8 with c1 = 0 in equation (6). Let zmin = 1 and zmax = m. It follows from Theorem 17 and Statements vi and vii of Lemma 10 as we have the inequality (43): (cid:18) mf4(m)f6(m) zmin ·(cid:18) log zmax log f1(m)(cid:19)(cid:19) = O(poly( zmin 1 ǫ , log 1 γ ) · m · (log m)O(1)). (43) Corollary 19. For each ξ > 0, there is a O(poly( 1 ξ ) rounds al- gorithm for A1 ∪ A2 ∪ ··· Am such that with probability at least 1 − γ, it gives a sum · M ∈ [(1 − ǫ)(1 − αL)(1 − βL) · A1 ∪ ··· ∪ Am, (1 + ǫ)(1 + αR)(1 + βR) · A1 ∪ ··· ∪ Am]. γ ) · m1+ξ) time and O( 1 ǫ , log 1 21 Proof: We let f1(m) = 8mξ/2 with c1 = ξ follows from Theorem 17 and Statements vi and vii of Lemma 10 as we have the inequality (44): 2 in equation (6). Let zmin = 1 and zmax = m. It (cid:18) mf4(m)f6(m) zmin ·(cid:18) log zmax log f1(m)(cid:19)(cid:19) = O(poly( zmin 1 ǫ , log 1 γ ) · m1+ξ). (44) An interesting open problem is to find an O(m) time and O(log m) rounds approximation scheme for A1 ∪ A2 ∪ ··· Am with a similar accuracy performance as Corollary 18. We were not able to adapt the method from Karp, Luby, and Madras [29] to solve this problem. 5. Approximate Random Sampling for Lattice Points in High Dimensional Ball In this section, we propose algorithms to approximate the numebr of lattice points in a high dimen- sional ball, and also develop algorithms to generate a random lattice point inside a high dimensional ball. Before present the algorithms, some definitions are given below. Definition 20. Let integer d > 0 be a dimensional number, Rd be the d−dimensional Euclidean Space. i. For two points p, q ∈ Rd, define p − q to be Euclidean Distance. ii. A point p ∈ Rd is a lattice point if p = (y1, ..., yd) with yi ∈ Z for i = 1, 2, ..., d. iii. Let p ∈ Rd, and r > 0. Define Bd(r, p, d) be a d−dimensional ball of radius r with center at p. iv. Let q = (µ1, µ2, ..., µd) ∈ Rd. Define Bd(r, q, k) = {(z1, z2, ..., zd) ∈ Rd : z1 = µ1, ..., zd−k = µd−k and (µi − zi)2 ≤ r2}. d Pi=1 v. Let p ∈ Rd, and r > 0. Define C(r, p, d) be the number of lattice points in the d−dimensional ball of radius r with the center at p. vi. Let λ, l be real numbers. Define D(λ, d, l) = {(x1,··· , xd) : (x1,··· , xd) with xk = ik + jkλ for an integer jk ∈ [−l, l], and another arbitrary integer ik for k = 1, 2, ..., d}. vii. Let λ, l be real numbers. Define D∗(λ, d, l) = {(x1,··· , xd) : (x1,··· , xd) with xk = jkλ for an integer jk ∈ [−l, l] with k = 1, 2, ..., d}. viii. Let λ = a−m, where a and m are integer and a ≥ 2. Define D∗∗(λ, d) = {(x1,··· , xd) : (x1,··· , xd) with xk = ik + jkλ for an integer jk ∈ [−λ−1 + 1, λ−1 − 1], and another arbitrary integer ik for k = 1, 2, ..., d}. 5.1. Randomized Algorithm for Approximating Lattice Points for High Dimensional Ball In this section, we develop algorithms to approximate the number of lattice points in a d-dimensional ball Bd(r, p, d). Two subsubsections are discussed below. 22 5.1.1. Counting Lattice Points of High Dimensional Ball with Small Radius In this section, we develop a dynamic programming algorithm to count the number of lattice points in d−dimensional ball Bd(r, p, d). Some definitions and lemmas that is used to prove the performance of algorithm are given before present the algorithm. Definition 21. Let p be a point in Rd, and p ∈ D(λ, d, L). Define E(r′, p, h, k) be the set of k−dimensional balls Bd(r′, q, k) of radii r′ with center at q = (y1, y2, ..., yh, xh+1, ..., xd) where h = d − k is the number of initial integers of the center q and yt ∈ Z for t = 1, 2, ..., h. Lemma 22 shows that for any two balls with same dimensional number, if their radii equal and the number of initial integers of their center also equal, then they have same number of lattice points. Lemma 22. For two k−dimensional balls Bd(r, q, k) and Bd(r, q′, k), if Bd(r, q, k) ∈ E(r, p, h, k) and Bd(r, q′, k) ∈ E(r, p, h, k), then C(r, q, k) = C(r, q′, k). In order to prove that C(r, q, k) = C(r, q′, k), we need to show that there is a bijection Proof: bewtten the set of of lattice points inside ball Bd(r, q, k) and the set of lattice points inside ball Bd(r, q′, k), where q = (y1, y2, ..., yh, xh+1, ..., xd) and q′ = (y′1, y′2, ..., y′h, xh+1, ..., xd) with y′t, yt ∈ Z for t = 1, 2, ..., h. Statement 1: ∀ q1 = (z1, z2, ..., zd) ∈ Bd(r, q, k), where zt ∈ Z for t = 1, 2, ..., d. we have (z1 − y1)2 + ··· + (zh − yh)2 + (zh+1 − xh+1)2 + ··· + (zd − xd)2 ≤ r2 then (z1 + y′1 − y1 − y′1)2 + ··· + (zh + y′h − yh − y′h)2 + (zh+1 − xh+1)2 + ··· + (zd − xd)2 ≤ r2. Therefore, there exists a lattice point (z1 + y′1 − y1, ..., zh + y′h − yh, zh+1, ..., zd) ∈ Bd(r, q′, k) Statement 2: ∀ q′1 = (z′1, z′2, ..., z′d) ∈ Bd(r, q′, k), where z′t ∈ Z for t = 1, 2, ..., d. we have correspoding to q1. (z′1 − y′1)2 + ··· + (z′h − y′h)2 + (z′h+1 − xh+1)2 + ··· + (z′d − xd)2 ≤ r2 and (z′1 − y′1 + y1 − y1)2 + ··· + (z′h − y′h + yh − yh)2 + (z′h+1 − xh+1)2 + ··· + (z′d − xd)2 ≤ r2. Therefore, there exists a lattice point (z′1 − y′1 + y1, ..., z′h − y′h + yh, z′h+1, ..., z′d) ∈ Bd(r, q, k) Based on above two statements, there exists a bijection between the set of lattice points inside correspoding to q′1. ball Bd(r, q, k) and the set of lattice points inside ball Bd(r, q′, k). Therefore, C(r, q, k) = C(r, q′, k). Lemma 23 shows that we can move ball Bd(r, q, k) by an integer units in every dimension without changing the number of lattice points in the ball. Lemma 23. Let λ be a real number. For two k−dimensional balls Bd(r, q1, k) and Bd(r, q2, k), where q1 = (y1, y2, ..., yd−k, xd−k+1, ..., xd), q2 = (y′1, y′2, ..., y′d−k, x′d−k+1, ..., x′d) with yt, y′t ∈ Z, t = 1, 2, ..., d − k, and xt′ = it′ + jt′ λ, it′ is an integer and jt′ ∈ [−l, l] for t′ = d − k + 1, ..., d, if x′t′ = jt′ λ, then we have C(r, q1, k) = C(r, q2, k). Proof: C(r, q1, k) = C(r, q2, k) via Lemma 22. Since Bd(r, q1, k) ∈ E(r, p, h, k) and Bd(r, q2, k) ∈ E(r, p, h, k) with h = d − k, we have We define R(r, p, d) be a set of radii r′ for the balls that generated by the intersection of Bd(r, p, d) wiht hyper-plane x1 = y1, ..., xk = yk, ..., xd = yd. 23 Definition 24. For a d−dimensional ball Bd(r, p, d) of radius r with center at p = (x1, x2, ..., xd). i. Define R(r, p, d) = {r′ : r′2 = r2 − r2 f or some integer k ∈ [1, d]}. k (yi − xi)2 with yi ∈ Z and Pi=1 k (yi − xi)2 ≤ Pi=1 Lemma 25 shows that we can reduce the cardinality of R(r, p, d) from exponentional to polynomial when setting the element of the ball's center has same type (i.e. p ∈ D(λ, d, l).) Lemma 25. Let Bd(r, p, d) be a d−dimensional ball of radius r with center at p, where p ∈ D∗(λ, d, l), then R(r, p, d) ≤ 4(r + lλ)3l3d3 and R(r, p, d) can be generated in O(cid:0)(r + lλ)3l3d3(cid:1) time. Proof: Since r′2 = r2 − k r′2 (yi − xi)2 for 0 ≤ k ≤ d, we have r′ as: Pi=1 = r2 − (y1 − j1λ)2 − ··· − (yd − jdλ)2 1 − 2y1j1λ + j2 = r2 − [y2 1 λ2] − ··· − [y2 = r2 − {y2 2 + ··· + y2 1 + y2 d} +{2y1j1 + 2y2j2 + ··· + 2ydjd}λ −{j2 3 + ··· + j2 d}λ2. 2 + j2 1 + j2 d − 2ydjdλ + j2 dλ2] Let R′ = {r′r′2 = r2 − (x + yλ + zλ2) with x, y, and z is nonnegative integer}, it is easy to Let see that r′ ∈ R′ then R ⊆ R′. 1 + y2 2 + ... + y2 X = {x′x′ = y2 Y = {y′y′ = 2y1j1 + 2y2j2 + ... + 2ydjd with yiji ∈ [I(r − lλ), I(r + lλ)], 0 ≤ i ≤ d} Z = {z′z′ = j2 d with yi ∈ [r − lλ, r + lλ], 0 ≤ i ≤ d} d with ji ∈ [−l, l], 0 ≤ i ≤ d}, 3 + ... + j2 1 + j2 2 + j2   then we have: (45) Z ≤ dl2 Y ≤ 4d(r + lλ)l X ≤ d(r + lλ)2.   For each r′ ∈ R, we have r′2 = r2 − (x + yλ + zλ2) with x ∈ X, y ∈ Y , and z ∈ Z. Therefore, R ≤ dl2 · 4d(r + lλ)l · d(r + lλ)2 = 4(r + lλ)3l3d3 via inequality (45). Then R(r, p, d) can be generated in O(cid:0)(r + lλ)3l3d3(cid:1) time. Lemma 26 is a spacial case of Lemma 25. It shows that there at most (r2 + 1)a2m cases of the radii when the elements of the center are the type like fractions in base a. For example, p = (3.891, 5.436, ..., 5.743) ∈ Rd. Lemma 26. Let λ = a−m where a is a interger with a ≥ 2. Let Bd(r, p, d) be a d−dimensional ball of radius r with center at p ∈ D∗∗(λ, d), then R(r, p, d) ≤ (r2 + 1)a2m and R(r, p, d) can be generated in O(cid:0)(r2 + 1)a2m(cid:1) time. Proof: We have r′2 = r2 − (y1 − j1λ)2 − ··· − (yd − jdλ)2 1 λ2] − ··· − [y2 1 − 2y1j1λ + j2 = r2 − [y2 = r2 − {y2 2 + ··· + y2 1 + y2 d} +{2y1j1 + 2y2j2 + ··· + 2ydjd}λ −{j2 3 + ··· + j2 d}λ2 2 + j2 1 + j2 d − 2ydjdλ + j2 dλ2] 24 via Lemma 25. For each r′2, it can be transformed into r′2 = r2 − (x + yλ + zλ2) with x, y and z are integers, and (46) z ≤ am y ≤ am x ≤ (r2 + 1).   Therefore, R ≤ (r2 + 1)a2m via inequality (46). Then R(r, p, d) can be generated in O(cid:0)(r2 + 1)a2m(cid:1) time. Definition 27. For a d−dimensional ball Bd(r, p, d) of radius r with center at p = (x1, x2, ..., xd). i. Define p[k] = (0, ..., 0, xk+1, ..., xd) for some integer k ∈ [1, d]. ii. Define Z(r, x, t) with Z(r, x, t)2 = r2 − (t − x)2 if t − x ≤ r, where t is a integer and x ∈ R. We give a dynamic programming algorithm to count the number of lattice points in a d−dimensional ball Bd(r, p, d). Algorithm 2 CountLatticePoint(r, p, d) Input : p = (x1, x2, ..., xd) where xk = ik + jkλ for an integer jk ∈ [−l, l], and another arbitrary integer ik for k = 1, 2, ..., d. r is radius and d is dimensional numbers. Output : The number of lattice points of the d−dimensional ball Bd(r, p, d). 1: 2: 3: 4: 5: 6: Let r0 = r For k = d − 1 to 0 for each rk ∈ R(r, p, d) (k + 1)) Return C(r0, p[0], d) let C(rk, p[k], d − k) = P save C(rk, p[k], d − k) to the look up table t∈Z and t∈[−rk+xk+1, rk+xk+1] C(z(rk, xk+1, t), p[k + 1], d − We note that if d − (k + 1) = 0 then C(z(rk, xk+1, t), p[k + 1], d − (k + 1)) = 1, otherwise z(rk, xk+1, t) is in R(r, p, d) (i.e. C(z(rk, xk+1, t), p[k + 1], d − (k + 1)) is avaiable in the table). Theorem 28. Assume λ be a real number and p ∈ D(λ, d, l), then there is a O(r(r + lλ)3l3d4) time algorithm to count C(r, p, d). Proof: Line 4 has at most 2⌊r⌋ + 1 items to add up. Line 2 has d iterations, Line 3 takes 4(r + lλ)3l3d3 to compute rk via Lemma 25, and Therefore, the algorithm CountLatticePoints(.) takes O(r(r + lλ)3l3d4) running time. Remark: When λ = 1 π , this is a specail case of Theorem 28, and the running time of the algorithm is O(r(r + lλ)3l3d4). The algorithm can count the lattice points of high dimensional ball if the element of the center of the ball has same type like i + jλ even though λ is a irrational number. Theorem 29 shows that the algorithm can count the number of lattice points of high dimensional ball if the element of the center of the ball has same type like fractions in base a. Theorem 29. Assume λ = a−m and p ∈ D∗∗(λ, d), where m and a are integers with a ≥ 2, then there is a O(r3a2md) time algorithm to count C(r, p, d). 25 Line 2 has d iterations, Line 3 takes (r2 + 1)a2m to compute rk via Lemma 26, and Line 4 Proof: has at most 2⌊r⌋ + 1 items to add up. Therefore, the algorithm CountLatticePoints(.) takes O(rd(r2 + 1)a2m) running time. Corollary 30. Assume λ = 10−m and p ∈ D∗∗(λ, d), where m is a integer, then there is a O(r3102md) time algorithm to count C(r, p, d). 5.1.2. Approximating Lattice Points in High Dimensional Ball with Large Radius In this section, we present an (1 + β)-approximation algorithm to approximate the number of lattice points in a d−dimensional ball Bd(r, p, d) of large radius with an arbitrary center p, where β is used to control the accuracy of approximation. Some definitions are presented before prove theorems. Definition 31. For each lattice point q = (y1, y2, ..., yd) ∈ Rd with yi ∈ Z for i = 1, 2, ..., d. 2 , ..., yd + 1 i. Define Cube(q) to be the d−dimensional unit cube with center at (cid:0)y1 + 1 2(cid:1) . ii. Define I(Bd(r, p, d)) = {q Cube(q) ⊂ Bd(r, p, d)}. iii. Define E(Bd(r, p, d)) = {q Cube(q) /∈ I(Bd(r, p, d)) and Cube(q) ∩ Bd(r, p, d) 6= ∅}. Theorem 32 gives an (1 + β)−approximation with running time O(d) algorithm to approximate the number of lattice point C(r, p, d) with p is an arbitrary center and r > 2d 3 2 β . Theorem 32. For an arbitrary β ∈ (0, 1), there is a (1 + β)−approximation algorithm to compute C(r, p, d) of d−dimensional ball Bd(r, p, d) with running time O(d) for an arbitrary center p when r > 2d 3 2 β . Let I(Bd(r, p, d)) be the number of lattice points q ∈ I(Bd(r, p, d)), E(Bd(r, p, d)) be Proof: the number of lattice points q ∈ E(Bd(r, p, d)), and Vd(r) be the volume of a d−dimensional ball with radius r. Now consider two d−dimensional balls Bd(r − √d, p, d) and Bd(r + √d, p, d) that have the same center as ball Bd(r, p, d). Since every lattice point q corresponds to a Cube(q) via Definition 31, then we have: (cid:26) Vd(r − √d) ≤ I(Bd(r, p, d)) ≤ Vd(r) 0 ≤ E(Bd(r, p, d)) ≤ Vd(r + √d) − Vd(r). Therefore, Vd(r − √d) ≤ C(r, p, d) = I(Bd(r, p, d)) + E(Bd(r, p, d)) ≤ Vd(r + √d). Then the bias is I(Bd(r,p,d))+E(Bd(r,p,d)) Vd(r) when using Vd(r) to approximate C(r, p, d). The volume formula for a d − dimensional ball of raduis r is Vd(r) = f (d) · rd 26 where f (d) = π d 2 Γ(cid:0) 1 2 d + 1(cid:1)−1 I(Bd(r, p, d)) + E(Bd(r, p, d)) ≤ Vd(r) Vd(r) and Γ(.) is Euler's gamma function. Then Vd(r + √d) f (d) · (r + √d)d = 1 + ≤ e ≤ 1 + f (d) · rd √d r !d 2d r = 3 2 r 3 2 . d Similarly, we have I(Bd(r, p, d)) + E(Bd(r, p, d)) Vd(r) = ≥ Vd(r) Vd(r − √d) f (d) · (r − √d)d = 1 − ≥ 1 − f (d) · rd √d r !d 3 2 d r 2d r 3 2 . From above two inequalities, we have ≥ 1 − 1 − 2d 3 2 r ! · Vd(r) ≤ C(r, p, d) ≤ 1 + 2d 3 2 r ! · Vd(r), then we have 1 1 + 2d r · C(r, p, d) ≤ Vd(r) ≤ 3 2 1 1 − 2d r 3 2 · C(r, p, d). Simplify the above inequality, we have 3 2 2d r − 2d 3 2! C(r, p, d) ≤ Vd(r) ≤ 1 + 3 2 2d r − 2d 3 2! C(r, p, d). (1 − β)C(r, p, d) ≤ Vd(r) ≤ (1 + β)C(r, p, d) (47) 1 − . 3 2 Thus, we have 3 2 with β > 2d r−2d d It takes O(d) to compute Vd(r) = f (d) · rd, since it takes O(d) to compute f (d) where f (d) = 2 d + 1(cid:1)−1 2 Γ(cid:0) 1 . Therefore, the algorithm takes O(d) running time to approximate C(r, p, d) becasue π of Equation (47). 27 Theorem 33. There is an (1 + β)-approximation algorithm with running time O(d) to approximate C(r, p, d) of Bd(r, p, d) with an arbitrry center p when r > 2d β ; and there is an dynamic programming 3 2 algorithm with running time O 1 when r ≤ 2d Proof: We discuss two cases based the radius of the d-dimensional ball. β + lλ(cid:19)3! to count C(r, p, d) with center p ∈ D(λ, d, l) 2 l3(cid:18) 2d β . β d 11 3 2 3 2 Case 1: When counting the number of lattice points of a d-dimensional ball with center p ∈ Case 2: When approximating the number of lattice points of a d-dimensional ball with an 3 2 D(λ, d, l) for r ≤ 2d arbitrary center p for r > 2d 3 2 β , apply Theorem 28. β , apply Theorem 32. Corollary 34. There is a dynamic programming algorithm to count C(r, p, d) of Bd(r, p, d) with running time O 1 β d 11 2 l3(cid:18) 2d 3 2 β + lλ(cid:19)3! for p ∈ D(λ, d, l) when r ≤ 2d 3 2 β . 5.2. A Randomized Algorithm for Generating Random Lattice Point of High Dimensional Ball In this section, we propose algorithms to generate a random lattice point inside a high dimensional ball. Two subsections are discussed below. 5.2.1. Generating a Random Lattice Point inside High Dimensional Ball with Small Radius In this section, we develop a recursive algorithm to generate a random lattice point inside a d−dimensional ball Bd(r, p, d) of small radius with center p ∈ D(λ, d, l). generate a random lattice point in the ball Bd(r, p, t). The purpose of the algorithm RecursiveSmallBallRandomLatticePoint(r, p, t, d) is to recursively Algorithm 3 RecursiveSmallBallRandomLatticePoint(r, p, t, d) Input : p = (y1, y2, ..., yd−t, xd−t+1, ..., xd) where xk = ik + jkλ with arbitrary integer ik, integer jk ∈ [−l, l], and yi ∈ Z, i = 1, 2, ..., d − t, t is a dimension number with 0 ≤ t ≤ d. Output : Generate a random lattice point inside t−dimensional ball. table C-Table by using Algorithm Save C(rk, p[k], d − k) If t = 0 CountLatticeP oint(r, p, d) for k = 0, 1, ..., d − 1 look into up Return lattice point (y1, y2, ..., yd) Else Return RecursiveSmallBallRandomLatticePoint(r′, q, t − 1, d) with probability , where q = (y1, y2, ..., yd−t, yd−t+1, xd−t+2, ..., xd) with yd−t+1 ∈ [xd−t+1−r, xd−t+1+r] C(r,p,t) C(r′,q,t−1) satisfying p − q2 ≤ r2, and r′2 = r2 − p − q2 1: 2: 3: 4: 5: We note that C(., ., .) is available at C-Table in O(1) step and the implementation of line 5 of the algorithm is formally defined below: Partition I = [1, C(r, p, t)] ∩ Z into I1,··· , Iw, is uniquely corresponds to an integer yd−t+1 ∈ [xd−t+1 − r, xd−t+1 + r] satisfying where Ii p − q2 ≤ r2, and Ii = C(r′, q, t − 1). Gen- q = (y1, y2, ..., yd−t, yd−t+1, xd−t+2, ..., xd), erate a random number z ∈ I. then it returns RecursiveSmallBallRandomLatticePoint(r′, q, t−1, d) with q = (y1, y2, ..., yd−t, yd−t+1, xd−t+2, ..., xd). is mapped to yd−t+1), If z ∈ Ii (Ii 28 The algorithm RandomSmallBallLatticePoint(r, p, d) is to generate a random lattice point in the ball Bd(r, p, d). It calls the function RecursiveSmallBallRandomLatticePoint(.). Algorithm 4 RandomSmallBallLatticePoint(r, p, d) Input : p = (x1, x2, ..., xd) where xk = ik + jkλ with arbitrary integer ik, integer jk ∈ [−l, l] for k = 1, 2,··· , d. Output : Generate a random lattice point inside d−dimensional ball. 1: Return RecursiveSmallBallRandomLatticePoint(r, p, d, d) Theorem 35. For an arbitrary β ∈ (0, 1), assume λ be a real number and p ∈ D(λ, d, l), then there is a O 1 β + lλ(cid:19)3! time algorithm to generate a lattice point inside a d−dimensional 2 l3(cid:18) 2d β d 11 3 2 ball Bd(r, p, d). Proof: By algorithm RandomSmallBallLatticePoint(.), we can generate a random lattice point C(r(d−1),q(d−1),0) = inside d−dimensional ball Bd(r, p, d) with probability C(r′,q,d−1) C(r,p,d) . · C(r′′,q′,d−2) C(r′,q,d−1) · ...· C(r,p,d) 1 1 It takes O 1 β d 11 2 l3(cid:18) 2d 3 2 β + lλ(cid:19)3! to compute C(r, p, d) via Theorem 33, then algorithm Small- β + lλ(cid:19)3! + O(d) running time. Thus, the algo- 2 l3(cid:18) 2d β d 11 3 2 BallRandomLatticePoint(.) takes O 1 rithm takes O 1 2 l3(cid:18) 2d β d 11 3 2 β + lλ(cid:19)3! running time. 5.2.2. Generating a Random Lattice Point of High Dimensional Ball with Large Radius In this section, we develop an (1 + α)−approximation algorithm to generate a random lattice point inside a d−dimensional ball Bd(r, p, d) of large radius r with arbitrary center p, where α is used to control the accuracy of approximation. We first propose an approximation algorithm RecursiveBigBallRandomLatticePoint(.) to gen- erate a random lattice point inside a d−dimensional ball Bd(r, p, d) of radius r with lattice point center p, then we apply algorithm RecursiveBigBallRandomLatticePoint(.) to design algorithm Big- BallRandomLatticePoint(.) to generate an approximate random lattice point in a d−dimensional ball Bd(r′, p, d) of radius r′ with arbitrary center p. Before present the algorithms, we give some definition and lemmas that is used to analysis algorithm RecursiveBigBallRandomLatticePoint(.). Definition 36. For an arbitrary β ∈ (0, 1), let Bd(r, q, k) be k−dimensional ball of radius r with arbitrary center q. Define P (r, q, k) as P (r, q, k) =( C(r, q, k) Vk(r) 3 2 r ≤ 2d otherwise, β where C(r, q, k) is the number of lattice point of k−dimensional ball Bd(r, q, k) and Vk(r) is the volume of ball Bd(r, q, k). Lemma 37 shows that we can use P (r, q, k) to approximate C(r, q, k) for k−dimensional ball Bd(r, q, k) no matter how much the radius r it is. 29 Lemma 37. For an arbitrary β ∈ (0, 1). Let Bd(r, q, k) be k−dimensional ball of radius r with arbitrary center q, then (1 − β)C(r, q, k) ≤ P (r, q, k) ≤ (1 + β)C(r, q, k). Proof: Two cases are considered. 3 2 Case 1: If r ≤ 2d Case 2: If r > 2d β , we have P (r, q, k) = C(r, q, k) via Definition 36. β , we have: 3 2 (1 − β) · C(r, q, k) ≤ Vk(r) ≤ (1 + β) · C(r, q, k) via Theorem 32, where Vk(r) be the volume of k−dimensional ball Bd(r, q, k) with radius r. Therefore, we have (1 − β) · C(r, q, k) ≤ P (r, q, k) ≤ (1 + β) · C(r, q, k), because P (r, q, k) = Vk(r) via Definition 36. By combining the above two cases, we conclude that: (1 − β)C(r, q, k) ≤ P (r, q, k) ≤ (1 + β)C(r, q, k). Lemma 38 shows that for two k−dimensional balls, if their radius are almost equal, then the number of their lattice points also are almost equal. Lemma 38. For an arbitrary β ∈ (0, 1) and a real number δ, let Bd(r′, q, k) be a k−dimensional ball of radius r′ with lattice center at q and Bd(r′′, q, k) be a k−dimensional ball of radius r′′ > 2d β with lattice center at q, where q = (y1, y2, ..., yd) with yt ∈ Z and t = 1, 2, ..., d, if r′′ ≤ r′ ≤ (1 + δ) r′′, then C(r′′, q, k) ≤ C(r′, q, k) ≤ 1+β Proof: a d − dimensional ball of raduis r is Let Vd(r) be the volume of d−dimensional ball of radius r. Since the volume formula for 1−β (1 + δ)k C(r′′, q, k). 3 2 Vd(r) = f (d) · rd and Γ(.) is Euler's gamma function. Then, we have the following as: where f (d) = π d 2 Γ(cid:0) 1 2 d + 1(cid:1)−1 Since r′′ > 2d 3 2 Vk(r′′) ≤ Vk(r′) ≤ Vk(r′′) · (1 + δ)k . β , then we have 3 2 β , r′ ≥ r′′ > 2 d 1+β Vk(r′) ≤ C(r′, q, k) ≤ 1 (cid:26) 1 1+β Vk(r′′) ≤ C(r′′, q, k) ≤ 1 1 1−β Vk(r′) 1−β Vk(r′′) via Theorem 32, Plugging inequality (48) to above inequality, then we have C(r′, q, k) ≤ ≤ = ≤ Vk(r′) Vk(r′′) · (1 + δ)k 1 1 − β 1 1 − β (1 + β) (1 − β) (1 + β) (1 − β) · (1 + δ)k C(r′′, q, k) (1 + β) 1 Vk(r′′) · (1 + δ)k 30 (48) and we also have Therefore, C(r′, q, k) ≥ C(r′′, q, k). C(r′′, q, k) ≤ C(r′, q, k) ≤ 1 + β 1 − β (1 + δ)k C(r′′, q, k). Definition 39. For an integer interval [a, b], c ∈ Z, r > 0, and δ ∈ (0, 1), an (r, c, 1 + δ)-partition for [a, b] is to divide [a, b] into [a1, b1], [a2, b2],··· , [aw, bw] that satisfies the following conditions: i. a1 = a, ai+1 = bi + 1 for i = 1,··· , w − 1. ii. For any x, y ∈ {ai, bi}, r2 − (x − c)2 ≤ (1 + δ)2(r2 − (y − c)2) and r2 − (y − c)2 ≤ (1 + δ)2(r2 − (x − c)2). iii. For any x ∈ {ai, bi} and y ∈ {ai+1, bi+1}, r2 − (x − c)2 > (1 + δ)2(r2 − y2) or r2 − (y − c)2 > (1 + δ)2(r2 − x2). The purpose of the algorithm RecursiveBigBallRandomLatticePoint(.) is to recursivly generate a random lattice point inside the d−dimensional ball Bd(r, p, d) of radius r with lattice point center p. Algorithm 5 RecursiveBigBallRandomLatticePoint(r, p, t, d) Input : p = (z1, z2, ..., zd−t, yd−t+1, ..., yd) where zi ∈ Z with 1 ≤ i ≤ d − t, and yi ∈ Z with d − t + 1 ≤ i ≤ d, α ∈ (0, 1) is a parameter to control the bias, r is radius, and t is dimensional number. Output : Z = {z1, ..., zd}. If t = 0 Return (z1, z2, ..., zd) w Let M = 1: 2: 3: 4: 5: Let I1 = [a1, b1],··· , Iw = [aw, bw] be the union of intervals via (cid:16)r, yd−t+1, 1 + ǫ4 g(d)(cid:17)- partitions for [⌈yd−t+1 − r⌉, yd−t+1] ∩ Z and [yd−t+1 + 1,⌊yd−t+1 + r⌋] ∩ Z, where ǫ4 ∈ (0, 1) and g(d) is a function of d Pi=1 (bi − ai + 1)P (ri, pi, t − 1), where pi = (z1, z2, ..., zd−t, bi, yd−t+2, ..., yd), and Return RecursiveBigBallRandomLatticePoint(r′i, p′i, t − 1, d) with probability P (ri,pi,t−1) , i = r2 − (zd−t+1 − yd−t+1)2, i = r2 − (z′d−t+1 − yd−t+1)2 and a random r2 i = r2 − (bi − yd−t+1)2 where zd−t+1 = bi, pi = (z1, z2, ..., zd−t, zd−t+1, yd−t+2, ..., yd), and r2 p′i = (z1, z2, ..., zd−t, z′d−t+1, yd−t+2, ..., yd), and r′2 integer z′d−t+1 ∈ [ai, bi] We note that the implementation of (cid:16)r, yd−t+1, 1 + ǫ4 g(d)(cid:17)-partitions in line 3 is as the following M pictures: 31 Figure 3: Example of (cid:16)r, yd−t+1, 1 + ǫ4 g(d)(cid:17)-Partitions in 2D Figure 4: Example of (cid:16)r, yd−t+1, 1 + ǫ4 g(d)(cid:17)-Partitions in 3D We have the following algorithm that can generate an approximate random lattice point in a large ball with an arbitrary center, which may not be a lattice point. Definition 40. Let integer d > 0 be a dimensional number, Rd be the d−dimensional Euclidean Space. i. A point q = (x′1, x′2, ..., x′d) ∈ Rd is the nearest lattice point of p = (x1, ..., xd) ∈ Rd if it satisfies 32 x′i = (cid:26) ⌊xi⌋ ⌈xi⌉ where i = 1, 2, ..., d. xi − [xi] ≤ 1 2 xi − [xi] > 1 2 , for xi ≥ 0 or x′i = (cid:26) ⌈xi⌉ ⌊xi⌋ xi − [xi] ≤ 1 2 xi − [xi] < 1 2 , for xi < 0, Algorithm 6 BigBallRandomLatticePoint(r, p, d) Input : p = (x1,··· , ..., xd) where xi ∈ R with 1 ≤ i ≤ d, α ∈ (0, 1) is a parameter to control the bias, r is radius, and k is dimensional number. Output : Generate a random lattice point inside d−dimensional ball. Let q be the nearest lattice point of p in Rd Repeat Let s =RecursiveBigBallRandomLatticePoint(r + √d, q, d) 1: 2: 3: 4: 5: Until s ∈ Bd(r, p, d) Return s α (cid:17) and Theorem 41. For an arbitrary α ∈ (0, 1), there is an algorithm with runing time O(cid:16) d3 log r (1 + α)−bias for a d−dimensional ball Bd(r, q, d) to generate a random lattice point with radius r > 2d3 α that centered at q = (y1, y2, ..., yd) with yt ∈ Z, t = 1, 2, ..., d. Proof: In line 5 of algorithm RecursiveBigBallRandomLatticePoint(.), define if ai ≤ yd−t+1 otherwise, , if ai ≤ yd−t+1 otherwise, r′2 and r2 i =(cid:26) r2 − (yd−t+1 − ai)2 r2 − (yd−t+1 − bi)2 p′i =(cid:26) (z1, z2, ..., zd−t, ai, yd−t+2, ..., yd) (z1, z2, ..., zd−t, bi, yd−t+2, ..., yd) i =(cid:26) r2 − (yd−t+1 − bi)2 r2 − (yd−t+1 − ai)2 pi =(cid:26) (z1, z2, ..., zd−t, bi, yd−t+2, ..., yd) (z1, z2, ..., zd−t, ai, yd−t+2, ..., yd) Let v(i) = (bi − ai + 1), and r′i = ri 1+ ǫ4 g(d) if bi ≤ yd−t+1 otherwise, if bi ≤ yd−t+1 otherwise. , then we have Xi C(r′i, p′i, t − 1)v(i) ≤ C(ri, pi, t) ≤Xi C(ri, pi, t − 1)v(i). Since r′i = ri 1+ ǫ4 g(d) , then 1 + β (cid:18)1 + 1 − β and ǫ4 g(d)(cid:19)−(t−1) Xi C(ri, pi, t) ≤Xi C(ri, pi, t − 1)v(i) ≤ C(ri, pi, t) C(ri, pi, t − 1)v(i) via Lemma 38, where δ = 1 + ǫ4 g(d) . Via Lemma 37 we have 1 + β(cid:19)2(cid:18)1 + (cid:18) 1 − β ǫ4 g(d)(cid:19)−(t−1) Xi P (ri, pi, t − 1)v(i) ≤ P (ri, pi, t) and P (ri, pi, t) ≤ 1 + β 1 − β Xi 33 P (ri, pi, t − 1)v(i). Thus, we have 1 + β(cid:19)2(cid:18)1 + (cid:18) 1 − β ǫ4 g(d)(cid:19)−(t−1) ≤ From above inequality, we have 1 + β(cid:19)2(cid:18)1 + (cid:18) 1 − β ǫ4 g(d)(cid:19)−(t−1) 1 P (ri, pi, t) ≤ Via Lemma 37 we have (1 − β)2 (1 + β)3 (cid:18)1 + ǫ4 g(d)(cid:19)−(t−1) 1 C(ri, pi, t) ≤ P (ri, pi, t) P (ri, pi, t − 1)v(i) ≤ 1 + β 1 − β . 1 P (ri, pi, t − 1)v(i) ≤ 1 + β 1 − β 1 P (ri, pi, t) . Pi Pi 1 P (ri, pi, t − 1)v(i) ≤ 1 + β (1 − β)2 1 C(ri, pi, t) . Pi Let g(d) = d2, ǫ4 = α 4 and β = α+16d+16 . Since Algorithm RecursiveBigBallRandomLattice- α Point(.) has d iteration, we can generate a random lattice point with bias of probability as: P (ri, pi, d − 2) P (ri, pi, d − 1)v(i) ··· P (ri, pi, 0) P (ri, pi, 0)v(i) Pi Pi 1 + β (1 − β)2 P (ri, pi, d − 1) P (ri, pi, d − 2)v(i) · 1 Pi 1 − β(cid:19)d−1 C(r, p, d) ·(cid:18) 1 + β 1 − β(cid:19)d C(r, p, d) ·(cid:18) 1 + β 1 · P (ri, pi, 0) · (1 + β)C(ri, pi, 0) ≤ 1 ≤ 1 − β 1 − β(cid:19)d+1 = (cid:18) 1 + β = (cid:18)1 + ≤ e ≤ (cid:18)1 + ≤ (1 + α) 4β 1 − β 2β 1−β (d+1) 1 1 C(r, p, d) 2β 1 − β(cid:19)d+1 1 1 C(r, p, d) C(r, p, d) (d + 1)(cid:19) C(r, p, d) 1 C(r, p, d) 34 and −(d−1)(d−2) 2 ǫ4 (1 − β)C(ri, pi, 0) ǫ4 1 ǫ4 −d2 2 1 1 2β 2β −(d−1)d 2 Pi C(r, p, d) C(r, p, d) g(d)(cid:19) P (ri, pi, 0) P (ri, pi, 0)v(i) 1 + β(cid:19)2(d−1)(cid:18)1 + P (ri, pi, d − 2) P (ri, pi, d − 1)v(i) ··· C(r, p, d)(cid:18) 1 − β P (ri, pi, d − 1) P (ri, pi, d − 2)v(i) · Pi (1 − β)2 (1 + β)3 (cid:18)1 + 1 + β(cid:19)2d+1(cid:18)1 + Pi g(d)(cid:19)−(d−1) g(d)(cid:19) 1 + β(cid:19)2d+1(cid:18)1 + 1 + β(cid:19)2d(cid:18)1 + 1 + β(cid:19)(cid:18)1 − 1 + β(cid:19) (1 − ǫ4) 1 + β − ǫ4(cid:19) 1 + β(cid:19) (1 − ǫ4) ≥ = (cid:18) 1 − β ≥ (cid:18)1 − ≥ (cid:18)1 − ≥ (cid:18)1 − ≥ (cid:18)1 − ≥ (cid:18)1 − ≥ (cid:18)1 − ≥ (1 − α) Therefore, we can generate a random lattice point with probability between g(d)(cid:19) g(d)(cid:19)−d2 g(d)(cid:19) C(r, p, d) 1 C(r, p, d) 1 C(r, p, d) 1 C(r, p, d) C(r, p, d) C(r, p, d) ǫ4d2 4βd 4βd 4βd 4βd 1 . ǫ4 1 ǫ4 1 (cid:20)(1 − α) 1 C(r, p, d) , (1 + α) 1 C(r, p, d)(cid:21) . ǫ4 r (1+ ǫ4 g(d)(cid:17)- In line 3 of algorithm RecursiveBigBallRandomLatticePoint(.), it forms a (cid:16)r, yd−t+1, 1 + ǫ4 partition I1,··· , Iw for [⌈yd−t+1 − r⌉,⌊yd−t+1 + r⌋] ∩ Z and [yd−t+1 + 1,⌊yd−t+1 + r⌋] ∩ Z. Then, g(d) )w ≤ 1. Solving w, we have w ≥ g(d) log r there are at most w number of ai, where w such that . · d(cid:17) = O( d3 log r Thus, the running time of the algorithm is O(cid:16) g(d) log r α (cid:17) . ) = O(cid:16) d3 log r Remark : We note that there are at most one (t − 1)−dimensional ball of radius r < 2d3 And there are d iterations in algorithm RecursiveBigBallRandomLatticePoint(.). center at a lattice point, where t = 1, 2, ..., d. For this case, we can apply Theorem 35 with β = 0. Theorem 42. For arbitrary α ∈ (0, 1), and α′ ∈ (0, 1), there is an (1 + α′)−bias algorithm with runing time O(cid:16) d3 log(r+√d) (cid:17) for a d−dimensional ball Bd(r, q, d) to generate a random lattice point contains ball Bd(r, p, d) , where r′ = r + √d. Let Vd(r) be the volume of a d−dimensional ball with radius r, then probability that a lattice point in Bd(r′, q, d) belongs to Bd(r, p, d) is at least (1 − α) C(r,p,d) C(r′,p,d) . Consider another ball Bd(r′, q, d) of radius r′ with lattice center q = (y1, y2, ..., yd) that α with an arbitrary center. of radius r > 2d α with Proof: ǫ4 ǫ4 α 3 2 Via Theorem 32, we have ( 1 1+β Vd(r) ≤ C(r, p, d) ≤ 1 1−β Vd(r) 1+β Vd(r + √d) ≤ C(r′, q, d) ≤ 1 1 1−β Vd(r + √d), 35 then we have Vd(r) 1 − β 1 + β Vd(r + √d) ≤ C(r, p, d) C(r′, p, d) ≤ The formula for a d − dimensional ball of raduis r is Vd(r) = f (d) · rd 1 + β 1 − β Vd(r) Vd(r + √d) . where f (d) = π and Γ(.) is Euler's gamma function. Let β = α 8+α and α > 2d r+√d , 3 2 d 2 d + 1(cid:1)−1 2 Γ(cid:0) 1 (1 − α) C(r, p, d) C(r′, p, d) ≥ (1 − α) = (1 − α) f (d) · rd 1 − β 1 + β 3 2 d 1 + β 1 − 1 − β 1 + β 1 − 1 − β f (d) ·(cid:16)r + √d(cid:17)d √d r + √d!d r + √d! 1 − β(cid:19) 1 − r + √d! . 1 − β − 2β 2β d 3 2 ≥ (1 − α) ≥ (1 − α)(cid:18)1 − ≥ 1 − α − 3 2 d r + √d! Therefore, the probability a lattice point in Bd(r′, q, d) belongs to Bd(r, p, d) fails is at most (cid:18)α + 2β 1−β + d LatticePoint(.) fails with small possibility. r+√d(cid:19) , where (cid:18)α + 2β 1−β + d 3 2 3 2 r+√d(cid:19) < 1, which means the algorithm BigBallRandom- The probability to generate a random lattic point in ball Bd(r′, q, d) is in range of (cid:20)(1 − α) 1 C(r′, q, d) , (1 + α) 1 C(r′, q, d)(cid:21) via Theorem 41. Then the bias to generate a random lattic point in ball Bd(r, p, d) is where Pr(pi) ∈h(1 − α) Then, we have 1 C(r′,q,d) , (1 + α) 1 C(r′,q,d)i . Pr(pi) Pi Pr(pi) , Pr(pi) Pr(pi) Pi (1 + α) 1 1 C(r′,q,d) C(r′,q,d) C(r, p, d) ≤ = (1 − α) 1 + α 1 − α =(cid:18)1 + 1 C(r, p, d) 2α 1 − α(cid:19) 1 , C(r, p, d) 36 and Pr(pi) Pr(pi) Pi (1 − α) 1 C(r′,q,d) (1 + α) 1 C(r′,q,d) C(r, p, d) ≥ = 1 − α 1 + α =(cid:18)1 − ≥(cid:18)1 − 1 C(r, p, d) 2α 1 + α(cid:19) 1 − α(cid:19) 2α 1 C(r, p, d) 1 C(r, p, d) . Therefore, the probability to generate a random lattice point in Bd(r, p, d) is range of (cid:20)(1 − α′) 1 C(r, p, d) , (1 + α′) 1 C(r, p, d)(cid:21) where α′ = 2α 1−α . α α (cid:17) running time to generate a random lattice. It takes O(cid:16) d3 log(r+√d) (cid:17) running time to generate a random lattice point inside a d−dimensional ball Bd(r + √d, p, d) with a lattice point center via Theorem 41. Thus, the algorithm BigBallRan- domLatticePoint(.) takes O(cid:16) d3 log(r+√d) Theorem 43. For an arbitrary α ∈ (0, 1), there is an algorithm with runing time O(cid:16) d3 log(r+√d) (cid:17) and (1+α)−bias for a d−dimensional ball Bd(r, q, d) to generate a random lattice pointo f radius r > α with a arbitrary center; and there is a O 1 β + lλ(cid:19)3! time algorithm to generate a lattice point inside a d−dimensional ball Bd(r, p, d) of radius r ≤ 2d α with center p ∈ D(λ, d, l). Proof: We discuss two cases based the radius of the d-dimensional ball. 2 l3(cid:18) 2d β d α 3 2 2d 11 3 2 3 2 Case 1: When generate a random lattice point inside a d-dimensional ball of radius r > 2d α with 3 2 3 2 center arbitrary center p, apply Theorem 42. Case 2: When generate a random lattice point inside a d-dimensional ball of radius r ≤ 2d α with center p ∈ D(λ, d, l), apply Theorem 35. 5.3. Count Lattice Point in the Union of High Dimensional Balls In this section, we apply the algorithm developed in Section 4 to count the total number of lattice point in the union of high dimensional balls. γ(cid:17) · m · (log m)O(1)(cid:17) time and O(log m) rounds algorithm Theorem 44. There is a O(cid:16)poly(cid:16) 1 for the number of lattice points in B1 ∪ B2 ∪···∪ Bm such that with probability at least 1− γ, it gives a sum·M ∈ [(1 − ǫ)(1 − αL)(1 − βL)·B1∪···∪Bm, (1 + ǫ)(1 + αR)(1 + βR)·B1∪···∪Bm], where each ball Bi satisfy that either its radius r > 2d β or its center p ∈ D(λ, d, l) and B1 ∪ ··· ∪ Bm is the total number of lattice point of union of m high dimensional balls. ǫ , log 1 3 2 Proof: Apply Theorem 33 and Theorem 43, we have mi for each ball Bi with mi ∈ ((1 − βL)Ci(ri, pi, t), (1 + βR)Ci(ri, pi, t)) , 37 and biased random generators with Prob(x = RandomElement(Bi)) ∈(cid:20) 1 − αL Ci(ri, pi, t) , 1 + αR Ci(ri, pi, t)(cid:21) for each input ball Bi, where Ci(ri, pi, t) is the number of lattice point of t−dimensional ball Bi of radius ri for i = 1, 2, ..., m. Then apply Theorem 17. 5.4. Hardness to Count Lattice Points in a Set of Balls In this section, we show that it is #P-hard to count the number of lattice points in a set of balls. √h 2 Theorem 45. It is #P-hard to count the number of lattice points in a set of d-dimensional balls even the centers are of the format (x1,··· , xd) ∈ Rd that has each xi to be either 1 or for some integer h ≤ d. Proof: We derive a polynomial time reduction from DNF problem to it. For each set of lattice √h points in a h-dimensional cube {0, 1}h, we design a ball with radius r = 2 and center at C = √h √h 2 ). It is easy to see that this ball only covers the lattice points in {0, 1}h. Every 0, 1- 2 ,··· , ( lattice point in 0, 1 has distance to the center C equal to r. For every lattice point P ∈ Rh that is not in {0, 1}h has distance d with d2 ≥ r2 + (1 + 1 Definition 46. For a center c = (c1,··· , cd) and an even number k > 0 and a real r > 0, a d-dimensional k-degree ball Bk(c, r) is {(x1,··· , xd) : (x1,··· , xd) ∈ Rd and 2 )2 = r2 + 2. 2 )2 − ( 1 d (xi − ci)k ≤ r}. Pi=1 Theorem 47. Let k be an even number at least 2. Then we have: i. There is no polynomial time algorithm to approximate the number of lattice points in the intersection n-dimensional k-degree balls unless P=NP. ii. It is #P-hard to count the number of lattice points in the intersection n-dimensional k-degree balls. Without loss of generality, Proof: We derive a polynomial time reduction from 3SAT problem to it. For each clause C = (x∗i ∨ x∗j ∨ x∗k), we can get a ball to contain all lattice points in the 0-1-cube to satisfy C, each x∗i is a literal to be either xi or its negation ¯xi. let C = (x1 ∨ x2 ∨ x3). Let δ = 0.30. Let center DC = 2 ), which has value 1 − δ in the first three 2 in the rest. For 0, 1 assignment (a1, a2,··· , an) of n variables, if it satisfies C if (ai − di)k ≤ 2(1 − δ)k + δk + (n − 3) · ( 1 2 )k. Therefore, we can select radius rC that Pi=1 C = 2(1 − δ)k + δk + (n − 3) · ( 1 (d1, d2, d3, d4, d5,··· , dn) = (1 − δ, 1 − δ, 1 − δ, 1 positions, and 1 2 )k. We have the following inequalities: 2 ,··· , 1 satisfies rk and only if 2 , 1 n (cid:26) (2 − δ)2 > (1 + δ)k > 2(1 − δ)k + δk 2 )k > 2(1 − δ)k + δk + ( 1 (1 + 1 2 )k. This is because we have the following equalities: (1 + δ)2 = 1.69, 2(1 − δ)2 + δ2 = 2 × 0.49 + 0.09 = 1.07, 2(1 − δ)2 + δ2 + ( 1 (1 + 1 2 )2 = 1.07 + 0.25 = 1.32, 2 )2 = 2.25.   If Y = (y1, y2,··· , yn) is not a 0, 1-lattice point, we discuss two cases: 38 (49) (50) i. Case 1. yi 6∈ {0, 1} for some i with 1 ≤ i ≤ 3. In this case we know that dist(Y, DC )2 > r2 C by inequality (50). ii. Case 2. yi 6∈ {0, 1} for some i with 3 < i ≤ n. In this case we know that dist(Y, DC )2 > r2 C by inequality (50). If Y = (y1, y2,··· , yn) is a 0, 1-lattice point, we discuss two cases: i. Case 1. Y satisfies C. In this case we know that dist(Y, DC )2 ≤ r2 C . ii. Case 2. Y does not satisfy C. In this case we know that dist(Y, DC )2 > r2 C by inequality (1 − δ)2 > δ2. The ball BC with center at DC and radius rC contains exactly those 0,1-lattice points that satisfy clause C. This proves the first part of the theorem. If there were any factor c-approximation to the intersection of balls, it would be able to test if the intersection is empty. This would bring a polynomial time solution to 3SAT. It is well known that #3SAT is #P-hard. Therefore, It is #P-hard to count the number of lattice points in the intersection n-dimensional balls. This proves the second part of the theorem. 6. Approximation for the Maximal Coverage with Balls We apply the technology developed in this paper to the maximal coverage problem when each set is a set of lattice points in a ball with center in D(λ, d, l). The classical maximum coverage is that given a list of sets A1,··· , Am and an integer k, find k sets from A1, A2,··· , Am to maximize the size of the union of the selected sets in the computational model defined in Definition 2. For real number a ∈ [0, 1], an approximation algorithm is a (1 − a)- approximation for the maximum coverage problem that has input of integer parameter k and a list of sets A1,··· , Am if it outputs a sublist of sets Ai1 , Ai2 ,··· , Aik such that Ai1 ∪ Ai2 ∪ ··· ∪ Aik ≥ (1 − a)Aj1 ∪ Aj2 ∪ ··· ∪ Ajk, where Aj1 , Aj2 ,··· , Ajk is a solution with maximum size of union. Theorem 48. [17] Let ρ be a constant in (0, 1). For parameters ξ, γ ∈ (0, 1) and αL, αR, δL, δR ∈ k )k − ξ(cid:17)-approximation for the maximum cover [0, 1 − ρ], there is an algorithm to give a (cid:16)1 − (1 − β problem, such that given a ((αl, αr), (δL, δR))-list L of finite sets A1,··· , Am and an integer k, with probability at least 1 − γ, it returns an integer z and a subset H ⊆ {1, 2,··· , m} that satisfy i. ∪j∈H Aj ≥(cid:16)1 − (1 − β ii. ((1 − αL)(1 − δL) − ξ) ∪j∈H Aj ≤ z ≤ ((1 + αR)(1 + δR) + ξ) ∪j∈H Aj, and iii. Its complexity is (T (ξ, γ, k, m), R(ξ, γ, k, m), Q(ξ, γ, k, m)) with k )k − ξ(cid:17) C∗(L, k) and H = k, T (ξ, γ, k, m) = O(cid:18) k3 ξ2 (cid:18)k log(cid:18) 3m k (cid:19) + log 1 γ(cid:19) m(cid:19) , where β = (1−αL)(1−δL) solution. (1+αR)(1+δR) and C∗(L, k) is the number of elements to be covered in an optimal We need Lemma 49 to transform the approximation ratio given by Theorem 48 to constant (1− 1 e ) to match the classical ratio for the maximum coverage problem. 39 Lemma 49. For each integer k ≥ 2, and real b ∈ [0, 1], we have: i. (1 − b ii. If ξ ≤ η k )k ≤ 1 e (b + b e (b + b 2k − 1). e − η 2k − 1), then 1 − (1 − b k )k − ξ > 1 − 1 e , where η = e− 1 4 . df (x) Proof: Let function f (x) = 1 − ηx − e−x. We have f (0) = 0. Taking differentiation, we get dx = −η + e−x > 0 for all x ∈ (0, 1 4 ). Therefore, for all x ∈ (0, 1 4 ), e−x ≤ 1 − ηx. (51) The following Taylor expansion can be found in standard calculus textbooks. For all x ∈ (0, 1), ln(1 − x) = −x − x2 2 − x3 3 − ··· . Therefore, we have (1 − b k 2k2 − b3 3k3 −··· ) = e−b− b2 2k − b3 3k2 −··· k − b2 k ) = ek(− b 2k = e−1 · e1−b− b )k = ek ln(1− b ≤ e−b− b ≤ e−1 · (1 − η · (b + 2k b 2k − 1)) ≤ 1 e − η e (b + b 2k − 1). (52) (53) Note that the transition from (52) to (53) is based on inequality (51). The part ii follows from part i. This is because 1− (1− b k )k− ξ ≥ 1− 1 e + η e (b + b 2k − 1)− ξ ≥ 1− 1 e . Theorem 50. There is a poly(λ, d, l, k, m) time (1 − 1 erage problem when each set is the set of lattice points in a ball with center in D(λ, d, l). e )-approximation algorithm for maximal cov- [Sketch] Let α = αL = αR = δL = δR = 1 Proof: easy to see (b + b Theorem 33 and Theorem 43. 2k − 1) ≥ 1 4k . Let ξ = η e (b + b 2k − 1) = Θ( 1 ck with c = 100, and b = β = 1−αL)(1−δL) (1+αR)(1+δR) . It is k ). It follows from Theorem 48, Lemma 49, 7. Conclusions We introduce an almost linear bounded rounds randomized approximation algorithm for the size of set union problem A1 ∪ A2 ∪ ... ∪ Am, which given a list of sets A1, ..., Am with approximate set size and biased random generators. The definition of round is introduced. We prove that our algorithm runs sublinear in time under certain condition. A polynomial time approximation scheme is proposed to approximae the number of lattice points in the union of d-dimensional ball if each ball center satisfy D(λ, d, l). We prove that it is #P-hard to count the number of lattice points in a set of balls, and we also show that there is no polynomial time algorithm to approximate the number of lattice points in the intersection of n-dimenisonal k-degree balls unless P=NP. 8. Acknowledgements We want to thank Peter Shor, Emil Jer´abek, Rahul Savani et al. for their comments about algorithm to geneate a random grid point inside a d−dimensional ball on Theoretical Computer Science Stack Exchange. 40 References [1] S. D. Adhikari and Y. F. S. P´etermann. Lattice points in ellipsoids. Acta Arith., 59(4):329 -- 338, 1991. [2] N. Alon, Y. Matias, and M. Szegedy. The space complexity of approximating the frequency In Proceedings of the Twenty-Eighth Annual ACM Symposium on the Theory of moments. Computing, Philadelphia, Pennsylvania, USA, May 22-24, 1996, pages 20 -- 29, 1996. [3] G. E. Andrews, S. B. Ekhad, and D. Zeilberger. A short proof of jacobi's formula for the number of representations of an integer as a sum of four squares. The American Mathematical Monthly, Vol. 100, No. 3:274 -- 276, 1993. [4] Z. Bar-Yossef, T. S. Jayram, R. Kumar, D. Sivakumar, and L. Trevisan. Counting distinct elements in a data stream. In Randomization and Approximation Techniques, 6th International Workshop, RANDOM 2002, Cambridge, MA, USA, September 13-15, 2002, Proceedings, pages 1 -- 10, 2002. [5] Z. Bar-Yossef, R. Kumar, and D. Sivakumar. Reductions in streaming algorithms, with an application to counting triangles in graphs. In Proceedings of the Thirteenth Annual ACM- SIAM Symposium on Discrete Algorithms, January 6-8, 2002, San Francisco, CA, USA., pages 623 -- 632, 2002. [6] J. Beck. On a lattice point problem of l. moser I. Combinatorica, 8(1):21 -- 47, 1988. [7] J. Blasiok. Optimal streaming and tracking distinct elements with high probability. In Pro- ceedings of the Twenty-Ninth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2018, New Orleans, LA, USA, January 7-10, 2018, pages 2432 -- 2448, 2018. [8] K. Bringmann and T. Friedrich. Approximating the volume of unions and intersections of high-dimensional geometric objects. Comput. Geom., 43(6-7):601 -- 610, 2010. [9] S. R. Buss and L. Hay. On truth-table reducibility to SAT and the difference hierarchy over NP. In Proceedings: Third Annual Structure in Complexity Theory Conference, Georgetown University, Washington, D. C., USA, June 14-17, 1988, pages 224 -- 233, 1988. [10] K. Chandrasekharan and R. Narasimhan. On lattice-points in a random sphere. Bull. Amer. Math. Soc., 73(1):68 -- 71, 1967. [11] J.-R. Chen. Improvement on the asymptotic formulas for the number of lattice points in a region of the three dimensions (ii). Scientia Sinica, 12(5). [12] S. A. Cook. The complexity of theorem-proving procedures. In Proceedings of the 3rd Annual ACM Symposium on Theory of Computing, May 3-5, 1971, Shaker Heights, Ohio, USA, pages 151 -- 158, 1971. [13] K. Corr´aadi and I. K´atai. A comment on k. s. gangadharan's paper entitled "two classical lattice point problems". Magyar Tud. Akad. Mat. Fiz. Oszt. Kozl, 17. [14] P. Flajolet, ´E. Fusy, O. Gandoue, and F. Meunier. Hyperloglog: the analysis of a near-optimal cardinality estimation algorithm. In 2007 Conference on Analysis of Algorithms, AofA 07, pages 127 -- 146, 2007. [15] P. Flajolet and G. N. Martin. Probabilistic counting algorithms for data base applications. J. Comput. Syst. Sci., 31(2):182 -- 209, 1985. [16] L. Fortnow and N. Reingold. PP is closed under truth-table reductions. In Proceedings of the Sixth Annual Structure in Complexity Theory Conference, Chicago, Illinois, USA, June 30 - July 3, 1991, pages 13 -- 15, 1991. 41 [17] B. Fu. Partial sublinear time approximation and inapproximation for maximum coverage. arXiv:1604.01421, April 5, 2016. [18] S. Ganguly, M. N. Garofalakis, and R. Rastogi. Tracking set-expression cardinalities over continuous update streams. VLDB J., 13(4):354 -- 369, 2004. [19] P. B. Gibbons. Distinct sampling for highly-accurate answers to distinct values queries and In VLDB 2001, Proceedings of 27th International Conference on Very Large event reports. Data Bases, September 11-14, 2001, Roma, Italy, pages 541 -- 550, 2001. [20] P. B. Gibbons and S. Tirthapura. Estimating simple functions on the union of data streams. In SPAA, pages 281 -- 291, 2001. [21] P. J. Haas, J. F. Naughton, S. Seshadri, and L. Stokes. Sampling-based estimation of the number of distinct values of an attribute. In VLDB'95, Proceedings of 21th International Conference on Very Large Data Bases, September 11-15, 1995, Zurich, Switzerland., pages 311 -- 322, 1995. [22] J. L. Hafner. New omega theorems for two classical lattice point problems. Inventiones Math- ematicae, 63(2):181 -- 186, 1981. [23] D. R. Heath-Brown. Lattice points in sphere. Numb. Theory Prog., 2:883 -- 892, 1999. [24] W. Hoeffding. Probability inequalities for sums of bounded random variables. Journal of the American Statistical Association, 58(301):13 -- 30, 1963. [25] Z. Huang, W. M. Tai, and K. Yi. Tracking the frequency moments at all times. CoRR, abs/1412.1763, 2014. [26] M. N. Huxley. Exponential sums and lattice points ii. Proc. London Math. Soc., 66(2):279 -- 301, 1993. [27] C. Jacobi. Gesammelte Werke, Berlin 1881-1891. Reprinted by Chelsea, New York, 1969. [28] D. M. Kane, J. Nelson, and D. P. Woodruff. An optimal algorithm for the distinct elements problem. In Proceedings of the Twenty-Ninth ACM SIGMOD-SIGACT-SIGART Symposium on Principles of Database Systems, PODS 2010, June 6-11, 2010, Indianapolis, Indiana, USA, pages 41 -- 52, 2010. [29] R. M. Karp, M. Luby, and N. Madras. Monte-carlo approximation algorithms for enumeration problems. J. Algorithms, 10(3):429 -- 448, 1989. [30] J. E. Mazo and A. M. Odlyzko. Lattice points in high-dimensional spheres. Monatsh. Math., 110(1):47 -- 61, 1990. [31] A. Meyer. On the number of lattice points in a small sphere and a recursive lattice decoding algorithm. Des. Codes Cryptography, 66(1-3):375 -- 390, 2013. [32] R. Motwani and P. Raghavan. Randomized Algorithms. Cambridge University Press, 2000. [33] G. Szego. Beitrage zur theorie der laguerreschen polynome ii: Zahlentheoretische anwendungen. Math. Z., 25(1). [34] K.-M. Tsang. Counting lattice points in the sphere. Bulletin of the London Mathematical Society, 32(6). [35] L. G. Valiant. The complexity of computing the permanent. Theor. Comput. Sci., 8:189 -- 201, 1979. 42 [36] A. I. Vinogradov and M. M. Skriganov. The number of lattice points inside the sphere with variable cente, analytic number theory and the theory of functions, 2. Zap. Nauen. Sem. Leningrad Otdel. Mat. Inst. Steklov (LOMI), 91:25 -- 30, 1979. [37] I. M. Vinogradov. On the number of integer points in a sphere. Izu. Akad. Nauk SSSR Ser. Mat., 27(5):957 -- 968, 1963. [38] A. Walfisz. Gitterpunkte in mehrdimensionalen Kugeln. Instytut Matematyczny Polskiej Akademi Nauk(Warszawa), 1957. [39] A. Walfisz. Weylsche exponentialsummen in der neueren zahlentheorie. VEB Deutscher Verlag der Wissenschaften, 1963. [40] A. A. Yudin. On the number of integer points in the displaced circles. Acta Arith, 14(2):141 -- 152, 1968. 43
1101.0160
1
1101
2010-12-30T21:05:23
The Complexity of Euclidian 2 Dimension Travelling Salesman Problem versus General Assign Problem, NP is not P
[ "cs.DS", "cs.CC" ]
This paper presents the differences between two NP problems. It focuses in the Euclidian 2 Dimension Travelling Salesman Problems and General Assign Problems. The main results are the triangle reduction to verify the solution in polynomial time for the former and for the later the solution to the Noted Conjecture of the NP-Class, NP is not P.
cs.DS
cs
The Complexity of Euclidian 2 Dimension Travelling Salesman Problem versus General Assign Problem, NP is not P Carlos Barr´on Romero [email protected] Universidad Aut´onoma Metropolitana Unidad Azcapotzalco, Divisi´on de Ciencias B´asicas e Ingenier´ıa Departamento de Ciencias B´asicas Av. San Pablo No. 180, Col. Reynosa Tamaulipas, C.P. 02200, MEXICO 2010 Abstract This paper presents the differences between two NP problems. It focuses in the Euclidian 2 Dimension Travelling Salesman Problems and General Assign Problems. The main results are the triangle reduction to verify the solution in polynomial time for the former and for the later the solution to the Noted Conjecture of the NP-Class, NP is not P. Algorithms, NP, Numerical optimization. 1 Introduction In [2] there are a complete introduction to this subject, an analysis in order to verify a solution for the Euclidian 2 Dimension Travelling Salesman Problem (E2DTSP) and the General Assign Problem (GAP). A review of the results for the travelling Salesman Problem is in [3], and for the NP Problems is in [4] The next proposition is the key of this research: Given an arbitrary and large GAPn, it has not an polynomial algorithm for verifying its solution. Here a slight different approach is presented to differentiate and focuses only in the classes E2DTSP and GAP in order to determine that does nos exist a polynomial time algorithm for solving the later, i.e., there is not a polynomial time algorithm for solving the Hard NP problems. The notation, results and a more details are in [2]. Section 2 depicts the similarities, characteristics and propositions of the GAPn and the E2DTSPn. The main result is that an arbitrary and large E2DTSPn preserves the inhered by construction the triangle inequality property. On the other hand, GAPn does not preserve or inhere any property that could drive toward the construction of a verifying algorithm of its solution. Therefore, it is impossible to build an efficient algorithm for solving arbitrary and large GAPn.The last section contains conclusions and future work. 2 The General Assign Problem and the Euclidian 2 Dimension Trav- elling Salesman Problem The notation is the same as in [2]. Definition 2.1. Notation 1. GAPn is the General Assign Problem of size n. 1 2. E2DTSPn stands for the version of the Traveller Salesman Problem with n vertices. They come from points in a plane (as subset of R2) and the weight of the edges are the euclidian distance between vertices. In this section the GAPn and E2DTSPns characteristics and properties are presented. It is intended to give general results for TSPn and for the specific case E2DTSPn. The GAPn consists a complete graph, a function which assigns a value for each edge, and objective function, GAP n = (Gn, c, f ), where Gn = (Vn, A), Vn ⊂ N A = {(i, j) i, j ∈ V }, c : V × V → R, and f is a real function for the evaluation of any path of vertices. Solving a GAP means to look for a minimum or a maximum value of f over all cycles of Gn. Note that c(i, i) = inf, and c(·, ·) can be see as a matrix of R n×n . Remark 2.2. Some properties and characteristics GAP and E2DTSP are: 1. The complete property of Gn means that ∀i, j ∈ Vn, ∃e = (i, j) ∈ A. 2. Gn is a directed graph, which means that edges are a ordered pair. 3. A path of vertices is a sequence of vertices of Vn. 4. A cycle is a path of different vertices but the first and the last vertex are the same. Hereafter, a complete cycle is a cycle containing the n vertices of Vn. Also, a complete cycle has n edges. 5. A E2DTSPn is a case of a GAPn where c(i, j) = c(j, i) (the cost matrix is symmetric) and c(i, j) ≥ 0, ∀i, j, and finally f is the sum of the edges' cost of a cycle. It is a special case where c(i, j) = distance(vi, vj) ∀vi, vj ∈ Vn, the vertex vi ∈ R2, ∀i = 1, . . . , n, and distance(vi, vj ) = kvi − vj k, is the Euclidian distance. Note that for a E2DTSPn, we are going to refers to a vertex by its number or by vi, in this case vi is a point of R2. 6. A sequence of vertices is a path and its denoted by pk. 7. The objective function f is also denoted by c, and let c(p) be the cost function of the path p, i.e., it is given by the summation of edges cost of the consecutive pairs of vertices of p. The following propositions are easy to prove and they are well known results (also they are presented in [2]). Proposition 2.3. 1. Any GAPn has a solution. This means that exists a Hamiltonian cycle with minimum cost. 2. Let f be the minimum or maximum edges cost as the objective function. Then the Hamiltonian cycle of the GAPn which is the solution can be found in polynomial time. 3. Any GAPn has (a) n(n − 1) edges. (b) (n − 1)! complete cycles. The complete cycles can be enumerated in n different ways. Hereafter, a cycle means a complete cycle. (c) For n ≥ 4, the maximum number of coincident edges of two different complete cycles is (n-3). 4. The Research Space of GAPn is finite and numerable, and it has (n − 1)! elements and can be enumerated in n different ways. 5. Let be [ik]n+1 k=1 a given cycle of a GAPn. Then ∃! m : [1, . . . , n] → [1, . . . , n] such that the cost of the cycles do not change for an equivalent GAP'n with cost function given by c ◦ m−1 = c(m−1(·)) and [m(ik)]n+1 k=1 = [n, n − 1, . . . , 1, n], which corresponds to the first cycle of the descent enumeration of the vertices beginning with n. 6. Let be [ik]n+1 k=1 the solution cycle of a GAPn. Then ∃! m : [1, . . . , n] → [1, . . . , n] such that [n, n − 1, . . . , 1, n] is the solution of the equivalent GAPn, which corresponds to the first cycle of the descent enumeration of the vertices beginning with n. 2 7. Let be GAPn such that c(i, j) is given by the following matrix n ... 1 ... nn−2 nn−2 · 2 nn−1 nn−1 · 2 2 n · 2 ... · · · · · ·   · · · · · · ... nn−1 · (n − 1) n − 1 n · n − 1 ... nn−2 · (n − 1)   then it has a unique solution and all cycles have different cost. Important differences between GAPn and TSPn are in the following proposition. Here c denotes de objective function. Proposition 2.4. 1. For E2DTSPn, c is monotonically increasing,i.e, c(p1) ≤ c(p2) where the sequence of vertices of p1 is a subsequence of p2. 2. For GAPn, c is not monotonically increasing. 3. Let c′ ∈ R, then for any E2DTSPn, P (c(p2) ≥ c′c(p1) = c′) = 1 where P is the probability function, and p1 is a sub-path of p2. 4. Let c′ ∈ R, then for GAPn. P (c(p2) ≤ c′c(p1) = c′) > 0 where P is the probability function, and p1 is a sub-path of p2. The following propositions characterizes the probability of searching the solution by a uniform random search. GAP has n + 1, (n very large) vertices in order to simplify the notation of the results. Proposition 2.5. Given an arbitrary and large GAPn+1. Let be m = min{c(j) j is a cycle of GAPn+1}. 1. The probability of selecting a cycle j of GAPn+1 is P (j) = 1 n! . 2. 1 n! ≤ P (j c(j) ≤ m). If GAPn+1has a unique solution, j, then P (j c(j) ≤ m) = 1 n! . 3. Let be J a set of cycles of GAPn+1, and cardinality of J = n3, i.e., J ∼ O((n + 1)3). Then ∃A, 1 < A < 23 . This means P (J) ≈ 0, and (n−3)! ≤ P (J c) ≤ A(n−3)!−1 n! . Also, (n−3)!−1 A(n−3)! such that P (J c) ≈ 1. 1 A(n−3)! ≤ P (J) = n3 n! ≤ 1 Proof. 1. It follows from the basic properties of complete graph of GAPn+1. 2. It follows by the previous statement and the unique pj. 3. It follows from an appropriate approximation of n! n3 . The last proposition shows that the cycle with minimum cost is quite difficult to find it, when no other properties are used than a uniform random search. Moreover, also if the solution is in a set of Hamiltonian cycles with polynomial cardinality, to look for it has a probability almost null, and the complementary event is almost certain. It means that properties are need to trim the search space in order to estimate or to verify the solution. The main difference between GAPn and E2DTSPn is that the last one preserve a triangle reducibility property. In [2] the reducibility was described for tubes, here, this property is related triangulation containing the solution. Fig. 1 depicts an example of this cunning property of an E2DTSPn. Fig. 2 depicts the corresponding sorted cost matrix of an of the E2DTSPn. Note that the triangle reduced sorted cost matrix is elongated, implying there are very few cycles to verify the solution. 3 Figure 1: Example of a E2DTSPn Complete and its triangle reduction. Figure 2: Example of the sorted cost matrix for E2DTSPn Complete and its triangle reduction. Figure 3: Sorted cost matrix for a GAPn. The green dots are the solution. The red dots are a very closed solution 4 Proposition 2.6. Given any E2DTSPn it is triangle reducible, i.e, it exists a triangulation of the E2DTSP which preserve the solution. Proof. Because the graphs edge's values of the E2DTSPn come from distances between vertices, it is trivial to build a triangulation for any E2DTSPn over the Hamiltonian cycle which is the solution. Moreover, the triangle inequality permits to select the proper edges to avoid diagonal over the solution. This means that the reduced E2DTSPn on this triangulation has the solution of the original problem by construction. In [2] a version of the previous proposition (Prop. 6.9) was presented to prove the that E2DTSPn has an algorithm to verify the solution in polynomial time. The next proposition shows that any E2DTSPn combined with any GAPm loss any property when they are combined to create a large GAPn+m. Moreover, the class E2DTSP is a proper subset of the class GAPn, i.e., class E2DTSP ⊂ class GAP, and class GAP 6= class E2DTSP. Proposition 2.7. Given a E2DTSPn (which is triangle reducible) and a GAPm, then ∃ a large arbitrary GAPn+m which is not triangle reducible. Proof. The complete graph of a GAPn+m is builded by inserting appropriately the graphs of E2DTSPn and GAPm. The rest of edges for the n + m vertices can be added with random values. Finally, the resulting GAPn+m is not reducible because many of its edgesvalues are not from 2D distance between vertices but random values. Moreover, the graph's edge's values of the GAPn+m do not comply the triangle inequality. In similar way, we can state the following property of lacking a property to verify the solution in polynomial time for arbitrary and large GAPn. Fig .3 depicts the sorted cost matrix of a GAPn. Because of the connectivity of the vertices with similar edge' cost, there is not a simple reduction of the GAPn's graph as in the case of the E2DTSPn. Note that the fact that the sorted cost matrix is not reduced, this imply that even with a putative solution there are many cycles to compare to verify the optimality of the putative solution. Proposition 2.8. Let be GAPn, such that has an algorithm to verify the solution in polynomial time. Given any GAPm, then ∃ a large arbitrary GAPn+m which has not an algorithm to verify the solution in polynomial time. Proof. The complete graph of a GAPn+m is builded by combining appropriately the graphs of GAPn and GAPm. The rest of edges for the n + m vertices can be added with random values. The GAPn's algorithm provides a reduction of the edges of GAPn to consider its solution to get a path, but the resulting GAPn+m can change the path so the solution of GAPn is not a sub path of the solution of GAPn+m. By example, it is possible to join GAPn with two GAP m 2 , in the way that GAPn is like a tube. This case could preserve the solution of GAPn but it is not a general case. Tt is easy to see by inspection of the sorted cost matrix M that the solution of GAPn which it is founded by the polynomial time algorithm must comply to have a elongated reduction with an appropriate enumeration of the vertices, otherwise the verification of this solution it is not possible in polynomial time. This means, that only an appropriate and few edges are needed to consider for GAPn. However, with an arbitrary joining between GAPn and GAPm a lot of edges with an appropriately random values not necessarily comply with the property (if it has one) of the verifying algorithm of GAPn. In the arbitrary case it is possible that any vertices of GAPn can have better alternatives by the added edges' connection with the vertices of GAPm. By alternatives, it is not only in the sense of a greedy algorithm, here we can have a sequences of oscillating edges' random values. Therefore, it exists a GAPn+m such that it nullifies or overrules any property inhered by the polynomial time algorithm of GAPn for verifying the solution in polynomial time of GAPn+m by the addition of appropriately random values for its edges. The proposition shows that an algorithm could claim and maybe solve a NP problem but the verification without properties over an a worst case with arbitrary data can not be demonstrated or seeing in polynomial time or by inspection of the sorted cost matrix M, and if the research space could be reduced then input problem is not a arbitrary worst case with many oscillating cycles. Prop. 2.4 states why E2DTSPn's solution is easy to verify but GAPn. Proposition 2.9. Given an arbitrary and large GAPn, it has not an polynomial algorithm for verifying its solution. Proof. It is immediately from the previous proposition. 5 Conclusions and future work Here the property of reduction was extended to triangle reduction for E2DTSPn. This means that these are easy to verify the solution (and it is very possible to solve they in polynomial time) but arbitrary GAPn is not. p (cid:17), ∀p ∈ [2, m − 1]. Therefore, it is highly possible that As it stated in [1] a triangulation algorithms has O(cid:16)n it exists an algorithm to solve arbitrary and large E2DTSPn. However, the proposition 2.8 shows that arbitrary and large GAPn, has not an inherited property allowing to build an efficient algorithm for verifying the solution, moreover, to solving it. When there is not structure or properties the simple machine, the finite automata has not an efficient implementation as it described in [2]. m−1 To my best knowledge this approach to verify in polynomial time the solution is given by the frontier's position on the sorted cost matrix M. The figures here depicts the differences between E2DTSPn and GAPn. The main result is from proposition 2.8, which is the base of the argumentation why P-Class (represented by E2DTSPn) and the Hard NP-Class (represented by GAPn) have totally different complexity. The later has not polynomial complexity in the general or worst case scenario, i.e., for large and arbitrary GAPn but exponential. The result shows that does not exist a general property that allows to solve in polynomial time all Hard NP problems. For the future, no student or colleague have accepted my invitation to build the efficient algorithm for E2DTSPn using my results and by example the article [1] for building a triangulation. Finally, this closing my previous article [2] in order to solve the Noted Conjecture of the NP-Class, and I hope, it brings a promising theoretical perspective to address the construction of efficient algorithms for arbitrary NP problems. Acknowledgement To whom, it wants to share the knowledge. This work is dedicated to my family, and my friends: Roland Glowinski, Ioannis Kakadiaris, Alberto Santa- Maria, Miguel Samano, Felipe Monroy, and COGEA. References [1] N. Amenta, D. Attali, and O. Devillers. Complexity of delaunay triangulation for points on lower-dimensional polyhedra. In SODA '07: Proceedings of the eighteenth annual ACM-SIAM symposium on Discrete algorithms, pages 1106–1113, Philadelphia, PA, USA, 2007. SIAM. [2] C. Barr´on-Romero. The complexity of the np-class. ArXiv, pages arXiv:submit/0056904, [cs.CC] 11 Jun 2010, 2010. [3] R. B. D. Applegate and V. Chvatal. On the solution of traveling salesman problems. In Documenta Mathematica Journal, Journal der Deutschen Mathematiker-Vereinigung, International Congress of Mathematicians, volume III, pages 645–656, 1998. [4] G. J. Woeginger. Exact algorithms for np-hard problems: A survey. Combinatorial Optimization - Eureka, You Shrink!, LNCS, pages 185–207, 2003. 6
1307.2806
1
1307
2013-07-10T14:40:38
Packing a Knapsack of Unknown Capacity
[ "cs.DS" ]
We study the problem of packing a knapsack without knowing its capacity. Whenever we attempt to pack an item that does not fit, the item is discarded; if the item fits, we have to include it in the packing. We show that there is always a policy that packs a value within factor 2 of the optimum packing, irrespective of the actual capacity. If all items have unit density, we achieve a factor equal to the golden ratio. Both factors are shown to be best possible. In fact, we obtain the above factors using packing policies that are universal in the sense that they fix a particular order of the items and try to pack the items in this order, independent of the observations made while packing. We give efficient algorithms computing these policies. On the other hand, we show that, for any alpha>1, the problem of deciding whether a given universal policy achieves a factor of alpha is coNP-complete. If alpha is part of the input, the same problem is shown to be coNP-complete for items with unit densities. Finally, we show that it is coNP-hard to decide, for given alpha, whether a set of items admits a universal policy with factor alpha, even if all items have unit densities.
cs.DS
cs
Packing a Knapsack of Unknown Capacity Yann Disser∗, Max Klimm, Nicole Megow†, and Sebastian Stiller Department of Mathematics, Technische Universitat Berlin, Germany. {disser,klimm,nmegow,stiller}@math.tu-berlin.de. August 1, 2018 Abstract We study the problem of packing a knapsack without knowing its capacity. Whenever we attempt to pack an item that does not fit, the item is discarded; if the item fits, we have to include it in the packing. We show that there is always a policy that packs a value within factor 2 of the optimum packing, irrespective of the actual capacity. If all items have unit density, we achieve a factor equal to the golden ratio ϕ ≈ 1.618. Both factors are shown to be best possible. In fact, we obtain the above factors using packing policies that are universal in the sense that they fix a particular order of the items and try to pack the items in this order, independent of the observations made while packing. We give efficient algorithms computing these policies. On the other hand, we show that, for any α > 1, the problem of deciding whether a given universal policy achieves a factor of α is coNP-complete. If α is part of the input, the same problem is shown to be coNP-complete for items with unit densities. Finally, we show that it is coNP-hard to decide, for given α, whether a set of items admits a universal policy with factor α, even if all items have unit densities. 1 Introduction In the standard knapsack problem we are given a set of items, each associated with a size and a value, and a capacity of the knapsack. The goal is to find a subset of the items with maximum value who's size does not exceed the capacity. In this paper, we study the oblivious knapsack problem where the capacity of the knapsack is not given. Whenever we try to pack an item, we observe whether or not it fits the knapsack. If it does, the item is packed into the knapsack and cannot be removed later. If it does not fit, we discard it and continue packing with the remaining items. The central question of this paper is how much we loose by not knowing the capacity, in the worst case. The oblivious variant of the knapsack problem naturally arises whenever items are prioritized by a different entity or at a different time than the actual packing of the knapsack. A solution to the oblivious knapsack problem is a policy that governs the order in which we attempt to pack the items, depending only on the observation which of the previously attempted items did fit into the knapsack and which did not. In other words, a policy is a binary decision tree with the item that is tried first at its root. The two children of the root are the items that are tried next, which of the two depends on whether or not the first item fits the knapsack, and so ∗Supported by the Alexander von Humboldt Foundation. †Supported by the German Science Foundation (DFG) under contract ME 3825/1. 1 on. We aim for a solution that is good for every possible capacity, compared to the best solution of the standard knapsack problem for this capacity. Formally, a policy has robustness factor α if, for any capacity, packing according to the policy results in a value that is at least a 1/α-fraction of the optimum value for this capacity. We show that the oblivious knapsack problem always admits a robustness factor of 2. In fact, this robustness factor can be achieved with a policy that packs the items according to a fixed order, irrespective of the observations made while packing. Such a policy is called universal. We provide an algorithm that computes a 2-robust, universal policy in time Θ(n log n) for a given set of n items. We complement this result by showing that no robustness factor better than 2 can be achieved in general, even by policies that are not universal. In other words, the cost of not knowing the capacity is exactly 2. We give a different efficient algorithm for the case that all items have unit density, i.e., size and value of each item coincide. This algorithm produces a universal policy with a robustness factor of at most the golden ratio ϕ ≈ 1.618. Again, we show that no better robustness factor can be achieved in general, even by policies that are not universal. While good universal policies can be found efficiently, it is intractable to compute the robustness factor of a given universal policy and it is intractable to compute the best robustness factor an instance admits. Specifically, we show that, for any fixed α ∈ (1, ∞), it is coNP-complete to decide whether a given universal policy is α-robust. For unit densities we establish a slightly weaker hardness result by showing that it is coNP-complete to decide whether a given universal policy achieves a given robustness factor α. Finally, we show that, for given α, it is coNP-hard to decide whether an instance of the oblivious knapsack problem admits a universal policy with robustness factor α, even when all items have unit density. Related work In the The knapsack problem has been studied for different models of imperfect information. stochastic knapsack problem, sizes and values of the items are random variables. It is known that a policy maximizing the expected value is PSPACE-hard to compute, see Dean et al. [7]. The authors assume that the packing stops when the first item does not fit the knapsack, and give a universal policy that approximates the value obtained by an optimal, not necessarily universal, policy by a factor of 2. They also provide a non-universal policy within a factor of 3 + ε of the optimal policy. Bhalgat et al. [3] give an algorithm with an improved approximation guarantee of 8/3 + ε. They also give a PTAS for the case that it is allowed to violate the capacity of the knapsack by a factor of 1 + ε. In robust knapsack problems, a set of possible scenarios for the sizes and values of the items is given. Yu [24], Bertsimas and Sim [2], Goetzmann et al. [12], and Monaci and Pferschy [19] study the problem of maximizing the worst-case value of a knapsack under various models. Busing et al. [5] and Bouman et al. [4] study the problem from a computational point of view. Both allow for an adjustment of the solution after the realization of the scenario. Similar to our model, Bouman et al. consider uncertainty in the capacity. The notion of a robustness factor that we adopt in this work is due to Hassin and Rubin- stein [13] and is defined as the worst-case ratio of solution and optimum, over all realizations. Kakimura et al. [15] analyze the complexity of deciding whether an α-robust solution exists for a knapsack instance with an unknown bound on the number of items that can be packed. Megow and Mestre [17] study a variant of the knapsack problem with unknown capacity closely related to ours. In contrast to our model, they assume that the packing stops once the first item does not fit the remaining capacity. In this model, a universal policy with a constant robustness factor may fail 2 to exist, and, thus, Megow and Mestre resort to instance-sensitive performance guarantees. They provide a PTAS that constructs a universal policy with robustness factor arbitrarily close to the best possible robustness factor for every particular instance. The concept of obliviousness is used in various other contexts (explicitly or implicitly), such as hashing (Carter and Wegman [6]), caching (Frigo et al. [10], Bender et al. [1]) routing (Valiant and Brebner [23], Racke [21]), TSP (Papadimitriou [20], Deineko et al. [8], Jia et al, [14]), Steiner tree and set cover (Jia et al, [14]), and scheduling (Epstein et al. [9], Megow and Mestre [17]). In all of these works, the general idea is that specific parameters of a problem instance are unknown, e.g., the cache size or the set of vertices to visit in a TSP tour, and the goal is to find a universal solution that performs well for all realizations of the hidden parameters. Universal policies for the oblivious knapsack problem play a role in the design of public key cryptosystems. One of the first such systems -- the Merkle -- Hellman knapsack cryptosystem [18] -- is based on particular instances that allow for a 1-robust universal policy for the oblivious knapsack problem. The basic version of this cryptosystem can be attacked efficiently, e.g., by the famous attack of Shamir [22]. This attack uses the fact that the underlying knapsack instance has expo- nentially increasing item sizes. A better understanding of universal policies may help to develop knapsack-based cryptosystems that avoid the weaknesses of Merkle and Hellman's. 2 Preliminaries An instance of the oblivious knapsack problem is given by a set of n items I, where each item i ∈ I has a non-negative value v(i) ∈ Q≥0 and a strictly positive size l(i) ∈ Q>0. For a subset S ⊆ I of items, we write v(S) = Pi∈S v(i) and l(S) = Pi∈S l(i) to denote its total value and total size, respectively, of the items in S. A solution for instance I is a policy P that governs the order in which the items are considered for packing into the knapsack. The policy must be independent of the capacity of the knapsack, but the choice which item to try next may depend on the observations which items did and which items did not fit the knapsack so far. Formally, a solution policy is a binary decision tree that contains every item exactly once along each path from the root to a leaf. The packing P (C) ⊆ I of P for a fixed capacity C is obtained as follows: We start with P (C) = ∅ and check whether the item r at the root of P fits the knapsack, i.e., whether l(r) + l(P (C)) ≤ C. If the item fits, we add r to P (C) and continue packing recursively with the left subtree of r. Otherwise, we discard r and continue packing recursively with the right subtree of r. A universal policy Π for instance I is a policy that does not depend on observations made while packing, i.e., the decision tree for a universal policy has a fixed permutation of the items along every path from the root to a leaf. We identify a universal policy with this fixed permutation and write Π = (Π1, Π2, . . . , Πn). Analogously to general policies, the packing Π(C) ⊆ I of a universal policy Π for capacity C ≤ l(I) is obtained by considering the items in the order given by the permutation Π and adding every item if it does not exceed the remaining capacity. We measure the quality of a policy for the oblivious knapsack problem by comparing its packing with the optimal packing for each capacity. More precisely, a policy P for instance I is called α- robust for capacity C, α ≥ 1, if it holds that v(Opt(I, C)) ≤ α · v(P (C)), where Opt(I, C) denotes an optimal packing for capacity C. We say P is α-robust if it is α-robust for all capacities. In this case, we call α the robustness factor of policy P . 3 3 Solving the Oblivious Knapsack Problem In this section, we describe an efficient algorithm that constructs a universal policy for a given instance of the oblivious knapsack problem. The solution produced by our algorithm is guaranteed to pack at least half the value of the optimal solution for any capacity C. We show that this is the best possible robustness factor. The analysis of our algorithm relies on the classical modified greedy algorithm (cf. [16]). We compare the packing of our policy, for each capacity, to the packing obtained by the modified greedy algorithm instead of the actual optimum. As the modified greedy is a 2-approximation, to show that our policy is 2-robust it is sufficient to show that its packing is never worse the one obtained by the modified greedy algorithm. We briefly review the modified greedy algorithm. Let d(i) = v(i)/l(i) denote the density of item i. The modified greedy algorithm (MGreedy) for a set of items I and known knapsack capacity C first discards all items that are larger than C from I. The remaining items are sorted in non-increasing order of their densities, breaking ties arbitrarily. The algorithm then either takes the longest prefix P of the resulting sequence that still fits into capacity C, or the first item s that does not fit anymore, depending on which of the two has a greater value. In the latter case, we say that s is a swap item (for capacity C) that and C is a swap capacity. In both cases, we refer to P as the greedy set for capacity C. See Algorithm 1 for a formal description. For our analysis, it is helpful to fix the tie-breaking rule of the greedy algorithm. To this end, we assume that there is a bijection t : I → {1, 2, . . . , n}, that maps every item i ∈ I to a tie- breaking index t(i), and that the modified greedy algorithm initially sorts the items decreasingly with respect to the tuple d(·) = (d(·), t(·)), i.e., the items are sorted non-increasingly by density and whenever two items have the same density, they are sorted by decreasing tie-breaking index. In the following, for two items i, j, we write d(i) ≻ d(j) if and only if d(i) > d(j), or d(i) = d(j) and t(i) > t(j), and say that i has higher density than j. We evaluate the quality of our universal policy by comparing it for every capacity with the solution of MGreedy. This analysis suffices because of the following well-known property of the modified greedy algorithm. Theorem 1 (cf. [16]). For every instance (I, C) of the standard knapsack problem with known capacity, v(Opt(I, C)) ≤ 2 · v(MGreedy(I, C)). We are now ready to describe our algorithm Universal (Algorithm 2) that produces a universal policy tailored to imitate the behavior of MGreedy without knowing the capacity. Algorithm 1: MGreedy(I, C) Input: set of items I, capacity C Output: subset S ⊆ I such that l(S) ≤ C and v(S) ≥ v(Opt(I, C))/2 D ← hitems in {i ∈ I l(i) ≤ C} sorted decreasingly by densityi k ← max{j l({D1, . . . , Dj}) ≤ C} P ← (D1, . . . , Dk), s ← Dk+1 if v(P ) ≥ v(s) then return P else return {s} 4 Algorithm 2: Universal(I) Input: set of items I Output: sequence of items Π L ← hitems in I sorted by non-decreasing sizei Π(0) ← ∅ for r ← 1, . . . , n do if Lr is a swap item then Π(r) ← (Lr, Π(r−1)) else j ← 1 while j ≤ Π and d(Πj) ≻ d(Lr) do j ← j + 1 Π(r) ← (Π(r−1) 1 return Π(n) , . . . , Π(r−1) j−1 , Lr, Π(r−1) j , . . . ) First, Universal determines which items are swap items. It then starts with an empty per- mutation, and considers the items in order of non-decreasing sizes, inserting each item into the permutation. Swap items are always placed in front of all items already in the permutation, and all other items are inserted in front of the first item in the permutation that has a lower density. We prove the following result. Theorem 2. The algorithm Universal constructs a universal policy of robustness factor 2. Before we prove this theorem, we first analyze the structure of the permutation output by Universal in terms of density, size, and value. First, we prove that every item following a non- swap item has lower density. Lemma 3. For a sequence Π returned by Universal, we have d(Πk) ≻ d(Πk+1) for every non-swap item Πk, 1 ≤ k < n. Proof. For j ∈ {k, k + 1}, let r(j) ∈ {1, . . . , n} be the index of the iteration in which Universal inserts Πj into Π. We distinguish two cases. If r(k) < r(k + 1), then the item Πk+1 cannot be a swap item, since it would appear in front of the item Πk if it was. As each non-swap item is inserted into Π such that all items left of it are larger with respect to d, the claim follows. If r(k) > r(k + 1), since it is not a swap item, Πk is put in front of Πk+1 because it has a higher density. We prove that no item preceding a swap item has smaller size. Lemma 4. For a permutation Π returned by Universal, we have l(Πj) ≥ l(Πk) for every swap item Πk, 1 < k ≤ n, and every other item Πj, 1 ≤ j < k. Proof. Since Πk is a swap item, it stands in front of all items inserted earlier into Π. Hence, all items that appear in front of Πk in Π have been inserted in a later iteration of Universal. Since Universal processes items in order of non-decreasing sizes, we have l(Πj) ≥ l(Πk). We prove that no item preceding a swap item has smaller value. 5 Lemma 5. For a permutation Π returned by Universal, we have v(Πj) ≥ v(Πk) for every swap item Πk, 1 < k ≤ n, and every other item Πj, 1 ≤ j < k. Proof. We distinguish three cases. First case: Πj is a swap item and d(Πj) ≥ d(Πk). By Lemma 4, we have l(Πj) ≥ l(Πk), and the claim trivially holds. Second case: Πj is a swap item and d(Πj ) < d(Πk). Since Πj is a swap item, there is a capacity C ≥ l(Πj) such that v(Πj) > v({i ∈ I l(i) ≤ C and d(i) ≻ d(Πj)}). In particular, for C = l(Πj) we obtain v(Πj ) > v({i ∈ I l(i) ≤ l(Πj) and d(i) ≻ d(Πj)}). (1) Since, by Lemma 4, l(Πj) ≥ l(Πk), the item Πk is included in the set on the right hand side of (1). We conclude that v(Πj) > v(Πk). Third case: Πj is not a swap item. Let Πj′ be the first swap item after Πj in Π, i.e., j′ = min{i ∈ {j + 1, . . . , k} Πi is a swap item }. Note that the minimum is attained as Πk is a swap item. The analysis of the first two cases implies that v(Πj′) ≥ v(Πk). By Lemma 3 we have d(Πj ) ≥ d(Πj+1) ≥ · · · ≥ d(Πj′), and by Lemma 4 we have l(Πj) ≥ l(Πj′). Hence, v(Πj) ≥ v(Πj′) ≥ v(Πk). Finally, the next lemma gives a legitimation for the violation of the density order in the output permutation. Essentially, whenever an item precedes denser items, we guarantee that it is worth at least as much as all of them combined. Lemma 6. For a permutation Π returned by Universal, we have for every item Πk, 1 ≤ k < n. v(Πk) ≥ v(cid:0)(cid:8)Πj j > k and d(Πj) ≻ d(Πk)(cid:9)(cid:1) Proof. We distinguish whether Πk is a swap item, or not. If Πk is a swap item, by definition, Πk is worth more than the greedy set for some capacity C ≥ l(Πk). Thus, v(Πk) > v(cid:0)(cid:8)Πj l(Πj) ≤ C and d(Πj) ≻ d(Πk)(cid:9)(cid:1) ≥ v(cid:0)(cid:8)Πj l(Πj) ≤ l(Πk) and d(Πj) ≻ d(Πk)(cid:9)(cid:1). Since items whose size is strictly larger than l(Πk) are inserted into Π at a later iteration of Universal, they can only end up behind Πk if they are smaller with respect to d. Hence, {Πj j > k and d(Πj) ≻ d(Πk)} ⊆ {Πj l(Πj) ≤ l(Πk) and d(Πj) ≻ d(Πk)}, and thus v(Πk) > v({Πj j > k and d(Πj) ≻ d(Πk)}), as claimed. If, on the other hand, Πk is not a swap item, let Πk′ be the first swap item after it in Π. If no such item exists, the claim holds by Lemma 3, since (cid:8)Πj j > k and d(Πj) ≻ d(Πk)(cid:9) = ∅. 6 Otherwise, by Lemma 3, we obtain d(Πk) ≻ d(Πk+1) ≻ · · · ≻ d(Πk′) and hence {Πj j > k and d(Πj) ≻ d(Πk)} = {Πj j > k′ and d(Πj) ≻ d(Πk)} ⊆ {Πj j > k′ and d(Πj) ≻ d(Πk′)}. Consequently, and by the argument above for swap items, v(Πk′) > v({Πj j > k′ and d(Πj) ≻ d(Πk′)}) ≥ v({Πj j > k and d(Πj) > d(Πk)})). Finally, by Lemma 5, we have v(Πk) ≥ v(Πk′) ≥ v({Πj j > k and d(Πj) ≻ d(Πk)}). We now prove Theorem 2. of Theorem 2. We show that for every set of items I, the permutation Π = Universal(I) satisfies v(Opt(I, C)) ≤ 2v(Π(C)) for every capacity C ≤ l(I). By Theorem 1, it suffices to show v(Π(C)) ≥ v(MGreedy(I, C)) for all capacities. We distinguish between swap capacities and capacities where MGreedy outputs a greedy set. First, assume that C is a swap capacity, and let {Πk} = MGreedy(I, C) be the swap item returned by the modified greedy algorithm. Then, Π(C) contains at least one item Πj with j ≤ k. By Lemma 5 we have v(Π(C)) ≥ v(Πj) ≥ v(Πk) = v(MGreedy(I, C)). Now assume that C is not a swap capacity. Let G+ = MGreedy(I, C) \ Π(C) be the set of items in the greedy set for capacity C that are not packed by the permutation Π. Similarly, let U + = Π(C) \ MGreedy(I, C). If G+ = ∅, then v(Π(C)) ≥ v(MGreedy(I, C)) and we are done. Suppose now that G+ 6= ∅. Then, also U + 6= ∅. For all items i ∈ U +, we have l(i) ≤ C and i /∈ MGreedy(I, C). Since C is not a swap capacity, MGreedy(I, C) is the greedy set for capacity C, and thus d(i) ≺ d(i′) for all i ∈ U + and i′ ∈ G+. By definition of Π(C) and since U + 6= ∅, we also have k = min{j Πj ∈ U +} < min{k′ Πk′ ∈ G+}, i.e., the first item Πk ∈ U + in Π is encountered before every item from G+. It follows that Using v(U +) ≥ v(Πk) and v(Πk) ≥ v(G+) (Lemma 6) we get G+ ⊆(cid:8)Πj j > k and d(Πj) ≻ d(Πk)(cid:1)(cid:9). v(Π(C)) = v(cid:0)Π(C) ∩ MGreedy(I, C)(cid:1) + v(U +) ≥ v(cid:0)Π(C) ∩ MGreedy(I, C)(cid:1) + v(G+) = v(MGreedy(I, C)). While it is obvious that Universal runs in polynomial time, we show that it can be modified to run in time Θ(n log n). Theorem 7. The algorithm Universal can be implemented to run in time Θ(n log n). Proof. We first argue how all swap items can be determined in time Θ(n log n). We use that an item is a swap item if and only if it is worth more than all smaller items of higher density combined. This is true, because every item i that is worth more than all smaller items of higher density is a 7 swap item for capacity l(i). Conversely, a swap item i for capacity C ≥ l(i) is worth more than all items of higher density that are smaller than C. We maintain a balanced search tree for items that is ordered by size and stores the total value of the items of both subtrees in the corresponding root. Inserting an item into this tree as well as determining whether an item is worth more than all smaller items in the tree both takes time Θ(log n). To determine the set of swap items, we iterate over all items in order of decreasing densities and insert items one by one into the search tree. After each insertion, we query whether the newly inserted item is worth more than all smaller items in the tree. This is true if and only if the item is worth more than all smaller items of higher density, i.e., if and only if the item is a swap item. Including the initial sorting by density, we can determine all swap items in time Θ(n log n). We construct the output permutation Π by iterating over the items in order of increasing size, as in Algorithm 2. We maintain a list L of balanced search trees, each ordered by density. Except for the last tree in L, every tree contains exactly one swap item, which is the item of smallest density in the tree. The density of a tree is the density of this swap item (or 0 if the tree has no swap item). Each tree stores the items in Π to the left of the corresponding swap item (if it exists) and to the right of the swap item of the preceding tree in L (if it exists). We start with a list containing a single tree with no corresponding swap item, which eventually holds all non-swap items that end up behind the last swap item in Π. Whenever we encounter a new swap item, we add a new tree consisting of only this swap item to the front of L. For each non-swap item, we have to find the correct tree to insert it into. Once we know the tree, we can determine the position at which to insert the item into the tree, and thus in Π, in time Θ(log n) simply by searching the tree. To complete the proof, we need an efficient way to find the correct tree in L for a non-swap item. For this purpose, we maintain a sublist L′ of L that contains only those trees that are needed for the remainder of the algorithm. Whenever a new swap item s adds a tree to the front of L, we also add the tree to the front of L′. Observe that from this point on no items are inserted into trees of a higher density than s. Hence, before inserting the tree of s to L′, we may remove trees of higher density from the front of L′. This guarantees that L′ remains sorted by density. We can thus implement L′ as a balanced search tree order by density. This way, we can find the correct tree for each non-swap item in time Θ(log n). Since every tree is removed at most once from L′, the amortized cost for maintaining the sublist is constant for each swap item. Since Universal requires n iterations, the total running time is Θ(n log n). We now give a general lower bound on the robustness factor of any policy for the oblivious knapsack problem. This shows that Universal is best possible. Theorem 8. For every δ > 0, there are instances of the oblivious knapsack problem where no policy achieves a robustness factor of 2 − δ. Proof. We give a family of instances, one for each size n ≥ 3. We ensure that for every item i of the instance of size n, there is a capacity C, such that packing item i first can only lead to a solution that is worse than Opt(I, C) by a factor of at least (2 − 4/n). This completes the proof, as the factor approaches 2 for increasing values of n. The instance of size n is given by I = {1, 2, . . . , n} with l(i) = Fn + Fi − 1, v(i) = 1 + i n , where Fi denotes the i-th Fibonacci number (F1 = 1, F2 = 1, F3 = 2, . . . ). We need to show that, no matter which item is tried first (i.e., no matter which item is the root of the policy), there is a capacity for which this choice ruins the solution. Observe that both values and 8 Algorithm 3: UniversalUD(I) Input: set of items I Output: sequence of items Π L ← hitems in I sorted such that L1 ≺ · · · ≺ Lni Π(0) ← ∅ for r ← 1, . . . , n do j ← 1 while j ≤ Π and v(Lr) < ϕv(Π(r−1) j ) do j ← j + 1 Π(r) ← (Π(r−1) 1 return Π(n) , . . . , Π(r−1) j−1 , Lr, Π(r−1) j , . . . ) sizes of the items are strictly increasing. Assume that item i ≥ 3 is packed first. Since the smallest item has size l(1) = Fn, for capacity Ci = 2Fn +Fi −2 < 2Fn +Fi −1 = l(1)+l(i), no additional item fits the knapsack. However, the unique optimum solution in this case is Opt(I, Ci) = {i − 1, i − 2}. These two items fit the knapsack, as l(i − 1) + l(i − 2) = 2Fn + Fi−1 + Fi−2 − 2 = 2Fn + Fi − 2 = Ci. By definition, v(i − 1) + v(i − 2) vi = 2n + 2i − 3 n + i = 2 − 3 n + i ≥ 2 − 3 n . Hence, policies that first pack item i ≥ 3 do not achieve a robustness factor α < 2 − 3/n. Now, assume that one of the two smallest items is packed first. For capacity C1,2 = l(n) = 2Fn − 1 < 2Fn = l(1) + l(2), no additional item fits the knapsack. The unique optimum solution, however, is to pack item n. It remains to compute the ratios v(n) v(1) > v(n) v(2) = 2n n + 2 = 2 − 4 n + 2 > 2 − 4 n . Hence, policies that first pack item 1 or item 2 do not achieve a robustness factor α < 2 − 4/n. 4 Unit Densities In this section we restrict ourselves to instances of the oblivious knapsack problem, where all items have unit density, i.e., v(i) = l(i) for all items i ∈ I. For two items i, j ∈ I we say that i is smaller than j and write i ≺ j if v(i) < v(j), or v(i) = v(j) and t(i) < t(j), where t is the tiebreaking index introduced in Section 3. We give an algorithm UniversalUD (cf. Algorithm 3) that produces a universal policy tailored to achieve the best possible robustness factor equal to the golden ratio ϕ ≈ 1.618. The algorithm considers the items from smallest to largest, and inserts each item into the output sequence as far to the end as possible, such that the item is not preceded by other items that are more than a factor ϕ smaller. Intuitively, the algorithm tries as much as possible to keep the resulting order sorted increasingly by size; only when an item dominates another item by a factor of at least ϕ the algorithm ensures that it precedes this item in the final sequence. Note that, even though ϕ is irrational, for rationals a, b the condition a < ϕb can be tested efficiently by testing the equivalent condition a/b < 1 + b/a. Theorem 9. The algorithm UniversalUD constructs a universal policy of robustness factor ϕ when all items have unit density. 9 Proof. Given an instance I of the oblivious knapsack problem with unit densities and any capacity C ≤ v(I), we compare the packing Π(C) that results from the solution Π = UniversalUD(I) with an optimal packing Opt(I, C). We define the set M of items in Π(C) for which at least one smaller item is not in Π(C), i.e., more precisely, let M = {i ∈ Π(C) ∃j ∈ I\Π(C) : j ≺ i}. We first consider the case that M 6= ∅ and set i = min≺ M to be the smallest item in M with respect to '≺'. Consider the iteration r of UniversalUD in which i is inserted into Π, i.e., i = Lr. By definition of M , there is an item j ≺ i with j /∈ Π(C). Let j be the first such item in Π. Since j ≺ i, we have j ∈ Π(r). From i ∈ Π(C) and j /∈ Π(C), it follows that i precedes j in Π (and thus in Π(r)). Let i′ be the item directly preceding j in Π(r). If i′ = i, i was compared with j when it was inserted into Π(r), with the result that v(i) ≥ ϕv(j) and thus v(Π(C)) ≥ ϕv(j). If i′ 6= i, by definition of j, we still have i′ ∈ Π(C). Also, either i′ ≻ j and thus v(i′) ≥ v(j), or j was compared with i′ when it was inserted into Π in an earlier iteration of UniversalUD, with the result that v(i′) > 1 ϕ v(j). Again, v(Π(C)) ≥ v(i) + v(i′) > v(j) + 1 ϕ v(j) = ϕv(j). In both cases it follows from j /∈ Π(C) that v(Opt(I, C)) ≤ C < v(Π(C)) + v(j), and using v(j) ≤ 1 ϕ v(Π(C)) we get v(Opt(I, C)) v(Π(C)) < v(Π(C)) + v(j) v(Π(C)) < 1 + 1 ϕ = ϕ. Now, assume that M = ∅. Intuitively, this means that Π(C) consists of a prefix of L (the smallest items). Let i1 ≻ · · · ≻ ik be the items in Π(C) \ Opt(I, C), and let j1 ≻ · · · ≻ jl be the items in Opt(I, C) \ Π(C). As Π(C) consists of a prefix of L, we have Π(C) ≥ Opt(I, C) and thus k ≥ l. If k = 0, the claim trivially holds. Otherwise, since M is empty, we have jl ≻ i1. Is suffices to show v(jh) ≤ ϕv(ih) for all h ≤ l. To this end, we consider any fixed h ≤ l. From v({i1, . . . , ih−1}) ≤ v({j1, . . . , jh−1}) it follows that v(jh) ≤ v(Opt(I, C)) − v({j1, . . . , jh−1}) ≤ C − v({i1, . . . , ih−1}). This implies that jh cannot precede all items of {ih, . . . , ik} in Π, as jh /∈ Π(C). Hence, there is an item i ∈ {ih, . . . , ik} that precedes jh in Π. Since jh ≻ i, in the iteration when UniversalUD inserted jh into Π, i was already present. From the fact that i ended up preceding jh it follows that jk was compared with i and thus v(jh) < ϕv(i) ≤ ϕv(ih). We obtain v(Opt(I, C)) v(Π(C)) ≤ v(Opt(I, C) \ Π(C)) v(Π(C) \ Opt(I, C)) which implies the result. h=1 v(jh) h=1 v(ih) = Pl Pk h=1 ϕv(ih) h=1 v(ih) ≤ Pl Pl = ϕ, A naıve implementation of UniversalUD runs in time Θ(n2). We improve this running time to Θ(n log n). Theorem 10. The algorithm UniversalUD can be implemented to run in time Θ(n log n). Proof. To improve the running time from the naıve Θ(n2), we maintain a balanced search tree T that stores a subset of the items in Π sorted decreasingly by their sizes. Whenever an item gets inserted to the front of Π, and only then, we also insert it into T . This way, the items in T remain sorted by their positions in Π throughout the execution of the algorithm. We need an efficient way of finding, in each iteration r of UniversalUD (Algorithm 3), the first item i in Π(r) for which v(Lr) ≥ ϕv(i), or detecting that no such item exists. We claim that, if such an item exists, it is stored in T and can thus be found in time Θ(log n). 10 It suffices to show that for every item i ∈ T and its predecessor j in T we have that none of the items that precede i in Π are smaller than j. To see this, we argue that none of the items between j and i in Π are smaller than j. We can then repeat the argument for j and its predecessor j′, etc. For the sake of contradiction, let i′ be the first item between j and i with v(i′) < v(j). None of the items between j and i′ are smaller than j, hence both j and i′ are inserted into Π earlier than all of them. Let r be the iteration in which j is inserted into Π. Since i′ is inserted earlier into Π, and since j is inserted to the front of Π(r), i′ is at the front of Π(r−1). This is a contradiction to i′ not being in T . We now establish that UniversalUD is best possible, even if we permit non-universal policies. Theorem 11. There are instances of the oblivious knapsack problem where no policy achieves a robustness factor of ϕ − δ, for any δ > 0, even when all items have unit density. Proof. Consider an instance of the oblivious knapsack problem with five items of unit density and values equal to v1 = 1 + ε, v2 = 1 + ε, v3 = 2/ϕ, v4 = 1 + 1/ϕ2, v5 = ϕ, for sufficiently small ε > 0. We show that no algorithm achieves a robustness factor of ϕ − δ for this instance. To this end we consider an arbitrary algorithm A and distinguish different cases depending on which item the algorithm tries to pack first. (a) If A tries item 1 or item 2 first, it cannot fit any additional item for a capacity equal to v5 = ϕ, as even v1 + v2 > ϕ. For this capacity A is worse by a factor of ϕ/(1 + ε) > ϕ − δ than the optimum solution, which packs item 5. (b) If A tries item 3 first, it cannot fit any additional item for a capacity equal to v1 + v2 = 2 + 2ε, as even v3 + v1 > 2 + 2ε. For this capacity A is worse by a factor of (1 + ε)ϕ > ϕ − δ than the optimum solution which packs items 1 and 2. (c) If A tries item 4 first, it cannot fit any additional item for a capacity equal to v2 + v3 = 1 + 2/ϕ + ε, as even v4 + v1 = 2 + 1/ϕ2 + ε > 1 + 2/ϕ + ε. For this capacity A is worse by a factor of 1+2/ϕ+ε 1+1/ϕ2 = ϕ > ϕ − δ than the optimum solution which packs items 2 and 3. 1+1/ϕ2 > ϕ+1/ϕ (d) If A tries item 5 first, it cannot fit any additional item for a capacity equal to v3 + v4 = ϕ + 1, ϕ = ϕ > ϕ−δ as even v5 +v1 = ϕ+1+ε > ϕ+1. For this capacity A is worse by a factor of ϕ+1 than the optimum solution which packs items 3 and 4. 5 Hardness Although we can always find a 2-robust universal policy in polynomial time, we show in this section that, for any fixed α ∈ (1, ∞), it is intractable to decide whether a given policy is α-robust, even if it is universal. This hardness result also holds for instances with unit densities when α is part of the input. As the final -- and arguably the most interesting -- result of this section, we establish coNP-hardness of the the problem to decide for a given instance and given α > 1, whether the instance admits a universal policy with robustness factor α. All proofs rely on the hardness of the following version of SubsetSum. 11 Lemma 12. Let W = {w1, w2, . . . , wn} be a set of positive integer weights and T ≤ Pn a target sum. The problem of deciding whether there is a subset U ⊆ W with Pw∈U w = T is NP-complete, even when k=1 wk be 1. T = 2k for some integer k ≥ 3, (a) all weights are in the interval [2, T /2), (b) all weights have a difference of at least 2 to the closest power of 2. Proof. Without Properties 1 to 1b, the SubsetSum problem is well known to be NP-complete (e.g., Garey and Johnson [11]). Given an instance (W, T ) of this classical problem, we construct an equivalent instance with Properties 1 to 1b. We first multiply all weights in W as well as the target sum T with 6 to obtain an equivalent instance (W ′, T ′). In the new instance, all weights are even but not a power of 2, hence they have distance at least 2 to the closest power of 2. We set T ′′ = 2σ, with σ =(cid:6)log2(T ′ +Pw′∈W ′ w′)(cid:7) + 2 and define two new weights u =(cid:22) T ′′ − T ′ 2 (cid:25) . (cid:23) , w =(cid:24) T ′′ − T ′ 2 We set W ′′ = W ′ ∪ {u, w} to obtain the final instance (W ′′, T ′′). Properties 1 and 1a are satisfied by construction. Also, any solution to the instance (W ′′, T ′′) has to include both u and w, since T ′′ > 4 ·Pw′∈W ′ w′. Hence, the instance remains equivalent to the original instance (W, T ). Since T ′′ − T ′ > 3T ′′/4, and since T ′′ is a power of two, the new items u and w are far enough from the closest power of 2 (which either is T ′′/2 or T ′′/4). We first show that it is intractable to determine the robustness factor of a given universal policy. Theorem 13. For any fixed and polynomially representable α > 1 it is coNP-complete to decide whether a given universal policy for the oblivious knapsack problem is α-robust. Proof. Regarding the membership in coNP, note that if a universal policy Π is not α-robust, then there is a capacity C such that v(Π(C)) < v(Opt(I, C))/α. Thus, C together with Opt(I, C) is a certificate for Π not being an α-robust solution. For the proof of coNP-hardness, we reduce from the variant of SubsetSum specified in Lemma 12. An instance of this problem is given by a set W = {w1, w2, . . . , wn} of positive integer weights in the range [2, T /2) and a target sum T = 2k for some integer k ≥ 3. Let α > 1 be polynomially representable. We may assume without loss of generality that α > T T −1 as we can ensure this property by multiplying T and all items in W by a sufficiently large power of 2. We construct an instance I and a sequence Π such that Π is an α-robust universal policy for I if and only if the instance of SubsetSum given by W and T has no solution. To this end, we introduce for each weight w ∈ W an item with value and size equal to w. In this way, the optimal knapsack solution for capacity T is at least T if the instance of SubsetSum has a solution. Furthermore, we introduce a set of additional items that make sure that the robustness factor for all capacities except T is at most α while maintaining the property that the optimal knapsack solution for capacity T is strictly less than T if the instance of SubsetSum has no solution. We now explain the construction of I and Π is detail. Let ε = α(T −1)−T (T −1)(1−ε) . Note that ε ∈ (0, 1) by our assumptions on T and α. For each weight w ∈ W , we introduce an item iw with l(iw) = v(iw) = w. The set of these items is called regular and is denoted by Ireg. Furthermore, we introduce a set of auxiliary items. Let m = log2 T − 1. Then, for each α(T −1)−1 , i.e., α = T −ε 12 k ∈ {0, 1, . . . , m}, we introduce an auxiliary item jk with size l(jk) = 2k and value v(jk) = 2k (1−ε). k=0 2k = T − 1. Finally, we Denoting the set of auxiliary items by Iaux, we have l(Iaux) = Pm introduce a dummy item d with l(d) = T + 1 and v(d) = 1 − ε ε (v(Iaux) + v(Ireg)) = 1 − ε ε (T − 1)(1 − ε) + Xw∈W w!. The universal policy Π is defined as Π = (d, jm, jm−1, . . . , j0, iwn, iwn−1, . . . , iw1). The hardness proof relies on the claim that Π is a 1 1−ε -robust universal policy for all capacities except T , i.e., v(Opt(I, C)) ≤ 1 1 − ε v(Π(C)) for all C 6= T. (2) As all item sizes are integer, it suffices to consider integer capacities. To prove (2), let us first consider capacities C ≤ T − 1. Since the density of each item with size not larger than T − 1 is bounded from above by 1, it is sufficient to show that v(Π(C)) = C(1−ε). To this end, we show that every capacity C ∈ {1, . . . , 2m+1−1 = T −1} is packed without a gap by the exponentially decreasing sequence of items jm, jm−1, . . . , j0. We prove this statement by induction over m. For m = 0, the statement is true, since there is only a single item with length 1, which packs the capacity C = 1 optimally. Now assume that the statement is true for all m′ < m and consider the sequence jm, jm−1, . . . , j0. We distinguish two cases. For capacities C ∈ {2m, . . . , 2m+1−1}, item jm is packed and, using the induction hypothesis, the residual capacity C = C − 2m ≤ 2m+1 − 1 − 2m ≤ 2m − 1 can be packed without a gap by the remaining sequence jm−1, jm−2, . . . , j0. For capacities C < 2m, item jm is not packed, and, again using the induction hypothesis, we derive that C can be packed by jm−1, . . . , j0. This completes the proof of our claim for C ≤ T − 1. Let us now consider our claim for capacities C ≥ T + 1. In this case, d ∈ Π(C) and we can trivially bound the robustness factor of Π by observing that v(Opt(I, C)) v(Π(C)) ≤ v(I) v(d) = 1 + (T − 1)(1 − ε) +Pw∈W w v(d) = 1 + ε 1 − ε = 1 1 − ε . We proceed to show that Π is an α-robust universal policy if and only if the instance of Subset- Sum given by W and T has no solution. Let us first assume that the instance of SubsetSum has no solution. We prove that Π is α-robust. For all capacities except T this is clear from claim (2). For capacity T , we argue as follows: As there is no packing of T with items of density 1, we bound v(Opt(I, T )) from above by (T − 1) + (1 − ε), whereas Π packs all auxiliary items. We get v(Opt(I, T )) v(Π(T )) ≤ (T − 1) + (1 − ε) (T − 1)(1 − ε) = α. Now, assume that the instance of SubsetSum has a solution. Then, v(Opt(T )) = T and thus v(Opt(I, T )) v(Π(T )) = T (T − 1)(1 − ε) > α, and we conclude that Π is not α-robust. We give a result similar to Theorem 13 for instances in which each item has unit density. Note that this time we require α to be part of the input. 13 Theorem 14. It is coNP-complete to decide whether, for given α > 1, a given universal policy for the oblivious knapsack problem is α-robust, even when all items have unit density. Proof. Membership in coNP follows from Theorem 13. To prove hardness, we again reduce from SubsetSum (Lemma 12) using a similar construction as in the proof of Theorem 13. Let the set W = {w1, . . . , wn} of weights and the target sum T ≥ 8 of an instance of SubsetSum be given, with w1 ≤ w2 ≤ · · · ≤ wn. We proceed to explain the construction of a universal policy Π for which the decision whether Π is α-robust is coNP-hard, for some α > 1. For each weight w ∈ W , we introduce an item iw with value v(iw) = w. The set of these items is called regular and is denoted by Ireg. Let m = log2 T − 1 and ε = 1/T 2. For each k ∈ {0, . . . , m}, we introduce an auxiliary item jk with value v(jk) = 2k(1 − ε). Denoting the set of auxiliary items k=0 2k = (1 − ε)(T − 1). We further introduce a set of dummy items Idum = {d0, . . . , dm′ }, where m′ = ⌈log2 wn⌉. We set v(dk) = T · 2k for each k ∈ {1, . . . , m′}, k=1 2k = by Iaux, we have v(Iaux) = (1 − ε)Pm and v(d0) = T + ε. The values of the dummy items sum up to v(Idum) = (T + ε) + T Pm′ T (2m′+1 − 1) + ε. In total, the sum of the values of all dummy and auxiliary items is S = v(Iaux) + v(Idum) = (1 − ε)(T − 1) + T (2m′+1 − 1) + ε. (3) Finally, we define the sequence Π as Π = (dm′ , dm′−1, . . . , d0, jm, jm−1, . . . , j0, iwn, iwn−1 , . . . , iw1 ), i.e., Π first tries to pack the dummy items in decreasing order, then the auxiliary items in decreasing (1−ε)(T −1) . We proceed to order, and finally the regular items in non-increasing order. Let α = prove the statement of the theorem by showing that Π is an α-robust universal policy if and only if the instance (W, T ) of SubsetSum has no solution. To this end, we first prove that Π is always an α-robust universal policy for all capacities except the critical capacities in the interval T −ε (cid:2)T − εT, T + ε(cid:1). Then, we argue that Π is α-robust for the critical capacities if and only if the instance (W, T ) of SubsetSum has no solution. We start by proving that v(Π(C)) is within an α-fraction of v(Opt(C)) for all capacities C ∈ [0, T − εT ). Since the regular items are of integer values and the values of the auxiliary items each are an (1 − ε)-fraction of an integer, only capacities C for which the ratio C/⌈C⌉ is not smaller than 1 − ε can be packed without a gap. Otherwise, the value of an optimal solution is bounded from above by ⌊C⌋. For capacities C ∈ [0, T − εT ), we obtain v(Opt(I, C)) ≤(C, ⌊C⌋, if C/⌈C⌉ ≥ 1 − ε otherwise. The value packed by Π is given by v(Π(C)) =((1 − ε)⌈C⌉, (1 − ε)⌊C⌋, if C/⌈C⌉ ≥ 1 − ε otherwise. From (4) and (5) it follows that v(Opt(I, C)) ≤ 1 1 − ε v(Π(C)) < α v(Π(C)) (4) (5) (6) for all C ∈ [0, T − εT ). We proceed to prove that Π is within an α-fraction of an optimal solution for all capacities C ∈ [T + ε, S]. We distinguish two cases for each such capacity C. 14 First case: Iaux ⊂ Π(C), i.e., all auxiliary items are packed by Π. Since, in Π, the dummy item d0 with value T + ε precedes all auxiliary items, and since C ≥ T + ε, this case can only occur for capacities C ≥ v(d0) + v(Iaux) = T + ε + (1 − ε)(T − 1) = 2(T + ε) − (1 + εT ). (7) On the other hand, the gap C − v(Π(C)) is at most the gap left after trying all dummy items and packing all auxiliary items, i.e., C − v(Π(C)) < v(d0) − v(Iaux) = T + ε − (1 − ε)(T − 1) = 1 + εT . Thus, v(Opt(I, C)) v(Π(C)) < C C − (1 + εT ) (7) ≤ 2(T + ε) − (1 + εT ) 2(T + ε) − 2(1 + εT ) = (T + ε) − (1 + εT )/2 (T + ε) − (1 + εT ) T ≥8 < T − ε (1 − ε)(T − 1) = α. Second case: Iaux \ Π(C) 6= ∅, i.e., not all auxiliary items are packed. This implies that the gap C − v(Π(C)) is at most 1 − ε. We calculate v(Opt(I, C)) v(Π(C)) < C C − (1 − ε) C≥T +ε ≤ T + ε T + 2ε − 1 ε=1/T 2 < T − ε (1 − ε)(T − 1) = α. Next, we consider capacities C ∈ (S, v(Iaux ∪ Idum ∪ Ireg)]. For these capacities, all dummy items and all auxiliary items are packed by Π. Using that the gap C − Π(C) is at most wn, we obtain v(Opt(I, C)) v(Π(C)) ≤ C C − wn C>S < S S − wn S>T 2m′ < T 2m′ T 2m′ − wn ≤ T wn T wn − wn = T T − 1 = T (1 − ε) (1 − ε)(T − 1) < T − ε (1 − ε)(T − 1) = α. To finish the proof, let us finally consider the critical capacities C ∈(cid:2)T −T ε, T +ε(cid:1). We proceed to show that v(Π(C)) is within an α-fraction of v(Opt(C)) for all C ∈(cid:2)T − T ε, T + ε(cid:1) if and only if (W, T ) does not have a solution. Let us first assume that (W, T ) does not have a solution. Then, v(Opt(C)) ≤ T − ε and we obtain v(Opt(I, C)) v(Π(C)) ≤ T − ε (T − 1)(1 − ε) = α, for all C ∈ (cid:2)T − T ε, T + ε(cid:1). If, on the other hand, (W, T ) has a solution, then v(Opt(T )) = T , implying that v(Opt(I, T )) v(Π(T )) = T (T − 1)(1 − ε) > α, i.e., Π is not an α-robust universal policy. Finally, we prove that it is hard to decide whether a given instance admits an α-robust universal policy when α is part of the input. 15 Theorem 15. It is coNP-hard to decide whether, for given α > 1, an instance of the oblivious knapsack problem admits an α-robust universal policy, even when all items have unit density. Proof. We again reduce from SubsetSum. To this end, let (W, T ) be an instance of Subset- Sum (Lemma 12), let I be the set of items constructed from (W, T ) in the proof of Theorem 14, (1−ε)(T −1) . We proceed to show that I admits an α-robust universal policy if and only and let α = if the instance (W, T ) of SubsetSum has no solution. T −ε For the case that (W, T ) has no solution, an α-robust universal policy is constructed in the proof of Theorem 14. Thus, it suffices to show that if (W, T ) has a solution, I does not admit an α-robust universal policy. First, we claim that any α-robust universal policy Π contains the auxiliary items in decreasing order. Otherwise, for the sake of contradiction, let j be the first auxiliary item in Π that is preceded by a smaller auxiliary item i. Consider the capacity C = v(j). As all dummy items are larger than T > C, only auxiliary and regular items can be in Π(C). Since i precedes j, we have j /∈ Π(C). If Π(C) contains only auxiliary items, since the sum of the values of the auxiliary items smaller than v(j) is v(j) − (1 − ε), we can use that j /∈ Π(C) to obtain v(Π(C)) ≤ v(j) − (1 − ε) < ⌊v(j)⌋. If Π(C) contains a regular item i′, then C−v(i′) ⌈C−v(i′)⌉ < 1 − ε, and hence the gap C − v(i′) cannot be packed with a value more than ⌊C − v(i′)⌋. It follows that v(Π(C)) ≤ ⌊v(j)⌋. In either case we have v(Opt(I, C)) v(Π(C)) ≥ v(j) ⌊v(j)⌋ v(j)≤(1−ε)T /2 ≥ (1 − ε)T /2 ⌊(1 − ε)T /2⌋ = (1 − ε)T /2 T /2 − 1 ε=1/T 2 > T − ε (T − 1)(1 − ε) = α. This is a contradiction to the assumption that Π is α-robust. We conclude that the auxiliary items appear in Π in decreasing order. Second, we claim that if Π(T ) contains a regular item, then Π is not α-robust. By the argument above, we may assume that the auxiliary items in Π are ordered decreasingly. Let i be the regular item contained in Π(T ) that appears first in Π. Consider the capacity C = (v(i) + 1)(1 − ε). The auxiliary items that appear before i in Π (if any) are ordered decreasingly. All of them must be larger than v(i), otherwise, the gap left after packing them for capacity T would be too small to fit i. By Lemma 12, we have that neither v(i) nor v(i) + 1 are a power of 2, thus Π(C) does not contain any of the auxiliary items preceding i. All regular items that appear before i in Π are larger than v(i), since they are not in Π(T ). Hence, Π(C) does not contain any regular items except i. We conclude that Π(C) = {i}. On the other hand, C is an integer multiple of 1 − ε and can be packed without a gap by auxiliary items only. We obtain v(Opt(C)) v(Π(C)) = C v(i) = (v(i) + 1)(1 − ε) v(i) v(i)≤T /2 ≥ (T /2 + 1)(1 − ε) T /2 ε=1/T 2 > α. We conclude that if an α-robust universal policy Π exists, then Π(T ) does not contain regular items. It follows that Π(T ) = Iaux and, thus, v(Π(T )) = (T − 1)(1 − ε). Using that the SubsetSum instance (W, T ) has a solution, we obtain v(Opt(I, T )) v(Π(T )) ≥ T (T − 1)(1 − ε) > α, which implies that no α-robust universal policy exists. 16 References [1] M. A. Bender, R. Cole, and E. D. Demaine. Scanning and traversing: maintaining data In Proceedings of the 10th European Symposium on for traversals in a memory hierarchy. Algorithms (ESA), pages 139 -- 151, 2002. [2] D. Bertsimas and M. Sim. Robust discrete optimization and network flows. Mathematical Programming, 98:49 -- 71, 2003. [3] A. Bhalgat, A. Goel, and S. Khanna. Improved approximation results for stochastic knapsack problems. In Proceedings of the 22nd Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1647 -- 1665, 2011. [4] P. C. Bouman, J. M. van den Akker, and J. A. Hoogeveen. Recoverable robustness by column generation. In Proceedings of the 19th European Symposium on Algorithms (ESA), pages 215 -- 226, 2011. [5] C. Busing, A. M. Koster, and M. Kutschka. Recoverable robust knapsacks: the discrete scenario case. Optimization Letters, 5(3):379 -- 392, 2011. [6] J. L. Carter and M. N. Wegman. Universal classes of hash functions. Journal of Computer and System Sciences, 18:143 -- 154, 1979. [7] B. C. Dean, M. X. Goemans, and J. Vondr´ak. Approximating the stochastic knapsack problem: In Proceddings of the 45th IEEE Symposium on Foundations of The benefit of adaptivity. Computer Science (FOCS), pages 208 -- 217, 2004. [8] V. G. Deineko, R. Rudolf, and G. J. Woeginger. Sometimes travelling is easy: The master tour problem. In Proceedings of the 3rd European Symposium on Algorithms (ESA), pages 128 -- 141. 1995. [9] L. Epstein, A. Levin, A. Marchetti-Spaccamela, N. Megow, J. Mestre, M. Skutella, and L. Stougie. Universal sequencing on an unreliable machine. SIAM Journal on Computing, 41(3):565 -- 586, 2012. [10] M. Frigo, C. Leiserson, H. Prokop, and S. Ramachandran. Cache-oblivious algorithms. In Proceedings of the 40th Symposium on Foundations of Computer Science (FOCS), pages 285 -- 297, 1999. [11] M. R. Garey and D. S. Johnson. Computers and Intractability, A Guide to the Theory of NP-Completeness. W.H. Freeman and Company, 1979. [12] K.-S. Goetzmann, S. Stiller, and C. Telha. Optimization over integers with robustness in cost and few constraints. In Proceedings of the 9th Workshop on Approximation and Online Algorithms (WAOA), pages 89 -- 101, 2011. [13] R. Hassin and S. Rubinstein. Robust matchings. SIAM Journal on Discrete Mathematics, 15(4):530 -- 537, 2002. [14] L. Jia, G. Lin, G. Noubir, R. Rajaraman, and R. Sundaram. Universal approximations for In Proceedings of the 37th Annual ACM Symposium on TSP, Steiner tree, and set cover. Theory of Computing (STOC), pages 386 -- 395, 2005. 17 [15] N. Kakimura, K. Makino, and K. Seimi. Computing knapsack solutions with cardinality ro- bustness. In Proceedings of the 22nd International Conference on Algorithms and Computation (ISAAC), pages 693 -- 702, 2011. [16] B. Korte and J. Vygen. Combinatorial Optimization. Theory and Algorithms. Springer, 2nd edition, 2002. [17] N. Megow and J. Mestre. Instance-sensitive robustness guarantees for sequencing with un- known packing and covering constraints. In Proceedings of the 4th Conference on Innovations in Theoretical Computer Science (ITCS), pages 495 -- 504, 2013. [18] R. Merkle and M. E. Hellman. Hiding information and signatures in trapdoor knapsacks. IEEE Transactions on Information Theory, 24(5):525 -- 530, 1978. [19] M. Monaci and U. Pferschy. On the robust knapsack problem. In Proceedings of the 10th Cologne-Twente Workshop on Graphs and Combinatorial Optimization (CTW), pages 207 -- 210, 2011. [20] C. H. Papadimitriou. Computational Complexity. Addison-Wesley, 1994. [21] H. Racke. Survey on oblivious routing strategies. In Proceedings of the 5th Conference on Computability in Europe: Mathematical Theory and Computational Practice (CiE), pages 419 -- 429, 2009. [22] A. Shamir. A polynomial time algorithm for breaking the basic Merkle-Hellman cryptosystem. In Proceedings of the 23rd Symposium on Foundations of Computer Science (FOCS), pages 145 -- 152, 1982. [23] L. G. Valiant and G. J. Brebner. Universal schemes for parallel communication. In Proceedings of the 13th Annual ACM Symposium on Theory of Computing (STOC), pages 263 -- 277, 1981. [24] G. Yu. On the max-min 0-1 knapsack problem with robust optimization applications. Opera- tions Research, 44(2):407 -- 415, 1996. 18
1806.03102
1
1806
2018-06-08T11:58:40
Compressed Communication Complexity of Longest Common Prefixes
[ "cs.DS" ]
We consider the communication complexity of fundamental longest common prefix (Lcp) problems. In the simplest version, two parties, Alice and Bob, each hold a string, $A$ and $B$, and we want to determine the length of their longest common prefix $l=\text{Lcp}(A,B)$ using as few rounds and bits of communication as possible. We show that if the longest common prefix of $A$ and $B$ is compressible, then we can significantly reduce the number of rounds compared to the optimal uncompressed protocol, while achieving the same (or fewer) bits of communication. Namely, if the longest common prefix has an LZ77 parse of $z$ phrases, only $O(\lg z)$ rounds and $O(\lg \ell)$ total communication is necessary. We extend the result to the natural case when Bob holds a set of strings $B_1, \ldots, B_k$, and the goal is to find the length of the maximal longest prefix shared by $A$ and any of $B_1, \ldots, B_k$. Here, we give a protocol with $O(\log z)$ rounds and $O(\lg z \lg k + \lg \ell)$ total communication. We present our result in the public-coin model of computation but by a standard technique our results generalize to the private-coin model. Furthermore, if we view the input strings as integers the problems are the greater-than problem and the predecessor problem.
cs.DS
cs
Compressed Communication Complexity of Longest Common Prefixes Philip Bille1, Mikko Berggreen Ettienne1, Roberto Grossi2, Inge Li Gørtz1, and Eva Rotenberg1 1 DTU Compute, AlgoLoG, Technical University of Denmark, 2800 Kgs. Lyngby, 2 Dipartimento di Informatica, Universit`a di Pisa, Italy Denmark Abstract. We consider the communication complexity of fundamen- tal longest common prefix (Lcp) problems. In the simplest version, two parties, Alice and Bob, each hold a string, A and B, and we want to determine the length of their longest common prefix ℓ = Lcp(A, B) using as few rounds and bits of communication as possible. We show that if the longest common prefix of A and B is compressible, then we can significantly reduce the number of rounds compared to the optimal uncompressed protocol, while achieving the same (or fewer) bits of com- munication. Namely, if the longest common prefix has an LZ77 parse of z phrases, only O(lg z) rounds and O(lg ℓ) total communication is nec- essary. We extend the result to the natural case when Bob holds a set of strings B1, . . . , Bk, and the goal is to find the length of the maximal longest prefix shared by A and any of B1, . . . , Bk. Here, we give a pro- tocol with O(log z) rounds and O(lg z lg k + lg ℓ) total communication. We present our result in the public-coin model of computation but by a standard technique our results generalize to the private-coin model. Furthermore, if we view the input strings as integers the problems are the greater-than problem and the predecessor problem. Keywords: communication complexity, LZ77, compression, upper bound, out- put sensitive, longest common prefix, predecessor 1 Introduction Communication complexity is a basic, useful model, introduced by Yao [14], which quantifies the total number of bits of communication and rounds of com- munication required between two or more players to compute a function, where each player holds only part the function's input. A detailed description of the model can be found, for example, in the book by Kushilevitz and Nisam [5]. Communication complexity is widely studied and has found application in many areas, including problems such as equality, membership, greater-than, and predecessor (see the recent book by Rao and Yehudayoff [9]). For the approxi- mate string matching problem, the paper by Starikovskaya [12] studies its de- terministic one-way communication complexity, with application to streaming 8 1 0 2 n u J 8 ] S D . s c [ 1 v 2 0 1 3 0 . 6 0 8 1 : v i X r a 2 P. Bille, M. B. Ettienne, R. Grossi, I. L. Gørtz, E. Rotenberg algorithms, and provides the first sublinear-space algorithm. Apart from these results, little work seems to have been done in general for the communication complexity of string problems [13]. In this paper, we study the fundamental longest common prefix problem, de- noted Lcp, where Alice and Bob each hold a string, A and B and want to deter- mine the length of the longest common prefix of A and B, that is, the maximum ℓ ≥ ℓ, such that A[1..ℓ] = B[1..ℓ] (where ℓ = 0 indicates the empty prefix). This problem is also called the greater than problem, since if we view both A and B as integers, the position immediately after their longest common prefix determines which is larger and smaller. The complexity is measured using the number of rounds required and the total amount of bits exchanged in the communication. An optimal randomized protocol for this problem uses O(lg n) communication and O(lg n) rounds [11,8] where n is the length of the strings. Other trade-offs between communication and rounds are also possible [10]. Buhrman et al. [2] describe how to compute Lcp in O(1) rounds and O(nǫ) communication. We show that if A and B are compressible we can significantly reduce the number of needed rounds while simultaneously matching the O(lg n) bound on the number of bits of communication. With the classic and widely used Lempel- Ziv 77 (LZ77) compression scheme [15] we obtain the following bound. Theorem 1. The Lcp problem has a randomized public-coin O(lg z)-round pro- tocol with O(lg ℓ) communication complexity, where ℓ ≤ n is the length of the longest common prefix of A and B and z ≤ ℓ is the number of phrases in the LZ77 parse of this prefix. Compared to the optimal uncompressed bound we reduce the number of rounds from O(lg n) to O(lg z) (where typically z is much smaller than ℓ). At the same time we achieve O(lg ℓ) = O(lg n) communication complexity and thus match or improve the O(lg n) uncompressed bound. Note that the number of rounds is both compressed and output sensitive and the communication is output sensitive. As far as we know, this is the first result studying the communication com- plexity problems in LZ77 compressed strings. A previous result by Bar-Yossef et al. [1] gives some impossibility results on compressing the text for (approxi- mate) string matching in the sketching model, where a sketching algorithm can be seen as a public-coin one-way communication complexity protocol. Here we exploit the fact that the common prefixes have the same parsing into phrases up to a certain point, and that the "mismatching" phrase has a back pointer to the portion of the text represented by the previous phrases: Alice and Bob can thus identify the mismatching symbol inside that phrase without further communication (see the "techniques" paragraph). We extend the result stated in Theorem 1 so as to compute longest com- mon prefixes when Bob holds a set of k strings B1, . . . , Bk, and the goal is to compute the maximal longest common prefix between A and any of the strings B1, . . . , Bk. This problem, denoted Lcpk, naturally captures the distributed sce- nario, where clients need to search for query strings in a text data base stored Compressed Communication Complexity of Longest Common Prefixes 3 at a server. To efficiently handle many queries we want to reduce both commu- nication and rounds for each search. If we again view the strings as integers this is the predecessor problem. We generalize Theorem 1 to this scenario. Theorem 2. The Lcpk problem has a randomized public-coin O(lg z) round communication protocol with O(lg z lg k + lg ℓ) communication complexity, where ℓ is the maximal common prefix between A and any one of B1, . . . , Bk, and z is the number of phrases in the LZ77 parse of this prefix. Compared to Theorem 1 we obtain the same number of rounds and only increase the total communication by an additive O(lg z lg k) term. As z ≤ ℓ the total communication increases by at most a factor lg k. The mentioned results hold only for LZ77 parses without self-references (see Sec. 2). We also show how to handle self-referential LZ77 parses and obtain the following bounds, where we add either extra O(lg lg ℓ) rounds or extra O(lg lg lg A) communication. Theorem 3. The Lcp problem has an randomized public-coin protocol with 1. O(lg z + lg lg ℓ) rounds and O(lg ℓ) communication complexity, 2. O(lg z) rounds and O(lg ℓ + lg lg lg A) communication complexity where ℓ is the length of the longest common prefix of A and B, and z is the number of phrases in the self-referential LZ77 parse of this prefix. Theorem 4. The Lcpk problem has a randomized public-coin protocol with 1. O(lg z + lg lg ℓ) rounds and O(lg z lg k + lg ℓ) communication complexity, 2. O(lg z) rounds and O(lg z lg k + lg ℓ + lg lg lg A) communication complexity where ℓ is the length of the maximal common prefix between A and any one of B1, . . . , Bk, and z is the number of phrases in the self-referential LZ77 parse of this prefix. Turning again to LZ77 parses without self-references we also show the fol- lowing trade-offs between rounds and communication. Theorem 5. For any constant ǫ > 0 the Lcp problem has a randomized public- coin protocol with 1. O(1) rounds and O(zǫ A) total communication where zA is the number of phrases in the LZ77 parse of A 2. O(lg lg ℓ) rounds and O(zǫ) total communication where z is the number of phrases in the LZ77 parse of the longest common prefix between A and B Using the standard transformation technique by Newman [7] all of the above results can be converted into private-coin results for bounded length strings: If the sum of the lengths of the strings is ≤ n, then, Newman's construction adds an O(lg n) term in communication complexity, and only gives rise to 1 additional round. 4 P. Bille, M. B. Ettienne, R. Grossi, I. L. Gørtz, E. Rotenberg Techniques. Our results rely on the following key idea. First, we want to per- form a binary search over the LZ77-parses of the strings, to find the first phrase where Alice and Bob disagree. Then, the longest common prefix must end some- where in the next phrase (see Figure 1). So Alice needs only to send the offset and length of her next phrase, and Bob can determine the longest common prefix with his string or strings (as proven in Lemma 6). A B 1 . . . . . . . . . . . . ℓ Fig. 1. If the longest common prefix L of A and B has z phrases, then the first z − 1 phrases of A, B, and L are identical. To implement the idea efficiently, we use standard techniques that allow Alice and Bob to check if a specific prefix of their strings match using O(1) commu- nication, with only constant probability of error (we call this the Equality problem). Similarly, if Bob holds k strings, they can check whether any of the k strings matches Alice's string with only O(log k) communication, with con- stant error probability (we call this the Membership problem). This leads to following O(log z) round communication protocol. 1. Alice and Bob do an exponential search, comparing the first, two first, four first, etc, phrases of their strings using Equality or Membership, until they find a mismatch. 2. Alice and Bob do a binary search on the last interval of phrases from Step 1, again, using Equality or Membership, until they find their longest common prefix up to a phrase border. 3. Alice sends the offset and length of her next phrase, and Bob uses this to determine the longest common prefix. To efficiently cope with errors in each step (which can potentially accumu- late), we show how to extend techniques for noisy binary search [4] to an ex- ponential search. Our new noisy exponential search only increase the number of rounds by a constant factor. Paper outline. In Section 2, we review protocols for Equality and Member- ship. Section 2 also contains a formal definition of the LZ77-parse of a string. In Section 3, we recall efficient techniques to handle errors using noisy binary search, and extend them to exponential search. In Section 4 we go on to prove Theorem 1 and Theorem 2. In Section 5, we show how to extend our results to self-referencing LZ77 (Theorems 3 and 4). Finally, in section 6, we give the constant-round and near-constant round protocols promised in Theorem 5. Compressed Communication Complexity of Longest Common Prefixes 5 2 Definition and Preliminaries A string S of length n = S is a sequence of n symbols S[1] · · · S[n] drawn from an alphabet Σ. The sequence S[i, j] is the substring of S given by S[i] · · · S[j] and, if i = 1, this substring is a prefix of S. Strings can be concatenated, i.e. S = S[1, k]S[k + 1, n]. Let Lcp(A, B) denote the length of the longest common prefix between strings A and B. Also, denote by [u] the set of integers {1, 2, . . . , u}. Communication Complexity Primitives. We consider the public-coin and private-coin randomized communication complexity models. In the public-coin model the parties share an infinite string of independent unbiased coin tosses and the parties are otherwise deterministic. The requirement is that for every pair of inputs the output is correct with probability at least 1 − ǫ for some specified 1/2 > ǫ > 0, where the probability is on the shared random string. We note that any constant probability of success can be amplified to an arbitrarily small constant at the cost of a constant factor overhead in communication. In the private-coin model, the parties do not share a random string, but are instead allowed to be randomized using private randomness. Newman [7] showed that any result in the public-coin model can be transformed into private-coin model result at the cost of an additive O(log log T ) bits of communication, where T is the number of different inputs to the players. In our results this leads to an O(log n) additive overhead, if we restrict our input to bounded length strings where the sum of the lengths of the strings is ≤ n. In the Membership problem, Alice holds a string A of length A ≤ n, and Bob holds a set B of k strings. The goal is to determine whether A ∈ B (we assume that n and k are known to both parties) [9]. Lemma 1. The Membership problem has a public-coin randomized 1-round communication protocol with m communication complexity and error probability k2−m, for any integer m > 0. Proof sketch. Let F : {0, 1}n → {0, 1}m be a random linear function over GF (2) where the coefficients of F are read from the shared random source (public coin). Alice applies F to A and sends the resulting m bits to Bob, i.e., she computes the product between a random m × n matrix and her string as a vector. Bob applies the same function to each of his strings, i.e., he computes the product between the same random matrix and each of his strings. If one of these products is the same as the one he received from Alice he sends a "1" to Alice indicating a match. This protocol has no false-negatives and by union bound the probability of a false-positive is at most k2−m. For further details see e.g. [2,6]. ⊓⊔ In the Equality problem, Alice holds a string A of size A ≤ n, and Bob holds a string B. The goal is to determine whether A = B (we assume that n is known to both parties). Lemma 1 implies the following corollary. Corollary 1. The Equality problem has a public-coin randomized 1-round communication protocol with m communication complexity and error probabil- ity 2−m. 6 P. Bille, M. B. Ettienne, R. Grossi, I. L. Gørtz, E. Rotenberg Lempel-Ziv Compression The LZ77 parse [15] of a string S of length n divides S into z substrings f1f2 . . . fz, called phrases, in a greedy left-to-right order. The ith phrase fi starting at position ui is the longest substring having a least one occurrence starting to the left of ui plus the following symbol. To compress S, we represent each phrase as a tuple (si, li, αi) ∈ ([n] × [n] × Σ), such that si is the position of the previous occurrence, li is its length, and αi is the symbol at position ui + li. It follows that s1 = l1 = 0, u1 = 1, α1 = S[1] and we define ei = ui + li for i ∈ z . That is, the ith phrase of S ends at position ei. We call the positions e1, . . . , ez the borders of S and the substring S[si, si + li] is the source source of the ith phrase fi = S[ui, ui + li]. When a phrase is allowed to overlap with its source, the parse is self-referential. A more restricted version does not allow self-references and thus require that si + li ≤ ui for i ∈ [z]. We consider LZ77 parse without self-references unless explecitly stated. An LZ77 parse of S can be found greedily in O(n) time from the suffix tree of S. It is easy to see that z = Ω(lg n) if self-references are not allowed, while z = Ω(1) for self-referential parses. 3 Noisy Search The noisy binary search problem is to find an element xt among a sequence of elements x1, . . . xn where xi ≤ xi+1 using only comparisons in a binary search. Each comparison may fail with a constant probability less than 1/2 and faults are independent. Lemma 2 (Feige et al. [4] Theorem 3.2). For every constant Q < 1/2, we can solve the noisy binary search problem on n elements with probability at least 1 − Q in O(lg(n/Q)) steps. We now show how to generalize the algorithm by Feige at al. to solve the noisy exponential search problem. That is, given a sequence x1, x2, . . . where xi ≤ xi+1 and an element xℓ find an element xr such that ℓ ≤ r ≤ 2ℓ using exponential search. Lemma 3. For every constant Q < 1/2, we can solve the noisy exponential search problem searching for xℓ with probability at least 1 − Q in O(lg(ℓ/Q)) steps. Proof. In case of no errors we can find xr on O(lg ℓ) steps comparing xℓ and xi for i = 1, 2, 4, 8 . . . until xi ≥ xℓ. At this point we have ℓ ≤ i ≤ 2ℓ. Consider the decision tree given by this algorithm. This tree is simply a path v0, v1, v2, . . . and when reaching vertex vi the algorithm compares elements xl and x2i . In order to handle failing comparisons we tranform this tree by adding a path with length li (to be specified later) as a child of vertex vi. Denote such a path with pi. The search now performs a walk in this tree starting in the the root and progresses as follows: Reaching vertex vi we first check if xl ≥ x2i−1 . If not, this reveals an earlier faulty comparison and we backtrack by moving to the parent. Otherwise, we check if xl ≥ x2i . If so we move to vertex vi+1. Otherwise, Compressed Communication Complexity of Longest Common Prefixes 7 we move to the first vertex on the path pi. Reaching a vertex u on a path pi we test if xl ≥ x2i−1 and if xl < x2i . If both tests are positive, we move to the only child of u. Otherwise, this reveals an earlier faulty comparison and we backtrack by moving to the parent of u. The search can be modeled as a Markov process. Assume that ⌈lg ℓ⌉ = j and thus j = O(lg ℓ) and direct all edges towards the leaf u on the path pj. For every vertex, exactly one adjacent edge is directed away from u and the remaining edges are directed towards u. The transition probability along an outgoing edge of a vertex is at greater than 1/2 and the transition probability along the remaining edges is less than 1/2. Let b be the number of backward transitions and f the number of forward transitions. We need to show that f − b ≥ j + lj with probability at least 1 − Q for Q < 1/2 implying that the search terminates in the leaf u. Setting li = ic1 this follows after c2(lg(2j/Q)) = O(lg(ℓ/Q)) rounds from Chernoff's bound [3] with suitable chosen constants c1 ⊓⊔ and c2. 4 Communication Protocol for Lcp We now present our protocol for the Lcp problem without self-references. We consider the case with self-references in the next section. First, we give an efficient uncompressed output sensitive protocol that works for an arbitrary alphabet (Lemma 4). Secondly, we show how to encode LZ77 strings as strings from a small alphabet (Lemma 5) which allows us to efficiently determine the first phrase where Alice and Bob disagree. Thirdly, we show that given this phrase Alice and Bob can directly solve Lcp (Lemma 6). Combining these results leads to Theorem 1. Finally, we generalize the results to the Lcpk case. First we show how to solve the Lcp problem with output-sensitive complexity for both the number of rounds and the amount of bits of communication. Lemma 4. Let A and B be strings over an alphabet Σ known to the parties. The Lcp problem has a pulic-coin randomized O(lg ℓ)-round communication pro- tocol with O(lg ℓ) communication complexity, where ℓ is the length of the longest common prefix between A and B. Proof. Alice and Bob compare prefixes of exponentially increasing length using equality, and stop after the first mismatch. Let t be the length of the prefixes that do not match and observe that t ≤ 2ℓ. They now do a binary search on the interval [0, t], using equality to decide if the left or right end of the interval should be updated to the midpoint in each iteration. The parties use Corollary 1 with m = 2, and new random bits from the shared random source for every equality check. Thus, the probability of a false-positive is at most 1/4, and the faults are independent. Using Lemma 3 and Lemma 2 we get that we can solve the problem in O(lg(ℓ/Q)) rounds of communication with probability at least 1 − Q for any constant Q < 1/2. ⊓⊔ Note that the size of the alphabet Σ does not affect the complexity of this protocol. Alice and Bob do however need to agree on how many bits to use per 8 P. Bille, M. B. Ettienne, R. Grossi, I. L. Gørtz, E. Rotenberg symbol in order to use the same number of random bits for the equality checks. Because Σ is known to the parties, they sort the alphabet and use lg Σ bits per symbol. We move on to consider how to handle LZ77 compressed strings. Recall that the ith phrase in the LZ77 parse of a string S is represented as a tuple (si, li, αi) consisting of the source si, the length li of the source, and a symbol αi ∈ Σ. Observe that the LZ77 parse can be seen as a string where each tuple describing a phrase corresponds to a symbol in this string. Because we consider LZ77 without self-references a phrase is never longer than sum of the lengths of the previous phrases and we can thus bound the number of bits required to write a phrase. Lemma 5. Let Zi = (s1, l1, α1), . . . , (si, li, αi) be the first i elements in the LZ77 parse of a string S. Then, si and li can be written in binary with i bits. Proof. Recall that ej is the position in S of the last symbol in the jth phrase. Since we have no self-references si and li are both no larger than ei−1 they can be written with lg ei−1 bits. By definition uj = ej−1 +1. Therefore, ej = uj +lj = ej−1 + 1 + lj ≤ 2ej−1 + 1, and it follows that ei−1 ≤ 2ei−2 + 1 ≤ · · · ≤ 2i − 1 since e1 = 1. ⊓⊔ We show that ℓ = Lcp(A, B) can be determined from Lcp(ZA, ZB) with only one round and O(lg ℓ) communication, where ZA and ZB are the respective LZ77 parses of A and B. While a LZ77 parse of a string is not necessarily unique, in this case, we can assume that the parties as part of the protocol agree deterministically upon their same decisions on LZ77-compression algorithm (e.g. taking always the leftmost source when there are multiple possibilities). This ensures that we obtain the same parsing for equal strings, independently and without any communication. Lemma 6. Let A and B be strings and let ZA and ZB be their respective LZ77 parses. If Alice knows A and Bob knows B and the length of the longest common prefix Lcp(ZA, ZB), then they can determine the length ℓ = Lcp(A, B) of the longest common prefix of A and B in O(1) round and O(lg ℓ) communication. Proof. First, ZA and ZB themselves can be seen as strings over the special alphabet Σ ′ ≡ ([n] × [n] × Σ) of tuples. Letting z = Lcp(ZA, ZB), these LZ77 parses of A and B are identical up until but no longer than their zth tuple. Now, let ℓ = Lcp(A, B). Let ai and bi denote the ith phrase border in the LZ77 parse of A and B respectively. Observe that A[1, az] = B[1, bz] but A[1, az+1] 6= B[1, bz+1] because of how we choose z and, thus, az = bz ≤ ℓ < az+1, bz+1. Let sz+1, lz+1 be the source and length of the (z + 1)th phrase in ZA. Alice sends sz+1, lz+1 to Bob in one round with O(lg az) = O(lg ℓ) bits of communication since sz+1, lz+1 ≤ az. At this point, it is crucial to observe that Bob can recover A[1, az+1] by definition of LZ77 parsing: he deduces that A[1, az+1] = B[1, bz]B[sz+1, sz+1 + lz+1], from which he can compute Lcp(A[1, az+1], B[1, bz+1]) = Lcp(A, B). ⊓⊔ We can now combine Lemmas 4, 5, and 6 to prove Theorem 1. Alice and Bob construct the LZ77 parse of their respective strings and interprets the parse Compressed Communication Complexity of Longest Common Prefixes 9 as a string. Denote these strings by ZA and ZB. They first use Lemma 4 to determine Lcp(ZA, ZB), where the parties decide to use 2i + lg Σ random bits for the equality check of the ith symbols (from Σ ′), which suffices by Lemma 5. Then they apply Lemma 6 to determine Lcp(A, B). In conclusion this proves Theorem 1. 4.1 The Lcpk case In this section we generalize the result on LCP to the case where Bob holds multiple strings. Here, Alice knows a string A and Bob knows strings B1, . . . , Bk, where all strings are drawn from an alphabet Σ known to the parties. The main idea is substitute the equality-tests by membership queries. We first generalize Lemma 4 to the Lcpk-case. Lemma 7. The Lcpk-problem has a randomized public-coin O(lg ℓ)-round com- munication protocol with O(lg ℓ lg k) communication complexity, where ℓ is the length of the maximal longest common prefix between A and any Bi. Proof. Along the same lines as the proof of Lemma 4, Alice and Bob per- form membership-queries on exponentially increasing prefixes, and then, per- form membership-queries to guide a binary search. They use Lemma 1 with m = 2 lg k, and exploit shared randomness as in the previous case. Again, the probability of a false positive is ≤ 1/4, and the faults are independent. Thus Lemma 3 and Lemma 2 gives us a O(lg ℓ) round communication protocol with total error probability 1 − Q for any constant choice of Q < 1/2. Since there are O(lg ℓ) rounds in which we spend O(lg k) communication, the ⊓⊔ total communication becomes O(lg ℓ lg k). We go on to show that the maximal Lcp(A, Bi) can be determined from solving Lcpk on ZA and {ZB1, . . . , ZBk } with only one additional round and O(lg n) communication. Lemma 8. Let ZA, ZB1, . . . , ZBk be the LZ77 parses of the strings A, B1, . . . , Bk. If Alice knows A, and Bob knows B1, . . . , Bk and the length of the maximal longest common prefix between ZA and any ZBi , they can find maxi Lcp(A, Bi) in O(1) round and O(lg n) communication. Proof. In this case, Bob holds a set, B ′, of at least one string that matches Alice's first z phrases, and no strings that match Alice's first z +1 phrases. Thus, if Alice sends the offset and length of her next phrase, he may determine Lcp(A, Bi) for all strings Bi ∈ B ′. Since the maximal Lcp among Bi ∈ B ′ is indeed the maximal over all Bi ∈ B, we are done. ⊓⊔ Combining Lemma 7 and Lemma 8 we get Theorem 2. 10 P. Bille, M. B. Ettienne, R. Grossi, I. L. Gørtz, E. Rotenberg 5 Self-referencing LZ77 We now consider how to handle LZ77 parses with self-references. The main hurdle is that Lemma 5 does not apply in this case as there is no bound on the phrase length except the length of the string. This becomes a problem when the parties need to agree on the number of bits to use per symbol when computing Lcp of ZA and ZB, but also when Alice needs to send Bob the source and length of a phrase in order for him to decide Lcp(A, B). First we show how Alice and Bob can find a bound on the number of random bits to use per symbol when computing Lcp(ZA, ZB). Lemma 9. Bob and Alice can find an upper bound ℓ′on the length of the longest common prefix between A and B where 1. ℓ′ ≤ ℓ2 using O(lg lg ℓ) rounds and O(lg lg ℓ) total communication 2. ℓ′ ≤ A2 using O(1) round and O(lg lg lg A) total communication. Proof. Part (1): Alice and Bob do a double exponential search for ℓ and find a number ℓ ≤ ℓ′ ≤ ℓ2 using equality checks on prefixes of their uncompressed strings in O(lg lg ℓ) rounds. Again, at the cost of only a constant factor, we apply Lemma 3 to deal with the probability of false positives. Part (2): Alice sends the minimal i such that A ≤ 22 i can be written in O(lg lg lg A) bits. Alice and Bob can now use n = 22 upper bound for ℓ, since ℓ ≤ A ≤ 22 < A2. i thus i = ⌈lg lg A⌉ as an ⊓⊔ i Assume that Alice and Bob find a bound ℓ′ using one of those techniques, then they can safely truncate their strings to length ℓ′. Now they know that every symbol in ZA and ZB can be written with O(lg ℓ′ + lg Σ) bits, and thus, they agree on the number of random bits to use per symbol when doing equality (membership) tests. Using Lemma 4 they can now find the length of the longest common prefix between ZA and ZB in O(lg ℓ) rounds with O(lg ℓ) communication. We now show how to generalize Lemma 6 to the case of self-referential parses. Lemma 10. Let A and B be strings and let ZA and ZB be their respective self- referential LZ77 parses. If Alice knows A and Bob knows B and the length of the longest common prefix between ZA and ZB, then they can determine the length ℓ of the longest common prefix of A and B in 1. O(1 + lg lg ℓ) rounds and O(lg ℓ) communication 2. O(1) rounds and O(lg ℓ + lg lg lg A) communication Proof. Let si, ei and li be the respective source, border and length of the ith phrase in ZA. The proof is the same as in Lemma 6 except that the length lz+1 of the (z + 1)th phrase in ZA that Alice sends to Bob is no longer bounded by ℓ. There are two cases. If lz+1 ≤ 2ez, then lz+1 ≤ 2ℓ, and Alice can send lz+1 to Bob in one round and O(lg ℓ) bits and we are done. Compressed Communication Complexity of Longest Common Prefixes 11 If lz+1 > 2ez then the source of the (z + 1)th phrase must overlap with the phrase itself and thus the phrase is periodic with period length at most ez and has at least 2 full repetitions of its period. Alice sends the starting position of the source of the phrase si+1 along with a message indicating that we are in this case to Bob in O(lg ℓ) bits. Now Bob can check if they agree on next 2ez symbols. If this is not the case, he has also determined Lcp(A, B) and we are done. Otherwise, they agree on the next 2ez symbols and therefore (z + 1)th phrases of both A and B are periodic with the same period. What remains is to determine which phrase that is shorter. Let la and lb denote the lengths of respectively Alice's and Bob's next phrase. Then (1) follows from Alice and Bob first computing a number ℓ′ ≤ ℓ2 using a double exponential search and equality checks in O(lg lg ℓ) rounds and total communication. Clearly either la or lb must be shorter than ℓ′ and the party with the shortest phrase sends its length to the other party in O(lg ℓ) bits and both can then determine Lcp(A, B). To get the result in (2) Alice sends the smallest integer i such that la ≤ 22 in a single round and O(lg lg lg A) bits of communication. Bob then observes that if lb ≤ 22 , then lb = ℓ and he sends ℓ to Alice using O(lg ℓ) bits. If lb > 22 then la = ℓ and he informs Alice to send him la in O(lg ℓ) bits. Finally, if 22 −1 < lb and la ≤ 22 ⊓⊔ ≤ ℓ2 he sends lb to Alice using O(lg ℓ) bits. i−1 i i i i Theorem 3 now follows from Lemmas 4, 9, and 10. 5.1 Lcpk in the self-referential case. Finally, we may generalize Theorem 2 to the self-referential case. Substituting equality with membership, we may directly translate Lemma 9: Lemma 11. Bob and Alice can find an upper bound on the length ℓ′ of the maximal longest common prefix between A and B1, . . . , Bk where 1. ℓ′ ≤ ℓ2 using O(lg lg ℓ) rounds and O(lg lg ℓ log k) total communication 2. ℓ′ ≤ A2 using O(1) round and O(lg lg lg A) total communication. Using the lemma above, we can generalize Corollary 10 to the LCPk-case. Lemma 12. Let A and B1, . . . , Bk be strings, and let ZA and ZBi be their re- spective self-referential LZ77 parses. If Alice knows A and Bob knows B1, . . . , Bk and Bob knows the length of the maximal longest common prefix between ZA and any ZBi , then they can determine ℓ in 1. O(1 + lg lg ℓ) rounds and O(lg ℓ lg k) communication 2. O(1) rounds and O(lg ℓ lg k + lg lg lg A) communication Proof tweak. Alice and Bob have already found a common prefix of size ez – question is whether a longer common prefix exists. As before, if Alice's next phrase is shorter than 2ez, she may send it. Otherwise, she sends the offset, and indicates we are in this case. Now, Bob can check if any of his strings agree with Alice's on the next 2ez symbols. If none do, we are done. If several do, he forgets 12 P. Bille, M. B. Ettienne, R. Grossi, I. L. Gørtz, E. Rotenberg all but the one with the longest (z + 1)'st phrase, and continue as in the proof of Corollary 10. ⊓⊔ Theorem 4 now follows from the combination of Lemmas 11 and 12. 6 Obtaining a trade-off via D-ary search. We show that the technique of Buhrman et al. [2], to compute Lcp of two strings of length n in O(1) rounds and O(nǫ) communication, can be used to obtain a compressed communication complexity. Note that we again consider LZ77 compression without self-references. We first show the following generalization of Lemma 4. Lemma 13. Let A and B be strings over an alphabet Σ known to the parties. The Lcp problem has a public-coin randomized communication protocol with 1. O(1) rounds and O(Aǫ) communication 2. O(lg lg ℓ) rounds and O(ℓǫ) communication where ℓ is the length of the longest common prefix between A and B, and ǫ > 0 is any arbitrarily small constant. Proof. Assume the parties agree on some parameter C and have previous knowl- edge of some constant ǫ′ with 0 < ǫ′ < ǫ (i.e. ǫ′ and ǫ are plugged into their protocol). They perform a D-ary search in the interval [−1, C] with D = C ǫ′ . In each round, they split the feasible interval into D chunks, and perform equality tests from Corollary 1 with m = 2 lg(D/ǫ′) on the corresponding prefixes. The feasible interval is updated to be the leftmost chunk where the test fails. There are lgD C = 1/ǫ′ = O(1) rounds. The communication per round is 2D lg(D/ǫ′) and the total communication is 1/ǫ′ · 2D lg(D/ǫ′) = O(C ǫ′ lg C). The probability of a false positive for the equality test is 2−m, and thus, by a union bound over D comparisons in each round and 1/ǫ′ rounds, the combined probability of failure becomes 1/4. 1. Alice sends A to Bob in lg A = O(Aǫ) bits and they use C = A. The total communication is then O(C ǫ′ lg C) = O(Aǫ) with O(1) rounds. 2. Alice and Bob use Lemma 9 to find an ℓ′ such that ℓ ≤ ℓ′ ≤ ℓ2 in O(lg lg ℓ) rounds and communication. They run the D-ary search protocol where ǫ′ < ǫ/4, setting C = ℓ′. The extra communication is O(C ǫ′ ⊓⊔ lg C) = O(ℓǫ). We can now combine Lemmas 13, 5, and 6 to prove Theorem 5. Alice and Bob construct the LZ77 parse of their respective strings and interpret the parses as a strings, denoted by ZA and ZB. They first use Lemma 13 to determine Lcp(ZA, ZB), and then Lemma 6 to determine Lcp(A, B). The parties use 2i + lg Σ random bits for the ith symbol, which suffices by Lemma 5. This enables them to apply Lemma 13 to ZA and ZB. In conclusion this proves Theorem 5. We note without proof that this trade-off also generalizes to self-referential parses by paying an additive extra O(lg lg lg A) in communication for Theorem 5 (1) and an additive O(lg ℓ) communication cost for Theorem 5 (2). The same goes for Lcpk where the comminication increases by a factor O(lg k) simply by increasing m by a factor lg k and using the techniques already described. Compressed Communication Complexity of Longest Common Prefixes 13 References 1. Ziv Bar-Yossef, T. S. Jayram, Robert Krauthgamer, and Ravi Kumar. The sketch- ing complexity of pattern matching. In Proc. 8th RANDOM, pages 261–272, 2004. 2. H. Buhrman, M. Kouck´y, and N. Vereshchagin. Randomised individual communi- cation complexity. In Proc. 23rd CCC, pages 321–331, 2008. 3. Herman Chernoff. A measure of asymptotic efficiency for tests of a hypothesis based on the sum of observations. Ann. Math. Stat., 23:493–507, 1952. 4. Uriel Feige, Prabhakar Raghavan, David Peleg, and Eli Upfal. Computing with noisy information. SIAM J. Comput., 23(5):1001–1018, October 1994. 5. Eyal Kushilevitz and Noam Nisan. Communication complexity. Cambridge Uni- versity Press, 1997. 6. Peter Bro Miltersen, Noam Nisan, Shmuel Safra, and Avi Wigderson. On data J. Comp. Syst. Sci., structures and asymmetric communication complexity. 57(1):37 – 49, 1998. 7. Ilan Newman. Private vs. common random bits in communication complexity. Inf. Proc. Lett., 39(2):67 – 71, 1991. 8. Noam Nisan. The communication complexity of threshold gates. Combinatorics, Paul Erdos is Eighty, 1:301–315, 1993. 9. Anup Rao and Amir Yehudayoff. Communication Complexity (Early Draft). https://homes.cs.washington.edu/~anuprao/pubs/book.pdf, 2018. 10. Pranab Sena and S Venkateshb. Lower bounds for predecessor searching in the cell probe model. J. Comp. Syst. Sci., 74:364–385, 2008. 11. DV Smirnov. Shannon's information methods for lower bounds for probabilistic communication complexity. Master's thesis, Moscow University, 1988. 12. Tatiana A. Starikovskaya. Communication and streaming complexity of approxi- mate pattern matching. In Proc. 28th CPM, pages 13:1–13:11, 2017. 13. Tatiana A. Starikovskaya. Streaming and property testing algorithms for string processing. 26th London Stringology Days, 2018. 14. Andrew Chi-Chih Yao. Some complexity questions related to distributive comput- ing(preliminary report). In Proc. 11th STOC, pages 209–213, 1979. 15. Jacob Ziv and Abraham Lempel. A Universal Algorithm for Sequential Data Compression. IEEE Trans. Inf. Theory, (3), 1977.
1804.03636
2
1804
2019-02-19T02:42:51
Testing Identity of Multidimensional Histograms
[ "cs.DS", "cs.IT", "cs.LG", "cs.IT", "math.ST", "math.ST" ]
We investigate the problem of identity testing for multidimensional histogram distributions. A distribution $p: D \rightarrow \mathbb{R}_+$, where $D \subseteq \mathbb{R}^d$, is called a $k$-histogram if there exists a partition of the domain into $k$ axis-aligned rectangles such that $p$ is constant within each such rectangle. Histograms are one of the most fundamental nonparametric families of distributions and have been extensively studied in computer science and statistics. We give the first identity tester for this problem with {\em sub-learning} sample complexity in any fixed dimension and a nearly-matching sample complexity lower bound. In more detail, let $q$ be an unknown $d$-dimensional $k$-histogram distribution in fixed dimension $d$, and $p$ be an explicitly given $d$-dimensional $k$-histogram. We want to correctly distinguish, with probability at least $2/3$, between the case that $p = q$ versus $\|p-q\|_1 \geq \epsilon$. We design an algorithm for this hypothesis testing problem with sample complexity $O((\sqrt{k}/\epsilon^2) 2^{d/2} \log^{2.5 d}(k/\epsilon))$ that runs in sample-polynomial time. Our algorithm is robust to model misspecification, i.e., succeeds even if $q$ is only promised to be {\em close} to a $k$-histogram. Moreover, for $k = 2^{\Omega(d)}$, we show a sample complexity lower bound of $(\sqrt{k}/\epsilon^2) \cdot \Omega(\log(k)/d)^{d-1}$ when $d\geq 2$. That is, for any fixed dimension $d$, our upper and lower bounds are nearly matching. Prior to our work, the sample complexity of the $d=1$ case was well-understood, but no algorithm with sub-learning sample complexity was known, even for $d=2$. Our new upper and lower bounds have interesting conceptual implications regarding the relation between learning and testing in this setting.
cs.DS
cs
Testing Identity of Multidimensional Histograms Ilias Diakonikolas ∗ University of Southern California Daniel M. Kane† University of California, San Diego [email protected] [email protected] John Peebles ‡ CSAIL, MIT [email protected] February 20, 2019 Abstract We investigate the problem of identity testing for multidimensional histogram distributions. A dis- tribution p : D → R+, where D ⊆ Rd, is called a k-histogram if there exists a partition of the domain into k axis-aligned rectangles such that p is constant within each such rectangle. Histograms are one of the most fundamental nonparametric families of distributions and have been extensively studied in com- puter science and statistics. We give the first identity tester for this problem with sub-learning sample complexity in any fixed dimension and a nearly-matching sample complexity lower bound. In more detail, let q be an unknown d-dimensional k-histogram distribution in fixed dimension d, and p be an explicitly given d-dimensional k-histogram. We want to correctly distinguish, with probability at least 2/3, between the case that p = q versus (cid:107)p − q(cid:107)1 ≥ . We design an algorithm for this hypothesis testing problem with sample complexity O((√k/2)2d/2 log2.5d(k/)) that runs in sample-polynomial time. Our algorithm is robust to model misspecification, i.e., succeeds even if q is only promised to be close to a k-histogram. Moreover, for k = 2Ω(d), we show a sample complexity lower bound of (√k/2) · Ω(log(k)/d)d−1 when d ≥ 2. That is, for any fixed dimension d, our upper and lower bounds are nearly matching. Prior to our work, the sample complexity of the d = 1 case was well-understood, but no algorithm with sub-learning sample complexity was known, even for d = 2. Our new upper and lower bounds have interesting conceptual implications regarding the relation between learning and testing in this setting. 9 1 0 2 b e F 9 1 ] S D . s c [ 2 v 6 3 6 3 0 . 4 0 8 1 : v i X r a ∗Supported by NSF Award CCF-1652862 (CAREER) and a Sloan Research Fellowship. †Supported by NSF Award CCF-1553288 (CAREER) and a Sloan Research Fellowship. ‡Supported by the NSF Graduate Research Fellowship under Grant 1122374, and by the NSF Grant 1065125. Some of this work was performed while visiting USC. 1 Introduction 1.1 Background The task of verifying the identity of a statistical model -- known as identity testing or goodness of fit -- is one of the most fundamental questions in statistical hypothesis testing [Pea00, NP33]. In the past two decades, this question has been extensively studied by the TCS and information-theory communities in the framework of property testing [RS96, GGR98]: Given sample access to an unknown distribution q over a finite domain [n] := {1, . . . , n}, an explicit distribution p over [n], and a parameter  > 0, we want to distinguish between the cases that q and p are identical versus -far from each other in (cid:96)1-norm (statistical distance). Initial work on this problem focused on characterizing the sample size needed to test the identity of an arbitrary distribution of a given support size n. This regime is well-understood: there exists an efficient estimator with sample complexity O(√n/2) [VV14, DKN15b, ADK15] that is worst-case optimal up to constant factors. The aforementioned sample complexity characterizes worst-case instances and drastically better upper bounds may be possible if we have some a priori qualitative information about the unknown distribution. For example, if q is an arbitrary continuous distribution, no identity tester with finite sample complexity exists. On the other hand, if q is known to have some nice structure, the domain size may not be the right complexity measure for the identity testing problem and one might hope that strong positive results can be obtained even for the continuous setting. This discussion motivates the following natural question: To what extent can we exploit the underlying structure to perform the desired statistical estimation task more efficiently? A natural formalization of the aforementioned question involves assuming that the unknown distribution belongs to (or is close to) a given family of distributions. Let D be a family of distributions over Rd. The problem of identity testing for D is the following: Given sample access to an unknown distribution q ∈ D, and an explicit distribution p ∈ D, we want to distinguish between the case that q = p versus (cid:107)q − p(cid:107)1 ≥ . (Throughout this paper, (cid:107)p − q(cid:107)1 denotes the L1-distance between the distributions p, q.) We note that the sample complexity of this testing problem depends on the complexity of the underlying class D, and it is of fundamental interest to obtain efficient algorithms that are sample optimal for D. A recent body of work in distribution testing has focused on leveraging such a priori structure to obtain significantly improved sample complexities [BKR04, DDS+13, DKN15b, DKN15a, CDKS17a, DP17, DDK18, DKN17]. One approach to solve the identity testing problem for a family D is to learn q up to L1-distance /3 and then check (without drawing any more samples) whether the hypothesis is /3-close to p. Thus, the sample complexity of identity testing for D is bounded from above by the sample complexity of learning (an arbitrary distribution in) D. It is natural to ask whether a better sample size bound could be achieved for the identity testing problem, since this task is, in some sense, less demanding than the task of learning. In this paper, we provide an affirmative answer to this question for the family of multidimensional histogram distributions. 1.2 Our Results: Identity Testing for Multidimensional Histograms In this work, we investigate the problem of identity testing for multidimensional histogram distributions. A d-dimensional probability distribution with density p : D → R, where D ⊂ Rd is either [m]d or [0, 1]d, is called a k-histogram if there exists a partition of the domain into k axis-aligned rectangles R1, . . . , Rk such that p is constant on Ri, for all i = 1, . . . , k. We let Hd k(D) denote the set of k-histograms over D. We will use the simplified notation Hd k when the underlying domain is clear from the context. Histograms constitute one of the most basic nonparametric distribution families and have been extensively studied in statistics and computer science. 1 Specifically, the problem of learning histogram distributions from samples has been extensively studied in the statistics community and many methods have been proposed [Sco79, FD81, Sco92, LN96, DL04, WN07, Kle09] that unfortunately have a strongly exponential dependence on the dimension. In the database community, histograms [JKM+98, CMN98, TGIK02, GGI+02, GKS06, ILR12, ADH+15] constitute the most common tool for the succinct approximation of large datasets. Succinct multivariate histograms repre- sentations are well-motivated in several data analysis applications in databases, where randomness is used to subsample a large dataset [CGHJ12]. In recent years, histogram distributions have attracted renewed interested from the TCS community in the context of learning [DDS12, CDSS13, CDSS14a, CDSS14b, DHS15, ADLS16, ADLS17, DKS16a, DLS18] and testing [ILR12, DDS+13, DKN15b, DKN15a, Can16, CDGR16, DKN17]. The algorithmic difficulty in learning and testing such distributions lies in the fact that the location and size of the rectangle partition is unknown. The majority of the literature has focused on the univariate setting which is by now well-understood. Specifically, it is known that the sample complexity of learning H1 k is Θ(k/2) (and this sample bound is achievable with computationally efficient algorithms [CDSS14a, CDSS14b, ADLS17]); k is Θ(√k/2) [DKN15b]. That is, in one dimension, while the sample complexity of identity testing H1 the gap between learning and identity testing as a function of the complexity parameter k is known to be quadratic. A recent work [DLS18] obtained a sample near-optimal and computationally efficient algorithm for learning multidimensional k-histograms in any fixed dimension. The sample complexity of the [DLS18] algorithm is O((k/2) logO(d)(k/)) while the optimal sample complexity of the learning problem (ignoring computational considerations) is (cid:101)Θ(dk/2)1. On the other hand, the property testing question in two (or more) dimensions is poorly understood. In particular, prior to this work, no testing algorithm with sub- learning sample complexity was known, even for d = 2 (independent of computational considerations). In this paper, we obtain an identity tester for multidimensional histograms in any fixed dimension with sub- learning sample complexity and establish a nearly-matching sample complexity lower bound (that applies even to the special case of uniformity testing). Our main result is the following: Theorem 1.1 (Main Result). Let  > 0 and k ∈ Z+. Let q ∈ Hd k(D) be an unknown k-histogram dis- k(D) be explicitly given. There is tribution over D = [0, 1]d or D = [m]d, where d is fixed, and p ∈ Hd an algorithm which draws m = O((√k/2)2d/2 log2.5d(dk/)) samples from q, runs in sample-polynomial time, and distinguishes, with probability at least 2/3, between the case that p = q versus (cid:107)p − q(cid:107)1 ≥ . Moreover, any algorithm for this hypothesis testing problem requires (√k/2)Ω(log(k)/d)d−1 samples for k = 2Ω(d), even for uniformity testing. A few remarks are in order: First, we emphasize that the focus of our work is on the case where the parameter k is much larger than the dimension d. For example, this condition is automatically satisfied when d is bounded from above by a fixed constant. We note that understanding the regime of fixed dimension d is of fundamental importance, as it is the most commonly studied setting in nonparametric inference. Moreover, in several of the classical database and streaming applications of multidimensional histograms (see, e.g., [PI97, GKTD00, BCG01, Mut05] and references therein) the dimension d is relatively small (at most 10), while the number of rectangles is orders of magnitude larger . For such parameter regimes, our identity tester has sub-learning sample complexity that is near-optimal, up to the precise power of the logarithm (as follows from our lower bound). Understanding the parameter regime where k and d are comparable, e.g., k = poly(d), is left as an interesting open problem. It is important to note that our identity testing algorithm is robust to model misspecification. Specif- ically, the algorithm is guaranteed to succeed as long as the unknown distribution q is /10-close, in L1- norm, to being a k-histogram. This robustness property is important in applications and is conceptually 1We note that the(cid:101)Θ() notation hides polylogarithmic factors in its argument. 2 interesting for the following reason: In high-dimensions, robust identity testing with sub-learning sample complexity is provably impossible, even for the simplest high-dimensional distributions, including spherical Gaussians [DKS16b]. A conceptual implication of Theorem 1.1 concerns the sample complexity gap between learning and identity testing for histograms. It was known prior to this work that the gap between the sample complexity of learning and identity testing for univariate k-histograms is quadratic as a function of k. Perhaps sur- prisingly, our results imply that this gap decreases as the dimension d increases (as long as the dimension remains fixed). This follows from our sample complexity lower bound in Theorem 1.1 and the fact that the k is Θ(dk/2) (as follows from standard VC-dimension arguments, see, sample complexity of learning Hd e.g., [DLS18]). In particular, even for d = 3, the gap between the sample complexities of learning and identity testing is already sub-quadratic and continues to decrease as the dimension increases. (We remind the reader that our lower bound applies for k > 2Ω(d).) Finally, we note here a qualitative difference between the d = 1 and d ≥ 2 cases. Recall that for d = 1 the sample complexity of identity testing k-histograms is Θ(√k/2). For d = 2, the sample complexity of our algorithm is O((√k/2) log5(k/)). It would be tempting to conjecture that the multiplicative logarith- mic factor is an artifact of our algorithm and/or its analysis. Our lower bound of Ω((√k/2) log(k)) shows that some constant power of a logarithm is in fact necessary. 1.3 Related Work The field of distribution property testing [BFR+00] has been extensively investigated in the past couple of decades, see [Rub12, Can15, Gol17]. A large body of the literature has focused on characterizing the sample size needed to test properties of arbitrary discrete distributions. This regime is fairly well understood: for many properties of interest there exist sample-efficient testers [Pan08, CDVV14, VV14, DKN15b, ADK15, CDGR16, DK16, DGPP16, CDS17, Gol17, DGPP17, BC17, DKS18, CDKS17b]. More recently, an emerging body of work has focused on leveraging a priori structure of the underlying distributions to obtain significantly improved sample complexities [BKR04, DDS+13, DKN15b, DKN15a, CDKS17a, DP17, DDK18, DKN17]. The area of distribution inference under structural assumptions -- that is, inference about a distribution under the constraint that its probability density function satisfies certain qualitative properties -- is a clas- sical topic in statistics starting with the pioneering work of Grenander [Gre56] on monotone distributions. The reader is referred to [BBBB72] for a summary of the early work and to [GJ14] for a recent book on the subject. This topic is well-motivated in its own right, and has seen a recent surge of research activity in the statistics and econometrics communities, due to the ubiquity of structured distributions in the sciences. The conventional wisdom is that, under such structural constraints, the quality of the resulting estimators may dramatically improve, both in terms of sample size and in terms of computational efficiency. the distribution. For discrete distributions p, q, their (cid:96)1 and (cid:96)2 distances are (cid:107)p − q(cid:107)1 = (cid:80)n and (cid:107)p − q(cid:107)2 = (cid:112)(cid:80)n (cid:107)p − q(cid:107)1 = (cid:82) 1.4 Basic Notation We will use p, q to denote the probability density functions (or probability mass functions) of our distri- butions. If p is discrete over support [n] def= {1, . . . , n}, we denote by pi the probability of element i in i=1 pi − qi i=1(pi − qi)2. For D ⊆ Rd and density functions p, q : D → R+, we have D p(x) − q(x)dx. The total variation distance between distributions p, q is defined to be i=1. For such a partition S, the reduced r corresponding to p and S is the discrete distribution over [(cid:96)] that assigns the i-th "point" the Fix a partition of the domain D into disjoint sets S := (Si)(cid:96) dTV (p, q) = (1/2) · (cid:107)p − q(cid:107)1. distribution pS mass that p assigns to the set Si; i.e., for i ∈ [(cid:96)], pS r (i) = p(Si). 3 chi-square distance: For probability distributions p, q and r let χp(q, r) def= (cid:82) dqdr Our lower bound proofs will use the following metric, which can be seen as a generalization of the dp . 1.5 Overview of Techniques In this section, we provide a high-level overview of our algorithmic and lower bounds techniques in tandem with a comparison to prior related work. Overview of Identity Testing Algorithm We start by describing our uniformity tester for d-dimensional k-histograms. For the rest of this intuitive description, we focus on histograms over [0, 1]d. A standard, yet important, tool we will use is the concept of a reduced distribution defined above. Note that a random sample from the reduced distribution pS r can be obtained by taking a random sample from p and returning the element of the partition that contains the sample. The first observation is that if the unknown distribution q ∈ Hd k and the uniform distribution p = U are -far in L1-distance, there exists a partition of the domain into k rectangles R1, . . . , Rk such that the difference between q and p can be detected based on the reduced distributions on this partition. If we knew the partition R1, . . . , Rk ahead of time, the testing problem would be easy: Since the reduced distributions have support k, this would yield a uniformity tester with sample complexity O(√k/2). The main difficulty is that the correct partition is unknown to the testing algorithm (as it depends on the unknown histogram distribution q). A natural approach, employed in [DKN15b] for d = 1, is to appropriately "guess" the correct rectangle partition. For the univariate case, a single interval partition already leads to a non-trivial uniformity tester. Indeed, consider partitioning the domain into Θ(k/) intervals of equal length (hence, of equal mass under the uniform distribution). It is not hard to see that the reduced distributions over these intervals can detect the discrepancy between q and p, leading to a uniformity tester with sample complexity Θ((k/)1/2/2) = Θ(k1/2/5/2). This very simple scheme gives an identity testing with sub-learning sample complexity when  is constant -- albeit suboptimal for small . Unfortunately, such an approach can be seen to inherently fail even for two dimensions: Any obliviously chosen partition in two dimensions requires Ω(k2/2) rectangles, which leads to an identity tester with sample complexity Ω(k/3). Hence, a more sophisticated approach is required in two dimensions to obtain any improvement over learning. Instead of using a single oblivious interval decomposition of the domain, the sample-optimal Θ(k1/2/2) uniformity tester of [DKN15b] for univariate k-histograms partitions the domain into intervals in several different ways, and runs a known (cid:96)2-tester on the reduced distributions (with respect to the intervals in the partition) as a black-box. At a high-level, we appropriately generalize this idea to the multidimensional setting. To achieve this, we proceed by partitioning the domain into approximately k identical rectangles, dis- tinguishing the different partitions based on the shapes of these rectangles. This requirement to guess the shape is necessary, as for example partitioning the square into rows will not suffice when the true partition is a partition into columns. We show that it suffices to consider a poly-logarithmic sized set of partitions, where any desired shape of rectangle can be achieved to within a factor of 2. In particular, we show that for each of the k rectangles in the true partition that are sufficiently large, at least one of our oblivious parti- tions will use rectangles of approximately the same size, and thus at least one rectangle in this partition will approximately capture the discrepancy due to this rectangle (note that only considering large rectangles suf- fices, since any rectangle on which the uniform distribution assigns substantially more mass than q must be reasonably large). This means that at least one partition will have an /polylog(k/) discrepancy between p and q, and by running an identity tester on this partition, we can distinguish them. One complication that arises here is that for small values of , the difference between p and q might In order to capture these rectangles, we will need be due to rectangles with area much less than 1/k. 4 some of our oblivious partitions to be into rectangles with area smaller than 1/k, for which there will necessarily be more than k rectangles in the partition (in fact, as many as k/ many rectangles). This would appear to cause problems for the following reason: the sample complexity of (cid:96)1-uniformity testing over a discrete domain of size n is Θ(n1/2/2). Hence, naively using such a uniformity tester on the reduced distributions obtained by a decomposition into k/ rectangles would lead to the sub-optimal sample complexity of Θ((k/)1/2/2) = Θ(k1/2/5/2). We can circumvent this difficulty by leveraging the following insight: Even though the total number of rectangles in the partition might be large, it can be shown that for a well-chosen oblivious partition, a reasonable fraction of this discrepancy is captured by only k of these rectangles. In such a case, the sample complexity of uniformity testing can be notably reduced using an "(cid:96)k 1-identity tester" -- an identity tester under a modified metric that measures the discrepancy of the largest k domain elements. By leveraging the flattening method of [DK16], we design such a tester with the optimal sample complexity of O(√k/2) (Theorem 2.3) -- independent of the domain size. This completes the sketch of our uniformity tester for the multidimensional case. To generalize our uniformity tester to an identity tester for multidimensional histograms, two significant problems arise. The first is that it is no longer clear what the shape of rectangles in the oblivious partition should be. This is because when the explicit distribution p is not the uniform distribution, equally sized rectangles are not a natural option to consider. This problem can be fixed by breaking the axes into pieces that assign equal mass to the marginals of the known distribution (Lemma 2.8). The more substantial problem is that it is no longer clear that the discrepancy between p and q can be captured by a partition of the square into k rectangles. This is because the two k rectangle partitions corresponding to the k-histograms p and q when refined could lead to a partition of the square into as many k2 rectangles. To remedy this, we note that there is still a partition into k rectangles such that q is piecewise constant on that partition. We show (Lemma 2.4) that if we refine this partition slightly -- by dividing each region into two regions, the half on which p is heaviest and the half on which p is lightest -- this new partition will capture a constant fraction of the difference between p and q. Given this structural result, our identity testing algorithm becomes similar to our uniformity tester. We obliviously partition our domain into rect- angles poly-logarithmically many times, each time we now divide each rectangle further into two regions as described above, and then run identity testers on these partitions. We show that if p and q differ by  in L1-distance, then at least one such partition will detect at least /polylog(k/) of this discrepancy. Overview of Sample Complexity Lower Bound Note that Ω(√k/2) is a straightforward lower bound on the sample complexity of identity testing k-histograms, even for d = 1. This follows from the fact that a k-histogram can simulate any discrete distribution over k elements. In order to prove lower bounds of the form ω(√k/2), we need to show that any tester must consider many possible shapes of rectangles. This suggests a construction where we have a grid of some unknown dimensions, where some squares in the grid are dense and the remainders are sparse in a checkerboard-like pattern. It should be noted that if we have two such grids whose dimensions differ by exactly a factor of 2, it can be arranged such that the distributions are exactly uncorrelated with each other. Using this observation, we can construct log(k) such uncorrelated distributions that the tester will need to check for individually. Unfortunately, this simple construction will not suffice to prove our desired lower bound, as one could merely run log(k) different testers in parallel. (We note, however, that this construction does yield a non- trivial lower bound, see Proposition 3.3.) We will thus need a slightly more elaborate construction, which we now describe: First, we divide the square domain into polylog(k) equal regions. Each of these regions is turned into one of these randomly-sized checkerboards, but where different regions will have different scales. We claim that this ensemble is hard to distinguish from the uniform distribution. The formal proof of the above sketched lower bound is somewhat technical and involves bounding the 5 chi-squared distance of taking Poi(m) samples from a random distribution in our ensemble with respect to the distribution obtained by taking Poi(m) samples from the uniform distribution. Bounding the chi-square distance is simplified by noting that since the sets of samples from each of the √k bins are independent of each other, we can consider each of them independently. For each individual bin, we take s ∼ Poi(m/√k) samples and need to compute χU⊗s(X⊗s, Y ⊗s) = χU (X, Y )s, where X and Y are random distributions from our ensemble and U is the uniform distribution. It is not hard to see that if X and Y are checkerboards of different scales, then the χ2-value is exactly 1. This saves us a factor of log(k), as there are log(k) many different scales to consider, and leads to the desired sample lower bound (Theorem 3.4). Organization In Section 2, we give our identity testing algorithm. Our sample complexity lower bound proof is given in Section 3. Finally, Section 4 outlines some directions for future work. 2 Sample Near-Optimal Identity Testing Algorithm In Section 2.1, we describe and analyze our identity tester, assuming the existence of a good oblivious covering. In Section 2.2, we show the existence of such a covering. 2.1 Algorithm and its Analysis Let q be the unknown histogram distribution and p be the explicitly known one. Our algorithm considers several judiciously chosen oblivious decompositions of the domain that will be able to approximate a set on which we can distinguish our distributions. We formalize the properties that we need these decompositions to have with the notion of a good oblivious covering (Definition 2.1 below). The essential idea is that we cover the domain [0, 1]d with rectangles that do not overlap too much in such a way so that any partition of [0, 1]d into k rectangles can be approximated by some union of rectangles in this family. Definition 2.1 (good oblivious covering). Let p be a probability distribution on [0, 1]d. For k, j, (cid:96) ∈ Z+ and 0 <  ≤ 1/2, a (k, j, (cid:96), )-oblivious covering of p is a family F of subsets of [0, 1]d satisfying the following: 1. For any partition Π of [0, 1]d into k rectangles, there exists a subfamily S ⊆ F such that: (a) We have that S ≤ k · j . (b) The sets in S are mutually disjoint, i.e., S1 (c) The sets in S together contain all except at most  of the probability mass of [0, 1]d under p, i.e., (d) For each S ∈ S there is some histogram rectangle R ∈ Π such that S only contains points from (cid:84) S2 = ∅ for all S1 (cid:54)= S2 ∈ S. p(∪S∈SS) ≥ 1 − . R, i.e., S ⊆ R. 2. For each point x in [0, 1]d, the number of sets in F containing x is exactly (cid:96). In Section 2.2, Lemma 2.8, we establish the existence of a (k, 2d logd(4kd/), logd(4kd/), )-oblivious covering of p for any distribution p on [0, 1]d and for all k, d,  with  ≤ 1/2. Our basic plan will be that if p is a distribution with a (k, j, (cid:96), /2)-oblivious covering F, and q is a k-histogram that differs from p by at least  in L1-distance, then q defines a partition Π of [0, 1]d into k rectangles. This partition gives rise to a subfamily S ⊆ F satisfying the constraints specified in Defini- tion 2.1. We would like to show that a constant fraction of the discrepancy between p and q can be detected by considering their restrictions to S. There are a couple of obstacles to showing this, the first of which is that we do not know what S is. Fortunately, we do have the guarantee that S is relatively small. We can 6 consider the restrictions of p and q over all sets in S and try to check if there is a significant discrepancy between the two coming from any small subset. To achieve this, we will make essential use of an identity tester under the (cid:96)1 k-metric, which we now define: Definition 2.2 ((cid:96)k 1-distance). Let p and q be distributions on a finite size domain, that we denote by [n] without loss od generality. For any positive integer k ≥ 1, we define (cid:107)p − q(cid:107)1,k as the sum of the largest k values of p(i) − q(i) over i ∈ [n]. (cid:80) Note that (cid:107)p − q(cid:107)1,k ≥  means that there exists a set A of k or fewer domain elements such that s∈A p(s) − q(s) ≥ . That is, these elements alone contribute at least  to the (cid:96)1-distance between the We start by proving the following theorem: distributions. Theorem 2.3 (Sample-Optimal (cid:96)k 1 Identity Testing). Given a known discrete distribution p and sample access to an unknown discrete distribution q, each of any finite domain size, there exists an algorithm that accepts with probability 2/3 if p = q and rejects with probability 2/3 if (cid:107)p − q(cid:107)1,k ≥ . The tester requires only knowledge of the known distribution p and O(√k/2) samples from q. Recall that if we wanted to distinguish between p = q and (cid:107)p − q(cid:107)1 > , this would require Ω(√n/2) samples. However, the optimal (cid:96)1-identity testers are essentially adaptations of (cid:96)2-testers. That is, roughly speaking, they actually distinguish between p = q and (cid:107)p − q(cid:107)2 > /√n. Hence, it should be intuitively 1-distance: If (cid:107)p−q(cid:107)1,k > , then (cid:107)p−q(cid:107)2 > /√k, clear why it would be easier to test for discrepancies in (cid:96)k making it easier for an (cid:96)2-type tester to detect the difference. We apply the flattening technique of [DK16] 1-identity tester. We note that an optimal combined with the (cid:96)2-tester of [CDVV14] to obtain our optimal (cid:96)k 1 closeness tester between discrete distributions was given in [DKN17]. The proof of Theorem 2.3 follows (cid:96)k along the same lines and is given in Appendix A. The second obstacle is that although q will be constant within each S ∈ S, it will not necessarily be the case that p(S) and q(S) will differ substantially even if the variation distance between p and q on S is large. To fix this, we show that S can be split into two parts such that at least one of the two parts will necessarily detect a large fraction of this difference: Lemma 2.4. Let p, q : Rd → R+ and let S be a bounded open subset in Rd on which q is uniform. Suppose S is partitioned into two subsets S1, S2 such that vol(S1) = vol(S2) = vol(S)/2 and p(s1) ≥ p(s2) for all s1 ∈ S1, s2 ∈ S2, where vol() denotes Euclidean volume. Then, max (p(x) − q(x))dx S1 (p(x) − q(x))dx S2 ≥ S p(x) − q(x)dx/4. Proof. Let W ⊆ S be the set of points x ∈ S for which p(x) ≥ q(x) and W (cid:48) = S\W . Then we have that S p(x) − q(x)dx = (p(x) − q(x))dx + (q(x) − p(x))dx. W (cid:48) We will show that max (p(x) − q(x))dx/2. By an argument analogous to the one we will give to prove Equation (1), one can also prove that (p(x) − q(x))dx (p(x) − q(x))dx ≥ S1 S2 W (1) max (p(x) − q(x))dx S1 ≥ (q(x) − p(x))dx/2. W (cid:48) S2 (p(x) − q(x))dx 7 (cid:26)(cid:12)(cid:12)(cid:12)(cid:12)(cid:90) (cid:90) (cid:26)(cid:12)(cid:12)(cid:12)(cid:12)(cid:90) (cid:26)(cid:12)(cid:12)(cid:12)(cid:12)(cid:90) (cid:12)(cid:12)(cid:12)(cid:12)(cid:90) (cid:12)(cid:12)(cid:12)(cid:12) , (cid:90) (cid:12)(cid:12)(cid:12)(cid:12)(cid:90) (cid:12)(cid:12)(cid:12)(cid:12) , (cid:12)(cid:12)(cid:12)(cid:12)(cid:90) (cid:12)(cid:12)(cid:12)(cid:12) , W (cid:90) (cid:90) (cid:90) (cid:12)(cid:12)(cid:12)(cid:12)(cid:27) (cid:90) (cid:12)(cid:12)(cid:12)(cid:12)(cid:27) (cid:12)(cid:12)(cid:12)(cid:12)(cid:27) (cid:90) (cid:12)(cid:12)(cid:12)(cid:12)(cid:90) (cid:82) Otherwise, h >(cid:82) If h ≤ together gives (cid:82) (cid:90) (cid:12)(cid:12)(cid:12)(cid:12) > Combining the above will give Lemma 2.4. Note that if S1 = S ∩ W , Equation (1) immediately holds. In fact, it holds even without the factor of two on the right hand side. Similarly, if S1 ⊆ S ∩ W , then it also holds (but this time with the factor of (cid:90) two). To show this, note that (cid:90) (cid:90) (cid:90) (cid:90) (p(x)−q(x))dx = W S1∩W (p(x)−q(x))dx+ S2∩W (p(x)−q(x))dx = (p(x)−q(x))dx+ S1 S2∩W (p(x)−q(x))dx. The RHS is a sum of two integrals where the second integral's integrand is always smaller than the smallest value of the first integral's integrand. Furthermore, the second integral is over a region that is no larger than the first region of the first integral, because vol(S1) = vol(S)/2, while vol(S2∩W ) ≤ vol(S2) = vol(S)/2. Thus, we have (cid:90) (p(x) − q(x))dx ≤ 2 W (p(x) − q(x))dx , S1 which implies Equation (1). (cid:82) The final case needed to prove Equation (1) holds is when S1 ∩ W (cid:40) S1, which is equivalent to saying S1∩W (cid:48)(p(x) − q(x))dx ≥ 0. Then we have (cid:90) that S1 contains points x for which p(x) < q(x). Let h = − (cid:90) (p(x) − q(x))dx = h + W (p(x) − q(x))dx . S1 W (p(x) − q(x))dx/2, then we can substitute this into the preceding equation and we are done. (p(x) − q(x))dx ≥ h. 2 Putting these W (p(x) − q(x))dx/2. Note that in this case, S2 (p(x) − q(x))dx S2 (p(x) − q(x))dx/2 , W completing the proof. We can now state the main algorithmic result of this section: Theorem 2.5. Let p be a known distribution on [0, 1]d with a (k, j, (cid:96), /2)-oblivious covering. There exists a tester that given sample access to an unknown k-histogram q on [0, 1]d distinguishes between p = q and dTV (p, q) ≥  with probability at least 2/3 using O(√kj · (cid:96)2/2) samples. Section 2.2) yields a sample complexity upper bound of O(√k2d/2 log2.5d(kd/)/2) for  ≤ 1/2. This Plugging in the bounds on j and (cid:96) of 2d logd(kd/) and logd(kd/) from Lemma 2.8 (established in gives the upper bound portion of Theorem 1.1. The high-level idea of the algorithm establishing Theorem 2.5 is to take each element of the oblivious cover and divide it in two, as in Lemma 2.4, and then use the tester from Theorem 2.3 on the induced distributions of p and q on the resulting sets. The algorithm itself is quite simple and is presented in pseudo- code below. Proof of Theorem 2.5. We note that the sample complexity of the tester described in Algorithm 1 is O(√kj(cid:96)2/2), as desired. It remains to prove correctness. The completeness case is straightforward. If p = q, then clearly p(cid:48) = q(cid:48) and our tester will accept with probability at least 2/3. 2This is because the integrand on the RHS is always more negative value of the integrand on the RHS and the region the integral on the LHS is over is at least as large as that of the integral on the RHS. This is very similar to the reasoning in the earlier case where S1 ∩ W = S1 above. 8 Algorithm 1 Identity Tester for d-dimensional k-histograms Input: sample access to k-histogram distribution q : [0, 1]d → R+,  > 0, and explicit distribution p : [0, 1]d → R+ with (k, j, (cid:96), /2)-oblivious covering. Output: "YES" if q = p; "NO" if (cid:107)q − p(cid:107)1 ≥ . defined in Lemma 2.4. (cid:48) by taking each S ∈ F and replacing it with the two sets S1 and S2 as (cid:48) where a random sample, x, from p(cid:48) (resp. q(cid:48)) is obtained (cid:48) by taking a random sample from p (resp. q) and then returning a uniform random element of F containing x. (We note that the distribution p(cid:48) can be explicitly computed, and we can take a sample from q(cid:48) at the cost of taking a sample from q.) 1. Let F be a (k, j, (cid:96), /2)-oblivious covering of the known distribution p. 2. Obtain a new family of sets F 3. Define discrete distributions p(cid:48), q(cid:48) over F size at most 2k · j with(cid:80) 4. Use the algorithm from Theorem 2.3 to distinguish between p(cid:48) = q(cid:48) and the existence of a set A of S∈A p(cid:48)(S) − q(cid:48)(S) ≥ /(8(cid:96)). 5. Output "YES" in the former case and "NO" in the latter case. We now proceed to prove soundness. If dTV (p, q) ≥ , we claim that our tester will reject with proba- bility at least 2/3. For this we note that the unknown distribution q defines some partition Π of [0, 1]d into k rectangles such that q is constant on each part of the partition. By the definition of an oblivious cover, there is a subfamily of disjoint sets S ⊆ F such that: [0,1]d\V pdx ≥ /2. (cid:48) be the collection of all S1 or S2 corresponding to an S ∈ S. We note that V max(p−q, 0)dx ≥ − S∈S S p − qdx ≥ /2. (cid:82) • q is constant on each element of S. • S ≤ k · j. • Letting V =(cid:83) [0,1]d max(p−q, 0)dx, we have that(cid:82) Since  = dTV (p, q) =(cid:82) Therefore, since the elements of S are disjoint, we have that(cid:80) S∈S S, we have that p (V ) ≥ 1 − /2. A = 2S ≤ 2k · j. Furthermore, by Lemma 2.4, we have that We now let A ⊆ F (cid:82) /8 ≤ ≤ ≤ (cid:90) S∈S S p − qdx/4 max{p(S1) − q(S1),p(S2) − q(S2)} (cid:88) (cid:88) (cid:88) S∈S A∈Ap(A) − q(A). (cid:88) A∈Ap(cid:48)(A) − q(cid:48)(A) ≥ /(8(cid:96)). On the other hand, for A ∈ A, we have that p(cid:48)(A) = p(A)/(cid:96) and q(cid:48)(A) = q(A)/(cid:96), so we have that Therefore, if dTV (p, q) ≥ , our tester will reject with probability at least 2/3. This completes the proof of Theorem 2.5. 9 (a) A z-grid with z = [1, 1]. (b) A z-grid with z = [2, 3]. Figure 1: z-grids for different values of z partition [0, 1]2 into rectangles. In this figure, the axes are scaled such that the marginal distributions of the vertical and horizontal coordinates, respectively, of p are uniform. Remark 2.6. Algorithm 1 is robust in the sense that it still works even if q is only (say) /10-close to some k-histogram distribution(cid:101)q instead of actually being one. To show this, one can note that the existing proof applied to p and(cid:101)q gives an A such that(cid:80) A∈A p(A) −(cid:101)q(A) is at least /8. The triangle inequality then implies(cid:80) A∈A p(A) − q(A) ≥ /40, which, by the same reasoning given in the proof of the non-robust case, implies the algorithm is still correct. Remark 2.7. Even though our testing algorithm was phrased for histograms over [0, 1]d, it can be made to apply for discrete histograms on [m]d via a simple reduction. In particular, if each element of [m]d is replaced by a box of side length 1/m on each side, a k-histogram on [m]d is transformed into a k-histogram over [0, 1]d, in a way that preserves total variation distance. If our algorithm is applied to the latter histogram, we can obtain correct results for the former. 2.2 Construction of Good Oblivious Covering In this section, we prove the existence of an oblivious covering: Lemma 2.8. For any continuous distribution p on [0, 1]d, positive integer k and  ≤ 1, there exists a (cid:0)k, 2d logd(4kd/), logd(4kd/), (cid:1)-oblivious covering of p. Proof. The basic idea of our construction will be to let F be a union of grids where the number of cells in each direction is a power of 2. For each coordinate, j ∈ [d], and each non-negative integer i, define the ith partition of this coordinate to be a partition of [0, 1] into 2i intervals such that jth marginal, pj, of p assigns each interval in the partition equal mass, and such that the ith partition is a refinement of the (i − 1)st. For each vector z ∈ Nd, define the z-grid as the partition of [0, 1]d into rectangles by taking the product j partition of the jth coordinate. We let F be the union of the cells in the z-grid for all z ∈ of the zth Nd ∩ [0, m − 1] for m = log2(4kd/). An illustration is given in Figure 1. We note that each x ∈ [0, 1]d is in exactly one cell in each z-grid, and therefore is contained in exactly is a subfamily Ti ⊆ F of disjoint subsets of Ri with Ti ≤ 2dmd, and such that p(cid:0)Ri\ md elements of F, verifying Property 2. For Property 1, consider a partition of [0, 1]d into rectangles R1, . . . , Rk. We claim that for each Ri there ≤ /k. It We let Ri =(cid:81)d is then clear that taking S to be the union of the Ti will suffice. In fact, we will show that for any rectangle Ri, there is a corresponding Ti with these properties. j=1 Ij for intervals Ij. We let I(cid:48) j be Ij minus the intervals of the (m − 1)st-partition of the jth coordinate that contain the endpoints of Ij. We note that pj(Ij\I(cid:48) j is a union j) ≤ /(kd) and that I(cid:48) S(cid:1) (cid:83) S∈Ti 10 Figure 2: How our oblivious covering is used to cover a rectangle Ri in the proof of Lemma 2.8. Each dimension of Ri is separately decomposed into non-overlapping one-dimensional rectangles, with a small amount of area shaded in beige left over on the sides. Ti is obtained by taking the family of all Cartesian products of the form I(cid:48)(cid:48) j. In this figure, the axes are scaled such that the marginal distributions of the vertical and horizontal coordinates, respectively, of p are uniform. j is any subinterval in the decomposition of I(cid:48) d where, for each j, I(cid:48)(cid:48) 1 × ··· × I(cid:48)(cid:48) of consecutive intervals in the (m − 1)st partition of this coordinate. We claim that this means that I(cid:48) j is the union of at most 2m intervals of one of the first m − 1 partitions of the jth coordinate. This is easy to see by induction on m, as I(cid:48) j is a union of consecutive intervals in the (m − 2)nd partition union at most one interval of the (m − 1)st on either end. The one-dimensional intervals on the top and left of Figure 2 show an illustration of this. j as a union of at most 2m intervals from the relevant partitions. We let Ti be the set of rectangles obtained by taking the product of one rectangle from each of these sets. It j into at most (2m)d pieces. Figure 2 shows an illustration of this. We now note that In order to produce Ti, we write each I(cid:48) is then clear that Ti partitions(cid:81)d R\ j=1 I(cid:48) d(cid:89) pj(Ij\I(cid:48) j) ≤ /k .  = p  d(cid:89)  ≤ d(cid:89) Ij\ I(cid:48) j I(cid:48) j p d(cid:88) j=1 j=1 j=1 j=1 Thus, T satisfies all of the desired properties, and taking the union of the Ti will yield an appropriate S. This completes the proof of Lemma 2.8. 3 Sample Complexity Lower Bound In this section, we prove the sample complexity lower bound of Theorem 1.1. The structure of this section is as follows: We begin (Proposition 3.2) by providing a new proof that Ω(√k/2) samples are required to test uniformity of a k-histogram in one dimension. The purpose of reproving this previously known result is so that we may later generalize it to higher dimensions. We then proceed by describing a basic construction that yields a slightly improved lower bound (Proposition 3.3). Finally, we present a more sophisticated construction that suffices to establish our final lower bound in Theorem 3.4. Basic Background. Recall the definition of the χ-metric. Notice that, for fixed q, χp(q, r) is an inner product on distributions q, r. Furthermore, by the Cauchy-Schwarz inequality it follows that if q and p are probability distributions then (cid:90) dq2 (cid:18)(cid:90) dq2 (cid:19)(cid:18)(cid:90) (cid:19) (cid:18)(cid:90) (cid:19)2 χp(q, q) = = dp dp ≥ dq = 1 . dp 11 RiI1Ti'I2'I1I2 This metric is useful for determining whether or not distributions can be distinguished. In particular, if q and p can be distinguished from a single sample, it must be the case that χp(q, q) is much bigger than 1. Formally, we have: Lemma 3.1. Suppose that q and p are probability distributions. Suppose furthermore that there is an algorithm that given a random sample from q accepts with probability at least 2/3, and given a random sample from p rejects with probability at least 2/3. Then, it holds that χp(q, q) ≥ 4/3. Proof. Let A be the set on which the algorithm accepts. We then have that q(A) ≥ 2/3 and p(A) ≤ 1/3. Therefore, we have that (cid:90) (cid:18)(cid:90) (cid:19)(cid:18)(cid:90) (cid:19) (cid:18)(cid:90) (cid:19)2 χp(q, q) ≥ dq2 dp ≥ 3 A dq2 dp A dp ≥ 3 A dq ≥ 4/3. A 3.1 Lower Bound for Uniformity Testing of Univariate Histograms We start by using Lemma 3.1 to prove a lower bound on the number of samples required to test uniformity of univariate k-histograms. We build on this argument in the following subsections to establish our final multidimensional lower bound. The idea is to use a standard adversary argument, using Lemma 3.1 to show that it is impossible to distinguish samples taken from a distribution from a particular ensemble, from those taken from the uniform distribution. Proposition 3.2. If there exists an algorithm that given s independent samples from an unknown k-histogram, q, on [0, 1] and accepts with at least 2/3 probability if q = U and rejects with at least 2/3 probability if dTV (q, U ) ≥ , then s = Ω(√k/2). Proof. We assume that k is even. Divide [0, 1] into k/2 equally sized bins. Let P be a distribution over k histograms where in each bin either dq = (1 + )dx on the first half and dq = (1 − )dx on the second half of the bin, or visa versa independently for each bin. Note that a sample from P is always a k-histogram q ⊗s be the distribution on [0, 1]s obtained by randomly picking a distribution q with dTV (q, U ) = . Let P from P and then taking s independent samples from q. a distribution can distinguish a single sample from P 3.1, we must have that χU⊗s(P the χ-metric, we have that Given that an algorithm to distinguish the uniform distribution from k-histograms far from it exists, such ⊗s from a sample from U⊗s. Therefore, by Lemma ⊗s is a mixture of the distributions q⊗s where q is drawn from P. Therefore, by linearity of ⊗s) ≥ 4/3. We will now try to bound this quantity. Note that P ⊗s,P χU⊗s(P ⊗s,P ⊗s) = Ep,q∼P [χU⊗s(p⊗s, q⊗s)] = Ep,q∼P [(χU (p, q))s] , where the last equality is by noting that the corresponding integral decomposes as a product. We now need to think about the distribution of χU (p, q) when p and q are drawn independently from k/2 with equal probability and dU is either 1+2 dpdq P. We note that for each bin B the quantity(cid:82) χU⊗s(p⊗s, q⊗s) ∼ independently for each bin. Therefore, B k/2 or 1−2 k/2(cid:88) s Xi , 2 k/2 i=1 1 + 12 where Xi are i.i.d. random variables Xi ∈u {±1}. Therefore, 2 k/2 ⊗s) = E χU⊗s(P ⊗s,P k/2(cid:88) i=1 Xi To bound this quantity, we use the fact that, for each t, the tth moment of a Rademacher random variable is less than or equal to the corresponding moment of the standard Gaussian. We thus have that where the Gi are i.i.d. N (0, 1) random variables. We can bound this latter quantity as follows: 1 + 1 + ⊗s) ≤ E (cid:34)(cid:32) (cid:34) 1 + ⊗s) ≤ E ≤ E χU⊗s(P ⊗s,P χU⊗s(P ⊗s,P s . s , (cid:33)s(cid:35) (cid:33)(cid:35) k/2(cid:88) i=1 Gi 2 k/2 N (0, 1) (cid:33) N (0, 1)  . /2 exp 2(cid:112)k/2 (cid:32)(cid:32) s2(cid:112)k/2 (cid:32) (cid:33)2 s2(cid:112)k/2 (cid:112)log(4/3) , = exp Hence, a testing algorithm can only exist when(cid:18) s2 √k (cid:19) ≥ or equivalently when s = Ω(√k/2). This completes the proof of Proposition 3.2. 3.2 First Attempt: Basic Multidimensional Lower Bound In this subsection, we build on the univariate construction of the previous subsection to obtain a slightly improved lower bound in d dimensions. We achieve this by modifying our ensemble in order to force any testing algorithm to guess the dimensions of the rectangles involved in the partition. Specifically, we prove the following: Proposition 3.3. If there exists an algorithm that, given s independent samples from a k-histogram, q, on [0, 1]d with k > 4d, accepts with at least 2/3 probability if p = U and rejects with at least 2/3 probability if dTV (p, U ) ≥ , then s = Ω(−2(cid:112)kd/2d log(log(k − d)/d)). defining vector of q. We next divide [0, 1]d into k/2 bins by producing a(cid:81)d Proof. We first assume that k is a power of 2, namely k = 2m+d. Since this can always be achieved by decreasing k by a factor of at most 2, this should not affect the final bound. We define an ensemble P similarly to how we did so in the proof of Proposition 3.2. To define a distribution q in P, first we randomly and uniformly pick a d-tuple (m1, m2, . . . , md) of non-negative integers summing to m. We call this the j=1 2mj grid We cut each bin into 2d equal sub-bins by diving it in half along each dimension. We divide these sub-bins into two classes based on their parity. We then let dq = (1 + )dV on the sub-bins of a random parity and dq = (1 − )dV on the other sub-bins, where the choices are independent for each bin. We note that a q drawn from P is always a k-histogram that is -far from the uniform distribution U. An illustration is given in Figure 3. 13 Figure 3: An example of a distribution from P. The dark cells have density 1 + , and the light cells have density 1− . The green lines separate the square into a 4× 2 grid, and each rectangle is filled with a random 2 × 2 checkerboard. We let P ⊗s be the distribution on ([0, 1]d)s obtained by drawing a random q from P and taking s ⊗s). We similarly independent samples from q. Once again, it suffices to bound from below χU⊗s(P have that ⊗s,P χU⊗s(P ⊗s,P ⊗s) = Ep,q∼P [(χU (p, q))s] . dpdq A d−1 s2√k/2d (cid:32)(cid:18) We note that if p and q have the same defining vectors, then the contribution to χU (p, q) from each bin is randomly and independently 2(1 ± 2)/k. Therefore, by the arguments of the previous subsec- tion, if we condition on p and q having the same defining vectors, the expectation of (χU (p, q))⊗s is at most exp . On the other hand, if p and q have different defining vectors, we claim that χU (p, q) = 1. In fact, we make the stronger claim that if A is the intersection of a defining bin of p and a dU = q(A). This is because without loss of generality we may assume that p's associated m1 is smaller than q's associated m1. This in turn means that given any point in A, the entire width of A along the first axis will be in the same sub-bin for q, but will pass through two sub-bins of opposite parity for p. Thus, the average of dp/dU over this line will be 1, and thus the integral over A of dpdp/dU is the same as the integral of dq. (cid:19)2(cid:33) defining bin of q, then(cid:82) (cid:1) different possible defining vectors, we have that Now since there are(cid:0)m+d−1 (cid:33)2 . (cid:18)m + d − 1 s2(cid:112)k/2d ⊗s) ≤ 1 + ⊗s,P (cid:115) (cid:33) (cid:32) s2(cid:112)k/2d s = Ω(−2(cid:113) d − 1 In order for this to be at least 4/3, it must be the case that (cid:19)−1 (cid:32) (cid:19) (cid:18)m + d − 1 χU⊗s(P d − 1 log (cid:29) exp or This completes the proof of Proposition 3.3. kd/2d log(log(k − d)/d)) . , 14 Figure 4: An example of a probability distribution from ensemble Q. The square is divided into n = 4 regions by the black lines. Each sub-square is divided into a randomly sized grid of 2m = 8 equal rectangles by the green lines. To get the final distribution, each of those rectangles should be filled with a random checkerboard as in Figure 3. 3.3 Second Attempt: Proof of Final Sample Lower Bound Unfortunately, the lower bound of Proposition 3.3 only saves us a log log(k) factor. This is essentially because a testing algorithm only needs to correctly guess one of poly-logarithmically many defining vectors, and once it has guessed the correct one, it only needs to see a signal large enough that the probability of error is only inverse poly-logarithmic. This can be done by increasing the number of samples by only a doubly logarithmic factor. In order to do better, we will need a slightly more complicated construction, where we chop our domain into pieces and fill each piece with rectangles, but where different pieces might have rectangles of different sizes. Theorem 3.4. If there exists an algorithm that, given s independent samples from a k-histogram, q, on [0, 1]d with k > 2100d, accepts with at least 2/3 probability if q = U, and rejects with at least 2/3 probability if dTV (p, U ) ≥ , then s = (√k/2) · Ω(log(k)/d)d−1. Proof. We first assume that k can be written in the form k = n2m+d, where n ≤ (perhaps decreasing k by a constant factor) we can achieve this with n = Ω(log(k)/d)d, and therefore we can assume this throughout the rest of the argument. (cid:1)/4. We note that (cid:0)m+d−1 d−1 We describe a new ensemble Q over k-histograms on [0, 1]d in the following way: First, divide [0, 1]d into n equal volume boxes in some arbitrary way. For each box Bi, pick a member pi from P, the ensemble from the proof of Proposition 3.3, independently for different i. We let the restriction of q to Bi be pi rescaled such that it assigns Bi total mass 1/n, and such that the domain of definition is Bi, rather than [0, 1]d. An example element of Q is illustrated in Figure 4. Similarly, it suffices to show that if s is below our desired sample lower bound then χU⊗s(Q ⊗s,Q ⊗s) = Ep,q∼Q[(χU (p, q))s] is less than 4/3. We note that for p and q drawn from Q the quantity(cid:82) q(cid:48) drawn from P. This is 1/n except with probability α := (cid:0)m+d−1 (cid:1)−1 and otherwise is distributed as  ,  2 2m(cid:88) n(cid:88) (cid:80)2m j=1 Xij, where the Xij are i.i.d. {±1} random variables. Notice that these are independent 1/n + 2 n2m for different i and sum to χU (p, q). Therefore, dU is distributed as χU (p(cid:48), q(cid:48))/n with p(cid:48) and d−1 Xij dpdq Bi χU (p, q) ∼ 1 + n2m j=1 Yi i=1 15 where the Yi are i.i.d., equal to 1 with probability α, and 0 otherwise. Therefore, we have that E (cid:34)(cid:32) Yi n2m 1 + Yi i=1 Gi n2m/2 ⊗s) = E χU⊗s(Q ⊗s,Q n(cid:88) i=1 2m(cid:88) j=1 independent Gaussians, this simplifies to 1 + (cid:18) 2 n(cid:88)  2 (cid:19)(cid:33)s(cid:35) with Gi i.i.d. standard normals. Noting that we still have a sum of(cid:80)n (cid:32) 2(cid:112)Binomial(n, α) (cid:32) s2(cid:112)Binomial(n, α) (cid:18) (cid:18) s24 (cid:19)(cid:19)n (cid:19)(cid:19) (cid:19) (cid:34)(cid:32) exp (cid:20) (cid:18) s24 (cid:18) s24 (cid:18) s24 (cid:19) 2n22m ⊗s,Q ⊗s) ≤ E ≤ E (cid:18) = E exp Binomial(n, α) χU⊗s(Q (cid:18) (cid:18) 1 + α exp ≤ exp nα exp 2n22m 2n22m n2m/2 n2m/2 1 + ≤ s . Xij (cid:33)(cid:33)s(cid:35)  N (0, 1) (cid:33)2 (cid:19)(cid:19)(cid:21) /2 Once again, this expectation is only increased if the Xij are replaced by standard Gaussians, and so χU⊗s(Q is at most ⊗s) ⊗s,Q i=1 Yi ∼ Binomial(n, α) many ≤ exp exp 2n22m /4 . In order for this to be at least 4/3, it must be the case that or equivalently that s24 2n22m (cid:29) 1 , (cid:113) kn/2d/2) = Ω(log(k)/d)d√k/2 . s = Ω(2m/2n/2) = Ω( This completes the proof of Theorem 3.4. Remark 3.5. We note that our lower bounds for uniformity testing of histograms on [0, 1]d can be made to work for histograms on [m]d, assuming that m (cid:29) k. In particular, our lower bound construction requires first dividing our domain into n equal boxes, and then subdividing each of these boxes into k/n equal boxes in such a way that the number of subdivisions in each dimension is a power of 2. For simplicity, let us assume that n is a power of d. In that case, we can first cut each edge of our original box into n1/d equal pieces and then further subdivide each side into k/n equal pieces. We note that all of the histograms in our adversarial family are consistent with this partition of our cube into fewer than kd boxes. Therefore, by the inverse of the reduction above, our lower bound can be made to work on [k]d rather than [0, 1]d. A more elaborate construction can show that our lower bounds apply for domain [m]d for any m (cid:29) k. 16 4 Conclusions and Future Directions In this work, we gave a computationally efficient and sample near-optimal algorithm for the problem of testing the identity of multidimensional histogram distributions in any fixed dimension. Our nearly matching upper and lower bounds have interesting consequences regarding the relation of learning and identity testing for this important nonparametric family of distributions. A natural direction for future work is to generalize our results to the problem of testing equivalence between two unknown multidimensional histograms. The one-dimensional version of this problem was resolved in [DKN15a, DKN17]. Additional ideas are required for this setting, as the algorithm and analysis in this work exploit the a priori knowledge of the explicit distribution. Another direction for future work concerns characterizing the sample and computationally complexity of identity testing d-dimensional k-histograms when the dimension d and the number of rectangles k are comparable, e.g., k = poly(d) or even k < d. We believe that understanding these parameter regimes requires different ideas. References [ADH+15] J. Acharya, I. Diakonikolas, C. Hegde, J. Li, and L. Schmidt. Fast and Near-Optimal Al- gorithms for Approximating Distributions by Histograms. In 34th ACM SIGMOD-SIGACT- SIGAI Symposium on Principles of Database Systems, PODS 2015, pages 249 -- 263, 2015. [ADK15] J. Acharya, C. Daskalakis, and G. Kamath. Optimal testing for properties of distributions. In Advances in Neural Information Processing Systems (NIPS), pages 3591 -- 3599, 2015. [ADLS16] [ADLS17] J. Acharya, I. Diakonikolas, J. Li, and L. Schmidt. Fast algorithms for segmented regression. In Proceedings of the 33nd International Conference on Machine Learning, ICML 2016, pages 2878 -- 2886, 2016. J. Acharya, I. Diakonikolas, J. Li, and L. Schmidt. Sample-optimal density estimation in In Proceedings of the Twenty-Eighth Annual ACM-SIAM Symposium nearly-linear time. on Discrete Algorithms, SODA 2017, pages 1278 -- 1289, 2017. Full version available at https://arxiv.org/abs/1506.00671. [BBBB72] R.E. Barlow, D.J. Bartholomew, J.M. Bremner, and H.D. Brunk. Statistical Inference under Order Restrictions. Wiley, New York, 1972. [BC17] [BCG01] T. Batu and C. L. Canonne. Generalized uniformity testing. In 58th IEEE Annual Symposium on Foundations of Computer Science, FOCS 2017, pages 880 -- 889, 2017. N. Bruno, S. Chaudhuri, and L. Gravano. Stholes: A multidimensional workload-aware his- togram. In Proceedings of the 2001 ACM SIGMOD international conference on Management of data, pages 211 -- 222, 2001. [BFR+00] T. Batu, L. Fortnow, R. Rubinfeld, W. D. Smith, and P. White. Testing that distributions are close. In IEEE Symposium on Foundations of Computer Science, pages 259 -- 269, 2000. [BKR04] [Can15] T. Batu, R. Kumar, and R. Rubinfeld. Sublinear algorithms for testing monotone and unimodal distributions. In ACM Symposium on Theory of Computing, pages 381 -- 390, 2004. C. L. Canonne. A survey on distribution testing: Your data is big. but is it blue? Electronic Colloquium on Computational Complexity (ECCC), 22:63, 2015. 17 [Can16] C. L. Canonne. Are few bins enough: Testing histogram distributions. In Proceedings of the 35th ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Systems, PODS 2016, pages 455 -- 463, 2016. [CDGR16] C. L. Canonne, I. Diakonikolas, T. Gouleakis, and R. Rubinfeld. Testing shape restrictions of discrete distributions. In 33rd Symposium on Theoretical Aspects of Computer Science, STACS 2016, pages 25:1 -- 25:14, 2016. [CDKS17a] C. L. Canonne, I. Diakonikolas, D. M. Kane, and A. Stewart. Testing bayesian networks. In Proceedings of the 30th Conference on Learning Theory, COLT 2017, pages 370 -- 448, 2017. [CDKS17b] C. L. Canonne, I. Diakonikolas, D. M. Kane, and A. Stewart. Testing conditional independence of discrete distributions. CoRR, abs/1711.11560, 2017. In STOC'18. [CDS17] C. L. Canonne, I. Diakonikolas, and A. Stewart. Fourier-based testing for families of distribu- tions. CoRR, abs/1706.05738, 2017. In NeurIPS 2018. [CDSS13] S. Chan, I. Diakonikolas, R. Servedio, and X. Sun. Learning mixtures of structured distribu- tions over discrete domains. In SODA, pages 1380 -- 1394, 2013. [CDSS14a] S. Chan, I. Diakonikolas, R. Servedio, and X. Sun. Efficient density estimation via piecewise polynomial approximation. In STOC, pages 604 -- 613, 2014. [CDSS14b] S. Chan, I. Diakonikolas, R. Servedio, and X. Sun. Near-optimal density estimation in near- linear time using variable-width histograms. In NIPS, pages 1844 -- 1852, 2014. [CDVV14] S. Chan, I. Diakonikolas, P. Valiant, and G. Valiant. Optimal algorithms for testing closeness of discrete distributions. In SODA, pages 1193 -- 1203, 2014. [CGHJ12] G. Cormode, M. Garofalakis, P. J. Haas, and C. Jermaine. Synopses for massive data: Samples, histograms, wavelets, sketches. Found. Trends databases, 4:1 -- 294, 2012. [CMN98] S. Chaudhuri, R. Motwani, and V. R. Narasayya. Random sampling for histogram construction: How much is enough? In SIGMOD Conference, pages 436 -- 447, 1998. [DDK18] C. Daskalakis, N. Dikkala, and G. Kamath. Testing Ising models. In SODA, 2018. [DDS12] C. Daskalakis, I. Diakonikolas, and R.A. Servedio. Learning k-modal distributions via testing. In SODA, pages 1371 -- 1385, 2012. [DDS+13] C. Daskalakis, I. Diakonikolas, R. Servedio, G. Valiant, and P. Valiant. Testing k-modal distri- butions: Optimal algorithms via reductions. In SODA, pages 1833 -- 1852, 2013. [DGPP16] I. Diakonikolas, T. Gouleakis, J. Peebles, and E. Price. Collision-based testers are optimal for uniformity and closeness. Electronic Colloquium on Computational Complexity (ECCC), 23:178, 2016. [DGPP17] I. Diakonikolas, T. Gouleakis, J. Peebles, and E. Price. Sample-optimal identity testing with high probability. CoRR, abs/1708.02728, 2017. In ICALP 2018. [DHS15] I. Diakonikolas, M. Hardt, and L. Schmidt. Differentially private learning of structured discrete distributions. In NIPS, pages 2566 -- 2574, 2015. 18 [DK16] I. Diakonikolas and D. M. Kane. A new approach for testing properties of discrete distributions. In FOCS, pages 685 -- 694, 2016. Full version available at abs/1601.05557. [DKN15a] I. Diakonikolas, D. M. Kane, and V. Nikishkin. Optimal algorithms and lower bounds for testing closeness of structured distributions. In IEEE 56th Annual Symposium on Foundations of Computer Science, FOCS 2015, pages 1183 -- 1202, 2015. [DKN15b] I. Diakonikolas, D. M. Kane, and V. Nikishkin. Testing identity of structured distributions. In Proceedings of the Twenty-Sixth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2015, pages 1841 -- 1854, 2015. [DKN17] I. Diakonikolas, D. M. Kane, and V. Nikishkin. Near-optimal closeness testing of discrete histogram distributions. In 44th International Colloquium on Automata, Languages, and Pro- gramming, ICALP 2017, pages 8:1 -- 8:15, 2017. [DKS16a] I. Diakonikolas, D. M. Kane, and A. Stewart. Efficient robust proper learning of log-concave distributions. CoRR, abs/1606.03077, 2016. [DKS16b] I. Diakonikolas, D. M. Kane, and A. Stewart. Statistical query lower bounds for robust estima- tion of high-dimensional gaussians and gaussian mixtures. CoRR, abs/1611.03473, 2016. In Proceedings of FOCS'17. [DKS18] [DL04] [DLS18] I. Diakonikolas, D. M. Kane, and A. Stewart. Sharp bounds for generalized uniformity testing. In Advances in Neural Information Processing Systems 31, NeurIPS 2018, pages 6204 -- 6213, 2018. L. Devroye and G. Lugosi. Bin width selection in multivariate histograms by the combinatorial method. Test, 13(1):129 -- 145, 2004. I. Diakonikolas, J. Li, and L. Schmidt. Fast and sample near-optimal algorithms for learning multidimensional histograms. In S´ebastien Bubeck, Vianney Perchet, and Philippe Rigollet, editors, Proceedings of the 31st Conference On Learning Theory, volume 75 of Proceedings of Machine Learning Research, pages 819 -- 842. PMLR, 2018. [DP17] C. Daskalakis and Q. Pan. Square Hellinger subadditivity for Bayesian networks and its appli- cations to identity testing. In Proceedings of the 30th Conference on Learning Theory, COLT 2017, pages 697 -- 703, 2017. [FD81] D. Freedman and P. Diaconis. On the histogram as a density estimator:l2 theory. Zeitschrift fur Wahrscheinlichkeitstheorie und Verwandte Gebiete, 57(4):453 -- 476, 1981. [GGI+02] A. C. Gilbert, S. Guha, P. Indyk, Y. Kotidis, S. Muthukrishnan, and M. Strauss. Fast, small- space algorithms for approximate histogram maintenance. In STOC, pages 389 -- 398, 2002. [GGR98] O. Goldreich, S. Goldwasser, and D. Ron. Property testing and its connection to learning and approximation. Journal of the ACM, 45:653 -- 750, 1998. [GJ14] P. Groeneboom and G. Jongbloed. Nonparametric Estimation under Shape Constraints: Esti- mators, Algorithms and Asymptotics. Cambridge University Press, 2014. [GKS06] S. Guha, N. Koudas, and K. Shim. Approximation and streaming algorithms for histogram construction problems. ACM Trans. Database Syst., 31(1):396 -- 438, 2006. 19 [GKTD00] D. Gunopulos, G. Kollios, V. J. Tsotras, and C. Domeniconi. Approximating multi- In Proceedings of the 2000 ACM dimensional aggregate range queries over real attributes. SIGMOD International Conference on Management of Data, pages 463 -- 474, 2000. [Gol17] O. Goldreich. Introduction to Property Testing. Forthcoming, 2017. [Gre56] [ILR12] U. Grenander. On the theory of mortality measurement. Skand. Aktuarietidskr., 39:125 -- 153, 1956. P. Indyk, R. Levi, and R. Rubinfeld. Approximating and Testing k-Histogram Distributions in Sub-linear Time. In PODS, pages 15 -- 22, 2012. [JKM+98] H. V. Jagadish, N. Koudas, S. Muthukrishnan, V. Poosala, K. C. Sevcik, and T. Suel. Optimal histograms with quality guarantees. In VLDB, pages 275 -- 286, 1998. [Kle09] [LN96] [Mut05] [NP33] [Pan08] [Pea00] [PI97] J. Klemela. Multivariate histograms with data-dependent partitions. 19(1):159 -- 176, 2009. Statistica Sinica, G. Lugosi and A. Nobel. Consistency of data-driven histogram methods for density estimation and classification. Ann. Statist., 24(2):687 -- 706, 04 1996. S. Muthukrishnan. Data streams: Algorithms and applications. Found. Trends Theor. Comput. Sci., 1(2):117 -- 236, 2005. J. Neyman and E. S. Pearson. On the problem of the most efficient tests of statistical hypothe- ses. Philosophical Transactions of the Royal Society of London. Series A, Containing Papers of a Mathematical or Physical Character, 231(694-706):289 -- 337, 1933. L. Paninski. A coincidence-based test for uniformity given very sparsely-sampled discrete data. IEEE Transactions on Information Theory, 54:4750 -- 4755, 2008. K. Pearson. On the criterion that a given system of deviations from the probable in the case of a correlated system of variables is such that it can be reasonably supposed to have arisen from random sampling. Philosophical Magazine Series 5, 50(302):157 -- 175, 1900. V. Poosala and Y. E. Ioannidis. Selectivity estimation without the attribute value independence assumption. In Proceedings of the 23rd International Conference on Very Large Data Bases, VLDB '97, pages 486 -- 495, San Francisco, CA, USA, 1997. Morgan Kaufmann Publishers Inc. [RS96] R. Rubinfeld and M. Sudan. Robust characterizations of polynomials with applications to program testing. SIAM J. on Comput., 25:252 -- 271, 1996. [Rub12] R. Rubinfeld. Taming big probability distributions. XRDS, 19(1):24 -- 28, 2012. [Sco79] D. W. Scott. On optimal and data-based histograms. Biometrika, 66(3):605 -- 610, 1979. [Sco92] D.W. Scott. Multivariate Density Estimation: Theory, Practice and Visualization. Wiley, New York, 1992. [TGIK02] N. Thaper, S. Guha, P. Indyk, and N. Koudas. Dynamic multidimensional histograms. In SIGMOD Conference, pages 428 -- 439, 2002. 20 [VV14] [WN07] G. Valiant and P. Valiant. An automatic inequality prover and instance optimal identity testing. In FOCS, 2014. R. Willett and R. D. Nowak. Multiscale poisson intensity and density estimation. IEEE Trans- actions on Information Theory, 53(9):3171 -- 3187, 2007. Appendix A Proof of Theorem 2.3 We use the flattening method developed in [DK16]. We begin by giving the definition of a split distribution from that work: to i. Thus,(cid:80)n Definition A.1. Given a distribution p on [n] and a multiset S of elements of [n], define the split distribution pS on [n + S] as follows: For 1 ≤ i ≤ n, let ai denote 1 plus the number of elements of S that are equal i=1 ai = n + S. We can therefore associate the elements of [n + S] to elements of the set B = {(i, j) : i ∈ [n], 1 ≤ j ≤ ai}. We now define a distribution pS with support B, by letting a random sample from pS be given by (i, j), where i is drawn randomly from p and j is drawn randomly from [ai]. We recall a basic fact about split distributions: Fact A.2 (Fact 2.5, [DK16]). Let p and q be probability distributions on [n], and S be a given multiset of [n]. Then: (i) We can simulate a sample from pS or qS by taking a single sample from p or q, respectively. (ii) It holds (cid:107)pS − qS(cid:107)1 = (cid:107)p − q(cid:107)1. We also recall an optimal (cid:96)2-closeness tester under the promise that one of the distributions has small (cid:96)2-norm: Lemma A.3 ([CDVV14]). Let p and q be two unknown distributions on [n]. There exists an algorithm that on input n, b ≥ min{(cid:107)p(cid:107)2,(cid:107)q(cid:107)2} and 0 <  < √2b, draws O(b/2) samples from each of p and q and, with probability at least 2/3, distinguishes between the cases that p = q and (cid:107)p − q(cid:107)2 > . We now have all the necessary tools to describe and analyze our (cid:96)k 1-identity tester. The pseudo-code of our algorithm follows: 1-Identity-Tester Algorithm 2 (cid:96)k Input: sample access to discrete distribution q : [n] → [0, 1], k ∈ Z+, and  > 0, and explicit distribution p : [n] → [0, 1]. Output: "YES" if q = p; "NO" if (cid:107)q − p(cid:107)1,k ≥ . 1. Let S be the multiset obtained by taking (cid:98)kpi(cid:99) copies of i ∈ [n]. 2. Use the (cid:96)2-tester of Lemma A.3 to distinguish between the cases that pS = qS and (cid:107)pS − qS(cid:107)2 2 ≥ 2/(2k) and return the result. We now provide the simple analysis. Note that S ≤ i=1 kpi = k and that pS assigns probability mass at most 1/k to each domain element. Therefore, we have that (cid:107)pS(cid:107)2 ≤ 1/√k. By Lemma A.3 -- applied for b = 1/√k and /√2k in place of  -- we obtain that the (cid:96)2-tester in Step 2 of the above pseudo-code requires O(b/2) = O(√k/2) samples from qS and pS. Since p is explicitly given, so is pS (cid:80)n 21 and therefore we can straightforwardly generate samples from pS for free. By Fact A.2, we can generate a sample from qS given a sample from q. Hence, our algorithm uses O(√k/2) samples from q. This completes the analysis of the sample complexity. We now prove correctness. If p = q, then by Fact A.2 we have that pS = qS and the algorithm will return "YES" with appropriate probability. On the other hand, if (cid:107)q − p(cid:107)1,k ≥ , then by definition of the (cid:96)k 1 metric it follows that (cid:107)pS − qS(cid:107)1,k+m ≥ , for m def= S. Since k + m elements contribute to total (cid:96)1-error at least , by the Cauchy-Schwarz inequality, we have that (cid:107)pS − qS(cid:107)2 2 ≥ 2/(k + m) ≥ 2/(2k) , where we used the fact that m = S ≤ k. Therefore, in this case, the algorithm returns "NO" with appropriate probability. This completes the proof of Theorem 2.3. 22
1709.04711
1
1709
2017-09-14T11:32:52
EMOMA: Exact Match in One Memory Access
[ "cs.DS" ]
An important function in modern routers and switches is to perform a lookup for a key. Hash-based methods, and in particular cuckoo hash tables, are popular for such lookup operations, but for large structures stored in off-chip memory, such methods have the downside that they may require more than one off-chip memory access to perform the key lookup. Although the number of off-chip memory accesses can be reduced using on-chip approximate membership structures such as Bloom filters, some lookups may still require more than one off-chip memory access. This can be problematic for some hardware implementations, as having only a single off-chip memory access enables a predictable processing of lookups and avoids the need to queue pending requests. We provide a data structure for hash-based lookups based on cuckoo hashing that uses only one off-chip memory access per lookup, by utilizing an on-chip pre-filter to determine which of multiple locations holds a key. We make particular use of the flexibility to move elements within a cuckoo hash table to ensure the pre-filter always gives the correct response. While this requires a slightly more complex insertion procedure and some additional memory accesses during insertions, it is suitable for most packet processing applications where key lookups are much more frequent than insertions. An important feature of our approach is its simplicity. Our approach is based on simple logic that can be easily implemented in hardware, and hardware implementations would benefit most from the single off-chip memory access per lookup.
cs.DS
cs
EMOMA: Exact Match in One Memory Access Salvatore Pontarelli, Pedro Reviriego, Michael Mitzenmacher 1 ! 7 1 0 2 p e S 4 1 ] S D . s c [ 1 v 1 1 7 4 0 . 9 0 7 1 : v i X r a Abstract-An important function in modern routers and switches is to perform a lookup for a key. Hash-based methods, and in particular cuckoo hash tables, are popular for such lookup operations, but for large structures stored in off-chip memory, such methods have the downside that they may require more than one off-chip memory access to perform the key lookup. Although the number of off-chip memory accesses can be reduced using on-chip approximate membership structures such as Bloom filters, some lookups may still require more than one off-chip memory access. This can be problematic for some hardware imple- mentations, as having only a single off-chip memory access enables a predictable processing of lookups and avoids the need to queue pending requests. We provide a data structure for hash-based lookups based on cuckoo hashing that uses only one off-chip memory access per lookup, by utilizing an on-chip pre-filter to determine which of multiple locations holds a key. We make particular use of the flexibility to move elements within a cuckoo hash table to ensure the pre-filter always gives the correct response. While this requires a slightly more complex insertion procedure and some additional memory accesses during insertions, it is suitable for most packet processing applications where key lookups are much more frequent than insertions. An important feature of our approach is its simplicity. Our approach is based on simple logic that can be easily implemented in hardware, and hardware implementations would benefit most from the single off-chip memory access per lookup. 1 INTRODUCTION Packet classification is a key function in modern routers and switches used for example for routing, security, and quality of service [1]. In many of these applications, the packet is compared against a set of rules or routes. The comparison can be an exact match, as for example in Ethernet switch- ing, or it can be a match with wildcards, as in longest prefix match (LPM) or in a firewall rule. The exact match can be implemented using a Content Addressable Memory (CAM) and the match with wildcards with a Ternary Con- tent Addressable Memory (TCAM) [2], [3]. However, these memories are costly in terms of circuit area and power and therefore alternative solutions based on hashing techniques using standard memories are widely used [4]. In particu- lar, for exact match, cuckoo hashing provides an efficient • S. Pontarelli is with Consorzio Nazionale Interuniversitario per le Teleco- municazioni (CNIT), Via del Politecnico 1, 00133 Rome, Italy. E-mail: [email protected] • P. Reviriego is with Universidad Antonio de Nebrija, C/ Pirineos, 55, E- 28040 Madrid, Spain. E-mail: [email protected] • M. Mitzenmacher is with Harvard University, 33 Oxford Street, Cam- bridge, MA 02138, USA. E-mail: [email protected] Manuscript submitted 13 Set. 2017 solution with close to full memory utilization and a low and bounded number of memory accesses for a match [5]. For other functions that use match with wildcards, schemes that use several exact matches have also been proposed. For example, for LPM a binary search on prefix lengths can be used where for each length an exact match is done [6]. More general schemes have been proposed to implement matches with wildcards that emulate TCAM functionality using hash based techniques [7]. In addition to reducing the circuit complexity and power consumption, the use of hash based techniques provides additional flexibility that is beneficial to support programmability in software defined networks [8]. High speed routers and switches are expected to process packets with low and predictable latency and to perform updates in the tables without affecting the traffic. To achieve those goals, they commonly use hardware in the form of Application Specific Integrated Circuits (ASICs) or Field Programmable Gate Arrays (FPGAs) [8], [9]. The logic in those circuits has to be simple to be able to process packets at high speed. The time needed to process a packet has also to be small and with a predictable worst case. For example, for multiple-choice based hashing schemes such as cuckoo hashing, multiple memory locations can be accessed in parallel so that the operation completes in one access cycle [8]. This reduces latency, and can simplify the hardware implementation by minimizing queueing and conflicts. Both ASICs and FPGAs have internal memories that can be accessed with low latency but that have a limited size. They can also be connected to much larger external memories that have a much longer access time. Some tables used for packet processing are necessarily large and need to be stored in the external memory, limiting the speed of packet processing [10]. While parallelization may again seem like an approach to hold operations to one memory access cycle, for external memories parallelization can have a huge cost in terms of hardware design complexity. Parallel access to external memories would typically use different memory chips to perform parallel reads, different buses to exchange addresses and data between the network device and the external memory, and therefore a significant number of I/O pins are needed to drive the address/data bus of multiple memory chips. Unfortunately, switch chips have a limited number of pins count and it seems that this limitation will be maintained over the next decade [11]. While the memory I/O interface must work at high speed, parallelization is often unaffordable from the point of view of the hardware design. When a single external memory is used, the time needed to complete a lookup depends on the number of external memory accesses. This makes the hardware implementation more complex if lookups are not always completed in one memory access cycle, and hence finding methods where lookups complete with a single memory access remains important in this setting to enable efficient implementations. More generally, such schemes may simplify or improve other systems that require lookup operations at large scale. It is well known that in the context of multiple-choice hashing schemes the number of memory accesses can be reduced by placing an approximate membership data struc- ture, such as a Bloom filter, as a prefilter on the on-chip memory to guide where (at which choice) the key can be found [12]. If we use a Bloom filter for each possible choice of hash function to track which elements have been placed by each hash function, a location in the external memory need only to be accessed when the corresponding Bloom filter returns that the key can be found in that location [12]. However, false positives from a Bloom filter can still lead to requiring more than one off-chip memory access for a non-trivial fraction of lookups, and in particular implies that more than one lookup is required in the worst case. Before continuing, we remark that our results are cur- rently empirical; we do not have a theoretical proof re- garding for example the asymptotic performance of our data structure. The relationship and interactions between the Bloom filter prefilter and the cuckoo hash table used in the EMOMA data structure are complex, and we expect our design to lead to interesting future theoretical work. The rest of the paper is organized as follows. Section 2 covers the background needed for the rest of the paper. Most importantly, it provides a brief overview of the relevant data structures (cuckoo hash tables and counting block Bloom filters). Section 3 introduces our Exact Match in One Memory Access (EMOMA) solution and discusses several implementation options. EMOMA is evaluated in Section 4, where we show that it can achieve high memory occu- pancy while requiring a single off-chip memory access per lookup. Section 5 compares the proposed EMOMA solution with existing schemes. Section 6 presents the evaluation of the feasibility of a hardware implementation on an FPGA We introduce an Exact Match in One Memory Access (EMOMA) data structure, designed to allow a key lookup with a single off-chip memory access. We modify the pre- filter approach based on Bloom filters to tell us in which memory location a key is currently placed by taking advan- tage of the cuckoo hash table's ability to move elements if needed. By moving elements, we can avoid false positives in our Bloom filters, while maintaining the simplicity of a Bloom filter based approach for hardware implementation. Our experimental results show that we can maintain high memory loads with our off-chip cuckoo hash table. The proposed EMOMA data structure is attractive for implementations that benefit from having a single off-chip memory access per lookup and applications that have a large ratio of lookups to insertions. Conversely, when more than one off-chip memory access can be tolerated for a small fraction of the lookups or when the number of insertions is comparable to that of lookups, other data structures will be more suitable. platform. Finally, Section 7 summarizes our conclusions and outlines some ideas for future work. 2 2 PRELIMINARIES This section provides background information on the mem- ory architecture of modern network devices and briefly describes two data structures used in EMOMA: cuckoo hash tables and counting block Bloom filters. Readers familiar with these topics can skip this section and proceed directly to Section 3. 2.1 Network Devices Memory Architecture The number of entries that network devices must store con- tinues to grow, while simultaneously the throughput and latency requirements grow more demanding. Unfortunately, there is no universal memory able to satisfy all performance requirements. On-chip SRAM on the main network pro- cessing device has the highest throughout and minimum latency, but the size of this memory is typically extremely small (few MBs) compared with other technologies [13]. This is due in part to the larger size of the SRAM memory cells and to the fact that most of the chip real estate on the main network processing device must be used for other functions related to data transmission and switching. On- chip DRAMs (usually called embedded RAM or eDRAM) are currently used in microprocessors to realize large memo- ries such as L2/L3 caches [14]. These memories can be larger (8x with respect to SRAM) but have higher latencies. Off- chip memories such as DRAM have huge size compared to on-chip memories (on the order of GB), but require power consumption one order of magnitude greater that on-chip memory and have latency higher than on-chip memories. For example, a Samsung 2Gb DRAM memory chip clocked at 1,866 MHz has worst case access time of 48 ns1 [15], [16]. Alternatives to standard off-chip DRAM that reduce latency have been explicitly developed for network devices. Some examples are the reduced latency DRAM (RLDRAM) [17] used in some Cisco Routers or the quad-data rate (QDR) SRAM [18] used in the 10G version of NetFPGA [9]. These memory types provide different compromises between size, latency, and throughput, and can be used as second level memories (hereinafter called external memories) for net- work devices. Regardless of the type of memory used, it is important to minimize the average and worst case number of external memory accesses per lookup. As said in the introduction, having a single memory access per lookup simplifies the hardware implementation and reduces both latency and jitter. Caching can be used, with the inner memory levels storing the most used entries [10]. However, this approach does not improve the worst-case latency. It also potentially creates packet reordering and packet jitter, and is effective only when the internal cache is big enough (or the traffic is concentrated enough) to catch a significant amount of traffic. 1. Here we refer to the minimum time interval between successive active commands to the same bank of a DRAM. This time corresponds to the latency between two consecutive read accesses to different rows of the same bank of a DRAM. Another option is to use the internal memory to store an approximate compressed information about the entries stored in the external memory to reduce the number of external memory accesses as done in EMOMA. This is the approach used for example in [19], where a counting Bloom filter identifies in which bucket a key is stored. However, existing schemes do not guarantee that lookups are completed in one memory access or are not amenable to hardware implementation. Section 5 discusses in more detail the benefits of EMOMA compared to other schemes based on using approximate compressed on-chip information. 2.2 Cuckoo Hashing Cuckoo hash tables are efficient data structures commonly used to implement exact match [5]. A cuckoo hash table uses a set of d hash functions to access a table composed of buckets, each of which can store one or more entries. A given element x is placed in one of the buckets h1(x), h2(x), . . . , hd(x) in the table. The structure supports the following operations: • • Search: The buckets hi(x) are accessed and the en- tries stored there are compared with x; if x is found a match is returned. Insertion: The element x is inserted in one of the d buckets. If all the buckets are initially full, an element y in one of the buckets is displaced to make room for x and recursively inserted. • Removal: The element is searched for, and if found it is removed. The above operations can be implemented in various ways. For example, typically on an insertion if the d buckets for element x are full a random bucket is selected and a random element y from that bucket is moved. Another common implementation of cuckoo hashing is to split the cuckoo hash table into d smaller subtables, with each hash function associated with (that is, returning a value for) just one subtable. The single-table and d-table alternatives pro- vide the same asymptotic performance in terms of memory utilization. When each subtable is placed on a different memory device this enables a parallel search operation that can be completed in one memory access cycle [20]. However, as discussed in the introduction, this is not desirable for external memories, as supporting several external memory interfaces requires increasing the number of pins and mem- ory controllers. It is possible that an element cannot be placed success- fully on an insertion in a cuckoo hash table. For example, when d = 2, if nine elements map to the same pair of buckets and each bucket only has four entries, there is no way to store all of the elements. Theoretical results (as well as empirical results) have shown this is a low probability failure event as long as the load on the table remains sufficiently small (see, e.g., [21], [22], [23]). This failure probability can be reduced significantly further by using a small stash to store elements that would otherwise fail to be placed [24]; such a stash can also be used to hold elements currently awaiting placement during the recursive insertion procedure, allowing searches to continue while an insertion is taking place [25]. In cuckoo hashing, a search operation requires at most d memory accesses. In the proposed EMOMA scheme, we use d = 2. To achieve close to full occupancy with d = 2, the table should support at least four entries per bucket. We use four entries per bucket in the rest of the paper. 3 2.3 Counting Block Bloom Filters A Bloom filter is a data structure that provides approximate set membership checks using a table of bits [26]. We assume there are m bits, initially all set to zero. To insert an ele- ment x, k hash function values h1(x), . . . hk(x) with range [0, m − 1] are computed and the bits with those positions in the table are set to 1. Conversely, to check if an element is present, those same positions are accessed and checked; when all of them are 1, the element is assumed to be in the set and a positive response is obtained, but if any position is 0, the element is known not to be in the set and a negative response is obtained. The Bloom filter can produce false positive responses for elements that are not in the set, but false negative responses are not possible in a Bloom filter. Counting Bloom filters use a counter in each position of the table instead of just a bit to enable the removal of elements from the set [27]. The counters associated with the positions given by the k hash functions are incremented during insertion and decremented during removal. A match is obtained when all the counters are greater than zero. Generally, 4-bit counters are sufficient, although one can use more sophisticated methods to reduce the space for counters even further [27]. In the case of counting Bloom filters one option to minimize the use of on-chip memory is to use a normal Bloom filter (by converting all non-zero counts to the bit 1) on-chip while the associated counters are stored in external memory. Search operations do not need to access the counters, but insertions and removals will require operations on the external memory; the benefit is that this reduces the amount of on-chip memory needed to implement the filter. A traditional Bloom filter requires k memory access to find a match. The number of accesses can be reduced by placing all the k bits on the same memory word. This is done by dividing the table in blocks and using first a block selection hash function h0 to select a block and then a set of k hash functions h1(x), h2(x), . . . hk(x) to select k positions within that block [28]. This variant of Bloom filter is known as a block Bloom filter. When the size of the block is equal to or smaller than a memory word, a search can be completed in one memory access. Block Bloom filters can also be extended to support the removal of elements by using counters. In the proposed scheme, a counting block Bloom filter (CBBF) is used to select the hash function to use to access the external memory on a search operation, as we describe below. 3 DESCRIPTION OF EMOMA EMOMA is a dictionary data structure that keeps key-value pairs (x, vx); the structure can be queried to determine the value vx for a resident key x (or it returns a null value if x is not a stored key), and allows for the insertion and deletion of key-value pairs. The structure is designed for a certain fixed size of keys that can be stored (with high probability), as explained further below. We often refer to the key x as an element. When discussing issues such as inserting an element x, we often leave out discussion of the value, although it is implicitly stored with x. The EMOMA structure is built around a cuckoo hash table stored in external memory. In particular, two hash functions are used for the cuckoo hash table, and without any optimization two memory accesses could be required to search for an element. To reduce the number of memory accesses to one – the main goal of EMOMA – a counting block Bloom filter (CBBF) is used to determine the hash function that needs to be used to search for an element. Specifically, the CBBF keeps track of the set of elements that have been placed using the second hash function. On a positive response on the CBBF, we access the table using the second hash function, and otherwise, on a negative response, we access the table using the first hash function. As long as the CBBF is always correct, all searches require exactly one access to the external memory. A potential problem of this scheme is that a false positive on the CBBF would lead us to access the table using the second hash function when the element may have been inserted using the first hash function. This is avoided by ensuring that elements that would give a false positive on the CBBF are always placed according to the second hash function. That is, we avoid the possibility of a false positive leading us to perform a look up in the wrong location in memory by forcing the element to use the second hash function in case of a false positive, maintaining consistency at the cost of some flexibility. In particular, such elements cannot be moved without violating the requirement that elements that yield a (false or true) positive on the CBBF must be placed with the second hash function. Two key design features make this possible. The first is that the CBBF uses the same hash function for the block selection as the first hash function for the cuckoo hash table. Because of this, entries that can create false positives on a given block in the CBBF can be easily identified, as we have their location in the cuckoo hash table. The second feature is that the cuckoo hash table provides us the flexibility to move entries so that the ones that would otherwise create false positives can be moved so that they are placed according to the second hash function. Although it may be possible to extend EMOMA for a cuckoo hash table that uses more than two hash functions, this is not considered in the rest of the paper. The main reason to do so is that in such configuration several CBBFs would be needed to identify the hash function to use for a search making the implementation more complex and less efficient. The CBBF can be stored on-chip while the associated counters can be stored off-chip as they are not needed for search operations; the counters will need to be modified for insertions or deletions of elements, however. The CBBF generally requires only one on-chip memory access as the block size is small and fits into a single memory word. The cuckoo hash table entries are stored off-chip. To achieve high utilization, we propose that the cuckoo hash table uses buckets that can contain (at least) four entries. As discussed in the previous section, two implementations are possible for the cuckoo hash table: a single table accessed with two 4 hash functions or two independent subtables each accessed with a different hash function. While in a standard cuckoo hash table both options are known to provide the same asymptotic performance in terms of memory occupancy, with our proposed data structure there are subtle reasons to be explained below that make the two alternatives different. In the rest of the section the discussion focuses on the single- table approach but it can be easily extended for the double- table case. 3.1 Structures The structures used in EMOMA for the single-table imple- mentation are shown in Figure 1 and include: 1) A counting block Bloom filter (CBBF) that tracks all elements currently placed with the second hash function in the cuckoo table. The associated Bloom filter for the CBBF is stored on-chip and the counters are stored off-chip; we refer generally to the CBBF for both objects, where the meaning is clear by context. We denote the block selection function by h1(x) and the k bit selection functions by g1(x), g2(x), . . . gk(x). The CBBF is preferably set up so that the block size is one memory word. 2) A cuckoo hash table to store the elements and asso- ciated values; we assume four entries per bucket. This table is stored off-chip and accessed using two hash functions h1(x) and h2(x). The first hash function is the same as the one used for the block selection in the CBBF. This means that when insert- ing an element y on the CBBF, the only other entries stored in the table that can produce a false positive in the CBBF are also in bucket h1(y). Therefore, they can be easily identified and moved out of the bucket h1(y) to avoid an erroneous response. 3) A small stash used to store elements and their values that are pending insertion or that have failed insertion. The elements in the stash are checked for a match on every search operation. In what follows, think of the stash as a constant-sized structure. Fig. 1. Block diagram of the single-table implementation of the proposed EMOMA scheme. As mentioned before, an alternative is to place the el- ements on two independent subtables, one accessed with h1(x) and the other with h2(x). This double-table imple- mentation is illustrated in Figure 2. In this configuration, to have the same number of buckets, the size of each of the tables should be half that of the single table. Since the CBBF uses h1(x) as the block selection function, this in turn means that the CBBF has also half the number of blocks as in the single table case. Assuming that the same amount of on-chip memory is used for the CBBF in both configurations this means that the size of the block in the CBBF is double that of the single-table case. In the following, the discussion will focus on the single-table implementation but the procedures described can easily be modified for the double-table implementation. Fig. 2. Block diagram of the double-table implementation of the proposed EMOMA scheme. Fig. 3. Search Operation. 3.2 Operations The process to search for an element x is illustrated on Figure 3 and proceeds as follows: 1) The element is compared with the elements in the stash. On a match, the value vx associated with that entry is returned, ending the process. 2) Otherwise, the CBBF is checked by accessing posi- tion h1(x) and checking if the bits given by g1(x), g2(x), . . . gk(x) are all set to one (a positive re- sponse) or not (a negative response). 3) On a negative response, we read bucket h1(x) in the hash table and x is compared with the elements 5 stored there. On a match, the value vx associated with that entry is returned, and otherwise we return a null value. 4) On a positive response, we read bucket h2(x) in the hash table and x is compared with the elements stored there. On a match, the value vx associated with that entry is returned, and otherwise we return a null value. In all cases, at most one off-chip memory access is needed. Insertion is more complex. An EMOMA insertion must ensure that there are no false positives for elements inserted using h1(x), as any false positive would cause the search to use the second hash function when the element was inserted using the first hash function, yielding an incorrect response. Therefore we ensure that we place elements obtaining a positive response from the CBBF using h2(x). However, those elements can no longer be moved and therefore reduce the number of available moves in the cuckoo hash table, which are needed to maximize occupancy. In the following we refer to such elements as "locked." As an example, assume now that a given block in the CBBF has already some bits set to one because previously some elements that map to that block have been inserted using h2(x). If we want to insert a new element y that also maps to that block, we need to check the CBBF. If the response of this check is positive, this means that a search for y would always use h2(y). Therefore, we have no choice but to insert y using h2(y) and y is "locked" in that bucket. Locked elements can only be moved if at some point elements are removed from the CBBF so that the locked element is no longer a false positive in the CBBF, thereby unlocking the element. Note that, to maintain proper counts in the CBBF for when elements are deleted, an element y placed using the second hash function because it yields a false positive on the CBBF must still be added to the CBBF on insertion. To minimize the number of elements that are locked, the number of elements inserted using h2(x) should be mini- mized as this reduces the number of ones on the CBBF and thus its false positive rate. This fact seems to motivate using a single table accessed with two hash functions instead of the double-table implementation. When two tables are used and we are close to full occupancy, at most approximately half the elements can be inserted using h1(x); with a single table, the number of elements inserted using h1(x) can be much larger than half. However, when two tables are used, the size of the block in the CBBF is larger making it more effective. Therefore, it is not clear which of the two options will perform better. In the evaluation section, results are presented for both options to provide insight into this question. To present the insertion algorithm, we first describe the overall process and then discuss each of the steps in more detail. The process is illustrated in Figure 4 and starts when a new element x arrives for insertion. The insertion algo- rithm will perform up to t iterations, where in each iteration an element from the stash is attempted to be placed. The steps in the algorithm are as follows: 1) Step 1: the new element x is placed in the stash. This ensures that it will be found should any search 2) 3) 4) 5) operation for x occur during the insertion. Step 2: select a bucket to insert the new element x. Step 3: select a cell in the bucket chosen in Step 2 to insert the new element x. Step 4: insert element x in the selected bucket and cell and update the relevant data structures if needed. Increase the number of iterations by one. Step 5: Check if there are elements in the stash, and if the maximum number of iterations t has not been reached. If both conditions hold, select one of the elements uniformly at random and go to Step 2. Otherwise, the insertion process ends. Fig. 4. Insertion Operation. The first step to insert an element x in EMOMA is to place it in the stash. This enables search operations to continue during the insertion as the new element will be found if a search is done. The same applies to elements that may be placed into the stash during the insertion as discussed in the following steps of the algorithm. In the second step, we select one of the two buckets h1(x) or h2(x). The bucket selection depends on the following conditions: 6 1) Are there empty cells in h1(x) and h2(x)? 2) Is the element x being inserted a false positive on the CBBF? 3) Does inserting x in the CBBF create false positives for elements stored in bucket h1(x)? Those conditions can be checked by reading buckets h1(x) and h2(x) and the CBBF block in address h1(x) and doing some simple calculations. There are five possible cases for an insertion, as show in in Table 1. (Note these cases are mutually exclusive and partition all possible cases.) We describe these cases in turn. The first case occurs when x itself is a false positive in the CBBF; in that case, we must insert x at h2(x) as on a search for x, the CBBF would return a positive and proceed to access the bucket h2(x). This is illustrated on Figure 5 (Case 1), where even if there is an empty cell in bucket h1(x) and there is no room in bucket h2(x), the new element x must be inserted in h2(x) displacing one of the elements stored there. The second case occurs when the new element is not a false positive on the CBBF and there are empty cells in bucket h1(x). We then insert the new element on h1(x). This second case is illustrated on Figure 5 (Case 2). The third case is when the new element x is not a false positive on the CBBF, all the cells are occupied in bucket h1(x), there are empty cells on bucket h2(x), and inserting x in the CBBF does not create false positives for other elements stored in bucket h1(x). Then x is inserted in bucket h2(x) as shown in Figure 5 (Case 3). The fourth case occurs when the new element x is not a false positive on the CBBF, all the cells are occupied in bucket h1(x), and inserting x on the CBBF creates false pos- itives for other elements stored in bucket h1(x). The element is stored in bucket h1(x) to avoid the false positives even if there are empty cells in bucket h2(x). This is illustrated on Figure 5 (Case 4) where inserting x in the CBBF would create a false positive for element a that was also inserted in h1(x) (where h1(a) = h1(x)). Finally, the last case is when both buckets are full, the new element is not a false positive in the CBBF, and inserting it in the CBBF does not create other false positives. Then the bucket for the insertion is selected randomly, as both can be used. 2) 1) The third step of the insertion algorithm selects a cell in the bucket chosen in the second step. This is done as follows: If there are empty cells in the bucket, select one of them randomly. If all cells are occupied the selection is done among elements that are not locked as follows: with proba- bility P select randomly among elements that create the fewest locked elements when moved (elements inserted with h2 will never create false positives). With probability 1 − P randomly among all ele- ments. It might seem that to reduce the elements that are locked during movements, we should set P = 1. Such a greedy Fig. 5. Examples of insertion of an element x in EMOMA. TABLE 1 Selection of a bucket for insertion Case Case 1 Case 2 Case 3 Case 4 Case 5 in h1(x) Yes/No Yes No No No in h2(x) Yes/No Yes/No Yes/No Yes No Empty cells Empty cells x is a false positive on the CBBF Inserting x on the CBBF creates false positives Yes/No Yes/No No Yes No Yes No No No No 7 Bucket selected for insertion h2(x) h1(x) h2(x) h1(x) Random selection approach of selecting an element to move that produces the fewest locked elements can limit flexibility, and can cause insertion failures that leave elements in the stash that could be placed. For example, if the element selected is y and in bucket h2(y) there are four locked elements the insertion process will cycle until eventually halting and leaving additional elements in the stash as we will show in detail later, putting the data structure closer to failure. We corroborate this in the evaluation section. Once the bucket and cell have been selected, the fourth step of the algorithm inserts element x there. Before doing so, we need to check if there is an element y stored in that cell. If so, y is placed in the stash and removed from the CBBF if it was inserted using h2(y). This may unlock elements that are no longer false positives on the CBBF due to the removal of y from the CBBF; such elements remain in the second table, however. We also need to check if x is inserted into h2(x) that, as a result of inserting x, elements in bucket h1(x) need to be moved (or locked) because they will be false positives on the CBBF once x is inserted. If so they are also placed in the stash. Then x is inserted in the CBBF if the selected bucket is h2(x), and finally x is inserted on the selected cell and removed from the stash. The number of iterations is increased by one before proceeding to the next step. In the fifth and last step of the insertion algorithm, we check if there are elements in the stash (either because they are placed there while inserting x, or if they have been left there from previous insertion processes). If there are any elements in the stash, and the maximum number of insertion iterations t has not been been performed, then we select randomly one of the elements in the stash and return to the second step. Otherwise, the insertion process ends. The number of iterations affects the time for an insertion process as well as the size of the stash that is needed. Generally, the more iterations, the longer an insertion can take, but the smaller a stash required. We explore this trade- off in our experiments. Elements may be left in the stash at the end of the insertion process. If the stash ever fails to have enough room for elements that have not been placed, the data structure fails. The goal is that this type of failure should be a low probability event. As with most hashing-based lookup data structures, insertion is more complex than search. Fortunately, in most networking applications, insertions are much less frequent than searches. For example, in a router, the peak rate of BGP updates is in the order of thousands per second, while the average rate is a few insertions per second [29], [30]. On the other hand, a router can perform several million packet lookups in a second. Similar or smaller update rates occur in other network applications such as MAC learning or reconfiguration of OpenFlow tables. Removing an element starts with a search and if the ele- ment is found it is removed from the table. If the element's location was given by the second hash function, the element is also removed from the CBBF by decreasing the counters associated with bits g1(x), g2(x), . . . gk(x) in position h1(x). If any counter reaches zero, the corresponding bit in the bit (Bloom filter) representation of the CBBF is cleared. The removal of elements from the CBBF may unlock elements previously locked on their second bucket if they are no longer false positives on the CBBF; however, such unlocked elements are not readily detected, and will not be moved to the bucket given by their first hash function until possibly some later operation. A potential optimization would be to periodically scrub the table looking for elements y stored in position h2(y) and moving them to position h1(y) if they are not false positives on the CBBF and there are empty cells on bucket h1(y). We do not explore this potential optimization further here. As mentioned before, a key feature in EMOMA is that the first hash function used to access the hash table is also used as the block selection function on the CBBF. Therefore, when we insert an element in the table using the second hash function, the elements that can result in a false positive in the Bloom filter as a result can be easily identified; they are in the bucket indexed by h1(x) that were inserted there using their own first hash function. To review, the main differences of EMOMA versus a standard cuckoo hash with two tables are: • Elements that are false positives in the CBBF are "locked" and can only be inserted in the cuckoo hash table using the second hash function. This reduces • the number of options to perform movements in the table. Insertions in the cuckoo hash table using the sec- ond hash function can create new false positives for the elements in bucket h1(x) that require additional movements. Those elements have to be placed in the stash and re-inserted into the second table. This means that, in contrast to standard cuckoo hashing, the stash occupancy can grow during an insertion. Therefore, the stash needs to be dimensioned to accommodate those elements in addition to the el- ements that have been unable to terminate insertion. The effect of these differences depends mainly on the false positive rate of the CBBF. That is why the insertion al- gorithm aims to minimize the number of locked elements. In the next section, we show that even when the number of bits per entry used in the CBBF is small, EMOMA can achieve memory occupancies of over 95% with 2 bucket choices per element and 4 entries per bucket. A standard cuckoo hash table can achieve memory occupancies of around 97% with 2 choices per element and 4 entries per bucket. The required stash size and number of movements needed for the in- sertions also increase compared to a standard cuckoo hash but remain reasonable. Therefore, the restrictions created by EMOMA for movements in the cuckoo hash table have only a minor effect in practical scenarios. Theoretically analyzing the effect of the CBBF on achievable load thresholds for cuckoo hash tables remains a tantalizing open problem. We formalize our discussion with this theorem. Theorem 1. When all elements have been placed successfully or lie in the stash, the EMOMA data structure completes search operations with one external memory access. Proof. As only one bucket is read on a search, we argue that if an element x is stored in the table, the search operation will always find it. If x is stored in bucket h1(x), then EMOMA will fail to find it only if the CBBF returns a positive on x. This is not possible as elements that are positive on the CBBF are always inserted into h2(x), as can be seen by examining all the cases in the case analysis. Similarly, if an element x is stored in bucket h2(x), then a search operation for x will fail only if x is not a positive on the CBBF. Again, this is not possible as elements inserted using h2(x) are added to the CBBF. These properties hold even when (other) elements are removed. When another element y is removed, it is also removed from the CBBF if it was stored on its second bucket. If x was a negative in the CBBF, it will remain so after the removal. If x was a positive in the CBBF, even if it was originally a false positive it was added into the CBBF to make it a true positive, and thus the CBBF result for x does not depend on whether other elements are stored or not on the CBBF. 4 EVALUATION OF EMOMA We have implemented the EMOMA scheme in C++ to test how its behavior depends on the various design parameters and to determine how efficiently it uses memory in practical settings. Since all search operations are completed in one memory access, the main performance metrics for EMOMA are the memory occupancy that can be achieved before the data structure fails (by overflowing the stash on an insertion) and the average insertion time of an element. The parameters that we analyzed are: 8 • The parameter P that determines the probability of selecting an element to move randomly, as described previously. • The number of bit selection hash functions k used in the CBBF. • The number of tables used in the cuckoo hash table (single-table or double-table implementations). • The number of on-chip memory bits per element (bpe) in the table, which determines the relative size of the CBBF versus the off-chip tables. • The maximum number of iterations t allowed during an insertion before stopping and leaving the ele- ments in the stash. These insertions are referred in the following as non-terminating insertions. • The size of the stash needed to avoid stash overflow. We first present simulations showing the behavior of the stash with respect to the k and P parameters for three table sizes (32K, 1M and 8M, where we conventionally use 1K for 210 elements and 1M for 220 elements.). We then present simulations to evaluate the stash occupancy when the EMOMA structure works at a high load (95%) under dynamic conditions (repeated insertion and removal of elements). We also consider the average insertion time of the EMOMA structure. Finally, we estimate how the size of the stash varies with table size and present an estimation of the failure probability due to stash overflow. In order to better understand the impact of the EMOMA scheme on the average insertion time and the stash occupancy we compared the obtained results with corresponding results using a standard cuckoo hash table. 4.1 Parameter selection Our first goal is to determine generally suitable values for the number of hash functions k in the CBBF and the proba- bility P of selecting an element to move randomly; we then fix these values for the remainder of our experiments. For this evaluation, we generously overprovision a stash size of 64 elements, although in many configurations EMOMA can function with a smaller stash. The maximum stash occupancy during each test is logged and can be used for relative comparisons. A larger stash occupancy means that those parameter settings are more likely to eventually lead to a failure due to stash overflow. We first present two experiments to illustrate the influ- ence of P and k on performance. In the first experiment, two small tables that can hold 32K elements each were used, k was set to four, and four bits per element were used for the CBBF while P varied from 0 to 1. The maximum number of iterations for each insertion t is set to 100. For each configuration, the maximum stash occupancy was logged and the simulation inserted elements until a 95% memory use was reached. The simulation was repeated 1000 times. Figure 6 shows the average across all the runs of the maximum stash occupancy observed. The value of P that provides the best result is close to 1, but too large 9 Figure 8. In all cases, the maximum stash size observed is fairly small. The maximum values for the single-table option were 9, 14, and 16 for table sizes 32K, 1M, and 8M respectively. For the double-table option, these maxima were 9, 18, and 33. These results suggest that the single-table option is better, especially for large table sizes. We also looked at the percentage of elements stored using h1(x) and h2(x). In the single-table implementation, the percentages were 59% and 41% respectively, while in the double-table implementation, the percentages were 52% and 48%. These results show how the use of a single table enables placing more elements using the first hash function, thereby reducing the false positive rate in the CBBF and thus the number of elements locked. This confirms our previous intuition. In fact, the use of a single-table has another subtle benefit: when inserting an element x using h2(x), of the elements in bucket h1(x), only those inserted there with h1 can cause a false positive. With two tables, all the elements in the first table in bucket h1(x) can cause a false positive. Therefore on average the single-table implementation has fewer candidates to create false positives than the double- table implementation for each insertion using h2. These factors tend to make the single-table option better, as will be further seen in our remaining simulation results. We therefore expect that the single-table variant will be used in practical implementations. 4.2 Dynamic behavior at maximum load We conducted additional experiments for tables of size 8M to test performance with the insertion and removal of elements. We first load the hash table to 95% memory occupancy, and then perform 16M replacement operations. The replacement first randomly selects an element in the EMOMA structure and removes it. Then it randomly cre- ates a new entry (not already or previously present in the EMOMA) and inserts it. This is a standard test for structures that handle insertions and deletions. The experiments were repeated 10 times, for both the single-table and double-table implementations. These experiments allow us to investigate the stability of the size of the stash in dynamic settings, near the maximum load. Ideally, the stash size would remain almost constant in such dynamic settings. In Figure 9 we report the maximum stash occupancy observed. Each data point gives the maximum stash occupancy observed over the 10 trials over the last 1M trials; that is, when the x-axis is 6, the data point is the maximum stash occupancy over replacements 5M to 6M over the 10 trials. The experiments show that both implementations reli- ably maintain a stable stash size under repeated insertions and removals. The maximum stash occupancy observed over the 10 trials for the standard cuckoo table is in the range 1-4, for the single table EMOMA is always in the range 7-10, and for the double-table EMOMA setting it is in the range 23-29. This again shows that the single-table implementation provides better performance than the double-table, with a limited penalty in terms of stash size with respect to the standard cuckoo table. Fig. 6. Average of the maximum stash occupancy over 1000 runs for different values of P at 95% memory occupancy, single-table, k = 4, bpe=4 and t = 100. Fig. 7. Average of the maximum stash occupancy over 1000 runs for different values of k at 95% memory occupancy, single-table, P =0.99, bpe=4 and t=100. a value of P yields a larger stash occupancy. This confirms the discussion in the previous section; in most cases it is beneficial to move elements that create the least number of false positives but a purely greedy strategy can lead to unfortunate behaviors. From these results it appears that a value of P in the range 0.95 to 0.99 provides the best results. In the second experiment, we set P = 0.99 and we varied k from 1 to 8. The results for the single-table configu- ration are shown in Figure 7. In this case, the best values were k = 3, 4 when the double-table implementation is used and k = 3 when a single table is used. However, the variation as k increases up to 8 is small. (Using k = 1 provided poor performance.) Based on the results of these two smaller experiments, the values P = 0.99 and k = 3 for the single-table variant and k = 4 for the double-table variant are used for the rest of the simulations. Given these choices of P and k, we aim to show that EMOMA can reliably achieve 95% occupancy in the cuckoo hash table using four on-chip memory bits per element for the CBBF. We test this for cuckoo hash tables of sizes 32K, 1M, and 8M elements, with both single-table and double- table implementations. In particular, we track the maximum occupancy of the stash during the insertion procedure in which the table is filled up to 95% of table size. The distri- bution of the stash occupancies over 1000 runs are shown in 10 15 20 25 30 35 40 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1Stash occupancyP 0 10 20 30 40 50 60 70 1 2 3 4 5 6 7 8Stash occupancyk 10 Fig. 8. Probability distribution function for the maximum stash occupancy observed during the simulation at 95% memory occupancy for t = 100 and a total size of 32K, 1M, and 8M elements. so elements remain in the stash, provoking an uncontrolled growth in the stash. With greater values of t, the system is able to insert the elements into the table in fewer than t steps on average, with the average number of iterations per new element converging to around 44. In other words, in our tests when t is at least 50, there will be some intervals where the stash empties, so the algorithm stops before reaching the maximum number of allowed iterations. The single- table configuration can therefore work reliably when t is set to values of at least 50. It is interesting to note that the results obtained for the single-table EMOMA configuration are qualitatively similar to those obtained for a standard cuckoo hash. In fact, for a standard cuckoo hash table the stash grows uncontrollably when t = 10, but is stable when t is at least 50. The average number of iterations per new element that is around 27 for the standard cuckoo hash table, so again we see the EMOMA implementation suffers a small penalty for the gain of knowing which of the two buckets an element lies in. Finally, it is interesting to note that the average number of iterations per new element also gives us an idea of the ratio of searches vs. insertions for which EMOMA is practical. For example, if the ratio is 1000 searches per insertion, then EMOMA requires only 4.4% of the memory bandwidth for insertions. For the double-table configuration, we instead see that the average insertion time remains almost equal to the maximum number of allowed iterations. This means that the stash almost never empties, with some elements in the stash that the structure is either unable to place in the main table, or that stay in the stash for a large number of iterations. To avoid wasting memory accesses trying to place those elements, we could mark those elements and avoid attempts at moving them into the main table until a suitable number of replacements has been done. However, because we assume that the single-table implementation will be preferred due to its better performance, we do not explore this possibility further. To better understand the relationship between the max- imum number of allowed iterations and the stash behavior, in Figure 11 we report the maximum stash occupancy ob- served over 100 trials at maximum load, for t = 50, 100, 500, and 1000, and for a table size of 8M elements. The graph reports the average insertion time for the single-table and double-table EMOMA configurations and for a standard cuckoo table. As expected, higher values of t allow a smaller stash. The graph also shows that, with the same value of t, the single-table configuration requires fewer elements in the stash than the double-table configuration. The comparison Fig. 9. Maximum stash occupancy observed during insertion/removal for the standard cuckoo table, the single-table EMOMA and the double- table EMOMA implementations of total size of 8M elements with t = 100. 4.3 Insertion time The average number of iterations per insertion, which we also refer to as the average insertion time, can determine the frequency with which the EMOMA structure can be updated in practice, as the memory bandwidth needed to perform insertions is not available for query operations. The average insertion time depends both on t, the maximum number of iterations allowed for a single insertion, and on the load of the EMOMA structure. Larger t allows for smaller stash sizes, as fewer elements are placed in the stash because they have run out of time when being inserted, but the corresponding drawback is an increase in the average insertion time. In Figure 10 we report the average number of itera- tions per insertion at different loads for t = 10, 50, 100, and 500 in tables of size 8M. The table is filled to the target load, and then 1M fresh elements are inserted by the same insertion/removal process described previously. We measure the average number of iterations per insertion for the freshly inserted elements. The plots report the average insertion time for the single-table and double-table EMOMA configurations and for a standard cuckoo table. As expected, the average insertion time increases sub- stantially when the load increases to a point where the table is almost full. However, the behavior of the single-table and double-table configurations is significantly different (note the difference in the scale of the y-axes). For the single-table at maximum load (95%) the average insertion time is almost equal to the maximum number of allowed iterations when t = 10. This corresponds to a condition in which EMOMA is unable to complete insertions of new elements in t steps, 0 5 10 15 20 25 30 35 40 45 50 1 2 3 4 5 6 7 8 9ProbabilityNumber of elements in the stashStash occupancy for a total table size of 32K elementssingle tabledouble table 0 5 10 15 20 25 30 35 40 45 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19ProbabilityNumber of elements in the stashStash occupancy for a total table size of 1M elementssingle tabledouble table 0 5 10 15 20 25 30 35 40 0 5 10 15 20 25 30 35ProbabilityNumber of elements in the stashStash occupancy for a total table size of 8M elementssingle tabledouble table 0 5 10 15 20 25 30 35 40 451M3M5M7M9M11M13M15MNumber of elements in the stashNumber of replacementsDynamic behavior of stash occupancy for a total table size of 8M elementssingle tabledouble tablestandard cuckoo 11 Fig. 10. Average insertion time with respect to number of inserted elements (load) with different t values. Fig. 11. Maximum observed stash occupancy with respect to maximum number of allowed iterations t. Fig. 12. Average and maximum over 10,000 trials of the maximum number of elements in the stash with respect to table size for the single- table configuration with the standard cuckoo table shows that the standard cuckoo table does not actually need a stash if the number of allowed iterations is sufficiently large (the maximum value of 1 is due to the pending item that is moved during the insertion process), while the stash remains necessary for the EMOMA structures. This is consistent with known results about cuckoo hashing [24]. Summarizing, these experiments show that the single- table configuration provides better performance, but both configurations can work reliably even at the maximum target load of 95%. 4.4 Stash occupancy vs. table size The previous results suggest that a fairly small stash size is sufficient to enable a reliable operation of EMOMA when the single-table configuration is used. It is important to quantify how the maximum stash occupancy changes with respect to the table size in order to provision the stash to avoid overflow. We performed simulations to estimate the behavior of the failure probability with respect the table size and tried to extract some empirical rules. Obtaining more precise, provable numerical bounds remains an interesting theoretical open question. Since we have already shown that the stash occupancy of the single-table configuration is sig- nificantly lower than that of the double-table configuration, we restricted the analysis only to the single-table case. We performed 10,000 experiments where we fill the EMOMA table up to 95% load and logged the maximum number of elements stored in the stash during the insertion phase. The simulation has been performed for table sizes 32K, 64K, 128K, 256K, 512K, 1M, 2M, 4M, and 8M. Fig. 12 presents the average maximum number of ele- ments in the stash with respect to table size at the end of the insertion phase and the overall maximum stash occupancy observed over the 10,000 trials. As a rule of thumb, we can estimate that the average number of elements in the stash increases by 0.5 when the table size doubles. A similar trend occurs also for the maximum stash occupancy observed over the 10,000 trials although in this case the variability is larger than for the average. Fig. 13 shows in linear and logarithmic scale the prob- ability distribution function for the maximum stash occu- pancy for different table sizes over the 10,000 trials. As can be seen, after reaching a maximum value, the probability distribution function decreases exponentially with a slope that is slightly dependent on the table size. A conservative estimate based on the empirical results is that beyond the average value for the maximum stash size, the probability of reaching a certain stash size falls by a factor of 10 as the stash size increases by 3 elements. As an example of how to use this rule of thumb, we see that the empirically observed probability of having 17 or more elements in the stash for a table of size 8M at 95% load is less than 10−3. If a stash of size 16 fails with probability at most 10−3, by our rule of thumb we estimate a stash of size 31 would fail with probability at most 10−8, and a stash of size 64 would fail with probability at most 10−19. While these are just estimates, they suggest that a stash that holds 64 elements will be sufficient for most practical scenarios. 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95Average insertion timeload (%)Average insertion time vs load single-table implementationt=10t=50t=100t=500 0 50 100 150 200 250 300 350 400 450 500 50 55 60 65 70 75 80 85 90 95Average insertion timeload (%)Average insertion time vs load double-table implementationt=10t=50t=100t=500 0 5 10 15 20 25 30 50 55 60 65 70 75 80 85 90 95Average insertion timeload (%)Average insertion time vs load Standard cuckoo hasht=10t=50t=100t=500 0 5 10 15 20 25 30 35 40 45 0 100 200 300 400 500 600 700 800 900 1000numbers of elements in the stashmaximum number of allowed iterationsStash occupancy vs max. number of iterationssingle tabledouble tablestandard cuckoo 0 5 10 15 20 2532K64K128K256K512K1M2M4M8Mnumbers of elements in the stashtable sizeAverage/maximum stash occupancy vs table sizemaximumaverage 12 Fig. 13. Probability distribution function for the maximum stash occupancy observed during the simulation at 95% memory occupancy for different table size 5 COMPARISON WITH ALTERNATIVE APPROACHES Most of the existing hash based techniques to implement exact match have a worst case of more than one external memory access to complete a lookup. Such a worst case would hold for example for a hash table with separate chaining or a standard cuckoo hash table. The number of external memory accesses can be re- duced by using an on-chip approximate membership data structure that selects the external positions that need to be accessed. In many cases this does not result in a worst case of one memory access per lookup due to false positives. For example if a Bloom filter is used to determine if a given position needs to be checked, a false positive will cause an access to that position, even if the element is stored in another position. Other approaches to this problem have been proposed, namely the Fast Hash Table (FHT) [19] and the Bloomier filter [31], [32]. In the Fast Hash Table with extended Bloom filter [19], k hash functions are used to map elements to k possible positions in an external memory. The same hash functions are used in an on-chip counting Bloom filter. Elements are then stored in the position (out of the k) that has the smallest count value in the counting Bloom filter. If there are more than one position with the same count value, the position with the smallest index is selected. Then on a search, the counting Bloom filter is checked and only that position is accessed. In most cases this method requires a single external memory access, even under the assumption that a bucket holds only one element. (We assume an external memory access corresponds to a bucket of four elements in our work above.) However, when two (or more) elements are stored on the same position (because it has the minimum count value for both), more than one access may be required. The probability of this occurring can be reduced by artifi- cially increasing the counter in those cases so that elements are forced to map to other positions. In [19], the counting Bloom filter was dimensioned to have a size m that is 12.8 times the number of elements n to be stored. As three bits were used for the counters this means that approximately 38 bits of on-chip memory are needed per element. This is almost an order of magnitude more than the on-chip mem- ory required for EMOMA. This difference arises because the counters have to be stored on-chip and the load n/m of the counting Bloom filter has to be well below one for the scheme to work. While this memory could be reduced for larger bucket sizes, the on-chip memory use is still signifi- cantly larger than ours in natural configurations. Similarly, the off-chip memory is significantly larger; most buckets in the FHT schemes are necessarily empty. Finally, insertions and deletions are significantly more complex. Overall, the FHT approach takes more space and, being more complex, is much less amenable to a hardware implementation. Another alternative would be to use the approach we use in this paper, but use a Bloomier filter [31], [32] in place of a counting block Bloom filter to determine the position in external memory that needs to be accessed. A Bloomier filter is a data structure designed to provide values for elements in a set; it can be seen as an extension of a Bloom filter that provides not just membership information, but a return value. In particular, the output for a Bloomier filter could be from {0, 1}, denoting which hash function to use for an element. If a query is made for an element not in the set, an arbitrary value can be returned; this feature of a Bloomier filter is similar to the false positive of a Bloom filter. Moreover, a mutable Bloomier filter can be modified, so if an element's position in the cuckoo table changes (that is the hash function used for that element changes), the Bloomier filter can be updated in constant average time and logarithmic (in n) time with high probability. As a Bloomier filter provides the exact response for elements in the set, only one external memory access is needed; for elements not present in the set, at most one memory access is also required, and the element will not be found. Advantages of the Bloomier filter are that it allows the full flexibility of the choices in the cuckoo hash table, so slightly higher hash table loads can be achieved. It can potentially also use less on-chip memory per element (at the risk of increasing the probability needed for reconstruction, discussed below). However, the Bloomier filter comes with significant drawbacks. First, a significant amount (Ω(n log n) under known constructions) of additional off-chip memory would be required to allow a Bloomier filter to be mutable. Bloomier filters have non-trivial failure probabilities; even offline, their failure probability is constant when using space linear in n. Hence, particularly under insertion and deletion of elements, there is a small but non-trivial chance 0 2 4 6 8 10 12 14 1632K64K128K256K512K1M2M4M8M 0 0.1 0.2 0.3 0.4 0.5 0.6ProbabilityStash occupancy with different table sizeNumber of elements in the stashTable sizeProbability 0.0001 0.001 0.01 0.1 1 0 2 4 6 8 10 12 14 16ProbabilityNumber of elements in the stashStash occupancy with different table size32K64K128K256K512K1M2M4M8M the Bloomier filter will have to be reconstructed with new hash functions. Such reconstructions pose a problem for network devices that require high availability. Finally, the construction and update procedures of Bloomier filters are more complex and difficult to implement in hardware than our construction. In particular, they require solving sets of linear equations (that can be solved by back substitution) to determine what values to store so that the proper value is returned on an element query, compared to the more simple operations of our proposed counting block Bloom filter. Because of these significant issues, we have not imple- mented head-to-head comparisons between EMOMA and these alternatives. While all of these solutions represent potentially useful data structures for some problem settings, for solutions requiring hardware-amenable designs using a single off-chip memory access, EMOMA appears signif- icantly better than these alternatives. 6 HARDWARE FEASIBILITY We have evaluated the feasibility of a hardware implemen- tation of EMOMA using the NetFPGA SUME board [9] as the target platform. The SUME NetFPGA is a well-known solution for rapid prototyping of 10Gb/s and 40Gb/s ap- plications. It is based upon a Xilinx Virtex-7 690T FPGA device and has four 10Gb/s Ethernet interfaces, three 36-bit QDRII+ SRAM memory devices running at 500MHz, and a DRAM memory composed of two 64-bit DDR3 memory modules running at 933MHz. We leverage the reference design available for the SUME NetFPGA to implement our scheme. In particular, the reference design contains a MicroBlaze (the Xilinx 32-bit soft-core RISC microprocessor) that is used to control the blocks implemented in the FPGA the using the AXI-Lite [33] bus. The microprocessor can be used to perform the insertion procedures of the EMOMA scheme, writing the necessary values in the CBBF, in the stash, and in the external memories. Our goal here is to determine the hardware resources that would be used by an EMOMA scheme. We select a key of 64 bits and an associated value of 64 bits. Therefore, each bucket of four cells has 512 bits. A bucket can be read in one memory access as a DRAM burst access provides precisely 512 bits. The main table has 524288 (512K) buckets of 512 bits requiring in total 256Mb of memory. The stash is realized implementing on the FPGA a 64x64 bits Content Addressable Memory with the write port connected to the AXI bus and the read port used to perform the query oper- ations. For the CBBF we used k = 4 hash functions and a memory size of 524288 (512K) words of 16 bits. The memory of the CBBF uses two ports: the write port is connected to the AXI bus and the read port is used for the query operations. The results are reported in Table 2. The table reports for each hardware block the number of LUTs (Look-Up Tables), the number of Flip-Flops, and the number of BRAMs (Block RAMs) used. We also show in parenthesis the percentage of resources used with respect to those available in the FPGA hosted in the NetFPGA board. For completeness, we report also the overhead of the MicroBlaze, even if it is not related only to the EMOMA scheme, as it is needed for almost any application built on top of the NetFPGA. It can be observed that EMOMA needs only a small fraction of the TABLE 2 Hardware cost of EMOMA components 13 EMOMA component Stash CBBF MicroBlaze #LUTs 3337 (1.12%) 61 (< 0.01%) 882 (0.27%) Flip-Flops 102 (< 0.01%) 1 (< 0.01%) 771 (0.09%) #BRAM 1 (< 0.01%) 256 (17.41%) 32 (2.18%) FPGA resources. As expected, the most demanding block is the memory for the CBBF, which in this case requires 256 (17%) of the 1470 available Block RAMs. Finally, the insertion procedure has been compiled for the MicroBlaze architecture and the code footprint is around 30KB of code. This is a fairly small amount of memory, since the instruction memory size of the MicroBlaze can be configured to be larger than 256KB. As a summary, this initial evaluation shows that EMOMA can be implemented on an FPGA based system with limited cost. 7 CONCLUSIONS AND FUTURE WORK We have presented Exact Match in One Memory Access (EMOMA), a scheme that implements exact match with only one access to external memory, targeted towards hardware implementations of high availability network processing devices such as switches or routers. EMOMA uses a count- ing block Bloom filter to select the position that needs to be accessed in an external memory cuckoo hash table to find an element. By sharing one hash function between the cuckoo hash table and the counting block Bloom filter, we enable fast identification of the elements that can create false positives, allowing those elements to be moved in the hash table to avoid the false positives. This requires a few additional memory accesses for some insertion opera- tions and a slightly more complex insertion procedure. Our evaluation shows that EMOMA can achieve around 95% utilization of the external memory when using only slightly more than 4 bits of on-chip memory for each element stored in the table. This compares quite favorably with previous schemes such as Fast Hash Table [19], and is also simpler for implementation. A theoretical analysis of EMOMA remains open, and might provide additional insights on optimization of EMOMA. Another idea to explore would be to generalize EMOMA so that instead of the same hash function being used for the counting block Bloom filter and the first po- sition in the cuckoo hash table, only the higher order bits of that function were used for the CBBF. This would mean several buckets in the cuckoo hash table would map to the same block in the CBBF, providing additional trade-offs. In particular, this would lead to EMOMA configurations using fewer bits of on-chip memory per element, but would lead to more complex insertion operations. 8 ACKNOWLEDGMENTS Salvatore Pontarelli is partially supported by the European Commission in the frame of the BEBA project http://www.beba-project.eu/. Pedro Reviriego would like to acknowledge the support of the excellence network Elas- tic Networks TEC2015-71932-REDT funded by the Spanish 14 [21] M. Dietzfelbinger, A. Goerdt, M. Mitzenmacher, A. Montanari, R. Pagh, and M. Rink, "Tight thresholds for cuckoo hashing via XORSAT," in Proc. of ICALP, pp. 213-225, 2010. [22] J. Cain, P. Sanders, and N. Wormald, "The random graph threshold for k-orientiability and a fast algorithm for optimal multiple- choice allocation," in Proc. of the Eighteenth Annual ACM-SIAM Symposium on Discrete Algorithms, pp. 469-476, 2007. [23] D. Fernholz and V. Ramachandran, "The k-orientability thresholds for Gn,p," in Proc. of the Eighteenth Annual ACM-SIAM Sympo- sium on Discrete Algorithms, pp. 459-468, 2007. [24] A. Kirsch, M. Mitzenmacher, and U Wieder, "More robust hashing: Cuckoo hashing with a stash," SIAM Journal on Computing, vol. 39, no. 4, pp. 1543-1561, 2009. [25] A. Kirsch, and M. Mitzenmacher, "Using a queue to de-amortize cuckoo hashing in hardware," in Proc. of the Forty-Fifth Annual Allerton Conference on Communication, Control, and Computing, 2007. [26] B. Bloom, "Space/time tradeoffs in hash coding with allowable errors," Communications of the ACM, vol. 13, no. 7, pp. 422-426, 1970. [27] A. Broder and M. Mitzenmacher, "Network applications of Bloom filters: A survey," Internet Math., vol. 1, no. 4, pp. 485-509, 2003. [28] U. Manber and S. Wu, "An algorithm for approximate member- ship checking with application to password security," Information Processing Letters, vol. 50, no. 4, pp. 191-197, 1994. [29] G. Huston, and A. Grenville "Projecting future IPv4 router re- quirements from trends in dynamic BGP behaviour,", in Proc. of the Australian Telecommunication Networks and Applications Conference (ATNAC), 2006. [30] A. Elmokashfi, A. Kvalbein and C.Dovrolis, "On the scalability of BGP: the roles of topology growth and update rate-limiting," in Proc. of the ACM CoNEXT Conference, 2008. [31] B. Chazelle, J. Kilian, R. Rubinfeld, and A. Tal, "The Bloomier filter: an efficient data structure for static support lookup tables," in Proc. Fifteenth Annual ACM-SIAM Symposium on Discrete Algorithms, pp. 30-39, 2004. [32] D. Charles and K. Chellapilla, "Bloomier filters: A second look," in Proc. 16th Annual European Symposium on Algorithms, pp. 259-270, 2008. [33] AXI Reference Guide - Xilinx https://www.xilinx.com/support/documentation/ ip documentation/ug761 axi reference guide.pdf Ministry of Economy and Competitivity. Michael Mitzen- macher was supported in part by NSF grants CNS-1228598, CCF-1320231, CCF-1535795, and CCF-1563710. REFERENCES [1] P. Gupta and N. McKeown, "Algorithms for packet classification," IEEE Network, vol. 15 no. 2, pp. 24-32, 2001. [2] K. Pagiamtzis and A. Sheikholeslami, "Content-addressable mem- ory (CAM) circuits and architectures: a tutorial and survey," IEEE Journal of Solid-State Circuits, vol. 41, no. 2, pp. 712-727, 2006. [3] F. Yu, R.H. Katz and T.V. Lakshman, "Efficient multimatch packet classification and lookup with TCAM," IEEE Micro, vol. 25, no. 1, pp. 50-59, 2005. [4] A. Kirsch, M. Mitzenmacher and G. Varghese, "Hash-based tech- niques for high-speed packet processing," Algorithms for Next Generation Networks, pp. 181-218, Springer London, 2010. [5] R. Pagh and F. F. Rodler, "Cuckoo hashing," Journal of Algorithms, pp. 122-144, 2004. [6] M. Waldvogel, et al. "Scalable high speed IP routing lookups," in Proc. of the Conference on Applications, Technologies, Architec- tures, and Protocols for Computer Communications (SIGCOMM), pp. 25-36, 1997. [7] W. Jiang, Q. Wang, and V. Prasanna "Beyond TCAMs: An SRAM based Parallel Multi-Pipeline Architecture for Terabit IP Lookup," in Proc of the 27th Conference on Computer Communications (INFOCOM), pp. 1786-194, 2008. [8] P. Bosshart, G. Gibb, H. S, Kim, G. Varghese, N. McKeown, M. Izzard, F. Mujica, and M. Horowitz, "Forwarding metamorpho- sis: fast programmable match-action processing in hardware for SDN," in Proc. of the Conference on Applications, Technologies, Architectures, and Protocols for Computer Communications (SIG- COMM), pp. 99-110, 2013. [9] N. Zilberman, Y. Audzevich, G. Covington and A. Moore, "NetF- PGA SUME: Toward 100 Gbps as research commodity," IEEE Micro, vol. 34, pp. 32-41, 2014. [10] Y. Kanizo, D. Hay and I. Keslassy, "Maximizing the Throughput of Hash Tables in Network Devices with Combined SRAM/DRAM Memory," IEEE Transactions on Parallel and Distributed Systems, vol. 26, no. 3, pp. 796-809, 2015. [11] N. Binkert, A. Davis, N.P. Jouppi, M. McLaren, N. Muralimanohar, R. Schreiber, and J.H. Ahn "The role of optics in future high radix switch design,' in Proc. of 38th IEEE International Symposium on Computer Architecture (ISCA), pp. 437-447, 2011. [12] S. Dharmapurikar, P. Krishnamurthy, and D. E. Taylor, "Longest prefix matching using Bloom filters," IEEE/ACM Transactions on Networking, vol. 14, no. 4, pp 397-409, 2006. [13] G. Pongr´acz, L Moln´ar and ZL Kis, Z Tur´anyi "Cheap silicon: a myth or reality? picking the right data plane hardware for soft- ware defined networking," in Proc. of the 2nd ACM SIGCOMM Workshop on Hot Topics in Software Defined Networking, pp. 103-108, 2013. [14] B. Sinharoy, et al. "IBM POWER8 processor core microarchitec- ture", IBM Journal of Research and Development, vol. 59, no. 1, pp. 2,1-21, 2015. 2Gb SDRAM data [15] Samsung available online: http://www.samsung.com/global/business/semiconductor/ file/2011/product/2011/8/29/729200ds k4b2gxx46d rev113.pdf [16] S. Iyer and N. McKeown. "Analysis of the parallel packet switch architecture," IEEE/ACM Transactions on Networking, vol, 11, no. 2, pp. 314-324, April 2003. sheet, [17] Micron RLDRAM 3 online: https://www.micron.com/ /media/documents/ products/data- sheet/dram/576mb rldram3.pdf available sheet, data [18] Cypress QDR-IV SRAM data available http://www.cypress.com/documentation/datasheets/ cy7c4022kv13cy7c4042kv13-72-mbit-qdr-iv-xp-sram sheet, online: [19] H. Song, S. Dharmapurikar, J. Turner and J. Lockwood, "Fast hash table lookup using extended Bloom filter: an aid to network processing," ACM SIGCOMM Computer Communication Review, vol. 35, no. 4, pp. 181-192, 2005. [20] S. Pontarelli, P. Reviriego and J.A. Maestro, "Parallel d-Pipeline: a Cuckoo Hashing Implementation for Increased Throughput," IEEE Transactions on Computers, vol. 65, no 1, pp. 326-331, Jan. 2016.
1509.01630
1
1509
2015-09-04T23:03:47
Optimization and Reoptimization in Scheduling Problems
[ "cs.DS" ]
Parallel machine scheduling has been extensively studied in the past decades, with applications ranging from production planning to job processing in large computing clusters. In this work we study some of these fundamental optimization problems, as well as their parameterized and reoptimization variants. We first present improved bounds for job scheduling on unrelated parallel machines, with the objective of minimizing the latest completion time (makespan) of the schedule. We consider the subclass of fully-feasible instances, in which the processing time of each job, on any machine, does not exceed the minimum makespan. The problem is known to be hard to approximate within factor 4/3 already in this subclass. Although fully-feasible instances are hard to identify, we give a polynomial time algorithm that yields for such instances a schedule whose makespan is better than twice the optimal, the best known ratio for general instances. Moreover, we show that our result is robust under small violations of feasibility constraints. We further study the power of parameterization. We show that makespan minimization on unrelated machines admits a parameterized approximation scheme, where the parameter used is the number of processing times that are large relative to the latest completion time of the schedule. We also present an FPT algorithm for the graph-balancing problem, which corresponds to the instances of the restricted assignment problem where each job can be processed on at most 2 machines. Finally, motivated by practical scenarios, we initiate the study of reoptimization in job scheduling on identical and uniform machines, with the objective of minimizing the makespan. We develop reapproximation algorithms that yield in both models the best possible approximation ratio of $(1+\epsilon)$, for any $\epsilon >0$, with respect to the minimum makespan.
cs.DS
cs
Optimization and Reoptimization in Scheduling Problems 5 1 0 2 p e S 4 ] S D . s c [ 1 v 0 3 6 1 0 . 9 0 5 1 : v i X r a Yael Mordechai Optimization and Reoptimization in Scheduling Problems Research Thesis Submitted in Partial Fulfillment of the Requirements for the Degree of Master of Science in Computer Science Yael Mordechai Submitted to the Senate of the Technion - Israel Institute of Technology Tamuz 5775 Haifa June 2015 This research was carried out under the supervision of Prof. Hadas Shachnai, in the Computer Science Department. The generous financial help of the Technion is gratefully acknowledged. Contents Abstract 1 Introduction Scheduling Models 1.1 Scheduling on Parallel Machines . . . . . . . . . . . . . . . . . . . . . . . 1.1.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2 Related Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 Fixed Parameter Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2.1 Parametrized Scheduling Problems . . . . . . . . . . . . . . . . . . 1.2.2 Related Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3 Combinatorial Reoptimization . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.1 Reoptimization in Scheduling . . . . . . . . . . . . . . . . . . . . . 1.3.2 Related Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.4 Main Results 2 Makespan Minimization for Fully-Feasible Instances 2.1 Preliminaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2 Approximation Algorithm for Fully-Feasible Instances . . . . . . . . . . . . 2.2.1 Approximation Algorithm . . . . . . . . . . . . . . . . . . . . . . . 2.3 A Better Bound for the Restricted Assignment Problem . . . . . . . . . . . 2.3.1 Approximation Algorithm . . . . . . . . . . . . . . . . . . . . . . . 3 Fixed-Parameter Algorithms for Scheduling on Unrelated Machines 3.1 Preliminaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 Parametrized Approximation Scheme for Scheduling on Unrelated Machines 3.3 An FPT Algorithm for Graph-Balancing . . . . . . . . . . . . . . . . . . . 4 Reoptimization Algorithms for Scheduling Problems 4.1 Preliminaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2 A (1, 1+ǫ)-Reapproximation Algorithm for Makespan Minimization on Iden- tical Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2.1 Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.2.2 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3 A (1, 1 + ǫ)-Reapproximation Algorithm for Makespan Minimization on Uni- form Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 2 2 3 5 6 6 7 7 7 8 10 10 11 12 18 19 22 22 23 24 28 28 29 29 30 35 4.3.1 Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3.2 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Conclusions and Future Work 5.1 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 37 40 40 40 List of Figures 2.1 Example of the construction in the rounding . . . . . . . . . . . . . . . . . . . 2.2 The bipartite graph Gσ. By changing the orientation of the path i3 → j5 → i5, . . . . . . . . . . . . we remove job j5 from i5 and schedule it on machine i3. 12 19 List of Tables 1.1 Known results for makespan minimization on unrelated machines. 1.2 Known FPT algorithms for scheduling. 1.3 Our contribution for reoptimization in scheduling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 7 9 Abstract Parallel machine scheduling has been extensively studied in the past decades, with appli- cations ranging from production planning to job processing in large computing clusters. In this work we study some of these fundamental optimization problems, as well as their parameterized and reoptimization variants. We first present improved bounds for job scheduling on unrelated parallel machines, with the objective of minimizing the latest completion time (or, makespan) of the schedule. We consider the subclass of fully-feasible instances, in which the processing time of each job, on any machine, does not exceed the minimum makespan. The problem is known to be hard to approximate within factor 4/3 already in this subclass. Although fully-feasible instances are hard to identify, we give a polynomial time algorithm that yields for such instances a schedule whose makespan is better than twice the optimal, the best known ratio for general instances. Moreover, we show that our result is robust under small violations of feasibility constraints. We further study the power of parameterization. In a parameterized optimization prob- lem, each input comes with a fixed parameter. Some problems can be solved by algorithms (or approximation algorithms) that are exponential only in the size of the parameter, while polynomial in the input size. The problem is then called fixed parameter tractable (FPT), since it can be solved efficiently (by an FPT algorithm or approximation algorithm) for constant parameter values. We show that makespan minimization on unrelated machines admits a parameterized approximation scheme, where the parameter used is the number of processing times that are large relative to the latest completion time of the schedule. We also present an FPT algorithm for the graph-balancing problem, which corresponds to the instances of the restricted assignment problem where each job can be processed on at most 2 machines. Finally, motivated by practical scenarios, we initiate the study of reoptimization in job scheduling on identical and uniform machines, with the objective of minimizing the makespan. We develop reapproximation algorithms that yield in both models the best pos- sible approximation ratio of (1 + ǫ), for any ǫ > 0, with respect to the minimum makespan. 1 Chapter 1 Introduction 1.1 Scheduling on Parallel Machines Consider the following fundamental problem in scheduling theory. We are given a set J of n independent jobs that must be scheduled without preemption on a collection M of m parallel machines. If job j is scheduled on machine i, the processing time required is pij, which is a positive integer, for every i ∈ M and j ∈ J . The total time used by machine i ∈ M, or the load on machine i, is the sum of the processing times for the jobs assigned to i, and the makespan of an assignment is the maximum load over all the machines. The objective is then to find a schedule, which assigns each job to exactly one machine, such that the makespan is minimized. 1.1.1 Scheduling Models The wide literature on scheduling often distinguishes between the following scheduling models. Identical Machines. Job processing times are identical across the machines, i.e., pij = pj for all j ∈ J and i ∈ M. Uniform Machines. Each machine i has a speed si. The length of job j on machine i is some uniform processing time pj scaled by the speed si, i.e., pij = pj for all j ∈ J and si i ∈ M. Unrelated Machines: Each job j may have an arbitrary processing time pij ≥ 0 on machine i, for j ∈ J and i ∈ M. While makespan minimization is known to be NP-hard in all models (even for m = 2) [LK79], the first two models are considered somewhat easier, since the problem can be ap- proximated efficiently in both up to some ǫ factor, for any ǫ > 0 (see Section 1.1.2). In con- trast, in the unrelated machines model, the problem becomes hard to approximate within 2 a factor better than 3 2. Moreover, since 1990, when the state of the art 2-approximation algorithm was presented by Lenstra, Shmoys and Tardos [LST90], there was no significant improvement on either the upper or lower bound, although the problem was consistently investigated. This led researchers to consider special cases and improving the bound of 2, either by a constant factor, or by some function of the input parameters (see review in Section 1.1.2). In this work, we consider the subclass of fully-feasible instances. We say that an instance is fully-feasible if job processing times, pij, do not exceed the length of the optimal schedule for the instance, for every job j ∈ J and machines i ∈ M. Observe that an optimal schedule never assigns a job to machine on which its length is greater than the makespan of an optimal schedule; thus, from an optimal scheduler's viewpoint, if pij exceeds the optimal makespan then pij is considered to be ∞. We also consider instances that are almost fully-feasible, that is, for any job j, the number of machines on which job j is not feasible (i.e., has processing time larger than the length of the optimal makespan) is relatively small. When considering real-life applications, the general model of unrelated machines, which makes no assumptions on job processing times, seems too broad. Indeed, such applications usually deal with fully-feasible (or almost fully-feasible) workloads, as they commonly han- dle relatively large sets of jobs. Let Topt and Lopt denote the optimal makespan and the minimal average machine load over optimal assignments, respectively. For heterogeneous workloads of a huge number of jobs, in which the makespan is counted in months or even years, the processing time of a given job is negligible compared to the makespan; for such workloads, we have pij ≪ Topt. In this case, an algorithm of [ST93], yields a schedule of makespan at most Topt + pmax, where pmax = maxijpij, is more suitable. However, for smaller sets of jobs, pij can be large relative to Topt, such that Lopt < pmax, and for these instances our algorithm is the state of the art. Relevant applications for such workloads are e.g., job packing in warehouse-scale [VKW14], large-scale clustering [VP+15] and applications in parallel design patterns such as Fork-Join and MapReduce (see, e.g., [DMN12, LL+12]). 1.1.2 Related Work Identical and Uniform Machines The problem of makespan minimization on identical or uniform machines is known to be NP-hard [GJ79]. A polynomial-time approximation scheme (PTAS) is a family of algorithms {Aǫ : ǫ > 0}, where Aǫ is a (1 + ǫ)-approximation algorithm that runs in time polynomial in the input size but is allowed to be exponen- tial in 1 ǫ . An efficient polynomial-time approximation scheme (EPTAS) is a PTAS with running time f ( 1 ǫ )poly(I), where I is the input size, (for some function f ), while a fully polynomial-time approximation scheme (FPTAS) runs in time poly( 1 ǫ ,I). Since the scheduling problem is NP-hard in the strong sense already on identical machines (as it con- tains bin packing and 3-Partition as special cases) [GJ79], we cannot hope for an FPTAS. [AA+98] gave an EPTAS with For identical machines, Hochbaum [H96] and Alon et al. running time f ( 1 ǫ , and for uniform machines, ǫ ) + O(n), where f is doubly exponential in 1 3 Jansen [J10] gave an EPTAS with running time 2O(1/ǫ2log(1/ǫ)3) + poly(I). Unrelated Machines A classic result in scheduling theory is the Lenstra-Shmoys-Tardos 2-approximation algorithm for makespan minimization [LST90]. They also proved that the problem is NP-hard to approximate within a factor better than 3 2. Gairing et al. [GMW07] presented a more efficient, combinatorial 2-approximation algorithm based on flow techniques. Shchepin and Vakhania [SV05] showed that the rounding technique used in [LST90] can be modified to derive an improved ratio of 2 − 1 m. Shmoys and Tardos [ST93] showed an approximation algorithm that yields a schedule of makespan at most the length of an optimal schedule plus the largest processing time of any job in the instance. Although makespan minimization on unrelated machines is a major open problem in scheduling theory, and is extensively studied, there was no significant progress on either the upper or lower bound for over two decades, since the publication of [LST90]. This led researchers to consider interesting special cases and improving the upper bound for them. A well known special case is the restricted assignment problem, where jobs have processing times pij ∈ {pj,∞}. Svensson [S12] gave a polynomial-time algorithm that approximates the optimal makespan of the restricted assignment problem within a factor of 33 17 + ǫ ≈ 1.94 + ǫ for ǫ > 0, and also presented a local search algorithm that will eventually find a schedule of the mentioned approximation guarantee, but is not known to converge in polynomial-time. Gairing et al. [GL+04] presented a combinatorial (2− 1 )- approximation algorithm for the restricted assignment problem. pmax Ebenlendr et al. considered in [EKS08] the graph balancing problem, a special case of the restricted assignment problem where each job j has a finite processing time, pij < ∞, on at most two machines. The paper gives an elaborate 1.75-approximation algorithm for the problem. The authors also show that the problem is hard to approximate within a factor less than 3 2 even on bounded degree graphs, i.e., when the maximum degree is some constant. In the unrelated graph balancing problem, introduced by Versache and Weiss [VW14], each job can be assigned to at most two machines, but processing times are not restricted. They showed that this subclass of instances constitutes the core difficulty for the linear programming formulation of makespan minimization on unrelated machines, often used as a first step in obtaining approximate solutions. Specifically, they showed that the strongest known LP-formulation, namely, the configuration-LP, has an integrality gap of 2. Vakhania et al. [VMH14] considered makespan minimization on unrelated machines for the subclass of instances where job lengths can take only two values, p and q, which are fixed positive integers, such that p < q. They presented a polynomial-time algorithm that uses linear programming with absolute approximation factor of q (i.e., all schedules have makespan at most OP T + q). Page [P14] considered restricted assignment instances with processing times in a fixed interval, [p, q], and gave a q p-approximation algorithm, and a 3 2-approximation algorithm for the case where pij ∈ {1, 2, 3}. Chakrabarty et al. [CK+15] considered instances with two types of jobs: long and short, namely, pij ∈ {1, ǫ} for some ǫ > 0. They obtained a (2 − δ)-approximation algorithm for such instances. Shmoys and Tardos [ST93] considered the generalized assignment problem (GAP), where each job j incurs a cost of cij > 0 when assigned on machine i, and the objective is to 4 minimize the makespan and the total cost. The paper [ST93] presents a polynomial-time algorithm that finds a schedule of makespan at most twice the optimum with optimal cost. A summary of the known results for unrelated machines is given in Table 1.1. Restrictions on the Unrelated Model Authors [LST90] [LST90] [ST93] [SV05] [S12] [EKS08] [CK+15] [VMH14] [P14] Result 2-approximation Hard for factor < 3 2 A bound of Topt + pmax (2 − 1 m)-approximation Integrality gap ≤ 1.95 1.75-approximation (2 − δ)-approximation, δ > 0 A bound of Topt + q q p & 3 2 -approximation A bound of Topt + Lopt A bound of Topt + Lopt ϕ A bound of pmax + Lopt ϕ pij ∈ {pj,∞} pij ∈ {pj,∞}, pij < ∞ on < 2 machines pij ∈ {1, ǫ} for some ǫ > 0 pij ∈ {p, q} for some p < q pij ∈ [p, q] & pij ∈ {1, 2, 3} pij ≤ Topt This Work This Work ϕ ≥ L This Work T , for minimal feasible values of T & L pij ∈ {pj,∞} Table 1.1: Known results for makespan minimization on unrelated machines. 1.2 Fixed Parameter Algorithms Parameterized complexity is a branch of computational complexity theory that focuses on classifying computational problems according to their inherent difficulty with respect to multiple parameters of the input. The complexity of a problem is then measured as a function in those parameters. This allows the classification of NP-hard problems on a finer scale than in the classical setting, where the complexity of a problem is only measured by the number of bits in the input (see, e.g., [DF12]). Under the assumption that P 6= NP , there exist many natural problems that require super-polynomial running time when complexity is measured in terms of the input size only, but that are computable in a time that is polynomial in the input size and exponential (or worse) in a parameter k. Hence, if k is fixed at a small value, and the growth of the function over k is relatively small, then such problems can still be considered "tractable" despite their traditional classification as "intractable". Some problems can be solved exactly, or approximately, by algorithms that are exponen- tial only in the size of a fixed parameter while polynomial in the size of the input. Such an (approximation) algorithm is called a fixed-parameter tractable (FPT) (approximation) algorithm, because the problem can be (approximately) solved efficiently for small values of the fixed parameter. Problems in which some parameter k is fixed are called parameterized problems. A parameterized problem that allows for such an FPT algorithm is said to be a fixed-parameter 5 tractable problem and belongs to the class FPT. 1.2.1 Parametrized Scheduling Problems Despite the fundamental nature of scheduling problems, and the clear advantages of fixed- parameter algorithms, no such algorithms are known for many of the classical scheduling problems. One obstacle towards obtaining positive results appears to be that, in contrast to most problems known to be fixed-parameter tractable, scheduling problems involve many numerical input data (e.g., job processing times, release dates, job costs), which alone causes many problems to be NP-hard, thus ruling out fixed-parameter algorithms. 1.2.2 Related Work While minimizing the makespan on identical and uniform machines admits an EPTAS, see e.g., [AA+98, J10], the running times of these approximation schemes usually have a bad dependence on ǫ. In addition, these problems are strongly NP-hard [GJ79], there- fore we cannot hope to obtain an FPTAS. These considerations call for finding which scheduling problems are fixed-parameter tractable (FPT). This amounts to identifying instance-dependent parameters k that allow for algorithms that find optimal solutions in time f (k) · poly(I), for instances I and some function f depending only on k. As for scheduling on unrelated machines, an FPTAS is known [HS76], but only when assuming a fixed number of machines. Note that, if the number of machines or the number of processing times are constant, the problem is still NP-hard [LST90], and thus no FPT- algorithms can exist for these choices of parameters. This motivates us to identify instance- dependent parameters k, while assuming an arbitrary number of machines, that allow for better FPT approximation algorithms. Marx [M11] proposed the research direction of scheduling with rejection, where the pa- rameter k is given with the input for the scheduling problem, and the solution has to schedule all but k jobs. This direction was explored recently by Mnich and Wiese [MW13], who presented for the first time a fixed-parameter algorithms for classical scheduling prob- lems such as makespan minimization, scheduling with job-dependent cost functions and scheduling with rejection. For the problem of makespan minimization on identical ma- chines, the paper [MW13] presents an FPT algorithm, where the parameter k defines an upper bound on the number of distinct processing times appearing in an instance. For the more general model of unrelated machines, the paper gives an FPT algorithm, using the number of machines and the number of distinct processing times as parameters. 6 Table 1.2 summarizes the known results. Result FPT algorithm FPT algorithm FPT approximation scheme FPT algorithm Parameters Authors Model maxjpj m, #distinct pij identical machines unrelated machines {(i, j) : pij > ǫT}, feasible T This Work unrelated machines graph balancing [MW13] [MW13] treewidth, degree This Work Table 1.2: Known FPT algorithms for scheduling. We are not aware of any other work in this area. 1.3 Combinatorial Reoptimization Reoptimization problems naturally arise in many real-life scenarios. Indeed, planned or unanticipated changes occur over time in almost any system. It is then required to respond to these changes quickly and efficiently. Ideally, the response should maintain high perfor- mance while affecting only a small portion of the system. Thus, throughout the continuous operation of such a system, it is required to compute solutions for new problem instances, derived from previous instances. Since the transition from one solution to another incurs some cost, a natural goal is to have the solution for the new instance close to the original one (under certain distance measure). We use the reoptimization model developed by Shachnai et al. [STT12]. In this model, we say that A is an (r, ρ)-reapproximation algorithm if it achieves a ρ-approximation for the optimization problem, while incurring a transition cost that is at most r times the minimum cost required for solving the problem optimally. 1.3.1 Reoptimization in Scheduling We consider instances of scheduling problems that can change dynamically over time. Our goal is to compute assignments within some guaranteed approximation for the new problem instances, derived from the previous instances. Since the transition from one assignment to another incurs some cost (for example, the cost of pausing the execution of a job on one machine and resuming its execution on another), an additional goal is to have the solution for the new instance close to the original one (under a certain distance measure). 1.3.2 Related Work Reoptimization Shachnai et al. [STT12] presented reapproximation algorithms for sev- eral non-trivial classes of optimization problems. This includes a fully polynomial time reap- proximation schemes (FPTRS) for DP-benevolent problems, reapproximation algorithms 7 for metric Facility Location problems, and (1, 1)-reoptimization algorithm for polynomially solvable subset-selection problems. Junosza-Szaniawski et al. [JLR15] considered a variant of a recoloring problem, called the r-Color-Fixing. They investigated the problem of finding a proper r-coloring of a graph, which is "most similar" to some given initial solution, i.e. the number of vertices that have to be recolored is minimum possible. They provide a (1, 1)-reoptimization algorithm for the problem. More work on reoptimization can be found e.g., in [J15, AE+14]. Reoptimization in Scheduling Baram and Tamir [BT14] considered the problem of scheduling on identical machines with the objective of minimizing the total flow time, i.e., minimizing Pj∈J Cj, where Cj is the completion time of job j. They presented an algorithm that yields an optimal solution using the minimal possible transition cost, and an algorithm that outputs the best possible schedule, using a given limited budget for the transition, for several classes of instances. Bender et al. [BF+13] focused on a scheduling problem where each job is unit-sized and has a time window in which it can be executed. Jobs are dynamically added and removed from the system. They presented an algorithm that reschedules only O(min{log∗n, log∗∆}) jobs for each job that is inserted or deleted from the system, where n is the number of active jobs, and ∆ is the size of the largest window. 1.4 Main Results Our first contribution is in the study of makespan minimization on unrelated machines, which leads to approximation algorithms with performance guarantees better that 2, the best known bound for general instances. In particular, for the subclass of fully-feasible instances, we present (in Chapter 2) an LP-based algorithm that achieves makespan at most Topt + Lopt, where Topt and Lopt are the minimal makespan and minimal average machine load for this makespan, respectively. This result is better than twice the minimal makespan for instances naturally arising in real-life applications. It also improves the minimal makespan plus the maximum processing time of a job, for instances where the average machine load is smaller than the maximum processing time of any job. We show that our algorithm is robust in the sense that it achieves an improved makespan also for instances that are almost fully-feasible. In such instances, each job may exceed the minimal makespan on a small number of machines. Formally, we define the feasibility parameter of a general instance I, denoted ϕ(I), as the minimal fraction of machines on which a job has a processing time at most Topt, i.e., ϕ(I) = minj∈J {i∈M:pij≤Topt} . We present an algorithm that yields, for instances with large enough feasibility parameter, a schedule of makespan at most Topt + Lopt ϕ(I). For instances of the restricted assignment problem, i.e., for instances with processing times pij ∈ {pj,∞}, we show that a bound of pmax + Lopt ϕ(I) is obtained by an efficient and simple combinatorial algorithm, where pmax is the largest processing time of any job in the instance. m We further study the power of parameterization and present an FPT approximation 8 scheme, i.e., a (1 + ǫ)-FPT approximation algorithm, for makespan minimization on un- related machines parametrized by the number of machine-job pairs, (i, j) ∈ M × J , such that pij > ǫT , for some makespan candidate T . We also show that the graph-balancing problem, parameterized by treewidth and the maximum degree of the graph, is in FPT. These results are presented in Chapter 3. Our third contribution is reapproximation algorithms for the reoptimization variants of makespan minimization on identical and uniform machines, which are studied here for the first time. Specifically, we develop (1, 1+ǫ)-reapproximation algorithms, namely, algorithms that achieve a ratio of (1 + ǫ) to the minimum makespan, and the minimum transition cost, in both the identical machines and the uniform machines models, where transition costs can take values in {0, 1}. For the uniform case, we assume that the ratio between the highest and the lowest machine speeds is bounded by some constant. Thus, our algorithms achieve the best possible ratio with respect to the makespan objective in these models. For the unrelated machines model, we note that an algorithm of Shmoys and Tardos [ST93] can be used to obtain a (1, 2)-reapproximation, thus matching the best known bound for makespan minimization also in this model. We summarize the results for reoptimization in scheduling in Table 1.3. The results are given in Chapter 4. Result costs Authors Model (1, 2)-reapproximation algorithm (1, 1 + ǫ)-reapproximation algorithm (1, 1 + ǫ)-reapproximation algorithm arbitrary {0,1} {0,1} [ST93] unrelated machines identical machines This Work This Work uniform machines with s1 sm ≤ b Table 1.3: Our contribution for reoptimization in scheduling. 9 Chapter 2 Makespan Minimization for Fully-Feasible Instances 2.1 Preliminaries Consider a scheduling instance I = (J ,M), consisting of a set of m machines M and a set of n jobs J with non-negative integers pij denoting the processing time of job j ∈ J on machine i ∈ M. An assignment of the jobs to the machines is a bijection σ : J → M where σ(j) = i if and only if job j is assigned to machine i. For any assignment σ, the load on machine i under assignment σ, denoted as loadσ(i), is the sum of processing times for the jobs that were assigned to machine i. Thus, loadσ(i) =Pj∈J :α(j)=i pij. The makespan of an assignment σ, denoted by T (σ), is the maximum load over all the machines. Thus, T (σ) = maxi∈Mloadσ(i). The average machine load of an assignment σ, denoted by L(σ), is given by L(σ) = Pi∈M loadσ (i) . Given an instance I = (J ,M), we denote by Topt the optimal makespan, i.e., Topt = minσ:M→J T (σ), and we denote by Lopt the minimum average machine load for an optimal assignment, i.e., Lopt = minσ∗:M→J ,T (σ∗)=ToptL(σ∗). m Given an instance I = (J ,M), we say that a job j is feasible on machine i, if and only if pij ≤ Topt. The feasibility parameter of I, denoted ϕ(I), is the minimal fraction of feasible machines for any given job, i.e., ϕ(I) = minj∈J . Thus, every job j ∈ J is feasible on at least ϕ(I)· m machines. In this terms, an instance I is fully-feasible if and only if ϕ(I) = 1. We often omit I in the notation if it is clear from the context, and refer to the feasibility parameter as ϕ. {i∈M:j is feasible on i} m Given an instance I = (J ,M), an assignment σ : J → M, two positive integers L and T and some real number γ ≥ 1, we denote by Bad(σ, γ) ⊆ M the subset of machines i with loadσ(i) > T + γ · L, by Good(σ, γ) ⊆ M the subset of machines i with loadσ(i) ≤ γ · L, and for all j ∈ J , by Goodj(σ, γ) ⊆ Good(σ, γ) the set of machines from Good(σ, γ) that are also legal for job j. For every i ∈ M we denote by ji max(σ) = argmax{pij : σ(j) = i} the job with the longest processing time, assigned, by σ, on machine i. 10 2.2 Approximation Algorithm for Fully-Feasible In- stances Given positive integers L and T , let xij be an indicator to the assignment of job j on machine i. Consider the following linear program. LP (T, L) : 1 m pijxij ≤ L nXj=1 mXi=1 mXi=1 nXj=1 xij ≥ 0, xij = 1, pijxij ≤ T , for j = 1, ..., n for i = 1, ..., m for i = 1, ...m , j = 1, ..., n One can see that integer solutions to the above LP are in one to one correspondence with assignments σ : M → J of average machine load at most L and makespan at most T . Theorem 2.1. If LP (T, L) is feasible for some L ≤ T , then there is a polynomial-time algorithm that yields a schedule σ with 1. L(σ) ≤ L 2. loadσ(i) ≤ T + max{pij : σ(j) = i}, ∀i ∈ M Proof. Let ¯x = (xij : i ∈ M, ∈ J ) be a fractional solution to LP (T, L). We round ¯x to an integer solution using the following classic rounding technique, also used in [ST93]. Let ki =lPj∈J xijm. Each machine is partitioned into ki sub-machines vi,s, s = 1, ..., ki. An edge weighted, bipartite graph B = (W, V ; E) is constructed, where W = {wj : j = 1, ..., n} representing the jobs and V = {vis : i = 1, .., m, s = 1, ..., ki} representing the sub-machines. The edges are constructed in the following way. Consider the nodes vis as bins of unit capacity and the nodes wj, as pieces of size xij. For every machine i ∈ M, consider the nodes in non-increasing order of the processing time of the corresponding job, on machine i. For convenience, assume pi1 ≥ pi2 ≥ ... ≥ pin. An edge (wj, vis) with cost pij is constructed if and only if a positive fraction of xij is packed in the bin vis. The packing of the bins (and construction of the edges) is done in the following way. The bins vi1, ..., viki are packed one by one, with the pieces in the order pi1, pi2, ..., pin. While vis is not totally packed, (otherwise we consider the next bin) we continue packing the next piece such that if its size, xij, fits vis (without causing an overflow) it is packed to vis, else, if it causes an overflow, only a fraction β > 0 of xij is packed to vis, consuming all the remaining volume of vis, and the remaining part of (1 − β)xij is packed in vi,s+1. Figure 2.1 gives a pictorial example of this construction. 11 Figure 2.1: Example of the construction in the rounding The rounding is done by finding a minimum-cost integer matching M ∈ E that matches all job nodes, and for every edge (wj, vis) ∈ M, set σ(j) = i i.e., assign job j on machine i. i=1Pj:σ(j)=i pij ≤ By taking a minimum-cost integer matching it is guaranteed that 1 L, or L(σ) ≤ L. By the construction of the graph it is guaranteed that the load on machine i, for every i ∈ M, is at most max{pij : σ(j) = i} +Pki is = max{pij : (wj, vis) ∈ E}. Since Pki is ≤ T (for a detailed proof, see [ST93]), we get that loadσ(i) ≤ max{pij : σ(j) = i} + T for all i ∈ M. mPm , where pmax s=2 pmax s=2 pmax is This result will be helpful in our approximation algorithm. 2.2.1 Approximation Algorithm Recall that an instance I is fully-feasible if and only if pij ≤ Topt for every job j ∈ J and machine i ∈ M. Although fully-feasible instances are hard to identify, we give a polynomial-time algorithm that yields for such instances an assignment whose makespan is better than twice the optimal makespan, the best known ratio for general instances. Our main result is as follows. Theorem 2.2. There is a polynomial-time algorithm that yields for fully-feasible instances an assignment of makespan at most Topt + Lopt. Note that always Lopt ≤ Topt. Lopt = Topt occurs only in case where every optimal assignment is perfectly balanced (i.e., the load on all the machines equals Topt). Thus, in the typical case we get Lopt < Topt, which means that in the typical case our algorithm guaranteed a bound that is strictly better that twice the optimum. The following theorem shows that the problem remains hard already when considering only the class of fully-feasible instances. 12 Theorem 2.3. Makespan minimization on unrelated machines is hard to approximate within factor < 4 3 , already in the class of fully-feasible instances. The proof of the hardness result follows from a reduction from 3-dimensional matching as in [LST90]. We prove a stronger result, that also shows that our result is robust under small violations of the feasibility constraints. Namely, we show that we can get better bounds also when our instance is not fully-feasible but has the property that every job can be non-feasible on some small fraction of the machines. For this, we will need some definitions. Definition 2.1. Job j ∈ J is feasible on machine i ∈ M if pij ≤ Topt Definition 2.2. The feasibility parameter of instance I is defined as ϕ(I) = minj∈J {i ∈ M : j is feasible on i} m In these terms, we have that every job j ∈ J is feasible on at least ϕ(I) · m machines. Moreover, an instance I is fully-feasible if and only if ϕ(I) = 1. Given an instance I, we can fix L and T to be the minimal values such that LP (T, L) is feasible in polynomial-time in the size of the input I, using binary search on some feasible regions for L and T . At the end of this operation, L and T will satisfy L ≤ T , L ≤ Lopt and T ≤ Topt. Theorem 2.4. There is a polynomial-time algorithm that, given the values L ≤ T , yields for instances I with feasibility parameter ϕ(I) ≥ L T , an assignment of makespan at most Topt + Lopt ϕ(I) Corollary 2.5. The statement of theorem 2.2 follows directly from 2.4, since the feasibility parameter of fully-feasible instances is 1. Given a general scheduling instance I, its optimal makespan, Topt, nor its feasibility parameter, ϕ(I), cannot be computed in polynomial-time, unless P = NP . However, let ℓ be the number of distinct processing times pij of an instance I and w.l.o.g assume that p1 ≤ p2 ≤ ... ≤ pℓ are the distinct processing times of I. If we denote pℓ+1 = ∞, then we see that Topt can belong to exactly one of the regions [pt, pt+1) for some t ∈ {1, ..., ℓ}. If Topt ∈ [pt, pt+1) for some t ∈ {1, ..., ℓ}, then job j ∈ J is feasible on some machine i ∈ M if and only if pij ≤ pt. Therefore, Topt ∈ [pt, pt+1) if and only if ϕ(I) = ϕt , minj∈J . {i∈M:pij≤pt} m We prove the theorem by describing an algorithm that admits the desired bound on the makespan, for instances with large enough feasibility parameter. The first step of the algorithm is to find the minimal T and L such that LP (T, L) is feasible. Next, it obtains a fractional solution to LP (T, L) and rounds it to obtain an initial assignment σ, such that L(σ) ≤ L and loadσ(i) ≤ T + max{pij : σ(j) = i}, ∀i ∈ M, as in Theorem 2.1. Then, for each guess of the optimal makespan region and the corresponding feasibility parameter, 13 it tries to fix the initial assignment to achieve a new assignment of makespan at most Topt + Lopt (and unless the feasibility parameter is too large, it will succeed for the right ϕ guess). This is done by balancing the initial assignment such as to reduce the load of the overloaded machines to meet the desired makespan. We first prove the following lemmas. Lemma 2.6. Let σ be an assignment for some instance I = (J ,M) such that L(σ) ≤ L, let T ≥ L and let γ ≥ 1. Denote k = Bad(σ, γ). Then 1. k < m γ+1. γ(cid:17) · m + k γ · T L . 2. Good(σ, γ) >(cid:16)1 − 1 Proof. Each machine i ∈ Bad(σ, γ) has load greater than T +γ·L, thereforePi∈M loadσ(i) > k · (T + γ · L). 1. Assume that k ≥ m γ+1 , then Pi∈M loadσ(i) > k(T + γL) ≥ m γ+1(T + γL) = m γ+1 (T + γL) ≥ m γ+1 (L + γL) = m · L The last inequality follows from the fact that T ≥ L. Hence, the average machine load is greater than L, a contradiction. It follows that k < m γ+1 . 2. Let Good(σ, γ) = l. Then, there are m − k − l machines having loads greater than γL. Assume that l ≤(cid:16)1 − 1 γ(cid:17) m + k γ · T L , then Pi∈M loadσ(i) > k(T + γ · L) + (m − l − k) γL = kT + (m − l) γL ≥ kT +(cid:16)m −(cid:16)1 − 1 γ(cid:17) m + k L(cid:17) γL γ · T L(cid:17) γL ≥ kT +(cid:16) m γ · T = kT + (mL + kT ) ≥ mL γ + k Hence, the average machine load is greater than L, a contradiction. It follows that Good(σ, γ) ≥(cid:16)1 − 1 γ(cid:17) · m + k γ · T L . Lemma 2.7. Let I = (J ,M) be an instance with feasibility parameter ϕ. Let σ be an assignment for I with average machine load L and let T ≥ L. If ϕ ≥ L T then for every subset A ⊆ Bad(σ, 1 ϕ ), N (A) ≥ A, where N (A) is the set of neighbors of A in Gσ, 1 . ϕ 14 Proof. Let (cid:12)(cid:12)(cid:12)Bad(σ, 1 ϕ )(cid:12)(cid:12)(cid:12) = k. Since the number of illegal machines for any job j is at most (1 − ϕ)m, the number of good machines for job j is at least the number of good machines minus its illegal machines (the worst case where all illegal machines for job j are contained in Good(σ, 1 ϕ )). Together with Lemma 2.6 we have (cid:12)(cid:12)(cid:12)Goodj(σ, 1 ϕ )(cid:12)(cid:12)(cid:12) − (1 − ϕ)m ϕ(cid:17) · m + k ϕ ) · T ( 1 ϕ )(cid:12)(cid:12)(cid:12) ≥(cid:12)(cid:12)(cid:12)Good(σ, 1 >(cid:16)1 − 1 = ϕ · k T ≥ k L L − (1 − ϕ)m The last inequality follows from the fact that ϕ ≥ L T . Now, let A ⊆ Bad(α, 1 ϕ ). Then A ≤(cid:12)(cid:12)(cid:12)Bad(σ, 1 (cid:12)(cid:12)(cid:12)∪i∈AGoodji N (A) ≥ k. ϕ )(cid:12)(cid:12)(cid:12) = k. ϕ )(cid:12)(cid:12)(cid:12) ≥ (cid:12)(cid:12)(cid:12)Goodji max(σ, 1 jobs ji Recall that the set of neighbors of A is the set of machines that are good for all the ϕ ). Obviously N (A) = max, i ∈ A, i.e., N (A) = ∪i∈AGoodji ϕ ) ⊆ Good(σ, 1 max(σ, 1 max(σ, 1 ϕ )(cid:12)(cid:12)(cid:12) for some i ∈ A. It follows from the above that Since A ≤ k we have that N (A) ≥ A. By Hall's Theorem [H35], there exist a perfect matching in Gσ, 1 ϕ if and only if for every A ⊆ Bad(σ, 1 ϕ ), N (A) ≥ A . Thus, we have Corollary 2.8. There exists a perfect matching in Gσ, 1 ϕ . By the above discussion, we can modify the initial assignment σ, by finding a perfect and then transferring jobs from bad machines to their matching good matching in Gσ, 1 machines. We describe this formally in algorithm AU M . ϕ 15 that Topt ∈ [pt, pt+1) and that ϕ(I) = ϕt. (a) If ϕt < L (b) Otherwise, construct the bipartite graph Gσ, 1 ϕt T , continue. size (cid:12)(cid:12)(cid:12)Bad(σ, 1 ϕt )(cid:12)(cid:12)(cid:12), if one exists. If not, continue. and find a perfect matching of Algorithm 1 AU M 1. Use binary search to find the minimal T , such that LP (T, T ) is feasible. Next, with that T fixed, search for the minimal L such that LP (T, L) is feasible. 2. Solve the linear relaxation LP (T, L). 3. Round the solution to obtain an integral assignment σ using a rounding technique as given in Theorem 2.1. 4. For every t = 1, ..., ℓ, where ℓ is the number of distinct processing times of I, guess (c) Obtain a resulting assignment σ′ from σ by transferring the longest job, ji max ). ), to its matching machine i′ ∈ Good(σ, 1 from each machine i ∈ Bad(σ, 1 ϕt ϕt 5. Return the assignment σ′ with minimal makespan. Proof of Theorem 2.4. We show that the assignment output by Algorithm AU M satisfies the statement of the theorem. Consider a general instance I. By performing binary search on a feasible bounded region of the optimal makespan we can find the minimal T for which LP (T, T ) is feasible, and then by performing binary search on a feasible bounded region of the optimal average machine load we can find the minimal L for which LP (T, L) is feasible. These integers satisfy that T ≤ Topt, L ≤ Lopt and L ≤ T . assignment σ of L(σ) ≤ L and loadσ ≤ T + max{pij : σ(j) = i}, for all i ∈ M. T be the feasibility parameter of I. Then for some t = 1, ..., ℓ, where ℓ is the number of distinct processing times in I, ϕt = ϕ. Then, by Corollary 2.8, there exists a perfect matching in Gσ, 1 ϕt and let M = {(ib1, ig1), ..., (ibk , igk)} be a perfect matching in Gσ, 1 and we will find it in Step 4(b) in AU M . Let k = (cid:12)(cid:12)(cid:12)Bad(σ, 1 By Theorem 2.1, since LP (T, L) is feasible then Step 3 is guaranteed to generate an For any machine i = 1, ..., m, loadσ(i) ≤ T + max{pij : σ(j) = i}. Let ji job processed by σ on machine i. Then, pi,ji from machine i guarantees that the new load of machine i will be at most T . max = max{pij : σ(j) = i}, thus removing ji max be the largest max Let ϕ ≥ L )(cid:12)(cid:12)(cid:12) ϕt ϕt . As for the good machines, if i is a good machine for job j then pij ≤ pt. Therefore, transferring j to i will increase the load of i by at most pt which is at most Topt (since Topt ∈ [pt, pt+1)). Since the load of a good machine is at most L , we have that after such a job transfer the load will be at most Topt + L ϕt ϕt . The load on the rest of the machines stays unchained, i.e., loadσ(i) ≤ T + L ϕt , for all i /∈ Bad(σ, 1 ϕt ) ∪ Good(σ, 1 ϕt ). 16 ϕt , T + L Thus, by performing the large-jobs transfers for all pairs (ibs, igs) ∈ M, s = 1, ..., k, we ϕt} for all i ∈ M, which obtain a new assignment σ′, with loadσ′ (i) ≤ max{T, Topt + L is at most Topt + Lopt ϕt , since L ≤ Lopt and T ≤ Topt. Theorem 2.9. The complexity of AU M is O((nm) Proof. We will show that Step 1 in AUM is the bottle-neck of the algorithm. In this step we perform a binary search on the feasible regions of T and L while solving LP (T, L). Since the feasible region for both T and L is [0,P(i,j)∈M×J pij], we solve the LP O(log(P(i,j)∈M×J pij)) 2 · log(P(i,j)∈M×J pij)) [K84], so overall 2 · log2(P(i,j)∈M×J pij)). times. Solving the LP can be done in time O((nm) this operation runs in O((nm) 7 7 7 2 · log2(P(i,j)∈M×J pij)). The number of vertices in the bipartite graph Gσ, 1 ϕt equals to the number of bad and good machines, which is at most m. From 2.6, the number of bad machines is at most m ϕ +1, thus the number of edges in the bipartite graph is at most Pi∈Bad(σ, 1 2 ≤ 1 (the last two inequalities are due to ϕ ≤ 1). Therefore finding a perfect matching in Gσ, 1 can be done in time O(qVσ, 1 ϕt ) = O(√m) [MV80]. In AU M , we find a perfect matching for every t = 1, .., ℓ, where ℓ ≤ n · m is the number of distinct processing times. Thus, the complexity of Step 4 sums to O(nm√m). 2 ·log(P(i,j)∈M×J pij)) time and Step 3 is done in O(n3(m+n)3) 2 · log2(P(i,j)∈M×J pij)). Therefore, the overall complexity of the algorithm is O((nm) Step 2 is done in O((nm) ϕ ) ϕm = ϕ ϕt · Eσ, 1 ϕ +1 ≤ ϕ [EK72]. ϕt 2 1 7 1 7 17 2.3 A Better Bound for the Restricted Assignment Problem In this section we consider the restricted version of our problem, where pij ∈ {pj,∞}, for each job j ∈ J , and each machine i ∈ M. This subclass is NP-hard to approximate within a factor better than 3 2 , which is also the best known lower bound for the general version [LST90]. In the restricted version, any job j with processing time pij < ∞ is feasible on machine i, since pj ≤ Topt for every j ∈ J . Hence, the feasibility parameter of a restricted instance I is exactly ϕ(I) = minj∈J {i∈M:pij<∞} , which can be computed efficiently. Fully- feasible restricted instances correspond to the identical machines instances, hence we do not consider especially fully-feasible instances in this case. Also, we say that an assignment σ : M → J is feasible if pij < ∞ for every machine i and job j such that σ(j) = i. For this variant, we show that a better bound than in Theorem 2.4 can be achieved by a much simpler and more efficient combinatorial algorithm, and for every feasibility parameter. Denote by pmax = maxj∈J pj the largest processing time of some restricted instance I. Gairing et al. [GL+04] presented a (2− 1 )-approximation algorithm for the restricted assignment problem. Using techniques from [GL+04], we obtain an approxima- tion algorithm which yields an assignment of makespan at most pmax + Lopt ϕ , where ϕ, is the feasibility parameter of the instance. pmax m Overview of the Algorithm of Gairing et al. We describe below the procedure UBF , used in [GL+04]. Let I be an instance for the restricted assignment problem. Let ∆ be an integer that will be determined by binary search, to be a lower bound on Topt. Let σ be a feasible assignment and let Gσ = (W ∪ V, Eσ) be a directed bipartite graph where W = {wj : j ∈ J } consists of the job nodes, and V = {vi : i ∈ M} consists of the machine nodes. For any job node wj and any machine node vi, if σ(j) = i there is an arc in Eσ oriented from vi to wj; if σ(j) 6= i and j is feasible on machine i, then there is an arc in Eσ oriented from wj to vi. Given a feasible assignment σ, consider the partition of machines into three subsets: M+(σ) (overloaded), M−(σ) (underloaded), and M0(σ) (all the remaining machines). A machine i ∈ M+(σ) is overloaded if loadσ(i) ≥ pmax + ∆ + 1. A machine i ∈ M−(σ) is underloaded if loadσ(i) ≤ ∆. The remaining machines, which are neither overloaded nor underloaded, form the set M0(σ) = M r (M−(σ)SM+(σ)). The procedure UBF (σ, ∆) starts with some initial feasible assignment of jobs to machines and iteratively improves the makespan until it obtains an assignment with makespan of pmax+∆, or declares that an assignment of makespan ∆ does not exist. In each iteration, the algorithm finds an augmenting path in Gσ, from an overloaded machine to an underloaded machine, and pushes jobs along this path, by performing a series of job reassignments between machines on that path. This results in balancing the load over the machines, i.e., reducing the load of the source that is an overloaded machine, and increasing the load of the destination that is an underloaded machine, while preserving the load of all other machines. Figure 2.2 gives a pictorial example of this operation. UBF terminates when there is no path from an overloaded machine to an underloaded 18 machine in Gσ, and this occurs after O(mS) steps, where S = Pj∈J {i : pij < ∞}. Let τ be the resulting assignment after UBF (σ, ∆) terminates. Then, it is shown in [GL+04] that if M+(τ ) 6= ∅, then Topt > ∆. The procedure UBF combined with a binary search over the possible range of values for ∆, is used to identify the smallest ∆ such that a call to UBF (σ, ∆) returns an assignment τ with M+(τ ) = ∅. This yields the approximation ratio of 2 − 1 The running time of the approximation algorithm is factored by a value that is logarith- mic in the size of the range in which we search for ∆, e.g., [0,Pj∈J pj]. Thus, the algorithm of [GL+04] computes an assignment having makespan within a factor of 2 − 1 optimal in time O(mSlogP ), where P =Pj∈J pj. from the pmax . pmax Figure 2.2: The bipartite graph Gσ. By changing the orientation of the path i3 → j5 → i5, we remove job j5 from i5 and schedule it on machine i3. 2.3.1 Approximation Algorithm Let I be an instance of the restricted assignment problem. The feasibility parameter of I is exactly ϕ = ϕ(I) = minj {i:pij<∞} . Let σ be an initial feasible assignment for I, and m consider the bipartite graph Gσ. Note that any feasible assignment σ for an instance of the restricted assignment problem has an average machine load L(σ) = 1 mXj∈J pj (2.1) Thus, Lopt = 1 mPj∈J pj for any instance I. Our algorithm proceeds as follows. 19 Algorithm 2 ARES(I) 1. Fix ∆ = ⌊ Lopt ϕ(I)⌋. 2. Apply UBF (σ, ∆) and return the resulting assignment. the optimal makespan. Let 3 ϕ(I) = pmax + Pj∈J pj d m such ϕ(I)⌋) terminates with M+ = ∅. The correctness of Theorem 2.10 follows from the next lemma. 2 < r < 2, then for instances with feasibility parameter d Theorem 2.10. For any instance I with feasibility parameter ϕ(I) , Algorithm 2 yields a schedule of makespan at most pmax + Lopt m·ϕ(I) , in time O(m2n). Corollary 2.11. Let I, be an instances with feasibility parameter ϕ(I) = d m, for some d = 1, ..., m. Then Algorithm 2 yields a schedule of makespan at most pmax + Pj∈J pj . Therefore, for instances with sufficiently large d (which is equivalent to a large feasibility parameter), namely d such that d· pmax >Pj∈J pj, we get a schedule with a makespan better than twice that d · (r − 1)pmax >Pj∈J pj, Algorithm 2 is a r-approximation algorithm. Lemma 2.12. Let I be an instance with feasibility parameter ϕ(I). Let σ be an initial feasible assignment for I. Then UBF (σ,⌊ Lopt Proof. Let τ be the assignment when UBF (σ,⌊ Lopt ϕ(I)⌋) terminates. At this point,there is no path from a machine in M+(τ ) to a machine in M−(τ ) in the graph Gτ . Assume that M+(τ ) 6= ∅. Then there exists a machine i′ with loadτ (i′) ≥ pmax + ⌊ Lopt ϕ ⌋. Denote by Mi′ the set of machines i such that vi is reachable from vi′, then Mi′ = {i ∈ M : there is a directed path in Gτ from vi′ to vi }. Obviously, there exists a job j′, such that τ (j′) = i′. Thus, there is an edge (vi′, uj ′) in Gτ . Since ϕ is the feasibility parameter of I, there exists at least ϕm machines on which uj ′ is feasible, i.e., there exists an edge from uj ′ to each one of these machines. By appending each of these edges to (vi′, uj ′) we get a directed path from vi′ to at least ϕm machines (including vi′). Therefore, we conclude that Mi′ ≥ ϕm. Now, we compute a lower bound on the average machine load for τ , by summing the loads of all the machines i ∈ M. We have that i′ ∈ M+(τ ), thus loadτ (i′) > pmax + Lopt ϕ . Also, there is no path from vi′ to machines in M−(τ ), and therefore Mi′ ∩ M−(τ ) = ∅. Thus, for all i ∈ Mi′ it holds that loadτ (i) ≥ ⌊ Lopt loadτ (i) ≥ loadτ (i′) + Xi∈Mi′ ,i6=i′ > pmax + ⌊ Lopt = pmax + Mi′(⌊ Lopt ≥ pmax + Mi′(( Lopt ≥ pmax + mϕ( Lopt ϕ ) = pmax + mLopt > mLopt ϕ ⌋ + 1 + (Mi′ − 1) · (⌊ Lopt ϕ ⌋ + 1) Xi∈M ϕ ⌋ + 1. Hence, loadτ (i) ϕ ⌋ + 1) ϕ − 1) + 1) 20 We have shown that the sum of loads of the assignment τ is greater than mLopt. Hence, the average load for τ is greater than Lopt. A contradiction. By 2.1, the average load of any schedule, and in particular τ , cannot exceed Lopt. Proof of Theorem 2.10. Let I be an instance with feasibility parameter ϕ. Let σ be some initial feasible assignment. By Lemma 2.12, when UBF (σ,⌊ Lopt ϕ ⌋) terminates, M+ = ∅. Therefore, the maximum load of the resulting assignment is at most pmax + ϕ ⌋ = pmax + ⌊Pj∈J pj ⌊ Lopt ⌋. The running time of the algorithm equals to the running time of one call to UBF , which is O(mS), where S = Pj∈J {i : pij < ∞}. Since S ≤ m · n for every instance I, the algorithm terminates after O(m2n) steps. Note that our algorithm has better running time than the algorithm of [GL+04], since we use a single call to the procedure UBF , in contrast to the (2 − 1 )-approximation algorithm of [GL+04], which uses binary search to find the best value for ∆, resulting in an overall running time of O(mSlogP ), where P =Pj∈J pj is the sum of processing times of all jobs. ϕ pmax 21 Chapter 3 Fixed-Parameter Algorithms for Scheduling on Unrelated Machines 3.1 Preliminaries Some problems can be solved exactly, or approximately, by algorithms that are exponential only in the size of a fixed parameter while polynomial in the size of the input. Such an (approximation) algorithm is called a fixed-parameter tractable (FPT) (approximation) algorithm, because the problem can be (approximately) solved efficiently for small values of the fixed parameter. Problems in which some parameter k is fixed are called parameterized problems. A parameterized problem that allows for such an FPT algorithm is said to be a fixed-parameter tractable problem and belongs to the class FPT. We give some definitions formalizing this concept. Definition 3.1. A problem is said to be FPT if it can be solved by an algorithm A that runs in time f (k) · poly(I), for every instance I with parameter k, and where f is a function independent of I. The algorithm A is called an FPT algorithm. We can similarly define FPT-approximation algorithms. Definition 3.2. A problem is said to have an r-FPT approximation algorithm, if there exists an r-approximation algorithm A to the problem, that runs in time f (k) · poly(I), for every instance I with parameter k, and where f is a function independent of I. Definition 3.3. A family {Aǫ : ǫ > 0}, where Aǫ is a (1+ǫ)-FPT approximation algorithm for all ǫ > 0, is called a parametrized approximation scheme. 22 3.2 Parametrized Approximation Scheme for Schedul- ing on Unrelated Machines Consider the problem of minimizing the makespan on unrelated machines, i.e., scheduling a set J of n jobs, j = 1, .., n, on a set M of m unrelated parallel machines, i ∈ M, where each job j has a processing time of pij on machine i and the objective is to find a schedule with minimum makespan. Our parameter k of a scheduling instance is the number of machine-job pairs (i, j) ∈ M × J such that pij > ǫ · T for some ǫ ∈ (0, 1] and a feasible value T . We will show that by rounding a solution to the MILP formulation of the problem where the k variables xij such that pij > ǫ · T are integral, we can get an assignment with makespan at most (1 + ǫ) the optimal makespan. Given a positive integer T , let xij be an indicator to the assignment of job j on machine i. Consider the following mixed integer linear program. MILP (ǫ, T ) : xij = 1, for j = 1, ..., n mXi=1 nXj=1 xij ≥ 0, xij ∈ {0, 1}, xij = 0, if pij > T, for i = 1, ...m , j = 1, ..., n for i, j such that pij ≤ ǫ · T for i, j such that pij > ǫ · T pijxij ≤ T , for i = 1, ..., m One can see that integer solutions to the above MILP are in one to one correspondence with assignments σ : J → M of makespan at most T, and that any feasible solution to MILP (ǫ, T ) has the property that the variables xij, such that pij > ǫT , are integral. Theorem 3.1. Let I be a scheduling instance, let ǫ ∈ [0, 1] and let T be a positive integer such that MILP (T, ǫ) is feasible. Then an assignment of makespan at most (1 + ǫ)T can be found in time 2k · poly(I), where k = {(i, j) : pij > ǫ · T}. Proof. Let xij, i = 1, ..., m, j = 1, ..., n be a solution to MILP (ǫ, T ). Then for every pair (i, j) ∈ M × J such that pij > ǫ · T , the corresponding xij is either 0 or 1. Let li be the number of jobs j for which pij > ǫ · T on machine i and such that the corresponding variable xij equals to 1. Recall the rounding technique as in Theorem 2.1. Then the first li slots of machine i are full and therefore the capacity left in the slots for the other jobs, with pij ≤ ǫ· T is T −Pj:pij>ǫT pij. From Theorem 2.1, we get that the jobs that are assigned by the rounding to the remaining slots li + 1, ..., ki (where ki = lPj∈J xijm) max + T −Pj:pij>ǫT pij to the load of machine i. Therefore the load of contribute at most pli+1 23 machine i is at most Pj:pij>ǫT pij +(cid:16)pli+1 max + T −Pj:pij>ǫT pij(cid:17) = pli+1 max ≤ ǫ · T , and therefore the total load of machine i is at most (1 + ǫ)T . The algorithm runs in time 2k · poly(I), since the bottle-neck of the algorithm is ob- taining a feasible solution to the MILP. This is done by brute-force search of at most 2k possible binary values for all the variables xij corresponding to (i, j) ∈ Sǫ, by fixing them and finding a solution for the resulting LP which can be done in polynomial-time in I [K84]. max + T . Now, pli+1 3.3 An FPT Algorithm for Graph-Balancing In this section we consider the special case of the restricted assignment problem, where each job can be assigned to at most two machines, with the same processing time on either machine. For this special case, Ebenlendr et al.[EKS08] presented a 1.75-approximation algorithm for the minimum makespan problem. An instance of the scheduling problem can be modeled as an undirected, multi-graph, with m nodes (a node for each machine) and n edges, such that every job j is associated with an edge of weight pj between both machine nodes on which it can be processed, or a loop of weight pj on the only machine node on which it can be processed. Minimizing the makespan is then equivalent to the problem of graph-balancing, i.e., of orienting each edge, such that the maximum weighted in-degree over all nodes is minimized. We exploit this graph representation of the problem to develop an FPT algorithm for this case. Definition 3.4. The maximum degree r of an undirected graph G = (V, E) is the maximum number of neighbors of any vertex, i.e., r = maxv∈V N(v), where N(v) = {e ∈ E : vu, for some u ∈ V }. We give below an FPT algorithm for graph balancing, where the parameters are the width of the tree decomposition of the graph, and the maximum degree of the graph. Note that we cannot hope for obtaining an FPT algorithm with the fixed parameter being only the maximum degree of the graph, as from the hardness proof for general instance [EKS08], if follows that he problem is hard to approximate within a factor less than 3 2 even on bounded degree graphs, i.e., when the maximum degree is some constant. Intuitively, a tree decomposition represents the vertices of a given graph G as subtrees in such a way that vertices in the given graph are adjacent only when the of a tree, corresponding subtrees intersect. Definition 3.5. Given a graph G = (V, E), a tree decomposition is a pair hX, Ti, where X = {X1, ..., Xt} is a family of subsets of V (also called bags), and T is a tree whose nodes are the subsets Xi, satisfying the following properties: 1. The union of all sets Xi equals V . That is, each graph vertex is associated with at least one tree node. 24 2. For every edge (v, w) in the graph, there is a subset Xi that contains both v and w. That is, vertices are adjacent in the graph only when the corresponding subtrees have a node in common. 3. If Xi and Xj both contain a vertex v, then all nodes Xk of the tree in the (unique) path between Xi and Xj contain v as well. That is, the nodes associated with vertex v form a connected subset of T . It can be stated equivalently that if Xi, Xj and Xk are nodes, and Xk is on the path from Xi to Xj, then Xi ∩ Xj ⊆ Xk. The width of a tree decomposition is the size of its largest set Xi minus one. The treewidth tw(G) of a graph G is the minimum width among all possible tree decompositions of G. It is observed in [B88, N06], that many algorithmic problems that are NP-complete for arbitrary graphs can be solved efficiently by dynamic programming for graphs of bounded treewidth, using the tree decompositions of these graphs. We show that the problem of graph balancing can be solved efficiently by dynamic programming for graphs of bounded treewidth and bounded vertex degree (the maximum number of neighbors of a vertex). Theorem 3.2. Let G be an undirected edge weighted multi-graph, with given tree decompo- sition h{X = {X1, ..., Xt}, Ti of width w. Then the graph balancing problem parameterized by the graph treewidth and the maximum degree, r, is solvable in time O(22w·r · wr · X. Proof. We show how the problem can be solved using dynamic programing on the tree decomposition of G. The idea is to examine for each bag Xi ∈ X all the possibilities of feasible assignments to the machines represented by the vertices in the bag Xi, and the jobs represented by the edges of the subgraph G[Xi], induced by the vertices in bag Xi. This information is stored in a table Bi corresponding to each bag Xi. The tables will be updated in a post-order manner, starting at the leaves of the tree decomposition and ending at the root. During this update process, it is guaranteed that local solutions for each subgraph corresponding to a bag of the tree decomposition are combined into a global optimal solution for the overall graph G. The algorithmic details are as follows. Step 0: Set an initial orientation on the edges of the graph G. For each bag Xi = {vi mi}, EG[Xi] = mi . Compute the following table of 2mi rows, and mi + ni + 1 columns: ni}, Xi = ni, let E[Xi] = {ei 1, ..., vi 1, ..., ei li(vi 1) li(vi 2) · · · li(vi ni) Ti() Bi = 1 ei ei 2 0 0 0 0 0 0 ... ... 1 1 1 1 · · · · · · · · · · · · ... · · · · · · ei mi 0 1 1 ... 0 1 25 The table consists of 2nir rows and nir + 1 columns. Each row represents an assignment to the sub-problem induced by the subgraph G[Xi]. Each row is a 0-1 sequence of length nir that determines which of the edges in G[Xi] is directed oppositely than its direction in the given initial orientation (1 if it is the opposite orientation, and 0 otherwise). Formally, we can describe an assignment by a mapping Ai : E[Xi] = {ei1, ..., eimi} → {0, 1}. Given the mapping Ai, let In(vj) denote the set of incoming edges for vj, for vj ∈ Xi. The last column, Ti(), is the makespan of the assignment Ai. Step 1: Table initialization. For every table Bi and assignment Ai : E[Xi] → {0, 1} set li(vi j)(j) = Xe∈In(vj ) c(e) for every vi1, ...., vini ∈ Xi, where c(e) is the cost of edge e, which corresponds to the processing time of the job associated with the edge e. Step 2: Dynamic programming. We now go through the tree decomposition of G, from the leaves to the root, and compare the corresponding tables against each other. Let i be the parent node of j. We show how the table for Xi can be updated by the table for Xj. Assume that Xi = {u1, .., us, vi ni−s} and Xj = {u1, .., us, vj mi−t} and E[Xj] = {e1, .., et, ej mj −t}. For each assignment A : {e1, ..., et} → {0, 1}, and each extension Ai : E[Xi] → {0, 1} of A, we consider an assignment Aj, which is an extension of A, that minimizes the new makespan, i.e., for each assignment Aj, which is an extension of A, we calculate nj−s}, and that E[Xi] = {e1, .., et, ei 1, ..., vj 1, ..., ej 1, ..., vi 1, ..., ei lj i (uk) = lj(uk) + li(uk) − X e∈E[Xi]∩E[Xj]∧e∈In(uk) c(e), for k = 1, ..., s. Then, we calculate the makespan T j i = max(cid:2)Tj(Aj), max1≤k≤slj i (uk), max1≤k≤ni−sli(vi k)(cid:3) We update the entry for Ai with lj i and T j i for j = argmin(T j i ). The values of li(v), v ∈ Xi, and Ti() grows by the minimal value for the makespan of the assignment problem induced by all the vertices contained in the subtree rooted at node i. If i has several children ji, ..., jl, then table Bi is updated successively against all tables Bj1, ..., Bjl in the same way. All this is repeated until the root node is finally updated. 26 Step 3: Construction of a minimum makespan assignment. The length of a minimum makespan assignment is derived from the minimal entry of the last column, Ti(), of the root node table. The assignment of the corresponding row shows where to assign the jobs represented by the edges in the subgraph induced by the vertices of the root bag. By recording in Step 2 how the respective minimum of each bag was determined by its children, one can easily determine the assignment of all edges in the graph. This concludes the description of the dynamic programming algorithm. It remains to show its correctness and running time. 1. The first and second conditions in Definition 3.5, namely V = ∪XXi and ∀e ∈ E ∃Xi ∈ X : e ∈ E[Xi], guarantee that every machine and job in the instance is considered through the computation. 2. The third condition in Definition 3.5 guarantees the consistency of the dynamic pro- gramming. If a vertex v ∈ V occurs in two different bags Xi1 and Xi2, then it is guaranteed that for the computed minimum makespan assignment only one set of jobs can be scheduled on the machine associated with that vertex v. As for the running time of the algorithm, for each edge (Xi, Xj) in the tree decomposition of G, and for each of 2mi assignments Ai, we go over all the assignments Aj that agree with Ai on the edges in E[Xi]∩ E[Xj] (at most 2mj ), and do a computation of time O(ni + mi). This results in complexity of O(2mi+mj ) · (ni + mi) · X. Since mk ≤ nk · r and nk ≤ w for all Xk ∈ X, we have that the complexity of the algorithm is O(22wr · wr · X). 27 Chapter 4 Reoptimization Algorithms for Scheduling Problems 4.1 Preliminaries Let ΠID and ΠU N denote the makespan minimization problems on identical and uniform machines, respectively. In the reoptimization model developed in [STT12], we consider instances of the scheduling problem that can change dynamically over time. Our goal is to compute assignments within some guaranteed approximation for the new problem instances, derived from the previous instances. Since the transition from one assignment to another incurs some cost (for example, the cost of pausing the execution of a process on one machine and resuming its execution on another), an additional goal is to have the solution for the new instance close to the original one (under a certain distance measure). Let I0 = (M0,J0) be an instance of jobs and machines. Let m0 = M0 and n0 = J0 and let σ0 : J0 → M0 be some initial assignment for I0. We denote by I = (M,J ) a new instance derived from I0 by an admissible operation, e.g., addition or removal of jobs and/or machines. For any job j ∈ J and a feasible assignment σ : J → M, we are given the transition cost of j when moving from the initial assignment σ0 to σ. We denote this transition cost by cσ0(j, σ). The goal is to find an optimal assignment for I, for which the total transition cost, given by Pj∈J cσ0(j, σ), is minimized. Recall that, given an optimization problem Π, we denote by R(Π) the reoptimization version of Π. Definition 4.1. An algorithm A yields an (r, ρ)-reapproximation for R(ΠID) (R(ΠU N )), for r, ρ ≥ 1, if for any instance I for ΠID (ΠU N ), A outputs an assignment of makespan at most ρ times the minimal makespan for I, and of total transition cost at most r times the minimal transition cost to an optimal assignment for I. We consider below the case where transition costs can take values in {0, 1}. In particular, job j ∈ J incurs a unit transition cost either if (i) j ∈ J0 and is moved to a different machine in the schedule for I, or (ii) j ∈ J \ J0, i.e., j is assigned to a machine for the first time in the schedule for I. Otherwise, the transition cost for job j is equal to 0. Formally, cσ0(j, σ) = 1 if j /∈ J0, or if j ∈ J0 and σ0(j) 6= σ(j); otherwise, cσ0(j, σ) = 0. 28 Definition 4.2. A polynomial time reapproximation scheme (PTRS) for R (Π) is an al- gorithm that, given the inputs I0 and I for R (Π) and parameters ǫ1, ǫ2 ≥ 0, yields a (1 + ǫ1, 1 + ǫ2)-reapproximation for R (Π), in time polynomial in I0 and I. 4.2 A (1, 1+ǫ)-Reapproximation Algorithm for Makespan Minimization on Identical Machines We present below a reapproximation algorithm, AID, for the problem of minimizing the makespan on identical machines. The algorithm uses a relaxed packing of items in bins, where the items correspond to jobs, and the bins represent the set of machines. Definition 4.3. Given a set of bins, each of capacity K > 0, and a set of items packed in the bins, we say that the packing is ǫ- relaxed, for some ǫ > 0, if the total size of items assigned to each bin is at most (1 + ǫ)K. 4.2.1 Algorithm Our algorithm for reoptimizaing makespan minimization on identical machines accepts as input the instances I0 and I, the initial assignment of jobs to the machines, σ0, and an error parameter ǫ > 0. The algorithm proceeds as follows. We apply a (1 + ǫ)-approximation algorithm [H96, AA+98] on the new instance to obtain a solution of makespan T ≤ (1 + ǫ)C ∗ max. Then, we split our instance into large and small jobs, round down the large jobs processing times (to have a polynomial-size collection of feasible configurations of large jobs on the machines), such that the load of each machine does not exceed T . Then, we iterate on this collection in order to find the configuration that minimizes the transition cost from the original solution. We prove that after we inflate the rounded jobs to their original processing times, and greedily assign all the small jobs within the configuration, the resulting makespan is at most (1 + ǫ)C ∗ max. We give below a detailed description of our algorithm, AID. Let C ∗ max(I) denote the minimum makespan for an instance I. For simplicity of the presentation, for the case where m < m0, we assume w.l.o.g. that the omitted machines are m + 1, m + 2, . . . , m0. 29 Algorithm 3 AID(I0,I, σ0) 1. Let ǫ0 = ǫ T ≤ (1 + ǫ0)C ∗ 2. Define αj = pj 4 . Use a PTAS for makespan minimization on identical machines to find max(I). T for all j ∈ J , and represent each machine as a bin of unit capacity. Consider the jobs as items whose sizes are αj ∈ (0, 1]. 3. An item j ∈ J is small if it has a size at most ǫ0; otherwise, item j is large. 4. Round down the sizes of the large items to the nearest multiple of ǫ2 0. Denote the rounded sizes ¯αj, for every large item j. 5. For any feasible assignment of rounded large items in the m bins, given by the con- figuration C ={C 1, . . . , C m}, do: (i) Let ℓ = max{m0, m}. Construct a complete bipartite graph G = (U, V, E), in which V = {1, . . . , ℓ}, and U = {C 1, C 2, . . . , C ℓ}. Each vertex i ∈ V corresponds to the initial configuration of machine i, given by C i 0 = {j ∈ J0 : σ0(j) = i}, for 0 = ∅ for all m0 + 1 ≤ i ≤ ℓ. If m0 ≥ m, set C i = ∅ 1 ≤ i ≤ m0; if m0 < m , set C i for all m + 1 ≤ i ≤ ℓ. Define a cost on the edges (i, C k), for all 1 ≤ i, k ≤ ℓ, as follows. (a) Add the cost of large items that appear in C k but not in the initial config- uration C i 0. (b) Add to C k all the small items that appear in C i 0 but not in C k and then omit the largest small items until the total size of C k does not exceed 1. Add the cost of the omitted items. For an empty configuration C k, the cost of the edge (i, Ck), for all 1 ≤ i ≤ ℓ is equal to 0. (ii) Find a minimum cost perfect matching in the bipartite graph. (iii) Add to the solution the omitted small items using First-Fit. 6. Choose the solution of minimum cost, and return the corresponding schedule of the jobs on the machines. 4.2.2 Analysis Theorem 4.1. For any ǫ > 0, Algorithm AID yields in polynomial time a (1, 1 + ǫ)- reapproximation for R (ΠID), We prove the theorem using the next lemmas. Lemma 4.2. Let I = (M,J ) be an instance of ΠID, for which the minimum makespan is C ∗ max, and let T ≥ C ∗ T , for all j ∈ J ; then, Pj∈J αj ≤ m. max. Let αj = pj 30 Proof. We note that the minimum makespan satisfies C ∗ have that αj = pj T ≤ pj C ∗ max for all j ∈ J , therefore, =Xj∈J m ≥Xj∈J pj T αj. max ≥ Pj∈J pj m . Since T ≥ C ∗ max, we Lemma 4.3. Let eC be a feasible assignment of rounded large items on the m machines, given by the configuration C = {C 1, . . . , C m}, to which we add in each bin the small items that were not omitted in Step 5 of AID. Then eC can be expanded in polynomial time to an ǫ0-relaxed packing of all items in the input I. Proof. Let C = {C 1, C 2, ..., C m} be a feasible configuration of the large rounded items, and let S1, S2, ..., Sm be the subsets of small items added in Step 5 to the bins, to form eC. Then eC yields a feasible packing, i.e., for all 1 ≤ i ≤ m, ¯αj +Xj∈Si αj ≤ 1. Xj∈C i Now, since ¯αj ≥ ǫ0 for all j ∈ C i, the number of large items in bin i is bounded by ⌊1/ǫ0⌋. Also, since αj − ¯αj ≤ ǫ2 αj ≤ Xj∈C i 0, for all j ∈ L, we have that αj ≤ Xj∈C i ¯αj +(cid:22) 1 0) +Xj∈Si 0 +Xj∈Si αj ≤ 1 + ǫ0. Xj∈C i∪Si ǫ0(cid:23) ǫ2 ( ¯αj + ǫ2 after we add the small items using First-Fit. Let α1, α2, ...αt denote the sizes of the items Hence, the packing of eC is ǫ0-relaxed. Now, we show that the packing remains ǫ0-relaxed packed in eC, and let αt+1, ..., αn be the sizes of the small unpacked items. By Lemma 4.2, we have nXi=1 αj ≤ m (4.1) We apply First-Fit in the following relaxed manner. Consider the next item in the unpacked list. Starting from bin 1, we seek the first bin in which the item can be added, such that the overall size of the items packed in this bin is at most 1 + ǫ0. Let ri be the total size of the items packed in bin i after adding the small items. Assume that, after we apply First-Fit, some small items remain unpacked (i.e., none of the bins can accommodate these items). Let iℓ, ..., in denote this subset of items. Then, we have that (1 + ǫ0) − ri < αj for all j = ℓ, . . . , n and i = 1, . . . , m. It follows, that (1 + ǫ0)m − mXi=1 ri < mαj ∀j = ℓ, . . . , n By the definition of ri, and since we packed all items up to iℓ−1, mXi=1 ri = ℓ−1Xj=1 αj 31 (4.2) (4.3) From (4.1), we get that ℓ−1Xj=1 αj ≤ m − Then, from (4.3), we have nXj=ℓ mXi=1 From (4.2) and (4.4), it follows that, for all ℓ ≤ j ≤ n, nXj=ℓ αj ≥ m − αj. ri m(1 + ǫ0) − (m − or, nXj=ℓ αj) ≤ m(1 + ǫ0) − mǫ0 + nXj=ℓ αj < mαj. mXi=1 ri < mαj, (4.4) (4.5) From (4.5), and since αj ≤ ǫ0 for j = ℓ, ..., n, we have that mǫ0 + nPj=ℓ αj < 0. A contradiction, since αj ≥ 0 for all j. Hence, the above relaxed implementation of First-Fit packs all of the remaining small αj < mǫ0; thus, nPj=ℓ pj max T ≤ C ∗ items and yields a relaxed-packing of the original instance. Lemma 4.4. Let OP T be an optimal solution, and let C = {C 1, ..., C m} be the configuration of large items derived from OP T . Then, the cost of this optimal solution is at least the cost of the solution for C in Step 5 of AID. Proof. C is an optimal configuration, therefore C is also a feasible configuration (since Pj∈C i T ≤ 1). Let ALGC be the solution for C the algorithm generates in Step 5. Assume that Cost (OP T ) < Cost (ALGC). Note that the cost for the large items is the same in both solutions, and therefore the difference between the cost is caused by packing small items. We also note that, in the algorithm, the small items we pay for are those that are omitted from their original bin and transfered to a different one. Since the transition costs are 1, it means that the number of omitted small items in OP T is smaller than in ALGC, or in other words, the number of small items that are packed in their original bin in OP T is greater than their number in ALGC. Therefore, there must exist a bin 1 ≤ i ≤ m for which this holds. Consider the small items packed in bin i in each solution. Denote by q1, ..., qs the sizes of small original items of bin i that are packed in bin i in both solutions, by pA l two distinct sets of small original items of bin i that are packed in ALGC and in OP T , respectively, but not in both. Since the algorithm chooses to omit the largest small items first, the fact it chose to omit pO k means that pO we have l are not smaller than pA k . In particular, let pO l but to keep pA 1 , ..., pA 1 , ..., pO l (cid:9), then k and pO 1 , ..., pO 1 , ..., pO 1 , ..., pO 1 , ..., pA 1 , ..., pA 1 = min(cid:8)pO k(cid:9) . (4.6) pO 1 = min(cid:8)pO 1 , ..., pO l (cid:9) ≥ max(cid:8)pA 1 , ..., pA 32 Since C ∗ max ≤ T , we get that Xj∈C i pj + sXj=1 qj + ℓXj=1 pO j ≤ max C ∗ T ≤ 1 The algorithm chose, in particular, to omit pO 1 , hence Xj∈Ci pj + sXj=1 qj + kXj=1 pA j ≤ 1 + ǫ0 but also Xj∈C i pj + By the above discussion, we also have that Pj∈C i pj + sPj=1 qj +Pk j=1 pA j + pO 1 qj + sXj=1 kXj=1 ≤(4.6) Pj∈C i ≤k<ℓ Pj∈C i ≤(4.6) Pj∈C i ≤(4.7) 1 pj + pj + pj + pA j + pO 1 > 1 + ǫ0. sPj=1 sPj=1 sPj=1 qj + kpO 1 + pO 1 qj + ℓpO 1 qj +Pℓ j=1 pO j (4.7) (4.8) (4.9) From the last inequality, we have a contradiction to (4.9). Hence, we have the statement of the lemma. Lemma 4.5. [EK72] Let G = (V, U, E) be a bipartite graph with V = U = n and, and let c : E → R be a cost function on the edges. A minimum cost perfect matching, i.e. a perfect matching M ⊆ E for which Pe∈M c(e) is minimized, can be found in O(n3) time. Now, we are ready to prove the main theorem. Proof of Theorem 4.1: Let C = C 1, ..., C m be the configuration of large items derived from an optimal solution, OP T . Let ALGC be the packing obtained for C in Step 5 of the algorithm. By Lemma 4.4, we have Cost (ALGC) ≤ Cost (OP T ) . (4.10) Cost(OP T ). Let ALG be the solution the algorithm outputs. Since Cost(ALG) = min{Cost(ALGC) : C is a legal configuration }, we have that Cost(ALG) ≤ Now, it is easy to see that if we transform ALG to the schedule of the job on the machines (by returning to the original processing times), we get a solution of makespan max, the algorithm is a (1 + ǫ0)2-approximation at most (1 + ǫ0)T . Since T ≤ (1 + ǫ0)C ∗ 33 algorithm. We note that (1 + ǫ0)2 = (1 + ǫ yields a (1 + ǫ)-approximation to C ∗ 16 ) ≤ 1 + ǫ, thus the algorithm We conclude that AID is a (1, 1 + ǫ)-reapproximation algorithm for the reoptimization 4)2 = (1 + ǫ max. 2 + ǫ2 problem. Now, we prove that AID runs in polynomial time. • In the first step, we run a PTAS for the new instance I, therefore, this part is ). polynomial in I (but exponential in 1 ǫ0 • Steps 2,3 and 4 are clearly polynomial in I. • For Step 5, we first show that the number of feasible configuration of large rounded items is polynomial in I. Recall that the number of large rounded items in each ǫ0k. Since the rounded sizes of large items can be of at most bin can not exceed j 1 ǫ0k+(cid:24) 1 0(cid:25) ǫ0m different sizes, the number of feasible configurations is at most R =(cid:0)j 1 l 1 (cid:1). (cid:24) 1 0(cid:25) most(cid:18) m + R . Now, for each con- figuration, we construct the bipartite graph in time polynomial in I and by [EK72] we find a perfect minimum cost matching in time O(k3) where k = max(cid:8)m, m′(cid:9), which is polynomial in I. • Packing of the small items in each iteration using First-Fit is also done in time m (cid:19) which is polynomial in m but exponential in 1 There are at most m bins, implying that the number of feasible configurations is at ǫ0 ǫ2 ǫ2 polynomial in I and Step 6 is clearly polynomial in I. 34 4.3 A (1, 1+ǫ)-Reapproximation Algorithm for Makespan Minimization on Uniform Machines We present below a reapproximation algorithm, AU N , for the problem of minimizing the makespan on uniform machines. The algorithm uses a relaxed packing of items in bins, where the items correspond to jobs, and the bins represent the set of machines. Definition 4.4. Given a set of m bins, with positive capacities K1, K2, ..., Km, and a set of items packed in the bins, we say that the packing is ǫ- relaxed, for some ǫ > 0, if for every 1 ≤ i ≤ m, the total size of items assigned to each bin is at most (1 + ǫ)Ki. 4.3.1 Algorithm Our algorithm for reoptimizing the makespan on uniform machines accepts as input the in- stances I0 and I, the initial assignment of jobs to the machines, σ0, and an error parameter ǫ > 0. In the previous section, it was convenient to convert the problem into a bin packing problem where all bins have equal size. We will consider the conversion to a bin packing problem also in the case of scheduling on unrelated machines, only here the bins will have variable sizes. In the generalization of the equal-size bin case to the variable-size case, we come across a major obstacle. The size of the subintervals in which the pieces are partitioned depends on the size of the bins in which the pieces are to be packed. Moreover, the definition of large and small pieces depends on the size of the bin in which the pieces are to be packed. Hochbaum and Shmoys [HS88] presented a PTAS for the problem of makespan minimization on uniform machines. They constructed, in polynomial time, a layered directed graph, with two nodes designated "initial" and "success", such that there exists a path from "initial" to "success" in the graph if and only if there is a schedule with makespan at most 1 + ǫ times the minimal makespan. From this path one can also define the configuration of "medium" and "large" jobs on each machine, and it is guaranteed that the "small" jobs can be scheduled. We add suitable costs to the edges of the layered graph and show that a feasible solution with optimal cost can be obtained by finding the lightest path from "initial" to "success" in the layered graph. It is also guaranteed that if there is a path from "initial" to "success" in the graph, then there is enough space in the bins to add the remaining pieces (e.g., using First-Fit), in the bins on which they are considered small. This way, as before, we can greedily pack the small pieces in their original bin (as long as we do not exceed its capacity), and pay only for packing the rest. Overview of the PTAS of [HS88] Assume that s1 is the highest speed, and represent each machine i as a bin of size si. Normalize the bin sizes by s1. Consider the jobs as items whose sizes are in (0, 1] (by normalizing them by some upper bound on the minimal makespan). Round down piece sizes in (cid:0)ǫk+1, ǫk(cid:3) to the nearest multiple of ǫk+2, for some integer k ≥ 0. For a bin of size si ∈(cid:0)ǫk+1, ǫk(cid:3) define: 35 • Pieces of sizes in (cid:0)ǫk+1, ǫk(cid:3) are large for the bin. • Pieces of sizes in (cid:0)ǫk+2, ǫk+1(cid:3) are medium for the bin. • Pieces of sizes less than or equal to ǫk+2 are small for the bin. For convenience, the interval (cid:0)ǫk+1, ǫk(cid:3) is referred as interval k. For pieces in interval k, a bin is large if it is in interval k, huge if it is in interval k − 1, and enormous if it is in intervals 0, ..., k − 2. A directed layered graph, GL = (VL, EL), is then constructed, in which each node is labeled with a state vector describing the remaining pieces to be packed as large or medium pieces. The graph is grouped into stages, where a stage specifies the large and medium pack of bins in one interval (cid:0)ǫk+1, ǫk(cid:3). Each layer within a stage corresponds to packing a bin in the corresponding interval. Both the bins within the stage and the stages are arranged in order of decreasing bin size. The state vector associated with each node is of the form (L; M; V1, V2, V ), where L and M are vectors, each describing a distribution of pieces in the subintervals of (cid:0)ǫk+1, ǫk(cid:3) and (cid:0)ǫk+2, ǫk+1(cid:3) respectively. There are two nodes designated "initial" and "success", such that "initial" is connected to the initial state vectors of the first stage, and every final state vector of the final stage is connected to "success". A path from "initial" to "success" in GL specifies a packing of the rounded medium and large pieces for every bin. We note that, after the large and medium pack of the bins in interval k, we must allow for the packing of the remaining pieces in interval k that will be packed as small. These pieces must be packed in enormous bins for them, therefore, we need to have sufficient unused capacity in the enormous bins to at least contain the total size of these unpacked pieces. This is represented by the value V1 in the state vector; it records the slack, or unused capacity in the partial packing of the enormous bins with large and medium pieces. For stages corresponding to intervals greater than k, we also need to have the unused capacity in the huge and large bins, and this is the role of V2 and V , respectively. Since we must represent the possible values in some compact way, we consider the sizes of the pieces that will be packed as small pieces into this as-yet-unused capacity. For V1, pieces in interval k are small, and thus all pieces to be packed into this unused capacity have rounded sizes that are multiples of ǫk+2; as a result, it will be sufficient to represent Vl as an integer multiple of ǫk+2. Similarly, V2 and V will be represented as integer multiples of ǫk+3 and ǫk+4, respectively. The following lemmas, due to [HS88], will be useful in analyzing our algorithm. Lemma 4.6. Given ǫ > 0, the layered graph GL has O(2m · n2/ǫ2+3 · 1/ǫ6) nodes and O(2m(n/ǫ2)(2/ǫ2)+3) edges. The number of nodes in each layer, which is the number of state vectors corresponding to packing the bins of that layer, is O(n2/ǫ2 (n/ǫ2)3). Lemma 4.7. For any ǫ > 0, there is a one to one correspondence between paths from "initial" to "success" in the layered graph GL and ǫ-relaxed packings. Lemma 4.8. Given an ǫ-relaxed packing of rounded piece sizes, for some ǫ > 0, restoring the piece sizes to their original size yields a (2ǫ + ǫ2)-relaxed packing of the original pieces. 36 We give below a detailed description of our algorithm, AU N . Let C ∗ max(I) denote the minimum makespan for an instance I. Algorithm 4 AU N (I0,I, σ0) 1. Let ǫ > 0. Use a PTAS for makespan minimization on uniform machines to find T < (1 + ǫ)C ∗ max(I). 2. Let s1 be the largest speed, and assume that s1 sm is bounded from above by some given constant b ≥ 1. Normalize all the processing times by s1 · T , and represent each machine as a bin of capacity si s1 ≤ 1. Consider the jobs now as pieces with sizes in (0, 1]. Denote the new bin sizes by 1 b ≤ sm ≤ sm−1 ≤ ... ≤ s1 = 1, and denote the piece sizes by p1, p2, ..., pn. 3. Round down the piece sizes pj ∈(cid:0)ǫk+1, ǫk(cid:3) to the nearest multiple of ǫk+2. 4. Construct the directed layered graph GL, and define edge costs as follows. Consider the edge ek ℓ connecting a node of the (ℓ − 1)'th layer to a node of the ℓ'th layer in some stage that corresponds to interval k. ek ℓ describes the large and medium pack of k the ℓ'th bin of stage k. Let C0 ℓ be the set of pieces packed in that bin in the initial solution. Fix the cost on that edge to be the number of large and medium pieces that appear in C0 ℓ . All other edges in GL are assigned the cost zero. k ℓ , but are not packed in the bin by ek 5. For every choice of exactly one update arc, at the end of each stage, do: (i.) Find the lightest path from "initial" to "success" in the graph (if one exists). Define the corresponding partial solution consisting of pieces that are packed as large or medium. (ii.) Add the remaining pieces greedily to the enormous bins for them: for each bin i, let S0i be the set of remaining pieces that belong to the bin in the initial solution and that are small for this bin. Start packing the pieces in S0i in bin i, in increasing order of piece sizes, and stop after the total size of packed pieces exceeds for the first time the bin capacity. Pack all the remaining pieces, as small, using First-Fit. 6. Return the solution of minimum cost. 4.3.2 Analysis Theorem 4.9. For any ǫ > 0, Algorithm AU N yields in polynomial time a (1, 1 + ǫ)- reapproximation for R (ΠU N ). We prove the theorem using the next lemmas. 37 Lemma 4.10. Given the partial packing of medium and large pieces (after Step 5(i) in AU N ), packing the remaining pieces greedily as small, in Step 5(ii), incurs the minimal cost for packing these pieces. Proof. For the partial packing of medium and large pieces, let R be the set of the remaining pieces. We show that packing the pieces in R in enormous bins for them, by the greedy algorithm given in Step 5(ii), results in the minimal cost for packing R. The greedy algorithm first packs every bin with its original pieces that are small. It sorts them in non- decreasing order by piece size and packs them to the original bin by this order, until the bin capacity is exceeded for the first time (or all pieces are packed). This way we guarantee that we pack to every bin the maximal number of small pieces that were originally packed in it. Thus, the number of pieces, packed as small, not in their original bin, is minimized. This also implies a minimum packing cost for R. Lemma 4.11. Let OP T be an optimal solution. Then, the cost of OP T is at least the cost of the solution obtained by AU N . Proof. Let C = {C 1, ..., C m} be the configuration of large and medium items derived from OP T . Since C is optimal, in particular, it is a truly feasible configuration of large and medium pieces that also leaves enough slackness for packing the remaining pieces as small, without exceeding the capacity of the bins. Thus, by Lemma 4.7, there is a path from "initial" to "success" in the layered graph, such that C is the large and medium pack derived from it. This path also contains exactly one update arc after each stage. Therefore, our algorithm, in particular, considers this choice of update arcs for which it finds a lightest path in the graph (which clearly exists for this choice). by Lemma 4.10, the cost of the solution output by the algorithm is at most the cost of the lightest path plus the minimal cost of packing all the remaining pieces as small, which is clearly at most the cost of OP T . Lemma 4.12. For any partial solution of large and medium rounded pieces, derived from a path from "initial" to "success" in GL, all the remaining rounded pieces can be packed in enormous bins for them, using the greedy algorithm in Step 5(ii), such that the load on each bin of size si is at most si(1 + ǫ + ǫ3). Proof. As shown in [HS88], the small-pack phase, which is done after every stage, is always successfully completed, since there is an update arc if and only if there is sufficient total slack to accommodate all pieces to be packed as small. Using a similar argument, AU N is able to pack all the remaining small pieces after packing all the large and medium pieces. Consider the rounded pieces packed into a bin of size si, which is in interval k. Focus on the small piece j that, when added to the bin, exhausts the usable slack. Then, piece j is of size less than or equal to ǫk+2, and before piece j was added, the rounded piece sizes did not exceed si + ǫk+4 (recall that the usable slack is rounded up to a multiple of ǫk+4). Hence, the bin contains pieces of total (rounded) size at most si + ǫk+4 + ǫk+2. Therefore, if Bi is the set of pieces packed in bin i, then the sum of the rounded piece sizes in Bi is at most si + ǫk+4 + ǫk+2 which is at most si + ǫsi + ǫ3si = si(1 + ǫ + ǫ3), since si ≥ ǫk+1. 38 Lemma 4.13. The number of different choices for update arcs, one after each stage, is at most O((n2/ǫ2 (n/ǫ2)3)S), where S is the number of stages in the graph. Proof. Between every two stages, there are O(n2/ǫ2 (n/ǫ2)3) update arcs, same as the number of state vectors in each layer (Lemma 4.6). Therefore, the number of possibilities for choosing one arc in each stage is O((n2/ǫ2 (n/ǫ2)3)S). Lemma 4.14. The number of stages S in GL depends only on ǫ and on b. Proof. The number of stages in GL is the number of intervals k that contain at least one bin. Since the smallest bin size satisfies sm ≥ 1 Now, we are ready to prove the main theorem. b , S is at most min{k ∈ N : ǫk+1 < 1 b}. Proof of Theorem 4.9: By Lemma 4.11, taking the best solution among all lightest paths (one for each choice of update arcs), we have a solution whose transition cost is at most the transition cost of an optimal solution. By Lemma 4.12, this solution is also an (ǫ + ǫ3)-relaxed packing of the rounded pieces, and by Lemma 4.8, after inflating the pieces to their original sizes, we get a (2(ǫ + ǫ3) + (ǫ + ǫ3)2)-relaxed packing. Hence, by fixing a suitable initial ǫ, e.g., ǫ = ǫ0/8, we conclude that AU N is a (1, 1 + ǫ0)-reapproximation algorithm for our reoptimization problem. We note that AU N runs in polynomial time. Constructing the graph GL = (VL, EL) can be done in time linear in the graph size, which is VL = O(2m · n2/ǫ2+3 · 1/ǫ6) and EL = O(2m(n/ǫ2)(2/ǫ2)+3), by Lemma 4.6. By Lemma 4.13, the number of different choices of update arcs, is X = O((n2/ǫ2 (n/ǫ2)3)S), where S is the number of stages in the graph. By Lemma 4.14, S depends only on ǫ and b. Therefore, the complexity of running e.g., Dijkstra's algorithm [D59] for finding a lightest path from "initial" to "success" and then greedily packing the small pieces, for every choice of update arcs, is O(X·(Dijkstra(GL)+Greedy(n, m))). Overall, we get that the complexity of the algorithm is O(X · (Dijkstra(GL) + Greedy(n, m))), which is polynomial in the input size. 39 Chapter 5 Conclusions and Future Work 5.1 Summary In this work we studied the fundamental problem of makespan minimization on parallel machines. For the unrelated machines model, we derived an improved bound, which de- pends on the minimum average machine load and the feasibility parameter of the instance. Our bound is strictly smaller than 2, the best known general upper bound, for a natural subclass of instances. We further studied the power of parameterization and presented an FPT algorithm and a parameterized approximation scheme for instances that are known to be hard to approximate within factor 3 2, based on classical complexity theory. Finally, we initiated the study of the reoptimization variants of makespan minimization on identical and uniform machines, and derived approximation ratios that match the best known ratios in these models. 5.2 Future Work Our study leaves open several avenues for future research. Makespan minimization on unrelated machines While reducing the gap between the general lower bound of 3 2 and the upper bound of 2 remains a prominent open problem, it would be interesting to tighten these bounds for other non-trivial subclasses of instances, either by a constant, or by a function of the input parameters. Another interesting direction is to study instances with a wider range of feasibility pa- rameters. In this work, we explored instances having large feasibility parameter. On the other hand, Ebenlendr et al. [EKS08] considered instances in which the feasibility param- eter is at most 2 m . Any results on other, intermediate values of this parameter, would shed more light on its role in obtaining better schedules. Other natural questions are: "Can we obtain better bound for fully-feasible instances, when Topt = Lopt?" "Can we derive a better lower bound for general instances for which Topt = Lopt?" 40 FPT algorithms for scheduling The problem of minimizing the makespan on unre- lated machines is NP-hard even if the number of machines or number of jobs is taken as a parameter [LST90], therefore no FPT algorithm exists with only these choices of parame- ters. In addition, we cannot hope for obtaining an FPT algorithm for graph balancing with the fixed parameter being only the maximum degree of the graph. Indeed, by the hardness proof of [EKS08], the problem is hard to approximate within a factor less than 3 2 even on bounded degree graphs, i.e., when the maximum degree is some constant. The question whether we can find an FPT algorithm for graph balancing with the treewidth being the only parameter remains open. Reoptimization in scheduling We list some of the questions arising from our results. "Can we obtain reapproximation algorithm with the same performance guarantees for gen- eral instances in the uniform machines model?" "Can we extend our results to arbitrary transition costs?". Finally, "Can we improve the running times of our reapproximation schemes, by adjusting the known EPTASs for identical and uniform machines to the reop- timization model?" 41 Bibliography [AA+98] N. Alon, Y. Azar, G. J. Woeginger, and T. Yadid. "Approximation schemes for scheduling on parallel machines." Journal of Scheduling 1.1 (1998): 55-66. [AE+14] F. N. Abu-Khzam, J. Egan, M. R. Fellows, Frances A. Rosamond, and Peter Shaw. "On the Parameterized Complexity of Dynamic Problems with Connectivity Constraints." Combinatorial Optimization and Applications. Springer International Publishing, 2014. 625-636. [B88] H. L. Bodlaender. Dynamic programming on graphs with bounded treewidth. Springer Berlin Heidelberg, 1988. [BF+13] M. A. Bender, M. Farach-Colton, S. Fekete, J. T. Fineman, and S. Gilbert. "Re- allocation problems in scheduling." In Proceedings of the twenty-fifth annual ACM symposium on Parallelism in algorithms and architectures, pp. 271-279. ACM, 2013. [BT14] G. Baram and T. Tamir. "Reoptimization of the minimum total flow-time schedul- ing problem." Sustainable Computing: Informatics and Systems 4.4 (2014): 241-251. [CK+15] D. Chakrabarty, S. Khanna, and S. Li. "On (1, ǫ)-restricted assignment makespan minimization." Proceedings of the Twenty-Sixth Annual ACM-SIAM Symposium on Discrete Algorithms. SIAM, 2015. [DMN12] J. Diaz, C. Munoz-Caro, and A. Nino. "A survey of parallel programming models and tools in the multi and many-core era." Parallel and Distributed Systems, IEEE Transactions on 23.8 (2012): 1369-1386. [D59] Dijkstra, E. W. "A note on two problems in connexion with graphs." Numerische mathematik 1.1 (1959): 269-271. [DF12] R. G. Downey and M. R. Fellows. Parameterized complexity. Springer Science & Business Media, 2012. [EK72] J. Edmonds and R. M. Karp. "Theoretical improvements in algorithmic efficiency for network flow problems." Journal of the ACM (JACM) 19.2 (1972): 248-264. [EKS08] T. Ebenlendr, M. Kr´cal, and J. Sgall. "Graph balancing: a special case of schedul- ing unrelated parallel machines." Proceedings of the nineteenth annual ACM-SIAM 42 symposium on Discrete algorithms. Society for Industrial and Applied Mathematics, 2008. [GJ79] M. R. Garey and D. S. Johnson. "Computers and intractability: a guide to the theory of NP-completeness. 1979." San Francisco, LA: Freeman (1979). [GL+04] M. Gairing, T. Lacking, M. Mavronicolas, and B. Monien. "Computing Nash equilibria for scheduling on restricted parallel links." Proceedings of the thirty-sixth annual ACM symposium on Theory of computing. ACM, 2004. [GMW07] M. Gairing, B. Monien, and A. Woclaw. "A faster combinatorial approximation algorithm for scheduling unrelated parallel machines." Theoretical Computer Science 380.1 (2007): 87-99. [H35] P. Hall. "On representatives of subsets." J. London Math. Soc 10.1 (1935): 26-30. [H96] D. S. Hochbaum. "Various notions of approximations: Good, better, best, and more." Approximation algorithms for NP-hard problems. PWS Publishing Co., 1996. [HS76] E. Horowitz and S. Sahni. "Exact and approximate algorithms for scheduling non- identical processors." Journal of the ACM (JACM) 23.2 (1976): 317-327. [HS88] D. S. Hochbaum and D. B. Shmoys. "A polynomial approximation scheme for scheduling on uniform processors: Using the dual approximation approach." SIAM journal on computing 17.3 (1988): 539-551. [J10] K. Jansen. "An EPTAS for scheduling jobs on uniform processors: using an MILP relaxation with a constant number of integral variables." SIAM Journal on Discrete Mathematics 24.2 (2010): 457-485. [J15] J. Monnot. "A note on the traveling salesman reoptimization problem under vertex insertion." Information Processing Letters 115.3 (2015): 435-438. [JLR15] K. Junosza-Szaniawski, M. Liedloff, and P. Rzazewski. "Fixing Improper Colorings of Graphs." SOFSEM 2015: Theory and Practice of Computer Science. Springer Berlin Heidelberg, 2015. 266-276. [K84] N. Karmarkar. "A new polynomial-time algorithm for linear programming." Pro- ceedings of the sixteenth annual ACM symposium on Theory of computing. ACM, 1984. [LL+12] K. H. Lee, Y. J. Lee, H. Choi, Y. D. Chung, and B. Moon. "Parallel data pro- cessing with MapReduce: a survey." AcM sIGMoD Record 40.4 (2012): 11-20. [LK79] J. K. Lenstra and A. R. Kan. "Computational complexity of discrete optimization problems." Annals of Discrete Mathematics 4 (1979): 121-140. 43 [LST90] J. K. Lenstra, D. B. Shmoys, and ´E. Tardos. "Approximation algorithms for scheduling unrelated parallel machines." Mathematical programming 46.1-3 (1990): 259-271. [M11] D. Marx. "Fixed-parameter tractable scheduling problems." Packing and Scheduling Algorithms for Information and Communication Services (Dagstuhl Seminar 11091). Vol. 1. 2011. [MV80] S. Micali and V. V. Vazirani. "An O(pV E) algoithm for finding maximum matching in general graphs." Foundations of Computer Science, 1980., 21st Annual Symposium on. IEEE, 1980. [MW13] M. Mnich and A. Wiese. "Scheduling Meets Fixed-Parameter Tractability." arXiv preprint arXiv:1311.4021 (2013). [N06] R. Niedermeier. "Invitation to fixed-parameter algorithms." (2006). [P14] D. R. Page. "Approximation Algorithms for Subclasses of the Makespan Problem on Unrelated Parallel Machines with Restricted Processing Times." SOP Transactions on Applied Mathematics, In Press, 2014. [S12] O. Svensson. "Santa claus schedules jobs on unrelated machines." SIAM Journal on Computing 41.5 (2012): 1318-1341. [ST93] D. B. Shmoys and ´E. Tardos. "An approximation algorithm for the generalized assignment problem." Mathematical Programming 62.1-3 (1993): 461-474. [STT12] H. Shachnai, G. Tamir, and T. Tamir. "A theory and algorithms for combinatorial reoptimization." LATIN 2012: Theoretical Informatics. Springer Berlin Heidelberg, 2012. 618-630. [SV05] E. V. Shchepin and N. Vakhania. "An optimal rounding gives a better approxi- mation for scheduling unrelated machines." Operations Research Letters 33.2 (2005): 127-133. [T77] K. Truemper. "On max flows with gains and pure min-cost flows." SIAM Journal on Applied Mathematics 32.2 (1977): 450-456. [V13] V. V. Vazirani. Approximation algorithms. Springer Science & Business Media, 2013. [VKW14] A. Verma, M. Korupolu, and J. Wilkes. "Evaluating job packing in warehouse- scale computing." Cluster Computing (CLUSTER), 2014 IEEE International Confer- ence on. IEEE, 2014. [VMH14] N. Vakhania, J. A. Hernandez, and F. Werner. "Scheduling unrelated machines with two types of jobs." International Journal of Production Research 52.13 (2014): 3793-3801. 44 [VP+15] A. Verma, L. Pedrosa, M. Korupolu, D. Oppenheimer, E. Tune, and J. Wilkes. "Large-scale cluster management at Google with Borg." In Proceedings of the Tenth European Conference on Computer Systems, p. 18. ACM, 2015. [VW14] J. Verschae and A. Wiese. "On the configuration-LP for scheduling on unrelated machines." Journal of Scheduling 17.4 (2014): 371-383. 45
1304.6189
2
1304
2013-10-01T13:32:40
On the parameterized complexity of cutting a few vertices from a graph
[ "cs.DS" ]
We study the parameterized complexity of separating a small set of vertices from a graph by a small vertex-separator. That is, given a graph $G$ and integers $k$, $t$, the task is to find a vertex set $X$ with $|X| \le k$ and $|N(X)| \le t$. We show that - the problem is fixed-parameter tractable (FPT) when parameterized by $t$ but W[1]-hard when parameterized by $k$, and - a terminal variant of the problem, where $X$ must contain a given vertex $s$, is W[1]-hard when parameterized either by $k$ or by $t$ alone, but is FPT when parameterized by $k + t$. We also show that if we consider edge cuts instead of vertex cuts, the terminal variant is NP-hard.
cs.DS
cs
On the parameterized complexity of cutting a few vertices from a graph1,2 Fedor V. Fomin Department of Informatics, University of Bergen, Norway [email protected] Petr A. Golovach Department of Informatics, University of Bergen, Norway [email protected] Janne H. Korhonen Helsinki Institute for Information Technology HIIT, Department of Computer Science, University of Helsinki, Finland [email protected] Abstract. We study the parameterized complexity of separating a small set of vertices from a graph by a small vertex-separator. That is, given a graph G and integers k, t, the task is to find a vertex set X with X ≤ k and N(X) ≤ t. We show that W[1]-hard when parameterized by k, and • the problem is fixed-parameter tractable (FPT) when parameterized by t but • a terminal variant of the problem, where X must contain a given vertex s, is W[1]-hard when parameterized either by k or by t alone, but is FPT when parameterized by k + t. We also show that if we consider edge cuts instead of vertex cuts, the terminal variant is NP-hard. 1This work is supported by the European Research Council (ERC) via grant Rigorous Theory of Preprocessing, reference 267959 (F.F., P.G.) and by the Helsinki Doctoral Programme in Computer Science -- Advanced Computing and Intelligent Systems (J.K.). 2This work has been published as a part of the proceedings of the 38th International Symposium on Mathematical Foundations of Computer Science (MFCS 2013) [11]. The final publication is available at http://link.springer.com/chapter/10.1007%2F978-3-642-40313-2_38. Introduction 1 We investigate two related problems that concern separating a small vertex set from a graph G = (V, E). Specifically, we consider finding a vertex set X of size at most k such that 1. X is separated from the rest of V by a small cut (e.g. finding communities in a social network, cf. [15]), or 2. X is separated from the rest of V by a small cut and contains a specified terminal vertex s (e.g. isolating a dangerous node, cf. [12, 14]). We focus on parameterized complexity of the vertex-cut versions of these problems. Parameterized vertex cuts. Our interest in the vertex-cut version stems from the following parameterized separation problem, studied by Marx [17]. Let N(X) denote the vertex-neighborhood of X. Cutting k Vertices Input: Graph G = (V, E), integers k ≥ 1, t ≥ 0 Parameter 1: k Parameter 2: t Question: Is there a set X ⊆ V such that X = k and N(X) ≤ t? In particular, Marx showed that Cutting k Vertices is W[1]-hard even when parameterized by both k and t. We contrast this result by investigating the parameterized complexity of the two related separation problems with relaxed requirement on the size of the separated set X. Cutting at Most k Vertices Input: Graph G = (V, E), integers k ≥ 1, t ≥ 0 Parameter 1: k Parameter 2: t Question: Is there a non-empty set X ⊆ V such that X ≤ k and N(X) ≤ t? Cutting at Most k Vertices with Terminal Input: Graph G = (V, E), terminal vertex s, integers k ≥ 1, t ≥ 0 Parameter 1: k Parameter 2: t Question: Is there a non-empty set X ⊆ V such that s ∈ X, X ≤ k and N(X) ≤ t? We show that these closely related problems exhibit quite different complexity behaviors. In particular, we show that Cutting at Most k Vertices is fixed- parameter tractable (FPT) when parameterized by the size of the separator t, while we need both k and t as parameters to obtain an FPT algorithm for Cutting at Most k Vertices with Terminal. A full summary of the parameterized complexity of these problems and our results is given in Table 1. The main algorithmic contribution of our paper is the proof that Cutting at most k vertices is FPT when parameterized by t (Theorem 5). To obtain 1 this result, we utilize the concept of important separators introduced by Marx [17]. However, a direct application of important separators -- guess a vertex contained in the separated set, and find a minimal set containing this vertex that can be separated from the remaining graph by at most t vertices -- does not work. Indeed, pursuing this approach would bring us to essentially solving Cutting at most k vertices with terminal, which is W[1]-hard when parameterized by t. Our FPT algorithm is based on new structural results about unique important separators of minimum size separating pairs of vertices. We also observe that it is unlikely that Cutting at most k vertices has a polynomial kernel. Edge cuts. Although our main focus is on vertex cuts, we will also make some remarks on the edge-cut versions of the problems. In particular, the edge-cut versions again exhibit a different kind of complexity behavior. Let ∂(X) denote the edge-boundary of X. Cutting at Most k Vertices by Edge-Cut Input: Graph G = (V, E), integers k ≥ 1, t ≥ 0 Parameter 1: k Parameter 2: t Question: Is there a non-empty set X ⊆ V such that X ≤ k and ∂(X) ≤ t? Cutting k Vertices by Edge-Cut with Terminal Input: Graph G = (V, E), terminal vertex s, integers k ≥ 1, t ≥ 0 Parameter 1: k Parameter 2: t Question: Is there a set X ⊆ V such that s ∈ X, X ≤ k and ∂(X) ≤ t? Results by Watanabe and Nakamura [20] imply that Cutting at most k vertices by edge-cut can be done in polynomial time even when k and t are part of the input; more recently, Armon and Zwick [2] have shown that this also holds in the edge-weighted case. Lokshtanov and Marx [16] have proven that Cutting at most k vertices by edge-cut with terminal is fixed-parameter tractable when parameterized by k or by t; see also [5]. We complete the picture by showing that Cutting at most k vertices by edge-cut with terminal is NP-hard (Theorem 13). The color-coding techniques we employ in Theorem 4 also give a simple algorithm with running time 2k+t+o(k+t) · nO(1). Parameter Cutting k Vertices Cutting ≤ k Vertices k t W[1]-hard, [17] W[1]-hard, Thm 10 W[1]-hard, [17] k and t W[1]-hard, [17] FPT, Thm 5 FPT, Thm 4 Cutting ≤ k Vertices with Terminal W[1]-hard, Thm 10 W[1]-hard, Thm 12 FPT, Thm 4 Table 1: Parameterized complexity of Cutting k Vertices, Cutting at Most k Vertices, and Cutting at Most k Vertices with Terminal. 2 Related edge-cut problems have received attention in the context of approxi- mation algorithms. In contrast to Cutting at most k vertices by edge-cut, finding a minimum-weight edge-cut that separates exactly k vertices is NP-hard. Feige et al. [9] give a PTAS for k = O(log n) and an O(k/ log n)-approximation for k = Ω(log n); Li and Zhang [15] give an O(log n)-approximation. Approximation algorithms have also been given for unbalanced s-t-cuts, where s and t are specified terminal vertices and the task is to find an edge cut (X, V \ X) with s ∈ X and t ∈ V \ S such that (a) X ≤ k and weight of the cut is minimized [12, 15], or (b) weight of the cut is at most w and X is minimized [14]. 2 Basic definitions and preliminaries Graph theory. We follow the conventions of Diestel [7] with graph-theoretic notations. We only consider finite, undirected graphs that do not contain loops or multiple edges. The vertex set of a graph G is denoted by V (G) and the edge set is denoted by E(G), or simply by V and E, respectively. Typically we use n to denote the number of vertices of G and m the number of edges. For a set of vertices U ⊆ V (G), we write G[U] for the subgraph of G induced by U, and G − U for the graph obtained form G by the removal of all the vertices of U, i.e., the subgraph of G induced by V (G) \ U. Similarly, for a set of edges A, the graph obtained from G by the removal of all the edges in A is denoted by G − A. For a vertex v, we denote by NG(v) its (open) neighborhood, that is, the set of vertices which are adjacent to v. The degree of a vertex v is dG(v) = NG(v). For a set of vertices U ⊆ V (G), we write NG(U) = ∪v∈U NG(v) \ U and ∂G(U) = {uv ∈ E(G) u ∈ U, v ∈ V (G) \ U}. We may omit subscripts in these notations if there is no danger of ambiguity. Submodularity. We will make use of the well-known fact that given a graph G, the mapping 2V → Z defined by U 7→ N(U) is submodular. That is, for A, B ⊆ V we have N(A ∩ B) + N(A ∪ B) ≤ N(A) + N(B) . (1) Important separators. Let G be a graph. For disjoint sets X, Y ⊆ V , a vertex set S ⊆ V \ (X ∪ Y ) is a (vertex) (X, Y )-separator if there is no path from X to Y in G − S. An edge (X, Y )-separator A ⊆ E is defined analogously. Note that we do not allow deletion of vertices in X and Y , and thus there are no vertex (X, Y )-separators if X and Y are adjacent. As our main focus is on the vertex-cut problems, all separators are henceforth vertex-separators unless otherwise specified. We will make use of the concept of important separators, introduced by Marx [17]. A vertex v is reachable from a set X ⊆ V if G has a path that joins a vertex of X and v. For any sets S and X ⊆ V \ S, we denote the set of vertices reachable from X in G− S by R(X, S). An (X, Y )-separator S is minimal if no proper subset of S is an (X, Y )-separator. For (X, Y )-separators S and T, we say that T dominates S if T ≤ S and R(X, S) is a proper subset of R(X, T). For singleton sets, we will write x instead of {x} in the notations defined above. 3 Definition 1 ([17]). An (X, Y )-separator S is important if it is minimal and there is no other (X, Y )-separator dominating S. In particular, this definition implies that for any (X, Y )-separator S there exists an important (X, Y )-separator T with T ≤ S and R(X, T) ⊇ R(X, S). If S is not important, then at least one of the aforementioned relations is proper. The algorithmic usefulness of important separators follows from the fact that the number of important separators of size at most t is bounded by t alone, and furthermore, these separators can be listed efficiently. Moreover, minimum-size important separators are unique and can be found in polynomial time. That is, we will make use of the following lemmas. Lemma 2 ([6]). For any disjoint sets X, Y ⊆ V , the number of important (X, Y )- separators of size at most t is at most 4t, and all important (X, Y )-separators of size at most t can be listed in time 4t · nO(1). Lemma 3 ([17]). For any sets X, Y ⊆ V , if there exists an (X, Y )-separator, then there is exactly one important (X, Y )-separator of minimum size. This separator can be found in polynomial time. Parameterized complexity. We will briefly review the basic notions of pa- rameterized complexity, though we refer to the books of Downey and Fellows [8], Flum and Grohe [10], and Niedermeier [19] for a detailed introduction. Parame- terized complexity is a two-dimensional framework for studying the computational complexity of a problem; one dimension is the input size n and another one is a parameter k. A parameterized problem is fixed-parameter tractable (or FPT) if it can be solved in time f(k) · nO(1) for some function f, and in the class XP if it can be solved in time O nf(k)(cid:17) for some function f. (cid:16) Between FPT and XP lies the class W[1]. One of basic assumptions of the parameterized complexity theory is the conjecture that W[1] 6= FPT, and it is thus held to be unlikely that a W[1]-hard problem would be in FPT. For exact definition of W[1], we refer to the books mentioned above. We mention only that Indpendent Set and Clique parameterized by solution size are two fundamental problems that are known to be W[1]-complete. The basic way of showing that a parameterized problem is unlikely to be fixed-parameter tractable is to prove W[1]-hardness. To show that a problem is W[1]-hard, it is enough to give a parameterized reduction from a known W[1]-hard problem. That is, let A, B be parameterized problems. We say that A is (uniformly many-one) FPT-reducible to B if there exist functions f, g : N → N, a constant c ∈ N and an algorithm A that transforms an instance (x, k) of A into an instance (x0, g(k)) of B in time f(k)xc so that (x, k) ∈ A if and only if (x0, g(k)) ∈ B. Cutting problems with parameters k and t. In the remainder of this section, we consider Cutting at most k vertices, Cutting at most k vertices with terminal, and Cutting at most k vertices by edge-cut with terminal with parameters k and t. We first note that if there exists a solution for one of the problems, then there is also a solution in which X is connected; indeed, it suffices to take any maximal connected Y ⊆ X. Furthermore, we note finding a connected set X with X = k and N(X) ≤ t is fixed-parameter tractable with parameters 4 k and t due to a result by Marx [17, Theorem 13], and thus Cutting at most k vertices is also fixed-parameter tractable with parameters k and t. We now give a simple color-coding algorithm [1, 4] for the three problems with parameters k and t, in particular improving upon the running time of the aforementioned algorithm for Cutting at most k vertices. Theorem 4. Cutting at most k vertices, Cutting at most k vertices with terminal, and Cutting at most k vertices by edge-cut with terminal can be solved in time 2k+t · (k + t)O(log(k+t)) · nO(1). Proof. We first consider a 2-colored version of Cutting at most k vertices. That is, we are given a graph G where each vertex is either colored red or blue (this is not required to be a proper coloring), and the task is to find a connected red set X with X ≤ k such that N(X) is blue and N(X) ≤ t. If such a set exists, it can be found in polynomial time by trying all maximal connected red sets. Now let G = (V, E) be a graph. Assume that there is a set X with X ≤ k and N(X) ≤ t; we may assume that X is connected. It suffices to find a coloring of V such that X is colored red and N(X) is colored blue. This can be done by coloring each vertex v either red or blue independently and uniformly at random. Indeed, this gives a desired coloring with probability at least 2−(k+t), which immediately yields a 2k+t·nO(1) time randomized algorithm for Cutting at Most k Vertices. This algorithm can be derandomized in standard fashion using universal sets (compare with Cai et al. [4]). Recall that a (n, ')-universal set is a collection of binary vectors of length n such that for each index subset of size ', each of the 2' possible combinations of values appears in some vector of the set. A construction of Naor et al. [18] gives a (n, ')-universal set of size 2' · 'O(log ') log n that can be listed in linear time. It suffices to try all colorings induced by a (n, k + t)-universal set obtained trough this construction. The given algorithm works for Cutting at most k vertices with terminal with obvious modifications. That is, given a coloring, we simply check if the terminal s is red and its connected red component is a solution. This also works for Cutting at most k vertices by edge-cut with terminal, as we have N(X) ≤ ∂(X). 3 Cutting at most k vertices parameterized by t In this section we show that Cutting at Most k Vertices is fixed-parameter tractable when parameterized by the size of the separator t only. Specifically, we will prove the following theorem. Theorem 5. Cutting at Most k Vertices can be solved in time 4t · nO(1). The remainder of this section consists of the proof of Theorem 5. Note that we 4 t < k < n − t. Indeed, if k ≤ ct for a fixed constant c < 1, then we may assume 3 can apply the algorithm of Theorem 4 to solve Cutting at Most k Vertices in time 4tnO(1). On the other hand, if k ≥ n − t, then any vertex set X of size k is a solution, as N(X) ≤ n − k ≤ t. We start by guessing a vertex u ∈ V that belongs to a solution set X if one exists; specifically, we can try all choices of u. We cannot expect to necessarily 5 find a solution X that contains the chosen vertex u, even if the guess is correct, as the terminal variant is W[1]-hard. We will nonetheless try; turns out that the only thing that can prevent us from finding a solution containing u is that we find a solution not containing u. With u fixed, we compute for each v ∈ V \ ({u} ∪ N(u)) the unique minimum important (u, v)-separator Sv. This can be done in polynomial time by Lemma 3. Let V0 be set of those v with Sv ≤ t, and denote R(v) = R(v, Sv). Finally, let X be a set family consisting of those R(v) for v ∈ V0 that are inclusion-minimal, i.e., if R(v) ∈ X, then there is no w ∈ V0 such that R(w) (cid:40) R(v). Note that we can compute the sets V0, R(v) and X in polynomial time. There are now three possible cases that may occur. 1. If V0 = ∅, we conclude that we have no solution containing u. 2. If there is v ∈ V0 such that R(v) ≤ k, then X = R(v) gives a solution, and we stop and return a YES-answer. 3. Otherwise, X is non-empty and for all sets A ∈ X we have A > k. We only have to consider the last case, as otherwise we are done. We will show that in that case, the sets A ∈ X can be used to find a solution X containing u if one exists. For this, we need the following structural results about the sets R(v). Lemma 6. For any v, w ∈ V0, if w ∈ R(v) then R(w) ⊆ R(v). Proof. Let A = R(v) and B = R(w). Since Sv = N(A) is a (u, v)-separator of minimum size, we must have N(A ∪ B) ≥ N(A). By (1), we have N(A ∩ B) ≤ N(A) + N(B) − N(A ∪ B) ≤ N(B) . Because w ∈ A, the set N(A ∩ B) is a (u, w)-separator. Thus, if B 6= A ∩ B, then N(A∩B) is a (u, w)-separator that witnesses that Sw is not an important separator. But this is not possible by the definition of Sw, so we have B = A ∩ B ⊆ A. Lemma 7. Any distinct A, B ∈ X are disjoint. Proof. Assume that A, B ∈ X are distinct and intersect. Then there is v ∈ A ∩ B. Since v ∈ A, the set N(A) is a (u, v)-separator of size at most t, and v ∈ V0. Recall that X contains inclusion-minimal sets R(w) for w ∈ V0. But by Lemma 6, R(v) is a proper subset of both A and B, which is not possible by the definition of X. Now assume that the input graph G has a solution for Cutting at Most k Vertices containing u. In particular, then there is an inclusion-minimal set X ⊆ V with u ∈ X satisfying X ≤ k and N(X) ≤ t. Let us fix one such set X. Lemma 8. For all A ∈ X, the set A is either contained in X ∪ N(X) or does not intersect it. Proof. Suppose that there is a set A ∈ X that intersects both X ∪ N(X) and its complement. Let Y = V \ (X ∪ N(X)). Now let v ∈ A ∩ Y . By Lemma 6, we have R(v) = A. If N(A ∪ Y ) > N(Y ) then it follows from (1) that N(A ∩ Y ) ≤ N(A) + N(Y ) − N(A ∪ Y ) < N(A) . 6 However, this would imply that N(A ∩ Y ) is a (u, v)-separator smaller than Sv = N(A). Thus, we have N(A ∪ Y ) ≤ N(Y ). But X0 = X \ (A ∪ Y ∪ N(A ∪ Y )) is a proper subset of X; furthermore, any vertex of N(X0) that is not in N(A ∪ Y ) is also in N(X) \ N(Y ), so we have N(X0) ≤ N(X) ≤ t. This is in contradiction with the minimality of X. Lemma 9. Let Z be the union of all A ∈ X that do not intersect X ∪ N(X). Then Z 6= ∅ and there is an important (Z, u)-separator S of size at most t such that R(u, S) + S ≤ k + t. Proof. Let S = N(X). Consider an arbitrary v ∈ V \ (X ∪ S); such vertex exists, since k + t < n. Since S separates v from u, the set R(v) is well-defined. Suppose now that R(v) is not contained in R(v, S). Let B = R(u, Sv). Since Sv is a minimum-size (u, v)-separator we have N(B) = N(R(v)). But N(X ∪ B) also separates u and v, so we have N(X ∪ B) ≥ N(R(v)) = N(B). By (1), we have N(X ∩ B) ≤ N(X) + N(B) − N(X ∪ B) ≤ N(X) ≤ t . But since R(v) is not contained R(v, S), it follows that X ∩ B is a proper subset of X, which contradicts the minimality of X. Thus we have R(v) ⊆ R(v, S). It follows that R(v, S) contains a set A ∈ X, which implies that Z 6= ∅ and v ∈ R(A, S) ⊆ R(Z, S). Furthermore, since v ∈ V \ (X ∪ S) was chosen arbitrarily, we have that R(Z, S) = V \ (X ∪ S). If S is an important (Z, u)-separator, we are done. Otherwise, there is an important (Z, u)-separator T with T ≤ S and R(Z, S) ⊆ R(Z, T). But then we have T ≤ t, and R(u, T) ∪ T ⊆ X ∪ S, that is, R(u, T) ∪ T ≤ k + t. (cid:16)2 + 1 (cid:17) 3 Recall now that we may assume A > k for all A ∈ X. Furthermore, we have k and the sets A ∈ X are disjoint by Lemma 7. X ∪ N(X) ≤ k + t < Thus, at most two sets A ∈ X fit inside X ∪ N(X) by Lemma 8. This means that if we let Z be the union of all A ∈ X that do not intersect X ∪ N(X), then as we have already computed X, we can guess Z by trying all O(n2) possible choices. Assume now that X is a minimal solution containing u and our guess for Z is correct. We enumerate all important (Z, u)-separators of size at most t. We will find by Lemma 9 an important (Z, u)-separator S such that S ≤ t and R(u, S) + S ≤ k + t. If R(u, S) ≤ k, we have found a solution. Otherwise, we delete a set S0 of R(u, S) − k elements from R(u, S) to obtain a solution X0. To see that this suffices, observe that N(X0) ⊆ S0 ∪ S. Therefore, N(X0) ≤ S0 +S = R(u, S)− k +S ≤ t. As all important (Z, u)-separators can be listed in time 4t · nO(1) by Lemma 2, the proof of Theorem 5 is complete. 4 Hardness results We start this section by complementing Theorem 5, as we show that Cutting at Most k Vertices is NP-complete and W[1]-hard when parameterized by k. We also show that same holds for Cutting at Most k Vertices with Terminal. Note that both of these problems are in XP when parameterized by k, as they can be solved by checking all vertex subsets of size at most k. 7 2 2 ! k 2 ! k 2 Theorem 10. Cutting at Most k Vertices and Cutting at Most k Vertices with Terminal are NP-complete and W[1]-hard with the parameter k. Proof. We prove the W[1]-hardness claim for Cutting at Most k Vertices by a reduction from Clique. Recall that this W[1]-complete (see [8]) problem asks for a graph G and a positive integer k where k is a parameter, whether G contains a clique of size k. Let (G, k) be an instance of Clique, n = V (G) and m = E(G); we construct an instance (G0, k0, t) of Cutting at Most k Vertices as follows. Let HV be a clique of size n3 and identify n vertices of HV with the vertices of G. Let HE be a clique of size m and identify the vertices of HE with the edges of G. Finally, add an edge between vertex v of HV and vertex e of HE whenever v is incident to e in G. Set k0 =(cid:0)k (cid:1) and t = k + m −(cid:0)k corresponding to edges of K we have X =(cid:0)k Furthermore, we have that X =(cid:0)k X ≤(cid:0)k−1 (cid:1). The construction is shown in (cid:1) and NG0(X) = k + m −(cid:0)k (cid:1). On (cid:1). Indeed, assume that this is not the case. If (cid:1) − k, then, since X has at least one neighbor in HV , we have If G has a k-clique K, then for the set X that consists of the vertices e of HE the other hand, suppose that there is a set of vertices X of G0 such that X ≤ k0 and NG0(X) ≤ t. First, we note that X cannot contain any vertices of HV , as then NG0(X) would be too large. Thus, the set X consists of vertices of HE. (cid:1) =(cid:0)k Fig. 1 a). 2 2 2 2 2 2 NG0(X) ≥ m − X + 1 ≥ m − and if(cid:0)k−1 (cid:1) < X <(cid:0)k (cid:1), then X has at least k neighbors in HV , and thus + k + 1 , 2 NG0(X) ≥ m − X + k > m − + k . vertices of HV that are in NG0(X) form a k-clique in G. Thus, we have that X only consist of vertices of HE and X =(cid:0)k clique HE and let k0 =(cid:0)k The W[1]-hardness proof for Cutting at Most k Vertices with Terminal uses the same arguments. The only difference is that we add the terminal s in the (cid:1) + 1 (see Fig. 1 b). (cid:1). But then the Because Clique is well known to be NP-complete [13] and our parameterized reductions are polynomial in k, it immediately follows that Cutting at Most k Vertices and Cutting at Most k Vertices with Terminal are NP- complete. 2 2 While we have an FPT-algorithm for Cutting at Most k Vertices when parameterized by k and t or by t only, it is unlikely that the problem has a polynomial kernel (we refer to [8, 10, 19] for the formal definitions of kernels). Let G be a graph with s connected components G1, . . . , Gs, and let k ≥ 1, t ≥ 0 be integers. Now (G, k, t) is a YES-instance of Cutting at Most k Vertices if and only if (Gi, k, t) is a YES-instance for some i ∈ {1, . . . , s}, because it can always be assumed that a solution is connected. By the results of Bodlaender et al. [3], this together with Theorem 10 implies the following. Theorem 11. Cutting at Most k Vertices has no polynomial kernel when parameterized either by k and t or by t only, unless NP ⊆ coNP/poly. 8 HE e = uv HE s e = uv u v u v n HV a) n HV b) E V e = uv u v s c) Figure 1: Constructions of G0 in the proofs of Theorems 10 and 12. We will next show that when we consider the size of the separator t as the sole parameter, adding a terminal makes the problem harder. Indeed, while Cutting at Most k Vertices with Terminal with parameter t is trivially in XP, we next show that it is also W[1]-hard, in contrast to Theorem 5. Theorem 12. Cutting at Most k Vertices with Terminal is W[1]-hard with parameter t. Proof. Again, we prove the claim by a reduction from Clique. Let (G, k) be a clique instance, n = V (G) and m = E(G); we create an instance (G0, k0, t, s) of Cutting at Most k Vertices with Terminal. The graph G0 is constructed as follows. Create a new vertex s as the terminal. For each vertex and edge of G, add a corresponding vertex to G0, and add an edge between vertices v and e in G0 when e is incident to v in G. Finally, connect all vertices of G0 corresponding to vertices of G to the terminal s, and set k0 = n − k + m −(cid:0)k K leaves exactly n− k + m−(cid:0)k (cid:1) + 1 and t = k. The (cid:1)+1 vertices in the connected component of G0 − K construction is shown in Fig. 1 c). 2 If G has a k-clique K, then cutting away the k vertices of G0 corresponding to containing s. Now suppose that X ⊆ V (G0) is a set with s ∈ X such that X ≤ k0 and NG0(X) ≤ t, and let S = NG0(X). Note that the elements of V (G0) that do not belong to X are exactly the elements v ∈ S and the vertices corresponding to e = uv such that u, v ∈ S and e /∈ S; denote this latter set of elements by E0. Since X is a solution, we have S + E0 ≥(cid:0)k (cid:1) + k, and thus E0 ≥(cid:0)k (cid:1). But this 2 is only possible if S is a k-clique in G. 2 2 Finally, we show that Cutting at most k vertices by edge-cut with terminal is also NP-hard. Theorem 13. Cutting at most k vertices by edge-cut with terminal is NP-complete. Proof. We give a reduction from the Clique problem. It is known that this problem is NP-complete for regular graphs [13]. Let (G, k) be an instance of Clique, with G being a d-regular n-vertex graph. We create an instance (G0, k0, t, s) of Cutting k Vertices by Edge-Cut with Terminal as follows. The graph G0 is constructed by starting from a base clique of size dn. One vertex in this base clique is selected as the terminal s, and we additionally distinguish d special vertices. For each v ∈ V (G), we add a new vertex to G0, and add an edge between this vertex and all of the d distinguished vertices of the base clique. For each edge e = uv in G, we also add a new vertex to G0, and add edges between this vertex and 9 vertices corresponding to u and v. The construction is shown in Fig. 2. We set k0 = dn + k +(cid:0)k (cid:1) and t = dn − 2(cid:0)k (cid:1). 2 2 e = uv E u v V d s base clique Figure 2: Construction of G0 in the proof of Theorem 13. 2 we have X = dn + k +(cid:0)k 2 (cid:1)(cid:1) = dn − 2(cid:0)k (cid:1). (cid:1) and ∂(X) = (dn − dk) +(cid:0)dk − 2(cid:0)k If G has a k-clique K, then selecting as X the base clique and all vertices of G0 corresponding to vertices and edges of K gives a solution to (G0, k0, t, s), as 2 For the other direction, consider any solution X to instance (G0, k0, t, s). The set X must contain the whole base clique, as otherwise there are at least dn − 1 edges inside the base clique that belong to ∂(X). Let V0 ⊆ V and E0 ⊆ E be the subsets of X corresponding to vertices and edges of G, respectively. If E0 = ∅, then ∂(X) = dn. Assume now that V0 is fixed, and consider how adding vertices to E0 changes ∂(X). For each edge e ∈ E(G), if neither of the endpoints of e is in V0, then adding e to E0 adds 2 to ∂(X). If exactly one of the endpoints of e is in V0, then adding e to E0 does not change ∂(X). Finally, if both of the endpoints of e are in V0, then adding e to E0 reduces ∂(X) by 2. Thus, in order to have ∂(X) ≤ dn − 2(cid:0)k edges in E0 are in V0. But due to the requirement that X ≤ dn + k +(cid:0)k (cid:1) and the endpoints of all (cid:1), this is (cid:1), we must have that E0 ≥(cid:0)k 2 only possible if V0 induces a clique in G. 2 2 Acknowledgements. We thank the anonymous reviewers for pointing out the related work of Lokshtanov and Marx. References [1] Noga Alon, Raphael Yuster, and Uri Zwick, Color-coding, Journal of the ACM 42 (1995), no. 4, 844 -- 856. [2] Amitai Armon and Uri Zwick, Multicriteria global minimum cuts, Algorithmica 46 (2006), no. 1, 15 -- 26. [3] Hans L. Bodlaender, Rodney G. Downey, Michael R. Fellows, and Danny Hermelin, On problems without polynomial kernels, Journal of Computer and System Sciences 75 (2009), no. 8, 423 -- 434. [4] L. Cai, S. Chan, and S. Chan, Random separation: A new method for solving fixed-cardinality optimization problems, Parameterized and Exact Computa- tion (2006), 239 -- 250. [5] Yixin Cao, A note on small cuts for a terminal, arXiv:1306.2578 [cs.DS], 2013. 10 [6] J. Chen, Y. Liu, and S. Lu, An improved parameterized algorithm for the minimum node multiway cut problem, Algorithmica 55 (2009), no. 1, 1 -- 13. [7] Reinhard Diestel, Graph theory, fourth ed., Springer, 2010. [8] Rodney G. Downey and Michael R. Fellows, Parameterized complexity, Springer-Verlag, 1999. [9] Uriel Feige, Robert Krauthgamer, and Kobbi Nissim, On cutting a few vertices from a graph, Discrete Applied Mathematics 127 (2003), no. 3, 643 -- 649. [10] Jörg Flum and Martin Grohe, Parameterized complexity theory, Springer- Verlag, 2006. [11] Fedor V. Fomin, Petr A. Golovach, and Janne H. Korhonen, On the parame- terized complexity of cutting a few vertices from a graph, 38th International Symposium on Mathematical Foundations of Computer Science (MFCS 2013), Springer, 2013, pp. 421 -- 432. [12] Giulia Galbiati, Approximating minimum cut with bounded size, 5th Interna- tional Network Optimization Conference (INOC 2011), 2011, pp. 210 -- 215. [13] Michael R. Garey and David S. Johnson, Computers and intractability: a guide to the theory of np-completeness, W. H. Freeman and Co., San Francisco, Calif., 1979. [14] Ara Hayrapetyan, David Kempe, Martin Pál, and Zoya Svitkina, Unbalanced graph cuts, 13th Annual European Symposium on Algorithms (ESA 2005), 2005, pp. 191 -- 202. [15] Angsheng Li and Peng Zhang, Unbalanced graph partitioning, Theory of Computing Systems (2012), 1 -- 13. [16] Daniel Lokshtanov and Dániel Marx, Clustering with local restrictions, Infor- mation and Computation 222 (2013), 278 -- 292. [17] D. Marx, Parameterized graph separation problems, Theoretical Computer Science 351 (2006), no. 3, 394 -- 406. [18] M. Naor, L.J. Schulman, and A. Srinivasan, Splitters and near-optimal deran- domization, 36th Annual Symposium on Foundations of Computer Science (FOCS 1995), IEEE, 1995, pp. 182 -- 191. [19] Rolf Niedermeier, Invitation to fixed-parameter algorithms, Oxford University Press, 2006. [20] Toshimasa Watanabe and Akira Nakamura, Edge-connectivity augmentation problems, Journal of Computer and System Sciences 35 (1987), no. 1, 96 -- 144. 11