• Nem Talált Eredményt

13 The dynamic program for traversing a vortex in a bounded genus graph

For the remainder of this section letG~ be an-vertex (0, g,1, p)-nearly embeddable graph.

Let H~ be the vortex inG, attached to some face~ F~. Let G~0 = G~ \(V(H~)\(F~)) and fix some embedding ψ of G~0 on a surface S of genus g. Let F be the symmetrization of F~. Let W~OPT be a closed walk in G~ that visits all vertices in H~ with minimum costG~(W~ ).

Fix a path-decomposition {Bv}v∈V(F) of H~ of widthp. We present a similar algorithm as in Section 12 for computing a walk traversing all vertices inV(H~) based on dynamic programming. By Lemma 54 we may assume w.l.o.g. thatG~ is facially normalized and cross normalized.

13.1 The dynamic program

LetQ be the set of all (possible closed) subpaths ofF. For any integerm, let Pm={A⊆ Q:|A| ≤m, for everyQ, Q0Awe have V(Q)∩V(Q0) =∅}

and let

P={A⊆ Q: For everyQ, Q0Awe have V(Q)∩V(Q0) =∅}.

For everyP ={Q1, . . . , Qm} ∈ P, letE(P) =Sm

i=1E(Qi) and letV(P) =Sm

i=1V(Qi).

For eachi∈ {1, . . . , m}, let ui andvi be the endpoints ofQi. Similar to the planar case, let H~P =H~ h

S

x∈V(P)Bx

i

. LetB=Sm

i=1(BuiBvi). LetCP be the set of all possible partitions ofB. LetDinP ={0, . . . , n}B, DPout ={0, . . . , n}B, that is, every element ofDPin∪ DPout is a functionf :B → {0, . . . , n}.

13.1.1 The dynamic programming table.

LetP=P324000g4. With these definitions, the dynamic programming table is indexed the exact same way as in the planar case. Also, apartial solution is a collection of walks inG.~ We say that a partial solutionSiscompatiblewith (P, φ) if the same conditions (T1)-(T5) as in the planar case are satisfied. The only difference is that instead ofBuBv, we haveB.

13.1.1.1 Merging partial solutions

We follow a similar approach as in the planar case. Let P = {Q1, . . . , Qm}, P1 = {Q01, . . . , Q0m0}, P2 = {Q001, . . . , Q00m00} ∈ P such that E(P1) 6= ∅, E(P2) 6= ∅, E(P1)∩ E(P2) = ∅, and E(P) = E(P1)∪E(P2). Let φ = (C, fin, fout, a, l, r, p) ∈ IP, φ1 = (C1, f1in, f1out, a1, l1, r1, p1)∈ IP1,φ2= (C2, f2in, f2out, a2, l2, r2, p2)∈ IP2.

Let S1 andS2 be partial solutions compatible with (P1, φ1) and (P2, φ2) respectively.

Similar to the planar case, we compute a partial solutionS compatible with (P, φ) as follows.

Merging phase 1: Joining the walks. For everywV(P1)∩V(P2), we check that for all xBwwe havef1in(x) =f2out(x) andf2in(x) =f1out(x). If not then the merging procedure returnsnil. Otherwise, for everywV(P1)∩V(P2) and everyxBw, we follow the exact same approach as in the planar case.

Merging phase 2: Updating the grip. This phase is identical to the planar case.

Merging phase 3: Checking connectivity. Similar to the planar case, we check that condi-tion (T5) holds forS and we returnnilif it does not.

13.1.2 Initializing the dynamic programming table.

For allP∈ P1 with|E(P)| ≤1, we follow the same approach as in the planar case.

13.1.3 Updating the dynamic programming table.

