0% found this document useful (0 votes)
15 views6 pages

A Quantum Algorithm For Minimal Spanning Tree

The document proposes a quantum algorithm to find the minimum spanning tree in a graph by modifying Prim's classical algorithm. It replaces the classical search in Prim's algorithm with quantum search, which leads to a more efficient algorithm. The paper also discusses implementing and simulating the probabilistic quantum-classical algorithm to represent the results.
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)
15 views6 pages

A Quantum Algorithm For Minimal Spanning Tree

The document proposes a quantum algorithm to find the minimum spanning tree in a graph by modifying Prim's classical algorithm. It replaces the classical search in Prim's algorithm with quantum search, which leads to a more efficient algorithm. The paper also discusses implementing and simulating the probabilistic quantum-classical algorithm to represent the results.
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/ 6

A Quantum Algorithm for Minimal Spanning Tree

Mohammad Reza Soltan Aghaei1, Zuriati Ahmad Zukarnain2, Ali Mamat3, and
Hishamuddin Zainuddin4
[email protected] , [email protected], [email protected],
1

[email protected]

Abstract
Quantum search solves what is known as the
Quantum computing algorithms are considered unstructured search problem, which can be stated as
for several problems in graph theory. Classical follows: Given a function f(x) that accepts integer
algorithms involve searching over some space for arguments x in the range 1 to N, which is zero
finding the minimal spanning tree problem in a everywhere except for one value x = t, find the value
graph. We modify classical Prim's algorithm and t using the fewest calls to f(x). If there are N entries
replace quantum search instead of classical search, in the telephone directory, it will take us O(N/2) calls
of which it will lead to more efficient algorithm. Also to f(x) on average, and O(N) calls to f(x) in the worst
we proposed the structure for non-classical case, to find the desired solution that the name of the
algorithms and design the various phases of the person whose telephone number we have.
probabilistic quantum-classical algorithm for Unstructured searches arise in important real
classical and quantum parts. Finally, we represent world applications, such as searching for
the result of implementing and simulating Prim's cryptographic keys [5]. For example, cracking the
algorithm in the probabilistic quantum-classical Data Encryption Standard would involve searching
algorithm. through some 256 = 7 × 1016 possible keys. If it could
test these keys at a rate of 100 million keys per
1. Introduction second, a classical computer would take about 23
years to discover the correct key. A quantum
Science and engineering have benefited from computer, running at the same rate, could use a
advances in algorithms and software. Over the last quantum search algorithm to find the answer in just
few years, several quantum algorithms have emerged. four years.
Some are exponentially faster than their best classical In this study, a classical-quantum algorithm is
counterparts [1, 2]; others are polynomially faster proposed to find the shortest path in graph. We
[3,4]. Quantum search falls into the latter category. consider Prim's algorithm for finding the minimum
While a polynomial speedup is less than we would weight spanning tree in a given graph and use
like ideally, quantum search has proven to be quantum search in implementing of Prim's algorithm.
considerably more versatile than the quantum The result of implementation and simulation shows
algorithms exhibiting exponential speedups. Hence, that using quantum search algorithm is faster than
quantum search is likely to find widespread use in classical one.
future quantum computers. The rest of this paper is organized as follow. First
we have a review on related work on quantum search
M.R. Soltan Aghaei is with Dep. of Computer Eng., Islamic
algorithm and discuss some of the exciting ways that
Azad University of Khorasgan, Isfahan, Iran, and PhD candidate
in Faculty of Computer Science and Information Tech., University can be used in science and engineering. Then, in
Putra Malaysia 43400 UPM Serdang, Selangor, Malaysia. section 3, we consider the Prim's algorithm for
Zuriati A.Z., and Ali Mamat are with Faculty of Computer finding the minimum weight spanning tree in a given
Science and Information Technology, University Putra Malaysia graph. Next, in section 4, a new framework is
43400 UPM Serdang, Selangor, Malaysia,
www.fsktm.upm.edu.my . proposed to improve the analyses and design of non-
Hishamuddin Z. is with Laboratory of Computational classical algorithm and we implement and simulate a
Sciences and Informatics, Institute for Mathematical Research, classical-quantum algorithm. Finally, the result
Universiti Putra Malaysia, 43400 UPM Serdang, Selangor, analyzes and conclusion is presented.
Malaysia.

