1 Introduction

A classical fact published by Tutte [26] and accredited to Smith states that, in a cubic (i.e. degree-3 regular) graph, every edge is contained in an even number of Hamiltonian cycles. The theorem of Smith was later generalized by Thomason [22] to all graphs in which every vertex has an odd degree. Therefore, every Hamiltonian graph with odd-degree vertices has at least one further Hamiltonian cycle; actually it is not hard to derive that also a third Hamiltonian cycle exists. However, if we allow vertices of even degree, the existence of a second Hamiltonian cycle is not guaranteed. More specifically, Entringer and Swart [13] constructed uniquely Hamiltonian graphs (i.e. graphs with a unique Hamiltonian cycle), in which all vertices have degree 3, except only two of them which have degree 4. Fleischner [15] also constructed two infinite families of uniquely Hamiltonian graphs, one with minimum degree 4 and maximum degree 14, and one with arbitrarily high maximum degree.

On the other hand, for regular graphs it is known that uniquely Hamiltonian graphs cannot have high degree. More specifically, Thomassen [25] proved that, for every \(r \ge 300\), every Hamiltonian r-regular graph has a second Hamiltonian cycle. This was subsequently improved to every \(r \ge 23\) [17]. It still remains unknown whether every r-regular Hamiltonian graph has a second Hamiltonian cycle, where \(4\le r \le 22\) is an even number. Sheehan conjectured in 1975 that this is true for \(r=4\) [21]. If Sheehan’s conjecture is true, then this will imply that, for every \(r\ge 3\), every r-regular Hamiltonian graph has a second Hamiltonian cycle. For non-regular graphs, it is known that a second Hamiltonian cycle is guaranteed to exist also in graphs with large minimum degree. Bondy and Jackson proved this for graphs with n vertices and minimum degree at least \(2.41 \log 8n +3\) [8].Footnote 1 This bound was later improved to \(1.752 \log n\) [17] and to \(1.71 \log n +2\) [1]. All the above results have been proved with the probabilistic method using non-constructive arguments.

Our focus in this paper is to devise algorithms which, given a graph G and a Hamiltonian cycle C of G, actually compute a second Hamiltonian cycle \(C^{\prime }\ne C\) in G, instead of just proving the existence of \(C^{\prime }\). For cubic (or, more generally, for odd-degree) Hamiltonian graphs, several exponential-time algorithms are known for computing \(C^{\prime }\) [3,4,5,6,7, 10,11,12, 14, 18, 19, 28]; however, it remains open whether \(C^{\prime }\) can be computed in polynomial, or even subexponential time. One possible relaxation of the problem is, given a Hamiltonian cycle C, to efficiently compute a second cycle \(C^{\prime }\ne C\) which is large enough (not necessarily Hamiltonian). For cubic Hamiltonian graphs, Bazgan et al. [2] showed that the knowledge of the first Hamiltonian cycle C algorithmically strictly helps to approximate the length of a second cycle. In fact, if C is not given along with the input, there is no polynomial-time constant-factor approximation algorithm for finding a long cycle in cubic graphs, unless P \(=\) NP. In contrast, if C is given, then for every \(\varepsilon >0\) a cycle \(C^{\prime } \ne C\) of length at least \((1-\varepsilon )n\) can be found in \(2^{O(1/\varepsilon ^2)}\cdot n\) time, i.e. there is a linear-time PTAS for approximating the second Hamiltonian cycle [2]. The main ingredient in the proof of the latter result is an \(O(n^{\frac{3}{2}} \log n)\)-time algorithm which, given G and C, computes a cycle \(C^{\prime } \ne C\) of length at least \(n-4\sqrt{n}\) [2]. In wide contrast to cubic graphs, for graphs of minimum degree at least three, only existential proofs are known for a second large cycle. In particular, Girão et al. [16] recently proved with a non-constructive argument that any n-vertex Hamiltonian graph with minimum degree at least 3 contains another cycle of length at least \(n - o(n)\).

Our Contribution In this paper we consider two relaxations of the problem of computing a second Hamiltonian cycle. First, we consider approximating the length of a second cycle on n-vertex graphs with minimum degree \(\delta \) and maximum degree \(\Delta \). We provide in Sect. 2 a linear-time algorithm for computing a cycle \(C^{\prime } \ne C\) of length at least \(n-4a(\sqrt{n}+2\alpha )+8\), where \(\alpha = \frac{\Delta -2}{\delta -2}\). On the one hand, this improves the results of Bazgan et al. [2] in two ways: (1) it provides a generalization from cubic Hamiltonian graphs to arbitrary Hamiltonian graphs of degree at least 3; (2) our algorithm works in linear time in n for all constant-degree regular graphs. In particular it works in time O(n) on cubic graphs (see Corollary 6). On the other hand, we complement the results of [16] as we provide a constructive proof for their result in case where \(\delta \) and \(\Delta \) are \(o(\sqrt{n})\)-factor away from each other. Formally, our algorithm constructs in linear time another cycle of length \(n - o(n)\) whenever \(\frac{\Delta }{\delta } = o(\sqrt{n})\) (see Corollary 7).

Our second relaxation of the problem is probabilistic. We propose in Sect. 3 a randomized algorithm which computes a second Hamiltonian cycle with high probability, given that the input graph G has a large enough minimum degree. More specifically, we prove that for every \(0<p\le 0.02\), if the minimum degree of G is at least \(\frac{8}{p} \log \sqrt{8}n + 4\), then a second Hamiltonian cycle can be computed with probability at least \(1 - \frac{1}{n}\left( \frac{50}{p^4} + 1 \right) \) in \(poly(n) \cdot 2^{4pn}\) time. Thus, by appropriately choosing the value of the parameter p, we can achieve different trade-offs between the minimum degree and the resulting running time, as it is illustrated in Table 1 (see Corollary 15). These results imply that, when the minimum degree \(\delta \) is sufficiently large, we can compute with high probability a second Hamiltonian cycle faster than any known deterministic algorithm. In particular, when \(\delta = \omega (\log n)\), our probabilistic algorithm works in \(2^{o(n)}\) time.

Table 1 Summary of our probabilistic results for computing a second Hamiltonian cycle in a Hamiltonian graph of large minimum degree \(\delta \), where c is a constant and \(\varepsilon \in (0,0.25)\)

2 Computing Another Long Cycle in a Hamiltonian Graph in Linear Time

Since the complexity status of finding a second Hamiltonian cycle in a given cubic Hamiltonian graph is illusive at the moment, we consider a simpler problem of finding another almost Hamiltonian cycle in a given Hamiltonian graph of minimum degree 3. Our main result in this section provides a O(m) time algorithm for finding a \(n - o(n)\) cycle in a given Hamiltonian graph of minimum degree at least 3 when the maximum and the minimum degrees of the graph are in certain relation.

Bazgan et al. [2] studied an optimization problem that can be seen as a relaxation of the problem of finding another Hamiltonian cycle in a cubic Hamiltonian graph. Namely, they considered the following problem.

figure a

The authors showed that

figure b

