Anticoloring for Toroidal Grids Shira Zucker BenGurion University
Anticoloring for Toroidal Grids Shira Zucker Ben-Gurion University of the Negev Advisors: Prof. Daniel Berend Prof. Ephraim Korach 1
The Problem w Anticoloring of a graph: A coloring of some of the vertices in which no two adjacent vertices are colored in distinct colors. w Input: A graph G, positive integers B 1, …, Bk. w Output: Yes – if there exists an anticoloring of G such that Bj vertices are colored in color j, j=1, …, k. No – otherwise. 2
Black and White Coloring (BWC) w Example: w. The Anticoloring Problem is NP-complete, even for two colors. 3
BWC problem w We usually refer to the optimization version of the BWC problem. w We are given a graph G and a positive integer B, and have to color B of the vertices in black, so that there will remain as many vertices as possible which are non-adjacent to any of the B vertices (These vertices are to be colored in white). w W - the maximum possible number of such vertices. 4
History w Hansen, Hertz and Quinodoz proved that the BWC problem is NP-complete. w They also gave an O(n 3 ) algorithm for trees. w Kobler, Korach and Hertz gave a polynomial algorithm for partial k-trees with fixed k (bounded tree width). 5
Berge’s Problem: Queens w Berge suggested a special instance of the problem: w Given positive integers n and B, place B black and W white queens on an n × n chessboard, so that no black queen and white queen attack each other, and with W as large as possible. w The complexity of the queens problem is still open. 6
The Rooks Problem w Yahalom investigated an analogous problem to that suggested by Berge, using rooks instead of queens. w She gave a sub-linear algorithm to this problem. w For special cases, in which the ratio between the sides of the board is an integer or close to an integer, she derived an explicit formula for the optimal solution. 7
The Kings Problem w Problem: Given positive integers m, n and B, place B black and W white kings on an m × n toroidal chessboard, so that no black king and white king attack each other, and with W as large as possible. 8
The kings problem – Cont. Remember that we are talking of a toroidal board. 9
Definitions w A black-white coloring (BWC) of a graph G is a function C: V {black, white, uncolored} such that there is no edge between a black and a white vertex. w Notice: C is uniquely determined by the set of vertices colored in black. 10
Definitions – Cont. w Completely full row (column): A row (column) all of whose vertices are black. w Almost completely full row (column): A row (column) all of whose vertices but one are black. w The rows of the toroidal board are enumerated by 1, 2, …, n. w The columns are enumerated by 1, 2, …, m (m ≥ n). 11
Definitions – Cont. w N(C) – the number of uncolored vertices of a coloring C. w Notice: The problem of maximizing W is equivalent to the problem of minimizing N(C). 12
Theorem – Part 1 An optimal solution may be constructed, depending on the size of B, as follows: : Let Color in black the set 13
Theorem – Part 2 : Let Color in black the set 14
Theorem – Part 3 : Let Color in black the set 15
Before we prove theorem… w In order to prove theorem, we will use several auxiliary lemmas. w The lemmas indicate changes which can be performed in order to achieve a better coloring C’, i. e. , with N(C’) ≤ N(C). w The idea: In order to prove the optimality of C, it is enough to consider only the “good candidates” exist. Those candidates are to be found by the following lemmas. 16
Lemma 1 w Given any coloring C, there exists a coloring C’, which is obtained from C by a permutation of rows (resp. columns), such that all completely and almost completely full rows (resp. columns) are placed in a single block and N(C’) ≤ N(C). 17
Lemma 1 – Example 18
Lemma 2 w Given any coloring C with an almost completely full row (resp. column), by replacing the uncolored vertex at that row (resp. column) with any black vertex, we get a new coloring C’ with N(C’) ≤ N(C). 19
Lemma 2 - Proof w There is only one vertex which may become uncolored. On the other hand, the original uncolored vertex which became black, reduced the number of uncolored vertices by 1. Hence, N(C’) = N(C) or N(C’) = N(C) – 1. 20
Lemma 3 w For any coloring C, if row k contains bk black vertices and row k+1 contains bk+1 black vertices, where max{bk+1, 1}≤ bk≤ m-2, then row k+1 contains at least bk –bk+1+2 uncolored vertices. 21
Lemma 4 w Suppose that a coloring contains black vertices, and that rows n-f+1, …, n are completely full, where f ≤ n-2, but no other rows are such. Let r 1 and r 2 be the rows with the minimal numbers of black vertices where, say, br ≤ br. Then br ≤ m-f-2 -d and br ≤ m-f 2+d for some d ≥ 0. 1 2 22
Lemma 4 - Explanation 1 ≤ m-f-2 2 ≤ m-f-2 n = m = 10 f=2 B = 39 ≤ 62 23
Lemma 5 w If a coloring C with contains a completely full column, then N(C) ≥ 2 n. w The idea of the proof: If each row contains at most m-2 black vertices, then it contains at least 2 uncolored vertices, and altogether we have at least 2 n. Otherwise… 24
Lemma 6 w If a coloring C with contains an almost completely full column, then N(C) ≥ 2 n. w The idea of the proof: Replace the uncolored vertex of an almost completely full column with any black vertex from another column. 25
Lemma 7 w If a coloring C with contains a completely or an almost completely full row, then N(C) ≥ 2 n. 26
Lemma 7 - Proof w If C contains a completely or an almost completely full column, then, according to Lemmas 5 and 6, N(C) ≥ 2 n, and we are done. w Otherwise, C contains no completely or almost completely full column. Since C contains a completely or an almost completely full row, each column of C contains at least two uncolored vertices. Therefore, N(C) ≥ 2 m ≥ 2 n. 27
Lemma 7 – Proof – Cont. 28
Corrollary 8 w If a coloring C with contains less than 2 n uncolored vertices, then each of its non-empty rows and columns contains at least two uncolored vertices. 29
Lemma 9 w If a coloring C with contains no three adjacent empty columns (or rows), then N(C) ≥ 2 n. 30
Lemma 9 - Proof w If C contains a completely or an almost completely full column, then, by Lemmas 5 and 6, N(C) ≥ 2 n and we are done. w Assume, therefore, that C contains no completely or almost completely full column. 31
Lemma 9 – Example Two adjacent empty columns 32
Lemma 9 – Proof – Cont. w If C contains no three adjacent empty columns, then each empty column is adjacent to a non-empty column and therefore, contains at least three uncolored vertices. w According to Corollary 8, each non-empty column contains at least two uncolored vertices. w Denote by x the number of non-empty columns in C. w We get that N(C) ≥ 2 x + 3(m-x) ≥ 2 m ≥ 2 n. 33
Lemma 10 w Suppose a coloring C contains three empty columns (rows, resp. ), of which two are adjacent, say columns j, m-1, m (rows i, n-1, n, resp. ). The coloring C’, obtained from C by moving columns j + 1, j +2, … , m-2 (rows i+1, i+2, …, n-2 resp. ) one place to the left (up, resp. ), and column j immediately to their right (row i immediately under them, resp. ), satisfies N(C’) ≤ N(C). 34
Lemma 10 – Cont. 35
Lemma 11 Three kinds of changes in a coloring C, which do not increase N(C). 36
Lemma 12 w If a coloring C contains exactly c non-empty columns, which are all adjacent, and exactly r non-empty rows, which are also adjacent, where 1≤ c≤ m-2 and 1≤ r≤ n-2, then N(C) ≥ 2 c+2 r+4. 37
Lemma 12 Sketch of the proof We build C’ with K rectangles of sizes ci × ri. ∑ ci ≥ c ∑ ri ≥ r 38
Conclusion of the Proof for Small B w Consider. w C 0 – the square configuration of theorem. w Suppose there exists a coloring C with N(C) < N(C 0) (and with the same B). w N(C 0) =. w Therefore, according to Lemmas 5, 6 and 7, C does not contain any completely or almost completely full column or row. 39
Small B – Cont. w According to Lemma 9, C contains at least 3 adjacent empty columns and at least 3 adjacent empty rows. w By Lemma 10, we can combine all empty columns and rows into one block, thus get a c × r rectangle, where c ≤ m-3, r ≤ n-3, and each row and column contains at least one black vertex. 40
Small B – Cont. w By Lemma 12, we have N(C) ≥ 2 c+2 r+4. w Since cr ≥ B, we get which contradicts our assumption. 41
The idea of the Proof for Intermediate B w Consider. w Most lemmas we used in the proof for small B were of the type: if…. then N(C) ≥ 2 n. w Here we use the same lemmas, in a similar way, but with N(C) ≥ 2 n + “something”, where “something” is equal to 0, 1 or 2. w The proof is more complicated and divided into some parts. 42
Proposition w N(B) – the minimal possible number of uncolored vertices for B black vertices in a graph G. w Proposition: Given a graph G=(V, E) and a number 0 ≤ B ≤ |V|, we have N(|V|-B-N(B)) ≤ N(B). 43
Conclusion of the Proof for Large B w Consider. w C 0 – the co-square configuration of theorem. w Suppose there exists a coloring C with N(C) < N(C 0) (and with the same B). w N(C 0) =. Denote B’: =mn-B-N(B). w 0 ≤ B’ ≤ mn-B <. w By the proposition, N(B’) ≤ N(B). 44
Large B – Cont. w Assume first that We showed that for those B', N(B') ≥ 2 n. w Now, 45
Large B – Cont. w Therefore, and we have a contradiction. 46
Large B – Cont. If then we compare N(B) to N(B’) and get to a contradiction by using the same principle as before, this time with the ‘square configuration’. 47
Union of Components w Input: A graph G=(V, E) where and. A number 1 ≤ B ≤ |V| and an optimal anticoloring Ck for each connected component Gk with 1 ≤ b ≤ B black vertices. w Output: An optimal anticoloring C For G with B black vertices. 48
Union of Components – Cont. w N(G, B) - the minimal number of uncolored vertices of a graph G with B black vertices. w Our algorithm use a dynamic programming. 49
Basic Algorithm for finding N(G, B) union(G, B) for l=2 to n by l l*2 for i=1 to n-l+1 by i j i+l-1 i+l for b=0 to B for bb=0 to b q m[i, k, bb]+m[k+1, j, b-bb] if q<m[i, j, b] then m[i, j, b] q 50
Complexity of union(G, B) 2 w O(B n), where 1 ≤ B, n ≤ |V|. w Notice: For a constant B, the algorithm is linear. 51
Improving the Algorithm w If B ≥ √ (log n), then before calling our algorithm, we sort the components of G by their size. w The complexity of familiar Sort Algorithms is O(nlog n). w The advantage of sorting the components is that, in case where B is greater than the size of some of the connected components, finding a solution for two 2 small components will cost less than B. (In this case, the cost will be the product of the components size. ) 52
Algorithm for finding an optimal Anticoloring color(B, i, j, num, m[][][]) if j>i for b=0 to B for bb=0 to b if m[i, k, bb]+m[k+1, j, b-bb]=num color(bb, i, k, m[i, k, bb], m) color(B-bb, k+1, j, m[k+1, j, b-bb], m) Where num is equal to N(G, B) that we already have. 53
- Slides: 53