J. Eur. Math. Soc. 27, 1769–1826 (2025)                                                      DOI 10.4171/JEMS/1604
© 2025 European Mathematical Society
Published by EMS Press and licensed under a CC BY 4.0 license




Peter Keevash · Katherine Staden

Ringel’s tree packing conjecture in quasirandom graphs
Received October 29, 2020; revised June 30, 2023

Abstract. We prove that any quasirandom graph with n vertices and rn edges can be decomposed
into n copies of any fixed tree with r edges. The case of decomposing a complete graph establishes
a conjecture of Ringel from 1963.

Keywords: graph decomposition, graph packing, Ringel’s conjecture.




Contents

1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1770
   1.1. Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1771
2. Proof overview and algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1772
   2.1. Formal statement of the algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1779
   2.2. Preliminaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1787
   2.3. Tree partition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1791
   2.4. High degrees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1792
   2.5. Intervals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1794
   2.6. Digraph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1795
3. Approximate decomposition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1797
   3.1. Hypergraph matchings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1797
   3.2. Potential embeddings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1801
   3.3. J degrees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1804
   3.4. G degrees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1808
4. Exact decomposition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1814
   4.1. Leftover graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1814
   4.2. Small stars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1815
   4.3. Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1817
   4.4. Large stars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1820
5. Concluding remarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1825
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1825




Peter Keevash: Mathematical Institute, University of Oxford, Oxford OX2 6GG, UK;
keevash@maths.ox.ac.uk
Katherine Staden: Mathematical Institute, University of Oxford, Oxford OX2 6GG;
School of Mathematics and Statistics, The Open University, Milton Keynes MK7 6AA, UK;
katherine.staden@open.ac.uk
Mathematics Subject Classification 2020: 05C51.
P. Keevash, K. Staden                                                                   1770


1. Introduction

This paper concerns the following conjecture posed by Ringel [30] in 1963.
Ringel’s Conjecture. For any tree T with n edges, the complete graph K2nC1 has a
decomposition into 2n C 1 copies of T .
    We prove this conjecture for large n, via the following theorem which is a general-
isation to decompositions of quasirandom graphs into trees of the appropriate size. For
the statement and throughout we use the following quasirandomness definition: we say
that a graph G on n vertices is .; s/-typical if every set S of at most s vertices has
                                                                  1
..1 ˙ /d.G//jSj n common neighbours, where d.G/ D e.G/ n2          is the density of G.
Theorem 1.1. There is s 2 N such that for all p > 0 there exist ; n0 such that for any
n  n0 such that p.n 1/=2 2 Z and any tree T of size p.n 1/=2, any .; s/-typical
graph G on n vertices of density p can be decomposed into n copies of T .
    The case p D 1 of Theorem 1.1 establishes Ringel’s conjecture for large n, a result
also recently obtained independently by Montgomery, Pokrovskiy and Sudakov [28] by
different methods, along the lines of their proof of an asymptotic version in [27]. They
show that certain edge-colourings of K2nC1 contain a rainbow copy of T , such that the
required T -decomposition can be obtained by cyclically shifting this rainbow copy. This
approach is specific to the complete graph, and does not apply to the more general setting
of quasirandom graphs as in Theorem 1.1.
    Ringel’s conjecture was well-known as one of the major open problems in the area of
graph packing, whose history we will now briefly discuss. In a graph packing problem,
one is given a host graph G and another graph F and the task is to fit as many edge-disjoint
copies of F into G as possible. If the size (number of edges) of F divides that of G, it may
be possible to find a perfect packing, or F -decomposition of G. More generally, given a
family F of graphs of total size equal to the size of G, we seek a partition of (the edge set
of) G into copies of the graphs in F .
    These problems have a long history, going back to Euler in the eighteenth century. The
flavour of the problem depends very much on the size of F . The earliest results concern F
of fixed size, in which case F -decompositions can be naturally interpreted as combinat-
orial designs. For example, Kirkman [22] showed that Kn has a triangle decomposition
whenever n satisfies the necessary divisibility conditions n  1 or 3 mod 6; for historical
reasons, such decompositions are now known as Steiner Triple Systems. Wilson [32–35]
generalised this to any fixed-sized graph in the 70’s, and Keevash [19] to decompositions
into complete hypergraphs, thus estalishing the Existence Conjecture for designs. A dif-
ferent proof and a generalisation to F -decompositions for hypergraphs F were given
by Glock, Kühn, Lo and Osthus [13]. A further generalisation that captures many other
design-like problems, such as resolvable hypergraph designs (the general form of Kirk-
man’s celebrated “Schoolgirl Problem”), was given by Keevash [17].
    There is also a large literature on F -decompositions where the number of vertices
of F is comparable with, or even equal to, that of G. Classical results of this type are
Ringel’s tree packing conjecture in quasirandom graphs                                      1771


Walecki’s 1882 decompositions of K2n into Hamilton paths, and of K2nC1 into Hamilton
cycles. There are many further results on Hamilton decompositions of more general host
graphs, notably the solution in [8] of the Hamilton Decomposition Conjecture, namely the
existence of a decomposition by Hamilton cycles in any 2r-regular graph on n vertices,
for large n and 2r  bn=2c.
     Much of the literature on F -decompositions for large F concerns decompositions into
trees. Besides Ringel’s conjecture, the other major open problem of this type is a conjec-
ture of Gyárfás [14], saying that Kn should have a decomposition into any family of trees
T1 ; : : : ; Tn where each Ti has i vertices. Both conjectures have a large literature of partial
results; we will briefly summarise the most significant of these (but see also [6,10,21,24]).
Joos, Kim, Kühn and Osthus [15] proved both conjectures for bounded degree trees.
Ferber and Samotij [11] and Adamaszek, Allen, Grosu and Hladký [1] obtained almost
perfect packings of almost spanning trees with maximum degree O.n=log n/. These res-
ults were generalised by Allen, Böttcher, Hladký and Piguet [4] to almost perfect packing
of spanning graphs with bounded degeneracy and maximum degree O.n=log n/. Allen,
Böttcher, Clemens and Taraz [3] extended [4] to perfect packings provided linearly many
of the graphs are slightly smaller than spanning and have linearly many leaves. After the
arXiv posting of the current paper, Allen, Böttcher, Clemens, Hladký, Piguet and Taraz [2]
proved the Gyarfás Conjecture for trees of maximum degree O.n=log n/. This maximum
degree bound of O.n=log n/ is a fundamental barrier for the methods in the above papers,
as they use randomised embeddings, for which a maximum degree bound O.n=log n/ is
necessary for concentration of probability. While the results of Montgomery, Pokrovskiy
and Sudakov [26, 27] mentioned above also use probabilistic methods, they are able to
circumvent the maximum degree barrier by methods such as the cyclic shifts mentioned
above.
     Our proof proceeds via a rather involved embedding algorithm, discussed and form-
ally presented in the next section, in which the various subroutines are analysed by a wide
range of methods, some of which are adaptations of existing methods (particularly from
[3, 26], and also our own recent methods in [20] for the “generalised Oberwolfach prob-
lem”, which are in turn based on [17]), but most of which are new, including a method
for allocating high degree vertices via partitioning and edge-colouring arguments and
a method for approximate decompositions based on a series of matchings in auxiliary
hypergraphs.


1.1. Notation
Given a graph G D .V; E/, when the underlying vertex set V is clear, we will also write G
for the set of edges. So jGj is the number of edges of G. Usually jV j D n. The edge density
d.G/ of G is jGj= n2 . We write NG .x/ for the neighbourhood of a vertex x in G. The
                                                                               T
degree of x in G is dG .x/ D jNG .x/j. For A  V .G/, we write NG .A/ WD x2A NG .x/;
note that this is the common neighbourhood of all vertices in A, not the neighbourhood
of A.
P. Keevash, K. Staden                                                                       1772


    We often write G.x/ D NG .x/ to simplify notation. In particular, if M is a matching
then M.x/ denotes the unique vertex y (if it exists) such that xy 2 M . We also write
         S
M.S / D x2S M.x/, which is not consistent with our notation NG .S / for common
neighbourhoods, but we hope that no confusion will arise, as we only use this notation if
M is a matching, when all common neighbourhoods are empty.
    We say G is .; s/-typical if

             jNG .S /j D ..1 ˙ /d.G//jSj n for all S  V .G/ with jS j  s.

    In a directed graph J with x 2 V .J /, we write NJC .x/ for the set of out-neighbours
of x in G and NG .x/ for the set of in-neighbours. We let dG˙ .x/ WD jNG˙ .x/j. We define
common out/in-neighbourhoods NJ˙ .A/ D x2A NJ˙ .x/:
                                                T

    The vertex set V .G/ will often come with a cyclic order, identified with the natural
cyclic order on Œn D ¹1; : : : ; nº. For any x 2 V we write x C for the successor of x, so if
x 2 Œn then x C is x C 1 if x ¤ n or 1 if x D n. Write S C D ¹x C W x 2 S º for S  V .G/.
We define the predecessor x similarly. Given x; y in Œn we write d.x; y/ for their cyclic
distance, i.e. d.x; y/ D min ¹jx yj; n jx yjº.
    We say that an event E holds with high probability (whp) if

                 P .E/ > 1      exp. nc /    for some c > 0 and n > n0 .c/.

We note that by a union bound for any fixed collection E of such events with jEj of
polynomial growth whp all E 2 E hold simultaneously.
   We omit floor and ceiling signs for clarity of exposition.
   We write a  b to mean 8b > 0 9a0 > 0 8 0 < a < a0 .
   We write a ˙ b for an unspecified number in Œa b; a C b.


2. Proof overview and algorithm
                                                                            3
Suppose we are in the setting of Theorem 1.1: we are given a .; 2508 /-typical graph G
on n vertices of density p, where n 1    p, and we need to decompose G into n cop-
ies of some given tree T with p.n 1/=2 edges. In this section we present the algorithm
by which this will be achieved. After describing and motivating the algorithm, we present
the formal statement in the next subsection, then various lemmas analysing certain sub-
routines over the following few subsections. We defer the analyses of the approximate
decomposition to Section 3 and the exact decomposition to Section 4.
    As discussed in the introduction, the most significant technical challenge not
addressed by previous attempts on Ringel’s Conjecture is the presence of high degree
vertices, so naturally these will receive special treatment. Our algorithm will consider
three separate cases for the tree T (similarly to [26]), one of which (Case L) handles trees
in which almost all (i.e. all but o.n/) vertices belong to large stars (i.e. of size > n1 o.1/ ).
Case L is handled by the subroutine L ARGE STARS, which will be discussed later in this
overview. The other two cases for T are Case S, when T has linearly many leaves in
Ringel’s tree packing conjecture in quasirandom graphs                                    1773


small stars, and Case P, when T has linearly many vertices in vertex-disjoint long bare
paths. In both Case S and P, we apply essentially the same “approximate step” algorithm
to embed edge-disjoint copies of F D T n Pex , obtained from T by removing the part that
will be embedded in the “exact step”, so Pex consists of stars in Case S and of bare paths
in Case P. The overview of the proof according to these cases is illustrated by Figure 1.
     The heart of the approximate step is the subroutine A PPROXIMATE DECOMPOSITION,
where in each step we extend our partial embeddings .w W w 2 W / of F by defining
them on some set Ai which is suitably nice: Ai is independent, has linear size, has no
vertices of degree > no.1/ , and every vertex of Ai has at most four previously embed-
ded neighbours. We find these extensions simultaneously via a matching in an auxiliary
hypergraph Hi (see Figure 2), which has an edge denoted “w .u/Dx” whenever it is
possible to define “w .u/Dx” for some w 2 W , u 2 Ai , x 2 V D V .G/. We encode
the various constraints that must be satisfied by the embeddings in the definition of these
edges. Thus “w .u/Dx” includes (as an auxiliary vertex in V .Hi /) all arcs yx       ! where
y D w .b/ is a previously defined embedding of some neighbour b of a; this ensures that
we maintain edge-disjointness of the embeddings of F . We also include in “w .u/Dx”
auxiliary vertices uw and xw, to ensure that every w .u/ is defined at most once and w
is injective.
     We ensure that Hi is suitably nice (its edges can be weighted so that every vertex
has weighted degree 1 C o.1/ and all weighted codegrees are n o.1/ ), in which case it
is well-known from the large literature developing Rödl’s semi-random “nibble” [31],
in particular [16], that one can find an almost perfect matching that is (in a certain sense)
quasirandom (we use a convenient refined formulation of this statement recently presented
in [9]). The quasirandomness of this matching is important for several reasons, including
quasirandomness of the extensions of the embeddings to Ai , which in turn implies that
later hypergraphs Hj with j > i are suitably nice (with weaker specific parameters), and
so the process can be continued.
     The above sketch yields an alternative method for approximate decomposition res-
ults along the lines of those mentioned in the introduction, but has not yet dealt with
high degree vertices. We will partition V .F / into A0 ; A1 ; : : : ; Ai  , where Ai for i  1
are the nice sets described above, and A0 is not nice – in particular, there is no bound
on the degree of vertices in A0 . We start the embedding of F in the subroutine H IGH
DEGREES by embedding vertices sequentially in a suitable order, where when we con-
sider some a 2 A0 we define w .a/ for all w 2 W simultaneously via a random matching
Ma D ¹w .a/w W w 2 W º in an auxiliary bipartite graph Ba  V  W , where the defin-
ition of Ba encodes constraints that must be satisfied by the embedding: we only allow
an edge vw if v … Im w and v is adjacent via unused edges to all w .b/ where b is
a previously embedded neighbour of a. (For simplicity we have suppressed several fur-
ther details in the above description which will be discussed below.) The important point
about this construction is that each v 2 V has to accommodate the vertex a for a unique
embedding w , so however large the degrees in T may be, the total demand for “high
degree edges” is the same at every vertex, and can be allocated to a digraph H which is
an orientation of a quasirandom subgraph of G.
P. Keevash, K. Staden                                                                                1774


                                                   T
                                            TREE PARTITION




                CASE L                              CASE S                              CASE P

                      ≤ p+ n
                                                                                     ≥ p+ n/(100K)
      ≥ n1−c


                                                       ≤ n1−c
                                                                ≥ p− n
                =




                                                   =




                                                                                  =
          LARGE STARS (i–iv)                        HIGH DEGREES, INTERVALS, EMBED A0

                  +                                  +                              +




           LARGE STARS (v)                             APPROXIMATE DECOMPOSITION

                                                     +                              +




           LARGE STARS (vi)                     SMALL STARS                       PATHS



Fig. 1. The three cases of the proof and the subroutines of the algorithm which embed each part
of T . From left to right, Case L: almost all vertices lie in large stars; Case S: linearly many vertices
lie in small stars; Case P: linearly many vertices lie in long bare paths. Red denotes high degree
vertices and their neighbours. Blue denotes the part embedded in the exact step.



     This digraph H is one of many oriented quasirandom subgraphs into which G is par-
titioned by the subroutine D IGRAPH, where each piece is reserved for embedding certain
subgraphs of F , with arcs directed from earlier to later vertices. Besides H , these include
Ringel’s tree packing conjecture in quasirandom graphs                                                                 1775

    v0

                                       Avi 0
                 v1               u1
                 v2                                            ϕw1 (v2 )x3        ϕw1 (v4 )x3
    v3                            u2
                 v4               u3
                 v6               u4                                    ϕw3 (v6 )x3
                                                                        ϕw1 (v3 )x3
           S                                        −
                                                    →                                           ϕw2 (v1 )x2
    A0         i′ ∈[i−1] Ai′    Ai                  Gi                       e2
                                                                   e1                 e3            e4


                      ϕw1 (u2 ) = x3
                                                                                                               x3 w1
                                                         u2 w1

                      ϕw2 (u1 ) = x2
                                                 u1 w2                                                             x2 w2


                      ϕw3 (u3 ) = x3
                                                                  u3 w3                         x3 w3

                                                                  u4 w3
                      ϕw3 (u4 ) = x3
                                                   Ai × W                          Hi                         Ji

Fig. 2. Part of the hypergraph Hi , where a section of F ŒAi ; A<i  and some of the corresponding
edges of Hi are illustrated. Here, u1 2 Ahi           lo               no
                                            i , u2 2 Ai and u3 ; u4 2 Ai . In a previous embedding,
we set w1 .v3 / D w3 .v6 / D x1 , and now the arc e2 D x3 x1 would be used by the potential
embeddings “w1 .u2 / D x3 ” (purple edge), “w3 .u3 / D x3 ” (green edge) and “w3 .u4 / D x3 ”
(blue edge). In particular, at most one of these embeddings is allowed.


             0                                             0
graphs Gigg                                 0    g    g
            i 0 for embedding subgraphs F ŒAi ; Ai 0 , according to a partition of each Ai
             lo   no
into Ahi                   hi
       i , Ai , Ai . Here Ai consists of vertices adjacent to some vertex with many neigh-
bours in Ai (which will lie in A0 and be unique), Alo   i consists of vertices adjacent to some
vertex in A0 (which will be unique) that does not have many neighbours in Ai , and Ano        i
consists of vertices with no neighbours in A0 . To ensure concentration of probability the
above sets are not defined if they would have size o.n/, in which case the correspond-
ing vertices are instead added to A0 . By partitioning G in this manner we can ensure
edge-disjointness when embedding different parts of F separately. To ensure injectivity
of the embeddings, we also randomly partition V  W into various subgraphs in which
w-neighbourhoods prescribe the allowed images in w of the various parts of the decom-
position of V .T /. In particular, while constructing the high degree digraph H , we also
construct Jihi  V  W so that each w .Ahi                                          hi
                                              i / will be approximately equal to Ji .w/.
    The separate treatment of these parts of Ai and careful construction of A0 to ensure
the uniqueness properties mentioned above is designed to handle a considerable technical
difficulty that we glossed over above when describing the embedding of A0 . Our approach
to the approximate decomposition discussed above depends on maintaining quasirandom-
ness, but we cannot ensure that jA0 j=n is negligible compared with 1= i  , where i  is the
number of steps in the approximate decomposition, so a naive analysis will fail due to
P. Keevash, K. Staden                                                                         1776



                                                        ≥∆
                                                                   Aai
                                                                   Abi    Ahi
                                                                           i



                                                                   Alo
                                                                    i
   a
   b
               AD                        ≤4
   A∆                                         ≤ p−1
                                                 max
           ∗
                                  ≥ δn
       A            ∗∗
                A                  A1                              Ano
                                                                    i
                         Bi∗ +1

                A0

                                                                   Ai
                                                                                       A i∗

Fig. 3. Partition of F obtained in T REE PARTITION. Red edges are from T n F and green edges are
F -edges from A0 to Ai (so Alo i ).




blow-up of the error terms. We therefore partition A0 into A , A and A00 , which are
embedded sequentially, where jA j=n and jA j=n are negligible compared with 1= i  ,
and so do not contribute much to the error terms. For A00 , we cannot entirely avoid large
error terms, but we can confine them to a set of o.n/ bad vertices, via arguments based on
Szemerédi regularity; these arguments require degrees in A00 to be bounded independently
of n, so A is introduced to handle degrees that are !.1/ but < no.1/ . The careful choice
of partition ensures that these bad error terms are only incurred by vertices in Alo .
    At this point, we return to consider various details glossed over in the above descrip-
tion of H IGH DEGREES. While the embedding via random matchings ensures that every
vertex of G has the same demand of high degree edges, we also need to plan ahead when
embedding A  A0 (which contains the very high degree vertices) so that it will be pos-
sible to allocate the other ends of these edges to distinct vertices for each w, i.e. so that
w .u/ ¤ w .u0 / whenever u ¤ u0 . To achieve this in D IGRAPH, we randomly partition V
into .Uh W h 2 Œm/, with m D n1 o.1/ , where each Uh will accommodate those ends of
high degree edges corresponding to colour h in a certain properly m-edge-coloured bipart-
                                ! is available for H if yw has colour h and x 2 U . Thus
ite multigraph in V  W , i.e. yx                                                     h
                          0
x D w .u/ 2 Uh and x D w .u0 / 2 Uh0 are distinct automatically if h ¤ h0 , and due
to properness of the colouring if h D h0 , because c determines a unique y 2 V .G/, so a
unique a D w 1 .y/ 2 A .
    The above multigraph M in V  W consists of copies of Ma  Ma for each a 2 A ,
with the copies distinguished by labels `aij , where for each a 2 A and part Ai in which
a has many neighbours, the number of labels `aij is proportional to the degree of a in Ai .
An edge yw of label `aij in M h means that H arcs yx     ! with x 2 U will be allocated
                                                                         h
to edges au of F with a D w 1 .y/ and u 2 NF .a/ \ Ai . For typicality we require for
any a and i that the number of edges in each M h with some label `aij is approximately
independent of h.
Ringel’s tree packing conjecture in quasirandom graphs                                   1777


    This is achieved by a construction based on cyclic shifts, which we will now sketch,