has an efficient polynomial-time approximation scheme (EPTAS) by proving the following theorem; recall an EPTAS finds a \((1-\varepsilon )\)-approximate solution in time \(f(\frac{1}{\varepsilon })\cdot poly(n)\), where f is a computable function.

Theorem 1

([2]) Let G be an n-vertex cubic Hamiltonian graph and let C be a Hamiltonian cycle in G. Given G and C, for every \(\varepsilon > 0\), a cycle \(C^{\prime } \ne C\) of length at least \((1-\varepsilon )\cdot n\) can be found in time \(2^{O(1/\varepsilon ^2)} \cdot n\).

The main ingredient of the proof of Theorem 1 is a polynomial-time procedure that finds in G a cycle \(C^{\prime }\) different from C of length at least \(n - 4 \sqrt{n}\). This result is formalized in the following:

Theorem 2

([2]) Let G be an n-vertex cubic Hamiltonian graph and let C be a Hamiltonian cycle in G. There is an algorithm that given G and C finds in G a cycle \(C^{\prime } \ne C\) of length at least \(n - 4\sqrt{n}\) in time \(O(n^{3/2} \log {n})\).

Our main result of this section improves Theorem 2 in two ways. First, it implies a generalization of Theorem 2 to arbitrary regular Hamiltonian graphs of degree at least 3. Second, our algorithm works in linear time in n for constant degree regular graphs. In particular, it works in time O(n) on cubic graphs (see Corollary 6).

2.1 Notation and Auxiliary Results

Before we proceed to the main result of the section, we introduce preliminary notation and state auxiliary results. Let G be a graph with a designated Hamiltonian cycle \(C = v_1v_2 \ldots v_n\). We assume that the the cycle has a fixed, clockwise, direction. Any edge of G that is not in C is called a chord. Two chords are independent if they do not share an endpoint. The length of a chord \(v_iv_j\) with \(i < j\) is defined as \(\min \{ j-i, n+i-j \}\). We say that two vertices \(u,v \in V(G)\) are chord-adjacent if they are connected by a chord of G. Two independent chords \(e_1\) and \(e_2\) are called crossing if their endpoints appear in alternating order around C; otherwise \(e_1\) and \(e_2\) are parallel.

Fig. 1
figure 1

Illustration of Lemma 4

For \(x,y \in V(G)\), we denote by \(d_C(x,y)\) the length of the path from x to y around C, using the clockwise direction. Note that \(d_C(x,y) \ne d_C(y,x)\) in general. We define the distance between two independent chords xy and ab, denoted \(dist (xy,ab)\), as follows:

  1. 1.

    if xy and ab are crossing, then \(dist (xy,ab) = \min \{ d_C(x,a) + d_C(y,b), d_C(x,b) + d_C(y,a) \}\);

  2. 2.

    if xy and ab are parallel such that neither y nor b lie on the path the path from x to a around C, then \(dist (xy,ab) = d_C(x,a) + d_C(y,b)\).

In the proof of our main result we use the following two lemmas. The first is a basic fact from graph theory and the second is straightforward to check (see Fig. 1 for illustration).

Lemma 3

([27], Exercise 3.1.29) Let \(G=(V,E)\) be a bipartite graph of maximum degree \(\Delta \). Then G has a matching of size at least \(\frac{|E|}{\Delta }\).

Lemma 4

Let \(G = (V,E)\) be an n-vertex graph with a Hamiltonian cycle \(C=v_1v_2 \ldots v_n\).

  1. (1)

    If G has a chord of length \(\ell \), then G contains a cycle \(C^{\prime } \ne C\) of length at least \(n-\ell +1\).

  2. (2)

    If G has two crossing chords \(e_1\), \(e_2\) and \(dist (e_1,e_2) = d\), then G contains a cycle \(C^{\prime } \ne C\) of length at least \(n-d+2\).

  3. (3)

    If G has four pairwise independent chords \(e_1\), \(e_2\), \(f_1\), and \(f_2\) such that

    1. (a)

      \(e_1\), \(e_2\) are parallel and \(f_1\), \(f_2\) are parallel,

    2. (b)

      \(e_i\) and \(f_j\) are crossing for every \(i,j \in \{1,2\}\),

    3. (c)

      \(dist (e_1,e_2) = d_1\) and \(dist (f_1,f_2) = d_2\),

    then G contains a cycle \(C^{\prime } \ne C\) of length at least \(n - d_1 - d_2 + 4\).

2.2 Long Cycles in Hamiltonian Graphs

Theorem 5

Let \(G = (V,E)\) be an n-vertex Hamiltonian graph of minimum degree \(\delta = \delta (G) \ge 3\). Let \(C=v_1v_2 \ldots v_n\) be a Hamiltonian cycle in G and let \(\Delta \) denote the maximum degree of G. Then G has a cycle \(C^{\prime } \ne C\) of length at least \(n-4\alpha (\sqrt{n} + 2\alpha )+8\), where \(\alpha = \frac{\Delta -2}{\delta -2}\). Moreover, given C a cycle \(C^{\prime }\) can be computed in O(m) time, where \(m = |E|\).

Proof

We start by showing the existence of the desired cycle \(C^{\prime }\).

Without loss of generality we assume that \(\alpha < \frac{\sqrt{n}}{2}\), as otherwise any cycle \(C^{\prime } \ne C\) in G satisfies the theorem.

Furthermore, we assume that the length of every chord in G is at least \(4 \alpha (\sqrt{n} + 2\alpha ) - 6\), as otherwise the existence of \(C^{\prime }\) follows from Lemma 4(1).

Let \(q = \alpha \sqrt{n}\).

We partition arbitrarily the vertices of the Hamiltonian cycle C into r consecutive intervals \(B_0, B_1, \ldots , B_{r-1}\), such that \(r \in \Big \{\Big \lfloor \frac{\sqrt{n}}{\alpha } \Big \rfloor , \Big \lfloor \frac{\sqrt{n}}{\alpha } \Big \rfloor + 1 \Big \}\) and \(\lfloor q \rfloor \le |B_i| \le \lfloor q \rfloor + 2\alpha ^2\) for every \(i \in \{ 0, 1, \ldots , r-1 \}\). It is a routine task to check that such a partition exists.

For every \(i \in \{ 0, 1, \ldots , r-1 \}\) we denote by \(W_i\) the set of vertices that are chord-adjacent to a vertex in \(B_i\) and by \(E_i\) we denote the set of chords that are incident with a vertex in \(B_i\). Furthermore, we denote by \(H_i\) the graph with vertex set \(B_i \cup W_i\) and the edges set \(E_i\). Since the length of every chord in G is at least \(4 \alpha (\sqrt{n} + 2\alpha ) - 6\), we observe that for every \(i \in \{ 0, 1, \ldots , r-1 \}\) set \(W_i\) is disjoint from \(B_{i-1} \cup B_i \cup B_{i+1}\) (where the arithmetic operations with indices are modulo r). The latter, in particular, implies that \(H_i\) is a bipartite graph with color classes \(B_i\) and \(W_i\).

