On the existence of Hamilton cycles with a periodic pattern in a random digraph

We consider Hamilton cycles in the random digraph $D_{n,m}$ where the orientation of edges follows a pattern other than the trivial orientation in which the edges are oriented in the same direction as we traverse the cycle. We show that if the orientation forms a periodic pattern, other than the trivial pattern, then approximately half the usual $n\log n$ edges are needed to guarantee the existence of such Hamilton cycles a.a.s.


Random Digraphs
In this paper we present results obtained for the random directed graph D n,p . More precisely, D n,p is a distribution over the class of graphs with vertex set [n] := {1, . . . , n} in which every ordered pair ij, i, j ∈ [n] and i = j, appears independently as an arc in D n,p with probability p. Note that p = p(n) may (and usually does) tend to zero as n tends to infinity. We say that D n,p has some property asymptotically almost surely (or a.a.s.) if the probability that D n,p has this property tends to 1 as n goes to infinity.
As it is done in the theory of (undirected) random graphs, we slightly abuse the notation and for some natural number m = m(n) ∈ N use D n,m to denote a directed graph on n vertices and precisely m arcs taken uniformly at random from the family of directed graphs on n vertices and m arcs. Alternatively, D n,m can be constructed during the random digraph process. Indeed, one may consider a sequence of digraphs (D n,m ) n(n−1) m=0 with common vertex set [n] in which D n,0 is the empty digraph and D n,m+1 is obtained from D n,m by adding a random arc that is not present in D n,m . The process ends once D n,n(n−1) , the complete digraph, is reached.

Asymptotic Notation and Convention
Given two functions f = f (n) and g = g(n), we will write f = O(g) if there exists an absolute constant c such that f ≤ cg for all n ∈ N, f = Ω(g) if g = O(f ), f = Θ(g) if f = O(g) and f = Ω(g), and we write f = o(g) or f ≪ g if the limit lim n→∞ f /g = 0. In addition, we write f = ω(g) or f ≫ g if g = o(f ). We also will write f ∼ g if f = (1 + o(1))g.
Through the paper, all logarithms with no subscript denoting the base will be taken to be natural. Moreover, as typical in the field of random graphs, for expressions that clearly have to be an integer, we round up or down but do not specify which, as long as this rounding does not affect the argument.

Patterns
Given a cycle C = (v 1 , . . . , v n , v 1 ) of length n ≥ 1 (where C is a loop for n = 1 and a double arc for n = 2), we are interested in describing periodic orientations of the edges of C. A pattern of length k ≥ 1 is a k-tuple π = (π 1 , . . . , π k ) where π i ∈ {→, ←}. We say that an orientation of C follows pattern π if k | n and each edge v i v i+1 for i ∈ [n] is oriented Here v n+1 = v 1 , and the indices of π i should be taken modulo k.) We identify a pattern π with the only oriented cycle C π of length k which follows π, and consider two patterns π and π ′ to be equivalent if their corresponding oriented cycles C π and C π ′ are isomorphic digraphs. In other words, two patterns are equivalent if they can be obtained from one another by applying a cyclic rotation of the entries and/or a reflection (that is, reversing both the order of the entries and the direction of the arrows). A pattern is primitive if it is not a concatenation of two or more consecutive copies of a shorter pattern. We call an oriented cycle C in a digraph D a π-Hamilton cycle (or π-HC for short) if C spans D and follows pattern π. Clearly, for two equivalent patterns π and π ′ , a digraph D contains a π-HC if and only if it contains a π ′ -HC. Moreover, if π is a primitive pattern of length k and π ′ is the concatenation of ℓ copies of π, then a digraph on n vertices has a π ′ -HC if and only if it has a π-HC and ℓk | n. In view of that, we can restrict our attention to the analysis of primitive patterns π. All patterns of length 1 are equivalent to (→), which we call the trivial pattern. Likewise, all primitive patterns of length 2 are equivalent to (→, ←). We refer to (→, ←) as the alternating pattern, so a (→, ←)-HC is simply called an alternating Hamilton cycle. Primitive patterns of length k ≥ 3 are defined to be non-alternating. Remark 1. While our main results concern only primitive patterns, in some parts of the argument it will be convenient to consider the non-primitive pattern (→, ←, →, ←) as well. This pattern will be useful when investigating the existence of alternating Hamilton cycles. Indeed, when the number of vertices n is divisible by 4, a Hamilton cycle follows (→, ←) if and only if it follows (→, ←, →, ←). In view of this, we can avoid some of the technical difficulties that arise in the analysis of patterns of length 2 by simply redefining the alternating pattern to be (→, ←, →, ←) when 4 | n. The case when n ≡ 2 mod 4 can be reduced to the previous case with a slight modification of the argument.

