Abstract 1 Introduction 2 Preliminaries 3 Quantum Algorithm for DSTCON 4 Quantum short path subroutine References

A Quantum Time-Space Tradeoff for Directed s⁒t-Connectivity

Stacey Jeffery ORCID CWI, QuSoft, Amsterdam, The Netherlands
University of Amsterdam, The Netherlands
   Galina Pass ORCID QuSoft, Amsterdam, The Netherlands
University of Amsterdam, The Netherlands
Abstract

Directed s⁒t-connectivity (dstcon) is the problem of deciding if there exists a directed path between a pair of distinguished vertices s and t in an input directed graph. This problem appears in many algorithmic applications, and is also a fundamental problem in complexity theory, due to its 𝖭𝖫-completeness. We show that for any Sβ‰₯log2⁑(n), there is a quantum algorithm for dstcon using space S and time T≀212⁒log⁑(n)⁒log⁑(n/S)+o⁒(log2⁑(n)), which is an (up to quadratic) improvement over the best classical algorithm for any S=o⁒(n). Of the S total space used by our algorithm, only O⁒(log2⁑(n)) is quantum space – the rest is classical. This effectively means that we can trade off classical space for quantum time.

Keywords and phrases:
Quantum algorithms, time-space tradeoffs, directed st-connectivity, switching networks, space-bounded computation
Category:
Track A: Algorithms, Complexity and Games
Copyright and License:
[Uncaptioned image] © Stacey Jeffery and Galina Pass; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation β†’ Quantum complexity theory
Related Version:
Full Version: https://arxiv.org/abs/2510.08403
Funding:
This work is co-funded by the European Union (ERC, ASC-Q, 101040624); the project Divide & Quantum (with project number 1389.20.241) of the research programme NWA-ORC, which is (partly) financed by the Dutch Research Council (NWO); and the Dutch National Growth Fund (NGF), as part of the Quantum Delta NL programme. SJ is a CIFAR Fellow in the Quantum Information Science Program.
Editors:
Sayan Bhattacharya, Danupon Nanongkai, Michael Benedikt, and Gabriele Puppis

1 Introduction

In the directed s⁒t-connectivity problem (dstcon), the input is a directed graph on n vertices with two distinguished vertices s and t, and the goal is to decide if there is a directed path from s to t. This fundamental problem underlies a wide range of applications in (e.g.) logistics, databases [1, 19], compilers [2, 16], and model checking [10, 5].

In addition to its practical applications, dstcon plays a central role in space-bounded complexity theory. It is 𝖭𝖫-complete (under 𝖭𝖒1 reductions), where 𝖭𝖫 is the class of problems decidable by nondeterministic logspace machines. Consequently, understanding its complexity has broad implications for space-bounded computation. For example, a classical (or quantum) algorithm for dstcon using O⁒(log⁑(n)) space would show that 𝖫, the class of problems solvable in O⁒(log⁑(n)) space (or its quantum analogue) contains 𝖭𝖫 – a major breakthrough in either case.

Currently, the smallest space complexity of any classical or quantum algorithm for dstcon is S=O⁒(log2⁑(n)), achieved by Savitch’s (classical) algorithm. However, Savitch’s algorithm achieves this low space complexity at the expense of a large quasipolynomial time complexity, using

T≀2log2⁑(n)+O⁒(log⁑(n))

steps of computation. In contrast, a simple breadth-first search (BFS) algorithm solves this problem in just T=O⁒(n3) steps (in the adjacency-matrix model), but at the expense of a much larger S=O~⁒(n) space requirement. The fundamental nature of this problem, as well as its many applications, motivates understanding the best possible tradeoff between the time and space needed to solve it. Progress was made by Barnes, Buss, Ruzzo and Schieber [6], who gave a classical algorithm that runs in time

T≀2log2⁑(nS)+O⁒(log⁑n⁒log⁑log⁑n) (1)

given any space Sβ‰₯log2⁑(n). Their approach combines a breadth-first search with a clever recursive algorithm.

For quantum algorithms, the study of space-bounded complexity is even more well motivated, as quantum memories are expected to be limited in size for the foreseeable future. It is an important question in which memory regimes we can still achieve speedups over classical algorithms, and time-space tradeoffs are a key part of this picture. We can make such a tradeoff even more useful by distinguishing between the quantum space and classical (or total) space needed by the algorithm, as quantum space is the scarce resource.

For dstcon, quantum speedups are known only at the two extreme regimes of space. In the high-space setting, DΓΌrr, Heiligman, HΓΈyer, and Mhalla [11] gave an O~⁒(n1.5)-time, O~⁒(n)-space algorithm using quantum search to build a spanning tree. In the low-space setting, Ref. [14] recently gave a quadratic quantum speedup over Savitch’s algorithm, running in time T≀212⁒log2⁑n+O⁒(log⁑n) with S=O⁒(log2⁑n) space. Between these two extremes, however, no quantum improvements over classical tradeoffs were known.

For the undirected variant (ustcon), the picture is much clearer, at least as far as quantum algorithms go: in both the adjacency-matrix and edge-list models of graph access111In this work, unless otherwise stated, we use the adjacency-matrix model, which assumes the input is given via queries to an adjacency matrix. This distinction is only significant in high-space regimes where the time complexity is polynomial., quantum algorithms achieve optimal time and space simultaneously [9, 4].

However, existing classical and quantum approaches face significant obstacles in the directed case. A random walk on a directed graph, starting from s, may fail to find t even when t is reachable from s, if the walk leads from s to some part of the graph from which t is not reachable. Quantum walks, which are powerful tools for studying undirected graphs, do not generalize to directed graphs. Moreover, known classical algorithms for dstcon such as the time-space tradeoff algorithm in [6] cannot be directly quantized. This stems from the fact that these classical algorithms are not reversible, and making them reversible using standard methods increases the space complexity. These difficulties highlight why directed connectivity remains a challenging and subtle problem. They also show that progress requires algorithmic ideas that go beyond random or quantum walks, and straightforward adaptations of classical tradeoffs.

Our Contribution

We present the first nontrivial quantum time-space tradeoff for dstcon, by designing a new quantum algorithm for this problem that, for any space bound Sβ‰₯log2⁑(n), runs in time

T≀212⁒log⁑(n)⁒log⁑(nS)+O⁒(log⁑n⁒log⁑log⁑n).

In particular, our result yields a quantum speedup over the best known classical algorithm (see (1)) in the regime S=o⁒(n1/2). We also show that, of the S space, the required quantum space is always O⁒(log2⁑(n)), which makes this result much more applicable to quantum computers with a limited number of qubits. This effectively means that we can tradeoff classical space for quantum time. We formally state this result in Theorem 13.

Our Techniques

The classical algorithm of Barnes et al. [6] achieves a time-space tradeoff for dstcon by combining breadth-first search with a recursive subroutine that decides, for any pair of vertices u and v, if there is a directed path from u to v of length at most L. We call this problem DistL. The breadth-first search saves on space by not traversing the whole graph, but only those vertices at a distance from s that is a multiple of L (the space then decreases as L increases). The subroutine is used to find these vertices in a manner that is more space efficient, but less time efficient, than BFS.

The BFS portion of this classical algorithm could be sped up using quantum search techniques, but this saves at most a polynomial factor in the time (and nothing in the space), which is not very interesting in the small-space regime (where we get our quantum improvement) where such polynomial factors are hidden by the O⁒(log⁑(n)) in the exponent. On the other hand, a direct quantization of their subroutine for DistL fails, in large part because this subroutine is not reversible, and making it so would increase the space complexity. Moreover, the subroutine calls itself recursively, with significant depth of recursion. A quantum speedup of this subroutine would most likely have bounded error. Naively composing bounded-error quantum subroutines to depth d results in logd factors, which can be significant. Recent techniques for composing bounded error quantum algorithms without log-factor overhead [8, 7] could reduce this overhead to cd for some constant, but this could still be significant, if c>1. Overcoming these limitation requires a fundamentally different approach.