We say that the intervals \(B_i\) and \(B_j\), where \(i \ne j\), are matched if there exist two independent chords such that each of them has one endpoint in \(B_i\) and the other endpoint in \(B_j\). We claim that every interval \(B_i\) is matched to another interval \(B_j\) for some \(j \in \{ 0, 1, \ldots , r-1 \} \setminus \{ i-1, i, i+1 \}\). Indeed, by Lemma 3, graph \(H_i\) has a matching \(M_i\) of size at least

$$\begin{aligned} \frac{\lfloor q \rfloor (\delta -2)}{\Delta -2} = \frac{\lfloor \alpha \sqrt{n} \rfloor }{\alpha }> \frac{\alpha \sqrt{n} - 1}{\alpha } \ge \sqrt{n} - 1 > \Big \lfloor \frac{\sqrt{n}}{\alpha } \Big \rfloor - 2 \ge r-3, \end{aligned}$$

and therefore, by the pigeonhole principle, there exists \(j \in \{ 0, 1, \ldots , r-1 \} \setminus \{ i-1, i, i+1 \}\) such that at least two edges in \(M_i\) have their endpoints in \(B_j\), meaning that \(B_i\) is matched to \(B_j\).

Let \(\sigma : \{ 0, 1, \ldots , r-1 \} \rightarrow \{ 0, 1, \ldots , r-1 \}\) be a function such that \(B_i\) is matched to \(B_{\sigma (i)}\), and denote by \(f_{i,1}\) and \(f_{i,2}\) some fixed pair of independent chords between \(B_i\) and \(B_{\sigma (i)}\). We observe that \(dist (f_{i,1}, f_{i,2}) \le 2 (\lfloor q \rfloor + 2\alpha ^2 - 1) \le 2\alpha (\sqrt{n} + 2\alpha ) - 2\), as the endpoints of \(f_{i,1}\) and \(f_{i,2}\) lie in the intervals \(B_i\) and \(B_{\sigma (i)}\) each of length at most \(\lfloor q \rfloor + 2\alpha ^2\).

Let now R be an auxiliary graph with a Hamiltonian cycle \(x_0x_1 \ldots x_{r-1}\) and the chord set being \(\{ x_i x_{\sigma (i)} : i = 0, 1, \ldots , r-1 \}\).

Let \(x_ix_j\) be a chord in R of the minimum length, where \(j = \sigma (i)\). Without loss of generality, we assume that \(i < j\) and \(j-i \le r+i-j\). Let \(x_k\) be a vertex of R such that \(i< k < j\) and let \(s = \sigma (k)\).

Since \(x_ix_j\) is of minimum length, the chords \(x_i x_j\) and \(x_k x_s\) are crossing, and hence each of \(f_{i,1}\) and \(f_{i,2}\) crosses both \(f_{k,1}\) and \(f_{k,2}\).

Finally, if \(f_{i,1}\), \(f_{i,2}\), or \(f_{k,1}\), \(f_{k,2}\), are crossing, then by Lemma 4(2) there exists a cycle \(C^{\prime } \ne C\) of length at least \(n-2\alpha (\sqrt{n} + 2\alpha )+4\). Otherwise, \(f_{i,1}, f_{i,2}\) are parallel and \(f_{k,1}, f_{k,2}\) are parallel, and hence by Lemma 4(3) there exists a cycle \(C^{\prime } \ne C\) of length at least \(n-4\alpha (\sqrt{n} + 2\alpha )+8\), which proves the first part of the theorem.

The above proof is constructive. We now explain at a high level how the proof can be turned into the desired algorithm. First, if \(\alpha \ge \frac{\sqrt{n}}{2}\), then we output any cycle formed by a chord and the longer path of C connecting the endpoints of the chord. Otherwise, we partition the vertices of C into intervals \(B_0, B_1, \ldots , B_{r-1}\) and assign to each vertex the index of its interval. Clearly, this can be done in O(n) time. Next, we traverse the vertices of G along the cycle C and for every vertex v of an interval \(B_i\) we check the chords incident to v. If we encounter a chord f of length less than \(4 \alpha (\sqrt{n} + 2\alpha ) - 6\), then we output the cycle formed by f and the longer path of C connecting the endpoints of f. Otherwise, for the interval \(B_i\) we keep the information of how many and which vertices of \(W_i\) belong to other intervals \(B_j\) for \(j \in \{ 0, 1, \ldots , r-1 \} \setminus \{ i-1, i, i+1 \}\). When we find an interval \(B_j\) that has at least two elements from \(W_i\), we set \(\sigma (i)\) to j and proceed to the first vertex of the next interval \(B_{i+1}\). By doing this, we also keep the information of the current shortest chord in the graph R (defined in the proof above). After finishing this procedure: (1) we have a function \(\sigma (\cdot )\); (2) for every \(i \in \{ 0, 1, \ldots , r-1 \}\) we know a pair \(f_{i,1}\), \(f_{i,2}\) of independent edges between \(B_i\) and \(B_{\sigma (i)}\); and (3) we know k such that \(x_kx_{\sigma (k)}\) is a minimum length chord in R. Clearly, this information is enough to identify the desired cycle in constant time. In total, we spent O(n) time to compute the partition of the vertices into the intervals and we visited every chord at most twice, which implies the claimed O(m) running time. \(\square \)

By noticing that in the above theorem parameter \(\alpha \) is equal to 1 for any regular graph, we obtain the following corollary.

Corollary 6

Let \(G = (V,E)\) be an n-vertex Hamiltonian \(\delta \)-regular graph with \(\delta \ge 3\), and let C be a Hamiltonian cycle in G. Then G has a cycle \(C^{\prime } \ne C\) of length at least \(n - 4\sqrt{n}\), which can be computed in \(O(\delta n)\) time.

Corollary 7

Let \(G = (V,E)\) be an n-vertex Hamiltonian graph of minimum degree \(\delta = \delta (G) \ge 3\). Let C be a Hamiltonian cycle in G and let \(\Delta \) denote the maximum degree of G. If \(\frac{\Delta }{\delta } = o(\sqrt{n})\), then G has a cycle \(C^{\prime } \ne C\) of length at least \(n-o(n)\), which can be computed in O(m) time.

3 Second Hamiltonian Cycle in Graphs of Large Minimum Degree

In this section we provide an algorithm (see Theorem 14) which, given a Hamiltonian cycle C in an arbitrary Hamiltonian graph G with n vertices and with large minimum degree \(\delta =\Omega (\log n)\), computes a second Hamiltonian cycle \(C^{\prime }\ne C\) faster than the best known algorithms (cf. the discussion in the Introduction).

3.1 Second Hamiltonian Cycle via Red-Independent and Green-Dominating Sets

Let G be a graph with a Hamiltonian cycle C. Colour the edges of C red and the chords green. A neighbor u of a vertex v is a red (resp. green) neighbor of v if uv is a red (resp. green) edge. A set X of vertices of G is red-independent if the subgraph G[X] of G induced by X contains no red edges, and X is green-dominating if every vertex outside X is adjacent to a vertex in X via green edge. The following lemma is a classical result of Thomassen [24] proved via Thomason’s lollipop argument [23].