suppressing some details. We partition V into V0 and .Vv W v  2 V  / and W into W0
and .Ww  W w  2 W  /, where V0 and W0 are small, V  and W  are copies of Œm, and
all Vv ; Ww  have the same size. The matchings Ma are chosen as Ma0 [ Ma , where
V .Ma0 / D V0 [ W0 and if vw 2 Ma then v 2 Vv , w 2 Ww  with v  D xa C w  , accord-
ing to some cyclic shifts .xa W a 2 A /, carefully chosen to ensure edge-disjointness. We
construct a labelled multigraph in V   W  analogously to that in V  W , and obtain
label-balanced matchings M h for all h 2 Œm as cyclic shifts of some fixed label-balanced
matching M 0 in V   W  , where for each v  w  2 M 0 with some label `aij we include
in M h all edges of Ma of the same label between Vv Ch and Ww  Ch .
    The above description of M h is over-simplified, as in fact we construct two such
matchings, one handling vertices of huge degree (almost linear) and the other handling
vertices with degree that is high but not huge. The version of M 0 for non-huge degrees
is constructed by the same hypergraph matching methods as in the above description of
the approximate step embeddings, but these do not apply to huge degrees (the codegree
bound fails) so we instead apply a result of Barát, Gyárfás and Sárközy [5] on rainbow
matchings in properly coloured bipartite multigraphs. The construction is illustrated in
Figure 4.
    The exact steps in Cases S and P are handled by adapting existing methods in the lit-
erature. In Case P, the subroutines I NTERVALS and PATHS are adaptations of the methods
we used in [20] for the “generalised Oberwolfach Problem” of decomposing any quasir-
andom even regular oriented graph into prescribed cycle factors; we refer the reader to
this paper for a detailed discussion of these methods. In Case S, we find the required stars
by adapting an algorithm of [3]: we find an orientation of the unused graph so that the
outdegree of each vertex is precisely the total size of stars it requires in all copies of T ,
and then process each vertex in turn, using random matchings to partition its outneigh-
bourhood into stars of the correct sizes, while maintaining injectivity of the embeddings.
    It remains to consider the exact step in Case L, when almost every vertex of T is a leaf
adjacent to a vertex of very large degree; this is more challenging and requires new meth-
ods (the arguments used in Case S fail due to lack of concentration of probability). The
most difficult constraint to satisfy is injectivity of the embeddings, so we build this into
the construction explicitly: we randomly partition V .G/ into sets U a for each star centre
a and require each embedding to choose most of its leaves for its copy of a within U a .
Each edge xy of G, say with x 2 U a , y 2 U b , will be randomly allocated one of two
options: (i) x is a leaf of a star in some embedding w with w .a/ D y, or (ii) y is a
leaf of a star in some embedding w 0 with w 0 .b/ D x. A final balancing step will swap
edges between stars (thus slightly bending the rules on leaf allocation) so that all stars are
exactly as required; see Figure 5. The above sketch can be implemented for decomposing
a quasirandom graph into star forests, but there is a considerable extra difficulty caused
by the constraints imposed by the initial embedding of the small part of T not contained
in the large stars.
    A naive approach to this embedding can easily cause many edges of G to be unusable
according to the rules for U a as described above. Indeed, for each edge xy of G, the two
P. Keevash, K. Staden                                                                                                                    1778

                                                                                                                   ′
                                                                                                                  B∆




                              a                       b
                       ≥Λ                                   ≥Λ             multiplicity Mia
                                         <Λ


                            Ai             Ai′′       Ai′

                                                                                                      W∗              V∗
                       (a, i), (b, i′′ ) ∈ QΛ , (a, i′ ) ∈ Q∆
                                                                                                      xa = m, xb = m − 1


                 Ma                                  Mb                                 MΛ′                                     M

                                                                                        ℓaij
                                                                                        ℓaij ′                                  ℓai′ j


                                  Vv ∗                                  Mb∗                                      v∗
                                                                                                 ′′
    Ww ∗                                                                    w   ∗       ℓ bi′′ j




                                                                                W∗                          V∗          W∗                V∗
     W0                           V 0 W0                              V0
           W     Ma0          V            W        Mb0          V
label ℓai∗                  Ma [Ww∗ −1 , Vv∗ ]                       label ℓai′ ∗
                 1                                   1                                 Vv ∗
                M≥Λ                                 M<Λ



                                                                                    Vv∗ +1
                                                                            hiP1 = <Λ
                                                                                                                                    x
                                  Vv ∗
                                                                            hiP2 = <Λ
                                  Vv∗ +1                                            Vv∗ +2
                                                                                                                                 U1
                                                                            hiP3 = ≥Λ
 Ww∗ +1                           Vv∗ +2
                                  Vv∗ +3
                                                                                     Vv∗ +3                          ∗
     W0                           V0 W 0                              V0                                          Hai    (x)
                                                                                                                   ∗
         W       Ma0          V            W        Ma0          V                                                Hai   ′ (x)

label ℓai∗     haij = 1                           hai′ j = 1         label ℓai′ ∗                                 Hbi∗ ′′ (x)
                                                                                        V0


                                                                                                      Dx1

                                                                                          0 where line
Fig. 4. From left to right, top to bottom: two high degree vertices a; b; the multigraph B
thickness represents multiplicity; the matchings Ma ; Mb between W and V ; the matchings Mƒ     0 ;M
                               1      1               1
on W ; V ; the matchings Mƒ ; M<ƒ ; the graph Dx for x 2 U1 with components P coloured to
represent the random choice hiP 2 ¹ƒ; <ƒº; the resulting edges of Hai        at x.
Ringel’s tree packing conjecture in quasirandom graphs                                                                        1779

                                                0                                                           0
             Ub                               Ub                        Ub                                Ub
       u                                       u0                  u                                       u0


                  wx                  wu
                                          0
                                                    w                        w                       wv         wu
                                                                                                                     0




        w              wv        wu
                                      0
                                                        w0         w                   wx       wu
                                                                                                     0
                                                                                                                     w0
                   x         v                      z        0
                                                                                  x         v                    z        0
        Ua         Uc            Ud                     Ua         Ua             Uc            Ud                   Ua

Fig. 5. A single step of the algorithm to modify the green star which is too small and the red star
which is too large.


options as described above will both become unavailable during the initial embedding if
we choose both w .a0 / D x for some a0 and w 0 .b 0 / D y for some b 0 . We therefore keep
track of a digraph J that records these constraints and choose the initial embedding so
that each edge of G always has at least one of its two options available. To control these
constraints, we also introduce partitions of each U a into three parts, and also of the set
W indexing the embeddings into three parts, and impose two different patterns for match-
ing parts of U a with parts of W according to whether or not a vertex has large degree.
The digraph J and its use in defining available sets for the embedding are illustrated in
Figure 6.
                  φw (b)
                                                             U1b

                                                             Awb
                                                              a              w00                            z


              Im φw                                          U2b                 w0                         x
                                                                                 w                          y



                                                             U3b
                        Ua                                                       W1                       U1
                                                    Ub

Fig. 6. Left: The available set Awb
                                 a for w 2 W1 and a 2 S. The black arcs are some arcs in J ; they
forbid their U b -endvertices from Awb
                                    a . The red arcs would be added to J if the labelled vertex is
chosen for w .a/. Right: A pair of edges wy, w 0 x that must be avoided by the matching defining
the embeddings of a, and a swap that may be implemented by Lemma 2.7 to remove wy. Red edges
define images of a and blue edges define images of some other vertices.



2.1. Formal statement of the algorithm
The input to the algorithm consists of a .; s/-typical graph G on n vertices of density p,
                3
where s D 2508 , n 1    p, and a tree T with p.n 1/=2 edges. We fix 0 < c 0 
c  1 and parameters
        n 1      p  C  pC  p;                                 and         D nc ; ƒ D n1 c :
P. Keevash, K. Staden                                                                       1780


Recall that a leaf in T is a vertex of degree 1 in T . We call an edge a leaf edge if it
contains a leaf. We call a star a leaf star if it consists of leaf edges. We call a path in T a
k-path if it has length k (that is, k edges), and call it bare if its internal vertices all have
degree 2 in T . By Lemma 2.9 below we can choose a case for T in ¹L; S; P º satisfying
 Case L: all but at most pC n vertices of T belong to leaf stars of size ƒ,
 Case S: at least p n vertices of T belong to leaf stars of size  ƒ,
 Case P: T contains pC n=.100K/ vertex-disjoint bare 8K-paths.
In Case L go to L ARGE STARS, otherwise continue. We let  D  in Case S or  D C
in Case P, and define further parameters

    0  D 1  ı  pmin  "1      "i C  pmax  "  p0    s 1 ; p;

with i C D 7 log " 1 and  0  K 1  d 1  D 1 in Case P. Given k 2 N, a tree T
and S  V .T /, the k-span spankT .S / of S in T is obtained by starting with S  D S and
iteratively adding any S 0  V .T / n S  with jS 0 j 2 Œk such that T ŒS  [ S 0  has fewer
components than T ŒS  , until there is no such S 0 . Clearly there are at most jS j iterations,
so jspankT .S /j  .k C 1/jS j. Note also that

                    jspankT .spankT .A/ [ B/ n spankT .A/j  .k C 1/jBj:

For k 2 N let Ak D ¹u W dT .u/  kº.
T REE PARTITION
 (i) Let A D span4T .A /. In Case S let Pex be a union of leaf stars in T n T ŒA , each
     of size  ƒ, with jPex j D p n=2 ˙ ƒ. In Case P let Pex be the vertex-disjoint union
     of two leaf edges in T n T ŒA  and pC n=.101K/ bare 8K-paths in T n T ŒA .
     Obtain F from T by deleting all edges of Pex and F  from F by deleting all vertices
     of A .
(ii) Define disjoint independent sets C1 ; : : : ; Ci  in F  as follows. At step i  1, let
     Bi D V .F  / n j <i Cj , let Ci0 be the set of v 2 Bi with
                     S

                                                                          1
                        dF  ŒBi  .v/  3   and dF  ŒSj <i Cj  .v/  pmax ;

     and let Ci be a maximum independent set in F  ŒCi0 . If jCi j < "n let i  D i      1 and
     stop, otherwise go to the next step.
(iii) Let A0 D span4T ŒA [Bi  C1 , A D span4T .AD /nA and A00 D A0 n.A [A /. For
      i 2 Œi   let Ai D Ci  C1 i n A0 and for k 2 N let Aki D ¹a 2 Ak W jNF .a/ \ Ai j  º.
      For a 2 A           a
                    i let Ai D NF .a/ \ Ai . Let

                                                                    ƒ
                             [                      [                       [
                                    a     <ƒ                  a
                     Ahi
                       i D        A i ; A i   D            A  i ; A i  D        Aai :
                         a2A
                            i                   a2A   ƒ
                                                   i nAi                  a2Aƒ
                                                                             i


     Obtain F 0 from F by deleting all edges ab with a 2 A          a
                                                          i and b 2 Ai for some i . Let
      lo                                         no
     Ai D ¹u 2 Ai W jNF 0 .u/ \ A0 j D 1º. Let Ai D ¹u 2 Ai W NF .u/ \ A0 D ;º.
Ringel’s tree packing conjecture in quasirandom graphs                                         1781


(iv) For j 2 Œ4, let ıj D ı :1j C:6 and let .ı1 ; : : : ; ı4 / D .no; ƒ; <ƒ; lo/. For each j 2 Œ4,
              ı                                ı                                     ı
     while jAi j j < ıj n for all i , move Ai j to A0 , let A0 D span4T ŒA0 [ Ai j , and update
             ƒ
     A<ƒ             lo
       i ; Ai ; Ai ; Ai .
                          no

 (v) If i Ai D ;, move A to A , i.e. redefine A as A [ A and A as ;.
        S hi

    Let Ahi D i Ahi                    no    lo
               S
                       i and define A ; A similarly.
    For k 2 N, let

                  Q D ¹.a; i / W   jNF .a/ \ Ai j < ƒº  A  Œi  ;
                  Qƒ D ¹.a; i / W jNF .a/ \ Ai j  ƒº  Aƒ  Œi  :

We introduce parameters
                                                       X                   X
               mai D d :2 jAai je1a2A ;       ma D         mai ;   mD          ma :
                                          i
                                                         i                a2A

Let  be an order on V .T / with A  A  A00  A1      Ai   V .Pex / n V .T / and
jN< .v/ \ Xj  1 whenever v 2 X 2 ¹A ; A ; A00 º. For v 2 V .T / we let <v D ¹u W u  vº,
N< .v/ D NF 0 .v/ \ <v, N .v/ D N< .v/ [ ¹vº and N> .v/ D NF 0 .v/ n <v.
    We stress the use of F 0 in this notation, which ensures that N> .a/ \ Ahi   i D ; for
all a 2 A0 : otherwise we would have a vertex not in A0 adjacent to two vertices of A0 ,
but this contradicts the definition of A0 as a span. We list here some other immediate
consequences of the definition of A0 that will often be used without comment.
 jA j  5n= and jA j  5n=D.
 Any u 2 A1 has jN< .u/ \ A0 j  1.
 Any uv 2 F ŒA1  has j.N< .u/ [ N< .v// \ A0 j  1.
 There is no 3-path in T n A0 with both ends in Ahi [ Alo .
                                   1
We also note that jN> .v/j  pmax    for all v 2 A1 , and jN< .v/j  4 for all v 2 V .T /. To
see the latter, note that if v 2 A1 then v has at most three earlier neighbours in A1 and
at most one in A0 , whereas if v 2 A0 then v has at most one earlier neighbour in each of
A , A and A00 .
    Write n D mn C n0 with jn0 n :1 j < m. Recall that we adopt the natural cyclic
orders on Œm and Œn, addition wraps, and d.; / is cyclic distance. Whenever an algorithm
is required to make a choice, it aborts if it is unable to do so (we will show whp it does
not abort).
    Given bipartite graphs B; Z  X  Y with jXj D jY j we write M D M ATCH.B; Z/
to mean that M is a random perfect matching from Lemma 2.7. (The choice of Z will
ensure edge-disjointness of the embeddings.)
H IGH DEGREES
 (i) Choose xa 2 Œm for a 2 A in  order, arbitrarily subject to d.xa ; xa0 / > 3d for all
     a0  a, and d.xa ; xa0 / ¤ d.xb ; xb 0 / for all a0 2 N< .a/ and bb 0 2 F Œ<a.
P. Keevash, K. Staden                                                                         1782


(ii) Choose independent uniformly random partitions of V .G/ into V0 of size n0 and
     Vv , v  2 V  , of size n , and W into W0 of size n0 and Ww  , w  2 W  , of size n ,
     where V  D W  D Œm.
(iii) For each a 2 A in  order we will define all w .a/ by choosing a perfect matching
      Ma D ¹w .a/w W w 2 W º. Let Ba  V  W consist of all vw where v … Im w and
      each w .b/v with b 2 N< .a/ is an unused edge of G. Let Za  V  W consist of
      all w .b/w with b 2 N< .a/.
                                     
      Let Ba0 D Ba ŒV0 ; W0  and Baw D Ba ŒVxa Cw  ; Ww   for w  2 W  . Define Za0 and
          
      Zaw similarly.
      Let Ma D Ma0 [ Ma with
                                                                              
                                                        [
                Ma0 D M ATCH.Ba0 ; Za0 / and Ma D          M ATCH.Baw ; Zaw /:
                                                             w

    We randomly identify V .G/ with Œn, cyclically ordered as above. Recall that each
x 2 Œn has successor x C D x C 1 (where n C 1 means 1) and predecessor x D x 1
(where 0 means n). Let di D d=.2s/i 1 for i 2 Œ2s C 1. We write n D ri di C si with
ri 2 N and 0  si < di , and let
                      ´
                  i      ¹kdi C j W 0  k  ri º      if j 2 Œsi ;
                Pj D
                         ¹kdi C j W 0  k  ri 1º if j 2 Œdi  n Œsi :
For each i 2 Œs C 1 and j 2 Œdi  we define a partition of Œn into a family of cyclic
intervals Iji defined as all Œx; y  where x 2 Pji and y is the next element of Pji in the
cyclic order. (So jIji j D n=di ˙ 1, each I 2 Iji has jI j  di , and Iji \ Iji 0 D ; for j ¤ j 0 .)
We let I i D j 2Œdi  Iji . (So for every z 2 Œn, exactly one Œx; y  2 I i has x D z, and
               S

exactly one Œx; y  2 I i has y D z.)
I NTERVALS
 (i) In Case S let Xxw D V n w .A /, pxw WD n 1 jXxw j for all w 2 W and go to D IGRAPH;
     otherwise (in Case P) continue. For each w 2W independently choose i.w/2Œ2s C1
     and j.w/ 2 Œdi.w/  uniformly at random. Let Wi D ¹w W i.w/ D i º.
                                                       i.w/
(ii) For each w 2 W , let Aw include each interval of Ij.w/ independently with probab-
     ility 1=2.
     Let w consist of all I 2 Aw such that both neighbouring intervals I ˙ of I are not
     in Aw .
(iii) For each w 2 W , let Xw include each I 2 w with probability .1 /n 1 jPex j
      independently, let Xw D Xw , Xxw D V n .w .A / [ Xw [ .Xw /C / and pxw D
                             S

      n 1 jXxw j.
(iv) Obtain Yw  Xw as follows. Remove any I from Xw that intersects w .A /, let
     ti D min ¹jX.I /j W I 2 I i º, where X.I / WD ¹w 2 Wi W I 2 Xw º, then delete each
     I 2 I i with i 2 Œ2s C 1 from jX.I /j ti sets Xw with w 2 X.I /, independently
     uniformly at random.
                S
     Let Yw D Yw and Y.I / D ¹w 2 Wi W I 2 Yw º.
Ringel’s tree packing conjecture in quasirandom graphs                                                         1783


E MBED A0
(i) For each xy 2 G  WD G n w w .T ŒA / independently let P .xy 2 G0 / D p0 =p.
                            S
                                                     ! 2 J / D p =px .
    For each w 2 W and x 2 Xxw independently let P .xw     0      0   w
(ii) Extend the embeddings w of T ŒA  to T ŒA0  in  order, where for each a 2
     A0 n A we choose a perfect matching Ma D ¹w .a/w W w 2 W º D M ATCH.Ba ; Za /,
     where Za D ¹w .b/w W b 2 N< .a/º and Ba  V  W consists of all vw with
     v 2 NJ0 .w/ n Im w where each w .b/v with b 2 N< .a/ is an unused edge of G0 .
                                                                 0                          0
   For i; i 0 2 Œi   and g; g 0 2 ¹hi; lo; noº, let pigg        1 0 g      g                 g
                                                         i 0 D n jF ŒAi ; Ai 0 j C pmin and pi 0 D
           g                                      gg 0       g
n 1 jF 0 ŒAi ; A0 j C pmin . We also write pi 0 D pi 0 for all g 0 for uniform notation later.
                                                  g         g
   For i 2 Œi  , g 2 A                                       1         lo     1
                            i [ ¹lo; noº let ˛i D jAi jn , ˛lo D jA jn , ˛no D jA jn
                                                                                            no    1
                      1
and ˛0 D jA0 jn .
   Let ˛ihi D :2 mi =n and ˛hi D i ˛ihi D :2 m=n D jAhi jn 1 ˙  :9 .
                                          P

   Let pex D n 1 jPex j. Let pex    0
                                      D . 78 /pex in Case P or pex  pex      0
                                                                                   1 in Case S.
   We note some identities and estimates for our parameters:
         p.n        1/=2 D jT j D jT ŒA0 j C jF 0 j C jAhi j C jPex j;
         1 C p.n 1/=2 D jV .T /j D jV .F /j C jV .Pex / n V .F /j;
           X gg 0                                 X g
               pi i 0 n 1 jF 0 j 2 Œ0; pmin :9 ;  ˛i D n 1 jAg j;
         i;i 0 ;g;g 0                                                i
                                  0
                            pigg
                        X
                                                            :9
         p=2                   i0     ˛hi   pex 2 Œ0; pmin ;
         p=2        .˛hi C ˛lo C ˛no C pex / 2 Œ0; ":9 ;
                    ´
                      1 jA0 jn 1 in Case S,
         pxw D
                        px ˙ d :9 with px D .1          ˛0 /.1           .1     /pex =8/   in Case P:
These estimates imply that the assignment of probabilities to mutually exclusive events
in D IGRAPH (vii) below is valid (i.e. the probabilities have sum  1). For ı 2 ¹<ƒ; ƒº,
let                                  X
                           mı D             mai ; pı D mı =m;
                                            .a;i /2Qı
and define labels
      Lı D ¹`aij W .a; i / 2 Qı ; j 2 ŒMia º where                           Mia 2 ¹bmai =pı c; dmai =pı eº
and jLı j D m.
D IGRAPH
  (i) For each a 2 A let Ma0 denote the perfect matching between V  and W  consist-
                                                                         0
      ing of all v  w  with w  2 W  and v  D xa C w  2 V  . Let Bai be the bipartite
                                   a
      multigraph formed by Mi copies of Ma labelled by `aij , j 2 ŒMia . For k 2 N
                                                 0

      let Bk0 D .a;i /2Qk Bai  0
                                  and Bk be the bipartite multigraph formed by Mia copies
                 S

      of Ma for each .a; i / 2 Qk labelled by `aij , j 2 ŒMia .
            

                                         0
  (ii) Let Mƒ0 be a largest matching in Bƒ with at most one edge of each label. Define a
                                   h
       partial m-edge-colouring .Mƒ W h 2 Œm/ of Bƒ , where for each h 2 Œm and edge
P. Keevash, K. Staden                                                                             1784

                                                         h
      v  w  of Mƒ0 with some label `aij we include in Mƒ all edges of Ma with label
      `aij between Vv Ch and Ww  Ch .
 (iii) Let .H ; !/ be the weighted 3-graph where for each v  w  labelled `aij with
       .a; i / 2 Q we include v  w  `aij with weight m 1 . Let M be a random matching
                                                                             h
       obtained from Lemma 2.8 applied to .H ; !/. Define matchings M<ƒ         B for
                                                                       h
                                         
       h 2 Œm, where for each edge v w `aij of M we include in M<ƒ all edges of Ma
       with label `aij between Vv Ch and Ww  Ch .
 (iv) Partition V as .Uh W h 2 Œm/ uniformly at random. Fix distinct haij 2 Œm for each
      `aij 2 Lı and ı 2 ¹<ƒ; ƒº (recalling jLı j D m). For all `aij 2 Lı , add a copy
                                                  h                              !
      of Ma0 with every edge labelled `aij to Mı aij . Let p1 D p p0 and let G1 be a
      uniformly random orientation of G1 WD G  n .G0 [ ¹xy W d.x; y/  3d º/.
  (v) For h 2 Œm and x 2 Uh let Dxh be the graph on N! .x/ consisting of all yy 0 with
                                                      G1
      y ¤ y 0 such that yw 2 M h and y 0 w 2 M h for some w 2 W with x 2 Xxw . For
                                     ƒ                            <ƒ
      each connected component P of Dxh independently choose one of P .hiP D ı/ D pı
      for ı 2 ¹ƒ; <ƒº. For each y 2 P with some yw 2 MhihP with label `aij include
                          ! D w.
       ! in H  and let w.yx/
      yx       ai
                !2!
 (vi) For each yx   G1 independently choose at most one of
              !2!
           P .yx  Gex / D 2pex =p1 , or
                  !
              ! 2 G G / D 2p gg 0 =p for 1  i 0 < i  i  and g; g 0 2 ¹hi; lo; noº, or
           P .yx        ii0        ii0           1
              !2!
           P .yx GiG0 / D 2pig0 =p1 for i 2 Œi   and g 2 ¹hi; lo; noº, or
              !2!
           P .yx G 0 / D 2p =p for i 2 Œi  , or
                        i         max        1
              ! 2 H / D 2˛ =p px if x 2 Xx ,
           P .yx          hi 1 w          w


      where w D w.yx/, ! and if yx ! 2 H a WD H \ H  include xw    ! 2 J a . Let J hi D
                                          i             ai                  i      i
                                         !             !
               Jia and J hi D i Jihi and Gi D g;g 0 ;j GijG .
      S                       S                S
        a2A i
                             ! … J [ J hi with x 2 Xx . For xw
(vii) Let J 0 be the set of xw                                ! 2 J 0 let p D px p
                                  0                  w                     xw    w 1
      2˛hi hixw , where hixw is 1 if w D w.yx/! for some y or 0 otherwise. For each
       ! 2 J 0 independently choose at most one of
      xw
                     ! 2 J / D p 0 =p
                 P .xw                                        or     ! 2 J lo / D ˛ lo =p
                                                                 P .xw                       or
                          ex       ex    xw                               i        i      xw
                     ! 2 J no / D ˛ no =p
                 P .xw                                               !      0
                                                              or P .xw 2 Ji / D pmax =pxw .
                              i          i            xw

                        lo                               no
      Let J lo D               no
                   S                         S
                    i Ji and J    D                  i Ji .
                           !2!
(viii) In Case P, for each yx                                              ! 2 J K/
                                                       ! 2 J 0 / D 7 or P .yx
                              Gex independently let P .yx   ex     8            ex
       D 81 .
     Some edges of G may not be allocated by this process. Note that arcs in J ŒV; W  are
all directed from V to W , so we will often suppress the direction and think of J ŒV; W  as
a graph.
Ringel’s tree packing conjecture in quasirandom graphs                                         1785

                             0                                                        !      !
   For uu0 2 F 0 ŒAgi ; Agi 0  with i; i 0 2 Œ0; i   and g; g 0 2 ¹hi; lo; noº let GiG0 D GiG0 for
                !        !                            0                  gg 0
every i and let Guu0 D GiGi 0 and puu0 D pigg                                      g         0
                                                   i 0 , recalling that pi 0 D pi 0 for all g .
                                     g                  g           g          g
   For g 2 A [ ¹lo; noº, u 2 Ai let Au D Ai , Ju D Ji , ˛u D ˛i .
   For xw! 2 J we also write A ! D A , J ! D J , ˛ ! D ˛ .
                u                     xw        u      xw       u   xw      u

A PPROXIMATE DECOMPOSITION
For i D 1; : : : ; i  apply the following steps.
                                                                   !
 (i) Let .Hi ; !/ be the weighted hypergraph Hi with vertex parts Gi , Ji and Ai  W ,
                                                         !
                                  ! 2 J such that xy 2 G for all y D  .v/ with
     where for each u 2 Ai and xw       u                  uv                w
     v 2 N< .u/ we include an edge labelled “w .u/Dx” consisting of uw, xw  ! and all
     such xy, with weight
                                                      Y
                          !.“w .u/Dx”/ WD jAu j 1          puv1 :
                                                             v2N< .u/

 (ii) Define ! 0 on Hi by ! 0 .e/ D .1 :5"i /!.e/=Q.e/ where Q.e/ is the maximum of
                              P
      1 and all !.Hi Œv/ WD ¹!.e/ W v 2 eº with v 2 e. Let Mi be a random matching
      obtained by applying Lemma 2.8 to .Hi ; ! 0 /. For each “w .u/Dx” in Mi extend
      w by setting w .u/ D x.
(iii) For each a 2 Ai in any order, let Wa D ¹w 2 W W w .a/ undefinedº, let Va 2 jWVa j
                                                                                        

      be uniformly random, and define ¹w .a/w W w 2 Wa º D M ATCH.Ba ; Za /, where
      Za D ¹w .b/w W b 2 N< .a/º and Ba  Va  Wa consists of all vw with v 2 NJi0 .w/ n
      Im w and each w .b/v for b 2 N< .a/ an unused edge of Gi0 .

    To avoid confusion, we emphasise that Hi is a digraph and Hi is a hypergraph.
We sometimes use bold font as above to avoid confusion between v 2 V .Hi / and v 2
V .Hi / D V .G/. We define “time” during the algorithm by a parameter t taking values
in a set T with the following elements: 0 is the start, ta for a 2 V .T / is the time (if it
exists) at which some w .a/ are defined by choosing a matching Ma , thi is the end of
H IGH DEGREES, tint is the end of I NTERVALS, tG0 is after choosing G0 and J0 , t is the
end of embedding A , t0 is the end of E MBED A0 , times ti and tiC for i 2 Œi   are just
before and just after we extend the embeddings according to the matching Mi (so t1 is
the end of D IGRAPH). For any time t ¤ 0 we let t be the time just before t.
    We write P t and Et for conditional probability and expectation given the history of
the algorithm up to time t. For t 2 T and w 2 W let A t;w be the set of w-embedded
vertices at time t. We write A t if it is independent of w.
                                                                                       0
    We denote the graph remaining after the approximate decomposition by Gex              D
     S
G n w2W w .F /.
    We complete the T -decomposition of G by the “exact step” algorithms below: we
apply S MALL STARS in Case S, PATHS in Case P, and L ARGE STARS in Case L.
S MALL STARS
 (i) For x 2 V .G/ let Lx be the set of all uw where u is a leaf of a star in Pex with centre
     w 1 .x/.
P. Keevash, K. Staden                                                                       1786

                                                   0                  C
(ii) Let D be a uniformly random orientation of Gex  . While not all dD .x/ equal jLx j,
                                                   C               C
     choose uniformly random x; y; z with jLx j > dD .x/, jLy j < dD .y/, z 2 NDC .y/ \
                            !
                        ! zx.
     ND .x/ and reverse yz,
(iii) For each x 2 V .G/ in arbitrary order, define w .u/ for all uw 2 Lx by
                        Mx D ¹¹uw; w .u/º W uw 2 Lx º D MATCH.Fx ; ;/;
     where Fx  Lx  NDC .x/ consists of all ¹uw; yº with uw 2 Lx , y 2 NDC .x/ \
     NJex .w/ n Im w .

PATHS
 (i) Call x 2 V .G/ odd if the parity of dGex0 .x/ differs from that of the number of w such
     that x D w .a/ where a is the end of a bare path in Pex . Let X be the set of odd
     vertices. Let a1 `1 , a2 `2 be the leaf edges in Pex , with leaves `1 , `2 . Throughout, let
     Gfree D ¹unused edgesº.
(ii) Define all w .`1 / by M1 D ¹w .`1 /w W w 2 W º D M ATCH.B1 ; Z1 /, where
        Z1 D ¹w .a1 /wºw2W         and     B1 D ¹vw W v 2 NJex .w/; vw .a1 / 2 Gfree º:
(iii) Fix X 0  X, W 0  W with jX 0 j D jW 0 j D jXj=2. Define w .`2 / for w 2 W 0 by
      M20 D ¹w .`2 /w W w 2 W 0 º D M ATCH.B20 ; Z20 /, where Z20 D ¹w .a2 /wºw2W 0 and
      B20 D ¹vw W w 2 W 0 ; v 2 NJex .w/ \ X 0 ; vw .a2 / 2 Gfree º.
(iv) Let V 0 D .V n X / [ X 0 . Define w .`2 / for w 2 W n W 0 by M2 D ¹w .`2 /w W
     w 2 W n W 0 º D M ATCH.B2 ; Z2 /, where Z2 D ¹w .a2 /wºw2W nW 0 and B2 D ¹vw W
     w 2 W n W 0 ; v 2 NJex .w/ \ V 0 ; vw .a2 / 2 Gfree º.
(v) For each w 2 W fix 8d.x; y/-paths Pwxy for each Œx; y 2 Yw centred in vertex-
    disjoint bare .8d.x; y/ C 2/-paths in Pex . Extend each w to an embedding of Pex n
    S       xy            1       1 C                        xy
      xy Pw so that w .x/, w .y / are the ends of Pw , according to a random
    greedy algorithm, where in each step, in any order, we define some w .a/ D z,
    uniformly at random with z 2 Jex .w/ n Im w and zz 0 2 Gfree whenever z 0 D w .b/
    with b 2 NT .a/.
(vi) Apply Theorem 4.6 to decompose Gfree into .Gw W w 2 W / such that each Gw is
     a vertex-disjoint union of 8d.x; y/-paths w .Pwxy /, Œx; y 2 Yw , internally disjoint
     from Im w .

L ARGE STARS
 (i) Let  be the union of all maximal leaf stars in T that have size  ƒ. Let F D T n .
                                                C
                                           ˇ S D ¹v
     Let S be the set of star centres of  and         ˇ 2 V .T / W dT .v/ƒº.
     Partition W as W1 [ W2 [ W3 with jWi j n=3ˇ < 1 for each i . For each v 2 V .G/
                                           ˇ
     independently choose exactly one of P .v 2 Uia / D d .a/=.3jj/ with a 2 S , i 2 Œ3.
     Let Ui D aˇ Uia .
               S
             P3 ˇ
     While i D1 jWi j jUi jˇ > 0 relocate a vertex between the Uia so as to decrease
                                ˇ

     this sum.
Ringel’s tree packing conjecture in quasirandom graphs                                     1787


(ii) Fix an order  on V .F / starting with some u0 2 S C such that N< .u/ D ¹v  u W
     vu 2 F º D ¹u º has size 1 for all u ¤ u0 2 V .F /. Fix distinct w .u0 /, w 2 W ,
     with w .u0 / 2 Ui whenever w 2 Wi .
(iii) Throughout, update Gfree D ¹unused edgesº, the image Im w of w , and a digraph J
                                 ! with y D  .a/ and x 2 U a \ Im  for some w 2 W ,
      on V .G/ consisting of all yx          w                      w
      a 2 S.
(iv) For each a 2 V .F / n ¹u0 º in  order let Mia D ¹w .a/w W w 2 Wi º D
     M ATCH.Bia ; Zia /, i 2 Œ3, thus defining all w .a/, with Bia ; Zia as follows.
      If a … S C let Zia D ¹w .a /wºw2Wi and define Bia  Ui 1  Wi (with U0 WD U3 )
       by
                       NBia .w/ D Awa WD Ui 1 \ NGfree .w .a // n Im w :

        If jUi 1 j < jWi j, choose w .a/w 2 Bia uniformly at random, update Bia and
        remove w from its vertex set. If jUi 1 j > jWi j, remove some randomly chosen
        u 2 Ui 1 from Bia .
      If a 2 S C let Zia D ¹vw W v 2 ¹w .a /º [ .U a \ Im w /ºw2Wi and define Bia 
       Ui  Wi by NBia .w/ D Aw               wb
                                      S
                                 a D    b2S Aa where

                                                 C
         Awb        b                                          a
                                                                                
          a D Ui \ NGfree .w .a // n Im w [ NJ .Im w \ U / [ NJ .w .b// :

(v) Orient Gfree as D D w2W Dw , where for each xy 2 Gfree with x 2 U a and y 2 U b ,
                       S
       ! 2 J we have yx
    if xy              ! 2 D where  .a/ D y, if yx! 2 J we have xy ! 2 D where
                             w        w                                    w
    w .b/ D x, otherwise we make one of these choices independently with probabil-
    ity 1=2.
(vi) While                        X X
                                             C
                          † WD             jdDw
                                                .w .a//     d .a/j > 0;
                                 w2W a2S
                                C                                          C
     we fix u D w .a/ with dD     .u/ < d .a/ and u0 D w 0 .a0 / with dD    .u0 / < d .a0 /,
                                 w                                          w0
     and apply a uniformly random xvz-move for uwu0 w 0 , defined as follows. Choose
                           ! xuº
     xvz with ¹vu0 ; zu0 ; vx;  !  D unmoved, with x … Im  , with v … Im  0 [
                                                                     w                   w
     Im w x where w x .b/ D x, u 2 U b , with u0 … Im w v where w v .c/ D v, x 2 U c ,
     and with z 2 NDC 0 .u0 / n Im w u0 where w u0 .d / D u0 , v 2 U d . The xvz-move for
                      w
     uwu0 w 0 reverses the path u0 vxu in D, assigning ux! 2 D , xv  ! 2 D x , vu  !0 2 D v
                                                                   w           w            w
     and zu0 2 Dw u0 .


2.2. Preliminaries
Here we gather some well-known results concerning concentration of probability and
Szemerédi regularity, and also a result on random perfect matchings in quasirandom
bipartite graphs, which is perhaps new (although the proof technique via switchings is
somewhat standard).
P. Keevash, K. Staden                                                                     1788


    We start with the following classical inequality of Bernstein (see e.g. [7, (2.10)]) for
sums of bounded independent random variables. (In the special case of a sum of inde-
pendent indicator variables we will simply refer to the “Chernoff bound”.)
Lemma 2.1. Let X D niD1 Xi be a sum of independent random variables with jXi j < b
                       P
                    Pn
for each i . Let v D iD1 E.Xi2 /. Then
                                                             2
                           P .jX      EXj > t / < 2e t =.2.vCbt =3// :

    We also use McDiarmid’s bounded differences inequality, which follows from
Azuma’s martingale inequality (see [7, Theorem 6.2]).
Definition 2.2. Suppose f W S ! R where S D niD1 Si and b D .b1 ; : : : ; bn / 2 Rn . We
                                                     Q

say that f is b-Lipschitz if for any s; s 0 2 S that differ only in the i th coordinate we have
jf .s/ f .s 0 /j  bi . We then also say that f is v-varying where v D niD1 bi2 =4.
                                                                             P

Lemma 2.3. Suppose Z D .Z1 ; : : : ; Zn / is a sequence of independent random variables,
                                                                          2
and X D f .Z/, where f is v-varying. Then P .jX EXj > t /  2e t =.2v/ .
                                                                                  P
   We say that a random variable is .; C /-dominated if we can write Y D i2Œm Yi
such that jYi j  C for all i and i2Œm E0 jYi j < , where E0 jYi j denotes the expectation
                                 P

conditional on any given values of Yj for j < i. The following lemma follows easily from
Freedman’s inequality [12].
Lemma 2.4. If Y is .; C /-dominated, then P .jY j > 2/ < 2e =.6C / .
   Next we recall some definitions (not quite in standard form) pertaining to Szemerédi
regularity. A bipartite graph B  X  Y with jBj D d jXj jY j is "-regular if

             jBŒX 0 ; Y 0 j D d jX 0 j jY 0 j ˙ "jXj jY j   for all X 0  X, Y 0  Y .

If also jB.x/ \ Y j D .1 ˙ "/d jY j and jB.y/ \ Xj D .1 ˙ "/d jXj for all x 2 X, y 2 Y
then B is "-super-regular. We will need the well-known “pair condition” discovered inde-
pendently by several pioneers in the theory of Szemerédi regularity (we refer to [23] for
the history and a version of the following statement).
Lemma 2.5. Let " < 2 200 and B  X  Y with jXj D jY j D m, where jNB .x/ \ Y j >
.d "/m for all x 2 X and jNB .xx 0 / \ Y / < .d C "/2 m for all but  2"m2 pairs xx 0
in X. Then B is "1=6 -regular.
    We also require the following lemma; the proof is standard, so we omit it.
Lemma 2.6. Let n 1  ˛  ˇ  d; r 1 ; D 1 and G be an ˛-super-regular bipartite
graph with parts X and Y of size  n and density d.G/  d . Suppose H is a r-
multigraph on Y of maximum degree D. Then for all but at most ˇjX j vertices x we
have                      X
                                 d.G/ jej D jH j ˙ ˇjY j:
                             e2H ŒNG .x/
Ringel’s tree packing conjecture in quasirandom graphs                                 1789


   Next we present a result on random perfect matchings in super-regular bipartite
graphs. Given M; Z  X  Y , an M ZM Z is a 4-cycle that alternates between M and Z.
We also write M ZM Z for the number of M ZM Z’s.
Lemma 2.7. Let n 1  ˛  d and B; Z  X  Y with jXj D jY j D n. Suppose Z has
maximum degree < n:4 and B is ˛-super-regular with density d.B/  d . Then there is
a distribution on perfect matchings M of B with M ZM Z D 0 such that P .xy 2 M / D
.1 ˙ ˛ :98 /.d.B/n/ 1 for any edge xy, and for any X 0  X, Y 0  Y , whp

                       jM ŒX 0 ; Y 0 j D jBŒX 0 ; Y 0 j.d.B/n/ 1 ˙ n:8 :

Proof. Let M be the set of perfect matchings of B. It is well-known (and easy to see by
Hall’s theorem) that M ¤ ;. We consider a Markov chain on M where the transition from
any M 2 M is a uniformly random swap, defined by choosing a 6-cycle C in B that is
M -alternating (every other edge is in M ) and swapping C \ M with C n M , subject
to the new edges C n M not forming any new M ZM Z’s. It is well-known that every
Markov chain on a finite state space has a stationary distribution (which is not necessarily
unique). Fix some stationary distribution  and let M  .
    To analyse the chain, we start with an estimate for the number of swaps for any
given M . Let GM be the auxiliary tripartite graph with parts X1 ; X2 ; X3 each a copy
of X, where for i 2 Œ3, xi 2 Xi , xi0 C1 2 Xi C1 we have xi xi0 C1 2 GM if M.xi /xi0 C1 2
B n M (and X4 WD X1 ). Note that M -alternating 6-cycles in G correspond to triangles
in GM . Each GM ŒXi ; XiC1  is a copy of B n M , so is 2˛-super-regular, and so by the
triangle counting lemma, GM has .1 ˙ ˛ :99 /.d.B/n/3 triangles. Each edge in M forms
an M ZM Z with  n:8 other edges, each forbidding  n possible swaps, so the number
of swaps is .1 ˙ ˛ :99 /.d.B/n/3 ˙ n2:8 D .1 ˙ 1:1˛ :99 /.d.B/n/3 .
    Next we claim that  is supported on M0 WD ¹M W M ZM Z D 0º. To see this, first
note that in any step of the chain, M ZM Z is non-increasing. Also, the M -alternating
6-cycles that remove any given e from M correspond to triangles in GM containing some
given vertex. There are .1 ˙ ˛ :99 /d.B/3 n2 such triangles, of which  n1:8 are forbidden.
Letting pMe denote the probability that e is removed by a transition from M we have
pMe D .1 ˙ 2:2˛ :99 /n 1 . In particular, if M ZM Z > 0 then it decreases with positive
probability. Thus M0 is an absorbing class, so the claim holds.
    Next we estimate P .e 2 M / for any given e 2 B. Let MŒe D ¹M 2 M W e 2 M º. For
                      Ce
M 2 M n MŒe let pM      denote the probability that e is added by a transition from M . The
M -alternating 6-cycles for adding e correspond to a choice in some common neighbour-
hood NGM .x1 / \ NGM .x2 /. Thus there are .1 ˙ ˛ :99 /d.B/2 n such 6-cycles, of which
                            Ce
 4n:4 are forbidden, so pM     D .1 ˙ 2:2˛ :99 /d.B/ 1 n 2 . Now
                         X              X                           X
                                                                                   Ce
        P .e 2 M / D           M D           M .1 pMe / C                  M pM    ;
                       M 2MŒe         M 2MŒe                      M 2MnMŒe
     P            e
                          P                Ce
so   M 2MŒe M pM D         M 2MnMŒe M pM and hence

                  .1 ˙ 4:5˛ :99 /n 1 P .e 2 M / D d.B/ 1 n 2 P .e … M /;
P. Keevash, K. Staden                                                                                 1790


giving
                            P .e 2 M / D .1 ˙ 5˛ :99 /.d.B/n/ 1 :
    To obtain the final property, we consider uniformly random partitions .Xi W i 2 I /
                                                 p                                 S
of X and .Yi W i 2 I / of Y with jXi j D jYi j D n ˙ 1 for each i . We let M D i 2I Mi
where for each i , Mi  i independently with i a stationary distribution of the above
chain for Bi D BŒXi ; Yi  and Zi D ZŒXi ; Yi . By Chernoff bounds whp each Bi is 1:1˛-
super-regular with d.Bi / D d.B/ ˙ n :1 . By the above analysis, for each e,
                   X                   X
     P .e 2 M / D       P .e 2 Mi / D      .n 1 jXi j/2 .1 ˙ 5.1:1˛/:99 /.d.Bi /jXi j/ 1
                        i                     i
                              :99
                 D .1 ˙ 6˛          /.d.B/n/ 1 :

    It remains to estimate jM ŒX 0 ; Y 0 j D i M ŒXi0 ; Yi0 , where Xi0 D X 0 \ Xi , Yi0 D
                                                P

Y 0 \ Yi . By Chernoff bounds, whp BŒXi0 ; Yi0  D n 1 jBŒX 0 ; Y 0 j ˙ n:76 for each i , so
                                                  p
            EjM ŒXi0 ; Yi0 j D .1 ˙ 6˛ :99 /.d.B/ n/ 1 .n 1 jBŒX 0 ; Y 0 j ˙ n:76 /:

Also,
                                                          X
         EjM ŒXi0 ; Yi0 j2 D EjM ŒXi0 ; Yi0 j C                         P .¹e; e 0 º  Mi / < 2n;
                                                    e¤e 0 2BŒXi0 ;Yi0 


as P .¹e; e 0 º  Mi / D .1 ˙ 6˛ :99 /.d.Bi /jXi j/ 2 for each ¹e; e 0 º by similar arguments to
those above. The required estimate for jM ŒX 0 ; Y 0 j now follows from Lemma 2.1.

    We conclude this subsection with a result on matchings in weighted hypergraphs,
along the lines of the literature stemming from the Rödl nibble mentioned in the overview
above. The following lemma is a slight adaptation of a convenient general setting of the
nibble recently provided by Ehard,     Glock and Joos [9]. Given a weighted hypergraph
                                   H
.H; !/, we call a function f W r ! R clean if f .I / D 0 whenever I is not a matching.
For H 0  H let
                                                            X²                         0 ³
           X                      0                                                   H
f .H 0 / D     ¹f .E/ W E 2 H   r
                                     º  and   f .H 0
                                                     ; !/ D       !.E/f   .E/ W E  2         ;
                                                                                       r
                                            H
                Q                             
where !.E/ D e2E !.e/. For S; T 2 r            we also let fS .T / D f .S [ T / if T \ S D ;,
and fS .T / D 0 otherwise.
Lemma 2.8. Let C 1  ˛  ˇ  r 1 ; ` 1 and .H; !/ be a weighted r-graph with
!.e/  C 1 for all e 2 H , and !.H Œv/  1, !.H Œuv/ < C ˇ for all u ¤ v 2 V .H /.
Then there is a distribution on matchings M in H such that
                                      ˇ                                                      ˛
               f .M / D .1 ˙ C            /f .H; !/ with probability  1               e C
                            H                                       ˇ
                               
for any clean function f on `   with fS .H; !/  C                     f .H; !/ whenever S ¤ ;.
   The proof of Lemma 2.8 is essentially the same as that of [9, Theorem 1.3], with a
few modifications as follows. The statement in [9]:
Ringel’s tree packing conjecture in quasirandom graphs                                 1791


 applies to unweighted hypergraphs of maximum degree  and maximum codegree
  < 1 ˇ ; our version can be reduced to this version by considering a multihypergraph
  where the multiplicity of an edge e is b2 !.e/c, say;
 gives a (deterministic) matching M satisfying the required conclusion for a suitably
  small set of functions f ; this is obtained by proving the existence of a distribution on
  matchings as in our statement and taking a union bound;
 applies to functions on H` , from which a version for functions on `       H
                                                                               
                                                                                   is easily
  deduced.


2.3. Tree partition
We start our analysis of the algorithm by considering the subroutine T REE PARTITION.
Lemma 2.9. We can choose a case in ¹L; S; P º for T and we have i  < i C . Also,
                                               ı                                        0
jA0 j  6"n, and for each i , jAai j   and jAi j j  ın if non-empty, with Aai \ Aai 0 D ;
for ai ¤ a0 i 0 .

Proof. To see that we can choose a case for T , we suppose that T does not satisfy Case L
or Case S, and show that it must satisfy Case P. Here we rely on the well-known fact
that any tree with few leaves must have many vertices in long bare paths (we will use
the precise statement given by [27, Lemma 4.1]). Let T 0 be the tree obtained from T by
removing all leaf stars of size  ƒ. Then jV .T 0 /j  pC n, as T does not satisfy Case L.
    We claim that T 0 has < 2p n leaves. To see this, let  be the set of maximal leaf
stars of T 0 . For each S 2  obtain S 0 from S by deleting all leaves of T 0 that are not
leaves of T . Note that jS 0 j  ƒ, or we would have removed S when defining T 0 . Then
          0                                                            0
P                                                        P
   S 2 jS j < p n, as T does not satisfy Case S. Also,    S 2 jS n S j < n=ƒ as each leaf
               0
in any S n S is the centre of a leaf star in T of size  ƒ. The claim follows.
    Now [27, Lemma 4.1] implies that T 0 has > pC n=.50K/ vertex-disjoint bare 8K-
paths. At most n=ƒ of these contain the centre of some star removed when obtaining T 0
from T , so > pC n=.100K/ are bare paths of T , as required.
    Next we bound i  . Recall that at step i  1 we let Bi D V .F  / n j <i Cj and Ci0 be
                                                                         S

the set of v 2 Bi with
                                                                        1
                      dF  ŒBi  .v/  3   and dF  ŒSj <i Cj  .v/  pmax :

We have jCi0 j > jBi j=3 2pmax n, as < 2pmax n vertices fail the second condition, and the
                                                                P
set X of vertices failing the first condition satisfies 3jXj  x2X dF  ŒBi  .v/ < 2jBi j.
Next we let Ci be a maximum independent set in F  ŒCi0 ; we have jCi j  jCi0 j=2 as trees
are bipartite. If jCi j < "n we let i  D i 1 and stop, otherwise we proceed to the next
step, noting that jCi j > jBi j=7. There can be at most i C D 7 log " 1 steps, otherwise we
                                                  C
would continue past a step i with jBi j < .6=7/i n < "n.
    For the remaining statements, we first note that the bounds for and disjointness of
the sets Aai are immediate from the algorithm and the definition of A0 as a span. Finally,
we consider step (iv) of T REE PARTITION. For each j 2 Œ4, there are at most i C steps
P. Keevash, K. Staden                                                                        1792

                          ı
where we move some Ai j to A0 if it has size < ıj n, thus adding < 5ıj n vertices to A0
after including any forced by the definition as a span. Note that by choice of the order
                                                  ı
ı1 ; : : : ; ı4 it is not possible for some Ai j to be moved to A0 and then to reappear at a
                                                            ı
later step. At the end of the process, any surviving Ai j has size
                     ı
                                  X
                  jAi j j > ıj n       5i C ıj 0 n  ıj n.1 5.4 j /ı :1 iC /  ın:
                                j 0 >j

This completes the proof.


2.4. High degrees
Continuing through the algorithm, the following lemma shows that the subroutine H IGH
DEGREES is whp successful, and the image of each embedding is well-distributed with
respect to common neighbourhoods in G.
Lemma 2.10. Whp H IGH DEGREES does not abort, and

                              P ta .w .a/ 2 NG .S // D .1 ˙ ı/p jS j

for any a 2 A , w 2 W and S  V .G/ with jS j  s.
    We make some preliminary observations before giving the proof. First, we write the
proof assuming jN< .a/j  4 for all a 2 A rather than using our real bound jN< .a/j  1,
so that it is more obvious how to apply the same proof to obtain Lemma 2.11. We
note that the choices of xa for a 2 A are possible. Indeed, at each step, we forbid
 6d jA j  30d n= choices of xa with d.xa ; xa0 /  3d for some a0  a, and < 5n=
choices with d.xa ; xa0 / D d.xb ; xb 0 / for some a0 2 N< .a/ and bb 0 2 F Œ<a. We also note
the following estimate for common neighbourhoods, which is immediate from a (hyper-
geometric) Chernoff bound: whp for any S  V .G/ with jS j  s and X D V0 or X D Vv
with v  2 V  we have

                           jNG .S / \ Xj D ..1 ˙ 1:1/p/jS j jXj:

Proof of Lemma 2.10. We can condition on partitions of V and W satisfying the above
estimates for jNG .S / \ Xj. First we consider the choices of .Ma W a 2 A /, which are
independent of .Ma0 W a 2 A /. For each a 2 A , w  2 W  , v  D xa C w  we will show
                                                                                            
that Lemma 2.7 applies to choose Ma ŒVv ; Ww   D M ATCH.Baw ; Zaw /, where Baw 
                         w 
Vv  Ww  satisfies Ba .w/ D NG ta .w .N< .a/// \ Vv n w .<a/, where G t  G is
the graph of unused edges at time t. For each v 2 V there is a unique edge ww .a/ 2 Ma
with w .a/ D v, which uses jN< .a/j edges at v, so G n G t has maximum degree 
jT ŒA j  5n=. Note that the constraint that w .a/w .a0 / is unused for all a0 2 N< .a/
is automatically satisfied as d.xa ; xa0 / ¤ d.xb ; xb 0 / for all bb 0 2 F Œ<a.
    We also note that Za D ¹w .b/w W b 2 N< .a/º has maximum degree  4.
    At time t, let Hwt  be the hypergraph on V .G/ with edges ew       t
                                                                          D w .N< .a/ \ A t / for
                          t                         
w 2 Ww  . Note that Hw  is a matching, as Mb is a matching for each b 2 N< .a/ and
Ringel’s tree packing conjecture in quasirandom graphs                                       1793


w .b/ 2 Vw  Cxb with distinct xb . We let B t be the “bad” event that

                         jHwt  ŒNG .v/j ¤ ..1 ˙ 7/p/jN< .a/\A t j n

for some v 2 V .G/, a 2 A , w  2 W  . We let  be the smallest t such that B t occurs, or
1 if there is no such t . We fix a 2 A and bound P . D ta /.
                         
    We claim that Baw is  0 -super-regular of density .1 ˙ 5/p jN< .a/j . To show this,
we first lighten our notation, writing t D ta and H D Hwt  , which has edges ew D
w .N< .a// for w 2 Ww  . Any v 2 Vv has degree jH ŒNG t .v/j ˙ j¹w 2 Ww  W
v 2 w .<a/ºj D jH ŒNG .v/j as vw .a0 / is unused for all a0 2 N< .a/ and all w 2 Ww  ,
and v D w .a00 / for some a00 2 <a and w 2 Ww  iff xa D v  w  D xa00 . As B t does
not hold for t < ta , v has degree ..1 ˙ 7/p/jN< .a/j n . Any w 2 Ww  has degree

      jNG .w .N< .a/// \ Vv j D ..1 ˙ 1:1/p/jN< .a/j n D .1 ˙ 5/p jN< .a/j n :

For any V 0  Vv , W 0  Ww  we have
             
                              X                             X
         jBaw ŒV 0 ; W 0 j D   jNG .w .N< .a/// \ V 0 j D   jH 0 ŒNG .v/j;
                              w2W 0                                  v2V 0

                                                    
where H 0 D ¹ew W w 2 W 0 º, so we have jBaw ŒV 0 ; W 0 j D p jN< .a/j jV 0 j jW 0 j ˙  0 n2 by
Lemma 2.6. This proves the claim.
    Thus Lemma 2.7 applies, giving P ta .vw 2 Ma / D .1 ˙ ı=2/.p jN< .a/j n / 1 for any
          
vw 2 Baw , so P ta .w .a/ 2 NG .S // D .1 ˙ ı/p jS j for any w 2 Ww  and S  V .G/
with jSj  s.
    To bound P .B t a /, note that Hwt  only changes when we choose Mb for b 2 N< .a/.
Fix v and write W t D ¹w W ew  t
                                 2 Hwt  ŒNG .v/º, where t D tb . For any w 2 W t we have
 tb     tb                               t
ew 2 Hw  iff w .b/ 2 NG .v/, so jHwb j D jMb ŒW t ; NG .v/j, which by Lemma 2.7 is
whp
               
           jBaw ŒNG .v/; W t j..1 ˙ 5/p jN< .a/j n/ 1 ˙ n:8 D .1 ˙ 7/pjW t j:
Thus whp B t a does not hold for any a, so  D 1.
   Now we consider the choice of Ma0 D M ATCH.Ba0 ; Za0 /, where Za D Za ŒV0 ; W0  and
Ba  V0  W0 is defined by Ba0 .w/ D NG t .w .N< .a/// \ V0 n w .<a/. Let Hat be the
                               t
hypergraph on V0 with edges ew    D w .N< .a/ \ A t / \ V0 for w 2 W0 . Let B t0 be the
                                
“bad” event that for some a 2 A we have

                         jHat ŒNG t .v/j ¤ ..1 ˙  0 /p/jN< .a/\A t j n0 :

We let  0 be the smallest t such that B t0 occurs, or 1 if there is no such t . We fix a 2 A
and bound P . 0 D ta /.
   Similarly to the arguments for Ma , as B t0 does not hold, Ba is  0 -super-regular of
density .1 ˙ 5/p jN< .a/j , using the maximum degree bound on G n G t to estimate com-
mon neighbourhoods jNG t .S / \ V0 j for degrees of w 2 W0 , recalling that n0 > n :1 =2,
and estimating jBa ŒV 0 ; W 0 j D v2V 0 jH 0 ŒNG t .v/j by Lemma 2.6 applied to G t and
                                   P
P. Keevash, K. Staden                                                                       1794


H 0 D ¹ew t
            W w 2 W 0 º, which has maximum degree at most 16, as for each b; b 0 2 N< .a/
and w 2 W0 there is a unique w 0 2 W0 with w .b/ D w 0 .b 0 /.
     Again we similarly deduce P ta .vw 2 Ba / D .1 ˙ ı=2/.p jN< .a/j n0 / 1 for any
vw 2 Ba , so P ta .w .a/ 2 NG .S // D .1 ˙ ı/p jS j for any w 2 W0 and S  V .G/ with
jS j  s. To bound P .B t0 a /, note that whp jHat ŒNG .v/j D ..1 ˙  0 =2/p/jN< .a/\A t j n0 by
the same argument as for Ma , and by the maximum degree bound on G n G t we can
replace G by G t in this estimate, changing  0 =2 to  0 . Thus whp B t0 a does not hold for
any a, so  0 D 1, as required.

    Note that G n G  has maximum degree  jT ŒA j < 5n=, as for each v 2 V .G/
there is a unique edge ww .a/ 2 Ma with w .a/ D v, which uses jN< .a/j edges at v.
Thus G  is .1:1; s/-typical, so whp the graphs G0 and G1 defined in E MBED A0 are
.1:2; s/-typical.
    We omit the proof of the following lemma, as it is similar to and simpler than the
previous one.
Lemma 2.11. For any a 2 A0 n A , w 2 W , x; y 2 V .G/, writing Aw  a for the set of y
such that w .a/ D y is possible given the history at time ta , whp

                   P ta .w .a/ D y/ D .1 ˙ D :9 ˙ ˛0:9 1a2A00 /jAw  1
                                                                  aj ;

so whp P ta .w .a/ 2 NG1 .x// D .1 ˙ D :9 ˙ ˛0:9 1a2A00 /p1 .


2.5. Intervals
Next we record some properties of the subroutine I NTERVALS that are needed for the exact
step in Case P (handled by the subroutine PATHS). We omit the proof, which is essentially
the same as that of the corresponding lemma in [20] (the only change is the deletion of
the negligible sets w .A /). We say that S  Œn is d -separated if d.a; a0 /  d for all
distinct a; a0 in S . For disjoint S; S 0  Œn we say .S; S 0 / is d -separated if d.a; a0 /  d
for all a 2 S , a0 2 S 0 .
Lemma 2.12. In Case P,
 (i) P thi .x 2 Xxw / D pxw ˙  :9 for all w 2 W and x 2 V .G/,
(ii) any subset of ¹¹x 2 Xxw º W w 2 W; x 2 V .G/º is independent if it does not include
     any pair ¹x 2 Xxw º, ¹x 0 2 Xxw º with d.x; x 0 /  3d ,
                         .1 /jPex j
(iii) whp jY.I /j D ti D 8.2sC1/d i
                                     ˙ n :9 for all I 2 I i , i 2 Œ2s C 1,
(iv) whp jYw j D .1      /jPex j=8 ˙ n :9 for all w 2 W ,
(v) for any U  V .G/, whp for any disjoint R; R0  W of sizes  s we have
                                                          jRj Y
           jU \ NJint .R/ \ NJx .R0 /j D jU j 18 .1 /pex        pxw ˙ n :1 ;
                                                                    w2R0

                                           ! W x 2 Xx º,
                    ! W x 2 Y º and Jx D ¹xw
     where Jint D ¹xw        w                       w
Ringel’s tree packing conjecture in quasirandom graphs                                                        1795


(vi) whp for any disjoint S; S 0  V of sizes  s,
      if S [ S 0 is 3d -separated then
                                                       X                       jS j      0
                 j¹w W S  Yw ; S 0  Xxw ºj D               1
                                                             8
                                                               .1     /pex              jS j
                                                                                       pxw    ˙ n :1 ;
                                                      w2W

      if .S; S 0 / is 3d -separated then j¹w W S  Yw ; S 0  Xxw ºj  2 2s n. 18 .1                /pex /jSj .


2.6. Digraph
Our next lemma summarises various properties of the decompositions of G and W V .G/
constructed in the subroutine D IGRAPH. Many of these properties are straightforward
consequences of the definition and Chernoff bounds. The most significant conclusion is
part (viii), showing that the high degree digraph H allocates roughly the correct number
of edges to each vertex x for each role ai where i 2 Œi  , a 2 A     i . For each such ai we
        0
let Mai    consist of all v  w  with some label `aij , where v  w  2 Mƒ0 if .a; i / 2 Qƒ or
v  w  `aij 2 M if .a; i / 2 Q .
                                                    !
     We write Gex for the underlying graph of Gex and define other underlying graphs
                             0        0
similarly. We define JexK by JexK ŒV; W  D Jint D ¹xw    ! W x 2 Y º and xy    ! 2 J K 0 ŒV  ,
                                                                      w                ex
! 2 J K ŒV , thus removing the “twist”: if for some edge xy of G we add xy
xy                                                                                    ! to J K
           ex                                                              ex                  ex
then we add xy ! to J K 0 .
                       ex

Lemma 2.13.       (i) P thi .xy 2 / D d  ./=p independently for each xy 2 G  , where
                       0                                     gg 0           0
       2 ¹Gex ; Gigg      0                          
                    i 0 ; Gi º, and d .Gex / D 2pex , d .Gi       / D pigg             0
                                                                         i 0 and d .Gi / D pmax ,
              ! 2 ‰/ D d  .‰/ for ‰ 2 ¹J hi ; J lo ; J no ; J ; J 0 º, where d  .J g / D ˛ g for
 (ii) P thi .xw                                          i   i      ex     i                     i        i
      g 2 ¹lo; noº, d  .J hi / D ˛hi , d  .Jex / D pex
                                                      0
                                                         , d  .Ji0 / D pmax ,
 (iii) any subset E of the events in (i) and (ii) is conditionally independent given any
       history of the algorithm at time t0 if it has no pairs that are equivalent or mutually
       exclusive,
 (iv) whp each  as in (i) is .1:2; s/-typical of density d./ D d  ./ ˙  :9 ,
  (v) for any w 2 W , u 2 V .F /, distinct v1 ; : : : ; vs 0 2 NF .u/ with s 0  s and x1 ; : : : ; xs 0
      in V .G/, whp
                       ˇ          s0
                                  \                      ˇ         s0
                                                                   Y
                                      C
                       ˇNJu .w/ \    N!             .xi /ˇ D jAu j    .1 ˙ 1:2/puvi ;
                       ˇ                                 ˇ
                                             Guvi
                                     i D1                           i D1

 (vi) in Case P, for all disjoint S ; SC  V and R  W each of size  s, for any k; k ; kC
      in ¹0; K 0 º, writing `0 D 7=8 and `K 0 D 1=8, we have

           jNJ k .R/ \ N CkC .SC / \ N k .S /j
               ex          Jex               Jex

                                            D .`k pex /jS j .`kC pex /jSC j .`k pex /jRj n ˙ :9 n:
      Also jW \ NJCint .S / \ NJC0 .SC /j is .pex =8/jS j .7pex =8/jSC j n ˙ :9 n if S [ SC is
                                     ex
      3d -separated, or is  2 3s .pex =8/jS j .7pex =8/jSC j n if .S ; SC / is 3d -separated,
P. Keevash, K. Staden                                                                                  1796

                 0                                0
(vii) whp each jMai j=Mia is in .1          n c ; 1,
                ˙         C                                 a
(viii) whp all dH a .x/, dJ a .x/ and dJ a .w/ are .1 ˙ ı/jAi j and NJ a .w/ \ N a0 .w/ D
                    i         i              i                                      i       Ji 0
                 0
       Hia \ Hia0 D ; whenever ai ¤ a0 i 0 .

Proof. We start by briefly justifying statements (i)–(iv), which are fairly straightforward
from the definition of the algorithm. The outcome of H IGH DEGREES determines G  at
time thi , where G n G  has maximum degree < jA j  5n=. For each xy independently,
we include it in G0 with probability p0 =p. Excluding < 6d n such xy with d.x; y/  3d ,
the remainder have P .xy 2 G1 / D 1 p0 =p D p1 =p. In D IGRAPH (iv) each is then
directed as xy       ! each with probability 1=2, and then in (vi) independently included in
              ! or yx,
at most one  as in (i) with probability d  ./=p1 , so with overall probability d  ./=p1 .
We note that xy may instead be included in H , again independently for all edges. This
justifies statement (i), and then (iv) is immediate by typicality and Chernoff bounds.
                                                         ! 2 ‰/ by multiplying px ˙  :9
     For (ii), we start the calculation for each P thi .xw                         w
for the event ¹x 2 Xxw º and then p1 D 1 p0 for ¹xw           ! … J º. This gives px p ,
                                                                      0                  w 1
which equals pxw if w is not some w.yx/,    ! and then we put xw    ! 2 ‰ with probability
d  .‰/=pxw , giving an overall probability d  .‰/. On the other hand, if w is some w.yx/!
then we include xw  ! in J hi with probability 2˛ =.p px /, so with overall probability 2˛ ,
                                                  hi    1 w                                hi
                !
or otherwise xw is available for other ‰ with probability pxw p1 2˛hi , which we define
                                                                          ! 2 ‰/.
to be pxw in this case, giving the same overall probabilities for P thi .xw
     For (iii), we emphasise that we only have conditional independence given the his-
tory at time t0 , rather than independence, due to the dependence between ¹x 2 Xxw º and
¹y 2 Xxw º when d.x; y/  3d . This still suffices to prove concentration statements in two
steps: first showing concentration of the conditional expectation under the random choices
in I NTERVALS, and then concentration under the random choices in D IGRAPHS. We illus-
trate this for (v), omitting the similar proof of (vi) via Lemma 2.12. For any 3d -separated
Y  V , for each y 2 Y independently we have P .y 2 Xxw / D pxw ˙  :9 , so by Chernoff
bounds whp jY \ Xxw j D pxw jY j ˙ 2 :9 n. Then for each y 2 Y \ Xxw we have
                                      s0
                                       \                                     s0
                                                                              Y
                                           C
                  P tint y 2 NJu .w/ \    N!                 .xi / D ˛u pxw 1    puvi :
                                                      Guvi
                                           i D1                              i D1
                  Ts 0
By partitioning i D1 NG .xi / into 3d -separated sets we deduce (v) by a Chernoff bound.
     For (vii), first note that for ı 2 ¹<ƒ; ƒº, if mı ¤ 0, then mı  ım, so pı  ı. We also
recall that .a;i /2Qƒ Mia D m. As Bƒ                0
             P
                                                       is a union of m matchings each of size m, by [5,
Theorem 2] of Barát, Gyárfás and Sárközy we have jMƒ0 j  m m:51 , so Mia jMai                     0
                                                                                                     j
   :51       :4         a                         ƒ                    
m < n Mi for each .a; i / 2 Q . For .a; i / 2 Q we apply Lemma 2.8 to H with
f .v  w  `a0 i 0 j 0 / D 1a0 Da;i 0 Di . To see that this is valid, we take D D m, so each edge weight
is D 1 , and note that each !.H Œv  / or !.H Œw  / is m 1 .a;i /2Q Mia D 1. Also, for
                                                                            P
                                                                                                   2
any v  w  with some label `aij we have !.H Œv  w  /  m 1 d :2 ƒ=ıe < D 1 c , say.
                           0              0
Thus Lemma 2.8 gives jMai    j D .1 ˙ n c /Mia , recalling that c 0  c, as required for (v).
    For (viii), we analyse the construction of H , which is illustrated in Figure 4. The
                                          C
disjointness statements and dJ a .w/ D dH   a .w .a// are clear from the definition of the
                                    i                 i
Ringel’s tree packing conjecture in quasirandom graphs                                 1797

                                                                                     ˙
algorithm, so it remains to establish the degree estimates. It suffices to show all dH  .x/
                                                                                      ai
are .1 ˙ :1ı/p1 pm  a                         !                     !       a
                  x i n=m; indeed, for each yx 2 Hai we have yx 2 Hi , yx 2 H ,    !
          !
where P .yx 2 H / D ˛ =p .px ˙ d :9 / independently, so the estimates on d ˙ .x/ hold
                         hi        1                                            Hia
whp by Chernoff bounds.
   Consider dH  .x/ for x 2 Uh , h 2 Œm. It suffices to estimate the contribution from
                  ai
V n V0 , as jV0 j D n0 is negligible by comparison with the error term in the required
                                                                                0
estimate. Let ı 2 ¹<ƒ; ƒº be such that .a; i / 2 Qı . For each v  w  2 Mai      we
              h                
include in Mı all edges of Ma with label `aij between Vv Ch and Ww  Ch . There are
.1 ˙ d :8 /pp
            x 1 n=m such edges yw with yx!2!  G1 and x 2 Xxw whp under the choices of
.Vv W v  2 V  /, intervals and orientation of G1 . For each such yw, in some component P
of Dxh , we have P .hiP D ı/ D pı , independently for distinct P , so
                                        0
                       EdH  .x/ D pı jMai j  .1 ˙ 2d :8 /pp
                                                           x 1 n=m:
                              ai

Under the orientation of G1 , whp jP j < log2 n for each P by Chernoff bounds. Then
dH  .x/ is a log2 n-Lipschitz function of independent decisions of all hiP , so Lemma 2.3
   ai
gives the required estimate on dH  .x/.
                        C          ai                                              a
    Finally, consider dH  .y/ for y 2 V .G/. If y 2 V0 , then there are exactly Mi values
                         ai
of h 2 Œm for which there is an edge yw 2 Mıh with label `aij for some j . If y … V0 ,
                          0
then there are exactly Mai  values of h 2 Œm for which there is an edge yw 2 Mıh with
                                             0
label `aij for some j , as each v  w  2 Mai  satisfies v  D xa C w  , determining some
h 2 Œm such that y 2 Vv Ch , and some edge yw 2 Mıh \ Ma , where w 2 Ww  Ch . By
                                                      C
typicality and Chernoff bounds whp each jUh \ N!         .y/j is .1 ˙ 1:1/p1 n=m. For each
              C                                       G1
x 2 Uh \ N! .y/ independently P .hix D ı/ D pı , writing hix D hiP where P is the
             G1
component of Dxh containing y. The events ¹x 2 Xxw º are independent for distinct x in
any 3d -separated set, so by partitioning Uh into 3d such sets, applying a Chernoff bound
                                                C
to each, we obtain the required estimate on dH    .y/, noting that it only depends on the
                                                   ai
number Mia or jMai  0
                      j of h 2 Œm such that Mıh includes yw with some label `aij , and not
on the set of such h, which is yet to be determined when choosing the matchings Ma .


3. Approximate decomposition

In this section we analyse the subroutine A PPROXIMATE DECOMPOSITION, which applies
hypergraph matchings to embed most of F in Cases S and P.

3.1. Hypergraph matchings
The main goal of this section is the following lemma, which will allow us to apply
Lemma 2.8 to the hypergraph matchings chosen in A PPROXIMATE DECOMPOSITION,
i.e. all auxiliary vertices have ! 0 -weighted degree close to and not exceeding 1, and all
! 0 -weighted codegrees are small; statement (ii) concerns the degree that a pair ux would
have if it were introduced as an auxiliary vertex (but we do not do this to avoid additional
P. Keevash, K. Staden                                                                        1798


complications in analysing the relationship between ! 0 and !). The “bad” graphs and sets
appearing in the lemma will be defined and analysed in Lemma 3.2.
Lemma 3.1. Whp for each i 2 Œi  ,
 (i) ! 0 .Hi Œv/ 2 .1 2":8 ; 1 for all v 2 V .Hi /,
                 0                        :8
     P
(ii)     w2W ! .“w .u/Dx”/ D 1 ˙ 2" for all x 2 V .G/, u 2 Ai ,
(iii) ! 0 .e/ > .1 C 2"i / 1 !.e/ for all e D “w .u/Dx” with u 2 Ai n .Abad        lo
                                                                         w \ NF 0 .A //,
       !
      xw 2 Ji n J bad ,
(iv) ! 0 .Hi Œuw/ 2 .1     2"i ; 1   :5"i  for all u 2 Ai n .Abad        lo
                                                                w \ NF 0 .A //,
(v) ! 0 .Hi Œvv0 / <  :9 for all v; v0  V .Hi /.
    To satisfy the hypotheses of Lemma 2.8 for .Hi ; ! 0 / we let C D n and ˇ D c=2.
Then the edge weights satisfy ! 0 .“w .u/Dx”/  jAu j 1  C 1 , the codegree condition
holds by Lemma 3.1 (v), and the vertex weights satisfy ! 0 .Hi Œv/ D ¹! 0 .e/ W v 2 eº 
                                                                         P

1 :5"i by definition of ! 0 .
    Next we define and bound the “bad” graphs and sets appearing in Lemma 3.1. For
                               0                                                0
each i write Alo                                        lo
                   i D Ai [ Ai , where for u 2 Ai with N< .u/ \ A0 D ¹u º we include
               0                     0     0     0       w
u in Ai if u 2 A [ A or in Ai if u 2 A0 . Let Si be the multiset on A00 where
for each u 2 A0i with N< .u/ \ A0 D ¹u0 º we include w .u0 /, with multiplicity, so that
jSiw j D jA0i j. Note that all multiplicities in Siw are  D by definition of A00 . Let
           ! 2 J lo W jS w \ N .x/j ¤ p jS w j ˙  0 nº and J bad D S J bad ;
 Jibad D ¹xw         i     i       !            1 i                              i i
                                   G1

 B D ¹x 2 V .G/ W dJ bad .x/ > ı nº and Aw WD .A [ A / \ x2B N> .w 1 .x//:
                                    3               bad     lo    no
                                                                         S

Lemma 3.2. Whp jBj < ı 4 n and dJ bad .w/; jAbad    3
                                             w j < ı n for all w 2 W .

Proof. We start by bounding dJ bad .w/ for each w 2 W . We may assume jA00 j >  0 n=D,
otherwise jSiw j   0 n for all i , w, and then J bad D ;. As G is .; s/-typical, a well-known
non-partite variant of Lemma 2.5 implies that G is  :1 -regular. Writing X D w .A00 /, as
jXj; jXxw n Xj   0 n=D, standard regularity properties imply that GŒX; Xxw n X  is  :01 -
regular of density p ˙  :01 . Then Chernoff bounds imply that whp G            z D ¹uv W u 2 X,
             !     !
v 2 Xxw n X, uv 2 G1 º is     :001
                                     -regular of density p1 ˙    :001
                                                                       . By Lemma 2.6 applied with
       z                                       0
G D G and H D ¹¹w .u /º W u 2 A0 º we deduce dJ bad .w/ <  0 n, so dJ bad .w/ < ı 7 n,
                              0        0
                                                                i
say. As                           X                  X
                   ı 3 njBj            dJ bad .x/      dJ bad .w/ < jW jı 7 n;
                                x2B              w2W
                  4                       1
we have jBj < ı       n. Since d> .u/  pmax for every u 2 A1 , we conclude that jAbad
                                                                                    w j <
  1
pmax jw 1 .B/j < ı n.3


    Henceforth, we assume Lemmas 3.1 and 3.2 for all i 0 < i , our aim being to show that
they hold for i. First we establish various properties of the matchings Mi 0 for i 0 < i that
will be used in the proof. We let Ai;w D A t C ;w n A ti ;w , which is the set of u 2 Ai such
                                              i
that w .u/ is defined by the matching Mi , and let A0i;w D Ai n Ai;w .
Ringel’s tree packing conjecture in quasirandom graphs                                                              1799


Lemma 3.3. For all 0 < i 0  i, w 2 W , W 0  W , X  V .G/, U  Alo     no
                                                                  i 0 [ Ai 0 , whp
 (i) jA0i0 ;w j < 2:1"i 0 jAi 0 j,
(ii) j¹w 2 W W w .u/ 2 Xºj < 1:1jXj C  for all u 2 Alo     no
                                                      i 0 [ Ai 0 ,
(iii) j¹w 2 W W w 1 .x/ 2 U ºj < 1:1jU j C  for all x 2 V .G/,
                             4               lo     no
(iv) j¹w 2 W W u 2 Abad
                    w ºj < 5ı n for all u 2 Ai 0 [ Ai 0 ,
 (v) :4"i 0 jW 0 j ıjAu j < j¹w 2 W 0 W u 2 A0i0 ;w ºj < 2:1"i 0 jW 0 j C ıjAu j for all u 2 Ai 0 ,
     P             0         0             0 g       0                   1       g
(vi)    u2Ai jF ŒN> .u/; Ai 0 ;w j and jF ŒAi ; Ai 0 ;w j are < 9pmax "i 0 jAi j for all g in
             g

     ¹hi; lo; noº.
                                                                               0
Proof. We write jAi 0 ;w j D f .Mi 0 /, where f is defined on Hi 0 by f .“w     .u0 /Dx 0 ”/ D
                             0              0        0                         3
                                 P
1w 0 Dw . We have f .Hi 0 ; ! / D u0 2Ai 0 ! .Hi 0 Œu w/  .1 2"i 0 /jAi 0 j ı n by Lemmas
3.2 and 3.1 (iv). For any e 2 Hi 0 we have f¹eº .Hi 0 ; ! 0 /  ! 0 .e/  1 < C ˇ f .Hi 0 ; ! 0 /.
By Lemma 2.8, whp
                                                         ˇ
                               f .Mi 0 / D .1 ˙ C            /f .Hi 0 ; ! 0 /  1    2:1"i 0 ;
so jA0i0 ;w 0 j < 2:1"i 0 jAi 0 j.
      Statements (ii) and (iii) are similar, using Lemma 3.1 (ii). For (iv), we have
                                      X
        j¹w 2 W W u 2 Abadw ºj              j¹w W w .v/ 2 Bºj  4:4jBj C 4 < 5ı 4 n
                                            v2N< .u/
by (ii) and Lemma 3.2.
    For (v) we write j¹w 2 W 0 W u 2 A0i0 ;w ºj D jW 0 j C :9 f .Mi 0 / redefining f by
setting f .;/ D :9 and f .“w .u0 /Dx”/ D 1w2W 0 ;u0 Du . Then
                      X
           0  :9 C       ! 0 .Hi 0 Œuw/ f .Hi 0 ; ! 0 / < j¹w 2 W W u 2 Abad
                                                                            w ºj:
                               w2W 0
                                                                 0      0      :9
By Lemma 3.1 (iv) we see that if u 2 Ahi       i 0 , then :5"i jW j < jW j C 
                                                              0                                         f .Hi 0 ; ! 0 / <
2"i 0 jW 0 j and if u 2 Alo     no
                         i 0 [ Ai 0 then (iv) implies

               :5"i 0 jW 0 j     5ı 4 n < jW 0 j C :9           f .Hi 0 ; ! 0 / < 2"i 0 jW 0 j C 5ı 4 n;
and f¹eº .Hi 0 ; ! 0 /  1 for all e, so by Lemma 2.8, whp (ii) holds.
    For (vi), we write 1 C jAgi j 1 u2Ag jF 0 ŒAi 0 ;w ; N> .u/j D f .Mi 0 /, where f .;/ D 1
                                       P
                                             i
and
                 f .“w .u0 /Dx 0 ”/ D 1wDw 0 jAgi j 1
                                                       X
                                                          jNF 0 .u0 / \ N> .u/j:
                                                                          g
                                                                     u2Ai
Using Lemma 3.1 (iv) we have
                                               2"i 0 /jAgi j 1
                                                                   X X
               f .Hi 0 ; ! 0 /    1 > .1                                          jNF 0 .u0 / \ N> .u/j
                                                                     g
                                                                  u2Ai u0 2Ai 0

                                               2"i 0 /jAgi j 1
                                                                   X
                                       D .1                              jF 0 ŒAi 0 ; N> .u/j
                                                                     g
                                                                  u2Ai
and
    f¹eº .Hi 0 ; ! 0 /  jAgi j 1 max                                         jAgi j 1 < C
                                               X
                                                                           1                      ˇ
                                   0
                                                             jN< .v/j < 4pmax                         f .Hi 0 ; ! 0 /:
                                        u
                                              v2N>   .u0 /
P. Keevash, K. Staden                                                                              1800


By Lemma 2.8, whp

  jAgi j 1   jF 0 ŒA0i0 ;w ; N> .u/j < 2:1"i 0 jAgi j 1
           X                                             X
                                                                                      1
                                                           jF 0 ŒAi 0 ; N> .u/j  9pmax "i 0 :
                  g                                               g
               u2Ai                                           u2Ai

The second bound is similar so we omit the proof.

    We conclude this subsection by deducing Lemma 3.1 (for i ) from the following estim-
ates on !-weighted degrees, which thus become the main goal of this section and which
we will prove assuming Lemmas 3.2–3.4 for all i 0 < i.
Lemma 3.4. Whp for each i 2 Œi  ,
 (i) !.Hi Œuw/ D 1 ˙ "i for all uw 2 Ai  W ,
                                                            ! … J bad ,
            ! is 1 ˙ :5":8 for all xw in J and is 1 ˙ " if xw
(ii) !.H Œxw/
           i                                        i                 i
                               :8      !
(iii) !.Hi Œxy/ is 1 ˙ " for all xy 2 Guv , and is 1 ˙ "i if v … Alo or y … B,
      P
(iv)    w2W !.“w .u/Dx”/ D 1 ˙ "i for all x 2 V .G/, u 2 Ai .

Proof of Lemma 3.1 for i . We have already noted that all ! 0 -weighted degrees are at most
1 :5"i , so it remains to prove the lower bounds. Statements (i) and (ii) are immediate
from ! 0 .e/ > .1 C ":8 / 1 .1 :5"i /!.e/ for any e 2 Hi , obtained by applying the defin-
ition of ! 0 , using Lemma 3.4.
    For (iii), if e D “w .u/Dx” with u 2 Ai n .Abad               lo
                                                     w \ NF 0 .A //, then !.Hi Œxy/ D
                                               !           bad
1 ˙ "i for all y D w .v/, v 2 N< .u/ and if xw 2 Ji n J , then !.Hi Œxw/  ! D1˙"
                                                                                          i
by Lemma 3.4, so
                      ! 0 .e/ > .1 C "i / 1 .1   :5"i /!.e/ > .1 C 1:6"i / 1 !.e/
by definition.
                                                                     no
   For (iv), note that for any e 2 Hi containing uw with u in Ahi         bad
                                                               i or Ai n Aw we have
 0                     1
! .e/ > .1 C 1:6"i / !.e/, so
                        ! 0 .Hi Œuw/ > .1 C 1:6"i / 1 !.Hi Œuw/ > 1          2"i :
                                                   0
If instead u 2 Alo n Abad
                      w then, by Lemma 3.1 (iii), ! .Hi Œuw/ is at least the sum of
             1
.1 C 1:6"i / !.e/ where e D “w .u/Dx” over x with xw! … J bad , so

 ! 0 .Hi Œuw/ > .1 C 1:6"i / 1 !.Hi Œuw/                                       4
                                                        ı 3 n  .1 ˙ :5":8 / 1 pmax jAu j 1 > 1   2"i :

    For (v), we consider codegrees according to the various types of vertices. First we
note that each ! 0 .“w .u/Dx”/  2pmax      4
                                                jAu j 1 . For each u, jAu j  , so this easily gives
the codegree bound for the pairs appearing in the following bounds: jHi Œuw; vwj D 0,
           ! D 0, jH Œuw; xwj
      ! ywj
jHi Œxw;                          !  1, jH Œuw; xyj  2. If “ .u/Dx” contains xw           ! and
                          i                       i                       w
                                                          !
xy then u 2 N> .v/ where w .v/ D y, so jHi Œxw; xyj is at most , or at most pmax              1
                                                                                                    if
                                   !         hi
v 2 A1 , or 0 if v 2 A0 and xw 2 J . These weighted codegrees are therefore at most
       4
2pmax   .ın/ 1 or 2pmax  4
                             1 <  :9 .
                                                                     !                  !
    It remains to bound ! 0 .Hi Œxy; xy 0 /. Suppose xy 2 Gu0 v0 and xy 0 2 Gu0 v00 , with
u0 v0 2 F 0 ŒAi ; Aj  and u0 v00 2 F 0 ŒAi ; Aj 0 , say with j 0  j . We have j > 0 as jN< .u/ \
A0 j  1 for all u 2 A1 , and as F ŒAhi  D ; we have jAu0 j jAv0 j  ın.
Ringel’s tree packing conjecture in quasirandom graphs                                    1801


    Suppose first that j 0 < j . Let f be the function on Hj [ ¹;º, where f .;/ D  :99 and
                               4
each f .“w .v/Dz”/ is 2pmax     jAu0 j 1 if z D y, v 2 Av0 and there are u 2 Au0 \ N> .v/
and v 0 2 N< .u/ \ Av00 with w .v 0 / D y 0 , or 0 otherwise. If j 0 > 0, then for each w 2 W
                                                          1
there is at most one v 0 with w .v 0 / D y 0 , at most pmax choices of u 2 Ai \ N> .v 0 /, and
at most four choices of v 2 N< .u/, so
                                            9
                f .Hj ; ! 0 /   :99 C 8npmax jAv0 j 1 jAu0 j 1 < 2 :99 :
If j 0 D 0, then there are at most  choices of u 2 Ai \ N> .v 0 /, and u 2 Alo , so every
v 2 N< .u/ in Av0 lies in Ano , so
                                                 8
                    f .Hj ; ! 0 /   :99 C 8npmax .ın/ 2 < 2 :99 :
                         4
As f¹eº .Hj ; ! 0 /  2pmax  1<C      ˇ
                                           f .Hj ; ! 0 /, by Lemma 2.8 whp
              ! 0 .Hi Œxy; xy 0 / < f .Mj / D .1 ˙ C    ˇ
                                                             /f .Hj ; ! 0 / <  :9 :
    Now suppose j 0 D j . Then j ¤ 0 and we cannot have v0 , v00 both in Ahi by definition
of A0 as a span, so jAv0 j jAv00 j  ın. Let f be the function on H2j [ ¹;º, where
                                                               4
f .;/ D  :99 and each f .“w .v/Dz”; “w .v 0 /Dz 0 ”/ is 2pmax jAu0 j 1 if z D y, z 0 D y 0 ,
                                                             0
v 2 Av0 , v 2 Av00 and there is u 2 Au0 \ N> .v/ \ N> .v /, or 0 otherwise. For each
u 2 Au0 there are  12 choices of .v; v 0 / so
                                            12
               f .Hj ; ! 0 /   :99 C 24npmax jAv0 j 1 jAv00 j 1 < 2 :99 :

As above, by Lemma 2.8, whp f .Mj / <  :9 .


3.2. Potential embeddings
We define a hypergraph H with vertex parts G, A1  W and V .G/  W , which contains
all potential edges of all Hi , in the following sense. Given w 2 W , u 2 V .T / and an
injection f W N .u/ ! V .G/ such that f .u0 /f .u/ 2 G for all u0 2 N< .u/ we let Pw .f /
be the “potential edge” containing u 2 V .T /, f .u/ 2 V .G/ and f .u0 /f .u/ 2 G for all
u0 2 N< .u/. For any u 2 S  N .u/ and injection f 0 W S ! V .G/ we let Pw .f 0 / be the
set of all Pw .f / 2 H such that f restricts to f 0 on S . We use the notation Pw .u ! x/
when S D ¹uº with f .u/ D x and Pw .uv ! xy/ when S D ¹u; vº with f .u/ D x,
f .v/ D y.
    For each time t we introduce a measure ! t on H where each ! t .Pw .f // estimates
the probability given the history at time t that the w-embedding will be consistent with f .
We define ! t by the following formula involving other estimated probabilities that will
be discussed below:
                                              Y
         ! t .Pw .f // D ! t .Pw W u ! x/           p t .uv/ 1 ! t .Pw W v ! f .v//:
                                             v2N< .u/

The key parameter in this formula is ! t .Pw W u ! x/, which will estimate the probab-
ility P t .w .u/ D x/ given the history at time t that we will have “w .u/Dx”. We also
associate an edge probability p t .uv/ to each v 2 N< .u/, where p t .uv/ D 1 if t  tv ,
P. Keevash, K. Staden                                                                           1802


otherwise p t .uv/ is p if t < t0 , is p1 if t0  t < t1 , or is puv for t  t1 . The intuition for
the formula is that conditional on “w .u/Dx”, the events w .v/ D f .v/ become about
p t .uv/ 1 times more likely and are roughly independent. In our calculations it will be
sufficient to work only with ! t .Pw W u ! x/, so the formula for the measure ! t above
can be thought of as just an intuitive explanation for why the calculations work (it is not
logically necessary for the proof).
      Note that we have introduced similar notation for two different quantities, namely
! t .Pw W u ! x/ and ! t .Pw .u ! x// D ¹! t .Pw .f // W Pw .f / 2 Pw .u ! x/º; they
                                                   P

will be approximately equal. In general, for any u 2 S  N .u/ and any injection f 0 W
S ! V .G/ we will have
                                                        Y
! t .Pw .f 0 //  ! t .Pw W f 0 / WD ! t .Pw W u ! x/         p t .uu0 / 1 ! t .Pw W u0 ! f .u0 //:
                                                       u0 2S n¹uº

Another important example of this will be

! t .Pw .uv ! xy//  ! t .Pw W uv ! xy/ D p t .uv/ 1 ! t .Pw W u ! x/! t .Pw W u ! y/:

Initially, we let all !0 .Pw W u ! x/ WD n 1 . (One can check that typicality of G gives
!0 .Pw .u ! x// D .1 ˙  :9 /!0 .Pw W u ! x/.) For t  tuw , i.e. times after w .u/ has been
defined, we let ! t .Pw W u ! x/ WD 1“w .u/Dx” . We thus have ! t .Pw .f 0 // D ! t .Pw W f 0 /
at times t after w .u/ has been defined for all u 2 N .u/ n S . In particular, if t  tu0 for
all u0 2 N< .u/ then there is at most one f with f .u/ D x consistent with the history, and
we have ! t .Pw .f // D ! t .Pw W u ! x/. Furthermore, for u 2 Ai , when we come to step
i of A PPROXIMATE DECOMPOSITION we will have ! ti .Pw W u ! x/ D !.“w .u/Dx”/.
     Now we define ! t .Pw W u ! x/ for general t and u 2 V .F /. As mentioned above,
we let !0 .Pw W u ! x/ D n 1 and ! t .Pw W u ! x/ D 1“w .u/Dx” for t  tuw . At each
time t < tuw where the possibility of “w .u/Dx” depends on an event in the algorithm,
if the event fails we let ! t .Pw W u ! x/ D 0, and if it succeeds we will divide by an
estimate for its probability, thus approximately preserving the conditional expectation of
the surviving weight. We let Pwt .u ! / be the set of x such that ! t .Pw W u ! x/ ¤ 0
and define Pwt . ! x/, Pt .u ! x/ in analogy, and also define Pwt . ! xy/ to be the set
of uv 2 F 0 such that ! t .Pw W u ! x/ ¤ 0 and ! t .Pw W v ! y/ ¤ 0.
     During H IGH DEGREES, we will have P tu0 .w .u0 /x 2 G/  p when we embed any
u 2 N< .u/ \ A , so if this occurs we let ! tu0 .Pw W u ! x/ WD p 1 ! t 0 .Pw W u ! x/. So
  0
                                                                               u
                                                                        
at the end of H IGH DEGREES, ! thi .Pw W u ! x/ is p jN< .u/\A j n 1 for x 2 Pwthi .u ! /
or 0 otherwise. (Note that our estimate ignores the possibility that “w .u/Dx” may be
impossible due to requiring an edge of G n G  .)
     In I NTERVALS, we require x 2 Xxw , which by Lemma 2.12 (i) occurs with probability
 pxw , and then we let ! tint .Pw W u ! x/ be pxw 1 ! thi .Pw W u ! x/ for x 2 Pwtint .u ! /
or 0 otherwise.
     In E MBED A0 , after choosing G0 and J0 , there are two cases. If u 2 A1 we let
                                                                           tG
! tG .Pw W u ! x/ D p1 jN< .u/\A0 nA j ! thi .Pw W u ! x/ for x 2 Pw 0 .u ! / and 0
     0                                                                             tG
otherwise. Indeed (recalling u 2 A1 ), for any x 2 Pwtint .u ! / we have x 2 Pw 0 .u ! /
Ringel’s tree packing conjecture in quasirandom graphs                                     1803


iff for u0 2 N< .u/ \ A0 n A we have xw .u0 / 2 G1 , which occurs with probability p1 . If
u 2 A0 n A we require xw  ! 2 J , which for available x has probability p =px , and then
                                  0                                            0   w
                                                                     tG
we let ! tG .Pw W u ! x/ be p0 1 ! thi .Pw W u ! x/ for x 2 Pw 0 .u ! / or 0 otherwise.
            0
     During the embedding of A0 , i.e. E MBED A0 (ii), after choosing some w .a/ at time
t D ta , for u 2 A0 n A we let ! t .Pw W u ! x/ be ! t .Pw W u ! x/ if au … T , or
if au 2 T we let ! t .Pw W u ! x/ be p0 1 ! t .Pw W u ! x/ for x 2 Pwt .u ! / or 0
                                                      
otherwise. So ! t0 .Pw W u ! x/ is p0 jNT .v/\A0 nA j ! thi .Pw W u ! x/ for x 2 Pwt0 .u ! /
or 0 otherwise. For u 2 A1 , if au 2 F 0 we let ! t .Pw W u ! x/ be p1 1 ! t .Pw W u ! x/
for x 2 Pwt .u ! / or 0 otherwise.
     For D IGRAPH, we let ! t1 .Pw W u ! x/ be
                                   Y
                       jAu j 1              puv1 for x 2 Pwt1 .u ! /
                               v2N< .u/\A0


or 0 otherwise. To justify this, we first consider u 2 Aai , a 2 A
                                                                  i , when N< .u/ \ A0 D ;,
          ˙
and all dH a .y/ D .1 ˙ ı/jAu j by Lemma 2.13 (viii). If u 2 Ano                       !
           i
                                                                    i we must choose xw 2
Jino with probability pxw =pxw  ˛ino =pxw D ˛ino =pxw . If instead u 2 Alo  i , we must choose
                        !
xw .v/ as an arc of Guv for all edges xw .v/ of G1 with v 2 N< .u/ \ A0 , each with
probability 12  2puv =p1 D puv =p1 independently, and wx     ! 2 J with probability ˛ lo =px .
                                                                     u                   i   w
    During A PPROXIMATE DECOMPOSITION, we let ! t .Pw W u ! x/ be equal to
jAu j 1 v2N< .u/\A t;w puv1 for x 2 Pwt .u ! / or 0 otherwise; we will see that whenever
         Q
                                                    !
we embed v 2 N< .u/, we have P .xw .v/ 2 Gu /  puv . We note that ! ti .Pw W u ! x/
D !.“w .u/Dx”/, as mentioned above. We emphasise that the ! t .Pw W u ! x/ are defin-
itions (with justifications provided only for intuition), and it is the sets Pwt .u ! x/ which
change during the algorithm.
    We use the notation ! t .Pw W u ! x/ with a set of vertices in place of one or more of
w; u; x to denote a sum of ! t .Pw W u ! x/ over these sets, for example ! t .PW W u ! x/
or ! t .Pw W V .T / ! x/ or ! t .PW W F 0 ŒAi ; Aj  ! xy/. To see the connection to weighted
                                                                       t
degrees in Lemma 3.4, observe that “w .u/Dx” 2 Hi iff x 2 Pwi .u ! /, so
                     X
    !.Hi Œuw/ D         ¹!.“w .u/Dx”/ W x 2 Pwti .u ! /º D ! ti .Pw W u ! NJu .w//
                D ! ti .Pw W u ! V .G//

                     ! D !  .P W A ! ! x/ and !.H Œxy/ D !  .P W F 0 ŒAg ; Ag 0 
and similarly !.Hi Œxw/   ti  w   xw             i          ti  W        i    j
                          0
! xy/ when xy 2 Gijgg .
    We conclude this subsection with the following lemma, which implies the estimate on
the weighted degrees !.Hi Œuw/ in Lemma 3.4 (i). The proof is immediate from Lemma
                                                                          C
2.13 (v), as x 2 Pwt .u ! / for t  t1 iff x 2 NJu .w/ \ v2N< .u/\A t;w N!
                                                         T
                                                                             .w .v//.
                                                                                Guv

Lemma 3.5. For all u 2 A1 , w 2 W and t  t1 we have
                                                                            Y
    jPwt .u ! /j D .1 ˙ 5/! t .Pw W u ! x/ 1 D .1 ˙ 5/jAu j                        puv :
                                                                      v2N< .u/\A t;w
P. Keevash, K. Staden                                                                          1804


3.3. J degrees
In this subsection we prove the estimates in Lemma 3.4 (v) concerning weighted degrees
         ! D !  .P W A ! ! x/ for xw
!.Hi Œxw/                               ! in J . We start with the following estimate at
                 ti  w    xw                    i
time t1 .
Lemma 3.6. For all xw ! 2 J hi [ J no we have !  .P W A ! ! x/ D 1. For all xw ! 2 J lo
                                   i       i            t1   w    xw                               i
whp ! t1 .Pw W Axw               :8
                  ! ! x/ D 1 ˙ :3" .


Proof. If xw! 2 J hi [ J no then P t1 . ! x/ D Ag , where g D no if xw ! 2 J no or g D a
                   i    i          w               i                           i
     !                                                              g 1
if xw 2 Ji for some a 2 Ai . We have ! t1 .Pw W u ! x/ D jAi j for all u 2 Agi , so
            a                               

! t1 .Pw W Agi ! x/ D 1.
                                                                       
      Now we consider the evolution of ! t .Pw W Alo                            lo
                                                    i ! x/. Initially !0 .Pw W Ai ! x/ D
         1
jAi jn D ˛i . During H IGH DEGREES, for each u 2 Ai , when we embed some a 2 A ,
    lo          lo                                       lo

if a … N< .u/ we have ! ta .Pw W u ! x/ D ! ta .Pw W u ! x/, whereas if a 2 N< .u/, as
P ta .w .a/ 2 NG .x// D .1 ˙ ı/p by Lemma 2.10 we have
           Eta ! ta .Pw W u ! x/ D P ta .w .a/ 2 NG .x//p 1 ! ta .Pw W u ! x/
                                         D .1 ˙ ı/! ta .Pw W u ! x/:
As jN< .u/j  4 we have E0 ! thi .Pw W Alo                 4 lo
                                         i ! x/ D .1 ˙ ı/ ˛i . For concentration, we
bound each j! ta .Pw W Ai ! x/ ! ta .Pw W Ai ! x/j by ! ta .Pw W Alo
                        lo                   lo
                                                                     i \ N> .a/ ! x/
       4
< pmax  .ın/ 1 , so by Lemma 2.4 whp ! thi .Pw W Alo
                                                    i  ! x/ D .1 ˙ 5ı/˛ lo
                                                                        i .
   After I NTERVALS, we can assume x 2 Xxw , and then
                          ! tint .Pw W Alo       xw 1 ! thi .Pw W Alo
                                         i ! x/ D p                  i ! x/:

After E MBED A0 , similarly to the above analysis for H IGH DEGREES, using Lemma 2.11
in place of Lemma 2.10, whp
                     ! t .Pw W Alo
                                   i ! x/ D .1 ˙ 5D
                                                    :9
                                                       /! tint .Pw W Alo
                                                                       i ! x/

and
                  ! t0 .Pw W Alo
                               i ! x/ D .1 ˙ 5D
                                                :9
                                                   ˙ 5˛0:9 /! tint .Pw W Alo
                                                                           i ! x/

                                         D .1 ˙ :1":8 /! tint .Pw W Alo
                                                                      i ! x/:

    After D IGRAPH, the part Jig of J containing xw! is determined; we can assume g D lo,
as we have already considered the other cases. Each ! t1 .Pw W u ! x/ is 0 unless u 2 Alo
                                                                                        i
                                        0   !                    0
and we have the event Eu that xw .u / in Guu0 for the unique u 2 N< .u/ \ A0 , in which
                                       1
case ! t1 .Pw W u ! x/ D jAlo   1
                             i j puu0 . By Lemma 2.13 we have
                           X
Et0 ! t1 .Pw W Alo
                 i ! x/ D        P t0 .Eu /jAlo  1  1
                                             i j puu0
                                 u2Alo
                                    i
          X
      D           .puu0 =p1 /  ! t0 .Pw W u ! x/pxw .˛ilo / 1 .p1 =puu0 / ˙  :9 D 1 ˙ :2":8 :
          u2Alo
             i

For concentration, note that for each xw .u0 / 2 G  , the assignment in D IGRAPH affects
Ringel’s tree packing conjecture in quasirandom graphs                                     1805


! t1 .Pw W Alo                0     lo   1     lo 1
             i ! x/ by  jN> .u / \ Ai jpmax jAi j
                                                          1
                                                      pmax .ın/ 1 . Consequently, by
                          lo                  :8
Lemma 2.4, whp ! t1 .Pw W Ai ! x/ D 1 ˙ :3" .
                                                                               ! … J bad .
    Next we give a significantly better estimate for ! t1 .Pw W Agi ! x/ for xw    i
               ! 2 J lo n J bad then whp !  .P W Alo ! x/ D 1 ˙ " .
Lemma 3.7. If xw    i      i               t1  w   i              1

Proof. By the proof of Lemma 3.6, whp
   ! t0 .Pw W A                   
                i ! x/ D ! t .Pw W Ai ! x/ D .1 ˙ 6D
                                                       :9
                                                          /.pxw n/ 1 jA
                                                                       i j ˙ ı;

and it suffices to show ! t0 .Pw W A0i ! x/ D .pxw n/ 1 jA0i j ˙ ı. For any u 2 A0i we have
          ! t0 .Pw W u ! x/ D .puu0 =p1 /  ! tint .Pw W u ! x/  1u0 2Siw \N ! .x/ ;
                                                                                      G1


so by definition of Jibad we have
         ! t0 .Pw W A0i ! x/ D .p1 pxw n/ 1 jSiw \ N! .x/j D .pxw n/ 1 jA0i j ˙ ı:
                                                             G1

The lemma follows.

    Next we give an estimate that will be used in several further lemmas below. For any
U  V .T / n A0 we let  2 .U / D ¹v W distT nA0 .v; U /  2º, where dist denotes graph
distance. For w 2 W we let
                Uw D ¹u 2 Pw . ! x/ \  2 .Alo / W N< .u/ \ Abad
                                                               w ¤ ;º:

Lemma 3.8. If u … Uw and u0 2 N< .u/ \ Ai 0 then
                    X
                           ! 0 .“w .u0 /Dx 0 ”/ D .1 ˙ 2:2"i 0 /puu0 :
                       x 0 2N !       .x/
                              Guu0


Proof. We note that
                        ! 0 .“w .u0 /Dx 0 ”/ D .1 ˙ 2"i 0 /!.“w .u0 /Dx 0 ”/
                 t 0
for any x 0 2 Pwi .u0 ! / n NJ bad .w/. Indeed, this holds by Lemma 3.1 (iii) for i 0 , as
u0 … Abad          lo
       w \ NF 0 .A / by definition of Uw . We deduce
                                                                  Y
         !.“w .u0 /Dx 0 ”/ D ! ti 0 .Pw W u0 ! x 0 / D jAu0 j 1        pu01v
                                                                        v2N< .u0 /\A<i 0
                                                  t 0
                                     D ..1 ˙ 5/jPwi .u0 ! /j/ 1
                                              0       0   0
                       P
by Lemma 3.5, so           x 0 2N !      .x/ ! .“w .u /Dx ”/ equals
                                  Guu0

                               t 0                   t 0               4 2
          .1 ˙ 2:1"i 0 /jPwi .u0 ! /j 1  jPwi .u0 ! / \ N! .x/j ˙ pmax ı ;
                                                                       Guu0

         4 2
with ˙pmax  ı accounting for x 0 2 NJbad .w/ when u0 … Ahi , and so ! 0 .“w .u0 /Dx 0 ”/ 
   4      1
pmax .ın/ . The lemma now follows by Lemma 2.13, similarly to the discussion before
Lemma 3.5.
P. Keevash, K. Staden                                                                                          1806


   Now we consider the evolution of ! t .Pw W Axw                        0
                                                 ! ! x/ during some step i < i of
A PPROXIMATE DECOMPOSITION. For lighter notation we write  D ti 0 and  D tiC0 .
                                                                        0


Lemma 3.9. Whp !0 .Pw W Axw                       :9  
                               ! ! x/ D .1 ˙ "i 0 /! .Pw W Axw   ! ! x/.


                                      on H
                                               
Proof. We consider the function             i 0 , where   .Eu / D 0 except if there is u 2
                                           4
Pw . ! x/ \ A>i 0 n Uw such that Eu consists of disjoint edges “w .u0 /Dx 0 ” with xx 0 2
!
Guu0 for each u0 2 N< .u/ \ Ai 0 , and then .Eu / D jAu j 1 u0 2N< .u/\Ai 0 puu10 . Now,
                                                               Q
                                                                                                       0
for u … Uw with N< .u/ \ A0i0 ;w D ;, given x 2 Pw .u ! /, we have x 2 Pw .u ! / iff
Eu  Mi 0 , and for such x we have .Eu / D !.“w .u/Dx”/. Thus
                                                      0
                        X
!0 .Pw W Axw
             ! ! x/ D      ¹!.“w .u/Dx”/ W x 2 Pw .u ! /º D .Mi 0 / ˙  ˙ 0 ;

where
           X
  D                                                       4
            ¹!0 .Pw W u ! x/ W N< .u/ \ A0i0 ;w ¤ ;º  pmax jAxw   1 0  0
                                                                 ! j jF ŒAi 0 ;w ; Axw
                                                                                     ! j

              5
    < 9"i 0 pmax ;
       X
 0 D                              5
             !0 .Pw W u ! x/  pmax jAbad
                                        w j jAxw
                                               !j
                                                  1     5 2
                                                    < pmax ı :
           u2Uw

Here we have bounded  by Lemma 3.3 (vi), and 0 by Lemma 3.2, also assuming
jAxw                                  !       hi              hi      2   lo
   ! j  ın, as we may, because if xw 2 J then Uw D ;, using A \  .A / D ; by
the definition of A0 as a 4-span.
    Next we estimate .Hi 0 ; ! 0 /, which equals
       X                      Y                  Y     X
                 jAu j 1               puu100                  ! 0 .“w .u0 /Dx 0 ”/:
     .!x/nU
 u2Pw                        u00 2N< .u/\Ai 0          u0 2N< .u/\Ai 0 x 0 2N !          .x/
              w
                                                                                   Guu0


By Lemma 3.8 we have

  .Hi 0 ; ! 0 /
                       X                           Y                           Y
            D                      jAu j 1                       puu100                     puu10 .1 ˙ 2:2"i 0 /puu0
                      .!x/nU
                  u2Pw                       u00 2N< .u/\A<i 0            u0 2N< .u/\Ai 0
                               w

            D .1 ˙ 8:9"i 0 /.! .Pw W Axw          5 2
                                         ! ! x/ ˙ pmax ı /;


with the error term as in the estimate for 0 . The lemma now follows from Lemma 2.8,
noting that jEu \ Eu0 j  1 (otherwise u; u0 would have two common neighbours), and
for any e D “w .u0 /Dx 0 ” we have
                             X
        f¹eº .Hi 0 ; ! 0 /                   4
                                   2jAu j 1 pmax       5
                                                  2pmax  1 < C ˇ .Hi 0 ; ! 0 /:
                               u2N> .u0 /

    Similarly to Lemma 2.11, we have the following estimates during the embedding
of A0i0 ;w (which has size < 2:1"i 0 n by Lemma 3.3).
Ringel’s tree packing conjecture in quasirandom graphs                                       1807

                                                                   0
Lemma 3.10. For any w 2 W , W 0  W , a 2 A0i0 ;w \ Agi 0 , x; y 2 V .G/, i 0 ; i 2 Œi  ,
g; g 0 2 ¹hi; lo; noº, writing Aw
                                a for the set of y such that w .a/ D y is possible given the
history at time ta , whp
 (i) P ta .w .a/ D y/ D .1 ˙ ":9     w 1
                               i 0 /jAa j ,
                                           gg          0
(ii) P ta .w .a/ 2 N!G .x// D .1 ˙ ":9
                                     i 0 /pi i 0 ,
                        Gi i 0
                                                 gg          0
(iii) j¹w 2 W W w .a/ 2 N!G .x/ºj D .1 ˙ ":9
               0                                         0     :8
                                           i 0 /pi i 0 jW j ˙ n .
                                  Gi i 0

Proof. Recallthat for each a 2 Ai 0 in any order, we let Wa D ¹w 2 W W w .a/ undefinedº,
let Va 2 jWVa j be uniformly random, and define

                      Ma D ¹w .a/w W w 2 Wa º D M ATCH.Ba ; Za /;

where Za D ¹w .b/w W b 2 N< .a/º and Ba  Va  Wa consists of all vw with v 2
NJi0 .w/ n Im w and each vw .b/ for b 2 N< .a/ an unused edge of Gi0 0 .
    To justify the application of Lemma 2.7 in defining Ma , we first note that by
Lemma 3.3 (v), jWa j > :3"i 0 n for all a 2 Ai 0 . Also Za has maximum degree  4. We
                                                                          jN< .a/jC1
also claim that whp Ba is ":7                                       :7
                                i 0 -super-regular of density .1 ˙ "i 0 /pmax        . To see this,
we argue similarly to Lemmas 2.10 and 2.11, except that Lemma 2.6 is not applicable, so
we instead apply Lemma 2.5. We have jWa j D jVa j  :3"i 0 n. We let Gfree  Gi0 0 denote
the graph of unused edges, and let B be the bad event that Gi0 0 n Gfree has each vertex of
degree > :1":9i 0 n. We will establish the claim at any step before B occurs, assuming the
claim for all b  a, and deduce       that whp B does not occur.
    Consider any R 2 W     a
                             
                         2
                              .  We    have
                                                   \                 [
            NBa .R/ D Va \ NJ 0 .R/ \ NGCfree            w .N< .a// n         Im w :
                                      i0
                                                       w2R                 w2R

As B does not occur, by Lemma 2.13 and a Chernoff bound, whp

                             jNBa .R/j D .1 ˙ ":8     jN< .a/jC1 jRj
                                               i 0 /.pmax       / jVa j;

unless R D ¹w; w 0 º with w .N< .a// \ w 0 .N< .a// ¤ ;; by Lemma 2.8 there are whp
< n1:5 such pairs R.
                            Va
   Now consider any R0 2 2      . Let W t be the set of w such that w .b/ 2 NG 0 .R0 / for
                               
                                                                                        i0
all b 2 N< .a/ with w .b/ defined at time t. As B does not occur,

                      jNBa .R0 /j D jWa \ NJC0 .R0 / \ W ta j ˙ :5":9
                                                                   i 0 n:
                                                  i0


For any b 2 N< .a/ and w 2 NJC0 .R0 /, if w .b/ is defined by Lemma 2.7 during H IGH
                              i0
DEGREES or A PPROXIMATE DECOMPOSITION then similarly to the proof of Lem-
ma 2.11, writing  D tb and  0 D tb , whp
                         0                                             0
                   jW  j D jM b ŒNG 0 .R0 /; W  j D .1 ˙ "j:8 /pmax
                                                                   jR j
                                                                        jW  j
                                           i0

by Lemma 2.7, assuming the claim for b 2 Aj with j < i 0 .
P. Keevash, K. Staden                                                                        1808


   Now suppose w .b/ is defined by the hypergraph matching in Hj . We consider the
function f on Hj with f .“w .u/Dx”/ D 1w2W  1uDb 1x2N 0 .R0 / , so
                                                         G 0
                                                          i
                                  X        X
                           0                     0
                  f .Hj ; ! / D                 ! .“w .b/Dx”/:
                                              x2N      .R0 / w2W 
                                                G0 0
                                                 i

Similarly to the proof of Lemma 3.8, if b … Abad
                                             w then
                                                            jR0 j
                        X
                                0
                              ! .“w .b/Dx”/ D .1 ˙ 2:2"j /pmax   :
                          x2N         .R0 /
                               G0 0
                                i
                                             4
By Lemma 3.3 (iv), whp j¹w W b 2 Abad
                                  w ºj < 5ı n, so
                    X       X
    f .Hj ; ! 0 / D              ! 0 .“w .b/Dx”/ D .1 ˙ 2:3"j /jNG 0 .R0 /j jW  j;
                                                                                   i0
                         x2N      .R0 / w2W 
                           G0 0
                            i
                                        0      jR j           0
and by Lemma 2.8, whp jW  j D .1 ˙ 3"j /pmax       jW  j.
    Together with Lemma 2.13 (ii) this proves the claim, and so justifies the definition
of Ma . Statements (i)–(iii) of the lemma now follow directly from Lemma 2.7, consider-
ing Ma ŒW 0 ; N!G .x/ for (iii). Also, whp every vertex degree in Gi0 0 n Gfree is .:1":9
                                                                                        i 0 n; 4/-
                Gi i 0
dominated from (i), so whp B does not occur.

   We deduce the following estimate similarly to the proof of Lemma 3.6, using
Lemma 3.10 in place of Lemma 2.11.
                                                  :8    
Lemma 3.11. Whp ! ti 0 C1 .Pw W Axw                               ! ! x/.
                                   ! ! x/ D .1 ˙ "i 0 /! C .Pw W Axw
                                                                            ti 0
                                                    ! D !  .P W A ! ! x/ required
    We conclude by deducing the estimates on !.Hi Œxw/   ti  w    xw
for Lemma 3.4. By Lemma 3.6, whp ! t1 .Pw W Axw                 :8
                                                ! ! x/ D 1 ˙ :3" , and by Lemmas
3.9 and 3.11, whp

               ! ti 0 C1 .Pw W Axw               :8    
                                                                   ! ! x/;
                                  ! ! x/ D .1 ˙ 2"i 0 /! C .Pw W Axw
                                                                     ti 0


so ! ti .Pw W Axw                :8             !
                 ! ! x/ D 1 ˙ :4" . Also, if xw … Ji
                                                       bad
                                                            then by Lemma 3.7, whp
   
! t1 .Pw W Axw! ! x/ D 1 ˙ "1 , and repeating the previous calculations shows that
                             :8
! ti .Pw W Axw
              ! ! x/ D 1 ˙ 3"i 1 D 1 ˙ "i . This completes the proof of Lemma 3.4 (ii).



3.4. G degrees
                                                !
This subsection concerns !.Hi Œxy/ for xy 2 Gi . We start by establishing Lem-
ma 3.4 (iii), which is Lemma 3.12 below, as this is needed for the analysis (and also
for Lemma 4.2 below).
Lemma 3.12. Whp ! ti .PW W u ! x/ D 1 ˙ "i for each x 2 V .G/ and u 2 Ai .
    We start with the corresponding estimate at time t1 .
Lemma 3.13. Whp ! t1 .PW W u ! x/ D 1 ˙ "1 for each x 2 V .G/ and u 2 Ai .
Ringel’s tree packing conjecture in quasirandom graphs                                                         1809


Proof. We consider cases according to the location of u.
     If u 2 Aai with a 2 A                               1
                          i then ! t1 .Pw W u ! x/ D jAu j 1w .a/x2Hi , and hence
                                                                     a

                         1
! t1 .PW W u ! x/ D jAu j dH a .x/ D 1 ˙ "1 by Lemma 2.13 (viii).
                                        i
                                           1
   If u 2 Ano
           i then ! t1 .Pw W u ! x/ D jAu j 1xw2J
                                              !
                                                  u
                                                    , so by Lemma 2.13 and a Chernoff
                                       :1
bound whp ! t1 .PW W u ! x/ D 1 ˙  .
                                             1       1
   If u 2 Alo i then ! t1 .Pw W u ! x/ D pu jAu j 1xw2J   !   1     0
                                                             u w .u /2N ! .x/
                                                                               , where
                                                                                                   Gu0
N< .u/ \ A0 D ¹u0 º. For each x 0 2 NG  .x/ there is a unique w 0 2 W with w 0 .u0 / D x 0 ,
so                                    X
            ! t1 .PW W u ! x/ D               pu01 jAu j 1 1xx 0 2!
                                                                   G
                                                                       !0 2J :
                                                                     1xw    u        u0
                                               x 0 2NG  .x/

As jNG  .x/j D .1 ˙ 2/pn, by Lemma 2.13 and a Chernoff bound whp ! t1 .PW W u ! x/
D 1 ˙ 3.

   Next we consider the evolution of ! t .PW W u ! x/ at step i 0 < i in the approximate
decomposition, again writing  D ti 0 ,  0 D tiC0 .
Lemma 3.14. Whp !0 .PW W u ! x/ D .1 ˙ ":8    
                                          i 0 /! .PW W u ! x/.

Proof. Let W 0 D ¹w 2 P .u ! x/ W u … Uw º. Consider the function on H
                                                                                    
                                                                                 i 0 where
                                                                               4
  .I / D 0 except if there is w 2 W 0 such that I consists of disjoint edges “w .u0 /Dx 0 ”
            !
with xx 0 2 Guu0 for each u0 2 N< .u/ \ Ai 0 , and then
                                                 Y
                              .I / D jAu j 1              puu10 :
                                                         u0 2N< .u/\Ai 0

Note that !0 .PW W u ! x/ D    .Mi 0 / ˙  ˙ 0 , where
                                     X
                      4
                 D pmax jAu j 1             j¹w 2 NJu .x/ W u0 2 A0i0 ;w ºj
                                     u0 2N< .u/\Ai 0
                           4        1
                      < 4pmax jAu j .2:1"i 0 dJu .w/ C ıjAu j/ < ":9
                                                                  i0 ;
                       4
                0 D pmax jAu j 1 j¹w 2 W W u 2 Uw ºj
                                    X
                       4
                    pmax .ın/ 1         j¹w W u0 2 Abad
                                                      w ºj < ı:
                                            u0 2N< .u/

Here we have used Lemmas 3.3 and 2.13 (ii, viii) to estimate  , and for 0 we have
used Lemmas 3.2 (v) and 3.3 (iv), also noting that if 0 ¤ 0 then u; u0 … Ahi by definition
of A0 , so jAu j  ın. Finally,

      .Hi 0 ; ! 0 /
           X                        Y                          Y             X
       D            jAu j 1                      puu10                                     ! 0 .“w .u0 /Dx 0 ”/
          w2W 0               u0 2N< .u/\Ai 0           u0 2N< .u/\Ai 0 x 0 2N !    .x/
                                                                              Guu0

      D .1 ˙ 9"i 0 /! .PW W u ! x/
by Lemma 3.8, and the lemma now follows from Lemma 2.8.
P. Keevash, K. Staden                                                                    1810


    We deduce Lemma 3.12 (i.e. Lemma 3.4 (iv)) from the previous two lemmas and the
following estimate which holds similarly to Lemma 3.11, using Lemma 3.10 (iii).
Lemma 3.15. Whp all ! ti 0 C1 .PW W u ! x/ D .1 ˙ ":8         
                                                        i 0 /! t C .PW W u ! x/.
                                                                i0
                                          !                                         0
   Now we turn to the degrees of xy 2 Gi . We consider ! t .PW W F 0 ŒAgi ; Ajg  ! xy/,
           !G                                                                            0
where xy 2 Gij , 0  j < i , and for convenient notation we label arcs of F 0 ŒAgi ; Ajg  as
                         0              !      !
uv with u 2 Agi , v 2 Ajg . Recall that GiG0 D GiG0 for all g 0 . We start with an estimate at
time t1 .
                                           0                                   !
Lemma 3.16. Whp ! t1 .PW W F 0 ŒAgi ; Ajg  ! xy/ D 1 ˙ "1 for all xy 2 GijG .

Proof. We consider cases according to g; g 0 ; i; j where 0  j < i.
                                 !
     We start with the case xy 2 GiG0 . For each uv 2 F 0 ŒAlo  i ; A0 , w 2 W we have
                                                   v
! t1 .Pw W uv ! xy/ D 0, except for the unique w 2 W with w v .v/ D y, for which

          ! t1 .Pw v W uv ! xy/ D ! t1 .Pw v W u ! x/ D .pilo0 jAlo   1
                                                                   i j/ 1xw v 2J lo ;
                                                                                  i


so ! t1 .PW W uv ! xy/ D .pilo0 jAlo   1                  v
                                   i j/ 1xw v 2Jilo . The w are distinct, so the events
    v
¹xw 2 Ji º are independent. Each affects ! t1 .PW W uv ! xy/ by < puv1 pmax
           lo                                                              1
                                                                              .ın/ 1 , so
by Lemma 2.4, whp

          ! t1 .PW W F 0 ŒAlo                       1 0  lo
                            i ; A0  ! xy/ D .puv n/ jF ŒAi ; A0 j ˙ n
                                                                        :4


                                           D puv1 .puv    pmin / ˙ n :4 D 1 ˙ "1 :
                                !
   Next consider the case xy 2 GijG , j 2 Œi 1. For each uv 2 F 0 ŒAhi   no
                                                                     i ; Aj , w 2 W we
                                        !           !                 
have ! t1 .Pw W uv ! xy/ D 0, except if xw 2 Ju and yw 2 Jv , when ! t1 .Pw W uv ! xy/
                                 ! 2 J iff  .a/ 2 N .x/, where u 2 Aa , and as
D .puv jAu j jAv j/ 1 . We have xw      u     w         Hia                     i
                                                                                    !
d.x; y/ > 3d since any close edges were removed from G1 , the events xy 2 Guv ,
  !                 !
¹xw 2 Ju º and ¹yw 2 Jv º are conditionally independent given H IGH DEGREES. By
Lemma 2.13 and a Chernoff bound, whp there are .1 ˙  :6 /˛v dH a .x/ choices of w
                                                                     i
with ! t1 .Pw W uv ! xy/ ¤ 0, so

   ! t1 .PW W uv ! xy/ D .1 ˙  :6 /dH a .x/puv1 jAu j 1 n 1 D .1 ˙ :2"1 /.puv n/ 1
                                            i

by Lemma 2.13, giving the required estimate.
                      !
   The case xy 2 GijG , j 2 Œi 1, is similar to the previous one.
                                 !
   Now consider the case xy 2 GijG , j 2 Œi 1. For each uv 2 F 0 ŒAno   no
                                                                    i ; Aj , w 2 W we
have ! t1 .Pw W uv ! xy/ D 0, except if xw           ! 2 J , when !  .P W uv ! xy/
                                           ! 2 J and yw
                                                 u          v        t1   w
                       1
D .puv jAu j jAv j/ . By a Chernoff bound, whp
                                 X
          ! t1 .PW W uv ! xy/ D      ! t1 .Pw W uv ! xy/ D .puv n/ 1 ˙ n 1:4 ;
                                  w2W

giving the required estimate.
Ringel’s tree packing conjecture in quasirandom graphs                                               1811

                                           !                              !
     Finally, consider the case xy 2 GijG , j 2 Œi 1. (The case xy 2 GijG is similar, and this
is the last case by the definition of A0 as a 4-span.) For each uv 2 F 0 ŒAlo       no
                                                                               i ; Aj , w 2 W
we have ! t1 .Pw W uv ! xy/ D 0, except in the event Euvw that xw 2 Ju , yw!           !2J
                                                                                                v
          0   !G               0         0    0                           
and xx 2 Gi0 , where x D .u /, ¹u º D N< .u/ \ A0 , when ! t1 .Pw W uv ! xy/ D
.puv pi0lo
            jAu j jAv j/ 1 . For each x 0 2 V .G/ there is a unique w 0 2 W with w 0 .u0 / D x 0 ,
so                                           X
                 ! t1 .PW W uv ! xy/ D          ! t1 .Pw W uv ! xy/
                                            w2W
                                               X
                                      D                    1Euvw .puv pilo0 jAu j jAv j/ 1 :
                                            x 0 2N ! .x/
                                                   G1

We have
                Et0 ! t1 .PW W uv ! xy/ D .pilo0 =p1 /d! .x/.puv pilo0 n2 / 1 ;
                                                                 G1
                                                                    ! affect
                                                             ! and yw
where whp d! .x/ D .1 ˙ 2/p1 n. Note that the decisions on xw
                G1
! t1 .PW W uv ! xy/ by < .puv pilo0 / 1 .pmax ın/ 2 . For each xx 0 , there are n choices
of w 0 , which determines u0 D w 10 .x 0 /, then <  choices for each of u and v, so the
decision on ¹xx 0 2 Gilo0 º affects ! t1 .PW W uv ! xy/ by < n.puv pilo0 / 1 .pmax ın/ 2 .
The required estimate now follows from Lemma 2.1.
                                                                        0
   Next we consider the evolution of ! t .PW W F 0 ŒAgi ; Ajg  ! xy/ at step i 0 < i in the
approximate decomposition, again writing  D ti 0 ,  0 D tiC0 .
                                                                   0
Lemma 3.17. At step i 0 < i whp !0 .PW W F 0 ŒAgi ; Ajg  ! xy/
                                         0                                    !
 is .1 ˙ :7":8 /! .PW W F 0 ŒAgi ; Ajg  ! xy/ for each 0  j < i and xy 2 GijG ,
                                      0
 is .1 ˙ "8i0 /! .PW W F 0 ŒAgi ; Ajg  ! xy/ if j ¤ i 0 or y … B or xy … G no;lo .
                                                                                         0
Proof. We start with the case j < i 0 . We note for each uv 2 F 0 ŒAgi ; Ajg , w 2 W that
! .Pw W uv ! xy / and !0 .Pw W uv ! xy/ are 0 unless w .v/ D y, in which case
! .Pw W uv ! xy/ D ! .Pw W u ! x/, and !0 .Pw W uv ! xy/ D !0 .Pw W u ! x/.
By Lemma 3.14 we deduce
                              0                         0
     !0 .PW W F 0 ŒAgi ; Ajg  ! xy/ D   jN< .u/ \ Ajg j.1 ˙ ":8
                                         X
                                                                      
                                                                i 0 /! .PW W u ! x/
                                                g
                                            u2Ai
                                                                    g    g          0
                                          D .1 ˙ ":8            0
                                                  i 0 /! .PW W F ŒAi ; Aj  ! xy/:


    Now we may assume j  i 0 . Suppose j D i 0 . We consider the function                     on H
                                                                                                     
                                                                                                   i0 ,
                                                                                                  4
                                                                                                 0
where   .E/ D 0 except if there are w 2 W and uv 2 Pw . ! xy/ \ F 0 ŒAgi ; Agi 0  with
                                                                           !
u … Uw such that E consists of disjoint edges “w .u0 /Dx 0 ” with xx 0 2 Guu0 for each
u0 2 N< .u/ \ Ai 0 and x 0 D y when u0 D v, and then
                                                        Y
                 .E/ D !0 .Pw W u ! x/ D jAu j 1                 puu10 :
                                                                 u0 2N< .u/\Ai 0
P. Keevash, K. Staden                                                                                    1812

                                            0
    Note that !0 .Pw W F 0 ŒAgi ; Agi 0  ! xy/ D            .Mi 0 / ˙  ˙ 0 , where
                     X
            D             ¹!0 .Pw W uv ! xy/ W N< .u/ \ A0i0 ;w ¤ ;º
                     uvw

                                          jF 0 ŒA0i0 ;w ; N> .v/ \ Agi jpmax jAgi j 1 jAyw
                        X         X
                                                                           8                 1
                                                                                         !j
                         ! g v2A !
                     wW xw2J i  yw

                           9 C
                 < 9"i 0 pmax dJ g .x/jAgi j 1
                                  i

              < ":9
                 i0 ;
                X
           0 D       ¹!0 .Pw W uv ! xy/ W u 2 Uw º
                     vw
                                        X
                     8
                  pmax n.ın/ 2                    j¹w W u0 2 Abad     :9
                                                               w ºj < ı :
                                      u0 2N< .u/

Here the bound on  follows from Lemmas 3.3 (vi) and 2.13, and the bound on 0 by
Lemmas 3.3 (iv) and 3.2, also noting that if 0 ¤ 0 then u; v … Ahi by definition of A0 ,
             0
so jAgi j; jAjg j  ın.
    Next we estimate .Hi 0 ; ! 0 /, which equals
     X          h         Y                                                        Y                       i
                  jAu j 1             puu100 ! 0 .“w .v/Dy”/                                     guu0 .xw/ ;
 uvw2S; u…Uw               u00 2N< .u/\Ai 0                               u0 2N< .u/\Ai 0 n¹vº

                                                                            0
where S WD ¹uvw W w 2 W; uv 2 Pw . ! xy/ \ F 0 ŒAgi ; Ajg º and by Lemma 3.8,
                                       X
             guu0 .xw/ WD                          ! 0 .“w .u0 /Dx 0 ”/ D .1 ˙ 2:2"i 0 /puu0 :
                               x 0 2N   !    .x/
                                        Guu0


To obtain the required estimates in the case j D i 0 , by Lemma 2.8 it suffices to show
that ! 0 .“w .v/Dy”/ is .1 ˙ :6":8 /!.“w .v/Dy”/ when v 2 Alo (which is equivalent to
xy 2 G no;lo ) and that if v … Alo or y … B then the sum of
                                              Y               Y
              f .uvw/ WD .jAu j jAv j/ 1               puu10           pvv10
                                                   u0 2N< .u/\Ai 0      v 0 2N< .v/\Ai 0


over uvw 2 S for which yw    ! 2 J bad is at most pı, the sum of f .uvw/ over uvw 2 S with
                                  p
v 2 Abad            lo
      w \ N< .A / is at most       ı, and for every other uvw 2 S we have ! 0 .“w .v/Dy”/
D .1 ˙ 2"i 0 /!.“w .v/Dy”/.
    So first assume v 2 Alo . For each y 0 D w .v 0 /, v 0 2 N< .v/, as v 2 Alo we have v 0 … Alo ,
so !.Hi 0 Œyy 0 / D 1 ˙ "i 0 by Lemma 3.4 (iii) for i 0 . Parts (i), (iii) imply that !.Hi 0 Œv/ D
1 ˙ :5":8 for v D vw; yw, ! so ! 0 .“ .v/Dy”/ D .1 :5" /.1 ˙ :5":8 /!.“ .v/Dy”/,
                                         w                          i                    w
as required.
    Next, suppose y … B or v … Alo . Consider those uvw 2 S with yw          ! 2 J bad . Then y … B
           lo                    !       bad            hi
and v 2 A , since otherwise yw … J . So u … A by the definition of A0 , and therefore
Ringel’s tree packing conjecture in quasirandom graphs                                                        1813


jAu j; jAv j  ın. Since y … B, there are < ı 3 n choices of w withpyw   ! 2 J bad , so the sum
                   !      bad         3
                                        P           8
of f .uvw/ with yw 2 J is  ı n uv pmax jAu j jAv j < ı.   1     1

    All other terms uvw have yw    ! … J bad . Consider those uvw 2 S with v 2 Abad \
                                                                                           w
N< .Alo /. Then v; u 2 Ano by the definition of A0 as a 4-span, so jAu j; jAv j  ın. Each
remaining w has < ı 3 n choices of v 2 Abad w by p Lemma 3.2, so the total sum of these terms
f .uvw/ is  w ı 3 npmax   9
                             jAu j 1 jAv j 1 < ı.
                P

    Since all other terms uvw have yw   ! … J bad , by Lemma 3.4 (iii) for i 0 we may assume
that there are (not necessarily distinct) v 0 ; v 00 2 N< .v/ with w .v 0 / 2 B and v 00 2 Alo ,
or else we have ! 0 .“w .v/Dy”/ D .1 :5"i 0 /.1 ˙ "i 0 /!.“w .v/Dy”/. But then v 2
                                                                       0
Abad           lo
  w \ N< .A /, proving the claim and completing the case j D i . 
    Finally, we suppose i 0 < j < i . We consider the function on H      8
                                                                           i 0 , where .E/ D 0
                                                                                    0
except if there are w 2 W and uv 2 Pw . ! xy/ \ F 0 ŒAgi ; Ajg  with u … Uw such that
                                                         !
E consists of disjoint edges “w .u0 /Dx 0 ” with xx 0 2 Guu0 for each u0 2 N< .u/ \ Ai 0
           !
and yx 0 2 Gvv0 for each v 0 2 N< .v/ \ Ai 0 , and then .E/ D f .uvw/. Note that we have
                         0
!0 .PW W F 0 ŒAgi ; Ajg  ! xy/ D .Mi 0 / ˙  ˙ 0 , with  as in the case j D i 0 and
                            X
                 0D              ¹!0 .Pw W uv ! xy/ W N< .v/ \ A0i0 ;w ¤ ;º
                            uvw

                                                 jAgi j 1 jAyw
                              X
                                              8                  1 1    0  0
                                           pmax             ! j pmax jF ŒAi 0 ;w ; Ayw
                                                                                      ! j
                               !
                            wWxw2J
                                        g
                                   i

                                                            jAgi j 1 < ":9
                                               X
                                  10
                        < 9"i 0 pmax                                    i0
                                                !
                                            wW xw2J
                                                        g
                                                    i


by Lemmas 3.3 (vi) and 2.13. Now we estimate
                     X      h            Y                                               Y                     i
   0
     .Hi 0 ; ! 0 / D          f .uvw/                                  guu0 .xw/                      gvv0 .yw/ :
                  uvw2S; u…Uw                       u0 2N< .u/\Ai 0                v 0 2N< .v/\Ai 0

By Lemma 3.8, guu0 .xw/ D .1 ˙ 2:2"i 0 /puu0 and gvv0 .yw/ D .1 ˙ 2:2"i 0 /pvv0 , so
                                                                g    g         0
                    0
                        .Hi 0 ; ! 0 / D .1 ˙ ":9            0
                                              i 0 /! .PW W F ŒAi ; Aj  ! xy/:

The lemma now follows from Lemma 2.8.

    Similarly to Lemma 3.11, we also have the following estimate.
Lemma 3.18. Whp
                                    0                                                           0
      ! ti 0 C1 .PW W F 0 ŒAgi ; Ajg  ! xy/ D .1 ˙ ":8             0  g    g
                                                      i 0 /! C .PW W F ŒAi ; Aj  ! xy/:
                                                                        ti 0

   We conclude the proof of Lemma 3.4 (and so of Lemma 3.1) by deducing the estimates
                                                                             !
on !.Hi Œxy/ D ! ti .PW W F 0 ! xy/ required for Lemma 3.4. For any xy 2 GijG , by
                                                    0
Lemma 3.16, whp ! t1 .PW W F 0 ŒAgi ; Ajg  ! xy/ D 1 ˙ "1 . At step i 0 < i, by Lemmas 3.17
                                                0                                                        0
and 3.18, whp !0 .PW W F 0 ŒAgi ; Ajg  ! xy/ is .1 ˙ :7":8 /! .PW W F 0 ŒAgi ; Ajg  ! xy/,
P. Keevash, K. Staden                                                                       1814

                                g    g      0
and is .1 ˙ 3":8            0                         0
              i 0 /! .PW W F ŒAi ; Aj  ! xy/ if j ¤ i or y … B or xy … G
                                                                           no;lo
                                                                                 . Thus
                                        0
!.Hi Œxy/ D ! ti .PW W F 0 ŒAgi ; Ajg  ! xy/ is 1 ˙ ":8 , and is 1 ˙ 4":8
                                                                          i 1 D 1 ˙ "i if j ¤ i
                                                                                                0

                     no;lo
or y … B or xy … G         .


4. Exact decomposition

In this section we complete the proof of our main theorem in each of the cases S, P
and L. We start in the first subsection with some properties of the leftover graph from the
approximate decomposition required for Cases S and P, then analyse each case separately
over the following subsections.


4.1. Leftover graph
In both Cases S and P the approximate decomposition constructs edge-disjoint copies Fw ,
                                                 0
                                                        S
w 2 W of F D T n Pex . The leftover graph Gex      D G n w2W w .F / is obtained from
Gex by adding all unused edges of G n Gex (and removing any orientations). We require
the following typicality properties.
Lemma 4.1. For any w 2 W and S 2 Vs     .G/
                                             
                                               , whp
                                     0
                        jNJex .w/ \ Gex .S /j D .1 ˙ p0:9 /pex
                                                            0
                                                               .2pex /jS j n:
                                                                                     0
    As in Lemma 2.13, a stronger form of this estimate holds with Gex in place of Gex  ,
so it suffices to bound the maximum degree in the unused subgraph of G n Gex . Given
the trivial bounds whp .G0 / < 1:1p0 n and .Gi0 / < 1:1pmax n, the following estimate
implies Lemma 4.1.
                                                                 0
Lemma 4.2. Whp the unused subgraph of each Gigg                          :8
                                              i 0 has maximum degree < 5" n.

Proof. We fix x 2 V .G/ and consider separately the contributions to the unused degree ux
            ˙
of x from N!  G
                .x/. For indegrees, let f be the function on Hi defined by
             Gi i 0

                                                                           0
                        f .“w .u/Dx 0 ”/ D 1x 0 Dx 1u2Ag jN< .u/ \ Agi 0 j:
                                                            i

We have
                            X
          f .Hi ; ! 0 / D       ¹! 0 .Hi Œxy/ W y 2 N!G .x/º  .1        2":8 /d!
                                                                                 ˙
                                                                                   G
                                                                                     .x/
                                                        Gi i 0                   Gi i 0

by Lemma 3.1, so by Lemma 2.8 whp this contribution to ux is < 2:1":8 n.
     For outdegrees, first note that if i 0 D 0 then for each u 2 A0 there is a unique w 2 W
with “w .u/Dx”, for which we use jN> .u/ \ Agi j out-arcs at x. Thus we use exactly
F 0 ŒA0 ; Agi  D n.pig0 pmax / out-arcs at x, so this contribution is whp < 2pmax n. Now
for i 0 2 Œi 1, let fi 0 be the function on Hi 0 defined by

                        fi 0 .“w .u/Dx 0 ”/ D 1x 0 Dx 1u2Ag0 jN> .u/ \ Agi j:
                                                             i0
Ringel’s tree packing conjecture in quasirandom graphs                                                   1815


By Lemma 3.1 we have
                                                                                                    0
                        jN> .u/ \ Agi j                                            2":8 /jF 0 ŒAgi 0 ; Agi j:
                      X                 X
 fi 0 .Hi 0 ; ! 0 / D                     ! 0 .“w .u/Dx”/  .1
                              g0                      w2W
                     u2Ai 0

             0                       0
As jF 0 ŒAgi 0 ; Agi j D n.pigg
                               i0          pmax /, this contribution is whp < 2:1":8 n.


4.2. Small stars
Here we conclude the proof of Theorem 1.1 in Case S, where Pex is a union of leaf stars
in T n T ŒA , each of size  ƒ D n1 c , with jPex j D pex n D p n=2 ˙ n1 c . We start
with some further properties of the approximate decomposition needed in this case.
                                             V
                                                
Lemma 4.3. (i) For any x 2 V and R 2 2           , whp
                              X
                    † WD            dPex .w 1 .x// D .1 ˙ "/.pex
                                                               0 jRj
                                                                  / jPex j:
                                   w2NJex .R/

(ii) For any y 2 V and w 2 W , whp
                         X
                               dPex .w 1 .x// D .1 ˙ "/2pex jPex j:
                                   x2Gex .y/

Proof. We prove (i) and omit the similar proof of (ii). We consider the contribution to †
from each a 2 V .F / according to its location in T .
    For each a in A0 we define Ma D ¹w .a/w W w 2 W º D M ATCH.Ba ; Za /. By Lem-
ma 2.7, for each b 2 N< .a/ and w 2 W we have P tb .w .b/ 2 NG .x// D .1 ˙ :1 0 /p, and
if w .b/ 2 NG .x/ for all b 2 N< .a/ then P ta .w .a/ D x/ D .1 ˙ :1 0 /.p jN< .a/j n/ 1 .
By Lemma 2.4, whp the contribution to † from A0 is
               X      X                                                   X
    †ŒA0  WD                 1w .a/Dx dPex .a/ D .1 ˙ :3 0 /jNJex .R/j   dPex .a/=n
                 a2A0 w2NJex .R/                                                     a2A0
                                           X
                         0 jRj
                          0
             D .1 ˙  /.pex /                     dPex .a/:
                                           a2A0

   Now we consider the contribution from Ai with i 2 Œi  . By the proof of Lemma 3.12,
whp      X
               ! 0 .“w .u/Dx”/ D ! ti .PJex .R/ W u ! x/ D .1 ˙ "i /.pex 0 jRj
                                                                             /
           w2Jex .R/

for each i 2 Œi  , u 2 Ai . The function f on Hi defined by

                               f .“w .u/Dx 0 ”/ D 1x 0 Dx 1w2NJex .R/ dPex .u/

has
                   X                        X                                                X
 f .Hi ; ! 0 / D          dPex .u/                                                  0 jRj
                                                      ! 0 .“w .u/Dx”/ D .1 ˙ "i /.pex /           dPex .u/:
                   u2Ai                  w2NJex .R/                                         u2Ai
P. Keevash, K. Staden                                                                        1816


By Lemma 2.8, whp the contribution to † from the hypergraph matching embedding Ai
is
                       X
   †ŒAi  WD f .Mi / D     dPex .u/j¹w 2 NJex .R/ W “w .u/Dx” 2 Hi ; u … A0i;w ºj
                           u2Ai
                                    X
                          0 jRj
            D .1 ˙ 2"i /.pex /            dPex .u/:
                                   u2Ai

    It remains to consider the contribution from defining w .a/ for w 2 Wa by ¹w .a/w W
w 2 Wa º D M ATCH.Ba ; Za /, where Za D ¹w .b/w W b 2 N< .a/º and Ba  Va  Wa con-
sists of all vw with v 2 NJi0 .w/ n Im w and each w .b/v for b 2 N< .a/ an unused edge
of Gi0 . Here Va 2 jWVa j is uniformly random, so P .x 2 Va / D jWa j=n. By Lemma 3.3 (ii),
                         

:3"i n < jWa j < 2:2"i n.
                                                                           jN< .a/j
    Similarly to the above analysis of A0 , whp there are .1 ˙ :1 0 /pmax          jNJex .R/j
choices of w 2 NJex .R/ with w .b/ 2 NGi0 .x/ for all b 2 N< .a/, and for each such
                                            jN< .a/j
w we have P ta .w .a/ D x/ D .1 ˙ :1 0 /.pmax      jWa j/ 1 . Thus the contribution from
defining w .a/ for a 2 Ai , w 2 Wa is whp
                  X
                       dPex .a/j¹w 2 Wa \ NJex .R/ºj=n < 3:1"i †ŒAi :
                   a2Ai

    Summing all contributions gives the stated estimate.

    In the subroutine S MALL STARS we start by finding an orientation D of the leftover
         0                   C
graph Gex   such that each dD   .x/ is jLx j, where Lx is the set of all uw where u is a leaf
of a star in Pex with centre w 1 .x/. By the case R D ; of Lemma 4.3 (i), whp jLx j D
                                                                                          0
.1 ˙ "/jPex j. To construct D, we start with a uniformly random orientation of Gex          , and
               C                                                                  C
while not all dD .x/ are jLx j, choose uniformly random x; y; z with jLx j > dD .x/, jLy j <
dDC
    .y/, z 2 NDC .y/ \ ND .x/ and reverse yz,     !
                                               ! zx.
                                                                         0
    To analyse this process, we first note that by typicality of Gex          (Lemma 4.1) and
                             C                    :7                       :7
a Chernoff bound, whp dD .x/ D .1 ˙ 1:1p0 /pex n D jLx j ˙ 2p0 n for each x and
jNDC .y/ \ ND .x/j  pex  2
                            n=2 for all x, y. Thus each vertex v plays the role of x or y at
         :7
most 2p0 n times. We let B be the bad event that we reverse > :2p0:6 n arcs at any vertex v.
We will show that whp B does not occur. At any step before B occurs where we con-
sider x and y as above, the number of choices for z is whp > :49pex    2
                                                                         n p0:6 n > :48pex    2
                                                                                                n.
                                                                       2
Thus at any step, v plays the role of z with probability < 1=.:48pex n/, so the number of
such steps is .; 1/-dominated with  < 2p0:7 n2 =.:48pex  2
                                                             n/ < :1p0:6 n. By Lemma 2.4 we
                                                                          C
deduce that whp B does not occur, so we can construct D with all dD          .x/ D jLx j.
    Now for each x 2 V .G/ in arbitrary order, we define w .u/ for all uw 2 Lx by
Mx D ¹¹uw; w .u/º W uw 2 Lx º D M ATCH.Fx ; ;/, where Fx  Lx  NDC .x/ consists
of all ¹uw; yº with uw 2 Lx , y 2 NDC .x/ \ NJex .w/ n Im w .
    To analyse this process, we consider
                   Zx D ¹¹uw; yº 2 Lx  .NDC .x/ \ Jex .w/ \ Im w /º
                                                                    :9
and let Bx be the bad event that Zx has every vertex of degree > :1pex jLx j. Recall that
Ringel’s tree packing conjecture in quasirandom graphs                                       1817

         0
pex  pex   1 in Case S and at the beginning of S MALL STARS we have Im w \
NJex .w/ D ;.
                                                                             :02
Lemma 4.4. Whp under the construction of D, if Bx does not occur then Fx is pex  -
                               :8   0
super-regular of density .1 ˙ pex /pex .
                 C
Proof. Any R 2 ND2.x/ has
                      

                                                                         0 jR0 j
                 X
   jNFx .R/j D                                  :9
                        dPex .w 1 .x// ˙ :1jRjpex                 :8
                                                   jLx j D .1 ˙ :1pex /.pex / jPex j
                  w2NJex .R/

by Lemma 4.3. Any R0 2 L   x
                             
                          2
                               has
                             ˇ         \        ˇ
              jNFx .R0 /j D ˇNDC .x/ \                      :9
                                         Jex .w/ˇ ˙ :1jR0 jpex jLx j;
                             ˇ                  ˇ
                                              uw2R0

                                                        :8    0 jR j         0
which by Lemma 4.1 and a Chernoff bound is whp .1 ˙ :1pex  /.pex / jPex j unless R0 D
¹uw; u0 wº for some w; there are < w2W dPex .w 1 .x//2 < n2 c such R0 . The lemma
                                  P

now follows from Lemma 2.5.

    By Lemma 2.7 we can choose Mx D ¹¹uw; w .u/º W uw 2 Lx º D M ATCH.Fx ; ;/,
                                :01    0
and P .w .u/ D y/ D .1 ˙ pex       /.pex jPex j/ 1 for all ¹uw; yº 2 Fx .
    It remains to show that whp no Bx occurs. We define a stopping time  as the first x
for which Bx occurs and bound P . D x/.
    First we bound dZx .uw/ for uw 2 Lx . For any y 2 NDC .x/, when processing any x 0
before x we defined w .u0 / for dPex .w 1 .x 0 // leaves u0 of w 1 .x 0 /, each of which
could be y if y 2 NDC .x 0 / \ Jex .w/, with probability < .:9pex   0
                                                                      jPex j/ 1 . Thus dZx .uw/ is
.; n1 c /-dominated with
               X
          D       jNDC .xx 0 / \ Jex .w/jdPex .w 1 .x 0 //.:9pex
                                                                0
                                                                   jPex j/ 1 < 1:2pex2
                                                                                       n;
                x0

so by Lemma 2.4, whp dZx .uw/ < 3pex jLx j.
    Now we bound dZx .y/ for y 2 NDC .x/. For any uw 2 Lx with w 2 Jex .y/, when
processing any x 0 2 ND .y/ before x, we had w .u/ D y for some leaf u with probability
< dPex .w 1 .x 0 //.:9pex
                        0
                           jPex j/ 1 . Thus dZx .y/ is .; n1 c /-dominated with
                                          X                 X
                            0
                 D .:9pex    jPex j/ 1        1w2Jex .y/          dPex .w 1 .x 0 //
                                      uw2Lx              x 0 2ND .y/
                        0
                  < .:9pex jPex j/ 1  jLex j  .1 C "/pex jPex j
                                                0
by Lemma 4.3 (ii), so whp dZx .w/ < 3jLx jpex =pex .
   Thus whp no Bx occurs, as required.

4.3. Paths
Here we conclude the proof of Theorem 1.1 in Case P, where Pex is the vertex-disjoint
union of two leaf edges in T n T ŒA  and pC n=.101K/ bare 8K-paths in T n T ŒA .
P. Keevash, K. Staden                                                                       1818


     The first phase of the PATHS subroutine fixes parity, as follows. We call x 2 V .G/ odd
if the parity of dGex0 .x/ differs from that of the number of w such that x D w .a/ where
a is the end of a bare path in Pex . We let X be the set of odd vertices and a1 `1 , a2 `2 be
the leaf edges in Pex , with leaves `1 , `2 .
     First we define all w .`1 / by M1 D ¹w .`1 /w W w 2 W º D M ATCH.B1 ; Z1 /, where
Z1 D ¹w .a1 /wºw2W and B1 D ¹vw W v 2 NJex .w/; vw .`1 / 2 Gfree º. Lemma 2.7
applies, as Z1 is a matching and similarly to the proof of Lemma 3.10, whp B1 is p0:5 -
super-regular with density .1 ˙ p0:5 /pex  0
                                              pex . Similarly, Lemma 2.7 applies to justify the
definition of w .`2 / for w 2 W by M20 D ¹w .`2 /w W w 2 W 0 º D M ATCH.B20 ; Z20 / and
                                    0

w .`2 / for w 2 W n W 0 by M2 D ¹w .`2 /w W w 2 W n W 0 º D M ATCH.B2 ; Z2 /. By
construction, there are no odd vertices after the embeddings of `1 and `2 .
     Next for each w 2 W we need 8d.x; y/-paths Pwxy in Pex for each Œx; y 2 Yw centred
in vertex-disjoint bare .8d.x; y/ C 2/-paths in Pex . We greedily choose these paths within
the bare 8K-paths in Pex that exist by definition of Case P. By Lemma 2.12, the total
number of vertices required by these paths is
        X
            ¹8d.x; y/ C 2 W Œx; y 2 Yw º D 8jYw j C jYw j D .1 /jPex j ˙ nd :9 :

At most d :9 jPex j vertices of the bare 8K-paths cannot be used due to rounding errors,
so as d 1   the algorithm to choose all Pwxy can be completed.
     Now we extend each w to an embedding of Pex n xy Pwxy so that w 1 .x/, w 1 .y C /
                                                        S

are the ends of Pwxy , according to a random greedy algorithm, where in each step, in any
order, we define some w .a/ D z, uniformly at random with z 2 Jex .w/ n Im w and
zz 0 2 Gfree whenever z 0 D w .b/ with b 2 NT .a/. Writing E for the set of ends of paths
in Pex , for any vertex y we use j¹w W  1 .y/ 2 Eºj < 1:1jEj < jPex j=.3K/ edges at y
due to it playing the role of an end.
     Let Xy be the number of additional edges used at y during the random greedy
algorithm, and let B be the bad event that any Xy > :1:9 n. We claim that whp B does not
occur. To see this, consider any step before B occurs, and suppose we are defining w .a/.
Let R be the set of b 2 NT .a/ such that w .b/ has been defined and note that jRj  2. By
Lemma 4.1 there are ..1 ˙ p0:9 /pex /jRj pex
                                           0
                                             n choices of z 2 Jex .w/ \ NGex0 .R/, of which
                                        :9
we forbid < 2pex n in Im w and <  n if B has not occurred. As  D C  pC (and
                                                                                 2 0
pC  13pex ) we can choose z, and any z is chosen with probability < .:9pex        pex n/ 1 .
Thus Xy is .; 2/-dominated with
                                        X ˇˇ         [       ˇ
                           2 0
                  D .:9pex  pex n/ 1         ˇPex n    Pwxy ˇ < 1:2pex1 n;
                                                             ˇ
                                      w2Jex .y/        xy


so by Lemma 2.4, whp Xy < :1:9 n, which proves the claim.
    Thus the random greedy algorithm can be completed, and the remaining graph Gfree is
an :9 -perturbation of Gex , i.e. jGex .x/ 4 Gfree .x/j < :9 n for any x 2 V . By construction,
every dGfree .x/ is even. The following lemma will complete the proof of Theorem 1.1 in
Case P.
Ringel’s tree packing conjecture in quasirandom graphs                                 1819


Lemma 4.5. One can decompose Gfree into .Gw W w 2 W / such that each Gw is a vertex-
disjoint union of 8d.x; y/-paths w .Pwxy / between x and y C for Œx; y 2 Yw , internally
disjoint from Im w .
     The proof of Lemma 4.5 is similar to the corresponding arguments in [20], so we will
be brief and give more details only where there are significant differences. We require
the following result on wheel decompositions; see [20] for its derivation from [17] and
discussion of how it provides the required paths. The statement requires a few definitions.
An 8-wheel consists of a directed 8-cycle (called the rim), another vertex (called the hub),
                                                                             !
and an arc from each rim vertex to the hub. We obtain the special 8-wheel W 8K by giving
                                           ! and one spoke yw
all arcs colour 0 except that one rim edge xy                  ! have colour K.
                                                         3
Theorem 4.6. Let n 1  ı  !  1, s D 2508 and d  n. Let J D J 0 [ J K be
a digraph with arcs coloured 0 or K, with V .J / partitioned as .V; W / where !n 
jV j; jW j  n, such that all arcs in J ŒV; W  point towards W and J ŒW  D ;. Then J has
  !
a W 8K -decomposition such that every hub lies in W if the following hold:
    Divisibility: dJ .w/ D 8dJ K .w/ for all w 2 W , and for all v 2 V we have dJ .v; V / D
  C
dJ .v; V / D dJC .v; W / and dJ K .v; V / D dJCK .v; W /.
                                                 !
    Regularity: each 3d -separated copy of W 8K in J has a weight in Œ!n 7 ; ! 1 n 7 
such that for any arc !e there is total weight 1 ˙ ı on wheels containing ! e.
    Extendability: for all disjoint A; B  V and L  W each of size  s, for any a; b; ` 2
¹0; Kº we have jNJCa .A/ \ NJ b .B/ \ NJ ` .L/j  !n, and furthermore, if .A; B/ is 3d -
separated then jNJC0 .A/ \ NJCK .B/ \ W j  !n.

Proof of Lemma 4.5. Recall that we constructed Jex in D IGRAPH, such that for every
xy 2 Gex , we have exactly one of xy            ! 2 J 0 , xy
                                      ! 2 J 0 , yx        ! 2 J K , yx! 2 J K , and there
                                             ex        ex          ex          ex
          !        0                          K             !
are also yw 2 Jex ŒV; W . Add the arcs Jex ŒV; W  D ¹xw W x 2 Yw º. It suffices to find
an :6 -perturbation L of Jex , i.e. L is obtained from Jex by adding, deleting or recolour-
ing at most :6 n arcs at each vertex, where LŒV  corresponds to Gfree under twisting, and
                                                                         !
NL .w/  V n Im w for each w, and a set E of edge-disjoint copies of W 8K in L, such that
                                !K
Theorem 4.6 applies to give a W 8 -decomposition of L0 WD L n E. This will suffice, by
                                                                  S

taking each Gw to consist of the union of the 8-paths that correspond under twisting to the
                               !
rim 8-cycles of the copies of W 8K containing w. Here an arc of L corresponds to an edge
                                    ! 2 L0 or yx
xy 2 Gfree under twisting if it is xy           ! 2 L0 or xy! 2 LK or yx  ! 2 LK (which
is a more flexible notion than in [20], as it does not depend on the orientation of L.)
     Whenever we make a series of n2 modifications to Jex of some type which involves
changing edges at some intermediate vertex z, we always ensure that no vertex plays the
role of z more than  :1 n times. There will always be more than, say, 2:1 n valid choices
of z, by Lemmas 2.12 and 2.13, and thus we can avoid the set of at most :1 n overused
vertices. This series of modifications will add  :1 to the perturbation constant.
                                                                          ! for each xy 2
     We start by deleting arcs corresponding to Gex n Gfree , adding arcs xy
                            !                                           ! C
Gfree n Gex , replacing any xy of colour K where d.x; y/ < 3d with xy of colour 0 and
deleting arcs yw! in LŒV; W  with y 2 N .w/ \ Im  . Next we delete or add arbitrary
                                            Jex           w
P. Keevash, K. Staden                                                                      1820

      ! with y 2 V n .Im  [ .Y /C [ N .w// until each d .w/ D 8jY j, and so
arcs yw                        w       w        Jex                  L            w
jLŒV; W j D jLŒV j. We require < :9 n such arcs for each w, by Lemma 2.12 and the
bounds on Xy during the embedding of Pex n xy Pwxy .
                                                 S

    While jL0 ŒV j > jL0 ŒV; W j we replace some xy                ! 2 LK ŒV , or while
                                                     ! 2 L0 ŒV  by xy
                                            !                !
jL0 ŒV j < jL0 ŒV; W j we replace some xy 2 LK ŒV  by xy C 2 L0 ŒV , continuing until
jL0 ŒV; W j D jL0 ŒV j, and hence jLK ŒV; W j D jLK ŒV j.
    Next we balance degrees in LK . While there are x; y in V with dLK .x; V / >
dLCK .x; W / and dLK .y; V / < dLCK .y; W /, we choose z 2 V such that zx         !C 2 L0
                                                                         ! 2 LK , zy
                           !C 2 L0 , zy
and replace these arcs by zx           ! 2 LK . While there are x; y in V with d C .x; V / >
                                                                                LK
                                                                                  ! C 2 L0
                                                                        ! 2 LK , yz
dLCK .x; W / and dLCK .y; V / < dLCK .y; W /, we choose z 2 V such that xz
                            !      K !C         0
and replace these arcs by yz 2 L , xz 2 L . We continue until
                 dLCK .v; V / D dLK .v; V / D dLCK .v; W / for all v 2 V .
    Now we require some new modifications which do not appear in [20]. We start by not-
ing that each dL .x; V / is even. To see this, note that as LŒV  corresponds to Gfree under
twisting, we have
            dL .x; V / D dGfree .x/ C dLK .x ; V /      dLK .x; V /
                        D dGfree .x/ C dLCK .x   ;W /   dLCK .x; W / D dGfree .x/;
where the last equality follows from interval properties (listed before the definition of
I NTERVALS). While there are x; y 2 V with dL .x; V / < 2dLC .x; W / and dL .y; V / >
                      ! to L0 and remove xw
2dLC .y; W /, we add yw                       ! from L0 for some w 2 N C .x; W / n
                                                                             L0
   C
NL .y; W / with y … Im w . We continue until
                          dL .v; V / D 2dLC .v; W / for all v 2 V .
     While there are x; y in V with dLC0 .x; V / > dLC0 .x; W / and dLC0 .y; V / < dLC0 .y; W /,
we choose z 2 V such that xz          ! 2 L0 and replace these arcs by zx
                             ! 2 L0 , yz                                              ! 2 L0 .
                                                                            ! 2 L0 , zy
        C            C
Now dL .v; V / D dL .v; W / for all v 2 V . Thus L satisfies the required divisibility con-
ditions, and is an :6 -perturbation of Jex , and LŒV  corresponds to Gfree under twisting.
It remains to satisfy the extendability and regularity conditions of Theorem 4.6. A sum-
mary of the argument is as follows (we omit the details as they are very similar to those
in [20]). There are many wheels on each arc, so we can greedily cover all xy   ! 2 LŒV  with
edge-disjoint wheels, incurring an insignificant perturbation of L. A stronger version of
the extendability hypothesis with Jex in place of L holds by Lemmas 2.12 and 2.13, and
so it holds for the perturbation L. By typicality, the regularity condition is satisfied by
assigning the same weight WO to every wheel, choosing WO so that any arc is in  WO 1
wheels.


4.4. Large stars
Here we conclude the proof of Theorem 1.1 in Case L, where all but at most pC n vertices
of T belong to leaf stars of size  ƒ D n1 c . The argument is self-contained: there is no
approximate step, and the entire embedding is achieved by the subroutine L ARGE STARS.
Ringel’s tree packing conjecture in quasirandom graphs                                   1821


    We start by letting  be the union of all maximal leaf stars in T that have size  ƒ.
We let F D T n ; by assumption jV .F /j  pC n. We let S C D ¹v 2 V .T / W dT .v/ƒº,
so that jS C j < 2 and S  S C  V .F /, whereˇ S is the setˇof star centres of .
    We partition W as W1 [ W2 [ W3 with ˇjWi j n=3ˇ < 1 for each i. For each
v 2 V .G/, we independently choose at most one of P .v 2 Uia / D d .a/=.3jj/
with a 2 S , i 2 Œ3. By Chernoff     bounds, whp jUia j D nd .a/=.3jj/ ˙ n:9 . We let
                          3
Ui D a Uia . While iD1 ˇjWi j jUi jˇ > 0, we relocate a vertex so as to decrease this
      S                P      ˇ           ˇ

sum, thus relocating < n:9 to or from any Uai , so < 3n:9 < n:99 in total.
    Noting that F is a tree, we can fix an order  on V .F / such that N< .u/ D ¹v  u W
vu 2 F º D ¹u º has size 1 for all u ¤ u0 2 V .F /. We fix distinct w .u0 /, w 2 W
with w .u0 / 2 Ui whenever w 2 Wi . We construct edge-disjoint copies Fw of F by
considering a 2 Fw in  order, defining all w .a/ by Mia D ¹w .a/w W w 2 Wi º D
M ATCH.Bia ; Zia /, i 2 Œ3, and updating

                   Gfree D ¹unused edgesº; Z D ¹vw W v 2 V .Fw /º;
                   J D ¹xx!0 W x D  .a/; x 0 2 Z.w/ \ U a º      :
                                       w                        w2W; a2S

By construction G n Gfree and Z both have maximum degree  jV .F /j  pC n.
Lemma 4.7. Every edge is used at most once and J has no 2-cycles.

Proof. First note that as Bia .w/  Gfree .w .a // n Z.w/ for all i; w, we embed each
w .a/ to a vertex not yet used by Fw so that w .a /w .a/ is an unused edge. Further-
more, when a 2 S , for each xx 0 2 J , by excluding w .a/ 2 NJC .Z.w/ \ U a / we do not
    !0 to J due to x D  .a/, x 0 2 Z.w/ \ U a , and by excluding N . .b// \ U b
add xx                      w                                           J    w
where x 0 2 U b we do not add xx !0 to J due to x D  .b/, x 0 D  .a/ 2 Z.w/ \ U b .
                                                       w            w
As before, by including all w .a /w in Zia we ensure that Mia does not require the same
edge of Gfree twice. Furthermore, when a 2 S , by including all vw with v 2 U a \ Z.w/
we ensure that Mia does not add both arcs of any 2-cycle to J : we cannot add xx !0 , xx 0
       0                a                             a        0         0 0
with x D w 0 .a/ 2 U \ Z.w/ and x D w .a/ 2 U \ Z.w / as xwx w would be an
Mia Zia Mia Zia . The lemma follows.

   Next we note that for all i 2 Œ3, w 2 Wi we have Bia .w/  Ui 0 , where i 0 D i   1a…S C .
We record some simple consequences of this observation:
 Z.w/ \ Ui C1 D ; for any w 2 Wi .
 Z.x/ \ Wi 1 D NJ .x/ \ Ui 1 D NJC .x/ \ UiC1 D ; for any x 2 Ui .
 If w 2 Wi then Z.w/ \ Ui only contains w .a/ with a 2 S C , so has size  jS C j  2.
 If x 2 Ui , b 2 S then NJC .x/ \ Uib D Z.Mib .x// \ Uib has size  2, as Mib .x/ 2 Wi .
 If x 2 Uib then Z.x/ \ Wi only contains Mia .x/ with a 2 S C , so jZ.x/ \ Wi j  2.
 If x 2 Uib then NJ .x/ \ Ui D Mib .Z.x/ \ Wi / has size  2.
 Each Zia has maximum degree  2.
   By construction, Bia is a balanced bipartite graph. To justify the application of Lem-
ma 2.7 in choosing Mia , it remains to establish the following.
P. Keevash, K. Staden                                                                      1822

                   :15
Lemma 4.8. Bia is pC   -super-regular.

Proof. We first consider ia  Ui 0  Wi with i 0 D i     1a…S C defined by Nia .w/ D Ui 0 \
G.w .a //. For any R 2 U2
                                
                             i 0 we have



            Nia .R/ D ¹w 2 Wi W R  G.w .a //º D Mia .NG .R/ \ Ui 0 /;

so jNia .R/j D jNG .R/ \ Ui 0 j D ..1 ˙ 1:1/p/jRj jWi j whp by typicality and a Chernoff
bound. Similarly, the set Nia .R0 / D Ui 0 \ w2R0 G.w .a // for R0 2 W
                                              T                               i
                                                                                
                                                                             2
                                                                                  whp has size
                  0
..1 ˙ 1:1/p/jR j jUi 0 j.
     Now we will show that ia n Bia has maximum degree  5pC n. To see this, we first
note that we have a contribution  4jV .F /j  4pC n to any degree in ia n Bia due to
edges in Z or G n Gfree (including the  1 vertex that is the image of a … S C for two
w; w 0 ). There are no other contributions for a … S C , so we consider a 2 S C and so i 0 D i .
First we estimate the contribution to degrees of w 2 Wi and to degrees of x 2 Ui due to
x 2 NJ .w .b/ \ Uib / for b 2 S , which we claim are both  42 . Indeed, for w 2 Wi
the contribution is  b2S jNJ .w .b// \ Ui j  2jS j  42 . For x 2 Ui , we count
                        P

w 2 Wi if w .b/ D y 2 NJC .x/, where y 2 Ui as w 2 Wi ; b 2 S , so this contribution is
 b jNJC .x/ \ Uib j  42 .
   P

     It remains to estimate the contribution to degrees of w 2 Wi and to degrees of x 2 Ui
due to x 2 NJC .Z.w/ \ U a /, which we claim are both  83 . To see this, first note that
we must have w 2 Z.y/ for some y 2 NJ .x/ \ U a , and x 2 Z.w 0 / \ Uib for some b with
w 0 .b/ D y 2 Z.w/. We note that w 0 2 Wi , as otherwise x 2 Z.w 0 / implies w 0 2 WiC1
and y D w 0 .b/ implies y 2 UiC1 , which contradicts y 2 Z.w/. Thus we have  2
choices for each w 0 2 Z.x/ \ Wi , then y 2 Z.w 0 / \ Ui , then w 2 Z.y/ \ Wi , which
proves the claim. The lemma now follows from Lemma 2.5.

   Thus we can apply Lemma 2.7, so each Mia D ¹w .a/w W w 2 Wi º D M ATCH.Bia ; Zia /
can be chosen and has P .vw 2 Mia / D .1 ˙ pC  :1
                                                  /.pn/ 1 for all vw 2 Bia . In particular,
we can complete step (iv), thus choosing edge-disjoint copies Fw of F .
Lemma 4.9. For x 2 V , w 2 W , a 2 S , whp

            jU a \ V .Fw /j < 1:1pC jU a j    and                         :9
                                                    jNJ˙ .x/ \ U a j < :1pC  jU a j:

Proof. The first statement holds by Lemma 2.4, as jU a \ V .Fw /j is .; 1/-dominated
with
                             X
                  :1
      D .1 ˙ pC     /.pn/ 1                                   :1
                                   jBiu .w/ \ U a j D .1 ˙ 1:1pC  /jV .F /jn 1 jU a j:
                              u2V .F /


Next recall for x 2 Ui that NJ .x/ \ Ui 1 D NJC .x/ \ UiC1 D ;, jNJ .x/ \ Ui j  2
and jNJC .x/ \ Ui j D b jNJC .x/ \ Uib j  42 .
                        P

     To bound jNJC .x/ \ Uia 1 j, note that for any w 2 W there are < 1:1pC jU a j choices of
x 0 2 U a \ V .Fw /, for which we add xx !0 to J if M a chooses xw. Thus jN C .x/ \ U a j
                                                      i                      J           i 1
Ringel’s tree packing conjecture in quasirandom graphs                                   1823

                                                      :1
is .; 1/-dominated with  < n  1:1pC jU a j  .1 ˙ pC  /.pn/ 1 , so by Lemma 2.4 whp
        :9   a
< :01pC jU j.
    Finally, for x 2 Uib we have NJ .x/ \ UiaC1 D M b .Z.x// \ UiaC1 , which by Lem-
ma 2.7 whp has size
     b                     a                 a
   jMiC1 ŒZ.x/ \ Wi C1 ; UiC1 j < jZ.x/j jUiC1                              :9
                                                j=.:99pjWi C1 j/ C n:8 < :01pC  jU a j:

    We deduce jNJ˙ .x/j < :1pC   :9
                                    n, so the underlying graph Jz of J has maximum degree
       :9
< :2pC n.
    In step (v) we orient Gfree as D D w2W Dw , where for each xy 2 Gfree with x 2 U a
                                         S
                 ! 2 J we have yx
and y 2 U b , if xy                ! 2 D where  .a/ D y, if yx                  !2D
                                                                   ! 2 J we have xy
                                           w         w                                 w
where w .b/ D x, or otherwise we make one of these choices independently with prob-
ability 1=2. We define Z C  V  W by Z C .w/ D V .Fw / [ V .Dw /.
                 C                                     :8
Lemma 4.10. Whp dDw
                    .x/ and jZ C .w/ \ U a j are .1 ˙ pC  /d .a/ for all x D w .a/,
w 2 W , a 2 S.

Proof. First note by typicality and Chernoff bounds that whp there are
                                                            :85
                .1 C 2/nd .a/p=jj ˙ 1:1pC jU a j D .1 ˙ pC   /2d .a/
                                                               :9
choices of v 2 U a \ Gfree .x/ after step (iv). Excluding < :2pC  jU a j choices with xv 2 Jz,
                                    !
for all other v independently P .xv 2 Dw / D 1=2. The lemma follows by a Chernoff
bound and Lemma 4.9.

    To analyse step (vi), we first observe that initially the sets NDCw .w .a// are disjoint
over a 2 S and disjoint from V .Fw /, and this is preserved by each move; moreover, each
move decreases † by 2, and if (vi) does not abort we have Dw [ Fw D T for every w.
So it suffices to show that (vi) does not abort. We start with an estimate for the number
of moves for any uwu0 w 0 that are original, meaning that they are present at the end of
step (v) before any arcs are moved.
Lemma 4.11. Any u D w .a/, u0 D w 0 .a0 / whp have > 9000 1 p 3 n2 d .a0 / original
uwu0 w 0 -moves.

Proof. We estimate the number of moves by sequentially choosing x, v then z. Sup-
                                                                           0
pose u 2 U b and w 0 2 Wi , so u0 D w 0 .a0 / 2 Ui . Suppose u0 2 U b . We claim there
are whp > :08pn choices of x 2 Ui \ ND .u/ n Z C .w/. To see this, note that there are
.1 ˙ pC :8
           /pn=3 choices of x 2 Ui \ Gfree .u/. Excluding < pC  :9
                                                                   n with xu or xw .b/ in Jz,
                                                     C
for all others independently P .x 2 ND .u/ n Z .w//  1=4, so the claim holds by a
Chernoff bound. Consider any such x, say with x 2 Uic , and let w x D M b .x/ 2 Wi .
     We claim there are whp > :01p 2 n choices of v 2 Ui 1 \ ND .x/ \ NDC .u0 / n
                                                                                   :8
.Z .w 0 / [ Z C .w x / [ M c .Z C .u0 ///. To see this, note that there are .1 ˙ pC
    C
                                                                                      /p 2 n=3
                                               0                                d
choices of v 2 Ui 1 \ Gfree .x/ \ Gfree .u /. For any such v, say in Ui 1 , we have
                           !0 … J , and so P .vv 0 2 D/  1=2. Similarly, v x WD  x .d / has
v 0 WD w 0 .d / 2 Ui , so vv                                                     w
P .vv x 2 D/  1=2 independently. Also v 2 M c .Z C .u0 / n Z.u0 // , w v WD M c .v/ 2
P. Keevash, K. Staden                                                                        1824


Z C .u0 / n Z.u0 / , yv!u0 2 D, where yv D w v .b 0 / 2 Ui 1 as w v 2 Wi 1 . Since each v
corresponds to a unique yv , the number of yv with yv u0 2 J is dJC .u0 /  :1pC   :9
                                                                                      n. Exclud-
                                        0                        c     C 0            0
ing such v, for all others we have yv u … J and so P .v 2 M .Z .u / n Z.u ///  1=2
                                          :9
independently. Excluding a further < pC      n choices of v in Z.w 0 / [ Z.w x / [ M c .Z.u0 //
or with vx or vu in Jz, any other v contributes independently with probability  2 5 , so
                   0

the claim follows by a Chernoff bound.
                                                      0
    Fix any such v, say with v 2 U d , and let w u D M d .u0 / 2 Wi 1 . Similarly to the
                                                                                 0
above, there are whp > :16d .a0 / choices of z 2 Ui 1 \ NDC 0 .u0 / n Z C .w u /, as there are
                                                                  w
       :8                              0
.1 ˙ pC   /d .a0 /=3 choices in Uia 1 \ Gfree .u0 / and letting z 0 D w u0 .a0 / 2 Ui , excluding
            :9      0
at most :1pC   jU a j vertices z such that zz 0 2 J , each other z has P .zz 0 2 D/  1=2. The
lemma follows.
                                                                                            :7
    After t moves, we let B t denote the bad event that any vertex y is incident to > pC       n
                        :7   q       !  0         0     q
moved arcs or to > pC jU j arcs yy with y 2 U for some q. We let  be the smallest t
such that B t occurs, or 1 if there is no such t. At any step t <  requiring a move for some
uwu0 w 0 with w 0 .a0 / D u0 , as B t does not hold there are > 10 4 p 3 n2 d .a0 / moves. To
complete the proof it therefore suffices to show whp  D 1. We fix t and bound P . D t /
as follows.
                                           :7
    We start by showing that whp < pC         n arcs are moved at any y. To see this, note first
that the number of times y plays the role of u or u0 in a move is
                   X                                    X
                           C                  1             :8           :8
                         jdD w
                               .y/    d .w    .y//j <    pC  d .a/ < pC  n:
                  w2W                                    a

Now fix uwu0 w 0 with w 0 .a0 / D u0 . Then y plays the role of x or v in < nd .a0 / moves,
so with probability < 104 p 3 n 1 . The number of moves where y plays x or v is there-
                                        :8 2                      :7
fore .; 1/-dominated, where  < pC       n  104 p 3 n 1 < :1pC     n, so by Lemma 2.4 this
                     :7                          a0
number is whp < :2pC n. Furthermore, y 2 U plays the role of z in < n2 moves, so with
probability < 104 p 3 d .a0 / 1 . The number of such moves is therefore .; 1/-dominated,
where                                  X
                                             C
               < 104 p 3 d .a0 / 1       jdD w
                                                 .w .a0 // d .a0 /j < :1pC:7
                                                                               n;
                                           w
                                             :7
so by Lemma 2.4 this number is whp < :2pC       n. The claim follows.
                      0 0           !
     Now, given uwu w , any arc yy with y 0 2 U q plays the role of vu0 or xu
                                      0                                          ! in <
                                          4   3    1                 !
nd .q/ moves, so with probability < 10 p n , and the role of vx in < d .q/ moves,
so with probability < 104 p 3 n 2 , and the role of zu0 in < n2 moves, so with probability
104 p 3 d .q/ 1 . Thus for any q 2 S and y D w .q/, the number of moved yy     !0 with
y 0 2 U q is .; 1/-dominated, where
                                     :8
                   < 104 p 3 n 1  pC                           :8 2
                                        njU q j C 104 p 3 n 2  pC n jU q j
                                               C
                        C 104 p 3 d .q/ 1  jdD w
                                                   .y/       d .q/j jU q j
                          :7
                     < :1pC  jU q j;
                                      :7
so by Lemma 2.4 this number is whp < pC  jU q j. This completes the proof.
Ringel’s tree packing conjecture in quasirandom graphs                                         1825


5. Concluding remarks

In this paper we have developed a variety of embedding techniques that are sufficiently
flexible to resolve a generalised form of Ringel’s Conjecture that applies to quasirandom
graphs, and which promise to have more general applications to packings of a family of
trees, as would be required for a solution of Gyárfás’ Conjecture.
Acknowledgements. We are grateful to the referee for their comments on the paper.
Funding. This work was supported in part by ERC Consolidator Grant 647678.



References

 [1] Adamaszek, A., Allen, P., Grosu, C., Hladký, J.: Almost all trees are almost graceful. Random
     Structures Algorithms 56, 948–987 (2020) Zbl 1456.05134 MR 4101349
 [2] Allen, P., Böttcher, J., Clemens, D., Hladký, J., Piguet, D., Taraz, A.: The tree packing con-
     jecture for trees of almost linear maximum degree. arXiv:2106.11720 (2021)
 [3] Allen, P., Böttcher, J., Clemens, D., Taraz, A.: Perfectly packing graphs with bounded degen-
     eracy and many leaves. Israel J. Math. 255, 501–579 (2023) Zbl 1519.05197 MR 4619546
 [4] Allen, P., Böttcher, J., Hladký, J., Piguet, D.: Packing degenerate graphs. Adv. Math. 354,
     106739, 58 (2019) Zbl 1419.05172 MR 3988639
 [5] Barát, J., Gyárfás, A., Sárközy, G. N.: Rainbow matchings in bipartite multigraphs. Period.
     Math. Hungar. 74, 108–111 (2017) Zbl 1399.05177 MR 3604112
 [6] Böttcher, J., Hladký, J., Piguet, D., Taraz, A.: An approximate version of the tree packing
     conjecture. Israel J. Math. 211, 391–446 (2016) Zbl 1334.05111 MR 3474969
 [7] Boucheron, S., Lugosi, G., Massart, P.: Concentration inequalities. Oxford University Press,
     Oxford (2013) Zbl 1337.60003 MR 3185193
 [8] Csaba, B., Kühn, D., Lo, A., Osthus, D., Treglown, A.: Proof of the 1-factorization and
     Hamilton decomposition conjectures. Mem. Amer. Math. Soc. 244, no. 1154, v+164 pp.
     (2016) Zbl 1367.05165 MR 3545109
 [9] Ehard, S., Glock, S., Joos, F.: Pseudorandom hypergraph matchings. Combin. Probab. Com-
     put. 29, 868–885 (2020) Zbl 1466.05147 MR 4173135
[10] Ferber, A., Lee, C., Mousset, F.: Packing spanning graphs from separable families. Israel J.
     Math. 219, 959–982 (2017) Zbl 1364.05057 MR 3649613
[11] Ferber, A., Samotij, W.: Packing trees of unbounded degrees in random graphs. J. London
     Math. Soc. (2) 99, 653–677 (2019) Zbl 1415.05147 MR 3977885
[12] Freedman, D. A.: On tail probabilities for martingales. Ann. Probab. 3, 100–118 (1975)
     Zbl 0313.60037 MR 0380971
[13] Glock, S., Kühn, D., Lo, A., Osthus, D.: The existence of designs via iterative absorption:
     hypergraph F -designs for arbitrary F . Mem. Amer. Math. Soc. 284, no. 1406, v+131 pp.
     (2023) Zbl 1515.05005 MR 4572074
[14] Gyárfás, A., Lehel, J.: Packing trees of different order into Kn . In: Combinatorics (Keszthely,
     1976), Vol. I, Colloq. Math. Soc. János Bolyai 18, North-Holland, Amsterdam, 463–469
     (1978) Zbl 0389.05030 MR 0519284
[15] Joos, F., Kim, J., Kühn, D., Osthus, D.: Optimal packings of bounded degree trees. J. Eur.
     Math. Soc. 21, 3573–3647 (2019) Zbl 1429.05164 MR 4022711
[16] Kahn, J.: A linear programming perspective on the Frankl–Rödl–Pippenger theorem. Random
     Structures Algorithms 8, 149–157 (1996) Zbl 0842.05066 MR 1607104
P. Keevash, K. Staden                                                                        1826


[17] Keevash, P.: The existence of designs. arXiv:1401.3665v4 (2014)
[18] Keevash, P.: The existence of designs II. arXiv:1802.05900 (2018)
[19] Keevash, P.: Coloured and directed designs. In: Building bridges II—mathematics of László
     Lovász, Bolyai Soc. Math. Stud. 28, Springer, Berlin, 279–315 (2019) Zbl 1443.05134
     MR 4297785
[20] Keevash, P., Staden, K.: The generalised Oberwolfach problem. J. Combin. Theory Ser. B 152,
     281–318 (2022) Zbl 1478.05116 MR 4332743
[21] Kim, J., Kühn, D., Osthus, D., Tyomkyn, M.: A blow-up lemma for approximate decomposi-
     tions. Trans. Amer. Math. Soc. 371, 4655–4742 (2019) Zbl 1409.05114 MR 3934464
[22] Kirkman, T. P.: On a problem in combinations, Cambridge and Dublin Math. J. 2, 191–204
     (1847)
[23] Kohayakawa, Y., Rödl, V.: Algorithmic aspects of regularity. In: Latin American Theoretical
     Informatics (LATIN 2000, Punta del Este), Lecture Notes in Computer Sci. 1776, Springer,
     Berlin, 1–17 (2000) Zbl 0964.05062
[24] Messuti, S., Rödl, V., Schacht, M.: Packing minor-closed families of graphs into complete
     graphs. J. Combin. Theory Ser. B 119, 245–265 (2016) Zbl 1334.05121 MR 3486345
[25] Montgomery, R.: Spanning trees in random graphs. Adv. Math. 356, article no. 106793, 92 pp.
     (2019) Zbl 1421.05080 MR 3998769
[26] Montgomery, R., Pokrovskiy, A., Sudakov, B.: Decompositions into spanning rainbow struc-
     tures. Proc. London Math. Soc. (3) 119, 899–959 (2019) Zbl 1429.05024 MR 3964824
[27] Montgomery, R., Pokrovskiy, A., Sudakov, B.: Embedding rainbow trees with applications to
     graph labelling and decomposition. J. Eur. Math. Soc. 22, 3101–3132 (2020)
     Zbl 1508.05024 MR 4153104
[28] Montgomery, R., Pokrovskiy, A., Sudakov, B.: A proof of Ringel’s conjecture. Geom. Funct.
     Anal. 31, 663–720 (2021) Zbl 1473.05249 MR 4311581
[29] Ray-Chaudhuri, D. K., Wilson, R. M.: Solution of Kirkman’s schoolgirl problem. In: Com-
     binatorics (Los Angeles, CA, 1968), Proc. Sympos. Pure Math. 19, American Mathematical
     Society, Providence, RI, 187–203 (1971) Zbl 0248.05009 MR 0314644
[30] Ringel, G.: Extremal problems in the theory of graphs. In: Theory of graphs and its applic-
     ations (Smolenice, 1963), Publishing House of the Czechoslovak Academy of Sciences,
     Prague, 85–90 (1964) Zbl 0161.20503 MR 0179778
[31] Rödl, V.: On a packing and covering problem. Eur. J. Combin. 6, 69–78 (1985)
     Zbl 0565.05016 MR 0793489
[32] Wilson, R. M.: An existence theory for pairwise balanced designs. I. Composition theorems
     and morphisms. J. Combin. Theory Ser. A 13, 220–245 (1972) Zbl 0263.05014
     MR 0304203
[33] Wilson, R. M.: An existence theory for pairwise balanced designs. II. The structure of PBD-
     closed sets and the existence conjectures. J. Combin. Theory Ser. A 13, 246–273 (1972)
     Zbl 0263.05015 MR 0304204
[34] Wilson, R. M.: An existence theory for pairwise balanced designs. III. Proof of the existence
     conjectures. J. Combin. Theory Ser. A 18, 71–79 (1975) Zbl 0295.05002 MR 0366695
[35] Wilson, R. M.: Decompositions of complete graphs into subgraphs isomorphic to a given
     graph. In: Proceedings of the Fifth British Combinatorial Conference (Aberdeen, 1975), Con-
     gress. Numer. 15, Utilitas Mathematica Publishing, Winnipeg, MB, 647–659 (1976)
     Zbl 0322.05116 MR 0396347
