Circuit Design for Clique Problem and Its Implementation on Quantum Computer

Finding cliques in a graph has several applications for its pattern matching ability. $k$-clique problem, a special case of clique problem, determines whether an arbitrary graph contains a clique of size $k$, has already been addressed in quantum domain. A variant of $k$-clique problem that lists all cliques of size $k$, has also popular modern-day applications. Albeit, the implementation of such variant of $k$-clique problem in quantum setting still remains untouched. In this paper, apart from theoretical solution of such $k$-clique problem, practical quantum gate-based implementation has been addressed using Grover's algorithm. This approach is further extended to design circuit for the maximum clique problem in classical-quantum hybrid architecture. The algorithm automatically generates the circuit for any given undirected and unweighted graph and any given $k$, which makes our approach generalized in nature. The proposed approach of solving $k$-clique problem has exhibited a reduction of qubit cost and circuit depth as compared to the state-of-the-art approach, for a small $k$ with respect to a large graph. A framework that can map the automated generated circuit for clique problem to quantum devices is also proposed. An analysis of the experimental results is demonstrated using IBM's Qiskit.


Introduction
Quantum computers were proposed in the early 1980s and the description of quantum mechanical computers was formalized in the late 1980s. Many efforts on quantum computers have progressed steadily since the early 1990s, because these computers were shown to be more powerful than classical computers on various specialized problems, especially on computationally NP-problems. Several quantum algorithms, for example Shor's Algorithm [1] for factoring integers, Grover's Algorithm [2] for searching an unstructured database, Triangle finding by Magniez et al. [3], Matrix Product Verification [4] have already been proposed and shown asymptotic improvements than their classical counterparts. In this paper, another computationally NP-problem i.e., clique problem [5] has been addressed in quantum setting. Our main focus in this paper is to provide an end-to-end framework that automatically implements an clique problem, so that if anyone can map their computational problem to the clique problem in polynomial time, will be able to implement further, without prior knowledge of gate-based quantum circuit implementation.
A clique is a subgraph of an undirected graph, where every distinct vertex in the subgraph is connected with every other vertex via an edge; that is, the subgraph is complete. The k-clique problem is a special case of clique problem which determines whether an arbitrary graph contains a clique of size k. Whereas, a maximum clique is a complete sub graph of a graph, whose size is the largest among all other complete sub graphs in the given graph. Clique problems have several applications in various branches of computer science, as for instance, pattern recognition [6], information retrieval [7], computer vision [6], analysis of financial networks [8] and spatial data mining [9]. Solving the clique problem especially k-clique problem using quantum algorithm [10], where the solution provides a clique of size k, is more efficient in terms of computation as compared to its classical counterpart due to its quantum mechanical properties. Quantum circuit design for the k-Clique problem has also been demonstrated in the literature [10]. Although, circuit designing in quantum setting for a variant of k-clique problem, where the solution of the problem lists all cliques of size k is much more difficult in reality due to the computational complexity of this variant of k-clique problem.
In this paper, we solve the variant of k-clique problem, which lists all the cliques of size k using well-known quantum search algorithm i.e., Grover's algorithm to get the immediate advantage of solving various modern-day applications like community detection [11,12,13], data mining in bio-informatics [14] and disease classification [15]. We have designed the circuit for specified variant of k-clique problem in such a way, so that the engineering challenge of implementing such variant of k-clique problem must be overcome. We further illustrate that for small value of k with comparatively larger graph, our approach of designing circuit for k-clique problem surpasses the state-of-the-art approach [10] with respect to the quantum cost with regards to qubit and circuit depth. Using this proposed approach of solving k-clique problem, a generalized algorithm for the maximum clique problem (MCP), which lists all the largest sized cliques among all the cliques for a given graph has also been proposed in this paper.
Our key contributions in this paper can be summarized as follows: • We propose an automated end-to-end framework for mapping clique problem to any available quantum computer so that anyone can get the advantage of gate-based implementation of quantum algorithm without much prior knowledge. • We propose an approach to implement the variant of k-clique problem, where the output of the problem lists all cliques of size k using quantum search algorithm for the first time to the best of our knowledge. • Our approach of solving k-clique problem outperforms the state-of-the-art approach with respect to qubit cost and circuit depth, when n >> k, where n is a large number of nodes of given graph (G(V = n, E = e)) and k is respectively very small. • We exemplify the triangle finding problem, which is an example of k-clique problem, where k = 3 to establish our claim. • Further, we extend our approach of solving k-clique problem to implement maximum clique problem via classical-quantum hybrid computation. • We implement the generalized algorithm on arbitrary graph instances and simulated the same in the QASM simulator as well as in a real quantum devices (IBMQX architecture [16], [17]) through a python based programming interface called QISKit [18] with noise model and study that for different graphs, how the error effects the resultant states further.
The paper has been organized as follows. Section 2 reviews related works in the classical and quantum domain. The general flow of the automated framework for clique problem is illustrated in Section 3. Our proposed algorithm for synthesis of the k-clique problem has been discussed in Section 4. The extension of the algorithm for solving MCP has also been depicted in this section. The performance of the circuit is analyzed in Section 5. Section 6 deals with experimental results of the circuit genrated for different exemplified graphs in the IBM Q_qasm_simulator and IBM Q_16_melbourne. The complexity of the algorithm has been analyzed in Section 7. Finally the paper concludes with a summary and future scope in Section 8.

Background
In this section, we will try to lay out some background knowledge on Quantum computing and clique problem.

