Hamilton transversals in random Latin squares

Gyárfás and Sárközy conjectured that every n×n$$ n\times n $$ Latin square has a “cycle‐free” partial transversal of size n−2$$ n-2 $$ . We confirm this conjecture in a strong sense for almost all Latin squares, by showing that as n→∞$$ n\to \infty $$ , all but a vanishing proportion of n×n$$ n\times n $$ Latin squares have a Hamilton transversal, that is, a full transversal for which any proper subset is cycle‐free. In fact, we prove a counting result that in almost all Latin squares, the number of Hamilton transversals is essentially that of Taranenko's upper bound on the number of full transversals. This result strengthens a result of Kwan (which in turn implies that almost all Latin squares also satisfy the famous Ryser–Brualdi–Stein conjecture).


Introduction
1.1. Transversals in Latin squares. An n × n Latin square is an arrangement of n symbols into n rows and n columns, such that each row and each column contains precisely one instance of each symbol. A (full) transversal in an n × n Latin square is a collection of n positions of the Latin square that use each row, column, and symbol exactly once, and a partial transversal is a collection of at most n positions not using any row, column, or symbol more than once. The most famous open problem on the topic of transversals in Latin squares is the following.
We define a set of positions in a Latin square to be connected if the corresponding subgraph of ← → K n is (weakly) connected, and we say a transversal is Hamilton if it is both full and connected. For the case of n-arc-colourings, Conjecture 1.4 is equivalent to the following: all n × n Latin squares have a connected transversal of size n − 1. If true, Conjecture 1.3 implies that every n × n Latin square has a partial transversal of size one less than what is predicted by Conjecture 1.1 and also that every proper n-edge-colouring of K n contains either a rainbow path of length n − 2, as predicted by Conjecture 1.2, or a spanning rainbow forest with two components. Conjecture 1.4, if true, implies all of Conjectures 1.1-1.3.

Random Latin squares.
In this paper, we study the above conjectures in the probabilistic setting. Recently, Kwan [23] proved that at most a vanishing proportion of Latin squares fail to satisfy the statement of Conjecture 1.1, even finding (many) full transversals in most Latin squares, as follows. Theorem 1.5 (Kwan [23]). Almost all n × n Latin squares have at least Equivalently, a uniformly random n×n Latin square has at least (1 − o(1))n/e 2 n transversals with high probability. We note that it was proven by Taranenko [35] (with a simpler proof later found by Glebov and Luria [14]) that n × n Latin squares can have at most (1 + o(1))n/e 2 n transversals, so that the counting term given in Theorem 1.5 is best possible, up to the exponential error term. Analogously, the authors, together with Kühn and Osthus [15], proved that almost all optimal edge-colourings (proper edge-colourings using the minimum possible number of colours) of K n admit a rainbow Hamilton path, which proves a stronger statement than Conjecture 1.2 for all but a vanishing proportion of such colourings.
The main result of this paper is the following strengthening of Theorem 1.5. Theorem 1.6 implies that a uniformly random proper n-arc-colouring satisfies Conjecture 1.4 with high probability, which in turn implies that a uniformly random n × n Latin square satisfies Conjectures 1.1 and 1.3 with high probability as well. We note that the number of optimal edgecolourings of K n is a vanishing fraction of the number of n × n Latin squares, so Theorem 1.6 does not imply the result of [15].
Random Latin squares can be difficult to analyze, in part due to their 'rigidity' and lack of independence. To prove Theorem 1.5, Kwan [23] -using Keevash's [21,22] breakthrough results on the existence of combinatorial designs -developed a method for approximating a uniformly random Latin square by an outcome of the 'triangle-removal process', which is in comparison much easier to analyze. Prior to Kwan's [23] work, a limited number of results (e.g. [9,26,29,36]) were proved using so-called 'switching' methods. Our proof, notably, does not rely on Keevash's [21,22] results and instead introduces new techniques for analyzing 'switchings' to study Latin squares, thus providing a more elementary proof of Theorem 1.5.
1.3. Organization of the paper. In Section 2 we clarify some notation and definitions that we will use throughout the paper. We overview the proof of Theorem 1.6 in Section 3, and give some preliminary probabilistic results and useful theorems of other authors in Section 4. Sections 5-7 are devoted to the proof of Theorem 1.6. For a digraph G, we write the arc set of G as E(G), and we denote an arc from a vertex u to a vertex v as uv, and we say that u is the tail of the arc e = uv, denoted u = tail (e), and that v is the head of e, denoted v = head (e). We say that any vertex v such that uv ∈ E(G) is an out-neighbour of u in G, and that any v such that vu ∈ E(G) is an in-neighbour of u in G. We define N + G (v) to be the set of out-neighbours of v in G, sometimes dropping the subscript G when G is clear from context, and we call N + G (v) the out-neighbourhood of v in G. We define the in-neighbourhood of v in G, denoted N − G (v), analogously, and we define the neighbourhood of v in G to be N G Suppose now that G is equipped with an arc-colouring φ G in colour set C. Then for a colour c ∈ C and an arc e ∈ E(G) we write φ G (e) = c to mean that e has colour c in the colouring φ G of G. We frequently drop the notation G when G is clear from context. Further, if φ(e) = c then we say that e is a c-arc, and in the case that e is a loop we say that e is a c-loop. We write E c (G) for the set of c-arcs in G (including cloops), and we refer to E c (G) as the colour class of c. Fix u ∈ V (G). If d ∈ C is such that there is a d-arc uv in G, then the (unique) vertex v is called the d-out-neighbour of u, which we denote by N + d (u). We define the d-in-neighbour N − d (u) of u analogously. For D ⊆ C we define With a slight abuse of notation, we often refer to a pair (H, φ) where H is a digraph and φ is a proper arc-colouring of H as a 'coloured digraph' H implicitly equipped with a proper arc-colouring φ H (or simply φ if it is clear from the context). Using this convention, we let Φ( ← → K n ) denote the set of all properly n-arc-coloured digraphs G ∼ = ← → K n with vertex set and colour set [n]. (That is, the set of pairs (G, φ) where G ∼ = ← → K n and φ is a proper n-arc-colouring of G). For a coloured digraph G ∈ Φ( ← → K n ) and a set of colours D ⊆ [n] we define G| D to be the coloured digraph obtained by deleting all arcs of G having colours not in D, and we set G n D := {G| D : G ∈ Φ( ← → K n )}, though we always drop the n in the superscript as n will be clear from context. By symmetry of the roles of rows, columns, and symbols in Latin squares, the correspondence between Latin squares and elements G ∈ Φ( ← → K n ), and the well-known result that any Latin rectangle has a completion to a Latin square, it is clear that G D could be equivalently defined as the set of all pairs (H, φ H ), where H is a |D|-regular digraph on vertices [n], and φ H is a proper arc-colouring of H in colours D. Throughout the paper we will use the letter G for an element of Φ( ← → K n ), and the letter H for an element of G D (for any D). We often write random variables and objects in bold notation. For an event E in any probability space we use the notation E to denote the complement of E.