Lemma 8

(Thomassen’s lemma, [24]) If G has a red-independent and green-dominating set of vertices, then G contains a Hamiltonian cycle \(C^{\prime } \ne C\).

Motivated by Thomassen’s lemma, it is natural to ask whether the knowledge of a red-independent and green-dominating set X in G can improve the time complexity of finding a second Hamiltonian cycle. The proof of Lemma 8 is reduced to the application of Thomason’s lollipop argument and therefore does not immediately imply an efficient algorithm for finding a second Hamiltonian cycle; it is known that there exist cubic graphs where Thomason’s algorithm requires exponential time [9]. However, if X is not too large, it can in fact be used to speed up the computation of a second Hamiltonian cycle. To explain this, we need to state another lemma, which can be easily extracted from Thomassen’s proof. Following the terminology of Bondy and Jackson [8], a set of vertices X of G is weakly green-dominating if every red neighbor of a vertex in X is also a green neighbor of some vertex in X.

Lemma 9

([24]) If G has a red-independent and weakly green-dominating set of vertices, then G contains a Hamiltonian cycle \(C^{\prime } \ne C\).

Clearly, any green-dominating set X in G is also weakly green-dominating. Let X be a red-independent and green-dominating set of size k, and let \(P_1, P_2, \ldots , P_k\) be the k paths obtained from C by removing the vertices of X. Let \(G^{\prime }\) be the graph obtained from G by removing all chords connecting two vertices not in X and all chords connecting a vertex in X and an internal vertex of any of the paths \(P_1, P_2 \ldots , P_k\). Clearly, X is red-independent and weakly green-dominating in \(G^{\prime }\), and therefore, by Lemma 9, \(G^{\prime }\) contains a Hamiltonian cycle \(C^{\prime } \ne C\), which is also a Hamiltonian cycle in G.

A simple, but important observation is that all internal vertices of the paths \(P_1, P_2 \ldots , P_k\) have degree two in \(G^{\prime }\), and hence all edges incident with these vertices belong to every Hamiltonian cycle of \(G^{\prime }\). Note here that the extreme vertices of these paths \(P_1, P_2 \ldots , P_k\) might have a higher degree. Let H be the graph obtained from \(G^{\prime }\) by removing, for every path \(P \in \{P_1, P_2 \ldots , P_k\}\) with at least four vertices, all its internal vertices and adding one new vertex and two new edges connecting the new vertex with the endpoints of P. Then, there is an obvious bijection between the Hamiltonian cycles of \(G^{\prime }\) and the Hamiltonian cycles of H. Denote by \(C_H\) the Hamiltonian cycle of H corresponding to the Hamiltonian cycle C of \(G^{\prime }\). We observe that X is a red-independent and weakly green-dominating set (with respect to \(C_H\)) in H. Therefore, by Lemma 9, H contains a Hamiltonian cycle \(C_{H}^{\prime } \ne C_H\), which in turn corresponds to a cycle \(C^{\prime } \ne C\) of \(G^{\prime }\) and can be efficiently computed from \(C_H^{\prime }\). We call the graph H shrunken and observe that the number of vertices in H is at most \(k + 3k = 4k\). If k is small enough, then applying a best known algorithm A for finding a Hamiltonian cycle to every graph \(H-e\), where e is a red edge in H that is incident to a vertex in X, one can find a Hamiltonian cycle \(C_H^{\prime } \ne C_H\) in H, and therefore a Hamiltonian cycle \(C^{\prime } \ne C\) in G, faster than applying n times the best known algorithm A directly to G. The above implies the correctness and running time of Algorithm 1, which is formally given in Theorem 10.

Algorithm 1
figure c

Second Hamiltonian Cycle via red-independent and green-dominating set

Theorem 10

Let \(G=(V,E)\) be an n-vertex graph, let C be a Hamiltonian cycle in G, and let X be a red-independent and green-dominating set in G, where \(|X| = k\). Let A be an algorithm that, given an input n-vertex graph, computes a Hamiltonian cycle in time \(f_A(n)\). Then Algorithm 1 computes a second Hamiltonian cycle in time at most \(poly(n) \cdot f_A(4k)\).

Using the above approach, we develop in the subsequent sections a randomized algorithm that computes a second Hamiltonian cycle in Hamiltonian graphs of large minimum degree.

3.2 Finding Sparse Red-Independent Green-Dominating Sets in Graphs of Large Minimum Degree

In this section we give a procedure that with high probability produces a red-independent and green-dominating set in graphs of large minimum degree. The procedure is a generalization of a random process used by Bondy and Jackson [8] to show that every n-vertex Hamiltonian graph of minimum degree at least \(c \log n\), for some constant c and large enough n, has a red-independent and green-dominating set, and hence a second Hamiltonian cycle.

For convenience, we reuse most of the notation and terminology from [8]. Let \(G=(V,E)\), where \(V=\{ 0, 1, \ldots , n-1 \}\), be a graph on n vertices and let \(C = (0,1,2, \ldots , n-1,0)\) be a Hamiltonian cycle in G. Let \(p \in (0,1)\) be a fixed number. We define a random subset X of V by the following procedure:

For \(p = \frac{1}{2}\) this is exactly the procedure used by Bondy and Jackson [8] to show that if every vertex in G has degree at least \(c\log 8n + 4\), where \(c = (2 - \log 3)^{-1}\), then with non-zero probability the set X produced by the procedure is red-independent and green-dominating. This implies that any such graph contains at least one red-independent and green-dominating set and therefore contains a second Hamiltonian cycle.

We will generalize and complement the arguments of Bondy and Jackson to show that for any small enough p, if every vertex in G has degree at least \(\frac{8}{p} \log \sqrt{8}n + 4\), then, with high probability, X is red-independent and green-dominating and also has size at most pn. In Sect. 3.3, we will combine this result with the general approach from Sect. 3.1 to obtain faster exponential and subexponential algorithms that find a second Hamiltonian cycle in graphs of large minimum degree with high probability. We proceed with some notation and an auxiliary lemma.

Let \(d\in \mathbb {N}\). A k-part composition of d is an ordered k-tuple \((d_1, d_2, \ldots , d_k)\) of positive integers summing up to d. We call each \(d_i\) a part of this composition of the number d. Denote by C(kd) the set of all k-part compositions of d, in which \(d_i\ge 2\) for every \(i\in \{2,\ldots ,k-1\}\). We write

$$\begin{aligned} c(k,d) = |C(k,d)|\quad \text {and}\quad C(d) = \bigcup _{k \ge 1} C(k,d). \end{aligned}$$

Similarly, we denote by \(C^*(k,d)\) the set of all k-part compositions of d, in which \(d_i\ge 2\) for every i, except possibly at most one of the two parts \(d_1\) or \(d_k\). We write

$$\begin{aligned} c^*(k,d) = |C^*(k,d)|\quad \text {and}\quad C^*(d) = \bigcup _{k \ge 1} C^*(k,d). \end{aligned}$$

Lemma 11

