An Asymptotically Fast Polynomial Space Algorithm for Hamiltonicity Detection in Sparse Directed Graphs
AAN ASYMPTOTICALLY FAST POLYNOMIAL SPACE ALGORITHM FORHAMILTONICITY DETECTION IN SPARSE DIRECTED GRAPHS
ANDREAS BJ ¨ORKLUND
Abstract.
We present a polynomial space Monte Carlo algorithm that given a directed graph on n vertices and average outdegree δ , detects if the graph has a Hamiltonian cycle in 2 n − Ω( nδ ) time. Thisasymptotic scaling of the savings in the running time matches the fastest known exponential spacealgorithm by Bj¨orklund and Williams ICALP 2019. By comparison, the previously best polynomialspace algorithm by Kowalik and Majewski IPEC 2020 guarantees a 2 n − Ω( n δ ) time bound.Our algorithm combines for the first time the idea of obtaining a fingerprint of the presence ofa Hamiltonian cycle through an inclusion–exclusion summation over the Laplacian of the graphfrom Bj¨orklund, Kaski, and Koutis ICALP 2017, with the idea of sieving for the non-zero terms inan inclusion–exclusion summation by listing solutions to systems of linear equations over Z fromBj¨orklund and Husfeldt FOCS 2013.This work was carried out while working as a researcher for Ericsson Research. a r X i v : . [ c s . D S ] S e p Introduction
Given a directed graph G = ( V, A ) on n = | V | vertices, we consider the problem of detecting if G has a Hamiltonian cycle, a directed cycle through G using a subset of the arcs A , visiting eachvertex of V exactly once. We call this the Hamiltonicity problem. Deciding Hamiltonicity in adirected graph is one of Karp’s original NP-complete problems [15]. For a very long time, the bestworst case algorithm known for this problem was based on Bellman’s [3] and Held and Karp’s [13]dynamic programming across all vertex subsets from the early 1960’s running in 2 n poly( n ) time.If and when one can improve over O ∗ (2 n ) time has been the focus of much of recent research,confer the related work section below. A recent result by Bj¨orklund and Williams [11], buildingon Bj¨orklund, Kaski, and Koutis [9], describes a deterministic, exponential space, 2 n − Ω( nδ ) timealgorithm that counts the number of Hamiltonian cycles where δ = | A | n is the average outdegree.A natural follow-up question is whether this speedup intrinsically comes at the cost of exponentialspace usage. In other words, is the obtained speedup necessarily an effect of efficient tabulationof solutions to recurrent subproblems? In this paper, we give a partial negative answer to thatquestion. We show that this requirement of an exponentially sized space resource can be reducedto a polynomially sized one, when we are only interesting in detecting if the graph has a Hamiltoniancycle, and are content with a randomised algorithm. We prove Theorem 1.
There is a polynomial space Monte Carlo algorithm that given an n -vertex directedgraph of average outdegree δ , detects w.h.p. if the graph has a Hamiltonian cycle in n − Ω( nδ ) time,without any false positives. Our algorithm builds on the algorithms by Bj¨orklund, Kaski, and Koutis [9] and its successor byBj¨orklund and Williams [11]. At the core of the algorithms in [9] and [11], are efficient methods tolist contributing terms to a sum evaluating to the number of Hamiltonian cycles. They use split,tabulate, and list procedures that seem to require exponential space. In more detail, in [11], theyreduce the problem to listing pairs of dissimilar vectors from two exponential size sets of shortvectors, where dissimilar means different in each coordinate. They further present two efficientalgorithms to solve this latter problem that build on tabulation, one explicitly on one of the twosets, and the other indirectly as subresults of a large fast matrix multiplication. Our overallalgorithm use a similar idea of listing contributing terms to a sum, but we use a different approachof obtaining the terms. In particular, we do not directly reduce to the problem of listing dissimilarvectors. Our main insight is that another technique previously used to compute the parity of thenumber of Hamiltonian cycles by Bj¨orklund and Husfeldt [7], by a careful design, can replace thetabulation for enumeration of solutions to a linear equation system over Z . This latter task is well-known to be possible to do in polynomial space. Our way of combining the above two techniquesis our main technical novelty.Polynomial space algorithms improving over O ∗ (2 n ) time in sparse graphs were known before.We note that for the easier case of everywhere sparse graphs, i.e., graphs in which the sum of thein- and outdegree at every vertex is bounded by d , Bj¨orklund et al. [8] implicitly showed that youcan decide Hamiltonicity in 2 n − Ω( dn d ) time using polynomial space. Their paper considered TSPin undirected graphs, but it is not difficult to see that their proof of Theorem 1.3 could also beused for directed Hamiltonicity. Very recently, Kowalik and Majewski [18] presented a polynomialspace, 2 n − Ω( n δ ) time algorithm for directed Hamiltonicity on n -vertex graphs of average outdegree δ . It builds on the algorithm by Bj¨orklund [5] which is a (2 − − δ ) n/ poly( n ) time polynomialspace algorithm in undirected bipartite graphs of average degree δ using techniques similar in spiritto our algorithm design here. Note though that in our design, the speedup is exponential in n/δ ,whereas the speedup in Kowalik and Majewski [18] is exponential in n/ δ .It should be noted in passing, that for many hard combinatorial problems the best known worstcase algorithms use exponential space. In fact, in some cases the only known algorithms that improve over a straight-forward brute-force algorithm testing all possibilities use exponential space,are deterministic, and are also able to count the solutions. To give just one example that is alsoon Karp’s list [15], this holds presently for MaxCut : compute a bipartition of the vertices thatmaximises the number of edges between the two parts. It has a O ∗ (1 . n ) time counting algorithmwhere n is the number of vertices [21], but no polynomial space algorithm improving substantiallyover the brute-force O ∗ (2 n ) time algorithm is known, even if we only consider detection and userandomisation.One reason to get rid of exponential space usage from a practical point of view, is to offer betterimplementability on parallel computing devices. This seems to be the case also with the presentalgorithm compared to the exponential space algorithms in [11]. In particular, the computationallyheavy steps in our algorithm can easily be scheduled to compute different parts of the sum thatmay run obliviously of each other on different processors, only adding up their final partial sumsin the end.1.1. Related work.
The fastest known (exponential space) algorithm for directed Hamiltonicityas far as we know is the 2 n − Ω( √ n/ log log n ) time algorithm by Bj¨orklund, Kaski, and Williams [10].The fastest known polynomial space algorithm is the 2 n poly( n ) time one based on counting closedwalks via adjacency matrix powering and inclusion–exclusion, discovered at least four times [17,16, 2, 1], the oldest by Kohn, Gottlieb, and Kohn [17] dates back to 1977. Much faster algorithmsexist for special cases, also apart from the 2 n − Ω( nδ ) time exponential space algorithm in averageoutdegree δ directed graphs by Bj¨orklund and Williams [11]. In bipartite directed graphs, thereis a O ∗ (1 . n ) time, polynomial space, algorithm by Bj¨orklund, Kaski, and Koutis [9]. There isalso an earlier O ∗ (1 . n ) time, exponential space, algorithm by Cygan, Kratsch, and Nederlof [12]based on a different technique. Bj¨orklund and Husfeldt [7] show a O ∗ (1 . n ) time, polynomialspace, algorithm that computes the parity of the number of Hamiltonian cycles in a directedgraph. Somewhat perplexingly, this algorithm does not seem to be useful for the detection problemin general. However, counting modulo powers of small primes can be used for detection whenthe number of Hamiltonian cycles are less than c n for some constant c : Bj¨orklund, Kaski, andKoutis [9], improving over a partial result in Bj¨orklund, Dell, and Husfeldt [6], show how to finda Hamiltonian cycle in O ((2 − (cid:15) c ) n ) time, with (cid:15) c > c . In undirected graphs, there is a O ∗ (1 . n ) time, polynomial space, algorithm, and in bipartiteundirected graphs, there is a O ∗ (1 . n ) time algorithm, both by Bj¨orklund [4]. Despite the partialpositive results above, it is a major open question in the area of exact exponential time algorithms,whether or not a O ( c n ) time algorithm for any c < Methodology.
Our algorithm is based on algebraic fingerprinting for Hamiltonian cycles,following a long line of works [4, 7, 6, 9, 5, 11]. The idea is to define a multivariate polynomial P over a ring, along with an efficient algorithm for its evaluation, with the property that P isnon-zero only if the graph has a Hamiltonian cycle. That polynomial can then be used to detectHamiltonicity, by testing if P is identically zero by evaluating P at a random point using the efficientalgorithm (Polynomial identity testing, PIT). The choice of ring is important and a somewhatdelicate matter. The basic observation is that using a larger ring increases the chance of making P non-zero on many points, whereas a smaller ring typically makes it easier to come up with anefficient evaluation algorithm. We will use a large ring for the polynomial, but our sample spacewill only take values from a small subring on a large subset of the variables. Our algorithm forevaluating P follows a construction by [9] based on an exponential sum of weighted Laplacians ofthe graph, that in itself already describes a 2 n poly( n ) time algorithm. To get a running time belowthat, we take measures in designing our sample space so that many summands will be zero for atrivial reason, and we can find out which are not by solving a linear equation system over Z . This is inspired by the algorithm in [7] that lists solutions to a quadratic equation system over Z tosieve for the contributing terms. We list the solutions to a linear equation system by generatingone solution from a Gaussian elimination followed by taking linear combinations of that solutionwith the null space (also found by the Gaussian elimination). This way we can list a superset of thesummands that are non-zero and compute the sum to obtain the value of P at our random point.2. The Algorithm
The Hamiltonicity Polynomial.
We begin by describing the polynomial P we will be using.Following [11], we will work on a slightly modified version G = ( V, A ) of the n -vertex input graph G in = ( V in , A in). We pick an arbitrary vertex u ∈ V in, and replace u with two new vertices s and t , where s retains all outgoing arcs from u , and t retains all incoming arcs to u . Note thatthe Hamiltonian paths from s to t in this modified G are in one-to-one correspondence with theHamiltonian cycles in the original graph G in, and that the average degree is not increased. In thefollowing, we consider the problem of detecting a s - t Hamiltonian path on the modified n + 1 vertexgraph G .Fix a (commutative) ring R , and introduce a variable z uv ∈ R for each arc uv ∈ A . Let H ( G )be the set of Hamiltonian s - t paths in G , and consider the Hamiltonicity polynomial P G as(1) P G ( z ) = (cid:88) H ∈H ( G ) (cid:89) uv ∈ H z uv . Our algorithm is based on an efficient way of evaluating P G ( z ) in a carefully chosen randompoint z over a particular ring. Note that we will write z uv in formulas to refer both to the formalvariable and its value in R according to a specific assignment z : A → R . In our analysis we willsometimes think of P G ( z ) as a formal polynomial in z with coefficients from R , but in the algorithmitself, we always mean P G ( z ) to be an evaluation over R of the polynomial P G in a specific point z .For now, note that an evaluation of P G ( z ) in a random point z can potentially be used as afingerprint of existence of a Hamiltonian cycle in the original input graph: On one hand, thepolynomial always evaluates to zero if the input graph has no Hamiltonian cycles (thus there areno false positives). On the other hand, by evaluating it in a random point, we will obtain a non-zero result if there is a Hamiltonian cycle in the input graph G in, unless we are unlucky and themonomials happen to cancel each other. As mentioned above, there are two conflicting aspects toconsider for a successful fingerprint design:(1) We want the ring and the sample space to be large enough so we can argue that the resultis non-zero w.h.p. if the graph G in is Hamiltonian.(2) We want the ring and the sample space to have some structure that we can use to derivean efficient evaluation algorithm.The rest of our paper describes one way of balancing these aspects without having to resort toexponential size tabulation to enable a fast evaluation algorithm, by combining the graph Laplacianmachinery in Bj¨orklund, Kaski, and Koutis [9] with the linear equation system modulo two listingidea from Bj¨orklund and Husfeldt [7]. In Section 2.3 we will address the first aspect of balancingthe fingerprint which is the major novel part. In Sections 2.4 and 2.5 we describe the basis of thealgorithm in [9] (and subsequently in [11]) that we will use, and in 2.6 and 2.7 we will address thesecond aspect of balancing the fingerprint by describing a linear algebra enumeration algorithminspired by the algorithm in [7]. Finally, in Section 2.8 we put the parts together into an algorithmfor Theorem 1. We begin by defining the ring.2.2. The Choice of Ring.
We will work over the polynomial ring R = Z k [ x ] / ( x m ), i.e., poly-nomials in one variable truncated at degree m with integer coefficients counted modulo 2 k . Withforesight, both k = k R and m = m R will be poly( n ), and hence an element in R is described bypoly( n ) bits, and the arithmetic operations of addition and multiplication can both be done in poly( n ) time. To compute a determinant of a matrix in R n × n , as we will need later, we may useKaltofen’s division-free algorithm [14], that uses O ( n . log n log log n ) ring operations. Altogether,the computation of the determinant of an n × n matrix over the ring R is a poly( n ) time task.2.3. The Sample Space.
In this section, we describe the sample space over which we chooseour point z for polynomial identity testing. We will also argue that a randomly chosen pointfrom the sample space has P G ( z ) (cid:54) = 0 with non-zero constant probability when the graph G has aHamiltonian s - t path. As we primarily are interested in the asymptotic form of the running timescaling, we will set the parameters somewhat arbitrarily for ease of calculations. The sample spaceis parameterised by two positive integers τ and (cid:96) to be defined later in our analysis. The processto choose the point z is given below: SamplePoint (Returns T and an assignment z to be used for PIT of P G )(1) Sample a subset T ⊆ V \ { s } of size τ uniformly at random.(2) For every arc uv, v ∈ T , set z uv = 1.(3) For every arc uv, v (cid:54)∈ T , set z uv = x w ( uv ) , where w ( uv ) ∈ { , · · · , (cid:96) } is a uniformly andindependently randomly chosen integer.We next turn to proving that the choice of z is good for PIT of P G . We will first look at theHamiltonicity polynomial after assigning z uv = 1 for all v ∈ T , but for now still treat all other z -variables unassigned (left as formal variables). We call these remaining variables ˜ z with ˜ z uv = z uv and consider the associated T -truncated polynomial P G,T (˜ z ) obtained from P G after the variablesubstitution. Define H T ( G ) as the arc subsets of Hamiltonian s - t paths in H ( G ) after the removalof any arc ending in T , i.e., H T ( G ) = {∪ uv ∈ H,v (cid:54)∈ T uv : H ∈ H ( G ) } . We call these the T -truncated Hamiltonian paths. We can write P G,T (˜ z ) = (cid:88) H (cid:48) ∈H T ( G ) e H (cid:48) · (cid:89) uv ∈ H (cid:48) ˜ z uv , where e H (cid:48) counts the number of Hamiltonian cycles in G with T -truncation H (cid:48) .We first need to prove that P G,T (˜ z ) is not the zero-polynomial with high enough probability, when G in has a Hamiltonian cycle. Note that it may equal the zero-polynomial even in the presence ofHamiltonian cycles in G in, when e H (cid:48) is a multiple of 2 k for all H (cid:48) ∈ H T ( G ), as this would resultin an annihilation in our ring R , where k = k R is the ring parameter in Section 2.2. We will firstargue that this doesn’t happen with too large a probability.To prove this will not happen with some non-zero constant probability, let H be any fixedHamiltonian s - t path in G . In particular, our arbitrary choice of H is independent of T . Let H T ∈ H T ( G ) be the T -truncation of H . We will upper bound the expectation of e H T , the number ofHamiltonian s - t paths in G whose T -truncation matches H T . For every T , define S = S ( T, H ) ⊆ V to be the set of in-neighbors of T along H , i.e.,(2) S = { u : v ∈ T, uv ∈ H } . Note that S and T are not necessarily disjoint, but of the same size τ . We consider the followingbipartite graph B H obtained from an induced subgraph of G as follows. B H has two parts, onerepresenting the vertices in S , and one representing the vertices in T . All arcs in B H connects avertex in the first part representing S to a vertex in the second part representing T . There is anarc from a vertex u in the first part to a vertex v in the second part, iff uv is an arc in the inducedsubgraph G [ S ∪ T ]. The following lemma tells us that the graph B H in expectation is not too dense. Lemma 2.
The expected number of arcs in B H is no more than | S | (cid:18) | T | δn (cid:19) . Proof.
Let d v denote the outdegree of vertex v ∈ V . Consider a vertex u ∈ S . The arc from u to the next vertex on H is always present in B H . The number of other arcs though, is inexpectation ( d u − | T |− n since the other vertices on T apart from u ’s out-neighbor on H areuniformly distributed. Hence, by the linearity of expectation, using that each vertex in V \ { t } isincluded in S with probability | S | /n , the expected number of arcs in B H is (cid:88) u ∈ V \{ t } | S | n (cid:18) d u − | T | − n (cid:19) ≤ | S | (cid:18) | T | δn (cid:19) . (cid:3) This means, that if we choose the fixed size τ = | T | = | S | = ncδ , we get expected averageoutdegree from the vertices in the part representing S in B H bounded by 1 + c − . By Markov’sinequality for a non-negative random variable X ,Pr[ X ≥ λ E [ X ]] ≤ λ , we can bound the probability that the average degree is not much larger: Corollary 3.
The probability that the average outdegree of a vertex in S in B H is at most (cid:18) (cid:19) (cid:18) c (cid:19) , is at least / . We next observe that all Hamiltonian s - t paths whose T -truncation is H T defines the same set S . This also means that every Hamiltonian s - t path in G whose T -truncation is H T must use somearc for each vertex in S in B H . The product of the outdegrees of vertices in S is an upper boundon their number e H T . Hence, by the above corollary with probability at least 1 /
50 there will be atmost ((1 + 1 / c − )) τ of them by the arithmetic mean-geometric mean inequality. By setting k R in Section 2.2 large enough so that2 k R > (cid:18)(cid:18) (cid:19) (cid:18) c (cid:19)(cid:19) τ , we will get a monomial with non-zero coefficient in P G,T (˜ z ) with probability at least 1 /
50. We notethat it suffices to set k R > τ log (cid:18)(cid:18) (cid:19) (cid:18) c (cid:19)(cid:19) = ncδ log (cid:18)(cid:18) (cid:19) (cid:18) c (cid:19)(cid:19) . We will need k R to be much smaller than τ in the evaluation algorithm described in the nextsections in order to evaluate P G ( z ) fast. Setting c = 20, say, we can thus use k R = τ and concludethat e H T < k R with large enough probability, and hence that P G,T (˜ z ) has at least one monomial.To summerise, we have that Lemma 4.
With τ = n δ and k R = n δ (i.e., the parameters set as above), SamplePoint returns T so that the formal polynomial P G,T (˜ z ) (cid:54) = 0 , when the input graph has a Hamiltonian cycle, with probability at least / . We next turn to arguing that P G ( z ) (cid:54) = 0 (over the ring R ) with high enough probability for theassignment z returned by SamplePoint . The next famous lemma by Mulmuley, Vazirani, andVazirani [19] shows that with (cid:96) large enough, we will be able to isolate a T -truncated Hamiltonianpath in H T ( G ) that is represented by a monomial in P G,T (˜ z ). Lemma 5 (Isolation Lemma, Mulmuley, Vazirani, and Vazirani [19]) . Let m < M be two positiveintegers and let F be a nonempty family of subsets of { , · · · , m } . Suppose each element x ∈{ , · · · , m } receives a weight w ( x ) ∈ { , · · · , M } independently and uniformly at random. Definethe weight of a set S in F as w ( S ) = (cid:80) x ∈ S w ( x ) . Then, with probability at least − mM , there is aunique set in F of minimum weight. We apply the above Lemma, on the family F equal to H T ( G ) further restricted to those T -truncated Hamiltonian paths that are represented by a monomial in P G,T (˜ z ), i.e., those H (cid:48) thathave 2 k R (cid:45) e H (cid:48) . We use the weights w ( uv ) set as in step 3 of SamplePoint above to obtain z ,with (cid:96) = 100 | A | . We have with probability at least 1 − /
100 that a monomial exists with someunique weight µ . In particular, with high enough probability, there is a Hamiltonian s - t path whose T -truncation H (cid:48) is in F that will be isolated and contribute the value e H (cid:48) x µ to P G ( z ).By setting the ring parameter m R > n(cid:96) in Section 2.2, we observe that this monomial in thepolynomial ring is possible to detect. Lemma 6.
With τ = n δ , k R = n δ , m R > n(cid:96) , and (cid:96) = 100 | A | (i.e., all the parameters set asabove), SamplePoint returns z so that the polynomial P G ( z ) (cid:54) = 0 , when the input graph has a Hamiltonian cycle, with probability at least / . The probability bound comes from the probability of T being a good choice in Lemma 4 toguarantee that there exists a H (cid:48) with e H (cid:48) < k R (1/50) after subtracting the probability that theIsolation Lemma was not successful in its isolation (1/100).2.4. The Laplacian.
Bj¨orklund, Kaski, and Koutis [9] observed that the number of Hamiltoniancycles in a directed graph can be evaluated as an inclusion–exclusion summation over a determinantof a polynomial matrix representing the graph. We will use their construction, not over the integers,but over the particular ring R defined in Section 2.2. This means we will lose the ability to countthe Hamiltonian cycles, but it will also enable a faster evaluation of the inclusion–exclusion formulaas we will demonstrate. We reiterate their construction here for the sake of completeness and easyreference.The weighted Laplacian of the graph G , is a ( n + 1) × ( n + 1) polynomial matrix L = L G ( y, z )with rows and columns indexed by the vertices V , in the variables y v for v ∈ V \ { t } , and variables z uv for uv ∈ A :(3) L i,j = (cid:80) wv ∈ A z wv y w if i = j = v − z uv y u if i = u, j = v, uv ∈ A . The Laplacian punctured at the start vertex s , is the matrix L s obtained by removing row andcolumn s from L . In [9](their Theorem 5), it was observed that Tutte’s directed version of theMatrix-Tree theorem of Kirchhoff [20], where det( L s ) is a polynomial in which each term corre-sponds to a directed spanning out-branching rooted at s , could be used to compute the Hamiltonic-ity polynomial. By the principle of inclusion–exclusion, letting | y | denote the number of vertices v for which y v = 1, we have Lemma 7 (Paraphrasing Equation (7) in Bj¨orklund, Kaski, and Koutis [9]) . (4) P G ( z ) = (cid:88) y :( V \{ t } ) →{ , } ( − n −| y | det ( L s ( y, z )) . The summation is over all 2 n − assignments y : V \ { t } → { , } . Hence, with the formula inLemma (7), we now have a way to evaluate P G ( z ) in a particular point z in 2 n poly( n ) time. Wewill next see how we can speed-up the evaluation for a z from our sample space.2.5. Random perturbations at T . Following [9] and [11], we perturb the Laplacian matrices,without affecting the determinant, so that in expectation many summands in the above formulaEq. 4 are zeroed-out. We introduce new random variables q v ∈ { , } for v ∈ T , sampled uniformlyand independently, where T is the sampled set from SamplePoint and define the q -perturbedLaplacian of G as(5) L qi,j = (cid:80) wv ∈ A z wv y w if i = j = v, v (cid:54)∈ T (cid:80) wv ∈ A z wv y w − q v if i = j = v, v ∈ T − z uv y u if i = u, j = v, uv ∈ A . Comparing this to Eq. 3, we have only added a term on some of the diagonal entries in the rowsindexed by our sampled set T . Note that these extra q v variables do not affect the final inclusion–exclusion sum, as only the monomials representing Hamiltonian paths from s to t are counted, inparticular only monomials with all n y u -variables for u ∈ V \ { t } , confer [9] for a proof. Hence,irrespective of q , we can still compute the Hamiltonicity polynomial as:(6) P G ( z ) = (cid:88) y :( V \{ t } ) →{ , } ( − n −| y | det ( L qs ( y, z )) . What we have gained by doing this, is that the probability that a row indexed by i ∈ T has itsdiagonal entry divisible by two, is 1 /
2, independently of other rows. We will next see how we canuse this.2.6.
Efficient Evaluation of P G ( z ) given T . The basic idea is the same underlying the speed-ups in [7, 9, 11]. We make sure that in expectation, many summands in Eq. (6) will be triviallyzero. Then, to evaluate the formula it suffices to list only the summands that are not trivially zero,so-called contributing terms, and sum up their contributions. Here, with “trivially zero”, we willmean matrices that has at least k = k R rows of the matrix among the rows indexed by a vertex inthe sampled set T from SamplePoint with all coefficients even. To see that such a term is zero,we merely have to recall Leibniz’s determinant expansion of a matrix M = { m i,j } :det( M ) = (cid:88) σ ∈ S n sgn( σ ) n (cid:89) i =1 m i,σ ( i ) , where S n is the set of all permutations on n elements. Note in particular that in every term thereis one element from each row. Hence, if the matrix has k rows in which every monomial ax b in aring element has a even, the product (over Z ) must be divisible by 2 k and hence cancel in the ring R .Our algorithm to compute P G ( z ) will list the terms in Eq. 6 that have at least one odd coefficientin some ring element in at least τ − k + 1 of the rows of L s representing vertices in T . This is whatis required to be a contributing terms. The algorithm outline is postponed to the next section.We begin by arguing that, in expectation over the random q values, there are not too manycontributing terms. Recalling Eq. 3, and inspecting any such row in the matrix L s ( y ) for a vertex v ∈ T , we see that(1) Off-diagonal entries are zero if y v = 0 or v = t ,(2) The diagonal entry is divisible by two if (cid:88) wv ∈ A y w = q v ( mod 2) , remembering that z wv = 1 for all wv ∈ A with v ∈ T .Fix an assignment y : V \ { t } → { , } , and let Z y ⊆ T be the vertices u for which the assignmentsets y u = 0, along with t if t ∈ T . From the above, the probability over the random q values, of theevent ε y that a fixed assignment y does not result in a trivially zero term in Eq. 6, is(7) Pr q [ ε y ] = (cid:18) (cid:19) | Z y | k − (cid:88) i =0 (cid:18) | Z y | i (cid:19) . Here we use that the diagonal entry of a row indexed by a vertex in Z y is even with probability1 / Y be the random variable equal tothe number of assignments that are contributing. Then, in expectation(8) E [ Y ] = (cid:88) y ∈ V \{ t } Pr q [ ε y ] . We can bound the expectation as
Lemma 8. E ( Y ) ∈ n − Ω ( nδ ) . Proof.
From Eq. 7 and Eq. 8 we have(9) E [ Y ] ≤ (cid:88) y ∈ V \{ t }| Z y | < τ (cid:88) y ∈ V \{ t }| Z y |≥ τ (cid:18) (cid:19) | Z y | k − (cid:88) i =0 (cid:18) | Z y | i (cid:19) . The left term in Eq. 9 is 2 n − τ τ/ − (cid:88) i =0 (cid:18) τi (cid:19) ∈ n − Ω( τ ) , and the right term in Eq. 9 is less than2 n (cid:32) τ/ k − (cid:88) i =0 (cid:18) τ / i (cid:19)(cid:33) ∈ n − Ω( τ ) , after remembering k < τ /
10 and τ = n δ , and noting that12 γ k − (cid:88) i =0 (cid:18) γi (cid:19) , for γ ∈ { τ / , · · · τ } is maximised for γ = τ /
3. The stated bound in the Lemma follows. (cid:3)
Listing Contributing Terms.
We finally describe how to list the contributing term assign-ments y : V \ { t } → { , } needed to compute P G ( z ) via Eq. 6 for a fixed q . The idea is to test foreach partial assignment y ∗ : T \ { t } → { , } with the interpretation that y v = y ∗ v for v ∈ T \ { t } ,and each way of assigning parities p : Z y ∗ → { , } to the diagonal entries of the vertices in Z y that is consistent with a not trivially zero assignment, i.e., p takes the value 0 on at most k − Z y describe a linear equation system over thevariables in y outside of T . The equation system E ( y ∗ , p ) consists of the equations (modulo two) (cid:88) wv ∈ A y w + q v = p v , for each v ∈ Z y , where we replace each variable y w with w ∈ T for its value y ∗ w . We can listall solutions to this equation system by Gaussian elimination. We first solve for one solution and a null space basis. We next can enumerate all solutions by taking all linear combinations of thenull space basis vectors with the solution. In summary our streaming procedure that generatesall contributing terms’ assignments is (we will think of it as a background process generating thesolutions one-by-one): ListingTerms (outputs contributing assignments y : V \ { t } → { , } needed for Eq. 6)(1) For each y ∗ : T \ { t } → { , } ,(2) For each p : Z y ∗ → { , } with | p | > | Z y ∗ | − k ,(3) Report every solution y to E ( y ∗ , p ).Note that this lists every contributing term’s assignment once since each y has precisely onerestriction y ∗ on T and matches one of the tested p ’s. To bound the running time, we know fromLemma 8 that the output number of y assignments are at most 2 n − Ω( nδ ) in expectation. Thisdominates the running time, since the number of equation systems considered, each of which canbe solved in polynomial time in the sense of providing a parameterisation of the solution space asone solution vector along with the null space, is at most 3 τ ∈ O ( n/δ ) .2.8. High-Level Algorithm.
Putting the parts of the previous sections together, we are readyto give the high-level description of our algorithm in Theorem 1 as
DecideHamiltonicity (answers whether input G in has a Hamiltonian cycle)(1) Repeat for 100 log n times:(2) Call SamplePoint to obtain point z and subset T .(3) Pick a q uniformly at random.(4) While there are still contributing terms:(5) Get next y from background process ListingTerms .(6) If the number of generated terms is too big, continue to next outer repetition.(7) Add y ’s contribution to P G ( z ).(8) If P G ( z ) (cid:54) = 0 break and output “Yes”.(9) Output “No”.In particular, there is no need to store the list of y assignments explicitly, but rather we use themone by one as they are generated to update the sum in Eq. 6. From Lemma 6 we know that a falsenegative happens with probability 1 − / n sample points z , independentlyof each other, we will be unsuccessful in all of them with probability (1 − /
100 log n < n − .From Section 2.7 we know the number of contributing term assignments and the running timeof ListingTerms is 2 n − Ω( nδ ) in expectation. If the number of generated terms are more than n times the expected value, we abort this z, T, q -value repetition at step 6 of the algorithm. This alsohappens only with probability n − by Markov’s inequality. Altogether, the probability of a falsenegative is at most n . This concludes the proof of Theorem 1. Acknowledgements
We are very grateful to an anonymous reviewer who pointed out a serious flaw in an earlier proofattempt of Lemma 6.
References [1] A. I. Barvinok. Two algorithmic results for the traveling salesman problem.
Math. Oper. Res. , 21(1):65–84, 1996.[2] E. T. Bax. Inclusion and exclusion algorithm for the hamiltonian path problem.
Inf. Process. Lett. , 47(4):203–207,1993.[3] R. Bellman. Dynamic programming treatment of the travelling salesman problem.
J. ACM , 9(1):61–63, Jan.1962.[4] A. Bj¨orklund. Determinant sums for undirected hamiltonicity.
SIAM J. Comput. , 43(1):280–299, 2014. [5] A. Bj¨orklund. Exploiting sparsity for bipartite hamiltonicity. In W. Hsu, D. Lee, and C. Liao, editors, , volume 123 of LIPIcs , pages 3:1–3:11. Schloss Dagstuhl - Leibniz-Zentrum f¨ur Informatik, 2018.[6] A. Bj¨orklund, H. Dell, and T. Husfeldt. The parity of set systems under random restrictions with applicationsto exponential time problems. In M. M. Halld´orsson, K. Iwama, N. Kobayashi, and B. Speckmann, editors,
Automata, Languages, and Programming - 42nd International Colloquium, ICALP 2015, Kyoto, Japan, July6-10, 2015, Proceedings, Part I , volume 9134 of
Lecture Notes in Computer Science , pages 231–242. Springer,2015.[7] A. Bj¨orklund and T. Husfeldt. The parity of directed hamiltonian cycles. In , pages 727–735, 2013.[8] A. Bj¨orklund, T. Husfeldt, P. Kaski, and M. Koivisto. The traveling salesman problem in bounded degree graphs.
ACM Trans. Algorithms , 8(2):18:1–18:13, 2012.[9] A. Bj¨orklund, P. Kaski, and I. Koutis. Directed hamiltonicity and out-branchings via generalized laplacians. InI. Chatzigiannakis, P. Indyk, F. Kuhn, and A. Muscholl, editors, , volume 80 of
LIPIcs , pages91:1–91:14. Schloss Dagstuhl - Leibniz-Zentrum f¨ur Informatik, 2017.[10] A. Bj¨orklund, P. Kaski, and R. Williams. Generalized kakeya sets for polynomial evaluation and faster compu-tation of fermionants.
Algorithmica , 81(10):4010–4028, 2019.[11] A. Bj¨orklund and R. Williams. Computing permanents and counting hamiltonian cycles by listing dissimilarvectors. In C. Baier, I. Chatzigiannakis, P. Flocchini, and S. Leonardi, editors, , volume 132 of
LIPIcs ,pages 25:1–25:14. Schloss Dagstuhl - Leibniz-Zentrum f¨ur Informatik, 2019.[12] M. Cygan, S. Kratsch, and J. Nederlof. Fast hamiltonicity checking via bases of perfect matchings.
J. ACM ,65(3):12:1–12:46, 2018.[13] M. Held and R. M. Karp. A dynamic programming approach to sequencing problems.
Journal for the Societyfor Industrial and Applied Mathematics , pages 1–10, 1962.[14] E. Kaltofen. On computing determinants of matrices without divisions. In P. S. Wang, editor,
Proceedings of the1992 International Symposium on Symbolic and Algebraic Computation, ISSAC ’92, Berkeley, CA, USA, July27-29, 1992 , pages 342–349. ACM, 1992.[15] R. M. Karp. Reducibility among combinatorial problems. In R. E. Miller and J. W. Thatcher, editors,
Proceedingsof a symposium on the Complexity of Computer Computations, held March 20-22, 1972, at the IBM Thomas J.Watson Research Center, Yorktown Heights, New York, USA , The IBM Research Symposia Series, pages 85–103.Plenum Press, New York, 1972.[16] R. M. Karp. Dynamic programming meets the principle of inclusion and exclusion.
Operations Research Letters ,1(2):49 – 51, 1982.[17] S. Kohn, A. Gottlieb, and M. Kohn. A generating function approach to the traveling salesman problem. In
Proceedings of the 1977 Annual Conference , ACM ’77, page 294300. Association for Computing Machinery,1977.[18] L. Kowalik and K. Majewski. The asymmetric travelling salesman problem in sparse digraphs. arXiv:2007.12120.To appear in IPEC’20 , 2020.[19] K. Mulmuley, U. V. Vazirani, and V. V. Vazirani. Matching is as easy as matrix inversion.
Combinatorica ,7(1):105–113, 1987.[20] W. T. Tutte. The dissection of equilateral triangles into equilateral triangles.
Mathematical Proceedings of theCambridge Philosophical Society , 44(4):463–482, 1948.[21] R. Williams. A new algorithm for optimal constraint satisfaction and its implications. In J. D´ıaz, J. Karhum¨aki,A. Lepist¨o, and D. Sannella, editors,
Automata, Languages and Programming: 31st International Colloquium,ICALP 2004, Turku, Finland, July 12-16, 2004. Proceedings , volume 3142 of