Quantum algorithms for path and cycle containment problems


Abstract

The quantum query complexity of subgraph-containment problems, which ask whether a given subgraph \(H\) is present in an input graph \(G\), has been the subject of considerable study. This interest stems not only from the natural and well-motivated formulation of these problems, but also from a flurry of novel quantum algorithmic techniques that were developed specifically to solve them. Notably, even for relatively simple subgraphs, such as paths and cycles, a complete understanding of their query complexities remains elusive.

In this work, we consider several variants of path- and cycle-containment problems in the adjacency matrix model, where we search for paths or cycles of constant length \(k \in O(1)\). We compare the settings where the graphs are directed or undirected, where the goal is to detect or find the existence of a path/cycle, and where the path/cycle we’re looking for has length exactly \(k\), or at most \(k\). We also consider several promise versions of these problems, where we know beforehand that the input graph has a certain structure. We characterize the relative difficulty of these variants of the path- and cycle-containment problems, by relating them to one another using randomized reductions, and grouping them into several equivalence classes.

When we restrict our attention to path-containment problems, this implies a dichotomy result. Some of the path-containment problems can be solved using a linear number of queries, and all the others are equivalent to one another (and additionally to several cycle-containment problems as well) under randomized reductions and up to constant multiplicative overhead. For the latter equivalence class, we prove a novel quantum-walk-based algorithm that achieves query complexity \(\widetilde{O}(n^{3/2-\alpha_k})\), where \(\alpha_k \in \Theta(c^{-k})\) and \(c = \sqrt{3+\sqrt{17}}/2 \approx 1.33\), beating the previous best upper bound \(O(n^{3/2})\) on its query complexity. We also provide a conditional lower bound based on the graph-collision problem, which implies that this equivalence class does not admit linear-query quantum algorithms unless graph collision admits an \(O(\sqrt{n})\) query algorithm.

1 Introduction↩︎

The subgraph containment problem asks whether a given (undirected) subgraph \(H\) is contained in an (undirected) input graph \(G\). In this work, we consider subgraphs \(H\) of constant size that are known ahead of time, and input graphs \(G\) consisting of \(n\) vertices that we can access through adjacency-matrix queries. Now, we wish to decide whether the subgraph \(H\) is present in the input graph \(G\), while making a minimal number of queries to the adjacency matrix of \(G\). We denote this problem concisely by \(\mathtt{Subgraph}^H\), and the minimal number of queries to the input required to solve it is known as its query complexity. We also consider a restricted version of this problem where we select several vertices \(v_1, \dots, v_m\) from \(H\) and additionally require that these vertices get mapped to predetermined positions \(s_1, \dots, s_m\) in \(G\). Under this restriction, we then ask whether \(H\) is present in \(G\), and we denote the resulting problem by \(\mathtt{Subgraph}^H_{v_1, \dots, v_m}\).

In the randomized setting, we decide which edges to query by a (classical) randomized algorithm, and we require the resulting algorithm to output the correct answer with probability at least \(2/3\). The randomized query complexity of the unrestricted subgraph containment problem, denoted by \(\mathsf{R}(\mathtt{Subgraph}^H)\), satisfies \(\Theta(n^2)\) for any non-empty graph \(H\). Moreover, it is not hard to show that the restricted problems are classified into three distinct classes, where the randomized query complexities \(\mathsf{R}(\mathtt{Subgraph}^H_{v_1, \dots, v_m})\) are \(\Theta(1)\), \(\Theta(n)\) and \(\Theta(n^2)\), respectively.

In contrast, in the quantum setting, we can query the adjacency matrix coherently in superposition, and we aim to give a quantum algorithm whose final measurement outputs the right answer with probability at least \(2/3\). The corresponding quantum query complexities, denoted by \(\mathsf{Q}(\mathtt{Subgraph}^H)\) for the unrestricted problem, and \(\mathsf{Q}(\mathtt{Subgraph}^H_{v_1, \dots, v_m})\) for the restricted problem, seem to have a much richer structure than their classical counterparts. This is the focus of this work.

The study of the constant-size subgraph-containment problem in the quantum setting was pioneered by Magniez, Szegedy and Santha [1], who built on a quantum walk algorithm by Ambainis [2] to show that the existence of any subgraph \(H\) consisting of \(k\) vertices can be detected using \(\widetilde{O}(n^{2-2/k})\) queries. This result was subsequently independently improved by Zhu [3], and Lee, Magniez and Santha [4], resulting in the current state-of-the-art complexity for general subgraphs \(H\) through the following learning-graph-based result.

Theorem 1 ([4]). Let \(H\) be an undirected graph with \(k \geq 3\) vertices, \(m\) edges, and minimum vertex-degree \(d \geq 1\), where \(k,m,d \in O(1)\). Then, \(\mathsf{Q}(\mathtt{Subgraph}^H) \in O\left(n^{2-2/k-t}\right)\), where \[t = \max\left\{\frac{k^2 - 2(m+1)}{k(k+1)(m+1)}, \frac{2k-d-3}{k(d+1)(m-d+2)}\right\}.\]

Even though this result gives a non-trivial upper bound on the query complexity for the subgraph containment problem for any subgraph \(H\), it is not expected that this bound is optimal in general. Indeed, for several specific families of subgraphs, we know better bounds than those provided by Lee, Magniez and Santha. Examples of such subgraph families include the line graphs with \(k\) edges (\(L_k\)) and cycle graphs with \(k\) edges (\(C_k\)), for which we refer to the subgraph-containment problems as \(\mathtt{Path}^{=k} := \mathtt{Subgraph}^{L_k}\) and \(\mathtt{Cycle}^{=k} := \mathtt{Subgraph}^{C_k}\), respectively.

The path-containment problem was pioneered by Childs and Kothari [5], who showed that it can be solved using \(\widetilde{O}(n^{3/2-1/\lceil k/2\rceil})\) quantum queries. This was later improved by Belovs and Reichardt [6] to \(\mathsf{Q}(\mathtt{Path}^{=k}) \in \Theta(n)\), for all \(k \in O(1)\). Their algorithm involves reducing this problem to the promise problem, which we denote by \(\mathtt{PromPath}^{\leq k}_{s,t}\), where two vertices \(s\) and \(t\) are fixed, and the task is to distinguish between the existence of a path between \(s\) and \(t\) of length at most \(k\), and no path between \(s\) and \(t\) at all. They used a span-program approach to show that \(\mathsf{Q}(\mathtt{PromPath}^{\leq k}_{s,t}) \in O(n\sqrt{k})\), even for non-constant \(k\).

Despite Belovs’s and Reichardt’s remarkable progress on the path-containment problem, subsequent efforts to generalize their techniques were unsuccessful. Specifically, all attempts to solve the path-containment problem in the directed setting, or a version of their promise problem where one is required to not just detect the existence of a path, but actually output it, have not resulted in linear-query algorithms. In this work, we argue why these efforts are unlikely to work, with the following reasoning containing two parts. First, we show that all these directed and finding versions of the path-containment problem are equivalent up to randomized reductions (3), and then we show a conditional quantum query lower bound for all these problems based on the graph-collision problem (6). Since it is considered unlikely that we can make progress on the graph-collision problem with the current techniques, we conclude it’s unlikely that we can make progress on these generalizations of Belovs’s and Reichardt’s work with the current techniques as well.

On the topic of cycle-containment problems, the problem of detecting \(3\)-cycles (more commonly known as the triangle-detection problem) has played a central role in the literature on quantum query complexity. The study of this problem gave rise to many novel quantum algorithmic frameworks, and has been improved multiple times since it was first considered in [7]. Currently, the best-known algorithm is by Carette, Laurière and Magniez [8], who removed the log-factors from the algorithm by Le Gall [9].

Theorem 2 ([8], [9]). \(\mathsf{Q}(\mathtt{Cycle}^{=3}) \in O(n^{5/4})\).

The more general constant-length cycle-finding problem was also considered by Childs and Kothari [5], who showed the following improved upper bounds for even values of \(k\).

Theorem 3 ([5]). Let \(4 \leq k \in \mathbb{N}\) be even. Then, \(\mathsf{Q}(\mathtt{Cycle}^{=k}) \in \widetilde{O}\left(n^{\frac{3}{2} - \frac{k-2}{k(k+2)}}\right)\). Moreover, \(\mathsf{Q}(\mathtt{Cycle}^{=4}) \in \widetilde{O}(n^{5/4})\).

Finally, Cade, Montanaro and Belovs [10] considered a promise version of the cycle-containment problem, where they fix a vertex \(s\) in the input graph, and then distinguish between graphs with a cycle of length at most \(k\) passing through \(s\) and graphs with no cycles at all. Much like the promise path problem, they present an algorithm making \(O(n\sqrt{k})\) queries, even for non-constant values of \(k\).

As in the path-containment setting, all attempts to generalize the above results to the directed setting proved to be futile. Moreover, generalizing the promise version of the problem considered by Cade, Montanaro and Belovs to the finding setting, where one additionally has to output the cycle, proved elusive as well. In this work, we connect the cycle-containment problems rigorously to the path-containment problems through randomized reductions, explaining in a similar fashion why these generalization efforts are unlikely to succeed.

From the lower-bound perspective, progress is hampered by the certificate barrier [11], [12], which states that lower bounds obtained through the non-negative-weighted adversary bound are upper bounded by the geometric average of the worst-case positive and negative certificate sizes. For all subgraph containment problems where the subgraph \(H\) is of constant size, the positive certificate sizes are of constant size as well, and therefore the best possible lower bound on the quantum query complexity we can obtain through the non-negative-weighted adversary bound is, up to constants, equal to \(\sqrt{n^2 \cdot 1} = n\).

Even though there are other methods available for proving lower bounds on quantum query complexity, like the polynomial method [13], and the general adversary bound [14], applying these techniques to the subgraph containment problem has so far not been fruitful. As such, proving any unconditional super-linear lower bound on the quantum query complexity for any subgraph containment problem is a major open problem in this area that has been open for about two decades.

Despite (or perhaps because of) these barriers, alternative progress was made by Balodis and Iraids [15] in showing a conditional lower bound for the triangle-detection problem, based on the hardness of the graph-collision problem. This problem is parametrized by a graph \(G\) on \(n\) vertices, which is completely known ahead of time. The input to the problem is a bit sting \(x\) that we have query access to, where each bit of \(x\) is associated with a distinct vertex of \(G\). The graph collision problem on \(G\) asks whether there exists an edge in \(G\) for which both endpoints are labeled by a \(1\) in \(x\). We refer to this problem as \(\mathtt{GC}_G\), and we write \(\mathsf{Q}(\mathtt{GC}_n)\) for the maximum of \(\mathsf{Q}(\mathtt{GC}_G)\), over all graphs \(G\) on \(n\) vertices.

The best generic algorithm for this problem was given by Magniez, Szegedy and Santha [1], which is essentially based on the algorithm of Ambainis [2] and has query complexity \(\mathsf{Q}(\mathtt{GC}_n) \in O(n^{2/3})\). This complexity is believed by some in the community to be optimal. However, the best-known lower bound is only \(\mathsf{Q}(\mathtt{GC}_n) \in \Omega(\sqrt{n})\), where further progress is again impeded by the certificate barrier.

Balodis and Iraids embedded the OR of \(n\) instances of the graph-collision problem into a single instance of the triangle-detection problem on \(3n\) vertices. In doing so, they prove a conditional lower bound on the family of cycle-containment problems.

Theorem 4 ([15]). \(\mathsf{Q}(\mathtt{Cycle}^{=3}) \in \Omega(\sqrt{n} \cdot \mathsf{Q}(\mathtt{GC}_n))\).

This result implies a plausible path toward lower bounding the query complexity of the triangle-detection problem. Indeed, any lower bound \(\omega(\sqrt{n})\) for the graph-collision problem would immediately imply a super-linear lower bound \(\omega(n)\) for the triangle-detection problem.

In this work, we provide similar graph-collision-based conditional lower bounds for the families of path- and cycle-containment problems. This solidifies the role of the graph-collision problem in the landscape of subgraph-containment problems, as a non-trivial lower bound for graph-collision would imply non-trivial lower bounds for both cycle- and path-containment problems.

1.1 Contributions↩︎

In this work, we provide a rigorous study of the different variants of subgraph-containment problems, with a specific focus on path- and cycle-containment problems. We present a number of simpler observations based on prior work that help paint the landscape of these problems, and we obtain three main results that improve our understanding of their query complexities.

For the general constant-size subgraph-containment problem, we consider relations between the undirected and the directed setting, as well as between their detection and finding versions. Even though it is not explicitly analyzed by Lee, Magniez and Santha, we make the simple observation that their learning-graph-based approach readily generalizes to the directed setting.

Observation 5 (Informal version of 16). 1 holds too whenever the subgraph \(H\) and the input graph are directed.

Next, we also observe that for non-promise subgraph-containment problems, detection and finding are equivalent up to randomized reductions and constant multiplicative overhead.

Observation 6 (Informal version of 5). For any (directed/undirected) subgraph \(H\), the quantum query complexities of the finding and detection versions of the non-promise (possibly restricted) subgraph-containment problem with subgraph \(H\) are equal up to a multiplicative constant.

We note that the above only holds for non-promise problems, i.e., where all graphs are valid inputs to the problem. That is, one can only have separations between the detection and finding versions of a subgraph-containment problem in a setting where the input satisfied some promise known a priori. Indeed, in such promise settings, there are several graph problems where the finding and detection versions seem to be very much distinct. For instance, there is a quantum algorithm that makes polylogarithmic queries to output the (first bit of the) exit vertex in the Welded tree graph [16], while outputting an entrance-to-exit path in this graph takes polynomially many queries for a certain natural class of quantum algorithms [17]. Moreover, as we will see, the promise problem \(\mathtt{PromFindPath}_{s,t}^{=k}\) would be polynomially harder than \(\mathtt{PromPath}_{s,t}^{=k}\) assuming graph collision is harder than its trivial lower bound.

We also show that there is a generic randomized reduction from the undirected version of a subgraph-containment problem to the directed one.

Observation 7 (Informal version of 6). Every directed subgraph-containment problem is at least as hard (in terms of randomized/quantum query complexity) as its undirected counterpart.

Next, we focus specifically on the path- and cycle-containment problems. For these problems, we consider the restricted and unrestricted versions of the problem, where in the restricted versions, we fix the start and end vertices \(s\) and \(t\) for the path-containment problem, and a single vertex \(s\) on the cycle for the cycle-finding problem. We also consider the directed versions of these problems, and the finding versions where we ask to output the path or cycle. Finally, we consider versions where we search for a path or cycle of length exactly \(k\), or at most \(k\). We denote the directed and finding versions with the keywords \(\mathtt{Dir}\) and \(\mathtt{Find}\), we attach a superscript \(=k\) or \(\leq k\) to indicate the length constraint, and we supply a subscript \(s\) or \(s,t\) for the restricted versions. Thus, for instance, the problem \(\mathtt{FindDirPath}_{s,t}^{=k}\) is the finding version of the directed path-finding problem between \(s\) and \(t\), of length exactly \(k\).

Akin to Belovs and Reichardt [6], and Cade et al. [10], we also consider promise versions of this problem. In the restricted path problem, i.e., where we fix the start and end vertex \(s\) and \(t\), the promise version satisfies that a path of the required length exists between \(s\) and \(t\), or \(s\) and \(t\) are not connected at all. Similarly, in the restricted cycle-finding problem through a vertex \(s\), either a cycle through \(s\) exists with the required length, or no cycle through \(s\) exists at all. We note that this promise is weaker than the promise considered in Cade et al. [10], and so our algorithmic results for this problem are stronger. Finally, for the unrestricted cycle-finding problem, we also consider a promise version, where either a cycle exists of the required length, or there exists no cycle at all (i.e., the graph is a forest). These problems are indicated with the \(\mathtt{Prom}\) keyword, i.e., \(\mathtt{PromDirCycle}_s^{\leq k}\) is the promise problem of detecting a directed cycle through \(s\) of length at most \(k\).1

Our first observation in this direction is that every \(\mathtt{PromFind}\)-version of these problems requires the same number of queries as the corresponding \(\mathtt{Find}\)-version.

Observation 8 (Informal version of [Thm:PromReducesNonProm,lem:PromFindForCycle]). Let \(\mathtt{P}\) be a (restricted/unrestricted, directed/undirected) path- or cycle-containment problem, with length constraint \(=k\) or \(\leq k\) with \(k \in O(1)\). Then, the finding version of \(\mathtt{P}\) is equivalent to the promise-finding version of \(\mathtt{P}\), up to randomized reductions and multiplicative constants.

[obs:detection-vs-finding,obs:find-vs-promfind] show that for all path- and cycle-containment problems \(\mathtt{P}\), we have that \(\mathtt{P}\), \(\mathtt{FindP}\) and \(\mathtt{PromFindP}\) are equivalent up to randomized reductions and multiplicative constants. As such, these three problems fall in the same equivalence class, and it suffices to restrict our attention to \(\mathtt{P}\) and \(\mathtt{PromP}\) in what follows.

Now, we arrive at the first main result of this work. We classify all remaining path- and cycle-containment problems into several equivalence classes via randomized reductions between them. We aid the reader by providing a graphical overview of these reductions in 1, and we obtain the following classification.

Main result 9. The unrestricted and undirected path-containment problem, and the undirected promise versions of the path- and cycle-containment problems admit linear-query quantum algorithms. All other path-containment problems are equivalent, and all other cycle-containment problems can be classified into at most 5 equivalence classes. See 1.

Figure 1: Randomized reductions between problems for k \geq 3. The dashed connections hold only for odd values of k. For the graph-collision problems, we can take any graph G with n vertices. All problems’ randomized query complexities are \Theta(n^2). All complexity bounds stated in the figure are upper and lower bounds on the quantum query complexity. In the upper bound for \mathsf{Q}(\mathtt{DirPath}^{=(k-2)}), \alpha_k \in \Theta(c^{-k}), with c \approx 1.33. If two problems have the same color, they have the same quantum query complexity up to constants.

For some reductions we use the color-coding technique, introduced by Alon, Yuster and Zwick [18]. The idea is to assign distinct colors to the vertices of the path/cycle graph \(L_k\)/\(C_k\), and then to randomly assign these colors to the vertices of the input graph \(G\). Next, we only keep an edge in \(G\) if the colors of the two vertices it connects are associated to two vertices in the path/cycle graph that are connected by an edge too. The resulting color-coded graph becomes a layered graph in the path-containment case, and a layered cycle graph in the cycle-containment case, as displayed in 2. With at least constant probability, a path/cycle in the original graph gets mapped to a path/cycle in the layered graph that straddles across all the layers.

Figure 2: A layered graph (left) and a layered cycle graph (right). These can be obtained from general graphs using the color-coding technique, where a path of length k (resp.cycle of length k) is preserved with constant probability.

To show relations between the various subgraph-containment problems, we cleverly make subtle modifications to the input graphs, oftentimes combined with the aforementioned color-coding technique. For instance, we can insert layers into a layered graph to show that one can find short paths using an algorithm that finds longer paths. Similarly, we can merge the vertices \(s\) and \(t\) into a single vertex \(s\) to convert an \(st\)-path containment problem into a cycle-containment problem through the vertex \(s\), and similarly we can separate a vertex \(s\) into two vertices \(s\) and \(t\) to prove a reduction in the reverse direction.

All these conversions, however, are subject to subtle caveats. For instance, in a layered cycle graph with \(k\) layers, a cycle of length \(k\) is guaranteed to go through all layers whenever \(k\) is odd, whereas when \(k\) is even it can exist between two consecutive layers. Similarly, when we merge two vertices \(s\) and \(t\) into a single vertex \(s\), a cycle through \(s\) in the resulting graph does not necessarily imply that the original graph contains an \(st\)-path. We obtain our classification, i.e., 9, by carefully checking which reductions can be made to work despite these caveats. Since we don’t expect 1 to collapse to a single island, we don’t expect these subtleties to be artifacts of the techniques used, but rather highlight the fundamental relations between these problems.

The overview of reductions presented in 1 reveals some interesting relations. For instance, it shows that one can reduce the \(\mathtt{DirCycle}_s^{\leq k}\)-problem to the \(\mathtt{Cycle}_s^{\leq k}\)-problem, through a series of reductions that involve the \(\mathtt{DirCycle}_s^{=k}\)- and \(\mathtt{Cycle}_s^{=k}\)-problems. We remark here that making this connection without going through the intermediate steps is not immediate, since it’s not clear how one can remove directions in a layered graph while preventing the introduction of new cycles. This highlights the benefit of this classification effort, as it uncovers relations between problems that would otherwise not be easily obtained.