To address this, we design a new quantum algorithm for DistL that is based on a recursively constructed switching network. A switching network (Definition 3) is an undirected graph with terminals u and v, whose edges are labeled by Boolean variables {x1,…,xm}, that can switch the edges β€œon” or β€œoff”, by their truth value. Such a network naturally defines a Boolean function f:{0,1}mβ†’{0,1}, with f⁒(x)=1 (we then say the switching network accepts x) if and only if u and v are connected by a path consisting of edges whose labels are true under the assignment x. An example is given in Figure 1.

Figure 1: (L) An example of a switching network. (R) The same switching network, with edges switched on (thick) or off (dashed) by the assignment x=10101. In this example, u and v are connected by a path of edges labelled by variables that are true under x, and so the switching network accepts x.

Switching networks are a natural and well-motivated model in classical computing, and have been used to study classical space-bounded complexity (see, e.g., [18]). They also give a simple way of designing quantum algorithms, as any switching network can be compiled into a quantum algorithm for the associated function, whose time and space complexity depend on certain properties of the switching network. Quantum algorithms for evaluating switching networks were developed in [13] using span program techniques inspired by [9], and a subsequent work [12] provided a tight analysis of these span program algorithms for arbitrary switching networks, in terms of query complexity. These quantum algorithms were only explicitly related to the classical model of switching networks in [14], where more detailed techniques were developed for efficiently implementing this type of quantum algorithm, and rigorously analyzing their time complexity.

Switching networks lend themselves well to quantum algorithms in part because they are a naturally reversible structure, being defined by undirected graphs. Moreover, they give a natural way of defining recursive quantum algorithms: by defining a switching network recursively, and turning the final product into a quantum algorithm, bounded error is introduced only once, when turning the switching network into a quantum algorithm, and there are no factors of cd or logd on the complexity of the algorithm, even when the depth of recursion in the switching network is d.

Because we keep the more space-intensive outer BFS algorithm classical, most of the space needed by the algorithm is classical. For any S, we only need O⁒(log2⁑(n)) qubits of quantum space to implement our quantum subroutine for DistL, the remainder of the S space is classical.

Our algorithm for DistL provides a compelling example of how switching networks can be used within quantum algorithms. It exploits the full power of the classical switching network model, while at the same time extending it into a setting where time-space tradeoffs become essential. It is the first time switching networks have been used to prove a quantum time-space tradeoff. Beyond its role in our algorithm for dstcon, our algorithm for DistL may be of independent interest as a quantum primitive for other space-efficient graph algorithms.

Open Problems

Our speedup over the best known classical algorithm is quadratic when S=log2⁑(n), and gets worse as S increases towards n, at which point we no longer achieve any speedup. However, we do know there is a quadratic speedup at the other extreme, S=n. It is thus very natural to hope that we might get a quadratic speedup over the algorithm of [6] for all S. One difficulty in this is that our algorithm is not just a quantization of the algorithm of [6], but actually does something different.

As mentioned earlier, for the undirected variant (ustcon), quantum algorithms achieve optimal time and space simultaneously [9, 4]. This naturally raises the question of whether a similar result is possible in the directed case.

We have already mentioned the compelling open problem of showing a O⁒(log⁑(n))-space quantum algorithm for dstcon. This would necessarily be a polynomial-time algorithm, and so it would, in some rough sense, achieve the above goal of have optimal space and time simultaneously. It would also show that the quantum analogue of 𝖫 (logspace) is contained in 𝖭𝖫 (nondeterministic logspace). Ref. [3] made some progress on this question by showing that a promise version of dstcon in which the input has few paths can be solved in O⁒(log⁑(n)) quantum space. We remark that any o⁒(log2⁑(n)) upper bound on the quantum space complexity of dstcon would be interesting.

Organization

The remainder of this paper is organized as follows. In Section 2, we give the necessary preliminaries on graph theory, switching networks, and quantum algorithms. In Section 3, we present our main result, a quantum algorithm for dstcon with a parameter L that can be used to tune the classical space complexity of the algorithm. The key technical building block of this algorithm is a quantum subroutine for the problem DistL, which we describe in Section 4.

2 Preliminaries

Here we state preliminaries. In Section 2.1, we define both directed and undirected graphs, as well as the notation we will use to talk about them. In Section 2.2, we formally define switching networks, and state results about quantum algorithms for evaluating them.

First, we state a few simple conventions and notational definitions. Unless otherwise specified, logarithms are with respect to base 2. We let 0¯ denote the all-zeros string, which throughout this paper will always have length log⁑n. We use O~⁒(f⁒(n)) to suppress poly(log⁑n) factors, where n is always the number of vertices in the input digraph. So, for example, O~⁒(1) is polylog(n).

2.1 Graphs

A directed graph G=(V⁒(G),E⁒(G)), or digraph, consists of a vertex set V⁒(G)={v1,…,vn} and an edge set E⁒(G)βŠ†{(u,v)∈V⁒(G)2:uβ‰ v}. We say v is reachable from u in G if there exists a path u=u0,…,uβ„“=v such that for all i∈[β„“], (uiβˆ’1,ui)∈E⁒(G). When G is clear from context, we just write V and E.

We are interested in solving the s⁒t-connectivity – or reachability – problem on directed graphs, but we will also make use of undirected graphs, in the context of switching networks, described shortly.

An undirected graph 𝒩 is just a directed graph, where we don’t care about the direction of the edge – and in fact, we will ultimately want to assign to each edge an arbitrary orientation, for convenience, so we could even take the same definition we used for directed graphs, and just change notions like reachability. However, for our purpose an undirected graph will ultimately define a quantum algorithm on a space spanned by the edges of 𝒩. We therefore take a somewhat edge-centric definition, which has the added bonus of accommodating multigraphs.

Definition 1.

An undirected graph 𝒩=(V⁒(𝒩),E⁒(𝒩)) is specified by a pair of finite sets of vertex labels, V and edge labels, E; as well as incidence sets E𝒩⁒(π—Ž)=E𝒩←⁒(π—Ž)βŠ”E𝒩→⁒(π—Ž) for each π—ŽβˆˆV, such that for all e∈E, there are unique distinct vertices π—Ž,π—βˆˆV such that e∈E→⁒(π—Ž)∩E←⁒(𝗏). We think of E→⁒(π—Ž) as the set of edges coming out of π—Ž, and E←⁒(π—Ž) as the set of edges going into π—Ž. When 𝒩 is clear from context, we omit it from the notation, as we have just demonstrated.

This definition gives us the freedom to specify e∈E however we want to, not necessarily by its endpoints, as e=(π—Ž,𝗏). To recover this usual edge set, we can map e to (π—Ž,𝗏) such that e∈E→⁒(π—Ž)∩E←⁒(𝗏). When this holds for some edge, we will abuse notation by writing (π—Ž,𝗏)∈E, to mean β€œthere is an edge from π—Ž to 𝗏 in 𝒩.” Note that while each edge does have an orientation, these are arbitrary and for convenience only. We say that π—Ž is connected to 𝗏 in 𝒩 (or reachable from 𝗏) if there is a π—Žπ—-path π—Ž=π—Ž0,…,π—Žβ„“=𝗏 such that for all i∈[β„“], (π—Žiβˆ’1,π—Ži)∈E or (π—Ži,π—Žiβˆ’1)∈E.

Finally, we will often build a (undirected) graph 𝒩 out of graphs 𝒩1 and 𝒩2 by β€œgluing” (identifying) some of the vertices in 𝒩1 with some vertices in 𝒩2. The following definition makes precise what we mean by this.