Overview of the proof
The proof of Theorem 1.6 proceeds in two key steps. We first analyze uniformly random G ∈ Φ( ← → K n ) and show that with high probability, G satisfies three key properties. It then suffices to suppose that a fixed G ∈ Φ( ← → K n ) satisfies these three properties, and use that hypothesis to build many rainbow directed Hamilton cycles in G. Before describing these properties, we discuss our strategy for building rainbow directed Hamilton cycles. To that end, we introduce the following definition.
is robustly rainbow-Hamiltonian (with respect to flexible sets V flex ⊆ V (H) and C flex ⊆ φ(H) of vertices and colours, and initial vertex u ∈ V (H) and terminal vertex v ∈ V (H)), if for any pair of equal-sized subsets X ⊆ V flex and Y ⊆ C flex of size at most min{|V flex |/2, |C flex |/2}, the graph H − X contains a rainbow directed Hamilton path with tail u and head v, not containing a colour in Y .
We show that for almost all G ∈ Φ( ← → K n ) and arbitrary sets V flex , C flex ⊆ [n] of sizes |V flex | = |C flex | = Ω(n/ log 3 n), G contains a robustly rainbow-Hamiltonian subgraph H with flexible sets V flex and C flex , such that H has O(n/ log 3 n) vertices and arcs in total. We construct rainbow directed Hamilton cycles by using the popular 'absorption' method, and H will form the key absorbing structure. More precisely, we find a rainbow directed path P having the terminal vertex v of H as its tail, the initial vertex u of H as its head, such that V (G) \ V (H) ⊆ V (P ), V (P ) ∩ V (H) is a subset of V flex of size at most |V flex /2|, and likewise for the colours. Letting X := V (P ) ∩ V (H) and Y := φ(P ) ∩ φ(H), the robust rainbow-Hamiltonicity of H guarantees there is a rainbow directed Hamilton path P ′ in H − X with tail u and head v, not containing a colour in Y , and P ∪ P ′ is a rainbow directed Hamilton cycle.
We find H by piecing together smaller building blocks we call 'absorbers' in a delicate way, where each absorber has the ability to 'absorb' a vertex v and a colour c not used by P . We delay a definition of a (v, c)-absorber to Definition 6.1, but we give a figure now (see Figure 1). Notice that a (v, c)-absorber has a rainbow directed Hamilton path with tail x 1 and head x 6 , and a rainbow directed path with the same head and tail using all vertices except v and all colours except c. This is the key property of a (v, c)-absorber, and by piecing these together in a precise way we ensure that the resulting union of absorbers (with the sets of specified vertices 'v' and colours 'c' forming V flex and C flex respectively) has the desired robustly rainbow-Hamiltonian property. For technical reasons, we find (v, c)-absorbers by piecing together two smaller structures we call (v, c)-absorbing gadgets and (y, z)-bridging gadgets (see Definitions 5.1 and 5.2, respectively), together with the short rainbow directed paths P 1 , P 2 , P 3 , P 4 as in Figure 1.
Thus, the first key property that we need almost all G ∈ Φ( ← → K n ) to satisfy, is that G contains many absorbing gadgets and bridging gadgets, in a 'well-spread' way that enables us to construct an appropriate robustly rainbow-Hamiltonian subgraph. We prove this in Section 5 using 'switchings' in Latin rectangles, then using permanent estimates (see [6,11,12], encapsulated by v x 1 x 2 . . , P4 are rainbow directed paths with directions as indicated, sharing no colours with each other or with the rest of the (v, c)-absorber.
Proposition 4.4 in the current paper) to compare a uniformly random k × n Latin rectangle to the first k rows of a uniformly random n × n Latin square. Lemma 5.6 ensures the existence of the absorbing gadgets we need, and Lemma 5.10 accomplishes the same for the bridging gadgets. This approach of using permanent estimates to translate statements between these probability spaces was pioneered by McKay and Wanless [29], who investigated the typical prevalence of 2 × 2 Latin subsquares (also called 'intercalates') in a uniformly random Latin square. For further insight into the usage of this method to study intercalates in random Latin squares, see for example [24][25][26]. As the substructures we seek are more complex than intercalates, and we moreover require that they are 'well-spread', our proof introduces new techniques for switching arguments in Latin rectangles. We note that in [15], the authors, with Kühn and Osthus, used switching arguments to analyze a uniformly random 1-factorization of K n and show that with high probability there is a large collection of subgraphs of a form analogous to that of our (v, c)-absorbing gadgets in the undirected setting. Fortunately, this argument also works in the directed setting with only minor changes, so we defer the proof of Lemma 5.6 to the appendix. Thus, Section 5 is primarily devoted to the proof of Lemma 5.9. The second property of almost all G ∈ Φ( ← → K n ) that we will need concerns the colours of the loops. Clearly, if we seek to find any rainbow directed Hamilton cycle of G ∈ Φ( ← → K n ), we need to know that there is no colour appearing only on loops in G, and this is given for almost all G ∈ Φ( ← → K n ) (in the context of Latin squares and in considerably stronger form) by Lemma 4.6. The third and final property of almost all G ∈ Φ( ← → K n ) that we will need is an appropriate notion of 'lower-quasirandomness', which roughly states that for any two subsets U 1 , U 2 of vertices of G and any set D of colours, the number of arcs in G with tail in U 1 , head in U 2 , and colour in D, is close to what we would expect if the colours of the arcs of G were assigned independently and uniformly at random. We delay the precise definition of lower-quasirandomness of G ∈ Φ( ← → K n ) to Definition 7.1. The desired property that almost all G ∈ Φ( ← → K n ) are lower-quasirandom will follow immediately from [26, Theorem 2] (see Theorem 4.7 of the current paper), originally stated in the context of 'discrepancy' of random Latin squares.
Armed with the three properties of typical G ∈ Φ( ← → K n ) described above, it then suffices to fix such a G and build many rainbow directed Hamilton cycles. In Section 6, we show that the existence of many well-spread absorbing and bridging gadgets enables us to greedily build a small robustly rainbow-Hamiltonian subgraph H ⊆ G with arbitrary flexible sets V flex and C flex of size Θ(n/ log 3 n), and in Section 7, we use this to prove Theorem 1.6. The rough idea is to first choose the flexible sets V flex and C flex randomly. Next, we use the lower-quasirandomness property of G to build a rainbow directed spanning path forest Q of G − H, one arc at a time, until Q has very few components. Then, we use the random choice of V flex and C flex , together with Lemma 4.6, to find short rainbow directed paths linking the components of Q and the designated start and end of H, which use all remaining colours of G − H, and at most half of V flex and C flex . Finally, we use the key robustly rainbow-Hamiltonian property of H to absorb the remaining vertices and colours in V flex and C flex as described above, completing the rainbow directed Hamilton cycle of G. To obtain the counting result on the number of rainbow directed Hamilton cycles in G, it suffices to count the number of choices we can make whilst building the rainbow directed spanning path forest Q of G − H.
We remark that this particular absorption strategy, wherein we create an absorbing structure with 'flexible' sets, is an instance of the 'distributive absorption' method, which was introduced by Montgomery [30] in 2018 and has been found to have several applications since. In particular, this method is also used in [23] and [15] to find transversals in random Latin squares and rainbow Hamilton paths in random 1-factorizations, respectively. Our approach differs from that of [23] and [15] in a few key ways. First, the 'asymmetry' of proper n-arc-colourings of ← → K n (in comparison to proper edge-colourings of K n with at most n colours, which correspond to proper n-arccolourings of ← → K n with monochromatic digons) and 'connectedness' of rainbow Hamilton cycles/ Hamilton transversals (in comparison to general transversals in Latin squares) necessitate a more complex absorbing structure than the one of either [23] or [15], which is more challenging to create and construct. Nevertheless, as mentioned, we show that switching arguments are sufficient for finding our absorbing structure, yielding a more elementary proof than that of [23], and moreover, by choosing our flexible sets randomly, we avoid complications involving vertices with few out-or in-neighbours in V flex on arcs with colour in C flex , providing a further simplification of the approach in [23]. In [15], results [2,31] on nearly perfect matchings in nearly regular hypergraphs are applied to auxiliary hypergraphs to construct both the absorbing structure and a nearly spanning rainbow path in a random 1-factorization of K n , but since the absorbers we use here (minus the internal vertices of the linking paths P 1 , . . . , P 4 ) are not regular, the analogous approach fails in the directed setting (as the corresponding auxiliary hypergraphs are not regular). However, as we show, the 'lower-quasirandomness' of typical G ∈ Φ( ← → K n ) is enough for us to find Q, the nearly spanning rainbow path forest, without these hypergraph matching results, and our absorbing structure is robust enough to augment it to a rainbow directed path.

