0% found this document useful (0 votes)
29 views11 pages

QCQI

This research explores quantum algorithms for solving the NP-complete Maximal Clique Problem, proposing three methods: Reduction to SAT, Grover’s Algorithm, and Quantum Approximate Optimization Algorithm (QAOA). The study highlights the theoretical advantages of quantum approaches over classical methods and emphasizes the practical applicability of hybrid algorithms like QAOA in the NISQ era. Fine-tuning these algorithms is crucial for optimal performance in addressing NP-complete problems.

Uploaded by

b11902027
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views11 pages

QCQI

This research explores quantum algorithms for solving the NP-complete Maximal Clique Problem, proposing three methods: Reduction to SAT, Grover’s Algorithm, and Quantum Approximate Optimization Algorithm (QAOA). The study highlights the theoretical advantages of quantum approaches over classical methods and emphasizes the practical applicability of hybrid algorithms like QAOA in the NISQ era. Fine-tuning these algorithms is crucial for optimal performance in addressing NP-complete problems.

Uploaded by

b11902027
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Solving the Clique Problem with Quantum Computation

Student: B11902027 陳思瑋

1 Abstract
This research investigates quantum approaches to solving the NP-complete Maximal Clique Prob-
lem, which requires exponential time for classical algorithms. Three quantum algorithms are proposed:
Reduction to SAT, Grover’s Algorithm, and Quantum Approximate Optimization Algorithm (QAOA).
The study compares these methods in terms of qubit requirements, time complexity, and performance.
Results show that quantum algorithms offer theoretical complexity advantages over classical methods,
while hybrid approaches like QAOA provide practical solutions for larger instances in the NISQ era.
Fine-tuning remains essential for optimal performance, presenting a promising pathway for addressing
NP-complete problems with quantum computing.

2 Introduction
2.1 Background
2.1.1 Maximal Clique Problem
The maximal clique problem involves finding all maximal cliques in a graph, where a clique is a
subset of vertices with all pairs connected, and a maximal clique cannot be extended further. This
problem is NP-hard, and a brute-force approach requires examining all subsets of vertices, leading to
a time complexity of O(2n · n2 ), where n is the number of vertices in the graph.

2.1.2 K-Clique Problem


The k-clique problem involves determining whether a graph contains a clique of size k. As an
NP-complete problem, it is computationally intensive for large k. This project focuses on enumerating
all k-cliques in G, providing insights into densely connected substructures.

2.1.3 3-SAT Problem


The 3-SAT (3-Satisfiability) problem is a classic NP-complete challenge in theoretical computer
science. Any NP problem can be efficiently transformed into an instance of 3-SAT.
In 3-SAT, the input is a Boolean formula in Conjunctive Normal Form (CNF), where each clause
is a disjunction of exactly three literals (Boolean variables or their negations). The goal is to determine
if there exists a truth assignment to the variables that makes the formula true.
A 3-SAT formula is represented as:

F = (x1 ∨ ¬x2 ∨ x3 ) ∧ (¬x4 ∨ x5 ∨ ¬x6 ) ∧ . . .


where xi are Boolean variables, ∨ is logical OR, ∧ is logical AND, and ¬ denotes negation.

Page 1
Final Project B11902027 QCQI

2.1.4 Quantum Approximate Optimization Algorithm (QAOA)


QAOA, proposed in 2014, is a hybrid quantum-classical algorithm designed to solve combinato-
rial optimization problems. Based on the Variational Quantum Eigensolver (VQE), it approximates
solutions to quadratic programming (QP) problems in polynomial time.
The algorithm uses the Hamiltonian HC , a matrix representing the cost function, to optimize
parameters ⃗γ and β⃗ (both of length p, the number of layers). A classical optimizer updates these
parameters iteratively to minimize the cost function. The updated parameters are sent back to the
quantum computer, and the process repeats for several iterations. The circuit is shown in Figure 1.

Figure 1: Naive Oracle

