1 Introduction

Quantum walk is a topic of great interest in quantum information theory [1,2,3]. Numerous possible applications were already discovered, including quantum spatial search [1, 4], Google algorithm [5,6,7] or quantum transport [8, 9]. Throughout this article, we consider quantum spatial search procedure, which is an example of an algorithm yielding a result up to quadratically faster than its classical counterpart. Since the very first paper describing it was published [1], plenty of new results have appeared in the literature. This includes the noise resistance [10], efficiency analysis [1, 4, 11,12,13], imperfect implementation [14] and difference in implementation [15].

Unfortunately, most of the results concern very specific graph classes like complete graphs [1, 10] or their simplex [14], and binary trees [13]. Due to some kind of ‘symmetry,’ it was not necessary to make analysis for all vertices separately (as, for example, in complete graphs or hypercubes), or at least it could be easily fixed (for example by the level in binary trees). The first big step toward the generalization into a large collection of graphs is the work of Chakraborty et al. [4], where Erdős–Rényi random graph model \(\mathcal G(n,p)\) was analyzed (with np standing for the number of vertices and probability of an edge being present, respectively). The authors have proven that for almost all graphs almost all vertices can be found optimally. Since there are already known examples of graphs for which some vertices are searched in \(\Theta (n^{\frac{1}{2}+a})\) time for \(a>0\) [1, 13] (throughout this paper \(O,o,\Omega ,\omega ,\Theta ,\sim \) denote asymptotic relations, see [16]), the result cannot be strengthened into ‘all graphs.’

The proof of the main result of Chakraborty et al. [4] is based on a lemma describing limit behavior of a principal eigenvector \(|\lambda _1\rangle \) of the adjacency matrix. The authors show that for \(p>\log ^{\frac{3}{2}}(n)/n\), if \(|s\rangle =\frac{1}{\sqrt{n}}\sum _{v\in V}|v\rangle = \alpha |\lambda _1\rangle +\beta |\lambda _1\rangle ^\bot \), then almost surely \(\alpha = 1-o(1)\). Since the time needed for quantum spatial search is \(\Theta (\frac{1}{|\langle {w}|{\lambda _1}\rangle |})\), where \( w\) denotes the marked vertex, we have that almost all vertices can be found in optimal time. However, in this case it is not trivial which vertex is chosen, since the Erdős–Rényi graph is not necessarily symmetric. This kind of convergence allows the existence of vertices, which can be found in linear time. As an example, consider a vector

$$\begin{aligned} |\lambda _1'\rangle =\frac{1}{n \sqrt{k}} \sum _{i=1}^k |i\rangle + \frac{\sqrt{n^2 - 1}}{n \sqrt{n-k}}\sum _{i=k+1}^{n}|i\rangle , \end{aligned}$$
(1)

for \(k=o(n)\). We have \(\langle {s}|{\lambda _1'}\rangle = \alpha = 1 - o(1)\), and thus a priori vector \(|\lambda _1'\rangle \) from [4], can be the leading eigenvector of an adjacency matrix. In such a case, the argument used by [4] is not tight enough to exclude a possibility that all vertices \(w \in \{1,\dots ,k\}\) will be found in \(\Omega (n)\) time, which is actually a random guess complexity. Note that it is even possible that for almost all graphs, such vertices exist. Furthermore, many of the applications mentioned in [4] require \(\langle {i}|{v_1}\rangle \approx \langle {j}|{v_1}\rangle \) for arbitrary ij. Otherwise, creating Bell states or quantum transport will be at least very difficult.

What is more, due to the laws of quantum mechanics, the measurement time needs to be known since the beginning. This includes not only differences in the complexity, but a constant as well. For example, if for two different nodes \(v,v'\) we have \(\langle {v}|{\lambda _1}\rangle =\frac{1}{\sqrt{n}}\) and \(\langle {v'}|{\lambda _1}\rangle =\frac{2}{\sqrt{n}}\), then different measurement times should be chosen for each.