978-1-4244-2328-6/08/$25.00 © 2008 IEEE

Authorized licensed use limited to: UNIV ESTADUAL PAULISTA JULIO DE MESQUITA FILHO. Downloaded on April 10,2023 at 16:46:53 UTC from IEEE Xplore. Restrictions apply.
2. Related Works Grover’s Search algorithm offers a polynomial
speedup over what we can do classically. It is
Lov Grover, a computer scientist at Lucent nevertheless extremely versatile and has inspired
Technologies Bell Labs, discovered the quantum several other quantum algorithms. Moreover, by
search algorithm in 1996. The algorithm solves the nesting one quantum search algorithm within another,
unstructured search problem, under the assumption even more impressive speedups appear to be
that there exists a computational oracle that can possible, and a better-than-classical exponential time
decide whether a candidate solution (such as the quantum algorithm for NP-hard problems appears to
index of an entry in the telephone directory) is the be within reach. This could have practical
true solution the index of the sought-after number applications in several areas of science and
[3,4]. engineering.
Originally, Grover’s algorithm was called the
database search algorithm, but this name was 3. Prim's Algorithm
dropped because it misled people into thinking that it
could be used to search real databases when, in fact, Prim's algorithm is based on a generic MST
it cannot [6], at least not without first encoding the algorithm. The main idea of Prim's algorithm is for
database in the quantum state to be amplitude finding shortest path in a given graph. Prim's
amplified. If this encoding is done naively, the cost algorithm has the property that the edges in the set A
of creating the database would be linear in its size always form a single tree. We begin with some vertex
that is, O(N). Thus, the cost of encoding followed by v in a given graph G =(V, E), defining the initial set
quantum search would be O(N + ), whereas the of vertices A. Then, in each iteration, we choose a
cost of a classical search alone would be just O(N) minimum-weight edge (u, v), connecting a vertex v in
beating the quantum scheme. the set A to the vertex u outside of set A. Then vertex
One of the most effective search algorithms for u is brought in to A. This process is repeated until a
hard computational problems such as constrained spanning tree is formed[8].
optimization is the so-called randomized algorithm
[10]. In the randomized algorithm use a sequence of
3.1. Algorithm
random numbers to determine a trajectory through
some search space. Quantum search can speed up
In Prim's algorithm choose a node and build a
such classical randomized algorithms [11]. The idea
tree from there selecting at every stage the shortest
is to use a superposition of seeds for the
available edge that can extend the tree to an
pseudorandom number generator to create a
additional node.
superposition of final states that is very likely to
contain a solution within it.
MST_PRIM (G, w, r)
Quantum search can also use to determine
1. Q ← V[G]
statistical properties such as means, medians,
2. for each u in Q do //each u∈V[G]
maxima, and minima of functions in the square root
3. key [u] ← ∞
of the number of steps needed to compute these
4. π[u] ← NIL
properties classically to the same precision [14]. Also
5. key [r] ← 0
the quantum mean estimation algorithm improved
and showed how to use it to compute the value of a 6. while Q ≠ ∅ do //while queue is not empty do
high-dimensional numerical integral [12]. The 7. u ← EXTRACT_MIN (Q)
evaluation of high-dimensional numerical integrals 8. for each v in Adj[u] do
might be a practical use of quantum mean estimation 9. if v∈Q and w(u, v) < key [v]
that in turn is derived from Grover’s quantum search 10. then π[v] ← w(u, v)
algorithm. 11. key [v] ← w(u, v)
A final application of quantum search is in the
domain of experimental physics to prepare selected 3.2 Analysis
superposition states. By amplitude amplifying an
equally weighted superposition of indices in some The performance of Prim's algorithm depends of
range, could selectively to create a state that is just a how we choose to implement the priority queue Q.
superposition of prime numbers within this range. Definitions: Sparse graphs are those for which |E| is
Thus, the quantum search algorithm might find a role much less than |V|2 i.e., |E| << |V|2 we preferred the
in experimental quantum physics as a way of adjacency-list representation of the graph in this case.
systematically manufacturing desired superposition On the other hand, dense graphs are those for which
states [13, 14]. |E| is graphs are those for which |E| is close to |V|2. In

978-1-4244-2328-6/08/$25.00 © 2008 IEEE