For all P ∈ P with |E(P)| > 1, and for all P1, P2 ∈ P with E(P1) 6= ∅, E(P2) 6= ∅, E(P1)∩E(P2) = ∅ andE(P1)∪E(P2) = E(P), and for all φ1 ∈ IP1 andφ2 ∈ IP2 we proceed as follows. Suppose that for allP0∈ P with|E(P0)|<|E(P)| and allφ0 ∈ IP0, we have computed the partial solutions in the dynamic programming table at (P0, φ0). Now similar to the planar case, if there exists partial solutionsS1 andS2at (P1, φ1) and (P2, φ2) respectively, we call the merging process to (possibly) get a partial solutionS at (P, φ) for someφ∈ IP. Now similar to the planar case, if there is no partial solution at (P, φ) then we storeS at (P, φ). Otherwise if there there exists a partial solutionS0 stored at (P, φ) and costG~(S)<costG~(S0) then we replaceS0 withS.

13.2 Analysis

LetWbe the collection of walks given by Lemma 56. LetF be the forest given by Lemma 57.

LetT be a subtree ofF. We say thatT istrivial ifψ(F)∪S

D∈V(T)ψ(D) is contractible.

Otherwise, we say thatT isnon-trivial.

Let Q∈ Q, and letT be a subtree of some tree inF. We define the termsQcoversT andQ avoids T the exact same way as in the planar case. Let P ={Q1, . . . , Qm} ∈ P. We say thatP covers T if for allDV(T) we haveV(D)∩V(F)⊆V(Q1. . .Qm). We say thatP avoids T if for allQiP we have thatQi avoidsT.

I Definition 66 (Basic family of paths). Let P = {Q1, . . . , Qm} ∈ P. For each i ∈ {1, . . . , m}, letui andvi be the endpoints ofQi. We say thatP isbasic (w.r.t.W) if either V(P)\(Sm

i=1{ui, vi}) does not intersect any of the walks in W (in which case we call it empty basic) or there existsT ∈ F andDV(T), with children D1, . . . , Dk, intersecting D in this order along a traversal ofD, such that the exact same conditions (1) & (2) as in Definition 60 hold, and|P|is minimal subject to the following:

3. If P covers TD and avoids T \ TD, letT[P] =TD, and otherwise letT[P] =Sj i=1TDi. For every two disjoint subtrees T1 andT2 of T[P], the following holds. If there exists QiP such thatQi coversT1∪ T2and avoidsT \(T1∪ T2), then there exist edge-disjoint subpaths Q0i, Q00i ofQi such thatQi=Q0iQ00i,Q0icovers T1 and avoidsT \ T1, andQ00i coversT2 and avoidsT \ T2 (see Figure 3 for an example).

Moreover if for each non-trivial treeT0 inF with T0 6=T, we have thatP avoidsT0, then we say thatP iselementary. Furthermore, if for each non-trivial treeT0 in F, we have that P avoidsT0, then we say that P istrivial.

IDefinition 67(Twins). LetP, P0 ∈ P. We say thatPandP0aretwinsif for each subtree T ofF,P coversT if and only if P0 coversT, andP avoidsT if and only ifP0 avoids T. I Definition 68 (Succinctness). Let P = {Q1, . . . , Qm} ∈ P be basic. For each i ∈ {1, . . . , m}, letui andvi be the endpoints ofQi, letQ0i=Qi\ {ui} and letQ00i =Qi\ {vi}.

We say that P issuccinct if for alli∈ {1, . . . , m},P and{Q1, . . . , Qi−1, Q0i, Qi+1, . . . , Qm} are not twins, and moreoverP and{Q1, . . . , Qi−1, Q00i, Qi+1, . . . , Qm}are not twins.

ILemma 69. LetP∈ P be non-empty basic. Then there exists some succinct and basic P0∈ P such thatP andP0 are twins with E(P0)⊆E(P).

Proof. It is immediate by Definition 68. J

Figure 3Example of a non-basic family of paths. P={Qi}is not basic. LetT1=D1D2 and T2=D3. ThenQi coversT1∪ T2 and avoidsT \(T1∪ T2), but there is no edge-disjoint subpaths Q0i, Q00i ofQisatisfying the third condition.

I Lemma 70. Let P ∈ P be non-empty basic elementary and succinct. Let T, D, j, D1, . . . , Dj be as in Definition 66. Then there exist P1, P2 ∈ P satisfying the following conditions:

1. P1 and P2 are non-empty basic elementary and succinct.