Next, the classification of path- and cycle-finding problems displayed in 1 motivates the search for new quantum algorithms and query lower bounds for problems in these equivalence classes specifically. For instance, the \(\mathtt{DirPath}^{=k}\)-problem is part of an equivalence class containing 12 other path- and cycle-containment problems, hence an improved algorithm for this problem immediately provides an algorithm for all the others as well. Moreover, this equivalence class includes all directed versions of the path problems, as well as the finding versions of the promise-path problems, i.e., exactly the problems for which generalizing Belovs’s and Reichardt’s span-program-based construction failed.

Our main algorithmic result is a novel quantum-walk-based algorithm for this \(\mathtt{DirPath}^{=k}\)-problem, and hence for all problems in the equivalence class highlighted in red in 1. The best previously-known algorithm for any of the problems in this equivalence class is an algorithm that finds the shortest path between \(s\) and \(t\), if it exists, and thereby solves the \(\mathtt{Path}_{s,t}^{\leq k}\)-problem. This algorithm was originally developed by Dürr et al. [19], making \(\widetilde{O}(n^{3/2})\) queries, and the log-factors were subsequently removed by a series of works culminating in a paper by Lin and Lin [20]. We note that Beigi and Taghavi also developed \(O(n^{3/2})\)-query algorithms for the \(\mathtt{Cycle}_s^{=k}\) and \(\mathtt{Cycle}_s^{\leq k}\)-problems [21]. Our result provides an improved algorithm for all these problems.

Main result 10 (10). Let \(5 \leq k \in \mathbb{N}\). Then, \(\mathsf{Q}(\mathtt{DirPath}^{=k}) \in \widetilde{O}(n^{3/2 - \alpha_k})\), where \(\alpha_k \in \Theta(c^{-k})\) as \(k \to \infty\), with \(c = \sqrt{3+\sqrt{17}}/2 \approx 1.33\).

The main algorithmic idea is to reduce the directed-path-detection problem of length \(k\) to the same problem with length \(k-2\). To that end, we employ the MNRS-framework [22] to search for vertices that have at least one incoming edge, and those that have at least one outgoing edge. Then, it remains to find a pair of such vertices that has a path of length \(k-2\) between them, which we then solve recursively. This results in a nested quantum-walk construction, where we optimize the parameters of the quantum-walk framework to minimize the resulting query complexity. The resulting minimization problem involves solving a recurrence relation, whose solution yields an exponent that satisfies \(3/2-\Theta(c^{-k})\) for large values of \(k\).

We additionally provide an improved algorithm for the \(\mathtt{Cycle}^{\leq k}\)-problem, which is also displayed in 1. A slight modification of Childs and Kothari [5] yields the following result.

Observation 11 (32). Let \(5 \leq k \in \mathbb{N}\) be an odd integer. Then, \(\mathsf{Q}(\mathtt{Cycle}^{\leq k}) \in \widetilde{O}(n^{\frac{3}{2} - \frac{k-5}{(k-1)(k+3)}})\).

Finally, we focus on the lower bounds. Our main result in this direction is relating the cycle-finding problem through a particular vertex \(s\) to the graph-collision problem. In particular, through the reductions highlighted in 1, we emphasize that this result also provides a conditional lower bound on the \(\mathtt{DirPath}^{=k}\)-problem, and consequently on all path-containment problems that are in the same equivalence class.

Main result 12 (33). Let \(5 \leq k \in \mathbb{N}\) be an odd integer. Then, \(\mathsf{Q}(\mathtt{Cycle}_s^{\leq k}) \in \Omega(\sqrt{n} \cdot \mathsf{Q}(\mathtt{GC}_n))\).

Even though the resulting lower bound is identical to the lower bound derived by Balodis and Iraids for the triangle-detection problem, the underlying construction is profoundly different. Whereas Balodis and Iraids embed \(n\) instances of the graph-collision problem into a single instance of triangle-detection, we embed a single instance of the graph-collision problem composed with the OR-function into a single instance of the \(5\)-cycle-detection problem through a fixed vertex \(s\). In other words, Balodis and Iraids prove \(\mathsf{Q}(\mathtt{Cycle}^{=3}) \in \Omega(\mathsf{Q}(\mathtt{OR}_n \circ \mathtt{GC}_n))\), whereas we prove that \(\mathsf{Q}(\mathtt{Cycle}^{=5}_s) \in \Omega(\mathsf{Q}(\mathtt{GC}_n \circ \mathtt{OR}_n))\), where \(\mathtt{OR}_n\) is the boolean functions encoding the OR-function on \(n\) bits.

Finally, we remark that combining all our results provides conditional separations between the \(\mathtt{Path}^{=k}\) and \(\mathtt{DirPath}^{=k}\) problems, the \(\mathtt{PromDirPath}_{s,t}^{=k}\) and \(\mathtt{PromPath}_{s,t}^{=k}\) problems, and the \(\mathtt{PromFindPath}_{s,t}^{=k}\) and \(\mathtt{PromPath}_{s,t}^{=k}\) problems. Indeed, any non-trivial lower bound on the graph-collision problem implies a query separation between each pair of these problems. This in particular suggests that Belovs’s and Reichardt’s span-program-based approach can likely not be generalized to either the directed or finding settings, and, as such, that the undirected promise problems are indeed likely to be much easier than their directed and non-promise counterparts.

1.2 Organization↩︎

The document is structured as follows. We provide the preliminaries in 2, where we fix notation, and provide several results from prior work that we will use throughout the text. Then, we dedicate one section to each main result separately. That is, in 3, we provide all the randomized reductions between the path- and cycle-containment problems, in 4, we develop the novel quantum algorithm for the \(\mathtt{DirPath}^{=k}\)-problem, and 5, we develop an improved algorithm for the \(\mathtt{Cycle}^{\leq k}\)-problem. Finally, in 6, we provide the novel lower-bound proofs based on the graph-collision problem.

2 Preliminaries↩︎

2.1 Notation↩︎

Let \(\mathbb{N}= \{1, 2, \ldots\}\) be the set of all positive integers, and \(\mathbb{N}_0 = \mathbb{N}\cup \{0\}\). For any integer \(n \in \mathbb{N}\), we define \([n] \mathrel{\vcenter{:}}= \{1,\ldots, n\}\) and \([n]_0 \mathrel{\vcenter{:}}= \{0,1,\ldots, n\}\).

Let \(g : \mathbb{R}\supseteq D_g \to \mathbb{R}_{\geq 0}\). We define \(O(g)\) to be the set of functions \(f : D_g \supseteq D_f \to \mathbb{C}\) such that there exist \(C,M > 0\) such that for all \(x \in D_f\), \(x > M \Rightarrow |f(x)| \leq C \cdot g(x)\). Similarly, we define \(\widetilde{O}(g)\) to be the set of functions \(f : D_g \supseteq D_f \to \mathbb{C}\) such that there exist \(C,M,k > 0\) such that for all \(x \in D_f\), \(x > M \Rightarrow |f(x)| \leq C \cdot g(x) \cdot \log^k(g(x))\). We define \(\Omega(g)\) and \(\widetilde{\Omega}(g)\) analogously, but with the conditions being \(|f(x)| \geq C \cdot g(x)\) and \(|f(x)| \geq C \cdot g(x) / \log^k(g(x))\), respectively. Finally, we write \(\Theta(g) := O(g) \cap \Omega(g)\), and \(\widetilde{\Theta}(g) := \widetilde{O}(g) \cap \widetilde{\Omega}(g)\).

We denote undirected graphs by \(G = (V,E)\), where every edge \(\{v,w\} = e \in E\) is a set of two vertices, with \(v,w \in V\). Similarly, we denote directed graphs by \(G = (V,A)\), where every arc \((v,w) = a \in A\) is an ordered pair of vertices, with \(v,w \in V\). If \(V' \subseteq V\), then \(G - V'\) denotes the graph \(G\) with all vertices from \(V'\) and their adjacent edges removed. All (undirected/directed) graphs considered in this work are simple, i.e., there are no duplicate edges and arcs. However, in the directed setting, we do allow for both arcs in opposite directions to exist simultaneously between two vertices.

We consider the adjacency-matrix model, where any algorithm can make queries to the entries of the adjacency matrix of an input graph \(G\). Equivalently, for an undirected graph, the algorithm can supply a set of two vertices to an oracle, that outputs whether an edge exists between the two, and similarly in the directed setting the algorithm can ask whether an arc exists between two vertices from an ordered pair. In the randomized setting, the algorithm can employ randomness to select which vertices to query. In the quantum setting, the vertex pairs can be queried coherently in superposition, e.g., for an undirected graph \(G = (V,E)\), the oracle behaves as a unitary \(O_G\) that acts as \[O_G : \left|v,w\right\rangle\left|b\right\rangle \mapsto \left|v,w\right\rangle\left|b \oplus [\{v,w\} \in E]\right\rangle, \qquad \forall v,w \in V, b \in \{0,1\}.\] We refer the reader to a quantum computing textbook for more details on the quantum computational model, e.g., [23]. The randomized and quantum query complexities of a given problem are the minimal numbers of queries required to solve the problem in these respective computational models.

Finally, we use regular expressions to denote sets of problems. That end, for two expressions \(\mathtt{A}\) and \(\mathtt{B}\), we write \(\mathtt{(A|B)}\) to denote the set of expressions \(\{\mathtt{A},\mathtt{B}\}\). We use this in combination with concatenation, i.e., \(\mathtt{A(B|C)}\) denotes the set \(\{\mathtt{AB},\mathtt{AC}\}\). In particular, some of the expressions can be empty, i.e., \(\mathtt{(|A)B}\) denotes the set \(\{\mathtt{B},\mathtt{AB}\}\).

2.2 Subroutines↩︎

We begin with a quantum subroutine that approximates the hamming weight of a Boolean string with a an error parameter \(\epsilon\).

Theorem 13 (Approximate quantum counting [24]). Let \(f:\{0,1\}^n \to \{0,1\}\) and \(\epsilon \in (0, 1]\). Let \(t = |f^{-1}(1)|\). Then, there is a quantum algorithm that outputs \(\tilde{t}\) such that \(|t-\tilde{t}| \leq \epsilon t\) with probability at least \(1 - \delta\) using \(O\left(\frac{1}{\epsilon} \sqrt{n/t} \log \frac{1}{\delta}\right)\) queries to \(f\).

We will mainly need to use the approximate counting algorithm for approximating the number of edges in a graph and approximating the degree of a vertex. For that reason, we will need the following corollaries.

Corollary 1 ([5]). Let \(A: \{0,1\}^{{n}\choose{2}} \to \{0,1\}\) be an adjacency matrix representation of an undirected graph \(G\), \(\epsilon \in (0, 1]\) be a constant and \(\overline{m}\) be an integer. Then, there is a quantum algorithm ApproxEdgeCount that accepts \(G\) if the number of edges \(|E(G)| = |A|\) in \(G\) are at least \((1+\epsilon) \overline{m}\) and rejects \(G\) if \(|E(G)|\) is at most \((1-\epsilon) \overline{m}\) with probability at least \(1 - \delta\) using \(O\left(\frac{1}{\epsilon} \sqrt{n^2/\overline{m}} \log \frac{1}{\delta}\right)\) queries to \(A\).

Corollary 2. Let \(A: \{0,1\}^{{n}\choose{2}} \to \{0,1\}\) be an adjacency matrix representation of an undirected graph \(G\), \(v\) be a vertex in \(G\), \(\epsilon \in (0, 1]\) be a constant and \(\overline{d}\) be an integer. Then, there is a quantum algorithm ApproxDegreeCount that accepts \((G,v)\) if the degree \(\deg(v)\) of \(v\) in \(G\) are at least \((1+\epsilon) \overline{d}\) and rejects \(G\) if \(\deg(v)\) is at most \((1-\epsilon) \overline{d}\) with probability at least \(1 - \delta\) using \(O\left(\frac{1}{\epsilon} \sqrt{n/\overline{d}} \log \frac{1}{\delta}\right)\) queries to \(A\).

We will also need a subroutine that retrieves all the marked elements of a function.

Lemma 1 ([5]). Let \(f:[n] \mapsto \{0,1\}\) and \(t = |f^{-1}(1)|\). Then, there is a quantum algorithm that computes \(f^{-1}(1)\) using \(O(\sqrt{n(t+1)})\) queries to \(f\).

The following lemma relates the query complexity of problems that can be related by a randomized reduction with one-sided error.

Lemma 2. Let \(\mathtt{P}\) and \(\mathtt{P}'\) be arbitrary decision problems. Let \(G\) be an instance of \(\mathtt{P}\) and let \(G'\) be obtained from \(G\) via an efficient randomized reduction, i.e., each query to \(G'\) can be made using \(O(1)\) queries to \(G\). Suppose that if \(G\) is a yes instance of \(\mathtt{P}\), then \(G'\) is a yes instance of \(\mathtt{P}'\) with probability at least \(p \in \Omega(1)\), and if \(G\) is a no instance of \(\mathtt{P}\), then \(G'\) is a no instance of \(\mathtt{P}'\) with probability \(1\). Then, for \(\mathsf{M} \in \{\mathsf{R},\mathsf{Q}\}\), we have \(\mathsf{M}(\mathtt{P}) \in O(\mathsf{M}(\mathtt{P}'))\).

Proof. Let \(\mathcal{A}\) be the optimal (randomized/quantum) algorithm for the problem \(\mathtt{P}'\). We first construct a new algorithm \(\mathcal{B}\) with majority voting, where we run \(\mathcal{A}\) on the same input a total of \(\Theta(\log(1/p))\) times, so that it decides between yes and no inputs with probability at least \(1-p/4\).

Now, we run the algorithm \(\mathcal{B}\) on an instance \(G'\) generated through the randomized reduction. Then, if \(G\) is a positive input, this procedure will succeed with probability at least \(p(1-p/4) > 3p/4\), whereas if \(G\) is a negative input, this procedure will succeed with probability at most \(p/4\). Thus, by running this procedure a total of \(\Theta(1/p)\) times, we can distinguish between these two cases with high probability. As such, the total number of calls to \(\mathcal{A}\) is \(\Theta((1/p)\log(1/p))\), which is constant as \(p \in \Omega(1)\). Thus, \(\mathsf{M}(\mathtt{P}) \in O(\mathsf{M}(\mathtt{P}'))\), for \(\mathsf{M} \in \{\mathsf{Q},\mathsf{R}\}\). ◻

Remark 14. Note that, to be able to argue sub-quadratic quantum query bounds for graph problems on \(n\) vertices through randomized reductions, these reductions must be query-efficient. In the reductions we use throughout this work, we express the edge set of the new graph in terms of the edge set of the original graph, such that checking a specific edge in the new graph requires \(O(1)\) queries to the edge set of the original graph, unless explicitly stated otherwise.

2.3 Quantum walks↩︎

Throughout this paper, we will be making use of the MNRS-framework for quantum walks, developed by Magniez, Nayak, Rolland and Santha [22]. We recall their result here.

Theorem 15 ([22]). Let \(P\) be a reversible ergodic Markov chain over a state space \(V\), with spectral gap \(\delta\). Let \(M \subseteq V\) be a marked subset, such that if \(M \neq \varnothing\), then \(\mathbb{P}_{v \sim \pi}[v \in M] \geq \varepsilon > 0\), where \(\pi\) is the stationary distribution of \(P\). Let \(\mathsf{S}\) be such that the number of queries required to prepare a q-sample of \(\left|\pi\right\rangle\) up to norm-error at most \(\delta\) is \(\widetilde{O}(\mathsf{S}\mathrm{polylog}(1/\delta))\). Similarly, let \(\mathsf{U}\) be such that the number of queries required to prepare a q-sample over the neighbors of a given vertex \(v \in V\) with norm-error at most \(\delta\) is \(\widetilde{O}(\mathsf{U}\mathrm{polylog}(1/\delta))\). Finally, let \(\mathsf{C}\) be the number of queries required to check whether a given state \(v \in V\) is marked, with high probability. Then, we can decide whether \(M\) is empty or non-empty with a total number of queries that satisfies \[\widetilde{O}\left(\mathsf{S} + \frac{1}{\sqrt{\varepsilon}}\left(\frac{1}{\sqrt{\delta}}\mathsf{U} + \mathsf{C}\right)\right).\]

On several occasions, we will recursively use this construction, which is known as a nested quantum walk. This has been considered ample times in previous works, for instance [5], [25]. These constructions typically suffer from polylogarithmic overhead, but recent work has shown that this can be avoided in certain settings [26], [27]. We leave using these more recent techniques to remove the polylogarithmic overhead from our algorithms for future work.

3 Reductions between subgraph containment problems↩︎

We start by formally introducing the different versions of the subgraph-containment problems we consider in this work.

Definition 1 (Subgraph containment). We define several computational problems.

  1. Let \(H = (V_H,E_H)\) be a known undirected graph, and suppose we have access to an undirected graph \(G = (V,E)\) through adjacency-matrix queries. Let \(m \in \mathbb{N}_0\), \(v_1, \dots, v_m \in V_H\) and \(s_1, \dots, s_m \in V\) all distinct. The subgraph containment problem asks whether there exists an injection \(\varphi : V_H \to V\), such that \(\varphi : v_j \mapsto s_j\), for all \(j \in [m]\), and such that the induced map \(\varphi' : \binom{V_H}{2} \to \binom{V}{2}\) acting as \(\{v,w\} \mapsto \{\varphi(v),\varphi(w)\}\) satisfies \(\varphi'(E_H) \subseteq E\). The resulting boolean function, that evaluates to \(1\) if and only if such an injection exists, is denoted by \[\mathtt{Subgraph}^{H,v_1, \dots, v_m}_{V,s_1, \dots, s_m} : \{0,1\}^{\binom{V}{2}} \to \{0,1\},\] and we use the following shorthand notation for the sequence of boolean functions \[\mathtt{Subgraph}^H_{v_1, \dots, v_m} := (\mathtt{Subgraph}^{H,v_1, \dots, v_m}_{[n],1,\dots, m})_{n=1}^{\infty}.\] Whenever \(m = 0\), we refer to the subgraph containment problem as unrestricted, in which case the boolean function is simply denoted by \(\mathtt{Subgraph}^H_V\), and the sequence of boolean functions by \(\mathtt{Subgraph}^H\). On the other hand, when \(m \geq 1\), we say that the problem is restricted.

  2. We define the restricted and unrestricted subgraph containment problems analogously for directed graphs, i.e., if \(H = (V_H,A_H)\) is a directed graph and we have adjacency-matrix-query access to a directed graph \(G = (V,A)\), we define the boolean function \(\mathtt{Subgraph}^H_V : \{0,1\}^{\{(v,w) : v,w \in V : v \neq w\}} \to \{0,1\}\), and similarly in the restricted setting.

  3. Finally, we define finding versions of these problems, which ask to output \(0\) if the subgraph \(H\) is not contained in \(G\), and the injective map \(\varphi\) otherwise. Formally, in the undirected unrestricted setting, this is a relation \(\mathtt{FindSubgraph}_V^H \subseteq \{0,1\}^{\binom{V}{2}} \times (\{0\} \cup \{\varphi : V_H \to V \text{ injective}\})\), and similarly for the restricted and directed settings.

We can now phrase many graph problems formally as subgraph containment problems. For instance, if we let \(H\) be an undirected cycle on three vertices, then the sequence of boolean functions \(\mathtt{Subgraph}^H\) represents the triangle finding problem, where we have the bounds \(\mathsf{Q}(\mathtt{Subgraph}^H) \in O(n^{5/4}) \cap \Omega(n)\) [8], [9].

In this work, we restrict our attention to subgraph-containment problems where the subgraph is of constant size. In this setting, we can prove several elementary structural properties of these problems.