Let \(k,d\in \mathbb {N}\) and \(\mu \in (0,2]\), and let \(\alpha = \frac{\sqrt{4\mu + 1} - 1}{2}\) and \(\beta = \frac{\sqrt{4\mu + 1} + 1}{2}\). Then

  1. (a)

    \(\sum \nolimits _{k \ge 1} \mu ^{k-1} \cdot c(k,d) = \frac{1}{\alpha +\beta } \big ( \beta ^{d+1} + (-1)^d \alpha ^{d+1} \big ) \le \left( \frac{\alpha + 4\beta }{4 (\alpha + \beta )} \right) \beta ^d\);

  2. (b)

    \(\sum \nolimits _{k \ge 1} \mu ^{k-1} \cdot c^*(k,d) = \beta ^{d-1} + (-1)^{d-1} \alpha ^{d-1} \le 2\beta ^{d-1}\),

Proof

In both cases we will count weighted compositions of d in which each composition into k parts is given weight \(\mu ^{k-1}\). This is done by assigning weight one to the first part \(d_1\) and weight \(\mu \) to each of the remaining parts. For a polynomial f(x) we denote by \([x^d]f(x)\) the coefficient of \(x^d\) in f(x). We will also make use of the following equation, which is a routine task to verify:

$$\begin{aligned} \begin{aligned}&[x^d](x + x^2 + \cdots ) \left( \sum \limits _{i \ge 0} (\mu x^2 + \mu x^3 + \cdots )^i \right) (\mu x + \mu x^2 + \cdots )\\&\quad = [x^d]\left( \frac{x}{1-x} \right) \left( \frac{1}{1-\frac{\mu x^2}{1-x}} \right) \left( \frac{\mu x}{1-x} \right) \\&\quad = [x^d]\frac{1}{\alpha + \beta } \left( \frac{\beta }{1 - \beta x} - \frac{\alpha + \beta }{1-x} + \frac{\alpha }{1+\alpha x} \right) \\&\quad = \frac{1}{\alpha + \beta } \left( \beta ^{d+1} - (\alpha + \beta ) + (-1)^d \alpha ^{d+1} \right) \\&\quad =\frac{1}{\alpha + \beta } \left( \beta ^{d+1} + (-1)^d \alpha ^{d+1} \right) - 1. \end{aligned} \end{aligned}$$
(1)

We proceed now by proving item (a).

$$\begin{aligned} \sum _{k \ge 1} \mu ^{k-1} \cdot c(k,d)&= 1 + \sum _{k \ge 2} \mu ^{k-1} c(k,d)\nonumber \\&= 1 + [x^d](x + x^2 + \cdots ) \left( \sum \limits _{i \ge 0} (\mu x^2 + \mu x^3 +\cdots )^i \right) \nonumber \\&(\mu x + \mu x^2 + \cdots ){\mathop {=}\limits ^{\small {(1)}}} \frac{1}{\alpha + \beta } \left( \beta ^{d+1} + (-1)^d \alpha ^{d+1} \right) . \end{aligned}$$
(2)

Now, since \(\mu \le 2\), we have \(\frac{\alpha }{\beta } \le \frac{1}{2}\), and therefore

$$\begin{aligned} \begin{aligned} \sum _{k \ge 1} \mu ^{k-1} \cdot c(k,d)&{\mathop {=}\limits ^{\small {(2)}}} \frac{1}{\alpha + \beta } \left( \beta ^{d+1} + (-1)^d \alpha ^{d+1} \right) \\&= \frac{1}{\alpha +\beta } \left( \beta + (-1)^d \alpha \left( \frac{\alpha }{\beta } \right) ^d \right) \beta ^d\\&\le \frac{1}{\alpha +\beta } \left( \beta + \frac{\alpha }{4} \right) \beta ^d = \left( \frac{\alpha + 4\beta }{4 (\alpha + \beta )} \right) \beta ^d . \end{aligned} \end{aligned}$$

To prove item (b) we first notice that by the inclusion–exclusion principle

$$\begin{aligned}{} & {} \sum \limits _{k \ge 1} \mu ^{k-1} \cdot c^*(k,d) = 1 + \sum \limits _{k \ge 2} \mu ^{k-1} \cdot \left( 2c^{\prime }(k,d) - c^{\prime \prime }(k,d)\right) = 1\nonumber \\{} & {} + 2\sum \limits _{k \ge 2} \mu ^{k-1} \cdot c^{\prime }(k,d)- \sum \limits _{k \ge 2} \mu ^{k-1} \cdot c^{\prime \prime }(k,d), \end{aligned}$$
(3)

where \(c^{\prime }(k,d)\) is the number of k-part compositions of d in which all parts are at least two, except possibly the first one; and \(c^{\prime \prime }(k,d)\) is the number of k-part compositions of d in which all parts are at least two. Now,

$$\begin{aligned} \sum \limits _{k \ge 2}&\mu ^{k-1} \cdot c^{\prime }(k,d)\nonumber \\&= [x^d](x + x^2 + \cdots ) \left( \sum \limits _{i \ge 0} (\mu x^2 + \mu x^3 + \cdots )^i \right) (\mu x^2 + \mu x^3 + \cdots )\nonumber \\&= [x^{d-1}](x + x^2 + \cdots ) \left( \sum \limits _{i \ge 0} (\mu x^2 + \mu x^3 + \cdots )^i \right) (\mu x + \mu x^2 + \cdots )\nonumber \\&{\mathop {=}\limits ^{\small {(1)}}} \frac{1}{\alpha + \beta } \left( \beta ^{d} + (-1)^{d-1} \alpha ^{d} \right) - 1. \end{aligned}$$
(4)

Similarly,

$$\begin{aligned} \sum \limits _{k \ge 2}&\mu ^{k-1} \cdot c^{\prime \prime }(k,d)\nonumber \\&= [x^d](x^2 + x^3 + \cdots ) \left( \sum \limits _{i \ge 0} (\mu x^2 + \mu x^3 + \cdots )^i \right) (\mu x^2 + \mu x^3 + \cdots )\nonumber \\&= [x^{d-2}](x + x^2 + \cdots ) \left( \sum \limits _{i \ge 0} (\mu x^2 + \mu x^3 + \cdots )^i \right) (\mu x + \mu x^2 + \cdots )\nonumber \\&{\mathop {=}\limits ^{\small {(1)}}} \frac{1}{\alpha + \beta } \left( \beta ^{d-1} + (-1)^{d-2} \alpha ^{d-1} \right) - 1. \end{aligned}$$
(5)

Plugging in (4) and (5)–(3) and using the fact that \(-2\beta + 1 = -(2\alpha + 1) = -(\alpha +\beta )\) we obtain

