Quantum Algorithms for Graph Connectivity and Formula Evaluation
Abstract
We give a new upper bound on the quantum query complexity of deciding connectivity on certain classes of planar graphs, and show the bound is sometimes exponentially better than previous results. We then show Boolean formula evaluation reduces to deciding connectivity on just such a class of graphs. Applying the algorithm for connectivity to Boolean formula evaluation problems, we match the bound on the quantum query complexity of evaluating formulas on variables, give a quadratic speedup over the classical query complexity of a certain class of promise Boolean formulas, and show this approach can yield superpolynomial quantum/classical separations. These results indicate that this connectivitybased approach may be the “right” way of looking at quantum algorithms for formula evaluation.
1 Introduction
Deciding whether two points are connected in a network is a problem of significant practical importance. In this work, we argue that this problem, connectivity, is also important as a quantum algorithmic primitive.
Dürr, Heiligman, Høyer, and Mhalla designed a quantum algorithm for deciding connectivity that requires queries to the adjacency matrix of a graph on vertex set [13]. Belovs and Reichardt later discovered an especially elegant spanprogrambased quantum algorithm for this problem, which is timeefficient and requires only logarithmic space [4]. Belovs and Reichardt’s algorithm improves on the query complexity of Dürr et al.’s algorithm when the connecting path is promised to be short (if it exists).
Belovs and Reichardt’s connectivity algorithm has already been adapted or been used as a subroutine for deciding other graph problems, such as detecting certain subgraphs [4], deciding whether a graph is a forest [8], and deciding whether a graph is bipartite [8].
In this work, we modify the span program algorithm used in [4], inheriting its space and time efficiency, and we restrict to deciding connectivity on a class of planar graphs. If the effective resistances of the set of graphs in question (and their planar duals) are small, then we find the quantum algorithm requires far fewer queries than suggested by the analysis in [4]. In fact, we obtain a polynomial to constant improvement in query complexity for some classes of graphs.
In addition to improving our understanding of the quantum query complexity of connectivity problems, we show that Boolean formula evaluation reduces (extremely naturally) to connectivity problems of the kind for which our improved analysis holds. Therefore, finding good algorithms for connectivity can lead to good algorithms for Boolean formula evaluation. While one might not expect that such a reduction would produce good algorithms, we find the reduction gives optimal performance for certain classes of Boolean formulas.
Boolean formula evaluation is a fundamental class of problems with widereaching implications in algorithms and complexity theory. Quantum speedups for evaluating formulas like or [15] and the nandtree [14] spurred interest in better understanding the performance of quantum algorithms for Boolean formulas. This research culminated in the development of span program algorithms [24, 23], which can have optimal quantum query complexity for any problem [20]. Using span program algorithms, it was shown that queries are sufficient for any readonce formula with inputs [22, 20]. Classically, the query complexity of evaluating nandtrees is [25] and the query complexity of evaluating arbitrary readonce formulas is [16].
While there are simple bounds on the quantum query complexity of total formula evaluation problems, promise versions are still not fully understood. Kimmel [19] showed that for a certain promise version of nandtrees, called fault trees, the quantum query complexity is , while Zhan, Kimmel, and Hassidim [27] showed the classical query complexity is , giving a superpolynomial quantum speedup for a range of values of . More general treatment of when promises on the inputs give superpolynomial query speedups can be found in [1].
Since our analysis of connectivity shows that graphs with small effective resistance can be decided efficiently, this in turn means that Boolean formula evaluation problems with the promise that their inputs correspond to low resistance graphs can also be evaluated efficiently. This result gives us new insight into the structure of quantum speedups for promise Boolean formulas.
Contributions. We summarize the main results in this paper as follows:

Improved quantum query algorithm for deciding connectivity when the input is a subgraph of some graph such that — with an additional edge — is planar.

The analysis involves the effective resistance of the original graph and its planar dual.

We find families of graphs for which this analysis gives exponential and polynomial improvements, respectively, over the previous quantum analysis in [4].


Algorithm for Boolean formula evaluation via reduction to connectivity.

Using this reduction, we provide a simple proof of the fact that readonce Boolean formulas with input variables can be evaluated using queries.

We show both a quadratic and a superpolynomial quantumtoclassical speedup using this reduction, for certain classes of promise Boolean formula evaluation problems.

