A Grover search-based algorithm for the list coloring problem

Graph coloring is a computationally difficult problem, and currently the best known classical algorithm for $k$-coloring of graphs on $n$ vertices has runtimes $\Omega(2^n)$ for $k\ge 5$. The list coloring problem asks the following more general question: given a list of available colors for each vertex in a graph, does it admit a proper coloring? We propose a quantum algorithm based on Grover search to quadratically speed up exhaustive search. Our algorithm loses in complexity to classical ones in specific restricted cases, but improves exhaustive search for cases where the lists and graphs considered are arbitrary in nature.


I. INTRODUCTION
G RAPH coloring problems provide for a rich family of NP-complete problems in theoretical computer science. While exhaustive search is believed to be the fastest classical approach for several NP-complete problems including satisfiability and hitting-set [8], there are much better classical algorithms using dynamic programming, inclusionexclusion and other structural approaches for problems such as graph coloring [4], [10], [18], the traveling salesman problem [13], [24], set cover [15] etc. Several authors have obtained quantum speedup on these classical algorithms [2], [30], [33]; however, all of these algorithms have the limitation that they cannot be easily generalized to the list coloring problem.
Given a finite graph G = (V, E), a proper coloring of G is a function χ : V → N such that for every edge uv ∈ E, χ(u) = χ(v). The list coloring problem tries to determine a proper coloring χ of a graph G = (V, E), given a list L v of available colors for each vertex v. In other words, it is forced that χ(v) ∈ L v . When L v = {1, 2, . . . , k} for every vertex v this reduces to the well-studied k-coloring problem. We propose a simple Grover search-based approach to obtain a quadratic speedup on exhaustive search for the list coloring problem.
Grover's algorithm [12] is known to speed up unstructured search quadratically using the technique of amplitude amplification. In its simplest form, to find some marked elements from a list of N = 2 n entries, the algorithm starts with a uniform quantum superposition of all 2 n basis states of an n-qubit register. It then amplifies the amplitudes of the searched state and reduces those of the other states, such that a measurement of the n qubits leads to one of the searched states with high probability.
In [39], a qutrit-based approach has been used to demonstrate the cost-efficiency of ternary quantum logic; however, their main algorithm is not realizable right now on NISQ devices. The algorithm of [33] has the same issue as it requires quantum RAM which has not been realized at this moment. On the other hand, the authors of [32] and [31] demonstrate a quantum algorithm solving the k-coloring problem on NISQ devices, comparing the efficiency of their algorithm against the reduction of 3-SAT to 3-coloring approach of Hu et. al. [14].
All of these algorithms use an oracle design which uses binary comparators, and provide solutions where almost all binary strings have positive probabilities of being selected, including those that do not represent valid colorings. Our approach circumvents this problem via a modified initialization and diffusion operator that restricts the evolution of the VOLUME 4, 2016 1 arXiv:2108.09061v2 [quant-ph] 3 Mar 2022 quantum algorithm to the only v∈Lv |L v | plausible states. Note that this is the total number of valid colorings when the underlying graph is empty. We achieve this via the restricted version of Grover search [11], [12].
Proposition 1 (Restricted Grover search). Let S ⊆ {1, 2, . . . , 2 n − 1}, and suppose S S is a set of marked states. Let O be an oracle that marks these states and requires a ancillas. Then, there is a quantum circuit on n+a+1 qubits which makes O( 2 n /|S |) queries, which when measured, gives one of the marked states with high probability. Further, states outside S are never measured.
Additionally, we use an oracle design different from those in [32], [39], and give a classical algorithm in Section 3 that can reduce the complexity of this oracle in several special cases (such as for the 3-coloring or 4-coloring problems). As a corollary of Proposition 1, our main theorem provides an algorithm for the list coloring problem.
Theorem 2 (Quantum list coloring algorithm). Given a graph G = (V, E) on n vertices and m edges and lists of available colors This paper is organized as follows. In Section II, we describe Grover's algorithm and a gate-level implementation. Section III is devoted to tackling the list coloring problem, and proves Theorem 2. In Section IV, we run experiments on classical simulators as well as real quantum machines, and compare the outcomes. We discuss applications and provide concluding remarks in Section V.

II. GROVER'S ALGORITHM
In this section, we provide a concise exposition on Grover search. The main idea behind Grover search is to amplify the amplitudes of some number of marked states (states which are being searched for), and consequentially decrease that of unmarked states. Grover's Algorithm requires three different operators: Initialization, Oracle, and Diffusion. Below we present two formulations of the algorithm:

A. UNRESTRICTED SEARCH SPACE
When searching for a marked state among the full search space S = {0, 1} n , the initialization step of the algorithm creates a uniform superposition of all the possible states of an n-qubit system. This is achieved via appending Hadamard gates on each qubit: |i n .
Here we abuse notation and write |i n to denote the state corresponding to an n-digit binary representation of i. Next, Grover's Algorithm requires an oracle O that, given a uniform superposition of all 2 n possible states, can change the sign of the marked states. Let S ⊆ {0, 1, . . . 2 n − 1} be a set of marked states. The Oracle O then switches the signs of the states in S , i.e.
The circuit implementation of the oracle O usually is the most difficult (and computationally expensive) part of the algorithm, and one of the most basic implementations requires the usage of phase kickback [7]. The final component of Grover's Algorithm is the diffusion operator D, which can be thought of as a reflection around the vector |0 n . As an operator, we have D is usually implemented using phase kickback in the same fashion as the oracle O.
Grover's algorithm requires repeated usage of the operator G = H ⊗n DH ⊗n O which has the net effect of reflecting around |+ n , amplifying the amplitudes of marked states and decreases those of other states. Measuring the state G r H ⊗n |0 n (r ≥ 1) gives one of the marked states with high probability, and this probability is maximum when r = π 4 2 n /|S | . Since |S | is not known in general, the r is either randomly selected [5], [9], or is estimated using quantum counting algorithms [1], [26].
See Figure

Init
Grover Operator FIGURE II.1: An example Grover search implementation. In this standard circuit implementation of Grover search, the initialization is achieved by the Hadamard operator H ⊗3 . Phase kickback from the fourth qubit initialized to the state |− is used to negate the amplitudes of |010 and |011 . Finally, diffusion is achieved via another phase kickback from the same qubit.

B. RESTRICTED SEARCH SPACE
Let us now consider a search space S {0, 1} n . In this case, the algorithm is designed to only evolve over the states of S, and this is achieved via an initialization operator A such that And the Grover operator is changed to a reflection around A|0 n instead of |+ n : The usage of ADA † instead of H ⊗n DH ⊗n makes sure that the evolution of the quantum states remains in the subspace spanned by S instead of the entire space {0, 1} n , and this leads to probability distribution of the measured outcomes being supported on the state S. The only detail missing in this formulation is the construction of the initialization operator A. As we shall see in Section 3, for graph coloring problems (and most applications in general), A can be represented as a block matrix and can be implemented in time linear in the number of qubits.
We make a remark here that the graph coloring algorithm of [32] uses the unrestricted formulation of Grover's algorithm, but modifies the oracle to discard states that represent invalid colorings. On the other hand, they do not modify their diffusion operator, leading to states outside the search space having positive probabilities of being measured.

III. QUANTUM LIST COLORING ALGORITHM
Our goal in this section is to prove Theorem 2. For the remainder of this section, assume that G = (V, E) is an arbitrary graph with |V | = n, |E| = m. Further, for every vertex v, let L v denote the list of admissible colors for vertex v. Then the i'th admissible color of the vertex v is denoted as As our algorithm is based on Grover search, we shall discuss the four basic steps of the algorithm: circuit setup, initialization, oracle and diffusion, each in their respective subsections.

A. SETUP AND QUBIT LABELS
Our algorithm design requires three different qubit registers: • A vertex register to keep track of vertex colors. For each vertex v, we require the usage of log 2 |L v | qubits to represent each color in L v . Let us denote j v := log 2 |L v | , and let the qubits corresponding to vertex v ∈ V be labeled by q 1 v , . . . , q jv v . • An edge register consisting of m qubits, one corresponding to each edge. Let q uv denote the qubit corresponding to an edge uv ∈ E. • A single qubit ancilla register, used for phase kickback in Grover's algorithm. Let q * denote this ancilla. The total number of qubits required is v∈V j v + m + 1. Now we take a closer look at our list coloring algorithm.

B. INITIALIZATION
For each v ∈ V , we initialize qubits q 1 v , . . . , q jv v to a uniform |i . This can be achieved via a unitary operator U v such that |i .
We shall replace any one entry |i with It can be seen that Span(B) = Span(B ). We can now consider B as an ordered basis with its first entry as χ v , and apply the Gram-Schmidt process to turn B into an orthonormal basis B [29]. Note that as The transpose of the coefficients of the vectors in B constitutes a change of basis operator that maps |0 to χ v , and this is how one can construct the matrix for U v . It can then be implemented with quantum gates using the results of [23], [27], [37] for example.
For the sake of clarity of the above procedure, let us consider an example with j v = 2 and Hence, in this case, we get Observe that by construction, U v |0 = U v 1 0 0 0 =