Authorized licensed use limited to: UNIV ESTADUAL PAULISTA JULIO DE MESQUITA FILHO. Downloaded on April 10,2023 at 16:46:53 UTC from IEEE Xplore. Restrictions apply.
this case, we like to represent graph with adjacency- structure link of classical part and quantum part of
matrix representation. algorithm.
A probabilistic quantum-classical algorithm can
3.2.1 When a Q is implemented as a adjacency be divided to following steps:
matrix. The timeline 1-5 is Θ(V). EXTRACT_MIN
takes O(V) time and there are |V| such operations. 1- Initialize classical part of algorithm.
Therefore, a total time for EXTRACT_MIN in 2- Run first classical part of algorithm.
while-loop is O(V2). Hence, the running time of the 3- Initialize Machine State.
algorithm with array implementation is O(V2 + E) = 4- Apply the Unitary Transformation.
O(V2). 5- Measure Machine Stat.
6- Evaluate Measurement.
3.2.2 When a Q is implemented as a binary heap. 7- If find solution then go to step 8 else go to step 3.
To building of heap in lines 1-5 perform O(V) time. 8- Run second classical part of algorithm.
The while-loop in lines 6-11 is executed |V| times, 9- Stop.
and since each EXTRACT_MIN operation takes Steps 1, 2, 6, 7 and 8 do by classical operations,
O(lgV) time, the total time for all calls to but steps 3, 4 and 5 do by quantum operations.
EXTRACT_MIN operation is O(V lgV). The
assignment in line 11 involves an implicit
DECREASE_KEY operation on the heap, which Classical
Classical Algorithm Classical Output
takes O(lgV) time with a binary heap. Thus, the total input (On Classical output Data
Input Computer)
time for Prim's algorithm using a binary heap is O(V Data Quantum
lgV + E lg V). Quantum Algorithm
(On Quantum
Quantum
input output
Computer)

3.2.3 When Q is implemented as a Fibonacci heap.


In this case, the performance of the
DECREASE_KEY operation implicitly called in line Feedback from the Quantum Algorithm to the Classical Algorithm
11 will be improved. Instead of taking O(lgV) time,
Figure 1: The structure link of classical part
with a Fiboncci heap of V elements, the
and quantum part of algorithm.
DECREASE_KEY operation will take O(1)
amortized time. With a Fibonacci heap, an
EXTRACT_MIN operation takes O(lg V) amortized All lines of Prim's algorithm run on the classical
time. Therefore, the total time for Prim's algorithm part of algorithm except EXTRACT_MIN procedure
using a Fibonacci heap to implement the priority in line 5. This procedure find the minimum value of a
queue Q is O(V lgV + E). computable function as the set of input arguments
ranges over a finite, but unordered list. In this case, if
the list is of length N, then the quantum cost of
4. A Quantum-Classical Algorithm
finding the minimum is O( ), while the classical
cost is O(N). We implement EXTRACT_MIN as a
A quantum computer is a device that takes
quantum procedure and use quantum search on
advantage of quantum mechanical effects to perform
quantum computer to find minimum value. We
certain computations faster than a purely classical
implement both parts of algorithm and simulate this
machine can. Quantum parallelism is best understood
quantum part on classical computer.
in the context of the concepts of superposition,
entanglement and measurement. A quantum
computer performs, in principle, exponentially many 5. Result
computations simultaneously; however,
exponentially many results of those computations We implemented the quantum versions of Prim's
cannot be read out, leaving us with the fascinating algorithm and simulated the Grover's algorithm with
problem of how to use such a machine to accelerate Matlab on classical computer. We have tested this
n
computations that interest us, But scaling them up to algorithm with N=2 possible inputs that n is number
solve problems that are classically intractable offers of qubits. The quantum algorithm use quantum
enormous technical challenges. computation and needed more memory. Our
The algorithm that we are going to develop is computer had 4 GB RAM and we could run with
consists of two parts; the first part is classical maximum 12-qubits. With 12-qubits as input data,
algorithm of which can be done on a classical we have 212 =4096 vertices in queue Q.
computer. The second part is Quantum algorithm of The simulation results for n=12 qubits as a data
which can be done on a quantum computer that we index will be shown in the figure 4. In these
simulate on classical computer. Figure 1 show the diagrams, number of possible inputs is N=4096 and
this number is length of queue Q. We assumed that