Open Problems. We would like to have better bounds on the classical query complexity of evaluating connectivity problems, as this would provide a new approach to finding separations between classical and quantum query complexity. Additionally, our reduction from Boolean formula evaluation to connectivity could be helpful in the design of new classical algorithms for formulas.
Another open problem concerns span programs in general: when can we view span programs as solving connectivity problems? This could be useful for understanding when span programs are timeefficient, since the timecomplexity analysis of connectivity span programs is straightforward (see Appendix A.1, [4, Section 5.3], [17, Appendix B]).
An important class of connectivityrelated span programs are those arising from the learning graph framework, which provides a means of designing quantum algorithms that is much simpler and more intuitive than designing a general span program [3]. A limitation of this framework is its onesidedness with respect to 1certificates: whereas a learning graph algorithm is designed to detect 1certificates, a framework capable of giving optimal quantum query algorithms for any decision problem would likely treat 0 and 1inputs symmetrically. In our analysis of connectivity, 1inputs and 0inputs are on equal footing. This duality between 1 and 0inputs in connectivity problems could give insights into how to extend the learning graph framework to a more powerful framework, without losing its intuition and relative simplicity.
Organization: Section 2 provides background information. In Section 3, we describe our improved analysis of the span program algorithm for connectivity for subgraphs of graphs such that is planar. In Section 4, we show that every formula evaluation problem is equivalent to an connectivity problem. In Section 5, we apply these results to promise nandtrees, for which we are able to prove the most significant classical/quantum separation using our approach. Also in Section 5, we use these ideas to create an improved algorithm for playing the twoplayer game associated with a nandtree.
2 Preliminaries
2.1 Graph Theory
For an undirected weighted multigraph , let and denote the vertices and edges of respectively. In this work, we will only consider undirected multigraphs, which we will henceforth often refer to as graphs. To refer to an edge in a multigraph, we will specify the endpoints, as well as a label , so that an edge is written . Although the label will be assumed to uniquely specify the edge, we include the endpoints for convenience. Let denote the set of directed edges of . For a planar graph (with an implicit planar embedding) let denote the faces of . We call the infinite face of a planar graph the external face.
For any graph with connected vertices and , we can imagine a fluid flowing into at , and traveling through the graph along its edges, until it all finally exits at . The fluid will spread out along some number of the possible paths in . Such a linear combination of paths is called an flow. More precisely:
Definition 1 (Unit flow).
Let be an undirected weighted graph with , and and connected. Then a unit flow on is a function such that:

For all , ;

; and