Preliminaries
In this brief section we state some results that we will use in the proof of Theorem 1.6. We begin with a well-known concentration inequality for independent random variables.
Let X 1 , . . . , X m be independent random variables taking values in X , and let f : . . , x m )| ≤ c i , then we say X i affects f by at most c i .  [28]). If X 1 , . . . , X m are independent random variables taking values in X and f : X m → R is such that X i affects f by at most c i for all i ∈ [m], then for all t > 0, Next, we need the notion of 'robustly matchable' bipartite graphs, which will form a key part of our absorption argument. • We say T is robustly matchable with respect to flexible sets A ′ ⊆ A and B ′ ⊆ B, if for every pair of equal-sized subsets X ⊆ A ′ and Y ⊆ B ′ of size at most min{|A ′ |/2, |B ′ |/2}, there is a perfect matching in T − (X ∪ Y ). • For m ∈ N, we say T is a 2RM BG(7m, 2m) if |A| = |B| = 7m and T is robustly matchable with respect to flexible sets A ′ ⊆ A and B ′ ⊆ B where |A ′ | = |B ′ | = 2m.
The concept of using robustly matchable bipartite graphs in absorption arguments was first introduced by Montgomery [30]. We need the following observation of the authors, Kühn, and Osthus [15,Lemma 4.5], which is based on the work of Montgomery. Lemma 4.3 (Gould, Kelly, Kühn, and Osthus [15]). For all sufficiently large m, there is a 2RM BG(7m, 2m) that is 256-regular.
For a coloured digraph H ∈ G D , we define comp(H) to be the number of distinct ways to complete H to an element G ∈ Φ( ← → K n ), or more precisely the number of . We will use the following proposition to compare the probabilities of events in the probability spaces corresponding to uniformly random H ∈ G D (for some small D ⊆ [n]) and uniformly random G ∈ Φ( ← → K n ) (see for example the proof of Lemma 5.10). Proposition 4.4 follows immediately from (for example) [26,Proposition 5] as G D can easily be seen to be equivalent to the set of |D| × n Latin rectangles.
Next, we show (in the context of Latin squares) that a uniformly random G ∈ Φ( ← → K n ) does not have too many loops of a fixed colour. We first need the following well-known result on the number of fixed points of a random permutation.
Lemma 4.6. Let L be a uniformly random n × n Latin square with entries in [n], and suppose t ≥ 3 log n/ log log n. Let X be the random variable which returns the maximum (over the symbol set [n]) number of times that any symbol appears on the leading diagonal, in L. Then P [X ≥ t] ≤ exp(−Ω(t log t)).
Proof. Let L n be the set of n × n Latin squares with symbols [n], and for L, L ′ ∈ L n , write L ∼ L ′ if L ′ can be obtained from L via a permutation of the rows. Clearly, ∼ is an equivalence relation on L n . Note that L can be obtained by first choosing an equivalence class S ∈ L n /∼ uniformly at random and then choosing L ∈ S uniformly at random. We actually prove the stronger statement that for every equivalence class S ∈ L n /∼, if L ∈ S is chosen uniformly at random, then P [X ≥ t] ≤ exp(−Ω(t log t)).
Each equivalence class S ∈ L n /∼ has size n! and contains a unique representative L S,i with every symbol on the leading diagonal being i, for each i ∈ [n]. Applying a uniformly random row permutation σ to L S,i yields a uniformly random element L of S, and the number of appearances X i of i on the leading diagonal of L is equal to the number of fixed points of σ. Then, if t ≥ 3 log n/ log log n and n is sufficiently large, we have by Lemma 4.5 and Stirling's formula that where we have used the simple observation that n−k j=0 (−1) j j! ≤ 1 for all k ∈ [n] 0 . A union bound over symbols i ∈ [n] now completes the proof.
Finally, we need the following theorem of Kwan and Sudakov [26,Theorem 2], originally stated in the context of 'discrepancy' of random Latin squares. Theorem 4.7 ensures in particular that almost all G ∈ Φ( ← → K n ) are 'lower-quasirandom' (see Definition 7.1), which we will use when building and counting the almost-spanning rainbow directed path forests (see Lemma 7.2) that we later absorb into rainbow directed Hamilton cycles. x 3 x 4 x 5 The key building blocks for the absorbing structure we build in Section 6.