C. ORACLE
Traditionally for the graph coloring problem, each vertex color is represented using the same number of qubits, and binary comparator circuits [39] are used to make sure that the two colors corresponding to two adjacent vertices are different. While this approach is very efficient for the k-coloring problem where every vertex has the same set of admissible colors, the list coloring problem may sometimes require a large number of qubits. In fact, the total number of qubits required for implementing a comparator-based oracle would VOLUME 4, 2016 be n · max v∈V log 2 max L v + m + 1, which can be much higher than our proposed oracle when the j v 's are not all equal.
In short, for every edge uv ∈ E, we shall encode all possible colorings in L u × L v via flipping the amplitudes of the states corresponding to valid colorings We propose a classical O(|L u | 2 |L v | 2 )-time algorithm to construct an efficient oracle O u,v for flipping these amplitudes. In short, O u,v should have the following net effect: Given a string s of length and a subset J = {j 1 , j 2 , . . . , j r } ⊆ {1, 2, . . . , } we use s J to denote the substring s j1 s j2 . . . s jr . F 2 denotes the finite field of two elements. Our algorithm for implementing O u,v (Algorithm 1) makes use of a subroutine called oracleReduction that can significantly simplify the complexity and the number of controlled not operations required in many cases.
Algorithm 1: Oracle O u,v for marking valid colorings.
1 Let W = oracleReduction(L u , L v ); 2 Create a circuit C with quantum wires q 1 , . . . , q ju+jv+1 ; 3 for every pair (J, s) in W do 4 Add a multicontrolled NOT gate to C with controls on wires {q j : j ∈ J, s j = 1}, anticontrols on wires {q j : j ∈ J, s j = 0} and target q ju+jv+1 .

return C
We shall now demonstrate the correctness of Algorithm 1.
Theorem 3. Algorithm 1 gives a circuit C satisfying (III.2). Further, assuming that the cost of implementing a kcontrolled NOT operation is k (refer to Remark 4), the cost of C is the smallest among all circuits that can be made using only controlled NOT operations onto the phase flip qubit.
Proof. It is sufficient to verify the action of C on the states |i 1 |i 2 |− , where i 1 < |L u | and i 2 < |L v |. Notice that a single controlled NOT gate corresponding to a pair (J, s) in C Function oracleReduction(L u , L v ) Input : Sets L u , L v . Output: A set of pairs W . | * · · · * s 1 j1'th * · · · * s 2 j2'th · · · · · · ··· · · · s k j k 'th * · · · * Thus, after application of all the controlled NOT gates, only states which appeared in an odd number of (J, s)-pairs in W will survive, and those appearing an even number of times will not have their amplitudes flipped.
Let us now fix a string t = t 1 t 2 · · · t ju+jv , where t 1 · · · t ju ∈ L u and t ju+1 · · · t ju+jv ∈ L v , and analyze the function oracleReduction closely.
We now have all the ingredients required to implement our full oracle, which is presented as Algorithm 2 below. Apply Oracle O u,v on qubits q 1 u , . . . , q ju u , q 1 v , . . . , q jv v , q uv of C; 3 Apply a controlled NOT operation with controls q * and target q * ; 4 for every edge uv ∈ E do 5 Apply Oracle O u,v on qubits q 1 u , . . . , q ju u , q 1 v , . . . , q jv v , q uv to de-entangle the vertex register of C; 6 return C

D. DIFFUSION
Our diffusion operator is very straightforward, and is a direct application of the restricted search space diffusion mentioned in section 2.2. Let A be the initialization operator we implemented in (III.1), then a diffusion is achieved by ADA † , where D = 2|0 0| − I can be implemented by a controlled NOT with anticontrols on each of the vertex qubits and target the phase flip ancilla.
Refer to Figure III.1 for an illustration of the full list coloring algorithm.

Initialization
Grover Operator H Z FIGURE III.1: Outline of our list coloring circuit for a single Grover iteration.

IV. RESULTS
We implement our list coloring algorithm in python 3.8 using blueqat-sdk. In order to gauge the efficiency of our result, we run experiments for the 3 and 4-coloring problems used in [32] on the the Amazon Statevector simulator.
The initialization operator U v can be written as the following circuit: Each Toffoli gate can be decomposed into two-qubit gates using the standard decomposition: To implement a cccx gate, we use a clean ancilla qubit to reduce circuit depth as demonstrated below: Finally, we are able to run our circuit on the Amazon Statevector Simulator after decomposing into these elementary single and two-qubit operations. Our resulting histogram for one Grover iteration is shown in Figure IV It is seen that states in the set A = {|000110 , |001001 , |011000 , |011000 , |100001 , |100100 } are all massively amplified. Each state of A represents a valid 3-coloring of K 3 . Let B = {|00 , |01 , |10 } ⊗3 . The statevector at the end of our algorithm can be calculated theoretically, and we present the probability density function over the 6-qubit states in Table 1. In particular, each state in A has a probability p A of 0.165066 to be measured, and states containing |11 as a color have probability 0 of being observed. Our algorithm has a single-shot accuracy of p A · |A| ≈ 0.9904.   In this case, the result of a statevector computation after one Grover iteration is shown in  The result of our experiment can also be seen to follow this distribution. We take [32] as the state-of-the-art result for the k-coloring problem. We compare the performance of our algorithm with theirs for k = 3. Figure IV.3 depicts the empirical probability distribution obtained via implementing their algorithm for one Grover rotation and running on the Amazon Statevector simulator. We observe that our algorithm has much higher probability of selecting a correct state (around 0.9904), whereas their method has an empirical success rate of 0.5965 for 2000 shots.

