arXiv:2107.00874v1 [math.CO] 2 Jul 2021 Introduction 1 that ooopim from homomorphisms 1 ∗ A l rpsaefiieadsml nti paper. this in simple and finite are graphs All [email protected] S ne rn o DM No. Grant under NSF by supported Partially [email protected]. φ h ls fall of class the osatfco;i lodtrie h xc au ftea the of value exact the determines also for it density factor; constant a u ahnr loalw st eemn h aiu number maximum the determine to us allows spar general also most machinery the Our gr are of classes dense classes nowhere many properties; and families wit minor-closed classes Hereditary (topological) class. dense nowhere hereditary any H ebr fahrdtr class hereditary a of members H n otatn ijitsbrpso radius of subgraphs disjoint contracting and odetmto o h ieof bound size lower the obvious for an estimation then good edge-density, a large with graph a usin rpsdsne19sadsrntesanme fr of number a strengthens that and theorem 1990s addresses general since a paper proves proposed This and questions dense. sparse be robustly g to are and allowed graphs theory are graph graphs extremal host in the studied extensively been have from morphisms homomorphism ooopimcut nrbsl pregraphs sparse robustly in counts Homomorphism ( u hmmrhss h aiu ubrof number maximum the -homomorphisms, idcdsbrpsi rpsi n eeiaycaswt bo with class hereditary any in graphs in subgraphs -induced ) o xdgraph fixed a For epoeta o n graph any for that prove We φ ( v ) ∈ H E -homomorphisms, ( d G dgnrt rpswt n fixed any with graphs -degenerate H rmagraph a from whenever ) H to to H G olg tto,T 74-38 USA 77843-3368, TX Station, College n o rirrl ag otgraphs host large arbitrarily for and G n h ubro ugah smrhcto isomorphic subgraphs of number the and onighmmrhssbtentogah per in appears graphs two between homomorphisms Counting . eateto Mathematics, of Department G ea & University, A&M Texas uv 1 H fgah,if graphs, of hnHn Liu Chun-Hung H H sbrpsand -subgraphs H ∈ uy5 2021 5, July hsrsl eemnstemxmmnme of number maximum the determines result This . oagraph a to Abstract E n n set any and ( H 1 .W eoeb hom( by denote We ). O H H ( | sbrps n h aiu number maximum the and -subgraphs, V aifisantrladml condition, mild and natural a satisfies G ( H d H H safunction a is . ) ∗ idcdsbrpsi rpsin graphs in subgraphs -induced | nmmesof members in ) fhmmrhssfrom homomorphisms of one xaso include expansion bounded h pswt eti geometric certain with aphs ecassi priytheory. sparsity in classes se G ahlmt hoywhen theory limits raph ovsanme fopen of number a solves slsi h literature. the in esults h aewe h host the when case the ne xaso pto up expansion unded h ubro homo- of number the , o h ieof size the for ypoi logarithmic symptotic S-1954054. φ of H : ,G H, H V G otie in contained ( sbrpsin -subgraphs antcreate cannot H h ubrof number the ) ) → H V H gives ( G to G such ) many areas, such as extremal , statistical physics, and computer science. For example, Lov´asz [51] showed that if hom(H,G1) = hom(H,G2) for every graph H, then G1 and G2 are isomorphic. One way to define the limit of a sequence (Gn)n≥1 of graphs |V (H)| is to consider the homomorphism density hom(H,Gn)/ V (Gn) for all graphs H. This | | notion leads to a rich theory for dense host graphs Gn (see [9, 50]). But this definition for homomorphism density does not work well for sparse graphs because hom(H,G) is often o( V (G) |V (H)|) for sparse graphs G. A class of graphs of bounded maximum degree is an example| | of classes of sparse graphs. If G has bounded maximum degree and H is connected, it is easy to show hom(H,G)= O( V (G) ). So one way to define convergence of a sequence | | (Gn)n≥1 of graphs with uniformly bounded maximum degree is to consider the convergence of hom(H,Gn)/ V (Gn) for all connected graphs H. This notion of convergence coincides | | with a notion introduced implicitly by Aldous [1] and explicitly by Benjamini and Schramm [6] (see [9]). Even though limit theory was developed for various sparse graph classes, such as for planar graphs [36], graphs of bounded average degree [53], graphs of bounded tree- depth [58], and nowhere dense graphs [59], it remained unknown what the correct exponent k k should be in order to make hom(H,Gn)/ V (Gn) meaningful when Gn is sparse. This is | | one motivation of this paper. A central direction in extremal graph theory is solving Tur´an-type questions which ask for the maximum number of copies of a fixed graph in graphs in a fixed graph class. Tur´an [71] determined the maximum number of edges in Kt-free graphs. Erd˝os and Stone [25] generalized it by determining the maximum number of edges in n-vertex L-free graphs, for any fixed graph L, up to an o(n2) error. In fact, the number of edges equals the number of subgraphs isomorphic to K2. Zykov [74] determined the maximum number of subgraphs isomorphic to Ks in Kt-free graphs, for any fixed integers s and t. In general, the maximum number of subgraphs isomorphic to a fixed graph H in L-free graphs for another fixed graph L has been extensively studied. For example, the cases when H and L are cycles, trees, complete graphs, or complete bipartite graphs were considered in [4, 32, 35, 41]. It is far from a complete list of known results of this type. We refer readers to [31] for a survey. Tur´an-type questions are closely related to counting homomorphisms. Counting the number of edges is equivalent to counting the number of K2-subgraphs, and the number of Ks-subgraphs in G equals hom(Ks,G)/s!. More generally, the number of H-subgraphs in G equals the number of injective homomorphisms from H to G divided by the size of the auto- morphism group of H. In addition, it is known that the difference between hom(H,G) and the number of injective homomorphisms from H to G is at most O( V (G) |V (H)|−1). So the | | homomorphism density approximates the density of injective homomorphisms with o(1) ad- ditive errors in dense graphs. This allows a powerful machinery for the use of homomorphism inequalities to solve Tur´an-type problems in dense graphs [66]. On the other hand, it was unclear how a similar machinery can be applied when the host graphs G are sparse because hom(H,G)= o( V (G) |V (H)|), and it was unknown what the correct exponent k to normalize | | homomorphism counts to properly define homomorphism densities hom(H,G)/ V (G) k is. This leads to another motivation of this paper. | | More precisely, we are interested in for every fixed graph H, determining the value k k such that maxG∈G,|V (G)|=n hom(H,G)=Θ(n ) and the analogous problem for the number of H-subgraphs in G, where is a class of sparse graphs. For some graphs H and some classes of sparse graphs, it is notG hard to determine this value k; in those cases, the coefficient G 2 Bounded ✲ Bounded ✲ Bounded ✲ Admitting tree-depth tree-width layered tree-width strongly sublinear ✑✑✸ ✒ balanced separators ✑ ✑ ✟✟✯ ✑ ✟ ❅ ✑ ✟✟ ❅ ✑ ✟ ❅❘ ✑ Bounded Minor- Topological Bounded Trees ✲ Planar ✲ ✲ ✲ ✲ Euler genus closed minor-closed expansion ✒

Bounded Nowhere ✲ Immersion-closed maximum degree dense

Figure 1: Relationship between extensively studied classes of sparse graphs. “A B” means that any class satisfying property A satisfies property B. → of nk has been studied, such as when H is a and G is either of bounded maximum degree [10, 15], of bounded Euler genus [18], Kt-minor free [29], or Kt-topological minor free [30, 49]. The subgraph counts when G is planar and H is either a cycle [39, 40], a complete bipartite graph [2], or a 4-vertex path [38] were also studied. However, determining the exponent k for any fixed graph H and fixed class of sparse graphs seems challenging in general. For example, the following old question of Eppstein [24] remained open (until this paper), where only some special cases for trees [44] or for classes of graphs embeddable in surfaces [24, 43, 73] were known; in fact, it was even unknown whether the value k in the following question can be chosen to be independent with n.

Question 1.1 ([24]) Are there proper minor-closed families and graphs H such that the maximum number of sugraphs isomorphic to H in an n-vertexF graph in is Θ(nk) for some non-integer k? F

The main result of this paper (Theorem 5.6) provides a negative answer to Question 1.1. Theorem 5.6 is actually much general in the following aspects.

• Theorem 5.6 determines the precise value of this integer k for any hereditary class with (Theorem 1.4) and determines k up to an additive o(1) error term for any hereditary nowhere dense class (Theorem 1.7). Nowhere dense classes are the most general sparse graph classes in sparsity theory; classes with bounded expansion are common generalizations of (topological) minor-closed families and many extensively studied graph classes with some geometric properties. Further motivation and formal definition of those classes are included in Section 1.2. (See Figure 1 for a relationship between classes of sparse graphs, and see Section 6 for concrete examples of applications of Theorem 1.4 that solves other open questions in the literature.)

• Moreover, this value k equals an “obvious lower bound” obtained by duplication and can be decided in finite time (if an oracle for membership testing is given) and can

3 be explicitly stated (for some classes that are explicitly described, see Section 6). See Section 1.1 for the precise definition of this obvious lower bound.2

• Theorem 5.6 counts the size of any set of homomorphisms from any fixed graph H to H graphs in any fixed class of sparse graphs mentioned above, as long as satisfies some natural and mild conditions for consistency with respect to isomorphisms.H (See Section 1.1.2 for the precise definition of consistent sets of homomorphisms.) This allows us to count the number of H-homomorphisms (without other restrictions), the number of H-subgraphs, the number of induced H-subgraphs, the number of H-homomorphisms in which every vertex in the image is mapped by a bounded number of vertices, and more.

• Theorem 5.6 works for graphs whose some cliques are labelled. (See Section 1.1.1 for the formal definition of the labelling.) This allows us to count objects beyond graphs, such as directed graphs, edge-colored graphs, hypergraphs, and relational structures.

• For any fixed graph H, Theorem 5.6 can count the number of homomorphisms from H to graphs in a class , as long as any shallow minor in graphs in with depth O( V (H) ) has low edge-density,F in contrast to nowhere dense classes orF bounded ex- | | pansion classes that require low edge-density for shallow minors with all depths. Our proof does not use machineries that are frequently applied in the study of sparsity theory such as low tree-depth coloring, center coloring or weak coloring. Our machin- ery applies to d-degenerate graphs for any fixed integer d (Theorem 1.9), which is a somewhere dense class of graphs, and solves a conjecture of Huynh and Wood in [44].

1.1 An obvious lower bound We describe an obvious lower bound for the number of homomorphisms from a fixed graph to graphs in a graph class in this subsection. A separation of a graph G is an ordered pair (A, B) of subsets of V (G) such that A B = V (G) and there exists no edge of G between A B and B A. The order of (A, B) is A∪ B . A collection of separations of G is independent− if − | ∩ | C • for every member (A, B) of , A B = , and C − 6 ∅ • for any distinct members (A, B) and (C,D) of , we have A D and C B. C ⊆ ⊆ We remark that we do not require B = for members (A, B) in an independent collection, so (V (G), ) is an independent collection.6 ∅ Note that for any two distinct members (A, B) and{ (C,D)∅ of} an independent collection, A B D C, so A B and C D are disjoint, − ⊆ − − − 2We remark that we state Theorems 1.4 and 1.7 in a general setting that will be described in the following bullets. The general setting requires a number of definitions stated in Sections 1.1.1-1.1.4. Readers who are interesting in counting subgraphs only can skip Sections 1.1.1-1.1.4 and jump to Section 1.2 after reading Proposition 1.2, and can treat all labelled graphs as graphs and treat ex(H,fH , , ,n) and dupH(H,fH , ) H G G stated in Theorems 1.4 and 1.7 as ex(H, ,n) and maxC over all collections stated in Proposition 1.2, respectively. All applications of TheoremsG 1.4 and 1.7 explicitly|C| stated in this paperC only rely on this special case for counting subgraphs in unlabelled graphs.

4 and there exists no edge between A B and C D. Hence every independent collection of separations of H has size at most the− independence− number of H. (The independence number of H, denoted by α(H), is the maximum size of a set of pairwise non-adjacent vertices in H.) Let H be a graph. Let Z V (H). Let k be a positive integer. We define H k Z to be ⊆ ∧ the graph obtained from a union of k disjoint copies of H by for each z Z, identifying the ∈ k copies of z into a vertex. So V (H k Z) = k( V (H) Z )+ Z . Let be an independent | ∧ | | |−| | | | C collection of separations of a graph H. We define H k to be H k ( B). Itis easy to ∧ C ∧ T(A,B)∈C |C| |V (G)| |C| 1 |C| see that if G = H k , then there are at least k ( ) V (G) induced ∧ C ≥ |V (H)| ≥ |V (H)|α(H) | | subgraphs of G isomorphic to H. Hence we obtain the following obvious lower bound.

Proposition 1.2 For every graph H, there exists a real number c = c(H) such that if is a G class of graphs and is an independent collection of separations of H such that H ℓ C ∧ C ∈ G for infinitely many positive integers ℓ, then ex(H, , n) cn|C| for infinitely many integers n, where ex(H, , n) is the maximum number of subgraphsG ≥ isomorphic to H contained in an G n-vertex graph in . G This obvious lower bound actually works for a more general setting (Proposition 1.3). We need a number of definitions to state our general setting and Proposition 1.3.

1.1.1 Labelled graphs Let G be a graph. A march in G is a sequence over V (G) with distinct entries. A labelling of G is a function such that every element in its domain is a march in G. A labelling f of G is legal if for every march in the domain of f, its entries form a clique. A labelled graph is a pair (G, fG), where G is a graph and fG is a labelling of G. A labelled graph is legal if its labelling is legal. A quasi-order is a pair (X, ), where X is a set and is a reflexive and transitive binary relation on X. For a quasi-order Q =(X, ), a Q-labelling of a graph G is a labelling of G whose image is a subset of X, and a Q-labelled graph is a labelled graph whose labelling is a Q-labelling. Each of following objects can be encoded as legal Q-labelled graphs for an antichain Q:

• Directed graphs. (Map each march corresponding to a directed edge to an element in Q representing the direction of this edge.)

• Edge-colored graphs (such as in the setting for k-common graphs [14, 45, 48] or for rainbow Tur´an problems [33, 46]).

• (m, n)-colored mixed graphs (such as in the setting in [64]).

• Hypergraphs. (Construct a graph by making each hyperedge a clique and label this clique).

• Relational structures. (Consider their Gaifman graphs, see [62].)

5 For any function f and a sequence s =(s1,s2, ..., sn) whose every entry is in the domain of f, we define f(s) to be the sequence (f(s1), f(s2), ..., f(sn)). Similarly, if S is a subset of the domain of f, we define f(S) to be the set f(x): x S . { ∈ } Let Q be a quasi-order. An isomorphism from a Q-labelled graph (H, fH )toa Q-labelled 3 graph (G, fG) is an isomorphism φ from H to G such that for every march m in the domain ′ of fH , φ(m) is in the domain of fG with fH (m)= fG(φ(m)), and for every march m in the −1 ′ domain of fG, φ (m ) is in the domain of fH . Two Q-labelled graphs are isomorphic if there is an isomorphism between them. Let Q be a quasi-order. A Q-labelled graph (H, fH ) is an induced Q-labelled subgraph (or simply induced subgraph) of a Q-labelled graph (G, fG) if H is an induced subgraph of G, the domain of fH is a subset of the domain of fG, and for each march m in the domain of fG whose all entries are in V (H), m is in the domain of fH and fH (m) = fG(m). We say that a class of Q-labelled graphs is hereditary if every induced Q-labelled subgraph of a G ′ member of is a member of . A Q-labelled graph (H , fH′ ) is a Q-labelled subgraph (or G G ′ simply subgraph)ofa Q-labelled graph (G, fG) if H is a subgraph of G, the domain of fH′ is a subset of the domain of fG, and for every march m in the domain of fH′ , fH′ (m)= fG(m). ′ ′ And we say that (H , fH′ ) is a spanning subgraph of (G, fG) if (H , fH′ ) is a subgraph of ′ (G, fG) and V (H )= V (G). Let Q =(X, ) be a quasi-order. A homomorphism from a legal Q-labelled graph (H, fH )  to a Q-labelled graph (G, fG) is a homomorphism φ from H to G such that for every march m in the domain of fH , φ(m) is in the domain of fG and fH (m) fG(φ(m)). Note that  since (H, fH ) is legal, every march m in the domain of fH form a clique, so entries of φ(m) are distinct and hence φ(m) is a march. For simplicity, we say that is a set of homomorphisms from (H, fH ) to a class if H G every member of is a homomorphism from (H, fH ) to a member of . A separation ofH a labelled graph (G, f) is a separation of G. Note thatG if f is legal, then for any separation (A, B) of G, there exists no march in the domain of f containing entries in both A B and B A. − − 1.1.2 Consistent sets of homomorphisms

Let Q be a quasi-order. Let (H, fH ) be a legal Q-labelled graph, and let be a hereditary G class of legal Q-labelled graphs. Let be a set of homomorphisms from (H, fH ) to members in . We say that is consistent ifH the following conditions hold. G H

(CON1) For every homomorphism φ from (H, fH ) to a member (G, f) in , ∈ H G – if (G′, f ′) is an induced subgraph of (G, f) with φ(V (H)) V (G′), then the func- tion obtained from φ by restricting the codomain to be V (⊆G′) is a homomorphism ′ ′ from (H, fH ) to (G , f ) and belongs to ; H – if (G, f) is an induced subgraph of another member (G′, f ′) in , then the function obtained from φ by changing the codomain to be V (G′) is a homomorphismG from ′ ′ (H, fH ) to (G , f ) and belongs to ; H 3An isomorphism from an (unlabelled) graph H to an (unlabelled) graph G is a function ι : V (H) V (G) such that ι is a bijection, and for every u, v V (H), uv E(H) if and only if ι(u)ι(v) E(G). → ∈ ∈ ∈

6 (CON2) For any members (G , f ) and (G , f ) of with an isomorphism ι from (G , f ) to 1 1 2 2 G 1 1 (G , f ), if φ is a homomorphism in from (H, fH ) to (G , f ), then ι φ is a homo- 2 2 H 1 1 ◦ morphism in from (H, fH ) to (G , f ). H 2 2 (CON3) For any members (G1, f1) and (G2, f2) of such that there exists an isomorphism ι ′ G ′ from (G2, f2) to a spanning subgraph (G1, f1) of (G1, f1), if φ is a homomorphism in 4 ′ ′ from (H, fH ) to (G1, f1) and φ is also an homomorphism from (H, fH ) to (G1, f1), H −1 −1 then ι φ is a homomorphism from (H, fH ) to (G , f ), and ι φ . ◦ 2 2 ◦ ∈ H Note that (CON1) and (CON2) are simply conditions for “consistency” with respect to the induced subgraph relation and isomorphisms, respectively. (CON3) is a condition stating that redundant edges can be dropped. Even though (CON3) might seem artificial at the first glance, it is actually a combination of analogies of (CON1) and (CON2) if is assumed to be closed under taking subgraphs (this assumption can always be made if oneG only considers homomorphisms with no restriction on non-adjacent pairs of vertices); but here we only assume that is hereditary (that is, closed under taking induced subgraphs) which it is a weak assumption;G this weaker assumption is more natural when we consider homomorphisms that might have restrictions on non-adjacent pairs, such as counting the number of induced subgraphs. In fact, (CON2) is a special case of (CON3), but we state them separately since we only need (CON2) in many lemmas. The following sets are examples of consistent sets of homomorphisms:

• The set of all homomorphisms from (H, fH ) to members in . G • The set of homomorphisms from (H, fH ) to members in corresponding to subgraph embeddings (or induced subgraph embeddings, respectively).G

• For any fixed integer t, the set consisting of all homomorphisms from (H, fH ) to mem- bers of such that for every member φ of this set and v V (G) with (G, fG) , the G ∈ ∈ G size of the set x V (H): φ(x)= v is at most t. { ∈ } Let Q be a quasi-order. Let (H, fH ) be a legal Q-labelled graph. Let be a set of con- H sistent homomorphisms from (H, fH ) to a hereditary class of legal Q-labelled graphs. For G any member (G, fG) , we define ex(H, fH , ,G,fG) to be the number of homomorphisms ∈ G H in from (H, fH ) to (G, fG). For every positive integer n, we define H ex(H, fH , , , n) := max ex(H, fH , ,G,fG). H G (G,fG)∈G,|V (G)|=n H

1.1.3 Duplication

For a labelled graph (G, fG), an independent collection of separations of (G, fG) is an independent collection of separations of G. Let (H, fH ) be a labelled graph. Let be an independent collection of separations of L (H, fH ). For a positive integer w, we define (H, fH ) w to be the labelled graph (G, fG) ∧ L such that there exist w disjoint isomorphic copies (G1, fG1 ), (G2, fG2 ), ..., (Gw, fGw )of(H, fH ) such that 4 ′ ′ Note that we only assume that is hereditary, so (G1,f1) is not necessarily in and hence φ is not necessarily in . G G H 7 • G is obtained from G1,G2, ..., Gw by for each vertex v T(A,B)∈L B, identifying the G ∈ copies of v in G1,G2, ..., Gw into a vertex v , • G if m is a march in the domain of fGi for some i [w], then m is in the domain of G G ∈ fG and fG(m )= fGi (m), where m is the march in G obtained from m by replacing each entry v of m with v B by vG, and ∈ T(A,B)∈L

• for every march m in the domain of fG, there exist i [w] and a march mi in the G ∈ domain of fGi such that m = mi and fG(m)= fGi (mi). For a class of labelled graphs , we say that is -duplicable if there exist infinitely many G L G positive integers k such that (H, fH ) k . ∧ L ∈ G For a graph G and a subset S of V (G), we define NG[S] to be the set of all vertices of G that are either in S or are adjacent in G to some vertex in S. Let Q be a quasi-order. Let (H, fH ) be a legal Q-labelled graph, and let be an indepen- L dent collection of separations of (H, fH ). Let be a set of homomorphisms from (H, fH ) to a class of Q-labelled graphs. We say that His ( , )-duplicable if there exist a Q-labelled G L G H graph (G, fG) and a homomorphism φ from (H, fH ) to (G, fG) such that ∈ H • φ is onto,

• φ(A B) φ(B)= for any (A, B) , and − ∩ ∅ ∈L

• (NG[φ(A B)],V (G) φ(A B)) : (A, B) is a -duplicable independent { − − − ∈ L} G collection of separations of (G, fG) with size . |L| Define

dupH(H, fH , ) := max , G C |C| where the maximum is over all ( , )-duplicable independent collections of separations of G H C (H, fH ).

1.1.4 Obvious lower bound in the general form Now we are ready to state the obvious lower bound in the general form. Its proof is almost identical to the proof of Proposition 1.2, so we omit its proof.

Proposition 1.3 For every graph H, there exists a positive real number c = c(H) such that the following holds. Let fH be a legal Q-labelling for some quasi-order Q. Let be a hereditary class of legal Q-labelled graphs. Let be a consistent set of homomorphismsG from H (H, fH ) to members of . Then there are infinitely many positive integers n such that G

dup (H,fH ,G) ex(H, fH , , , n) cn H . H G ≥ The main results of this paper show that the lower bound in Proposition 1.3 is also an upper bound, up to a constant factor or an no(1) multiplicative error, when has bounded G expansion or is nowhere dense, respectively.

8 An immediately following question is whether dup (H, fH , ) is decidable. It is not hard H G to give explicit descriptions for dupH(H, fH , ) when has nice structures (see examples in Section 6) or when H has only few verticesG or has niceG structures (such as for the cases studied in Tur´an-type questions, like when H is a complete graph, a complete bipartite graph, a forest or a cycle). In general, deciding dup (H, fH , ) only requires to check whether each H G independent collection of separations of (H, fH ) is ( , )-duplicable or not; and there are only finitely many suchC collections. To check whetherG aH collection is ( , )-duplicable or not, since is hereditary and is consistent, it suffices to check forC eachG QH-labelled graph ′ G H (H , fH′ ) on at most V (H) vertices satisfying that there exists an onto homomorphism in | ′ | ′ from (H, fH ) to (H , fH′ ), whether the corresponding independent collection of (H , fH′ ) isH -duplicable or not. Note that there are only finitely many such graphs H′, and if Q is G finite (such as for the case we encode directed graphs or hypergraphs), then there are only ′ finitely many such Q-labelled graphs (H , fH′ ). Moreover, since is hereditary, for every G labelled graph (H, fH ), there exists an integer k such that any independent collection of L separations of (H, fH ) is -duplicable if and only if (H, fH ) k . Hence dupH(H, fH , ) can be decided in finite timeG if Q is finite, provided an oracle∧ toL test∈ G the membership of Gis G given.

1.2 Main results One of the main results of this paper shows that the obvious lower bounded mentioned in Proposition 1.3 actually gives an upper bound for graphs with a robust sparsity condition. We first describe such a condition. Planar graphs and graphs with bounded degeneracy are sparse in the sense that the number of their edges are at most a linear function of the number of their vertices. But these two kinds of graphs behave very differently. Planarity is a robust sparsity in the sense that contracting any connected subgraph preserves the planarity, so contracting disjoint connected subgraphs in planar graphs cannot create a . On the other hand, bounded degeneracy is not a robust sparsity, since subdividing every edge of a large complete graph results in a 2-degenerate graph, and contracting disjoint stars from this 2-degenerate graph results in a very dense graph. Such robust sparsity conditions are the hearts of the extensively studied sparsity theory (for example, see [62]) and can be described in terms of conditions of the edge-density of shallow minors. The radius of a connected graph G is the minimum k such that there exists a vertex v of G such that every vertex of G has distance from v at most k. Let ℓ Z . We say that a graph G contains another graph H as an ℓ-shallow minor (or equivalently,∈ ∪ {∞} H is an ℓ-shallow minor of G) if H is isomorphic to a graph that can be obtained from a subgraph G′ of G by contracting disjoint connected subgraphs of G′ of radius at most ℓ. In other words, every branch set of an ℓ-shallow minor is a connected subgraph of radius at most ℓ. Note that 0-shallow minors are exactly subgraphs, up to isomorphism. We say that a graph H is a minor of G if G contains H as an -shallow minor. Note that this definition for minors ∞ is equivalent to the usual definition for minors in the literature. Theorem 5.6 is the main theorem of this paper. It determines ex(H, fH , , , n) up toa constant factor when the edge-density of every O( V (H) )-shallow minor inH a graphG in is | | G 9 small. In order to serve as a source to derive almost all other results in this paper and to solve open questions in the literature, it is stated in a general but technical form. We postpone its formal statement until Section 5. We include some simple applications of Theorem 5.6 in this section. More concrete applications of Theorem 5.6 are included in Section 6. A class of graphs has bounded expansion if there exists a function f : N 0 R F ∪{ } → such that for every nonnegative integer d, every d-shallow minor of a graph in has average degree at most f(d). F Classes of bounded expansion are very general. They not only include any class of bounded maximum degree but also include a number of classes of graphs with some natural geometric properties. (See Figure 1 for a relationship between bounded expansion classes and other classes.) Well-known examples of classes of bounded expansion include any proper minor-closed family [55] (such as the classes of graphs of bounded Euler genus and the class of knotless embeddable graphs), any proper topological minor-closed family [21] (such as the classes of bounded crossing number), any class of graphs with bounded or bounded stack number [63], and any class of graphs admitting strongly sublinear balanced separators [23] (such as any class of string graphs with a forbidden bipartite subgraph [28] and any class of intersection graphs of sets in Rd with certain geometric properties [22, 57]). Moreover, for every p> 0, there exists a class with bounded expansion such that an Erd˝os- G p R´enyi random graph (n, n ) belongs to this class asymptotically almost surely [63]. Our main result (Theorem 5.6) determines ex(H, fH , , , n) up to a constant factor for any class of bounded expansion. We say that a class of labelledH G graphs has bounded expansion if the class of their underlying graphs has bounded expansion.