Absorbers via switchings
The aim of this section is to prove that almost all G ∈ Φ( ← → K n ) have many well-distributed absorbing gadgets and bridging gadgets, which we define now (see also Figure 2).
equipped with a proper arc-colouring φ A , such that the following holds: • the colours f 1 , f 2 , f 3 , c are distinct. In this case, we say (x 4 , x 5 ) is the pair of abutment vertices of A.
Definition 5.2. For distinct vertices y and z, a (y, z)-bridging gadget is a digraph B such that V (B) = {y, z, w 1 , w 2 , . . . , w 6 } and E(B) = {yw 1 , w 2 w 1 , w 2 w 3 , zw 3 , w 4 y, w 4 w 5 , w 6 w 5 , w 6 z}, equipped with a proper arc-colouring φ B , such that the following holds: As discussed in Section 3, the union of a (v, c)-absorbing gadget and an (x 4 , x 5 )-bridging gadget (together with some short rainbow directed paths) forms a structure we will call a (v, c)-absorber (see Figure 1 and Definition 6.1), which is the key building block of our absorption structure. To show that almost all G ∈ Φ( ← → K n ) contain the gadgets we need, we analyze switchings in the probability space corresponding to uniformly random H ∈ G D (recall that G D is the set of digraphs obtained from the digraphs in Φ( ← → K n ) by deleting all arcs with colour not in D) for small D ⊆ [n], before applying Proposition 4.4 to compare this probability space with that of uniformly random G ∈ Φ( ← → K n ) (see the proof of Lemma 5.10). First, we need the following lemma, which asserts that for small D ⊆ [n], a uniformly random H ∈ G D does not have too many more arcs than we would expect between any pair of vertex sets, each of size |D|.
For a colour c ∈ D and uniformly random H ∈ G D , we write F c = F c (H) for the random colour class of c in H (F here standing for 'factor'), so that H is determined by the random variables {F c } c∈D .
has size |D| = n/10 6 . Fix c ∈ D, let H ∈ G D be chosen uniformly at random, and let F c = F c (H). Then for any outcome F of F c we have ). The authors of [15] proved a lemma ([15, Lemma 6.3]) analogous to Lemma 5.4 in the undirected setting. The proof of Lemma 5.4 is similar so we omit it here. In the appendix, we describe how the proof of [15,Lemma 6.3] can be modified to obtain a proof of Lemma 5.4.
We condition on versions of upper-quasirandomness when we are using switching arguments to show that almost all H ∈ G D admit many absorbing gadgets and bridging gadgets. Further, we will need that H does not have many c-loops in order to find many (v, c)-absorbing gadgets, for any v ∈ V (H). Lemma 5.4 enables us to 'uncondition' from these two events, so as to study simply the probability that a uniformly random H has many absorbing gadgets.
Since, as discussed in Section 3, we eventually piece together gadgets in a greedy fashion to build an absorbing structure in a typical G ∈ Φ( ← → K n ), it will be important to know that we can find collections A of gadgets which are 'well-spread', in that no vertex or colour of G is contained in too many A ∈ A. We formalise this notion in the following definition.
Definition 5.5. Suppose that G is an n-vertex directed, arc-coloured digraph with vertices V and colours C. Fix v ∈ V , c ∈ C, and fix y, z ∈ V distinct. We say that a collection A of (v, c)-absorbing gadgets in G is well-spread if for all u ∈ V \ {v} and d ∈ C \ {c}, there are at most n distinct A ∈ A which contain u, and at most n distinct A ∈ A which contain d. We say that a collection B of (y, z)-bridging gadgets in G is well-spread if for all u ∈ V \ {y, z} and d ∈ C, there are at most n distinct B ∈ B which contain u, and at most n distinct B ∈ B which contain d.
The next lemma ensures that almost all G ∈ Φ( ← → K n ) contain the collections of well-spread absorbing gadgets that we need.
be chosen uniformly at random, and let E be the event that for all v, c ∈ [n], G contains a well-spread collection of at least n 2 /2 100 (v, c)-absorbing gadgets. Let C be the event that no colour class of G has more than n/10 9 loops. Then P [E | C] ≥ 1−exp(−Ω(n 2 )), and in particular, P [E] ≥ 1 − exp(−Ω(n log n)) by Lemma 4.6.
As with Lemma 5.4, the authors of [15] proved an analogous lemma ([15, Lemma 3.8]) in the undirected setting with a similar proof, so we omit it here but provide details in the appendix of how the proof of [15, Lemma 3.8] may be modified to prove Lemma 5.6.
The rest of this section is dedicated to showing that almost all G ∈ Φ( ← → K n ) have large wellspread collections of bridging gadgets (recall Figure 2b). For technical reasons that make the switching argument a little easier to analyze, we instead actually look for a slightly more special structure. In particular, we add some extra arcs so that all vertices we find are in the neighbourhood of y or of z, we partition the colours to limit the number of 'roles' certain arcs can play when we apply the switching operation, and we introduce the notion of distinguishability, which will be useful when arguing that the gadgets we find are well-spread.
, let H ∈ G D , and let P = (D i ) 6 i=1 be an equitable (ordered) partition of D into six parts. Let y, z ∈ [n] be distinct vertices.
• We say that a subgraph B ⊆ H is a (y, z, P)-bridge (see Figure 3) if B is the union of a (y, z)-bridging gadget B ′ (with vertex-and colour-labelling as in Definition 5.2) and the extra arcs yw 2 , zw 5 , such that • we say that a (y, z, in H containing any of the arcs w 2 w 1 , w 2 w 3 , w 4 w 5 , w 6 w 5 ; • we write r (y,z,P) (H) for the number of distinguishable (y, z, P)-bridges in H; • for s ∈ [n|D|] 0 , we write M We frequently drop the (y, z, P)-notation in the terminology introduced above when the tuple (y, z, P) is clear from context. For every distinct y, z ∈ [n] and equitable partition In Lemma 5.9 we use switchings on some H ∈ G D to produce some H ′ ∈ G D having r(H ′ ) = r(H) + 1. As mentioned earlier, we condition on upper-quasirandomness in this lemma; more specifically, we will condition that H ∈ Q D . The notion of distinguishability of (y, z, P)-bridges is useful because, as we show in Lemma 5.10, Claim 1, a collection of distinguishable (y, z, P)bridges in G| D is necessarily well-spread (recall Definition 5.5).
We now discuss the switching operation that forms the backbone of the proof of Lemma 5.9.
. For a twist system T ⊆ H, we define twist T (H) to be the coloured digraph obtained from H by deleting the arcs u ′ The (y, z, P)-bridge in twist T (H) with arc set {yu 1 , yu 2 , u 2 u 1 , u 2 u 3 , zu 3 , u 6 z, zu 5 , u 6 u 5 , u 4 u 5 , u 4 y} is called the canonical (y, z, P)-bridge of the twist.
Notice that if H ∈ G D and T is a twist system of H, then twist T (H) ∈ G D , even if u ′ 1 , . . . , u ′ 8 are not distinct. We now use the twist switching operation to argue that almost all H ∈ Q D have many distinguishable (y, z, P)-bridges, for fixed y, z, P, and appropriately sized D.
by putting an arc HH ′ whenever H ∈ M s contains a twist system T for which the canonical (y, z, P)-bridge of the twist is distinguishable in twist T (H) =: To that end, we first obtain an upper bound for ∆ − s+1 . Fix H ′ ∈ M s+1 . There are s + 1 choices of a distinguishable (y, z, P)bridge B in H ′ which could have been the canonical (y, z, P)-bridge of a twist of a graph H ∈ M s producing H ′ . There are then at most n 8 choices for the eight additional arcs added by a twist whose canonical bridge is B since the colours of these arcs are determined by B and there are n arcs of each colour in H ′ . For any such sequence of choices, there is a unique H ∈ M s and twist system T ⊆ H such that twist We now find a lower bound for δ + s , in the case where s ≤ k 4 /(10 24 n 2 ). Fix H ∈ M s . We proceed by finding a large collection T of distinct twist systems in H, such that for each T ∈ T , the canonical (y, z, P)-bridge of the twist is distinguishable in twist T (H) =: H ′ and H ′ ∈ M s+1 . We do this by ensuring that for any T ∈ T , the arc deletions involved in twisting on T do not decrease r(H), and that the only (y, z, P)-bridge created by the arc additions involved in twisting on T is the canonical (y, z, P)-bridge B of the twist (whence B is evidently distinguishable in H ′ ). We first use the assumption on s to argue that H is not far from being upper-quasirandom (as per Definition 5.3). Indeed, since H ∈ M s and s ≤ k 4 /(10 24 n 2 ) we have by Definition 5.7 that for any sets We now use (5.2) to find a large set Λ of choices for a sequence of colours and arcs λ = (d 1 , d 2 , . . . , d 6 , e 1 , . . . , e 4 ) with d i ∈ D i , and e i ∈ E d i (H), such that λ has a number of desirable properties. We simultaneously use such a sequence λ to choose vertices u 1 , . . . , u 6 , u ′ 1 , . . . , u ′ 8 , u ′′ 1 , . . . , u ′′ 8 as in Definition 5.8 and a subgraph T λ ⊆ H[{y, z} ∪ U int ∪ U mid ∪ U ext ], thus constructing a set T of such T λ by ranging over all λ ∈ Λ. We will then use the known properties of the sequences λ ∈ Λ to verify that each T λ ∈ T is a twist system for which the arc There are at most 10 8 loops with colour d 1 in H; (D 1 2) u 1 has at most 300k 2 /n in-neighbours in the set N + D 5 (y); (D 1 3) there are at most k/100 arcs e coloured d 1 in H such that e is contained in a distinguishable (y, z, P)-bridge in H; (D 2 1) there are at most 10 8 loops with colour d 2 in H; (D 2 2) u 6 has at most 300k 2 /n out-neighbours in the set N + D 6 (z); (D 2 3) there are at most k/100 arcs e coloured d 2 in H such that e is contained in a distinguishable (y, z, P)-bridge in H; (V 1,2 ) the vertices y, z, u 1 , u 6 are distinct, and u ′ Since H contains at most n loops, |D 1,1 | ≤ n/10 8 = k/100. Since e H (N + D 5 (y), N + D 1 (y)) ≤ 3k 3 /n by (5.2), |D 1,2 | ≤ k/100. Since any d 1 -arc of H whose tail is not y is contained in at most one distinguishable (y, z, P)-bridge B and each B contains two such arcs, r(H) ≥ |D 1,3 |(k/100−1)/2.
Claim 5: For any T λ ∈ T , the only (y, z, P)-bridge in twist T λ (H) that is not in H is the canonical (y, z, P)-bridge of the twist.
Proof of claim: Fix T λ ∈ T (fixing the notation of all the vertices and arcs as above), and let B be the canonical (y, z, P)-bridge of the twist (which has vertices V (B) = {y, z, u 1 , . . . , u 6 } and colours d 1 , . . . , d 6 ). Suppose that B ′ is a (y, z, P)-bridge in twist T λ (H) that is not in H, and label the vertices of B ′ as V (B ′ ) = {y, z, v 1 , . . . , v 6 } (where the role of v i in B ′ corresponds to that of u i in B), and label the colours of B ′ as d ′ i ∈ D i , for i ∈ [6]. By (V 1,2 ), (V 3,4 ), and (V 5,6 ), all arcs we add when producing twist T λ (H) from H do not have y or z as an endpoint, and thus one (or more) of the arcs v 2 v 1 , v 2 v 3 , v 4 v 5 , v 6 v 5 is added by the twist operation. Further, due to the colour partition P, v 2 v 1 must either be in H, or be one of the added arcs But since we do not add any arcs incident to y, by (E2), u ′′ 1 and u ′′ 2 are not in the neighbourhood of y in twist T λ (H), whence u ′′ 1 cannot be v 1 , and u ′′ 2 cannot be v 2 . Thus v 2 v 1 must either be in H, or be u 2 u 1 . Similarly v 2 v 3 , v 4 v 5 , v 6 v 5 must be u 2 u 3 , u 4 u 5 , u 6 u 5 respectively, or be in H, in some combination. We now split the analysis into cases, depending on how many arcs in F : In each case we show either that that case does not occur or that B ′ = B, which will complete the proof of the claim. Since B ′ H, at most three arcs in F are in H. Case 1: Precisely three arcs in F are in H. Let e be the arc in F that is not in H. Suppose e = v 2 v 1 , which implies that e = u 2 u 1 , and and v 5 is the d ′ 1 -out-neighbour of v 6 in twist T λ (H), which is the d 1 -out-neighbour of u 6 in twist T λ (H), namely u 5 . This is a contradiction, since v 6 v 5 is in H, but u 6 u 5 is not. One similarly obtains a contradiction if e is v 2 v 3 , v 4 v 5 , or v 6 v 5 , so we deduce that this case does not occur.
But this now also determines that v 4 v 5 = u 4 u 5 and v 6 v 5 = u 6 u 5 , a contradiction since then no arcs in F are in H. All remaining possibilities yield a contradiction similarly, whence this case does not occur. Case 3: Precisely one arc in F is in H.
We are now ready to argue that almost all G ∈ Φ( ← → K n ) contain large well-spread collections of bridging gadgets, which will complete our study of the properties we need to be satisfied by uniformly random G ∈ Φ( ← → K n ).
Lemma 5.10. Let G ∈ Φ( ← → K n ) be chosen uniformly at random, and let E be the event that for all distinct y, z ∈ [n], G contains a well-spread collection of at least n 2 /10 50 distinct (y, z)-bridging gadgets. Then P [E] ≥ 1 − exp(−Ω(n 2 )).
Proof. For D ⊆ [n], let E| D denote the event (in Φ( ← → K n )) that G| D contains a well-spread collection of n 2 /10 50 distinct (y, z)-bridging gadgets, for each distinct y, z, ∈ [n]. Let H ∈ G D be chosen uniformly at random, let P D denote the measure for this probability space, and let E (y,z) D denote the event (in G D ) that H contains a well-spread collection of n 2 /10 50 distinct (y, z)bridging gadgets, and define E D := y,z∈[n] distinct E (y,z) D . Claim 1: Suppose D ⊆ [n] has size |D| ≤ 3n/4, let P = (D i ) i∈ [6] be an equitable partition of D into six parts, and fix y, z, ∈ [n] distinct. Then P D r (y,z,P) (H) ≥ n 2 /10 50 ≤ P D E (y,z) D . Proof of claim: Suppose that H ∈ G D and that r(H) ≥ n 2 /10 50 . By definition of r(H) (see Definition 5.7), there is a collection B of n 2 /10 50 distinct (y, z, P)-bridges such that for each i ∈ [4], any d i ∈ D i , and any arc e ∈ E d i (H) for which e does not have y nor z as an endvertex, we have that e is contained in at most one B ∈ B. Note that for each u ∈ [n] \ {y, z}, we have for any B ∈ B which contains u, that B must contain an arc e incident to u with colour in D i for some i ∈ [4] such that e is not incident to y nor z. Therefore u is contained in at most 4 · 2 · |D|/6 ≤ n distinct B ∈ B. For any colour d ∈ D 1 , any B ∈ B which uses the colour d must be such that N + d (y) / ∈ {y, z} and must contain the vertex N + d (y), and thus the colour d is used by at most n distinct B ∈ B (and similarly for d ∈ D i for all i ∈ [6]). Now, forming a collection B ′ of (y, z)-bridging gadgets in H by deleting the arcs with colours in D 5 ∪ D 6 for each B ∈ B, it is clear that B ′ witnesses that H ∈ E (y,z) D . The claim follows. − Arbitrarily fix c ∈ [n] and D ⊆ [n] of size |D| = n/10 6 , and let F be the set of all possible colour classes for a proper n-arc colouring of ← → K n (more precisely, F is the collection of all sets F of n arcs of ← → K n such that every vertex of ← → K n is the head of precisely one arc in F and the tail of precisely one arc in F ). Observe that for a fixed equitable partition P = (D i ) 6 i=1 of D into six parts, and for fixed distinct y, z ∈ [n], by (5.1), the law of total probability, and Lemma 5.4, Then the law of total probability, (5.3), and Lemma 5.9 give (5.4) P D r (y,z,P) (H) ≤ n 2 10 50 ≤ P D r (y,z,P) (H) ≤ n 2 10 50 Q D + P D Q D ≤ exp(−Ω(n 2 )).
By ( which completes the proof of the lemma.

Absorption
The aim of this section is to show that if G ∈ Φ( ← → K n ) satisfies the conclusions of Lemmas 5.6 and 5.10, then G admits a small robustly rainbow-Hamiltonian subdigraph H (recall Definition 3.1), with arbitrarily chosen flexible sets of appropriate size. In Section 7, H will form the key 'absorbing structure'. In this case, we also say a collection (P 1 , P 2 , P 3 , P 4 ) of properly arc-coloured directed paths completes the pair (A, B) if: • P 1 has tail x 2 and head x 3 ; • P 2 has tail w 1 and head w 4 ; • P 3 has tail w 5 and head w 2 ; • P 4 has tail w 3 and head w 6 ; • P 1 , . . . , P 4 are mutually vertex-disjoint and the internal vertices of P 1 , . . . , P 4 are disjoint from V (A) ∪ V (B); • 4 i=1 P i is rainbow and shares no colour with A ∪ B. In this case, we say that Figure 1), and we also define the following.
• The initial vertex of A * is x 1 , and the terminal vertex of A * is x 6 .
• The (v, c)-absorbing path in A * is the directed path with arc set Observe that the (v, c)-absorbing path and (v, c)-avoiding path of a (v, c)-absorber satisfy the following key properties.
(6.1) The initial (resp. terminal) vertex of a (v, c)-absorber is the tail (resp. head) of both the (v, c)-absorbing path and the (v, c)-avoiding path. (6.5) The (v, c)-avoiding path in a (v, c)-absorber is rainbow and contains all of the colours except c. We now use (v, c)-absorbers to define a 'T -absorber' for a bipartite graph T , which will essentially form our absorbing structure in almost all G ∈ Φ( ← → K n ), for suitably chosen T . The role of T is to provide the 'template' for which pairs (v, c) must provide a (v, c)-absorbing path to the rainbow directed Hamilton cycle we are building, and which pairs must provide a (v, c)-avoiding path. Definition 6.2. Let T be a bipartite graph with bipartition (A, B). A digraph H equipped with a proper arc-colouring φ is a T -absorber if the following holds.
(i) There exist injections f V : A → V (H) and f C : There exist pairwise vertex-disjoint length-three paths P 1 , . . . , P |E(T )|−1 , each contained in H, satisfying the following.
(a) Suppose that a bipartite graph T is robustly matchable (recall Definition 4.2) with respect to flexible sets A ′ and B ′ . The following lemma shows that a T -absorber is robustly rainbow-Hamiltonian (recall Definition 3.1) with respect to the root vertices and colours corresponding to A ′ and B ′ . This (together with Lemmas 5.6 and 5.10) reduces the task of finding such a subdigraph in almost all G ∈ Φ( ← → K n ) to the task of using large well-spread collections of (v, c)absorbing gadgets and (y, z)-bridging gadgets to embed a T -absorber, for an appropriate robustly matchable T . Lemma 6.3. Let G ∈ Φ( ← → K n ) with proper n-arc-colouring φ. Let T be a bipartite graph with bipartition (A, B), let H ⊆ G be a T -absorber, and let u and v be the initial and terminal vertices of H, respectively. Let A ′ ⊆ A and B ′ ⊆ B, and let V ′ and C ′ be the set of root vertices and colours of H corresponding to A ′ and B ′ , respectively. If T is robustly matchable with respect to flexible sets A ′ and B ′ , then H is robustly rainbow-Hamiltonian with respect to flexible sets V ′ and C ′ and initial and terminal vertices u and v.

Proof.
Let X ⊆ V ′ and Y ⊆ C ′ such that |X| = |Y | ≤ min{|V ′ |/2, |C ′ |/2}. It suffices to show that H − X contains a rainbow directed Hamilton path which starts at u and ends at v, not containing a colour in Y . Since H is a T -absorber, by Definition 6. Since V ′ and C ′ are the sets of root vertices and colours of H corresponding to A ′ and B ′ , Thus, since T is robustly matchable with respect to A ′ and B ′ , there exists a perfect matching . For each ab ∈ E(T ), define a directed path P ab as follows. If ab ∈ M , then let P ab be the (f V (a), f C (b))-absorbing path in A ab , and otherwise let P ab be the (f V (a), f C (b))-avoiding path in A ab . Now let P := e∈E(T ) P e ∪ |E(T )|−1 i=1 P i . We claim that P is a rainbow directed Hamilton path in H − X which starts at u, ends at v, and does not contain a colour in Y . To that end, we first show the following: (a) u has out-degree one and in-degree zero in P ; (b) v has in-degree one and out-degree zero in P ; (c) every w ∈ V (P ) \ {u, v} has in-degree and out-degree one in P ; . Indeed, (a) and (b) follow from (6.1), 6.2(i)(a), 6.2(ii)(b), and 6.2(ii)(c), and (c) follows from (6.1), (6.4), 6.2(i)(a), 6.2(ii)(b), and 6.2(ii)(c).
By (6.1), 6.2(ii)(b), 6.2(ii)(c), and (a)-(c), P contains no cycle, so (a)-(e) imply that P is indeed a directed path in H − X, not containing a colour in Y , which starts at u and ends at v, and (f) implies that P is Hamilton in H − X, as required. It remains to show that P is rainbow. By (6.3), (6.5), and 6.2(i)(b), e∈E(T ) P e is rainbow, so 6.2(ii)(a) implies that P is rainbow, as required.
The following proposition implies that there are many short rainbow paths that are 'wellspread' in all G ∈ Φ( ← → K n ). This enables us to embed these paths in any such G in a vertex-and colour-disjoint way whilst constructing a T -absorber for suitably chosen T , and whilst absorbing the colours unused by the large rainbow directed path forests we find in Section 7.
Proposition 6.4. Let G ∈ Φ( ← → K n ) with proper n-arc-colouring φ, let V := V (G), and let C := φ(G). Let u, v ∈ V such that u = v, and let c ∈ C. The following holds for n sufficiently large.
(i) There are at least n 2 /3 length-three directed rainbow paths in G with head v and tail u.
(ii) If at most n/2 loops in G are coloured c, then there are at least n 2 /5 length-four directed rainbow paths in G with head v and tail u such that the second arc is coloured c. (iii) For every w ∈ V , there are at most 2n length-three directed rainbow paths in G with head v and tail u that contain w as an internal vertex. (iv) For every w ∈ V , there are at most 3n length-four directed rainbow paths in G with head v and tail u that contain w as an internal vertex such that the second arc is coloured c. (v) For every d ∈ C, there are at most 3n length-three directed rainbow paths in G with head v and tail u that contain an arc coloured d. (vi) For every d ∈ C \ {c}, there are at most 3n length-four directed rainbow paths in G with head v and tail u that contain an arc coloured d such that the second arc is coloured c.
Proof. First, for each vertex w ∈ V , we let B w := {x ∈ V \ {w, v} : φ(wx) = φ(xv)}, we say w is bad if |B w | > n/2, and we let B ⊆ V be the set of bad vertices. We claim that there is at most one bad vertex; that is, |B| ≤ 1. To that end, suppose for a contradiction that distinct vertices w and w ′ are bad.
The proofs of (iii)-(vi) are similar, so we only provide a complete proof of (vi). Fix d ∈ C \{c}, and let P (vi) be the set of length-four rainbow directed paths in G with head v and tail u that contain an arc coloured d such that the second arc is coloured c. Partition P (vi) into sets P (vi),1 , . . . , P (vi),4 such that for i ∈ [4], a path P ∈ P (vi),i if the arc coloured d is the ith arc of P . Since d = c, P (vi),2 = ∅. Every path in P (vi),1 is uniquely determined by the vertex in the path adjacent to v, every path in P (vi),3 is uniquely determined by an ordered pair (w 2 , w 3 ) such that φ(w 2 w 3 ) = d, and every path in P (vi),4 is uniquely determined by an ordered pair (w 1 , w 2 ) such that φ(w 1 w 2 ) = c. Therefore |P (vi) | ≤ 3n, as desired.
We conclude by outlining the necessary changes to the proof of (vi) to obtain proofs of (iii)-(v). Define P (iii) , P (iv) , and P (v) in an analogous way. Partition P (iii) and P (iv) based on the position of w in each path, and partition P (v) based on the position of the arc coloured d. Finally, show that each part contains at most n paths.
For any m = ω(1) (in Section 7 we will set m := ⌊n/ log 3 n⌋, and we assume n to be sufficiently large) we have by Lemma 4.3 that there exists a 256-regular 2RM BG(7m, 2m), say T (recall Definition 4.2). In the following lemma, we show that if m < n/ log n, then we may greedily embed a T -absorber in any G ∈ Φ( ← → K n ) that satisfies the conclusions of Lemma 5.6 and 5.10, by choosing each absorber successively in three steps: for each edge vc of T , we first embed a (v, c)-absorbing gadget A, then choose a bridging gadget B that bridges A (recall Definition 6.1), and finally use Proposition 6.4 to embed the extra short rainbow paths required to complete the (v, c)-absorber and connect it to the previously embedded absorber.
Lemma 6.5. Let G ∈ Φ( ← → K n ) with proper n-arc-colouring φ, let V := V (G), and let C := φ(G). Let m < n/ log n, let T be a 256-regular 2RM BG(7m, 2m), let U ⊆ V and D ⊆ C such that |U | = |D| = 7m, and let V ′ ⊆ U and C ′ ⊆ D such that |V ′ | = |C ′ | = 2m. For n sufficiently large, if • for all v ∈ V and c ∈ C, G contains a well-spread collection A v,c of at least n 2 /2 100 (v, c)-absorbing gadgets and • for all distinct y, z ∈ V , G contains a well-spread collection B y,z of at least n 2 /10 50 (y, z)-bridging gadgets, then G contains a T -absorber H rooted on vertices U and colours D such that V ′ and C ′ are the sets of root vertices and colours of H corresponding to the flexible sets of T . (ii) a (y j , z j )-bridging gadget B j in G, where (y j , z j ) is the pair of abutment vertices of A j , which bridges A j , and (iii) length-three rainbow directed paths P j,1 , . . . , P j,5 in G, such that P j,1 , . . . , P j,4 complete the pair (A j , B j ) to a (v, c)-absorber A * j , such that the following holds: ℓ ∪ P ℓ,5 ) = ∅ for all ℓ < j, and φ(B j ) ∩ D = ∅; (e) j V (P j,k ) ∩ V (A * ℓ ∪ P ℓ,5 ) = ∅ for all k ∈ [4] and ℓ < j, and V (P j,k ) ∩ U = ∅ for all k ∈ [5]; (f) j φ(P j,k ) ∩ φ(A * ℓ ∪ P ℓ,5 ) = ∅ for all k ∈ [4] and ℓ < j, and φ(P j,k ) ∩ D = ∅ for all k ∈ [5]; (g) j φ(P j,5 ) ∩ φ(A * ℓ ) = ∅ for all ℓ ≤ j, and φ(P j,5 ) ∩ φ(P ℓ,5 ) = ∅ for all ℓ < j; (h) j if j > 1, then the tail of P j,5 is the terminal vertex of A * j−1 , the head of P j,5 is the initial vertex of A * j , P j,5 is internally vertex-disjoint from A * ℓ for all ℓ ≤ j, V (P j,5 ) ∩ V (P ℓ,5 ) = ∅ for all ℓ < j, and if j = 1, then P j,5 = ∅.
To that end, we let i ∈ [|E(T )|] and assume A j , B j , and P j,1 , . . . , P j,5 satisfying (a) j -(h) j have been chosen for j < i, and we show that we can indeed choose A j , B j , and P j,1 , . . . , P j,5 according to (i)-(iii) satisfying (a) j -(h) j for j = i. Let U ′ := U ∪ ℓ<j V (A * ℓ ∪ P ℓ,5 ), and let D ′ := D ∪ ℓ<j φ(A * ℓ ∪P ℓ,5 ). For every ℓ < j, we have by (i)-(iii) that |V (A * ℓ ∪P ℓ,5 )|, |φ(A * ℓ ∪P ℓ,5 )| ≤ 24. Thus, since T is 256-regular and m < n/ log n, First we show that we can choose a (v, c)-absorbing gadget A j according to (i) satisfying (a) j and (b) j . By assumption, G contains a well-spread collection A v,c of n 2 /2 100 (v, c)-absorbing gadgets. For each u ∈ U ′ , let v,c , A j satisfies (a) j and (b) j , as desired. Now let (y j , z j ) be the abutment vertices of A j . By a similar argument, we can choose a (y j , z j )-bridging gadget B j according to (ii) satisfying (c) j and (d) j .
Finally, we show that we can choose P j,1 , . . . , P j,5 according to (iii) satisfying (e) j -(h) j . The argument is again similar, using (i), (iii), and (v) of Proposition 6.4 instead of the existence of a well-spread collection of gadgets, so we omit the proof.
To complete the proof, we show that H : In this section we use the results we have obtained thus far to prove Theorem 1.6. We begin by arguing that a 'lower-quasirandomness' condition in G ∈ Φ( ← → K n ) (which holds in almost all G ∈ Φ( ← → K n ) by Theorem 4.7) is enough to ensure the existence of many rainbow directed path forests spanning all but a small arbitrary set of vertices, avoiding a small arbitrary forbidden set of colours, and having few components. We remark that the method we use to count the rainbow directed path forests is inspired by the method used by Kwan (see the proof of [23,Lemma 5.5]) to count large matchings in random Steiner triple systems.
with proper n-arc-colouring φ, let V := V (G), and let C := φ(G). Let U ⊆ V and let D ⊆ C be equal-sized sets of size at most n/ log 2 n. If G is lower-quasirandom, then there are at least (1 − o(1))n/e 2 n spanning rainbow directed path forests Q of G − U such that φ(Q) ∩ D = ∅ and Q has at most n 9/10 components.
Proof. Throughout the proof we implicitly assume n is sufficiently large for certain inequaities to hold. We say a rainbow directed path forest in G is valid if it has no vertices in U and no colours in D. Let n ′ := n − |U | − ⌊n 9/10 ⌋, and let n ′′ := n − |U |. If Q is a spanning directed path forest of G − U , then the number of components of Q is equal to |V \ U | − |E(Q)|, so Q has at most n 9/10 components if and only if it has at least n ′ arcs. Thus, it suffices to count the number of valid rainbow directed path forests in G that have n ′ arcs. To that end, we first count the number of ordered sequences of arcs (e 1 , . . . , e n ′ ) such that n ′ i=1 e i is a valid rainbow directed path forest in G. We claim that for every j ∈ [n ′ ], if e 1 , . . . , e j−1 are arcs in G such that j−1 i=1 e i is a valid rainbow directed path forest, then there are at least (1 − o(1)) (n ′′ − (j − 1)) 3 /n choices of an arc e j ∈ E(G) such that j i=1 e j is also a valid rainbow directed path forest. Let V H be the set of vertices u ∈ V \ U such that u has no out-neighbor in j−1 i=1 e i , let V T be the set of vertices u ∈ V \U such that u has no in-neighbor in j−1 i=1 e i , and let D ′ : , and since j ≤ n ′ = n ′′ − ⌊n 9/10 ⌋, we have that The spanning path forest in G − U with edge set {e 1 , . . . , e j−1 } has k := n ′′ − (j − 1) components, which we denote P 1 , . . . , P k . For every i ∈ [k], there is a unique arc f i ∈ E(G) (whose head is the tail of P i and whose tail is the head of P i ) such that P i ∪ f i is a directed cycle. Let F := {f 1 , . . . , f k }, and let e j ∈ E G,D ′ (V H , V T ) \ F . By the choice of V H , V T , D ′ , and F , we have that j i=1 e i is rainbow, has maximum in-degree and out-degree one, and contains no cycle. Hence, it is a valid rainbow directed path forest, as required. By (7.1) (1)) (n ′′ − (j − 1)) 3 /n, so the claim follows.
Therefore, the number of ordered sequences of arcs e 1 , . . . , e n ′ ∈ E(G) such that n ′ i=1 e i is a valid rainbow directed path forest is at least Since |U | ≤ n/ log 2 n, we have n ′ ≥ n − 2n/ log 2 n and (n ′′ ) 3 /n ≥ (1 − 3/ log 2 n)n 2 . Hence, Since the function x → log(1 − x) is negative and monotonically decreasing for x ∈ [0, 1), By substituting (7.3) and (7.4) into the right side of (7.2), the expression in (7.2) is at least By Stirling's approximation, n! = (1 + O(1/n)) √ 2πn(n/e) n ≤ ((1 + o(1))n/e) n . Hence, since (7.5) provides a lower bound on the number of ordered sequences of edges e 1 , . . . , e n ′ ∈ E(G) such that n ′ i=1 e i is a valid rainbow directed path forest, the total number of valid rainbow directed path forests in G with at most n 9/10 components is at least We now have all the tools we need to prove Theorem 1.6.
Proof of Theorem 1.6. Let G ∈ Φ( ← → K n ) with proper n-arc-colouring φ, let V := V (G), and let C := φ(G). By Lemma 4.6, Theorem 4.7, and Lemmas 5.6 and 5.10, it suffices to show that if (7.6) for every c ∈ C, at most n/2 loops in G are coloured c, (7.7) G is lower-quasirandom, (7.8) G contains a well-spread collection of at least n 2 /2 100 (v, c)-absorbing gadgets for every v ∈ V and c ∈ C, and (7.9) G contains a well-spread collection of at least n 2 /10 50 (y, z)-bridging gadgets for every y, z ∈ V , then G contains at least (1 − o(1)) n/e 2 n rainbow directed Hamilton cycles.
Let m = ⌊n/ log 3 n⌋, and let T be a 256-regular 2RM BG(7m, 2m) (which exists by Lemma 4.3). We build a T -absorber H in G using Lemma 6.5, but first we need the following claim to choose the roots of H that will correspond to the flexible sets of T .
Claim 1: There exist V ′ ⊆ V and C ′ ⊆ C such that |V ′ | = |C ′ | = 2m and for every u, v ∈ V such that u = v and for every c ∈ C, there are at least n 99/50 directed paths P in G such that (i) P is rainbow and has length four, (ii) P has head v and tail u, (iii) the second arc of P is coloured c, Proof of claim: Let p := (2m + n 9/10 )/n, and let U ′ ⊆ V and D ′ ⊆ C be chosen randomly by including every v ∈ V in U ′ and every c ∈ C in D ′ independently with probability p. We claim that the following holds with high probability: (a) |U ′ |, |D ′ | = pn ± n 4/5 , and (b) for every u, v ∈ V such that u = v and for every c ∈ C, there are at least p 6 n 2 /10 directed paths P in G satisfying (i)-(iii), such that V (P ) \ {u, v} ⊆ U ′ and φ(P ) \ {c} ⊆ D ′ . Indeed, (a) follows from a standard application of the Chernoff Bound. To prove (b), we use McDiarmid's Inequality. To that end, fix u, v ∈ V distinct and c ∈ C. We let f denote the random variable counting the number of paths satisfying (b). Note that f is determined by the independent binomial random variables {X w : w ∈ V } ∪ {X d : d ∈ C}, where X w indicates if w ∈ U ′ and X d indicates if d ∈ D ′ . By (7.6) and Proposition 6.4(ii), there are at least n 2 /5 paths satisfying (i), (ii), and (iii), and each such path satisfies V (P ) \ {u, v} ⊆ U ′ with probability p 3 and φ(P ) \ {c} ⊆ D ′ with probability p 3 , independently. Hence, E [f ] ≥ p 6 n 2 /5. For each w ∈ V , by Proposition 6.4(iv), X w affects f by at most 3n, and for each d ∈ C, by Proposition 6.4(vi), X d affects f by at most 3n. Therefore by McDiarmid's Inequality (Theorem 4.1) applied with t := E [f ] /2, there are at least p 6 n 2 /10 paths satisfying (b) with probability at least 1 − exp(−Ω(p 12 n)). Hence, by a union bound, (b) holds for every u, v ∈ V with u = v and every c ∈ C with high probability, as claimed. Now we fix a choice of U ′ and D ′ satisfying both (a) and (b) simultaneously. By (a), |U ′ |, |D ′ | ≥ 2m, so there exists V ′ ⊆ U ′ and C ′ ⊆ D ′ such that |V ′ | = |C ′ | = 2m, as required. Moreover, by (a), |U ′ \ V ′ |, |D ′ \ C ′ | ≤ 2n 9/10 . Thus, by Proposition 6.4(iv) and 6.4(vi), (b) implies that for every u, v ∈ V distinct and c ∈ C, there are at least p 6 n 2 /10 − 2(2n 9/10 )(3n) ≥ n 99/50 directed paths satisfying (i)-(v), as desired. − Now let U ⊆ V and D ⊆ C such that |U | = |D| = 7m, V ′ ⊆ U , and C ′ ⊆ D. By Lemma 6.5, (7.8), and (7.9), there is a T -absorber H in G rooted on U and D such that V ′ and C ′ are the sets of root vertices and colours of H corresponding to the flexible sets of T . By Lemma 6.3, H is robustly rainbow-Hamiltonian with respect to flexible sets V ′ and C ′ and initial and terminal vertices t and h, where t is the initial vertex of H and h is the terminal vertex of H. Note that Claim 2: If Q is a spanning rainbow path forest in G − V (H), sharing no colour with H, with at most n 9/10 components, then G has a rainbow directed Hamilton cycle F such that F −V (H) = Q.
Proof of claim: Let P 1 , . . . , P k be the components of Q, and for each i ∈ [k], let h i be the head of P i , and let t i be the tail of P i . Let t k+1 denote the initial vertex of H, and let h 0 denote the terminal vertex of H. That is, t k+1 := t and h 0 := h. Let c 1 , . . . , c k ′ be an enumeration of the colours in C \ (φ(H) ∪ φ(Q)). Since Q is rainbow, |φ(Q)| = |E(Q)| = |V \ V (H)| − k, so by (7.10), k ′ = k + 1. By Claim 1, for each j ∈ [k + 1], there is a collection P j of at least n 99/50 directed paths satisfying (i)-(v) where u = h j−1 , v = t j , and c = c j . For each j ∈ [k + 1], we inductively choose a path P ′ j ∈ P j such that (a) j φ(P ′ j ) ∩ φ(P ′ ℓ ) = ∅ for every ℓ < j and To that end, we let i ∈ [k+1] and assume P ′ j ∈ P j has been chosen to satisfy (a) j and (b) j for each j < i, and we show that we can indeed choose such a P ′ j for j = i.
. For each u ∈ U j , let P u := {P ∈ P j : u ∈ V (P )}, and for each d ∈ D j , let P d := {P ∈ P j : d ∈ φ(P )}. Let P ′ j := P j \ u∈U j P u ∪ d∈D j P d . By Proposition 6.4(iv), |P u | ≤ 3n for each u ∈ U j , and by Proposition 6.4(vi), |P d | ≤ 3n for each d ∈ D j . Since P ′ ℓ has length four for each ℓ < j, we have |U j |, |D j | ≤ 3k. Hence, |P ′ j | ≥ n 99/50 − (6k)(3n) > 0. In particular, there exists P ′ j ∈ P ′ j . By construction of P ′ j , P ′ j satisfies (a) j and (b) j , as desired. Since Q shares no vertices or colours with H, for each j ∈ [k + 1], since the internal vertices of P ′ j are in V ′ ⊆ V (H) and since φ(P ′ j ) \ D ′ = {c j }, it follows that P ′ j ∪ P j is a rainbow directed path with tail h j−1 and head h j . Moreover, by induction, using (a) j and (b) j , if j ≤ k, then j ℓ=1 (P ′ ℓ ∪ P ℓ ) is a rainbow directed path with tail h 0 and head h j , and in particular, . Note that |X|, |Y | ≤ 3(k + 1) ≤ m. Therefore, since H is robustly rainbow-Hamiltonian, there exists a rainbow directed Hamilton path P * 2 in H − X with tail t k+1 and head h 0 , not containing a colour in Y . Now F := P * 1 ∪ P * 2 is a rainbow directed Hamilton cycle in G, and F − V (H) = Q, as desired. − By Lemma 7.2 and (7.10), there is a collection Q of at least (1 − o(1))n/e 2 n spanning rainbow directed path forests in G − V (H) that share no colours with φ(H) and have at most n 9/10 components. By Claim 2, for every Q ∈ Q, there is a rainbow directed Hamilton cycle F Q such that F − V (H) = Q. Therefore {F Q : Q ∈ Q} is a collection of at least (1 − o(1))n/e 2 n distinct rainbow directed Hamilton cycles in G, as desired.
• the main ingredients in the proof of [15,Lemma 3.8] are [15, Lemmas 6.3, 6.8, and 6.9], and we will need an analogue of each of these; • as mentioned, Lemma 5.4 is the analogue of [15,Lemma 6.3], and the proof adapts easily to this setting; • we will need the obvious directed analogues of [15, [15,Lemma 6.3] by fixing an outcome F of F c and analyzing the following 'rotate' switching operation on the set of H ∈ G D whose c-colour class is F . For fixed A, B ⊆ [n] satisfying |A| = |B| = |D| = n/10 6 , we instead say that a 'rotation system' of H is a subdigraph R ⊆ G together with a labelling of its vertices V (R) = {a, b, v, w} such that E(R) = {ab, vw} where a ∈ A, b ∈ B, v / ∈ A, w / ∈ B, aw, vb / ∈ E(H), and φ H (ab) = φ H (vw) = c. Then the 'rotate' switching operation replaces the arcs ab and vw with the arcs aw and vb, each in colour φ H (ab) = c, thus leaving the c-colour class, F , unchanged. Analyzing auxiliary bipartite graphs B s as in the proof of [15, Lemma 6.1] and defining δ s and ∆ s−1 to be the analogous quantities, where an edge captures a rotation operation destroying an arc from A to B in some H ∈ M s , it is simple to see that ∆ s−1 ≤ |D| 3 , and δ s ≥ (n − |A| − |B| − 2|D|)(s − |A|) = 999996 10 6 n(s − |D|) (here the '−|D|' term occurs due to avoiding any arc of colour c to be the one that the rotation switching operation destroys between A and B). Then for s ≥ 3|D| 3 2n and n sufficiently large we obtain that |M s |/|M s−1 | ≤ 9/10. Proceeding as in the end of the proof of [15, Lemma 6.1], the result follows.
The rest of the appendix is dedicated to the proof of Lemma 5.6, which we split into two lemmas (Lemmas A.1 and A.2), which roughly speaking correspond to [15,Lemmas 6.8 and 6.9] and the proof of [15,Lemma 3.8], respectively. We begin by defining six events (in addition to E and C defined in the lemma statement and Q 1 D defined in Definition 5.3) that we will use, as well as giving some extra notation. For fixed c ∈ [n], we define E c to be the event in the probability space S corresponding to uniformly random choice of G ∈ Φ( ← → K n ), that G contains a well-spread collection of n 2 /2 100 (v, c)-absorbing gadgets, for all v ∈ [n]. We define C c to be the event in S that there are at most n/10 9 c-loops in G, and for fixed D ⊆ [n] we define (E c | D ) to be the event in S that G| D contains a well-spread collection of n 2 /2 100 (v, c)-absorbing gadgets, for all v ∈ [n].
For fixed D ⊆ [n] and c ∈ D we define E c D to be the event in the probability space S D corresponding to uniformly random choice of H ∈ G D , that H contains a well-spread collection of n 2 /2 100 (v, c)-absorbing gadgets, for all v ∈ [n], and we define C c D to be the event in S D that there are at most n/10 9 c-loops in H. Finally, we define the event Q D in S D in an analogous way to the definition of Q col D * in [15] (see the text preceding Definition 6.7 in the cited paper). Indeed, for an equitable partition (D i ) 4 i=1 of D we define '(v, c, P)-gadgets', 'distinguishability' of (v, c, P)-gadgets, 'saturation' of c-arcs, and the function r (v,c,P) : G D → [n|D|] 0 in ways corresponding to [15,]. (Just add the necessary directions as per Definition 5.1 of the current paper, orienting the d 4 -arc (with d 4 ∈ D 4 ) of a (v, c, P)-gadget away from v (say).) Then Q D is the set of H ∈ G D such that if r (v,c,P) (H) = s, then e H (A, B) ≤ 2|D| 3 /n + 6s for all A, B ⊆ [n] such that |A| = |B| = |D|. Q D is just a reformulation of upper-quasirandomness which is closed under the switching operation we use to find (v, c, P)-gadgets. The following lemma plays a role analogous to [15,Lemmas 6.8 and 6.9]. First, we discuss the switching operation that we will use in the proof. Suppose D ⊆ [n], v, c ∈ [n], let H ∈ G D , and fix a partition P = (D i ) 4 i=1 of D. Let u 1 , u 2 , . . . , u 14 ∈ [n] \ {v}, where u 1 , u 2 , u 5 , u 6 , u 7 , u 8 , u 9 , u 10 , u 13 , u 14 are distinct and {u 1 , u 2 , u 5 , u 6 , u 7 , u 8 , u 9 , u 10 , u 13 , u 14 } ∩ {u 3 , u 4 , u 11 , u 12 } = ∅. Then we say that a subgraph T ⊆ H[{v, u 1 , u 2 , . . . , u 14 }] is a twist system of H if T satisfies [15, Definition 6.7(i)-(vii)] (with directions added as discussed above), and we define the switching operation 'twist T ' and the 'canonical (v, c, P)-gadget of the twist' analogously to [15,Definition 6.7]. We use the notation P D for the measure of the probability space S D .
Lemma A.1. Suppose D ⊆ [n] has size |D| = n/10 6 , and fix c ∈ D. Then Proof. It is simple to repurpose the arguments of [15,Lemma 6.9] to show that if r (v,c,P) (H) ≥ n 2 /2 100 for all v then E c D occurs, whence it suffices to show that choices for d 4 . Next we choose d 1 ∈ D 1 avoiding the colours of the arcs vv, u 7 u 7 , vu 8 (if they are present in H) so that we have at least k/5 acceptable choices. Now we choose d 2 ∈ D 2 avoiding the colours of 8 arcs which if chosen would cause us to give the label u 6 or u 10 to a vertex already labelled, and also avoiding any of the at most 100k 2 /n = n/10 10 choices of d 2 for which there is an arc from u 10 to u 8 . (This ensures that u 6 and u 10 are distinct vertices.) There are at least k/5 acceptable choices for d 2 . There are at most 21 colours d 3 ∈ D good 3 we must avoid for relabelling reasons. Our choice of d 3 may cause u 3 = u 4 and/or u 11 = u 12 , or instead may cause u 3 = u 11 and/or u 4 = u 12 , but this seems difficult to avoid, and does not cause any problems. Thus there are at least k/12 acceptable choices of d 3 ∈ D good
Claim 3: There is a set Λ * ⊆ Λ of size at least |Λ|/2 such that each λ ∈ Λ * satisfies the following properties: (Q1) T λ is a twist system of H; (Q2) deleting the six d 3 -arcs in T λ does not decrease r(H); (Q3) the canonical (v, c, P)-gadget of the twist twist T λ (H) is distinguishable, and it is the only (v, c, P)-gadget that is in twist T λ (H) but not in H. Observe that each twist adds only six arcs, and that each λ ∈ Λ * produces a unique twist system T λ ⊆ H. Thus, from Claims 2 and 3 we deduce that if s ≤ k 4 /2 16 n 2 then δ s ≥ |Λ * | ≥ k 4 n 2 /20000, whence either T s = ∅ or |T s |/|T s+1 | ≤ ∆ s+1 /δ s ≤ 2/3, where T s is the set of H ∈ Q D ∩ C c D for which r(H) = s. We now obtain P D r (v,c,P) (H) ≤ n 2 /2 100 Q D ∩ C c D ≤ exp(−Ω(n 2 )) by repurposing the calculations at the end of the proof of [15,Lemma 6.8]. By a union bound over v ∈ [n], (A.1) holds, which completes the proof of the lemma.
The following lemma does most of the analogous work to the proof of [15,Lemma 3.8].

Proof.
Arbitrarily select D ⊆ [n] such that c ∈ D and |D| = n/10 6 . Define F to be the collection of all sets F of n arcs of ← → K n such that every vertex of ← → K n is the head of precisely one arc in F and the tail of precisely one arc in F , and define F good ⊆ F to be the set of F ∈ F such that F contains at most n/10 9 loops. Note that (A.2) where we have used Lemma 5.4 and the fact that Q 1 D ⊆ Q D . Now using Lemma A.1, (A.2), and the law of total probability, we obtain that (A. 3) P D E c D | C c D ≤ P D E c D | Q D ∩ C c D + P D Q D | C c D ≤ exp(−Ω(n 2 )).