Definition 2.

Let 𝒩1 and 𝒩2 be graphs, with π—Ž1,1,…,π—Ž1,r∈V⁒(𝒩1) and π—Ž2,1,…,π—Ž2,r∈V⁒(𝒩2). The graph 𝒩 obtained from these graphs by gluing vertex π—Ž1,i with π—Ž2,i for all i∈[r] is defined by the following vertex and edge (label) sets:

V⁒(𝒩) =V⁒(𝒩1)βŠ”(V⁒(𝒩2)βˆ–{π—Ž2,1,…,π—Ž2,r})
and ⁒E⁒(𝒩) =E⁒(𝒩1)βŠ”E⁒(𝒩2)

and incidence sets:

βˆ€π—ŽβˆˆV⁒(𝒩1)βˆ–{π—Ž1,1,…,π—Ž1,r},E𝒩→⁒(π—Ž) =E𝒩1→⁒(π—Ž)⁒ and ⁒E𝒩←⁒(π—Ž)=E𝒩1←⁒(π—Ž),
βˆ€π—ŽβˆˆV⁒(𝒩2)βˆ–{π—Ž2,1,…,π—Ž2,r},E𝒩→⁒(π—Ž) =E𝒩2→⁒(π—Ž)⁒ and ⁒E𝒩←⁒(π—Ž)=E𝒩2←⁒(π—Ž),
andΒ β’βˆ€i∈[r],E𝒩→⁒(π—Ž1,i) =E𝒩1→⁒(π—Ž1,i)βŠ”E𝒩2→⁒(π—Ž2,i)
and ⁒E𝒩←⁒(π—Ž1,i) =E𝒩1←⁒(π—Ž1,i)βŠ”E𝒩2←⁒(π—Ž2,i).

We made the arbitrary choice to let the glued vertices inherit their names from 𝒩1 rather than 𝒩2, but since in practice, we will mainly work on the edges of the graph, this detail doesn’t matter so much. What is more important is that the edge set is simply a disjoint union of the edges sets of 𝒩1 and 𝒩2.

2.2 Switching Networks

A switching network on {0,1}m (see e.g. [18]) is an undirected graph 𝒩 with two distinct boundary vertices π—Œ and 𝗍, in which each edge is labeled by a literal from {x1,…,xm,Β¬x1,…,Β¬xm,1}. To simplify things slightly, in our case, we only have edges labeled with positive literals, {x1,…,xm}, so we can just use the label set [m] (or more specifically, in our case, the labels will be pairs i,j∈[n], with xi,j=1 if and only if (vi,vj)∈E⁒(G) for G the input digraph). For x∈{0,1}m, letting 𝒩⁒(x) denote the subgraph of 𝒩 that includes only those edges whose labels are true under the string x, we say that 𝒩 accepts x if and only if π—Œ is connected to 𝗍 in 𝒩⁒(x). In [14], formalizing [13], switching networks were additionally equipped with some associated subspaces, as we describe in the following definition.

Definition 3.

A switching network 𝒩 on {0,1}m consists of:

  1. 1.

    an undirected multigraph 𝒩=(V,E) with a source π—ŒβˆˆV and sink π—βˆˆVβˆ–{π—Œ};

  2. 2.

    for each edge e∈E, a query label Ο†e∈[m].

For x∈{0,1}m, we define 𝒩⁒(x) by restricting 𝒩 to those edges e∈E such that xΟ†e=1. We associate the following spaces with 𝒩, and an input x:

  1. 1.

    Ξžπ—Œπ’œ=span{|π—ŒβŸ©+|←,π—ŒβŸ©} and Ξžπ—π’œ=span{|β†’,π—βŸ©+|π—βŸ©}

  2. 2.

    for all π—βˆˆVβˆ–{π—Œ,𝗍}, 𝒱𝗏=span{|Οˆβ‹†(𝗏)⟩:=βˆ‘e∈E→⁒(𝗏)|β†’,e⟩+βˆ‘e∈E←⁒(𝗏)|←,e⟩}

  3. 3.

    π’±π—Œ=span{|Οˆβ‹†(π—Œ)⟩:=βˆ‘e∈E→⁒(π—Œ)|β†’,e⟩+βˆ‘e∈E←⁒(π—Œ)|←,e⟩+|←,π—ŒβŸ©}

  4. 4.

    𝒱𝗍=span{|Οˆβ‹†(𝗍)⟩:=βˆ‘e∈E→⁒(𝗍)|β†’,e⟩+βˆ‘e∈E←⁒(𝗍)|←,e⟩+|β†’,π—βŸ©}

  5. 5.

    for all e∈E, Ξe=span⁒{|β†’,e⟩,|←,e⟩}, Ξeπ’œβ’(x)=span⁒{|β†’,e⟩+(βˆ’1)xΟ†e⁒|←,e⟩}, Ξeℬ=span⁒{|β†’,e⟩+|←,e⟩}.

Then we let H𝒩=⨁e∈EΞeβŠ•span{|π—ŒβŸ©,|π—βŸ©,|←,π—ŒβŸ©,|β†’,π—βŸ©} and define the following two important subspaces of H𝒩:

π’œβ’(x)=Ξžπ—Œπ’œβŠ•Ξžπ—π’œβŠ•β¨e∈EΞeπ’œβ’(x)andℬ=β¨π—ŽβˆˆV⁒(G)π’±π—Ž+⨁e∈EΞeβ„¬βŠ•span⁒{|←,π—ŒβŸ©+|β†’,π—βŸ©}. (2)

A single switching network can potentially compute different functions for different possible values of π—Œ or 𝗍. Thus, we will later find it convenient to equip a set of sinks222We could also allow multiple sources instead of just a single π—Œ, but we don’t need that for our constructions., which, together with the single source π—Œ, will form a boundary for 𝒩.

β–ΆΒ Remark 4.

It is also possible to assign weights to the edges of 𝒩 in the definition of a switching network, which impacts the complexity of the quantum algorithm for evaluating it, but in this work we will assume all edges have weight 1.

A switching network, along with the spaces defined in Definition 3, is a special case of a subspace graph, defined in [14]. As there, we can define working bases for a switching network as a pair of bases Ξ¨π’œ and Ψℬ for π’œ and ℬ respectively. For switching networks, the natural working basis for π’œ is simply

Ξ¨π’œ(x)={|β†’,e⟩+(βˆ’1)xΟ†e|←,e⟩:e∈E(𝒩)}βˆͺ{|π—ŒβŸ©+|←,π—ŒβŸ©,|β†’,π—βŸ©+|π—βŸ©}.

It’s not difficult to see that this basis can be generated using a query to x, and O⁒(1) basic operations, by which we mean the following.

Definition 5 (Basis Generation).

We say an orthonormal basis Ξ¨={|bβ„“βŸ©}β„“βˆˆLβŠ‚H𝒩 can be generated in time T if:

  1. 1.

    The reflection around the subspace span{|β„“βŸ©:β„“βˆˆL} of H𝒩 can be implemented in time T.

  2. 2.

    There is a map that acts as |β„“βŸ©β†¦|bβ„“βŸ© for all β„“βˆˆL that can be implemented in time T.

For the space ℬ, we construct a basis for the orthogonal complement and invoke the following lemma from [14, Corollary 2.11], which guarantees that this suffices.

Lemma 6.

If Ξ¨ is a basis that can be generated in time T, then there is a basis Ξ¨β€² for span⁒{Ξ¨}βŠ₯ that can be generated in time T.

The following is a special case of [14, Theorem 3.13], which is proven by analyzing a phase estimation algorithm on the product of reflections around π’œ, and ℬ. It is also similar to [13, Theorem 13], but with a different implementation of reflection around ℬ by generating a basis directly, rather than via a quantum walk, which is potentially more expensive.