While QAOA theoretically converges to the optimal solution as p → ∞, in practice, good ap-
proximations can be achieved with small p, balancing performance and accuracy.
Quadratic programming (QP) involves minimizing a quadratic function with linear constraints.
Quadratic Unconstrained Binary Optimization (QUBO), a special case of QP with no constraints
and binary variables, is particularly well-suited for QAOA, as the lack of constraints simplifies the
problem.

3 Problem and Methodology


In our project, we address the maximal clique problem in its form of listing all maximal cliques.
We employ three methods to solve this problem: Reduction to SAT, Grover’s Algorithm, and
QAOA (Quantum Approximate Optimization Algorithm).

3.1 Reduction to the SAT Problem


In this approach, we solve the clique problem by progressively reducing it to a 3-SAT problem.
Below is a bottom-up overview of the steps involved in solving this problem:

1. Solving the 3-SAT problem using the Grover’s algorithm.

2. Transform General SAT into 3-SAT.

3. Solving k-clique problem by the General SAT solver.

4. Solving maximal clique problem by iterations of k-clique solver.

We’ll now step by step explain the above approach in detail.

Page 2
Final Project B11902027 QCQI

3.1.1 Solving the 3-SAT Problem using Grover’s Algorithm


In this section, the design of the oracle is the most critical aspect. For a 3-SAT problem, we can
construct a straightforward oracle that verifies all the clauses and literals. For instance, given the
clause:

(¬x0 ∨ ¬x1 ∨ ¬x2 ) ∧ (x0 ∨ ¬x1 ∨ x2 ) ∧ (x0 ∨ x1 ∨ ¬x2 ),


we can represent it as a quantum circuit, as illustrated in the figure below.
The above quantum circuit simply constructs a Toffoli gate for each clause and stores the results
in q3 , q4 , and q5 . Then, we check if all the results are 1. If so, we set q7 to 1; otherwise, we set it
to 0. Up to this point, the main function of the oracle is completed, and the remaining part of the
quantum circuit is used to reverse the previous operations performed on the first six qubits.
In our implementation, we use the PhaseOracle object to construct the oracle. The PhaseOracle
object can construct an oracle with fewer qubits by utilizing circuit optimization techniques, such as
employing XOR-AND Graphs (XAG) and decomposition into k-LUTs.
For the same example clause mentioned above, using the PhaseOracle object, we can construct
a much more efficient oracle, as shown in the figure.

Figure 2: Naive Oracle vs. PhaseOracle

3.1.2 Transform General SAT into 3-SAT


This section outlines the transformation of General SAT to 3-SAT for clauses containing one
literal, two literals, or more than three literals.

• Clauses with one literal: For a clause with one literal, two dummy variables can be added to
transform it into 3-SAT clauses. For example, given the clause x0 , add y0 and y1 to transform
it into (x0 ∨ y0 ∨ y1 ) ∧ (x0 ∨ ¬y0 ∨ ¬y1 ) ∧ (x0 ∨ y0 ∨ ¬y1 ) ∧ (x0 ∨ ¬y0 ∨ y1 ).

• Clauses with two literals: For a clause with two literals, one dummy variable can be added.
For example, given the clause (x0 ∨ x1 ), add y0 to transform it into (x0 ∨ x1 ∨ y0 ) ∧ (x0 ∨ x1 ∨ ¬y0 ).

• Clauses with more than three literals: For a clause with k literals (k ≥ 4), add k − 3
dummy variables. For example, given (x1 ∨ x2 ∨ x3 ∨ · · · ∨ xk ), add y0 , y1 , . . . , yk−3 to transform
it into (x1 ∨ x2 ∨ y1 ) ∧ (¬y1 ∨ x3 ∨ y2 ) ∧ (¬y2 ∨ x4 ∨ y3 ) ∧ · · · ∧ (¬yk−3 ∨ xk−1 ∨ xk ).

Page 3
Final Project B11902027 QCQI

3.1.3 Solving the k-Clique Problem with a SAT Solver


The k-Clique Problem is transformed into a SAT problem by encoding its constraints into a
Boolean formula in Conjunctive Normal Form (CNF). The objective is to determine whether a graph
G = (V, E) contains a clique of size k.

