1 Introduction

According to Shenvi, Kempe, and Whaley [17], quantum walks provide one of the most promising features, an intuitive framework for building new quantum algorithms. They were pioneers in designing a quantum search algorithm on the hypercube based on quantum random walks [14]. Recent works have used the quantum walks to search weights and train artificial neural networks [19, 20].

The topology of the structure where the walk is applied considerably affects the evolution of the walker [22]. Therefore, many works are developed to improve the performance of quantum walks, quantum search algorithms in different structures: one-dimensional, two-dimensional, and multidimensional grids, complete and bipartite graphs, among others [4, 5, 11, 15].

Quantum walk modification proposals are also made to improve their performance. For example, Wong [24] added to each vertex of a two-dimensional grid a self-loop, so the walker has some probability of staying put, achieving an improvement over the algorithm without self-loop [3].

Rhodes [16] proposed an ideal weight for all vertex-transitive graphs with a single marked vertex such that the ideal self-loop weight is equal to the degree of the loopless graph divided by the total number of vertices. Potovcek [14] observed that the nearest neighbors are also presented with high probability and Nahimovs [10] that adjacent vertices can be hard to find by quantum walks.

In this way, we investigate whether the optimal value of \(l = (d / N)\) for a single marked vertex is optimal for multiple marked vertices, where d is the degree of the loopless vertex and N is the number of vertices. We analyzed the quantum walk on hypercube without self-loop and with self-loop. We analyzed the quantum walk on the hypercube for multiple marked adjacent and non-adjacent vertices. Finally, we find an optimal value of l for a quantum walk in the hypercube with multiple marked vertices.

This paper is organized as follows. In Sect. 2, we present some concepts about quantum walks and specifically the quantum walk on the hypercube. In Sect. 3, we characterize the probability distribution along with the space, adjust the self-loop weight for multiple marked vertices, and search for adjacent marked vertices. Finally, in Sect. 4 is the conclusion.

2 Quantum Walk

The processing of quantum information is governed by quantum mechanics or quantum physics [18]. Quantum computing study the processing of this information [8, 13, 25]. Quantum walks are the quantum counterpart of classical random walks. Discrete and continuous-time quantum walks are the advanced tools used to build quantum algorithms [1, 2]. The main feature that differentiates these two types of quantum walks is the timing used to applying the evolution operators. In the quantum walk in continuous time, the evolution operator is applied at any time, whereas the quantum walks in discrete time, the evolution operator is applied in discrete time steps [21]. The quantum walk evolution in the discrete-time process occurs by the successive applications of a unitary evolution operator U that acts on the Hilbert space

$$\begin{aligned} \mathcal {H} = \mathcal {H}^{C} \otimes \mathcal {H}^{S}. \end{aligned}$$

The coin space \(\mathcal {H}^{C}\) is the Hilbert space associated with a quantum coin, and the walker’s space \(\mathcal {H}^{S}\) is the Hilbert space associated with the position of the nodes in a graph, for example. The evolution operator U is defined in Eq. 1.

$$\begin{aligned} U = S(C\otimes I_{N}) \end{aligned}$$
(1)

where, S is the shift operator, i.e., a permutation matrix that acts in the walker’s space based on the state of the coin space. The unitary matrix C is the coin operator [17]. Therefore, the equation of evolution represented by a quantum walk at time t is given by

figure a

2.1 Quantum Walk on the Hypercube

According to Venegas [21], the hypercube is defined as an undirected graph of degree n and \(N = 2^{n}\) nodes. Each node is represented by an n-bit binary string. Two nodes \(\vec {x}\) and \(\vec {y}\) are connected by an edge if the Hamming distance between them is 1, i.e., \(\left| \vec {x} - \vec {y} \right| = 1\). This means that \(\vec {x}\) and \(\vec {y}\) only differ in a single bit. The expression \(\left| \vec {x} \right| \) is the Hamming weight of \(\vec {x}\). The Hilbert space associated with the quantum walk on the hypercube is

$$\begin{aligned} \mathcal {H} = \mathcal {H}^{n} \otimes \mathcal {H}^{2^{n}}, \end{aligned}$$

where \(\mathcal {H}^{n}\) is the Hilbert space associated with the quantum coin space, and \(\mathcal {H}^{2^{n}}\) is the Hilbert space associated with nodes on the hypercube.