Results
We are now ready to state our main results.
Theorem 2. Let π = (→, ←) be the alternating pattern. Consider the random digraph process (D n,m ) n(n−1) m=0 (restricted to even n). The following property holds a.a.s.: D n,m contains a π-HC the first time all vertices have in-degree at least 2 or out-degree at least 2.
From this result, we immediately and easily establish the sharp threshold for the existence of the alternating Hamilton cycle, and obtain the limiting probability at the critical window. In particular, the following corollary holds. We obtain similar results for all primitive patterns of order k ≥ 3.
Theorem 4. For any fixed k ≥ 3, let π = (π 1 , . . . , π k ) be a primitive pattern. Consider the random digraph process (D n,m ) n(n−1) m=0 (restricted to integers n that are divisible by k). The following property holds a.a.s.: D n,m contains a π-HC the first time all vertices have total degree at least 2.
Remark 6. Let us point out that there are different coefficients in the log log n terms in Corollaries 3 and 5. It follows from the fact that having a vertex with both in-degree and out-degree equal to 1 prevents there being a Hamilton cycle with the alternating pattern, but it does not prevent any other pattern. See Lemma 10 to see how this affects the probability threshold.

Idea of the Proof
We start with a naïve description of the argument. Let k ≥ 1 be any fixed natural number, and let π be any pattern of length k. Suppose that we wish to find a π-Hamilton cycle in a given random digraph on n vertices, where n is divisible by k. Here is one simple approach: first partition the n vertices into k bins, B 1 , . . . , B k , so that each bin receives exactly n/k vertices (this is done arbitrarily, before examining the edges); then build a cycle (v 1 , . . . , v n , v 1 ), where each v i ∈ B i and each v i v i+1 is oriented as π i . (Here the indices of B i and π i should be interpreted modulo k). This gives us the desired π-HC. Clearly, for the above construction to succeed, every vertex v in bin B i should have some neighbours w ∈ B i−1 and w ′ ∈ B i+1 such that the edges vw and vw ′ are appropriately oriented. Unfortunately, it is easy to see that for the D n,p model the above property fails a.a.s. when k ≥ 2 and p ∼ log n/(2n) (which is the sharp threshold for the degree constraints given in Theorems 2 and 4). This is due to the presence of vertices v such that v and all its neighbours belong to the same bin. To overcome this obstacle, in this section we will analyze a simpler model of random digraphs for which the above naïve construction of a π-HC works. Later in Section 5, we will show how to modify D n,p (by moving a few vertices to different bins and contracting some short paths) so that the resulting random graph can be analyzed by means of this simpler model. We consider a model that generalizes the D s-in,t-out model of [1] as follows. Let S = (s i,j ) 1≤i,j≤k and T = (t i,j ) 1≤i,j≤k be two k × k matrices with entries in N ∪ {0}. We construct the random digraph D S-in,T -out as follows. We have n vertices placed in k ≥ 1 bins as explained above. For each vertex v in bin B i , we add s i,j distinct in-arcs to v (that is, with head vertex v) and tail vertices chosen uniformly at random (u.a.r.) from B j \ {v}. In other words, each of the n/k s i,j choices (or n/k−1 is equally likely. Similarly, for each vertex v in bin B i , we add t i,j distinct out-arcs from v (that is, with tail vertex v) and head vertices chosen u.a.r. from B j \ {v}. Let us note that D S-in,T -out is, in general, a multi-digraph since an arc vw may be generated once as an out-arc from v and once as an in-arc to w.
We start with the following observation. Proof. Walkup [9] (see Theorem 17.6 in [6]) proved that the following model of a random bipartite graph has a perfect matching a.a.s: given disjoint sets A, B of size m, each vertex of A chooses 2 random neighbours in B and each vertex of B chooses 2 random neighbours in A. This is a random graph with 4m edges. The random graph D S-in,T -out consists of two independent copies of Walkup's graph, with orientations preserved, and so the conclusion follows immediately.
With one additional ingredient, namely, the fact that D 2-in,2-out a.a.s. has a directed Hamilton cycle, we get the following useful lemma. For technical reasons we disregard the case k = 2, and restrict our attention to patterns of length k ≥ 3 (see Remark 9 below). Moreover, we do not assume patterns to be primitive so, in particular, the lemma applies to π = (→, ←, →, ←). Lemma 8. Let k ≥ 3 be any natural number and let π = (π 1 , . . . , π k ) be any pattern. Let S = (s i,j ) 1≤i,j≤k and T = (t i,j ) 1≤i,j≤k be k ×k matrices with Then a.a.s. D S-in,T -out has a Hamilton cycle (v 1 , . . . , v n ) with v i ∈ B j when i ≡ j mod k and with each v i v i+1 oriented as π i .
Proof. Using Lemma 7, we find a family of perfect matchings between B i and B i+1 directed as π i for each i = 1, . . . , k − 1. This gives a partition of the vertex set into sets that induce paths of length k − 1. Each of these paths P = (u 1 , . . . , u k ) has u i ∈ B i and u i u i+1 oriented as π i . We contract each path into a single vertex. Without loss of generality, we may assume that π k = →; otherwise, a symmetric argument can be applied. It suffices to find a directed Hamilton cycle on the contracted paths, so that each edge is oriented from the B k end of one path to the B 1 end of the next one. In order to do this, given each path P = (u 1 , . . . , u k ), note there are t k,1 = 2 out-arcs from u k to a random vertex in B 1 and s 1,k = 2 in-arcs to u 1 from a random vertex in B k . Keeping only those arcs, we get a D 2-in,2-out graph on the vertices associated with the contracted paths. It was shown by Cooper and Frieze [2] that D 2-in,2-out a.a.s. has a directed Hamilton cycle. Un-contracting the paths gives us the desired π-Hamilton cycle of the original graph.
Remark 9. The proof of the lemma does not work 'as is' for k = 2 and π = (→, ←), since the arcs between B 1 and B 2 used in the last step to complete a Hamilton cycle may have already been used in the first perfect matching between these same bins. With some extra work, one can show that the statement still holds in that scenario if we allow S = T = 0 4 4 0 . We chose not to include this case in the statement, since it is not needed in our main argument.
Lemma 8 will be useful in analyzing the random digraph process. However, the argument will be more delicate and the above proof strategy needs to be amended in order to deal with vertices of low degree that occur in the original process but not in the D S-in,T -out one. These vertices will be "buried" inside paths after contracting them to "fat" vertices.

Bin partition
Throughout this section, π is a fixed primitive nontrivial pattern. We consider two different scenarios: either π = (→, ←) (alternating case) or π is a primitive pattern (π 1 , . . . , π k ) of length k ≥ 3 (non-alternating case). We will analyze several models of random digraphs with common vertex set [n]. In the non-alternating case, we assume that the length of the pattern k divides n, and partition the vertices into k bins B 1 , . . . , B k in an equitable manner (that is, every bin receives exactly n/k vertices). The alternating case is slightly different. Here we assume that n is even, but partition the vertices into 4 bins B 1 , . . . , B 4 , so that bins B 1 , B 2 receive ⌈n/4⌉ vertices and bins B 3 , B 4 receive ⌊n/4⌋ vertices. By setting k = 4, the alternating case can be intuitively regarded as if π = (→, ←, →, ←) instead of (→, ←), with the weaker requirement that n is even but not necessarily divisible by 4 (see Remark 1). In either case, the partition of the vertex set into bins is done arbitrarily before examining the arcs of any of the random digraphs.

Necessary conditions
We now describe what will turn out to be the main obstruction to the existence of a π-HC in D n,p . In the non-alternating case (that is, π primitive of length k ≥ 3), let A denote the event that D n,p has no vertices of total degree less than 2. In the alternating case, we require a stronger condition, and define A to be the event that every vertex in D n,p has in-degree at least 2 or out-degree at least 2. Note that in either case A is trivially a necessary condition for the existence of π-HC.
The following result is a standard exercise in the field of random graphs, so we just sketch the main steps of the proof. Proof (sketch). Let us first consider the case π = (→, ←). Let X denote the number of vertices in D n,p alt with in-degree 1 and out-degree 1. Easy computations show that As a result, it follows that X is asymptotically Poisson with mean λ := e −c /4. In particular, Moreover, the expected number of vertices of total degree at most 1 is (1), and so The non-alternating case is very similar. This time we need to investigate random variable Y , the number of vertices in D n,p non-alt with total degree 1. We get that

and so
Pr The details are left for the reader.

In-and out-arcs
For each p = p(n) ∈ [0, 1], we can view D n,p as the union of two independent copies of D n,p ′ , denoted D in n,p ′ and D out n,p ′ , where p ′ = p ′ (n) is chosen such that This is a standard, simple but useful, observation called double round exposure or sprinkling.
The arcs in D in n,p ′ receive label"in", and we will call them in-arcs. Likewise, the arcs in D out n,p ′ are labeled "out", and will be called out-arcs. Note that an arc − → vw may appear in both D in n,p ′ and D out n,p ′ , which creates a parallel pair of arcs, one in-arc − → vw and one out-arc − → vw. This is useful for the purpose of building a Hamilton cycle, since we may use either copy of − → vw for the cycle. By forgetting the labels and merging parallel pairs into single arcs, we recover the usual distribution of D n,p . Hence, we regard D n,p as a simple digraph, where each arc has label "in", "out", or both.
Furthermore, we wish to build the standard random digraph process (D n,p ) 0≤p≤1 in a way that is compatible with the arc labels. To do so, we introduce a sequence ( n,p ′ (and merging parallel pairs into single arcs), we obtain three random processes (D n,p ) 0≤p≤1 , (D in n,p ′ ) 0≤p ′ ≤1 and (D out n,p ′ ) 0≤p ′ ≤1 with the usual couplings: we say that arc − → vw appears in (D n,p ) 0≤p≤1 at time p 1 with label "in" and gets a second label "out" at time p 2 . However, if we choose to ignore labels, then arc − → vw simple appears in (D n,p ) 0≤p≤1 at time p 1 .
In the context of the random digraph process (D n,p ) 0≤p≤1 , we consider random variable p * = min{p ∈ [0, 1] : D n,p satisfies A}.
Let ω := log log log n = o(log log n) and let In particular, by Lemma 10, a.a.s. p − < p * < p + .
In the remainder of this section, we will analyze the two random digraph processes These two processes, in turn, determine the process (D n,p ) p − ≤p≤p + , as explained above. For each "time" p ′ ∈ [p ′ − , p ′ + ], we associate out-arcs (that is, arcs in D out n,p ′ ) to their tail vertex and in-arcs to their head vertex. More precisely, if − → vw is an out-arc with tail at v and head at w, then we say that it is visible from v and invisible from w. Similarly, if − → vw is an in-arc, then it is invisible from v and visible from w. Later in the argument, we will expose the endpoint of each arc from which the arc is visible and leave the other endpoint random. This trick will be useful to emulate the D S-in,T -out model.

Useful properties
Recall that vertices are equitably partitioned into bins B 1 , . . . , B k before exposing any random arcs. (In the alternating case, k = 4 and |B 1 | = |B 2 | = ⌈n/4⌉ while |B 3 | = |B 4 | = ⌊n/4⌋.) We use this partition to classify vertices into three different types (good, bad, or dangerous): • We say a vertex v is good if, for every i ∈ [k], v has at least 4k + 2 visible out-arcs (that is, out-arcs visible from v) in D out n,p ′ − whose head vertex is in bin B i and also at least 4k + 2 visible in-arcs in D in n,p ′ − whose tail is in B i . (Note that this property is required for each bin, including the bin vertex v belongs to.) • We say that v is bad if it is not good, but its total degree in D n,p − = D in (including all arcs that are incident with v, visible and invisible, and ignoring labels) is at least 4k + 3.
• The remaining vertices that have total degree at most 4k + 2 are called dangerous.
The above classification of vertices is based solely on the two digraphs D in In other words, if a vertex is good/bad/dangerous at time p − it stays of this type during any time p ∈ [p − , p + ].
Given a digraph D, the D-distance between two vertices of D denotes the usual graph distance in the underlying undirected graph. Let H (for handsome) be the family of all digraphs D with D n,p − ⊆ D ⊆ D n,p + satisfying: H1: Every vertex in D has fewer than 4k vertices that are not good within D-distance 10k.
H2: Every dangerous vertex in D has only good vertices within D-distance 10k.
H3: Every cycle (with any orientation, any labels on the associated arcs, and including cycles of length 2) in D of length at most 10k has only good vertices within D-distance 10k.
Note that distances in H1-H3 are measured with respect to digraph D, whereas the definitions of being good, bad, and dangerous depend only on arcs that are already present in D n,p − ⊆ D ⊆ D n,p + . As a result, H is a monotone decreasing family of digraphs.
We will show now that random directed graphs are typically handsome.
Proof. As mentioned above, H1-H3 are monotone decreasing properties, so it suffices to show that a.a.s. H holds for p = p + . We will investigate these three events in turn.
H1: Let M = 40k 2 . Then, Pr(∃ a vertex of D n,p + not satisfying H1) Indeed, there are n choices for a vertex v and then there will be an additional ℓ vertices that make up the paths, where 4k ≤ ℓ ≤ M = (4k) × (10k). We choose these vertices in at most n ℓ ways and then choose a spanning tree that is contained in the union of the paths in at most (ℓ + 1) ℓ−1 ways. The factor (2p + ) ℓ bounds the probability the arcs of the tree exist, ignoring orientation gives us the 2. We then choose 4k vertices that are not good and multiply by an upper bound for the probability that these vertices have few D n,p − in-or out-neighbours in some of the k bins outside of the set of ℓ + 1 ≤ M + 1 vertices chosen so far.
H2: The probability that there is a dangerous vertex v and a not good vertex w such that dist(v, w) = ℓ ≤ 10k can be bounded from above by Indeed, there are n choices for a dangerous vertex v and then at most n ℓ choices for additional vertices that form a path of length ℓ reaching a vertex w that is not good. The next term is an upper bound for the probability that w is not good. The last term is an upper bound for the probability that v is dangerous. (Note that v already has one neighbour on the path that is already identified; hence, j ≤ 4k + 1, not 4k + 2.
H3: If there is a cycle not satisfying H3, then there is a set of 2 ≤ ℓ ≤ M = 10k +10k = 20k vertices containing at least ℓ arcs and at least one not good vertex. The probability of this event occurring in D n,p can be bounded from above by M ℓ=2 n ℓ The proof of the lemma is finished.
Given a digraph D n,p − ⊆ D ⊆ D n,p + and a vertex v of D, the neighbourhood N D (v) = N(v) of v is the set of all vertices w that are joined to v by an arc (in-or out-arc, visible or invisible from v). We now give some useful deterministic consequences of properties H1-H3.
Lemma 12. Let D be any digraph in H, and let P 0 be a pairwise vertex-disjoint collection of paths, where each path P ∈ P 0 has length at most 6k + 2 and contains exactly one non-good vertex (that is, bad or dangerous). Then Proof. Pick any vertex v. H3 implies that no path P ∈ P 0 intersects more than one vertex in N(v), since otherwise we would create a cycle of length at most 10k with at least one non-good vertex within distance 10k. Then, by H1, we immediately get H5. Moreover, if v is dangerous, then H2 implies H4.

Cycle Construction
In this section we will prove Theorems 2 and 4 by showing that a.a.s. D n,p * contains a π-Hamilton cycle, where π is either the alternating pattern (→, ←) or a primitive pattern (π 1 , . . . , π k ) of length k ≥ 3. For notational convenience, in the alternating case we set k = 4 and redefine π to be (→, ←, →, ←), even though n is only assumed to be even but not necessarily divisible by 4 (see Remark 1). In the non-alternating case, we always require that k | n. As in Section 4, the vertex set [n] is equitably partitioned into k ≥ 3 bins B 1 , . . . , B k of size |B i | = n/k (in the non-alternating case) or |B 1 | = |B 2 | = ⌈n/4⌉ and |B 3 | = |B 4 | = ⌊n/4⌋ (in the alternating case). Recall that this partition is done before exposing any random arcs.
We will analyze the random processes (D in n,p ′ ) p ′ − ≤p ′ ≤p ′ + , (D out n,p ′ ) p ′ − ≤p ′ ≤p ′ + and (D n,p ) p − ≤p≤p + introduced in Section 4, where D n,p = D in n,p ′ ∪ D out n,p ′ for 2p ′ − p ′ 2 = p (merging parallel arcs into single arcs) and where p − , p + are defined as in (1). In view of Lemmas 10 and 11, we will assume that p − < p * < p + and that event H holds in D n,p for all p − ≤ p ≤ p + . Otherwise our construction will simply fail, but this occurs with probability o(1). Note that we do not condition on these events, since this would destroy the probability space. Instead, we will expose some partial information about (D n,p ) p − ≤p≤p + and assume it does not contradict our assumptions above, while we leave all the unexposed information random.
Step 1 -digraph D * : We first consider digraphs D in (inand out-arcs, visible and invisible) that are incident with v, and label these arcs discovered. This information determines whether v is bad or dangerous. Hence, all vertices are classified into the good, bad and dangerous types defined in Section 4. We also label every vertex that is not good as discovered. (Good vertices remain undiscovered for now, but this will change later on, as we reveal more information about D n,p − and label some good vertices as discovered.) For each i ∈ [k], letB i denote the set of undiscovered vertices in bin B i . Note that some of the arcs that are visible from undiscovered (i.e. good) vertices may be discovered, but these are few as we shall see. For each undiscovered vertex v and each bin B i , let u + i (v) be the number of undiscovered out-arcs visible from v and whose other end is in B i , and let U + i (v) be the set of unexposed endvertices of these out-arcs. Similarly, let u − i (v) be the number of undiscovered in-arcs visible from v and whose other end is in B i , and let U − i (v) be the set of unexposed endvertices of these in-arcs. Property H1 of H guarantees the following: U1: For any bins B j , B i (possibly with i = j) and any undiscovered vertex v ∈ B j , Moreover, since the unexposed endpoint of each undiscovered arc remains random, we get: Note that U1-U2 are desired properties in light of Lemma 8. We shall see that they remain valid after we expose additional arcs and slightly modify our digraph.
Unfortunately, the arcs in D n,p − do not suffice to build a π-HC, since the necessary conditions of event A do not hold at time p − (in view of our assumption that p − < p * ). To that effect, we expose all the arcs in D n,p * that are incident with a dangerous vertex and label them discovered, as well. Since p * is a random time, here is a more careful description of this operation. Let us first expose the number r of arcs (but not their locations) in D n,p + \ D n,p − , and list them as e 1 , . . . , e r in the order they appear in the process. For each 1 ≤ i ≤ r, we determine whether or not e i is incident with a dangerous vertex, and if it is then we fully disclose the two endvertices of e i and label e i discovered. Otherwise, the endpoints of e i remain unknown (such e i will not play any role in our construction of the π-HC). Let r * be the smallest i ∈ {0, 1, . . . , r} such that D n,p − ∪ {e 1 , . . . , e i } satisfies the conditions in event A. From our assumption that p − < p * < p + , we have 1 ≤ r * ≤ r − 1 and D n,p * = D n,p − ∪ {e 1 , . . . , e r * }. Let D * = D n,p − ∪ {e i : e i is discovered, 1 ≤ i ≤ r * }. By construction D * satisfies A and H (since D * ⊆ D n,p * ⊆ D n,p + and H is monotone decreasing). Moreover, the additional newly discovered arcs in {e 1 , . . . , e r * } are disjoint with the undiscovered arcs of D n,p − . Hence, the joint distribution of the sets U ± i (v) of unexposed endpoints of undiscovered arcs is unaffected by the additional information revealed, and in particular properties U1-U2 are still valid. Our goal is to build a π-HC in D * (or just a (→, ←)-HC when π = (→, ←, →, ←) and n ≡ 2 mod 4). In the sequel, we will expose some additional information about D * and make slight modifications to it (such as moving some vertices from one bin to another). By abusing slightly the notation, we will still use D * to denote the probability distribution of the modified random digraph given all the exposed information.
Step 2 -short path collection: Our next step is to build a pairwise vertex-disjoint collection P of short paths, each of which contains exactly one vertex that is not good. To make this more precise, we first consider the case where k | n (i.e. either π is nonalternating or π = (→, ←, →, ←) with 4 | n). For each non-good vertex w (that is, w is bad or dangerous), we will build a path P (w) = v 1 v 2 · · · v 6k+1 of length 6k with the following properties: w is an internal vertex of P (w); all the vertices in P (w) are good except for w (so in particular w → P (w) is a bijection between non-good vertices and paths in P); each arc v i v i+1 is oriented as π i for i = 1, . . . , 6k; and each v i ∈ B i for i = 1, . . . , 6k + 1. (Recall that modular arithmetic is used for both bins and pattern positions so, for instance, v 6k+1 ∈ B 1 .) Note that in order to achieve this last property, we may have to move some vertices from one bin to another, but this will be done while keeping the bin sizes unchanged. Moreover, only internal vertices of paths in P may be moved to a different bin. When π = (→, ←, →, ←) with n ≡ 2 mod 4, we define the collection of paths P as above with the only proviso that exactly one of the paths in P must have length 6k + 2 instead of 6k. In this longer path P = v 1 v 2 · · · v 6k+3 , each vertex v i ∈ B i for i = 1, . . . , 6k + 2 but B 6k+3 ∈ B 1 (so the path cycles 6 times through bins B 1 , B 2 , B 3 , B 4 , and then visits B 1 , B 2 and again B 1 ), and arcs are oriented in an alternating fashion with v i v i+1 oriented as π i for i = 1, . . . , 6k + 2.
We will show that we can build a such a collection of paths P. Assume inductively that we have already created a sub-collection P 0 ⊂ P of such paths (possibly P 0 = ∅ is the trivial sub-collection) and let w 2 be a non-good vertex not contained in any path in P 0 . Our goal is to build a new path P (w 2 ) with all the desired properties and add it to P 0 . We will first suppose that k | n (that includes the case when π = (→, ←, →, ←) with 4 | n), and then show how to modify the construction if π = (→, ←, →, ←) and n ≡ 2 mod 4.
Step 2a -starting path P (w 2 ): Recall that N(w 2 ) = N D * (w 2 ) is the set of neighbours of w 2 (that is, those vertices that are joined to w 2 by arcs in D * with any label and orientation). This set has already been exposed since w 2 is not good. We claim that we can pick two different neighbours w 1 , w 3 ∈ N(w 2 ) that are good and are not contained in any path in P 0 .
Moreover, for the alternating pattern, we can pick w 1 , w 3 so that arcs w 1 w 2 and w 3 w 2 are either both oriented out of w 2 or both into w 2 . Indeed, if w 2 is bad, then |N(w 2 )| ≥ |N Dn,p − (w 2 )| ≥ 4k+3 by the definition of being bad. Then N(w 2 ) contains at least three good vertices not contained in any path in P 0 by property H5 of Lemma 12. By the pigeonhole principle, we can pick two such vertices w 1 and w 3 that are joined to w 2 by arcs with the same orientation. On the other hand, if w 2 is dangerous, all its neighbours are good and do not intersect any path in P 0 by property H4. In that case, event A guarantees the existence of appropriate vertices w 1 , w 3 (with arcs w 1 w 2 and w 3 w 2 both oriented out of w 2 or both into w 2 , in the alternating case).
Step 2b -growing path P (w 2 ): We first show that we can pick a position j ∈ [k] in the pattern such that w 1 w 2 and w 2 w 3 are oriented as π j and π j+1 . First suppose that arcs w 1 w 2 and w 3 w 2 are both oriented out of w 2 or both into w 2 (note that these are the only two possible cases in the alternating case, from our choice of w 1 and w 3 ). Clearly for π = (→, ←, →, ←) and also for any primitive pattern π of length k ≥ 3, there must be some j ∈ [k] such that π j =← and π j+1 =→ (and similarly some j ′ ∈ [k] such that π j ′ =→ and π j ′ +1 =←). In either case, we can pick a position j with w 1 w 2 and w 2 w 3 oriented as π j and π j+1 , as claimed. For k ≥ 3, there is an additional case to be considered. Suppose that exactly one of the arcs w 1 w 2 and w 3 w 2 is oriented out of w 2 and the other one is into w 2 . Since π is not the alternating pattern, there must be some j ∈ [k] such that π j = π j+1 =→ or π j = π j+1 =←. Hence (switching vertices w 1 and w 3 if needed), we can conclude that w 1 w 2 and w 2 w 3 are oriented as π j and π j+1 , also for this case. Let B a 1 , B a 2 , B a 3 (possibly a 1 = a 2 = a 3 ) be the bins containing vertices w 1 , w 2 , w 3 , respectively. We will find a path P (w 2 ) = w −k−j+2 · · · w 0 w 1 w 2 w 3 · · · w 5k−j+2 of length 6k in D * with the following properties: P (w 2 ) does not intersect any path in P 0 ; all vertices w −k−j+2 , . . . , w 5k−j+2 (of course, except for w 2 ) are good; each arc w i w i+1 is oriented as π i+j−1 for i = −k − j + 2, . . . , 5k − j + 1; and each w i ∈ B i+j−1 for i = −k − j + 2, . . . , 5k − j + 2, except for The bins of vertices w i and w a i +(i+1)k−j+1 will be swapped for i = 1, 2, 3 (unless a i = i+ j −1, in which case both w i and w a i +(i+1)k−j+1 will be placed correctly in the same bin B a i = B i+j−1 ). Note that since j, a 1 , a 2 , a 3 ∈ [k] and k ≥ 3, −k − j + 2 < 1 < 2 < 3 < a 1 + 2k − j + 1 < a 2 + 3k − j + 1 < a 3 + 4k − j + 1 < 5k − j + 2, so in particular all six vertices w 1 , w 2 , w 3 , w a 1 +2k−j+1 , w a 2 +3k−j+1 , w a 3 +4k−j+1 must be distinct and internal vertices of the path. For each i = −k − j + 2, . . . , 5k − j + 2, let B α i be the bin where we wish to find vertex w i . Then α i = i + j − 1, with the possible exceptions described in (2). We will grow our path P (w 2 ) by adding vertices to each end of w 1 w 2 w 3 , one vertex at a time. We can achieve this as follows. For each i = 3, . . . , 5k − j + 1, expose all in-and out-arcs of D * incident with w i (visible and invisible from w i ). We label all these exposed arcs as discovered and vertex w i is labelled discovered as well. Since w i is good, it has at least 4k + 2 neighbours w in bin B α i+1 with w i w oriented as π i+j−1 . By property H5, at least 2 of these vertices are good and not in any path P ∈ P 0 ∪ {w 1 w 2 w 3 · · · w i }. Pick one of them and call it w i+1 . By an analogous argument, we also grow the path from the other end, by adding a suitable vertex w i−1 for each i = 1, 0, −1, . . . , −k − j + 3, and thus complete our path P (w 2 ). This path has all the required properties, except for the fact that vertices listed in (2) may be placed in the wrong bin (depending on the values of a 1 , a 2 , a 3 ). Hence, we swap the bins of the vertices in the path that were misplaced: that is, w i is moved to bin B i+j−1 and w a i +(i+1)k−j+1 is moved to B a i , for i = 1, 2, 3. Note that the sizes of the bins remain unchanged and thus balanced. Moreover, writing P (w 2 ) = v 1 v 2 · · · v 6k+1 with v i = w i−k−j+1 , we have that every vertex v i (i = 1, . . . , 6k + 1) belongs to bin B i , and each arc v i v i+1 (i = 1, . . . , 6k) is oriented as π i , as required. Then, we can extend P 0 to P 0 ∪ {P (w 2 )} and inductively obtain our desired collection of paths P.
When π = (→, ←, →, ←) and n ≡ 2 mod 4, we just need to extend one of the paths P = v 1 v 2 · · · v 6k+1 in P two more steps. When doing so, we must make sure that the two additional vertices v 6k+2 , v 6k+3 belong to the right bins and the edges v 6k+1 v 6k+2 , v 6k+2 v 6k+3 have the appropriate orientations. This can be achieved by the exact same argument as above, and thus we omit the details. Note that we have tacitly assumed that P contains at least one path, which would not be true if all the vertices of D * were good 1 . In that case, we could still create one path by applying Step 2a to a good vertex w 2 , and extending this path as in Step 2b.
Step 3 -path contraction: A crucial property in the above construction of P is that we have only exposed (and labelled discovered) those arcs that are incident with discovered vertices, which are precisely the internal vertices of the paths in P. All the other vertices remain undiscovered (and are good). Note that some arcs incident with undiscovered edges may be discovered. However, in view of H5 (applying Lemma 12 with P 0 = P), we infer that each undiscovered vertex v is incident with at most 4k discovered arcs. Hence, property U1 remains valid for any undiscovered vertex v ∈ B j and bins B i , B j , with the updated values ofB i , U ± i (v) and u ± i (v). Moreover, since we did not reveal any information about undiscovered arcs, the unexposed endpoints of the undiscovered arcs visible from v remain random, and therefore property U2 also holds. Now we contract each path in P into a vertex. Vertices obtained from a contracted path are called fat and are placed in bin B 1 , while other vertices are called ordinary. We declare fat vertices to be undiscovered, so all vertices in the contracted graph are undiscovered. Let n ′ be the number of vertices (ordinary or fat) that remain in the digraph after the path contractions. Clearly n/(7k) ≤ n ′ ≤ n, since each path has fewer than 7k vertices. In particular, n ′ → ∞. We claim that k | n ′ and moreover, after contracting the paths, every bin contains exactly n ′ /k vertices. Indeed, when k | n, each path in P has 6 vertices in each bin B i (i = 2, . . . , k) and 7 vertices in bin B 1 , so path contractions maintain the bin sizes balanced. On the other hand, when π = (→, ←, →, ←) and n ≡ 2 mod 4, two additional vertices-one in bin B 1 and one in B 2 -are contracted (as a result of the longer path), so bins B 1 , B 2 , B 3 , B 4 become balanced as well in this case.
Step 4 -end of the proof: At this final stage, we will only need arcs between vertices in consecutive bins B i and B i+1 , for each i ∈ [k], so we delete all the remaining arcs. Moreover, for each fat vertex v obtained by contracting a path P = v 1 · · · v 6k+1 , we delete all arcs (inand out-arcs, visible and invisible) that are incident with v 1 except for those whose other end is in bin B k , which remain unexposed. Similarly, we delete all arcs that are incident with v 6k+1 except for those whose other end is in bin B 2 . In other words, fat vertex v plays the role of vertex v 1 (respectively, v 6k+1 ) when concerned with arcs between bins B 1 and B k (respectively, B 1 and B 2 ). Let us call the resulting digraph D * * . (Recall that D * * has n ′ → ∞ vertices with k | n ′ , and each bin contains exactly n ′ /k vertices.) We claim that, after all these edge deletions, properties U1-U2 remain valid for any vertex v ∈ B j and bin B i with i ∈ {j − 1, j + 1}. 2 This is clearly true if v is a fat vertex corresponding to a path P = v 1 · · · v 6k+1 , since v inherits the arcs visible from v 1 with opposite end in B k and the arcs visible from v 6k+1 with opposite end in B 2 . On the other hand, for any ordinary vertex v ∈ B j and bin B i (i ∈ {j − 1, j + 1}), the only arcs visible from v that may have been deleted are those incident with a fat vertex (and thus with some vertex of a path in P). Hence, by property H5 as before, we conclude that U1 remains valid. Property U2 also follows from the fact that we have not exposed any additional information about the surviving arcs and thus they remain uniformly distributed. Finally, U1 and U2 imply that the contracted digraph D * * contains a copy of D S-in,T -out (on n ′ vertices with n ′ → ∞) with s i,i+1 , s i,i−1 , t i,i−1 , t i,i−1 ≥ 2. So we can apply Lemma 8 and find a π-HC in D * * a.a.s. Finally, when π is primitive of length k ≥ 3, un-contracting the paths yields the desired π-HC in D * ⊆ D n,p * . When π = (→, ←, →, ←), we simply get a (→, ←)-HC. This finishes the proof of Theorem 2. Corollaries 3 and 5 follow immediately as a consequence of Lemma 10.

Final Comments
We have proved a hitting time result for the existence of a Hamilton cycle with edges oriented according to a periodic pattern. We have shown that this typically requires asymptotically one half of that needed for a consistently oriented Hamilton cycle. It would be of some interest to discover how many such cycles there are typically and as to whether there are all such cycles, up to a bound on the length of the pattern π.