for all , .
Definition 2 (Unit Flow Energy).
Given a unit flow on a graph , the unit flow energy is
(1) 
Definition 3 (Effective resistance).
Let be a graph with . If and are connected in , the effective resistance is , where runs over all unit flows. If and are not connected,
Intuitively, characterizes “how connected” the vertices and are. The more, shorter paths connecting and , the smaller the effective resistance.
The effective resistance has many applications. In a random walk on , is equal to the commute time between and , or the expected time a random walker starting from takes to reach and then return to [9, 2]. If models an electrical network in which each edge of is a unit resistor and a potential difference is applied between and , then corresponds to the resistance of the network, which determines the ratio of current to voltage in the circuit (see [11]). We can extend these connections further by considering weighted edges. A network consists of a graph combined with a positive realvalued weight function .
Definition 4 (Effective Resistance with weights).
Let be a network with . The effective resistance of is , where runs over all unit flows.
In a random walk on a network, which models any reversible Markov chain, a walker at vertex traverses edge with probability proportional to . Then the commute time between and is . When models an electrical network in which each edge represents a resistor with resistance , then corresponds to the resistance of the network.
When is a single edge with weight , then the resistance . When calculating effective resistance, , we use the rule that for edges in series (i.e., a path), or more generally, graphs connected in series, resistances add. Edges in parallel, or more generally, graphs connected in parallel, follow the rule that conductances in parallel add, where the conductance of a graph is given by one over the resistance. (The conductance of an edge is equal to the weight of the edge.) More precisely, it is easy to verify the following:
Claim 5.
Let two networks and each have nodes and . If we create a new graph by identifying the nodes and the nodes (i.e. connecting the graphs in parallel) and define by if and if , then
(2) 
However, if we create a new graph by identifying the node of with the node of , relabeling this node (i.e. connecting the graphs in series) and define as before, then
(3) 
As a bit of foreshadowing, if we let and take values , representing false, or , representing true, then clearly (3) computes the function or, since , and . We also have that (2) computes the and function, if we use and .
Definition 6 (cut).
Given a graph with , if and are not connected, an cut is a function such that , , and whenever .
In other words, defines a subset such that , , and there is no edge of with one endpoint in , and one endpoint in . An cut is a witness that and are in different components of , so no path exists between and
Finally, we consider dual graphs:
Definition 7 (Dual Graph).
Let be a planar graph (with an implicit embedding). The dual graph, , is defined as follows. For every face , has a vertex , and any two vertices are adjacent if their corresponding faces share an edge, . We call the edge between two such vertices the dual edge to , . By convention, and will always have the same label, so that if , then for and the faces of on either side of the edge .
2.2 Span Programs and Quantum Query Algorithms
Span programs [18] were first introduced to the study of quantum algorithms by Reichardt and Špalek [24]. They have since proven to be immensely important for designing quantum algorithms in the query model.
Definition 8 (Span Program).
A span program on is made up of (I) finitedimensional inner product spaces , and such that , (II) a vector space , (III) a nonzero target vector , and (IV) a linear operator . For every string , we associate the subspace , and an operator , where is the orthogonal projector onto .
Definition 9 (Positive and Negative Witness).
Let be a span program on and let be a string . Then we call a positive witness for in if , and . We define the positive witness size of as:
(4) 
if there exists a positive witness for , and otherwise. Let denote the set of linear maps from to We call a linear map a negative witness for in if and . We define the negative witness size of as:
(5) 
if there exists a negative witness, and otherwise. If is finite, we say that is positive (wrt. ), and if is finite, we say that is negative. We let denote the set of positive inputs, and the set of negative inputs for . In this way, the span program defines a partition of .
For a function , with , we say decides if and . We can use to design a quantum query algorithm that decides , given access to the input via queries of the form .
Theorem 10 ([21]).
Fix and , and let be a span program on that decides . Let and . Then there is a bounded error quantum algorithm that decides with quantum query complexity .
2.3 Boolean Formulas
A readonce Boolean formula can be expressed as a rooted tree in which the leaves are uniquely labeled by variables, , and the internal nodes are labeled by gates from the set . Specifically, a node of degree 2 must be labeled by (not), whereas higher degree nodes are labeled by (and) or (or), with the fanin of the gate being defined as the number of children. The depth of a Boolean formula is the largest distance from the root to a leaf. We define an andor formula (also called a monotone formula) as a readonce Boolean formula for which every internal node is labeled by or . Restricting to andor formulas does not lose much generality, since for any formula, there is an equivalent formula in which all notgates are at distance one from a leaf, and such not gates do not affect the query complexity of the formula. Moreover, although we only consider readonce formulas here, our techniques can be applied to more general formulas in which a single variable may label multiple leaves, since this is equivalent to a larger readonce formula with a promise on the input. Hereafter, when we refer to a formula, we will mean an andor readonce formula.
In a slight abuse of notation, at times will denote a Boolean variable, and at times, it will denote a bit instantiating that variable. If is an instantiation of all variables labeling the leaves of a formula , then is the value of on that input, defined as follows. If has depth 0, then . If has depth greater than 0, we can express recursively in terms of subformulas , as , if the root is labeled by , or , if the root is labeled by . In the former case, we define , and in the latter case, we define . A family of formulas on variables gives rise to an evaluation problem, , in which the input is a string , and the output is . If , we say is a instance, and if , is a 1instance. By , we mean composed with . That is, if and , then evaluates as , where for .
An important formula evaluation problem is nandtree evaluation. A nandtree is a full binary tree of arbitrary depth — that is, every internal node has two children, and every leaf node is at distance from the root — in which an internal node is labeled by if it is at even distance from the leaves, or if it is at odd distance from the leaves. We use to denote a nandtree of depth . While is sometimes defined as a Boolean formula of nandgates composed to depth , we will instead think of the formula as alternating andgates and orgates — when is even, these two characterizations are identical. An instance of nand is a binary string , where . For example, the formula is a nandtree of depth . denotes the singlebit identity function.
A nand instance can be associated with a twoplayer game on the rooted binary tree that represents nand, where the leaves take the values , as in Figure 5. The game starts at the root node, which we call the current node. In each round of the game, as long as the current node is not a leaf, if the current node is at even (respectively odd) distance from the leaves, Player (resp. Player ) chooses one of the current node’s children to become the current node. When the current node is a leaf, if the leaf has value , then Player wins, and if the leaf has value , then Player wins. The sequence of moves by the two players determines a path from the root to a leaf.
A simple inductive argument shows that if is a 1instance of nandtree, then there exists a strategy by which Player can always win, no matter what strategy employs; and if is a instance, there exists a strategy by which Player can always win. We say an input is winnable if it has value 1 and winnable if it has value .
3 Improved Analysis of stconnectivity Algorithm
In this section, we give an improved bound on the runtime of a quantum algorithm for connectivity on subgraphs of , where is planar.
Let conn be a problem parameterized by a family of multigraphs , which takes as input a string where . An input defines a subgraph of by including the edge if and only if . For all , conn if and only if there exists a path connecting and in . We write conn when . A quantum algorithm for conn accesses the input via queries to a standard quantum oracle , defined .
The authors of [4] present a quantum query algorithm for conn when is a complete graph, which is easily extended to any multigraph . We further generalize their algorithm to depend on some weight function (a similar construction is also implicit in [3]). We call the following span program :
(6) 
For any choice of weight function , this span program decides conn, but as we will soon see, the choice of may impact the complexity of the resulting algorithm.
Using with for all , the authors of Ref. [4] show that the query complexity of evaluating conn is
(7) 
Their analysis was for the case where is a complete graph, but it is easily seen to apply to more general multigraphs . In fact, it is straightforward to show that this bound can be improved to
(8) 
where
(9) 
In particular, when is a complete graph on vertex set , with the promise that if an path exists, it is of length at most , Eq. (7) gives a bound of In the worst case, when , the analysis of [4] does not improve on the previous quantum algorithm of [13], which gives a bound of ).
In this paper, we consider in particular multigraphs that are planar even when an additional edge is added (equivalently, there exists a planar embedding in which and are on the same face), as in graph in Figure 1. (In the case of Figure 1, and are both on the external face.) Given such a graph , we define three other related graphs, which we denote by , , and .
We first define the graph , which is the same as , but with an extra edge labeled by connecting and We then denote by the planar dual of . Because every planar dual has one edge crossing each edge of the original graph, there exists an edge that is dual to , also labeled by . We denote by and the two vertices at the endpoints of . Finally, we denote by the graph except with the edge removed.
By construction, will always have the same number of edges as . Then as defines a subgraph of by including the edge if and only if , we let be the subgraph of where we include the edge if and only if .
If there is no path from to in , there must be a cut between and Note that for any , if and only if . Looking at Figure 1, one can convince oneself that any path in defines an cut in : simply define for vertices above the path, and for vertices below the path.
Let be a weight function on . Then we define a weight function on as Then for every there will be a path either from to in (and hence ) will be finite), or a path from to in (in which case will be finite).
We can now state our main lemma:
lemmaposwit Let be a planar multigraph with such that is also planar, and let be a weight function on . Let . Then and .
Theorem 11.
Let be a planar multigraph with such that is also planar. Then the bounded error quantum query complexity of evaluating conn is
(10) 
where the minimization is over all positive realvalued functions on .
While it might be difficult in general to find the optimal edge weighting , any choice of will at least give an upper bound on the query complexity. However, as we will see, sometimes the structure of the graph will allow us to efficiently find good weight functions.
The proof of Lemma 1 is in Appendix A. The positive witness result follows from generalizing the proof in [4] to weighted multigraphs. The idea is that an path witnesses that and are connected, as does any linear combination of such paths — i.e. an flow. The effective resistance characterizes the size of the smallest possible flow.
Just as a positive witness is some linear combination of paths, similarly, a negative witness turns out to be a linear combination of cuts in . But as we’ve argued, every cut corresponds to an path in . Using the correspondence between cuts and paths, we have that a negative witness is a linear combination of paths in . This allows us to show a correspondence between complexityoptimal negative witnesses and minimal flows, connecting to .
In Appendix A.1, we show that if a quantum walk step on the network can be implemented time efficiently, then this algorithm is not only query efficient, but also time efficient. Let
(11) 
Then we show the following.
theoremtimeComp Let be defined as in (3). Let be an upper bound on the time complexity of implementing . If has the property that is planar, then the time complexity of deciding conn is at most
(12) 
In Appendix A.1, we also show that if the space complexity of implementing in time is , the algorithm referred to in Theorem 11 has space complexity at most .
3.1 Comparison to Previous Quantum Algorithm
When is planar, our algorithm always matches or improves on the algorithm in [4]. To see this, we compare Eqs. (10) and (8), and choose to have value on all edges of . Then the first terms are the same in both bounds, so we only need to analyze the second term. However, using the duality between paths and cuts, we have
(13) 
To obtain the inequality in Eq. (13), we create an flow on that has value one on edges on the shortest path from to and zero on all other edges. Such a flow has unit flow energy equal to the shortest path. However, the true effective resistance can only be smaller than this, because it is the minimum energy over all possible flows.
We now present two simple examples where our algorithm and analysis do better than that of [4]. In the first example, we highlight how the change from to in the complexity gives us an advantage for some graphs. In the second example, we show that being able to choose a nontrivial weight function can give us an advantage for some graphs.
Let be an path of length : i.e., vertices arranged in a line so that each vertex is connected to its neighbors to the left and right by a single edge, and and are the vertices on either end of the line, as in Figure 2. For some , let , where is the allone string of length , and is the hamming weight of the string .
Then, choosing to have value on all edges of , we have
(14) 
because the only such that and are connected in is , in which case the only unit flow has value on each edge. This flow has energy . However
(15) 
because when and are not connected in , has at most edges, so has at least edges. Thus we can define a unit flow with value on each of parallel edges in , giving an energy of On the other hand
(16) 
In fact, since counts the minimum number of edges across any cut (i.e. such that and ), it is always at least 1, for any in which an cut exists, whereas can be as small as for some .
Choosing in our example, and applying Eqs. (8) and (10), the analysis in [4] gives a query complexity of while our analysis gives a query complexity of . In Section 4 we will show that this bound is tight.
Now consider the graph in Figure 3. It consists of edges in a line, connecting vertices , and then multiedges between and . We assign weights for edges on the path from to , and for all other edges.
Then,
(17) 
which occurs when only one of the multiedges between and is present. In that case, the edges each contribute 1 to the effective resistance, and the final edge between and contributes . Also
(18) 
where the maximum occurs when there is only one path from to . (If it is the path with edges, each edge has weight , and so contributes to the flow energy.) However
(19) 
for a cut across the multiedges between and , and
(20) 
which occurs when only one of the multiedges between and is present.
Thus, the analysis in [4] gives a query complexity of while our analysis gives a query complexity of .
4 ANDOR Formulas and stConnectivity
In this section, we present a useful relationship between andor formula evaluation problems and connectivity problems on certain graphs. As mentioned in Section 2, for simplicity we will restrict our analysis to readonce formulas, but the algorithm extends simply to “readmany” formulas. In this case, we will primarily be concerned with the query complexity: the input to a formula will be given via a standard quantum oracle , defined .
Given an andor formula with variables, we will recursively construct a planar multigraph , such that has two distinguished vertices labeled by and respectively, and every edge of is uniquely labeled by a variable . If is just a single variable, then is just a single edge with vertices labeled by and , and edge label . That is and
Otherwise, suppose . Then is the graph obtained from the graphs by identifying the vertex labeled in with the vertex labeled in , for all , and labeling the vertex labeled in by , and the vertex labeled in by . That is, we connect the graphs in series, as in Figure 4. (For a formal definition of , see Appendix B).
The only other possibility is that . In that case, we construct by starting with and identifying all vertices labeled by , and labeling the resulting vertex with , and identifying all vertices labeled by , and labeling the resulting vertex by . That is, we connect in parallel (see Figure 4). We note that graphs constructed in this way are exactly the set of seriesparallel graphs with two terminals (see e.g. [26, Def. 3]), and are equivalent to graphs without a minor [10, 12].
Note that for any , is planar, and furthermore, both and are always on the same face. Thus, we can define , and as in Section 3. Then we can show the following: {restatable}lemmaformulast Let </