According to Shenvi [17], in a d-dimensional hypercube, the d directions specify the coin state. Kempe [7] defines that directions can be labeled by the n base-vectors on the hypercube which corresponding to the n vectors of Hamming weight 1. These n vectors are represented by the states , where \(e_{d}\) has a 1 in the d-th bit. The shift operator S described in Eq. 2 acts mapping a state .

(2)

The initial state of the quantum walk in the hypercube is defined according to Eq. 3 as an equal superposition over all N nodes and n directions.

(3)

According to Rhodes [16], the hypercube was the first graph in which quantum walks were researched. In their work, Shenvi [17] presented a quantum search algorithm based on the random walk quantum architecture. In this article, we are based on the approach used by Wong [24]. The pure quantum walk (without search) evolves by repeated applications from the evolution operator described in Eq. 1, where C is Grover’s “diffusion” operator on the coin space and is given by

(4)

where, \(I_{n}\) is the identity operator, n is the vertex degree loopless, and is the equal superposition over all n directions [9, 17], i.e.,

(5)

We include a query to the “Grover oracle”, described in Eq. 6, at each step of the quantum walk.

$$\begin{aligned} U' = U \cdot (I_{n} \otimes Q) \end{aligned}$$
(6)

where, , and means the marked vertex. The system is initiated according to the initial state presented in Eq. 3.

3 Analyzing the Quantum Walk on the Hypercube

In this section, we experimentally analyze the quantum walk on the hypercube searching for multiple marked vertices. The simulations and the obtained results are detailed in the following subsections.

3.1 Characterizing the Probability Distribution Along the Space

Previous works showed there is an amplification in the solution neighborhood, which interferes with the amplification of the solutions by the quantum walk on the hypercube [11, 14, 17]. Initially, it is necessary to understand how the probability amplitudes are distributed in the search space and how the quantum walk evolves in the hypercube over time considering the impacts caused by the solution neighborhood.

Figure 1 shows the probability of success after one hundred steps for the quantum walk in the hypercube with one, two, three, and four arbitrarily marked vertices. Although the search algorithm is able to amplify the probability amplitudes of the marked vertices, if a measurement is performed, the probability of finding one of the solutions is still unsatisfactory. Another interesting aspect that can be observed is that as the number of marked vertices increases, the speed of amplification the probability amplitudes also increases. However, it is necessary to increase the probability amplitudes of the marked vertices.

Figure 2 shows the probability distributions of the marked vertices only after the number of iterations necessary to reach the maximum value of the probability amplitude close to 1/2. As Potovcek et al. [14] noted in their work, we also note that the set of neighbors have a high probability. If we add the amplitudes of the neighbor’s vertices, the values are compatible with the amplitude value of the marked vertex. We conclude that a considerable part of the energy, approximately 1/2, is retained in the neighbors of the marked vertices. Figure 2d, shows the probability distribution of four marked vertices. Note that the amplitudes of each vertex have their maximum and a neighborhood region. The x-axis distribution is the relative position of the position on the hypercube. It explains why even increasing the number of marked vertices, the success probabilities do not reach values above 1/2.

Fig. 1.
figure 1

Success probability after 100 steps in a hypercube with 1024 nodes. The solid blue curve is the success probability for one solution. The dotted orange curve is the success probability for two solutions. The dot-dashed green curve is the success probability for three solutions. The dotted red curve is the success probability for four solutions. (Color figure online)

Fig. 2.
figure 2

Probability distribution of the quantum walk after the number of iterations necessary to reach the maximum value of the probability amplitude with \(n = 10\) and \(N = 1024\) vertices. The y-axis values are at different ranges to improve visualization. (a) solid blue bar show the probability distribution for one marked vertex. (b) solid blue bar and orange dashed bar show the probability distribution for two marked vertices. (c) solid blue bar, orange dashed bar and green dash-dot bar show the probability distribution for three marked vertices. (d) solid blue bar, orange dashed bar, green dash-dot bar and dotted red bar show the probability distribution for four marked vertices. (Color figure online)

Figure 3 shows the success probability for the quantum walk with one and four marked vertices after one hundred steps. Figure 3a shows the behavior of the success probability of one marked vertex, the solid blue curve, and its neighbors, which is the dotted orange curve. If a measurement is performed, the probability of getting a neighbor vertex is greater than getting a marked vertex. With probability above \(90\%\), you get the solution or a vertex that is one step away from the solution. Figure 3b shows the behavior of the success probability of four marked vertices, the solid blue curve, and their neighbors, the dotted orange curve. Note that in a step when the probability of success of the marked vertices is high, the probability of success of the neighbors decreases, and in the next step, when the probability of success of the neighbors is high, the probability of success of the marked vertices decreases. Because of this behavior, if a measurement is performed, the probability of getting a neighbor is high. This happens in Fig. 3a but more smoothly.