Theorem 1.4 For any quasi-order Q with finite ground set, hereditary class of legal Q- G labelled graphs with bounded expansion, legal Q-labelled graph (H, fH ), consistent set of H homomorphisms from (H, fH ) to , we have G

dup (H,fH ,G) ex(H, fH , , , n)=Θ(n H ). H G Theorem 1.4 solves a number of open questions in the literature. Most of them will be stated in Section 6. We give two examples in this section. For any class of graphs and graph H, we define ex(H, , n) to be the maximum number of subgraphs isomorphicG to H contained in G, where theG maximum is over all n-vertex graphs G in . A class of graphs is minor-closed if every minor of a member of this class belongs to thisG class; a minor-closed family is proper if it does not contain all graphs. Every proper minor-closed family is hereditary and has bounded expansion [55]. So Theorem 1.4 immediately gives a negative answer to Question 1.1. A variant of Question 1.1 is the following conjecture.

Conjecture 1.5 ([37, Conjecture 2.6]) For any finite set of graphs and for any graph F H, if is the set of all planar graphs with no subgraph isomorphic to any member in , and5 HG , then ex(H, , n)=Θ(nk) for some integer k. F ∈ G G 5Note that the statement in [37] does not include the condition H . But it is required. If H , then no graph in can contain H as a subgraph, so ex(H, ,n) = 0. ∈ G 6∈ G G G

10 Note that the class in Conjecture 1.5 is not minor-closed, so it is incomparable with Question 1.1. But thisG class is still hereditary and has bounded expansion, so Theorem 1.4 immediately gives a positiveG answer to Conjecture 1.5. In fact, we do not require the finiteness of , and can be replaced by an arbitrary hereditary class of graphs with bounded expansion.F Moreover,G instead of forbidding members of as subgraphs, we can F obtain stronger results by forbidding members of as induced subgraphs. Note that for every class , there exists a class ′ such that forbiddingF all members of as subgraphs is equivalentF to forbidding all membersF of ′ as induced subgraphs; but thereF exists a class F ′′ such that forbidding all graphs in ′′ as induced subgraphs cannot be described by Fforbidding graphs in any class as subgraphs.F The following corollary of Theorem 1.4 solves both Question 1.1 and Conjecture 1.5 simultaneously.

Corollary 1.6 For any proper minor-closed family and any (not necessarily nonempty or finite) set of graphs, if is the set of all graphs inC with no induced subgraph isomorphic F G C to any member in , and H , then ex(H, , n)=Θ(nk) for some integer k. F ∈ G G The most general classes in sparsity theory are the nowhere dense classes. A class of graphs is somewhere dense if there exists an integer t such that every complete graphF is a t-shallow minor of a graph in . A class of graphs is nowhere dense if it is not somewhere dense. Even though the definitionsF for these two kinds of classes look artificial, there are a number of equivalent definitions showing that these two classes are the right notions for capturing the dichotomy about sparse and dense graphs [61, 62]. Theorem 1.4 cannot be generalized to nowhere dense classes even when H = K2: the class of all graphs whose maximum degree are at most their girth is nowhere dense and hereditary, and n-vertex graphs in this class have O(n1+o(1)) edges, but there exists no constant c such that every graph in this class has at most cn edges [62]. However, our main result (Theorem 5.6) applies to nowhere dense classes as well, by giving a slightly weaker estimate comparing to Theorem 1.4. For any quasi-order Q, legal Q-labelled graph (H, fH ), class of Q-labelled graphs, and G consistent set of homomorphisms from (H, fH ) to , the asymptotic logarithmic density H G for (H, fH , , ) is defined to be G H

log(ex(H, fH , , , n)) lim sup H G . n→∞ log n

Note that if the asymptotic logarithmic density for (H, fH , , ) is k, then ex(H, fH , , , n) cnk+f(n) for some constant c and function f(n) = o(1).G SoH this notion is slightlyH weakerG ≤ than the estimate in Theorem 1.4. Our main result (Theorem 5.6) implies the following analog of Theorem 1.4 in terms of nowhere dense classes and asymptotic logarithmic density.

Theorem 1.7 Let Q be a quasi-order with finite ground set. Let (H, fH ) be a legal Q- labelled graph. Let be a hereditary nowhere dense class of legal Q-labelled graphs. Let G H be a consistent set of homomorphisms from (H, fH ) to . Then the asymptotic logarithmic G density for (H, fH , , ) equals dup (H, fH , ). G H H G

11 Theorem 1.7 strengthens a result of Neˇsetˇril and Ossona de Mendez [60] who proved that the asymptotic logarithmic density for the number of H-induced subgraphs in graphs in a hereditary nowhere dense class is an integer between 0 and α(H). Note that the set of induced subgraph embeddings is a consistent set of homomorphisms, and any independent collection of separations of H has size at most α(H). The machinery developed for the proof of Theorem 5.6 works for some somewhere dense classes as well. For any nonnegative integer d, a graph is d-degenerate if every its subgraph has minimum degree at most d. The class of d-degenerate graphs is somewhere dense when d 2, since this class contains all graphs that can be obtained by subdividing every edge of a≥ complete graph. The following is an equivalent statement of a conjecture of Huynh and Wood [44]. (For a nonnegative integer d and graph H, flapd(H) is defined to be the maximum size of an independent collection of separations of H of order at most d.)

Conjecture 1.8 ([44, Conjecture 16]) Let d be a nonnegative integer. If d is the class D flap (H) of d-degenerate graphs and H is a d-degenerate graph, then ex(H, d, n)=Θ(n d ). D We disprove Conjecture 1.8 and prove the correct exponent for n. For a nonnegative integer d and a graph H, we define αd(H) to be the maximum size of a set of pairwise non-adjacent vertices of degree at most d in H.

Theorem 1.9 Let d be a nonnegative integer. If d is the class of d-degenerate graphs and D α (H) H is a d-degenerate graph, then ex(H, d, n) = Θ(n d ). Moreover, there are infinitely D many d-degenerate graphs H with αd(H) < flap (H) when d 2. d ≥ 1.3 Organization of this paper In Section 2, we will prove a key lemma about counting the number of homomorphisms: if G is a graph with a “nice” ordering, then one can bound the size of any given set of homomorphisms from a graph H to G and construct an independent collection of separations of H matching the size for this bound. Graphs with bounded degeneracy have such a nice ordering. In Section 3, we prove Theorem 1.9 by showing that the independent collection obtained in the previous lemma is duplicable. The next goal is to prove our main theorem (Theorem 5.6). The strategy is to prove that graphs mentioned in Theorem 5.6 has a nice ordering as stated in the lemma in Section 2 and prove that the corresponding independent collection is duplicable. In Section 4, we prove structure theorems for graphs whose shallow minors have low edge-density. These structure theorems will be used in Section 5 to prove Theorem 5.6. We will also show how to deduce Theorems 1.4 and 1.7 from Theorem 5.6 in Section 5. In Section 6, we will use Theorem 5.6 (or more precisely, Corollary 5.7 which is a more informative version of Theorem 1.4) to deduce results about ex(H, , n), including solutions of some open questions in the literature. Results in Section 6 canG be read without any knowledge in earlier sections except the statement of Corollary 5.7.

12 1.4 Notations Now we define some notations that will be used in this paper. For any vertex x of ≤ℓ a graph G and any (possibly negative) real number ℓ, we define NG [x] to be the set of ≤0 all the vertices in G whose distance to x is at most ℓ; in particular, NG [x] = x and ≤−1 ≤1 { } N [x] = . We also denote N [x] by NG[x]. For every subset S of V (G), we define G ∅ G NG(S) = v V (G) S : uv E(G) for some u S ; note that NG[S] = NG(S) S. { ∈ − ∈ ∈ } ∪ When S consists of only one vertex x, we write NG(S) as NG(x). For a subset S of V (G), we define G[S] to be the subgraph of G induced by S. For a function f whose domain is a set of marches over a set S, if T is a subset of S, then we define f T to be the function obtained from f by restricting the domain to be m : m is a march in| the domain of f, and { all entries of m are in T . For a positive integer k,[k] denotes the set 1, 2, ..., k . } { } 2 A counting lemma

Let G be a graph. An ordering of G is a bijection from V (G) to [ V (G) ]. Let σ be | | an ordering of G. Given i [ V (G) ], we define Gσ, i to be the subgraph of G induced by ∈ | | ≥ v V (G): σ(v) i . Let p be a nonnegative integer. Let = (Si : i [ V (G) ]) be { ∈ ≥ } S ∈ | | a sequence such that for each i [ V (G) ], Si v V (G): σ(v) i +1 . For each i [ V (G) ], the p-basin (with respect∈ | to σ |and ⊆) at { i ∈is the set N ≤p ≥ [σ−1(}i)]. That is, Gσ,≥i−Si ∈ | | S −1 the p-basin at i consists of the vertices in Gσ,≥i that can be reached from σ (i) by a path in Gσ,≥i of length at most p disjoint from Si.

Lemma 2.1 For any integers k 0, h 1, N 0, there exists a positive integer c = ≥ ≥ ≥ c(k, h, N) such that the following holds. Let H be a graph on h vertices. Let G be a graph, and let σ be an ordering of G. Let =(Si : i [ V (G) ]) be a sequence such that Si v S ∈ | | ⊆{ ∈ V (G): σ(v) i +1 and Si k for every i [ V (G) ]. For every i [ V (G) ], let Bi be ≥ } | | ≤ ∈ | | ∈ | | the (h 1)-basin with respect to σ and at i. Let b be a positive real number. If Bi b for every− i [ V (G) ], then for every setS of homomorphisms from H to G, there exists| | ≤ an ∈ | | H integer t such that the following hold.

1. cbh V (G) t, |H| ≤ | |

2. For every φ , there exist an independent collection φ of separations of H with ∈ H L φ t and an injection ιφ : φ [ V (G) N] such that for every (X,Y ) φ, if |L | ≤ L → | | − ∈ L i = ιφ((X,Y )), then

−1 (a) σ (i) φ(X Y ) Bi, ∈ − ⊆ (b) φ(X Y ) Si, ∩ ⊆ (c) for every component C of H[X Y ], σ−1(i) φ(V (C)), and − ∈ (d) every vertex in X Y is adjacent in H to some vertex in X Y . ∩ −

3. There exists φ with φ = t. ∈ H |L |

13 Proof. Let k 0, h 1, N 0 be integers. Let c = h(k + h)2h−1 + N. Define c = ch. ≥ ≥ ≥ 1 1 Let H, G, σ, = (Si : i [ V (G) ]), b, B , B , ..., B be as stated in the lemma. For S ∈ | | 1 2 |V (G)| each i [ V (G) ], let vi be the vertex of G with σ(vi)= i. ∈ | | Let be a set of homomorphisms from H to G. For every φ , we define the following. H ∈ H

• Let Hφ, = H, Zφ, = and Iφ, = . 0 0 ∅ 0 ∅ • For each i [ V (G) ], ∈ | |

– if vi φ(V (Hφ,i )), then ∈ −1 ∗ let Zφ,i = Zφ,i vi , −1 ∪{ } ∗ let φ,i be the collection of the components of Hφ,i u V (H): φ(u) Si Q −1−{ ∈ ∈ } containing a vertex u V (H) with φ(u)= vi, ∈ ∗ let Hφ,i = Hφ,i−1 V (Q), − SQ∈Qφ,i ∗ define Iφ,i as follows:

· if i V (G) N and Sj φ(V (Q)) = , then let ≤| | − Sj∈[i−1],vj ∈Zφ,i−1 ∩ SQ∈Qφ,i ∅ Iφ,i = Iφ,i vi , −1 ∪{ } · otherwise, let Iφ,i = Iφ,i−1;

– otherwise, let Zφ,i = Zφ,i−1, Hφ,i = Hφ,i−1 and Iφ,i = Iφ,i−1.

• Let Zφ = Zφ,|V (G)| and Iφ = Iφ,|V (G)|.

Claim 1: For every φ , φ(V (H)) Bσ(v). ∈ H ⊆ Sv∈Zφ Proof of Claim 1: Let φ . Let w be a vertex of H. Since H V G is empty, there exists ∈ H | ( )| iw [ V (G) ] such that w V (Hφ,i ) V (Hφ,i ). So there exists Q φ,i such that Q ∈ | | ∈ w−1 − w ∈ Q w is a component of Hφ,i u V (H): φ(u) Si containing w and a vertex u V (H) w−1 −{ ∈ ∈ w } ∈ with φ(u)= vi Zφ,i . Hence there exists a path P in Gσ, i Si from vi to φ(w) with w ∈ w ≥ w − w w length at most V (H) 1= h 1. So φ(w) Bi = Bσ(v ) Bσ(v). This proves the w iw Sv∈Zφ claim.  | | − − ∈ ⊆ For every φ , ∈ H

• let Dφ be the directed graph with V (Dφ) = V (G) and E(Dφ) = (vi,u): i { ∈ [ V (G) ],u Si (u, vi): i [ V (G) ], vi Zφ,u φ(V (Q)) , | | ∈ }∪{ ∈ | | ∈ ∈ SQ∈Qφ,i }

• let Rφ = v V (Dφ) : there exists a directed path in Dφ from a vertex in Iφ to v of { ∈ length at most 2h 2 v V (Dφ): σ(v) V (G) N +1 , and − }∪{ ∈ ≥| | − }

• let Wφ = Bσ(v). Sv∈Rφ

Claim 2: For every φ and for every v Zφ Iφ with σ(v) V (G) N, there exist ∈ H ∈ − ≤| | − u Zφ with σ(u) < σ(v) and a directed path in Dφ from u to v with length at most two. ∈ Proof of Claim 2: Let φ . Let v Zφ Iφ with σ(v) V (G) N. Since v Iφ, ∈ H ∈ − ≤ | | − 6∈ by the definition of Iφ, Sj φ(V (Q)) = . So there exist Sj∈[σ(v)−1],vj ∈Zφ,σ(v)−1 ∩ SQ∈Qφ,σ(v) 6 ∅ u Zφ,σ(v)−1 Zφ with σ(u) < σ(v) and w Sσ(u) φ(V (Q)). Hence uwv is a ∈ ⊆ ∈ ∩ SQ∈Qφ,σ(v) directed path in Dφ from u to v of length at most two. 

14 Claim 3: For every φ , φ(V (H)) Wφ. ∈ H ⊆ Proof of Claim 3: Let φ . By Claim 2, for every v Zφ with σ(v) V (G) N, ∈ H ∈ ≤ | | − there exists a directed path in Dφ from a vertex in Iφ to v with length at most 2( Zφ | | − 1) 2( V (H) 1) = 2h 2. Hence Zφ Rφ. By Claim 1, φ(V (H)) Bσ(v) ≤ | | − − ⊆ ⊆ Sv∈Zφ ⊆ Bσ(v) = Wφ.  Sv∈Rφ

Claim 4: For every φ , every vertex of Dφ has out-degree at most k + h. ∈ H Proof of Claim 4: Let φ . Let x V (Dφ). Since Zφ V (H) , there exists at most ∈ H ∈ | |≤| | h integers i [ V (G) ] with vi Zφ such that x φ(V (Q)). So the out-degree of x ∈ | | ∈ ∈ SQ∈Qφ,i in Dφ is at most Sσ x + h k + h.  | ( )| ≤ Define t = maxφ Iφ . Since Iφ Zφ V (H) for every φ , t h. ∈H| | | |≤| |≤| | ∈ H ≤ |V (G)| Claim 5: There exist t  subsets of V (G) with size at most c1b such that for any φ , φ(V (H)) is contained in at least one of those sets. ∈ H |V (G)| Proof of Claim 5: By the definition of t, Iφ t for every φ . So there exist | | ≤ ∈ H t  subsets of V (G) with size t such that for any φ , Iφ is contained in at least one of them. ∈ H By Claim 4, for every φ , every vertex of Dφ has out-degree at most k + h, so for every ∈ H 2h−2 j 2h−1 v V (Dφ), there exist at most Pj=0 (k + h) (k + h) directed paths in Dφ of length ∈ ≤ |V (G)| at most 2h 2 starting from v. So there exist t  subsets of V (G) with size at most 2h−1 − 2h−1 t(k+h) h(k+h) such that for any φ , Rφ v V (Dφ): σ(v) V (G) N+1 ≤ ∈ H −{ ∈ |V (G)| ≥| |− } is contained in at least one of those sets. Hence there exist t  subsets of V (G) with 2h−1 size at most h(k + h) + N = c1 such that for any φ , Rφ is contained in at least one ∈ H |V (G)| of those sets. Since Bi b for every i [ V (G) ], there exist subsets of V (G) with | | ≤ ∈ | | t  size at most c1 b such that for any φ , Wφ is contained in at least one of those sets. Then this claim· follows from Claim 3. ∈ H Note that for each subset U of V (G), there are at most U |V (H)| homomorphisms from | ||V (G)| h h t H to G whose image is contained in U. So by Claim 5, t  (c1b) cb V (G) . This proves Statement 1 of this lemma. |H| ≤ · ≤ | | Now we prove Statements 2 and 3. Note that for every φ and v Zφ, v is the unique ∈ H ∈ vertex in Z Z , and is defined; we denote by φ,v for simplicity. φ,σ(v) − φ,σ(v)−1 Qφ,σ(v) Qφ,σ(v) Q Claim 6: For every φ and for any v Iφ and Q φ,v, NH (V (Q)) u V (H): ∈ H ∈ ∈ Q ⊆ { ∈ φ(u) Sσ v . ∈ ( )} Proof of Claim 6: Let φ . Let v Iφ. Let Q φ,v. Suppose to the contrary that there ∈ H ∈ ∈ Q exists a vertex w NH (V (Q)) u V (H): φ(u) S . Since V (Q) is the vertex-set of ∈ −{ ∈ ∈ σ(v)} a component of Hφ,σ v u V (H): φ(u) Sσ v , w V (H) V (Hφ,σ v ). So there ( )−1 −{ ∈ ∈ ( )} ∈ − ( )−1 exists iw [σ(v) 1] such that w V (Hφ,iw−1) V (Hφ,iw ). Hence there exists a component ′ ∈ − ∈ − ′ Q φ,viw of Hφ,iw−1 u V (H): φ(u) Siw containing w and a vertex w V (H) with ∈′ Q −{ ∈ ∈ } ′ ∈ φ(w )= viw Zφ,iw Zφ,σ(v)−1. Since w NH (V (Q)), w V (Q ) is adjacent in H to some ′′ ∈ ⊆ ∈ ′ ∈ ′ ′′ vertex w in Q Hφ,σ(v)−1 = Hφ,σ(v)−1 V (Q ) Hφ,iw−1 V (Q ), so w u V (H): ⊆ ′′ − ⊆ − ∈ { ∈ ′′ φ(u) Si . Hence φ(w ) Si φ(V (Q)) Sj ′′ V (Q ). ∈ w } ∈ w ∩ ⊆ Sj∈[σ(v)−1],vj ∈Zφ,σ(v)−1 ∩ SQ ∈Qφ,v Therefore, v Iφ, a contradiction.  6∈ For every φ and every v Iφ, let Xφ,v = NH [ V (Q)], and let Yφ,v = ∈ H ∈ SQ∈Qφ,v V (H) V (Q), so (Xφ,v,Yφ,v) is a separation of H with Xφ,v Yφ,v u V (H): − SQ∈Qφ,v ∩ ⊆ { ∈

15 φ(u) Sσ(v) by Claim 6. Note that Xφ,v Yφ,v = NH ( V (Q)) and Xφ,v Yφ,v = ∈ } ∩ SQ∈Qφ,v − V (Q), so every vertex in Xφ,v Yφ,v is adjacent in H to some vertex in Xφ,v Yφ,v. SQ∈Qφ,v ∩ − For every φ , let φ = (Xφ,v,Yφ,v): v Iφ , and for every (Xφ,v,Yφ,v) φ, let ∈ H L { ∈ } ∈ L ιφ((Xφ,v,Yφ,v)) = σ(v). Clearly, ιφ is an injection from φ to [ V (G) ]. Note that v φ(V (Q)) L | | ∈ for every Q φ,v. Since Xφ,v Yφ,v = V (Q)= V (Hφ,σ(v)−1) V (Hφ,σ(v)), φ is an ∈ Q − SQ∈Qφ,v − L independent collection of separations of H. Moreover, every component of H[Xφ,v Yφ,v] is − a member of φ,v, so v is contained in φ(V (C)) for every component C of H[Xφ,v Yφ,v]. Q − For every φ and v Iφ, since V (H) = h and v φ( V (Q)) V (Gσ,≥σ(v)) ∈ H ∈ | | ∈ SQ∈Qφ,v ⊆ − Sσ(v), we know φ( V (Q)) Bσ(v). So for any φ and (X,Y ) φ, there exists SQ∈Qφ,v ⊆ ∈ H ∈ L v Iφ with σ(v) = ιφ((X,Y )) such that v φ(X Y ) Bσ v , φ(X Y ) Sσ v , ∈ ∈ − ⊆ ( ) ∩ ⊆ ( ) and for every component C of H[X Y ], v φ(V (C)). Note that v Iφ implies that − ∈ ∈ σ(v) V (G) N. So the image of ιφ is contained in [ V (G) N]. ≤| | − | | − Since φ = Iφ , Statements 2 and 3 of this lemma follow from the definition of t. |L | | | 3 Bounded degeneracy

We will prove Theorem 1.9 in this section. A subgraph embedding from a graph H to a graph G is an injective homomorphism from H to G. Note that the ratio between the number of subgraph embeddings from H to G and the number of H-subgraphs of G are upper bounded and lower bounded by constants only depending on H. Recall that for any nonnegative integer d and a graph G, αd(G) is the maximum size of a set of pairwise non-adjacent vertices of degree at most d in G.

Lemma 3.1 For any integers d 0 and h 1, there exists an integer c = c(d, h) such that the following holds. If H is a graph≥ on h vertices≥ and G is a d-degenerate graph, then there are at most c V (G) αd(H) subgraph embeddings from H to G. | | Proof. Let d 0 and h 1 be integers. Define c = c2.1(d, h, 0), where c2.1 is the number c mentioned in≥ Lemma 2.1.≥ Let H be a graph on h vertices. Let G be a d-degenerate graph. Since G is d-degenerate, there exists an ordering σ of G such that for every v V (G), v has at most d neighbors in −1 ∈ G . For each i [ V (G) ], let Si = NG (σ (i)), so Si v V (G): σ(v) i +1 σ,≥σ(v) ∈ | | σ,≥i ⊆ { ∈ ≥ } and Si d. Let = (Si : i [ V (G) ]). For each i [ V (G) ], let vi be the vertex of G | | ≤ S ∈ | | ∈ | | with σ(vi)= i, and let Bi be the (h 1)-basin with respect to σ and at i. Note that each − S Bi equals vi , so Bi = 1. By Lemma 2.1, there exists an integer t such that there are at { } | | most c V (G) t subgraph embeddings from H to G, and there exist a subgraph embedding φ | | from H to G and an independent collection φ of separations of H with φ = t such that L |L | for every (X,Y ) φ, there exists iX [ V (G) ] such that vi φ(X Y ) Bi = vi ∈L ∈ | | X ∈ − ⊆ X { X } and φ(X Y ) Si . For every (X,Y ) φ, φ(X Y )= vi , so there exists uX X Y ∩ ⊆ X ∈L − { X } ∈ − with φ(uX)= vi . Since φ is a subgraph embedding, φ is injective. So for every (X,Y ) φ, X ∈L X Y = uX ; since φ(X Y ) Si , the degree of uX in H is at most Si d. Therefore, − { } ∩ ⊆ X | X | ≤ uX :(X,Y ) φ is a set of pairwise non-adjacent vertices of degree at most d in H. Hence { ∈L } t = φ αd(H) |L | ≤

16 Theorem 3.2 Let d 0 be an integer. Let d be the class of all d-degenerate graphs. Let ≥ D αd(H) H be a graph. If H is d-degenerate, then there exist real numbers c1,c2 such that c1n α (H) ≤ ex(H, d, n) c n d ; if H is not d-degenerate, then ex(H, d, n)=0. D ≤ 2 D Proof. If H is not d-degenerate, then H cannot be a subgraph of any graph in d, so D ex(H, d, n) = 0. Hence we may assume that H is d-degenerate. D α (H) By Lemma 3.1, there exists a real number c such that ex(H, d, n) c n d . Let S be 2 D ≤ 2 a set of pairwise non-adjacent vertices of degree at most d in H. Then = (NH [v],V (G) L { − v ): v S is an independent collection of separations of H of order at most d. For any { } ∈ } positive integer k, let Hk = H k . ∧ L We shall show that for every positive integer k, Hk is d-degenerate. Let k be a positive integer and let R be a subgraph of Hk. If R contains a copy of some vertex in S, then R contains a vertex of degree at most d. If R does not contain any copy of a vertex in S, then R is a subgraph of H S and hence contains a vertex of degree at most d. So Hk is d-degenerate. − Hence, H k for all positive integers k. Note that every graph is a legal Q-labelled ∧ L ∈ G graph for some quasi-order of size 1. So is -duplicable by definition. Let be the set of all subgraph embeddings from H to graphsL inG . Then is ( , )-duplicableH by definition. G L G H αd(H) By Proposition 1.3, there exists a real number c1 such that ex(H, d, n) c1n since α (H) α (H) D ≥ = αd(H). Therefore, c n d ex(H, d, n) c n d . |L| 1 ≤ D ≤ 2 Theorem 1.9 is an immediate corollary of Theorem 3.2 and the following proposition. Proposition 3.3 Let d be a positive integer with d 2. Then there are infinitely many ≥ d-degenerate graphs H with αd(H) < flapd(H). Proof. Define H to be a graph whose vertex-set is a union of three disjoint set X,Y,Z such that H[Z]= Kd+1, Y is a stable set in H with size d, every vertex in Y is adjacent to exactly d vertices in Z such that every vertex in Z is adjacent to at least one vertices in Y (it is possible since d 2), X is a nonempty stable set in H, and the neighborhood of any vertex ≥ in X is Y . We first show that H is d-degenerate. Let R be a subgraph of H. If R contains at least one vertex in X, then R contains a vertex of degree at most Y = d. If V (R) X = | | ∩ ∅ and V (R) Y = , then the degree in R of any vertex in V (R) Y is at most d. If ∩ 6 ∅ ∩ V (R) X = V (R) Y = , then R is a subgraph of H[Z] = Kd+1, so R contains a vertex of degree∩ at most d.∩ Hence∅H is d-degenerate. Since X is a stable set in H, and every vertex in X has degree at most d, we know αd(H) X . Since every vertex of H with degree at most d is contained in X, αd(H)= X . ≥| | | | But (Y Z,X Y ), ( x Y,Y Z): x X is an independent collection of separations { ∪ ∪ { } ∪ ∪ ∈ } of H of order at most Y = d. So flapd(H) X +1 >αd(H). Note that X can arbitrary, so there are infinitely| many| such graphs H.≥| | | |

4 Structure for graphs with forbidden shallow minors

In this section we prove structural theorems for graphs whose shallow minors have low edge-density.

17 Let s, t be positive integers. Let G be a graph. For p, q N ,a(p, q)-model for a ∈ ∪ {∞} Ks,t-minor in G is an ordered pair of two collections ( , ) such that X Y • = s, = t, |X| |Y| • is a collection of pairwise disjoint connected subgraphs of G, X ∪Y • for each X and Y , there exists an edge of G between V (X) and V (Y ), ∈ X ∈Y • every member of contains at most p vertices, and X • every member of contains at most q vertices. Y