Qubits and Quantum States
The qubit is the quantum equivalent of a classic bit [19]. Instead of working with classical bits, quantum computers, or more precisely quantum processing units (QPUs), use qubits. Qubits are mathematically expressed using dirac notation. This notation is also known as bra-ket notation. An example of complete bra-ket notation is φ| |ψ , where φ represents ket part and ψ represents bra part. A bit is a binary information that can have two possible values: 0 or 1. On the contrary, a qubit can be expressed as |ψ = α |0 + β |1 , where α and β are amplitudes of the state |0 and |1 and α 2 + β 2 = 1. The states |0 and |1 are the basis states, similar to bit values of 0 and 1 in classical computers. To denote a quantum state, only the ket part of the notation is used. For example, to represent the classical values of 0 and 1 in a quantum state, we can write as |0 = 1 0 , |1 = 0 1 . The column vector represents amplitude of the quantum state.

Quantum Logic Gates
A quantum circuit is a model for quantum computation, where reversible quantum gates like Hadamard, CNOT, Toffoli are imposed on qubits to evolve the quantum states towards solution of a specific quantum algorithm [20]. Quantum gates are the unitary operations, where number of gate collections to be sequentially executed defines the depth of a quantum circuit. Whereas, The number of qubits defines the width of the circuit. The matrix representation of the quantum gates that are used in the proposed approach is shown in the following Table 1.
Apart from these four gates described in Table 1, Multi-Controlled Toffoli Gate (MCT) is also used to design our proposed circuit for clique problem. There are n number of inputs and outputs in an n-qubit MCT. This MCT gate passes the first n − 1 inputs, which are referred as control bits to the output unaltered. It inverts the n th input, which is referred as the target bit if the first n − 1 inputs are all one. An MCT gate is shown in Figure 1, where black dots • represent the control bits and the target bit is denoted by a ⊕.

NISQ Devices
In recent years, NISQ (Noisy Intermediate Scale Quantum devices) [21] that can perform quantum computation with a short circuit length have appeared, although the scale and accuracy are insufficient to perform continuous and effective error correction. Various physical systems such as superconductors, ion traps, quantum dots, NV centres, and optics are used in NISQ devices. As an instance, superconducting based IBM Q processors accept gates written in the QASM language [22], which is further used in this paper for all the experiments that we have performed. Specifically, we have used IBM's Melbourne quantum device. The qubit topology of IBM's Melbourne is as shown in Figure 2.
All multi-controlled logical gates of the generated logical circuits are needed to be decomposed into four types of one-qubit and two-qubit gates to map into IBM Q processor. We describe those gate sets and the required pulses in the IBM Q superconducting processors in Table 2. Since no pulse is required, we can perform U 1 with zero cost. The error level of U 3 is twice of U 2 and approximately an order of magnitude less than the CX gate.
Cross-resonance pulses and One π 2 pulse.
In Figure 3, we have depicted that the circuit depth increases with respect to the number of Toffoli controls through implementation of MCT gate on IBM Q device. With the increase of depth, error in quantum circuit also becomes colossal, which is thoroughly described next.

Errors in NISQ Devices
Qubits are not stable as even a small perturbation in the environment can change the state of a qubit. Error rate for a qubit can be defined as probability of undesired change in the qubit state. Errors in quantum computers can be classified into two categories: retention-errors and operational-errors.
Retention Errors or Coherence Errors: A qubit can retain data for only a limited time, and this duration is called as Coherence Time. There are two types of retention errors that can occur, and there are two metrics to specify the coherence time of a quantum device. A qubit in an high-energy state (state |1 ) naturally decays to the low-energy state (state |0 ), and the time constant associated with this decay is called T 1 Coherence Time. However, there is also a possibility that qubit might interact with environment and encounter a phase error even before relaxing into |0 state, and the time constant associated with this decay is called T 2 Coherence Time. T 2 indicates the time for a qubit to get affected by the environment.
Operational Errors or Gate Errors: Quantum operations do not give perfect result. So operations on qubits can also affect their state incorrectly due to errors, for example, an instruction that rotates the state by some desired angle can introduce extra erroneous rotation. Operational error-rate is defined as the probability of introducing an error while performing the operation. Thus, if the depth of a circuit is high, operational errors become huge.

General Hybrid Architecture for Quantum Algorithms
In this paper, the concept of hybrid quantum and classical computing is used [24] to solve maximum clique problem. In a hybrid quantum classical architecture, a classical algorithm is used for performing some basic operations(preparation of inputs, feeding output to the quantum machine) which may be required by the quantum algorithm. The quantum subsystem of this architecture initializes the quantum registers/nodes, prepares the inputs by applying quantum gates, execute the quantum oracle with the help of quantum gates and unitary transformations. Finally, evaluate the result stored in the quantum registers and send them to classical computer as feedback for further processing. The general architecture of the hybrid model is shown in Figure 4. Next, let us put some light on the fundamental concepts of Grover's algorithm and clique problem, which are of utmost importance with respect to our proposed approach.  Grover's algorithm works with a unitary operator O called the oracle function, which is defined by |x |q =⇒ |x |q ⊕ f (x) . where |x is the n qubit index register and |q is an additional qubit, called the oracle qubit. The functional view of Grover's Search Algorithm is presented here. ∃ function oracle (O) such that More elaborately, The steps of the Grover's algorithm are as follows: Initialization: The algorithm starts with the uniform superposition of all the basis states on input qubits n. The last ancilla qubit is used as an output qubit which is initialized to H |1 . Thus, we obtain the quantum state |ψ .
Sign Flip: Flip the sign of the vectors for which the oracle gives output 1.
Amplitude Amplification: We need to perform the inversion about the average of all amplitudes of quantum state for a certain number of iterations to make the amplitude of the marked state large enough, so that it can be obtained from a measurement with probability close to 1. This phenomenon is known as amplitude amplification which is performed by using a diffusion operator.

