Solving The General Planar Graph Coloring Problem Using Grover's Algorithm
Solving The General Planar Graph Coloring Problem Using Grover's Algorithm
ISSN No:-2456-2165
Abstract: In this paper, we discuss the structure and area, the number of workers, total electricity production, as
implementations of the planar graph coloring problem well as the medium of transmission. We can optimize bus
(PGCP). We briefly look at well-known classical routing based on distance and traffic mobilization for
algorithms used to solve the PGCP but primarily focus deterministic time frames. We can also allocate network
on the quantum computational angle. Grover’s search is bandwidth in a way that meets transmission requirements
a well-known quantum algorithm that offers a quadratic with the least interference and maximizes network
advantage relative to its classical counterparts. efficiency.
Traditionally, this algorithm is used for search and
sorting; in this paper, we inspect its application to the The aforementioned issues, based on the problem
PGCP and build a corresponding quantum circuit. domains and requirements, fall under resource allocation
While we take a specific case of specialists in Nepalese and effective scheduling. For a general resource allocation
hospitals and optimize their placements, the approach problem, a set of resources is to be allocated to different
we have shown in this paper has wide implications for specifications. Different constraints are then defined which
efficiently solving a huge range of optimization problems adds objectivity to the problem. Additional constraints can
in health, transport, and so on. be defined to maximize the output function based on the
problems. Likewise, as a scheduling problem goes, a set of
I. INTRODUCTION works to be scheduled for a given time based on work-
specific and time-specific parameters can be determined.
Mathematical and computational methods of problem-
solving have grown exponentially over the past century, For our paper, the problem we shall be focusing on is
providing efficient and effective solutions to various to allocate specialist doctors to different hospitals in the
problems. From the classic brute force and manual Kathmandu Valley such that no doctor of similar expertise
calculations, these methods have evolved to yield faster lands in the same or even adjacent hospitals at a given
calculations with efficient algorithms. Mathematical period of time. The hospitals have been chosen based on
algorithms have been integrated into different fields of accessibility, proximity, clinical metrics, and resources. This
human endeavors, such as finance, health, agriculture, sort of problem with adjacency in terms of resource
education, and so on. The applications are open to allocation and scheduling can be modeled using graph
exploration in many endeavours. The development of coloring.
problem-oriented computational algorithms dates back to
the mid-20th century (Knuth, 1977). Researchers including Various classical algorithms have been developed to
Turing (1936), Dantzig (1951), Hoare (1961), Haigh (1993), address the graph coloring problem. However, we have
Copeland (2004), Belvos (2013), Montanaro (2016), Childs opted for the use of the quantum algorithm “Grover’s
et. al. (2018) have reported compelling algorithms ranging algorithm” to solve the problem. After mapping the
from logic, linear functions, universal computation to information of hospitals and specialists in the graph coloring
optimizations. With the advancement of quantum problem, we apply Grover’s algorithm which, through re
mechanics, quantum computing algorithms have also been peated iterations, gives us the most effective solution. The
intensively used in the fields of optimization, cryptography sections to follow cover the details of mapping a graph
and cryptoanalysis. These quantum algorithms offer a coloring problem using different classical algorithms as well
speedup in calculation due to carrying out multiple as implementing Grover’s algorithm.
calculations simultaneously.
Problem Introduction
Taking Nepal as a sample location to map out dif Leading Nepali news portals have often reported
ferent real life scenarios in terms of mathematical and problems in health services due to the unavailability of
computational models for efficient problem-solving, a special doctors in rural Nepal. A fairly recent account of the
number of areas can be considered. We can map out the threatened future of Nepal’s health sector due to a lack of
location of disaster-prone areas and based on the distance superspecialist doctors has been reported (OnlineKhabar
between the major necessities, allocate the appropriate English News, 2023). According to the Nepal Medical
resources. We Can effectively plan hydropower plant Council (NMC), there are 10,080 specialist doctors as of
schedul ing, based on the energy consumption of a certain January 2023. The specialist doctors have not been
Based on the above graph, we can know the ad jacent Graph coloring, just like its name, is a way of coloring
nodes. Let E = (0,1), (0,5), (0,6), (0,7), (1,2), (1,6),(2,3), vertices of the graph such that no two adjacent vertices share
(2,6), (3,4), (3,6), (4,5), (4,7), (5,7), (6,7)be the set of all the the same color. For this kind of coloring the easiest hack is
edges in the graph. To solve the graph coloring problem, to use different colors for each node. Since the total number
any two vertices are associated with an edge. i.e. two of nodes in a graph doesn’t have any restrictions, using
adjacent vertices should not have the same color. In our different colors for different nodes is not feasible. Thus, for
case, the color represents the specialist doctors. proper coloring of a graph, one should color the graph using
a minimum number of colors.
II. GRAPH COLORING PROBLEM
The lowest number of colors required to color a
A graph is a collection of vertices(nodes) connected by graph(G) is called the chromatic number of G (Boyer et al.,
the edges. Typically, vertices of graphs are represented by 1998). A graph G with a chromatic number (G)=k is k
names or properties. Edge is often used to link any two chromatic. Graph G whose vertices can be colored using k
vertices of the graph. In terms of symbols, we represent colors is called k colorable (Boyer et al., 1998). Normally
graphs as G, vertices as V, and edges as E. The vertices there are three types of graph coloring: Vertex coloring,
having an edge between them are often called adjacent edge coloring, and face coloring (Diao, 2010). In this paper,
vertices. Graphs are either directed or undirected. Edges of we will stick with vertex coloring. Discussing further the
directed graphs have direction associated with them while chromatic number of a graph, we will discuss one of the
the edges of undirected graphs don’t have any direction. All landmark achievements in the field of graph theory widely
the graphs discussed in this paper will be undirected graphs. known as the Four Coloring Theorem. The four-coloring
Undirected graphs in our paper are simple graphs, that is theorem implies that for any planar graphs, their chromatic
there won’t be more than one edge connecting the same pair number is at most four. In other words, we can always color
of vertices. a planar graph with 4 colors.
This interesting conjecture was first conjectured by Note that this theorem is limited to planar graphs.
Francis Guthrie in 1852 and remained unsolved for more Because of this interesting boundary on chromatic numbers
than a century. Finally, the major proof was given in 1977 for planar graphs, we will be dealing with planar graphs in
by Appel and Haken (K. Appel & W. Haken, 1977). Their our paper. So let’s look at what exactly are planar graphs.
proof was largely computer-based as it required solving too
many cases. Whether this kind of computerized proof Basically, a planar graph is a graph that can be drawn
actually constituted proof in the mathematical community is in the plane such that no two edges cross except at a vertex.
still controversial. But we can’t ensure if a graph is planar just by looking at it.
You can see Fig 2 as an illustration.
To overcome this problem, Euler formulated a famous surface, it breaks into separate pieces, and each piece is
theorem known as Euler’s theorem. The theorem states that called a region. We also need to be aware that there’s
for any planar graph, No. of Vertices(v) Number of always one special outer region that contains all the parts of
Edges(e) + regions(r) equals 2, i.e. v e+r=2. The number 2 the surface that go on forever. For a region, degree (deg) is
in this theorem is not random as you can notice 2 usually the number of edges that are adjacent to the region, written
has something to do with the plane. In this theorem, the as deg(R). As an example of Euler’s theorem, you can see it
region(r) of a planar graph is basically sections of a flat works in the graph below. Since, v=4, e=6 and r=4, 4
surface separated by a planar graph. You can look at Figure 6+4=2.
2 for its illustration. Imagine erasing vertices from the
Why Study Graph Coloring Problems? classical and brute force methods, because the paths leading
Graph coloring problem is one of the most important to false solutions are terminated earlier, preventing any
aspects of graph theory because of its real-life implications further branches on that path. Although the upper bound of
like scheduling, resource allocation, assigning radio time complexity for both the backtracking and brute force
frequency, map coloring, and many others. However, to methods are of O(mn).
date, there is no efficient algorithm for solving the graph
coloring problem. It is one of the well-known Np complete Here, m is the number of colors and n is the number of
problems. Np complete problems are the problems which nodes, the average time complexity of backtracking is
don’t have any established polynomial time algorithm. lesser. Here is how backtracking works:
Polynomial-time algorithms are considered to be efficient
because the execution times do not grow rapidly as the We want the adjacent nodes to be of different colors.
problem size increases, unlike exponential-time algorithms. First, we make a list of nodes and a list of colors. Now we
Thus finding a polynomial time algorithm for any of the np put the first color on the first node and move on to the
complete problems can solve all of them. adjacent node. Since the second node can’t have the same
color as the first, the algorithm looks for the next color on
Classical Solutions the color list and goes on till all the vertices are colored as
One of the popular classical algorithms for solving required. When the algorithm reaches a node and can’t find
graph coloring problems is the Backtracking Algorithm. any color that works, the algorithm backtracks and colors
Backtracking is a classical approach to solving graph the previous node with a different color. All the.
coloring using recursion. It is proven better than other
Fig 7 A Simple Graph to Illustrate Quantum Circuit. of Applying u w and v d on s . and it Turns Out
Notice how after applying Grover’s algorithm, our We now move on to designing the oracle to invert the
final output will be a 2n-bit binary number whose leftmost phase of the coloring combination in which adjacent nodes
two values represent N1’s color, then the next two values have different colors. To achieve that, we break the oracle’s
represent N2’s color, and so on until the last two values function into two parts, so that the gate implementation is
represent Nn’s color. For our use, we’ll refer to the qubits simpler. First, we need to identify the solution states whose
represented by the Nn node as Nn qubits. So, the second last adjacent nodes are differently colored. Second, we need to
pair of qubits is the N3 qubits. invert the phase of the identified solution states.
Since these are the only qubits that represent our color, For now, let’s just look at N1 and N2 from our specific
we can apply the Hadamard H gate to make them into a case. Since they’re adjacent, the first part of the oracle must
uniform superposition. Any ancilla qubit we need/use later identify if they have the same color. We’ll use multi-control
will not need to be initialized because their final values are Toffoli gates in the following combination (see Figure 10) to
of no use to us. see if they have the same color and store their value in an
ancilla, which we’ll call an edge ancilla. Note that the two
nodes below are represented by two qubits each. The
ancillia starts from the null state. Ancilla indexing is the
same as the edge indexing from the graph. This is done for
simplicity’s sake.
Fig 9 Circuit with two Nodes Showing Multi -Control Tofolli Gates and Ancilla
A truth table with all possible inputs in the N1 and N2 Act like inverses of one another to give an output of 0
qubits shows that the edge ancilla returns 0 only when the in the edge ancilla.
N1 and N2 qubits have different values (i.e., different colors).
This will be the case we desired. When the colors in the Because of their frequent use, the combination of these
adjacent nodes are the same, only one of the Toffoli of the Toffoli gates to check if any pair of adjacent nodes Ni and Nj
four flips the sign of the edge ancilla, making it a 1, a case with edge Ek have different colors or not, we’ll be calling
that shows that the pairing isn’t valid as a solution to the them color-checking gates (C(i, j)) and their corresponding
graph coloring problem. Else, two Toffoli gates are edge ancilla is Ek. For ease of notation, we’ll name the
activated which inverse of C(i, j) to be C(j, i) because C(j, i) must have the
Toffoli gates in the reverse order of C(i, j
We now design the second part of the oracle to flip the only when adjacent nodes have different colors.
phase of the correct states identified in the first part. Our
goal is to filter out the solution state after kicking its phase. We now take the edge ancillas as the control and the
For that, we’ll use phase kickback (Alsing & McDonald, negative ancilla as the target in a Toffoli gate to flip the
2011) by using a new ancilla, which we’ll refer to as the phase only when all the edge ancillas return 0–when the
negative ancilla. In a Tofolli gate, the state of the target coloring is valid. However, computationally, it is more
qubit is flipped if and only if the con trol qubit is in the state efficient to make the controls that check 1, else we’ll need to
—1〉, known as phase kickback. The kickback helps identify use X gates before and after all the controls. This will
our solution state. We’ll again use a multi-control Toffoli increase the gate complexity, and we try to avoid this.
gate to flip the phase of the solution states.
Hence, in the initialization step itself, we make all
In the first part of the oracle, we know we’ll have e
edge ancillas. If all of these edge ancillas return 0, we the edge ancillas to 1 to reduce the cost of the quantum
know that is a valid coloring because the edge ancillas are 0 circuit. In a diagram, we would have.
So, up until now, we have initialized the states, D = 2 |s⟩ ⟨s| − I (6)
checked which states have valid coloring, and flipped the
phase of states with valid coloring. To prevent the effect on D = 2(H⊗n |0⟩) ⟨H⊗n |0⟩| − I
phase due to C(i,j), we apply C(j, i) right after the phase (7)
kickback completes our oracle.
Because D can be written as a reflection about
For the diffusion operator, recall that it can be written Mathematically, we want a gate such that.
as.
M0 |0⟩ = |0⟩ (8)
s = H⊗n |0⟩ (5)
M0 |x⟩ = − |x⟩ for x ̸= 0 (9)