Both effects mentioned above can be described as hiding nodes in the graphs. Finally, we propose a following research problem: can we actually ‘hide’ a vertex in a random Erdős–Rényi graph? We have managed to show that in the case of adjacency matrix, \(p=\omega (\log ^3(n)/(n\log ^2(\log (n)))\) is a sufficient requirement for all-vertices optimal search. Under further constraint \(p=\omega (\log ^8(n)/n)\), we have common time measurement. Moreover, we went a step further than the authors of [4] and studied also Laplacian matrix, which led us to tighter results. In the case of Laplacian matrix, \(p>(1+\varepsilon )\log (n)/n\), for constant \(\varepsilon >0\), is sufficient for common time measurement; however in the \(p=\Theta (\log (n)/n)\) case, it may not be true that almost surely the probability 1 of a successful measurement is achieved. If \(p<(1-\varepsilon )\log (n)/n\), then a random graph contains almost surely isolated nodes [17]; hence, it is possible to hide a vertex for both adjacency and Laplacian matrix.

2 Element-wise optimality for adjacency matrix

Let \(G=(V,E)\) be a simple undirected graph with node set \(V=\{1,\dots ,n\}\) and edge set \(E\subset V\times V\). Moreover, let \(\mathcal H_G\) be a quantum system spanned by an orthonormal basis \(\{|v\rangle : v \in V\}\). Quantum spatial search is based on the Schrödinger differential equation

$$\begin{aligned} |\dot{\psi }_t\rangle = -\mathrm {i}H |\psi _t\rangle = -\mathrm {i}\left( -M_\mathrm{G}- |w\rangle \langle w| \right) |\psi _t\rangle , \end{aligned}$$
(2)

where \(M_\mathrm{G}\) is a matrix corresponding to the graph structure, typically rescaled adjacency matrix A or Laplacian \(L=D-A\), where D is the degree matrix. In [4], authors have proven that for a random Erdős–Rényi graph in case of an adjacency matrix almost all vertices from almost all graphs can be found optimally. We say some property holds almost surely for all graphs, when the probability of choosing random graph having such is \(1-o(1)\). The result was based on the following simplified lemma.

Lemma 1

[4] Let H be a Hamiltonian with eigenvalues \(\lambda _1\ge \dots \ge \lambda _n\) satisfying \(\lambda _1=1\) and \(|\lambda _i|\le c <1\) for all \(i>1\) with corresponding eigenvectors \(|\lambda _1\rangle =|s\rangle ,|\lambda _2\rangle ,\dots ,|\lambda _n\rangle \) and let w denote a marked vertex. For an appropriate choice of \(r\in [-\frac{c}{1+c},\frac{c}{1-c}]\), the starting state \(|s\rangle \) evolves by the Schr\(\ddot{o}\)dinger’s equation with the Hamiltonian \((1+r)H +|w\rangle \langle w|\) for time \(t = \Theta (\sqrt{n})\) into the state \(|f\rangle \) satisfying \(|\langle {w}|{f}\rangle |^2\ge \frac{1-c}{1+c}+o(1)\).

According to the proof of the lemma, the bound can be derived by choosing r satisfying

$$\begin{aligned} \sum _{i=2}^n \frac{|\langle {w}|{\lambda _i}\rangle |^2}{(1+r)\lambda _i -r} = \sum _{i=2}^{n}|\langle {w}|{\lambda _i}\rangle |^2 . \end{aligned}$$
(3)

The assumptions from the lemma guarantee the existence of \(r\in [\frac{-c}{1+c},\frac{c}{1-c}]\) satisfying the above equality. Note that the result is constructive for \(c=o(1)\), as in this case \(r=o(1)\) as well as \(t=\frac{\pi \sqrt{n}}{2}\). Otherwise, a proper determination of r and t is needed.

According to the lemma, two properties of \(M_\mathrm{G}\) are useful in proving search optimality. Firstly, the matrix should have a single outlying eigenvalue. Secondly, if \(|\lambda _1\rangle \) is the eigenvector corresponding to the outlying eigenvalue, one should have \( \vert \langle {w}|{\lambda _1}\rangle \vert =\Theta (\frac{1}{\sqrt{n}})\).

Note that in the limit \(n\rightarrow \infty \), norms cease to be equivalent; thus, different concepts of closeness of vectors can be chosen. In [4], authors choose \(1-|\langle {\psi }|{\phi }\rangle |\) for arbitrary vectors \(|\psi \rangle , |\phi \rangle \), which allows to infer that o(n) of nodes can be found in time \(\omega (\sqrt{n})\), see the example given in Eq. (1). In order to make statements concerning all vertices, we should study the limit behavior of the principal vector in \(L^{\infty }\) norm \(\Vert \cdot \Vert _\infty \), which bounds the maximal deviation of coordinates. More precisely, we are interested whether \(\Vert | \lambda _{1}\rangle -|s\rangle \Vert _\infty = \frac{o(1)}{\sqrt{n}}\), as this would imply that for an arbitrary marked node \( w\) we have \( \langle {w}|{\lambda _{1}}\rangle =(1+o(1))\frac{1}{\sqrt{n}}\). The above will give us the bound \(\Theta (\frac{1}{|\langle {w}|{\lambda _1}\rangle |}) = \Theta (\sqrt{n})\) for the time needed for quantum spatial algorithm to locate vertex w.

Indeed, a convergence of infinity norm was shown by Mitra [18] providing \(p\ge \log ^6(n)/n\). We have managed to weaken the assumptions and thereby strengthen the result.

Proposition 1

Suppose A is an adjacency matrix of a random Erdős–Rényi graph \(\mathcal G(n,p)\) with \(p=\omega ( \log ^3(n)/(n\log ^2\log n))\). Let \(|\lambda _{1}\rangle \) denote the eigenvector corresponding to the largest eigenvalue of A and let \(|s\rangle =\frac{1}{\sqrt{n}}\sum _{v}|v\rangle \). Then,

$$\begin{aligned} \Vert |\lambda _{1}\rangle -|s\rangle \Vert _\infty =o\left( \frac{1}{\sqrt{n}} \right) \end{aligned}$$
(4)

with probability \(1-o(1)\).

The proof, which follows the concept proposed by Mitra [18], can be found in Section A in Supplementary Materials. This implies that all vertices can be found optimally in \(\Theta (\sqrt{n})\) time for almost all graphs.

To show the common time measurement, suppose that the largest eigenvalue of \(\frac{1}{np}A\) satisfies

$$\begin{aligned} \left| \lambda _{1}-1\right| \le \delta , \end{aligned}$$
(5)

where \(\delta \rightarrow 0\). Then, the probability of measuring the searched vertex w in time t can be approximated by [4]

$$\begin{aligned} \begin{aligned} P_\omega (t)&= \left| \langle w| \exp (-\mathrm {i}Ht) |s\rangle \right| ^2 \\&\approx \frac{1}{1+n\delta ^2/4}\sin ^2 \left( \sqrt{\delta ^2/4 + 1/n} t\right) . \end{aligned} \end{aligned}$$
(6)

Since \(|\lambda _1\rangle \) tends to \(|s\rangle \) in the \(\Vert \cdot \Vert _\infty \) norm, the approximation works for all nodes. Hence, when \(\delta =O(\frac{1}{\sqrt{n}})\) (with small constant in the \(\Theta (\frac{1}{\sqrt{n}})\) case), then all of the vertices can be found in time \(O(\sqrt{n})\). Nevertheless, \(\delta \) depends on a chosen graph, and thus, the measurement time may differ. In order to ensure that the time and probability of measurement are the same for all marked nodes and almost all graph chosen, one should provide \(\delta = o(\frac{1}{\sqrt{n}})\) almost surely.

If \(p=\omega (\log ^8(n)/n)\), then the largest eigenvalue \(\lambda _1\) follows \(\mathcal N\left( 1,\frac{1}{n}\sqrt{2(1-p)/p} \right) \) distribution [19], see Section B in Supplementary Materials for a step-by-step derivation, where \(\mathcal N(\mu ,\sigma )\) is the normal distribution with mean \(\mu \) and standard deviation \(\sigma \). Therefore, one can show that asymptotically almost surely

$$\begin{aligned} \left| \lambda _{1}\left( \frac{1}{np} A\right) -1 \right| \le \delta , \end{aligned}$$
(7)

where \(\delta =o(\frac{1}{n\sqrt{p}})\). Note that since \(np=\omega (\log ^8(n))\), we have actually \(\delta =o(\frac{1}{\sqrt{n}\log ^4(n)})\) in the worst-case scenario. This, in turn, allows us to use the simplified version of Eq. (6)

$$\begin{aligned} P_{\omega }(t) \approx \sin ^2\left( \frac{t}{\sqrt{n}}\right) \end{aligned}$$
(8)

for large n. Thus, we have that in time \(t=\frac{\pi }{2}\sqrt{n}\), the probability of measurement is optimal, independently on a chosen marked node. Finally, we can conclude our results concerning adjacency matrix with the following theorem.

Theorem 2

Suppose we chose a graph according to Erdős–Rényi \(\mathcal G(n,p)\) model with \(p=\omega (\log ^8(n)/n)\). Then by choosing \(M_\mathrm{G}=\frac{1}{np}A\), where A is an adjacency matrix in Eq. (2), almost surely all vertices can be found with probability \(1-o(1)\) with common measurement time approximately \(t=\pi \sqrt{n}/2\).

3 Element-wise optimality for Laplacian matrix

Similar property holds for a Laplacian matrix L. This is a positive semi-definite matrix, where the dimensionality of null space corresponds to the number of connected components. Based on the results from [20], one can show that for \(p=\omega (\log (n) /n)\) all of the other eigenvalues of \(\frac{L}{np}\) converge to 1, see Section C in Supplementary Materials. At the same time, the eigenvector corresponding to the null space is exactly the equal superposition \(|s\rangle = |\mu _n\rangle = \frac{1}{\sqrt{n}}\sum _{v\in V} |v\rangle \). Thus, since for \(p>(1+\varepsilon )\log (n)/n\) a graph is almost surely connected, the Laplacian matrix takes the form

$$\begin{aligned} \frac{L}{np} = 0 \cdot |s\rangle \langle s| + \sum _{i=1}^{n-1}\mu _i |\mu _i\rangle \langle \mu _i|, \end{aligned}$$
(9)

where \(\mu _i\rightarrow 1\) almost surely for \(1\le i\le n-1\). Here \(\mu _1,\dots ,\mu _{n}\) denote eigenvalues of Laplacian matrix with corresponding eigenvectors \(|\mu _1\rangle ,\dots ,|\mu _n\rangle \).

Note that since the identity matrix corresponds to global phase change only, which is an unmeasurable parameter, we can equivalently choose

$$\begin{aligned} \mathrm {I}-\frac{L}{np} = |s\rangle \langle s|- \sum _{i=1}^{n-1}(\mu _i-1) |\mu _i\rangle \langle \mu _i|. \end{aligned}$$
(10)

Note that the matrix above satisfies the requirements of Lemma 1 from [4], and therefore, all of the vertices can be found optimally with probability \(1-o(1)\). Common time measurement is a direct application of Lemma 1 from [4], since more in-depth proof analysis shows that, under the theorem assumptions, \(t=\pi \sqrt{n} /2\) should be chosen for maximizing the success probability.

The situation changes in the case of \(p=O(\log (n)/n)\). Note that for both adjacency and Laplacian matrices the evolution does not change the probability of measuring isolated vertices. If \(p<(1-\varepsilon )\log (n)/n\), then graphs almost surely contain such vertices, and hence, you actually can hide a vertex in such a graph.

The \(p\sim p_0\log (n)/n\) for a constant \(p_0>1\) is a smooth transition case between hiding and non-hiding cases mentioned before. In this case based on Exercise III.4 from [21], one can show that \(\mu _1 \sim (1-p_0)(W_{0}(\frac{1-p_0}{\mathrm {e}p_0}))^{-1}\log (n)\) and \(\mu _{n-1} \sim (1-p_0)(W_{-1}(\frac{1-p_0}{\mathrm {e}p_0}))^{-1}\log (n)\), where \(W_{0},W_{-1}\) are Lambert W functions, see Section D in Supplementary Materials. Here we use the notation \(f(n)\sim g(n) \iff f(n)-g(n)=o(g(n))\) . In this case, the \(M_\mathrm{G}=\mathrm {I}-\frac{1}{np}L\) does not imply that both \(\mu _1\) and \(\mu _{n-1}\) converge to 1.

Nevertheless, we can still make simple changes in a matrix in order to obtain optimality of the procedure. Let \(a=(1-p_0)(W_{0}(\frac{1-p_0}{\mathrm {e}p_0}))^{-1} \) and \(b=(1-p_0)(W_{-1}(\frac{1-p_0}{\mathrm {e}p_0}))^{-1}\) denote constants corresponding to \(\mu _{1}\) and \(\mu _{n-1}\) limit behavior. Then

$$\begin{aligned} \mathrm {I}-\frac{2}{(a+b)\log n}L \end{aligned}$$
(11)

again satisfies Lemma 1 from [4] with \(c=\frac{a-b}{2}\). According to Lemma 1, the probability of success after time \(t=\frac{\pi }{2 \sqrt{n}}\) is bounded from below by

$$\begin{aligned} p_{\mathrm {bound}}=\frac{1-c}{1+c} = {W_{0}\left( \frac{1-p_0}{\mathrm {e}p_0}\right) }/{W_{-1}\left( \frac{1-p_0}{\mathrm {e}p_0}\right) }. \end{aligned}$$
(12)

The bound converges to 0 when \(p_0\rightarrow 1^+\) and to 1 when \(p_0\rightarrow \infty \) and monotonically changes in \((1,\infty )\), see Fig. 1. Note that this corresponds to the other results. For \(p_0<1\), the probability of measuring all vertices is equal to 0 due to the connectivity issues mentioned before. For \(p_0\rightarrow \infty \), the situation becomes similar to \(p=\omega (\log (n)/n)\), where non-hiding property was already shown. Note, however, that the actual success probability seems to be much higher than the bound, see Fig. 2. Eventually, we conclude all of the results by the following theorems.

Fig. 1
figure 1

The lower bound of success probability of quantum spatial search for \(p=p_0\frac{\log (n)}{n}\) for almost all graph from Erdős–Rényi graph model. The exact formula is \(p_\mathrm {bound}=W_{0}\left( \frac{1-p_0}{\mathrm {e}p_0}\right) /W_{-1}\left( \frac{1-p_0}{\mathrm {e}p_0}\right) \). Note that \(p_{\mathrm {bound}}\rightarrow 0\) as \(p_0\rightarrow 1^+\), where connectivity threshold is achieved. Furthermore, \(p_{\mathrm {bound}}\rightarrow 1\) as \(p_0\rightarrow \infty \)

Theorem 3

Suppose we chose a graph according to Erdős–Rényi \(\mathcal G(n,p)\) model. For \(p=\omega (\log (n)/n)\), by choosing \(M_\mathrm{G}=\frac{1}{np}L\) in Eq. (2), almost surely all vertices can be found with probability \(1-o(1)\) in asymptotic \(\pi \sqrt{n}/2\) time. For \(p\sim p_0\log (n)/n \), by choosing \(M_\mathrm{G} = (1+r)\gamma L\) for some proper r, where \(\gamma \) is defined as in Eq. (11), all vertices can be found in \(\Theta (\sqrt{n})\) time with probability bounded from below by the constant in Eq. (12).

We leave determining proper r and t values as open question.

Fig. 2
figure 2

The figure presents probability bounds for quantum spatial search together with success probability derived from simulation. The red dashed line denotes the limit bound for success probability. The blue error bars denote \(\frac{1-c}{1+c}\) for \(c=\max \{|\lambda _2|,|\lambda _n|\}\) for matrix from Eq. 11 for randomly chosen graph. Black error bars denote the actual success probability. Deviations correspond to the maximal and minimal obtained values. Graphs were chosen according to the \(\mathcal G(n,2\frac{\log (n)}{n})\) model, r were derived according to Eq. 3, and we chose time \(t=\frac{\pi \sqrt{n}}{2}\). Thirty graphs were chosen for each size. One can see that the bound for randomly chosen graph oscillates around the limit value; nonetheless, the true success probability is much higher than the bound

Theorem 4

Suppose we chose a graph according to Erdős–Rényi \(\mathcal G(n,p)\) model with \(p\le (1-\varepsilon )\log (n)/n\), where \(\varepsilon >0\). Then for both adjacency and Laplacian matrices, there exist vertices which cannot be found in o(n) time.

4 Conclusion and discussion

In this work, we prove that all vertices can be found optimally with common measurement time \((\pi \sqrt{n})/2\) for almost all Erdős–Rényi graphs for both adjacency and Laplacian matrices under conditions \(p=\omega (\log ^8(n)/n)\) and \(p\ge (1+\varepsilon )\log (n)/n\), respectively. The proof is based on element-wise ergodicity of the eigenvector corresponding to the outlying eigenvalue of adjacency or Laplacian matrix. While under the mentioned constraint adjacency matrix almost surely achieves success probability \(1-o(1)\), the same probability for Laplacian matrix in the \(p\sim p_0\log (n)/n\) case for some \(p_0>1\) can only be bounded from below by some positive constant. At the same time for \(p<(1-\varepsilon )\log (n)/n\), the property does not hold anymore, since almost surely there exist isolated vertices which need \(\Omega (n)\) time to be found.

While our derivation concerning the Laplacian matrix is nearly complete, since only upper bound for success probability is missing in the \(p=\Theta (\log (n)/n)\) case, in our opinion it is possible to weaken the condition on p for the adjacency matrix. The first key step would be showing that the largest eigenvalue \(\lambda (\frac{1}{np} A)\) follows \(\mathcal N(1,\frac{1}{n}\sqrt{2(1-p)/p)}\) distribution for \(p\ge (1+\varepsilon )\log (n)/n\). Then, since element-wise convergence of principal vector requires \(p=\omega (\log ^3(n)/(n\log ^2\log n))\), the result would be strengthened to the last mentioned constraint. The second step would be the generalization of the mentioned element-wise convergence theorem.

Further interesting generalization of the result would be the analysis of more general random graph models as well. While this proposition has already been stated [4], our results show that in order to prove security of the quantum spatial search, it would be desirable to analyze the limit behavior of the principal vector in the sense of \(\Vert \cdot \Vert _\infty \) norm.