Observing these results, we must consider the probability p of obtaining a marked vertex and the probability \(p' = (1 - p)\) of obtaining an unmarked vertex which is the sum of the probabilities of the \((N - k)\) vertices, where k is the number of marked vertices. These results are shown in Table 1. Note the column of the value of \(p'\), which is composed of the value of the amplitudes of the neighbors and the amplitude of the vertices that are neither neighbors nor marked. The probability of the walker finding a region is high because the energy is concentrated in the neighboring region. It is concluded that the amplification of the neighborhood around the marked vertices interferes with the probability of success of finding a target vertex.

Table 1. Probabilities of success of marked and unmarked vertices.
Fig. 3.
figure 3

Probability of success after 100 steps with \(n = 10\) and \(N = 1024\) vertices. (a) shows the probability of success for one marked vertex and its neighbors. (b) shows the probability of success for four marked vertices and their neighbors. (Color figure online)

3.2 Adjusting the Self-loop Weight for Multiple Marked Vertices

Many works have been proposed with the purpose of improving the search capacity of quantum algorithms. According to Wong [23], adding a self-loop to each vertex boosts the success probability from 1/2 to 1. A modification to the initial state in the Eq. 3 and to Grover’s coin in the Eq. 4 is needed so that the self-loop can be added. The addition of the self-loop is described in Eq. 7. Thus, the coin space is now an \((n + 1)\)-dimensional space [16].

(7)

One of the concerns when adding a self-loop at each vertex is knowing the best self-loop value. More specifically, in the case of the quantum walk on the hypercube, Rhodes [16] proposed an optimal self-loop value

$$\begin{aligned} l = \frac{d}{N}, \end{aligned}$$
(8)

where d is equal to the degree of the loopless graph and N is the number of vertices in the hypercube. Recently, two works showed that inserting the number of marked vertices in calculating the self-loop value optimizes quantum walks. Carvalho [6] shows that the optimal value of the self-loop for quantum walks in D-dimensional grids with multiple marked vertices is

$$\begin{aligned} l = \frac{2Dm}{N}, \end{aligned}$$

where 2D is the number of movements the walker can do, not counting the self-loop, m the number of marked vertices, and N the number of vertices of the grid. Nahimovs [12] shows that for different types of two-dimensional grids - triangular, rectangular, and honeycomb the optimal self-loop value is also,

$$\begin{aligned} l = \frac{m\cdot d}{N} \end{aligned}$$

where d is the degree of the vertex, m is the number of marked vertices, and N is the number of vertices of the grid.

Fig. 4.
figure 4

Comparison between multiple self-loops values and \(l = (n/N)\). (a) shows the success probability for one marked vertex. (b) shows the success probability for two marked vertices. (c) shows the success probability for three marked vertices. (d) shows the success probability for four marked vertices. (Color figure online)