Variables Define Boolean variables xi,j , where i ∈ {1, . . . , k} represents the i-th position in the
clique, and j ∈ {1, . . . , n} represents the j-th vertex in the graph. xi,j = 1 indicates vertex vj occupies
position i in the clique.

Constraints The constraints for valid encoding are as follows:

• Position
Vk Wn Occupancy: Each position in the clique must be occupied by at least one vertex:
i=1 j=1 xi,j .

• No Repeated Vertices: A vertex cannot occupy more than one position: ¬xi,j ∨ ¬xi′ ,j for all
i ̸= i′ and j ∈ {1, . . . , n}.

• Connectivity: Only connected vertices can form a clique: ¬xi,p ∨ ¬xi′ ,q for all (vp , vq ) ∈
/ E and
i ̸= i′ .

The CNF formula ϕ is given by:

ϕ = (Position Occupancy) ∧ (No Repeated Vertices) ∧ (Connectivity).

A SAT solver checks the satisfiability of ϕ. If ϕ is satisfiable, the satisfying assignment corresponds
to a k-clique in G.

3.1.4 Solving maximal clique problem by iterations of k-clique solver


To solve the maximal clique problem, we iteratively solve the k-clique problem for increasing
values of k, starting from 1, until no k-clique is found. After doing so, we obtain a list of cliques of
varying sizes, and the remaining task is to eliminate the cliques that are not maximal.
To achieve this, we can iteratively check if a clique of size k is a subset of a clique of size k + 1.
If it is, we remove the clique of size k from the list. The remaining cliques are the maximal cliques in
the graph.

3.2 Using Grover’s Algorithm to Solve the Problem Directly


3.2.1 Quantum State Representation
Grover’s algorithm solves the problem by utilizing three types of quantum registers: one for
subsets of vertices |x⟩, one for graph data |Cj ⟩, and an ancillary register for intermediate calculations.
The quantum state |x⟩ = |x1 x2 . . . xn ⟩ represents subsets of vertices, where each qubit xi specifies
whether a vertex is included (1) or excluded (0) in the subset. For a graph with n vertices, all possible
subsets are represented in a uniform superposition as:
1 X
√ |x⟩
2n x∈{0,1}n

This quantum state encodes all vertex subsets simultaneously.

Page 4
Final Project B11902027 QCQI

To model the graph G, its adjacency matrix A is constructed. To ensure that each vertex connects
to itself, self-loops are added by defining A′ = A + I, where I is the identity matrix. Each column
of A′ , denoted as |Cj ⟩ = |c1j , c2j , . . . , cnj ⟩, is stored in a quantum register, with cij = 1 indicating a
connection between vertices i and j, and cij = 0 otherwise.
Ancillary qubits are employed to hold temporary data, such as the set of common neighbors,
which is essential for verifying clique conditions.

