Counting Deranged Matchings

Let $\mathrm{pm}(G)$ denote the number of perfect matchings of a graph $G$, and let $K_{r\times 2n/r}$ denote the complete $r$-partite graph where each part has size $2n/r$. Johnson, Kayll, and Palmer conjectured that for any perfect matching $M$ of $K_{r\times 2n/r}$, we have for $2n$ divisible by $r$ \[\frac{\mathrm{pm}(K_{r\times 2n/r}-M)}{\mathrm{pm}(K_{r\times 2n/r})}\sim e^{-r/(2r-2)}.\] This conjecture can be viewed as a common generalization of counting the number of derangements on $n$ letters, and of counting the number of deranged matchings of $K_{2n}$. We prove this conjecture. In fact, we prove the stronger result that if $R$ is a uniformly random perfect matching of $K_{r\times 2n/r}$, then the number of edges that $R$ has in common with $M$ converges to a Poisson distribution with parameter $\frac{r}{2r-2}$.


Introduction
A derangement is a permutation π with π i = i for any i, and the number of derangements of size n is denoted by d n .Derangements are one of the most well studied objects in combinatorics, whose origins date back to 1708 with work of de Montmort [3].
A common interpretation of derangements comes from the hat check problem: if n people each have a hat and these hats are randomly distributed back to each person, what is the probability that no person receives their own hat?This probability is easily seen to be equal to d n /n!, and it is by now a standard exercise in the principle of inclusion-exclusion to show the surprising fact that We refer the interested reader to Stanley [14] for further results and problems related to derangements.
The asymptotic formula (1) can be interpreted in terms of graph theory.To this end, let pm(G) denote the number of perfect matchings of a graph G.It is not difficult to see pm(K n,n ) = n! and pm(K n,n − M ) = d n for any perfect matching M of K n,n .Thus (1) is equivalent to saying Another question that can be phrased in the language above is the kindergarten problem: if 2n kindergarteners pair up for a field trip at the start of the day and then are randomly paired up again at the end of the day, what is the probability that no pair of kindergartners are matched at both the start and end of the day?This problem was motivated by a question from the United States Tennis Association about the tournament draw for the 1996 U.S. Open, and it was reformulated in terms of kindergarteners by Kayll.
Brawner [2] conjectured that the probability for the kindergarten problem tends to e −1/2 , and this was proven by Margolius [9].By viewing the kindergartners as the vertices of K 2n , this result is equivalent to saying pm(K 2n − M ) pm(K 2n ) ∼ e −1/2 . ( Noticing the similarities between ( 2) and (3), Johnston, Kayll, and Palmer [8] made the following conjecture concerning perfect matchings of K r×2n/r , the complete r-partite graph with parts of sizes 2n/r.
Conjecture 1.1.If r = r(n) ≥ 2 is integer valued and divides 2n, and if M n is a sequence of perfect matchings in K r×2n/r , then pm(K r×2n/r − M n ) pm(K r×2n/r ) ∼ e −r/(2r−2) , as n tends to infinity.
As an aside, we note that while Conjecture 1.1 first appeared formally in [8] earlier this year, the conjecture has been around for some time now.Indeed, Kayll first wrote about this in his Fullbright proposal in 2014, and we first heard about Conjecture 1.1 in 2017 when Palmer spoke about it at a conference.
Some special cases of Conjecture 1.1 were proven in [8].In particular, the cases r = 3 and r linear in n were proven using a mixture of inclusion-exclusion arguments and Tannery's theorem, and the case when r = Ω(n δ ) for any fixed δ > 0 was solved using a powerful result of McLeod [13] which is a strengthening of a result of Bollobás [1].
In this paper we give a self-contained proof which fully resolves Conjecture 1.1 in a strong form.Recall that for X, Y integer random variables, we define their total variation distance by Theorem 1.2.Let r = r(n) ≥ 2 be integer valued and divide 2n, and let M n be a sequence of perfect matchings in K r×2n/r .Let R n be a uniform random perfect matching on K r×2n/r and X = X(M n ) the number of edges shared by M n and R n .Then as n tends to infinity, where Po(λ) is the Poisson distribution with parameter λ.
Note that Pr(X = 0) is exactly pm(K r×2n/r ) , so the fact that Pr Po r 2r−2 = 0 = e −r/(2r−2) gives Conjecture 1.1.Our methods also give the following result, which can be viewed as a generalization of Theorem 1.2 when r tends to infinity.Theorem 1.3.Let G n be a sequence of graphs such that G n has 2n vertices and has minimum degree 2n − o(n), and let M n ⊆ G n be a sequence of perfect matchings.Let R n be a uniform random perfect matching on G n and X the number of edges shared by M n and R n .Then as n tends to infinity.
Notation.We typically use P, Q to denote generic perfect matchings, R a uniformly random perfect matching, and M the perfect matching that we are deleting.If P is a perfect matching and x is a vertex of a graph G, we define P (x) to be the unique vertex y ∈ V (G) such that xy ∈ P .We write N ℓ (G, M ) to denote the set of perfect matchings of G which contain exactly ℓ edges of M , and we denote this set simply by N ℓ (G, M ) whenever G, M are clear from context.Note that pm Given two functions f, g depending on some parameter n, we write f (n) = O(g(n)) to mean there exists an absolute constant C > 0 such that |f (n)| ≤ C|g(n)| for all n.We emphasize that C is allowed to depend on r whenever we declare r to be a fixed constant.We also emphasize that expressions like 1 + O(n −1 ) and 1 − O(n −1 ) have the same meaning, and we will utilize whichever form seems more natural in a given setting.We write tends to 0 as n tends to infinity.We write

Proof Sketch
Our proof uses techniques known as "switching" arguments, which have been used to obtain precise estimates on the number of various combinatorial objects, see for example [4,5,11,12].A general version of this technique can be found in Hasheminezhad and McKay [6], and a simple example (which is spiritually similar to the argument we pursue in this paper) can be found in an answer of Brendan McKay's to a question of Terence Tao on MathOverflow [10].We now sketch the argument we use for proving Conjecture 1.1 when r tends towards infinity (which is very similar to the argument used to prove Theorem 1.3).
By definition of N ℓ = N ℓ (K r×2n/r , M ) being the set of perfect matchings of K r×2n/r which contain exactly ℓ edges of M , we have pm With this, we will be done if we can show and rearranging gives the desired bound.
It remains to construct a bipartite graph H on N k ∪ N k−1 which has the desired degrees.We do this by making each P ∈ N k adjacent to every Q ∈ N k−1 which can be obtained from P by selecting three edges ax, by, cz ∈ P and "rotating" their endpoints (i.e. by deleting these edges and replacing them with bx, cy, az), see Figure 1 for an example.Simple counting arguments will then show that each element of N k ∪ N k−1 has roughly their desired degree.From this we can prove Conjecture 1.1 when r tends towards infinity.
The approach for fixed r is similar but requires some extra difficulties.In particular, we will not be able to guarantee that every Q ∈ N k−1 has roughly the degree we are looking for.We overcome this obstacle by studying the behavior of typical perfect matching of K r×2n/r (see Proposition 3.4) to show that "most" Q have the correct degrees, and with this we can prove the result.
Figure 1: The good (x, y, z)-switch of a perfect matching P replaces the three pairs connected by solid lines with the three pairs connected by dashed lines, obtaining the perfect matching Q.This switch is good if all of the lines are edges of G and if xP (x) is the only one of these six edges that is in M .

Proof of Results
We break our proofs into three parts.First we prove effective estimates on , where the case of r fixed for Theorem 1.2 is proven under the assumption of a technical result Proposition 3.4.We then show how these ratio estimates imply Theorems 1.2 and 1.3.Finally, we prove Proposition 3.4.

Ratio Estimates
We first consider the case when G has large minimum degree.
Lemma 3.1.Let G be a 2n-vertex graph with minimum degree 2n − t, and let M ⊆ G be a perfect matching.
Proof.For a triple of distinct vertices (x, y, z) and a perfect matching P of G, define the (x, y, z)-switch of P to be the set of pairs P \ {xP (x), yP (y), zP (z)} ∪ {xP (y), yP (z), zP (x)}, see Figure 1 for an example.Note that the (x, y, z)-switch may not be a subgraph of G if, say, P (y) is not adjacent to x.We say that the triple (x, y, z) is good (with respect to P and M ) if the following hold: 1.The (x, y, z)-switch of P is a subgraph of G.That is, x ∼ P (y), y ∼ P (z), and z ∼ P (x).
These conditions imply that if Q is the (x, y, z)-switch of some Motivated by this, we define an auxiliary bipartite graph Proof.Note that deg H (P ) is exactly the number of good triples (x, y, z) with respect to P , so it suffices to count this quantity.Every good triple can be formed by (i) picking some x which is in an edge of P ∩ M , (ii) picking some y = x which is not a vertex in an edge of P ∩ M and such that P (y) is a neighbor of x, and (iii) picking some z = x, y which is not a vertex in an edge of P ∩ M and such that P (z) is a neighbor of y, and z is a neighbor of P (x), and yP (z) / ∈ M .We note that these conditions imply that x, y, z, P (x), P (y), P (z) are all distinct vertices.
The number of choices for (i) is exactly 2k.The number of choices for each of (ii) and (iii) is certainly at most 2n and it is at least 2n − 2k − 2t − 4 (since, for example, in choosing z one only has to avoid the 2k vertices in an edge of P ∩ M , the t vertices which are not a neighbor of P (x), the t vertices z with P (z) not a neighbor of y, and each of the vertices x, y, M (y)).Multiplying the number of choices gives the result.
Proof.Call a triple of distinct vertices (x, y, z) reverse good with respect to and if we have xQ(z) ∈ M and yQ(x), zQ(y), yQ(y) / ∈ M .Note that (x, y, z) is reverse good if and only if Q is the (x, y, z)-switch of some P ∈ N k with (x, y, z) good (since Q(x) = P (y), Q(y) = P (z), Q(z) = P (x)).Thus it suffices to count the number of reverse good (x, y, z).
To form such a triple, we (i) pick x which is not in an edge of Q ∩ M , (ii) let z = Q(M (x)), (iii) pick y = x, z which is not in an edge of Q ∩ M and such that Q(y) is a neighbour of z, and y is a neighbor of Q(x), and yQ(x) / ∈ M .It is not difficult to see that the output form this procedure will always be reverse good, and that every reverse good triple arises uniquely from this process.Thus it suffices to bound the number of choices at each step.For (i) this is 2n − 2k, (ii) is 1 choice, and (iii) is at most 2n and at least 2n − 2k − 2t − 4. Multiplying these out gives the result.

These two claims and the assumption
giving the result.
The case for G = K r×2n/r with r fixed is harder and requires the following result, which roughly says that most perfect matchings P of K r×2n/r behave "as expected".Here and throughout we let V 1 ∪ • • • ∪ V r denote the r-partition of K r×2n/r .Proposition 3.4.Let r ≥ 2 fixed, n such that r divides 2n, and M an arbitrary perfect matching on G = K r×2n/r .Let 1 ≤ k ≤ log n and let Q be a uniform random perfect matching on G that uses exactly k − 1 edges of M .Then the following holds with high probability: for any i ∈ [r], the number of vertices We defer the proof of Proposition 3.4 until Subsection 3.3 and use it to prove the following.
Note that in general the (x, y, z)-switch of P might not be a perfect matching.For P ∈ N k , we say that a triple (x, y, z) is good (with respect to P and M ) if the following hold: These conditions ensure that if Q is an (x, y, z)-switch of P ∈ N k with (x, y, z) good, then Q ∈ N k−1 .We define the bipartite graph H on N k ∪ N k−1 by having each P ∈ N k adjacent to every Q ∈ N k−1 which is an (x, y, z)-switch of P for some good (x, y, z).Claim 3.6.For every P ∈ N k , we have Proof.Note that deg H (P ) is exactly the number of triples (x, y, z) which are good with respect to P .To form such a triple, we first pick any x such that xP (x) ∈ M , the number of choices of which is exactly 2k by definition of N k .If one has chosen x ∈ V i , then the number of choices for y ∈ V i \ {x} with yP (y) / ∈ M is at most |V i | = 2n/r and at least 2n/r − 1 − k.Given such x, y, the number of choices for z ∈ V i \ {x, y} with zP (z) / ∈ M and yP (z) / ∈ M is between 2n/r and 2n/r − 3 − k.As each good triple can be formed uniquely by this procedure, we conclude the result.
Motivated by Proposition 3.4, we define F k−1 ⊆ N k−1 to be the set of perfect matchings Q such that for any i ∈ [r], the number of vertices and for every Proof.We say that a triple of distinct vertices (x, y, z) is reverse good for Q if x, y, z ∈ V i for some i and if xQ(z) ∈ M and yQ(x), zQ(y), yQ(y), zQ(z) / ∈ M .Note that Q is a (x, y, z)-switch of some P ∈ N k with (x, y, z) good if and only if (x, y, z) is reverse good, so it suffices to count how many triples have this property.
Observe that for any reverse good triple, we have that z = Q(M (x)) is in the same part as x (since M (x) = Q(z)).Thus any such triple can be formed (uniquely) by first picking x such that Q(M (x)) = x lies in the same part V i as x, setting z = Q(M (x)), and then choosing any y ∈ V i \ {x, z} such that yQ(x), zQ(y), yQ(y) / ∈ M .
There are trivially at most 4n 2 ways to carry out this procedure, so we conclude deg G (Q) ≤ 4n 2 for all Q ∈ N k−1 , and we may assume Q ∈ F k−1 from now on.By definition of F k−1 , the number of choices for Given this, the number of choices for y is at most 2n/r and at least 2n/r − 4 − k.Putting this together gives the claim.

4, the above gives
Using this and the first claim gives and we conclude the result.

Using Ratio Estimates
It remains to use the ratio bounds to establish our results, and for this we use the following.
and such that for all e ∈ G n we have Proof.By assumption, there exists a function ω := ω(n) growing arbitrarily slowly to infinity such that for any ℓ ≤ ω, Also by assumption and linearity of expectation, we have .
We note that the condition Pr(e ) in Proposition 3.8 will automatically apply whenever the G n are edge-transitive, and in particular when G n = K r×2n/r .With this in mind, we prove our main result.
Proof of Theorem 1.2.Let ε ∈ (0, 1) be an arbitrary fixed constant.We will show that there exists a constant n ε such that for all n ≥ n ε , r|2n, and perfect matching M n of K r×2n/r , the random variable X = X(M n ) satisfies Let t(ε, n) be the largest number such that for all r ≤ t(ε, n) with r|2n, we have d(n, r) ≤ ε.Lemma 3.5 and Proposition 3.8 implies that for any fixed integer c, we have t(ε, n) ≥ c for all large enough n.Therefore t(ε, n) → ∞ as n → ∞.Now from Lemma 3.1 and Proposition 3.8, it follows that for all large enough n and r ≥ t(ε, n), r|2n, we have which completes the proof.
Finally, we prove Theorem 1.3 when working with graphs of minimum degree 2n − o(n).
Proof of Theorem 1.3.By Proposition 3.8 and Lemma 3.1, it suffices to show that if G is a 2n-vertex graph with minimum degree 2n−o(n), then a uniform random perfect matching R of G satisfies Pr(e ∈ R) = O(1/n) for all e ∈ E(G).We accomplish this with a switching argument.
Fix an edge e = xy in G. Let N e be the set of perfect matching on G that contains e, and let N c e be the set of perfect matching not containing e.We consider an auxiliary graph H on N e ∪ N c e where P ∈ N e and Q ∈ N c e are adjacent if there exists an edge uv ∈ P \ {xy} such that e .Note that P has a neighbor in H for each edge uv ∈ P \ {xy} with u ∈ N G (y) and v ∈ N G (x), and the number of such edges is at least n − o(n) by the minimum degree condition.With this By Dirac's theorem and the fact that r ≥ 3, there exists a perfect matching P that completes P ′ .It is clear that for any i < j, the number of edges between any two parts lies in proving the result.
This allows us to prove that there are not too many elements in any given set P u .
Proof.By Lemma 3.10 there exits some v (c) ∈ P 0 .We claim that for all v, v ′ ∈ P u , we have , and hence To complete the claim, it remains to show that v (c) + v − v ′ satisfies (PM).We have (v (c) + v − v ′ ) i,j ≥ 0 by the inequality above and c ≥ 3d for n sufficiently large in terms of r.Since v, v ′ ∈ P, for any i we have proving the claim.
If P u = ∅ then there is nothing to prove.Otherwise, fix some arbitrary v ′ ∈ P u and define the map Note that f is injective and maps P u to C by our claim, giving the result.
We will need the following technical lemma.
Lemma 3.12.Let x 1 ≥ . . .≥ x t ≥ 0 and y 1 ≥ . . ., y t ≥ 0 be non-negative integers such that t i=1 x i = t i=1 y i := S. Let c = ⌊S/t⌋ and suppose that |x i − c| ≤ k for all i ∈ [t] and y 1 ≥ c + 2δ.Then Proof.In order to estimate t i=1 z i ! for any z 1 ≥ . . .≥ z t ≥ 0 with t i=1 z i = S, we will iteratively construct sequences of integers γ is as close to c as possible for all i, and such that γ (ℓ) i = z i for the final value of ℓ.By keeping track of how much i !changes at each step, we will be able to effectively estimate has the property that there is a j ∈ [t] such that z i ≥ γ (0) i for all i ≤ j and z i < γ (0) i for all i > j.Iteratively given γ (ℓ−1) i which continues to satisfy this property, we pick the smallest index i 1 such that γ (ℓ−1) i1 < z i1 and the largest index i 2 such that γ for all other i; noting that with this, γ (ℓ) i satisfies the desired property and t i=1 γ (ℓ) i = S.We terminate this process when γ (ℓ) i = z i for all i, and we let n(z 1 , . . ., z t ) be the step at which we terminate.Define and we make the simple observations that Γ (ℓ) ≥ Γ (ℓ−1) and Γ (n(z1,...,zt)) = t i=1 z i !.By using this approach for x 1 , . . ., x t , observing that n(x 1 , . . ., x t ) ≤ kt and Γ (ℓ) /Γ (ℓ−1) ≤ (c + k)/(c − k) for all ℓ, we have Similarly, by using this approach for y 1 , . . ., y t and observing that for ℓ = δ, δ + 1, . . ., 2δ − 1 we have Γ (ℓ) /Γ (ℓ−1) ≥ (c + δ)/(c + 1) (since we will increase the value of γ ≤ c + 1 by 1 for some i 2 ), and hence Combining ( 10) and (11) gives the desired result.
For any v = (v i,j ) i<j∈[r] ∈ P and S ⊆ P, let φ(v) := Pr(uniform random perfect matching R on G has v i,j edges between V i , V j ∀i < j), φ(S) := v∈S φ(v).
Note that Lemma 3.13.For any u ∈ Z ( r 2 ) , |u| 1 ≥ 100r 4 , v ∈ P u , v ′ ∈ C, we have One can easily improve the bound of this lemma with a more careful argument, but we do not make any attempt at optimizing our bound beyond what is needed.
Proof.First we note that and that This implies Using this together with |u| 1 ≥ 100r 4 gives i<j,ui,j ≥0 Therefore, max i,j u i,j ≥ 49r 4 , and hence a crude bound gives Therefore by (12) and Lemma 3.12 and some crude estimates, which gives the desired result.
We now have all we need to prove Proposition 3.9.
Proof of Proposition 3.9.By Lemmas 3.11 and 3.13, for any u with |u| 1 ≥ 100r 4 , Since the number of u such that P u is non-empty is (very crudely) at most n ( r 2 ) , the inequality above gives which concludes the proof.
Finally, we prove Proposition 3.4, which we restate for convenience.
Proposition 3.4.Let r ≥ 2 fixed, n such that r divides 2n, and M an arbitrary perfect matching on G = K r×2n/r .Let 1 ≤ k ≤ log n and let Q be a uniform random perfect matching on G that uses exactly k − 1 edges of M .Then the following holds with high probability: for any i ∈ Proof.The result is trivial if r = 2, so we assume r ≥ 3. We prove the following stronger statement: let M * be a subset of M with |M * | = k − 1 ≤ log n, and let Q be a uniform random perfect matching on G that intersects M at exactly M * .Then the conclusion of Proposition 3.4 still holds.
Let G ′ be the graph obtained by removing the endpoints of M * in G, leaving the complete r-partite graph with vertex set V ′ 1 , . . ., V ′ r .Let Q ′ be the restriction of Q to G ′ , let M ′ be the restriction of M to G, and let R be a uniform random perfect matching on G ′ .It is not too difficult to see that Q ′ is a uniform random perfect matching on G ′ that avoids M ′ .
For any matching P on G ′ , we define P i,j ⊆ V ′ i to be the set of vertices x ∈ V ′ i such that P (x) ∈ V ′ j .We note that the graph G ′ satisfies the conditions of Proposition 3.9 (with n replaced by 2n/r).Therefore, for any i < j ∈ [r], with high probability |R i,j | = 2n r(r−1) + O( √ n log n).By symmetry, we know that if we condition on |R i,j | = m, then R i,j is the uniform random subset of V ′ i with size m.Combining these two facts, from standard concentration inequalities (see [7, Theorem 2.1 and 2.10]) we get that with high probability Given a perfect matching P of G ′ , let and let S = {S(P ) : P ⊆ G ′ − M ′ }.
Claim 3.14.There exists a constant C r such that for all S ∈ S, we have Proof.Recall that d N is the number of derangements of order N , and define Note that α < ∞ since we restrict to N ≥ 2 and since lim n→∞ dN N != e −1 by (1), and that α ≥ 1.We will prove our result with C r = 2α ( r 2 ) .
To this end, for S ∈ S we let pm(G ′ , S) denote the number of perfect matchings U of G ′ with S(U ) = S, and we similarly define pm(G ′ − M ′ , S).We claim that pm(G ′ , S) ≤ α ( r 2 ) pm(G ′ − M ′ , S).
Indeed, we have pm(G ′ , S) = i<j |S i,j |!.Because S ∈ S, there exists some perfect matching P ⊆ G ′ − M ′ with S(P ) = S.In particular, for all i = j we either have |S i,j | ≥ 2, or we have S i,j = {x}, S j,i = {y} with xy / ∈ M ′ (as otherwise no such P ⊆ G ′ − M ′ could exist).Letting d i,j = 1 if this latter case happens and otherwise setting d i,j = d |Si,j | , we see that pm(G ′ − M ′ , S) ≥ i<j d i,j , as there are at least d i,j ways to choose the matching between S i,j and S j,i while avoiding M .By definition we have |S i,j |!/d i,j ≤ α for all i, j, and from this the subclaim follows.
For any perfect matching P of G ′ , S(P ) / ∈ S only if P i,j = 1 for some i, j.Therefore by Proposition 3.9, S(R) ∈ S with high probability.To finish the proof, we observe that With this claim and (13), we have with high probability This gives the desired result, as the number of vertices x ∈ V i such that Q(M (x)) ∈ V i is (deterministically)

Further Directions
In this paper we proved Conjecture 1.1 by utilizing switching arguments, and there are a number of extensions one could consider.One such direction is to try and estimate pm(K r×2n/r − D)/pm(K r×2n/r ) when D is a d-regular subgraph of K r×2n/r for some d > 1.It is possible that more complicated versions of our arguments here could be effective for this problem.
A different direction in the spirit of Theorem 1. for any perfect matching M ⊆ G? It seems likely that this statement is far too strong to be true, but we do not know of any counterexamples.We note that the question for α < 1 does not make sense since G may not have a perfect matching, and that the result is false at α = 1.In particular, the result fails at α = 1 by considering G to be K n ∪ K n together with a perfect matching M (since for n odd, pm(G − M ) = 0).
3 is to see to what extent Conjecture 1.1 can be generalized to graphs G other than K r×2n/r .For example, is it true that for all α > 1, a sequence of 2n-vertex αn-regular graphs G satisfies lim n→∞ pm(G − M ) pm(G) = e −1/α |, we construct an auxillary bipartite graph H on N k ∪ N k−1 with the property that deg H (P ) ≈ 2k(2n) 2 for all P ∈ N k and deg H Proposition 3.8.Let G n be a sequence of graphs with |V (G n )| tending towards infinity such that each G n has an even number of vertices, Θ(|V (G n )| 2 ) edges, and contains some perfect matching M n ⊆ G n .Let R n be a uniform random perfect matching on G n and X = X(M n ) the number of edges shared by M n and R n .If there exists a fixed real number α > 0 such that for all k