Theorem 7.

For f:{0,1}mβ†’{0,1}, let 𝒩 be a switching network that accepts x∈{0,1}m if and only if f⁒(x)=1. Suppose that for all x accepted by 𝒩, there is an π—Œπ—-path in 𝒩⁒(x) of length at most W+. Suppose the space β„¬βŸ‚ of 𝒩 has a basis Ξ¨β„¬βŸ‚ that can be generated in time TB. Then there is a quantum algorithm that decides f with bounded error in time O⁒(TB⁒W+⁒|E⁒(𝒩)|) and space O⁒(log⁑|E⁒(𝒩)|).

We can get a stronger version of this theorem by replacing path length with effective resistance, and cut size with capacitance (see [12]), but the theorem as stated suffices for our purposes.

3 Quantum Algorithm for DSTCON

In this section, we prove our main result, by describing a quantum algorithm for dstcon that works for any space bound Sβ‰₯log2⁑(n). We begin by stating the main technical result of this paper, which we prove in Section 4. Specifically, we present a quantum algorithm for deciding directed s⁒t-connectivity under an additional constraint on the path length (i.e. solving π™³πš’πšœπšL). While this subroutine is quantum, the algorithm we decide in the remainder of this section is otherwise classical.

Theorem 8.

Let G=(V,E) be a directed graph such that V={v1,…,vn}. Assume that G can be accessed via a quantum oracle π’ͺG that can be implemented in time O⁒(1), where for any i,j∈[n], b∈{0,1}