2. P1 covers Sj−1

i=1TDi and avoidsT \(Sj−1 i=1TDi).

3. P2 covers TDj and avoidsT \ TDj.

4. E(P1)⊆E(P),E(P2)⊆E(P), andE(P1)∩E(P2) =∅.

Proof. We begin by defining auxiliaryZ1, Z2∈ P. The desiredP1 andP2 will be succinct twins ofZ1 andZ2. First we defineZ1. Initially, we setZ1=P and we inductively modify Z1until it covers C1=Sj−1

i=1TDi and avoidsA1=T \(Sj−1

i=1TDi) as follows: If Z1 contains a pathQthat does not intersectC1then we removeQfromZ1. IfZ1contains a pathQthat intersects bothC1andA1then we proceed as follows: letRbe the collection of paths obtained fromQby deleting all vertices inA1∩Q; letR0be the collection obtained fromRby removing all paths that do not intersectC1; letR00be the collection obtained fromR0by replacing each Q0R0 be the minimal subpathQ00Q0 withV(Q00)∩C1=V(Q0)∩C1. We repeat the above process until the resultingZ1 coversC1=Sj−1

i=1TDi and avoidsA1=T \(Sj−1 i=1TDi).

In a similar fashion we define Z2 that covers C2 = TDj and avoids A2 = T \ TDj. It is immediate by construction thatE(Z1)⊂E(P),E(Z2)⊂E(P) andE(Z1)∩E(Z2) =∅.

Next we argue thatZ1is basic. It is immediate that conditions (1) & (2) of Definition 66 are satisfied. It remains to establish condition (3) of Definition 66. LetQP1. By construction there existsQ0P such that QQ0. LetT[Z1] and T[P] be as in Definition 66. LetT1 andT2be disjoint subtrees ofT[Z1] such thatQcoversT1∪ T2and avoidsT \(T1∪ T2). Let TQ0 be the minimal subtree ofT[P] that contains all the nodes ofT[P] that are covered by Q0. LetT0=TQ0∪ T1∪ T2. By definition we have thatT0 is a subtree ofT[P]. Therefore there exist disjoint subtreesT10 andT20 ofT0 such thatT1⊆ T10,T2⊆ T20, andT0=T10∪ T20. SinceP is basic, it follows by condition (3) of Definition 66 that there exist edge-disjoint subpathsQ01, Q02ofQ0 such thatQ01 coversT10and avoidsT \ T10 andQ02 coversT20and avoids T \ T20. LetQ1 =QQ01 andQ2 =QQ02. It now follows thatQ1 covers T1 and avoids T \ T1and Q2 coversT2and avoids T \ T2, establishing Condition (3) of Definition 66.

It remains to show that|P1|is minimal subject to condition (3) of Definition 66. Suppose not. Then there areQ, Q0P1that are consecutive inF such that we can replaceQandQ0 inP1 by some subpathQ00that containsQandQ0. IfQandQ0 are subpaths of the same path inP then this is a contradiction because by construction there must exist a vertex in

V(Q00)\(V(Q)∪V(Q0)) thatP1 must avoid. Therefore there must exist distinctR, R0P such that QR andQ0R0. However this means that we can replace R and R0 in P by some subpath containing bothR andR0, contradicting the fact that P is basic. This establishes that |P1| is minimal subject to condition (3) of Definition 66. We have thus obtained thatZ1 is basic. It is also immediate by construction that sinceP is elementary, Z1 is also elementary. By the exact same argument it follows that Z2 is also basic and elementary.

For any i∈ {1,2} let Pi be a succinct twin of Zi obtained by Lemma 69. SinceZi is basic and elementary, it follows thatPi is also basic and elementary, and thus condition (1) is satisfied. SincePi is a twin ofZi, it follows that conditions (2) & (3) are satisfied. Since E(Zi)⊂E(P) andE(Pi)⊆E(Zi), we getE(Pi)⊂E(P). Finally, sinceE(Z1)∩E(Z2) =∅, we haveE(P1)∩E(P2) =∅, and thus condition (4) is satisfied, which concludes the proof. J IDefinition 71(P-facial restriction). LetP ={Q1, . . . , Qm} ∈ P be basic. We define the P-facial restriction ofWthe exact same way as in Definition 61. We remark thatP is now a family of paths, while in the planar caseP is a single path; the definition remains the same by replacing the notion of basic path given in Definition 60 by the notion of basic family of paths given in Definition 66.