Note that if there exists a (p, q)-model for a Ks,t-minor in G, then G contains Ks,t as a max p, q -shallow minor. For collections , of subgraphs of a graph G, a (p, q, , )- { } C1 C2 C1 C2 model for a Ks,t-minor in G is a (p, q)-model ( , ) for a Ks,t-minor such that and X Y X ⊆ C1 2. Y ⊆For C a set S of nonnegative integers, we say a graph G is an S-subdivision of a graph H if for every e E(H), there exists se S such that G can be obtained from H by subdividing ∈ ∈ each edge e of H exactly se times. The vertices in H are called the branch vertices of the S-subdivision. For a graph G, a subset Y of V (G), and an integer r, we say a subgraph H of G is r-adherent to Y if V (H) Y = and NG(V (H)) Y r. The proof of the following∩ lemma∅ is| essentially∩ the| same ≥ as the proof of [54, Lemma 4.2] but with more detailed analysis.

Lemma 4.1 For any positive integers r, t and positive real number k′, there exists a real number α = α(r, t, k′) > 0 such that the following holds. If ℓ N 0, , b N, ǫ′ 0 is a ∈ ∪{ ∞} ∈ ≥ real number, G is a graph, Y V (G), and is a collection of disjoint connected subgraphs of G Y on at most b vertices⊆ such that eachC member of is r-adherent to Y and has radius at most− ℓ, then either C

1. there exists a graph H with E(H) > k′ V (H) 1+ǫ′ such that G contains a subgraph isomorphic to a [2ℓ + 1]-subdivision| | of H |with all| branch vertices in Y ,

2. there exist a (1, b, G[ y ]: y Y , )-model for an ℓ-shallow Kr,t-minor in G, or { { } ∈ } C 3. α Y 1+ǫ′(r−1). |C| ≤ | | Proof. Let r 1, t 1 be integers, and let k′ > 0 be a real number. Define α = ≥ ≥ (t 1)(2k′)r−1 + k′ + t 1. −Let ℓ, b, ǫ′, G, Y, be− as stated in the lemma. Let G′ be the graph obtained from G by C contracting each member of into a vertex. Note that Y V (G′) since each member of is disjoint from Y . Let Z = V (CG′) V (G). Note that Z is the⊆ set of the vertices of G′ obtainedC by contracting members of . Define− G′′ to be the graph obtained from G′ E(G′[Y ]) by C − repeatedly choosing a vertex v in Z adjacent in G′ to a pair of nonadjacent vertices u,w in (G′ E(G′[Y ]))[Y ], deleting v, and adding an edge uw, until for any remaining vertex in Z, its neighbors− in Y form a clique.

18 Let H = G′′[Y ]. Note that some subgraph H′ of G′ is isomorphic to a 1 -subdivision of H with all branch vertices in Y , and V (H′) V (H) Z. Since each vertex{ } in Z comes from contracting a member of , and each member− of ⊆has radius at most ℓ, there exists a C C subgraph H′′ of G isomorphic to a [2ℓ + 1]-subdivision of H with all branch vertices in Y . So for every subgraph H0 of H, some subgraph of G is isomorphic to a [2ℓ + 1]-subdivision of H0 with all branch vertices in Y . Hence we may assume that for every subgraph H0 of ′ 1+ǫ′ H, E(H0) k V (H0) , for otherwise Statement 1 holds and we are done. So for every | | ≤ | | ′ ǫ′ ′ ǫ′ subgraph H0 of H, there exists a vertex of degree at most 2k V (H0) 2k V (H) in H0. ′ ǫ′ | | ≤ | | 2k |V (H)| ′ r−1 ǫ′(r−1)+1 By [72, Lemma 18], there are at most at most r−1  V (H) (2k ) V (H) = ′ | | ≤ | | (2k′)r−1 Y ǫ (r−1)+1 cliques of size r in H. | | ′′ We first assume that there exists a subgraph L of G isomorphic to Kr,t with a partition R, T of V (L), where R = r and T = t such that R and T are stable sets in L, R Y { } | | | | ⊆ and T Z. Since each member of contains at most b vertices and has radius at most ℓ, ⊆ C there exists a (1, b, G[ y ]: y Y , )-model for an ℓ-shallow Kr,t-minor in G. Therefore, Statement 2 holds. { { } ∈ } C ′′ Hence we may assume that there does not exist a subgraph L of G isomorphic to Kr,t with a partition R, T of V (L), where R = r and T = t such that R and T are stable { } | | | | sets in L, R Y and T Z. This implies that for each clique K in G′′[Y ] of size r, ⊆′′ ⊆ ′′ z Z V (G ): K NG′′ (z) t 1. In addition, for every z Z V (G ), since every |{ ∈ ∩ ⊆ }| ≤ − ∈ ∩ member of is r-adherent to Y , NG′′ (z) Y is a clique consisting of at least r vertices in H. C ′∩ Hence Z V (G′′) (t 1)(2k′)r−1 Y ǫ (r−1)+1. When| ∩r = 1, if|Z ≤ −(t 1) Y +| 1,| then some vertex in Y is adjacent in G′ to at least t | | ≥ − | | vertices in Z, so Statement 2 holds. So if r = 1, then we may assume that Z (t 1) Y α Y 1+ǫ′(r−1), so Statement 3 holds since = Z . Hence we may assume| that| ≤r −2. | | ≤ | By| the definition of G′′, the vertices|C| in Z but| | not in V (G′′) are the ones being≥ deleted while adding edges between vertices in Y . Hence Z V (G′′) E(G′′[Y ]) = E(H) k′ V (H) 1+ǫ′ = k′ Y 1+ǫ′ k′ Y 1+ǫ′(r−1), since r 2.| So− |≤| | | | ≤ | | | | ≤ | | ≥ ′ ′ ′ = Z = Z V (G′′) + Z V (G′′) (t 1)(2k′)r−1 Y ǫ (r−1)+1+k′ Y 1+ǫ (r−1) α Y 1+ǫ (r−1). |C| | | | ∩ | | − | ≤ − | | | | ≤ | | Hence Statement 3 holds. Let G be a graph. For a subset Y of V (G), v V (G) Y and integers k and r, we define a (v,Y,k,r)-span to be a connected subgraph∈ H of G− Y containing v such that − Y NG(V (H)) r, and for every vertex u of H, there exists a path in H from v to u| of∩ length at most| ≥ k. A(v,Y,k,r)-span H is minimal if no proper subgraph of H is a (v,Y,k,r)-span. The following lemma (Lemma 4.2) is a strengthening of a result implicitly proved in earlier work of the author and Wei [54, Lemma 4.4]. A big portion of the proof of Lemma 4.2 is identical to the proof of [54, Lemma 4.4]. Lemma 4.2 For any positive integers r, t, nonnegative integer ℓ, real numbers k′ > 0, β 0, ′ ≥ there exists a real number c = c(r,t,ℓ,k , β) such that for any graph G, subset Y0 of V (G) and real number 1 ǫ′ 0, either ≥ ≥ 1. there exists a graph H with E(H) > k′ E(H) 1+ǫ′ such that some subgraph of G is isomorphic to a [2ℓ + 1]-subdivision| | of H,| |

19 2. there exists a (1,ℓr + 1)-model for an ℓ-shallow Kr,t-minor in G,

ℓ 3. V (G) c Y ǫ0 , where ǫ =(1+ ǫ′(r 1))(r+1) , or | | ≤ | 0| 0 − 4. there exist X,Z V (G) Y with Z X and Z > β V (G) X 1+ǫ′(r−1) such that ⊆ − 0 ⊆ | | | − | (a) for any distinct z, z′ Z, the distance in G[X] between z, z′ is at least ℓ +1, ∈ (b) for any z Z and any u X whose distance from z in G[X] is at most ℓ, ∈ ∈ NG(u) X r 1, and | − | ≤ − ≤ℓ−1 (c) NG(N [z]) X r 1 for every z Z. | G[X] − | ≤ − ∈ Proof. Let r, t be positive integers, ℓ be a nonnegative integer, k′ be a positive real number, ′ and β be a nonnegative real number. Let α = α4.1(r, t, k ), where α4.1 is the number α ℓ mentioned in Lemma 4.1. Let η = β +1+(ℓr + 1)α. Define c =1+ η(r+1)(r+1) . ′ ′ Let G be a graph. Let Y0 V (G). Let ǫ be a real number with 0 ǫ 1. Let ′ (r+1)ℓ ⊆ ≤ ≤ ǫ0 = (1+ ǫ (r 1)) . We may assume that Statements 1 and 2 do not hold, for otherwise we are done.− We shall prove that Statements 3 or 4 hold. Let X = V (G) Y . For each integer i 0, we define the following. 0 − 0 ≥

• Define i to be a maximal collection of pairwise disjoint subgraphs of G[Xi], where C each member of i is a minimal (v,Yi,ℓ,r)-span for some vertex v Xi satisfying that C ≤ℓ−1 ∈ if ℓ 1, then Yi NG(N [v]) r. ≥ | ∩ G−Yi | ≥

• Di = V (L). SL∈Ci

• Zi is a maximal subset of Xi Di such that −

– for any two distinct vertices in Zi, the distance in G[Xi] between them is at least ℓ + 1, and ≤ℓ−1 – for every z Zi, N [z] NG(Di)= . ∈ G[Xi−Di] ∩ ∅

• Xi = Xi (Zi Di). +1 − ∪

• Yi = Yi Zi Di. +1 ∪ ∪

We remark that the definitions of i,Di,Zi,Xi ,Yi for i 0 are identical to their def- C +1 +1 ≥ initions in the proof of [54, Lemma 4.4], except the initial conditions for X0,Y0 are different. Hence the proof of following claim is identical to the proof of [54, Claim 4.4.1 in Lemma 4.4].

Claim 1: For any integer i 0 and z Zi, ≥ ∈ ≤ℓ−1 • NG(N [z]) Xi r 1, and | G[Xi] − | ≤ − ≤ℓ • if u N [z], then NG(u) Xi r 1. ∈ G[Xi] | − | ≤ −

20 ∗ 1+ǫ′(r−1) If there exists a nonnegative integer i such that Zi∗ > β V (G) Xi∗ , then by | | | − 1+| ǫ′(r−1) defining X = Xi∗ and Z = Zi∗ , we have Z X and Z > β V (G) X such that ⊆ | | | − | Statement 4 holds (Statements 4(a) follows from the definition of Zi∗ , and Statements 4(b) and 4(c) follow from Claim 1). 1+ǫ′(r−1) 1+ǫ′(r−1) So we may assume that Zi β V (G) Xi = β Yi for every nonnegative | | ≤ | − | | | integer i. The proof of the following claim is identical to the proof of [54, Claims 4.4.2-4.4.5 in Lemma 4.2].

Claim 2: X Y ℓ . 0 ⊆ (r+1) Now we are ready to complete the proof. For each i 0, every member of i is a minimal ≥ C (v,Yi,ℓ,r)-span, so every member of i contains at most ℓr + 1 vertices by [54, Lemma 4.3]. C 1+ǫ′(r−1) Hence for each i 0, by Lemma 4.1, i α Yi . So for every nonnegative integer i, ≥ |C | ≤ | | 1+ǫ′(r−1) 1+ǫ′(r−1) 1+ǫ′(r−1) Yi+1 Yi = Zi +X V (L) β Yi + i (ℓr+1) β Yi +(ℓr+1)α Yi , | − | | | | | ≤ | | |C |· ≤ | | | | L∈Ci so 1+ǫ′(r−1) 1+ǫ′(r−1) Yi Yi +(β +(ℓr + 1)α) Yi η Yi . | +1|≤| | | | ≤ | | (2+ǫ′(r−1))i (1+ǫ′(r−1))i Therefore, for every nonnegative integer i, Yi η Y . | | ≤ | 0| By Claim 2,

′ (r+1)ℓ ′ (r+1)ℓ (r+1)ℓ (2+ǫ (r−1)) (1+ǫ (r−1)) (r+1) ǫ0 X Y ℓ η Y η Y , | 0|≤| (r+1) | ≤ | 0| ≤ | 0| since ǫ′ 1. Since V (G)= X Y and ǫ 1, ≤ 0 ∪ 0 0 ≥

(r+1)ℓ (r+1)ℓ V (G) = X + Y η(r+1) Y ǫ0 + Y (1 + η(r+1) ) Y ǫ0 = c Y ǫ0 . | | | 0| | 0| ≤ | 0| | 0| ≤ | 0| | 0| So Statement 3 holds.

Lemma 4.3 For any positive integers r, t, nonnegative integer ℓ, real numbers k > 0,k′ > 0, β 0, there exists a real number d = d(r,t,ℓ,k,k′, β) such that for any graph G and real numbers≥ ǫ 0 and 1 ǫ′ 0, either ≥ ≥ ≥ 1. E(G) >k V (G) 1+ǫ, | | | | 2. there exists a graph H with E(H) > k′ E(H) 1+ǫ′ such that some subgraph of G is isomorphic to a [2ℓ + 1]-subdivision| | of H,| |

3. there exists a (1,ℓr + 1)-model for an ℓ-shallow Kr,t-minor in G, or

4. there exist X,Z V (G) with Z X and Z > β V (G) X 1+ǫ′(r−1) such that ⊆ ⊆ | | | − | 1 1+ǫ− ǫ ′ (a) every vertex in X has degree at most d V (G) 0 in G, where ǫ0 = (1+ ǫ (r ℓ | | − 1))(r+1) , (b) for any distinct z, z′ Z, the distance in G[X] between z, z′ is at least ℓ +1, ∈

21 (c) for any z Z and any u X whose distance from z in G[X] is at most ℓ, ∈ ∈ NG(u) X r 1, and | − | ≤ − ≤ℓ−1 (d) NG(N [z]) X r 1 for every z Z. | G[X] − | ≤ − ∈ Proof. Let r, t be positive integers, ℓ be a nonnegative integer, k,k′ be positive real numbers, ′ and β be a nonnegative real number. Let α = α4.1(r, t, k ), where α4.1 is the number α ′ mentioned in Lemma 4.1. Let c = c4.2(r,t,ℓ,k , β), where c4.2 is the number c mentioned in Lemma 4.2. Define d =2kc. ′ ′ Let G be a graph. Let ǫ and ǫ be nonnegative real numbers with ǫ 1. Let ǫ0 = ℓ ≤ 1 ′ (r+1) 1+ǫ− ǫ (1+ǫ (r 1)) . Let Y0 be the set of all vertices of G of degree greater than d V (G) 0 . − | | 1 ǫ0 1+ǫ− ǫ If V (G) c Y0 , then since every vertex in Y0 has degree greater than d V (G) 0 and ǫ | 1, | ≤ | | | | 0 ≥

1+ǫ− 1 1+ǫ− 1 V (G) 1 d 1+ǫ 1+ǫ 2 E(G) >d V (G) ǫ0 Y d V (G) ǫ0 (| |) ǫ0 V (G) =2k V (G) , | | | | ·| 0| ≥ | | · c ≥ c | | | | so Statement 1 holds and we are done. Hence we may assume that V (G) > c Y ǫ0 and | | | 0| Statements 1-3 do not hold. So by Lemma 4.2, there exist X,Z V (G) Y0 with Z X and Z > β V (G) X 1+ǫ′(r−1) such that Statements 4(b)-4(d) hold.⊆ Since−X V (G) ⊆Y , | | | − | ⊆ − 0 Statement 4(a) holds. This proves the lemma.

Lemma 4.4 For any positive integers r, t, t′, nonnegative integer ℓ, and positive real numbers k,k′, there exist real numbers d = d(r, t, t′,ℓ,k,k′) and N = N(r, t, t′,ℓ,k,k′) and a positive integer r = r (r, ℓ) such that for any graph G and real numbers ǫ 0 and 1 ǫ′ 0, either 0 0 ≥ ≥ ≥ 1. E(G) >k V (G) 1+ǫ, | | | | 2. there exists a graph H with E(H) > k′ V (H) 1+ǫ′ such that some subgraph of G is | | | | isomorphic to a [2 max ℓ, 2ℓ 2 + 1]-subdivision of H, { − }

3. there exists a (1, max ℓ, 2ℓ 2 r + 1)-model for a max ℓ, 2ℓ 2 -shallow Kr,t-minor { − } { − } in G,

4. there exist X,Z,W V (G) with Z X, Z = t′, W V (G) X and W r 1 such that ⊆ ⊆ | | ⊆ − | | ≤ −

1+ǫ− 1 (a) every vertex in X has degree at most d V (G) ǫ0 in G, where ǫ = (1+(r | | 0 − 1)ǫ′)r0 , (b) for any distinct z, z′ Z, the distance in G[X] between z, z′ is at least max ℓ, 2ℓ 2 +1, and ∈ { − } ≤max{ℓ−1,0} (c) NG(N [z]) X = W for every z Z, G[X] − ∈ 5. (1 + ǫ 1 )(2 max ℓ, 2ℓ 2 + 1) > 1 , or − ǫ0 { − } 2 6. V (G) N. | | ≤

22 Proof. Let r, t, t′ be positive integers, ℓ be a nonnegative integer, and let k,k′ be positive real ′ ′ numbers. Let α = maxp∈[r] α4.1(p, t ,k ), where α4.1 is the number α mentioned in Lemma ′ 4.1. Define d = d4.3(r, t, max ℓ, 2ℓ 2 ,k,k ,rα), where d4.3 is the real number d mentioned { −′ } t′ ′ 2 4 max{ℓ,2ℓ−2}+2 in Lemma 4.3. Let α0 = α4.1(r, t, k ). Let γ = α . Define N =(α0γ + rt + γ) d . max{ℓ,2ℓ−2} Define r0 =(r + 1) . Let G be a graph. Let ǫ and ǫ′ be nonnegative real numbers with ǫ′ 1. We may assume that Statements 1-3 do not hold, for otherwise we are done. By Lemma≤ 4.3, there exist X,Z V (G) with Z X and Z > rα V (G) X 1+ǫ′(r−1) such that 0 ⊆ 0 ⊆ | 0| ·| − | 1 1+ǫ− ǫ ′ (i) every vertex in X has degree at most d V (G) 0 in G, where ǫ0 = (1+ ǫ (r max{ℓ,2ℓ−2} | | − 1))(r+1) =(1+ ǫ′(r 1))r0 , − ′ ′ (ii) for any distinct z, z Z0, the distance in G[X] between z, z is at least max ℓ, 2ℓ 2 + 1, ∈ { − } (iii) for every z Z and u X whose distance from z in G[X] is at most max ℓ, 2ℓ 2 , ∈ 0 ∈ { − } NG(u) X r 1, and | − | ≤ − ≤max{ℓ,2ℓ−2}−1 (iv) NG(N [z]) X r 1 for every z Z . | G[X] − | ≤ − ∈ 0 We assume that Z0 is maximal subject to the above properties. ≤max{ℓ−1,0} Claim 1: NG(N [z]) X r 1 for every z Z . | G[X] − | ≤ − ∈ 0 Proof of Claim 1: If ℓ 1 0, then max ℓ 1, 0 = ℓ 1 max ℓ, 2ℓ 2 1, so ≤max{ℓ−1,0} − ≥ ≤max{ℓ,2ℓ−2}−{ 1 − } − ≤ { − } − NG(NG[X] [z]) X NG(NG[X] [z]) X r 1 for every z Z0 by (iv). If | − |≤| ≤max{ℓ−1,0} −≤0 | ≤ − ≤∈max{ℓ−1,0} ℓ 1 < 0, then for every z Z , N [z]= N [z]= z , so NG(N [z]) − ∈ 0 G[X] G[X] { } | G[X] − X = NG(z) X r 1 by (iii).  | | − | ≤ − By Claim 1 and piegeonhole principle, there exist p [r 1] 0 and Z1 Z0 with 1 1+ǫ′(r−1) ≤∈max{−ℓ−1,0}∪{ } ⊆ Z Z > α V (G) X such that NG(N [z]) X = p for every | 1| ≥ r | 0| | − | | G[X] − | z Z1. ∈We first assume that p [r 1]. In particular, r 1 p 1 and α α (p, t′,k′). ∈ − − ≥ ≥ ≥ 4.1 Let Y = V (G) X. Let = G[N ≤max{ℓ−1,0}[z]] : z Z . By (ii), is a collection of − C { G[X] ∈ 1} C pairwise disjoint connected subgraphs of G Y of radius at most max ℓ 1, 0 . By (i), 1 ℓ (1+ǫ− −)ℓ { − } each member of has at most d V (G) ǫ0 vertices. Furthermore, each member of is C | | 1+ǫ′(r−1) C p-adherent to Y . Note that = Z1 >α Y . Since Statement 2 of this lemma does 1 |C| | | | ℓ | (1+ǫ− )ℓ not hold, by Lemma 4.1, there exists a (1,d V (G) ǫ0 , G[ y ]: y Y , )-model for a | | { { } ∈ } C ′ max ℓ 1, 0 -shallow Kp,t′ -minor in G. So there exist W Y with W = p and a subset of 1 { − ′ } ′ ℓ (1+ǫ− )ℓ ⊆ ′ | | C with = t and a (1,d V (G) ǫ0 , G[ y ]: y W , )-model for a max ℓ 1, 0 - C |C | | | { { } ∈ } C ′ ≤max{ℓ−1,{0} − } shallow Kp,t′ -minor in G. Let Z be the subset of Z such that = G[N [z]] : z 1 C { G[X] ∈ Z . Then Statement 4 holds. } ′ So we may assume that p =0. If Z1 t , then Statement 4 holds by choosing W = and ′ | | ≥ ′ ∅ ′ Z to be a subset of Z1 with size t . So we may assume that Z1 < t . Hence Z0 r Z1 < rt . 1+ǫ′(r−1) 1+ǫ′(r−1) | t′ | | | ≤ | | Since Z0 > rα V (G) X , V (G) X α = γ. | | | − | ≤max{ℓ,2ℓ|−2} − | ≤ Let X1 = X N [z]. By the maximality of Z0, for every x X1, Sz∈Z0 G[X] ≤max{ℓ,2ℓ−2}− ∈ NG(N [x]) X r. So for each x X , there exists a subgraph Lx of | G[X] − | ≥ ∈ 1 23 ≤max{ℓ,2ℓ−2} G[NG[X] [x]] consisting of a union of at most r paths of length at most max ℓ, 2ℓ 2 ≤max{ℓ,2ℓ−2} { − } from x in G[NG[X] [x]] such that Lx is r-adherent to Y . Note that each Lx contains at most r max ℓ, 2ℓ 2 + 1 vertices. Let X2 be a maximal subset of X1 such that the distance in· G[X{] between− } any two distinct elements in X is at least 2 max ℓ, 2ℓ 2 + 1. 2 · { − } Let 2 = Lx : x X2 . Note that members of 2 are pairwise disjoint r-adherent sub- graphsC of G{ Y on∈ at most} max ℓ, 2ℓ 2 r + 1 verticesC of radius at most max ℓ, 2ℓ 2 . − { − } {1+ǫ′(r−1) } Since Statements 2 and 3 of this lemma do not hold, by Lemma 4.1, 2 α0 Y = 1+ǫ′(r−1) |C | ≤ | | α0 V (G) X α0γ. | − | ≤ ≤2 max{ℓ,2ℓ−2} Let ℓ0 = max ℓ, 2ℓ 2 . By the maximality of X2, X1 N [x] = { − } ⊆ Sx∈X2 G[X] N ≤2ℓ0 [x]. By (i), Sx∈X2 G[X]

2ℓ0 1 1+ǫ− ǫ i X1 X2 X(d V (G) 0 ) | | ≤| |· | | i=0 1 2ℓ +1 (1+ǫ− )(2ℓ0+1) X d 0 V (G) ǫ0 ≤| 2|· | | 1 ℓ 2ℓ0+1 (1+ǫ− ǫ )(2 0+1) = 2 d V (G) 0 |C |· | | 1 2ℓ +1 (1+ǫ− )(2ℓ0+1) α γd 0 V (G) ǫ0 . ≤ 0 | |

≤max{ℓ,2ℓ−2} ≤ℓ0 Since X1 = X N [z]= X N [z], − Sz∈Z0 G[X] − Sz∈Z0 G[X]

