4.2.1 Quantum Quadrilateral Algorithm #1
Our first quantum quadrilateral algorithm [BdW] is a straightforward adjacency matrix al- gorithm:
2Classical Quadrilateral Algorithm #1 could take in an adjacency matrixM instead. If so, it would need a preliminary step that transformsM into an adjacency list. (The algorithm could be adapted for an adjacency matrix in other ways, but the other adaptations are no more efficient.) This extra step would take O(n2)
Quantum Quadrilateral Algorithm #1
1. Choose two random vertices u, v∈V.
2. Perform Grover’s search to find two verticesu0, v0 ∈V such thatu, u0, v, v0 is a quadrilateral. 3. Perform amplitude amplification on steps 1–2.
Step 1 selects random vertices u and v, and step 2 searches for vertices u0 and v0 that are adjacent to bothu andv. This search requiresO(√n) queries and succeeds with probability at least 1/2 ifu and v are in a four-cycle together.
However, the probability that u and v are in the same four-cycle is just O(1/n2), so
the success probability of steps 1–2 is also just O(1/n2). We boost the algorithm’s success probability by embedding steps 1–2 inO(n) iterations of amplitude amplification. This raises the overall success probability to at least 1/2 and raises the overall query complexity to O(n3/2).
4.2.2 Quantum Quadrilateral Algorithm #2
Our second quantum quadrilateral algorithm [BdW] takes in an adjacency list representation A, as well as the lengths of the linked lists in A. It is more complicated but more efficient than the previous algorithm:
Quantum Quadrilateral Algorithm #2
1. Choose a random vertex u ∈ V, which has k neighbors v1, . . . , vk with adjacency lists A[v1], . . . , A[vk].
2. Perform Grover’s search on v1, . . . , vk to find up to 2n1−c + 1 neighbors vL such that
|A[vL]| ≥nc (c to be determined later). We say that these vL have “long” lists and that
all other vertices in{v1, . . . , vk} have “short” lists.
3. If there are more than2n1−c neighbors with long lists, then graphGmust contain a quadri- lateral (see explanation below). Truncate each long list to lengthnc, and concatenate these truncated lists into a new list L. Perform quantum element distinctness algorithm on Lto find a vertexw6=u that is adjacent to at least two neighborsvL.
4. Otherwise, concatenate all lists (short and long) into a new listL. Perform quantum element distinctness algorithm onL to find a vertexw∈V that is adjacent to at least two vertices that are adjacent to u.
5. Perform amplitude amplification on steps 1–4.
Step 1 selects a random vertex u, which has k≤n−1 neighbors v1, . . . , vk. Step 2 searches these neighbors to determine whether more than 2n1−c of them are adjacent to at least nc vertices (we calculate c below). This search is bounded by O(√n2−c) queries.3 Now our
algorithm forks, depending on the result of the search.
If u does have more than 2n1−c neighbors vL with “long” listsA[vL], then G must have a quadrilateral. This is because P
vL|A[vL]| >2n
1−c·nc = 2n > n+k, which means that, taken together, the listsA[vL] must contain at least two instances of at least one vertex other thanu. In other words, at least one vertexw 6=u must be adjacent to two vertices vL1 and vL2. Thatw is in a quadrilateral withu, vL1,and vL2.
To find vL1, vL2, and w, we truncate 2n
1−c + 1 of the long lists to length nc and then concatenate the truncated lists. The concatenation has length (2n1−c+ 1)·nc >2n > n+k, so it must contain at least two instances of at least one vertex w6=u. We run the quantum element distinctness algorithm to find such a w and to determine vL1 and vL2. Doing so requires O(n2/3) queries and brings the query complexity to O((n2−c)1/2+n2/3).
3
For some unknownt, there are tvertices vL ∈ {v1, . . . , vk}such that|A[vL]| ≥ nc. If t ≤2n1−c, then
finding allvL’s (and determining that there are no more) requires Pt i=1O( p k/i) +O(√k) = O(√kt) = O(√n·2n1−c) =O(√n2−c) queries. Ift >2n1−c
Ifudoes not have more than 2n1−c neighbors with long lists, then there are at mostn−1 short lists, each with length less than nc. In addition, there are at most 2n1−c long lists, whose combined length is at most 2n. We concatenate all of these lists into a new list L, whose length is bounded above by O((n−1)·nc + 2n) = O(n1+c). Running the element distinctness algorithm onLbrings our query complexity toO (n2−c)1/2+n2/3+ (n1+c)2/3. As we have seen before, these first few steps are not sufficient. IfGhas one quadrilateral, the probability that step 1 chooses auin a quadrilateral isO(1/n), so the overall probability of finding a quadrilateral is bounded above byO(1/n). Therefore, we embed steps 1–4 inO(√n) iterations of amplitude amplification, bringing the algorithm’s overall query complexity to O √n (n2−c)1/2+n2/3+ (n1+c)2/3
.
In order to minimize this complexity, we must find acthat minimizes the sum of (n2−c)1/2 and (n1+c)2/3. So, we set them equal to each other and solve forc:
n(2−c)/2 =n(2+2c)/3 ⇒ (2−c)/2 = (2 + 2c)/3 ⇒ c= 2/7.
Pluggingc= 2/7 into the overall query complexity, we obtain:
O √ n (n12/7)1/2+n2/3+ (n9/7)2/3 = On1/2(n6/7+n2/3+n6/7)=On1/2(n6/7)=O(n19/14).
This algorithm is significantly more efficient than the other algorithms in this chapter, and its efficiency is due not to a clever procedure but rather to careful balance between its search components and its built-in knowledge about when a list must contain indistinct elements. If “long” lists were defined differently, or if a different number of “long” lists were sought, this balance would be disrupted, and the efficiency would suffer.
This balance makes this algorithm unlike the other algorithms in this paper, and it deserves examination and admiration. However, its impressiveness is overshadowed by the generality of the quantum walk algorithm for arbitrary subgraphs (which of course include quadrilaterals), which is discussed in Section 5.3.