ILemma 72(Malnič and Mohar [21]). LetS be an either orientable or non-orientable surface of Euler genus g, and letxS. LetX be a collection of noncontractible curves. Suppose that at least one of the following holds:

(i) The curves inX are disjoint and (freely) nonhomotopic.

(ii) There existxS such that for everyC, C0∈ X, we haveCC0 =x, and the curves in X are nonhomotopic (inπ1(S, x)).

Then,

|X | ≤

0 if S is the 2-sphere

1 if S is the torus or the projective plane 3(g−1) otherwise

We recall the following result on the genus of the complete bipartite graph [14].

ILemma 73. For anyn, m≥1, the Euler genus of Km,n isd(m−2)(n−2)/4e.

ILemma 74. LetP ∈ P be elementary and succinct. Then|P| ≤18000g3.

Proof. LetT[P] be as in Definition 66. If T[P] is trivial, we can findQ∈ Qsuch that Q covers T[P] and avoids T \ T[P], and thus |P|= 1 and we are done. Now suppose that T[P] is non-trivial. Letm=|P|and suppose thatP ={Q1, . . . , Qm}such thatQ1, . . . , Qm

are subpaths of F in this order along a traversal of F. LetZ1, . . . , Zm0 be a sequence of disjoint subsets ofP such thatP =Sm0

i=1Zi, and eachZi is maximal subject to the following condition: LetZi0 be the minimal subpath ofF that contains all the paths inZi and does not intersect any other paths inP; thenZi0 avoids all non-trivial tress in F \ T. For every j∈ {1, . . . , m0−1}, letPj be the subpath betweenZj0 andZj+10 and letP0={P1, . . . , Pm−1}.

Note that sinceP is basic, for every two consecutiveZj0 andZj+10 , there exists a non-trivial treeTj such thatTj intersectsPj.

We construct a setR of non-trivial trees as follows. We initially setR={T1}. In each stepi >1, if there exists T0R such thatT0 intersectsPi, we continue to the next step.

Otherwise, we letTi0 be some non-trivial tree that intersectsPi and we addTi0 toR and we continue to the next step. We argue that|R| ≤20g. Suppose not. For eachT0Rwhere

T0 intersects someP0 ∈ P0 at some x0V(P0), we construct a path γT0 in the surface, with both endpoints on ψ(F), and such that after contractingψ(F) into single point, the loop resulting fromγT0 is non-contractible, as follows. First suppose thatψ(T0) contains some non-contractible loop γ. Then letζ be a path in ψ(T0) between x0 and some point inγ. We setγT0 to be the path starting atx0, traversingζ, followed byγ, followed by the reversal ofζ, and terminating atx0. Otherwise, suppose that ψ(cT0) does not contain any non-contractible loops. SinceT0 is non-trivial, it follows thatψ(T0) contains some path ξ with both endpoints inψ(F) such that after contractingψ(F) into a single point, the loop obtained from ξ is non-contractible. Let ξ0 be some path in ψ(T0) between x0 and some point inξ. By Thomassen’s 3-path condition [22] it follows thatξξ0 contains some path ξ00with both endpoints inψ(F), such that one of these endpoints isx0, and such that after contractingψ(F) into a single point, the loop resulting fromξ00is non-contractible. We set γT0 to beξ00.

LetL be the set of all loops obtained from the pathsγT0 as follows. Pick a point xin the interior of the disk bounded byψ(F). Connect xto both endpoints of eachγT0 by paths such that all chosen paths are interior disjoint. During this process each path γT0 gives rise to a non-contractible loop inL such that any two loops inL intersect only atx. Let L0, L00, L00∈ Lbe distinct. We show thatL0,L00 andL000 can not be all homotopic. Suppose not. Since they are interior-disjoint, by removing them from the surface we obtain three connected components. Sinceψ(T) does not intersect any ofL0,L00 andL000, it has to be inside one of the three connected components completely. We may assume w.l.o.g thatT is inside the component which is bounded byL0 andL00. Therefore, there is no path fromT to L000 without crossingL0L00, which is a contradiction.