C. COMPARISON WITH PREVIOUS WORK: 3-COLORING K3
Finally, we compare the gate count of their circuit versus ours for the 3-coloring K 3 problem for one Grover iteration in Table 3  The code we used for this comparison is available at the following GitHub repository: https://github.com/Potla1995/ Grover-ListColoring.

D. EXPERIMENTS ON NISQ DEVICES AND LIMITATIONS
We also ran our circuits on the IonQ physical device. However, reasonable results were not obtained. There might be several possible reasons behind this, such as: 1) cx is not a gate natively implemented on the IonQ processor. Although its fully connected topology is ideal for the circuits we construct, controlled operations need to be expressed in terms of Mølmer-Sørensen gates [25], which makes them expensive. 2) Our circuit has a depth of 30 when expressed in terms of the elementary gates (including cx). This makes the circuit much more susceptible to errors from noise and decoherence. Although we can implement and run our algorithm on quantum devices currently available, the results suggest that devices with lesser intrinsic noise are needed for practical use of our algorithm. These limitations suggest that while our algorithm is designed for running on NISQ devices, the circuits generated by it are too complex, giving unusable results due to the intrinsic noise in the currently available quantum devices. In any case, classical computers can brute-force the list coloring problem for the small-sized graphs that can be currently encoded on an NISQ device using our encoding scheme.

V. APPLICATIONS AND CONCLUDING REMARKS
The list coloring problem is ubiquitous in real life, as it not only generalizes an already well-appearing problem of graph coloring (scheduling, satisfiability etc.), but is also applicable to several other scenarios, such as: • Wireless network Allocation [38]: In a wireless network, each radio is allocated special frequencies which it can connect to. Suppose that radios in close proximity cannot operate on the same frequency due to interference. The problem of which radio is connected to which network frequency can be modeled as a listcoloring problem in the following graph: let the radios be represented by vertices, and add an edge between two radios if they are in close proximity of each other. The lists for each vertex will be the set of available frequencies for its corresponding radio. • Register Allocation: In compiler optimization, register allocation is the process of assigning a large number of target program variables (n) onto a small number of CPU registers (k), which reduces to a k-coloring problem on an n-vertex graph. • Sudoku: We can represent every cell in a sudoku problem with a vertex, and join two vertices with an edge if they are in same row or same column or same block. Given x already filled cells, we can formulate the sudoku problem as a list-coloring problem on 81 − x vertices and at most 9 colors.
We proposed a Grover search-based quantum algorithm that achieves quadratic speedup in query complexity compared to a classical brute force search, and also proposed a classical algorithm that can simplify the oracle design for several special instances of the list coloring problem. We demonstrate the efficiency of our method in comparison with previous work by running our algorithm on the Amazon statevector simulator for the 3 and 4-coloring problems.
Unfortunately, the list coloring problem is difficult to solve both classically and using quantum algorithms, as for generic lists with no known structure, brute force seems to be the only way to attack the problem. As our algorithm is basically a brute force quantum search with some optimizations in the oracle, it is expected to perform better in general cases where the structure of the lists are unknown. However, the existence of clever hybrid algorithms exploiting specific structures for known lists cannot be ignored, and is a very promising future direction.
Finally, we note that one can obtain an improvement on our algorithm by just changing a given list coloring problem to a reduced problem. For example, if G = (V, E) has a vertex v with |L v | = 1, we can color v first and remove its color from each L u such that uv ∈ E, and iterate until all lists have at least two colors.

ACKNOWLEDGMENTS
Part of this work was completed during a summer internship at Elyah Co. in 2020. The author is grateful to Sydney Andrews, Ryūtarō Nagai and Goutham Rajendran for several helpful discussions and comments; Yūichirō Minato and Salman Al Jimeely for encouragement and support; and the anonymous reviewers whose insightful comments and suggestions helped drastically improve the quality of the manuscript. VOLUME 4, 2016