Number of Iterations:
Iterations of Grover's algorithm is the number of times that the oracle and amplification stages are performed. Each iteration of the algorithm increases the amplitude of the marked state by O( 1/N ). In this way, Grover's search algorithm requires N/M iterations to get the probability of one of the marked states M out of total N number of states set. If the number of iterations of Grover's algorithm are more than the optimal number, the probability of measuring the desired state actually goes down. Therefore, right number of iterations are important for getting proper result.
Diffusion operator: This diffusion operator of Grover's algorithm [2] inverts the amplitude of the input states about their mean value of amplitude. The generalized matrix representation of the diffusion operator is shown in Table 3. A six-qubit diffusion operator is also presented in Table 3. As shown in six-qubit diffusion operator, a 6-qubit Toffoli gate is required. Therefore, for n-qubit diffusion operator, n-qubit Toffoli gate is needed. This n-qubit Toffoli gate needs to be realized into one-qubit or two-qubit gates as discussed. While decomposing the n-qubit Toffoli gate, if the depth and the ancilla qubits increase arbitrarily then the time complexity of the algorithm also increases, which is undesirable.

Clique Problem
This subsection deals with the definition of a clique, k-clique, maximum clique of a graph and the clique problem in quantum domain, which are used in the rest of the paper.

Clique, k-clique and maximum clique
A clique is a complete sub graph of a graph. Particularly, if there is a subset of k vertices that are connected to each other, we state that the graph contains a k-clique. Let G(V, E) be a graph, where V be the set of vertices and E be the set of edges. If u, v ∈ E, then u and v are said to be adjacent. The set of vertices adjacent to a vertex v is called the neighbourhood of v and is denoted by N (v). A clique of a graph G is a set of vertices C in which u, v ∈ C =⇒ u, v ∈ E. We say that the graph contains a k-clique, if there is a subset of k vertices that are connected to each other. A maximum clique is a complete sub graph of a graph G, whose size is largest among all other complete sub graphs in G. In the graph of Figure 6, there are six vertices, but available cliques are (234)(352)(543)(425)(2345) and maximum clique is (2345).

Clique Problem in Quantum Domain
The most commonly studied clique problem specifically k-clique problem is the 3-clique problem or triangle finding problem. It is quite trivial to show that the randomized classical query complexity of the 3-clique problem is O(n 2 ) where n denotes the number of vertices in the graph [25]. Szegedy constructed a quantum algorithm for the 3-clique problem with query complexity O(n 10 7 ) [26]. Later, Magniez et al. showed, that the 3-clique problem can be solved with improved query complexity O(n 13 10 ) using a quantum walk approach [3]. To date, the best known lower bound on the quantum query complexity of the 3-clique problem is Ω(n) and the best known algorithm has a complexity of O(n 5 4 ) [27] [28]. Further, using quantum algorithms, some research works have also been done for the k-clique problem, when k > 3 [3,10]. Among all these works on k-clique problem, the state-of-the-art work [10] showed that to implement k-clique problem, at least n number of input qubits are required, when the number of vertices of given graph are n. In addition total log 2 k + 3 ancilla qubits are required to perform Grover's algorithm for solving k-clique problem. In this paper, we compare our proposed work with this state-of-the-art work on k-clique problem.
We also propose a generalized approach of solving MCP with the help of proposed approach of k-clique problem. There are some existing works on MCP in quantum computing, which are needed to be discussed. In 2015, Pronaya Prosun Das et al. [29] used the concept of quantum inspired evolutionary algorithm proposed by Kuk-Hyun Han et al [30] for solving the MCP. A quantum inspired evaluation algorithm is a combination of quantum computing and evolutionary algorithm. Elijah Pelofske et al. proposed quantum annealing for solving the MCP [31]. With this background, we are inclined to contribute some research advancement on clique problem in quantum domain.

General Flow of Proposed Automated Framework for Mapping Clique Problem to Quantum Computers
The complete flow of proposed design for mapping clique problem from a graph to quantum computer is shown in Figure 7. The proposed algorithm Oracle_clique_problem takes adjacency matrix as input and gives an QASM gate list as output. After realizing the logical gates into quantum computer supported 1-qubit and 2-qubit gates and through qubit mapping algorithm based on qubit topology, this QASM gate list can be further used as an input to a quantum computer to get the implementation result of clique problem. These MCT realization [32] and qubit mapping algorithm [33,34,35] are well-defined in the literature. We have just adopted them as a support in our framework.
The main contribution that we have made in this paper is to automatically design the circuit for clique problem using Grover's algorithm, when the adjacency matrix of graph and clique size k are given. As discussed in subsection 2.5, circuit design of diffusion operator is generalized irrespective of the given computational problem. Moreover, the oracle is problem specific, therefore our proposed algorithm is completely based on the generation of oracle circuit for clique problem.

Proposed Methodology of Circuit Design for Clique Problem
This section outlines the proposed methodology for the circuit synthesis of the k-clique problem using Grover's search algorithm. k-clique problem takes an adjacency matrix of a graph as input and determines the cliques of size k exist within the graph. As mentioned in the previous section, there are two parts of the Grover's search algorithm. While the diffusion operator is predefined for all problem instances, the oracle is specific to the given search problem. Hence, this paper proposes the design of an oracle circuit that takes a graph as input and determines if the graph contains a clique of size k. The oracle then marks those states that form a clique before the diffusion operator is applied to them. This proposed approach of k-clique problem is further used to solve MCP later in this section. Let's start with the proposed oracle for k-clique problem.