Let L0 ⊆ L be a maximal subset such that for all L0, L00 ∈ L0 we have that L0 and L00 are non-homotopic. Since |L|>20g and for every three loops in L0 we know that at most two of them are homotopic, we have that|L0|>10g, which contradicts Lemma 72.

Therefore, we have that|R| ≤20g and thus there existsT0R such thatT0 intersects at least 10g= 200g2/20gelements of P0. Letx1be a point inside the face. Letx2 be a point in the root ofT0 and letx3 be a point inψ(D). There exists P10, . . . , P10g0 ∈ P0 such that for everyi∈ {1, . . . ,10g},T0 intersects Pi0. For every i∈ {1, . . . ,10g}, letyi be a point onPi0. By the construction, for everyyi we can find non-crossing paths tox1,x2andx3. Therefore, we get an embedding ofK3,10g in a surface of genusgwhich contradicts Lemma 73. This establishes thatm0 ≤200g2.

Leti∈ {1, . . . , m0}. We next we bound|Zi|. Suppose Zi ={Qa, Qa+1, . . . , Qa+`}. Let xbe an arbitrary point inψ(D). For eachj∈ {0, . . . ,b(`−1)/2c} pick an arbitrary point xjψ(Qa+2j)∩ψ(T); we define a path in the surface betweenxj andxas follows: we start from the vertexD0 ofT containingxj; ifD0 is a closed walk then we traverseD0 clockwise until we reach the point that connectsD0 to its parent; otherwise we traverse the unique path betweenxj and the point that connectsD0to its parent. We continue in this fashion until we reachD, and we finally traverse Dclockwise until we reachx. This completes the definition of the pathγj. It is immediate that for allj6=j0, the pathsγj andγj0 are non-crossing.

LetS0 be the surface obtained by contractingψ(F) into a single pointy, and identifying xwithy (note that S0 has Euler genus at mostg+ 2). For eachj ∈ {0, . . . ,b(`−1)/2c}

let γj0 be the loop in S0 obtained from γj after the above contraction and identification.

We argue that there can be at most 4 loopsγj0 that are pairwise homotopic. Suppose for the sake of contradiction that there are at least 5 such loops. It follows that there must existt∈ {0, . . . ,b(`−1)/2c}such thatγt0, γ0t+1, andγt+20 are all pairwise homotopic. We are going to obtain a contradiction by arguing that the pathsQa+2tandQa+2t+1 violate

the fact that P is basic. To that end, let Q0 be the minimal subpath of F that contains bothQa+2tandQa+2t+1 and does not intersect any other paths inP. We will show that (P\ {Qa+2t, Qa+2t+1})∪ {Q0}is basic, thus violating the fact that|P|is minimal subject to condition (3) of definition 66. Let T1, T2 be disjoint subtrees of T[P] such thatQ0 covers T1∪ T2and avoidsT \(T1∪ T2). We need to show that there exist edge-disjoint subpaths Q01andQ02ofQ0 such thatQ0=Q01Q02,Q01coversT1 and avoidsT \ T1, andQ02coversT2

and avoidsT \ T2. Letλbe the subpath of ψ(F) inS betweenxt andxt+1 that contains xt+1. Since γt0, γ0t+1, andγt+20 are homotopic, it follows thatγtλγt+2 bounds a disk Ψ in S. Each xs is contained in the image of a unique vertex D0s ofT[P]. Let B be the path inT[P] betweenDt0 andD0t+2. For eachr∈ {1,2},Tr intersectsB into some possibly empty subpathBr. It follows that there exist disjoint disks Ψ1,Ψ2⊂Ψ such that for each r∈ {1,2},ψ(Tr)∩Ψ⊂Ψr. Therefore there exist edge-disjoint subpathsQ01 andQ02 ofQ0 withQ0=Q01Q02 such thatψ(Q0)∩Ψ1ψ(Q01) andψ(Q0)∩Ψ2ψ(Q02). It follows that Q01 coversT1 and avoidsT \ T1, andQ02 coversT2and avoidsT \ T2. This contradicts the fact thatP is basic, and concludes the proof that there are at most four loop γt0 that are pairwise homotopic.