978-1-4244-2328-6/08/$25.00 © 2008 IEEE

Authorized licensed use limited to: UNIV ESTADUAL PAULISTA JULIO DE MESQUITA FILHO. Downloaded on April 10,2023 at 16:46:53 UTC from IEEE Xplore. Restrictions apply.
there is one solution in queue Q. The amplitude
value of solution in Grover's algorithm reaches to one
after (π/4) =50 iterates and the amplitude value of
other data reached to zero.
In figure 5 compare speeds of some versions of
Prim's algorithm for finding the minimal weight
spanning tree in the graph. The time taken by Prim's
algorithm in these states is determined by the speed
of the queue operations. In the next section we
discuss on these states and to compare all version of
Prim's algorithm in the complete and incomplete
graphs.
Figure 4. The simulation result of quantum
6. Discussion search algorithm with 12 qubits input data
and 4096 elements in queue with (π/4) =50
With comparing the time complexities of the iteration that the record of 3750 is solution
some versions of Prim's algorithms, mentioned in key in queue.
section 3.2, we can see that |E| is greater than |V|, the
Prim's algorithm with the Fibonacci-heap
implementation will be asymptotically faster than the
one with the binary-heap implementation.
The time taken by Prim's algorithm is
determined by the speed of the queue operations.
With the queue implemented as a Fibonacci heap, it
takes O(VlgV + E) time.
However, if the edge-weights are integers ranging
from 1 to |V|, the array implementation does not help.
The operation DECREASE_KEY would still be
reduced to constant time, but operation
EXTRACT_MIN would now use O(V) time, for the
total running time of O(V2 +E). Therefore, we are
better off sticking with the Fibonacci-heap
implementation, which takes O(VlgV + E) time. (a) In sparse graph
When graph G = (V, E) is sparse, From above
description, it can be seen that both versions of
Prim's algorithm will have the running time O(V
lgV). Therefore, the Fibonacci-heap implementation
will not make Prim's algorithm asymptotically faster
for sparse graph. When graph G is dense, we can see
that Prim's algorithm with the binary heap will take
V2lgV time whereas Prim's algorithm with Fibonacci-
heap will take V2. Therefore, the Fibonacci-heap
implementation does not make Prim's algorithm
asymptotically faster for dense graphs.

(b) In dense graph

Figure 5. Compare speeds of Prim's


algorithm in four states of implementation to
finding the shortest path in the graph.

When a Q is implemented as a quantum search,


EXTRACT_MIN takes O( V ) time. Therefore, a
total time of the quantum work for filling in the cost

978-1-4244-2328-6/08/$25.00 © 2008 IEEE