Proposed Oracle for k-Clique Problem
The aim of this paper is to construct the quantum circuit block for k-clique problem. Theoretically, the oracle is only a function that checks whether a specific item is the target or not. However, due to the linearity of quantum mechanics, when the oracle is applied to the superposition state |ψ 0 , all possible items are examined against the criteria. In this generalized circuit, there are seven main steps, which are Initialization, Hadamard transformation, Qubit activation, Edge detection, Clique detection, Qubit deactivation and Phase flip. For finding k-clique in a graph, all the steps have been described in the following subsections.

Initialization
If there are n vertices in the input graph, then the number of qubits required to represent each vertex is log 2 n . The oracle checks a combination of k vertices from a combination of all k vertices without duplicate vertices set at a time to determine if a clique is formed by them. Hence, a total of m = k * log 2 n input qubit lines are required to represent a combination of k vertices for input. Total number of ancilla qubits required to verify whether the subgraph formed by k number of vertices is complete or not is k 2 +1. The initial input qubits include m qubits prepared in the ground state |ψ = |0 ⊗m , ( k 2 +1) ancilla qubits in the ground state |θ = |0 ⊗( k 2 )+1 (These ( k 2 +1) ancilla qubits are required to prepare clique detector block, which is described in the next subsection thoroughly) and one output qubit in the excited state |φ = |1 , which is required to perform the CNOT operation of the oracle. This entire initialization can be mathematically written as:

Hadamard Transformation
After the initialization, the Hadamard transform H ⊗m on input qubits and H on output qubit is performed, therefore all possible states are superposed as |ψ 0 ⊗ |θ 0 ⊗ |φ 0 , where

Qubit Activation
For a given graph, vertices need to be numbered as {0, 1, 2 . . . n − 1}. The input qubit lines act as the binary representation of combination of k vertices. After Hadamard transformation on input qubit lines, |ψ 0 represents all possible combination of k vertices of given graph. But, the oracle checks only the combination of k vertices without any duplicate entry of vertices to determine if a clique exists or not. After Hadamard transformation, we get superposition of all the states which includes several invalid states. So we have reduced the search space by excluding all the invalid vertex combinations that do not contribute to clique. Only valid vertex combinations that may form a clique are considered using a technique named as Qubit Activation. To make sure that the oracle is checking only all possible combinations of k vertices without duplicate entry, all the input qubit lines are needed to be in the excited state |1 for those particular combination of k vertices to make the input qubit lines suitable as control lines for Multi Control Toffoli (MCT) operation. A number of NOT gate has to be imposed on the input qubit lines, which are in the ground state |0 for every possible combination of k vertices without duplicate entry. The qubit activation block activates a qubit by applying NOT gate if it is 0 to make the desired inputs are string of 1's.

Clique Detector Block
The proposed Clique Detector Block is shown in Figure 8. This block is defined as follows: , v k are the combination of k vertices of the input graph, which are activated input qubit lines and the f is the circuit output of Clique Detector Block, which is represented by ( k 2 + 1) st ancilla qubit line. Then, the Edge Detector Block imposes if a pair of vertices of input graph is adjacent. This edge detecting sub-circuit is defined next.

Edge Detector Block
The function of the Edge Detector Block is to detect edges between pair of vertices. A Multi-controlled Toffoli gate is applied for checking the connectivity between a pair of vertices. One MCT gate indicates presence of edge between a pair of vertices. So for detecting multiple edges, multiple MCT gates are needed.
This sub-circuit Edge Detector Block checks if two vertices are adjacent and changes the state of the output line to |1 . First k 2 ancilla lines are the representation of these output lines. If this is true to all k 2 ancilla lines, the Clique Detector confirms the presence of a clique in the form of |1 state on the ( k 2 + 1) st ancilla line, otherwise the state of ( k 2 + 1) st ancilla line remain same as it's initial state. Therefore, if there exists a clique, the ancila qubit state becomes |θ 1 for respective input vertices.
Clique detection block detects a clique by applying Toffoli gate between the output of edge detection blocks.

Qubit Deactivation
A number of NOT gate has to be imposed on the input qubit lines in the reverse order to deactivate the qubits again or to reset the input qubits to their initial value.

CNOT Operation
The output qubit state |φ 0 is initially set as 1 . Applying an CNOT gate on output line considering ( k 2 + 1) st ancilla qubit as control results in an eigenvalue kickback −1, which causes a phase shift for the respective input state, which makes a clique. The Figure 9 shows the generalized view of the oracular circuit for k-clique problem. The proposed algorithm for designing k-clique problem takes adjacency matrix as input and gives QASM gate list as output. This QASM gate list can further be used as an input to quantum simulator for verification or to map into quantum technologies. The algorithm for the synthesis of k-clique problem has a classical control that consist of classical components, which helps to build the quantum part of the algorithm. This algorithm can be illustrated as follows: • Classical input: The execution of the algorithm is as follows: • Step 1: Initialize Adjacency Matrix for the input graph. Calculate the total number of combinations of vertices using a classical algorithm. • Step 2: Initialize quantum register I[] that holds the input qubits with |0 .
• Step 3: Apply Hadamard gates on all the input qubits. • Step 4: Apply Hadamard gate on the output qubit. • Step 5: Execute the proposed unitary blocks i.e., Qubit Activation, Clique Detector, Qubit Deactivation for finding the marked states. This checks full connectivity in a set of vertices by applying unitary transformation of quantum gates.
• Step 6: Apply Grover's operator for maximizing the amplitude of the marked states. • Step 7: Measure the output of quantum register I[] using classical register.

