1 Introduction
A Hamilton cycle in a graph is a cycle that visits every vertex exactly ones. We say that a graph is Hamiltonian if it contains a Hamilton cycle. The Hamilton cycle problem, which we denoted by HAM, asks to determines whether a given graph has a Hamilton cycle; it belongs to the list of Karp’s 21 NP-complete problems [13] and if then there does not exist an algorithm that determines the Hamiltonicity of in time for every graph on vertices. The fastest deterministic algorithm known today that solves HAM is the Held–Karp algorithm, also called Bellman–Held–Karp algorithm [6],[12]; it is a dynamic programming algorithm with worst-case time complexity time and worst-case space complexity .
In [11], Gurevich and Shelah gave an algorithm that determines the Hamiltonicity of an -vertex graph in polynomial time on average. Equivalently, as is the uniform measure over all graph on vertices, the expected running time of their algorithm over the input distribution is polynomial in when . The last statement raises the question for which values of there exists an algorithm that solves HAM in polynomial expected running time over the input distribution . Gurevich and Shelah [11], Thomason [18] and Alon and Krivelevich [1] gave such an algorithm for being constant, and respectively.
In this paper we introduce CertifyHAM, a deterministic algorithm that solves HAM. Our main result is the following.
Theorem 1.1.
CertifyHAM solves HAM in expected running time over the input distribution for .
In the above Theorem we assume that we are given , the adjacency matrix of , and that each entry of can be accessed in time. Observe that any algorithm that solves HAM has to identify at least edges of ; hence w.h.p.111We say that a sequence of events holds with high probability (w.h.p. in short) if
One of the most interesting figures of Theorem 1.1 is that it can also deal with below the Hamiltonicity threshold. A cerebrated result of Bollobás [8] and of Komlós and Szemerédi [14] state that the threshold for Hamiltonicity is the same as the threshold for minimum degree 2 in the model and it is equal to . For a complete survey on the Hamilton Cycles in random graphs see [10].
Theorem 1.1 falls into the area of average-case analysis of algorithms. For a complete survey on this area see [7]. It is motivated by the idea that the worst-time complexity of an algorithm is usually based on some well orchestrated instance and such instances are atypical. Thus the average time complexity may be a better measure of the performance of an algorithm. In addition using algorithms that run fast on average is one way to cope with NP-hard problems.
A distributional problem is a pair where is a decision problem and where
is a probability distribution on the inputs of
of size . We say that a distributional problem belongs to if there exists an algorithm (with running time for an instance of ), a constant and a polynomial with the property thatLet . Theorem 1.1 and the upper bound on given in Lemma 2.9, give the following.
Corollary 1.2.
belongs to for all .
1.1 Description of CertifyHAM
CertifyHAM impliments 2 algorithms. First it implements CerHam1. CerHam1 solves with input in time with probability . In addition, if then CerHam1 returns “ in not Hamiltonian”. If CerHam1 fails to solve HAM for a given instance then CertifyHAM implements CerHam2 whose expected run time of CerHam2 is . For an instance denote by and the running time with input of CerHam1, CerHam2 and CertifyHam respectively. Then, for ,
The description of CerHam1 is given in [4]. In this paper we introduce and analyse CerHam2.
CerHam2 takes as an input a graph and starts by querying a number of edges of . By querying an edge of we refer to reading the corresponding entry of the adjacency matrix of . When we consider that initially all of the entries of are blank. Once we query an edge of we reveal whether the edge belongs to , equivalently whether the corresponding entry of is filled with 0 or 1. As the corresponding entry is equal to 1 independently of all the entries that we have revealed so far.
Once CerHam2 has made its initial queries it proceeds and iterates over a while loop. Each iteration starts with a full path packing of and a set . A full path packing of is a set of vertex disjoint paths in that cover . Here we consider single vertices to be paths of length 0. Thus has at least 1 full path packing, namely the one that consists of the paths of length 0. Then the algorithm adds to a set of edges that join the paths in into a Hamilton path. It continues by performing sequences of restricted Pósa rotations, defined in Section 2, and identifies sets , such that for every and there exists a Hamilton path in from to . Now either (I) all of the sets are large or (II) at least one of them is small. In the first case it identifies and queries an edge with and that has not been queried yet. If then it updates to a full path packing of size 1 less or claims that is Hamiltonian; in such a case we say it improves on . In the unlikely event that (II) occurs and one of the sets , is small then it adds this set to , along with possibly some other sets. It then attempts to pack paths in such that every vertex in is in the interior of some path. If no such path packing exists then it outputs “ is not Hamiltonian”. If such a path packing does exists then it adjust such that it contains as a subset. The algorithm exits the while-loop if gets too large or too many attempts to improve have been taken place. In the unlikely event that the CerHam2 exits its while loop it implements the Held-Karp algorithm.
The rest of the paper is organised as follows. In Section 2 we present the tools needed for the presentation and analysis of CerHam2. We then present and analyse CerHam2 in Section 3. Its analysis is split into 3 cases corresponding to the regimes , and respectively. For ease of the presentation of the paper we have moved the proofs of technical results to the Appendix.
2 Preliminaries
2.1 Restricted Pósa Rotations
Given a Hamilton path and , we say that the path is obtained from via a Pósa rotation that fixes . We call and the pivot vertex and the new endpoint respectively. We call and the inserted and the deleted edge respectively. We will not perform all Pósa rotations possible. Instead we will only perform Pósa rotations for which the pivot vertex does not belong to some prescribed set . The exact procedure which we call follows shortly. It takes as an input a graph , a Hamilton path of with endpoints and a set not containing . It then outputs sets and such that for each there exists a Hamilton path in from to .
As every vertex enters at most once the set , both have size at most throughout the above algorithm which runs in time.
We replace the classical Pósa Lemma with the first part of the following one.
Lemma 2.1.
Let be a graph, , a Hamiltonian path of with endpoints and . Then,
Proof.
Let be the vertices in in the order that are added to and be the corresponding Hamiltonian paths. Let and for , where is the deleted edge in the Pósa rotation that results to the Hamilton path for and is the vertex preceding on for .
Now let and . If a Pósa rotation occurs with being the deleted edge then for some . Else the vertex that succeeds on is for some . In this case let be the sequence of paths in that correspond to the Pósa rotations that transform to . Then at every path of this sequence an edge incident to is either equal to or is an inserting edge. In both cases, both of the endpoints of belong to hence . Therefore and
∎
The key advantage of performing restricted Pósa rotations as opposed to normal Pósa rotations is given by the following observation.
Observation 2.2.
If and then and are disjoint. Indeed . Thereafter for a vertex only a Pósa rotation with a pivot vertex in may result to a path with as an endpoint. As for we have that no vertex in ever enters .
Observation 2.3.
If then the set is connected in .
We use as a subroutine in the algorithm stated below. takes as an input a full path packing . It then performs and outputs sets , and a set of full path packings with the following property. For and there exists a full path packing of size at most with the property that adding to creates a Hamilton cycle if or joints two paths in and creates a full path packing of size at most .
calls O(n) times, hence its running time is .
2.2 Covering non-expanding sets
In this subsection we introduce which is the subroutine that we will use to deal with “problematic sets”. These sets will be non (sufficiently) expanding and will contain small sets outputted by . takes as an input a graph , a set of size less than and a full path packing and tries to adjust so that every vertex in is found in the interior of some path in . It starts by implementing the Held-Karp algorithm to find a path packing that covers . It then adjusts so that it contains .
The correctness of line 4 of the above algorithm is given by the following Lemma.
Lemma 2.4.
Let and be such that and each vertex in has the same neighborhood in both and . Then if CoverAndAdjust() outputs “ is not Hamiltonian” then is not Hamiltonian.
Proof.
Assume that has a Hamilton cycle and let be an arbitrary component of . Then, as the edges of incident to induce a path packing that cover such that the endpoints of lie in for . As each vertex in has the same neighborhood in both and these paths are present in , hence in . Finally as every pair of vertices in forms an edge in the paths can be used to form a Hamilton cycle in . Thus CoverAndAdjust() does not outputs “ is not Hamiltonian”. ∎
Observation 2.5.
After the execution of may increase by at most . This is because the “new” paths cover at most vertices and for each vertex covered by a new path at most 2 edges may be deleted at line 6.
The running time of ) is dominated by the application of Held-Karp algorithm and it is where is the size of the largest component of the subgraph of induced by .
2.3 A Family of Pseudorandom Graphs
Initially CerHam2 queries the edges of that belong to some graph . is constructed by taking a -regular pseudorandom graph on at least and at most vertices, then taking the subgraph of induced by a subset of of size and finally adding a number of edges incident to vertices of small degree. The construction of as well as the proof of the Lemma that follows is given in Appendix A.
Lemma 2.6.
For significantly large there exists a graph on that can be constructed in time and satisfies the following.
-
For every pair of disjoint sets the number of edges spanned by is at least and at most
-
has minimum degree .
-
At most vertices in have degree larger than in .
2.4 A coloring process
For a graph we let be the graph on with edge set . At the regimes where we first implement the following red/blue/black coloring coloring procedure: Initially all the vertices of are coloured black. While there exists a blue or black vertex with at most black neighbors in recolor red and the black neighbors of blue.
We denote by , and the sets of vertices that their final color given by the above procedure is red, blue and black respectively. A standard argument shows that , and do not depend on the order in which the vertices are being processed (see [3]). Observe that every vertex in both and has at least neighbors in . The motivation of the above procedure is to separate the sparse (red) portion of the graph from the dense one (black) by a cut (blue) while ensuring that the vertices in the cut are robustly connected to the dense part. In our analysis, for the sparse regimes, we use this decomposition and take advantage of the following observation and lemma. For the proof of Lemma 2.8 see Appendix A.
Observation 2.7.
During the above coloring process every time a vertex is colored red at most 5 other vertices are colored blue. Thus, for every component of the subgraph of induced by we have that .
Lemma 2.8.
Let and . For define the following events,
there exists a set of size at most with the property | |||
and
there exists a set of size at most and a subgraph of | |||
Then, for , and the following hold.
(1) |
(2) |
2.5 Minimum degree 2
De facto if does not have minimum degree 2 then is not Hamiltonian. Such a feature can be detected in time. In the event that we can initiate CerHam2 by implementing an algorithm for prepossessing that runs in time inversely proportional to . Thus it becomes crucial to upper bound . This is done in the following Lemma. Its proof can be found at Appendix A.
Lemma 2.9.
Let and . Then,
(3) |
3 Certifying Hamiltonicity
CerHam2 takes as input a graph on and two sets . It also utilizes the graph whose construction is given in Appendix A. Throughout its execution consists of the edges of that have been queried so far and is the subgraph of with edge set the edges in that belong to .
For the correctness of CerHam2 one has to verify the correctness of lines 9 and 12. If CerHam2 outputs “ is not Hamiltonian” at line 9 then this statement is indeed true due to Lemma 2.4; here we are using that we reveal all the edges in incident to at line 8 and hence the edge sets incident to in and are identical. For line 12 recall that Observation 2.2 implies that at every iteration of the while-loop the sets and disjoint from . In addition observe that is an upper bound on the number of edges in not incident to . Furthermore Lemma 2.6 states that at most vertices have degree larger than in . Therefore if the algorithm proceeds to line 12 then the set contains at least edges and the corresponding choice of and is possible.
Let for . The following lemma upper bounds the number of edges in we need to identify at line 13. We later use Lemma 3.1 to upper bound the probability that at the end of the while-loop. For let if the time line 13 is executed an edge in is identified.
Lemma 3.1.
For we have,
(4) |
Furthermore,
(5) |
In addition, if then for ,
(6) |
Finally, if CerHam2 exits the while-loop and then,
(7) |
Proof.
Let and let be the sets added to , due to lines 6 and 7, in the order that they were added, to form . As throughout the algorithm is a supergraph of , with , we have,
For the proof of (6) we repeat the above argument with being the sets added to to form .
Now observe that due to line 7 of the algorithm we have that . Therefore,
for . Hence .
If CerHam2 exits the while-loop and then the line 14 has been executed times. Say if a Hamilton cycle has been constructed. The time line 9 is executed the number of paths in may be increased by at most (see Observation 2.5). On the other hand implies a decrease in the time line 13 is executed. If CerHam2 exits the while-loop then throughout the algorithm and as initially we have,
∎
3.1 The upper range
Let and . We execute CerHam2() with . For the analysis of this regime we define the following events.
and
Lemma 3.2.
If
(8) |
then the expected running time of CerHam2 is .
Proof.
Lemma 3.1 implies that and therefore CerHam2 may execute at most times line 4. Each execution of line 4 runs in time; hence line 4 takes in total time. This is also the running time of CerHam2 in the event that it never proceeds to line 6 and it does not exit the while-loop.
In the event the algorithm may exit the while loop. Before exiting the while loop it may reach line 5 at most times, each time spending at most time at lines 5 to 9. After exiting the while-loop it executes Held-Karp whose complexity is . Thus, in the event CerHam2 runs in time.
On the other hand, if none of , occurs then for and . The inequality follows from the fact that while the algorithm will not search for larger sets to add to at line 7 and it will never add to it a set of size larger than at line 6. Thus if a set is added by CerHam to then and . In addition, by Lemma 3.1, and hence and and as does not occur we have that
Thus, if none of , occurs and we let then and the event occurs. In the event CerHam2 may execute lines 6-10 at most times each running in time yielding a total running time for lines 6-10 of .
Equation (8) follows from the fact that at least one of the events occurs. ∎
Lemma 3.3.
Equation (8) holds.
Proof.
In the event we can find disjoint sets of size and such that no edge from to belongs to . Thus,
In the event (7) implies that . For , with probability independently of . Thus,
Finally, for , in the event