Lemma 3. Let \(H\) be a graph of constant size, \(m \in \mathbb{N}_0\) and \(v_1, \dots, v_m \in V_H\). Suppose that \(H_1, \dots, H_{\ell}\) are the connected components of \(H\), and we write \(i^{\ell'}_1, \dots, i^{\ell'}_{m_{\ell'}} \in [m]\) such that \(v_{i^{\ell'}_1}, \dots, v_{i^{\ell'}_{m_{\ell'}}}\) are the vertices from \(v_1, \dots, v_m\) that are contained in \(H_{\ell'}\), for all \(\ell' \in [\ell]\). Then, for \(\mathsf{M} \in \{\mathsf{Q},\mathsf{R}\}\), we have \[\mathsf{M}\left(\mathtt{Subgraph}^H_{v_1, \dots, v_m}\right) \in \Theta\left(\max_{\ell' \in [\ell]}\left\{\mathsf{M}\left(\mathtt{Subgraph}^{H_{\ell'}}_{v_{i^{\ell'}_1}, \dots, v_{i^{\ell'}_{m_{\ell'}}}}\right)\right\}\right).\]

Proof. For the upper bound, we randomly divide the free vertices \([n] \setminus \{1, \dots, m\}\) into \(\ell\) groups \(I_1, \dots, I_{\ell}\) of size \(\Theta(n/\ell)\), and we define the subgraphs \(G_{\ell'}\) as the input graph restricted to \(I_{\ell'} \cup \{i^{\ell'}_1, \dots, i^{\ell'}_{m_{\ell'}}\}\), for all \(\ell' \in [\ell]\). If \(H\) was not present in \(G\), then there must be an \(\ell' \in [\ell]\) such that \(H_{\ell'}\) is not present in \(G_{\ell'}\). On the other hand, if \(H\) was present in \(G\), then with constant probability, \(H_{\ell'}\) will be contained in \(G_{\ell'}\) for all \(\ell' \in [\ell]\). Thus, we now use 2 to argue that \[\mathsf{M}\left(\mathtt{Subgraph}^{H,v_1, \dots, v_m}_{[n],1,\dots,m}\right) \in O\left(\mathsf{M}\left(\bigwedge_{\ell'=1}^{\ell} \mathtt{Subgraph}^{H_{\ell'},v_{i_1^{\ell'}}, \dots, v_{i_{m_{\ell'}}^{\ell'}}}_{I_{\ell'} \cup \{i^{\ell'}_1, \dots, i^{\ell'}_{m_{\ell'}}\}, i_1^{\ell'}, \dots, i_{m_{\ell'}}^{\ell'}}\right)\right).\] Finally, we use that \(\ell\) is constant, and \(\mathsf{M}(\mathtt{P}_1 \land \mathtt{P}_2) \in \Theta(\max\{\mathsf{M}(\mathtt{P}_1), \mathsf{M}(\mathtt{P}_2)\})\), for total problems \(\mathtt{P}_1\) and \(\mathtt{P}_2\).

For the lower bound, suppose that \(\ell' \in [\ell]\) maximizes the expression on the right-hand side. Suppose we have an input on \(n\) vertices for the \(\mathtt{Subgraph}^{H_{\ell'}}_{[n],v_{i_1^{\ell'}}, \dots, v_{i_{m_{\ell'}}^{\ell'}}}\) problem. Then, we add a constant number of vertices \(n_0 \in \Theta(1)\) containing the subgraphs \(H_{\ell''}\) for all \(\ell'' \in [\ell] \setminus \{\ell'\}\). Now, the new input contains \(H\) if and only if the original input contains \(H_{\ell'}\), and so \(\mathsf{M}(\mathtt{Subgraph}^H_{[n+n_0],v_1,\dots,v_m}) \geq \mathsf{M}(\mathtt{Subgraph}_{[n],v_{i_1^{\ell'}}, \dots, v_{i_{m_{\ell'}}^{\ell'}}})\). ◻

The above lemma informs us that we can without loss of generality focus on the case where \(H\) is connected. Next, we provide a full classification of these problems in the randomized setting, and a similar partial classification in the quantum setting. This lemma is folklore (see for instance [6] for the third item), but we provide a formal statement and proof here for completeness.

Lemma 4. Let \(H\) be a connected non-empty graph of constant size, and let \(m \in \mathbb{N}_0\) with \(v_1, \dots, v_m \in V_H\). Then,

  1. If \(\{v_1, \dots, v_m\} = V_H\), then \(\mathsf{Q}(\mathtt{Subgraph}^H_{v_1, \dots, v_m}) \in \Theta(1)\) and \(\mathsf{R}(\mathtt{Subgraph}^H_{v_1, \dots, v_m}) \in \Theta(1)\).

  2. If \(H - \{v_1, \dots, v_m\}\) contains just isolated vertices, then \(\mathsf{Q}(\mathtt{Subgraph}^H_{v_1, \dots, v_m}) \in \Theta(\sqrt{n})\) and \(\mathsf{R}(\mathtt{Subgraph}^H_{v_1, \dots, v_m}) \in \Theta(n)\).

  3. If \(H - \{v_1, \dots, v_m\}\) contains an edge, then \(\mathsf{Q}(\mathsf{Subgraph}^H_{v_1, \dots, v_m}) \in \Omega(n)\) and we have \(\mathsf{R}(\mathtt{Subgraph}^H_{v_1, \dots, v_m}) \in \Theta(n^2)\).

Proof. In the first case, there is only one possibility for the injective map, and so we simply (deterministically) check whether all the required edges exist in the input.

In the second case, let \(V_H \setminus \{v_1, \dots, v_m\} = \{w_1, \dots, w_{\ell}\}\). Similar to the proof of 3, the query complexity is upper bounded by searching for an image of each of the vertices \(w_{\ell'}\) individually, for \(\ell' \in [\ell]\). As for each \(\ell' \in [\ell]\), checking whether a given vertex plays the role of \(w_{\ell'}\) takes \(O(1)\) (deterministic) queries, the total query complexity is \(O(\sqrt{n})\) in the quantum setting and \(O(n)\) in the randomized setting.

In the third case, we have the trivial upper bound of \(O(n^2)\) in the randomized setting, because we can simply learn the entire input with \(\binom{n}{2} \in \Theta(n^2)\) queries.

For the lower bounds, observe in the second case that we can consider an input that contains all edges except for the ones that are connected to \(w_1\). Now, we can reduce a search problem of size \(n\) to this subgraph containment problem, and so we find that \(\mathsf{Q}(\mathtt{Subgraph}^H_{v_1, \dots, v_m}) \in \Omega(\sqrt{n})\) and \(\mathsf{R}(\mathtt{Subgraph}^H_{v_1, \dots, v_m}) \in \Omega(n)\).

Finally, in the third case, we can embed all of \(H\) except for the connections between \(v\) and \(w\), with \(\{v,w\} \in E_{H - \{v_1, \dots, v_m\}}\). Now, we add \(n\) candidate vertices for \(v\) and \(n\) candidate vertices for \(w\), and we connect them up to their respective neighbors in \(H\). Now, we can embed a search problem on \(\binom{n}{2}\) items into the bipartite graph between the candidate vertices for \(v\) and \(w\). Hence, we find that \(\mathsf{Q}(\mathtt{Subgraph}^H_{v_1, \dots, v_m}) \in \Omega(\sqrt{\binom{n}{2}}) = \Omega(n)\) and \(\mathsf{R}(\mathtt{Subgraph}^H_{v_1, \dots, v_m}) \in \Omega(\binom{n}{2}) = \Omega(n^2)\). ◻

Note that the above lemma completely characterizes the randomized query complexity of all detection versions of undirected subgraph containment problems. The simplicity of this characterization is in stark contrast with the quantum setting, where such a characterization seems elusive.

Next, we provide some generic reductions between the detection and finding versions of the subgraph containment problems, and between the undirected and directed versions.

Lemma 5. Let \(H\) be a connected non-empty graph of constant size, \(m \in \mathbb{N}_0\), and \(v_1, \dots, v_m \in V_H\). Then, for \(\mathsf{M} \in \{\mathsf{Q},\mathsf{R}\}\), we have the characterization \(\mathsf{M}(\mathtt{Subgraph}^H_{v_1, \dots, v_m}) \in \Theta(\mathsf{M}(\mathtt{FindSubgraph}^H_{v_1, \dots, v_m}))\).

Proof. It is clear that \(\mathsf{M}(\mathtt{Subgraph}^H_{v1,\dots,v_m}) \in O(\mathsf{M}(\mathtt{FindSubgraph}^H_{v_1, \dots, v_m}))\), since we can run an algorithm for the finding problem, and then output \(1\) if its output was non-zero. Thus, it remains to prove the reverse direction. In the randomized setting, it is clear that the finding versions of the subgraph containment problems follow the same classification as in 4, since in the second case, we can learn the entire neighborhoods for all the vertices \(v_1, \dots, v_m\) with \(O(n)\) queries, and that is sufficient to find the subgraph, if it exists. Thus it remains to focus on the quantum setting.

To that end, observe that if we are in the first case of 4, there is only one possible place where \(H\) could be embedded in the input, and so the finding version of the subgraph-containment problem also has constant query complexity as well. thus without loss of generality we are in the second or third case in 4. Now, we describe a randomized reduction that solves the finding problem, using the detection algorithm as a black box. To that end, suppose that for every \(n \in \mathbb{N}\), the optimal algorithm makes \(T_n\) quantum queries to the input to solve the \(\mathsf{Subgraph}_{[n],1, \dots, m}^{H,v_1, \dots, v_m}\)-problem. It is immediate that \((T_n)_{n=1}^{\infty}\) is increasing, since we can always trivially embed an instance of \(n\) vertices into an instance with \(n+1\) vertices by ignoring one of the vertices in the input.

Then, by considering an integer \(\ell > 1\), we can embed an OR of \(\ell\) disjoint instances of the boolean function \(\mathtt{Subgraph}^{H,v_1, \dots, v_m}_{[n],1, \dots, m}\) into \(\mathrm{Subgraph}^{H,v_1, \dots, v_m}_{[m+\ell(n-m)],1,\dots,m}\), and so \[\begin{align} \mathsf{Q}(\mathtt{Subgraph}^{H,v_1, \dots, v_m}_{[m + \ell (n-m)],1,\dots,m}) &\geq \mathsf{Q}(\mathtt{OR}_{\ell} \circ \mathtt{Subgraph}^{H,v_1, \dots, v_m}_{[n],1,\dots,m}) \\ &\in \Theta(\sqrt{\ell} \cdot \mathsf{Q}(\mathtt{Subgraph}^{H,v_1, \dots, v_m}_{[n],1, \dots, m})), \end{align}\] where in the last step we use that quantum query complexity is multiplicative under composition up to constants [28]. Thus, \(T_{m + \ell(n-m)} \in \Omega(\sqrt{\ell} \cdot T_n)\) and so by fixing \(\ell \in \mathbb{N}\) large enough, we obtain that \(T_{\ell n} \geq T_{m + \ell(n-m)} \geq KT_n\) for large enough \(n\), for some constant \(K > 1\). We will without loss of generality also assume that \(\ell > 9\).

Now, we consider the finding problem of size \(\ell n\). We can randomly choose \(n\) of the \(\ell n\) available vertices, and remove all the others. Then, if \(H\) was present in the original input, it will still be present in the new input with probability at least \(\Omega(\ell^{-|V_H|}) = \Omega(1)\), where we use that \(n\) is large enough. On the other hand, if \(H\) was not present in the original input, it will still not be present in the new input. Thus, using the generic amplification procedure, 2, we can with \(O(T_n)\) queries build a procedure that outputs \(0\) if \(H\) is not present in the graph, and that outputs a subset of size \(n\) that contains \(H\) if it is, with probability at least \(5/6\). Then, in the latter case we can subsequently run the finding routine with size \(n\) on this subset, with three runs and certificate checking to have a failure probability of at most \(1/6\) in this step as well. The total cost of the finding routine, which we denote by \(F_{\ell n}\), then satisfies for some constant \(C > 0\), \[F_{\ell n} \leq C \cdot T_n + 3 F_n.\] Now since \(T_n\) satisfies the regularity condition, as we argued earlier, and since \(\log_\ell(3) < 1/2\) and \(T_n \in \Omega(\sqrt{n})\) by 4, we can use the master theorem [29] to conclude that \(F_n \in O(T_n)\), and so \(\mathsf{Q}(\mathtt{FindSubgraph}^H_{v_1, \dots, v_m}) \in O(\mathsf{Q}(\mathtt{Subgraph}^H_{v_1, \dots, v_m}))\). ◻

Lemma 6. Let \(H\) be a connected non-empty undirected graph of constant size, \(m \in \mathbb{N}_0\), and \(v_1, \dots, v_m \in V_H\). Let \(\vec{H}\) be the same graph as \(H\), but then with arcs pointed in arbitrary directions. Then, for \(\mathsf{M} \in \{\mathsf{Q},\mathsf{R}\}\), we have \(\mathsf{M}(\mathtt{Subgraph}^H_{v_1, \dots, v_m}) \in O(\mathsf{M}(\mathtt{Subgraph}^{\vec{H}}_{v_1, \dots v_m}))\).

Proof. We provide a randomized reduction. Indeed, suppose that we have an instance to the undirected version of the subgraph containment problem. We now generate an input to the directed version of the problem by randomly associating a direction to each edge. We observe that if \(H\) was not present in the undirected input, then \(\vec{H}\) will definitely also not be present in the new input. On the other hand, if \(H\) was present in the original input, now \(\vec{H}\) will be contained in the new input with probability at least \(2^{-|E_H|} \in \Omega(1)\). Thus, we can now use the generic amplification procedure 2 to solve the undirected version of the problem, with constant overhead. ◻

We note that the above lemmas also completely characterize the randomized query complexity for all directed and finding subgraph containment problems. We spend the rest of the document investigating the quantum counterparts of these results in more detail.

Finally, we recall that 1, as proved by Lee, Magniez and Santha, strictly speaking only holds for undirected subgraph-containment problems. However, we argue that their learning-graph-based algorithm also works in the directed setting, with the same complexity.

Proposition 16. Let \(H = (V,A)\) be a directed graph, and let \(H' = (V,E')\) be its undirected counterpart, i.e., \(\{v,w\} \in E'\) if and only if \((v,w) \in A\) or \((w,v) \in A\). Then, \(\mathsf{Q}(\mathtt{Subgraph}^H)\) is upper bounded by the expression in 1 applied to \(H'\).

Proof. As \(\mathtt{Subgraph}^{H'}\) is a boolean function on \(|V|(|V|-1)\) bits, we can also interpret it as a function on \(\binom{V}{2}\) \(2\)-tuples, where the \(2\)-tuple labeled by \(\{v,w\}\) contains the information whether the arcs \((v,w)\) and \((w,v)\) are present in the input. Now, we have \[\mathtt{Subgraph}^{H'} : \{0,1\}^{\binom{V}{2}} \to \{0,1\}, \qquad \text{and} \qquad \mathtt{Subgraph}^H : (\{0,1\}^2)^{\binom{V}{2}} \to \{0,1\}.\]

In particular, we observe that the index labels into the input are now the same. We argue that on top of that, the certificate structures for both functions, as defined in [30], are also the same. To that end, observe that both graph properties are monotone, and so all the minimal positive certificates contain exactly a single copy of \(H'\) and \(H\), respectively. As such, we conclude that the (non-adaptive) learning-graph complexities for both problems are also equal, due to [30].

Finally, we observe that the two learning-graph algorithms presented in [4] are both non-adaptive. As such, the upper bound stated in 1 is in fact an upper bound on the non-adaptive learning graph complexity of the undirected subgraph-containment problem with subgraph \(H'\). This means it is also an upper bound on the non-adaptive learning graph complexity for the directed subgraph-containment problem with subgraph \(H\), which in turn upper bounds \(\mathsf{Q}(\mathtt{Subgraph}^H)\). ◻

3.1 Path-containment reductions↩︎

We introduce shorthand notations for the subgraph-containment problems where the subgraph is a line graph. We refer to these as path-containment problems.

Definition 2 (Path-containment problems). Let \(k \in \mathbb{N}\).

  1. Let \(L_k\) be the undirected line graph with \(k\) edges, with the endpoint vertices labeled by \(s\) and \(t\). We define \(\mathtt{Path}^{=k} := \mathtt{Subgraph}^{L_k}\), and \(\mathtt{Path}^{=k}_{s,t} := \mathtt{Subgraph}^{L_k}_{s,t}\).

  2. Let \(L_k'\) be the directed version of \(L_k\), where the edges are all pointing from \(s\) to \(t\). We define \(\mathtt{DirPath}^{=k} := \mathtt{Subgraph}^{L_k'}\), and \(\mathtt{DirPath}^{=k}_{s,t} := \mathtt{Subgraph}^{L_k'}_{s,t}\).

Finally, for \(\mathtt{P} \in \mathtt{(|Dir)Path}_{(|s,t)}\), we write \[\mathtt{P}^{\leq k} := \bigvee_{\ell=1}^k \mathtt{P}^{=\ell}.\] We also consider the finding versions of these problems, denoted by \(\mathtt{FindP}\) for all \(\mathtt{P} \in \mathtt{(|Dir)Path}_{(|s,t)}^{(=k|\leq k)}\). In the \((\leq k)\)-problems, it suffices to output a path for any of the subproblems \(\mathtt{P}^{=\ell}\), with \(\ell \in \{1, \dots, k\}\).

We also consider promise versions of the path-containment problems.

Definition 3 (Promise path-containment problems). Let \(k \in \mathbb{N}\).

  1. The \(\mathtt{PromPath}^{(=k|\leq k)}_{s,t}\)-problem is the \(\mathtt{Path}^{(=k|\leq k)}_{s,t}\)-problem, restricted to inputs that satisfy the promise that if \(s\) and \(t\) are connected, then there exists a path of length exactly, or at most, \(k\) between \(s\) and \(t\), respectively.

  2. The \(\mathtt{PromDirPath}^{(=k|\leq k)}_{s,t}\)-problem is the \(\mathtt{DirPath}^{(=k|\leq k)}_{s,t}\)-problem, restricted to inputs that satisfy the promise that if \(s\) and \(t\) are connected by a directed path from \(s\) to \(t\), then there exists a directed path of length exactly, or at most, \(k\) from \(s\) to \(t\), respectively.

The finding versions of these problems, \(\mathtt{FindPromPath}_{s,t}^{(=k|\leq k)}\) and \(\mathtt{FindPromDirPath}^{(=k|\leq k)}_{s,t}\) respectively, are the finding problems under the same restriction.

Formally speaking the promise path-containment problems are also boolean functions, but on a restricted domain. As such, they are partial booelan functions, rather than total ones.

We start by showing some elementary reductions between the promise and non-promise versions of the path-containment problems.

Lemma 7. Let \(\mathtt{P} \in \mathtt{(|Dir)Path}_{s,t}^{(=k|\leq k)}\).

  1. We have \(\mathsf{Q}(\mathtt{PromP}) \in O(\mathsf{Q}(\mathtt{P}))\).

  2. We have \(\mathsf{Q}(\mathtt{FindP}) \in \Theta(\mathsf{Q}(\mathtt{PromFindP}))\).

Proof. It is clear that \(\mathsf{Q}(\mathtt{PromP}) \in O(\mathsf{Q}(\mathtt{P}))\), because the function that is to be computed in the promise version of the problem is a restriction of the one in the non-promise problem. The same follows for \(\mathsf{Q}(\mathtt{PromFindP}) \in O(\mathtt{FindP})\) by comparing the relations to one another. Thus, it remains to show the reverse direction in the finding case.

To that end, suppose that we have an instance of the \(\mathtt{FindP}\)-problem. Any accepting instance will also be a valid instance for the promise version as well, and so in that case the algorithm for \(\mathtt{PromFindP}\) should output a valid path with high probability. In the rejecting case, though, the promise might not be satisfied, so the promise problem could output anything. However, we can simply check whether the path it outputs actually exists in the graph, and reject if not. Since in the rejecting case no path exists, this procedure always rejects, and it adds only constant additive overhead to the query complexity. ◻

Through [Thm:PromReducesNonProm,lem:find-detect-subgraph], we conclude that the \(\mathtt{Find}\) and \(\mathtt{PromFind}\) versions of the path-containment problems considered above all have the same query complexity up to constants as the non-promise detection version of the problem. Thus, to understand the relative hardness of the path-containment problems introduced above, we will ignore the \(\mathtt{Find}\) and \(\mathtt{PromFind}\) versions in what follows. We provide a graphical overview of the remaining problems in 3, with arrows representing the reductions we prove in the remainder of this section.

Figure 3: Randomized reductions between path-containment problems. All the green problems can be solved in linear number of queries, and all the red problems are equivalent under randomized reductions and constant multiplicative overhead.

If we set \(k = 1\), or \(k = 2\) then the problems \(\mathtt{(|Dir)Path}_{s,t}^{(=k|\leq k)}\) are instances of the first and second classes derived in 4, respectively. Thus, whenever we set \(k = 1\) or \(k = 2\), we already understand the exact query complexity of the problems in 3, and so we assume without loss of generality that \(k \geq 3\).

For the \(\mathtt{PromPath}_{s,t}^{\leq k}\)-problem, Belovs and Reichardt [6] proved that it can be solved using \(O(n\sqrt{k})\) queries, which is simply \(O(n)\) when \(k\) is constant. They also realize that the \(\mathtt{PromPath}^{=k}_{s,t}\)-problem has a stronger promise, and so there is a generic reduction from this problem to the \(\leq k\)-version. Moreover, they provide a randomized reduction from the \(\mathtt{Path}^{=(k-2)}\)-problem to the \(\mathtt{PromPath}^{=k}_{s,t}\)-problem [6]. This means that these three problems have linear query complexity, i.e., their query complexity is \(\Theta(n)\) for \(k \geq 3\).

We now prove that all the other path-containment problems form an equivalence class, i.e., they have the same query complexity up to a constant. We then prove a new quantum algorithm that solves all the problems from this equivalence class in 4.

We begin with showing monotonicity of \(\mathsf{Q}(\mathtt{DirPath}^{\leq k}_{s,t})\) in terms of \(k\). From our results later in this section, this monotonicity result also follows for all the problems in the same equivalence class as \(\mathtt{DirPath}^{\leq k}_{s,t}\).

Lemma 8. Let \(3 \leq \ell \leq k \in \mathbb{N}\). Then, \(\mathsf{Q}(\mathtt{DirPath}^{= \ell}_{s,t}) \in O(\mathsf{Q}(\mathtt{DirPath}^{= k}_{s,t}))\).

Proof. Given a graph instance \(G = (V,E)\) of \(\mathtt{DirPath}^{= \ell}_{s,t}\), we construct a graph instance \(G' =(V,E')\) of \(\mathtt{DirPath}^{= k}_{s,t}\) using the color-coding technique as follows. Color \(s\) with color \(0\), color \(t\) with color \(k\), and for each vertex \(v\) in \(V \setminus \{s,t\}\), color \(v\) uniformly at random from \([\ell-1]\) colors. For each \(v \in V\), let \(c(v)\) denote the color of \(v\). Choose a color \(i^* \in [\ell-1]\) and make \(k-\ell\) copies of each vertex colored \(i^*\). For each \(j \in [k-\ell+1]\), let \(v_j\) denote the \(j\)th copy of the vertex \(v\) with \(c(v) = i^*\). For all vertices \(v\) with \(c(v) = i^*\) and \(j \in [k-\ell]\), add edges \((v_j,v_{j+1})\) in \(E'\). For each edge \((u,v) \in E\) with \(c(v) = c(u) + 1\), add an edge \((u,v)\) if \(c(u),c(v) \neq i^*\), add an edge \((u_{k-\ell+1},v)\) in \(E'\) if \(c(u) = i^*\) and add an edge \((u,v_1)\) if \(c(v) = i^*\). It is easy to see that if \(G\) has a directed \(s-t\) path of length \(=\ell\), \(G'\) will have a directed \(s-t\) path of length \(=k\) with probability at least \(1/(\ell-1)^{\ell-1} \in \Omega(1)\), and if \(G\) did not have a directed \(s-t\) path of length \(=\ell\), then \(G'\) will not have a directed \(s-t\) path of length \(=k\). Invoking 2 proves the desired claim. ◻

Proposition 17. Let \(3 \leq k \in \mathbb{N}\). Then,

  1. \(\mathsf{Q}(\mathtt{Path}^{=k}_{s,t}) \in O(\mathsf{Q}(\mathtt{Path}^{\leq k}_{s,t}))\);

  2. \(\mathsf{Q}(\mathtt{Path}^{\leq k}_{s,t}) \in O(\mathsf{Q}(\mathtt{DirPath}^{\leq k}_{s,t}))\);

  3. \(\mathsf{Q}(\mathtt{DirPath}^{\leq k}_{s,t})) \in O(\mathsf{Q}(\mathtt{DirPath}^{= k}_{s,t}))\);

  4. \(\mathsf{Q}(\mathtt{DirPath}^{= k}_{s,t})) \in O(\mathsf{Q}(\mathtt{Path}^{= k}_{s,t}))\).

Proof. We will prove all these statements one by one via reductions.

  1. Given a graph instance \(G = (V,E)\) of \(\mathtt{Path}^{=k}_{s,t}\), we construct a graph instance \(G' =(V,E')\) of \(\mathtt{Path}^{\leq k}_{s,t})\) using the color-coding technique as follows. Color \(s\) with color \(0\), color \(t\) with color \(k\), and for each vertex \(v\) in \(V \setminus \{s,t\}\), color \(v\) uniformly at random from \([k-1]\) colors, and for each edge \({u,v} \in E\), add \(\{u,v\}\) in \(E'\) if \(u\) and \(v\) have consecutive colors. If \(G\) had an \(s-t\) path of length \(=k\), \(G'\) will have an an \(s-t\) path of length \(=k\) with probability at least \(1/(k-1)^{k-1} \in \Omega(1)\), and if \(G\) did not have an \(s-t\) path of length \(=k\), then \(G'\) will not have it either. Moreover, any \(s-t\) path in \(G'\) will be of length at least \(k\). Invoking 2 proves the desired statement.

  2. This follows from a reduction similar to 6 and invoking 2.

  3. From 8, we have that \(\mathsf{Q}(\mathtt{DirPath}^{= \ell}_{s,t})) \in O(\mathsf{Q}(\mathtt{DirPath}^{= k}_{s,t}))\) for all \(3 \leq \ell \leq k\). To decide if \(G\) has a directed \(s-t\) path of length \(\leq k\), we loop over all \(3 \leq \ell \leq k\) and run the above procedure to decide if \(G\) has a directed \(s-t\) path of length \(=\ell\), and output yes if it outputs yes for any \(\ell \in [k]\).

  4. Given a graph instance \(G = (V,E)\) of \(\mathtt{DirPath}^{= k}_{s,t}\), we construct a graph instance \(G' =(V,E')\) of \(\mathtt{Path}^{= k}_{s,t}\) using the color-coding technique as follows. Color \(s\) with color \(0\), color \(t\) with color \(k\), and for each vertex \(v\) in \(V \setminus \{s,t\}\), color \(v\) uniformly at random from \([k-1]\) colors, and for each edge \((u,v) \in E\), add \(\{u,v\}\) in \(E'\) if \(c(v) = c(u) + 1\). Now, note that if \(G\) has a directed \(s-t\) path of length \(=k\), \(G'\) will have an \(s-t\) path of length \(=k\) with probability at least \(1/(k-1)^{k-1} \in \Omega(1)\), and if \(G\) did not have a directed \(s-t\) path of length \(=k\), then \(G'\) will not have an \(s-t\) path of length \(=k\). Invoking 2 proves the desired statement.

 ◻

An immediate corollary of the above theorem is as follows.

Corollary 3. Let \(3 \leq k \in \mathbb{N}\). Then, all the problems in \(\mathtt{(|Dir)Path_{s,t}^{(=k|\leq k)}}\) have the same, up to constants, quantum query complexity.

Proposition 18. Let \(k \in \mathbb{N}\). Then,

  1. \(\mathsf{Q}(\mathtt{DirPath}^{=k}) \in O(\mathsf{Q}(\mathtt{DirPath}^{= k+2}_{s,t}))\);

  2. For \(k \geq 3\), \(\mathsf{Q}(\mathtt{DirPath}^{=k}_{s,t}) \in O(\mathsf{Q}(\mathtt{DirPath}^{= k-2}))\).

Proof. We will prove both these statements via reductions.

  1. Given a graph instance \(G = (V,E)\) of \(\mathtt{DirPath}^{= k}\), we construct a graph instance \(G' =(V \cup \{s,t\},E')\) of \(\mathtt{DirPath}^{= k+2}_{s,t}\) using the color-coding technique as follows. For each vertex \(v\) in \(V\), color \(v\) uniformly at random from \([k+1]\) colors, and for each edge \((u,v) \in E\), add it in \(E'\) if \(c(v) = c(u) + 1\). Also add edges \((s,v)\) for all vertices \(v\) with color \(1\) and edges \((v,t)\) for all vertices \(v\) with color \(k+1\). Now, note that if \(G\) has a directed path of length \(=k\), \(G'\) will have a directed \(s-t\) path of length \(=k+2\) with probability at least \(1/(k+1)^{k+1} \in \Omega(1)\), and if \(G\) did not have a directed path of length \(=k\), then \(G'\) will not have a directed \(s-t\) path of length \(=k+2\). Invoking 2 proves the desired statement.

  2. Given a graph instance \(G = (V,E)\) of \(\mathtt{DirPath}^{= k}_{s,t}\), we construct a graph instance \(G' =(V \setminus \{s,t\},E')\) of \(\mathtt{DirPath}^{= k-2}\) using the color-coding technique as follows. For each vertex \(v\) in \(V \setminus \{s,t\}\), color \(v\) uniformly at random from \([k-1]\) colors, and for each edge \((u,v) \in E\) with \(u,v \notin \{s,t\}\), add \((u,v)\) in \(E'\) if \(c(v) = c(u) + 1\) and either \(c(u) \neq 1\) and \(c(v) \neq k-1\) or \(c(u) = 1\) and \((s,u) \in E\) or \(c(v) = k-1\) and \((v,t) \in E\). Now, note that if \(G\) has a directed \(s-t\) path of length \(=k\), \(G'\) will have a directed path of length \(=k-2\) with probability at least \(1/(k-1)^{k-1} \in \Omega(1)\), and if \(G\) did not have a directed path of length \(=k\), then \(G'\) will not have a directed \(s-t\) path of length \(=k+2\). Invoking 2 proves the desired statement.

 ◻

Corollary 4. Let \(3 \leq k \in \mathbb{N}\). Then, the problems in \(\mathtt{DirPath}_{s,t}^{=k}\) and \(\mathtt{DirPath}^{=k-2}\) have the same, up to constants, quantum query complexity.

Proposition 19. Let \(3 \leq k \in \mathbb{N}\). Then,

  1. \(\mathsf{Q}(\mathtt{PromDirPath}^{=k}_{s,t}) \in O(\mathsf{Q}(\mathtt{PromDirPath}^{\leq k}_{s,t}))\);

  2. \(\mathsf{Q}(\mathtt{PromDirPath}^{\leq k}_{s,t}) \in O(\mathsf{Q}(\mathtt{DirPath}^{\leq k}_{s,t}))\);

  3. \(\mathsf{Q}(\mathtt{DirPath}^{\leq k}_{s,t})) \in O(\mathsf{Q}(\mathtt{DirPath}^{= k}_{s,t}))\);

  4. \(\mathsf{Q}(\mathtt{DirPath}^{= k}_{s,t})) \in O(\mathsf{Q}(\mathtt{PromDirPath}^{= k}_{s,t}))\).

Proof. We will prove all these statements one by one via reductions.

  1. Note that the promise of \(\mathtt{PromDirPath}^{=k}_{s,t}\) is stronger than the promise of \(\mathtt{PromDirPath}^{\leq k}_{s,t})\) since the yes and no instances of the former are also yes and no instances of the latter respectively. Thus, an algorithm for the latter will also be an algorithm for the former.

  2. This follows directly by the definitions of \(\mathtt{PromDirPath}^{\leq k}_{s,t}\) and \(\mathtt{DirPath}^{\leq k}_{s,t}\).

  3. This follows from [pt:3] of 17.

  4. Given a graph instance \(G = (V,E)\) of \(\mathtt{DirPath}^{= k}_{s,t}\), we construct a graph instance \(G' =(V,E')\) of \(\mathtt{PromDirPath}^{= k}_{s,t}\) using the color-coding technique as follows. Color \(s\) with color \(0\), color \(t\) with color \(k\), and for each vertex \(v\) in \(V \setminus \{s,t\}\), color \(v\) uniformly at random from \([k-1]\) colors, and for each edge \((u,v) \in E\), add \((u,v)\) in \(E'\) if \(c(v) = c(u) + 1\). Now, note that any directed \(s-t\) path in \(G\) of length \(\neq k\) will not be preserved in \(G'\). Thus, \(G'\) is a valid instance of \(\mathtt{PromDirPath}^{= k}_{s,t}\). Also, any directed \(s-t\) path of length \(=k\) in \(G\) is preserved in \(G'\) with probability at least \(1/(k-1)^{k-1} \in \Omega(1)\). Therefore, invoking 2 proves the desired statement.

 ◻