Authorized licensed use limited to: UNIV ESTADUAL PAULISTA JULIO DE MESQUITA FILHO. Downloaded on April 10,2023 at 16:46:53 UTC from IEEE Xplore. Restrictions apply.
function and in while-loop is O(V V ). Since the details are yet to be worked out. It is also needs to
total number of edges in all the adjacency list is |E|. design a general plan for implementation and
Therefore for-loop iterates |E| times with each simulation of non-classical algorithms.
iteration taking O(1) time. Hence, the running time of
the algorithm with array implementation is O(V V + 8. References
E). When graph G is sparse, the total cost of the
whole algorithm is therefore O(V V +V) = O(V V ) [1] D. Deutsch and R. Jozsa, “Rapid Solution of Problems
and when graph G is dense, this time is O(V V +V2) by Quantum Computation,” Proc. Royal Soc. London,
London, vol. 439, 1992, pp. 553–558.
= O(V2). Hence in average the quantum minimal
weight spanning tree algorithms can effectively use [2] P.W. Shor, “Polynomial-Time Algorithms for Prime
the graph structure with a low memory cost better Factorization and Discrete Logarithms on a Quantum
than classical algorithms. Computer,” Proc. 35th Ann. Symp. Foundations of
Computer Science, IEEE CS Press, Los Alamitos, Calif.,
1994, pp. 124–134.
7. Conclusion and future work
[3] L.K. Grover, “A Fast Quantum Mechanical Algorithm
With comparing the time complexities of the for Database Search,” Proc. 28th Ann. ACM Symp. Theory
versions of Prim's algorithms, mentioned in sections of Computing, ACM Press, New York, 1996, pp. 212–219.
3 and 6, we can see that the time taken by Prim's [4] L.K. Grover, “Quantum Mechanics Helps in Searching
algorithm is determined by the speed of the queue for a Needle in a Haystack,” Physical Rev. Letters, vol. 79,
operations. The Prim's algorithm with the Fibonacci- no. 2, 1997, pp. 325–328.
heap implementation will be asymptotically faster
than the one with the binary heap implementation. [5] G. Brassard, “Searching a Quantum Phone Book,”
Science, vol. 275, 1997, p. 627.
With the queue implemented as a Fibonacci heap, it
takes O(VlgV + E) time. Since the keys in the [6] C. Zalka, “Using Grover’s Quantum Algorithm for
priority queue are edge weights, it might be possible Searching Actual Databases,” Physical Rev. A, vol. 62,
to implement the queue even more efficiently when 2000.
there are restrictions on the possible edge weights.
However, if the edge-weights are integers ranging [7] C.H. Bennett et al., “Strengths and Weaknesses of
from 1 to |V|, the array implementation does not help Quantum Computing,” SIAM J. Computing, vol. 26, no. 5,
and the total cost is O(V2 +E). Therefore, we are pp. 1510–1523, 2001.
better off sticking with the Fibonacci-heap
[8] K. H. Thomas, C. E. Leiserson, R. L. Rivest, and C.
implementation. Stein, Introduction of Algorithms, MIT press, 2001.
When the graph is not complete, the Fibonacci-
heap implementation will not make Prim's algorithm [9] R. Paturi et al., “An Improved Exponential Time
asymptotically faster for sparse graph. When the Algorithm for k- SAT,” Proc. IEEE 39th Symp.
graph is complete, we can see that Prim's algorithm Foundations of Computer Science, IEEE CS Press, Los
with the binary heap will take |V|2lg|V| time whereas Alamitos, Calif., 1998, pp. 628–637.
Prim's algorithm with Fibonacci-heap will take |V|2.
Therefore, the Fibonacci-heap implementation does [10] N.J. Cerf, L.K. Grover, and C.P. Williams, “Nested
Quantum Search and Structured Problems,” Physical Rev.
not make Prim's algorithm asymptotically faster for
A, vol. 61, 2000.
dense graphs.
When a queue is implemented as a quantum [11] A. Carlini and A. Hosoya, “Quantum Probabilistic
search, the quantum minimal weight spanning tree Subroutines and Problems in Number Theory,” Physical
algorithms can effectively use the graph structure Rev. A, vol. 62, 2000.
with a low memory cost better than classical
algorithms. Thus for highly unbalanced complete [12] D.S. Abrams and C.P. Williams, “Fast Quantum
bipartite graphs, the quantum algorithm is better than Algorithms for Numerical Integrals and Stochastic
the classical algorithm. Hence, the quantum Processes,” http://xxx.lanl.gov/abs/quant-ph/9908083,
2001.
algorithm is much faster than linear array for finding
the minimal weight spanning tree in graph. Also the [13] L.K. Grover, “Synthesis of Quantum Superpositions
quantum algorithm does not need any special by Quantum Computation,” Physical Rev. Letters, vol. 85,
conditions for graph and this algorithm can be used no. 6, 2000, pp. 1334–1337.
for all kinds of graphs.
The quantum search algorithm can be extended to [14]. Colin P. Williams, "Quantum Search Algorithms in
other classical algorithms for the future work. Science and Engineering," IEEE Computing in Science &
Presumably the quantum algorithms given here can Engrineering, 1521-9615/01/ 2001.
be readily extended to these problems, although the

978-1-4244-2328-6/08/$25.00 © 2008 IEEE

Authorized licensed use limited to: UNIV ESTADUAL PAULISTA JULIO DE MESQUITA FILHO. Downloaded on April 10,2023 at 16:46:53 UTC from IEEE Xplore. Restrictions apply.
[15]. P. Kaya, R. Laflamme, and M. Mosca, An
Introduction to Quantum Computing, Oxford University
Press, 2007.

978-1-4244-2328-6/08/$25.00 © 2008 IEEE

Authorized licensed use limited to: UNIV ESTADUAL PAULISTA JULIO DE MESQUITA FILHO. Downloaded on April 10,2023 at 16:46:53 UTC from IEEE Xplore. Restrictions apply.

You might also like