$$\begin{aligned} \sum \limits _{k \ge 1}&\mu ^{k-1} \cdot c^*(k,d) \\&= 1 + \frac{2}{\alpha + \beta } \left( \beta ^{d} + (-1)^{d-1} \alpha ^{d} \right) - 2 - \frac{1}{\alpha + \beta } \left( \beta ^{d-1} + (-1)^{d-2} \alpha ^{d-1} \right) + 1 \\&= \frac{1}{\alpha + \beta } \left( 2\beta ^{d} + 2(-1)^{d-1} \alpha ^{d} - \beta ^{d-1} + (-1)^{d-1} \alpha ^{d-1}\right) \\&= \frac{1}{\alpha + \beta } \left( (-1)^{d-1} \alpha ^{d-1} (2\alpha + 1) - \beta ^{d-1} (-2\beta + 1) \right) \\&= \beta ^{d-1} + (-1)^{d-1} \alpha ^{d-1}\\&\le \beta ^{d-1} + \alpha ^{d-1} \le 2\beta ^{d-1}, \end{aligned}$$

where in the latter inequality we used the fact that \(\alpha \le \beta \). \(\square \)

Green-Dominating Clearly, the set X produced by Algorithm 2 is always red-independent. We show next that, if the minimum degree of G is large enough, then X is also green-dominating with high probability.

Lemma 12

Let \(p \in (0, 0.2]\). If every vertex in G has degree at least \(\frac{8}{p} \log \sqrt{8}n + 4\), then the set X produced by Algorithm 2 is green-dominating with probability at least \(1 - \frac{1}{n}\).

Proof

Let \(m\in \{0,1,\ldots ,n-1\}\) be a fixed vertex of G. The green neighborhood \(\widehat{N}(m)\) of m is the set

$$\begin{aligned} \widehat{N}(m) = N(m) \setminus \{ m-1, m+1\} = \{ m_1, m_2, \ldots , m_t \}, \end{aligned}$$

where \(0 \le m_1< m_2< \ldots < m_t\) and the arithmetic operations are modulo n.

If \(m_1 = 0\), then \(0 \in \widehat{N}(m) \cap X\). We shall show that in all other cases \(\widehat{N}(m) \cap X = \emptyset \) with probability less than \(n^{-2}\), which implies by the union bound that with probability at least \(1-\frac{1}{n}\) the set X is green-dominating.

Algorithm 2
figure d

Bondy and Jackson’s procedure

Denote by \(\mathcal {A}\) the set of all sequences \(A = (a_0, a_1, \ldots , a_r)\), where \(0=a_0< a_1< \ldots< a_r < n-1\), and \(a_{i+1} - a_{i} \ge 2\), \(0 \le i \le r-1\). For \(A = (a_0, a_1, \ldots , a_r) \in \mathcal {A}\),

$$\begin{aligned} \begin{aligned} P(X = A)&= \prod _{i=1}^{r} p(1-p)^{a_{i }- a_{i-1} - 2} \left( \sum \limits _{i=0}^{\infty } p(1-p)^{-a_r + (n-1+i) - 2} \right) \\&= p^{r+1}(1-p)^{n-2r-3} \sum _{i=0}^{\infty } (1-p)^i \\&= p^{r} (1-p)^{n-2r-3} \\&= (1-p)^{n-3} \left( \frac{p}{(1-p)^2} \right) ^r \\&= (1-p)^{n-3} \mu ^r, \end{aligned} \end{aligned}$$

where we denote \(\mu = \frac{p}{(1-p)^{2}}\).

Let now \(d_1 = m_1\), \(d_i = m_i - m_{i-1}\), \(2 \le i \le t\), and \(d_{t+1} = n-m_t\), and

$$\begin{aligned} \mathcal {C}= C^*(d_1) \times C(d_2) \times \cdots \times C(d_t) \times C^*(d_{t+1}). \end{aligned}$$

There is a natural bijection between \(\mathcal {C}\) and the subset \(\widehat{\mathcal {A}}\) of \(\mathcal {A}\) consisting of those sequences which are disjoint from \(\widehat{N}(m)\). Moreover, for \(A = (a_0, a_1, \ldots , a_r) \in \widehat{\mathcal {A}}\),

$$\begin{aligned} P(X = A) = (1-p)^{n-3} \mu ^r = (1-p)^{n-3}\prod _{i=1}^{t+1} \mu ^{k_i-1}, \end{aligned}$$
(6)

where \(k_i\) is the number of parts in the corresponding composition of \(d_i\), \(1 \le i \le t+1\).

Note that

$$\begin{aligned} \mathcal {C}&= \left( \bigcup _{k_1 \ge 1} C^*(k_1, d_1) \right) \times \left( \bigcup _{k_2 \ge 1} C(k_2, d_2) \right) \times \cdots \times \left( \bigcup _{k_t \ge 1} C(k_t, d_t) \right) \nonumber \\&\quad \times \left( \bigcup _{k_{t+1} \ge 1} C^*(k_{t+1}, d_{t+1}) \right) = \bigcup \Big ( C^*(k_1, d_1) \times C(k_2,d_2) \times \cdots \times C(k_t,d_t)\nonumber \\&\quad \times C^*(k_{t+1},d_{t+1}) \Big ), \end{aligned}$$
(7)

where the union is taken over all \((t+1)\)-tuples \((k_1, k_2, \ldots , k_{t+1})\) of positive integers. Therefore (6) implies that

$$\begin{aligned} P(X \in \widehat{\mathcal {A}})= & {} (1-p)^{n-3} \sum {\left[ \mu ^{k_1-1} \cdot c^*(k_1, d_1) \left( \prod _{i=2}^t \mu ^{k_i-1} \cdot c(k_i,d_i) \right) \right. }\\{} & {} {\left. \mu ^{k_{t+1}-1} \cdot c^*(k_{t+1}, d_{t+1}) \right] }, \end{aligned}$$

where the summation is taken over all \((t+1)\)-tuples \((k_1, k_2, \ldots , k_{t+1})\) of positive integers. Thus, by Lemma 11,

$$\begin{aligned}&P(X \in \widehat{\mathcal {A}}) \\&= (1-p)^{n-3} \left( \sum _{k_1 \ge 1} \mu ^{k_1-1} c^*(k_1, d_1) \right) \left( \prod _{i=2}^{t} \sum _{k_i \ge 1} \mu ^{k_i-1} c(k_i, d_i) \right) \\&\left( \sum _{k_{t+1} \ge 1} \mu ^{k_{t+1}-1} c^*(k_{t+1}, d_{t+1})) \right) \\&\le (1-p)^{n-3} \left( \frac{2}{\beta } \right) \beta ^{d_1} \left( \prod _{i=2}^t \left[ \left( \frac{\alpha + 4\beta }{4 (\alpha + \beta )} \right) \beta ^{d_i} \right] \right) \left( \frac{2}{\beta } \right) \beta ^{d_{t+1}}\\&= (1-p)^{n-3} \beta ^{\left( \sum _{i=1}^{t+1} d_i \right) } \left( \frac{2}{\beta } \right) ^2 \left( \frac{\alpha + 4\beta }{4 (\alpha + \beta )} \right) ^{t-1}\\&= (1-p)^{n-3} \beta ^{n} \left( \frac{2}{\beta } \right) ^2 \left( \frac{\alpha + 4\beta }{4 (\alpha + \beta )} \right) ^{t-1}. \end{aligned}$$