3.2.2 Oracle
The oracle identifies whether a quantum state |x⟩ represents a maximal clique. If |x⟩ corresponds
to a maximal clique, a phase flip is applied, changing |x⟩ to −|x⟩.
First, controlled-NOT operations perform a bitwise-AND between the graph data |Cj ⟩ and the
vertex subset encoded in |x⟩, identifying common neighbors of vertices in the candidate clique. The
operation is defined as:
(
cij , if xj = 1
xj cij ⊕ xj cij ⊕ xj cij =
1, if xj = 0
The ancilla qubits store these common neighbors, with each bit indicating whether a vertex is
shared among all vertices in |x⟩ (1 for common neighbor, 0 otherwise).
A Cn (X) operation is then applied, where the ancilla qubits act as controls, and |x⟩ serves as the
target. If the common neighbors match the vertices in |x⟩, the oracle flips |x⟩, confirming it represents
a maximal clique.

Figure 3: circuit of the oracle

3.2.3 Our Approach


For practical implementation, our method follows the description in [1] with certain trade-offs. To
reduce the number of qubits required and enable testing on real devices and simulators with limited
qubits, we used a fixed estimation for the number of Grover iterations instead of deriving M from the
Quantum Counting Algorithm (Phase Estimation).
Since real devices are prone to noise, and fixed estimations may introduce errors, we incorporated
a classical verification step with O(k · n2 ) time complexity after measurement to ensure the marked
clique is indeed maximal (k being the number of cliques marked by the oracle). Additionally, as
classical verification was employed, we simplified the oracle to mark cliques rather than maximal
cliques, as described in [1].

Page 5
Final Project B11902027 QCQI

3.3 QAOA (Quantum Approximate Optimization Algorithm)


QAOA is a quantum approximation algorithm designed to solve combinatorial optimization prob-
lems. To solve the CLIQUE problem, it must first be transformed into a Quadratic Unconstrained
Binary Optimization (QUBO) problem.
The process involves three steps:

1. Convert the CLIQUE problem into a Quadratic Programming (QP) formulation.

2. Transform the QP into a QUBO representation.

3. Solve the QUBO problem using QAOA and estimate the result.

3.3.1 QP Formulation
The CLIQUE problem can be formulated as a Quadratic Programming (QP) problem.

1. Compute the complement of G, denoted as G = (V, E ′ ), where V is the set of vertices, and E ′
contains edges that are not present in G.

2. For each (vi , vj ) ∈ E ′ , add the constraint xi + xj ≤ 1. Here, V = {v0 , v1 , . . . , vn−1 }, and n = |V |.
This ensures that xi = 1 and xj = 1 cannot occur simultaneously, as (vi , vj ) ∈ E ′ would violate
the clique condition.

The QP formulation is as follows:


n−1
X
Maximize: xi
i=0

Subject to: xi + xj ≤ 1, ∀(vi , vj ) ∈ E ′


Bounds: xi ∈ {0, 1}, ∀i ∈ {0, 1, . . . , n − 1}

3.3.2 QUBO Formulation


QUBO (Quadratic Unconstrained Binary Optimization) is a special case of QP with binary
variables and no constraints. Each constraint in the original problem is incorporated as a penalty
term in the objective function.
The problem is formulated as follows, where λ is a hyperparameter controlling the penalty term
to ensure feasibility:
n−1
X X
Minimize: − xi + λ xi xj
i=0 (vi ,vj )∈E

Bounds: xi ∈ {0, 1}, ∀i ∈ {0, 1, . . . , n − 1}


The objective function, also referred to as the cost function, is to be minimized. It can be further
represented using a matrix Q as:
n
X n
X
C(x) = xi Qij xj + ci x i
i,j=1 i=1

Page 6
Final Project B11902027 QCQI

3.3.3 Using QAOA


The goal is to find a Hamiltonian HC such that HC |x⟩ = C(x)|x⟩, where C(x) is the cost function.
The cost function can be converted into a Hamiltonian HC as follows:
n n n
! n n
!
X 1 X 1 X X Qij X ci
HC = Qij Zi Zj − ci + Qij Zi + + I
i,j=1
4 i=1
2 j=1 i,j=1
4 i=1
2
In practice, the term with I is treated as an offset and can be added back later. Thus, the
Hamiltonian HC′ is simplified as:
n n n
!

X 1 X 1 X
HC = Qij Zi Zj − ci + Qij Zi
i,j=1
4 i=1
2 j=1

Additionally, another Hamiltonian HB is required, defined as:


n
X
HB = Xi
i=1
⃗ where:
Using these Hamiltonians, QAOA minimizes the function F (⃗γ , β),

⃗ = ⟨ψp (⃗γ , β)|H


⃗ ′ ⃗
F (⃗γ , β) C |ψp (⃗
γ , β)⟩
⃗ is given by:
The state |ψp (⃗γ , β)⟩

⃗ = e−iβp HB e−iγp HC′ · · · e−iβ1 HB e−iγ1 HC′ |+⟩⊗n


|ψp (⃗γ , β)⟩
A classical optimizer updates the parameters ⃗γ and β⃗ iteratively to minimize F (⃗γ , β).
⃗ The number
of layers p is a hyperparameter that must be fine-tuned.
The size of the clique is given by the optimal solution, which is an integer since xi ∈ {0, 1} for
all i. The chosen clique corresponds to the values of xi in the optimal solution.

4 Results and Analysis


4.1 Reduction to SAT
4.1.1 Number of Qubits Used
To estimate the qubits required for the final quantum circuit, we first determine the number of
clauses generated for the SAT problem and then calculate the variables in its 3-SAT transformation.
For a graph G = (V, E) with N vertices and E edges, and a desired clique size K, the number of
clauses in the general SAT problem is:
1. Position Occupancy: K clauses with N literals.
2. No Repeated Vertices: N × K × (K − 1) clauses with 2 literals.
 
3. Connectivity: K × (K − 1) × N ×(N
2
−1)
− E clauses with 2 literals.

The 3-SAT transformation introduces K(2N −3)+3[N K(K −1)+K(K −1)( N (N2−1) −E)] ∈ O(N 4 )
variables. Using the PhaseOracle object, the number of qubits in the quantum circuit equals the
variables in the 3-SAT problem.

Page 7
Final Project B11902027 QCQI

4.1.2 Time Complexity Analysis


The SAT solver’s time complexity
√ dominates each k-Clique solver iteration. Grover’s algorithm
in the SAT solver operates in O( 2n ), where n is the number√ of2 qubits in the circuit. For a graph
with N vertices, the k-Clique solver has a complexity of O( 2N k ).
To find maximal cliques, the k-Clique problem is solved iteratively for increasing k. The total
PN √ N k2 PN −1 N  N
 N3
time complexity is O k=1 2 + k=1 k · k+1 = O(2 2 ), where the second term accounts
for eliminating non-maximal cliques.

4.1.3 Test Cases


Due to the overhead of SAT reduction, testing is limited to small cases, such as graphs with three
vertices, requiring approximately 30 qubits. Larger cases exceed simulator capacity due to the high
qubit demand.

4.2 Solving Directly with Grover’s Algorithm


4.2.1 Number of Qubits Used
Our quantum-classical approach minimizes qubit requirements while maintaining compatibility
with NISQ devices. The quantum oracle uses n + 2n2 qubits, compared to n + 2n2 + (n + 4) required
for phase estimation in the original proposal [1].

4.2.2 Time Complexity Analysis


√ √
Grover iterations execute in O(n2 2n ) time using a fixed R = π4 2n iterations, avoiding quantum
q
π N
counting (R = 4 M ). Classical post-processing adds an O(2n · n2 ) overhead, but the oracle’s V −
W − V † structure ensures correctness.

4.2.3 Test Cases


Experiments on IBM Quantum hardware confirm feasibility. For n = 3, maximal cliques were
identified with a noise threshold of > 5 counts. The largest tested graph (127 qubits available) had
7 vertices. Circuit depth was reduced to 300-400 gates (a ∼ 70% reduction from the > 1000 gates
required by phase estimation), enabling execution on real hardware.

4.2.4 Implementation Details


The V -gate uses 3n2 Toffoli gates, while the W -gate employs n Cn (X) gates, maintaining poly-
nomial scaling. Classical verification with is maximal clique() mitigates noise and runs in O(n2 )
per candidate, with the limited candidate states ensuring manageable overhead. Experimental results
show near 100% accuracy, demonstrating the hybrid method’s practicality.

4.3 QAOA (Quantum Approximate Optimization Algorithm)


4.3.1 Number of Qubits Used
The quantum space complexity of QAOA is determined by the number of qubits required in the
circuit. For a graph with n vertices, the quantum circuit requires n qubits. This is because each
vertex corresponds to a binary variable in the QUBO formulation.

Page 8
Final Project B11902027 QCQI

4.3.2 Time Complexity Analysis


The time complexity of the QAOA algorithm is influenced by the number of layers p and the
number of vertices n. Given that the number of edges is O(n2 ), the breakdown is as follows:

1. QP Formulation (Classic): O(n2 ) to traverse all edges in the graph.

2. QUBO Formulation (Classic): O(n2 ) to convert constraints into penalty terms and construct
the matrix Q.

3. Preparing for QAOA (Classic): O(n2 ) for Hamiltonian calculation and O(p) for preparing
⃗ resulting in O(n2 + p) overall.
parameters ⃗γ and β,

4. QAOA Execution (Quantum + Classic): O(p) per quantum iteration and O(n2 ) for the
classical optimizer, leading to O(n2 + p) overall.

Thus, the total time complexity of QAOA is O(n2 + p). For large n, this simplifies to O(n2 ), as
p is typically small.

4.3.3 Test Cases


Experiments were conducted on a simulator to determine the optimal number of layers p for
QAOA with varying input sizes. Initial values of ⃗γ and β⃗ were randomly chosen and fine-tuned for
stability.
The criterion for selecting p was to find the smallest p that consistently produced correct results
five times in a row. Results, shown in the figure below, indicate a positive correlation between p and
the number of vertices n, with an outlier at n = 9. This anomaly may be due to the number of edges,
as it affects the number of constraints in the problem. However, this factor was not considered here,
as the number of edges was assumed to be m = O(n2 ). Further experiments are needed to explore
the relationship between edge count and the optimal p.

Figure 4: smallest p needed for consecutive five correct result

Page 9
Final Project B11902027 QCQI

5 Discussion and Conclusion


5.1 Comparison of the Three Methods
The three approaches—Reduction to SAT, Grover’s Algorithm, and QAOA—each demonstrate
unique strengths and limitations in solving the CLIQUE problem.

• Reduction to SAT: This method provides a systematic way to encode the CLIQUE problem
N3
as a Boolean satisfiability problem. While it scales poorly with the number of vertices (O(2 2 )),
it leverages classical SAT solvers effectively for small problem sizes.

• Grover’s Algorithm: By employing quantum search, this approach reduces the search space
quadratically compared to classical brute-force methods. However, its hardware requirements
and noise sensitivity restrict its practical applicability to small graphs in the current NISQ era.

• QAOA: This hybrid algorithm offers a promising trade-off between quantum and classical
computation. While its performance depends heavily on the choice of parameters and problem
size, QAOA shows potential for efficiently solving QUBO problems and is well-suited for near-
term quantum devices.

A comparative summary of the three methods is shown below:

Classical SAT Reduction Grover QAOA


# of Qubits N/A O(n4 ) O(n2 ) O(n)
n3 p
Time Complexity O(n2 2n ) O(2 2 ) O( n2 2n /M ) O(n2 )
Test Cases 30–40 3 7 127

Table 1: Comparison of Methods: Classical, SAT Reduction, Grover, and QAOA

5.2 Hybrid Methods as a Bridge to Quantum Advantage


Fully quantum methods, such as Grover’s Algorithm, are constrained by current quantum hard-
ware limitations, including qubit count, gate fidelity, and noise levels. These limitations make large-
scale quantum computation impractical in the near term.
Hybrid approaches, such as QAOA, serve as a bridge to quantum advantage by combining the
strengths of classical optimization with quantum computation. These methods are feasible in the NISQ
(Noisy Intermediate-Scale Quantum) era, offering glimpses of quantum advantage through improved
performance on specific problem classes.

5.3 Quantum Computing as a Complement to Classical Computing


The current state of quantum computing is best viewed as a complement to classical computation
rather than a replacement. Classical methods remain indispensable for large-scale, general-purpose
problem solving, while quantum computing provides novel tools for tackling specific, hard-to-solve
optimization problems. Hybrid approaches exemplify this synergy, paving the way for more practical
applications of quantum technologies in the future.

Page 10
Final Project B11902027 QCQI

6 References
[1] Chu Ryang Wi, Department of Electrical Engineering, University at Buffalo, State University of
New York, Buffalo, NY. A Quantum Circuit to Construct All Maximal Cliques Using Grover Search
Algorithm. arXiv preprint arXiv:1711.06146v2, 2018.
[2] Edward Farhi, Jeffrey Goldstone, and Sam Gutmann. A Quantum Approximate Optimization
Algorithm. arXiv preprint arXiv:1411.4028, 2014.

7 Appendix
The repository of the project could be found here.

Page 11

You might also like