Automated and Generalized Algorithm for Circuit Synthesis of Proposed Oracle for k-Clique Problem
The proposed algorithm of oracular circuit synthesis for the k-clique problem is illustrated in this subsection. Algorithm 1 describes the algorithm for oracle circuit synthesis of the k-clique problem. The algorithm takes the adjacency matrix of the given graph as input and the k sized cliques to be searched. The output of the algorithm is the oracle circuit in the form of a circuit netlist.

Algorithm 1: AutoGenerateOraclek-Clique
Input: Adjacency matrix adj(n, n) of graph G(V, E). Size of the clique to be searched that is k. Im are input qubit lines where 1 ≤ m ≤ k * log 2 n . Ax and T are ancilla lines where 1 ≤ x ≤ k 2 . O is output line. Output: Circuit Netlist(QASM) Initialize Im input lines with |0 followed by Hadamard gate, Ax ancilla lines with |0 , T ancilla line with |0 , and output line O with |1 followed by a Hadamard gate. Make n k combinations of vertices and store them in an array combarr. Initialize comb ← 0, m ← k * log 2 n and x ← 1; for i ← 1 to n k do insert Qubit Activation Block; insert k-clique Detector Block; insert Qubit Deactivation Block; comb ← comb + k (To check next possible combination of vertices for searching k-clique), x ← 1; The steps of the algorithms are described as follows: Algorithm 3: k-clique Detector Block for i ← comb to comb + k − 2 do for j ← i + 1 to comb + k − 1 do if adj(combarr(i), combarr(j)) ← 1 then if (j + 1)%k ← 0 then insert a multi-controlled Toffoli gate with I ((i%k) * log 2 n )+1 to I ((i+1)%k) * log 2 n input qubit lines and I ((j%k) * log 2 n )+1 to I ((j%k)+1) * log 2 n input qubit lines as control and ancilla Ax as target.
x ← x − 1; Step 1: From the adjacency matrix, the number of vertices in the graph are obtained, which are further used to calculate the total number of qubit lines required for the oracle circuit. If there are n vertices in the input graph, at first vertices are indexed as {0, 1, 2, . . . n − 1}. The algorithm stores n k combination of vertices without duplicate entry in an array called comb arr . The number of qubits required to represent each vertex is log 2 n . Hence, a total of k * log 2 n qubit lines are required for input. There are two types of ancilla qubit lines, A x and T which are initialized by |0 . A x ancillas are used for checking whether two vertices are connected by an edge and T ancilla is used for checking if k 2 edges form a clique of size k. There is one output line O, initialized to |1 , which indicates if a clique of size k exists in the input graph.
Step 2: The algorithm first applies Hadamard gates on all input qubit lines. For every possible combination from array comb arr , binary representation of k vertices in log 2 n binary digits stores in array active. This is further required to activate all the input qubit lines having |0 quantum state using appropriate NOT gates to make them suitable as control lines for MCT operation with the help of Qubit Activation method. This Qubit Activation method is described in Algorithm 2.
Step 3: For every possible combination from array comb arr , the algorithm checks every possible vertex pairs (comb arr (i), comb arr (j)) that are connected by an edge using edge detector block and insert a k-clique detector block on appropriate qubit lines for respective vertices. The circuit synthesis of k-clique Detector Block is described in Algorithm 3. The algorithm checks for every possible combination of k vertices without duplicate entry, if vertex pairs (comb arr (i), comb arr (j)) are connected by an edge, then insert a multi-controlled Toffoli gate with I ((i%k) * log 2 n )+1 to I (i%k) * log 2 n input qubit lines and I ((j%k) * log 2 n )+1 to I ((j%k)+1) * log 2 n input qubit lines as control and one of the ancilla A x as target if (j + 1)%k is zero, (where i, j are the index values of array comb arr ) or else insert a multi-controlled Toffoli gate with I ((i%k) * log 2 n )+1 to I (i%k) * log 2 n input qubit lines and I ((j%k) * log 2 n )+1 to I (j+1) * log 2 n input qubit lines as control and one of the ancilla A x as target. If all vertex pairs of a vertex combination are adjacent, then each of the A x ancilla qubits are activated, which implies there exists a clique of size k between them. This information is stored in the T ancilla by applying a k 2 -controlled Toffoli gate with A x ancillas as control and T ancilla as target. These steps are needed to be repeated followed by Qubit Deactivation Block to generate the mirror of it in order to keep the overall circuit reversible.
Step 4: The algorithm then applies a CNOT gate to the output line with T ancilla as control. As a result, the output line shall indicate the presence of a clique of size k in the graph. On the contrary, if there is no clique of size k in the input graph, T ancilla will be in their initial state |0 . The remaining steps of the algorithm generates the mirror for the original circuit in order to keep the overall circuit netlist reversible. To understand Algorithm 1 more precisely, an example of 4 vertices graph has been considered The oracle circuit generated for the example graph by the proposed algorithm is illustrated in the next subsection.