Now, since \(\mu =\frac{p}{(1-p)^2}\) and \(\beta = \frac{\sqrt{4\mu + 1} + 1}{2}\) (cf. Lemma 11), it follows that \(1+p \le \beta \le \frac{1}{1-p}\) for every \(p \in (0,1)\). Therefore, for \(p \le 0.2\), we have

$$\begin{aligned} \begin{aligned}&P(X \in \widehat{\mathcal {A}}) \\&\le (1-p)^{n-3}\left( \frac{1}{1-p} \right) ^{n} \left( \frac{2}{1+p} \right) ^2 \left( \frac{\alpha + 4\beta }{4 (\alpha + \beta )} \right) ^{t-1}\\&=\frac{4}{(1-p)^3(1+p)^2} \left( \frac{\alpha + 4\beta }{4 (\alpha + \beta )} \right) ^{t-1}\\&\le 8 \left( \frac{\alpha + 4\beta }{4 (\alpha + \beta )} \right) ^{t-1}. \end{aligned} \end{aligned}$$

Therefore, if the degree of the fixed vertex m is equal to \(t+2 \ge c \log \sqrt{8}n + 4\), where \(c \ge 2 \log ^{-1}\frac{4 (\alpha + \beta )}{\alpha + 4\beta }\), then \(P(X \in \widehat{\mathcal {A}}) < \frac{1}{n^2}\). To conclude the proof, it is enough to show that \(\frac{8}{p} \ge 2 \log ^{-1}\frac{4 (\alpha + \beta )}{\alpha + 4\beta }\) or, equivalently, \(\log \frac{4(\alpha + \beta )}{\alpha + 4\beta } \ge \frac{p}{4}\) for any \(p \in (0, 0.2]\).

First, using series expansions one can derive \(p(1+p) \le \alpha \le \frac{p}{(1-p)^2}\) and \(1+p \le \beta \le \frac{1-p+p^2}{(1-p)^2}\) in the target interval \(p \in (0, 0.2]\). Therefore,

$$\begin{aligned} \log \frac{4(\alpha + \beta )}{\alpha + 4\beta } \ge \log \frac{4(p(1+p) + (1+p))}{\frac{p}{(1-p)^2} + \frac{4(1-p+p^2)}{(1-p)^2}} = \log \frac{4(p+1)^2 (1-p)^2}{p + 4(1-p+p^2)}. \end{aligned}$$

Let us denote the latter function by f(p). One can check that f(p) is concave in the interval [0, 0.2] and \(f(p) \ge \frac{p}{4}\) in the extreme points of the interval. Consequently, \(f(p) \ge \frac{p}{4}\) holds in all points of the interval, which gives the desired conclusion and completes the proof. \(\square \)

In the remainder of this section we are going to show that the size of X is at most pn with high probability. To this end, we formalize Algorithm 2 as a Markov chain with two states: State 0 and State 1. At time point \(t=0\) the Markov chain is in State 1, and for \(t \ge 1\)

  1. 1.

    if at time point \(t-1\) the Markov chain is in State 0, then at time point t it is in State 1 with probability p and in State 0 with probability \(1-p\);

  2. 2.

    if at time point \(t-1\) the Markov chain is in State 1, then at time point t it is in State 0.

Let \(N = n-1\). For \(i \in \{ 0, 1, \ldots , N-1\}\) we denote by \(\xi _i\) the random variable which is equal to \(\alpha \in \{ 0, 1 \}\) if the Markov chain is in State \(\alpha \) at time point i. We interpret the Markov chain as follows: a vertex i is included in X if and only if the Markov chain is in State 1 at time point i, i.e. \(\xi _i = 1\). In particular, \(X = \{ i~|~\xi _i = 1, i = 0, 1, \ldots , N-1 \}\), \(|X| = \sum _{i=0}^{N-1} \xi _i\).

Denote by \(\Pi = (0, 1)\) the vector of initial distribution of the Markov chain, which means that at time point 0 the Markov chain is in State 1 with probability 1 (this corresponds to inclusion of 0 to X). Let also \(T\) denote the transition matrix

$$\begin{aligned} T= \begin{pmatrix} 1-p &{}\quad p \\ 1 &{}\quad 0 \end{pmatrix} \end{aligned}$$

of the Markov chain. Then the probability distribution of \(\xi _i\) is defined by the vector \(\Pi ^{(i)} = \Pi \cdot T^i\).

It can be shown by induction that

$$\begin{aligned} T^i = \frac{1}{1+p} \begin{pmatrix} 1 &{}\quad p \\ 1 &{}\quad p \end{pmatrix} + \frac{(-p)^i}{1+p} \begin{pmatrix} p &{} -p \\ -1 &{} 1 \end{pmatrix}, \end{aligned}$$

and hence

$$\begin{aligned} \Pi ^{(i)} = \Pi \cdot T^i = \frac{1}{1+p} \begin{pmatrix} 1 - (-p)^{i},&\quad p + (-p)^{i} \end{pmatrix}, \end{aligned}$$

that is, \(\mathbb {P}[\xi _i = 0] = \frac{1 - (-p)^{i}}{1+p}\) and \(\mathbb {P}[\xi _i = 1] = \frac{p + (-p)^{i}}{1+p}\).

Lemma 13

For n large enough and \(p \in (0, 0.2]\), the size of the set X produced by Algorithm 2 is at most pn with probability at least \(1 - \frac{50}{np^4}\).

Proof

As before, let \(N = n-1\). To prove the statement, we first show that for \(\varepsilon > 0\)

$$\begin{aligned} \mathbb {P}\left[ \left| \frac{|X|}{N} - \frac{p}{1+p}\right| > \varepsilon \right] \le \frac{34}{N \varepsilon ^2}. \end{aligned}$$
(8)

By Chebyshev’s inequality we have

$$\begin{aligned} \mathbb {P}\left[ \left| \frac{|X|}{N} - \frac{p}{1+p}\right| > \varepsilon \right] \le \frac{\mathbb {E}\left[ \left| \frac{|X|}{N} - \frac{p}{1+p}\right| ^2 \right] }{\varepsilon ^2}. \end{aligned}$$

Therefore, in order to prove (8), we only need to show that \(\mathbb {E}\left[ \left| \frac{|X|}{N} - \frac{p}{1+p}\right| ^2 \right] \le \frac{34}{N}\).

Let \(\pi = \frac{p}{1+p}\) and \(p_{1}^{(i)} = \mathbb {P}[\xi _i = 1] = \frac{p + (-p)^{i}}{1+p}\). Then

$$\begin{aligned} \mathbb {E}\left[ \left| \frac{|X|}{N} - \frac{p}{1+p}\right| ^2 \right]= & {} \mathbb {E}\left[ \left| \frac{\sum _{i=0}^{N-1} \xi _i}{N} - \pi \right| ^2 \right] = \frac{1}{N^2} \mathbb {E}\left[ \left( \sum _{i=0}^{N-1} (\xi _i - \pi ) \right) ^2 \right] \nonumber \\= & {} \frac{1}{N^2} \sum _{i=0}^{N-1} \sum _{k=0}^{N-1} \delta _{ik}, \end{aligned}$$
(9)