An immediate corollary of the above theorem is as follows.

Corollary 5. Let \(3 \leq k \in \mathbb{N}\). Then, all the problems in \(\mathtt{(|Prom)DirPath}_{s,t}^{(=k|\leq k)}\) have the same, up to constants, quantum query complexity.

3.2 Cycle-containment reductions↩︎

We now introduce cycle-containment problems.

Definition 4 (Cycle-containment problems). Let \(3 \leq k \in \mathbb{N}\).

  1. Let \(C_k\) be the undirected cycle graph with \(k\) edges, and let \(s\) be any vertex on the cycle. Then, \(\mathtt{Cycle}^{=k} := \mathtt{Subgraph}^{C_k}\) and \(\mathtt{Cycle}^{=k}_s := \mathtt{Subgraph}^{C_k}_s\).

  2. Let \(C_k'\) be the directed cycle graph with \(k\) arcs all pointing in the same direction, and let \(s\) be any vertex on the cycle. Then, \(\mathtt{DirCycle}^{=k} := \mathtt{Subgraph}^{C_k'}\) and \(\mathtt{DirCycle}^{=k}_s := \mathtt{Subgraph}^{C_k'}_s\).

We also consider versions of the problem where we are looking for cycles of length at most \(k\), i.e., for all \(\mathtt{P} \in \mathtt{(|Dir)Cycle}_{(|s)}\), we write \[\mathtt{P}^{\leq k} = \bigvee_{\ell=3}^k \mathtt{P}^{=k}.\] Finally, we also consider the finding versions of these problems. That is, for all \(\mathtt{P} \in \mathtt{(|Dir)Cycle}_{(|s)}^{(=k|\leq k)}\), we consider \(\mathtt{FindP}\) where the task is to output the cycle. For the \((\leq k)\)-problem, outputting a cycle of any length \(3 \leq \ell \leq k\) suffices.

For simplicity, we only consider cycles of length at least \(3\). Technically, one can also have a “cycle” of length \(2\) in the directed setting, if two arcs in opposite directions are present between two vertices, but we will refrain from calling these cycles in this work.

We also consider promise problems of these problems.

Definition 5 (Promise cycle-containment problems). Let \(3 \leq k \in \mathbb{N}\).

  1. The \(\mathtt{PromCycle}^{(=k|\leq k)}\) problem is the \(\mathtt{Cycle}^{(=k|\leq k)}\)-problem, restricted to inputs where if there exists any cycle in the graph, there must be at least one cycle of length exactly, or at most, \(k\), respectively.

  2. The \(\mathtt{PromDirCycle}^{(=k|\leq k)}\) problem is the \(\mathtt{DirCycle}^{(=k|\leq k)}\)-problem, restricted to inputs where if there exists any directed cycle in the graph, there must be at least one directed cycle of length exactly, or at most, \(k\), respectively.

  3. The \(\mathtt{PromCycle}_s^{(=k|\leq k)}\) problem is the \(\mathtt{Cycle}_s^{(=k|\leq k)}\)-problem, restricted to inputs where if there exists any cycle in the graph that passes through \(s\), there must be at least one cycle of length exactly, or at most, \(k\), respectively, that passes through \(s\).

  4. The \(\mathtt{PromDirCycle}_s^{(=k|\leq k)}\) problem is the \(\mathtt{DirCycle}_s^{(=k|\leq k)}\)-problem, restricted to inputs where if there exists any directed cycle in the graph that passes through \(s\), there must be at least one directed cycle of length exactly, or at most, \(k\), respectively, that passes through \(s\).

We consider the finding versions of these problems as well, which are defined to be the finding problems under the same restrictions on the input, and denoted by \(\mathtt{FindProm(|Dir)Cycle}_{(|s)}^{(=k|\leq k)}\).

We note here that the same reductions hold between the promise and non-promise versions of the cycle-containment problems as in the path case.

Lemma 9. Let \(3 \leq k \in \mathbb{N}\), and \(\mathtt{P} \in \mathtt{(|Dir)Cycle}_{(|s)}^{(=k|\leq k)}\).

  1. We have \(\mathsf{Q}(\mathtt{PromP}) \in O(\mathsf{Q}(\mathtt{P}))\).

  2. We have \(\mathsf{Q}(\mathtt{FindP}) \in \Theta(\mathsf{Q}(\mathtt{PromFindP}))\).

Proof. The proof is identical to 7. ◻

Similar to the path-containment setting, the above lemma informs us that we don’t need to consider the finding versions of the cycle-containment problems, since they are always equivalent to the non-promise detection versions up to randomized reductions. Thus, for all \(\mathtt{P} \in \mathtt{(|Dir)Cycle}_{(|s)}^{(=k|\leq k)}\), we only consider the problems \(\mathtt{P}\) and \(\mathtt{PromP}\) in the remainder of this section.

We now prove several randomized reductions between these problems, and we give a concise graphical overview of them in 4.

Figure 4: Pictorial representation of the randomized reductions we prove in this section, for k \geq 3. The dashed connections only hold for odd values of k. Problems depicted in the same color have the same quantum query complexity up to constants. Note that the connections represented in bold only exist in the restricted cycle-containment version of the problem, i.e., the corresponding result cannot be obtained in the left-hand side of the picture using the same techniques.

Before we present the remaining cycle-containment problems and the reductions between them, we define some techniques similar to ones used to prove the path-containment reductions in 3.1, for e.g., color-coding, layer insertion, but tailored towards cycle subgraph containment problems.

Definition 6 (\(\ell\)-color cyclic construction for graphs (\(|\)through \(s\))). Let \(\ell \in \mathbb{N}\). Let \(G=(V,E)\) be a (directed or an undirected) graph. An \(\ell\)-color cyclic construction of \(G\) (\(|\)through a given vertex \(s\)), let us denote by \(G'=(V',E')\) a simple graph constructed as follows,

  1. set \(V'=V\);

  2. for every \(v \in V'\), assign a color from \([\ell-1]_0\) picked uniformly at random; if the \(\ell\)-color cyclic construction has to be through a specific vertex \(s \in V'\) then color \(s\) with \(0\) and, for every \(v \in V'\setminus \{s\}\) assign a color from \([\ell-1]\) uniformly at random;

  3. if \(G\) is directed, then for every edge \((u,v) \in E\) with \(c(v)=(c(u)+1) \mod \ell\), keep edge \((u,v)\) in \(E'\); and, if \(G\) is undirected, then for every edge \(\{u,v\} \in E\) with \(|c(v)-c(u)|\in \{1,\ell-1\}\) keep edge \(\{u,v\}\) in \(E'\) if doesn’t already exist in \(E'\). This construction additionally ensures that \(G'\) is a directed graph if and only if \(G\) is a directed graph.

Definition 7 (\((\ell,t)\)-color cyclic construction for graphs). Let \(G=(V,E)\) be a (directed or an undirected) graph. Let \(G'=(V',E')\) be a \(\ell\)-color cyclic graph constructed from \(G\) (\(|\)through \(s\)) using the random construction as stated in \(\Cref{def:ColorCodingTechniqueForCycles}\). The \((\ell,t)\)-color cyclic construction of \(G\) (\(|\) through \(s\)), let us denote by \(G''=(V'',E'')\), is a simple graph constructed (from \(G'\)) in the following way,

  1. set \(V''=V'\) and for every \(v \in V''\) assign the same color that \(v\) gets in \(V'\);

  2. set \(E''=E'\) to begin with;

  3. pick a color \(i^* \in [\ell-1]\) and make \(t\) copies of each vertex colored \(i^*\);

  4. for each \(j \in [t]\), let \(v_j\) denote the \(j\)th copy of vertex \(v\) with \(c(v)=i^*\). If \(G'\) is directed (undirected), then for all vertices with \(c(v)=i^*\) add \((v,v_1)\) (\(\{v,v_{1}\}\)) in \(E''\) and additionally for all \(j\in [t-1]\) add edges \((v_j,v_{j+1})\) (\(\{v_j,v_{j+1}\}\)) in \(E''\). Additionally, for all edges \((v,w) \in E''\) with \(c(v)=i^*\) and \(c(w)=(i^*+1) \mod \ell\), remove the edge \((v,w)\) (\(\{v,w\}\)) from \(E''\) and instead add the edge \((v_t,w)\) (\(\{v_t,w\}\)) to \(E''\). This construction additionally ensures that \(G''\) is a directed graph if and only if \(G\) (and by construction \(G'\)) is a directed graph.

For the following problems we can show that the quantum query complexity is monotonically increasing in \(k\).

Lemma 10. Let \(3 \leq \ell \leq k \in \mathbb{N}\). Then,

  1. \(\mathsf{Q}(\mathtt{DirCycle}^{=\ell}) \in O(\mathsf{Q}(\mathtt{DirCycle}^{=k}))\);

  2. \(\mathsf{Q}(\mathtt{PromDirCycle}^{=\ell})\in O(\mathsf{Q}(\mathtt{PromDirCycle}^{= k})\);

  3. \(\mathsf{Q}(\mathtt{Cycle}^{\leq(k-1)}) \in O(\mathsf{Q}(\mathtt{Cycle}^{\leq k}))\) whenever \(k\) is an odd integer.

Moreover, same monotonicity relations hold for \(\mathtt{P}_{s}\) where \(\mathtt{P} \in \{\mathtt{DirCycle},\mathtt{PromDirCycle},\mathtt{Cycle}\}\).

Proof. We prove all these statements one by one via reductions.

  1. We will prove that, for any \(\ell \in [k]\setminus \{1,2\}\), \(\mathsf{Q}(\mathtt{DirCycle}^{=\ell})\in O(\mathsf{Q}(\mathtt{DirCycle}^{=k}))\). Let \(G = (V,E)\) be the input of \(\mathtt{DirCycle}^{= \ell}\), we construct an \((\ell,k-\ell)\)-color cyclic construction corresponding to \(G\) as sketched in 7; let us denote the resultant directed graph by \(G'' =(V'',E'')\). If \(G\) has a directed cycle of length \(=\ell\) then \(G''\) will have a directed cycle of length \(=k\) with probability at least \(1/\ell^{\ell} \in \Omega(1)\). In any other case, \(G''\) will not have any directed cycle of length \(=k\). Invoking 2 proves that for any \(\ell \in [k]\setminus \{1,2\}\) we have \(\mathsf{Q}(\mathtt{DirCycle}^{=\ell}) \in O(\mathsf{Q}(\mathtt{DirCycle}^{=k}))\).

  2. The argument for showing \(\mathsf{Q}(\mathtt{PromDirCycle}^{=\ell}) \in O(\mathsf{Q}(\mathtt{PromDirCycle}^{= k}))\) for any \(\ell \in [k]\setminus \{1,2\}\) is via the same reduction that is stated in the proof of [item:MonotonicityDirCycle]. What remains to be established is that the promise for \(\mathtt{PromDirCycle}^{= k}\) is not “badly” violated for any of the reduced instances. Let \(G\) be the input instance of \(\mathtt{PromDirCycle}^{=\ell}\). Let \(G''\) denote a \((\ell,k-\ell)\)-color cyclic construction corresponding to \(G\).

    1. \(G\) is a no instance of \(\mathtt{PromDirCycle}^{=\ell}\). This means there is no directed cycle of any length in \(G\) and, note that the construction of \(G''\) doesn’t create any new cycles. This means that \(G''\) constructed from such a \(G\) will also not have any cycle. Hence, a no instance of \(\mathtt{PromDirCycle}^{=\ell}\) maps to a well-defined promise-satisfying no instance of \(\mathtt{PromDirCycle}^{= k}\).

    2. \(G\) is a yes instance of \(\mathtt{PromDirCycle}^{=\ell}\). First observe that, When \(G\) is a yes instance of \(\mathtt{PromDirCycle}^{=\ell}\) then with probability \(\Omega(1)\) the constructed \(G''\) will also be a promise-satisfying yes instance of \(\mathtt{PromDirCycle}^{= k}\). For the remaining fraction, the \(\ell\)-length cycle from \(G\) is not preserved due to the random color coding but other length \(>\ell\) cycles could be present. Which would then translates to no cycle of length \(=k\) to be present in \(G''\) but length \(>k\) cycles being present in \(G''\), and this is not in the promise of \(\mathtt{PromDirCycle}^{= k}\).

    Inspite of the occasional violation of promise in the yes case, the reduction can be made to work. When \(G\) is a no instance the constructed \(G''\) fully satisfies the promise for \(\mathtt{PromDirCycle}^{= k}\) while being a no instance itself. And, \(G''\) satisfies the promise for \(\mathtt{PromDirCycle}^{= k}\) while being a yes instance with probability \(\Omega(1)\) when \(G\) is a yes instance. Therefore, running an algorithm for \(\mathtt{PromDirCycle}^{= k}\) on \(G''\) for \(O(1)\) many times is sufficient to deduce whether or not \(G\) is a yes or a no instance with high probability. This concludes the argument.

  3. Let \(G=(V,E)\) be an undirected graph that is input to \(\mathtt{Cycle}^{\leq(k-1)}\). Let \(\mathcal{A}\) denote an algorithm for \(\mathtt{Cycle}^{\leq k}\). We loop over \(\ell \in [k-1]\) and run \(\mathcal{A}\) on \(G''(\ell)\) where \(G''(\ell)\) denotes a random \((\ell,k-\ell)\)-cyclic construction of \(G\). If \(\mathcal{A}\) outputs no for \(G''(\ell)\) for all \(\ell \in [k-1]\) (more precisely, for constant many constructions of \(G''(\ell)\) for each \(\ell\)) then we know that \(G\) has cycles of only length \(>k-1\) and therefore we output no. On the other hand, if \(\mathcal{A}\) outputs yes on any of the above runs then that is because either there was a \(\leq (k-1)\) cycle in \(G\) that got encoded in one of the \(G''(\ell)\) with probability \(> 1/\ell^{\ell} \in \Omega(1)\) for at least one \(\ell \in [k-1]\) or there was length-\(k\) cycle in the original graph \(G\) that survived in \(G''\). Fortunately, enforcing \(k\) is odd ensures that any valid length-\(k\) cycle in \(G''\) passes through the color-coded layers and as well as the inserted dummy layers which then corresponds to some length-\(\ell\) (where \(\ell < k\)) cycle of \(G\). Without enforcing that \(k\) is odd we cannot get rid of the original length-\(k\) cycles of \(G\). Finally, invoking 2 concludes the proof.

The argument for monotonicity for \(\mathtt{P}_{s}\) where \(\mathtt{P} \in \{\mathtt{DirCycle},\mathtt{PromDirCycle},\mathtt{Cycle}\}\), works in the same way as above except for the difference that while constructing \((\ell,k-\ell)\)-color cyclic construction, the color coding construction goes through \(s\) as described in 6. Note that, this difference changes the exact probability of success for mapping the yes instances to yes instances but is still \(\Omega(1)\). ◻

Using these definitions and lemmas we will now prove a few cycle-containment reductions as illustrated in 4.

Proposition 20. Let \(3 \leq k \in \mathbb{N}\) be a constant. Then,

  1. \(\mathsf{Q}(\mathtt{DirCycle}^{=k}) \in \Theta(\mathsf{Q}(\mathtt{DirCycle}^{\leq k}))\);

  2. \(\mathsf{Q}(\mathtt{PromDirCycle}^{\leq k}) \in \Theta(\mathsf{Q}(\mathtt{PromDirCycle}^{= k}))\);

  3. \(\mathsf{Q}(\mathtt{Cycle}^{\leq k}) \in O(\mathsf{Q}(\mathtt{Cycle}^{=k}))\);

  4. \(\mathsf{Q}(\mathtt{PromCycle}^{=k}) \in \Theta(\mathsf{Q}(\mathtt{PromCycle}^{\leq k}))\);

  5. \(\mathsf{Q}(\mathtt{DirCycle}^{=k}) \in O(\mathsf{Q}(\mathtt{Cycle}^{=k}))\) whenever \(k\) is an odd integer;

  6. \(\mathsf{Q}(\mathtt{PromCycle}^{\leq k}) \in O(\mathsf{Q}(\mathtt{Cycle}^{\leq k}))\);

  7. \(\mathsf{Q}(\mathtt{PromDirCycle}^{\leq k}) \in O(\mathsf{Q}(\mathtt{DirCycle}^{\leq k})))\);

  8. \(\mathsf{Q}(\mathtt{PromCycle}^{=k}) \in O(\mathsf{Q}(\mathtt{PromDirCycle}^{= k}))\);

  9. \(\mathsf{Q}(\mathtt{Cycle}^{\leq k}) \in O(\mathsf{Q}(\mathtt{DirCycle}^{\leq k}))\);

  10. \(\mathsf{Q}(\mathtt{Cycle}^{=k}) \in O(\mathsf{Q}(\mathtt{DirCycle}^{=k}))\).

Proof. We will prove all these statements one by one via reductions.

  1. First, we prove \(\mathsf{Q}(\mathtt{DirCycle}^{=k}) \in O(\mathsf{Q}(\mathtt{DirCycle}^{\leq k}))\). We want to decide if a directed input graph \(G=(V, E)\) has a directed cycle of length \(=k\) using an algorithm \(\mathcal{A}\) that decides whether a directed graph has a cycle of length \(\leq k\). We construct a \(k\)-color cyclic construction of \(G\) as sketched in 6; let us denote the resultant graph (which is a directed graph) as \(G'=(V',E')\). If \(G\) had a directed cycle of length \(k\) then \(G'\) will also have a cycle of length \(=k\) with probability at least \(1/k^k \in \Omega(1)\), and if \(G\) did not have a directed cycle of length \(k\) then \(G'\) will not have it either. Moreover, any cycle in \(G'\) will be of length at least \(k\). Invoking 2 proves the desired direction.

    In the other direction, from [item:MonotonicityDirCycle] of 10 we have a reduction that establishes \(\mathsf{Q}(\mathtt{DirCycle}^{=\ell}) \in O(\mathsf{Q}(\mathtt{DirCycle}^{=k}))\) for any \(\ell \in [k]\setminus \{1,2\}\). To decide if \(G\) has a directed cycle of length \(\leq k\), we loop over all \(\ell \in [k]\setminus \{1,2\}\) and run the above procedure to decide if \(G\) has a directed cycle of length \(=\ell\), and output yes if it outputs yes for any \(\ell \in [k]\setminus \{1,2\}\). Hence, proving that \(\mathsf{Q}(\mathtt{DirCycle}^{\leq k}) \in O(\mathsf{Q}(\mathtt{DirCycle}^{=k}))\).

  2. The reductions to prove both these relations are similar to the arguments presented for [item:DirCycleEqLeqk]. What remains to be argued is that the arguments hold in the promise setting as well. To prove the relation \(\mathsf{Q}(\mathtt{PromDirCycle}^{= k})\in O(\mathsf{Q}(\mathtt{PromDirCycle}^{\leq k}))\) we use the same idea of its non-promise counterparts. It is easy to see that when \(G\) (the input for \(\mathtt{PromDirCycle}^{= k}\)) is a no instance then because of the promise there will be no cycle of any length in \(G\) which means \(G'\) (the input for \(\mathtt{PromDirCycle}^{\leq k}\)) will also have no cycles as the construction doesn’t create new cycles. When \(G\) is a yes instance, \(G'\) is also a yes instance with probability \(\Omega(1)\). Even though the promise of \(\mathtt{PromDirCycle}^{\leq k}\) may not be satisfied for the rest of the times, invoking 2 concludes the argument.

    To show the other relation, i.e., \(\mathsf{Q}(\mathtt{PromDirCycle}^{\leq k}) \in O(\mathsf{Q}(\mathtt{PromDirCycle}^{= k}))\), we invoke [item:PromMonotonicityDirCycle] of 10 and then use the same reduction used for its non-promise counterparts as stated in [item:DirCycleEqLeqk].

  3. We will show that \(\mathsf{Q}(\mathtt{Cycle}^{\leq k}) \in O(\mathsf{Q}(\mathtt{Cycle}^{=k}))\). Let \(G\) be the input to \(\mathtt{Cycle}^{\leq k}\). The idea is to loop over \(\ell \in [3,k]\) and construct an \((\ell,k-\ell)\)-cyclic construction of \(G\) (as sketched in 7) for every value of \(\ell \in [3,k]\); let the constructed instance be denoted by \(G''(\ell)\). The idea is to now run an algorithm for \(\mathtt{Cycle}^{=k}\), let us denote by \(\mathcal{A}\), on every \(G''(\ell)\) and output yes if \(\mathcal{A}\) outputs yes on \(G''(\ell)\) for any value of \(\ell \in [3,k]\), otherwise output no. This reduction works because of the following reasons. Suppose that \(G\) did not contain any cycle of length \(\leq k\), i.e., \(G\) is a no instance of \(\mathtt{Cycle}^{\leq k}\). Then either \(G\) contains cycles of length \(>k\) or no cycle at all. In either of the cases none of the \(G''(\ell)\)s will not contain a cycle of length \(=k\) because the construction enforces that no new cycles are created and the length of the cycles (if present) in \(G\) doesn’t decrease in length. This means a no instance of \(\mathtt{Cycle}^{\leq k}\) maps to a no instances of \(\mathtt{Cycle}^{=k}\). On the other hand, if \(G\) was a yes instance of \(\mathtt{Cycle}^{\leq k}\) then \(G''(\ell)\) will be a yes instance of \(\mathtt{Cycle}^{=k}\) with probability \(>1/\ell^{\ell} \in \Omega(1)\) for at least one \(\ell \in [3,k]\). Finally, invoking 2 concludes the proof.

    (It is beneficial to note that the reduction in the other direction doesn’t hold; at least we don’t know how to prove it yet. Mainly, because we don’t know how to get rid of smaller cycles.)

  4. The relation \(\mathsf{Q}(\mathtt{PromCycle}^{\leq k}) \in O(\mathsf{Q}(\mathtt{PromCycle}^{=k}))\) follows from the definitions of the respective promise problems, along with the reduction we use for [item:CycleEqLeqk] and by invoking 2.

    For the other direction, \(\mathsf{Q}(\mathtt{PromCycle}^{=k}) \in O(\mathsf{Q}(\mathtt{PromCycle}^{\leq k}))\), we run the \(\mathtt{PromCycle}^{\leq k}\) algorithm on the \(k\)-color cyclic construction of \(G=(V,E)\), let us denote by \(G'=(V',E')\) where \(G\) is the input to the \(\mathtt{PromCycle}^{=k}\) problem. The promise on our input \(G\) ensures that there won’t be any cycle in the no case so running algorithm for \(\mathtt{PromCycle}^{\leq k}\) on \(G'\) will give no. And, in the yes case the construction \(G'\) will have a cycle of length \(k\) with probability \(> 1/k^k \in \Omega(1)\). Invoking 2 gives us the desired result.

  5. We will now argue \(\mathsf{Q}(\mathtt{DirCycle}^{=k}) \in O(\mathsf{Q}(\mathtt{Cycle}^{=k})\) holds for odd values of \(k\). Let \(G=(V,E)\) be an input to \(\mathtt{DirCycle}^{=k}\) problem. We first construct a \(k\)-color cyclic construction of \(G\), let us denote it by \(G'=(V',E')\). Note that \(G'\) will also be a directed graph and will contain a directed cycle of length \(=k\) with probability at least \(1/k^k \in \Omega(1)\). Moreover, if at all \(G'\) contains directed cycles then it will be of length at least \(k\) and furthermore “cycles” with inconsistent edge directions won’t exist in \(G'\) because of the color-coding. We now construct an undirected simple graph from \(G'\), let us denote by \(G''=(V'',E'')\). We do so by forgetting the directions of all the edges in \(E'\). We then run an algorithm for \(\mathtt{Cycle}^{=k}\) on \(G''\). If \(k\) is even, then forgetting the edge directions in \(G'\) could induce undirected cycles of length \(=k\) that were not present in the directed \(G'\); for example - a cycle could be just a multipartite matching between a few adjacent colors. But this is not a problem in the case when \(k\) is odd because any multipartite matching would only induce cycles of even length. Invoking 2 gives us the desired relation.

For [item:promCleqkNonprom,item:promDirCleqkNonprom], the relations follow from a straightforward application of 9. And, for [item:CEqKDir,item:ClEqKdir,item:PromCEqKPromDir], the relations follow from 6. ◻

Theorem 21 (Implicit in [6]). Let \(3\leq k \in \mathbb{N}\) be a constant. Then, there exists a \(O(n)\)-query quantum algorithm that, given a simple graph \(G\) with \(n\) vertices, accepts if \(G\) contains a cycle of length \(k\) and rejects if \(G\) is a forest, except with error probability at most \(1/3\).

Combining [Item:PromCycleEqLeqk] of 20 and 21 we conclude the following.

Corollary 6. Let \(3 \leq k \in \mathbb{N}\) be a constant. Then, \(\mathsf{Q}(\mathtt{PromCycle}^{=k|\leq k}) \in \Theta(n)\).

We will now present a few other cycle-containment reductions where the cycles are required to pass through a specific vertex, let us denote by \(s\), given as input. For these reductions we will use color-coding and layer insertion techniques as done earlier, but we will use the color-coding version that passes through \(s\). It is interesting to note that for some of these problems we are able to prove stronger relation in contrast to its counterparts that don’t have this additional requirement of the subgraph containing \(s\). For example, [item:CycleEqLeqksPartB,item:dirCycleEqkCycleEqks] in 22 are to name a few. See 4 for an illustrative and comparative summary of the results.

Proposition 22. Let \(3 \leq k \in \mathbb{N}\) be a constant. Then,

  1. \(\mathsf{Q}(\mathtt{DirCycle}^{=k}_{s}) \in \Theta(\mathsf{Q}(\mathtt{DirCycle}^{\leq k}_{s}))\);

  2. \(\mathsf{Q}(\mathtt{PromDirCycle}^{\leq k}_{s}) \in \Theta(\mathsf{Q}(\mathtt{PromDirCycle}^{= k}_{s}))\);

    1. \(\mathsf{Q}(\mathtt{Cycle}^{\leq k}_{s}) \in O(\mathsf{Q}(\mathtt{Cycle}^{=k}_{s}))\);

    2. \(\mathsf{Q}(\mathtt{Cycle}^{=k}_{s}) \in O(\mathsf{Q}(\mathtt{Cycle}^{\leq k}_{s}))\);

  3. \(\mathsf{Q}(\mathtt{PromCycle}^{=k}_{s}) \in \Theta(\mathsf{Q}(\mathtt{PromCycle}^{\leq k}_{s}))\);

  4. \(\mathsf{Q}(\mathtt{DirCycle}^{=k}_{s}) \in O(\mathsf{Q}(\mathtt{Cycle}^{=k}_{s}))\);

  5. \(\mathsf{Q}(\mathtt{PromDirCycle}^{= k}_{s}) \in \Theta(\mathsf{Q}(\mathtt{DirCycle}^{=k}_{s}))\);

  6. \(\mathsf{Q}(\mathtt{PromCycle}^{\leq k}_{s}) \in O(\mathsf{Q}(\mathtt{Cycle}^{\leq k}_{s}))\);

  7. \(\mathsf{Q}(\mathtt{PromDirCycle}^{\leq k}_{s}) \in O(\mathsf{Q}(\mathtt{DirCycle}^{\leq k}_{s})))\);

  8. \(\mathsf{Q}(\mathtt{PromCycle}^{=k}_{s}) \in O(\mathsf{Q}(\mathtt{PromDirCycle}^{= k}_{s}))\);

  9. \(\mathsf{Q}(\mathtt{Cycle}^{\leq k}_{s}) \in O(\mathsf{Q}(\mathtt{DirCycle}^{\leq k}_{s}))\);

  10. \(\mathsf{Q}(\mathtt{Cycle}^{=k}_{s}) \in O(\mathsf{Q}(\mathtt{DirCycle}^{=k}_{s}))\).

Proof. The reductions for [item:DirCycleEqLeqks,item:PromDirCycleEqLeqks,item:CycleEqLeqksPartA,Item:PromCycleEqLeqks] follow (almost) exactly via the reductions used for their problem counterparts in 20 where the subgraph doesn’t have to go through vertex \(s\). The only change needed here is that we use the color coding construction that goes through \(s\) as described in 6; this difference changes the exact probability of success for yes instances but is still \(\Omega(1)\) as required.

For the item in [item:CycleEqLeqksPartB] we want to argue that \(\mathsf{Q}(\mathtt{Cycle}^{=k}_{s}) \in O(\mathsf{Q}(\mathtt{Cycle}^{\leq k}_{s}))\). Let \(G=(V,E)\) and \(s \in V\) be the input to \(\mathtt{Cycle}^{=k}_{s}\). The main idea for this reduction is to try and get rid of all the small (i.e., length \(<k\)) cycles in \(G\). Towards establishing that, we first learn the neighborhood of \(s\) with \(n\) queries to \(G\); let us denote its neighborhood by \(N(s)\). As \(\mathsf{Q}(\mathtt{Cycle}^{=k}_{s}) \in \Omega(n)\) from 4 we can now treat our input \(G,s\) as \(G,s\) equipped with query-free access to \(N(s)\). We will now construct an instance \(G'=(V',E')\) from \(G=(V,E)\) in the following way. For every \(w \in N(s)\), we assign \(w\) to one of the three groups, let us denote by \(N^{\texttt{red}}(s),N^{\texttt{yellow}}(s),N^{\texttt{blue}}(s)\), uniformly at random. Consequently, \(N(s)=N^{\texttt{red}}(s) \sqcup N^{\texttt{yellow}}(s) \sqcup N^{\texttt{blue}}(s)\). Set \(V'=V\setminus N(s)\). For every \(\{u,v\} \in E\) add it to \(E'\) only when \(u,v \notin N(s)\cup\{s\}\). We now add vertices \(r,b\) in \(V'\); here \(r,b\) corresponds to a vertex after “contracting” the vertices in \(N^{\texttt{red}}(s),N^{\texttt{blue}}(s)\), respectively. Add \(\{s,r\}, \{s,b\}\) to \(E'\) and additionally for every \(\{u,v\} \in E\) such that \(u \in N^{\texttt{red}}(s)\) and \(v \neq s\) add \(\{u,r\}\) to \(E'\). Similarly,for every \(\{u,v\} \in E\) such that \(u \in N^{\texttt{blue}}(s)\) and \(v \neq s\) add \(\{u,b\}\) to \(E'\). We now construct \(G''=(V'',E'')\) by color-coding \(G'=(V',E')\) by assigning colors \(1,2,k\) to \(s,r,b\), respectively and color coding the rest of the vertices into the rest of the \(k-3\) colors as done in other reductions. We can now run an algorithm for \(\mathtt{Cycle}^{\leq k}_{s}\) on \(G'',s\). First note that any cycle in \(G''\) going through \(s\) (if present) has to pass through both \(r,b\) and therefore must is of length \(\geq k\). If there is a cycle of length \(=k\) in \(G\) (yes instance) then with probability \(\Omega(1)\) there will be a cycle of length \(=k\) through \(s\) in \(G''\) and the algorithm will output yes. If there was no cycle through \(s\) in \(G\) then \(G''\) also has no cycle through \(s\) because the construction doesn’t create new cycles. Moreover, any smaller cycles in \(G\) passing through \(s\) don’t survive in \(G''\). And, cycles of length \(>k\) in \(G\) map to no instance of \(G'',s\) either by not surviving or by being too long. Therefore, the reduction maps the no instance \(G,s\) to a no instance \(G'',s\). Invoking 2 concludes the argument.

For the relation in [item:dirCycleEqkCycleEqks], i.e., towards proving \(\mathsf{Q}(\mathtt{DirCycle}^{=k}_{s}) \in O(\mathsf{Q}(\mathtt{Cycle}^{=k}_{s}))\), we use a similar trick as done in [item:CycleEqLeqksPartB]. Let \(G=(V,E)\) be a directed graph that is input to \(\mathtt{DirCycle}^{=k}_{s}\). We first learn the neighborhood of \(s\) using \(n\) queries and that is fine because \(\mathsf{Q}(\mathtt{DirCycle}^{=k}_{s}) \in \Omega(n)\); see 4. Now we construct \(G''=(V'',E'')\) exactly as we did in the previous argument except that the constructed graph is directed. We now forget the directions of the edges in the constructed graph and then running an algorithm for \(\mathtt{Cycle}^{=k}_{s}\) on this graph suffices. If \(G\) was a no instance then the final constructed graph undirected-\(G''\) is also a no instance because undirected-\(G''\) will have cycles of length \(>k\). And in the case when \(G\) is a yes instance then the final constructed graph undirected-\(G''\) is also a yes instance with probability \(\Omega(1)\). Invoking 2 concludes the proof.

For the relation in [item:PromDirCycleEqksDirCycleEqks], one direction is straightforward application of 9. We now argue the other direction, i.e., \(\mathsf{Q}(\mathtt{DirCycle}^{=k}_{s}) \in O(\mathsf{Q}(\mathtt{PromDirCycle}^{= k}_{s}))\). Let the directed graph \(G=(V,E)\) and vertex \(s\) be the input to \(\mathtt{DirCycle}^{=k}_{s}\) problem. We first construct a \(k\)-color cyclic construction of \(G\) through \(s\) using 6. Let us denote this new directed graph by \(G'=(V',E')\). Note that, the construction ensures if \(G'\) has any cycle then it will only have cycles of length \(=k\) and not any other integral multiples of \(k\) because there is only one single vertex of color \(0\) in \(G'\) (which is \(s\)) and to have any bigger cycle in \(G'\) one needs to have another vertex \(\neq s\) of color \(0\), which is not possible because of the construction. Which means the graph \(G'\) either has a directed cycle of length \(=k\) through \(s\), which happens with probability \(\Omega(1)\) when the original graph \(G\) has a length \(=k\) cycle, or \(G'\) has no directed cycle passing through \(s\) when \(G\) is a no instance. These requirements perfectly align with the promise of \(\mathtt{PromDirCycle}^{= k}_{s}\). Therefore, it suffices to run an algorithm for \(\mathtt{PromDirCycle}^{= k}_{s}\) on \(G'\) to solve \(\mathtt{DirCycle}^{=k}_{s}\) on \(G\). And, invoking 2 gives us the desired relation.

For [item:promCleqkNonproms,item:promDirCleqkNonproms], the relations follow from a straightforward application of 9. And, for [item:PromCEqKPromDirs,item:CEqKDirs,item:ClEqKdirs], the relations follow from 6. ◻

Consequently, we get the following.

Corollary 7. Let \(3 \leq k \in \mathbb{N}\). Then, all the problems in \(\mathtt{(|Prom)DirCycle}_{s}^{(=k|\leq k)}\) have the same, up to constants, quantum query complexity.

Finally, we prove a connection between the restricted and unrestricted version of the cycle-containment problems.

Proposition 23. Let \(3 \leq k \in \mathbb{N}\) be a constant. Then, \(\mathsf{Q}(\mathtt{DirCycle}^{=k}_{s}) \in O(\mathsf{Q}(\mathtt{DirCycle}^{=k}))\) and \(\mathsf{Q}(\mathtt{PromDirCycle}^{= k}_{s}) \in O(\mathsf{Q}(\mathtt{PromDirCycle}^{= k}))\).

Proof. Let the graph \(G=(V,E)\) and vertex \(s\) be the input to the \(\mathtt{DirCycle}^{=k}_{s}\) problem. We construct a \(k\)-color cyclic construction of \(G\) through \(s\) as described in 6; let us denote the resultant graph as \(G'=(V',E')\). The construction ensures that the only directed cycles of length \(=k\) that go through \(s\) has a chance to survive in \(G'\). Hence, running an algorithm \(\mathtt{DirCycle}^{=k}\) on \(G'\) will detect such a cycle (if it existed in \(G\)) with probability \(\Omega(1)\) and if there were no cycles of length \(=k\) in \(G\) through \(s\) then \(G'\) will also not have any cycle of length \(k\). Invoking 2 concludes the proof. Thus, \(\mathsf{Q}(\mathtt{DirCycle}^{=k}_{s}) \in O(\mathsf{Q}(\mathtt{DirCycle}^{=k}))\).

Observe that, the reduction described earlier can also be used to strengthen the result in their respective promise versions. Consequently, implying \(\mathsf{Q}(\mathtt{PromDirCycle}^{= k}_{s}) \in O(\mathsf{Q}(\mathtt{PromDirCycle}^{= k}))\). ◻

3.3 Path-cycle-containment reductions↩︎

In this subsection, we present reductions between path and cycle problems (in both directions) to further refine the classification established in [sec:PathContainmentReductions,sec:CycleContainmentReductions] for path and cycle problems, respectively.

Proposition 24. Let \(3 \leq k \in \mathbb{N}\) be a constant. Then, \(\mathsf{Q}(\mathtt{DirCycle}^{=k}_{s}) \in O(\mathsf{Q}(\mathtt{DirPath}_{s,t}^{=k}))\).

Proof. Let the graph \(G=(V,E)\) and vertex \(s\) be the input to \(\mathtt{DirCycle}^{=k}_{s}\). Construct a new directed \(G'=(V',E')\) in the following way:

  1. set \(V'=V \sqcup \{t\}\) where \(t\) denotes a new vertex that is not already present in \(V\);

  2. for every \((u,v) \in E\) with \(v\neq s\), keep \((u,v)\) in \(E'\) and for all \((u,s) \in E\) create edge \((u,t)\) in \(E'\). Basically, we are directing all the incoming edges of \(s\) to \(t\) in our new graph \(G'\).

Observe that, every length-\(\ell\) directed cycle in \(G\) passing through \(s\) maps to a length-\(\ell\) \(s \rightarrow t\) path in \(G'\). Moreover, no other \(s \rightarrow t\) paths are created in \(G'\) in this process. Therefore, with this construction, we can solve \(\mathtt{DirCycle}^{=k}_{s}\) on \(G,s\) by solving \(\mathtt{DirPath}_{s,t}^{=k}\) on graph \(G',s,t\). ◻

Proposition 25. Let \(3 \leq k \in \mathbb{N}\) be a constant. Then, \(\mathsf{Q}(\mathtt{PromDirPath}_{s,t}^{=k}) \in O(\mathsf{Q}(\mathtt{PromDirCycle}^{= k}_{s}))\).

Proof. Let the graph \(G=(V,E)\) along with the vertices \(s,t\) be the input to \(\mathtt{PromDirPath}_{s,t}^{=k}\). We will construct a directed graph \(G'=(V',E')\) by first setting \(V'=V\). Color \(s\) with \(0\) and color \(t\) with \(k\). Additionally, for all \(v \in V'\setminus \{s,t\}\) assign a color from \([k-1]\) chosen uniformly at random. And, for each edge \((u,v) \in E\), add \((u,v)\) to \(E'\) if \(c(v)=c(u)+1\). We now construct \(G''=(V'',E'')\) from \(G'\) by merging the vertices \(s,t\) into say \(s''\) - basically means, for all edges \((s,u) \in E'\) add edge \((s'',u)\) to \(E''\) and for all \((u,t) \in E'\) add edge \((u,s'')\) to \(E''\). We will run the algorithm for \(\mathtt{PromDirCycle}^{= k}_{s}\) on graph \(G''\) and vertex \(s''\).

Let us now see why the reduction holds. The yes instance of \(\mathtt{PromDirPath}_{s,t}^{=k}\) constructs a yes instance \(G'\) to \(\mathtt{PromDirPath}_{s,t}^{=k}\) with probability \(1/(k-1)^{k-1} \in \Omega(1)\). And, a yes instance \(G'\) maps to a yes instance \(G''\) of \(\mathtt{PromDirCycle}^{= k}_{s}\) with probability \(1\). Moreover, the construction ensures that there are no directed cycles that go through only \(s\) or only \(t\) in graph \(G'\) because \(s\) only contains outgoing edges and \(t\) only contains incoming edges in \(G'\) - this means if algorithm for \(\mathtt{PromDirCycle}^{= k}_{s}\) on \(G'',s''\) outputs yes then there is corresponding \(s \rightarrow t\) path of length \(k\) in \(G'\) (and hence in \(G\)). Additionally, the promise of \(\mathtt{PromDirPath}^{=k}_{s,t}\) ensures that if there is no \(s \rightarrow t\) path in \(G\) then there is no path at all from \(s \rightarrow t\) in \(G\). This promise is satisfied even in the color coded version \(G'\) and satisfies the promise for \(\mathtt{PromDirCycle}^{= k}_{s}\) as well. Therefore, invoking 2 gives us the desired relation. ◻

Using 5 from 3.1, 7 from 3.2 and [thm:CrossArrow-DirCycleEqksToDirPathstEqk,thm:crossArrow-promDirPathEqkstToPromDirCycleEqks] we conclude the following.

Corollary 8. Let \(3 \leq k \in \mathbb{N}\) be a constant. Then, the path problems \(\mathtt{(|Prom)DirPath}_{s,t}^{(=k|\leq k)}\) and the cycle problems \(\mathtt{(|Prom)DirCycle}_{s}^{(=k|\leq k)}\) have the same, up to constants, quantum query complexity.

Proposition 26. Let \(3 \leq k \in \mathbb{N}\) be a constant. Then, \(\mathsf{Q}(\mathtt{PromCycle}^{=k}_{s}) \in O(\mathsf{Q}(\mathtt{PromPath}_{s,t}^{=k}))\).

Proof. To prove \(\mathsf{Q}(\mathtt{PromCycle}^{=k}_{s}) \in O(\mathsf{Q}(\mathtt{PromPath}_{s,t}^{=k}))\), we use the following argument. Let the graph \(G=(V,E)\) and vertex \(s\) be the input of \(\mathtt{PromCycle}^{=k}_{s}\). We construct graph \(G'=(V',E')\) from \(G=(V,E)\) in the following way:

  1. set \(V'=V \sqcup \{t\}\) where \(t\) is a new vertex that was not present in \(V\);

  2. for every \(\{u,v\} \in E\) such that \(u\neq s\) and \(v \neq s\), add the edge \(\{u,v\}\) in \(E'\), and, for every \(\{u,s\} \in E\), choose uniformly at random to either add \(\{u,s\}\) to \(E'\) or (exclusive or) to add \(\{u,t\}\) to \(E'\).

We will run the algorithm for \(\mathtt{PromPath}_{s,t}^{=k}\) on graph \(G'=(V',E')\) and vertices \(s,t\). Observe that, if there was a length-\(k\) cycle through \(s\) in graph \(G\) then with probability \(1/2 \in \Omega(1)\) there will be length \(k\) path between \(s,t\) in \(G'\). In the case where the algorithm for \(\mathtt{PromPath}^{=k}_{s,t}\) outputs yes then there are two distinct neighbors of \(s\) in the original graph \(G\) with a path of length \(k-2\) which means there is a cycle through \(s\) in \(G\). Invoking 2 concludes the reduction. ◻

Proposition 27. Let \(3 \leq k \in \mathbb{N}\) be a constant. Then, \(\mathsf{Q}(\mathtt{PromPath}_{s,t}^{=k}) \in O(\mathsf{Q}(\mathtt{PromCycle}_{s}^{=k}))\).

Proof. Let graph \(G=(V,E)\) and vertices \(s,t\) be the input to \(\mathtt{PromPath}_{s,t}^{=k}\). Using \(2n\) many queries to \(G\), we learn the neighborhood of \(s,t\) which we denote by \(N(s), N(t)\), respectively. It is fine to do so because \(\mathtt{PromPath}_{s,t}^{=k} \in \Omega(n)\). We will now construct an instance \(G'=(V',E')\) from \(G=(V,E)\) in the following way. For every \(u \in N(s)\), we assign \(u\) to one of the two groups, let us denote by \(N^{\textit{red}},N^{\textit{yellow}}\), uniformly at random. Similarly, for every \(v \in N(t)\setminus N(s)\), we assign \(v\) to either \(N^{\textit{yellow}}\) or to a new group, let us denote by \(N^{\textit{blue}}\), uniformly at random. Similarly to the idea in [item:CycleEqLeqksPartB] of 22 we construct a new graph \(G'=(V',E')\) by contracting all the vertices in \(N^{\textit{red}},N^{\textit{blue}}\) and denoting them as \(r,b\), respectively and preserving all the edges from \(E\) to \(E'\) that are incident on \(N^{\textit{red}},N^{\textit{blue}}\) (except the ones to \(s,t\)) as edges to/from \(r,b\), respectively. We also add all the edges from \(E\) in \(E'\) that don’t involve any of the vertices in \(\{s,t\}\cup N(s) \cup N(t)\) as either of its end points. Additionally, we add the edges \(\{r,s'\}, \{b,s'\}\) to \(E'\). To solve \(\mathtt{PromPath}_{s,t}^{=k}\) on \(G\) we now run an algorithm for \(\mathtt{PromCycle}^{=k}_{s}\) on \(G',s'\). If \(G\) has a length \(k\) path between \(s,t\) then with probability \(\Omega(1)\) there will be a length \(k\) cycle through \(s'\) in graph \(G'\). If \(G\) is a no instance then because of the promise there is no path between \(s,t\) in \(G\) and the construction ensures that there is no cycle (of any length) going through \(s'\) in graph \(G'\). Invoking 2 concludes the proof. ◻

As \(\mathtt{PromPath}_{s,t}^{=k}\) is known to have quantum query complexity of \(\Theta(n)\) (see 3), using [Item:PromCycleEqLeqks] of 22 and [thm:crossArrow-promCycleEqksToPromPathEqkst,thm:crossArrow-PromPathstToPromCycles] we can conclude the following:

Corollary 9. Let \(3 \leq k \in \mathbb{N}\) be a constant. Then, \(\mathsf{Q}(\mathtt{PromCycle}_{s}^{(=k|\leq k)}) \in \Theta(n)\).

4 Length-\(k\) directed path-detection algorithm↩︎

In this section, we consider the subgraph containment problem \(\mathtt{DirPath}^{=k}\), and we develop a novel algorithm for this problem. This implies a query upper bound for all of the problems displayed in red in 1.

We start by employing the color-coding technique, introduced by Alon, Yuster and Zwick [18], to partition the graph into \(k+1\) subsets.

Lemma 11. Let \(k,n \in \mathbb{N}\), and let \(G = (V,A)\) be a directed graph with \(|V| = n\) and \(k \in O(1)\). Let \(V_0 \sqcup \cdots \sqcup V_k \subseteq V\) be a random partition of \(V\) such that \(|V_j| \in \Theta(n/k)\). We define \(G' = (V,A')\), where \[A' = A_1 \sqcup \cdots \sqcup A_k, \qquad \text{with} \qquad A_j = \{(v,w) \in A : v \in V_{j-1}, w \in V_j\}.\] Now, if \(\mathtt{DirPath}^{=k}(G) = 0\), then \(\mathtt{DirPath}^{=k}(G') = 0\). On the other hand, if \(\mathtt{DirPath}^{=k}(G) = 1\), then \[\underset{G'}{\mathbb{P}}\left[\mathtt{DirPath}^{=k}(G') = 1\right] \in \Omega(1),\] where the probability distribution is over the randomization in the procedure that constructs \(G'\).

Proof. For the negative case, we observe that the new graph \(G'\) only contains a subset of the arcs in \(G\). Therefore, if the original graph \(G\) does not contain a directed path of length \(k\), then neither does \(G'\).

For the positive case, we observe that every vertex obtains any given color with probability \(1/(k+1)\). Thus, the probability that every vertex in the directed path receives the correct color is \((k+1)^{-(k+1)} \in \Omega(1)\). ◻

We can combine the previous theorem with 2, so without loss of generality we can consider the color-coded version of the problem, i.e., where the graph’s vertices are already partitioned into \(k+1\) disjoint sets and where we’re looking for a path that traverses all the way from one end to the other, as displayed in 5. To optimize the parameters in the recusion, we consider a vertion this problem where the first and last layer have a smaller size than all the intermediate layers, and setting \(r = n\) recovers the problem considered in 11.

Figure 5: The layered-path problem. Every set V_j for j \in[k-1] represents a set of \Theta(n) vertices, and the first and last layer might have a different size, say |V_0| = |V_k| = r. We are looking for a directed path that traverses all the layers from V_0 to V_k.

We now provide a recursive nested walk construction that finds such a layered path, if it exists.

Lemma 12. Let \(k,n,r \in \mathbb{N}\), with \(3 \leq k \in O(1)\) and \(r \leq n\). Let \(n/2 \geq s \in \mathbb{N}\), and suppose that we can solve the layered path-finding problem with length \(k-2\) and first and last layer size \(s\) with \(C_{n,s}^{(k-2)}\) queries. Then, we can solve the layered path-finding problem with complexity \(C_{n,r}^{(k)}\), satisfying \[C^{(k)}_{n,r} \in \widetilde{O}\left(s\sqrt{r} + \left(\frac{n}{s}\right)\left(\sqrt{sr} + C^{(k-2)}_{n,s}\right)\right).\]

Proof. We use a quantum walk. To that end, we first construct the graph that we will be walking over.

Let \(J_1\) be the Johnson graph of all subsets of size \(s\) from \(V_1\). Similarly, let \(J_{k-1}\) be the Johnson graph of all subsets of size \(s\) from \(V_{k-1}\). We will be walking over the Cartesian product of these graphs, i.e., \(G = J_1 \Box J_{k-1}\). We compute the spectral gap of \(G\) as \[\delta(G) = \min\{\delta(J_1), \delta(J_{k-1})\} = \frac{n}{s(n-s)} \in \Theta\left(\frac{1}{s}\right).\]

Now, we describe the marked set. We say that a vertex of \(G\), denoted by \((W_1, W_{k-1})\) where \(W_1 \subseteq V_1\) and \(W_{k-1} \subseteq V_{k-1}\) is marked whenever there exits a directed path of length \(k\) from \(V_0\) to \(V_k\) that passes through \(W_1\) and \(W_{k-1}\). If there exists one such path, then we easily compute that the fraction of marked vertices, i.e., \(\varepsilon\), satisfies \[\varepsilon \geq \frac{\binom{|V_1|-1}{s-1}}{\binom{|V_1|}{s}} \cdot \frac{\binom{|V_{k-1}|-1}{s-1}}{\binom{|V_{k-1}|}{s}} = \frac{s}{|V_1|} \cdot \frac{s}{|V_{k-1}|} \in \Theta\left(\left(\frac{s}{n}\right)^2\right).\]

Next, we desribe the data structure that we store along the way. At every vertex \((W_1,W_{k-1})\), we store for every vertex \(v \in W_1\) whether it can be reached from at least one vertex in \(V_0\), and similarly for every vertex \(v \in W_{k-1}\) whether there exists an edge going from \(v\) to a vertex in \(V_k\). Since these are simple search problems, we observe that the setup cost becomes \(\mathsf{S} \in O(s\sqrt{r})\), and since in the update routine we always only exchange a constant number of vertices, we have \(\mathsf{U} \in O(\sqrt{r})\). Finally, the checking routine, is the recursive procedure that only considers the vertices in \(W_1\) and \(W_{k-1}\) that are marked in the database, which results in a checking cost \(\mathsf{C} = C_{n,s}^{(k-2)}\).

Now, plugging everything into the MNRS-framework, i.e., 15, yields the claimed result. ◻

Now that we have described the recursive algorithm, we should work out what the resulting number of queries becomes, for a given value of \(k \in O(1)\). This is the objective of the following lemma.

Lemma 13. Let \(\alpha_r \in [0,1]\). For all \(k \in \mathbb{N}\), let \(\alpha_{k,r}\) be defined by the recurrence relation \[\alpha_{k+2,r} := \min_{\alpha_s \in [0,1]} \max\left\{\alpha_s + \frac{1}{2}\alpha_r, 1 - \frac{1}{2}\alpha_s + \frac{1}{2}\alpha_r, 1 - \alpha_s + \alpha_{k,s}\right\},\] with \(\alpha_{1,r} = \alpha_r\), and \(\alpha_{2,r} = \frac{1}{2} + \frac{1}{2}\alpha_r\). Next, let \(n \in \mathbb{N}\), and \(r \in \Theta(n^{\alpha_r})\). Then, we can solve the layered-path problem with first and last layer size \(r\) with a number of queries that satisfies \(C_{n,r}^{(k)} \in \widetilde{O}(n^{\alpha_{k,r}})\). Moreover, the solution to the recurrence relation satisfies \(\alpha_{k,n} \in 3/2 - \Theta(c^{-k})\) with \(c \approx 1.33\).

Proof. We first observe that if \(k = 1\), then we simply need to search over \(\binom{r}{2}\) possible edges, which requires \(O(r) = O(n^{\alpha_r}) = O(n^{\alpha_{1,r}})\) queries.

Next, for \(k = 2\), then we first search for the middle vertex, and then check whether there is a connection from the middle vertex to both the first and last layer. This requires a number of queries that satisfies \(O(\sqrt{nr}) = O(n^{\frac{1}{2} + \frac{1}{2}\alpha_r}) = O(n^{\alpha_{2,r}})\).

Then, for every \(k\), we observe by induction and 12 that the number of queries required to solve the layered-path problem with length \(k+2\) and first and last layer size \(r\) satisfies \[\begin{align} C_{n,r}^{(k+2)} &\in \widetilde{O}\left(\min_{\substack{s \in \mathbb{N}\\ 1 \leq s \leq n}} s\sqrt{r} + \left(\frac{n}{s}\right)\left(\sqrt{sr} + C_{n,s}^{(k)}\right)\right) \\ &\subseteq O\left(\min_{\alpha_s \in [0,1]} n^{\alpha_s + \frac{1}{2}\alpha_r} + n^{1-\frac{1}{2}\alpha_s+\frac{1}{2}\alpha_r} + n^{1-\alpha_s+\alpha_{k,s}}\right) = O(n^{\alpha_{k+2,r}}). \end{align}\]

Thus, it remains to solve the recurrence relation. To that end, we prove the following claim:

Claim 28. We consider the recurrence relations \[x_{k+2} = \frac{1+x_k}{2-y_k}, \quad \text{and} \quad y_{k+2} = \frac{1-y_k}{2(2-y_k)}, \quad \text{with} \quad x_2 = \frac{1}{2}, x_3 = \frac{2}{3}, y_2 = \frac{1}{2}, y_3 = \frac{1}{2}.\] These recurrence relations are well-defined, \((x_k + y_k)_{k=2}^{\infty}\) is increasing, and for all \(k \geq 2\), we have \(0 \leq 3/2 - (x_k + y_k) \in \Theta(c^{-k})\) where \(c = \sqrt{3+\sqrt{17}}/2 \approx 1.33\). Finally, we have \(\alpha_{k+2,r} = \max\{x_k + y_k, x_{k+2} + y_{k+2}\alpha_r\}\) for all \(k \geq 2\).

For future reference, we compute the first few values for \(x_k\) and \(y_k\).

Table 1: No caption
\(k\) \(2\) \(3\) \(4\) \(5\) \(6\) \(7\) \(8\) \(9\) \(10\) \(11\) \(12\)
\(y_k\) \(\frac{1}{2}\) \(\frac{1}{2}\) \(\frac{1}{6}\) \(\frac{1}{6}\) \(\frac{5}{22}\) \(\frac{5}{22}\) \(\frac{17}{78}\) \(\frac{17}{78}\) \(\frac{61}{278}\) \(\frac{61}{278}\) \(\frac{217}{990}\)
\(x_k\) \(\frac{1}{2}\) \(\frac{2}{3}\) \(1\) \(\frac{10}{9}\) \(\frac{12}{11}\) \(\frac{38}{33}\) \(\frac{46}{39}\) \(\frac{142}{117}\) \(\frac{170}{139}\) \(\frac{518}{417}\) \(\frac{206}{165}\)
\(x_k + y_k\) \(1\) \(\frac{7}{6}\) \(\frac{7}{6}\) \(\frac{23}{18}\) \(\frac{29}{22}\) \(\frac{91}{66}\) \(\frac{109}{78}\) \(\frac{335}{234}\) \(\frac{401}{278}\) \(\frac{1219}{834}\) \(\frac{1453}{990}\)

Proof. We first assert well-definedness. To that end, observe that \(|y_k| \leq 1/2\) implies that \(|y_{k+2}| \leq (1+|y_k|)/(2(2-|y_k|)) \leq 1/2\), and so \(y_k \neq 2\) for all \(k \geq 2\). Consequently, \(1 - y_k \geq 1/2\), and so \(x_k \leq 2\) implies that \(x_{k+2} \leq 3/(2-1/2) = 2\), hence by induction \(x_k \leq 2\) for all \(k \geq 2\).

Next, we can easily verify that for all \(\ell \geq 1\), \[y_{2\ell} = y_{2\ell+1} = \frac{\sqrt{17}}{2(-(-\chi)^\ell + 1)} + \varphi, \qquad \text{where} \qquad \chi = \frac{13 + 3\sqrt{17}}{4}, \quad \text{and} \quad \varphi = \frac{5 - \sqrt{17}}{4}.\]

Now, we assert that \((x_k + y_k)_{k=2}^{\infty}\) is increasing. To that end, we write \(\alpha = 1/(1-\varphi)\), and we bound for all \(k \geq 2\) that \[\alpha - x_{k+2} = \frac{\varphi - y_k}{\alpha(2 - y_k)} + \frac{\alpha - x_k}{2 - y_k}, \qquad \text{which implies} \qquad \left|\alpha - x_{k+2} - \frac{\alpha - x_k}{2 - \varphi}\right| < \frac{3}{\chi^{\lfloor k/2\rfloor}}.\] As \((2 - \varphi)/\chi < 1/3\), we obtain that for all \(k \geq 2\) and \(\ell \in \mathbb{N}\), \[\begin{align} \left|\alpha - x_{k+2\ell} - \frac{\alpha - x_k}{(2 - \varphi)^\ell}\right| &< \frac{3}{\chi^{\lfloor k/2\rfloor}} \sum_{m = 0}^{\ell-1} \frac{1}{(2 - \varphi)^m\chi^{\ell-1-m}} \\ &= \frac{3}{\chi^{\lfloor k/2\rfloor}(2 - \varphi)^{\ell-1}} \sum_{m=0}^{\ell-1} \left(\frac{2 - \varphi}{\chi}\right)^m < \frac{9}{2\chi^{\lfloor k/2\rfloor}(2-\varphi)^{\ell-1}}. \end{align}\] Now, we let \(k \in \{10,11\}\), and we check that \((x_{k+1} - x_k)/(2 - \varphi) > 1/1000 > 10/\chi^5\). Thus, we observe that for all \(\ell \in \mathbb{N}\) that \[\begin{align} &(x_{k+2\ell+1} - y_{k+2\ell+1}) - (y_{k+2\ell} + x_{k+2\ell}) \\ &\qquad = -(\alpha - x_{k+2\ell+1}) + (\alpha - x_{k+2\ell}) + (y_{k+2\ell+1} - \varphi) - (y_{k+2\ell} - \varphi) \\ &\qquad > \frac{\alpha - x_{k+1}}{(2 - \varphi)^{\ell}} - \frac{\alpha - x_k}{(2 - \varphi)^{\ell}} - \frac{9}{\chi^{\lfloor k/2\rfloor}(2 - \varphi)^{\ell-1}} - \frac{5}{\chi^{\lfloor k/2\rfloor + \ell}} \\ &\qquad > \frac{1}{(2 - \varphi)^{\ell-1}}\left[\frac{x_{k+1} - x_k}{2 - \varphi} - \frac{10}{\chi^{\lfloor k/2\rfloor}}\right] > 0. \end{align}\] Hence, \((x_k+y_k)_{k=10}^{\infty}\) is indeed increasing, and we manually check it is for the first few values of \(k\) as well.

From the above analysis we immediately observe that \(y_k \to \varphi\) and \(x_k \to \alpha\), as \(k \to \infty\). Moreover, we find \[\frac{3}{2} = \alpha + \varphi > x_k + y_k \in \frac{3}{2} - \Theta\left(c^{-k}\right),\] where \(c = \min\{\sqrt{\chi}, \sqrt{2-\varphi}\} = \sqrt{3+\sqrt{17}}/2\).

Finally, we prove that for all \(k \geq 2\), \(\alpha_{k+2,r} = \max\{x_k + y_k, x_{k+2} + y_{k+2}\alpha_r\}\). To that end, we work out the first couple of steps to obtain that \[\alpha_{3,r} = \max\left\{1, \frac{2}{3} + \frac{\alpha_r}{6}\right\}, \qquad \alpha_{4,r} = 1 + \frac{\alpha_r}{6}, \qquad \text{and} \qquad \alpha_{5,r} = \max\left\{\frac{7}{6}, \frac{10}{9} + \frac{\alpha_r}{6}\right\},\] and so the basis for induction is established. For the induction step, we suppose that the relation holds for a given \(k \geq 2\), and then observe that \[\alpha_{k+4,r} = \min_{\alpha_s \in [0,1]} \max\left\{\alpha_s + \frac{\alpha_r}{2}, 1 - \frac{\alpha_s}{2} + \frac{\alpha_r}{2}, 1 - \alpha_s + x_k + y_k, 1 - \alpha_s + x_{k+2} + y_{k+2}\alpha_s\right\}.\] Minimizing the first term in combination with the second, third and fourth terms yields \(\alpha_s = 2/3\), \(\alpha_s = \min\{1,(1+x_k+y_k)/2 - \alpha_r/4\}\) and \(\alpha_s = \min\{1,(1+x_{k+2})/(2-y_{k+2}) - \alpha_r/(2(2-y_{k+2}))\}\), respectively. Thus, \[\alpha_{k+4,r} = \max\left\{\frac{2}{3} + \frac{\alpha_r}{2}, \frac{1+x_k+y_k}{2} + \frac{\alpha_r}{4}, x_k + y_k, x_{k+4} + y_{k+4}\alpha_r, x_{k+2} + y_{k+2}\right\}.\] We obtain \(x_{k+2}+y_{k+2} \geq 7/6\) and \((x_k + y_k)_{k=2}^{\infty}\) is increasing, so the first and third term are always dominated by the fifth. For the second term, we compare to the fourth. We let \(k \in \{8,9\}\), and we observe that \(\alpha - x_k > 1/20 > 54/\chi^4\). Let \(\ell \in \mathbb{N}_0\), and using \(y_{k+2\ell+4} < 1/4\), we observe that \[\begin{align} &x_{k+2\ell+4} + y_{k+2\ell+4}\alpha_r - \frac{1+x_{k+2\ell}+y_{k+2\ell}}{2} - \frac{\alpha_r}{4} \\ &\qquad \geq x_{k+2\ell+4} + y_{k+2\ell+4} - \frac{3 + 2(x_{k+2\ell}+y_{k+2\ell})}{4} \\ &\qquad = \frac{1}{2}\left(\frac{3}{2} - (x_{k+2\ell} + y_{k+2\ell})\right) - \left(\frac{3}{2} - (x_{k+2\ell+4} + y_{k+2\ell+4})\right) \\ &\qquad > \left[\frac{1}{2} - \frac{1}{(2-\varphi)^2}\right]\left(\frac{3}{2} - (x_{k+2\ell}+y_{k+2\ell})\right) - \frac{8}{\chi^{\lfloor k/2\rfloor+\ell}} > \frac{\alpha - x_k}{6(2-\varphi)^{\ell}} - \frac{9}{\chi^{\lfloor k/2\rfloor+\ell}} \\ &\qquad > \frac{1}{6(2-\varphi)^{\ell}}\left[\alpha - x_k - \frac{54}{\chi^{\lfloor k/2\rfloor}}\right] > 0. \end{align}\] Thus, for all \(k \geq 8\), the second term is dominated by the fourth, and we manually check this is the case for smaller values of \(k\) as well. ◻

Finally, we plug in \(r = n\), and hence \(\alpha_r = 1\), to conclude that \(\alpha_{k,n} = x_k + y_k \in 3/2 - \Theta(c^{-k})\), where \(c \approx 1.33\). ◻

Putting everything together, we now obtain the following result.

Corollary 10. \(\mathsf{Q}(\mathtt{DirPath}^{=k}) \in \widetilde{O}(n^{\frac{3}{2} - \alpha_k})\), where \(\alpha_k \in \Omega(c^{-k})\) as \(k \to \infty\), with \(c = \sqrt{3+\sqrt{17}}/2 \approx 1.33\).

Proof. We combine 11 with 2 to obtain that solving the layered path-finding problem with length \(k\) and first and last layer size \(n\) is sufficient for finding a directed path of length \(k\) in a directed graph. The result then follows from plugging in \(r = n\) in 13. ◻

We compute the resulting query complexity for the first few values of \(k\) for good measure.

Table 2: The query complexity of \(\mathsf{Q}(\mathtt{DirPath}^{=k})\) for the first few values of \(k\).
\(k\) \(1\) \(2\) \(3\) \(4\) \(5\) \(6\) \(7\)
\(\mathsf{Q}(\mathtt{DirPath}^{=k})\) \(\widetilde{O}(n)\) \(\widetilde{O}(n)\) \(\widetilde{O}(n^{7/6})\) \(\widetilde{O}(n^{7/6})\) \(\widetilde{O}(n^{23/18})\) \(\widetilde{O}(n^{29/22})\) \(\widetilde{O}(n^{91/66})\)

5 Length-\(\leq k\) cycle-detection algorithm↩︎

In this section, we modify the approach developed in [5], to obtain a novel quantum algorithm for the \(\mathtt{Cycle}^{\leq k}\)-problem, whenever \(k\) is odd. The core result that we are using is the following theorem.

Theorem 29 ([5]). Let \(\mathcal{P}\) be the property that an \(n\)-vertex graph either has more than \(\overline{m}\) edges, where \(\overline{m} \in \Omega(n)\), or contains a given subgraph \(H\). Let \(H'\) be the graph obtained by deleting all degree-\(1\) vertices of \(H\) that are not part of an isolated edge. Then \(\mathsf{Q}(\mathcal{P}) \in \widetilde{O}(\sqrt{\overline{m}}n^{1-\frac{1}{\text{vc}(H')+1}})\), where \(\text{vc}(H')\) denotes the vertex cover of \(H'\), i.e., the minimum number of vertices in \(H'\) required to cover all edges.

Applying this to \(k\)-cycles, we get the following corollary.

Corollary 11. Let \(k \geq 3\). Let \(\mathcal{P}\) be the property that an \(n\)-vertex graph either has more than \(\overline{m}\) edges, where \(\overline{m} \in \Omega(n)\), or contains a \(k\)-cycle. Then, there is a quantum algorithm that computes \(\mathcal{P}\) using \(\widetilde{O}(\sqrt{\overline{m}}n^{1-\frac{1}{\lceil k/2 \rceil+1}})\) queries.

We modify the algorithm attaining the result in 29 (and 11) to get a slight improvement for the case when \(k\) is odd (making a stronger assumption on \(\overline{m}\) which will also be satisfied for our applications).

Theorem 30. Let \(k \geq 3\). Let \(\mathcal{P}\) be the property that an \(n\)-vertex graph either has more than \(\overline{m}\) edges, where \(\overline{m} \in \Omega(n^{1+1/(\ell+1)})\) and \(\ell = \lfloor k/2 \rfloor\), or contains a \(k\)-cycle. Then, there is a quantum algorithm SparseCycle that computes \(\mathcal{P}\) using \(\widetilde{O}(\sqrt{\overline{m}}n^{1-\frac{1}{\ell+1}})\) queries.

Proof. Our algorithm is very similar to that of 29 by [5]. The checking cost of their quantum walk procedure is \(0\) since their walk database contains a \(k\)-cycle whenever a vertex is marked. In a nutshell. for the \(k\)-cycle problem, we improve the complexity of the setup and update steps in their walk at the cost of increasing the checking complexity (which will still be bounded by the complexity corresponding to the setup and update steps). We provide the algorithm and the complexity analysis for completeness.

We use 1 to decide if the number of edges \(m\) in the input graph is at least \(\overline{m}\) or at most \(\overline{m}/3\) edges with probability at least \(1-1/n\) using \(\widetilde{O}(\sqrt{n^2/\overline{m}}) \subseteq \widetilde{O}(\sqrt{n})\) queries. If this procedure accepts, we accept; otherwise, we suppose that \(m \in O(\overline{m})\) and proceed as follows.

We will assume that \(k\) is odd since for the case when \(k\) is even, we get the desired result directly from 11.

We will partition the vertex set \(V\) into \(\lceil \log n \rceil\) many parts according to its degree. We will not explicitly compute this partition; instead, we will maintain the relevant information about this partition in our quantum walk (as we explain below).

For \(i \in [\ell]\), fix \(p_i \in [\lceil \log n \rceil]\) and \(q_i = 2^{p_i}\). We will describe an algorithm for determining if there are vertices \(v_i\) for \(i \in [\ell]\) with degree close to \(q_i\) (i.e. \([q_i/2, 3q_i/2]\)) such that \(v_1, \dots, v_\ell\) are non-adjacent vertices of a \(k\)-cycle. We can run this procedure for all \(\lceil \log n \rceil^\ell\) tuples of length \(\ell\) comprising of elements from \([\lceil \log n \rceil]\), incurring a polylogarithmic overhead.

We will use a quantum walk procedure on a Johnson graph invoking 15. In the walk database, for each \(i \in [\ell]\), we will store \(r_i\) vertices whose degree is close to \(q_i\) and their neighborhoods. Note that the number of vertices whose degree is in \([q_i/2, 3q_i/2]\) is \(t_i \in O(\overline{m}/q_i)\).

To determine if a vertex \(v\) has degree at least \(q_i/2\) or at most \(q_i/6\) with probability at least \(1-1/n^3\), we can use the approximate degree counting algorithm in 2 using \(\tilde{O}(\sqrt{n/q_i})\) queries. Similarly, to determine if a vertex \(v\) has degree at least \(9q_i/2\) or at most \(3q_i/2\) with probability at least \(1-1/n^3\), we can use the approximate degree counting algorithm in 2 using \(\tilde{O}(\sqrt{n/q_i})\) queries. Thus, for a vertex \(v\), if \(\deg(v) \in [q_i/2, 3q_i/2]\), then it is accepted by the first check and rejected by the second check with probability at least \(1-2/n^3\). Since there are \(t_i\) vertices with degree in \([q_i/2, 3q_i/2]\), the probability that a randomly sampled vertex has such degree is \(t_i/n\). Thus, via Grover’s algorithm, the total cost of searching for a vertex with degree close to \(q_i\) is \(\widetilde{O}(\sqrt{n/t_i} \cdot \sqrt{n/q_i}) \subseteq \widetilde{O}(n/\sqrt{t_i})\). Computing the neighborhood for any \(v\) with its degree close to \(q_i\) will cost \(\widetilde{O}(\sqrt{n \deg(v)}) = \widetilde{O}(\sqrt{n \cdot q_i})\) by 1.

For each update step of our walk, for each \(i \in [\ell]\), we randomly remove \(s_i\) of the \(r_i\) vertices (and their neighbors) and add \(s_i\) other vertices with degree close to \(q_i\) and their neighborhoods. We say that a vertex of our walk is marked if the database associated with this vertex contains \(\ell\) non-adjacent vertices of a \(k\)-cycle and their neighborhood in \(\ell\) different blocks.

We are now ready to compute the cost of our quantum walk. The setup (and update) cost involves, for each \(i \in [\ell]\), searching for \(r_i\) (respectively \(s_i\)) vertices with degree close to \(q_i\) and computing their neighborhoods. We earlier noticed that for each vertex, the former step costs \(\widetilde{O}(n/\sqrt{t_i})\) and the latter step costs \(\widetilde{O}(\sqrt{n \cdot q_i})\) queries. Thus, the total cost for each vertex is \(\widetilde{O}(n/\sqrt{t_i} + \sqrt{n \cdot q_i}) \subseteq \widetilde{O}(\sqrt{n \overline{m}/t_i})\) since \(t_i \cdot q_i \in O(\overline{m})\) and \(\overline{m} \in \Omega(n)\). It follows that the setup and update costs are \(S \in \widetilde{O}(\sum_{i \in [\ell]} r_i \cdot \sqrt{n \overline{m}/t_i})\) and \(U \in \widetilde{O}(\sum_{i \in [\ell]} s_i \cdot \sqrt{n \overline{m}/t_i})\) respectively. The checking procedure involves determining if the database contains \(\ell\) non-adjacent vertices of a \(k\)-cycle in \(\ell\) different blocks. Since we also store the neighborhoods of all the vertices, we need to decide if there are \(\ell\) vertices in \(\ell\) different blocks forming a length-\(2\ell\) path that can be extended to a cycle of length \(k = 2\ell+1\). This can be done by searching for an edge that connects a pair of endpoints of any such path in \(O(\sqrt{n^2}) = O(n)\) queries using Grover’s algorithm. The spectral gap \(\delta\) of our walk is \(\Omega(\min_{i \in [\ell]}s_i/r_i)\) and the probability \(\epsilon\) of marked vertices of our walk is \(\Omega(\prod_{j \in [\ell]} r_j/t_j)\). Therefore, the total cost of our walk is \[S + \frac{1}{\sqrt{\epsilon}} \left( \frac{1}{\sqrt{\delta}}U + C\right) \in \widetilde{O}\left(\sum_{i \in [\ell]} r_i \cdot \sqrt{\frac{n \overline{m}}{t_i}} + \prod_{j \in [\ell]} \sqrt{\frac{t_j}{r_j}} \left(\max_{i \in [\ell]} \sqrt{\frac{r_i}{s_i}} \left(\sum_{i \in [\ell]} s_i \cdot \sqrt{\frac{n \overline{m}}{t_i}}\right) + n \right)\right)\]

We will let \[\frac{r_i}{r_j} = \frac{s_i}{s_j} = \sqrt{\frac{t_i}{t_j}}, \qquad \qquad s_1 = 1, \qquad \qquad r_1 = \sqrt{t_1} n^{\frac{1}{2}-\frac{1}{\ell+1}},\] and argue that all the three terms in the above expression are bounded by \(\widetilde{O}(\sqrt{\overline{m}}n^{1-\frac{1}{\ell+1}})\). First, notice that

\[\begin{align} \sum_{i \in [\ell]} r_i \cdot \sqrt{\frac{n \overline{m}}{t_i}} = \ell \cdot r_1 \cdot \sqrt{\frac{n \overline{m}}{t_1}} \in O (\sqrt{\overline{m}} n^{1-\frac{1}{\ell+1}}). \end{align}\]

For the second term, we first simplify \[\begin{align} \prod_{j \in [\ell]} \frac{t_j}{r_j} = \left(\frac{\sqrt{t_1}}{r_1}\right)^\ell \cdot \prod_{j \in [\ell]}\sqrt{t_j} = \frac{t_1}{r_1} \cdot \left(\frac{\sqrt{t_1}}{r_1}\right)^{\ell-1} \prod_{j \in [2,\ell]}\sqrt{t_j} \leq \frac{t_1}{r_1} \cdot \left(\frac{\sqrt{t_1 n}}{r_1}\right)^{\ell-1} = \frac{t_1}{r_1} n^{\frac{\ell-1}{\ell+1}} \end{align}\] so \[\begin{align} \prod_{j \in [\ell]} \sqrt{\frac{t_j}{r_j}} = \sqrt{\frac{t_1}{r_1}} n^{\frac{\ell-1}{2(\ell+1)}}. \end{align}\]

We also simplify \[\begin{align} \max_{i \in [\ell]} \sqrt{\frac{r_i}{s_i}} \left(\sum_{i \in [\ell]} s_i \cdot \sqrt{\frac{n \overline{m}}{t_i}}\right) = \ell \cdot \sqrt{r_1 s_1} \cdot \sqrt{\frac{n \overline{m}}{t_1}} \in O\left(\sqrt{r_1 s_1} \cdot \sqrt{\frac{n \overline{m}}{t_1}} \right) = O\left(\sqrt{\frac{r_1}{t_1}} \cdot \sqrt{n \overline{m}} \right). \end{align}\]

Taking their products gives us \[\begin{align} \prod_{j \in [\ell]} \sqrt{\frac{t_j}{r_j}} \left(\max_{i \in [\ell]} \sqrt{\frac{r_i}{s_i}} \left(\sum_{i \in [\ell]} s_i \cdot \sqrt{\frac{n \overline{m}}{t_i}}\right) \right) \in O\left(\sqrt{n \overline{m}} \cdot n^{\frac{\ell-1}{2(\ell+1)}}\right) = O (\sqrt{\overline{m}} n^{1-\frac{1}{\ell+1}}). \end{align}\]

It remains to argue that the term corresponding to the checking cost is bounded by \(O (\sqrt{\overline{m}} n^{1-\frac{1}{\ell+1}})\). To show this, it is sufficient to argue that \(C \in O(1/\sqrt{\delta} \cdot U)\), which we do as follows. \[\begin{align} \frac{1}{\sqrt{\delta}} U \geq \sqrt{\frac{r_1}{t_1}} \cdot \sqrt{n \overline{m}} = \sqrt{\frac{n^{\frac{1}{2}-\frac{1}{\ell+1}}}{\sqrt{t_1}}} \cdot \sqrt{n \overline{m}} \geq n^{\frac{1}{2}-\frac{1}{2(\ell+1)}} \cdot \sqrt{\overline{m}} \in \Omega(n) \subseteq \Omega(C). \end{align}\] where the last step follows since \(\overline{m} \in \Omega(n^{1+1/(\ell+1)})\). ◻

Now, we can combine this construction with a combinatorial result by Bondy and Simonovits [31], that connects the non-existence of an even-length cycle of a given length to a sparsity condition on the graph.

Theorem 31 ([31]). Let \(G\) be a graph on \(n\) vertices. For any \(\ell \geq 2\), if \(|E(G)| > 100 \ell n^{1+1/\ell}\) then \(G\) contains \(\mathcal{C}_{2\ell}\) as a subgraph.

Combining the previous two results now gives us our algorithm that solves the \(\mathtt{Cycle}^{\leq k}\)-problem.

Theorem 32. Let \(k \geq 4\). Then, \(\mathsf{Q}(\mathtt{Cycle^{\leq k}}) \in \widetilde{O}(n^{\frac{3}{2}-\gamma(k)})\), where \[\gamma(k) = \begin{cases} \frac{k-2}{k(k+2)}, & \text{if k is even}, \\ \frac{k-3}{(k-1)(k+1)}, & \text{if k is odd}. \end{cases}\]

Proof. Let \(\ell = \lfloor k/2 \rfloor\). The general strategy of our algorithm is to first check if \(G\) is dense enough to already have a \(\mathcal{C}_{2\ell}\) using 31. If it is not, then we know that \(E(G) \in O(n^{1+1/\ell})\), which we can use to efficiently compute if there is a \(\mathcal{C}_j\) for any \(j \in [3,k]\) using 30. See 6 for a formal description of this algorithm.

The correctness is easy to check. It remains to argue the desired complexity. For the density reduction stage, it follows from 1 that \(\widetilde{O}(\sqrt{n^2/\overline{m}}) = \widetilde{O}(\sqrt{n^{1-1/\ell}})\) queries would be sufficient. If the algorithm does not abort in the density reduction stage, then we can suppose that \(E(G) \in O(\overline{m}) = O(n^{1+1/\ell})\). The complexity expression in 30 is non-decreasing in \(k\) so the complexity contribution for the iteration where \(j=k\) will dominate the cost of the for loop in the sparse case stage. In fact, this step will dominate the cost of 6 since the cost of the density reduction stage is sublinear. From 11, we deduce that the cost will be \[\widetilde{O}(\sqrt{\overline{m}} n^{1-\frac{1}{\ell+1}}) = \widetilde{O}(n^{\frac{3}{2} - \frac{\ell-1}{2\ell (\ell+1)}}) = \begin{cases} \widetilde{O}(n^{\frac{3}{2} - \frac{k-2}{k(k+2)}}), & \text{if k is even}, \\ \widetilde{O}(n^{\frac{3}{2} - \frac{k-3}{(k-1)(k+1)}}), & \text{if k is odd}. \end{cases}\qedhere\]

Figure 6: Algorithm for \mathtt{Cycle}^{\leq k} for k \geq 4

 ◻

Finally, we summarize the best-known upper bounds on the query complexities for \(\mathtt{Cycle}^{=k}\) and \(\mathtt{Cycle}^{\leq k}\) in 7. We observe that for all \(k\), the \(\mathtt{Cycle}^{\leq k}\)-problem can be solved in \(o(n^{3/2})\) queries, whereas for the \(\mathtt{Cycle}^{=k}\)-problem, we can only make that statement for even values of \(k\). It would be a very interesting direction of future research to establish whether the \(\mathtt{Cycle}^{=k}\)-problem for odd values of \(k\) can be solved in \(\widetilde{O}(n^{3/2})\) queries as well.

Figure 7: The best-known upper bounds on the query complexity of the \mathtt{Cycle}^{=k}-problem (shown in blue) and the \mathtt{Cycle}^{\leq k}-problem (shown in red). The black vertices represent the best-known unconditional lower bounds on both problems, and the green dots represent the best-known conditional lower bounds on the \mathtt{Cycle}^{=k}-problem, conditional on \mathsf{Q}(\mathtt{GC}_n) \in \Omega(n^{2/3}).

We also observe that the expressions we obtain for general values of \(k\) do not recover the best-known upper bounds for the cases where \(k = 3\) and \(k = 4\). This suggests that for higher values of \(k\), the upper bounds we know for these cycle-containment problems are likely not tight. Therefore, we think it’s a very nice future direction of research to improve the best-known algorithms for these problems.

6 Conditional lower bounds based on graph collision↩︎

In this final section, we prove a novel super-linear conditional lower bound on the query complexities of several problems in 1. Our lower bounds will be based on the graph-collision problem, introduced in [1].

Definition 8 (Graph collision problem [1]). Let \(G = (V,E)\) be an undirected graph. We consider the boolean function \(\mathtt{GC}_G = \mathtt{GraphCollision}_G : \{0,1\}^V \to \{0,1\}\), which evaluates to \(1\) on input \(x \in \{0,1\}^V\) if and only if there exists an edge \(vw \in E\), such that \(x_v = x_w = 1\). This is the graph collision problem on \(G\). For all \(n \in \mathbb{N}\), \[\mathsf{Q}(\mathtt{GC}_n) := \max_{\substack{G = (V,E) \\ |V| = n}} \mathsf{Q}(\mathtt{GC}_G).\]

We find by a straightforward reduction to search that \(\mathsf{Q}(\mathtt{GC}_n) \in \Omega(\sqrt{n})\). Conversely, we have that \(\mathsf{Q}(\mathtt{GC}_n) \in O(n^{2/3})\), see for instance [1].

Balodis and Iraids showed that the quantum query complexity of triangle finding is related to the graph collision problem, which gives us a conditional lower bound on several of the equivalence classes displayed in 1. We modify Balodis’s and Iraids’s approach to give the same lower bound to the cycle-finding problem through a vertex \(s\).

Proposition 33. \(\mathsf{Q}(\mathtt{Cycle}_s^{=5}) \in \Omega(\sqrt{n} \cdot \mathsf{Q}(\mathtt{GC}_n))\).

Proof. Let \(G = (V,E)\) be any graph on \(n\) vertices, where we write \(V = \{v_1, \dots, v_n\}\). We will reduce \(\mathtt{GC}_G \circ \mathtt{OR}_n\) to \(\mathtt{Cycle}_s^{\leq k}\). That is, given query access to individual bits of \(n\) strings \(x^{(i)} \in \{0,1\}^n\) with \(x^{(i)}\) associated with \(v_i\), which forms an instance of \(\mathtt{GC}_G \circ \mathtt{OR}_n\), we construct a graph instance \(G' =(V',E')\) of \(\mathtt{Cycle}_s^{=5}\) as follows. Let \(V' = \{v_j^{(\ell)} : j \in [n], \ell \in [4]\} \cup \{s\}\). We define \[\overline{E} = \{\{s,v_j^{(1)}\},\{s,v_j^{(4)}\} : j \in [n]\} \cup \{\{v_j^{(2)}, v_k^{(3)}\}, \{v_k^{(2)}, v_j^{(3)}\} : \{v_j,v_k\} \in E\},\] and \[E_x = \{\{v_j^{(1)},v_k^{(2)}\},\{v_k^{(3)}, v_j^{(4)}\} : x_j^{(k)} = 1\}.\]

We now argue that \(G' = (V',\overline{E} \cup E_x)\) is a positive input to \(\mathtt{Cycle}^{=5}\) if and only if \(x\) is a positive input to \(\mathtt{GC}_G \circ \mathtt{OR}_n\). To that end, suppose that \(x\) is a positive input for \(\mathtt{GC}_G \circ \mathtt{OR}_n\). Then, there exist \(j,k \in [n]\) such that \(\{v_j,v_k\} \in E\), and that there are \(\ell_j, \ell_k \in [n]\) such that \(x_{\ell_j}^{(j)} = x_{\ell_k}^{(k)} = 1\), and so we have a cycle \(s\)\(v_{\ell_j}^{(1)}\)\(v_j^{(2)}\)\(v_k^{(3)}\)\(v_{\ell_k}^{(4)}\)\(s\) of length \(5\) in \(G'\).

For the reverse direction, suppose that \(G'\) has a cycle of length \(5\) passing through \(s\). As \(G'\) is a color-coded graph with an odd number of layers, any cycle of length \(5\) must traverse through all the layers, which means its path can be written as \(s\)\(v_{\ell_j}^{(1)}\)\(v_j^{(2)}\)\(v_k^{(3)}\)\(v_{\ell_k}^{(4)}\)\(s\), for suitable choices of \(\ell_j, j, k, \ell_k \in [n]\). This then implies that \(\{v_j,v_k\} \in E\), and \(x_{\ell_j}^{(j)} = x_{\ell_k}^{(k)} = 1\), which means that \(x\) is a positive instance for \(\mathtt{GC}_G \circ \mathtt{PromOR}_n\).

Thus, we find that \(\mathsf{Q}(\mathtt{Cycle}_s^{=5}) \geq \mathsf{Q}(\mathtt{GC}_G \circ \mathtt{OR}_n) \in \Theta(\sqrt{n} \cdot \mathsf{Q}(\mathtt{GC}_G))\), for all graphs \(G\) with \(n\) vertices, using that the quantum query complexity multiplies under composition [28]. Finally, we can take the maximum over all such \(G\) on the right-hand side of the equation to obtain the claimed result. ◻

Acknowledgments↩︎

We would like to thank Andrew Childs and Matthew Coudron for many useful discussions. A.C.acknowledges support by a Simons-CIQC postdoctoral fellowship through NSF QLCI Grant No.. A.S.G. acknowledges support from the U.S. Department of Energy, Office of Science, Accelerated Research in Quantum Computing, Fundamental Algorithmic Research toward Quantum Utility (FAR-Qu) and the National Institute of Standards and Technology (NIST). S.P.acknowledges the support from the Dutch Ministry of Education, Culture, and Science through Gravitation project "Challenges in Cyber Security - 024.006.037" for this work.

References↩︎

[1]
F. Magniez, M. Santha, and M. Szegedy, “Quantum algorithms for the triangle problem,” SIAM Journal on Computing, vol. 37, no. 2, pp. 413–424, 2007.
[2]
A. Ambainis, “Quantum walk algorithm for element distinctness,” SIAM Journal on Computing, vol. 37, no. 1, pp. 210–239, 2007.
[3]
Y. Zhu, “Quantum query complexity of subgraph containment with constant-sized certificates,” arXiv preprint arXiv:1109.4165, 2011.
[4]
T. Lee, F. Magniez, and M. Santha, “Learning graph based quantum query algorithms for finding constant-size subgraphs,” Chicago Journal of Theoretical Computer Science, vol. 10, pp. 1–21, 2012.
[5]
A. M. Childs and R. Kothari, “Quantum query complexity of minor-closed graph properties,” SIAM Journal on Computing, vol. 41, no. 6, pp. 1426–1450, 2012.
[6]
A. Belovs and B. W. Reichardt, “Span programs and quantum algorithms for st-connectivity and claw detection,” in European symposium on algorithms, 2012, pp. 193–204.
[7]
H. Buhrman et al., “Quantum algorithms for element distinctness,” in Proceedings of the 16th annual conference on computational complexity, 2001.
[8]
T. Carette, M. Laurière, and F. Magniez, “Extended learning graphs for triangle finding,” Algorithmica, vol. 82, no. 4, pp. 980–1005, 2020.
[9]
F. Le Gall, “Improved quantum algorithm for triangle finding via combinatorial arguments,” in 2014 IEEE 55th annual symposium on foundations of computer science, 2014, pp. 216–225.
[10]
C. Cade, A. Montanaro, and A. Belovs, “Time and space efficient quantum algorithms for detecting cycles and testing bipartiteness,” Quantum Information and Computation, vol. 18, no. 1–2, pp. 18–50, 2018.
[11]
S. Zhang, “On the power of ambainis lower bounds,” Theoretical Computer Science, vol. 339, no. 2–3, pp. 241–256, 2005.
[12]
R. Špalek and M. Szegedy, “All quantum adversary methods are equivalent,” Theory of Computing, vol. 2, no. 1, pp. 1–18, 2006.
[13]
R. Beals, H. Buhrman, R. Cleve, M. Mosca, and R. de Wolf, “Quantum lower bounds by polynomials,” in Proceedings of the 39th annual symposium on foundations of computer science, 1998.
[14]
P. Hoyer, T. Lee, and R. Spalek, “Negative weights make adversaries stronger,” in Proceedings of the thirty-ninth annual ACM symposium on theory of computing, 2007, pp. 526–535.
[15]
K. Balodis and J. Iraids, “Quantum lower bound for graph collision implies lower bound for triangle detection.” Baltic Journal of Modern Computing, vol. 4, no. 4, 2016.
[16]
A. M. Childs, R. Cleve, E. Deotto, E. Farhi, S. Gutmann, and D. A. Spielman, “Exponential algorithmic speedup by a quantum walk,” in Proceedings of the thirty-fifth annual ACM symposium on theory of computing, 2003.
[17]
A. M. Childs, M. Coudron, and A. S. Gilani, Quantum Algorithms and the Power of Forgetting,” in 14th innovations in theoretical computer science conference (ITCS 2023), 2023.
[18]
N. Alon, R. Yuster, and U. Zwick, “Color-coding,” Journal of the ACM (JACM), vol. 42, no. 4, pp. 844–856, 1995.
[19]
C. Dürr, M. Heiligman, P. Hoyer, and M. Mhalla, “Quantum query complexity of some graph problems,” SIAM Journal on Computing, vol. 35, no. 6, pp. 1310–1328, 2006.
[20]
C. Y.-Y. Lin and H.-H. Lin, “Upper bounds on quantum query complexity inspired by the elitzur-vaidman bomb tester,” in Proceedings of the 30th conference on computational complexity, 2015, pp. 537–566.
[21]
S. Beigi and L. Taghavi, “Quantum speedup based on classical decision trees,” Quantum, vol. 4, p. 241, 2020.
[22]
F. Magniez, A. Nayak, J. Roland, and M. Santha, “Search via quantum walk,” in Proceedings of the thirty-ninth annual ACM symposium on theory of computing, 2007, pp. 575–584.
[23]
M. A. Nielsen and I. L. Chuang, Quantum computation and quantum information. Cambridge university press, 2010.
[24]
G. Brassard, P. Hoyer, M. Mosca, and A. Tapp, “Quantum amplitude amplification and estimation,” AMS Contemporary Mathematics Series, vol. 305, 2000.
[25]
S. Jeffery, R. Kothari, and F. Magniez, “Nested quantum walks with quantum data structures,” in Proceedings of the twenty-fourth annual ACM-SIAM symposium on discrete algorithms, 2013, pp. 1474–1485.
[26]
S. Jeffery, “Quantum subroutine composition,” arXiv preprint arXiv:2209.14146, 2022.
[27]
A. Cornelissen, “Quantum walks through generalized graph composition,” arXiv preprint arXiv:2510.04973, 2025.
[28]
B. W. Reichardt, “Reflections for quantum query algorithms,” in Proceedings of the twenty-second annual ACM-SIAM symposium on discrete algorithms, 2011, pp. 560–569.
[29]
J. L. Bentley, D. Haken, and J. B. Saxe, “A general method for solving divide-and-conquer recurrences,” ACM SIGACT News, vol. 12, no. 3, pp. 36–44, 1980.
[30]
A. Belovs and A. Rosmanis, “On the power of non-adaptive learning graphs,” computational complexity, vol. 23, no. 2, pp. 323–354, 2014.
[31]
J. A. Bondy and M. Simonovits, “Cycles of even length in graphs,” Journal of Combinatorial Theory, Series B, vol. 16, no. 2, pp. 97–105, 1974.

  1. Note that we don’t consider a promise version of the unrestricted path-containment problem, because we don’t see a meaningful way of defining it.↩︎