Figure 4a shows the probability of success after two hundred steps for one marked vertex. Here, the values of l were the same as used by Rhodes. The dashed red curve has the optimum value of l. Our interest was to investigate whether the value of l described in Eq. 8 also improved the walk results for a number (\(k>1\)) of marked vertices. For this, we performed three more experiments where we increased the number of marked vertices up to four. As we added the marked vertices the success probability of the dashed red curve decreased to \(88.7\%\) (4b) while the success probability of the dotted purple curve increased to \(99.8\%\) (4b) but then also decreased to \(96.2\%\) (4c) and \(89.3\%\) (4d). It indicates that a new value of l is required when the number of marked vertices increases. To find the optimal self-loop for multiple marked vertices, we defined a set of values in the form \(l' = (\alpha \cdot l)\), where \(\alpha \in \mathbb {N}\).

Figure 5 compares the probability of success for a set of marked vertices, \(k = \{2, 3, 5, 14, 17\}\), these vertices were chosen randomly as well as their number. The self-loop values for these vertex numbers are \(\alpha \cdot l\), where \(l = (d/N)\) and \(\alpha = \{1, 2, 3,...\}\). Note that the curves have their maximum points exactly at the locations on the x-axis where the \(l'\) values are. We can conclude that the value of (\(\alpha = k\)). Therefore, we can set the value of l for multiple marked vertices for the quantum walk in the hypercube,

$$\begin{aligned} l' = \frac{n}{N} \cdot k \end{aligned}$$
(9)

where n is equal to the degree of the loopless vertex of the hypercube, N the number of vertices in the hypercube, and k the number of marked vertices. The self-loop value shown by Nahimovs [12] for the quantum search in various types of two-dimensional grids coincides with the optimal self-loop value for the search for a quantum walk in the hypercube.

Figure 5 shows that, as the values of l approach the optimal value, the probability of success of the curve also approaches its maximum value. We can observe this behavior in Table 2 which shows the probability of success for multiple values of l and multiple marked vertices. Consider the values of the main diagonal, which are the maximum success probabilities for each \(l = (n/N)\cdot k\).

Fig. 5.
figure 5

Investigation to set the value of l for multiple marked vertices.

Table 2. Probability of success for multiple values of l.

Table 2 shows the relationship between the self-loop value and the number of marked vertices. We observe the relationship between the self-loop value and the number of marked vertices. Note that when the values of l approach the optimal values for each number of marked vertices, there is an improvement in the probability amplitude. Figure 6 shows the probability of success after two hundred steps for multiple marked vertices. We can conclude that for cases where there is more than one marked vertex, the optimal value of \(l = (n/N)\cdot k\).

Fig. 6.
figure 6

Probability of success after 200 steps. Solid blue curve, \(k = 1\). Dotted orange curve, \(k = 2\). Green dash-dot curve, \(k = 3\). Red dashed curve, \(k = 4\). Dotted purple curve, \(k = 5\) (Color figure online)

3.3 Searching for Adjacent Marked Vertices

The results found in the previous sections refer to the search for non-adjacent marked vertices, i.e., \(\left| \vec {\omega _{i}} - \vec {\omega _{j}}\right| \ne 1\) the Hamming distance from vertex \(\vec {\omega _{i}}\) and all other marked vertices is different from 1. Nahimovs et al. [11] shows in their work that for quantum walks in the hypercube if the search space contains marked neighbors vertices, the search can be drastically affected. The authors considered two sets, one with two adjacent marked vertices and the other with two non-adjacent marked vertices. In the first case, the two adjacent marked vertices are \(M = \{0, 1\}\). The absolute value of the overlap remained close to 1, and the probability remains close to the initial state probability. In the second case, the two non-adjacent marked vertices are \(M = \{0, 3\}\). The behavior on this one is different, the same behavior as the solid blue curve in Fig. 3a.

As the addition of self-loop in the quantum walk in the hypercube improved the search for multiple non-adjacent marked vertices, we investigated the case where the marked vertices are adjacent. We consider ten sets of vertices, \(M = [\{0,1\},\{0,1,2\},\cdots ,\{0,1,2,4,8,\cdots ,256,512\}]\), i.e., all vertices adjacent to the vertex 0. We add one more vertex to the set of marked vertices on each new walk until the number of vertices in M is equal to the degree n of the vertex.

Figure 7 shows the probability of success after two hundred steps. Figure 7a shows the result for the value of \(l = (n/N)\). The probability reaches its maximum when the number of vertices reaches \(k = 4\) with a probability of success of \(99.1\%\). Then the probability starts to decrease as k increases. Figure 7b shows the result for the value of \(l = (n/N)\cdot k\). The probability reaches its maximum when the number of vertices reaches \(k = 11\) with a success probability of \(94.5\%\). Although the probability increases with a slower speed when \(k = 5\), it already reaches \(78.3\%\). This behavior is interesting for search spaces where the marked vertex density is high. Note the probability of the solid cyan curve. This behavior was found in work done by Nahimovs et al. [11] and was repeated here in our experiments. According to the authors, this is because the quantum walk has a stationary state.

Fig. 7.
figure 7

Probability of success after 200 steps with \(n = 10\) and \(N = 1024\) vertices. Shows the probability of success for k adjacent marked vertices. (a) shows for \(l = (n/N)\) and (b) for \(l = (n/N)\cdot k\).

Figure 8 shows the comparison between what happens to the success probabilities in Fig. 7 when the number of k increases. Note the dotted orange curve, the probability of success grows to its maximum value when the value of \(l = (n/N)\cdot k\). The same does not happen when \(l = (n/N)\).

Fig. 8.
figure 8

Maximum probability reached for each number of marked vertices in the neighborhood after one hundred steps with \(n = 10\) and \(N = 1024\) vertices. Evaluating the interference of the number of adjacent marked vertices in the value of l. (Color figure online)

We considered before that the marked vertices were neighbors. Now, let us analyze the possibility that in addition to having marked vertices in the neighborhood, there are also marked vertices that are not neighbors. We run ten experiments, and each one starts with two adjacent marked vertices \(M = \{0,1\}\). In each experiment, a \(i = \{1,2,3,\cdots \}\) non-adjacent vertex is randomly marked and the next marked neighbor, i.e., \(M = \{0,1,2,...\}\). Therefore, in the tenth experiment, there will be eleven adjacent and ten non-adjacent vertices.

Fig. 9.
figure 9

Maximum probability reached for each number of marked vertices after one hundred steps with \(n = 10\) and \(N = 1024\) vertices. (a) shows the probability of success for k adjacent and non-adjacent marked vertices for \(l = (n/N)\). (b) shows the probability of success for k adjacent and non-adjacent marked vertices for \(l = (n/N)\cdot k\). (Color figure online)

Figure 9 shows the behavior of probability amplitudes when for each set of adjacent vertices, a number of non-adjacent vertices are marked. Figure 9a shows that as new non-adjacent vertices are marked the probability is affected. Note that the behavior seen in the solid blue curve in Fig. 8 when there were no non-adjacent vertices is similar, i.e., as the density of the marked vertices increases, the probabilities decrease, even adding the vertices non-adjacent. The same can be seen in the case of the dotted orange curves in Figs. 8 and 9b, i.e., when the density of the marked vertices increases, the probability also increases, this tells us that the value of \(l = (n/N)\cdot k\) is optimal for high marked vertex densities.

Figure 10 shows the probability of success for the search of marked adjacent and non-adjacent vertices in the search space. We performed an experiment, where, at every hundred steps, an adjacent vertex and a non-adjacent vertex were marked, i.e., for each M set of adjacent vertices a vertex \(i \notin M\) was marked randomly, then, \(M' = \{0,1,i_{0}\},\{0,1,i_{0},2,i_{1}\},\cdots ,\{0,1,i_{0},2,i_{1},4, i_{2},\cdots ,512,i_{10}\}\). Figure 10a shows the probability of success for \(l = (n/N)\) and Fig. 10b shows the probability of success for \(l = (n/N) \cdot k\). Note that the probability of success above \(90\%\) is achieved in a smaller number of steps.

Fig. 10.
figure 10

Probability of success after 100 steps with \(n = 10\) and \(N = 1024\) vertices. (a) shows the probability of success for k adjacent and non-adjacent marked vertices for \(l = (n/N)\). (b) shows the probability of success for k adjacent and non-adjacent marked vertices for \(l = (n/N)\cdot k\). (Color figure online)

4 Conclusions

Many efforts are applied in order to improve the performance of quantum search algorithms. Quantum walks are the main tool for building these algorithms. We initially analyzed the quantum walk in the hypercube applying Grover’s search and came to the conclusion that neighbor vertices affect the search performance, an observation that has been corroborated by other authors. We found that the walk could not improve its results even for a number of marked vertices equal to one. Many authors have developed works for adding self-loops in various types of graphs and grids of different dimensions. In this sense, we decided to investigate how to improve the quantum search in the hypercube using self-loops. Previous works defined the optimal self-loop value as \(l = (d/N)\) for one marked vertex to the quantum walk on the hypercube. After performing experiments we saw that this value of l was not optimal for multiple marked vertices. We arrive at a value of \(l = (n/N)\cdot k\) for an arbitrary number of vertices. This value is also used when searching in two-dimensional grids. Another aspect of the quantum walk in the hypercube is whether the marked vertex is adjacent or not, this interferes with the search performance. We then analyzed whether the value of \(l = (n/N)\) and \(l = (n/N)\cdot k\) had any positive effect when applied to the hypercube vertices. The results show that the value of \(l = (n/N)\) is not optimal for the quantum walk in the hypercube with multiple marked vertices adjacent or not. It also shows that for a search space where there are marked adjacent vertices, just one non-adjacent marked vertex is sufficient for the value of \(l = (n/N)\cdot k\) to be better. According to the results presented here, there is a greater than \(90\%\) probability that the measurement will collapse in one of the solutions. Recent works have used the quantum walks to search weights and train artificial neural networks [19, 20]. The quantum walk in the hypercube has an interesting behavior, the amplification of neighbors vertices. In future work, we intend to use this quantum walk to find a set of weights to initialize and train classical artificial neural networks. We also intend to analyze the quantum walk in the hypercube with multiple weighted self-loops.