Generation of proposed Oracle Circuit for k-clique Problem for an Exemplified Graph
The circuit for finding triangle in the graph of Figure 10 has been shown in Figure 11. For a 4-vertex graph, adjacency matrix is represented by adj(4, 4) and vertices are indexed as 0, 1, 2, 3. Each vertex is represented by log 2 4 = 2 qubits. Hence, total six qubit lines are required for inputs. As per Algorithm 1, input qubit lines are represented as I m , where 1 ≤ m ≤ 6. These input qubit lines are initialized with |0 followed by Hadamard gate. In order to store edge information, three ancilla lines A x , where 1 ≤ x ≤ 3, one ancilla line T initialized to |0 and one output line O initialized to |1 followed by Hadamard gate are required to store the output of the circuit. Hence, a total of 11 qubit lines are required for the simulation. The algorithm now stores 4 3 = 4 possible combination of vertices as ((0, 1, 2), (0, 1, 3), (0, 2, 3), (1, 2, 3)) in an array called comb arr . The algorithm now initializes variable comb as 0, variable m as 6 and x as 1. • For each zero in active array, insert NOT gate to qubit line I r+1 where r is the index value of active array to make these input lines suitable as control for MCT operation or edge detector block.
• Thereafter, for every possible vertex pair (0, 1), (0, 2), and (1, 2), the algorithm checks that they are connected by an edge or not by accessing the information of adjacency matrix.
• Thereafter, Insert a three-controlled Toffoli gate with each of the three A 1 , A 2 , and A 3 ancilla lines as control and T ancilla as target. • Again to make three A 1 , A 2 , and A 3 ancilla lines reusable, In case of vertex pair (comb arr (i = 0), comb arr (j = 1)) = (0, 1), adj(0, 1) = 1, insert an MCT gate with I 1 to I 2 input qubit lines and I 3 to I 4 input qubit lines as control and A 2 as target. • for vertex pair ((comb arr (i = 0), comb arr (j = 2)) = (0, 2), adj(0, 2) = 1, then (j + 1)%3 is zero, then insert an MCT gate with I 1 to I 2 input qubit lines and I 5 to I 6 input qubit lines as control and A 1 as target. • These steps are repeated for other three combination of three vertices. The algorithm then applies a CNOT gate to the output line O with T ancilla as control. As a result, the output line shall indicate the presence of a clique in the graph. The remaining steps of the algorithm generate the mirror for the original circuit in order to keep the overall circuit netlist reversible.

Mathematical Formulation of Proposed Oracle for k-clique Problem for an Exemplified Graph
Generalization of the oracle for k-clique problem is already well established in the previous subsections. This section shows how an arbitrary graph formulates the proposed oracle mathematically. We have considered the same graph as shown in Figure 10 and the corresponding generated circuit given in Figure 11.
Initialization: The input qubits are initialized with |0 . Ancilla qubits are initialized with |0 . Output qubit is initialized with |1 . Entire initialization can be mathematically written as: Hadamard Transformation: After the initialization, the Hadamard transform H ⊗6 on input qubits and H on output qubit is performed, therefore all possible states are superposed as |ψ 0 ⊗ |θ 0 ⊗ |φ 0 , where Oracle: • 1st combination of vertices |000110 :-1. Search space reduction using qubit activation:-After applying NOT gates to the 1st (I 1 ), 2nd (I 2 ), 3rd (I 3 ) and 6th (I 6 ) qubit of all superposed states, the quantum state evolves as 2. Edge detection:-Two MCT gates are applied for the combination of vertices (|00 , |10 ) and (|01 , |10 ) for two edges. The quantum state evolves as 3. Clique detection:-An MCT gate flips the fourth ancilla qubit T , if the three ancilla qubits A 1 , A 2 , A 3 are 1. The quantum state evolves as 4. Mirror circuit for 1st combination: After applying mirror circuit the quantum state evolves as • 2nd combination of vertices |001011 .
|ρ 17 = 1 √ 2 7 (|00000000000 + |00000100000 + · · · + |00011000000 + · · · + |00101100011 · · · + |00011100011 · · ·+|01101100000 +· · ·+|11111100000 )+ 1 • Hadamard gate on the output qubit: After applying Hadamard gate on the output qubit (O) the quantum state evolves as We observe that the two marked states |000111 and |001011 are with negative amplitude only. Now, Grover's diffusion operator performs the inversion about the average of all amplitudes of the quantum state for a certain number of iterations to get the amplitude of the marked state large enough. So, the amplitude of the marked states become higher than other states.

Automated and Generalized Algorithm for Solving Maximum Clique Problem using the Proposed
Approach of k-clique Problem in Classical-Quantum Hybrid Architecture The automated and generalized algorithm of quantum circuit synthesis for maximum clique problem is discussed in this subsection. Maximum clique problem finds clique in a graph with maximum cardinality. Input of the algorithm is the Adjacency Matrix of the graph G(V, E) and the output is the QASM gatelist. The algorithm uses the concept of proposed k-clique algorithm. The algorithm starts with finding clique of size k = n (n is total number of vertices of the graph) using the algorithm of k-clique. If a clique is found, it is maximum clique of the graph. Otherwise a clique is searched for size n − 1. The process continues up to n = 2. The algorithm is performed in classical-quantum hybrid architecture. As described in subsection 2.4, hybrid architecture requires a feedback loop from quantum part of the algorithm to the classical part of the algorithm, which is portrayed in Figure 12 for MCP problem.
The steps of the circuit synthesis for MCP are shown below: • Step 1: Algorithm for finding k-clique is used for searching clique of size n, where the number vertices of the given graph is k. • Step 2: If a clique is found, then exit from the process. • Step 3: If clique is not found, then clique size n is reduced to n − 1 and repeat the whole process from step 1. • Step 4: At each iteration the value of n is reduced by 1 (n, n − 1, n − 2, n − 3, . . . , 2), until a clique is found.
The algorithm for solving MCP using the proposed approach of k-clique problem is illustrated in Algorithm 4.

Cost analysis of the Circuit
Cost of a quantum circuit depends on the number of the input lines, ancilla lines and the number of gates used. If the circuit is designed for a size k, then total combination is n k , when the number of vertices of given graph is n. Therefore, a total number of O(k * n k + k) logical gates are required to design the oracle circuit for a variant of k-clique problem, which lists all the cliques of size k. As this is a first its kind approach of solving such k-clique problem, there are no sufficient works to compare the oracular gate cost. Albeit we assume that if the oracle circuit of the state-of-the-art work [10] can be designed in such a way that it gives all the cliques of size k as output, then the oracular gate cost of our proposed work should be better than [10]. But, this proof remains out of the scope of this paper.
In present scenario, due to the constraint of less number of qubits, quantum circuit with large number of gates with multiple qubits cannot be implemented in real hardware due to its depth. As discussed in the previous section that each vertex is represented by log 2 n qubits, so total number of input qubits k * log 2 n are required along with k 2 + 2 ancilla qubits as shown in Table 4. Therefore, for detecting an edge between two vertices, we need a multi-controlled Toffoli gate with 2 * log 2 n control qubits and for detection of clique of size k, we need multi-controlled Toffoli gate with k 2 control qubits as shown in Table 4. Finally, we can conclude that k * log 2 n -qubit MCT gate is required to perform diffusion part of the proposed approach of Grover's algorithm. Analysis of the qubit cost and the depth of the complete circuit for k-clique problem is as follows: Lemma 1 Improved qubit cost for proposed approach of solving k-clique problem, when n >> k, where n is a large number of nodes of given graph (G(V = n, E = e)) and k is respectively very small.
The total number of qubits are required to solve k-clique problem using proposed approach is k * log 2 n + k 2 + 2. Whereas discussed in subsection 2.6.2 in the background, state-of-the-art approach requires a total n + log 2 k + 3 qubits for solving k-clique problem, which gives a clique of size k as output. The state-of-the-art problem is the subset of the proposed problem of k-clique as our proposed algorithm gives all the cliques of size k as output. So from this, we can infer that if we solve such variant of k-clique problem, then it can also solves the state-of-the-art problem of k-clique. To prove the stated Lemma, we have considered three instances of n and k values. Let's start with if n = 1024 and respectively k is very small i.e., 3, then the qubit cost 3 * log 2 1024 + 3 2 + 2 = 35 of the proposed approach is very efficient as compared to the qubit cost 1024 + log 2 3 + 3 = 1029 of state-of-the-art approach. Now, if we slightly increase the value of k as 32, but still remains very small as compared to n = 1024, then the qubit cost 32 * log 2 1024 + 32 2 + 2 = 818 of the proposed approach is still efficient as compared to the qubit cost 1024 + log 2 32 + 3 = 1032 of state-of-the-art approach. But, if we increase the value of k little further towards n, our approach becomes costlier with respect to qubit cost to find a clique size of k in a given graph. For instance, suppose n = 1024 and k = 64, the qubit cost 64 * log 2 1024 + 64 2 + 2 = 2658 of the proposed approach is costlier as compared to the qubit cost 1024 + log 2 64 + 3 = 1033 of state-of-the-art approach. Thus, we can conclude that our proposed approach outperforms the state-of-the-art approach of solving k-clique problem with respect to qubit cost, when k is respectively very small with respect to large n.
Proposition 1 Improved circuit depth for proposed approach of solving k-clique problem, when n >> k, where n is a large number of nodes of given graph (G(V = n, E = e)) and k is respectively very small.
From Lemma 1, it can be inferred that the input qubit cost k * log 2 n of the proposed approach is also efficient as compared to the input qubit cost n of the state-of-the-art approach, when n >> k and when k ≡ n, it becomes inefficient as n * log 2 n > n. It is already defined that the diffusion operator is imposed on all the input qubits. Therefore, a k * log 2 n -qubit MCT is required to perform this diffusion for the proposed approach as compared to n-qubit MCT for the state-of-the-art. As k * log 2 n < n, when n >> k, we can infer from Figure 3 in subsection 2.3 that the depth of the circuit is also efficient of the proposed approach as compared to the state-of-the-art method. As Figure 3 suggests that with the increasing number of controls in the MCT gate also increases the depth of the circuit drastically, our goal is to restrict the number of controls in the MCT gate as compared to the [10], which is successfully achieved for n >> k.

Implementation Results
Quantum simulators are used to simulate the behaviour of a quantum algorithm on a classical computer in order to have an idea of how the circuit is executed on a real quantum computer could be. We can also experiment quantum algorithm in quantum computers via IBM cloud. IBM offers its Quantum Experience platform with freely accessible quantum computers up to 14 qubits and a quantum simulator up to 32 qubits. Though, we can perform the experimentation with real quantum computers, simulators still play an important role in testing quantum algorithms. We have to consider the fact that, it is not possible to access to certain data which is useful for testing purposes on a real quantum computer. Another problem is that we would like to test a quantum algorithm that needs a large number of qubits, which is still unreachable for real hardware machines. Implementation of a circuit in real quantum device depends on the circuit depth or length of the critical path of the circuit. Unfortunately, the circuit depth is highly dependent on the hardware layout of qubits and the connections between them. Due to this limitation, we could not implement the circuit for larger graphs in the real quantum device.

Ideal Simulation on ibmq_qasm_simulator
The oracle circuit for k-clique problem for the graph shown Figure in 13 has been implemented in ibmq_qasm_simulator. Here, we have 6 qubit lines for inputs, there can be a total of 2 6 = 64 different qubit combinations as |000000 , |000001 , . . . , |111111 after applying Hadamard gate to all input qubits. Hence, the database on which Grover's algorithm is applied contains 64 different elements. Figure 14 shows the complete gate level synthesis of the Grover's circuit for 3-clique problem. The simulation steps on IBM Q_Qasm_Simulator [17] required for the synthesis are as follows: 1. The oracle checks whether two vertices are adjacent or not. It determines whether a clique is formed by a three-vertex combination. three-vertex combinations are |000110 . It then inverts the amplitude of the solution state for which the vertex combination forms a clique. The solution state for this case is |000110 .
2. The output of the oracle is acted upon by the Grover's diffusion operator as shown in Figure 14. The diffusion operator amplifies the amplitude of the marked solution state.
3. Steps 1 and 2 constitute the Grover's operator for the Grover's search algorithm. Hence, these two steps are The resultant output after applying Grover's operator π 4 Figure 15, where the amplitude of the solution state has been amplified. The location of the solution state is |000110 , which is the vertex combination in an example graph of Figure 13 that forms clique with high probability. The circuit for clique size three has been simulated in IBM Q_Qasm_Simulator. The marked state |011000 is in high amplitude as shown in the output Figure 15, which depicts that |00 , |01 and |10 form a triangle.

Implementation on IBM Q_16_melbourne
The results of the simulation using the IBM's simulator are not realistic as it show ideal output without any error and noise. The circuit of Figure 14 is implemented again on IBM Q_16_melbourne. Executing again the algorithm in IBM Q_16_melbourne gives us the histogram in Figure 16. As we observe that the desired state |000110 is not marked properly and the noise caused a loss of information. As discussed in the background, quantum gates and qubits are noisy and error prone. So, for a realistic result, quantum circuit can be implemented with noise model obtained from real quantum device. Qiskit Aer offers ten standard error models, like Pauli Error, Phase Damping Error, Mixed Unitary Error, Depolarization Error, Reset Error, Thermal Error where user can customize the error models. In addition, the user can choose whether to apply the error to all qubits or a specific set of qubits. We have executed the quantum circuit of Figure 14 on the remote ibmq_qasm_simulator, applying a noise model obtained from the available data about ibmq_16_melbourne . Executing again the algorithm with the mentioned noise model gives us the histogram in Figure 17: the peaks are no more clearly distinguishable and the noise caused a loss of information. Figure 18 shows the comparison between the two histograms, with ideal computation in blue and real (noisy) computation in orange.

Analysis of the Result
We observe from the implementation results in the real quantum device, that the result has been affected by noise, which is obvious from Figure 17. Here, we calculate percentage of gate error and decoherence error of the circuit of Figure 14, while implementing in IBM Q_16_M elbourne. The total number of gates of the circuit in Figure 14 are 230. From the data available about IBM Q_16_M elbourne, we can mention the following two parameters: The probability that at least one gate fails is given by the following This result infers that without accounting for decoherence errors, failure rate of our circuit is 38%. This is a first important piece of information that gives us an idea of the problem of noise in quantum computation. Now, talking about the errors due to decoherence, we can try to compute the time needed by the ibmq_16_melbourne to finish the execution of our circuit. The basis gates set used by the ibmq_16_melbourne to realize quantum circuits and translate more complicated gates into simpler ones is composed by U 1, U 2, U 3 and CNOT. From public data about the ibmq_16_melbourne available at [36] and [23], we can obtain the required data to calculate the following: • Time needed for U1: 0ns; • Time needed for U2: 100ns + 20ns = 120ns; • Time needed for U3: 100ns + 20ns + 100ns + 20ns = 240ns; • Roughly average time needed for CNOT: 100ns+20ns+360ns+20ns+100ns+ 20ns + 360ns + 20ns = 1000ns.
The real circuit depth is equal to 139. Now, let's suppose that this circuit depth is composed by 80% of CNOT gates, 15% bof U 3 gates and 5% of U 2 gates i.e., we have 111 CNOT gates, 21 U 3 gates and 7 U 2 gates.
• Total time required for U 3 gate is 21 × 240 = 5040ns So, total time required to execute the circuit is 111000 + 840 + 5040 = 116880ns = 116.86µs. Hence, our circuit will take approximately 116.86 µs. As coherence times for Melbourne are T 1 = 71.5µs and T 2 = 21.4µs, we can infer that we have a relatively low probability to execute the whole circuit without at least one error due to decoherence. It's worth to notice that the circuit of Figure 14 stands for a total number of gates equal to 230 and a circuit depth is 139. For larger circuit total number of gates and circuit depth both will be higher. The Qiskit code for generating the simulation graphs is given in the github. The link is https://github.com/abhaduri77/k-clique-code.git.

Complexity Analysis
Proposed combinatorial approach for the synthesis of k-clique problem in this paper is based on Grover's algorithm, which gives quadratic speed up than its classical counter part. As the total number of input vertices are n and clique size is k, the oracle and the diffusion of Grover's algorithm needs to be iterated O( n k m ) to find m possible cliques with high probability.

Conclusion
An automated and generalized approach of quantum circuit synthesis for k-clique problem using Grover's algorithm with O( n k m ) iterations for any given undirected and unweighted graph has been proposed in this paper, which gives all cliques of size k as output. We exhibited that the proposed approach of solving k-clique problem is cost efficient with respect to qubit and circuit depth, when k is very small with respect to a large graph. Triangle finding problem is demonstrated as an example of k-clique problem, when k = 3 to showcase the effectiveness of our proposed approach of solving k-clique problem. The algorithm for k-clique problem is further used to solve maximum clique problem in classical-quantum hybrid setting. An automated end-to-end framework for mapping clique problem to any available quantum computer is also designed and proposed. The generated circuits are implemented in NISQ devices and ibmq_qasm_simulator. From the results, we have observed that the current real quantum computers are affected by some important limitations, like the maximum number of available qubits and different kinds of noise and circuit depth. In future scope of this paper, we shall try to apply some error mitigation scheme that can reduce the error of the output in the real quantum device so that we can have the expected output. We shall also try to reduce the number of gates and ancilla qubit for designing the circuit for clique problem. These will help one to implement clique problem for more larger graphs with large k.