where \(\delta _{ik} = \mathbb {E}[\xi _i \xi _k] - \pi \mathbb {E}[\xi _i] - \pi \mathbb {E}[\xi _k] + \pi ^2\).

Observe that \(|p_{1}^{(i)} - \pi | \le \frac{p^i}{1+p}\), and hence for \(i,k \in \{0, \ldots , N\}\)

$$\begin{aligned} \begin{aligned} \delta _{ik}&= \mathbb {E}[\xi _i \xi _k] - \pi \mathbb {E}[\xi _i] - \pi \mathbb {E}[\xi _k] + \pi ^2\\&= p_1^{(s)}p_1^{(t)} - \pi p_1^{(i)} - \pi p_1^{(k)} + \pi ^2\\&\le \frac{2}{1+p} ( p^s + p^t + p^i + p^k), \end{aligned} \end{aligned}$$
(10)

where \(s = \min \{i,k\}\) and \(t = |i-k|\). Therefore, by plunging in (10)–(9) we obtain

$$\begin{aligned} \begin{aligned} \mathbb {E}\left[ \left| \frac{|X|}{N} - \frac{p}{1+p}\right| ^2 \right]&= \frac{1}{N^2} \sum _{i=0}^{N-1} \sum _{k=0}^{N-1} \delta _{ik} \\&\le \frac{2}{N^2(1+p)} \sum _{i=0}^{N-1} \sum _{k=0}^{N-1} [p^s + p^t + p^i + p^k]\\&\le \frac{8}{N^2(1+p)} \sum _{i=0}^{N-1} \sum _{k=0}^{N-1} p^{\min \{s,t\}}\\&\le \frac{8}{N^2(1+p)} \sum _{i=0}^{\lceil N/2 \rceil -1} p^i \big [ 2(N - 2i - 1) + 2(N - 2i) \big ]\\&\le \frac{8}{N^2(1+p)} \cdot \frac{4N}{1-p} \le \frac{34}{N}, \end{aligned} \end{aligned}$$

where in the latter inequality we used the assumption \(p \le 0.2\). This proves (8).

Now, by setting \(\varepsilon = \frac{p^2}{1+p}\), we deduce from (8) that

$$\begin{aligned} \mathbb {P}\left[ \left| \frac{|X|}{N} - \frac{p}{1+p}\right| > \frac{p^2}{1+p} \right] \le \frac{34(1+p)^2}{N p^4} \le \frac{49}{N p^4}, \end{aligned}$$

which implies \(\mathbb {P}[|X| \le pN] \ge 1 - \frac{49}{Np^4}\) and therefore \(\mathbb {P}[|X| \le pn] \ge 1 - \frac{50}{np^4}\) for all \(n \ge 50\). \(\square \)

3.3 Faster Algorithms for Second Hamiltonian Cycle

In this section we combine Algorithm 2 with the general procedure from Sect. 3.1 to obtain randomized algorithms for finding a second Hamiltonian cycle in graphs of large minimum degree.

Algorithm 3
figure e

Randomized algorithm for Second Hamiltonian Cycle

Theorem 14

Let \(G=(V,E)\) be an n-vertex graph, C be a Hamiltonian cycle in G, and \(p \in (0, 0.2]\). If every vertex of G has degree at least \(\frac{8}{p} \log \sqrt{8}n + 4\), then given G, C, and p, Algorithm 3 succeeds with probability at least \(1 - \frac{1}{n}\left( \frac{50}{p^4} + 1 \right) \). Furthermore, the algorithm works in \(poly(n) \cdot 2^{4pn}\) time.

Proof

Algorithm 3 fails if and only if Algorithm 2 outputs a non-green-dominating set or the size of the set exceeds pn. The former happens with probability at most \(\frac{1}{n}\), by Lemma 12, and the latter happens with probability at most \(\frac{50}{np^4}\), by Lemma 13. Hence, the algorithm succeeds with probability at least \(1 - \frac{1}{n}\left( \frac{50}{p^4} + 1 \right) \).

Now, if Algorithm 3 does not fail, by Theorem 10, it constructs a second Hamiltonian cycle in G in time not exceeding \(poly(n) \cdot f(4pn)\), where \(f(k) = O(k^{2} 2^{k})\) is the time complexity of the Bellman–Held–Karp algorithm [3, 18]. Hence the theorem. \(\square \)

The next corollary follows by Theorem 14, when replacing the factor \(\frac{8}{p}\) by either (1) a constant 32c, or (2) a polylogarithmic factor \(32 \log ^c n\), or (3) a polynomial factor \(32 n^{\varepsilon }\) (where \(\varepsilon < 0.25\)). Note that the second case of the corollary is implied by the fact that \(64 \log ^{c+1} n > 32 \log ^{c}n \cdot \log \sqrt{8} n + 4\), for large enough n.

Corollary 15

Let \(c,\varepsilon \) be positive constants, where \(\varepsilon <0.25\). Let \(G=(V,E)\) be an n-vertex graph and C be a Hamiltonian cycle in G. Then:

  1. 1.

    If every vertex of G has degree at least \(32c \cdot \log \sqrt{8}n + 4\), then Algorithm 3 finds a second Hamiltonian cycle in G in time \(poly(n) \cdot 2^{n/c}\) with probability at least \(1 - O\left( \frac{1}{n} \right) \).

  2. 2.

    If every vertex of G has degree at least \(64 \log ^{c+1} n\), then Algorithm 3 finds a second Hamiltonian cycle in G in time \(poly(n) \cdot 2^{n/\log ^c{n}}\) with probability at least \(1 - O\left( \frac{\log ^{4c} n}{n} \right) \).

  3. 3.

    If every vertex of G has degree at least \(32 n^{\varepsilon } \cdot \log \sqrt{8}n + 4\), then Algorithm 3 finds a second Hamiltonian cycle in G in time \(poly(n) \cdot 2^{n^{1-\varepsilon }}\) with probability at least \(1 - O\left( \frac{1}{n^{1-4\varepsilon }} \right) \).

4 Conclusions

We conclude by stating some questions for future research. The most prominent problem is to classify the complexity of finding a second Hamiltonian cycle, when its existence is guaranteed and we are given a first Hamiltonian cycle.

For cubic graphs, the only known upper bound for the problem is the complexity class PPA [20]. It is unknown whether the problem is hard for PPA, or some other complexity class, or if it can be solved in polynomial time. In fact, it is not even known, if the problem can be solved in \(2^{o(n)}\) time by a randomized algorithm.

Our randomized algorithm can achieve such time complexity at the expense of a larger minimum degree. For example, it works in time \(2^{o(n)}\) when the minimum degree is \(\omega (\log n)\). This suggests the following problem:

Problem 16

Let c be any sufficiently large constant. Does there exist a \(2^{o(n)}\)-time deterministic algorithm that, given an n-vertex Hamiltonian graph G of minimum degree at least \(\log ^c n\) and a Hamiltonian cycle C in G, computes a Hamiltonian cycle in G that is different from C?