π’ͺG:|i⟩|j⟩|bβŸ©β†¦{|i⟩|j⟩|bβŠ•1⟩if ⁒(vi,vj)∈E|i⟩|j⟩|b⟩otherwise.

Let L≀n be a power of 2. Then there is a bounded-error quantum algorithm, 𝙳L⁒(G,u,v), that decides for any u,v∈V whether there is a directed path from u to v in G of length at most L, in time

O~⁒((Llog⁑3⁒(2⁒n+1)log⁑L⁒n)1/2)

and space O⁒(log⁑(L)⁒log⁑(n)).

In Section 4, we prove the statement for L a power of 2, using a recursive structure, but a simple corollary extends this result to any L.

Corollary 9.

Let G be as in Theorem 8, and let L be any positive integer. Then there is a bounded-error quantum algorithm, π™³πš’πšœπšL⁒(G,u,v), that decides for any u,v∈V whether there is a directed path from u to v in G of length at most L, in time

O~⁒((Llog⁑3⁒(2⁒n+1)log⁑L⁒n)1/2)

and space O⁒(log⁑(L)⁒log⁑(n)).

Proof.

To prove the statement, we exhibit a quantum algorithm, Algorithm 1 that uses one call to the subroutine 𝙳 from Theorem 8, on a graph Gβ€² that is constructed from G by adding a directed path from some new vertex s1 into u of length such that any u⁒v-path of length at most L corresponds to a s1⁒v-path of length at most 2⌈log⁑LβŒ‰ (see Figure 2). Since Gβ€² can be queried using at most one query to G, the result follows. β—€

Algorithm 1 Dist(G,u,v)L.

Parameter: a positive integer L≀n
Input: a directed graph G=(V,E) and a pair of vertices u,v∈V
Output: 0 or 1 indicating there is a path of length at most L between u and v in G

  1. 1.

    Let β„“=⌈log⁑LβŒ‰ and a=2β„“βˆ’L

  2. 2.

    Let Gβ€² be the graph G with a new vertices s1,…,sa and a new edges (s1,s2),…,(saβˆ’1,sa),(sa,u). Then Gβ€² is just G with a directed path of length a coming into u, and can easily be queried using queries to G.

  3. 3.

    Return 𝙳2ℓ⁒(Gβ€²,s1,v).

Figure 2: The graph Gβ€² constructed from G. It is clear that there is a u⁒v-path of length at most L in G if and only if there is a s1⁒v-path of length at most L+a in Gβ€².

3.1 BFS algorithm that calls the quantum short path subroutine

To get a time-space tradeoff for dstcon, and prove our main result, we describe a classical BFS-based algorithm, Algorithm 2, from [6], that makes calls to a subroutine for the problem Dist(G,u,v)L, of deciding whether there is a path of length at most L from u to v in a directed graph G. Our algorithm for dstcon is obtained by instantiating that subroutine with the quantum algorithm π™³πš’πšœπšL from Corollary 9.

Algorithm 2 DSTCON(G,s,t)L [6].

Parameter: a positive integer L≀n
Input: a directed graph G=(V,E) and a pair of vertices s,t∈V
Output: Connected if there is a directed path from s to t in G, Not Connected otherwise

Ref. [6] show that this algorithm correctly decides dstcon whenever π™³πš’πšœπšL decides whether there is a path of length at most L. From [6], or by inspecting Algorithm 2, we get the following.

Lemma 10.

Let π™³πš’πšœπšL⁒(G,u,v) be a bounded-error algorithm for DistL, with time complexity DT⁒(n,L), and the space complexity is DS⁒(n,L). Then the time complexity of Algorithm 2 is

O~⁒(n3L⁒DT⁒(n,L))

and its space complexity is

O⁒(n⁒log⁑nL+DS⁒(n,L)).

If π™³πš’πšœπšL is implemented by a quantum algorithm, then the quantum space complexity is at most O⁒(DS⁒(n,L)), and any remaining space is classical.

Substituting the result of Corollary 9 yields the following theorem, which combines our quantum subroutine with the classical BFS algorithm. Although the algorithm in Corollary 9 has bounded error, its success probability can be boosted high enough that the outer algorithm will not notice, using majority voting, at the cost of an overhead of log⁑O~⁒(n3/L), which is hidden in the O~ of the final complexity.

Theorem 11.

Let G=(V,E) be a directed graph such that V={v1,…,vn}, and s,t∈V. Assume that G can be accessed via a quantum oracle π’ͺG that can be implemented in time O⁒(1), where for any i,j∈[n], b∈{0,1},

π’ͺG:|i⟩|j⟩|bβŸ©β†¦{|i⟩|j⟩|bβŠ•1⟩if ⁒(vi,vj)∈E|i⟩|j⟩|b⟩otherwise.

Then there is a quantum algorithm that decides whether there is a directed path from s to t in G with bounded error in time

O~⁒(n3.5⁒L.5⁒log⁑(3)βˆ’1⁒(2⁒n+1)0.5⁒log⁑L)

and total space

O~⁒((nL+log⁑L)⁒log⁑n)

of which O⁒(log⁑(L)⁒log⁑(n)) is quantum space.

3.2 Complexity comparison: classical vs. quantum

Theorem 12 ([6]).

Let G=(V,E) be a directed graph such that V={v1,…,vn}, and s,t∈V. Assume that G can be accessed via a classical oracle π’ͺG that can be implemented in time O⁒(1), where for any i,j∈[n],

π’ͺG⁒(i,j)={1if ⁒(vi,vj)∈E0otherwise.

Then for any Sβ‰₯log2⁑(n), there is a classical algorithm that decides whether there is a directed path from s to t in G using space O⁒(S) and time

T≀2log2⁑nS+O⁒(log⁑n⁒log⁑log⁑n).

In [6], they state a bound of T≀2O⁒(log2⁑(n/S)), but using their choice of parameters, and a slightly more precise analysis of their algorithm, we can compute the more fine-grained upper bound we have stated above. We improve on their result in our main theorem, which is the following.

Theorem 13.

Let G=(V,E) be a directed graph such that V={v1,…,vn}, and s,t∈V. Assume that G can be accessed via a quantum oracle π’ͺG that can be implemented in time O⁒(1), where for any i,j∈[n], b∈{0,1},

π’ͺG:|i⟩|j⟩|bβŸ©β†¦{|i⟩|j⟩|bβŠ•1⟩if ⁒(vi,vj)∈E|i⟩|j⟩|b⟩otherwise.

Then for any Sβ‰₯log2⁑(n), there is a quantum algorithm that decides for any s,t∈V whether there is a directed path from s to t in G with bounded error using space O⁒(S) and time

T≀212⁒log⁑n⁒log⁑nS+O⁒(log⁑n⁒log⁑log⁑n).

This algorithm uses O⁒(log2⁑(n)) quantum space.

Proof.

We analyze the time-space tradeoff of the quantum algorithm of Theorem 11. Assuming L⁒log⁑L=O⁒(n), its space complexity becomes S=O⁒(nL⁒log⁑n), with only O⁒(log⁑(L)⁒log⁑(n))=O⁒(log2⁑(n)) quantum space. That is, we can express L=Θ⁒(nS⁒log⁑n). Substituting this into the time complexity T=O~⁒(n3.5⁒L.5⁒log⁑(3)βˆ’1⁒(2⁒n+1)0.5⁒log⁑L) and taking logarithms, we obtain

log⁑T =3.5⁒log⁑n+log⁑L⁒(log⁑(2⁒n+1)2+.5⁒log⁑(3)βˆ’1)+O⁒(log⁑log⁑n)
=(log⁑nS+log⁑log⁑n+O⁒(1))⁒(log⁑n2+O⁒(1))+O⁒(log⁑n)
=12⁒log⁑(nS)⁒log⁑(n)+O⁒(log⁑(n)⁒log⁑log⁑(n)).

β—€

β–ΆΒ Remark 14.

For S=o⁒(n1/2), the quantum algorithm of Theorem 13 achieves a better time-space tradeoff than the classical time-space tradeoff stated in Theorem 12.

4 Quantum short path subroutine

In this section, we prove Theorem 8 by describing and analyzing a quantum algorithm for DistL⁒(G,s,t), for G=(V,E) a directed graph with V={v1,…,vn}, s,t∈V any pair of vertices, and Lβˆˆβ„• a power of 2. The algorithm is designed by exhibiting a switching network (Definition 3), and then applying Theorem 7.

In Section 4.1, we describe the switching network, through a recursive construction. In order to apply Theorem 7, we need to analyze the number of edges in the switching network, and upper bound the distance between its source π—Œ and sink 𝗍, which we do in Section 4.2. Finally, in Section 4.3, we put it all together to prove Theorem 8.

4.1 Switching network

The switching networks we will work with will have vertices represented by a tuple [u1,…,uk]∈Vk, of some number k of vertices of G, as well as possibly some additional information. We will not actually care so much about naming conventions for the vertices, but the important detail is that each vertex of a switching network has an associated subset {u1,…,uk}βŠ†V (so the order of the tuple actually doesn’t matter). In particular, we will construct switching networks by gluing together switching networks of this form (see Definition 2), and it will be important that any pair of vertices we glue together have the same associated set, so there is no ambiguity.

The way we construct our switching networks, we will only have an edge between a pair of vertices where the associated sets are of the form {u1,…,uk} and {u1,…,uk,uk+1}, and the query label for that edge (see Definition 3) is (ui,uk+1) for some i∈[k]. Such switching networks were first studied in [17]. This structure ensures that a vertex [u] can only be connected to a vertex [u1,…,uk] by a path of β€œon” edges if each ui is reachable from u in G – a property that will be crucial for our analysis in Section 4.1.2.

In this section, we will describe and analyze a switching network 𝒩L⁒(s) of the above described form. This will be built inductively from switching networks 𝒩2ℓ⁒(u) for β„“βˆˆ{0,…,log⁑L}, and u∈V, called the root. 𝒩2ℓ⁒(u) has a single source [u] and n sinks {[u,vi]:vi∈V}. With respect to the i-th sink [u,vi], the switching network computes whether vi is reachable from u by a path of length at most 2β„“, for every vi∈V simultaneously (i.e. vi is reachable from u by a path of length at most 2β„“ in G if and only if [u] and [u,vi] are connected in 𝒩2ℓ⁒(u)⁒(G)). This β€œextended boundary” is used solely for the recursive construction in Section 4.1.1. The final construction 𝒩L⁒(s) has source π—Œ=[s] and a single sink 𝗍=[s,t]. We write 𝒩L⁒(s,t) when we want to emphasize this.

4.1.1 Graph construction

Define Ξ£={(0,0Β―)}βˆͺ{(1,i):i∈{0,1}log⁑n}βˆͺ{(2,j):j∈{0,1}log⁑n}, an alphabet of size 2⁒n+1. We have ensured that all symbols in this alphabet have an obvious representation as a string in {0,1,2}Γ—{0,1}log⁑n, but for convenience we will sometimes use 0 to denote (0,0Β―), and 1⁒i or 2⁒j to denote (1,i) or (2,j). For any ΟƒβˆˆΞ£βˆ—, let |Οƒ| denote its length, and define:

f1⁒(Οƒ):={max⁑{i∈{1,…,|Οƒ|}:Οƒi∈{1}Γ—{0,1}log⁑n}ifΒ β’βˆƒi:Οƒi∈{1}Γ—{0,1}log⁑n0else.

We now define 𝒩2ℓ⁒(u) for β„“βˆˆ[log⁑L], by a recursive construction.

Base construction

For the base case, β„“=0, the switching network 𝒩1⁒(u) consists of a source vertex [u] connected to n sinks [u,vi],vi∈V. The edges have query labels (u,vi), each β€œchecking” whether there is an edge (u,vi) in G (see Figure 3). More precisely, we formally define the sets of vertices and edges as follows.

V1={[u]}βˆͺ{[u,vi]:vi∈V},andE1={|ei⟩=|i⟩:i∈[n]}.

Above, we put edge labels in a ket, to emphasize that they form an orthonormal basis of some inner product space. The incidence of edges and vertices is defined (see Definition 1 for a reminder of how undirected graphs are specified):

E1→⁒([u])=E1andE1←⁒([u])=βˆ…
βˆ€i∈[n],E1β†’([u,vi])=βˆ…andE1←([u,vi])={|ei⟩}.

The query label of the edge ei is (u,vi).

Figure 3: Graph construction for the switching network 𝒩1⁒(u) that decides whether each vertex of a graph G=(V,E) is reachable from a vertex u∈V by a path of length 1. Each edge ([u],[u,vi]) of 𝒩1⁒(u) has query label (u,vi) and is β€œon” in 𝒩1⁒(u)⁒(G) if and only if (u,vi)∈E. Therefore, it holds that vi is reachable from u by a path of length at most 1 in G if and only if [u] and [u,vi] are connected in 𝒩1⁒(u)⁒(G).
Recursive construction

Next, we describe the construction of 𝒩2ℓ⁒(u), assuming that a construction of 𝒩2β„“βˆ’1⁒(u) is given. Let 𝒩2β„“βˆ’1v⁒(u) denote a copy of 𝒩2β„“βˆ’1⁒(u) in which each vertex-tuple of the switching network is augmented with an additional vertex v∈V (although the order in the tuple doesn’t matter, for clarity, assume we append v to the front of each tuple).

The construction of 𝒩2ℓ⁒(u) uses 2⁒n+1 copies 𝒩2β„“βˆ’1⁒(uβ€²) for some uβ€², some of them augmented by additional vertices. Specifically, define:

𝒩2β„“βˆ’10 =𝒩2β„“βˆ’1⁒(u)
βˆ€i∈[n],𝒩2β„“βˆ’1(1,i) =𝒩2β„“βˆ’1u⁒(vi)
βˆ€j∈[n],𝒩2β„“βˆ’1(2,j) =𝖱𝖾𝗏⁒(𝒩2β„“βˆ’1vj⁒(u)).

Above, we used the notation 𝖱𝖾𝗏⁒(𝒩) to be the switching network 𝒩 except with the orientation of every edge reversed. As we will see shortly, this ensures that all edges of 𝒩2ℓ⁒(u) have a logical left-to-right orientation. Define 𝒩2ℓ⁒(u) from these 2⁒n+1 copies of 𝒩2β„“βˆ’1 by gluing (as made precise in Definition 2) the i-th sink of 𝒩2β„“0 – which encodes [u,vi] – to the source of 𝒩2β„“(1,i) – which also encodes [u,vi] – (for all i∈[n]); and gluing the j-th sink of 𝒩2β„“(1,i) – which encodes [u,vi,vj] – to the i-th sink of 𝒩2β„“(2,j) – which also encodes [vj,u,vi]≑[u,vi,vj] – (for all i,j∈[n]), as in Figure 4. Note that the source of 𝒩2β„“(2,j), which encodes [vj,u]≑[u,vj], is the j-th sink of 𝒩2ℓ⁒(u). The source [u] of 𝒩2β„“βˆ’10 is the source of 𝒩2ℓ⁒(u).

Figure 4: Graph construction for the switching network 𝒩2ℓ⁒(u) that decides whether each vertex of a graph G=(V,E) is reachable from a vertex u∈V by a path of length 2β„“.

The edges E2β„“ of 𝒩2β„“ should be the disjoint union of the edge sets of the 2⁒n+1 copies of 𝒩2β„“βˆ’1. We use the elements of Ξ£ labeling each copy to make this union disjoint:

E2β„“=β¨†ΟƒβˆˆΞ£E⁒(𝒩2β„“βˆ’1Οƒ)=Σ×E2β„“βˆ’1=Ξ£β„“Γ—E1. (3)

For ΟƒβˆˆΞ£β„“ and i∈{0,1}log⁑n, we will sometimes denote the edge |Οƒ,ei⟩=|Οƒ,i⟩ using

(βˆ’1)|Οƒ|2|eiΟƒβŸ©:=|Οƒ,ei⟩, (4)

where |Οƒ|2 denotes the number of occurrences of (2,j) for some j in Οƒ. The reason for the sign is that we always want |Οƒ,ei⟩ to represent the i-th edge in the Οƒ-labeled copy of 𝒩1 oriented from left-to-right333Such an orientation is not strictly necessary, but is more intuitive. (i.e. from source towards sinks), and we therefore need to reverse the edge orientations every time we use a copy of 𝒩2β„“ in the (2,j)-th position for some j. Generally, if |ψ⟩∈span{|e⟩:e∈E2β„“} – equivalently, ψ is a function on E2β„“ – and ΟƒβˆˆΞ£β„“β€², we will let

|ΟˆΟƒβŸ©=(βˆ’1)|Οƒ|2|ΟƒβŸ©|ψ⟩, (5)

which is a state in span{|e⟩:e∈E2β„“+β„“β€²} that is only supported on the Οƒ-labeled copy of 𝒩2β„“ (which we may denote 𝒩2β„“Οƒ) in 𝒩2β„“+β„“β€².

Each of the 2⁒n+1 copies of 𝒩2β„“βˆ’1 in 𝒩2β„“ has a unique label ΟƒβˆˆΞ£. From this label, and the (global) root u of 𝒩2ℓ⁒(u), we can extract the root of the specific copy 𝒩2β„“βˆ’1Οƒ, and the vertex that is additionally stored in all of its vertices.

Inductively, we assign to each copy of 𝒩2β„“βˆ’k,k∈[β„“] a label ΟƒβˆˆΞ£k, from which we can extract the root of the specific copy 𝒩2β„“βˆ’kΟƒ and the set that is additionally stored in its vertices, knowing the global root u∈V. In particular, each copy of 𝒩1 has a label ΟƒβˆˆΞ£β„“ and consists of n edges. We can extract the root of each copy of 𝒩1 from its label Οƒ and the global root u∈V and, hence, recover the edge query labels as well. In the following lemma, we show how exactly the query label can be extracted from the label of an edge.

Lemma 15.

Let ΟƒβˆˆΞ£β„“ and i∈[n] encode an edge in 𝒩2ℓ⁒(u). Then its edge is labeled by the query ((vΟƒ(f1⁒(Οƒ))2),vi), if f1⁒(Οƒ)β‰ 0, and (u,vi) otherwise.

Proof.

We prove the statement by induction. In the base case of 𝒩1⁒(u), the claim is trivial. Since ΟƒβˆˆΞ£0 is an empty string, we have f1⁒(Οƒ)=0. The edges are encoded as |ei⟩=|i⟩, and the corresponding query labels are (u,vi).

For the induction step, assume that the claim holds for 𝒩2β„“βˆ’1. The switching network 𝒩2ℓ⁒(u) consists of 2⁒n+1 copies of 𝒩2β„“βˆ’1 labeled by 0,(1,i),(2,j), where i,j∈[n]. The edges in each of these switching networks are encoded by |Οƒ~,k⟩, where Οƒ~βˆˆΞ£β„“βˆ’1 and k∈[n]. First, consider the copies of 𝒩2β„“βˆ’1 labeled by 0 and (2,j) for j∈[n]. These are the switching networks 𝒩2β„“βˆ’1⁒(u) and 𝒩2β„“βˆ’1vj⁒(u) for j∈[n], all of which have u as root, which is the same as the global root of 𝒩2ℓ⁒(u). By the induction hypothesis, the query label of an edge |Οƒ~,k⟩ in one of these switching networks is ((vΟƒ~(f1⁒(Οƒ~))2),vk), if f1⁒(Οƒ~)β‰ 0, and (u,vk) otherwise. In the global switching network 𝒩2ℓ⁒(u), the same edge is encoded by |Οƒ,k⟩, where Οƒ=0⁒σ~ or Οƒ=(2,j)⁒σ~, depending on the copy of 𝒩2β„“βˆ’1⁒(u). Note that, in both cases, f1⁒(Οƒ)=f1⁒(Οƒ~), which proves the statement for the copies of 𝒩2β„“βˆ’1 labeled by 0 and (2,j) for j∈[n].

Next, consider the copies of 𝒩2β„“βˆ’1(1,i) for i∈[n]. These are the switching networks 𝒩2β„“βˆ’1u⁒(vi) for i∈[n] that have vi as their roots. By the induction hypothesis, the query label of an edge (Οƒ~,k) in one of these switching networks is ((vΟƒ~(f1⁒(Οƒ~))2),vk), if f1⁒(Οƒ~)β‰ 0, and (vi,vk) otherwise. In the global switching network 𝒩2ℓ⁒(u), the same edge is encoded by |Οƒ,k⟩, where Οƒ=(1,i)⁒σ~. Note that f1⁒(Οƒ)=f1⁒(Οƒ~) if f1⁒(Οƒ~)β‰ 0 and f1⁒(Οƒ)=1 otherwise. This proves the statement for the copies of 𝒩2β„“βˆ’1 labeled by (1,i) with i∈[n], and thus concludes the proof. β—€ Finally, we describe a top-down approach to building up 𝒩2β„“+1.

Lemma 16.

Let 𝒩′ be a switching network obtained from 𝒩2β„“ by replacing each 𝒩1 block with an 𝒩2 block with the same boundary. Then 𝒩′=𝒩2β„“+1.

Proof.

We prove the statement by induction. The base case is trivial, 𝒩1 is entirely replaced with 𝒩2. For the induction step, assume that the statement holds for every 𝒩2β„“β€² such that β„“β€²<β„“. To show it for 𝒩2β„“, we observe that it consists of 𝒩2β„“βˆ’1 blocks. For each such block, if we replace every 𝒩1 block with 𝒩2, it becomes 𝒩2β„“ by the induction hypothesis. Therefore, the whole switching network becomes 𝒩2β„“+1. β—€

4.1.2 Correctness of the construction

Next, we show that this construction is indeed a switching network that simultaneously decides the connectivity of all vi to u. The proofs in this section follow the general ideas of [18, Chapter 3], adapted to the setting of our switching network.

Lemma 17.

For every β„“βˆˆ{0,…,log⁑L} and u,vi∈V, vi is reachable from u by a path of length at most 2β„“ in G if and only if source [u] and sink [u,vi] are connected in 𝒩2ℓ⁒(u)⁒(G).

To prove the statement of Lemma 17, we define the following pebbling game on the input graph G.

  • β– 

    Initially, there is one pebble on the vertex u;

  • β– 

    For vertices v,vβ€²βˆˆV such that (v,vβ€²)∈E, if there is a pebble on v, it is legal to put a pebble on vβ€² or remove a pebble from vβ€².

In such a game, various choices of legal moves give rise to different β€œpebblings” – sets of vertices containing pebbles – of the graph. Clearly no vertex not reachable from u can ever be pebbled (i.e., contain a pebble). Restricting the number of pebbles available may further restrict the possible configurations achievable, as the following two lemmas show.

Lemma 18 ([15]).

Let D⁒(β„“) be the maximal distance from u on which a vertex can be pebbled if β„“ pebbles are available in the game. Then D⁒(β„“)≀2β„“βˆ’1βˆ’1.

Lemma 19.

Let Dr⁒(β„“) be the maximal distance from u such that it is possible to obtain pebbling configuration [u,v] for some v∈V using only β„“ pebbles. Then Dr⁒(β„“)≀2β„“βˆ’2

Proof.

We prove the statement by showing that Dr⁒(β„“+1)≀D⁒(β„“)+1. The claim then follows from Lemma 18. Assume for contradiction that it is possible to obtain a configuration [u,uD⁒(β„“)+2] for some uD⁒(β„“)+2∈V⁒(G) such that the distance from u to uD⁒(β„“)+2 is at least D⁒(β„“)+2. Before the last time a pebble is placed on uD⁒(β„“)+2, there is a pebble on some uD⁒(β„“)+1∈V⁒(G) such that the distance from u to uD⁒(β„“)+1 is at least D⁒(β„“)+1. After this, the pebble is removed from uD⁒(β„“)+1 using only β„“ pebbles. Consider the sequence of moves that accomplishes this in reverse. It is a sequence of moves that allows to put a pebble on uD⁒(β„“)+1 using only β„“ pebbles, since one pebble always stays on uD⁒(β„“)+2. This is a contradiction, since the distance from u to uD⁒(β„“)+1 is at least D⁒(β„“)+1. β—€

Lemma 20.

If a vertex v∈V⁒(G) is reachable from u by a path of length at most L in G, then it is possible to obtain pebbling configuration [u,v] using log⁑L+2 pebbles and Llog⁑3 moves of the pebbling game on G.

Proof.

Let u=u0,u1,…,uL=v be the path from u to v in G. Without loss of generality, its length is L, which is a power of 2. We show by induction how to put pebbles on vertices of the path to obtain the configuration [u,v]. Assume that there is a sequence of Mk moves that ends in the configuration [u,uk], k≀L/2. Then we can obtain [u,u2⁒k] as follows, using M2⁒k=3⁒Tk moves.

  1. 1.

    Perform the sequence of Tk moves to obtain [u,vk];

  2. 2.

    Perform the same sequence of Tk moves with respect to vk to obtain [u,vk,v2⁒k];

  3. 3.

    Perform step 1 in reverse to obtain [u,v2⁒k].

The base case is putting a pebble on v1 while there is a pebble on u, which is a valid pebbling game move. In the base case, we use 2 pebbles while traversing distance 1 in M1=1 moves. In the induction step, we double the distance from u and use one additional pebble for this. Therefore, we need log⁑(L)+2 pebbles in order to obtain [u,v], and ML=3⁒ML/2=3log⁑L=Llog⁑3. β—€

Lemma 21.

Let S be a list of vertices of G. If pebbling configuration [S] can be obtained in the pebbling game on G then every v∈S is reachable from u in G.

Proof.

We prove this statement by induction. The base case is the starting configuration [u], the starting vertex u is reachable from itself. For the induction step we assume that [S] is a pebbling configuration that can be obtained in the pebbling game and each vertex in S is reachable from u in G. Then, we consider the two types of possible pebbling game moves.

  • β– 

    If we remove a pebble from a vertex in S, then all remaining vertices remain reachable from u.

  • β– 

    If we put a pebble on a new vertex vβ€², then it is reachable by some vertex v∈S. Since v is reachable from u by the induction hypothesis, we can combine paths form u to v and from v to vβ€² and conclude that vβ€² is reachable from u.

β—€

Lemma 22.

It is possible to obtain pebbling configuration [u,v] in the pebbling game on G if and only if there is a path from u to v in G.

Proof.

If there is a path from u to v in G, then, by Lemma 20, configuration [u,v] can be obtained in the pebbling game.

If it is possible to obtain pebbling configuration [u,v] in the pebbling game on G, then, by Lemma 21, v is reachable from u in G. β—€

Lemma 23.

Every path in 𝒩2ℓ⁒(u)⁒(G) corresponds to a sequence of moves in the pebbling game on G transforming the corresponding configurations.

Proof.

Every vertex of the switching network contains a list of vertices of G and represents a configuration of pebbles. By construction, every edge that is β€œon” is of the form {[S],[S,vβ€²]} labeled by (v,vβ€²)∈E⁒(G) for some v∈S. Therefore, depending on the direction, an edge of a path in the switching network corresponds either to adding a pebble to a vertex of G or removing a pebble from a vertex of G. β—€

Proof of Lemma 17.

We prove by induction that if vi is reachable from u by a path of length 2β„“, then the source [u] and the sink [u,vi] are connected in 𝒩2ℓ⁒(u)⁒(G).

Base case.

For β„“=0, consider 𝒩1⁒(u)⁒(G). If the edge (u,vi) is present in G, then the edge with query label (u,vi) and endpoints [u] and [u,vi] is present in 𝒩1⁒(u)⁒(G). Consequently, [u] and [u,vi] are connected.

Induction step.

Assume the claim holds for 2β„“βˆ’1. Let p be a path of length at most 2β„“ from u to vi in G, and let uβ€² denote the midpoint of p. Then uβ€² is reachable from u by a path of length at most 2β„“βˆ’1, and vi is reachable from uβ€² by a path of length at most 2β„“βˆ’1. By the induction hypothesis:

  • β– 

    [u] and [u,uβ€²] are connected in 𝒩2β„“βˆ’1⁒(u)⁒(G);

  • β– 

    [u,uβ€²] and [u,uβ€²,vi] are connected in 𝒩2β„“βˆ’1u⁒(uβ€²)⁒(G);

  • β– 

    [u,uβ€²,vi] and [u,vi] are connected in 𝖱𝖾𝗏⁒(𝒩2β„“βˆ’1vi⁒(u)⁒(G)).

Concatenating these paths yields a path from [u] to [u,vi] in 𝒩2ℓ⁒(u)⁒(G). This completes the induction.

If source [u] and sink [u,vi] are connected in 𝒩2ℓ⁒(u)⁒(G), then, by Lemma 23, there is a sequence of pebbling game moves on G that transforms [u] into [u,vi]. Therefore, by Lemma 22, there is a path from u to vi in G. Note that the configurations in the sequence contain at most β„“+2 vertices of G, by construction of 𝒩2ℓ⁒(u)⁒(G). Hence, by Lemma 19, the path in G is of length at most 2β„“. β—€

4.2 Complexity analysis of the switching network

Lemma 24.

Fix any β„“βˆˆ{0,…,log⁑L} and u,v∈V such that there is a path from u to v in G of length at most 2β„“. Then there is a path connecting the source [u] and the sink [u,v] in 𝒩2ℓ⁒(u)⁒(G) of length at most 2ℓ⁒log⁑3.

Proof.

The statement of this lemma follows directly from the proof of Lemma 17. β—€

Lemma 25.

For any β„“βˆˆ{0,…,log⁑L}, and u∈V, |E⁒(𝒩2ℓ⁒(u))|≀(2⁒n+1)ℓ⁒n.

Proof.

|E⁒(𝒩2ℓ⁒(u))|=(2⁒n+1)⁒|E⁒(𝒩2β„“βˆ’1⁒(u))|=(2⁒n+1)ℓ⁒|E⁒(𝒩1⁒(u))|=(2⁒n+1)ℓ⁒n. β—€

4.3 Complexity of the subroutine

It remains to justify the basis-generation assumption required by Theorem 7. We use the following technical lemma, whose proof is deferred to the full version.

Lemma 26.

There exists an orthonormal basis of β„¬βŸ‚β’(𝒩L⁒(s,t)) that can be generated in time O~⁒(1).

We conclude by combining the switching network and corresponding basis generation we have given in the previous sections with Theorem 7 to prove Theorem 8, which states the existence of an algorithm for DistL.

Proof of Theorem 8.

From Lemma 17, it follows that the switching network 𝒩L⁒(s,t) accepts G if and only if there is a path of length at most L from s to t in G. We apply Theorem 7 to 𝒩L⁒(s,t). By Lemma 24, whenever there is a s⁒t-path of length ≀L in G, there is a path from the source [s] to the sink [s,t] in 𝒩L⁒(s,t)⁒(G) of length at most W+:=Llog⁑3. By Lemma 25, |E⁒(𝒩L⁒(s,t))|≀(2⁒n+1)log⁑L⁒n. By Lemma 26, there exists an orthonormal basis of β„¬βŸ‚β’(𝒩L⁒(s,t)) that can be generated in time TB=O~⁒(1). Hence, by Theorem 7, there exists a quantum algorithm that decides whether there is a path of length at most L from s to t in G in time

O⁒(TB⁒|E⁒(𝒩L⁒(u,v))|⁒W+)=O~⁒((Llog⁑3⁒(2⁒n+1)log⁑L⁒n)1/2)

and space

O⁒(log⁑|E⁒(𝒩L⁒(u,v))|)=O⁒(log⁑L⁒log⁑n).

β—€

References

  • [1] Serge Abiteboul, Richard Hull, and Victor Vianu. Foundations of Databases. Addison-Wesley, 1995.
  • [2] Alfred V. Aho, Monica S. Lam, Ravi Sethi, and Jeffrey D. Ullman. Compilers: Principles, Techniques, and Tools. Pearson, 2nd edition, 2006.
  • [3] Simon Apers and Roman Edenhofer. Directed st-Connectivity with Few Paths Is in Quantum Logspace. In Srikanth Srinivasan, editor, 40th Computational Complexity Conference (CCC 2025), volume 339 of Leibniz International Proceedings in Informatics (LIPIcs), pages 18:1–18:15, Dagstuhl, Germany, 2025. Schloss Dagstuhl – Leibniz-Zentrum fΓΌr Informatik. doi:10.4230/LIPIcs.CCC.2025.18.
  • [4] Simon Apers, Stacey Jeffery, Galina Pass, and Michael Walter. (No) Quantum Space-Time Tradeoff for USTCON. In Inge Li GΓΈrtz, Martin Farach-Colton, Simon J. Puglisi, and Grzegorz Herman, editors, 31st Annual European Symposium on Algorithms (ESA 2023), volume 274 of Leibniz International Proceedings in Informatics (LIPIcs), pages 10:1–10:17, Dagstuhl, Germany, 2023. Schloss Dagstuhl – Leibniz-Zentrum fΓΌr Informatik. doi:10.4230/LIPIcs.ESA.2023.10.
  • [5] Christel Baier and Joost-Pieter Katoen. Principles of Model Checking. MIT Press, 2008.
  • [6] Greg Barnes, Jonathan F Buss, Walter L Ruzzo, and Baruch Schieber. A sublinear space, polynomial time algorithm for directed st connectivity. SIAM Journal on Computing, 27(5):1273–1282, 1998. doi:10.1137/S0097539793283151.
  • [7] Aleksandrs Belovs and Stacey Jeffery. Space-efficient quantum error reduction without log factors, 2025. arXiv: 2502.09249
  • [8] Aleksandrs Belovs, Stacey Jeffery, and Duyal Yolcu. Taming quantum time complexity. Quantum, 8(1444), 2024. arXiv: 2311.15873 doi:10.22331/q-2024-08-23-1444.
  • [9] Aleksandrs Belovs and Ben W. Reichardt. Span programs and quantum algorithms for s⁒t-connectivity and claw detection. In Proceedings of the 20th Annual European Symposium on Algorithms (ESA), pages 193–204, 2012. doi:10.1007/978-3-642-33090-2_18.
  • [10] Edmund M. Clarke, Orna Grumberg, and Doron A. Peled. Model Checking. MIT Press, 1999.
  • [11] Christoph DΓΌrr, Mark Heiligman, Peter HΓΈyer, and Mehdi Mhalla. Quantum query complexity of some graph problems. SIAM Journal on Computing, 35(6):1310–1328, 2006. Earlier version in ICALP’04. arXiv: quant-ph/0401091 doi:10.1137/050644719.
  • [12] Michael Jarret, Stacey Jeffery, Shelby Kimmel, and Alvaro Piedrafita. Quantum algorithms for connectivity and related problems. In Proceedings of the 26th Annual European Symposium on Algorithms (ESA), pages 49:1–49:13, 2018. doi:10.4230/LIPIcs.ESA.2018.49.
  • [13] Stacey Jeffery and Shelby Kimmel. Quantum algorithms for graph connectivity and formula evaluation. Quantum, 1(26), 2017. doi:10.22331/q-2017-08-17-26.
  • [14] Stacey Jeffery and Galina Pass. Multidimensional Quantum Walks, Recursion, and Quantum Divide & Conquer. In 42nd International Symposium on Theoretical Aspects of Computer Science (STACS 2025), volume 327 of Leibniz International Proceedings in Informatics (LIPIcs), pages 54:1–54:16, Dagstuhl, Germany, 2025. Schloss Dagstuhl – Leibniz-Zentrum fΓΌr Informatik. doi:10.4230/LIPIcs.STACS.2025.54.
  • [15] Ming Li and Paul VitΓ‘nyi. Reversibility and adiabatic computation: trading time and space for energy. Proceedings of the Royal Society of London. Series A: Mathematical, Physical and Engineering Sciences, 452(1947):769–789, 1996.
  • [16] Flemming Nielson, Hanne R. Nielson, and Chris Hankin. Principles of Program Analysis. Springer, 1999.
  • [17] Aaron Potechin. Bounds on monotone switching networks for directed connectivity. Journal of the ACM, 9(4), 2014.
  • [18] Aaron H Potechin. Analyzing monotone space complexity via the switching network model. PhD thesis, Massachusetts Institute of Technology, 2015.
  • [19] Jeffrey D. Ullman. Principles of Database and Knowledge-Base Systems, Volumes 1–2. Computer Science Press, 1988–1989.