Pick I ⊆ {0, . . . ,b(`−1)/2c}, with |I| ≥ b(`−1)/10c such that for all t 6= t0I, we have thatγt0 andγ0t0 are non-homotopic. Since the paths γt are non-crossing, we may assume w.l.o.g. that the paths γt0 are interior disjoint after an infinitesimal perturbation.

By Lemma 72 on S0 it follows that|I| ≤3(g+ 1). Since |I| ≥`/15, we get `≤45(g+ 1).

Therefore|Zi| ≤45(g+ 1).

We conclude thatm≤Pm0

i=1|Zi| ≤m0·maxi∈{1,...,m0}|Zi| ≤9000g2(g+1)≤18000g3. J ILemma 75. Let P1={Q1, . . . , Qm} ∈ P be succinct. Let P2={Q01, . . . , Q0l} ∈ P such thatP1 and P2 are twins,V(P1)⊆V(P2) and E(P1)⊆E(P2). For every i∈ {1, . . . , m}, let ui and vi be the endpoints of Qi. Let B1=Sm

i=1(BuiBvi). LetWP1 be theP1-facial restriction of W. LetΓ1=S

W~∈WP1

W~ . Let C1 be the partition of B1 that corresponds to the weakly-connected components ofΓ1. For any x∈ B1 let f1in(x) =in-degreeWP

1(x) and f1out(x) =out-degreeW

P1(x). We similarly define C2, f2in, f2out andWP2 for P2. Suppose that there exists somea1∈ A ∪(A × A)∪nilandl1, r1, p1∈(V(G)∪~ nil)such that the dynamic pro-gramming table contains some partial solutionS1 at location(P1,(C1, f1in, f1out, a1, l1, r1, p1)), with costG~(S1) ≤ costG~(WP1). Then there exists some a2 ∈ A ∪ (A × A)∪ nil and l2, r2, p2 ∈ (V(G)~ ∪nil) such that the dynamic programming table contains some partial solution S2 at location(P2,(C2, f2in, f2out, a2, l2, r2, p2)), with costG~(S2)≤costG~(WP2).

Proof. Let E1 = E(P2)\E(P1). For every eE1, letQe ∈ Q be the path containing a single edge e, and let Pe ={Qe}. Note that Pe is an empty basic family of paths and

|E(Pe)|= 1. Therefore for every eE1, the initialization step of the dynamic programming, finds a partial solutionSeforPe. By mergingS1 with all these partial solutions sequentially in an arbitrary order, we get a partial solutionS2forP2, as desired. J I Lemma 76. Let P = {Q1. . . , Qm} ∈ P be basic and trivial (w.r.t. W). For every i∈ {1, . . . , m}, letui andvi be the endpoints ofQi. LetB=Sm

i=1(BuiBvi). LetWP be the P-facial restriction ofW. LetΓ =S

W~∈WP

W~ . LetC be the partition of Bthat corresponds to the weakly-connected components of Γ. For any x∈ B letfin(x) =in-degreeWP(x)and

fout(x) = out-degreeW

P(x). Then there exists some a ∈ A ∪(A × A)∪nil and l, r, p ∈ (V(G)~ ∪nil)such that the dynamic programming table contains some partial solutionS at location(P,(C, fin, fout, a, l, r, p)), with costG~(S)≤costG~(WP).

Proof. SinceP is trivial, we have that P ∈ P1, and thus the exact same argument as in

Lemma 64 applies here. J

W~ . LetC be the partition of Bthat corresponds to the weakly-connected components of Γ. For any x∈ B letfin(x) =in-degreeWP(x)and fout(x) = out-degreeWP(x). Then there exists some a ∈ A ∪(A × A)∪nil and l, r, p ∈ (V(G)~ ∪nil)such that the dynamic programming table contains some partial solutionS at location(P,(C, fin, fout, a, l, r, p)), with costG~(S)≤costG~(WP).

Proof. LetT, D, k, D1, . . . , Dk andj be as in Definition 66. We prove the assertion by induction onT. For the base case, whereDis a leaf ofT, the same argument as in Lemma 64 applies here. Suppose thatD is non-leaf. In this case, we prove the assertion by another induction onj. For the base case, wherej = 1, the same argument as in Lemma 64 applies here. Now suppose that we have proved the assertion for allj0< j. LetP1∈ Psuch that by deleting all isolated vertices. We defineP100to be the set of connected components in Γ000. Note that Γ000 has at most 36000g3 connected components, and each such component is a path. ThusP100∈ P36000g3, andE(P10)⊆E(P100). By the induction hypothesis, there exists a partial solutionS10 forP10, and thus by Lemma 75, there exists a partial solutionS100forP100. Also, by the induction hypothesis, there exists a partial solutionS20 forP20. By mergingS100 andS20, we get a partial solution S forP, as desired. J

We define the following three types of non-trivial trees inF:

1. We say that a non-trivial treeT is of thefirst type, if there exists a non-leafDV(T), such thatD is a closed walk, withV(D)∩V(F) =∅, such thatψ(D) is non-contractible.

2. We say that a non-trivial treeT is of thesecond type, if it is not of the first type and there exists a leafDV(T) such thatψ(D)ψ(F) is non-contractible.

3. We say that a non-trivial treeT is of thethird type, if it is not of the first type nor of the second type.

We say that a non-trivial treeT isgood, if at least one of the following conditions holds:

Figure 4Example of good non-trivial treesT0,T1, andT2 that are pairwise friends; note thatT0

is of the second type whileT1 andT2 are of the third type.

1. T is of the second type, and for everyD1, D2V(T) whereψ(D1)∪ψ(F) andψ(D1)∪ ψ(F) are non-contractible, we have that the loops obtained fromψ(D1) and ψ(D1) by contractingψ(F) into a single poitxare homotopic inπ1(S, x). LetDV(T) such that ψ(D)ψ(F) is non-contractible. We letβ(T) to be the homotopy class of the loopψ(D) in the surface obtained after contractingψ(F) into a single point.

2. T is of the third type and the following holds. Let X =ψ(F)∪S

D∈V(T)ψ(D) and let X0 be the image ofX after contracting ψ(F) into a single point x. Then and all non-contractible loops in X0 are homotopic inπ1(S, x). We let β(T) be the homotopy class in π1(S, x) of all non-contractible loops in X0; note that we may always take a non-contractible loop in X0 that contains the basepointxsinceX is connected.

Otherwise, we say thatT is a bad tree.

Let T0 and T1 be non-trivial good trees in F. We say that T0 is a friend of T1 if β(T0) =β(T1) (see Figure 4 for an example).

IDefinition 78(Friendly). LetP ∈ P. We say thatP isfriendly if the following holds.

1. P avoids all non-trivial bad trees.

2. For any two non-trivial good trees T0 andT1 inF thatP covers, we have that β(T0) = β(T1).

3. If P covers a non-trivial good treeT0, thenP covers all non-trivial good treesT1 with β(T0) =β(T1).

ILemma 79. There exists at most12g bad trees inF.

Proof. We partition all bad trees inF into three sets:

1. F1={T ∈ F :T is a bad tree of the first type}.

2. F2={T ∈ F :T is a bad tree of the second type}.

3. F3={T ∈ F :T is a bad tree of the third type}.

We first bound|F1|. LetT ∈F1. We letβ(T) to be the homotopy class of some non-leaf DV(T), such thatDis a closed walk, withV(D)∩V(F) =∅, andψ(D) is non-contractible.

Note that by the definition of trees of the first type, such a non-leafDV(T) exists. Let

Note that by the definition of trees of the first type, such a non-leafDV(T) exists. Let