≤ℓ0 X X1 + [ N [z] | | ≤| | | G[X] | z∈Z0 ǫ 1 ℓ ǫ 1 ℓ 2ℓ0+1 (1+ − ǫ )(2 0+1) ℓ0+1 (1+ − ǫ )( 0+1) α0γd V (G) 0 + Z0 d V (G) 0 ≤ | | 1 | | | | 2ℓ0+1 (1+ǫ− ǫ )(2ℓ0+1) (α0γ + Z0 )d V (G) 0 ≤ | | | | 1 ′ 2ℓ +1 (1+ǫ− )(2ℓ0+1) <(α γ + rt )d 0 V (G) ǫ0 . 0 | | Let ǫ = (1+ ǫ 1 )(2ℓ + 1). Hence X < (α γ + rt′)d2ℓ0+1 V (G) ǫ1 . 1 ǫ0 0 0 − 1 | | | | 1 We may assume that ǫ1 2 , for otherwise Statement 5 holds. Since ǫ0 1, 0 ǫ1 2 . Hence ≤ ≥ ≤ ≤

V (G) = X + V (G) X | | | | | − | ′ X + V (G) X 1+ǫ (r−1) ≤| | | − | (α γ + rt′)d2ℓ0+1 V (G) ǫ1 + γ ≤ 0 | | ′ 2ℓ0+1 ǫ1 (α0γ + rt + γ)d V (G) ≤ 1 | | √N V (G) 2 . ≤ | | Therefore, V (G) N, so Statement 6 holds. | | ≤ Recall that a set of homomorphisms is consistent if it satisfies (CON1) and (CON2) as stated in Section 1.1.2.

24 Lemma 4.5 For any positive integers r, t, t′, a, nonnegative integer ℓ, and positive real num- bers k,k′, there exist real numbers d = d(r, t, t′,a,ℓ,k,k′), N = N(r, t, t′,a,ℓ,k,k′) and a pos- itive integer r = r (r, ℓ) such that for any graph G and real numbers ǫ 0 and 1 ǫ′ 0, 0 0 ≥ ≥ ≥ either

1. E(G) >k V (G) 1+ǫ, | | | | 2. there exists a graph H with E(H) > k′ V (H) 1+ǫ′ such that some subgraph of G is isomorphic to a [2 max ℓ, 2ℓ | 2 +| 1]-subdivision| | of H, { − }

3. there exists a (1, max ℓ, 2ℓ 2 r + 1)-model for a max ℓ, 2ℓ 2 -shallow Kr,t-minor { − } { − } in G,

1 1 ′ r0 4. (1 + ǫ )(2 max ℓ, 2ℓ 2 + 1) > , where ǫ0 = (1+ ǫ (r 1)) , − ǫ0 { − } 2 − 5. V (G) N, or | | ≤ 6. there exist X,Z,W V (G) with Z X, Z = t′, W V (G) X with W r 1 such that ⊆ ⊆ | | ⊆ − | | ≤ −

1+ǫ− 1 (a) every vertex in X has degree at most d V (G) ǫ0 in G, | | (b) for any distinct z, z′ Z, the distance in G[X] between z, z′ is at least max ℓ, 2ℓ 2 +1, ∈ { − } ≤max{ℓ−1,0} (c) NG(N [z]) X = W for every z Z, and G[X] − ∈ (d) for any quasi-order Q = (U, ) with U a, legal Q-labelling fG of G, set  | | ≤ H of homomorphisms from an element in (L, fL):(L, fL) is a legal Q-labelled { graph with V (L) [ℓ] to the set of all induced subgraphs of (G, fG) satisfying ⊆ } (CON1) and (CON2), if there exist z0 Z and φ from some (L, fL) to ≤max{ℓ−1,0} ∈ ∈ H (G[NG[X] [z0] W ], fG N ≤max{ℓ−1,0}[z ]∪W ) with z0 φ(V (L)), then for every ∪ | G[X] 0 ∈ ≤max{ℓ−1,0} z Z, there exists φz from (L, fL) to (G[NG[X] [z] W ], fG N ≤max{ℓ−1,0}[z]∪W ) ∈ ∈ H ∪ | G[X] such that

i. z φz(V (L)), ∈ ii. for every y W and u V (L), y = φ(u) if and only if y = φz(u), ∈ ∈ iii. for every u V (L), φ(u)= z if and only if φz(u)= z, and ∈ 0 iv. there exists an isomorphism ιz from (G[φ(V (L)) W ], f ) to ∪ |φ(V (L))∪W (G[φz(V (L)) W ], f φ V L W ) such that ιz(φ(u)) = φz(u) for every u ∪ | z( ( ))∪ ∈ V (L), and ιz(y)= y for every y W . ∈ Proof. Let r, t, t′, a be positive integers, ℓ be a nonnegative integer, and let k,k′ be pos- ℓ 2 ℓ ℓ+(2) a 2 ·ℓ! 4 ℓ (2r−1)ℓ itive real numbers. Let ℓ1 = 2 , ℓ2 = ℓ1 2 a , and ℓ3 = ℓ2 ℓ 2 . Define ′ ′ ′· · ′ · · d = d4.4(r, t, t ℓ3,ℓ,k,k ) and N = N4.4(r, t, t ℓ3,ℓ,k,k ), where d4.4 and N4.4 are the real numbers d and N mentioned in Lemma 4.4, respectively. Define r0 = r4.4(r, ℓ), where r4.4 is the integer r0 mentioned in Lemma 4.4.

25 Let G be a graph. Let ǫ and ǫ′ be nonnegative real numbers with ǫ′ 1. Let ǫ = ≤ 0 (1+ǫ′(r 1))r0 . We may assume that Statements 1-5 do not hold, for otherwise we are done. By Lemma− 4.4, there exist X,Z , W V (G) with Z X, Z = t′ℓ , W V (G) X and 0 ⊆ 0 ⊆ | 0| 3 ⊆ − W r 1 such that | | ≤ − 1+ǫ− 1 • every vertex in X has degree at most d V (G) ǫ0 in G, | | • for any distinct z, z′ Z , the distance in G[X] between z, z′ is at least max ℓ, 2ℓ ∈ 0 { − 2 + 1, and } ≤max{ℓ−1,0} • NG(N [z]) X = W for every z Z . G[X] − ∈ 0

Let 1 be the set of all graphs whose vertex-sets are contained in [ℓ]. So 1 ℓ1. Let be the setF of all isomorphism classes of quasi-orders whose underlying set have|F | size ≤ at mostQ a+2(a) a2 a. Note that 2 2 = 2 . Let 2 = (L, fL): L 1, (L, fL) is a Q-labelled graph |Q| ≤ F2ℓ·ℓ! { ′ ∈F for some Q . So 2 1 a ℓ2. Let = φ : φ is a homomorphism from ∈ Q} |F |≤|F |·|Q|· ′ ≤ H { an element (L, fL) in 2 to an element (L , fL′ ) in 2 such that there exists an isomorphism ′ F F ι from (L , fL′ ) to an induced subgraph of (G, fG) such that ι φ . Since every graph ◦ ∈ H} in contains at most ℓ vertices, ′ ℓ2 ℓℓ. F2 |H | ≤ 2 · Denote W by v1, v2, ..., v|W | . For each z Z0, let Sz be the set of all tuples ((L, fL), ′ { } ∈ (L , fL′ ),φ,A0, A1, A2, ..., A|W |,C1,C2, ..., C|W |) such that

′ • (L, fL), (L , fL′ ) , ∈F2 ′ ′ • φ is a homomorphism from (L, fL) to (L , fL′ ), and ∈ H ′ ≤max{ℓ−1,0} • there exists an isomorphism ι from (L , fL′ ) to an induced subgraph of (G[N [z] G[X] ∪ W ], fG N ≤max{ℓ−1,0}[z]∪W ) containing z such that | G[X]

– for each j [ W ] 0 , Aj = u V (L) [ℓ]: ι(φ(u)) = vj , where v = z, and ∈ | | ∪{ } { ∈ ⊆ } 0 – for each j [ W ], Cj = u V (L) [ℓ]: ι(φ(u))vj E(G) . ∈ | | { ∈ ⊆ ∈ }

Note that the definition of A0, A1, ..., A|W |,C1, ..., C|W | depends on the choice of ι, but each ℓ Aj or Cj is a subset of [ℓ], so there are at most 2 possibilities for Aj or Cj for each fixed ′ ℓ 2|W |+1 2 2 ℓ (2r−1)ℓ j [ W ] 0 . Hence there are at most 2 2 (2 ) ℓ2 ℓ2ℓ 2 = ℓ3 ∈ | | ∪{ } |F |·|F |·|H |· ≤ · · 1 ′ possibilities for the sets Sz among all z Z0. So there exists Z Z0 with Z Z0 t ∈ ⊆ | | ≥ ℓ3 | | ≥ such that for any z1, z2 Z, Sz1 = Sz2 . Then Statement 6 holds, since satisfies (CON1) and (CON2). ∈ H

Lemma 4.6 For any positive integers r, t, c, m, p, there exists a positive integer s = s(r, t, c, m, p) such that the following holds. Let G be a bipartite graph with a bipartition A, B such that every edge of G is colored with one element in [c]. Assume that there exists{ no} subgraph of G isomorphic to Kr,t such that the part consisting of t vertices is a subset of A. If A s, then there exists a subset A′ of A with A′ m such that for every subset T of | | ≥ ′ | | ≥ B with T p, there exists MT A with MT m such that for every v T , either there | | ≤ ⊆ | | ≥ ′ ∈ exists cv [c] such that v is adjacent in G to all vertices in A by using edges with color cv, ∈ or v is non-adjacent in G to all vertices in MT .

26 Proof. Let r, t, c, m, p be positive integers. Let s0 = t. For every positive integer i, let si = mpcsi−1. Define s = sr. We shall prove this lemma by induction on r. Let G be a graph stated in this lemma. We may assume that there exists a subset T0 of B with T0 p such that for every subset S of A with S = m, there exists an edge | | ≤ | | ′ eT0,S of G between T0 and S, for otherwise we are done by choosing A = A. Since there |A| are m  subsets of A with size m, and for each edge e of G incident with T0, there are at |A|−1 most m−1  subsets S of A with S = m such that eT0,S = e, we know that there are at |A| |A|−1 |A| | | ∗ least m / m−1  = m pcsr−1 T0 csr−1 edges incident with T0. So there exist v T0, ≥ ≥| | ∗ ∈ cv∗ [c] and A A with A = sr such that v is adjacent to all vertices in A by using ∈ 1 ⊆ | 1| −1 1 edges with color cv∗ . Since sr−1 s0 t, there exists a K1,t subgraph whose part consisting of t vertices is contained in A, so≥r ≥2, and the lemma holds when r = 1. ′ ∗ ≥ ′ Let G = G[A (B v )]. Note that G has no Kr ,t subgraph whose part consisting 1 ∪ −{ } −1 of t vertices is contained in A1. Since A1 sr−1, by the induction hypothesis, there exists ′ ′ | | ≥ ∗ a subset A of A1 with A1 m such that for every subset T of B v with T p, ′ | | ≥ −{ } | | ≤ there exists MT A with MT m such that for every v T , either there exists cv [c] ⊆ | ′ | ≥ ′ ∈ ∈ such that v is adjacent in G G to all vertices in A by using edges with color cv, or v is ′ ⊆ non-adjacent in G (and hence in G) to all vertices in MT . For every subset T of B with ∗ ∗ ∗ T p, if v T , then T B v , so MT is desired; if v T , then let MT = MT −{v∗}, | | ≤ 6∈ ∗⊆ −{ } ∈ ′ and MT is desired since v is adjacent to all vertices in A A by using edges with color 1 ⊇ cv∗ . This proves the lemma.

Lemma 4.7 For any positive integers r, t, t′, a, m, h, nonnegative integer ℓ, and positive real numbers k,k′, there exist positive real numbers d = d(r, t, t′,a,m,h,ℓ,k,k′), N = N(r, t, t′, a, ′ ′ ′ m,h,ℓ,k,k ), b = b(r, t, t ,a,m,h,ℓ,k,k ),r0 = r0(r, ℓ),r1 = r1(r, ℓ) such that if G is a graph and ǫ, ǫ′ are nonnegative real numbers with ǫ 1 and ǫ′ r such that ≤ 8 max{ℓ+1,2ℓ}+4 ≤ 1 1. for every induced subgraph L of G, E(L) k V (L) 1+ǫ, | | ≤ | | 2. for every graph L for which some subgraph of G is isomorphic to a [2 max ℓ+1, 2ℓ +1]- ′ { } subdivision of L, E(L) k′ V (L) 1+ǫ , and | | ≤ | |

3. there exists no (1, max ℓ +1, 2ℓ r +1)-model for a max ℓ +1, 2ℓ -shallow Kr,t-minor { } { } in G,

then for any quasi-order Q = (U, ) with U a and legal Q-labelling f of G, there exist  | | ≤ an ordering σ of G and a sequence (Si : i [ V (G) ]) such that for every i [ V (G) ], ∈ | | ∈ | |

1. Si is a subset of v V (G): σ(v) i +1 with size at most r 1, and { ∈ ≥ } −

2. if i [ V (G) N], then the max ℓ 1, 0 -basin Bi with respect to σ and (Sj : j ∈ | | − { − } ∈ [ V (G) ]) at i satisfies the following: | | 1 (1+ǫ− ǫ )ℓ ′ r0 (a) Bi b V (G) 0 , where ǫ0 =(1+ ǫ (r 1)) . | | ≤ | | − 1 1+ǫ− ǫ (b) Every vertex in Bi has degree at most d V (G) 0 in Gσ, i. | | ≥

27 ∗ ′ (c) There exists a set Z = z1, z2, ..., z|Z∗| of at least t vertices in v V (G): σ(v) i +1 . { } { ∈ ≥ } ∗ ′ ′ ′ (d) There exist Z pairwise disjoint subsets Z1,Z2, ..., Z|Z∗| of v V (G): σ(v) | | ≤min{ℓ,1} { ∈ ≥ i +1 Si disjoint from N [Bi] such that for any set of homomorphisms } − Gσ,≥i H from an element in (L, fL):(L, fL) is a legal Q-labelled graph with V (L) [ℓ+1] { ⊆ } to the set of all induced subgraphs of (Gσ, i, f V G ) satisfying (CON1) and ≥ | ( σ,≥i) (CON2), if (L, fL) is a legal Q-labelled graph such that there exists φ from −1 ∈ H (L, fL) to (Gσ, i[Bi Si], f B S ) with σ (i) φ(V (L)), then ≥ ∪ | i∪ i ∈ ∗ ′ i. for every j [ Z ], there exists φj from (L, fL) to (Gσ,≥i[Z Si], f Z′ ∪S ) ∈ | | ∈ H j ∪ | j i such that

• zj φj(V (L)), ∈ • for every y Si and u V (L), y = φ(u) if and only if y = φj(u), ∈ ∈ −1 • for every u V (L), φ(u)= σ (i) if and only if φj(u)= zj, and ∈ • there exists an isomorphism ιj from (Gσ, i[φ(V (L)) Si], f φ V L S ) to ≥ ∪ | ( ( ))∪ i (Gσ, i[φj(V (L)) Si], f φ V L S ) such that ιj(φ(u)) = φj(u) for every ≥ ∪ | j( ( ))∪ i u V (L), and ιj(y)= y for every y Si. ∈ ∈ ∗ ii. for any I [i 1] with I h, there exists MI Z with MI m such ⊆ − −1 | | ≤ ⊆ | | ≥ that for every v σ (I) and zj MI , u V (L): vφ(u) E(G) u ∈ ∈ { ∈ ∈ }⊇{ ∈ V (L): vφj(u) E(G) . ∈ } ∗ ∗ (e) There exist Z sets Z ,Z , ..., Z ∗ such that for every j [ Z ], | | 1 2 |Z | ∈ | | ≤max{ℓ−1,0} ′ • N [zj] Zj Z , and Gσ,≥i−Si ⊆ ⊆ j ′ • if ℓ 1, then NG [Zj] Z Si. ≥ σ,≥i ⊆ j ∪ Proof. Let r, t, t′, a, m, h be positive integers, ℓ be a nonnegative integer, and let k,k′ be positive real numbers. Let be the collection of Q-labelled graphs with vertex-set contained in [ℓ + 1], among all isomorphismL classes of quasi-orders Q with ground set size at most a. Note that is finite and only depends on ℓ and a. So there exists an integer ℓ∗ such that there|L| are at most ℓ∗ homomorphisms from a member of to a member of . Let ∗ ′ L L s = s4.6(r, t, ℓ (ℓ + 1), m + t +1, h), where s4.6 is the integer s mentioned in Lemma |L| ′ ′ 4.6. Define d = d4.5(r, t, s, a, ℓ +1,k,k ), N = N4.5(r, t, s, a, ℓ +1,k,k ), r0 = r4.5(r, ℓ + 1), where d4.5, N4.5,r4.5 are the numbers d,N,r0 mentioned in Lemma 4.5, respectively. Define 1 ( 1 ) r0 −1 1− 1 ℓ 8 max{ℓ+1,2ℓ}+4 b = d and r1 = r . ′ ′ r0 Let G be a graph and ǫ, ǫ be real numbers as stated in the lemma. Let ǫ0 = (1+ǫ (r 1)) 1 ′ 1 − and ǫ = (1+ ǫ )(2 max ℓ +1, 2ℓ + 1). Since ǫ r , ǫ 1 , so ǫ 1 ǫ0 1 0 1− 1 − { } ≤ ≤ 8 max{ℓ+1,2ℓ}+4 ≤ 1 1 1 ( 8 max{ℓ+1,2ℓ}+4 + ǫ)(2 max ℓ +1, 2ℓ + 1). Since ǫ 8 max{ℓ+1,2ℓ}+4 , ǫ1 2 . Let Q be a quasi-order{ and f a} legal Q-labelling≤ as stated in the lemma.≤ Now we define the ordering σ and the sequence (Sj : j [ V (G) ]) and show that they ∈ | | satisfy the conclusions of this lemma. To define σ, it suffices to define its inverse function from [ V (G) ] to V (G). | | −1 Let i [ V (G) ]. Assume that σ (j) and Sj are defined for every j [i 1]. For each ∈ | | ∈ − j [i 1], we denote the vertex v with σ(v) = j by vj. Let Gi = G vj : j [i 1] . ∈ − −{ ∈ − } 28 −1 −1 −1 So Gσ,≥i = Gi no matter how we further define σ (i), σ (i + 1), ..., σ ( V (G) ). If i −1 | | ≥ V (G) N + 1, then define σ (i) to be an arbitrary vertex in Gi and define Si = . If | | − 1 ∅ i [ V (G) N], then V (Gi) N + 1, and since ǫ and Gi is an induced subgraph of ∈ | | − | | ≥ 1 ≤ 2 G, by applying Lemma 4.5 to Gi, we know that there exist X,Z,W V (Gi) with Z X, ⊆ ⊆ Z = s, W V (Gi) X and W r 1 such that | | ⊆ − | | ≤ − 1 1+ǫ− ǫ (i) every vertex in X has degree at most d V (G) 0 in Gi, | | ′ ′ (ii) for any distinct z, z Z, the distance in Gi[X] between z, z is at least max ℓ+1, 2ℓ + ∈ { } 1,

≤ℓ (iii) NG (N [z]) X = W for every z Z, and i Gi[X] − ∈

(iv) for any set of homomorphisms from an element in (L, fL):(L, fL) is a legal Q- H { labelled graph with V (L) [ℓ + 1] to the set of all induced subgraphs of (Gi, f V G ) ⊆ } | ( i) satisfying (CON1) and (CON2), if there exist z0 Z and φ from (L, fL) to ≤ℓ ∈ ∈ H (Gi[N [z ] W ], f ≤ℓ ) with z φ(V (L)), then for every z Z, there Gi[X] 0 N [z0]∪W 0 ∪ | Gi[X] ∈ ∈ ≤ℓ exists φ L,f ,z, from (L, fL) to (Gi[N [z] W ], f ≤ℓ ) such that ( L) H Gi[X] N [z]∪W ∈ H ∪ | Gi[X] – z φ (V (L)), ∈ (L,fL),z,H – for every y W and u V (L), y = φ(u) if and only if y = φ L,f ,z, (u), ∈ ∈ ( L) H – for every u V (L), φ(u)= z if and only if φ (u)= z, and ∈ 0 (L,fL),z,H – there exists an isomorphism ι from (Gi[φ(V (L)) W ], f ) to (L,fL),z,H ∪ |φ(V (L))∪W (Gi[φ(L,f ),z,H(V (L)) W ], f φ (V (L))∪W ) such that ι(L,f ),z,H(φ(u)) = L ∪ | (L,fL),z,H L φ L,f ,z, (u) for every u V (L), and ι L,f ,z, (y)= y for every y W . ( L) H ∈ ( L) H ∈ Note that since every stated in (iv) satisfies (CON1) and (CON2), there are at most ℓ∗ H different ’s stated in (iv). For every z Z, let i,z = ((L, fL), ):(L, fL) ,φ L,f ,z, H ∈ L { H ∈L ( L) H is defined for some stated in (iv) . Let Fi be the bipartite graph with V (Fi) = Z −1 H −1 ′ } ′ −1 ′ ∪ σ ([i 1]), and E(Fi) = zσ (i ): z Z, i [i 1], σ (i ) is adjacent in G to some − { ∈ ∈ − −1 ′ vertex in φ(L,f ),z,H(V (L)) W . For each edge zσ (i ) of Fi, color it with S((L,fL),H)∈Li,z L − } −1 ′ ((L, fL), ,u) : ((L, fL), ) i,z,u V (L), σ (i )φ (u) E(G) . So we use at { H H ∈ L ∈ (L,fL),z,H ∈ } most ℓ∗(ℓ + 1) colors. Since there exists no (1, max ℓ +1, 2ℓ r +1)-model for a max ℓ + |L| { } { 1, 2ℓ -shallow Kr,t-minor in G, Fi has no Kr,t subgraph whose part consisting of t vertices is contained} Z. Since Z s, by Lemma 4.6, there exists Z′ Z with Z′ m + t′ + 1 such | | ≥ ⊆ | | ≥ that

′ ′ ′ ′ (v) for every subset I [i 1] with I h, there exists MI Z with MI m+t +1 such ′ ⊆ − −1| ′| ≤ ⊆ | |′ ≥ that for every i I, either σ (i ) is adjacent in Fi to all vertices in Z using the same −1 ′ ∈ ′ color, or σ (i ) is non-adjacent in Fi to all vertices in MI . (Note that the latter implies −1 ′ that σ (i ) is not adjacent in G to any vertex in φ(L,f ),z,H(V (L)) W .) S((L,fL),H)∈Li,z L − ′ −1 If i [ V (G) N], then let vi be a vertex in Z , and define σ (i)= vi and Si = W . ∈ | | − ′ When i V (G) N + 1, Si = ; when i [ V (G) N], vi Z X, so Si = W ≥ | | − ∅ ∈ | | − ∈ ⊆ ⊆ V (Gi) X v V (G): σ(v) i +1 and Si = W r 1. So Conclusion 1 of this lemma− holds.⊆ { ∈ ≥ } | | | | ≤ −

29 Now we show that Conclusion 2 of this lemma holds for i. So we may assume i [ V (G) N]. Let p = max ℓ 1, 0 . ∈ | | − { − } Claim 1: For every z Z′, N ≤p [z]= N ≤p [z]. Gi[X] Gi−Si ∈ ≤p ≤p Proof of Claim 1: Suppose to the contrary that N [z] = N [z]. Since Gi Si Gi[X] Gi−Si ≤p ≤p ≤p 6 ≤p − ⊇ Gi[X], N [z] N [z]. So there exists u N [z] N [z]. Hence there exists Gi−Si ⊃ Gi[X] ∈ Gi−Si − Gi[X] a path P in Gi Si of length at most p from z to u. We may assume that u is chosen − ≤p so that P is as short as possible. So P u is a path in Gi[X] and u N [z] X. − ∈ Gi−Si − Since u X, u = z, so V (P ) u = . Note that V (P ) u N ≤p [z]. Since 6∈ 6 − { } 6 ∅ − { } ⊆ Gi[X] u N (V (P ) u ) N (N ≤p [z]), we have u X W by (iii). Since u X, Gi Gi Gi[X] ∈ − { }≤p ⊆ ∈ ∪ 6∈ u W = Si, so u N [z], a contradiction.  ∈ 6∈ Gi−Si Let Bi be the max ℓ 1, 0 -basin with respect to σ and (Sj : j [ V (G) ]) at i. Note ≤p { − } ′ ≤p ∈ | | that Bi = N [vi]. Since vi Z , by Claim 1, Bi = N [vi]. In particular, Bi X. Gi−Si ∈ Gi[X] ⊆ Hence Conclusion 2(b) follows immediately from (i). 1 (1+ǫ− ǫ )ℓ If p = 0, then Bi = 1 b V (G) 0 ; if p 1, then p = ℓ 1, and since Bi = | | ≤ | | 1 ≥ 1 − 1 ≤p p 1+ǫ− ǫ j 1+ǫ− ǫ p+1 1+ǫ− ǫ ℓ N [vi], by (i), Bi (d V (G) 0 ) (d V (G) 0 ) (d V (G) 0 ) = Gi[X] | | ≤ Pj=0 | | ≤ | | ≤ | | (1+ǫ− 1 )ℓ b V (G) ǫ0 . So Conclusion 2(a) holds. | | ∗ ′ ∗ ′ ∗ Let Z = Z vi . So Z m + t . Let z , z , ..., z Z∗ be the vertices in Z . For −{ } | | ≥ 1 2 | | every j [ Z∗ ], let Z′ = N ≤ℓ [z ] and Z = N ≤p [z ]. By Claim 1, for each j [ Z∗ ], j Gi[X] j j Gi[X] j ≤p ∈ | | ′ ∈ |∗ | NGi−Si [zj]= Zj Zj v V (G): σ(v) i +1 Si. Furthermore, for each j [ Z ], if ⊆ ⊆{ ∈ ≥≤p } − ≤p+1 ≤p ∈ | | ℓ 1, then ℓ = p +1, so NG [Zj] = NG [N [zj]] N [zj] (NG [N [zj]] X) i i Gi[X] Gi[X] i Gi[X] ≥≤ℓ ′ ⊆ ∪ − ⊆ N [zj] Si = Z Si by (iii). So Conclusions 2(c) and 2(e) hold. Gi[X] ∪ j ∪ ′ ≤min{ℓ,1} ′ ′ When ℓ = 0, each Z is disjoint from B = N [B ], and Z , ..., Z ′ are pairwise j i Gσ,≥i i 1 t disjoint; when ℓ 1, ℓ+1 2ℓ, so by (ii), each Z′ is disjoint from N [B ]= N ≤min{ℓ,1}[B ], j Gσ,≥i i Gσ,≥i i ′ ′ ≥ ≤ and Z1, ..., Zt′ are pairwise disjoint. So Conclusion 2(d)(i) immediately follows from (iv). ′ ∗ ′ For every I [i 1] with I h, let MI = MI Z , so MI MI 1 m + ′ −1∈ − | | ≤ ∩ | |≥| | − ≥ t . For v σ (I) and zj MI , if u V (L) such that vφ (u) E(G), then ∈ ∈ ∈ (L,fL),H,zj ∈ either φ(L,fL),H,zj (u) W = Si (so φ(u) = φ(L,fL),H,zj (u) and vφ(u) E(G)), or φj(u) ∈ ∈ ′ ∈ φ(L,f ),z,H(V (L)) W , so by (v), v is adjacent in Fi to all vertices in Z by S((L,fL),H)∈Li,z L − using edges with the same color, and hence vφ(u) E(G) by the definition of the edge- ∈ coloring of Fi. Hence Conclusion 2(d)(ii) holds. This proves the lemma.

5 Homomorphism counts and shallow minors

Before considering homomorphisms, we first prove Lemma 5.3 that will be convenient for cleaning up structures. We need the following well-known bipartite Ramsey theorem.

Lemma 5.1 For any positive integers a, b, c, there exists a positive integer R = R(a, b, c) such that any c-coloring of the edges of KR,R results in a monochromatic Ka,b. Lemma 5.2 For any positive integers r, h, w, there exists a positive integer s = s(r, h, w) such that the following holds. Let G be a graph with no Kr,r-subgraph. For every i [2], ∈ 30 let i be a collection of pairwise disjoint subsets of V (G) with each member having size at C ′ most h. If i s for every i [2], then for every i [2], there exists a subset i of i with ′ = w such|C | that ≥ every member∈ of ′ is disjoint and∈ non-adjacent in G to everyC memberC of |Ci| C1 ′ . C2 Proof. Let r, h, w be positive integers. Let m = max r, h+1,w . Let s = R (m, m, h2+2), { } 5.1 where R5.1 is the integer R mentioned in Lemma 5.1. Let G, and be as stated in this lemma. By taking subsets, we may assume that C1 C2 = = s. Denote the members of by A , A , ..., As, and denote the members of by |C1| |C2| C1 1 2 C2 B , B , ..., Bs. For each i [s], we denote Ai = vi,j : j [ Ai ] and Bi = ui,j : j [ Bi ] . 1 2 ∈ { ∈ | | } { ∈ | | } Let H be a graph isomorphic to Ks,s with a bipartition A, B , where A = ai : i [s] and { } { ∈ } B = bi : i [s] . For every i [s] and j [s], define f(aibj) to be { ∈ } ∈ ∈ • 0, if Ai is disjoint and non-adjacent in G to Bj,

• 1, if Ai Bj = , ∩ 6 ∅

• (x, y), if Ai Bj = , vi,x is adjacent to uj,y in G, and subject to this, the lexicographic order of (x,∩ y) is minimal.∅

2 So f is an (h + 2)-coloring of E(H). By Lemma 5.1, there exists a monochromatic Km,m, say with color c. If c = 1, then some member of 1 intersects at least m h + 1 members of 2; but it is impossible since every member ofC has size at most h and≥ members of areC pairwise C1 C2 disjoint, a contradiction. If c = (x, y) for some x [h] and y [h], then there exists a ∈ ∈ Km,m-subgraph of G consisting of the x-th vertex of each of some m members of and the C1 y-th vertex of each of some m members of 2, contradicting that G has no Kr,r-subgraph. C ′ ′ So c = 0. Hence for each i [2], there exists i i with i = m w such that every member of ′ is disjoint and∈ non-adjacent in GCto⊆ every C member|C | of ′ .≥ C1 C2 Lemma 5.3 For any positive integers r,h,w,p, there exists a positive integer s = s(r,h,w,p) such that the following holds. Let G be a graph with no Kr,r-subgraph. For every i [p], ∈ let i be a collection of pairwise disjoint subsets of V (G) with each member having size at C ′ most h. If i s for every i [p], then for every i [p], there exists a subset i of i with ′ |C | ≥ ∈ ∈ ′ C C i = w such that for any i1, i2 with 1 i1 < i2 p, every member of i1 is disjoint and non-adjacent|C | in G to every member of ≤′ . ≤ C Ci2 Proof. Let r,h,w,p be positive integers. Let f(1, 1) = w. For any positive integers x and y, let f(x +1, 1) = f(x, x) and let f(x +1,y +1) = s5.2(r, h, f(x +1,y)). Define s = f(p,p). We shall prove this lemma by induction on p. Since f(1, 1) = w, the case p = 1 holds. So we may assume that p 2 and the lemma holds when p is smaller. ≥ Let G, , , ... p be as stated in this lemma. Let , = . By induction, for every C1 C2 C C1 1 C1 positive integer x with 2 x p, applying Lemma 5.2 with taking ( , )=( ,x , x), ≤ ≤ C1 C2 C1 −1 C we know that there exist a subset ,x of ,x of size f(p,p x + 1) and a subset x of x C1 C1 −1 − D C with x = f(p,p x + 1) f(p, 1) = f(p 1,p 1) such that every member of ,x is |D | − ≥ − − C1 disjoint and non-adjacent in G to every member of x. So every member of ,p is disjoint D C1 and non-adjacent to every member of x for every 2 x p. By the induction hypothesis, D ≤ ≤ 31 ′ ′ for every x with 2 x p, since x f(p 1,p 1), there exists x x with x = w ≤ ≤ |D | ≥ − − ′ C ⊆D |C | such that for any i1, i2 with 2 i1 < i2 p, every member of i1 is disjoint and non-adjacent ′ ≤ ≤ C ′ in G to every member of . Hence the lemma follows by taking = ,p. Ci2 C1 C1 Now we are ready to consider homomorphisms.

Lemma 5.4 For any positive integers r, t, w, h, a and positive real numbers k,k′, there exist ′ positive real numbers c = c(r,t,w,h,a,k,k ), r0 = r0(r, h) and r1 = r1(r, h) such that if G is a graph and ǫ, ǫ′ are nonnegative real numbers with ǫ 1 and ǫ′ r such that ≤ 16h+4 ≤ 1 1. for every induced subgraph L of G, E(L) k V (L) 1+ǫ, | | ≤ | | 2. for every graph L for which some subgraph of G is isomorphic to a [4h + 1]-subdivision of L, E(L) k′ V (L) 1+ǫ′ , and | | ≤ | |

3. there exists no (1, 2hr + 1)-model for a 2h-shallow Kr,t-minor in G, then for any quasi-order Q = (U, ) with U a, legal Q-labelled graph (H, fH ) on h  | | ≤ vertices, legal Q-labelling fG of G, and consistent set of homomorphisms from (H, fH ) to H the set of all induced subgraphs of (G, fG), there exists a nonnegative integer q such that the following hold.

q+(1+ǫ− 1 )|V (H)|2 1. The number of members of with codomain V (G) is at most c V (G) ǫ0 , H | | where ǫ =(1+ ǫ′(r 1))r0 . 0 −

2. There exists an independent collection of separations of (H, fH ) with = q such that for every (X,Y ) , L |L| ∈L (a) every vertex in X Y is adjacent in H to a vertex in X Y , and ∩ − (b) if every member of is injective, then H[X Y ] is connected. H − ′ 3. There exists an induced subgraph (H , fH′ ) of (G, fG) such that

′ (a) there exists an onto homomorphism φH from (H, fH ) to (H , fH′ ) such that ∈ H • φH (A B) φH (B)= for every (A, B) , − ∩ ∅′ ∈L • (NH′ [φH (A B)],V (H ) φH (A B)):(A, B) , denoted by H′ , is an { − − − ′ ∈ L} L independent collection of separations of (H , fH′ ), and

• H′ = , |L | |L| ′ (b) (H , fH′ ) w H′ is isomorphic to an induced subgraph of (G, fG). ∧ L ′′ ′ 4. There exists a spanning legal Q-labelled subgraph (H , fH′′ ) of (H , fH′ ) such that

′′ (a) φH is an onto homomorphism from (H, fH ) to (H , fH′′ ) such that (NH′′ [φH (A ′′ { − B)],V (H ) φH (A B)) : (A, B) , denoted by H′′ , is an independent − − ′′ ∈ L} L collection of separations of (H , fH′′ ) of order at most r 1 with H′′ = , and − |L | |L| ′′ (b) (H , f H′′ ) w H′′ is isomorphic to a legal Q-labelled subgraph of (G, fG). | ∧ L

32 Proof. Let r, t, w, h, a be positive integers, and let k,k′ be positive real numbers. We define the following. • Define r0 = r4.7(r, h), where r4.7 is the real number r0 mentioned in Lemma 4.7. • ′ ′ Define r1 = r4.7(r, h), where r4.7 is the real number r1 mentioned in Lemma 4.7. • Let w1 = max1≤i≤h s5.3(r + t, h, w, i), where s5.3 is the integer s mentioned in Lemma 5.3.

• Let ℓ∗ be the number of isomorphism classes of Q-labelled graphs with vertex-set contained in [h], among all isomorphism classes of quasi-orders Q with ground set size at most a.

′ ∗ • Let t = rh + w1ℓ . • ′ ′ ′ Let N1 = N4.7(r, t, t , a, t ,h,h,k,k ) , where N4.7 is the real number N mentioned in Lemma⌈ 4.7. ⌉

• ′ ′ ′ Let b1 = b4.7(r, t, t , a, t ,h,h,k,k ), where b4.7 is the real number b mentioned in Lemma 4.7.

• Define c = c (r 1, h, N ) bh, where c is the number c mentioned in Lemma 2.1. 2.1 − 1 · 1 2.1 ′ Let G, ǫ, ǫ , Q = (U, ), (H, fH ), fG, and be as stated in the lemma. Let ǫ =  H 0 (1 + ǫ′(r 1))r0 . Note that ǫ 1, so 1+ ǫ 1 0. 0 ǫ0 Since−h 1, max h +1, 2h≥=2h. By Lemma− ≥ 4.7, there exist an ordering σ of G and a ≥ { } sequence (Si : i [ V (G) ]) such that for every i [ V (G) ], ∈ | | ∈ | |

(i) Si is a subset of v V (G): σ(v) i +1 with size at most r 1, and { ∈ ≥ } −

(ii) if i [ V (G) N1], then the p-basin Bi with respect to σ and (Sj : j [ V (G) ]) at i, where∈ |p = max| − h 1, 0 = h 1, satisfies the following: ∈ | | { − } − ǫ 1 (1+ − ǫ )h (iia) Bi b V (G) 0 . | | ≤ 1| | ∗ (iib) There exists a subset Z = zi,1, zi,2, ..., zi,|Z∗| of v V (G): σ(v) i +1 with i { i } { ∈ ≥ } Z∗ t′. | i | ≥ ∗ ′ ′ ′ (iic) There exist Zi pairwise disjoint subsets Zi,1,Zi,2, ..., Zi,|Z∗| of v V (G): σ(v) | | i { ∈ ≥ i +1 Si disjoint from NG [Bi]. } − σ,≥i ′ (iid) For any set of homomorphisms from an element in (L, fL):(L, fL) is a legal Q-labelledH graph with V (L) [h] to the set of all{ induced subgraphs of ⊆ } (Gσ,≥i, fG V (Gσ,≥i)) satisfying (CON1) and (CON2), if (L, fL) is a legal Q-labelled | ′ graph such that there exists φ from (L, fL) to(Gσ, i[Bi Si], fG B S ) with ∈ H ≥ ∪ | i∪ i σ−1(i) φ(V (L)), then ∈ ∗ ′ ′ ∗ for every j [ Z ], there exists φi,j from (L, fL) to (Gσ, i[Z ∈ | i | ∈ H ≥ i,j ∪ Si], fG Z′ ∪S ) such that | i,j i · zi,j φi,j(V (L)), ∈ 33 · for every y Si and u V (L), y = φ(u) if and only if y = φi,j(u), ∈ ∈ −1 · for every u V (L), φ(u)= σ (i) if and only if φi,j(u)= zi,j, and ∈ · there exists an isomorphism ιi,j from (Gσ, i[φ(V (L)) Si], f φ V L S ) to ≥ ∪ | ( ( ))∪ i (Gσ, i[φi,j(V (L)) Si], f ) such that ιi,j(φ(u)) = φi,j(u) for ≥ ∪ |φi,j (V (L))∪Si every u V (L), and ιi,j(y)= y for every y Si. ∈ ∈ ∗ ∗ ′ for any I [i 1] with I h, there exists Mi,I Zi with Mi,I t such ⊆ − −1 | | ≤ ⊆ | | ≥ that for every v σ (I) and zi,j Mi,I , u V (L): vφ(u) E(G) u ∈ ∈ { ∈ ∈ }⊇{ ∈ V (L): vφi,j(u) E(G) . ∈ } ∗ ∗ ≤h−1 (iie) There exist Z sets Z ,Z , ..., Z ∗ such that for every j [ Z ], N [z ] i i,1 i,2 i,|Zi | i Gσ,≥i−Si i,j ′ | | ′ ∈ | | Zi,j Z and NG [Zi,j] Z Si. ⊆ ⊆ i,j σ,≥i ⊆ i,j ∪ So by (i), (iia) and Lemma 2.1, there exists an integer q such that

(iii) The number of members of with codomain V (G) is at most c2.1(r 1, h, N1) 1 1 (1+ǫ− )h h q H q+(1+ǫ− )h2 − · (b V (G) ǫ0 ) V (G) c V (G) ǫ0 , and 1| | ·| | ≤ | |

(iv) there exist a homomorphism φ from (H, fH )to(G, fG), an independent collection 0 ∈ H of separations of H with = q, and an injection ιφ : [ V (G) N ] such that L |L| 0 L→ | | − 1 for every (X,Y ) , there exists iX [ V (G) N ] with iX = ιφ ((X,Y )) such that ∈L ∈ | | − 1 0 −1 (iva) σ (iX ) φ (X Y ) Bi , ∈ 0 − ⊆ X (ivb) φ (X Y ) Si , 0 ∩ ⊆ X −1 (ivc) for every component C of H[X Y ], σ (iX ) φ (V (C)), and − ∈ 0 (ivd) every vertex in X Y is adjacent in H to some vertex in X Y . ∩ − Note that (iv) implies that q 0. So Conclusion 1 of this lemma follows from (iii). And Conclusion 2(a) follows from (ivd).≥ Moreover, if every member of is injective, then φ is H 0 injective, so H[X Y ] is connected by (ivc). So Conclusion 2 of this lemma holds. − −1 For every i [ V (G) N1], by permuting indices, we may assume that Mi,φ0(V (H))∩σ ([i−1]) ′∈ | |− zi,j : j [t ] . ⊇{ ∈ } Since V (H) = h, φ0(V (H)) h, so φ0(V (H)) Sσ(v) rh by (i). For Sv∈φ0(V (H)) | | | ′ | ≤ | ∪ | ≤ each i [ V (G) N1], Zi,j’s are pairwise disjoint by (iic), so by permuting indices, we may ∈ | ′ | − ′ assume that Z (φ0(V (H)) Sσ(v))= for every j [t rh]. i,j ∩ ∪ Sv∈φ0(V (H)) ∅ ∈ − For every (X,Y ) , let (LX , fLX ) be a legal Q-labelled graph with V (LX ) [h] ∈−1 L ⊆ −1 isomorphic to (H[X φ0 (SiX φ0(V (H)))], fH X φ S φ V H ) with an isomorphism ιX , ∪ 0 ( iX ∩ 0( ( ))) ′ ∪ ∩ | −1 −1 and let X = φ X φ S φ V H ιX : φ ,φ(X φ0 (SiX φ0(V (H)))) V (Gσ,≥iX ) . ∪ 0 ( iX ∩ 0( ( ))) ′ H { | ◦ ∈ H ∪ ∩ ⊆ } So is a set of homomorphisms from an element in (L, fL):(L, fL) is a legal Q-labelled HX { graph with V (L) [h] to the set of all induced subgraphs of (Gσ, i , fG V G ). By (iva) ≥ X ( σ,≥iX ) ⊆ } ′ ′′ | and (ivb), φ0 X∪φ−1(S ∩φ (V (H))) ιX X . Let X be the minimal set of homomorphisms | 0 iX 0 ◦ ∈ H H from an element in (L, fL):(L, fL) is a legal Q-labelled graph with V (L) [h] to the set { ′ ⊆ } of all induced subgraphs of (Gσ,≥i , fG V G ) containing and satisfying (CON1) and X ( σ,≥iX ) X (CON2). | H −1 For every (X,Y ) , since σ (iX ) φ0(X) BiX SiX by (iva) and (ivb), we know that ∈L ′ ′′ ∈ ⊆ ∪ −1 by (iid) (with taking i = iX , = X , (L, fL)=(LX , fLX ), φ = φ0 X∪φ (S ∩φ (V (H))) ιX , H H | 0 iX 0 ◦ 34 −1 ′ ′ ∗ and I = φ0(V (H)) σ ([iX 1])), there exists JX [t rh] with JX (t rh)/ℓ = w1 such that ∩ − ⊆ − | | ≥ −

(v) there exists a legal Q-labelled graph (RX , fRX ) such that for every j JX , there exists −1 ∈ −1 a homomorphism φiX ,j from (H[X φ0 (SiX φ0(V (H)))], fH X φ S φ V H ) to ∪ 0 ( iX ∩ 0( ( ))) ′ ∪ ∩ | ′ (Gσ,≥iX [Zi ,j SiX ], fG Z ∪Si ) and an isomorphism ιX,j from (RX , fRX )to(G[φiX ,j(X) X ∪ | iX ,j X Si v φ0(V (H)) : σ(v) iX 1 ], f φ (X)∪S ∪{v∈φ (V (H)):σ(v)≤i −1}) such that ∪ X ∪{ ∈ ≤ − } | iX ,j iX 0 X

(va) zi ,j φi ,j(X), X ∈ X −1 (vb) for every y Si and u X φ (Si φ (V (H))), y = φ (u) if and only if ∈ X ∈ ∪ 0 X ∩ 0 0 y = φiX ,j(u), −1 (vc) for every u X, φ (u)= σ (iX ) if and only if φi ,j(u)= zi ,j, ∈ 0 X X ′ (vd) there exists an isomorphism ι from (G[φ (X) Si ], f φ X S )to(G[φi ,j(X) iX ,j 0 X 0( )∪ iX X ′ ∪ | ∪ −1 −1 SiX ], f φi ,j (X)∪Si ) such that ιi ,j φ0 X φ S φ V H = φiX ,j X φ S φ V H X X X ∪ 0 ( iX ∩ 0( ( ))) ∪ 0 ( iX ∩ 0( ( ))) ′ | ◦ | | and ι S is the identity function, iX ,j| iX −1 −1 −1 ′ (ve) for every y Si (φ (V (H)) σ ([iX 1])), ι (y)= ι ′ (y) for any j JX , ∈ X ∪ 0 ∩ − X,j X,j ∈ −1 −1 −1 ′ (vf) for every x X φ0 (SiX φ0(V (H))), ιX,j(φiX ,j(x)) = ιX,j′ (φiX ,j (x)) for any ′ ∈ ∪ ∩ j JX , and ∈ −1 −1 (vg) for every x X φ (Si φ (V (H))) and y φ (V (H)) σ ([iX 1]), if ∈ ∪ 0 X ∩ 0 ∈ 0 ∩ − yφi ,j(x) E(G), then yφ (x) E(G). X ∈ 0 ∈

Claim 1: For every (X,Y ) and j JX , the following hold. ∈L ∈

• For every u X Y , φ (u)= φi ,j(u). ∈ ∩ 0 X

• φi ,j(X) Si = φ (X Y )= φi ,j(X Y ). X ∩ X 0 ∩ X ∩

• φi ,j(X Y ) Zi ,j. X − ⊆ X

Proof of Claim 1: Let (X,Y ) . Let j JX . Let u X Y . Then φ (u) Si by ∈ L ∈ ∈ ∩ 0 ∈ X (ivb). Since u X Y X, φ (u) = φi ,j(u) by (vb). This proves the first statement of ∈ ∩ ⊆ 0 X this claim. Note that this implies that φ (X Y )= φi ,j(X Y ). 0 ∩ X ∩ If v φi ,j(X) Si , then v φ (X) Si by (vb), so v φ (X Y ) by (iva). ∈ X ∩ X ∈ 0 ∩ X ∈ 0 ∩ Hence φi ,j(X) Si φ (X Y ) = φi ,j(X Y ). Since φ (X Y ) Si by (ivb), X ∩ X ⊆ 0 ∩ X ∩ 0 ∩ ⊆ X φi ,j(X) Si φ (X Y )= φ (X Y ) Si = φi ,j(X Y ) Si φi ,j(X) Si . So X ∩ X ⊆ 0 ∩ 0 ∩ ∩ X X ∩ ∩ X ⊆ X ∩ X all inclusions are equalities. This proves the second statement of this claim. ′ Since φiX ,j(X) SiX ZiX ,j by (v), and φiX ,j(X) SiX = φiX ,j(X Y ) by Statement 2 ⊆ ∪ ′ ∩ ∩ of this claim, we know φiX ,j(X Y ) ZiX ,j. By (ivc), for every component C of H[X Y ], − −⊆1 − there exists vC V (C) such that σ (iX ) = φ (vC ), so by (vc), φi ,j(vC ) = zi ,j. For any ∈ 0 X X component C of H[X Y ] and vertex v of C, since there exists a path PC in C H[X Y ] − ⊆ − from vC to v, there exists a path in Gσ,≥iX from φiX ,j(vC ) = ziX ,j to φiX ,j(v) whose vertex- ′ ≤|E(PC )| set is contained in φi ,j(V (PC )) φi ,j(X Y ) Z , so φi ,j(v) N ′ [zi ,j] X X iX ,j X Gσ,≥i [Z ] X ⊆ − ⊆ ∈ X iX ,j ⊆ ≤h−1 NG −S [ziX ,j] ZiX ,j by (iic) and (iie). Hence φiX ,j(V (C)) ZiX ,j for every component σ,≥iX iX ⊆ ⊆

35 C of H[X Y ]. Therefore, φiX ,j(X Y ) ZiX ,j. This proves the third statement of this claim.  − − ⊆ Denote the elements of by (X ,Y ), (X ,Y ), ..., (X ,Y ). For every j [ ], let L 1 1 2 2 |L| |L| ∈ |L| ij = iXj . By Statement 3 of Claim 1, (iic) and (iie), we know that for every j [ ], φi ,ℓ(Xj Yj): ∈ |L| { j − ℓ JX is a collection of pairwise disjoint subsets of V (G), and each member has size at ∈ j } most h. Since there exists no (1, 2hr +1)-model for a 2h-shallow Kr,t-minor in G, G has no

Kr+t,r+t-subgraph. So by Lemma 5.3 (with taking j = φij ,ℓ(Xj Yj): ℓ JXj for every C { ′ − ∈ ′ } j [ ]), we know that for every (X,Y ) , there exists JX JX with JX = w such ∈ |L| ∈ L ⊆ |′ | that for any distinct j1, j2 [ ], every member of φij ,ℓ(Xj1 Yj1 ): ℓ J is disjoint 1 Xj1 ∈ |L| { − ′ ∈ } and non-adjacent in G to every member of φij ,ℓ(Xj2 Yj2 ): ℓ J . And by Statement 2 Xj2 { − ∈ } ′ 3 in Claim 1, (iic) and (iie), for every j [ ], members of φij ,ℓ(Xj Yj): ℓ JXj are ∈ |L| ′ {′ − ∈ } pairwise disjoint and non-adjacent in G. Since J JX [t rh], by permuting indices, X ⊆ ⊆ − we may assume that J ′ = [w] for every (X,Y ) . Hence we have X ∈L

(vi) φiX ,ℓ(X Y ):(X,Y ) ,ℓ [w] is a collection of pairwise disjoint and pairwise {non-adjacent− in G subsets∈ L of V∈(G), and} this collection has size w. |L| Define G∗ = G[φ ( B) φ (X Y )]. 0 T(A,B)∈L S(X,Y )∈L Sℓ∈[w] iX ,ℓ ∪ − ′ ′ Since Zi ,j φ (V (H)) = for all (X,Y ) and j [w]= J [t rh], by Statement X ∩ 0 ∅ ∈L ∈ X ⊆ − 3 in Claim 1 and (vi), we have

∗ (vii) φi ,ℓ(Xj Yj),φ ( B): j [ ],ℓ [w] is a partition of V (G ) with size { j − 0 T(A,B)∈L ∈ |L| ∈ } w + 1, where φ ( B) is the only possibly empty member and is the only |L| 0 T(A,B)∈L possible member intersecting φ0(V (H)).

′ ′ Define H = G[φ ( B) φi , (X Y )]. Define φH : V (H) V (H ) 0 T(A,B)∈L ∪ S(X,Y )∈L X 1 − → such that for every x B, φH (x) = φ (x), and for every x A B for some ∈ T(A,B)∈L 0 ∈ − (A, B) , φH (x) = φiA,1(x). Note that φH is well-defined since is an independent collection∈ ofL separations of H. By Statement 1 of Claim 1, we have L

(viii) for any (X,Y ) and v X, φH (v)= φi , (v). ∈L ∈ X 1 Define H′′ to be the spanning subgraph of H′ obtained from H′ by, for every (X,Y ) , ′ ′ −1 ∈L deleting all edges of H with one end in φi , (X Y ) and the other end in V (H ) σ [iX 1]. X 1 − ∩ − Let fH′′ be the function whose domain consisting of the marches π in the domain of fG V (H′) ′′ | such that the entries of π form a clique in H , and for each x in the domain of fH′′ , fH′′ (x)= ′′ ′′ ′ fG(x). So fH′′ is a legal labelling of H , and(H , fH′′ ) is a spanning subgraph of (H , fG ′ ) |V (H ) and hence a subgraph of (G, fG). ′′ Claim 2: φH is an onto homomorphism from (H, fH ) to (H , fH′′ ). ′ ′′ ′′ Proof of Claim 2: Note that V (H ) = V (H ), so φH is a function from V (H) to V (H ). Clearly, φH is onto. So it suffices to show that φH is a homomorphism from (H, fH ) to ′′ (H , fH′′ ). ′′ Suppose to the contrary that there exists uv E(H) such that φH (u)φH(v) E(H ). ∈ 6∈ If both u, v are in B, then φH (u)φH (v) = φ (u)φ (v) E(G) since φ is a ho- T(A,B)∈L 0 0 ∈ 0 momorphism; since both φ (u) and φ (v) are not in φi ,ℓ(Xj Yj) by (vii), 0 0 Sj∈[|L|] Sℓ∈[w] j − 36 φ (u)φ (v) E(H′′), a contradiction. So there exists (X,Y ) such that both u, v are in 0 0 ∈ ∈L X. Hence by (viii), φH (u)φH (v)= φiX ,1(u)φiX ,1(v) E(G), since φiX ,1 is a homomorphism. ′′ ∈ By (v) and (vii), φi , (u)φi , (v) E(H ), a contradiction. X 1 X 1 ∈ So φH preserves adjacency. Let π be a march in the domain of fH . Since fH is legal, either all entries of π are in X for some (X,Y ) , or all entries of π are in B. For ∈L T(A,B)∈L the former, fH (π) fG(φiX ,1(π)) = fG(φH (π)) by (viii); for the latter, fH (π) fG(φ0(π)) =   ′′ fG(φH (π)). Since fH is legal and φH preserves adjacency, φH (π) is a clique in H . So φH (π) is in the domain of fH′′ , and fH′′ (φH (π)) = fG(φH (π)). Hence fH (π) fH′′ (φH (π)). ′′  Therefore, φH is an onto homomorphism from (H, fH ) to (H , fH′′ ).  ′ Claim 3: φH is an onto homomorphism from (H, fH ) to (H , fG V (H′)) and φH . ′′ | ′ ∈ H Proof of Claim 3: Since (H , fH′′ ) is a spanning subgraph of (H , fG V (H′)), φH is an onto ′ | homomorphism from (H, fH )to(H , fG V (H′)) by Claim 2. Let G0 be the spanning subgraph of G[φ (V (H))] obtained from G[φ (V (|H))] by, for every (X,Y ) , deleting all edges of 0 0 ∈ L G[φ0(V (H))] satisfying that

• one end is in φ0(X Y ) and the other end is in NG [Bi ] (Si φ0(X)), or − σ,≥iX X − X ∪ −1 • one end is in φ (u) for some u X Y and the other end v is in φ (V (H)) σ [iX 1] 0 ∈ − 0 ∩ − with vφi , (u) E(G). X 1 6∈

Let f be the function whose domain consists of the marches π in the domain of fG 0 |φ0(V (H)) such that the entries of π form a clique in G0, and for each x in the domain of f0, f0(x) = fG(x). Note that (G , f ) is a spanning subgraph of (G[φ (V (H))], fG φ V H ), and φ is 0 0 0 | 0( ( )) 0 also a homomorphism from (H, fH ) to(G , f ) by (iva) and (ivb). Since satisfies (CON1) 0 0 H and (G[φ0(V (H))], fG φ0(V (H))) is an induced subgraph of (G, fG), we know that the function φ′ obtained from φ by| restricting the codomain of φ to φ (V (H)) is a member in and 0 0 0 0 H an onto homomorphism from (H, fH ) to (G0, f0). ′ By (iic), (iie), (vd), (vg) and (vi), (H , fG V (H′)) is isomorphic to (G0, f0) with an iso- ∗ ∗ −1 ′ | ∗ −1 ′ morphism ιH such that (ιH ) φ0 = φH . Since satisfies (CON3), φH =(ιH ) φ0 .  ◦ H ◦ ∈ H

By (vii) and (viii), φH (A B) φH (B) = for every (A, B) . Define H′ = ′ − ∩ ∅ ∈ L L (NH′ [φH (X Y )],V (H ) φH (X Y )) : (X,Y ) . By (vi) and (viii), H′ is an { − − − ′ ∈ L} L independent collection of separations of H , and H′ = . These together with Claim 3 |L | |L| imply Conclusion 3(a). ∗ Recall that G = G[φ ( B) φi ,ℓ(X Y )]. Note that if there 0 T(A,B)∈L ∪ S(X,Y )∈L Sℓ∈[w] X − ∗ exists v NG [φiX ,ℓ(X Y )] φiX ,ℓ(X) for some (X,Y ) and ℓ [w], then v φ ( ∈ B), and either− σ−1(−v) i 1 or v S by Statement∈ L 3 of Claim∈ 1 and (iie),∈ 0 T(A,B)∈L X iX ≤ − ′ ∈ ∗ ′ ′ so v NG [φiX ,ℓ (X Y )] φiX ,ℓ (X) for every ℓ [w] by (vd), (ve) and (vf). Hence by (vb), ∈ ′ − − ∈ ∗ (ve) and (vf), (H , fG ′ ) w H′ is isomorphic to (G , fG ∗ ). Therefore Conclusion |V (H ) ∧ L |V (G ) 3(b) of this lemma holds. ′′ ′′ Let H′′ = (NH′′ [φH (X Y )],V (H ) φH (X Y )):(X,Y ) . Since (H , fH′′ ) is a L { − ′ − − ∈ L} spanning legal Q-labelled subgraph of (H , fG V (H′)), Conclusion 4(b) follows from Conclusion 3(b). By Claim 3 and Conclusion 3(a) of this| lemma, to prove this lemma, it suffices to prove that every separation in H′′ has order at most r 1. L −

37 Suppose to the contrary that there exists (X,Y ) such that the order of (NH′′ [φH (X ′′ ∈L ′′ − Y )],V (H ) φH (X Y )) is at least r. Note that (NH′′ [φH (X Y )],V (H ) φH (X Y )) = − − ′′ − − − ′′ ′′ (NH [φiX ,1(X Y )],V (H ) φiX ,1(X Y )) by (viii). And the order of (NH [φiX ,1(X ′′ − − − − Y )],V (H ) φi , (X Y )) is NH′′ (φi , (X Y )) , so NH′′ (φi , (X Y )) Si by (i). − X 1 − | X 1 − | X 1 − 6⊆ X ′′ Hence there exists u φiX ,1(X Y ) and v NH (φiX ,1(X Y )) SiX . By Statement 3 in ∈ − ∈ − ′ − Claim 1 and (iie), either σ(v) iX 1, or σ(v) iX and v ZiX ,1. Since u φiX ,1(X Y ) ′′ ≤ − ≥ ′′ ∈ ′ ∈ −′′ and uv E(H ), σ(v) iX by the definition of H . So v ZiX ,1. Since v V (H ) = ′ ∈ ′′ ≥ ′ ∈ ∈ V (H ) and uv E(H ) E(H ), by (vi) and (vii), v φ0(T(A,B)∈L B) φ0(V (H)). But ′ ∈ ⊆ ∈ ⊆ Z φ0(V (H)) = , a contradiction. iX ,1 ∩ ∅ Therefore, every separation in H′′ has order at most r 1. This proves Conclusion 4(a) L − of this lemma and completes the proof.

Lemma 5.5 For any quasi-order Q with finite ground set, positive integers r, t, h, hereditary class of legal Q-labelled graphs, legal Q-labelled graph (H, fH ) on h vertices, consistent set G ′ of homomorphisms from (H, fH ) to , and positive real numbers k,k , there exist positive H G ′ real numbers c = c(Q, r, t, h, , (H, fH), ,k,k ), r0 = r0(r, h) and r1 = r1(r, h) such that if G ′ H 1 ′ (G, fG) is a member in , and ǫ, ǫ are nonnegative real numbers with ǫ 16h+4 and ǫ r1 such that G ≤ ≤

1. for every induced subgraph L of G, E(L) k V (L) 1+ǫ, | | ≤ | | 2. for every graph L in which some subgraph of G is isomorphic to a [4h + 1]-subdivision of L, E(L) k′ V (L) 1+ǫ′ , and | | ≤ | |

3. there exists no (1, 2hr + 1)-model for a 2h-shallow Kr,t-minor in G, then there exists a nonnegative integer q such that

1 2 q+(1+ǫ− ǫ )|V (H)| 1. there are at most c V (G) 0 homomorphisms in from (H, fH ) to (G, fG), | | H where ǫ =(1+ ǫ′(r 1))r0 , 0 −

2. there exists a ( , )-duplicable independent collection of separations of (H, fG) with G H L = q, and |L| 3. if every member of is injective, then for every separation (X,Y ) in , it has order H L at most r 1 and H[X Y ] is connected. − − Proof. Let Q be a quasi-order with finite ground set. Let r, t, h be positive integers. Let be a hereditary class of legal Q-labelled graphs. Let (H, fH ) be a legal Q-labelled graph G ′ on h vertices. Let be a consistent set of homomorphisms from (H, fH ) to . Let k,k be positive real numbers.H G For any non-( , )-duplicable independent collection of separations of H, let sL be the G H L ′ minimum positive integer s such that for every Q-labelled graph (H , fH′ ) and φ from ′ ∈ H (H, fH )to(H , fH′ ) satisfying that φ is onto, φ(A B) φ(B)= for every (A, B) , L,φ −′ ∩ ∅ ∈L′ W is an independent collection of separations of (H , fH′ ) with size , we have (H , fH′ ) s′ ′ ′ |L| ∧ L,φ for every s s, where L,φ = (NH′ [φ(A B)],V (H ) φ(A B)):(A, B) . W 6∈ G ≥ W { − − − ′∈ L} Note that such sL exists since there are only finitely many legal Q-labelled graphs (H , fH′ )

38 ′ such that there exists an onto function φ from (H, fH )to(H , fH′ ). If there exists no non- ( , )-duplicable independent collections∈ Hof separations of H, then let s = 1; otherwise, let sG=H max s , where the maximum is overL all non-( , )-duplicable independent collections L L G H of separations of H. Note that this maximum exists since there are only finitely many independentL collections of separations of H. Let a = U , where U is the ground set of Q. ′ | | Define c = c5.4(r, t, s + t, h, a, k, k ), where c5.4 is the real number c mentioned in Lemma ′ ′ 5.4. Define r0 = r5.4(r, h) and r1 = r5.4(r, h), where r5.4 and r5.4 are the real numbers r0 and r1 in Lemma 5.4. ′ ′ Let (G, fG) and let ǫ and ǫ be the real numbers as stated in the lemma. Let be ∈ G H the subset of consisting of the members of from (H, fH ) to some induced subgraphs of H ′ H ′ (G, fG). Since is consistent, is consistent. Applying Lemma 5.4 (with taking = ), H H H H there exists a nonnegative integer q such that the following hold.

1 2 q+(1+ǫ− ǫ )|V (H)| ′ (i) There are at most c V (G) 0 homomorphisms in from (H, fH ) to | ′ | r0 H (G, fG), where ǫ =(1+ ǫ (r 1)) . 0 −

(ii) There exist an independent collection of separations of (H, fH ) with = q such that for every (X,Y ) , L |L| ∈L (iia) every vertex in X Y is adjacent in H to a vertex in X Y , and ∩ − (iib) if every member of ′ is injective, then H[X Y ] is connected. H − ′ (iii) There exists an induced subgraph (H , fH′ ) of (G, fG) such that

′ ′ (iiia) there exists an onto homomorphism φH from (H, fH ) to(H , fH′ ) such ∈ H ⊆ H that

∗ φH (A B) φH (B)= for every (A, B) , − ∩ ∅′ ∈L ∗ (NH′ [φH (A B)],V (H ) φH (A B)):(A, B) , denoted by H′ , is an { − − − ′ ∈ L} L independent collection of separations of (H , fH′ ), and

∗ H′ = , |L | |L| ′ (iiib) (H , f H′ ) s t H′ is isomorphic to an induced subgraph of (G, fG). | ∧ + L ′′ ′ (iv) There exists a legal spanning subgraph (H , fH′′ ) of (H , fH′ ) such that

′′ – φH is an onto homomorphism from (H, fH )to(H , fH′′ ) such that (NH′′ [φH (A ′′ { − B)],V (H ) φH (A B)) : (A, B) , denoted by H′′ , is an independent − − ′′ ∈ L} L collection of separations of (H , fH′′ ) of order at most r 1 with H′′ = , and − |L | |L| ′′ ′ – (H , f H′′ ) s t H′′ is isomorphic to a legal subgraph (G , fG′ ) of (G, fG). | ∧ + L Since every member of with codomain V (G) belongs to ′, Conclusion 1 follows from (i). H H ′ Suppose that is non-( , )-duplicable. By (iiia) and the definition of s ,(H , f H′ ) s t L G H L | ∧ + H′ . But is hereditary, so it contradicts (iiib). Hence Conclusion 2 follows from (ii). L Now6∈ G we proveG Conclusion 3. Assume that every member of is injective. By (iib), it H suffices to show that every member of has order at most r 1. Suppose to the contrary L ∗ ∗ − ′′ that there exists (X,Y ) of order at least r. Let (A , B )=(NH′′ [φH (X Y )],V (H ) ∈L − − 39 ∗ ∗ ′′ φH (X Y )). Note that (A , B ) is a member of H′′ , so it is a separation of (H , fH′′ ) of − ∗ ∗ L order at most r 1 by (iv). Since A B = NH′′ (φH (X Y )), NH′′ (φH (X Y )) = r 1 < − ∩ − | − | − r X Y = NH (X Y ) , where the last equality follows from (iia). Since φH , φH is ≤| ∩ | | − | ∈ H injective. So φH (NH (X Y )) NH (X Y ) > NH′′ (φH (X Y )) . Since φH is an injective | − |≥| ′′ − | | − | homomorphism from (H, fH ) to (H , fH′′ ) by (iv), φH (NH (X Y )) NH′′ (φH (X Y )). − ⊆ − Hence φH (NH (X Y )) NH′′ (φH (X Y )) , a contradiction. This proves Conclusion 3. | − |≤| − |

Now we are ready to prove the main theorem of this paper. Recall that ex(H, fH , , , n) H G is the maximum number of homomorphisms in from (H, fH )to(G, fG), among all members H (G, fG) of on n vertices; and dup (H, fH , ) is the maximum size of a ( , )-duplicable G H G G H independent collection of separations of (H, fH ).

Theorem 5.6 For any positive integers r, h, there exist positive real numbers r0 and r1 such that for any quasi-order Q with finite ground set, positive integer t, hereditary class G of legal Q-labelled graphs, legal Q-labelled graph (H, fH ) on h vertices, consistent set of ′ H homomorphisms from (H, fH ) to , and positive real numbers k,k , there exist positive real G ′ 1 numbers c1 and c2 such that if there exist nonnegative real numbers ǫ, ǫ with ǫ 20h2 and ′ ≤ ǫ r such that any member (G, fG) of satisfies ≤ 1 G 1. for every induced subgraph L of G, E(L) k V (L) 1+ǫ, | | ≤ | | 2. for every graph L in which some subgraph of G is isomorphic to a [4h + 1]-subdivision of L, E(L) k′ V (L) 1+ǫ′ , and | | ≤ | |

3. there exists no (1, 2hr + 1)-model for a 2h-shallow Kr,t-minor in G.

then

dup (H,f ,G) 1. ex(H, fH , , , n) c n H H for infinitely many positive integers n, H G ≥ 1 1 2 dupH(H,fH ,G)+(1+ǫ− ǫ )h 2. ex(H, fH , , , n) c n 0 for all positive integers n, where ǫ = H G ≤ 2 0 (1 + ǫ′(r 1))r0 , and − 3. if every member of is injective, then there exists a ( , )-duplicable independent H G H collection of separations of H with = dupH(H, fH , ) such that for every (X,Y ) , X YL r 1 and H[X Y ] is|L| connected. G ∈ L | ∩ | ≤ − − ′ ′ Proof. Let r and h be positive integers. Define r0 = r5.5(r, h) and r1 = r (r, h), where ′ 5.5 r5.5 and r5.5 are the real numbers r0 and r1 mentioned in Lemma 5.5, respectively. Define 1 ( 1 ) r0 −1 1− 1 r to be min r′ , 2h2 . Let Q be a quasi-order with finite ground set. Let t be a 1 { 1 r−1 } positive integer. Let be a hereditary class of legal Q-labelled graphs. Let (H, fH ) be a legal Q-labelled graphG in h vertices. Let be a consistent set of homomorphisms from ′ H (H, fH ) to . Let k and k be positive real numbers. Define c1 = c1.3(H), where c1.3 is the G ′ real number mentioned in Proposition 1.3. Define c = c (Q, r, t, h, , (H, fH), ,k,k ), 2 5.5 G H where c5.5 is the real number c mentioned in Lemma 5.5.

40 ′ 1 ′ Let ǫ and ǫ be nonnegative real numbers with ǫ 20h2 and ǫ r1 such that every member of satisfies the conditions stated in the lemma.≤ ≤ Then ConclusionG 1 of this lemma immediately follows from Proposition 1.3. Let n be a positive integer. For every member (G, fG) of on n vertices, by Lemma 5.5, G there exists a nonnegative integer qG such that

1 2 qG+(1+ǫ− ǫ )h (i) there are at most c n 0 homomorphisms in from (H, fH )to(G, fG), where 2 H ǫ = (1+ ǫ′(r 1))r0 , 0 −

(ii) there exists a ( , )-duplicable independent collection G of separations of (H, fH ) G H L with G = qG, and |L | (iii) if every member of is injective, then for every separation (X,Y ) in G, it has order H L at most r 1 and H[X Y ] is connected. − −

By (ii), qG dupH(H, fH , ) for every (G, fG) . So by (i), ex(H, fH , , , n) ≤ 1 2 G ∈ G H G ≤ dupH(H,fH ,G)+(1+ǫ− )h c n ǫ0 homomorphisms in from (H, fH ) to (G, fG). Hence Conclusion 2 H 2 holds. ′ 1 1 1 2 11 Since ǫ r1, 1 2 . So (1+ ǫ )h < 1. Note that dup (H, fH , ) and ≤ − ǫ0 ≤ 2h − ǫ0 ≤ 20 H G qG are integers for any (G, fG) . So by Conclusion 1 and 2 of this lemma, there exist a ∈ G dup (H,f ,G) ∗ ∗ large integer N with ex(H, fH , , , N) c N H H and (G , f ) on N vertices H G ≥ 1 ∈ G such that qG∗ = dup (H, fH , ). Define = G∗ . Then Conclusion 3 follows from (iii) by H G L L taking = G∗ . L L Now we are ready to deduce Theorem 1.4 from Theorem 5.6. The following corollary immediately implies Theorem 1.4.

Corollary 5.7 For any quasi-order Q with finite ground set, hereditary class of legal Q- G labelled graphs with bounded expansion, legal Q-labelled graph (H, fH ), consistent set of H homomorphisms from (H, fH ) to , there exist positive integers c and c such that G 1 2 dup (H,f ,G) 1. ex(H, fH , , , n) c n H H for infinitely many positive integers n, H G ≥ 1 dup (H,fH ,G) 2. ex(H, fH , , , n) c n H for every positive integer n, and H G ≤ 2 3. if every member of is injective and there exist positive integers r and t such that H every graph in has no (1, 2r V (H) + 1)-model for a 2 V (H) -shallow Kr,t-minor, G | | | | then there exists a ( , )-duplicable independent collection of separations of (H, fH ) G H L of order at most r 1 with = dupH(H, fH , ) such that H[X Y ] is connected for every (X,Y ) . − |L| G − ∈L Proof. Let Q be a quasi-order with finite ground set. Let be a hereditary class of legal Q-labelled graphs with bounded expansion. So there exists aG function f : N 0 N 0 ∪{ }→ ∪{ } such that has expansion at most f. Let (H, fH ) be a legal Q-labelled graph. Let be a G H consistent set of homomorphisms from (H, fH ) to . Let h be the number of vertices of H. G Define c1 and c2 to be the real numbers c1 and c2, respectively, mentioned in Theorem 5.6 by ′ taking (r, h, Q, t, , (H, fH), ,k,k )=(f(2h)+1, h, Q, f(2h)+1, , (H, fH), , f(0), f(2h+ 1)). G H G H

41 If there exists (G, fG) such that there exists a (1, 2h (f(2h) + 1) + 1)-model for ∈ G · a 2h-shallow Kf(2h)+1,f(2h)+1-minor in G, then G contains some graph with average degree greater than f(2h) as a 2h-shallow minor, a contradiction. Then applying Theorem 5.6 by taking ǫ = ǫ′ = 0, Statements 1 and 2 immediately follows from Conclusions 1 and 2 of Theorem 5.6. If there exist positive integers r and t such that every graph in has no G (1, 2r V (H) +1)-model for a 2 V (H) -shallow Kr,t-minor, then we can apply Theorem 5.6 by taking| (r, t)=(| r, t), so Statement| 3| of this corollary follows from Conclusion 3 of Theorem 5.6.

Another consequence of Theorem 5.6 is Theorem 1.7. We will use the following charac- terization for the classes of nowhere dense graphs.

Theorem 5.8 ([61, Theorem 4.1]) Let be a hereditary class of graphs. For every non- C negative integer ℓ, let Mℓ be the set consisting of all graphs L such that some graph in C contains L as an ℓ-shallow minors, and let Sℓ be the set consisting of all graphs L such that some graph in contains a ([2ℓ] 0 )-subdivision of L. Then following are equivalent. C ∪{ } 1. is nowhere dense. C 2. For every positive integer k, there exists an integer g(k) such that the size of every clique in any graph in Mk is at most g(k).

log|E(L)| 3. limℓ lim sup 1. →∞ L∈Mℓ log|V (L)| ≤ 4. For every nonnegative integer ℓ, lim sup log|E(L)| 1. L∈Mℓ log|V (L)| ≤ log|E(L)| 5. limℓ→∞ lim sup 1. L∈Sℓ log|V (L)| ≤ 6. For every nonnegative integer ℓ, lim sup log|E(L)| 1. L∈Sℓ log|V (L)| ≤ Note that Statements 4 and 6 are not stated in [61, Theorem 4.1], but they are equivalent to Statements 3 and 5, respectively, since M M M ... and S S S ... by 0 ⊆ 1 ⊆ 2 ⊆ 0 ⊆ 1 ⊆ 2 ⊆ the definition of Mℓ and Sℓ. Now we are ready to prove Theorem 1.7. The following is a restatement of Theorem 1.7.

Corollary 5.9 Let Q be a quasi-order Q with finite ground set. Let (H, fH ) be a legal Q- labelled graph. Let be a hereditary nowhere dense class of legal Q-labelled graphs. Let G H be a consistent set of homomorphisms from (H, fH ) to . Then the asymptotic logarithmic G density for (H, fH , , ) equals dup (H, fH , ). G H H G

Proof. By Proposition 1.3, the asymptotic logarithmic density for (H, fH , , ) is at least G H dup (H, fH , ). To prove that the asymptotic logarithmic density for (H, fH , , ) is at H G G H most dup (H, fH , ), it suffices to show that it is at most dup (H, fH , )+ δ for every H G H G δ > 0. Let h be the number of vertices of H. By Theorem 5.8, there exists a positive integer r such that no member of contains Kr as a (6h + 1)-shallow minor. Since Kr,r contains G

42 Kr as a 1-shallow minor, no member of contains Kr,r as a 2h-shallow minor. Let r and G 0 r1 be the positive real numbers r0 and r1, respectively, mentioned in Theorem 5.6 by taking (r, h)=(r, h). Let δ be a positive real number with δ < 1. Let ǫ′ = min r , 1 1 . Let 1 (r−1)(1− δ )1/r0 r−1 { 2h2 − } ′ r0 1 2 δ 1 δ 1 2 ǫ0 = (1+ ǫ (r 1)) . So (1 )h . Let ǫ = min 2 , 2 . Hence (1 + ǫ )h δ. − − ǫ0 ≤ 2 { 20h 2h } − ǫ0 ≤ For every nonnegative integer ℓ, let Mℓ be the set consisting of all graphs L such that some graph in contains L as an ℓ-shallow minors, and let Sℓ be the set consisting of all G graphs L such that some graph in contains a ([2ℓ] 0 )-subdivision of L. By Theorem 5.8, G log|E(L)| ∪{ } ′ there exists a positive integer N such that log|V (L)| 1 + min ǫ, ǫ for every L M0 S2h+1 ≤ { } 2 1+min∈{ǫ,ǫ′} ∪ with V (L) N. Hence for every L M0 S2h+1, E(L) N V (L) . Let c | | ≥ ∈ ∪ | | ≤ | | ′ be the real number c2 mentioned in Theorem 5.6 by taking (r, h, Q, t, , (H, fH ), ,k,k )= 2 2 G H (r, h, Q, r, , (H, fH ), , N , N ). G H Let (G, fG) be a member of . Then for every induced subgraph L of G, L M0, so E(L) N 2 V (L) 1+ǫ. For everyG graph L in which some subgraph of G is isomorphic∈ to a | | ≤ | | 2 1+ǫ′ [4h + 1]-subdivision of L, L S h , so E(L) N V (L) . Recall that no member of ∈ 2 +1 | | ≤ | | G contains Kr,r as a 2h-shallow minor, so there exists no (1, 2hr + 1)-model for a 2h-shallow Kr,r-minor in G. H,f , ǫ 1 h2 dupH( H G)+(1+ − ǫ ) dup (H,fH ,G)+δ So by Theorem 5.6, ex(H, fH , , , n) cn 0 cn H for H G ≤ ≤ every positive integer n. Hence the asymptotic logarithmic density for (H, fH , , ) is at G H most dup (H, fH , )+ δ. H G Since δ is an arbitrary small positive real number, the asymptotic logarithmic density for (H, fH , , ) is at most dup (H, fH , ). This proves the corollary. G H H G 6 Concrete applications

In this section, we apply Theorem 1.4 (or precisely, Corollary 5.7) to solve open questions on some extensively studied graph classes of (unlabelled) graphs. We will concentrate on determining the number of (induced or not) subgraphs isomorphic to H and the number homomorphisms from H (without other conditions). We first show that Corollary 5.7 implies that the subgraph counts determine these three quantities up to a constant factor for monotone classes with bounded expansion. A class of graphs is monotone if every subgraph of any member of belongs to . Note G G G that every monotone class is hereditary. For any graph H, class of graphs and integer n, we define G

• ex(H, , n) to be the maximum number of subgraphs of G isomorphic to H, among all G n-vertices graphs G in , G • ind(H, , n) to be the maximum number of induced subgraphs of G isomorphic to H, amongG all n-vertices graphs G in , G • hom(H, , n) to be the maximum number of homomorphisms from H to G, among all n-verticesG graphs G in , and G

43 Corollary 6.1 Let H be a graph. Let be a monotone class of graphs with bounded expan- sion. Then G

1. ind(H, , n) = Θ(ex(H, , n)). G G ′ ′ 2. hom(H, , n) = maxH′ Θ(ex(H , , n)), where the maximum is over all graphs H with V (H′) G V (H) such that thereG exists an onto homomorphism from H to H′. | |≤| | Proof. Let be the set of all injective homomorphisms from H to . Note that H1 G ex(H, , n) = Θ(maxG∈G,|V (G)|=n φ 1 : φ is from H to G ). Let 2 = φ 1 : φ mapsG any pair of non-adjacent|{ vertices∈ H to a pair of non-adjacent}| verticesH .{ Note∈ H that } ind(H, , n) = Θ(maxG , V G n φ : φ is from H to G ). Since is monotone, G ∈G | ( )|= |{ ∈ H2 }| G an independent collection of separations of H is ( , 1)-duplicable if and only if is ( , )-duplicable. Since L and are consistent,G andH since every monotone classL of G H2 H1 H2 graphs is hereditary, Statement 1 of this proposition follows from Statements 1 and 2 of Corollary 5.7. Let S be the set of all isomorphism classes of graphs H′ with V (H′) V (H) such that there exists an onto homomorphism from H to H′. For every| homomorphism|≤| φ| from H to a graph G, let Hφ be the subgraph of G induced by φ(V (H)), so Hφ S. So h ′ ∈ hom(H, , n) h PH′∈S ind(H , , n). Since S is upper bounded by a function only G ≤ G | | ′ depending on H, we have hom(H, , n) = maxH′∈S O(ind(H , , n)). On the other hand, ′ G ′ G hom(H, , n) ind(H , , n) for every H S. So hom(H, , n) = maxH′ S Θ(ind(H, , n)). G ≥ G ∈ G ∈ G Hence Statement 2 follows from Statement 1.

By Corollary 6.1, we can concentrate on ex(H, , n). For a graph class and a graph H, we say that an independent collection is -duplicableG if it is ( , )-duplicable,G where is G G H H the collection of all injective homomorphisms from H to . So it suffices to understand the maximum size of a -duplicable collection by Corollary 5.7.G G 6.1 Preparation A collection of separations of a graph H is essential if for every (A, B) , every vertex in A B Lis adjacent in H to some vertex in A B, and H[A B] is connected.∈ L ∩ − − Proposition 6.2 Let be a monotone class of graphs. Let H be a graph. Let k be a G nonnegative integer. If is a -duplicable independent collection of separations of H such that every separation inL hasG order at most k, then there exists an essential -duplicable independent collection ′Lof separations of H with ′ such that every separationG in L |L | ≥ |L| ′ has order at most k. L

Proof. For every (A, B) , let A = (NH [V (C)],V (H) V (C)) : C is a component of ∈ L L { − H[A B] . Clearly, A is an essential collection of separations of H of order at most A B . −′ } L ′ ′ | ∩ | Let = S(A,B)∈L A. Since is independent, and is independent. Since is monotoneL and isL -duplicable,L ′ is -duplicable.|L | ≥ |L| L G L G L G

44 Proposition 6.3 Let be a monotone class of graphs. Let H be a graph. Let be an essential -duplicable independentG collection of separations of H. Let H′ be the graphL ob- tained fromG H by adding edges such that A B is a clique for every (A, B) . Then some ∩ ∈L ([ V (H) 2] 0 )-subdivision of H′ belongs to . | | − ∪{ } G |V (H)| Proof. Let w = + 1. Since is -duplicable and is monotone, H w . 2  L G G ∧ L ∈ G Since is essential, for every (A, B) and for every u, v A B, there exists a path in H[A] onL at most V (H) vertices from∈Lu to v whose all internal∈ vertices∩ are in A B. Since |V (H)| | | ′ − w = 2  + 1, H w contains a ([ V (H) 2] 0 )-subdivision of H . This proposition follows since is monotone.∧ L | | − ∪{ } G Let be an independent collection of separations of a graph H. A torso of is a graph L L that is either obtained from H[ B] by adding edges such that A B is a clique for T(A,B)∈L ∩ every (A, B) , or obtained from H[X] for some (X,Y ) by adding edges such that ∈ L ∈ L X Y is a clique. ∩We say that a graph H is a topological minor of another graph G if some subgraph of G is isomorphic to a subdivision of H. A class of graphs is topological minor-closed if every G topological minor of any member of is a member of . G G Proposition 6.4 Let be a topological minor-closed class of graphs. Let H be a graph. Let G be an essential -duplicable independent collection of separations of H. Then every torso Lof belongs to .G L G Proof. Let H′ be the graph obtained from H by adding edges such that A B is a clique for every (A, B) . By Proposition 6.3, H′ since is topological minor-closed.∩ This ∈L ∈ G G proposition follows since every torso of is a subgraph of H′. L

Let t be a nonnegative integer. Let G1 and G2 be graphs. If G1 contains a clique u1,u2, ..., ut of size t, and G2 contains a clique v1, v2, ., , , vt of size t, then a t-sum of G{ and G is} a graph obtained from the disjoint union{ of G and} G by, for each i [t], 1 2 1 2 ∈ identifying ui and vi into a new vertex wi, and then deleting any number of edges whose both ends are in w ,w , ..., wt . A( t)-sum of G and G is a k-sum of G and G for { 1 2 } ≤ 1 2 1 2 some integer k with 0 k t. Note that for every independent collection of separations ≤ ≤ L of a graph H, H is a ( t)-sum of all torsos of , where t = max(A,B)∈L A B . A class of graphs is closed under≤ ( t)-sum if any ( t)-sumL of members of belongs| ∩ to| . G ≤ ≤ G G Proposition 6.5 Let be a monotone class of graphs. Let H be a graph. Let t be a nonnegative integer. LetG be an independent collection of separations of H such that every L separation in has order at most t. If is closed under ( t)-sum, and every torso of belongs to , thenL is -duplicable. G ≤ L G L G Proof. For every positive integer w, H w is a subgraph of a ( t)-sum of torsos of and hence belongs to . So is -duplicable.∧ L ≤ L G L G Corollary 6.6 Let t be a positive integer. Let be a topological minor-closed class of graphs closed under ( t 1)-sum. Let be an essentialG independent collection of separations of ≤ − L a graph H such that every member of has order at most t 1. Then is -duplicable if and only if every torso of belongs toL . − L G L G 45 Proof. It is an immediate corollary of Propositions 6.4 and 6.5.

Proposition 6.7 Let t be a positive integer. Let be the minor relation or the topological minor relation. Let be a -closed class of graphs. Let be the set of -minimal graphs that G  F  do not belong to . If every member of is t-connected, then is closed under ( t 1)-sum. G F G ≤ −

Proof. Let G bea ( t 1)-sum of graphs G1,G2 . So there exists a separation (A, B) of G with order at most≤ −t 1 such that V (A) = V∈(G ) and V (B) = V (G ). Suppose to − 1 2 the contrary that G . Then H G for some graph H . So H is t-connected. Since A B t 1 and 6∈A G B is a clique in G and a clique in∈FG , either H G or H G . | ∩ | ≤ − ∩ 1 2  1  2 So one of G ,G is not in , a contradiction. 1 2 G Corollary 6.8 Let r be a positive integer. Let be the minor relation or the topological minor relation. Let be a -closed class of graphs. Let be the set of -minimal graphs that G  F  do not belong to . If every member of is r-connected, and there exists a positive integer t G F such that every graph in has no (1, 2r V (H) +1)-model for a 2 V (H) -shallow Kr,t-minor, then ex(H, , n)=Θ(nk)G, where k is the| maximum| size of an essential| independent| collection G of separations of H of order at most r 1 whose every torso is in . − G Proof. By Corollary 5.7, ex(H, , n)=Θ(nk), where k is the maximum size of a -duplicable independent collection of separationsG of H of order at most r 1. By PropositionG 6.2, k − equals the maximum size of an essential -duplicable independent collection of separations of H of order at most r 1. By PropositionG 6.7, is closed under ( r 1)-sum. Since every − G ≤ − minor-closed class is topological minor-closed, by Corollary 6.6, k equals the maximum size of an essential independent collection of separations of H of order at most r 1 whose every torso of is in . − G 6.2 Minor-closed families We address minor-closed families, one of the most extensively studied sparse graph classes, in this subsection.

6.2.1 Common minor-closed families Huynh and Wood [44] proposed the following conjecture which was a potential answer of a question of Eppstein [24]. (Recall that flapd(H) is the maximum size of an independent collection of separations of H of order at most d.)

Conjecture 6.9 ([44, Conjecture 15]) Let s, t be positive integers with s t. Let ≤ G be the class of graphs containing no Ks,t-minor. Then for every Ks,t-minor free graph H, ex(H, , n)=Θ(nflaps−1(H)). G The following corollary disproves Conjecture 6.9 by providing the correct bound, as it is

easy to see that the bound mentioned in the following corollary is not equal to flaps−1(H) for infinitely many graphs H.

46 Corollary 6.10 Let s, t be positive integers with s t. Let be the class of graphs con- ≤ G k taining no Ks,t-minor. Then for every Ks,t-minor free graph H, ex(H, , n)=Θ(n ), where k is the maximum size of an essential independent collection of separationsG of H of order L at most s 1 such that every torso of is Ks,t-minor free. − L

Proof. Since is Ks,t-minor free, every graph in has no (1, 2s V (H) + 1)-model for a G G | | 2 V (H) -shallow Ks,t-minor. Since Ks,t is s-connected, this corollary immediately follows | | from Corollary 6.8.

Corollary 6.10 generalizes a result of Eppstein [24] who proved the case that H is s- connected, a result of Huynh, Joret and Wood [43] who proved the case that s 3, and a ≤ result of Huynh and Wood [44] who proved the case that H is a tree. Note that the result in [44] for trees is described by using αs−1(H), but it can be easily shown that it matches the result in Corollary 6.10 by counting the number of edges and considering ( 1)-sums. ≤ A similar result for Kt-minor free graphs can be proved in a similar way.

Corollary 6.11 Let t be a positive integer. Let be the class of graphs containing no Kt- G k minor. Then for every Kt-minor free graph H, ex(H, , n)=Θ(n ), where k is the maximum G size of an essential independent collection of separations of H of order at most t 2 such L − that every torso of is Kt-minor free. L

Proof. Since every graph in is Kt-minor free, every graph in has no 2 V (H) -shallow G G | | Kt−1,t−1-minor. Since Kt is (t 1)-connected, this corollary immediately follows from Corol- lary 6.8. −

Similar arguments lead to results for the class of bounded tree-width graphs, one of the most extensively studied minor-closed families. The tree-width of a graph G is the minimum k such that G is a subgraph of a chordal graph with maximum clique size k + 1.

Corollary 6.12 Let t be a positive integer. Let be the class of graphs of tree-width at G most t. Then for every graph H of tree-width at most t, ex(H, , n)=Θ(nk), where k is the maximum size of an essential independent collection of separationsG of H of order at most L t such that every torso of has tree-width at most t. L

Proof. Since Kt+1,t+1 has tree-width t+1, every graph in has no 2 V (H) -shallow Kt+1,t+1- minor. By Corollary 5.7, ex(H, , n)=Θ(nk), where k is theG maximum| size| of a -duplicable G G independent collection of separations of H of order at most t. By Proposition 6.2, k equals the maximum size of an essential -duplicable independent collection of separations of H of order at most t. By the definitionG of tree-width, is closed under ( t)-sum. By Corollary G ≤ 6.6, k equals the maximum size of an essential independent collection of separations of H of order at most t whose every torso is in . G The special case that H is a tree in Corollaries 6.11 and 6.12 were proved by Huynh and Wood [44]. Another common minor-closed family is the class of graphs of bounded path-width. The path-width of a graph G is the minimum k such that there exists a function f that maps each

47 vertex of G to an interval in R with positive integral endpoints such that f(u) f(v) = for every edge uv E(G), and v V (G): x f(v) k + 1 for every real number∩ x;6 the∅ function f is called∈ a path-decomposition|{ ∈ of G∈of width}| ≤k. Huynh and Wood [44] asked the following question.

Question 6.13 ([44]) If H is a tree, what is the maximum number of H-subgraphs in an n-vertex graph of path-width at most t.

Corollary 5.7 solves this question, up to a constant factor, even when H is not a tree.

Corollary 6.14 Let t be a positive integer. Let be the class of graphs of path-width at most t. Then for every graph H of path-width at mostG t, ex(H, , n)=Θ(nk), where k is the G maximum size of an essential independent collection of separations of H of order at most L t such that H t +2t+3 has path-width at most t. ∧(2) L

Proof. Since Kt+1,t+1 has tree-width t + 1, it has path-width at least t + 1. So every graph in has no (1, 2(t+1) V (H) +1)-model for a 2 V (H) -shallow Kt ,t -minor. By Corollary G | | | | +1 +1 5.7 and Proposition 6.2, ex(H, , n) = Θ(nk), where k is the maximum size of an essential -duplicable independent collectionG of separations of H of order at most t. G It suffices to show that an essential independent collection of separations of H of order L at most t is -duplicable if and only if H t +2t+3 . Let be an essential independent G ∧(2) L ∈ G L collection of separations of H of order at most t. It suffices to show that if H t +2t+3 , ∧(2) L ∈ G then is -duplicable by the definition of -duplicable collections. L G ′G Assume that H t +2t+3 . Let H be the graph obtained from H by adding edges ∧(2) L ∈ G such that A B is a clique in H′ for every (A, B) . Note that is also an essential ∩ ′ ∈ L L ′ independent collection of separations of H of order at most t. Since is essential, H 2t+3 ′ L ∧ L is a minor of H t t . Since is minor-closed, H 2t+3 . So there exists a path- (2)+2 +3 ∧ ′ L G ∧ L ∈ G decomposition f of H 2t+3 with width at most t. ∧ L ′ For each (A, B) , let YA, ,YA, , ..., YA, t be the copies of A B in H [A] t (A B). ∈L 1 2 2 +3 − ∧2 +3 ∩ For each (A, B) and i [2t + 3], let IA,i = f(v); let A be the multiset IA,j : Sv∈YA,i ∈ L ∈ ′ C { j [2t + 3] . Since is essential, H [A B] is connected, so IA,i is an interval with integral ∈ } L − endpoints for every (A, B) and i [2t + 3]; we let aA,i and bA,i be the left and right ∈ L ∈ endpoints of IA,i, respectively. Since the width of f is at most t, for every (A, B) , ∈ L there do not exist t + 2 pairwise intersecting members of A by Helly’s property. For each C (A, B) , since A = 2(t + 1) + 1, by repeatedly greedily choosing an interval in A with ∈L |C | C smallest bi among all intervals in A disjoint from the intervals that have been chosen, there C exist three pairwise disjoint members in A; by symmetry, we may assume that IA, ,IA, ,IA, C 1 2 3 are pairwise disjoint, and bA, < aA, bA, < aA, . Since is essential, for every (A, B) , 1 2 ≤ 2 3 L ∈L every vertex in A B is adjacent to some vertex in A B, so IA, is contained in the interior ∩ − 2 of f(v) for every v A B. For every (A, B) , let jA be an integer in IA, such that ∈ ∩ ∈ L 2 v YA,2 : jA f(v) is as large as possible. Note that jA IA,2 is contained in the interior|{ ∈ of f(v) for∈ every}|v A B. ∈ ∈ ∩ ′ To show that is -duplicable, it suffices to show that H w for every integer w. L G ∧ L ∈ G ′ Let w be an arbitrary positive integer. We shall construct a path-decomposition of H w ∧ L

48 of width at most t. Note that it suffices to define a function g that maps each vertex of ′ ′ H w to a closed interval in R such that g(u) g(v) = for every uv E(H w ), and ∧ L ′ ∩ 6 ∅ ∈ ∧ L v V (H w ): x g(v) t + 1 for every x R, as we can stretch all intervals to |{ ∈ ∧ L ∈ }| ≤ ∈ make them having integral endpoints without changing the intersection patterns. For each u T(X,Y )∈L Y , define g(u) = f(u). For each (A, B) and v A B, ′ ∈ ′ ∈′ L ∈ − let v be the copy of v in YA,2 and denote f(v ) = [av, bv], and let f (v) = [(av aA,2) 1 1 ′ ′ − · , (bv aA,2) ]. That is, f (v) is obtained from f(v ) by first (bA,2−aA,2+1)2w − · (bA,2−aA,2+1)2w shifting and then scaling. For each (A, B) , by the definition of IA,2, we know that ′ ∈ L 1 Sv∈A−B f (v) is an interval with left endpoint 0 and with length less than 2w . For each ′ ′ ′ (A, B) and v A B, denote f (v) by [av, bv], and for each i [w], let g map the i-th ∈L ∈i−1 − ′ i−1 ′ ∈ copy of v to [jA + w + av, jA + w + bv]. Clearly, for distinct i1, i2 [w], g maps the i1-th ∈ 1 copy of A B and the i2-th copy of A B into disjoint intervals contained in [jA, jA +1 2w ]. − − ′ − Then it is straight forward to show that g(u) g(v) = for every uv E(H w ). And ′ ∩ 6 ∅ ∈ ∧ L for every x R, v V (H w ): x g(v) t + 1 by the definition of jA for each (A, B) .∈ This proves|{ ∈ the corollary.∧ L ∈ }| ≤ ∈L 6.2.2 Minor-closed families with topological properties Another extensively studied minor-closed family is the class of linkless embeddable graphs and flat embeddable graphs. A graph is linkless embeddable if it can be embedded in R3 such that any two disjoint cycles are unlinked (in the topology sense). A graph is flat embeddable if it can be embedded in R3 such that every cycle is the boundary of an open disk disjoint from the embedding. (See [67] for a survey about these two notions.) It is easy to see that the classes of linkless embeddable or flat embeddable graphs are minor-closed. Robertson, Seymour and Thomas [68] proved that linkless embeddable graphs are equivalent to flat embeddable graphs and proved that a graph is linkless embeddable if and only if it does not contain any graph in the Petersen family as a minor. The Petersen family consists of the graphs that can be obtained from K6 by repeatedly applying ∆Y -operations or Y ∆- operations. There are seven graphs in the Petersen family, and the Petersen graph is one of them. Linkless embeddable graphs are related to the Colin de Verdi`ere parameter. Colin de Verdi`ere [11, 12] introduced a parameter µ(G) for any graph G, motivated by the study of the maximum multiplicity of the second eigenvalue of certain Schr¨odinger operators. It is defined to be the largest corank of certain matrices associated with G. For any integer k, the class of graphs with µ k is minor-closed [11]. Many graphs with certain topological properties can be characterized≤ by using this algebraic parameter. For example, µ(G) 1 if ≤ and only if G is a disjoint union of paths [11]; µ(G) 2 if and only if G is outerplanar [11]; µ(G) 3 if and only if G is planar [11]; µ(G) 4≤ if and only if G is linkless embeddable [52, 67,≤ 68]. See [42] for a survey. ≤

Corollary 6.15 Let t be a positive integer. Let be the class of all graphs G with µ(G) t. Let H be a graph with µ(H) t. Then ex(H, G, n) = Θ(nk), where k is the maximum≤ size of an essential independent collection≤ of separationsG of H of order at most t 1 such that − every its torso L satisfies µ(L) t. ≤

49 Proof. It is shown in [42] that µ(Kt,t+3) = t + 1. Since is minor-closed, no graph in G k G contains a 2 V (H) -shallow Kt,t+3-minor. So ex(H, , n) = Θ(n ) by Corollary 5.7, where k is the maximum| | size of a -duplicable independentG collection of separations of order at G most t 1. By [42, Theorem 2.10, Corollary 2.11], is closed under ( t 1)-sum. By Proposition− 6.2 and Corollary 6.6, k equals the maximumG size of an essential≤ − independent collection of separations of H of order at most t 1 whose every torso is in . − G Recall that µ(G) 4 if and only if G is linkless embeddable [52, 67, 68]. So Corollary 6.15 immediately implies≤ the following result for linkless embeddable graphs.

Corollary 6.16 Let be the class of linkless embeddable graphs. Let H be a linkless em- beddable graph. ThenGex(H, , n) = Θ(nk), where k is the maximum size of an essential independent collection of separationsG of H of order at most 3 such that every its torso is linkless embeddable.

Note that Corollary 6.16 can also be derived by using the characterization for linkless embeddable graphs by Robertson, Seymour and Thomas [68] in terms of Petersen family minors without considering µ, but we omit this direct proof. The characterization in [68] is also a key ingredient for showing the equivalence between µ 4 and linkless embeddability. Recall that µ(G) 3 if and only if G is planar [11]. So the≤ case µ 3 in Corollary 6.15 ≤ ≤ immediately implies the result for the class of planar graphs. The case for 3-connected H in this result was conjectured by Perles (see [2]) and independently proved by Wormald [73] and Eppstein [24]. On the other hand, this result for planar graphs is a special case of a recent result of Huynh, Joret and Wood [43] for graphs of bounded Euler genus. In Section 6.3, we will show that Corollary 5.7 implies an even stronger result that allows crossings in drawings in surfaces of bounded Euler genus. Since µ(G) 2 if and only if G is outerplanar [11], the case µ 2 in Corollary 6.15 ≤ ≤ implies the following result about outerplanar graphs. (A cut-vertex of a graph is a vertex whose deletion increases the number of components. A block of a graph H is the maximal connected subgraph L of H such that L has no cut-vertex. A end-block of H is a block of H containing at most one cut-vertex of H.)

Corollary 6.17 Let be the class of outerplanar graphs. Let H be an outerplanar graph. Then ex(H, , n)=Θ(Gnk), where k is the number of end-blocks of H. G Proof. Since µ(G) 2 if and only if G is outerplanar, Corollary 6.15 implies that ex(H, , n) ≤ G = Θ(nk), where k is the maximum size of an essential independent collection of separations of H of order at most 1 such that every its torso L is outerplanar. Note that the condition for torsos can be dropped since the maximum order of separations considered here is at most 1. And it is easy to see that the maximum size of an essential independent collection of separations of H of order at most 1 equals the number of end-blocks of H by seeing the block-tree.

The special case that H is 2-connected in Corollary 6.17 was proved by Eppstein [24]. Note that outerplanar graphs are exactly the graphs with stack number 1. We will consider graphs with bounded stack number in Section 6.4.3.

50 A graph is knotless embeddable if it can be embedded in R3 such that every cycle forms a trivial knot. Knotless embeddable graphs share some features with linkless embeddable graphs, but they are significantly more complicated. For example, even though the class of knotless embeddable graphs is a minor-closed family, the complete list of minor-minimal non-knotless embeddable graphs remains unknown. In contrast to the known complete list of 7 graphs in the Petersen family for linkless embeddable graphs, the current incomplete list of minor-minimal non-knotless embeddable graphs contains more than 200 graphs [34], including K7 [13] and K3,3,1,1 [27]. See [26] for a survey. Corollary 5.7 can be applied to the class of knotless embeddable graphs as well. However, since structures of knotless embeddable graphs are far from being well-understood, and in particular it seems unknown whether the class of knotless embeddable graphs is closed under ( 4)-sum, we only obtain less explicit result. ≤ Corollary 6.18 Let be the class of knotless embeddable graphs. Let H be a knotless G embeddable graph. Then the following statements hold.

1. ex(H, , n) = Θ(nk), where k is the maximum size of an essential -duplicable inde- pendentG collection of separations of H of order at most 4. G

2. ex(H, , n)= O(nk), where k is the maximum size of an essential independent collec- tion ofG separations of H of order at most 4 whose torsos are knotless embeddable.

3. If is closed under ( 4)-sum, then ex(H, , n) = Θ(nk), where k is the maximum G ≤ G size of an essential independent collection of separations of H of order at most 4 whose torsos are knotless embeddable.

Proof. By [69], K5,5 . Since is minor-closed, no graph in contains a 2 V (H) -shallow 6∈ G Gk G | | K5,5-minor. So ex(H, , n) =Θ(n ) by Corollary 5.7, where k is the maximum size of a - duplicable independentG collection of separations of order at most 4. By Proposition 6.2,Gk equals the maximum size of an essential -duplicable independent collection of separations of H of order at most 4. So Statement 1G holds. Since is minor-closed, if is an essential -duplicable independent collection of separations of HG, then every torso ofL belongs to . G L G So Statement 2 holds. Statement 3 immediately follows from Corollary 6.6.

We remark that the special cases that H is a tree for Corollaries 6.15, 6.16 and 6.18 were proved by Huynh and Wood [44].

6.3 Topological minor-closed families We consider topological minor-closed but not minor-closed classes in this subsection. The class of all graphs with no Kt-topological minor is a typical example.

Corollary 6.19 Let t be a positive integer. Let be the class of graphs containing no Kt- G k topological minor. Then for every Kt-topological minor free graph H, ex(H, , n) = Θ(n ), where k is the maximum size of an essential independent collection of separationsG of H of L order at most t 1 such that every torso of is Kt-topological minor free. − L

51 Proof. Since every graph in is Kt-topological minor free, every graph in has no G G (1, 2t V (H) +1)-model for a 2 V (H) -shallow Kt, t -minor. So by Corollary 5.7 and Proposi- | | | | (2) tion 6.2, ex(H, , n)=Θ(nk), where k equals the maximum size of an essential -duplicable independent collectionG of separations of H of order at most t 1. To prove thisG corollary, it − suffices to prove that is closed under ( t 1)-sum by Corollary 6.6. Suppose to the contraryG that there exist≤ −G ,G and an integer q with 0 q t 1 1 2 ∈ G ≤ ≤ − such that the q-sum G of G and G contains a subdivision of Kt. For each i [2], let Si 1 2 ∈ be the subset of V (Gi) consisting of the q vertices identified with vertices in G3−i. Since S1 is a clique in G1 and S2 is a clique in G2, some branch vertex v1 of this subdivision is in V (G) V (G2) and some branch vertex is in V (G) V (G1). Since Kt is (t 1)-connected, q = t −1 and there exist t 1 disjoint paths in G from− v to S . Since S is− a clique of size − − 1 1 1 1 t 1 in G , G contains a subdivision of Kt, a contradiction. − 1 1

K3,t-topological minor free graphs are also of particular interests since every graph em- beddable in a surface of Euler genus at most g is K3,2g+3-topological minor free. Corollary 6.20 Let s, t be positive integers with s 3 and s t. Let be the class of graphs ≤ ≤ G containing no Ks,t-topological minor. Then for every Ks,t-topological minor free graph H, ex(H, , n)= Θ(nk), where k is the maximum size of an essential independent collection G L of separations of H of order at most s 1 such that every torso of is Ks,t-topological minor − L free.

Proof. If some graph G in has a (1, 2s V (H) +1)-model for a 2 V (H) -shallow Ks,t-minor, G | | | | then since s 3, every vertex of Ks,t of degree greater than 3 corresponds to one vertex in ≤ this shallow minor, so G contains a Ks,t-topological minor, a contradiction. Since t s, Ks,t is s-connected. Then this corollary immediately follows from Corollary 6.8. ≥

Arguably the most well-known topological minor-closed but non-minor-closed class is the class of graphs with bounded crossing number. A surface is a non-null connected 2-dimensional compact manifold without boundary. Let Σ be a surface. A drawing of a graph is a mapping that maps vertices to points Σ injectively and maps each edge to a curve in Σ connecting its ends internally disjoint from the points embedding the vertices such that no point in Σ belongs to the interior of at least three of those curves; a crossing of this drawing is a point that belongs to the intersection of the interior of two of those curves. The Σ-crossing number of a graph G is the minimum nonnegative integer k such that G has a drawing in Σ with at most k crossings. When Σ is the sphere, the Σ-crossing number is called the crossing number. Note that graphs with Σ-crossing number 0 are exactly the graphs that can be drawn in Σ with no crossing. It is easy to see that the class of graphs with Σ-crossing number at most a fixed integer k is topological minor-closed but not minor-closed. See [70] for a survey about crossing number. Recall that Wormald [73] and Eppstein [24] proved that ex(H, , n) = Θ(n) when is the set of planar graphs and H is a 3-connected . Huynh,G Joret and WoodG [43] generalized this result by determining the value k such that ex(H, , n) =Θ(nk) when is the class of graphs of bounded Euler genus and H is an arbitrary graphG in . CorollaryG 5.7 G leads to a more general result: it determines ex(H, , n) up to a constant factor for the class of graphs with Σ-crossing number at most t for anyG surface Σ and nonnegative integer t.

52 For an independent collection of separations of a graph H, the central torso of is L L the graph obtained from H[T(A,B)∈L B] by adding edges such that for every (A, B) , A B is a clique; every edge in the central torso of whose both ends are in A B for some∈ L ∩ L ∩ (A, B) is called a peripheral edge; every torso of that is not the central torso is called a peripheral∈L torso. L Lemma 6.21 Let Σ be a surface. Let t be a nonnegative integer. Let be the class of graphs G with Σ-crossing number at most t. Let be an essential independent collection of H of order at most 2. Then is -duplicable if andL only if every peripheral torso of is planar and L G L the central torso of can be drawn in Σ with at most t crossings such that every peripheral edge does not containL any crossing. Proof. It suffices to show that if is -duplicable, then every peripheral torso of is L G L planar and the central torso of can be drawn in Σ with at most t crossings such that every peripheral edge does not containL any crossing, since the converse statement is obvious. Assume that is -duplicable. Hence for every positive integer w, H w can be drawn L G ∧ L in Σ with at most t crossings, and we denote such a drawing by Dw. Since is essential, for L every (A, B) with A B = 2, there exists a path PA in H[A] between the two vertices ∈L | ∩ | in A B with length at least two. Since every crossing is contained in at most two edges, by ∩ using the drawing D2t+1, H can be drawn in Σ with at most t crossings such that for every (A, B) with A B = 2, no edge in PA contains an crossing, so the central torso of ∈ L | ∩ | L can be drawn in Σ with at most t crossings such that every peripheral edge does not contain any crossing. In addition, by using the drawing D2g+2t+3, where g is the Euler genus of Σ, we know that for every (A, B) , H[A] g (A B) can be drawn in Σ with no crossing, ∈L ∧2 +2 ∩ so by [5, Theorem 1.1] (or [56, Theorem 1]), H[A] 2 (A B) can be drawn in the sphere with no crossing, and hence the peripheral torso corresponding∧ ∩ to (A, B) is planar. Corollary 6.22 Let Σ be a surface. Let t be a nonnegative integer. Let be the class of G graphs with Σ-crossing number at most t. Let H be a graph in . Then ex(H, , n)=Θ(nk), where k is the maximum size of an essential independent collectionG of separationsG of H of order at most 2 whose every peripheral torso is planar and whose central torso can be drawn in Σ with at most t crossings such that every peripheral edge does not contain any crossing. Proof. If L is a graph that can drawn in Σ with at most t crossings, then adding a vertex on each crossing leads to a new graph L′ with V (L′) V (L) + t and E(L′) E(L) . | |≤| | | |≥| | So Euler’s formula implies that there exists a positive integer q such that K ,q . If some 3 6∈ G graph G in contains a (1, 6 V (H) + 1)-model for a 2 V (H) -shallow K ,q-minor, then G G | | | | 3 contains a subdivision of K3,q since each of the branch sets corresponding to vertices in K3,q with degree greater than 3 has size 1. Since is topological minor-closed, no graph in G G contains a (1, 6 V (H) +1)-model for a 2 V (H) -shallow K3,q-minor. Since every| topological| minor-closed class| has| bounded expansion, by Corollary 5.7 and Proposition 6.2, ex(H, , n) = Θ(nk), where k is the maximum size of an essential - G G duplicable independent collection of separations of H of order at most 2. Then this corollary follows from Lemma 6.21.

We remark that the case t = 0 implies the result of Huynh, Joret and Wood [43] for graphs with bounded Euler genus.

53 6.4 Non-topological minor-closed classes In this subsection, we give examples for non-topological minor-closed classes but still with bounded expansion.

6.4.1 With some subgraphs forbidden It is natural to study ex(H, , n), where is a class of planar graphs with no subgraph G G isomorphic to certain fixed graph. We can make it more general: what is ex(H, , n), where is a class of graphs satisfying a topological minor-closed property and with noG subgraph isomorphicG to any member in a fixed set of graphs? Such as a class is not topological minor-closed but still has bounded expansion. Corollary 5.7 can deal with such classes. One example of such a question is the following conjecture proposed by Gy˝ori, Paulos, Salia, Tompkins and Zamora [37], and they proved the case for ℓ = 2 and p 5. ≥ Conjecture 6.23 ([37, Conjecture 2.10]) For every integer ℓ 2 and for every suffi- ciently large integer p, if H is the p-cycle and is the class of all planar≥ graphs with no even G ⌊ p ⌋ cycle of length between 4 and 2ℓ, then ex(H, , n)=Θ(n ℓ+1 ). G Here we provide the following example (Corollary 6.24) to show how to use Corollary 5.7 to solve questions in this kind; Conjecture 6.23 follows from its special case that Σ is the sphere, t = 0, and H is a p-cycle, since it is easy to construct a collection of separations of the p p-cycle with size ℓ+1 satisfying the condition mentioned in Corollary 6.24 by considering edge-disjoint paths⌊ of⌋ length ℓ + 1; the special case that Σ is the sphere, t = 0 and H is a tree was also proved in [37].

Corollary 6.24 Let Σ be a surface. Let t be a nonnegative integer. Let ℓ be a positive integer. Let be the class of all graphs with Σ-crossing number at most t and with no even cycle of lengthG between 4 and 2ℓ. Let H be a graph in . Then ex(H, , n)=Θ(nk), where k is the maximum size of an essential independent collectionG of separationsG of H of order L at most 2 such that

1. every peripheral torso is planar,

2. the central torso can be drawn in Σ with at most t crossings such that no peripheral edge contains a crossing, and

3. for every (A, B) with A B = 2, there exists no path in H[A] between the two ∈ L | ∩ | vertices in A B with length between 2 and ℓ. ∩ Proof. Let ′ be the class of graphs with Σ-crossing number at most t. Since ′ is topological minor-closed,G ′ has bounded expansion. Since is a subset of ′, for any nonnegativeG integer G G G r, any r-shallow minor of a member of is an r-shallow minor of a member of ′. So has bounded expansion. And as shown inG the proof of Corollary 6.22, no graph inG ′ (andG G hence in ) contains a (1, 6 V (H) + 1)-model for a 2 V (H) -shallow K ,q-minor for some G | | | | 3 integer q. So by Corollary 5.7 and Proposition 6.2, ex(H, , n) = Θ(nk), where k is the maximum size of an essential -duplicable independent collectionG of separations of H of G 54 order at most 2. Since every -duplicable collection is ′-duplicable, by Lemma 6.21, every essential -duplicable collectionG satisfies Statements 1 andG 2. In addition,G if (A, B) is a member of a -duplicable independent collection of separations G of H with A B = 2, then there is no path in H[A] between the two vertices in A B with length between| ∩ 2| and ℓ, for otherwise H[A] (A B) contains an even cycle of length∩ between ∧2 ∩ 4 and ℓ. Hence every essential independent collection of separations of H of order at most 2 satisfies Statements 1-3. On the other hand, it is easy to see that every essential independent collection of separations of order at most 2 satisfying Statements 1-3 is -duplicable. This G proves the corollary.

6.4.2 Linearly many crossings For a surface Σ and a nonnegative integer t, a graph is (Σ, t)-planar if it can be drawn in Σ such that every edge contains at most t crossings. When Σ is the sphere, (Σ, t)-planar graphs are called t-planar graphs in the literature. The case t = 1 is of particular interests in the literature. See [47] for a survey. (Σ, t)-planar graphs are almost equivalent to (g, t)- planar graphs which are the graphs that can be drawn in a surface of Euler genus at most g such that every edge contains at most t crossings. Note that every graph with Σ-crossing number at most t is (Σ, t)-planar. But in general, the number of crossings of a (Σ, t)-planar graph can be linear in the number of its edges. For a surface Σ and a nonnegative real number t, a graph G is t-close to Σ if for every subgraph L of G, L can be drawn in Σ with at most t E(L) crossings. So (Σ, t)-planar graphs are t-close to Σ. Neˇsetˇril, Ossona de Mendez and| Wood| [63] showed that the class of (Σ, t)-planar graphs has bounded expansion when Σ is the sphere; Dujmovi´c, Eppstein and Wood [17] further showed that for every surface Σ, the class of (Σ, t)-planar graphs has bounded layered tree-width and hence has bounded expansion. In fact, the class of graphs that are t-close to Σ also has bounded expansion. This fact seems not appeared in the literature but might be well-known by the community. Here we include a proof of this fact for completeness; our proof is a slight modification of the proof of a result in [65]. Proposition 6.25 For any surface Σ and nonnegative real number t, the class of graphs that are t-close to Σ has bounded expansion. Proof. By [21, Theorem 11], it suffices to show that there exists f : N 0 R such that if L is a graph such that some graph G that is t-close to Σ contains a subgraph∪{ }→H isomorphic to an ([ℓ] 0 )-subdivision of L for some nonnegative integer ℓ, then the average degree of L is at most∪{ f}(ℓ). By definition, H is t-close to Σ, so H can be drawn in Σ with at most t E(H) crossings. Since H is an ([ℓ] 0 )-subdivision of L, L can be drawn in Σ with at | | ∪{ } most t E(H) edge-corssings, and E(H) (ℓ +1) E(L) . So this drawing of L has at most | | | | ≤ | | t(ℓ + 1) E(L) crossings. By [65, Lemma 4.6], E(L) ct,ℓ, V (L) for some number ct,ℓ, | | | | ≤ Σ| | Σ only dependent on t, ℓ and Σ. So we are done by defining f(ℓ)=2ct,ℓ,Σ for every nonnegative integer ℓ. Lemma 6.26 Let Σ be a surface. Let t be a nonnegative integer. Let be the class of G (Σ, t)-planar graphs. Let be an essential independent collection of H of order at most 2. Then is -duplicable ifL and only if L G 55 1. the central torso of can be drawn in Σ such that every edge contains at most t crossings, and no peripheralL edge contains a crossing, and 2. for every (A, B) , the peripheral torso of corresponding to (A, B) can be drawn in the sphere such∈ Lthat every edge contains atL most t crossings, and if A B = 2, | ∩ | then the edge with both ends in A B does not contain any crossing. ∩ Proof. It is easy to see that if satisfies Statements 1 and 2, then is -duplicable. So L L G we may assume that is -duplicable and show that satisfies Statements 1 and 2. L G L Since is -duplicable, H t|L||E(H)|(2g+3)+t|E(H)| can be drawn in Σ such that every edge contains atL mostG t crossings. Since∧ every edge containsL at most t crossings, H ∧t|L||E(H)|(2g+3)L can be drawn in Σ such that no crossing is contained in one edge with both ends in T(X,Y )∈L Y and one edge with at least one end not in Y . For each (A, B) and each copy of T(X,Y )∈L ∈L A in H , there are at most t E(H) crossings contained in an edge with both ∧t|L||E(H)|(2g+3) L | | ends in this copy of A. So by greedily sacrificing some copies of A for (A, B) , we know ∈L that H 2g+2 can be drawn in Σ such that every crossing is contained in two edges with both ends∧ in L Y or in two edges with both ends in a copy of A for some (A, B) . T(X,Y )∈L ∈L Since is essential, in this drawing of H 2g+2 , for each (A, B) with A B = 2, there existsL a curve contained in the drawing∧ ofL a copy of A connecting∈ L the two| vertices∩ | in A B. So the central torso of can be drawn in Σ such that every edge contains at most t crossings,∩ and no peripheral edgeL contains a crossing. Hence Statement 1 holds. In addition, for each (A, B) , by using the aforementioned drawing of H g , we ∈L ∧2 +2 L know H[A] 2g+2 (A B) can be drawn in Σ such that every crossing is contained in two edges in the∧ same copy∩ of H[A] but not contained in any edge with both ends in A B. ∩ By adding a vertex on each crossing of this drawing of H[A] 2g+2 (A B), we obtain a graph W that can be draw in Σ with no crossing, and every component∧ ∩ of W (A B) is − ∩ contained in the subdrawing of one copy of H[A] (A B). So by [5, Theorem 1.1] (or [56, − ∩ Theorem 1]), the subgraph of W induced by H[A] 2 (A B) and the vertices corresponding to their crossings can be drawn in the sphere with∧ no crossing.∩ Hence the peripheral torso corresponding to (A, B) can be drawn in the sphere such that every edge contains at most t crossings, and if A B = 2, the edge with both ends in A B does not contain any crossing. So Statement 2 holds.| ∩ | ∩

Corollary 6.27 Let Σ be a surface. Let t be a nonnegative integer. Let be the class of G (Σ, t)-planar graphs. Let H be a graph in . Then ex(H, , n) = Θ(nk), where k is the maximum size of an essential independent collectionG of separationsG of H of order at most 2 such that 1. the central torso of can be drawn in Σ such that every edge contains at most t crossings, and no peripheralL edge contains a crossing, and 2. for every (A, B) , the peripheral torso of corresponding to (A, B) can be drawn in the sphere such∈ Lthat every edge contains atL most t crossings, and if A B = 2, | ∩ | then the edge with both ends in A B does not contain any crossing. ∩ Proof. Let q be an integer such that some graph in has a (1, 6 V (H) + 1)-model for a G | | 2 V (H) -shallow K ,q-minor. Then some ([6 V (H) ] 0 )-subdivision L of K ,q belongs to | | 3 | | ∪{ } 3 G 56 since each of the branch sets corresponding to vertices in K3,q with degree greater than 3 has size 1. So L can be drawn in Σ with at most t E(L) crossings. Since L is a ([6 V (H) ] 0 )- | | | | ∪{ } subdivision of K ,q, K ,q can be drawn in Σ with at most t E(L) t(6 V (H) +1) E(K ,q) 3 3 | | ≤ | | | 3 | crossings. So K3,q is t(6 V (H) + 1)-close to Σ. By [65, Lemma 4.8], q is upper bounded by a constant only depended| on Σ,| t and V (H) . That is, there exists a large integer q∗ such | | that no graph in contains a (1, 6 V (H) + 1)-model for a 2 V (H) -shallow K3,q∗ -minor. By Proposition 6.25,G Corollary 5.7 and| Proposition| 6.2, k equals| the| maximum size of an essential -duplicable independent collection of separations of H of order at most 2. Then G this corollary follows from Lemma 6.26.

Proposition 6.25, Corollary 5.7 and Proposition 6.2 also immediately lead to the following corollary for the class of graphs t-close to Σ; but the explicit descriptions for -duplicable collection is more complicated, so we omit it. G

Corollary 6.28 Let Σ be a surface. Let t be a nonnegative real number. Let be the class of graphs that are t-close to Σ. Let H be a graph in . Then ex(H, , n)= Θ(Gnk), where k G G is the maximum size of an essential -duplicable independent collection of separations of H of order at most 2. G

The case t = 0 in either Corollaries 6.27 or 6.28 coincides the result for the class of graphs of bounded Euler genus proved in [43]. And the special case that H is a tree in either Corollaries 6.27 or 6.28 was proved in [44].

6.4.3 Higher dimensional objects For a positive integer k, a graph G has a k-stack layout if there exist an ordering σ of G and a partition E , E , ..., Ek of E(G) into k (not necessarily non-empty) sets such that for every { 1 2 } i [k], there do not exist edges u v ,u v Ei such that σ(u ) < σ(u ) < σ(v ) < σ(v ). ∈ 1 1 2 2 ∈ 1 2 1 2 The stack number of a graph G is the minimum k such that G has a k-stack layout. Each stack layout is also called a which is an embedding of G in a union of half-planes in R3 sharing a common line and all vertices are embedded in this line. And stack number is also called book thickness and page number. Stack number and book embeddings have been extensively studied in theoretical computer science and graph drawing. (See [20] for a survey.) It is not hard to see that graphs with stack number 1 are exactly the outerplanar graphs (for example, see [7]). So graphs with bounded stack number can be viewed as generalizations of outerplanar graphs. In addition, even though classes of graphs with bounded stack numbers are not topological minor-closed families, Blankenship [8] proved that every graph in a fixed minor-closed family has bounded stack number. As for extremal aspects, Eppstein [24] asks the following question.

Question 6.29 ([24]) What are the graphs H for which ex(H, , n)= O(n) when is the class of graphs with stack number at most k? G G

Corollary 5.7 gives an answer to this question.

57 Corollary 6.30 Let t be a positive integer. Let be the class of graphs with stack number at most t. Then for every graph H with stack numberG at most t, ex(H, , n)=Θ(nk), where k is the maximum size of an essential -duplicable independent collectionG of separations of G H.

Proof. Clearly, is monotone. By [63, Theorem 8.4], has bounded expansion. So this corollary immediatelyG follows from Corollary 5.7 and PropositionG 6.2.

Stacks are one of the most fundamental data structures. Another fundamental structure is a queue. For a positive integer k, a graph G has a k-queue layout if there exist an ordering σ of G and a partition E , E , ..., Ek of E(G) into k (not necessarily non-empty) sets such { 1 2 } that for every i [k], there do not exist edges u v ,u v Ei such that σ(u ) < σ(u ) < ∈ 1 1 2 2 ∈ 1 2 σ(v2) < σ(v1). The queue number of a graph G is the minimum k such that G has a k-queue layout. See [20] for a survey about queue numbers and queue layouts. Queue number and stack number share similar features. For example, classes of graphs with bounded queue number are not (topological) minor-closed, and Dujmovi´c, Joret, Micek, Morin, Ueckerdt and Wood [19] proved that every proper minor-closed class has bounded queue number. However, even though they look similar, the connection between these two notions are unclear. It was recently shown that stack number cannot be upper bounded by queue number [16]. But it remains open whether queue number can be upper bounded by stack number or not. We also have the analogy of Corollary 6.30 for queue number.

Corollary 6.31 Let t be a positive integer. Let be the class of graphs with queue number at most t. Then for every graph H with queue numberG at most t, ex(H, , n)=Θ(nk), where G k is the maximum size of an essential -duplicable independent collection of separations of H. G

Proof. Clearly, is monotone. By [63, Theorem 7.4], has bounded expansion. So this G G corollary immediately follows from Corollary 5.7 and Proposition 6.2.

Classes of graphs with strongly sublinear separators are typical examples of classes of graphs with bounded expansion besides topological minor-closed classes. For a function f : N 0 R, we say that a graph G admits f-balanced separators if ∪{ } → for every subgraph H of G, there exists a separation (A, B) of H with A B f( V (H) ) such that A B 2 V (H) and B A 2 V (H) . Note that for| every∩ | subgraph ≤ | H|, | − | ≤ 3 | | | − | ≤ 3 | | every separation (A, B) of G[V (H)] is a separation of H, so the above condition can be simplified by only requiring every induced subgraph of G having a desired separation. A class of graphs admits strongly sublinear balanced separators if there exist constants c 1 G ≥ and 0 < δ 1 and a function f : N 0 R defined by f(x) = cx1−δ for every x, such that every graph≤ in admits f-balanced∪{ } separators. → Strongly sublinearG separators are useful for designing divide-and-conquer algorithms and inductive proofs. A celebrated theorem of Alon, Seymour and Thomas [3] states that every minor-closed class admits strongly sublinear separators. On the other hand, Dvoˇr´ak and Norin [23] proved that every class of graphs admitting strongly sublinear separators have

58 bounded expansion. So Corollary 5.7 can be applied to all hereditary classes of graphs admitting strongly sublinear separators. Here we just include one example for such classes. The intersection graph of a set is a graph G such that there exists a bijection ι from C V (G) to such that for any distinct u, v V (G), uv E(G) if and only if ι(u) ι(v) = . For positiveC integers k and d, a k-ply∈ neighborhood∈ system in Rd is a set of∩ closed6 ∅ balls in Rd such that no point in Rd is contained in the interior of k members of this set. Miller, Teng, Thurston and Vavasis [57] proved that the class of intersection graphs of k-ply neighborhood systems in Rd admits strongly sublinear balanced separators. Hence such as a class is hereditary and has bounded expansion. Therefore, Corollary 5.7 immediately implies the following.

Corollary 6.32 Let k and d be positive integers. Let be the class of intersection graphs of k-ply neighborhood systems in Rd. Let H be a graphG in . Then ex(H, , n) = Θ(nk), where k is the maximum size of a -duplicable independent collectionG of separationsG of H. G Note that the k-ply neighborhood system is a special case of a much more general result of Dvoˇr´ak, McCarty and Norin [22] about intersection graphs of certain sets ensuring strongly sublinear balanced separators. We refer readers to [22] for details.

7 Concluding remarks

In this paper, we determine the maximum number of homomorphisms in to an n- H vertex labelled graph in up to a multiplicative constant, where is any hereditary class with bounded expansionG and is a consistent set of homomorphismsG from a fixed labelled graph H to (Theorem 1.4 andH Corollary 5.7). Classes with bounded expansion are general G classes of sparse graphs, including many graph classes with some geometric and combinatorial properties. Our results are generalizations of a number of known results and solve a number of open questions, as shown in Sections 1 and 6, about counting the number of H-subgraphs, H-induced subgraphs, and homomorphisms from H. Moreover, our machinery allows us to determine the exact value of the asymptotic logarithmic density for in nowhere dense H classes which are the most general classes of sparse graphs in sparsity theory (Theorem 1.7 andG Corollary 5.9) and determine the maximum number of H-subgraphs in the classes of d-degenerate graphs with any fixed d up to a multiplicative constant (Theorem 1.9). For most of the applications of the aforementioned results stated in this paper, we only require that is monotone and only consider the number of unlabelled H-subgraphs. The G proof of our main results can be significantly simplified in those settings. But our focus is on proving more general results. In addition, we put no efforts on optimizing the hidden constants in our theorems. On the other hand, as our result determines the number of H-subgraphs and the number of homomorphisms from H up to a multiplicative constant, now we know how to normalize them to define the H-subgraph density or the density for homomorphisms from H, for any fixed graph H. This immediately leads to the question whether one can develop the theory about flag algebra or homomorphism inequalities for graphs in bounded expansion classes (or even nowhere dense classes) to compute the number of H-subgraphs up to lower order terms. More detailed discussions can be found in Section 8 in [43].

59 References

[1] D. J. Aldous, Tree-valued Markov chains and Poisson-Galton-Watson distributions, in: Microsurveys in Discrete Probability (D. Aldous and J. Propp, editors), DIMACS Ser. Discrete Math. Theoret. Comput. Sci. 41(1998) Amer. Math. Soc., Providence, RI. (1998), 1–20.

[2] N. Alon and Y. Caro, On the number of subgraphs of prescribed type of planar graphs with a given number of vertices, in: Convexity and graph theory, 25–36, North-Holland Math. Stud., 87, Ann. Discrete Math., 20, North-Holland, Amsterdam, 1984.

[3] N. Alon, P. Seymour and R. Thomas, A separator theorem for nonplanar graphs, J. Amer. Math. Soc. 3 (1990), 801–808.

[4] N. Alon and C. Shikhelman, Many T -copies in H-free graphs, J. Combin. Theory Ser. B 121 (2016), 146–172.

[5] D. Archdeacon, The nonorientable genus is additive, J. Graph Theory 10 (1986), 363– 383.

[6] I. Benjamini and O. Schramm, Recurrence of distributional limits of finite planar graphs, Electron. J. Probab. 6 (2001), 1–13.

[7] F. Bernhart and P. C. Kainen, The book thickness of a graph, J. Combin. Theory Ser. B 27 (1979), 320–331.

[8] R. Blankenship, Book embeddings of graphs, Ph.D. Thesis, Department of Mathematics, Louisiana State University, USA, 2003.

[9] C. Borgs, J. Chayes, L. Lov´asz, V. T. S´os and K. Vesztergombi, Counting graph ho- momorphisms, In: Klazar M., Kratochv´ılJ., Loebl M., Matouˇsek J., Valtr P., Thomas R. (eds), Topics in Discrete Mathematics, 315–371, Algorithms Combin., 26, Springer, Berlin (2006).

[10] Z. Chase, The maximum number of triangles in a graph of given maximum degree, Adv. Comb. (2020), Paper No. 10.

[11] Y. Colin de Verdi`ere, Sur un nouvel invariant des graphes et un crit`ere de planarit´e, J. Combin. Theory Ser. B 50 (1990), 11-21.

[12] Y. Colin de Verdi`ere, On a new graph invariant and a criterion for planarity, in: Graph structure theory, 137–147, Contemp. Math., 147, Amer. Math. Soc., Providence, RI, 1993.

[13] J. H. Conway and C. McA. Gordon, Knots and links in spatial graphs, J. Graph Theory 7 (1983), 445–453.

[14] J. Cummings and M. Young, Graphs containing triangles are not 3-common, J. Comb. 2 (2011), 1–14.

60 [15] J. Cutler and A.J. Radcliffe, The maximum number of complete subgraphs in a graph with given maximum degree, J. Combin. Theory Ser. B 104 (2014), 60–71. [16] V. Dujmovi´c, D. Eppstein, R. Hickingbotham, P. Morin, and D. R. Wood, Stack-number is not bounded by queue-number, Combinatorica, accepted (2021). arXiv:2011.04195. [17] V. Dujmovi´c, D. Eppstein and D. R. Wood, Structure of graphs with locally restricted crossings, SIAM J. Discrete Math. 31 (2017), 805–824. [18] V. Dujmovi´c, G. Fijavˇz, G. Joret, T. Sulanke and D. R. Wood, On the maximum number of cliques in a graph embedded in a surface, European J. Combin. 32 (2011), 1244–1252. [19] V. Dujmovi´c, G. Joret, P. Micek, P. Morin, T. Ueckerdt and D. R. Wood, Planar graphs have bounded queue-number, J. ACM 67 (2020), Art. 22, 38pp. [20] V. Dujmovi´cand D. R. Wood, On linear layouts of graphs, Discrete Math. Theor. Comput. Sci. 6 (2004), 339–357. [21] Z. Dvoˇr´ak, On forbidden subdivision characterizations of graph classes, European J. Combin. 29 (2008), 1321–1332. [22] Z. Dvoˇr´ak, R. McCarty and S. Norin, Sublinear separators in intersection graphs of convex shapes, SIAM J. Discrete Math. 35 (2021), 1149–1164. [23] Z. Dvoˇr´ak and S. Norin, Strongly sublinear separators and polynomial expansion, SIAM J. Discrete Math. 30 (2016), 1095–1101. [24] D. Eppstein, Connectivity, graph minors, and subgraph multiplicity, J. Graph Theory 17 (1993), 409–416. [25] P. Erd˝os and A. H. Stone, On the structure of linear graphs, Bull. Amer. Math. Soc. 52 (1946), 1087–1091. [26] E. Flapan, T. W. Mattman, B. Mellor, R. Naimi and R. Nikkuni, Recent developments in spatial graph theory, in: Knots, links, spatial graphs, and algebraic invariants, 81–102, Contemp. Math., 689, Amer. Math. Soc., Providence, RI, 2017. [27] J. Foisy, Intrinsically knotted graphs, J. Graph Theory 39 (2002), 178–187. [28] J. Fox and J. Pach, A separator theorem for string graphs and its applications, Combin. Probab. Comput. 19 (2010), 371–390. [29] J. Fox and F. Wei, On the number of cliques in graphs with a forbidden minor, J. Combin. Theory Ser. B 126 (2017), 175–197. [30] J. Fox and F. Wei, On the number of cliques in graphs with a forbidden subdivision or immersion, SIAM J. Discrete Math. 34 (2020), 2556–2582. [31] Z. F¨uredi and M. Simonovits, The history of degenerate (bipartite) extremal graph prob- lems, Erd˝os centennial, 169–264, Bolyai Soc. Math. Stud., 25, J´anos Bolyai Math. Soc., Budapest (2013).

61 [32] D. Gerbner, E. Gy˝ori, A. Methuku and M. Vizer, Generalized Tur´an problems for even cycles, J. Combin. Theory Ser. B 145 (2020), 169–213.

[33] D. Gerbner, T. M´esz´aros, A. Methuku and C. Palmer, Generalized rainbow Tur´an prob- lems, arXiv:1911.06642, (2019).

[34] N. Goldberg, T. W. Mattman and R. Naimi, Many, many more intrinsically knotted graphs, Algebr. Geom. Topol. 14 (2014), 1801–1823.

[35] A. Grzesik, On the maximum number of five-cycles in a triangle-free graph, J. Combin. Theory Ser. B 102 (2012), 1061–1066.

[36] O. Gurel-Gurevich and A. Nachmias, Recurrence of planar graph limits, Ann. of Math. 177 (2013), 761–781.

[37] E. Gy˝ori, A. Paulos, N. Salia, C. Tompkins and O. Zamora, Generalized planar Tur´an number, arXiv:2002.04579, (2020).

[38] E. Gy˝ori, A. Paulos, N. Salia, C. Tompkins and O. Zamora, The maximum number of paths of length three in a planar graph, arXiv:1909.13539, (2019).

[39] E. Gy˝ori, A. Paulos, N. Salia, C. Tompkins and O. Zamora, The maximum number of pentagons in a planar graph, arXiv:1909.13532, (2019).

[40] S. L. Hakimi and E. F. Schmeichel, On the number of cycles of length k in a maximal planar graph, J. Graph Theory 3 (1979), 69–86.

[41] H. Hatami, J. Hladk´y, D. Kr´al’, S. Norine and A. Razborov, On the number of pentagons in triangle-free graphs, J. Combin. Theory Ser. A 120 (2013), 722–732.

[42] H. van der Holst, L. Lov´asz and A. Schrijver, The Colin de Verdi`ere graph parameter, in: Graph theory and combinatorial biology, 29–85, Bolyai Soc. Math. Stud., 7, J´anos Bolyai Math. Soc., Budapest, 1999.

[43] T. Huynh, G. Joret and D. R. Wood, Subgraph densities in a surface, arXiv:2003.13777, (2020).

[44] T. Huynh and D. R. Wood, Tree densities in sparse graph classes, Canad. J. Math., accepted (2021). arXiv:2009.12989, (2020).

[45] C. Jagger, P. Sˇ´tov´ıˇcek and A. Thomason, Multiplicities of subgraphs, Combinatorica 16 (1996), 123–141.

[46] P. Keevash, D. Mubayi, B. Sudakov and J. Verstra¨ete, Rainbow Tur´an problems, Com- bin. Probab. Comput. 16 (2007), 109–126.

[47] S. G. Kobourov, G. Liotta and F. Montecchiani, An annotated bibliography on 1- planarity, Comput. Sci. Rev. 25 (2017), 49–67.

62 [48] D. Kr´al’, J. A. Noel, S. Norin, J. Volec and F. Wei, Non-bipartite k-common graphs, Combinatorica, to appear. arXiv:2006.09422.

[49] C. Lee and S. Oum, Number of cliques in graphs with a forbidden subdivision, SIAM J. Discrete Math. 29 (2015), 1999-2005.

[50] L. Lov´asz, Large networks and graph limits, American Mathematical Society Collo- quium Publications, 60. American Mathematical Society, Providence, RI, 2012.

[51] L. Lov´asz, Operations with structures, Acta Math. Hungar. 18 (1967), 321–328.

[52] L. Lov´asz and A. Schrijver, A Borsuk theorem for antipodal links and a spectral char- acterization of linklessly embeddable graphs, Proc. Amer. Math. Soc. 126 (1998), 1275– 1285.

[53] R. Lyons, Asymptotic enumeration of spanning trees, Combin. Probab. Comput. 14 (2005), 491–522.

[54] C.-H. Liu and F. Wei, Phase transition of degeneracy in minor-closed families, arXiv:1912.02375, (2019).

[55] W. Mader, Homomorphies¨atze f¨ur graphen, Math. Ann. 178 (1968), 154–168.

[56] G. L. Miller, An additivity theorem for the genus of a graph, J. Combin. Theory Ser. B 43 (1987), 25–47.

[57] G. L. Miller, S.-H. Teng, W. Thurston and S. A. Vavasis, Separators for sphere-packings and nearest neighbor graphs, J. ACM 44 (1997), 1–29.

[58] J. Neˇsetˇril and P. Ossona de Mendez, A unified approach to structural limits and limits of graphs with bounded tree-depth, Mem. Amer. Math. Soc. 263 (2020), no. 1272.

[59] J. Neˇsetˇril and P. Ossona de Mendez, Existence of modeling limits for sequences of sparse structures, J. Symb. Log. 84 (2019), 452–472.

[60] J. Neˇsetˇril and P. Ossona de Mendez, How many F ’s are there in G?, European J. Combin. 32 (2011), 1126–1141.

[61] J. Neˇsetˇril and P. Ossona de Mendez, On nowhere dense graphs, European J. Combin. 32 (2011), 600–617.

[62] J. Neˇsetˇril and P. Ossona de Mendez, Sparsity. Graphs, structures, and algorithms. Algorithms and Combinatorics, 28. Springer, Heidelberg, 2012.

[63] J. Neˇsetˇril, P. Ossona de Mendez and D. R. Wood Characterisations and examples of graph classes with bounded expansion, European J. Combin. 33 (2012), 350–373.

[64] J. Neˇsetˇril and A. Raspaud, Colored homomorphisms of colored mixed graphs, J. Combin. Theory Ser. B 80 (2000), 147–155.

63 [65] P. Ossona de Mendez, S. Oum and D. R. Wood, Defective colouring of graphs excluding a subgraph or minor, Combinatorica 39 (2019), 377–410.

[66] A. A. Razborov, Flag algebras, J. Symbolic Logic 72 (2007), 1239–1282.

[67] N. Robertson, P. D. Seymour and R. Thomas, A survey of linkless embeddings, in: Graph structure theory, 125–136, Contemp. Math., 147, Amer. Math. Soc., Providence, RI, 1993.

[68] N. Robertson, P. Seymour and R. Thomas, Sachs’ linkless embedding conjecture, J. Combin. Theory Ser. B 64 (1995), 185–227.

[69] M. Shimabara, Knots in certain spatial graphs, Tokyo J. Math. 11 (1988), 405–413.

[70] L. A. Sz´ekely, A successful concept for measuring non-planarity of graphs: the crossing number, Discrete Math. 276 (2004), 331–352.

[71] P. Tur´an, On an extremal problem in graph theory, Mat. Fiz. Lapok 48 (1941), 436–452.

[72] D. R. Wood, Cliques in graphs excluding a complete , Electron. J. Combin. 23 (2016), no. 3, Paper 3.18, 16 pp.

[73] N. C. Wormald, On the frequency of 3-connected subgraphs of planar graphs, Bull. Aus- tral. Math. Soc. 34 (1986), 309–317.

[74] A. A. Zykov, On some properties of linear complexes, Mat. Sbornik N.S. 24 (1949), 163–188.

64