# Balanced Black and White Coloring Problem on knights chessboards

Graph anticoloring problem is partial coloring problem where the main feature is the opposite rule of the graph coloring problem, i.e., if two vertices are adjacent, their assigned colors must be the same or at least one of them is uncolored. In the same way, Berge in 1972 proposed the problem of placing b black queens and w white queens on a n × n chessboard such that no two queens of different color can attack to each other, the complexity of this problem remains open. In this work we deal with the knight piece under the balance property, since this special case is the most difficult for brute force algorithms.

## Authors

• 1 publication
• 1 publication
• 2 publications
10/09/2021

### Linear-time algorithm for vertex 2-coloring without monochromatic triangles on planar graphs

In the problem of 2-coloring without monochromatic triangles (or triangl...
08/05/2021

### Fairer Chess: A Reversal of Two Opening Moves in Chess Creates Balance Between White and Black

Unlike tic-tac-toe or checkers, in which optimal play leads to a draw, i...
09/15/2020

### Scatterplot Selection Applying a Graph Coloring Problem

Scatterplot selection is an effective approach to represent essential po...
12/28/2018

### Tight Bounds on the Minimum Size of a Dynamic Monopoly

Assume that you are given a graph G=(V,E) with an initial coloring, wher...
08/30/2017

### The Painter's Problem: covering a grid with colored connected polygons

Motivated by a new way of visualizing hypergraphs, we study the followin...
11/24/2010

### Distributed Graph Coloring: An Approach Based on the Calling Behavior of Japanese Tree Frogs

Graph coloring, also known as vertex coloring, considers the problem of ...
##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

Graph Anticoloring Problem (GAC) was introduced by Hansen et al. [2] as a generalization of Vertex Separator Problem (VSP), proposed by Lipton and Tarjan in [3] to solve the Problem 1.3 for rooks.

###### Problem 1.1 (Gac)

Input: A graph , a set of positive integers .
Output: 1 If it is possible coloring vertices of with color such that, for each , and have the same color or at least one is uncolored.

If we limit , we have the Black and White Coloring Problem(BWC), defined as follows:

###### Problem 1.2 (Bwc)

Input: A graph , and two positive integers.
Output: 1 If it is possible coloring vertices of with color black and vertices of with color white, such that, for each , and have the same color or at least one is uncolored.

###### Problem 1.3 (BWC-chessboards)

Input: A chessboard, black chessboard pieces and white chessboard pieces, with the same piece type.
Output: 1 If it is possible to place black pieces and white pieces in chessboard, without attacking each other, 0 otherwise.

Lipton and Tarjan solved the Problem 1.3 with rook pieces. Hansen et al. showed that the BWC is NP-complete for general graphs in [2]. Until this work the complexity of Problem 1.3 with knights and queens remained open.

In our case we deal with knight chessboards. One way to answer the Problem 1.3 with knights is to fix the value of and maximize the size of white knights set. This problem is named Optimization Black and White Coloring Problem for Knights (OBWC-Knights). In [1] Berend et al., proposed the Problem 1.4 over chessboards with each original piece of chess since this special case is the most difficult one. They solved the cases of kings, bishops and towers, as well they proposed two conjectures, one for the case of knights and one for queens. In this work we give a proof for knights case on chessboards.

###### Problem 1.4 (Balanced BWC)

Input: A chessboard and a type of piece of chess.
Output: , of the specified piece.

## 2 The knights case

First, we model the Problem 1.4 as an integer program. Given a chessboard. For each position on the board we define the following variables:

 xij={1if a black piece is placed on i,j0otherwise
 yij={1if a white piece is placed on i,j0otherwise
 maxθ (1)
 θ≤b (2)
 θ≤w (3)
 m∑i=1n∑j=1xij=b (4)
 m∑i=1n∑j=1yij=w (5)
 ∑s,r∈N[i,j]ysr≤|N[i,j]|(1−xij) ∀ (i,j) (6)
 xi,j,yi,j∈{0,1}  b,w∈Z+ (7)

where and are the number of blacks and whites respectively and is the closed neighborhood of the vertex . Now we define as the optimal result of the integer program (17) for the piece . In [1] Berend et al. proposed the Conjecture 1 for the value of . The left side of Figure 1 shows the case of even where Conjecture 1

it is fulfilled and the right side shows the case of odd

where the conjecture is not fulfilled.

###### Conjecture 1

Given a chessboard. The value of is:

 ϕknight(n,n)=⎧⎪ ⎪ ⎪ ⎪⎨⎪ ⎪ ⎪ ⎪⎩n(n−22) if n is evenn(n−32)+n−12 if n is odd

Conjecture 1 is not true because it is not fulfilled when is odd and we have a better solution for this case, also the value of does not work with values of . In the Figure 2 we show a solution for chessboard with 10 black and 10 white knights. The solution provided by the Conjecture 1 gives . The difference is because on chessboard there are some positions that can not be reached by knights in one movement.

We can proof a general version of this conjecture in Theorem 1.

###### Theorem 1

Given a chessboard, , , . The value of is:

 ϕknight(m,n)=⎧⎪ ⎪ ⎪ ⎪⎨⎪ ⎪ ⎪ ⎪⎩m(n−22) if n is even m(n−32)+⌈m2⌉ otherwise

The values of and are and respectively and their proofs are trivial. In the case of the value of have a few pathological cases for small values of and the rest can be solved by the application of Theorem 1 with a few modifications. For example in the case of , must be greater equal than 7 due with there are zones that knights can not reach in one movement.

###### Proposition 1

Given a chessboard with , then

 ϕknight(3,n)=⎧⎪ ⎪ ⎪ ⎪⎨⎪ ⎪ ⎪ ⎪⎩3(n−22)  if  n is even3(n−32)+2  if  n is odd

Proof: We assume that , now we proof that the optimal number of white knights is . By the size of exists at least one column on the chessboard with 2 black knights and this column is the one that more black knights have, the other columns have at most 2 black knights, by this fact the number of non empty columns are at least and the number of uncolored vertices is at least . If we fill all the two knights columns we have at least or uncolored vertices depending on the parity of , decreases the number of non-empty columns and the number of uncolored vertices. We have a solution with exactly or uncolored vertices depending on parity of . We calculate the optimal number of white knights with the following equation.

 wopt=3n−b−uncolored=3n−3(n−22)−6=3(n−22) in the even case.

Which is the same number of uncolored vertices as in our solution. The odd case is similar. To verify is the greatest value that is necessary a conclusion like the Theorem 1 shown in the section 3.1.

For the proof of Theorem 1 we use plenty of lemmas, which some of them are easy to verify and their proofs will be omitted.

### 2.1 Auxiliary Lemmas

###### Definition 1

A full column (row) is a column (row) with a black knight on each of its vertices.

###### Definition 2

An empty column (row) is a column (row) with all of their uncolored vertices.

###### Definition 3

An empty vertex is a position on chessboard that should not have a knight.

###### Definition 4

A vertex is covered by a black knight if is uncolored and can be reached by in one movement.

###### Lemma 1

A full column (row) covers completely the columns and for any i. e. columns and can not be white.

###### Definition 5

An almost full column (row) is a column (row) with 1 or 2 uncolored vertices.

###### Lemma 2

An almost full column (row) covers at least vertices in columns and ( in the case of rows).

Proof: The proof of this lemma uses the fact that each vertex in columns and is covered twice by the knights of column except for the topmost and bottommost vertices of column , which are covered only one time. Now if we remove two blacks from column we can uncover up to 4 vertices in columns and .

Let be the number of vertices that must be uncolored in a coloring .

###### Definition 6

A block is a set of columns (rows) with no intermediate empty columns (rows).

###### Definition 7

An empty block is a set of contiguous empty columns (rows).

###### Lemma 3

Given a coloring with black knigths, there is a coloring , which is obtained by permutation of its rows (or columns) such that only all full rows and almost full rows (or columns) are in a single block and .

Proof: Without loss of generality. Suppose we have a coloring with all full and almost full columns in two blocks. The columns in the first block are labeled as and columns in second block as , with . The left side of first block has at least covered vertices. The right side of the same block has at least covered vertices. The right side of the first block and the left side of the second block may share covered vertices. If the second block is placed next to the first one some potential white vertices between first and second blocks may become uncolored. In the worst case we loss only 4 potential white vertices but release columns and , then .

###### Lemma 4

If a coloring has at least one almost full row (column) and we move a black knight to the uncolored vertex in the almost full column , the new coloring satisfy .

Proof: There are two cases in this proof:

• If the almost full column has a black knight in column or . Due to Lemma 2 in columns and we must have at least uncolored vertices. On the other hand the isolated black knight could share uncolored vertices with almost full column in its left side but has at least uncolored vertices in column or . Therefore, the new coloring has the same number of uncolored vertices or less.

• If the isolated black knight is on the column or is similar to previous case. If the black knight is in column, the isolated black knight has more uncolored vertices. Therefore, if we fills the almost full column with the isolated black knight, the new coloring is better.

Let the number of black knights on the column (row) .

###### Definition 8

A compact column (row) is a non empty column (row) with its black knights in rows (columns) .

###### Lemma 5

Given a coloring with black knights. There is a coloring obtained by compacting the all non empty columns and satisfy .

Proof: We only proof the case where is even. We suppose that the coloring does not have full or almost full columns because in this case is trivial because of the Lemmas 3 and 4. On the other hand, we choose the column with more black knights, this column must have more than black knights because the size of . If there was no column with at least that number of knights would have non-empty columns. In this case the coloring could have more uncolored vertices since .

Now by choosing the column with more black knights, this column produces in the left side at least uncolored vertices and in the right side , Therefore . If we compact the columns like in the Figure 3 the number of uncolored vertices does not increase and .

###### Definition 9

A compact coloring is a coloring where all its columns are compact.

###### Lemma 6

Given a compact coloring with black knights. There is a compact coloring such that all non empty columns are in descending order and satisfy .

Proof: Given a compact coloring with black knights. Now we can choose the largest for . This produces . If we put the biggest column on the leftmost of block like in the Figure 4, the number of uncolored vertices in new coloring is , therefore .

###### Lemma 7

Given a compact and ordered coloring with black knights. there is a coloring obtained by filling all non empty columns, such that where is the column with more black knights and is the last non-empty column in new coloring . The new coloring satisfy .

Proof: Without loss of generality we can place the column with more black knights in the first column of chessboard, by Lemma 6 we can place all non-empty columns in descending order and we have at least .

Expanding

 N(C)≥2b1+(b2+b3+…+bk−2)−(b4+b5+…+bk−1+bk)−b2−b3+bk−1+bk=2b1.

By filling and completing all columns such that , like in the Figure 5. The differences , for all , in coloring . Some of that differences are strictly positive. The new coloring has at least the same number of uncolored vertices .

###### Lemma 8 (Berend, et al.)

Given a coloring with black knights, if has full empty columns (rows), we can put all the full empty columns (rows) next to non empty columns (rows) in a single empty block. New coloring satisfy .

###### Lemma 9

Given a coloring with black knights. It exists a coloring with at least one full column such that .

Proof: By the application of Lemmas 3, 4, 5, 6 and 7 a solution is built with a block with where and are the column and the row with more black knights. Now . If we fill at least one column the number of uncolored vertices remains equal or decreases until exactly , therefore the new coloring has uncolored vertices and .

###### Lemma 10

Given a coloring with at least one full column then or .

Proof: In this case there are two possibilities like in the Figure 6. Let the last non empty column on chessboard and the number of black knights in that column.

• Case 1: Columns and has at least uncolored vertices.

• Case 2: Columns and has at least uncolored vertices.

The second case is only possible when and are odd. Due to the Lemma 8 it is possible to put the column next to a full column and satisfy . Column has uncolored vertices, column has at least uncolored vertices and column has uncolored vertices. In total . In the second case the column has uncolored vertices, in column has uncolored vertices and column has at least uncolored vertices, in total , for this particular case then .

###### Lemma 11

Given a coloring with black knights. It satisfies or .

Proof: Due to the Lemma 9 and the size of is possible to build a solution with at least one full column. By the Lemma 10 and the parity of chessboard, that solution has at least or uncolored vertices.

### 2.2 Minimum uncolored set

We propose a solution with a thigh lower bound in the number of uncolored vertices like in Table 1 and Figure 7.

## 3 The value of ϕknight(m,n)

Now we are enabled to write a formula for the optimal number of white knights under the condition that the number of black knights is the same as in the Theorem 1.

 wopt=mn−(b=ϕknight(m,n))−{2mCases 1,2% ,32m−1Case 4 (8)

### 3.1 Conclusion of proof of the Theorem 1

In this section we only show case 1. The proof is similar for other cases. We can calculate the optimal number of white knights since our solution is a thigh lower bound in the number of uncolored vertices.

 wopt=mn−m(n−22)−2m=m(n−22)

By definition of balanced BWC we need since . We also need the greatest value of all minimum values. We increase the value of by units. If is not optimal, the value of will be increased. Let the optimal number of whites with black knights with .

 wkopt=mn−m(n−22)−k−2m=m(n−22)−k

now

 min(b+k,wkopt)=wkopt

and

 max(b,wkopt)=b

## 4 Conclusions and future work

The balanced BWC problem with knights and queens remained unsolved until this work. We shown a proof of a generalization of the Conjecture proposed by Berend et al. for knight case, also we shown that the second part of the conjecture is not fulfilled and we have provided a better solution in this case. The next step is a proof of not balanced case and what happens in the case of toroidal chessboards. In the case of queens the problem remains open.

## References

• Berend et al. [2008] D. Berend, E. Korach, and S. Zucker. Anticoloring of a family of grid graphs. Discrete Optimization, 5(3):647–662, 2008.
• Hansen et al. [1997] P. Hansen, A. Hertz, and N. Quinodoz. Splitting trees. Discrete Mathematics, 165:403–419, 1997.
• Lipton and Tarjan [1979] R. J. Lipton and R. E. Tarjan. A separator theorem for planar graphs. SIAM Journal on Applied Mathematics, 36(2):177–189, 1979.