Asymptotic enumeration of digraphs and bipartite graphs by degree sequence
We provide asymptotic formulae for the numbers of bipartite graphs with given degree sequence, and of loopless digraphs with given in- and out-degree sequences, for a wide range of parameters. Our results cover medium range densities and close the gaps between the results known for the sparse and dense ranges. In the case of bipartite graphs, these results were proved by Greenhill, McKay and Wang in 2006 and by Canfield, Greenhill and McKay in 2008, respectively. Our method also essentially covers the sparse range, for which much less was known in the case of loopless digraphs. For the range of densities which our results cover, they imply that the degree sequence of a random bipartite graph with m edges is accurately modelled by a sequence of independent binomial random variables, conditional upon the sum of variables in each part being equal to m. A similar model also holds for loopless digraphs.
\section{Introduction} 
Enumeration of discrete structures with local constraints has attracted the interest of many researchers and has applications in various areas such as coding theory, statistics and neurostatistical analysis. Exact formulae are often hard to derive or infeasible to compute. Asymptotic formulae are therefore sought and often provide sufficient information for the aforementioned applications. In this paper we find such formulae for bipartite graphs  with given degree sequence, or loopless digraphs with given in- and out-degree sequences. Our results imply that the degree sequence of a random digraph or bipartite graph with $m$ edges is close to a sequence of independent binomial random variables, conditional upon the sum of degrees in each part being equal to $m$. 

We frame all our arguments in terms of bipartite graphs: as noted below, digraphs are equivalent to ``balanced" bipartite graphs. Thus, if loops are not forbidden, the digraph enumeration problem is the same as the bipartite one.  
The loopless case for digraphs is equivalent to bipartite graphs with a forbidden perfect matching. 
Our results on counting bipartite graphs with a given degree sequence imply equivalent results on counting $0$-$1$ matrices with given row and column sums. Similarly, counting (loopless) digraphs is equivalent to counting square $0$-$1$ matrices with given row and column sums where the entries on the diagonal are required to be 0. 


Our results are obtained via the method of degree switchings and contraction mappings recently introduced by the authors in~\cite{lw2018} to count the number of  ``nearly" regular  graphs of a given degree sequence for  medium-range densities, and a wider range of degree sequences for low densities.  The basic structure of the argument is very similar in the present case, but it needs significant modifications to account for the fact that we are dealing with bipartite graphs and certain edges are not allowed. 
\subsection{Enumeration results}
 The formulae in~\cite{lw2018} are stated in terms of a relationship between the degree sequence of the Erd\H{o}s-R\'enyi random graph and a sequence of  independent binomial random variables. We shall do the same here for appropriate bipartite random graphs and suitable independent binomials. 
We first introduce appropriate graph theoretic notation. Let $\ell, n$ be integers and let $S=[\ell]$ and $T=[n+\ell]\setminus [\ell]$. We use $S$ and $T$ as the two parts of the vertex set of a bipartite graph $G$, i.e.\  a graph $G$ with bipartition $(S, T)$. Such a graph is said to   have degree sequence $({\bf s},{\bf t})$  if vertex $a$ has degree $s_a$ for all $a\in S$, and $v$ has degree $t_v$ for all $v\in T$. (Our convention is to denote elements of   $S$   by $\{a,b,\ldots\}$ and elements of $T$  by $\{v,w,\ldots\}$.)  We let $\cD(G)$ denote the degree sequence of $G$. 
 %
When $\ell =n$, we use the fact that a digraph on $n$ vertices with out-degree sequence ${\bf s}$ and in-degree sequence ${\bf t}$ corresponds to a bipartite graph with degree sequence  $({\bf s},{\bf t})$, the equivalence obtained by directing all edges from $S$ to $T$. For use in the digraph case, if $a\in S$ we define   $\mathrm{mate}{a}=a+\ell\in T$, and for $v\in T$ we define   $\mathrm{mate}{v}=v-\ell\in S$. The digraph contains a loop if and only if the bipartite graph has an edge joining $a$ to $a'$. 
 

 The following probability spaces play an important role in this paper. 
Let $\mathcal{G}(\ell,n,m)$ denote the bipartite graph chosen uniformly at random among all bipartite graphs with bipartition $(S,T)$ and with $m$ edges. 
In the case when $\ell=n$, conditioning on the event that none of those $m$ edges is of the form $aa'$ yields a model of random directed graphs  without loops which we call  $\vec \mathcal{G}(n,m)$. 
We define $\cD(\mathcal{G}(\ell,n,m))$ and $\cD(\vec \mathcal{G}(n,m))$ to be the corresponding probability spaces of degree sequences of $\mathcal{G}(\ell,n,m)$ or of $\vec\mathcal{G}(n,m)$, respectively.
Let $\mathcal{B}_p(\ell,n)$ be the probability space of vectors of length $\ell+n$ where the first $\ell$ elements are distributed as $\ensuremath{\mathrm{Bin}}(n,p)$ and the next $n$ are distributed as $\ensuremath{\mathrm{Bin}}(\ell ,p)$. Furthermore, let $\mathcal{B}_m(\ell,n)$ be the restriction of $\mathcal{B}_p(\ell,n) $ to the event $  \Sigma_1=\Sigma_2= m $, where $\Sigma_1$ is the sum of the first $\ell$ elements of the vector, and $\Sigma_2$ the sum of the other $n$ elements. 
Similarly, define $\vec\mathcal{B}_p(n)$ to be the probability space of random vectors of length $2n$, every component being independently distributed as $\ensuremath{\mathrm{Bin}}(n-1,p)$. Finally, let $\vec\mathcal{B}_m( n)$ be the restriction of $\vec\mathcal{B}_p( n)$ to the event $\Sigma_1=\Sigma_2= m $, where $\Sigma_i$ is defined as above with $\ell=n$. 
Note that if  $\sum s_a = \sum t_v=m$, then  
\begin{align}\lab{probbin}
\pr_{\mathcal{B}_m(\ell,n)}({\bf s},  {\bf t})  &=  {\ell n \choose m }^{-2} \prod_{a\in S} { n \choose s_a }\prod_{v\in T} { \ell \choose t_v}  \mbox{ and}\nonumber\\
 \pr_{ \vec\mathcal{B}_m( n)} ({\bf s},  {\bf t})  &=  { n(n-1) \choose m}^{-2} \prod_{a\in S} { n-1 \choose s_a }\prod_{v\in T} { n-1 \choose t_v},   
\end{align}
which we note are both independent of $p$. 

Our main result for degree sequences of ``medium density" states essentially that for certain sequences ${\bf d}$, the probability $\Pr_{\cD(\mathcal{G})}({\bf d})$ is asymptotically equal to $\Pr_{\mathcal{B}_m}({\bf d}){\tilde H}({\bf d})$, where $\mathcal{G} =\mathcal{G}(\ell,n,m)$ and $\mathcal{B}_m =\mathcal{B}_m(\ell,n)$ in the bipartite case, $\mathcal{G} =\vec\mathcal{G}(n,m)$ and $\mathcal{B}_m =\vec\mathcal{B}_m(n)$ in the digraph case, and where ${\tilde H}$ is a correction factor which we define next. For asymptotics in this paper, we take $n\to\infty$; the restrictions  on $\ell$ will also  ensure that $\ell\to\infty$. 

With $S$ and $T$ as above, let ${\bf d}$ be a sequence of length $N=\ell+n$. We set $M_1=M_1({\bf d}) =  \sum_{i=1}^N d_i$ and use ${\bf s}={\bf s}({\bf d})$ and ${\bf t}={\bf t}({\bf d})$ to denote the vectors consisting of the first $\ell$, and  of the last $n$, entries of ${\bf d}$ respectively. Thus, ${\bf d}=({\bf s},{\bf t})$. We also let $s=s({\bf d})$ and $t=t({\bf d})$ denote average of the components of ${\bf s}$, and of ${\bf t}$, respectively, that is 
$s = \frac{1}{\ell}\sum_{a\in S} s_a$ and $t = \frac{1}{n}\sum_{v\in T} t_v$.
 Then we set 
$$\sigma^2({\bf s})= \frac{1}{\ell}\sum_{a\in S} (s_a-s)^2, \quad \sigma^2({\bf t})= \frac{1}{n}\sum_{v\in T} (t_v-t)^2, $$
 and, in the digraph case, 
$$\sigma({\bf s},{\bf t})=\frac{1}{n}\sum_{a\in S} (s_a-s)(t_{a'}-t).$$  
We unify our analysis  of the two cases, bipartite graphs and digraphs, by introducing the indicator variable $\delta^{\mathrm{di}}$ which is $1$ in the digraph case (in which case $\ell = n$ is assumed) and $0$ in the bipartite case (in which case terms containing $\delta^{\mathrm{di}}$ as a factor may be undefined). This significantly simplifies notation  and permits us to emphasise the similarities between the two cases. 
 Define $\mu=\mu({\bf d})=M_1({\bf d})/(2n(\ell-\delta^{\mathrm{di}}))$. (This will denote the {\em relative edge density} of a bipartite graph or a digraph with degree sequence ${\bf d}$.)
We then set 
\begin{align}\lab{corrH}
\corr{{\bf d}} = \exp\left(-\frac12 \left(1-\frac{\sigma^2({\bf s})}{s(1-\mu)}\right)
                     \left(1-\frac{\sigma^2({\bf t})}{t(1-\mu)}\right) 
                     -\frac{\delta^{\mathrm{di}}\sigma({\bf s},{\bf t})}{s(1-\mu)}\right)
\end{align}
for a sequence ${\bf d}$ of length $\ell+n$, where $\mu = \mu({\bf d})$, ${\bf s}={\bf s}({\bf d})$, ${\bf t}={\bf t}({\bf d})$. 
We can now state our main result.
\begin{thm}\thlab{t:mainbip}
For  a sufficiently small constant  $\mu_0$, the following holds. Let $1/2<\varphi<3/5$. Let $\ell$, $n$ and $m$ be integers that satisfy 
$$
m/(n\ell)<\mu_0, \quad   (\ell+n)^{5-5\varphi} 
  =o(\ell nm^{3-5\varphi}), 
$$
  and for all fixed $K>0$, $ \ell \log^K n+ n\log^K\ell  =o(m)$.  
Let $\D$ be the set of sequences ${\bf d}=({\bf s},{\bf t})$ with ${\bf s}$ and ${\bf t}$ of lengths $ \ell$ and $n$ respectively, satisfying $M_1({\bf s})=M_1({\bf t})=m$,  $|s_a-s|\le s^{\varphi}$ and $|t_v-t|\le t^{\varphi}$ for all $a\in S$ and all $v\in T$, where $s=m/\ell$ and $t=m/n$.
Either set $\mathcal{G}=\mathcal{G}(\ell,n,m)$ and $\mathcal{B}_m= \mathcal{B}_m(\ell,n)$ (the bipartite case), or  set $\mathcal{G}=\vec \mathcal{G}(n,m)$ and $\mathcal{B}_m= \vec\mathcal{B}_m(n)$ and restrict to $\ell=n$ (the digraph case). 
 Then uniformly for all ${\bf d}\in\D$,  \bel{enumFormula}
 \pr_{\cD(\mathcal{G})} ({\bf d}) =  \pr_{\mathcal{B}_m}({\bf d})\corr{{\bf d}}\left(1+O\left(\frac{\log^2\ell}{\sqrt{\ell}}+\frac{\log^2n}{\sqrt{n}}+(\min\{s,t\})^{5\varphi-5}m^2/\ell n \right)\right).
 \end{equation}
\end{thm}
Recall that in this paper, asymptotic statements refer to $n\to\infty$. The condition $ \ell \log^K n+ n\log^K\ell  =o(m)$, however, together with the trivial upper bound $m\le n\ell$ implies that $\ell\to\infty$ as well.  
We prove this theorem in Section~\ref{s:denseBip}. 
\begin{remark}\lab{r:first}
In view of~\eqn{probbin} and  the fact that $|\mathcal{G}(\ell,n,m)|  =  {\ell n \choose m }$, the formula in \thref{t:mainbip} is equivalent to the assertion that the number of bipartite graphs with degree sequence  $({\bf s},{\bf t})$ is
$$
     {\ell n \choose m }^{-1}\prod_{a\in S}{ n \choose s_a }\prod_{v\in T} { \ell \choose t_v} 
 \exp\bigg(-\frac12 \bigg(1-\frac{\sigma^2({\bf s})}{\mu(1-\mu) n}\bigg)
                     \bigg(1-\frac{\sigma^2({\bf t})}{\mu(1-\mu)\ell  }\bigg) +O(\xi)\bigg),
$$ 
where $\xi$ is the error term from~\eqn{enumFormula}.
Similarly, \eqn{probbin} and the fact that $|\vec \mathcal{G}(n,m)| =    { n(n-1) \choose m }$ 
gives an asymptotic formula for the number of directed graphs with given degree sequence of in- and out-degrees. 
\end{remark}

Our corresponding result for the sparse case is the following. Although it is not new in the bipartite case (see below), it completes the full range of densities (in a sense, for instance, regarding regular digraphs) in the digraph case. For a sequence ${\bf d}=({\bf s},{\bf t})$ as above, define $\Delta_S=\Delta({\bf s})=\max_{a\in S}(s_a)$, and similarly $\Delta_T=\Delta({\bf t}) =\max_{v\in T}(t_v)$. 

\begin{thm}\thlab{t:sparseCaseBip} 
Let  $0<\varepsilon<1/2$, let $\ell$, $n$ and $m$ be integers 
such that $n/\log^4n + \ell/\log^4\ell=o(m)$, and set $s=m/\ell$, and $t=m/n$. 
Let $\D$ be a set of  sequences ${\bf d}=({\bf s},{\bf t})$ such that ${\bf s}$ and ${\bf t}$ have length $\ell$ and $n$, respectively, and such that $M_1({\bf s})=M_1({\bf t})=m\ge 1$ and $\Delta_S^3\Delta_T^3 (n\ell)^{\varepsilon/2} = o(\min\{sm, tm\})$ uniformly over $\D$. 
Either set $\mathcal{G}=\mathcal{G}(\ell,n,m)$ and $\mathcal{B}_m= \mathcal{B}_m(\ell,n)$ (the bipartite case), or  set $\mathcal{G}=\vec \mathcal{G}(n,m)$ and $\mathcal{B}_m= \vec\mathcal{B}_m(n)$ and restrict to $\ell=n$ (the digraph case). Then uniformly for ${\bf d}\in\D$, 
$$
\pr_{\cD(\mathcal{G})}({\bf d}) =  \pr_{\mathcal{B}_m}({\bf d})\corr{{\bf d}}\bigg(1+O\bigg(\frac{\Delta_S^3\Delta_T^3 (n\ell)^{\varepsilon/2}}{m} ( 1/s +1/t) +   n^{\varepsilon-1/2}  +  \ell^{\varepsilon-1/2} \bigg)\bigg). 
$$ 
\end{thm}

We prove this theorem in Section~\ref{s:sparseBip} before tackling the more involved case of medium range densities. We note at this point that if we restrict $\D$ to the set of sequences where $s_a,t_v\ge 1$ for all $a\in S$ and $v\in T$ then  $m\ge n, \ell$ and so the condition 
$n/\log^4n + \ell/\log^4\ell=o(m)$ is always true (as $n$   tends to infinity), and the condition 
 $\Delta_S^3\Delta_T^3(n\ell)^{\varepsilon/2} =o(\min\{sm,tm\})$ is implied by $\Delta_S^3\Delta_T^3 = o(m^{1-\varepsilon})$ as $s,t\ge 1$.  
Sequences failing these conditions therefore contain entries 0, which are less interesting since the formula is then often implied by considering only the non-zero entries. One could also apply our method to reach further into this very sparse case, but given these considerations, it is possibly not warranted, and we do not attempt to do so here. Similarly, further examination of our argument should yield results covering cases with wider disparities between $\ell$ and $n$. 

There have been many contributions to this topic in the past. Finding (asymptotic) formulae for the number of bipartite graphs with a given degree sequence goes back to Read's thesis~\cite{read1958} and gained wider interest since the 1970's, including~\cite{ bbk1972, b1974, bm1986,CM, es1971,  m1984, MWX,  mp1976, o1969, wormald1980}. 
In particular, the sparse case is best covered by Greenhill, McKay and Wang~\cite{GMW}, who proved an asymptotic formula for the number of bipartite graphs of a given sequence $({\bf s},{\bf t})$, provided that $M_1({\bf s})=M_1({\bf t})$ and ${\bf s}_{\max}{\bf t}_{\max} =o\left((M_1({\bf s}))^{2/3}\right)$, and their result covers the bipartite version of \thref{t:sparseCaseBip}, in terms of both the density range $m/n\ell$ and the size of the error terms. 
This  
is supplemented by formulae for the number of dense bipartite graphs with specified degree sequences by Canfield, Greenhill, and McKay~\cite{CGM} that apply as long as $\ell$ and $n$ are not too far apart. 
In fact, in \cite{CGM} it was found that the formulae for the sparse and the dense case can be unified to produce the formula in \thref{t:mainbip}, which was implicitly conjectured in~\cite{CGM} to hold for the cases in between. This conjecture is essentially verified by  \thref{t:mainbip} for a wide range of parameters ${\bf s}$ and ${\bf t}$. 

 
A special case is that of so-called semi-regular bipartite graphs, in which all vertices on one side of the bipartition have degree $s$, say, and all vertices on the other side have degree $t$. So let   ${\bf s}$ denote the constant vector of length $\ell$ in which every entry is $s$, and  ${\bf t}$ denote the constant vector of length $n$ in which every entry is $t.$ In 1977, Good and Crook~\cite{gc1977} suggested that the number of bipartite graphs with degree sequence $({\bf s},  {\bf t})$
is roughly 
$ 
 \binom{n}{s}^{\ell}\binom{\ell}{t}^{n}/\binom{\ell n}{m} 
$
when $m= s\ell = tn$.
Some of the references mentioned above, in  particular~\cite{MWX} and~\cite{CM}, verify that this formula is correct up to a constant factor, for  particular ranges of $m$, $n$, $s$ and $t$,  by showing that the number is 
\bel{suggbip}
\frac{\binom{n}{s}^{\ell}\binom{\ell}{t}^{n}}{\binom{\ell n}{m}}  e^{-1/2+o(1)}.  
\end{equation}
 This asymptotic assertion is immediately equivalent to
$\pr_{\mathcal{G}(\ell,n,m)} ({\bf s},  {\bf t}) \sim \pr_{  \mathcal{B}_m(\ell,n)}({\bf s},  {\bf t}){\tilde H}({\bf s},  {\bf t})$.  Consequently, \thref{t:mainbip} verifies~\eqn{suggbip} for a new range  of parameters in the moderately dense case. 
 

For digraphs without loops, there are far fewer corresponding results. For the dense case, i.e.~when the number of edges is $\Theta(n^2)$, a result by 
Greenhill and McKay~\cite{GM} implies an asymptotic formula.
Barvinok~\cite{b2010} provides upper and lower   bounds  which are coarser but their bounds apply to a wider range of in- and out-degree sequences. 
The only result we are aware of that explicitly enumerates loopless digraphs by degree sequence in the sparse case is by Bender~\cite{b1974}, which only applies for bounded degrees. However, it is clear that the standard   techniques used previously for sparse graph enumeration could be used to increase the density and obtain results more in line with the existing ones for bipartite graphs. 

 
 {\subsection{Models for the degree sequences of   random graphs }
In 1997, McKay and Wormald~\cite{degseq1} showed that if a certain enumeration formula holds for the number of graphs of a given degree sequence then the degree sequences of the random graph models $\mathcal{G}(n,m)$ and ${\cal G}(n,p)$ can be modelled by certain binomial-based models. The model for ${\cal G}(n,p)$ showed that the degree sequence was distributed almost the same as a sequence of independent binomial random variables, subject to having even sum, but with a slight twist that introduces dependency. It was also shown there that for properties of the degree sequence satisfying some quite general conditions, this conditioning and dependency make no significant difference, and hence those properties are essentially the same as for a sequence of independent binomials.

At that time, the existing formulae for the sparse and the dense case supplied that relationship of the models. Recently, the enumeration results of \cite{lw2018} for the medium range provide the missing formulae for the gap range of densities, establishing a conjecture from~\cite{degseq1}. 
A natural supposition since~\cite{degseq1} appeared was that the degree sequences of random bipartite graphs and digraphs satisfy similar properties. This was an implicit conjecture of McKay and Skerman~\cite{MS}, who adapted some of the arguments in~\cite{degseq1} to show that the existing enumeration results for dense bipartite graphs and directed graphs imply a binomial-based model of the degree sequences of such graphs. This is quite analogous to the model in the graph case, except that it contains an extra complicating conditioning required because the sum of degrees of the vertices in each part must be equal.
McKay and Skerman point out that, once the  enumeration formulae are proved in the missing ranges, one would expect the model results to follow. 
Our enumeration results stated above provide what is necessary to immediately establish the relevant conjecture in the case of $\mathcal{G}(\ell,n,m)$ and $\vec\mathcal{G}(n,m)$, as described below, provided that $\ell$ and $n$ are not too disparate. For their binomial random graph siblings $\mathcal{G}(\ell,n,p)$ and $\vec\mathcal{G}(n,p)$, in which edges are selected independently with probability $p$, one would expect that arguments similar to those in~\cite{MS}, in conjunction with our results, will now suffice. 
 
Let $A_n$ and $B_n$ be two sequences of probability spaces with the same underlying set for each $n$. Suppose that whenever a sequence of events $H_n$ satisfies $\Pr(H_n)=n^{-O(1)}$ in either model, it is true that $\Pr_{A_n}(H_n)\sim\Pr_{B_n}(H_n)$, where by $f(n)\sim g(n)$ we mean that $f(n)/g(n)\to 1$ as $n\to\infty$. Then we call $A_n$ and $B_n$ {\em asymptotically quite equivalent (a.q.e.).}  We use $\omega$ to mean a function going to infinity as $n\to\infty$, possibly different in all instances. 
 

\begin{thm}\thlab{t:bipmodel} 
\begin{enumerate}[label=(\alph*)]
\item\label{model-a}  The probability spaces  $\cD(\vec \mathcal{G}(n,m))$ and $\vec \mathcal{B}_m(n) $ are a.q.e.~provided that  $\log ^3n  =  o(\min\{m, n\ell-m\})$;
\item\label{model-b} The probability spaces $\cD(\mathcal{G}(\ell,n,m))$  and $\mathcal{B}_m(\ell,n) $ are a.q.e.~provided that $\max\{m, n\ell-m\}=\omega \log n$ and at least one of the following holds: 
\begin{enumerate}[label=(\roman*)]
\item\label{model-b-ii}
$\ell\le n$ and for some fixed $\mu_0>0$ and $\varepsilon>0$ 
we have 
$m<\mu_0n\ell$ and $n^3=o(\ell^2m^{1-\varepsilon})$;
\item\label{model-b-iii}
 $n/\log^4n + \ell/\log^4\ell=o(m)$ and  for some fixed $\varepsilon>0$ we have $m^{4+\varepsilon}=o(n^2\ell^2\min\{ \ell,n\})$;
\item\label{model-b-iv}
$m=o(\min\{n/\log^2n,   \ell/\log^2\ell\})$ and $\log^3 \ell + \log^3 n=o(m)$.
\end{enumerate}
  \end{enumerate}
 \end{thm}
 We prove this theorem in Section~\ref{s:denseBip}. 
 We note that the assertion for~\ref{model-a} for the range $m> n^2 / \log n$ is covered by McKay and Skerman~\cite[Theorem 1(d)]{MS}. For the bipartite case~\cite[Theorem 1(c)]{MS}  covers the range  $m>\ell n / \log n$ and $\ell = n^{1+o(1)}$.  \thref{t:bipmodel}~\ref{model-b}\ref{model-b-ii} applies for a slightly larger range of $\ell$ and $n$, at least for large-ish $m$. 
The last condition in~\ref{model-b-ii}  is equivalent to  
$$\frac{n^{2+\varepsilon}}{\ell^{3-\varepsilon}} \ll \mu^{1-\varepsilon}$$ for some $\varepsilon>0,$ where $\mu = m/n\ell$. Thus, $n$ may be as large as $\ell^{2-\varepsilon}$ for sufficiently large density $\mu$. 

Finally, we note that when $\min\{\ell,n\}\gg \max\{\ell,n\}^{10/11+\varepsilon}$ for fixed $\varepsilon>0,$ then all values of $m$ are covered by \thref{t:bipmodel} (swapping $\ell$ and $n$ in~\ref{model-b}\ref{model-b-ii} if necessary) and using~\cite[Theorem 1(d)]{MS} for the dense cases of both~\ref{model-a} and~\ref{model-b}. 
 

\subsection{ Edge probabilities.}
As a by-product of our proof of \thref{t:mainbip} in Section~\ref{s:denseBip}, we obtain asymptotic formulae for the edge probabilities in a random bipartite graph with a given  degree sequence, and of a random digraph with a given sequence of out- and in-degrees.  
 
 
\begin{thm}\thlab{t:edgeprobability} 
Let $n$, $\ell$, $m$, and $\D$ be as in \thref{t:mainbip}  and  let $\mathcal{G} = \mathcal{G}(\ell,n,m)$ or $\mathcal{G} = \vec\mathcal{G}(n,m)$. Let $a\in S$ and $v\in T $, with $v\ne a'$   in the digraph case. Then uniformly for ${\bf d}=({\bf s},{\bf t})\in \D$, the probability that  $av$  is an edge of  $G\in \mathcal{G}$, conditional on the event that $\cD(G)={\bf d}$, is
$$
  \frac{s_at_v}{m-\delta^{\mathrm{di}}t}\left(1-\frac{(s_a-s)(t_v-t)}{m-\delta^{\mathrm{di}}t-\tavgs}
+\frac{(s_a-s)\sigma^2({\bf t})}{\tavgs(\ell-t)}
+\frac{(t_v-t)\sigma^2({\bf s})}{\tavgs(n-s)}
+\frac{\delta^{\mathrm{di}}(t_{\mathrm{mate}{a}}+s_{\mathrm{mate}{v}})}{n-1} +O\left(\min\{s,t\}^{4\varphi-4}\frac{m}{n\ell}\right)
 \right),
$$
where $s= m/\ell$ and $t = m/n$. 
\end{thm}
 We prove this theorem in Section~\ref{s:denseBip}. 






\section{Preliminaries}
\lab{s:prelim}

As we indicated in the introduction, the argument in this paper derives from that  in~\cite{lw2018}, whose notation and structure we will follow quite closely. 
Differences occur though to account for the fact that we are dealing with certain forbidden edges. 
Naturally, we resort to notation used in~\cite{lw2018} and add notation that is special to the bipartite case. We then state several intermediate results from~\cite{lw2018}. 

\subsection{Notation}\lab{s:notation} 
Our {\em graphs} are simple, that is, they have no loops or multiple edges. We write $a\sim b$ to mean that $a/b\to 1$, $f=O(g)$ if $|f|\le Cg$ for some constant $C$,  and $f=o(g)$ if $f/g\to 0$.  We use $\omega$ to mean a function going to infinity, possibly different in all instances. Also $\binom{V}{2}$ denotes the set of $2$-subsets of the set $V$, and $V$ is often of the form $[N]$, which denotes $\{1,\ldots , N\}$. In this paper  multiplication by juxtaposition has precedence over ``$/$", so for example $j/\mu N^2= j/(\mu N^2)$. 

Let $N$ be an integer and let $V=[N]$. 
Assume that $\cA=\cA(N)\se \binom{ [N] }{2}$ is specified; we call this the set of {\em allowable pairs}. Note that as usual we regard the edge joining vertices $u$ and $v$ as the unordered pair $\{u,v\}$, and denote this edge by $uv$ following standard graph theoretic notation. 
A sequence ${\bf d}= (d_{1},\ldots,d_{N})$ is called  
{\em $\cA$-realisable} 
if there is a graph $G$ 
on vertex set $V$ such that vertex $a\in V$ has degree $d_a$ and all edges of $G$ 
are allowable pairs. 
In this case, we say $G$ {\em realises ${\bf d}$ over $\cA$}.  In standard terminology, if ${\bf d}$ is $\binom{V}{2}$-realisable, it is  {\em graphical}. 
Let $\mathcal{G}_{\cA}({\bf d})$ be the set of all graphs that realise ${\bf d}$ over $\cA$. 
The graph case when $\cA=\binom{V}{2}$ is dealt with in~\cite{lw2018}. 
In this paper, we are particularly interested in the following two special cases of $\cA$. 
\begin{itemize}
\item  {\bf Bipartite graph case.\\} 
Let $ \ell, n$ be integers and set $N =\ \ell +n$. 
Set $\cA=\cA^{\mathrm{bi}} = \{uw:u\in [ \ell], w\in  [N]\sm[\ell]\}$. 
Then $\mathcal{G}_\cA({\bf d})$ is the set of all bipartite graphs $G$ on vertex set $[N]$ that 
realise the degree sequence ${\bf d}=({\bf s},{\bf t})$ with one part being $S=[\ell]$ and the other part $T=[N]\setminus[\ell]$. 

\item {\bf Digraph case.\\} 
Assume that $N$ is even and let $n$ be an integer such that $N =2n$. 
Set $\cA=\cA^{\mathrm{di}} = \{uw: u\in [n], w\in [n+1,2n], u+n \neq w\}$. 
Then $\mathcal{G}_\cA({\bf d})$ corresponds to the set of all bipartite graphs $G$ on vertex set $[2n]$ that 
realise the degree sequence ${\bf d}=({\bf s},{\bf t})$ with one part being $S=[n]$ and the other part $T=[2n]\setminus[n]$ that do not contain any edge of a predefined matching, or equivalently,  
$\mathcal{G}_\cA({\bf d})$ corresponds to the set of all digraphs $G$ on vertex set 
$[n]$ that have no loops and that realise the out-degree sequence ${\bf s}$ and in-degree sequence ${\bf t}$. Recall that $\mathrm{mate}{a}=a+n$ for $a\in S$ and $v'= v-n$ for $v\in T$ so that edges of the form $aa'$ are forbidden. 
\end{itemize} 

Let $\ell$, $n$ be integers and suppose that ${\bf d}$ is a sequence of length  $\ell + n$. 
Recall the definitions of  ${\bf s}={\bf s}({\bf d})$, ${\bf t}={\bf t}({\bf d})$, $s$, $t$, $M_1({\bf d})$, $\sigma({\bf s},{\bf t})$, and of $\sigma^2({\bf d})$ from the introduction. 
We also use $\Delta$ or $\Delta({\bf d})$ to denote $\max_i d_i$, in line with the notation for maximum degree of a graph. 
With $\cA$ understood (to be either $\cA^{\mathrm{bi}} $ or $\cA^{\mathrm{di}} $ in this paper) we write $\mu=\mu({\bf d})	$ for the quantity $M_1({\bf d})/|\cA|$ and note that this agrees with the definition of $\mu$ given just above~\eqref{corrH} in the introduction. 
Throughout this paper we use ${\bf e}_i$ to denote the elementary unit vector with 1 in its  coordinate indexed by $i$. 
We say ${\bf d}$ is  {\em balanced}   if $M_1({\bf s})=M_1({\bf t})$. Clearly being balanced is necessary for ${\bf d}$ to be $\cA$-realisable in either of the cases $\cA=\cA^{\mathrm{bi}}$ or $\cA=\cA^{\mathrm{di}}$. Furthermore, we say that ${\bf d}$ is {\em $S$-heavy} if $M_1({\bf s})=M_1({\bf t})+1$, and we call it {\em $T$-heavy}  if $M_1({\bf s})=M_1({\bf t})-1$.  

Finally, we use $1\pm \xi$ to denote a quantity between $1-\xi$ and $1+\xi$ inclusively.
\subsection{Cardinalities, probabilities and ratios} 
We first quote a simple result by which we leverage absolute estimates of probabilities from comparisons of related probabilities.
\begin{lemma}[Lemma 2.1 in \cite{lw2018}]\thlab{l:lemmaX} 
Let  $\mathcal{S}$ and $\mathcal{S}'$ be probability spaces with the same underlying set $\Omega$.  
Let $G$ be a graph with vertex set  $\W\subseteq \Omega$  such that $ \pr_\mathcal{S}(v),\pr_{\mathcal{S}'}(v) >0$  for all $v\in \W$. Suppose that  $\varepsilon_0,  \delta >0$ such that 
 $\min\{ \pr_\mathcal{S}(\W), \pr_{\mathcal{S}'}(\W)\}>1-\varepsilon_0>1/2$,  and such that  for every edge $uv$ of $G$,  
$$
\frac{\pr_{\mathcal{S}'}(u)}{\pr_{\mathcal{S}'}(v)}=   e^{O( \delta )}  \frac{\pr_{\mathcal{S}}(u)}{\pr_{\mathcal{S}}(v)}   
$$
where the constant implicit in $O(\cdot)$ is  absolute. 
Let $r$ be an upper bound on the diameter of $G$ and assume $r<\infty$. Then for each $v\in \W$ we have
$$
  \pr_{\mathcal{S}'}(v)  =e^{O(r \delta +\varepsilon_0)}  \pr_\mathcal{S}(v) ,
$$
with again a   bound uniform for all $v$.
\end{lemma}
Using the lemma calls for analysing the ratios of probabilities both in the ``true'' probability space $\mathcal{S}'$ (which will be the degree sequence of $\mathcal{G}(\ell,n,m)$ or of $\vec\mathcal{G}(n,m)$) and in an ``ideal'' probability space $\mathcal{S}$ by which we are approximating the true space. 
This leads to computing ratios of closely related instances of the expression on the right hand side of~\eqref{enumFormula}. 
Let ${\bf d}=({\bf s},{\bf t})$ be a sequence where ${\bf s}$ and ${\bf t}$ are of length $\ell$ and $n$, respectively, let $a, b\in S$, and assume that ${\bf d}$ is $S$-heavy. 
Note first that the following are immediate from~\eqref{probbin}:
$$\frac{\Pr_{\mathcal{B}_m(\ell,n)}({\bf s}-{\ve_a},{\bf t})}{\Pr_{\mathcal{B}_m(\ell,n)}({\bf s}-{\ve_b},{\bf t})} 
	= \frac{s_a(n+1-s_b)}{s_b(n+1-s_a)} \quad \text{ and }\quad
\frac{\Pr_{\vec\mathcal{B}_m(n)}({\bf s}-{\ve_a},{\bf t})}{\Pr_{\vec\mathcal{B}_m(n)}({\bf s}-{\ve_b},{\bf t})} 
	= \frac{s_a(n-s_b)}{s_b(n-s_a)}.$$ 
Similarly,  straight from the definition of ${\tilde H}$ in~\eqref{corrH} we have 
\begin{align*} 
\frac{\corr{{\bf s}-{\ve_a},  {\bf t}}}{\corr{{\bf s}-{\ve_b},  {\bf t}}} 
 &= 
  \exp\bigg(\frac{s_b-s_a}{s\ell(1-\mu')}
 \left(1-\frac{\sigma^2({\bf t})}{t(1-\mu')}\right)
 +\frac{ \delta^{\mathrm{di}} (t_{a'}-t_{b'})}{sn(1-\mu')}\bigg),  
\end{align*} 
where $\mu'=\mu({\bf s}-{\ve_a},{\bf t})$, $s=s({\bf s}-{\ve_a},{\bf t})$, $t=t({\bf s}-{\ve_a},{\bf t})$, 
which are, in this case, equal to $\mu({\bf s}-{\ve_b},{\bf t})$, $s({\bf s}-{\ve_b},{\bf t})$, and $t({\bf s}-{\ve_b},{\bf t})$, respectively (recalling that $\mu$ is slightly different in the two cases of $\cA^{\mathrm{bi}}$ and $\cA^{\mathrm{di}}$), and where, we recall, $\delta^{\mathrm{di}}$ is the indicator variable for the digraph case. 
Therefore, denoting by ${H}({\bf d}')$ the function $\Pr_{\mathcal{B}_m}({\bf d}'){\tilde H}({\bf d}')$, 
we get a ``combined goal ratio'' in the two cases which is 
\begin{align}\lab{H}
\frac{{H}({\bf s}-{\ve_a},{\bf t})}{{H}({\bf s}-{\ve_b},{\bf t})} 
 =\frac{s_a(n+\delta^{\mathrm{bi}} -s_b)}{s_b(n+\delta^{\mathrm{bi}}-s_a)}
 \exp\bigg(\frac{s_b-s_a}{s\ell(1-\mu')}
 \left(1-\frac{\sigma^2({\bf t})}{t(1-\mu')}\right)
 +\frac{ \delta^{\mathrm{di}} (t_{a'}-t_{b'})}{sn(1-\mu')}\bigg),  
\end{align}
where $\delta^{\mathrm{bi}} = 1-\delta^{\mathrm{di}}$. 

To analyse the ratios of such nearby sequences in the ``true'' probability space note that, with the above notation, $\Pr_{\cD(\mathcal{G})}({\bf d})$ in \thref{t:mainbip} is just $|\mathcal{G}_{\cA}({\bf d})|/|\mathcal{G}|$ where $\mathcal{G}$ is the random graph space $\mathcal{G}(\ell,n,m)$ or $\vec\mathcal{G}(n,m)$. Let us introduce some more notation. 
Let $F\se \cA$, i.e.~a subset of the allowable edges. 
We write $\mathcal{N}_F({\bf d})$ and $\mathcal{N}^*_F({\bf d})$ 
for the number of graphs $G\in \mathcal{G}_{\cA}({\bf d})$ 
that contain, or do {\em not} contain, the edge set $F$, respectively.  (When  $\mathcal{N}$ and similar notation is used, the set $\cA$ should be clear by context.)
We abbreviate $\mathcal{N}_F({\bf d})$ to $\mathcal{N}_{ab}({\bf d})$   if  $F={\{ab\}}$ (i.e.~contains the single edge $ab$), 
and put $\mathcal{N}({\bf d})=|\mathcal{G}_{\cA}({\bf d})|$. Additionally, for a vertex $a\in V$, we set $\cA(a) =\{v\in V: av \in \cA\}$, and, with ${\bf d}$ understood, we use $\cA^*(a)$ for the set of $v\in \cA(a)$ such that $\mathcal{N}_{av}({\bf d})>0$. 

We pause for a notational comment. In this paper, a subscript  $ab$  is always  interpreted as an ordered pair $(a,b)$ rather than an edge (and similar for triples). This is irrelevant for $\mathcal{N}_{ab}({\bf d}) =  \mathcal{N}_{ba}({\bf d})$ since the two ordered pairs signify the same edge, but the distinction is important with other notation such as the following. 
For vertices $a,b \in V$, if ${\bf d}$ is a sequence such that ${\bf d}-{\ve_b}$ is $\cA$-realisable,   
we define 
\bel{realRatio}
R_{ab}({\bf d})  =\frac{\mathcal{N}({\bf d}-{\ve_a})}{\mathcal{N}({\bf d}-{\ve_b})} 
\end{equation}
and note that this is exactly $\Pr_{\cD(\mathcal{G})}({\bf d}-{\ve_a})/\Pr_{\cD(\mathcal{G})}({\bf d}-{\ve_b})$. 
Estimating those ``true'' ratios will be tightly linked to estimating the following. 
For  $F\se \cA$, let 
$$P_F({\bf d})  =\frac{\mathcal{N}_{F}({\bf d})}{\mathcal{N}({\bf d})},$$ 
which is the probability 
that the edges in $F$ are present in a graph $G$ that 
is drawn uniformly at random from $\mathcal{G}_{\cA}({\bf d})$. 
Of particular interest are the probability of a single edge $av$ and a path $avb$, 
for which we simplify the notation to
\bel{realProb}
P_{av}({\bf d}) =P_{\{av\}}({\bf d}),\qquad P_{avb}({\bf d}) =P_{\{av, bv\}}({\bf d}).
\end{equation}


The following is~\cite[Lemma 2.2]{lw2018}, used to switch between degree sequences of differing total degree.
\begin{lemma}\thlab{trick17}
Let $a v\in \cA$ and let ${\bf d}$ be a sequence of length $N$. 
Then 
\begin{align*}
\mathcal{N}_{av}({\bf d}) 
	&= \mathcal{N} ({\bf d} - {\ve_a} - {\ve_v}) -  \mathcal{N}_{av} ({\bf d} - {\ve_a} - {\ve_v})\\  
	&= \begin{cases} 
		\mathcal{N} ({\bf d} - {\ve_a} - {\ve_v}) (1- P_{av}({\bf d}- {\ve_a} - {\ve_v})) & \mbox{if } \mathcal{N}({\bf d} - {\ve_a} - {\ve_v}) \ne 0\\ 
		0 & \mbox{otherwise.}
	\end{cases}
\end{align*}
\end{lemma}

In Lemma 2.3 in~\cite{lw2018} we bound the probability of an edge of a random graph in $\mathcal{G}({\bf d})$ in the graph case. A similar switching argument is used to obtain corresponding bounds in the bipartite and digraph cases. 
Recall that by $\Delta({\bf d})$ we denote $\max_i d_i$, and that $M_1({\bf d}) = \sum_i d_i$. 
   
\begin{lemma}\thlab{l:simpleSwitching}
Let $\cA$ be $\cA^{\mathrm{bi}}$ or $\cA^{\mathrm{di}}$ and let                 
$({\bf s},{\bf t})$ be an $\cA$-realisable sequence.  
Then for any  $av\in\cA$  
we have 
$$
 P_{av}({\bf s},{\bf t})\le \frac{\Delta({\bf s})\Delta({\bf t})}{M_1({\bf s}) 
 \left(1- 2(\Delta({\bf s})+1)(\Delta({\bf t})+1)/M_1({\bf s})\right)}. 
$$
\end{lemma}
\begin{proof} 
 Assume without loss of generality that $a\in S$ which forces $v\in T$ in both the digraph and bipartite cases. 
For each bipartite graph $G$ with degree sequence $({\bf s},{\bf t})$ and an edge joining $a$ and $v$, we can perform a switching (of a type often used previously in graphical enumeration) by removing both $av$ and  another randomly chosen edge $bw$ (with $b\in S$, and $w\in T$), and inserting the edges  $aw$ and $bv$, provided that no multiple edges are formed. Note that the way we choose $b$ and $w$ no loops can occur this way. In the digraph case, we should also make sure that $w\neq\mathrm{mate}{a}$ 
and that $b\neq v'$, 
since the pairs $aa'$ and $vv'$ are not allowable. 
The number of such switchings that can be applied to $G$ with the vertices of each edge ordered, is at least 
$$
M_1({\bf s}) - (\Delta({\bf s}) +1)\Delta({\bf t})- \Delta({\bf s})(\Delta({\bf t})+1) 
$$
since there are $M_1({\bf s})$ ways to choose $b\in S$ and $w\in T$, 
whereas the number of such choices that are ineligible is at most the number of choices with $b$ being a neighbour of $v$ (which automatically rules out  $b=a$) or $b=\mathrm{mate}{v}$, or similarly for $w$. On the other hand, for each graph $G'$ in which  $av$ is {\em not} an edge, the number of ways that it is created by performing such a switching backwards is at most $\Delta({\bf s})\Delta({\bf t})$. Counting the set of all possible switchings over all such graphs $G$ and $G'$ two different ways shows that the ratio of the number of graphs with  $av$  to the number without  $av$ is at most
$$
\beta:=\frac{\Delta({\bf s})\Delta({\bf t})}{M_1({\bf s})- 2(\Delta({\bf s}) +1)(\Delta({\bf t})+1) }.
$$
Hence $P_{av}({\bf d})\le \beta/(1+\beta)$, and the lemma follows in both cases. 
\end{proof}


\subsection{Proof structure}\lab{s:template}

We recall the template of the method introduced in~\cite{lw2018}. We follow this template in both the sparse and dense cases. 

\noindent
{\bf Step~1.}~Obtain an estimate of the ratio $R_{ab}({\bf d})$ between the numbers of graphs of related degree sequences, using the forthcoming Proposition~\ref{l:recurse}. This step is the crux of the whole argument. 

\smallskip
\noindent
{\bf Step 2.} By making suitable definitions, we cause this ratio  to appear  as   the expression $\pr_{\mathcal{S}'}({\bf d})/ \pr_{\mathcal{S}'}({\bf d}')$ for some probability space $\mathcal{S}'$ on an underlying set $\Omega$ in an application of  Lemma~\ref{l:lemmaX}. There, $\Omega$ is the set of degree sequences, with probabilities in $\mathcal{S}'$ determined by  the random graph under consideration, and the graph $G$ in the lemma has a suitable vertex set $\W$ of such sequences. Each edge of $G$ is in general a  pair of degree sequences   ${\bf d}-{\ve_a}$ and ${\bf d}-{\ve_b}$ of the form occurring in the definition of $R_{ab}( {\bf d}) $. Having defined $G$, we may call any two such degree sequences {\em adjacent}.  

\smallskip
\noindent
{\bf Step 3.}~Another probability space $\mathcal{S}$ is defined on $\Omega$, by taking a probability space $\mathcal{B}$ directly from a joint binomial distribution,   together with a function $\corr{{\bf d}}$ that varies quite slowly, and defining  probabilities in $\mathcal{S}$ by the equation
$  \pr_\mathcal{S}({\bf d})=    \pr_{\mathcal{B} }({\bf d}) \corr{{\bf d}} /{\bf E}_{\mathcal{B}} {\tilde H}$.

\smallskip
\noindent
{\bf Step 4.}~Using sharp concentration results, show that  $P(\W) \approx 1$ in both of the  probability spaces $\mathcal{S}$ and $\mathcal{S}'$ (where, by $\approx$, we mean approximately equal to, with some specific error bound in each case). As part of this, we show that ${\bf E}_{\mathcal{B} } {\tilde H} \approx 1 $. At this point, we may specify $\varepsilon_0$ for the application of Lemma~\ref{l:lemmaX}.
 
\smallskip
\noindent
{\bf Step 5.}~Apply Lemma~\ref{l:lemmaX} and the conclusions of the previous steps to deduce   $P_{\mathcal{S}'}({\bf d}) \approx P_\mathcal{S}({\bf d})\approx \pr_{\mathcal{B} }({\bf d}) \corr{{\bf d}}$. Upon estimating the errors in the approximations, which includes bounding the diameter of the graph $G$, we obtain an estimate for the probability $P_{\mathcal{S}'}({\bf d})$ of the random graph having degree sequence ${\bf d}$ in terms of a known quantity.



\subsection{Realisability}
As in the graph case in~\cite{lw2018}, before estimating how many (bipartite) graphs have degree sequence ${\bf d}$, for preparation we need to know that there is at least one such graph for various ${\bf d}$. Mirsky~\cite[p.~205]{M} gives a necessary and sufficient condition  for the existence of a non-negative integer matrix with row and column sums in specified intervals. For the case that those sums are specified precisely, the statement is the following.
\begin{thm}[Corollary of Mirsky~\cite{M}]\lab{t:mirsky}  Let $0\le r_i$, $0\le c_j$, $m_{ij}\ge 0$ be integers for all $1\le i  \le\ell $, $1\le j\le n$ such that $ \sum_{1\le i\le  \ell  } r_i = \sum_{ 1\le j\le n} c_j$. Then there exists an $ \ell\times n$ integer matrix $B=(b_{ij})$ with row sums $r_1,\ldots, r_\ell $ and column sums $c_1,\ldots, c_n$ such that $0\le b_{ij}\le m_{ij}$ for all such $i$ and $j$ if and only if, for all $X\subseteq \{1,\ldots, \ell\}$ and $Y\subseteq  \{1,\ldots, n\}$,
$$
\sum_{i\in X,\,j\in Y} m_{ij} \ge \sum_{i\in X } r_i - \sum_{ j\notin Y} c_j.
$$
\end{thm}
 %
We   use this to show existence of bipartite graphs with given degrees and forbidden edges for the cases of interest, avoiding maximum generality in order to keep it simple. In order to apply this to digraphs, one would set $\ell= n$ and regard the edges as directed from the first part to the second. For loopless digraphs, we merely forbid all edges of the form $\{i,i+n\}$. Recall that, with $\ell$ and $n$ understood, we set $S=[\ell]$ and $T=[n+\ell]\sm[\ell]$ for convenience.
\begin{lemma}\thlab{lem:bipRealisable}
Given  a constant $C\ge 1$, the following holds for $\ell,n$ sufficiently large and  $\varepsilon>0$   sufficiently small.  Let  $s_a\ge 1$ and $t_v\ge 1$ be integers for all $a \in S$, $v\in T$, with  $m:= \sum_{a \in S} s_a = \sum_{ v\in T } t_v$.  Also let 
$F \se\{av : a\in S,v\in T\}$  be a set of unordered pairs, representing forbidden edges, with no more than $C$ pairs in $F$  containing any $w\in S\cup T$. Let $\Delta_S=\max_{a\in S} s_a $ and $\Delta_T=\max_{v\in T} t_v$. 
Then  there exists a bipartite graph  with bipartition $(S,T)$ with degrees $s_a$ for $a\in S$ and $t_v$ for $v\in T$, and containing no edge in the forbidden set $F$, provided that either of the following holds. 
\begin{enumerate}[label=(\alph*)]
\item  \label{lem:bipRealisablei} We have $m\le \ell n/9$, as well as  $\Delta_S \le 2s$  and  $\Delta_T  \le2t$ where   $s=m/\ell$ and $t=m/n$.
\item \label{lem:bipRealisableii} We have $\Delta_S\le \sqrt  m/2-C$ and  $\Delta_T\le \sqrt  m/2-C$.
\end{enumerate}
\end{lemma}
\begin{proof} 
We will apply Theorem~\ref{t:mirsky} with $m_{ij}=0$ if $\{i,j+\ell\}$ is a forbidden edge, and  $m_{ij}=1$ otherwise, and with $r_i=s_i$ and $c_j=t_{j+\ell}$. Note that 
$ 
\sum_{a\in X,v\in Y} m_{ij}\ge xy-C \min\{x,y\}
$ 
for all subsets $X\se S$, $Y\se T$, where $x=|X|$ and $y=|Y|$. 
We will show that 
for all $X\subseteq S$ and $Y\se T$, with $x=|X|$ and $y=|Y|$, we have
\bel{cond0}
 m-C \min\{x,y\}\ge  \sum_{a\in X} s_a +\sum_{v\in   Y} t_v -xy.
\end{equation}
Equivalently, $ xy-C \min\{x,y\}\ge  \sum_{a\in X} s_a -\sum_{v\in T\sm Y} t_v$. Note that with the previous observation and Theorem~\ref{t:mirsky}, this implies that there is a matrix $B$ which is the adjacency matrix of the desired bipartite graph.

For (a), suppose first that $x\ge 2t+C$. Then using $\sum_{a\in X} s_a\le m$ and $\sum_{v\in   Y} t_v \le y\Delta_T \le 2y t$, we find that the right hand side of~\eqn{cond0} is at most $m-yC$, and~\eqn{cond0} follows. A symmetric argument works if $y\ge 2s+C$. So we may assume that neither of these occur. Then
$$
  \sum_{a\in X} s_a +\sum_{v\in   Y} t_v  \le x\Delta_S+y\Delta_T\le (2t+C)2s+(2s+C)2t
$$
and the left hand side is at least 
$m-C(x+y)/2\ge m- C(s+t)-C^2$.
Thus~\eqn{cond0}  follows if we show
that  $m\ge 8st+  5C(s+t)+C^2$, i.e.\ if $1\ge 8m/\ell n +  5C(1/\ell+1/n) +C^2/m$ (since $s=m/\ell$ and $t=m/n$). This  holds for  $\ell$ and $n$ sufficiently large because  $ n\le  m\le \ell n/9$. 

Now consider (b).
Without loss of generality, since $S$ and $T$ can be interchanged along with $X$ and $Y$, $\ell$ and $n$ etc., we assume $x\ge y$. First consider the case that $x\le \sqrt m / 2$. Then $y\le \sqrt m / 2$, and so  the right hand side of~\eqn{cond0} is  at most 
$$
x\Delta_S  +y\Delta_T   \le m/2-C(x+y),
$$
which implies~\eqn{cond0}. On the other hand, if $  x>\sqrt m / 2$ then we can bound the first summation in~\eqn{cond0} by $m$ and the second one by $y\Delta_T\le y\sqrt m/2-yC$, and use $xy> y\sqrt m/2$
to obtain~\eqn{cond0}.
\end{proof}



\subsection{Recursive relations}\lab{s:recursive}

In this subsection we collect results about recursive relations that were obtained in~\cite{lw2018}. The results were stated for an arbitrary set $\cA$ of allowable pairs in $\binom{V}{2}.$ 
Recall the definitions of the probabilities $P_{av}({\bf d})$ and $Y_{avb}({\bf d})$ in~\eqref{realProb}, and of the ratio $R_{ab}({\bf d})$ in~\eqref{realRatio}.
\begin{proposition}[Proposition 3.1 in \cite{lw2018}]\thlab{l:recurse}
Let ${\bf d}$ be a sequence of length  $n$ and let $\cA\se \binom{[n]}{2}$.
\begin{itemize}
\item[$(a)$] Let $a,v\in V$. If $\mathcal{N}_{av}({\bf d})>0$ 
then 
	\begin{equation*}
	P_{av}({\bf d}) =d_{v} \Bigg(\sum_{b\in \cA^*(v)}
	 R_{ba} ( {\bf d}- {\ve_v})
	\frac{1-P_{bv}({\bf d} - {\ve_b} - {\ve_v})}
	{1-P_{av}({\bf d} - {\ve_a} - {\ve_v})}\Bigg)^{-1}.
	\end{equation*}
\item[$(b)$] Let $a,b\in V$. If ${\bf d}-{\ve_b}$ is $\cA$-realisable then 
	\begin{align} \lab{Ratformula
	 R_{ab} ( {\bf d}) &= \frac{d_{a}}{d_{b}}\cdot \frac{ 1-\ensuremath {B}(a,b, {\bf d} - {\ve_b})}{ 1-\ensuremath {B}(b,a, {\bf d} - {\ve_a})}, 
	\end{align}
	where 
	\begin{align}\lab{eq:bad}
	\ensuremath {B}(i,j, {\bf d}') 
	& =
	 \frac{1}{d_{i}}\Bigg(\sum_{ v \in \cA(i)\setminus \cA(j)}  P_{iv}({\bf d}')   +
	 \sum_{ v \in \cA(i)\cap \cA(j) }  Y_{ivj}({\bf d}') \Bigg), 
	\end{align}
	provided that  $\ensuremath {B}(b,a, {\bf d} - {\ve_a}) \ne 1$.

\item[$(c)$] Let $a,v,b$ be distinct elements of $V$. If ${\bf d}-{\ve_a}-{\ve_v}$ is $\cA$-realisable then 
$$Y_{avb}({\bf d})=\frac{P_{av}({\bf d})\big(P_{bv}({\bf d}-{\ve_a}-{\ve_v})-Y_{avb}({\bf d}-{\ve_a}-{\ve_v})\big)}
	{1-P_{av}({\bf d}-{\ve_a}-{\ve_v})}.$$
\end{itemize}
\end{proposition}





These recursive relations 
motivated the definition of operators in~\cite{lw2018} that we restate here.

Let  $\Z^N$  denote the set of non-negative integer sequences  of length $N$.   
For a given integer $N$ and a set $\cA\se \binom{[N]}{2}$ we define $\oA$ to be the set of ordered pairs $(u,v)$ with $\{u,v\}\in \cA$.  Ordered pairs are needed here because, although the functions of interest are symmetric in the sense that the probability of an edge $uv$ is the same as $vu$, our approximations to the probability do not obey this symmetry. 
Similarly, let $\oA_2$ denote the set of ordered triples $(u,v,w)$ with $u$, $v$ and $w$ all distinct and $\{u,v\}$, $\{v,w\} \in \cA$. 

Suppose we are given 
${\bf p}: \oA\times\Z^N\to\R_{\ge 0}$, 
${\bf y}: \oA_2\times \Z^N\to\R_{\ge 0}$ and 
${\bf r}: [N]^2 \times \Z^N\to\R_{\ge 0}$. 
We  write ${\bf p}_{av}({\bf d})$ for ${\bf p}(a,v,{\bf d})$ (where ${\bf d}\in \Z^N$), and remind 
the reader that in this paper, a subscript $av$ always denotes an ordered pair rather than an edge. 
Similarly, we write ${\bf y}_{avb}({\bf d})$ for ${\bf y}(a,v,b,{\bf d})$ and 
${\bf r}_{ab}({\bf d})$ for ${\bf r}(a,b,{\bf d})$. 
We also define an associated function  $\ensuremath {{\bf bad}}({\bf p},{\bf y})$ as follows. 
For ${\bf d}\in \Z^N $ and $a,b\in [N]$ with $a\neq b$, set 
$\ensuremath {{\bf bad}}({\bf p},{\bf y})(a,a,{\bf d}) = 0$ and 
\begin{equation}\lab{def:bad}
\ensuremath {{\bf bad}}({\bf p},{\bf y})(a, b, {\bf d}) = 
\frac{1}{d_{a}}
\left( 
\sum_{v\in \cA(a)\sm \cA(b)} {\bf p}_{av}({\bf d}) 
+ \sum_{v\in \cA(a)\cap \cA(b)} {\bf y}_{avb}({\bf d}) \right).
\end{equation}
We define two operators 
${\cal P}({\bf p},{\bf r})$, ${\cal Y}({\bf p},{\bf y})$ and ${\cal R}({\bf p},{\bf y})$, acting on ${\bf p}$, ${\bf y}$ and ${\bf r}$ as above, as follows. 
For ${\bf d} \in \Z^N$ 
and $a,v,b \in [N]$ 
we set 
\begin{align}
{\cal P}({\bf p},{\bf r})(a,v,{\bf d}) &= 
d_{v} \left(\sum_{b\in A(v)}
 {\bf r}_{ba} ({\bf d} - {\ve_v}) 
\frac{1-{\bf p}_{bv}({\bf d} - {\ve_b} - {\ve_v})}
{1-{\bf p}_{av}({\bf d} -{\ve_a} - {\ve_v})}\right)^{-1} \text{ for } (a,v)\in \oA,\lab{F1def}\\
{\cal Y}({\bf p},{\bf y})(a,v,b,{\bf d}) &= 
\frac{{\bf p}_{av}({\bf d})\big({\bf p}_{bv}({\bf d}-{\ve_a}-{\ve_v})-{\bf y}_{avb}({\bf d}-{\ve_a}-{\ve_v})\big)}
	{1-{\bf p}_{av}({\bf d}-{\ve_a}-{\ve_v})} \text{ for } (a,v,b)\in \oA_2, \lab{FYdef}\\
{\cal R}({\bf p},{\bf y})_{ab}({\bf d})&= 
\frac{d_{a}}{d_{b}}\cdot \frac{1- \ensuremath {{\bf bad}}({\bf p},{\bf y})(a,b,{\bf d}-{\ve_b})}{1- \ensuremath {{\bf bad}}({\bf p},{\bf y})(b,a, {\bf d} - {\ve_a})}
 \text{ for } a,b\in S \text{ or } a,b\in T. \lab{F2def}
\end{align}	 
 
We observed in~\cite{lw2018} that these operators are ``contractive'' in a certain sense, for particular functions ${\bf p}$ and ${\bf y}$, defined as follows. 
\begin{definition}\thlab{Pi-defn}
Let $\D_0\se \Z^N$ and let $\mu\in\R$. We use $\Pi_{\mu}(\D_0)$ to denote the set of pairs of functions $({\bf p},{\bf y})$ with ${\bf p}:\oA\times \Z^N \to \R_{\ge 0}$ and ${\bf y}:\oA_2\times  \Z^N \to \R_{\ge 0}$ such that for all balanced  ${\bf d}\in \D_0$, we have  
\begin{enumerate}[label={$\mathrm{(}\Pi\mathrm{\alph*}\mathrm{)}$}]
 \item\label{Pi-a}
 $0\le{\bf p}_{av}({\bf d})   \le \mu$ for all $ (a,v) \in \oA$, 
 \item\label{Pi-b}
 $\sum_{v\in \cA(a)\cap\cA(b)} {\bf y}_{avb}({\bf d})\le  \mu d_a $ for all $a\ne b\in [N]$,  and 
 \item\label{Pi-c}
$0\le {\bf y}_{avb}({\bf d})\le     \mu   {\bf p}_{bv}({\bf d})$ for all  $ (a,v,b)\in  \oA_2$.
\end{enumerate}
\end{definition}
 
For the next  lemma, we need to adapt~\cite[Lemma 5.2]{lw2018} to the present bipartite setting. 
Recall the definitions of $\cA^{\mathrm{bi}}$ and $\cA^{\mathrm{di}}$, and of $S$ and $T$ and $a'$ in Subsection~\ref{s:notation}. 
In this setting, $\cA(a)\cap\cA(b)\neq\emptyset$ if and only if both $a,b\in S$ or both $a,b\in T$. For such $a,b$ we have $|\cA(a)\sm\cA(b)| \leq 1$. Further note that $(a,v)\in\oA$ if and only if $a\in S$ and $v\in T$ in the bipartite case or $v\in T\sm\{a'\}$ in the digraph case (or $S$ and $T$ swapped), and thus $(a,v,b)\in\oA_2$ if and only if both $a, b\in S$, $a\neq b$ and $v\in T$ (bipartite) or $v\in T\sm\{a',b'\}$ (digraph); or $S$ and $T$ swapped. 

Also, for ${\bf d}=({\bf s},{\bf t})$ of length $\ell+n$, 
we let $Q_r^0({\bf d}),\, Q_r^S({\bf d})\, \se\Z^{\ell+n}$ be the set of balanced and $S$-heavy, respectively, vectors of non-negative integers that have  $L_1$-distance at most $r$ from ${\bf d}$.  
Recall that we use $1\pm \xi$ to denote a quantity between $1-\xi$ and $1+\xi$ inclusively. 
With these definitions, Lemma~5.2 in~\cite{lw2018} specialises to the following. 
 
\begin{lemma}\thlab{l:errorImplication} 
There is a constant $C>0$ such that the following holds. 
Let $\ell, n$ be integers, $N=\ell+n$, and let $\cA$ be either $\cA^{\mathrm{bi}}$ or $\cA^{\mathrm{di}}$. Let ${\bf d}\in\Z^{\ell+n}$ such that $d_a>1$ for all $a\in [N]$. 
Let $0<\xi \le 1$ and $0<\mu_0=\mu_0(\ell,n) <C$. 
Let $({\bf p},{\bf y})$ and $({\bf p}',{\bf y}')$ be members of $\Pi_{\mu_0}(Q_2^0({\bf d}))$, 
and let 
 ${\bf r}, {\bf r}':[N]^2\times \Z^n \to \R$. Let $a,b\in S$, $v\in T$.
  \begin{enumerate}[label={(\alph*)}]
\item
If ${\bf d}$ is $S$-heavy, ${\bf p}_{cw}({\bf d}')={\bf p}'_{cw}({\bf d}')(1 \pm\xi )$ for all  $ (c,w)\in \oA$  and all ${\bf d}' \in  Q^0_{1}({\bf d})$, 
and ${\bf y}_{cwh}({\bf d}')={\bf y}'_{cwh}({\bf d}')(1 \pm\xi )$ for all $(c,w,h)\in\oA_2$ and all ${\bf d}' \in  Q^0_{1}({\bf d})$, then 
$$
{\cal R}({\bf p},{\bf y})_{ab}({\bf d})= {\cal R}({\bf p}',{\bf y}')_{ab}({\bf d})(1+O\left(\mu_0\xi \right)). 
$$
\item
If ${\bf d}$ is balanced, $v\neq a'$, ${\bf p}_{cv}({\bf d}')={\bf p}'_{cv}({\bf d}')(1 \pm\xi )$ for all $c \in S\sm\{v'\}$ and all ${\bf d}' \in  Q^0_{2}({\bf d})$, and ${\bf r}_{ca}({\bf d}')={\bf r}_{ca}'({\bf d}')(1 \pm\mu_0\xi)$ for all $c \in S\sm\{v'\}$ and all ${\bf d}'\in  Q^1_1 ({\bf d})$,  then  
$$
{\cal P}({\bf p},{\bf r})_{av}({\bf d})={\cal P}({\bf p}',{\bf r}')_{av}({\bf d})\left(1+O\left(\mu_0\xi \right)\right). 
$$
\item
If ${\bf d}$ is balanced, $a\neq b$, $v\not\in\{a', b'\}$, 
${\bf p}_{cv}({\bf d}')={\bf p}'_{cv}({\bf d}')(1 \pm\mu_0\xi )$ for all $c \in S\sm\{v'\}$ and all ${\bf d}' \in  Q^0_{2}({\bf d})$, and 
${\bf y}_{cwh}({\bf d}')={\bf y}'_{cwh}({\bf d}')(1 \pm\xi )$ for all $(c,w,h)\in\oA_2$ and all ${\bf d}' \in  Q^0_{2}({\bf d})$, then 
$$
{\cal Y}({\bf p},{\bf y})_{avb}({\bf d})={\cal Y}({\bf p}',{\bf y}')_{avb}({\bf d})\left(1+O\left(\mu_0\xi \right)\right). 
$$
\end{enumerate}
The constants implicit in $O(\cdot)$ are absolute. 
  \end{lemma}
 %

  


\subsection{Concentration of  random variables}
When ${\bf d}=({\bf s},{\bf t})$ is either the degree sequence of $\mathcal{G}(\ell,n,m)$ or 
$\mathcal{B}_m(\ell,n)$ then we need that $\sigma^2({\bf s})$, $\sigma^2({\bf t})$ and 
$\sigma({\bf s},{\bf t})$ (in the digraph case) are concentrated (to be used in Step 4 of the template given in Subection~\ref{s:template}). 
The following is due to McDiarmid~\cite{McD}, see, e.g., Lemma~4.1 in \cite{lw2018}. 
\begin{lemma}[McDiarmid]
\thlab{l:subsetConc}  Let $c>0$ and let $f$ be a function  defined on the set of   subsets of some set $U$ such that $|f(S)-f(T)|\le c$ whenever $|S|=|T|=m$ and $|S\cap T|=m-1$. Let $S$ be a randomly chosen $m$-subset of $U$. Then for all $\alpha>0$ we have
$$
\pr\left(|f(S)-{\bf E} f(S)| \ge \alpha c\sqrt m  \right) \le 2\exp (- 2\alpha^2).
$$
 \end{lemma}
 The following are the concentration results we need for both the sparse and the medium-dense ranges. 
\begin{lemma}
\thlab{l:sigmaConcBip} 
Let $\ell, n, m$ be integers, let ${\bf d}=({\bf s},{\bf t})$ be a sequence in $\cD(\mathcal{G}(\ell,n,m))$, $\cD(\vec \mathcal{G}(n,m))$, or either of the binomial models   $\mathcal{B}_m(\ell,n)$ and $\vec\mathcal{B}_m(n)$, and
let $s = m/\ell$ and $t =m/n$, $\mu=\mu({\bf d})=m/n(\ell-\delta^{\mathrm{di}})$. Let $a\in S$, $v\in T$. Then the following hold. 
\begin{enumerate}[label={(\roman*)}]

\item For 
	all $\alpha >0$ we have 
	$$\Pr\left(|s_a-s|\ge \alpha  \right)\le 2\exp\bigg(-\frac{\alpha^2}{2(s+\alpha/3)}\bigg), \ 
	\Pr\left(|t_v-t|\ge \alpha  \right)\le  2\exp\bigg(-\frac{\alpha^2}{2(t+\alpha/3)}\bigg).$$

\item If  $\log^3 n +\log^3 \ell =o(m)$ and $(\log n)/\sqrt n +(\log^{3/2} n)/\sqrt{m}=o(\alpha)$ 
	then $$\pr\left(|\sigma^2({\bf t})- {\bf Var}\, t_v \ge \alpha t +1/n\right) = o(n^{-\omega }),$$
	where ${\bf Var}\, t_v = t (1-\mu)(1-1/n) (1+O(1/n\ell))$; 
	if  $\log^3 n +\log^3 \ell =o(m)$ and $(\log \ell)/\sqrt \ell +(\log^{3/2} \ell)/\sqrt{m}=o(\alpha)$ 
	then 
	$$\pr\left(|\sigma^2({\bf s})- {\bf Var}\, s_a| \ge \alpha s +1/\ell\right) = o(\ell^{-\omega }),$$ 
	where ${\bf Var}\, s_a = s (1-\mu)(1-1/\ell) (1+O(1/n\ell))$. 
	Furthermore, for  ${\bf d}=({\bf s},{\bf t})$ in $\cD(\vec G(n,m))$ or $\vec\mathcal{B}_m(n)$, 
 $$
\pr\big(|\sigma({\bf s},{\bf t}) - {\bf Covar}( s_a, t_v ) | \ge \alpha s +1/n\big) = o(n^{-\omega }),  
$$
 where $ {\bf Covar}( s_a, t_v )    = O( \mu)$.
\end{enumerate}
\end{lemma}

\begin{proof}   
The proofs of these concentration results are routine so we just point out the differences compared with the proof of~\cite[Lemma 6.2]{lw2018}. 
Note that $s_a$ is distributed hypergeometrically with parameters $n(\ell-\delta^{\mathrm{di}})$, $m$, $n-\delta^{\mathrm{di}}$ in all four models, and similarly, each $t_v$ is distributed hypergeometrically with parameters $n(\ell-\delta^{\mathrm{di}})$, $m$, $\ell-\delta^{\mathrm{di}}$.  
Hence, the claims in (i), and in (ii) for $\sigma^2({\bf s})$ and $\sigma^2({\bf t})$, follow from the proof of Lemma 6.2 in~\cite{lw2018} with only trivial adjustments. For $\sigma({\bf s},{\bf t})$, define 
$$
g(a,b)=  \sign(a-b)  \min\{|a-b|,\sqrt x\}, 
$$
where $\sign(y)$ is $1$, $-1$ or 0 if $y$ is positive, negative or 0, respectively, 
and where $x$ is a function that satisfies $s\log n+\log^2n\ll x\ll \alpha^2sn/\log n$ as in the proof of~\cite[Lemma 6.2]{lw2018}. Let $f=\sum_{i=1}^n g(s_i,s)g(t_i,t)$, and adapt the rest of the proof of Lemma~6.2 in~\cite{lw2018} in the obvious way. This gives the  required concentration bound for $\sigma({\bf s},{\bf t})$
near its expected value, which is $\frac{1}{n}  \sum_{b\in S} {\bf Covar}(s_b,t_{\mathrm{mate}{b}}) =  {\bf Covar}(s_a, t_{\mathrm{mate}{a}})$. 
On the other hand,  we can bound ${\bf Covar}(s_a,t_{\mathrm{mate}{a}}) $  as follows. 
In $\cD(\vec G(n,m))$, the joint distribution of $(s_a,t_{a'})$ is multivariate hypergeometric, with $m$  edges chosen from $n(n-1)$ positions, and  $s_a$ and 
$t_{\mathrm{mate}{a}}$ are the counts for disjoint subsets of size $n-1$ each. Thus, the well known formula gives
$$
{\bf Covar}(s_a,t_{\mathrm{mate}{a}}) = \frac{m(n-1)^2(n(n-1)-m)}{(n(n-1))^2(n(n-1)-1)}=O(m/n^2), 
$$
which establishes the final claim for  $\cD(\vec G(n,m))$. In $\vec\mathcal{B}_m(n)$ the random variables $s_a$ and $t_{v}$ are independent since we condition on $M_1({\bf s}) = m$ and $M_1({\bf t})=m$ separately. Thus the covariance is 0. 
\end{proof}


\section{A formula for sparse digraphs and bipartite graphs} \lab{s:sparseBip}
As mentioned in the introduction, our argument is based on~\cite{lw2018}, and this section in particular has much in common with the corresponding   argument given there for the graph case.
Recall that for a given sequence ${\bf d}=({\bf s},{\bf t})$  
we define $\Delta_S=\Delta({\bf s})=\max_a(s_a)$, and similarly $\Delta_T=\Delta({\bf t}) =\max_v(t_v)$. 

\begin{proof}[Proof of \thref{t:sparseCaseBip}]
If $\D=\emptyset$, there is nothing to prove. So fix ${\bf d}^*\in\D$ and define 
$\hat\Delta_S =2\Delta_S({\bf d}^*)+\ell^{\varepsilon/6}$ and 
$\hat\Delta_T =2\Delta_T({\bf d}^*)+n^{\varepsilon/6}$. 
Let $\D^+$ contain all sequences ${\bf d}\in \Z^{\ell+n}$ with $M_1({\bf s})=M_1({\bf t})=m$, $\Delta_S({\bf d})\le  \hat\Delta_S$ and $\Delta_T({\bf d})\le \hat\Delta_T$. 
   
For an integer $r\ge 0$, denote by $Q_r^0$ (or $Q_r^S$) the set of all balanced (or $S$-heavy, respectively) sequences in $\Z^{\ell+n}$ that have $L_1$ distance at most $r$ from some sequence in $\D^+$. 
(Recall that we define ${\bf d}=({\bf s},{\bf t})$ to be balanced if $M_1({\bf s})=M_1({\bf t})$ and we call it 
$S$-heavy if $M_1({\bf s})=M_1({\bf t})+1$.) 
We start by estimating the ratios of the probabilities of adjacent degree sequences in the random bipartite graph model and the random digraph model, as prescribed by Step 1 of the template in Subsection~\ref{s:template}, using the following. Recall the definition of $R_{ab}$ in~\eqref{realRatio} with $\cA$ being $\cA^{\mathrm{bi}}$ or $\cA^{\mathrm{di}}$.
\begin{claim}\thlab{RSparseBiAndDi}
Uniformly for sequences ${\bf d}=({\bf s},{\bf t})\in Q_1^S$ and for $a, b \in S$ 
$$ 
R_{ab}({\bf d})=\frac{s_a}{s_b} \left(1 +\frac{(s_a-s_b) M_2 +( t_{\mathrm{mate}{a}}-t_{\mathrm{mate}{b}}) \delta^{\mathrm{di}} M_1 }{M_1^2}  \right) \left(1+O\left(\frac{\hat\Delta_S^3\hat\Delta_T^3}{t m^2}\right)\right),
$$
where $M_1 = M_1({\bf s}) -1 = M_1({\bf t})$, $M_2=M_2({\bf t})=\sum_{v\in T}t_v(t_v-1)$ 
 and $\delta^{\rm di}$ is 0 in the bipartite case and 1 in the digraph case.
 \end{claim}
 %
 %
\begin{proof} 
 Note that the claim is true when $a=b$ as $R_{aa} = 1$ by definition. Hence, we can assume $a\neq b$ in the remainder of the proof.
First, consider instead ${\bf d}=({\bf s},{\bf t})\in\D^+$, let $\ell_1$ and $n_1$ be the number of non-zero coordinates in ${\bf s}$ and ${\bf t}$, respectively. 
By definition, $s \ell = M_1({\bf s})\le \ell_1\Delta_S({\bf d})$.
By assumption we therefore have 
\bel{deltas}
\Delta_S({\bf d})\le \hat\Delta_S \ll (s\ell)^{1 /3} 
\leq \left(\Delta_S({\bf d}) \ell_1\right)^{1/3},
 \end{equation}
which readily implies that $\Delta_S({\bf d}) =o(\ell_1^{1/2})$. 
Similarly we find that $\Delta_T({\bf d})=o(n_1^{1/2})$. 
Now apply Lemma~\ref{lem:bipRealisable}(ii), 
with $F=\emptyset$ for the bipartite graph case, and $F$ being the set of disallowed edges from $S$ to $T$ in the digraph case, 
to the sequence formed by the non-zero coordinates of ${\bf d}$ to deduce that 
$\mathcal{N}({{\bf d}})>0$  for $\ell,n$ sufficiently large. 
We can deduce the same conclusion for all ${\bf d}\in Q^0_{8}$, since $\Delta_S({\bf d})$, $\Delta_T({\bf d})$, $\ell_1$ and $n_1$ can only change by a bounded additive term 
when moving from such ${\bf d}$ to the closest member of $\D^+$. 
Similarly, $M_1({\bf s})=\sum_i s_i=s\ell+O(1)$ for all ${\bf d}=({\bf s},{\bf t})\in Q^0_{8}$. Thus, all such ${\bf d}$ are $\cA$-realisable and 
$\hat\Delta_S=o(M_1({\bf s})^{1/3})$ and $\hat\Delta_T=o(M_1({\bf s})^{1/3})$, by~\eqn{deltas}. This and \thref{l:simpleSwitching} imply that 
\bel{Pbound}
P_{av}({\bf d})=O(\hat\Delta_S\hat\Delta_T/M_1({\bf s})) = o(1) \quad  \mbox{for all ${\bf d}\in Q^0_{8},\ av\in \cA$}. 
\end{equation} 
Next consider any distinct $a,b\in S$, $v\in T$  such that $av,bv\in\cA$ (i.e.~$(a,v,b)\in\oA_2$) and ${\bf d}\in Q_6^0$ with $d_a>0$ and $d_v>0$. 
Then ${\bf d}-{\ve_a}-{\ve_v} \in Q_{8}^0$ and hence $\mathcal{N}({\bf d}-{\ve_a}-{\ve_v})>0$ from above, 
and also $P_{av}({\bf d}-{\ve_a}-{\ve_v})=O(\hat\Delta_S\hat\Delta_T/s \ell) <1$ using~\eqref{Pbound}. 
Thus, for $\ell,n$ sufficiently large, $\mathcal{N}_{av}({\bf d})>0$ by \thref{trick17}, 
and we have $\mathcal{N}_{av}({\bf d})<\mathcal{N}({\bf d})$ since $P_{av}({\bf d})<1$ for similar reasons. This establishes the hypotheses for $\mathcal{N}_{av}({\bf d})$ and $\mathcal{N}({\bf d})$ in \thref{l:recurse} whenever they are needed below. 

It now follows that $Y_{avb}({\bf d})=O\left((\hat\Delta_S\hat\Delta_T/M_1({\bf s}))^2\right)$ for ${\bf d}\in Q_6^0$; 
if $d_a$ or $d_v$ is 0 then this is immediate, and otherwise it follows from~\eqn{FYdef}   in view of~\eqref{Pbound}, and noting that the numerator is non-negative by definition. 
Next, definition~\eqn{eq:bad} yields 
$\ensuremath {B}(a,b,{\bf d})=O\left((\hat\Delta_S\hat\Delta_T)^2/t M_1({\bf s})\right)$ 
for all distinct $a,b\in S$ and all ${\bf d}\in Q_{6}^0$ with $d_a>0$. 
(In the current setting 
$|\cA(a)\setminus \cA(b)|$ is 0 and $\cA(a)\cap \cA(b) = T$ for the bipartite case, 
and $\cA(a)\setminus \cA(b) =\{\mathrm{mate}{b}\}$ and $\cA(a)\cap \cA(b) = T\sm\{\mathrm{mate}{a},\mathrm{mate}{b}\}$ for the digraph case.) 
Thus~\eqref{Ratformula} gives $R_{ab}=d_a/d_b(1+O((\hat\Delta_S\hat\Delta_T)^2/t M_1({\bf s})))$ for all ${\bf d}\in Q_{5}^S$ and all distinct $a,b\in S$ such that $d_a, d_b>0$. 
Now let ${\bf d}\in Q_4^0$ and $v\in T$ with $d_v>0$. 
We want to evaluate $\sum_{b\in\cA^*(v)}d_b$ in \thref{l:recurse}(a) and 
recall that $\cA^*(v)$ is the set of vertices $b$ such that $bv\in \cA$ and $\mathcal{N}_{bv}({\bf d})>0$. 
If $d_b>0$ then $\mathcal{N}_{bv}({\bf d})>0$ as noted above. 
Therefore 
$\sum_{b\in\cA^*(v)}d_b = \sum_{b\in\cA(v)}d_b  = M_1({\bf s})- \delta^{\mathrm{di}}d_{\mathrm{mate}{v}}$ for such ${\bf d}$. Thus \thref{l:recurse} gives 
\bel{Pavsparse}
P_{av}({\bf d}) =d_ad_v/M_1({\bf s})
	\left(1+O\left((\hat\Delta_S\hat\Delta_T)^2/t M_1({\bf s})\right)\right)
\end{equation}
for all ${\bf d}\in Q_4^0$, $av\in \cA$ (if $d_a$ and $d_v$ are non-zero, the proposition applies as mentioned above, and if either is 0 then the claim holds trivially). 
Using a similar argument,~\eqn{FYdef} gives 
$$
Y_{avb}({\bf d})=\frac{d_a[d_v]_2 d_b}{M_1({\bf s})^2}\left(1+O\left(\frac{(\hat\Delta_S\hat\Delta_T)^2}{t M_1({\bf s})}\right)\right)
$$
for all ${\bf d}\in Q^0_2$, all $(a,v,b)\in \oA_2$ with $a\in S$,
and where $[x]_2$ denotes the falling factorial $x(x-1)$. 
Next, apply these results to the definition~\eqn{eq:bad} of $\ensuremath {B}$ for  ${\bf d}\in Q^0_2$ and distinct $a,b\in S$, 
and note that $\cA(a)\setminus \cA(b) = \{b'\}$ for the digraph case and is empty in the bipartite case. 
This  gives the sharper estimate 
$$\ensuremath {B}(a,b,{\bf d}) =  
		\left(\frac{d_b M_2({\bf t})}{M_1({\bf s})^2} 
		+\delta^{\mathrm{di}} \frac{d_{\mathrm{mate}{b}}}{M_1({\bf s})} 
		\right)
		\left(1+O\left(\frac{\hat\Delta_S^2\hat\Delta_T^2}{t M_1({\bf s})}\right) \right)
		+O\left(\frac{\hat\Delta_T^2 \hat\Delta_S}{M_1({\bf s})^2}\right)
$$ 
for  ${\bf d}\in Q^0_2$, which we note is $O(\hat\Delta_S\hat\Delta_T/M_1({\bf s}))$ as 
$M_2({\bf t}) \leq \hat\Delta_T M_1({\bf t})=\hat\Delta_T M_1({\bf s})$. Recalling that $t\le \hat\Delta_T({\bf d})+2$ let us write $\hat\Delta_T^2 \hat\Delta_S/M_1({\bf s})^2 =O(\hat\Delta_T^3 \hat\Delta_S/tM_1({\bf s})^2)$. 
Thus, for all ${\bf d}\in Q_1^S $ and all distinct $a,b\in S$, and noting that $M_2=M_2({\bf t})$ changes by a negligible additive term $O(\hat\Delta_T)$ under bounded perturbations of the elements of the sequence ${\bf d}$,
\bel{Req1}
R_{ab}({\bf d}) =\frac{d_a}{d_b}\frac{\big(1  -  ( d_b-1)M_2/M_1^2 - \delta^{\mathrm{di}}(d_{\mathrm{mate}{b}})/M_1 \big)}
{\big(1 -  ( d_a-1)M_2/M_1^2 -   \delta^{\mathrm{di}}(d_{\mathrm{mate}{a}})/M_1\big)}
\bigg(1+O\bigg( \frac{(\hat\Delta_S\hat\Delta_T)^3}{tM_1^2}\bigg)\bigg),
\end{equation}
by \thref{l:recurse}(b), which implies the claim since $d_a=s_a$ and $d_{\mathrm{mate}{a}}=t_{\mathrm{mate}{a}}$, and similarly for $d_b$ and $d_{\mathrm{mate}{b}}$. \end{proof}

We  next  make the definitions of probability spaces necessary to apply Lemma~\ref{l:lemmaX} (see Steps 2 and 3 in the template). 
Let $\Omega$ be the underlying set of $\mathcal{B}_m(\ell,n)$ in the bipartite case and of $\vec\mathcal{B}_m(n)$ in the digraph case. 
Let 
$$
\W=\left\{ {\bf d}\in \D^+ : \max\{ \sigma^2({\bf s})\ell,\sigma^2({\bf t})n \} \le 2m\right\}
$$ 
 in the bipartite case, and the same but with the additional restriction that 
$$
|\sigma({\bf s},{\bf t})|\le 2 s 
$$
in the digraph case. 
Let $ \mathcal{S}'=\cD(\mathcal{G}(\ell,n,m))$ in the bipartite case, and $ \mathcal{S}'=\cD(\vec \mathcal{G}(n,m))$ in the digraph case. 
We now turn to define a second probability space $\mathcal{S}$ on the underlying set $\Omega$ (see Step 3 of the template). 
Recall the definition of ${\tilde H}({\bf d})$ in~\eqn{corrH}
and let ${H}({\bf d}) 
=\pr_{\mathcal{B}_m}({\bf d}) {\tilde H}({\bf d})$, where $\mathcal{B}_m$ is $\mathcal{B}_m(\ell,n)$ in the bipartite case and $\vec\mathcal{B}_m(n)$ in the digraph case. 
Now define the probability function in $\mathcal{S}$ by 
\bel{PS}
\pr_\mathcal{S}({\bf d}) = {H}({\bf d})/\sum_{ {\bf d}'\in\W}{H}({\bf d}') = \frac{ \pr_{\mathcal{B}_m}({\bf d}) {\tilde H}({\bf d})}{{\bf E}_{\mathcal{B}_m} (\mathbbm{1}_{\W}{\tilde H})}
\end{equation}
for ${\bf d}\in \W$, and  $\pr_{\mathcal{S}}({\bf d})=0$ otherwise. 
The graph $G$ has vertex set $\W$ where two vertices are adjacent if they are either of the form ${\bf d}-{\ve_a}$, ${\bf d}-{\ve_b}$ for some $a$ and $b$ in $S$, or  ${\bf d}-{\ve_v}$, ${\bf d}-{\ve_w}$ for some $v$ and $w$ in $T$.  


We need to estimate the probability of $\W$ in the two probability spaces $\mathcal{S}$ and $\mathcal{S}'$ 
(see Step 4 in the template). For convenience, we simultaneously make a similar estimate of   $\pr_{\mathcal{B}_m}(\W)$ for use outside the present proof. Note that $\pr_{\mathcal{S}}(\W)=1$ by definition. We combine estimating $\pr_{\mathcal{S}'}(\W)$ and estimating the expressions ${\tilde H} ({\bf d})$ and ${\bf E}_{\mathcal{B}_m} (\mathbbm{1}_{\W}{\tilde H})$ in \eqn{PS} for later use. In the following, let ${\bf d}$ be in either of $\mathcal{S}'$ or $\mathcal{B}_m$. 
We first claim that ${\bf d}\in \D^+$ with high probability. 
Clearly, $M_1({\bf s})=M_1({\bf t})$ for all such ${\bf d}$ since this is true for any bipartite graph (or digraph) with sequence $({\bf s},{\bf t})$ by the definition of $\mathcal{B}_m$. 
Letting  $\Delta_S^*=\Delta_S({\bf d}^*)$ and $\Delta_T^*=\Delta_T({\bf d}^*)$, we have by definition $\hat\Delta_S\ge \Delta_S^*+\ell^{\varepsilon/12}\sqrt {\Delta_S^*}\ge s+\ell^{\varepsilon/12}\sqrt {\Delta_S^*}$ and similarly $\hat\Delta_T\ge t+n^{\varepsilon/12}\sqrt {\Delta_T^*}$. 
Thus, for   ${\bf d}\in  \Omega$, in either $\mathcal{S}'$ or $\mathcal{B}_m$,
\begin{align}\lab{aux885}
\pr (s_a > \hat\Delta_S)&\le \pr\big(s_a>s+ \ell^{\varepsilon/12 }\sqrt {\Delta_S^*}\big) 
=o(\ell^{- \omega}), \text{ and}\\
\pr(t_v > \hat\Delta_T)&\le  \pr\big(t_v>t+ n^{\varepsilon/12 }\sqrt {\Delta_T^*}\big) 
=o(n^{- \omega})
\end{align} 
by \thref{l:sigmaConcBip}(i) and noting that $\Delta_S^*,\Delta_T^*\to\infty$. The union bound now gives that, with probability $1- o(n^{- \omega}+\ell^{- \omega})$, $\Delta_S({\bf d})\le\hat\Delta_S$  and $\Delta_T({\bf d})\le\hat\Delta_T$ and hence ${\bf d}\in \D^+$, in both $\mathcal{S}'$ and $\mathcal{B}_m$. 
We next argue that the $\sigma$-terms are concentrated for ${\bf d}$ chosen in $\mathcal{S}'$ or $\mathcal{B}_m$. Let $\alpha = \max\{\log^4\ell/\sqrt{\ell},\log^4n/\sqrt{n}\}$ and note that the conditions  $\log^3n+\log^3\ell=o(m)$, $(\log n)/\sqrt{n}+(\log^{3/2}n)/\sqrt{m}=o(\alpha)$,  and $(\log \ell)/\sqrt{\ell}+(\log^{3/2}\ell)/\sqrt{m}=o(\alpha)$ in \thref{l:sigmaConcBip}(ii) follow from $n/\log^4n + \ell/\log^4\ell=o(m).$ 
Recalling that $\mu=m/n(\ell-\delta^{\mathrm{di}})$ we thus deduce that $\sigma^2({\bf t}) = t (1-\mu) \big(1+O(\alpha)\big)$ with probability $1-o(n^{-\omega})$, that $\sigma^2({\bf s})=s (1-\mu) \big(1+O(\alpha)\big)$ with probability $1-o(\ell^{-\omega})$, and, in the digraph case, $\sigma({\bf s},{\bf t})=O(\mu+s\alpha)$ with probability $1-o(n^{-\omega})$, by \thref{l:sigmaConcBip}(ii).   
This already implies that $\Pr_{\mathcal{S}'}(\W) =  1-o(n^{-\omega}+ \ell^{- \omega})$, in preparation for applying  Lemma~\ref{l:lemmaX}, and similarly $\Pr_{B_m}(\W) =  1-o(n^{-\omega})$. 

Now note that if $\sigma^2({\bf t})= t (1-\mu)\big(1+O(\alpha)\big)$, 
then the term  $\sigma^2({\bf t})/t(1-\mu)$ in the exponent of ${\tilde H}({\bf d})$ 
is $1+O(\alpha)$. Similarly for the term  $\sigma^2({\bf s})/s(1-\mu)$. 
Furthermore, the term $\sigma({\bf s},{\bf t})/s(1-\mu)$ in the digraph case  is $O(\alpha)$. 
It follows using the strong concentration shown in the previous paragraph that 
\bel{HConc}
{\tilde H}({\bf d})=1+O(\alpha) \text{ with probability } 1-\bar n^{-\omega} \text{ for ${\bf d} \in \mathcal{B}_m$}, 
\end{equation} 
where $\bar n=\min\{n,\ell\}$. 
Recall that $\sigma^2({\bf s})\le 2s$, $\sigma^2({\bf t})\le 2t$ and, in the digraph case, $|\sigma({\bf s},{\bf t})|\le 2s$ for all ${\bf d}\in \W$. Thus, ${\tilde H}({\bf d})=\Theta(1)$ for ${\bf d}\in\W$,  using the fact that $\mu < 1/2$, say. 
This and \eqn{HConc} then imply that ${\bf E}_{\mathcal{B}_m} (\mathbbm{1}_{\W}{\tilde H}) = 1+O(\alpha)$. 

To apply \thref{l:lemmaX} (see Step 5 in Section~\ref{s:template}), the final condition we need to show is that the ratios of probabilities satisfy 
\bel{eq:target1}
\frac{\Pr_{\mathcal{S}'}({\bf d}-{\ve_a})}{\Pr_{\mathcal{S}'}({\bf d}-{\ve_b})} =e^{O(\delta)}\frac{\Pr_{\mathcal{S}}({\bf d}-{\ve_a})}{\Pr_{\mathcal{S}}({\bf d}-{\ve_b})}
\end{equation}
whenever ${\bf d}-{\ve_a}$ and ${\bf d}-{\ve_b}$ are elements of $\W$ that are adjacent in the auxiliary graph $G$ defined above, for $\delta=\delta(\hat\Delta_S,\hat\Delta_T)$ independent of ${\bf d}$ which we specify below, where  the constant implicit in $O()$ is independent of ${\bf d}$ and ${\bf d}^*$. 
Compare the ratio formula 
\begin{align}\label{eq:ratioSparse}
\frac{\Pr_{\mathcal{S}}({\bf d}-{\ve_a})}{\Pr_{\mathcal{S}}({\bf d}-{\ve_b})} 
= \frac{{H}({\bf d}-{\ve_a})}{{H}({\bf d}-{\ve_b})}
\end{align}
in~\eqref{H} with the expression in \thref{RSparseBiAndDi} 
when $a$ and $b$ are in $S$. Then use the identity $n\sigma^2({\bf t})=M_2-(t-1)M_1$ and recall that $M_1=\mu'n\ell$   in~\eqref{H} to deduce that 
 \bel{ratios2}
 R_{ab}({\bf d}) = \frac{{H}({\bf s}-{\ve_a},  {\bf t})}{{H}({\bf s}-{\ve_b}, {\bf t})} \bigg(1+O\bigg( \frac{\hat\Delta_S^3\hat\Delta_T^3}{t ^3 n^2}  \bigg)\bigg) 
\end{equation}
whenever $a,b \in S$ and 
${\bf d}\in Q_1^S$, 
where we use   
$(n+\delta^{\mathrm{di}}-s_b)/(n+\delta^{\mathrm{di}}-s_a)=\exp\big((s_a-s_b)/n+O(\Delta_S^2/n^2)\big)$,  $1/(1-\mu)=1+O(\mu)$, 
$M_2({\bf t})=O(\Delta_T M_1)$ 
and $(\Delta_S\Delta_T)^2/M_1^2\le (\Delta_S\Delta_T)^3/tm^2$, $\Delta_S\le \hat\Delta_S$, $\Delta_T\le \hat\Delta_T$, and the most significant error term derives from \thref{RSparseBiAndDi}. 
The corresponding statements when $a,b \in T$ follow accordingly (after swapping 
$S\leftrightarrow T$, $s\leftrightarrow t$ and $\ell \leftrightarrow n$ in the conclusion of the argument). 
Equation~\eqn{ratios2} now implies that  
$$
\frac{  \pr_{\mathcal{S}'}({\bf d}-{\ve_a})}{ \pr_{\mathcal{S}'}({\bf d}-{\ve_b}) } = R_{ab}({\bf d}) = e^{O(\delta)}\frac{  \pr_{\mathcal{S}}({\bf d}-{\ve_a})}{ \pr_{\mathcal{S}}({\bf d}-{\ve_b})}
$$
whenever ${\bf d}-{\ve_a}$ and ${\bf d}-{\ve_b}$ are adjacent elements of $\W$, 
where we may take 
$ \delta= (\hat\Delta_S\hat\Delta_T)^3(1/t m^2 + 1/s m^2)$ which 
is the error term in~\eqn{ratios2} together with the symmetric error after the swap. 
It is clear that the diameter $r$ of $G$ is at most $M_1 ({\bf s}) +M_1({\bf t})= 2m$.
Lemma~\ref{l:lemmaX}  then   implies  that $P_{\mathcal{S}'}({\bf d})=e^{O( r\delta+\varepsilon_0)}P_{\mathcal{S}}({\bf d})$ for ${\bf d}\in \W$, where $\varepsilon_0 = 1/n+1/\ell$. 
To proceed from here,  since we found that ${\bf E}_{\mathcal{B}_m} (\mathbbm{1}_{\W}{\tilde H}) = 1+O(\alpha)$, equation~\eqn{PS} implies $P_{\mathcal{S}}({\bf d}) = {H}({\bf d})(1+O(\alpha))$ for ${\bf d}\in \W$. Hence, 
\bel{generalError}
P_{\mathcal{S}'}({\bf d}^*)=e^{O(r\delta+\varepsilon_0+\alpha)}  {H}({\bf d}^*). 
\end{equation}
Note that $\alpha=O(n^{\varepsilon-1/2}+\ell^{\varepsilon-1/2})$, and  
$$r\delta+\varepsilon_0=  O\left((\hat\Delta_S\hat\Delta_T)^3\left(\frac{1}{tm}+\frac{1}{sm}\right)\right)
	=  O\left( \Delta_S({\bf d}^*)^3\Delta_T({\bf d}^*)^3 (\ell n)^{\varepsilon/2}\left(\frac{1}{tm}+\frac{1}{sm}\right)\right).$$
The theorem for ${\bf d}\in \W$ follows since $\mathcal{S}'$ is $\cD(\mathcal{G}(\ell,n,m))$ or $\cD(\vec\mathcal{G}(n,m))$, respectively, and by definition of ${H}$. 
On the other hand, to treat the elements of $\D^+\setminus \W$, where some $\sigma$-term may be unbounded, we still have~\eqn{ratios2} holding for all  ${\bf d}\in Q_1^S$.  
For any  ${\bf d}\in \D^+$, there is  a telescoping product of such ratios starting with ${\bf d}'\in \W$, of length at most $2m$, which shows that $\pr_{\mathcal{S}}({\bf d})/{H}({\bf d})=  \pr_{\mathcal{S}}({\bf d}')/{H}({\bf d}')(1+O(m\delta))$.   From this,  the required formula for  $\pr_{\mathcal{S}}({\bf d})$ follows for all ${\bf d}\in\D$, in both the bipartite graph and digraph cases. 
\end{proof}

 
\section{Proof of \thref{t:mainbip,t:bipmodel,t:edgeprobability}} \lab{s:denseBip}


\def\epsV{\varepsilon} 
\def\epsA{\varepsilon}  
\def\sigma_S{\sigma_S}
\def\sigma_T{\sigma_T}
 
In this section we prove Theorem~\ref{t:mainbip}. 
Following the template in Subsection~\ref{s:template} we first consider the ratio of probabilities of ``adjacent'' degree sequences. 

To estimate those ratios we first present functions that approximate the ratios and the probabilities. We  write these approximations parameterised to facilitate identifying negligible terms. 
We express the formulae for the approximations of $P$, $Y$ and $R$ in both the bipartite graph case and the digraph case simultaneously, again using $\delta^{\mathrm{di}}$ as the indicator variable which is 1 in the digraph case and 0 in the bipartite case. 
For integers $\ell$ and $n$, and a sequence of real numbers $\mu$, $\epsA_a$, etc.,
we define the expressions   
\remove{\ac{There was a discussion here to change to a different parametrisation, using $\mu/t^2$ instead of $1/t\ell$. In the end I decided against it. There are two reasons: For once, this introduces a slight error for the digraphs, and we'd have to argue once again that this is negligible. Second, in the old version the $\sigma_T^2$ term always comes with a factor $1/t \ell$. So in maple, we use a variable $sV$ that stands for $\sigma_T^2/t\ell$. This is important, as $\sigma$ by itself doesn't necessarily go to 0. With this extra factor, saying that the square of this term is negligible is much easier. I hope you don't mind. I thought about for a while when tackling the maple. \\
I DID change: $1/n-1$ to $\mu/s$ in both $\pi$ and $\rho$. This way, the only place where $n$ and $\ell$ appear is together with the $\sigma^2$ terms. That's less to worry about in the worksheet. }}
\begin{eqnarray*}
\pi & = &\mu (1+\epsA_a)(1+\epsV_v)
		\left(1 - \frac{\mu\epsA_a\epsV_v- \epsA_a \sigma_T^2/t \ell  -\epsV_v \sigma_S^2  /s n}{1-\mu}
		+ \frac{\delta^{\mathrm{di}}(\epsV_{a'}+\epsA_{v'})\mu}{s}\right),\\
\rho  
	& = &\frac{1+\epsA_a}{1+\epsA_b}\cdot\frac{1-  \mu(1 + \epsA_b)+\mu/s}
	{1- \mu(1+ \epsA_a)+ \mu/s} \\
	&& \times \left(1 
	+\frac{\epsA_a-\epsA_b}
	{(1-\mu)}\left(\frac{\sigma_T^2 }{(1-\mu)t\ell} 
	- \frac{1}{\ell}
	\right)
	+\frac{\delta^{\mathrm{di}}(\epsV_{a'}-\epsV_{b'})\mu}{s(1-\mu)}
	\right).
\end{eqnarray*}


In the calculations below, there are small changes in most of the variables that turn out to have a negligible effect. Changes in the various occurrences of $\varepsilon$-type terms, however, need to be tracked precisely. In particular, we use 
\begin{itemize}
\item 
$\pi(x,y)$ to stand for $\pi$ with  $\epsA_a,\epsV_v$ replaced by $x,y$, 
\item
$\pi(x,y,z,w)$ to stand for $\pi$ with  $\epsA_a,\epsV_v,\epsV_{a'},\epsA_{v'}$ replaced by $x,y,z,w$,
\item 
$\rho(x,y,z,w)$ to stand for $\rho$ with  $\epsA_a,\epsA_b,\epsV_{a'},\epsV_{b'}$ replaced by $x,y,z,w$. 
\end{itemize} 
Recall that we consider  sequences ${\bf d} = ({\bf s},{\bf t})$, where ${\bf s}$ and ${\bf t}$ have length $\ell$ and $n$, respectively, and where $\ell = n$ in the digraph case. 
Also $\mu =  \frac12 M_1({\bf d}) /  |\cA|$, where $|\cA|=(1-\delta^{\mathrm{di}})n\ell+\delta^{\mathrm{di}}n(n-1)$, 
$s=(\sum_{a\in S}s_a)/\ell$ and $t=(\sum_{v\in T}t_v)/n$. 
Noting that $S\cap T=\emptyset$, we set $\varepsilon_a=(s_a-s)/s$ for $a\in S$, $\varepsilon_v=(t_v-t)/t$ for $v\in T$,  
$\sigma_S^2 = \sigma^2({\bf s})$, and $\sigma_T^2=\sigma^2({\bf t})$.
Then with $*$ standing  for either of $\mathrm{bi}$ or $\mathrm{di}$, we define
$$
P^*=\pi, \quad R^* = \rho,$$ 
$$
Y^*= \pi\cdot \pi(\epsA_b, \epsV_v-1/t, \epsV_{b'},\epsA_{v'})\cdot
\left( 
1+\frac{\mu(1 + \epsA_a)-  \mu^2(1+\epsA_a+\epsA_b)  }{t(1-\mu)}
 \right) ,
$$
so that $P_{av}^{\mathrm{bi}}$ etc.\ are functions of degree sequences. 
For example, the  edge probability function for bipartite graphs with ``classical'' parameters $d_a$ etc is given by 
\begin{eqnarray*} 
P_{av}^{\mathrm{bi}} & = &  \frac{d_ad_v}{m} \left(
	1-\frac{n\ell(d_a-s)(d_v-t)}{m(n\ell-m)}-\frac{(d_a-s)\sigma^2({\bf t})n}{ts(n\ell-m)}
	-\frac{(d_v-t)\sigma^2({\bf s})\ell}{ts(n\ell-m)}\right)
\end{eqnarray*} 
for $a\in S$, $v\in T$. 
One can compute similar expressions for $P_{av}^{\mathrm{di}}$,  the ratio functions $R_{ab}^{\mathrm{bi}}$ and $R_{ab}^{\mathrm{di}}$, and the 2-path probabilities $Y_{avb}^{\mathrm{bi}}$ and $Y_{avb}^{\mathrm{di}}$. 
 In particular, we remark that $R^*_{ab}({\bf d})$ written with ``classical'' parameters is just the expression in~\eqref{H}.
The functions $P^*$,  $Y^*$ and $R^*$ are our ``guessed'' probability and ratio functions and we will show that they approximate the actual  functions sufficiently well. 
The following implies that they are close to fixed points of the operators defined in~(\ref{F1def}--\ref{F2def}). 
 
\begin{lemma}\thlab{l:mapleHigher}
Let $n, \ell$ be integers and let $1/2\le \varphi < 3/5$. 
Let   
$\cA$ be as in either the bipartite or the digraph case,  
let ${\bf d}=({\bf s},{\bf t})$ be a sequence of length $\ell+n$, 
 let $\mu=M_1({\bf d})/2|\cA|$, and assume that $\mu<1/4$. 
Furthermore, let $s$ and $t$ be the average of ${\bf s}$ and ${\bf t}$, respectively, and  $\varepsilon= \bar d^{\varphi-1}$, where $\bar d = \min\{ s, t\}$, 
and assume that 
	$\max_{a\in S} |s_a - s|/s \leq \varepsilon$, 
	$\max_{v\in T} |t_v - t|/t \leq \varepsilon$. 
Let $*$ stand  for either of $\mathrm{bi}$ or $\mathrm{di}$.   
Then 
\begin{itemize}
\item[(a)] ${\cal R}(P^*,Y^*) _{ab}( {\bf d})=  R^*_{ab} ( {\bf d})
 \left(1 + O\left(\mu\varepsilon^4\right)\right)$ for all $a,b\in S$, 
\item[(b)] 
${\cal P}(P^*,R^*)_{av}({\bf d}) =  P^*_{av}({\bf d})
 \left(1 + O(\mu\varepsilon^4)\right)$  for all $a\in S$, 
 $av\in \cA $
\item[(c)] 
${\cal Y}(P^*,Y^*)_{avb}({\bf d}) =  Y^*_{avb}({\bf d})
 \left(1 + O(\mu\varepsilon^4)\right)$  for all distinct $a,b\in S$, 
 $v\in T $, $av,vb\in\cA$.
\end{itemize}
\end{lemma}

 
\begin{proof} 
This follows the proof of~\cite[Lemma 7.1]{lw2018} very closely, with modifications due to the bipartite setting.

We first present some convenient approximations of $P^*$ and $\pi$ for use when their parameters have been slightly altered. Let ${\bf d}'=({\bf s}',{\bf t}')$ be a sequence  where ${\bf s}'$ and ${\bf t}'$ are of length $\ell$ and $n$, respectively, such that ${\bf d}'$  is at $L_1$ distance $O(1)$ from ${\bf d}$, and with $d_a'=d_a-j_a$ and $d_v'=d_v-j_v$ for some $a\in S$, $v\in T$. 
Here and in the following, the bare symbols $\mu$,  $\epsA_a$ and so on are defined with respect to the original sequence ${\bf d}$, whilst $\mu'$,  $\epsA_a'$, etc., are defined with respect to ${\bf d}'$. For such a sequence ${\bf d}'$ we have that $\mu({\bf d}')$ is $\mu'= \mu +O(1/ n\ell)$ by definition of $\mu({\bf d}')$.    
Therefore, the variables $\epsA_a$ and $\epsV_v$ change to 
 $\epsA_a'=\epsA_a-j_a/s+O(1/\mu n\ell)$ and $\epsV_v'=\epsV_v-j_v/t+O(1/\mu n\ell)$. (Note that this takes into account that 
$\epsA_a'$ and $\epsV_v'$   are defined with respect to 
$s({\bf d}')$ and $t({\bf d}')$.) 
Furthermore, 
$$\sigma^2 ({\bf s}')-\sigma^2 ({\bf s})=O(( \max_{c\in S} |s_c-s| +1 )/ n )=O(\varepsilon s/n),$$ 
and similarly, for $\sigma^2 ({\bf t}')$. Hence, by definition of $P^*=\pi$ and the preceding considerations,
\bel{piwithprime2}
P^*_{av}({{\bf d}'})
=\pi( \epsA_a-j_a/s,\epsV_v-j_v/t)\big(1+O( 1/\mu n\ell)\big),
\end{equation}
That is, the changes from $\mu$, $s$, $t$, $\sigma_S^2$ and $\sigma_T^2$ to 
$\mu'$, $s'$, $t'$, $(\sigma_S^2)'$ and $(\sigma_T^2)'$ are negligible in the formula for $P^*$. 


For (a), we note first that ${\cal R}( {P^*},{Y^*})_{aa}({\bf d}) = 1 = R^*_{aa}({\bf d})$ by definition of $\rho$ and ${\cal R}$ in~\eqref{F2def}. Assume now that $a\neq b$. Using~\eqn{F2def} to evaluate ${\cal R}( {P^*},{Y^*})_{ab}({\bf d})$, we estimate the expression 
$\ensuremath {{\bf bad}}(a,b,{\bf d}-{\ve_b})=\ensuremath {{\bf bad}}({P^*},{Y^*})(a,b,{\bf d}-{\ve_b})$ for which, in turn, we need to estimate 
$\sum Y^*_{avb}({\bf d}-{\ve_b})$, where the sum is over all $v\in T$  such that both $av$ and $bv$ are allowable (see \eqref{def:bad}). 
By definition and~\eqref{piwithprime2}, 
$$
Y^*_{avb}({\bf d}-{\ve_b}) = \pi \cdot  \pi(\epsA_{b}- 1/s,\, \epsV_{v}- 1/t)
	\cdot\left(1+\frac{\mu(1+\epsA_a) - \mu^2(1+\epsA_a+\epsA_b)}{t(1-\mu )} +O( 1/\mu n\ell) \right),
	$$
where we use $\epsA_a$, $\epsA_b$ and $\mu $ in the third factor (rather than the altered versions $\epsA_a'$ etc.)~using the same reasoning as for obtaining~\eqref{piwithprime2}.
Consider expanding this expression for $Y^*_{avb}({\bf d}-{\ve_b})$ ignoring terms of  order  $\varepsilon^4$, and hence also ignoring those of order $s^{-2}$, $t^{-2}$, $\varepsilon^2/t$, and $\varepsilon^2/s$ since $\varepsilon^2\ge 1/\bar d =\max\{1/t,1/s\}$. 
A convenient way to do this is to make substitutions $\epsA_v=y_1\epsA_v$,   $1/t  = y_1^2/t $,  
$\mu  = y_2 \mu$, $1/n =y_1^2y_2/n$,   
and so on where $y_1$ represents a parameter of size $O(\varepsilon)$ and $y_2$ one of size $O(\mu)$ (for instance, $\sigma_T^2/t\ell$ is $O(\varepsilon^2\mu)$), and then expand about  $y_1=0$ and drop terms of order $y_1^4$.
Since $Y^*_{avb}({\bf d}-{\ve_b})$ gains a factor  $y_2^2$ via the factors of $\mu$ in $\pi$,  each term containing $y_1^i$ is of order  $y_1^iy_2^2$ and is hence $O(\mu^2\varepsilon^i)$. 
Next, removing the `sizing' variables $y_i$   by setting them equal to 1, and then  expanding the result  about  $(\epsA_{v'},\epsV_v) =(0,0)$  and retaining all terms of total degree at most 3 in $ \epsA_{v'}$ and $ \epsV_v$, we get
 \begin{align*}
Y^*_{avb}({\bf d}-{\ve_b})
&= c_{0} 
		+ c_{10}\epsV_{v}
		+ c_{01}\epsA_{v'}
		+ c_{20}\epsV_{v}^2
 		+O(\mu^2\varepsilon^4),
\end{align*}
where the functions  $c_{0}$, $c_{10}$, $c_{01}$, and $c_{20}$   
are independent of $\epsV_v$ and $\epsA_{v'}$, with $c_0$, $c_{10}$ and $c_{01}$ linear in $1/s$ and $  1/t$, and $c_{20}$ constant in those variables. (By calculation, the third order terms all turn out to be absorbed by the error term.  Furthermore, the relative error $1/\mu \ell n$ in the previous expression for $Y^*$ yields an absolute error $O(\mu/\ell n)=O(\mu^2\varepsilon^4)$ since~$Y^*$ is~$O(\mu^2)$.)  We note that $c_{01}$ has a factor $\delta^{\mathrm{di}}$ since $\epsA_{v'}$ in $\pi$ has such a factor. 
  
Then considering the definition of $\ensuremath {{\bf bad}}(a,b,{\bf d}-{\ve_b})$ in~\eqn{def:bad} we find that the second summation can be written as 
\begin{align*}
\Sigma _{\ensuremath {{\bf bad}}} 
&= \sum_{v\in \cA(a)\cap \cA(b)}Y^*_{avb}({\bf d}-{\ve_b})\\
&= \sum_{v\in \cA(a)\cap \cA(b)}
		(c_{0} 
		+ c_{10}\epsV_{v}
		+ c_{01}\epsA_{v'}
		+ c_{20}\epsV_{v}^2
		+ O(\mu^2\varepsilon^4)) \\
&= n c_0 +  nc_{20}\sigma_T^2/t^2\\
	%
&\qquad
	+\delta^{\mathrm{di}}
	\left(
	-2c_0 - c_{10}(\epsV_{a'}+\epsV_{b'})
	- c_{01}(\epsA_a+\epsA_b)
	-c_{20}(\epsV_{a'}^2+\epsV_{b'}^2)
	\right) +O(n \mu^2\varepsilon^4),  
\end{align*}
since $a$ and $b$ are distinct elements of $S$ (in which case $\cA(a)\cap\cA(b)$ is $T$ in the bipartite case and is $T\sm\{a',b'\}$ in the digraph case),
and where we also use that $\sum_{v\in T}\epsV_v =0$ and that, in the digraph case, $\sum_{v\in T}\epsA_{v'} = \sum_{a\in S}\epsA_a =0$.  
Noting that   $\cA(a)\setminus \cA(b)$  is $\emptyset$ in the bipartite case 
and consists of just $\mathrm{mate}{b}$ in $T$ in the digraph case,  
we can write $\ensuremath {{\bf bad}}(a,b,{\bf d}-{\ve_b})$ in~\eqn{F2def}, by using~\eqn{def:bad}, as 
\begin{align*}
\ensuremath {{\bf bad}}(a,b,{\bf d}-{\ve_b}) &= \frac{1}{d_a} 
	\left(\Sigma_{\ensuremath {{\bf bad}}}
	+\delta^{\mathrm{di}} \pi(\epsA_a,\epsV_{b'},\epsV_{a'},\epsA_b-1/t) +O(1/ \ell n) 
\right), 
\end{align*}
where $d_a =s_a = (1+\epsA_a)s$,  and  the $O(1/n\ell)$ term captures the fact that we use $\mu=\mu({\bf d})$, $\sigma^2({\bf s})$, and $\sigma^2({\bf t})$, respectively, instead of $\mu({\bf d}')$, $\sigma^2({\bf s}')$, and $\sigma^2({\bf t}')$, in the formula for $\pi$ applied to an altered sequence ${\bf d}'$.  
The error term $O(1/\ell n)$ here, together with the one from $\Sigma_{\ensuremath {{\bf bad}}}$ above, produce an additive error in $\ensuremath {{\bf bad}}(a,b,{\bf d}-{\ve_b}) $ of $O(\mu\varepsilon^4)$ since $n/d_a=n/s_a\sim 1/\mu$ and $1/\ell n<\mu\varepsilon^4$.
Substituting the above expression, stripped of its error  terms, into
\begin{align*}
 \frac{{\cal R} (P^*,Y^*)_{ab} ({\bf d})}{\rho} -1
 &= \frac{1}{\rho}\cdot \frac{(1+\epsA_a)(1-\ensuremath {{\bf bad}}(a,b,{\bf d}-{\ve_b}))}{(1+\epsA_b)(1-\ensuremath {{\bf bad}}(b,a,{\bf d}-{\ve_a}))}  -1
\end{align*}
and simplifying gives a rational function $\widehat F$ which satisfies ${\cal R}(P^*,Y^*)_{ab}({\bf d})/\rho  = 1+ \widehat F + O(\mu\varepsilon^4)$.  After inserting the  size variables $y_1$ and $y_2$  into $\widehat F$ as specified above (and here it may be convenient to use $n=\delta^{\mathrm{di}}+s/\mu$), and simplifying, we find that $\widehat F$ has $y_2$ as a factor (of multiplicity 1), and its denominator is nonzero at $y_1=0$.  Then expanding the expression in powers of $y_1$ shows that  $\widehat F=O( y_1^4)$. Along with the extra factor $y_2$, this implies $\widehat F=O(\mu\varepsilon^4)$. Part (a) follows. 

To prove part (b) let $av\in\cA$ with $a\in S$ and let ${\bf d}'$ be the sequence ${\bf d} -{\ve_v}$. 
Note that, analogous to~\eqn{piwithprime2}, 
the differences in the values of $\mu$, $s$, $t$ in $\rho$ between ${\bf d}$ and ${\bf d}'$ are negligible, as are the differences in $\epsA_a$ and $\epsA_b$ 
for $b\in \cA(v) = S\sm\{v'\}$ (note that with these assumptions $v$ is never equal to $a, a', b$ or $b'$; so the values of $\epsA_a$, $\epsA_b$, $\epsA_{a'}$, $\epsA_{b'}$ only change since $s$ changes).  Hence, we also have  
$$ R^*_{ab}({\bf d}')  
=\rho\cdot \left(1 +O\left( 1/ \mu  n\ell  \right)\right)$$
for $a,b\in S$, $v\in \cA(a)\cap \cA(b)$.
Therefore, by definition \eqref{F1def},  
\begin{align}\lab{aux1552}
{\cal P}( P^*, R^* )_{av}({\bf d})  
	&= d_{v} \left(\sum_{b\in  \cA(v)}
		R^*_{ba} ({\bf d}-{\ve_v})
		\frac{1- P^*_{bv}({\bf d}  - {\ve_b} - {\ve_v})}
		{1-P^*_{av}( {\bf d} -{\ve_a} - {\ve_v})}\right)^{-1}\nonumber\\
	&= d_{v} \left(\sum_{b\in \cA(v)} 
		\rho (\epsA_b,\epsA_a,\epsV_{b'},\epsV_{a'} ) \cdot 
		\frac{1-\pi\left(\epsA_b- 1/s ,\epsV_v- 1/t ,\epsV_{b'},\epsA_{v'}\right)}
		{1-\pi\left(\epsA_a- 1/s,\epsV_v- 1/t ,\epsV_{a'},\epsA_{v'}\right)}
		\left(1 +O\left(\frac{1}{ \mu  n\ell }\right)\right)\right)^{-1}. 
\end{align}
By expanding in powers of $\epsA_b$ and $\epsV_{b'}$ 
we obtain 
\begin{align*}
\rho(\epsA_b,\epsA_a,\epsV_{b'},\epsV_{a'}) 
\cdot \frac{1-\pi(\epsA_b- 1/s ,\epsV_v- 1/t ,\epsV_{b'},\epsA_{v'})}
			{1-\pi(\epsA_a- 1/s ,\epsV_v- 1/t ,\epsV_{a'},\epsA_{v'})} 
			& = K + O(\varepsilon^4) 
\end{align*} 			
where $K$ is a polynomial in $\epsA_b$ and $\epsV_{b'}$ of total degree at most 3 in $\{\epsA_b,\epsV_{b'}\}$.  
Calculations using the  size variables $y_1$ and $y_2$  as above show  that $K = k_{00} + k_{10} \epsA_b + k_{01} \epsV_{b'}  +  k_{20} {\epsA_b}^2 + O(\varepsilon^4)$  for some $k_{ij}$ 
(and in particular, the  coefficients $k_{11}$ and $k_{02}$, and those for terms of third order, are all absorbed by the error terms). 
We also note from the definition of $\pi$ and $\rho$ that $k_{01}$ has $\delta^{\mathrm{di}}$ as a factor. 
Also, for $v\in T$ we have $\cA(v) = S$ in the bipartite case and $\cA(v) = S\sm\{\mathrm{mate}{v}\}$ in the digraph cases. Then the main summation over~$b$  in~\eqn{aux1552}  can be evaluated as 
\begin{align*}
\ell\cdot k_{00} +  \ell \sigma_S^2 k_{20}/s^2
	+\delta^{\mathrm{di}} \left( - k_{00} - k_{10}\epsA_{v'} -  k_{01}\epsV_v - k_{20} {\epsA_{v'}}^2\right),  
\end{align*}
with relative error $O(\varepsilon^4)$, noting  
that $K$ has constant order, 
where we use that $\sum_{b\in S} \epsA_b = 0$ and that $\sum_{b\in S} {\epsA_b}^2 = \ell \sigma_S^2/{s}^2$.  
Using the size variables $y_1$ and $y_2$ as described above, we then find  that  ${\cal P}(P^*,R^*)_{av}({\bf d}) = \pi (1+O(\mu\varepsilon^4))$, with the extra factor $\mu$ arising in the error term in the same way as for ${\cal R}$ in part (a). Part (b) follows. 

Part (c) is more straightforward than the first two parts and is easily verified by similar considerations, so we omit details.
\end{proof}

\begin{proof}[Proof of \thref{t:mainbip}]
Let $\mu_0$, $\varphi$, $\ell$, $n$, $m$, $\D$ be as in the theorem statement. Note that all sequences ${\bf d}$ in $\D$ have the same values 
$\mu = \mu({\bf d})=m/n(\ell-\delta^{\mathrm{di}})$, $s = s({\bf d}) = m/\ell$ and $t = t({\bf d}) = m/n$. All other sequences ${\bf d}'$ in this proof will be close enough to $\D$ (in Hamming distance)  that $\mu':=\mu({\bf d}') \sim \mu$. 
Let $\varepsilon= \max\{s^{\varphi-1},t^{\varphi-1}\}$ and note that 
$\varepsilon\geq \max\{1/\sqrt{s}, 1/\sqrt{t}\}$ by the lower bound on $\varphi$. 
	
We follow the template from Subsection~\ref{s:template},   first considering the ratios $R_{ab}$ for $a,b\in S$. 
Recall that $P$, $Y$ and $R$ denote the {\em actual} edge probability, path probability and ratio functions (c.f.~\eqref{realRatio} and \eqref{realProb}) and that $P^*$, $Y^*$ and $R^*$ are functions of degree sequences with closed form given at the beginning of this section. 
Recall that $P$, $Y$ and $R$ are always defined with respect to some underlying set $\cA$ which is either $\cA^{\mathrm{bi}}$ or $\cA^{\mathrm{di}}$ here. 
The next claim states that the functions $P^*$ and $R^*$ approximate $P$ and $R$ sufficiently well.  An analogous statement  for $Y^*$ and $Y$ appears in the proof of the claim but is not needed elsewhere.  
It is easy to see inductively that we only require $R_{ab}({\bf d})$ when $a$ and $b$ are in the same set of the bipartition. 
Let $Q_1^{S}$ denote the set of sequences ${\bf d}=({\bf s},{\bf t})\in \Z^{\ell+n}$ such that ${\bf d}-{\ve_a}\in \D$ for some $a\in S$; and let $Q_1^{T}$ denote the set of sequences ${\bf d}=({\bf s},{\bf t})\in \Z^{\ell+n}$ such that ${\bf d}-{\ve_v}\in \D$ for some $v\in T$. 

\begin{claim}\thlab{RDenseBip}
Let $*$ be either $\mathrm{bi}$ or $\mathrm{di}$. 
For ${\bf d}\in \D$, $av\in\cA$, 
\begin{equation}\lab{appP}
P_{av}({\bf d}) = P_{av}^*({\bf d}) (1+O(\mu\varepsilon^4)),
\end{equation}
and uniformly for all ${\bf d}\in Q_1^S$ and all $a,b\in S$ 
\begin{equation}\lab{appR}
R_{ab}({\bf d}) = R_{ab}^*({\bf d}) (1+O(\mu\varepsilon^4)).
\end{equation}
\end{claim}
By symmetry, \eqref{appR} also holds for all ${\bf d}\in Q_1^T$ and all distinct $a,b\in T$. 
 The proof is very similar to the proof of Claim~6.4 in~\cite{lw2018} with some adaptations to the bipartite setting.   We include a full proof for the sake of completeness. 

\begin{proof}[Proof of the claim.]
To show that $P$ and $P^*$ (and $R$ and $R^*$) are $(\mu\varepsilon^4)$-close  in the sense of~\eqref{appP} and~\eqref{appR}, we define the compositional operator  
$${\cal C}({\bf p},{\bf y})= \big(\hat{\bf p}, {\cal Y}(\hat{\bf p}, {\bf y})\big),\ \mbox{where\, $\hat{\bf p} = {\cal P}({\bf p},{\cal R}({\bf p},{\bf y}))$}.$$
  We first observe that ${\cal C}$ fixes $(P,Y)$,  where in this context  we regard $P$ to be the function ${\bf p}$ with ${\bf p}_{ av}=P_{av} $ for all $av\in \cA$, and similarly $Y$ to be ${\bf y}$ with ${\bf y}_{avb}= Y_{avb}$, by \thref{l:recurse}. We will deduce a certain contraction property of ${\cal C}$ by applying \thref{l:errorImplication}(a--c) one after the other, and then 
show that for any integer $k>0$, ${\cal C}^{k}({P^*},{Y^*})$ and ${\cal C}^{k}(P,Y)$ are $O(\mu)^{k }$-close.   We will also show that ${P^*}$ and ${\cal C}^{k}({P^*})$ are $O(\mu\varepsilon^4)$-close. These observations will then be shown to imply \thref{RDenseBip}.
 

Fix $k_0 = 4\log n$ and $r=4k_0+4=O(\log n)$.   
Let $\Omega^{(0)}$ be the set of sequences ${\bf d}' \in \Z^n$ that are at $L_1$ distance at most $r$ from a sequence in $\D$.  Let $ \mu_1=5\mu$, and  define $\Omega^{(s)}$ to be the set of sequences ${\bf d}'\in\Omega^{(0)}$ of $L_1$ distance at least $s+1$ from all sequences outside   $\Omega^{(0)}$. 

Towards applying \thref{l:errorImplication} we first establish that $(P,Y)$ and $({P^*},{Y^*})$ are elements of $\Pi_{ \mu_1}(\Omega^{(2)})$ (see \thref{Pi-defn}).
 Note that for ${\bf d}'\in \Omega^{(0)}$, the values of  $s({\bf d}')$, $t({\bf d}')$  and $\mu({\bf d}')$ are asymptotically equal to  $s$, $t$  and $\mu$, respectively, since $M_1({\bf d}')=M_1({\bf d}_0)+O( \log n)$ for some sequence ${\bf d}_0\in \D$. Thus, $\mu$ and  $\mu({\bf d}')$ are interchangeable in the error terms below. Furthermore, we note that the bounds on $s_a$ and $t_v$ in the theorem statement imply that for all balanced ${\bf d} \in \Omega^{(0)}$, $s_a\sim s$ and $t_v\sim t$ uniformly for all $a\in S$ and $v\in T$. By \thref{lem:bipRealisable}\eqref{lem:bipRealisablei} we obtain  ${\cal N}({\bf d})>0$ for all balanced ${\bf d}\in \Omega^{(0)}$ in both cases  $\cA^{\mathrm{bi}}$ and $\cA^{\mathrm{di}}$. In doing so, we may take $C=1$ and $F$ to be either empty in the bipartite case, or a matching in the digraph case; the condition $m\le \ell n/9$ 
 follows from choosing $\mu_0$ small enough, and the conditions on $\Delta_S$ and $\Delta_T$  can be seen to follow from $|s_a-s|\le s^{\varphi}$ for all $a\in S$, 
 $|t_v-t|\le t^{\varphi}$ for all $v\in T$ and $\varphi <1$, say.
After this, for $n$  and $\ell$  sufficiently large,~\thref{l:simpleSwitching}, together with 
the facts that  $s_a\sim s$ and $t_v\sim t$ uniformly for all $a\in S$, $v\in T$,  implies that for all $av\in \cA$ 
\bel{Pbound2}
P_{av}({\bf d})\leq\frac{\mu}{1- 2\mu}(1+o(1)) <  \frac{5\mu}{4} 
\quad  \mbox{for all balanced ${\bf d}\in \Omega^{(0)}$},
\end{equation} 
where for the last inequality we use that $\mu< \mu_0  <  1/11$, say.  
Since $\Omega^{(2)}\se \Omega^{(0)}$ and $5\mu/4 <\mu_1$ this establishes requirement~\ref{Pi-a} for $P$ in the definition of $\Pi_{\mu_1}(\Omega^{(2)})$.
Now restrict slightly to ${\bf d} \in \Omega^{(2)}$. 
 By definition $Y_{avb}({\bf d})$ is the probability that both edges $av$ and $bv$ are present.
Hence  \thref{l:recurse}(c) implies (with the above bounds on $P_{av}({\bf d})$ applying for all ${\bf d}\in \Omega^{(0)}$) that $0\le Y_{avb}({\bf d}) =Y_{bva}({\bf d}) \le  3\mu P_{bv}({\bf d})/2$ 
  (easily) assuming, as we may, that $\mu$ is sufficiently small. Thus $(P,Y)$ 
 satisfies condition~\ref{Pi-c} for membership of $\Pi_{\mu_1}(\Omega^{(2)})$, and also
 $$
 \sum_{v\in  \cA(a)\cap \cA(b)} Y_{avb}({\bf d}) \le  \sum_{v\in  \cA(a)\cap \cA(b)}\frac{3P_{bv}({\bf d})\mu}{2}\le 3 \mu s_a(1+o(1)) 
 $$
  for all distinct $a,b\in S$, 
using $P_{bv}({\bf d})\le 2\mu\sim 2s_a/n$
 which follows from \eqref{Pbound2} and recalling that $s_a\sim \mu n$ uniformly for all $a\in S$ for all ${\bf d} \in \Omega^{(0)}$.  As  $4\mu < \mu_1$, this shows $Y$ satisfies condition~\ref{Pi-b} for membership of $\Pi_{\mu_1}(\Omega^{(2)})$ when $n$ is sufficiently large  and $a,b\in S$ are distinct. The equivalent statement for both $a,b\in T$ follows analogously. Note that this covers all cases of~\ref{Pi-b} as otherwise $\cA(a)\cap \cA(b)=\emptyset$ and the statement is trivial.
  %
To see that $({P^*},{Y^*})$ is also in $\Pi_{ \mu_1}(\Omega^{(2)})$,   
we first observe that $P^*_{av}({\bf d})\sim \mu$ for all $av\in \cA$ and all ${\bf d}\in \Omega^{(0)}$. This is because $\varepsilon\to 0$ since $\varphi <1$ and both $s,t\to\infty$, and because $\sigma_T^2/t\ell, \sigma_S^2/sn=O(\varepsilon^2\mu)$.  
Properties~\ref{Pi-a}-\ref{Pi-c} follow directly from this fact and the definition of $Y^*$  since $\mu=\mu_1/5$.   


Now for large $n$  and $\ell$  and for $(a,v)\in \oA$ we have $P_{av}({\bf d})=P^*_{av}({\bf d})(1\pm1)$ for all balanced ${\bf d}\in \Omega^{(0)}$ since $P^*_{av}({\bf d})\sim \mu$ and by~\eqref{Pbound2}.  Also,  $0\le Y_{avb}({\bf d})\le 3\mu P_{bv}({\bf d})/2$ implies  $Y_{avb}({\bf d})=Y^*_{avb}({\bf d})(1\pm1)$ for balanced ${\bf d}\in \Omega^{(2)}$.  
We may now apply \thref{l:errorImplication}(a) with $\xi=1$ for any $S$-heavy ${\bf d} \in \Omega^{(3)}$  to deduce that
$$
{\cal R}(P ,Y ) _{ab}({\bf d})= {\cal R}({P^*} ,{Y^*} )_{ab}({\bf d})(1+O (\mu_1))
$$
for all  $a,b\in S$ (noting that for $a=b$ the claim is trivial, and for distinct $a,b$ we use the previous observations).  
Writing ${\bf r}$ for ${\cal R}(P ,Y )$ and ${\bf r}'$ for ${\cal R}({P^*} ,{Y^*} )$ we obtain from this 
and \thref{l:errorImplication}(b) that 
$$
{\cal P}(P ,{\bf r} ) _{av}({\bf d})= {\cal P}({P^*} ,{\bf r}' )_{av}({\bf d})(1+O (\mu_1  ))
$$ 
for all balanced   ${\bf d} \in \Omega^{(4)}$  and all $av\in \cA$.   
Next applying \thref{l:errorImplication}(c) in the same way to balanced ${\bf d} \in \Omega^{(6)}$ gives 
$$
{\cal Y}(\hat{\bf p} ,Y) _{avb}({\bf d})= {\cal Y}(\hat{\bf p}' , {Y^*} )_{avb}({\bf d})(1+O (\mu_1  ))
$$ 
for all balanced ${\bf d} \in \Omega^{(6)}$, and all  $(a,v,b)\in \oA_2$ with $a\in S$,   
where $\hat{\bf p} = {\cal P}(P ,{\bf r} )$ and $\hat{\bf p}' = {\cal P}({P^*} ,{\bf r}' )$. 
 Recalling the definition of ${\cal C}({\bf p},{\bf y})$ from the beginning of this proof, we note that 
  the  three conclusions above imply that, for ${\cal C}(P ,Y )=(P_1,Y_1)$ and ${\cal C}({P^*} ,{Y^*} )=(P_1^*,Y_1^*)$, we have $P_1^*({\bf d})=P_1({\bf d})(1+O(\mu_1))$ and  $Y_1^*({\bf d})=Y_1({\bf d})(1+O(\mu_1))$ for all ${\bf d} \in \Omega^{(6)}$. Similarly, making $k-1$ iterated applications of the three parts of \thref{l:errorImplication} with ever-decreasing $\xi$ produces
$$
P_k^*({\bf d})=P_k({\bf d})(1+O(\mu_1)^k) \mbox{and} Y_k^*({\bf d})=Y_k({\bf d})(1+O(\mu_1)^k)
$$
for all ${\bf d} \in \Omega^{(2k+2)}$,  where $P_k$, $P_k^*$ etc.\ are defined analogously for ${\cal C}^{k}$. 
In the same way, applying  \thref{l:mapleHigher}(a), (b) and (c) in turn,   recalling Lemma~\ref{l:errorImplication} to handle the small error terms, shows that  $P_1^*({\bf d})=P^*({\bf d})(1+O(\mu \varepsilon^4))$ and  $Y_1^*({\bf d})=Y^*({\bf d})(1+O(\mu \varepsilon^4))$ for all ${\bf d} \in \Omega^{(6)}$.
 Using the three parts of \thref{l:errorImplication} repeatedly, and bounding the total distance moved during the iterations as for a contraction mapping  (as the sum of a geometric series), this gives
$$
P_k^*({\bf d})=P^*({\bf d})(1+O(\mu \varepsilon^4))   \mbox{ and  }  Y_k^*({\bf d})=Y^*({\bf d})(1+O(\mu \varepsilon^4))
$$
for all ${\bf d} \in \Omega^{(2k+2)}$. Using the last two conclusions with $k:= k_0 = 4 \log n$ and the fact that $P_k = P$ (as ${\cal C}$ fixes $(P,Y)$) gives~\eqn{appP} for all balanced ${\bf d}\in \Omega^{(r-2)}$ since
   we may assume that the  $ O( \mu_1)$ term is at most $1/e$ say. (Recall that $\mu_1=5\mu < 5\mu_0$ which we may choose to be sufficiently small.)
Note that $\D\se  \Omega^{(r)}\subseteq \Omega^{(r-2)}$ by definition.  
 For~\eqn{appR}, we now use that~\eqn{appP} holds for all balanced ${\bf d}\in \Omega^{(r-2)}$ to deduce from \thref{l:errorImplication}(a) that 
${\cal R}(P,Y)_{ab}({\bf d}) = {\cal R}({P^*} ,{Y^*} )_{ab}({\bf d}) (1+O(\mu \varepsilon^4))$ for all $S$-heavy ${\bf d}\in \Omega^{(r-1)}$. 
This, together with (a) above and the fact that ${\cal R}(P,Y)=R$,   
implies~\eqn{appR} for all ${\bf d}\in Q_1^S \subseteq   \Omega^{(r-1)}$.
\end{proof} 

Moving on to Step 2 of the template, we now make suitable definitions of probability spaces $\mathcal{S}$ and $\mathcal{S}'$ in preparation for using \thref{l:lemmaX}. Let $\Omega$ be the underlying set of 
$\mathcal{B}_m(\ell,n)$ in the bipartite case and of $\vec \mathcal{B}_m(n)$ in the digraph case, that is, the set of all degree sequences ${\bf d}=({\bf s},{\bf t})\in \Z^{\ell+n}$ such that $M_1({\bf s})=M_1({\bf t})=m$ (and $\ell =n$ in the digraph case). Let $\mathcal{S}'=\cD(\mathcal{G}(\ell,n,m))$ in the bipartite case, and $\mathcal{S}'=\cD(\vec \mathcal{G}(n,m))$ in the digraph case. 
Set 
$$
\W=\{{\bf d}=({\bf s},{\bf t})\in \D : 
 \sigma^2({\bf s}) \le  2s,\ \sigma^2({\bf t}) \le 2t,\left|\delta^{\mathrm{di}}\sigma({\bf s},{\bf t})\right|<\xi s  \}
$$
where $\xi= \max\{ \log^2\ell/\sqrt{\ell},\log^2n/\sqrt{n}\}$. 
 

Define the graph $G$ on vertex set $\D$ by joining two degree sequences by an edge if they are of the form ${\bf d}-{\ve_a}$ and ${\bf d}-{\ve_b}$ for some ${\bf d}\in Q_1^S$ and $a,b\in S$, or for some ${\bf d}\in Q_1^T$ and $a,b\in T$. 
We note at this point that the diameter of $G$ is $r=O(\ell s^{\varphi}+nt^{\varphi})=O(\varepsilon\mu n\ell)$ since the constant sequence $(d,\ldots,d)$ is an element of $\D$ and by the degree constraints for ${\bf d}\in \D$. The same bound holds for the diameter of $G[\W]$. 
By definition of $R$ in~\eqref{realRatio} and its approximation in~\eqref{appR}  we   have,   for adjacent vertices/sequences in this graph, that 
\begin{align}\lab{targetLHSnew}
\frac{\Pr_{\mathcal{S}'}({\bf d}-{\ve_a})}{\Pr_{\mathcal{S}'}({\bf d}-{\ve_b})}
&= R_{ab}({\bf d}) = 
R^*_{ab}({\bf d}) \left(1+ O\left(\mu \varepsilon^4\right)\right). 
\end{align}

We now define the ideal probability space $\mathcal{S}$ (see Step 3 of the template) on $\Omega$. Recall the definition of ${\tilde H}({\bf d})$ in~\eqref{corrH}, which is slightly different in the bipartite case and the digraph case (due to $\mu$ being defined slightly differently and the extra term in the exponent in the digraph case). Also recall  (from just before~\eqref{H}) that we use ${H}({\bf d})$ to denote the product $\Pr_{\mathcal{B}_m}({\bf d}){\tilde H}({\bf d})$ on the right hand side of~\eqref{enumFormula}, where $\mathcal{B}_m = \mathcal{B}_m(\ell,n)$ in the bipartite case and $\mathcal{B}_m=\vec\mathcal{B}_m(n)$ in the digraph case. 
Then set 
$$
\Pr_{\mathcal{S}}({\bf d}) = {H}({\bf d})/\sum_{{\bf d}'\in\W}{H}({\bf d}')
	= \frac{{H}({\bf d})}{{\bf E}_{\mathcal{B}_m}(\mathbbm{1}_{\W}{\tilde H})} 
$$
for ${\bf d}\in \W$ and $\Pr_{\mathcal{S}}({\bf d})=0$ otherwise. 

Following the template to Step 4 we next estimate the probability of $\W$ in the two probability spaces $\mathcal{S}$ and $\mathcal{S}'$ in both cases, bipartite and digraph. We simultaneously evaluate $\Pr_{\mathcal{B}_m}(\W)$ and  ${\bf E}_{\mathcal{B}_m}(\mathbbm{1}_{\W}{\tilde H})$  for later use.  First note that $\Pr_{\mathcal{S}}(\W)=1$ by definition. Next, $M_1({\bf s})=M_1({\bf t})=m$ for all ${\bf d}=({\bf s},{\bf t})\in\Omega$, by definition. Let $\bar n =\min\{n,\ell\}.$ For   the following, let  ${\bf d}$  be chosen  in either of $\cD(\mathcal{G})=\mathcal{S}'$ and $\mathcal{B}_m$, in either of  the bipartite and the digraph case. Then $|s_a-s|\le s^{\varphi}$ and $|t_v-t|\le t^{\varphi}$ for all $a\in S$ and $v\in T$ with probability at least $1-O({\bar n}^{-\omega})$
by \thref{l:sigmaConcBip}(i) and since  $s> (\log \ell)^K$ and $t> (\log n)^K$  for all $K>0$. It follows that $\Pr_{\cD(\mathcal{G})}(\D) = \Pr_{\mathcal{S}'}(\D) = 1-O(\bar n^{-\omega})$ and 
$\Pr_{\mathcal{B}_m}(\D) = 1-O(\bar n^{-\omega})$. 
  Next, apply  \thref{l:sigmaConcBip}(ii) with $\alpha =\xi/2$ for ${\bf d}=({\bf s},{\bf t})$ (noting that $m\ge s+t\gg\log^3 \ell+ \log^3 n$ and $(\log^3 n+\log^3 \ell)/m=o(\xi^2)$ by definition of $\xi$)  to deduce that 
$\sigma^2({\bf s})=s(1-\mu)(1\pm \xi)$, $\sigma^2({\bf t})=t(1-\mu)(1\pm \xi)$ and $\sigma({\bf s},{\bf t})=O(\xi s)$ with probability $1-O(\bar n^{-\omega})$. 
This implies in particular that $\Pr (\W) = 1-O(\bar n^{-\omega})$ in both $\mathcal{S}'$ and $\mathcal{B}_m$. 
Thus $\Pr(\W)\ge 1-\varepsilon_0$ in both $\mathcal{S}$ and $\mathcal{S}'$ in both cases, bipartite and digraph, for, say, $\varepsilon_0=1/\bar n$. 


 Before moving on to Step 5 of the template we use these concentration results to estimate ${\bf E}_{\mathcal{B}_m}(\mathbbm{1}_{\W}{\tilde H})$. If $\sigma^2({\bf t})=t(1-\mu)(1+O(\xi))$ then the term $\sigma^2({\bf t})/t(1-\mu)$ in the exponent of ${\tilde H}({\bf d})$ is $1+O(\xi)$. Similarly for the term $\sigma^2({\bf s})/s(1-\mu)$. Furthermore, in the digraph case, if $\sigma({\bf s},{\bf t})=O(\xi s)$ then the term $\delta^{\mathrm{di}}\sigma({\bf s},{\bf t})/s(1-\mu)$ in ${\tilde H}({\bf d})$ is $O(\xi)$. It follows, using the strong concentration results in the previous paragraph, that 
\bel{HConcDense}
{\tilde H}({\bf d})= 1+O(\xi) \text{ with probability } 1-O(\bar n^{-\omega}) \text{ for } {\bf d}\in\mathcal{B}_m.
\end{equation}
Furthermore, by definition of $\W$ it follows that ${\tilde H}({\bf d}) = \Theta(1)$ for all ${\bf d}\in \W$, using the fact that $\mu < 1/2,$ say. This and~\eqref{HConcDense} then imply that ${\bf E}_{\mathcal{B}_m}(\mathbbm{1}_{\W}{\tilde H})=1+O(\xi+\bar n^{-\omega})=1+O(\xi).$
 

We now move to Step 5 in the template. 
For  ${\bf d}=({\bf s},{\bf t})\in Q_1^S$ and $a,b\in S$, 
\begin{align}\label{eq:ratioDense}
\frac{{H}({\bf d}-{\ve_a})}{{H}({\bf d}-{\ve_b})} &=
\frac{{H}({\bf s}-{\ve_a},{\bf t})}{{H}({\bf s}-{\ve_b},{\bf t})}
=  \frac{s_a(n+\delta^{\rm bi} -s_b)}{s_b(n+\delta^{\rm bi}-s_a)}
 \exp\bigg(\frac{s_b-s_a}{s(1-\mu)\ell }
 \left(1-\frac{\sigma^2({\bf t})}{t(1-\mu)}\right)
 +\frac{ \delta^{\rm di} (t_{a'}-t_{b'})}{t(1-\mu)n}\bigg),  
\end{align}
by~\eqref{H}. 
Compare the expression on the right hand side with $R^*=\rho$ at the beginning of this section (after a straight-forward reparameterisation) to see that 
\bel{targetRHS}
 \frac{{H}({\bf d}-{\ve_a})}{{H}({\bf d}-{\ve_b})} 
= R^*_{ab}({\bf d})  \left(1+ O\left( 1/\bar n^2\right)\right),  
\end{equation}
where the error is due to the fact that we use $e^x = 1+x+O(x^2)$ and that $\mu({\bf d}) = \mu +O(1/n\ell)$ for ${\bf d}\in Q_1^S$.   
This together with
\eqref{targetLHSnew} gives
\bel{ratioInD}
\frac{\Pr_{\mathcal{S}'}({\bf d}-{\ve_a})}{\Pr_{\mathcal{S}'}({\bf d}-{\ve_b})} =e^{O(\mu\varepsilon^4)} \frac{{H}({\bf d}-{\ve_a})}{{H}({\bf d}-{\ve_b})} 
\end{equation}
for ${\bf d}\in Q_1^S$ and $a,b\in S$. 
The same applies for ${\bf d}\in Q_1^T$ and $a,b\in T$ by symmetry. 
 Note that when both ${\bf d}-{\ve_a}$ and ${\bf d}-{\ve_b}$ are elements of $\W$ then the right hand side is in fact equal to 
$ e^{O(\mu\varepsilon^4)}\Pr_{\mathcal{S}}({\bf d}-{\ve_a})/\Pr_{\mathcal{S}}({\bf d}-{\ve_b}),$ by definition of $\Pr_{\mathcal{S}}$ above. 
Therefore, by \thref{l:lemmaX} 
\begin{align*}
\Pr_{\mathcal{S}'}({\bf d}) &= \Pr_{\mathcal{S}}({\bf d}) e^{O\left( r\mu\varepsilon^4+\varepsilon_0 \right)}\\
&= \Pr_{\mathcal{B}_m}({\bf d}){\tilde H}({\bf d})\left(1+O\left(\xi + r\mu\varepsilon^4+\varepsilon_0\right)\right) 
\end{align*} 
for all ${\bf d}\in \W$,  where we use that ${\bf E}_{\mathcal{B}_m} (\mathbbm{1}_{\W}{\tilde H}) = 1+O(\xi)$. 
Now let ${\bf d}\in \D\sm\W$. Then there is some sequence ${\bf d}'\in \W$ such that the distance of ${\bf d}$ and ${\bf d}'$ in $G$ is at most $2r$. Any two adjacent sequences $\tilde{\bf d}-{\ve_a}$ and $\tilde{\bf d}-{\ve_b}$ along that path satisfy~\eqref{ratioInD}, so that by telescoping we see that 
\begin{align*}
\Pr_{\mathcal{S}'}({\bf d}) &= H({\bf d}) \left(1+O\left(\xi + r\mu\varepsilon^4+\varepsilon_0\right)\right)
\end{align*} 
for such ${\bf d}$ as well. This proves the claim, 
since $\xi = \max\{ \log^2\ell/\sqrt{\ell},\log^2n/\sqrt{n}\}$, $\varepsilon_0=1/n$, and 
$r\mu\varepsilon^4 = O\left(\varepsilon^5\mu^2n\ell\right)$.
\end{proof}


\begin{proof}[Proof of \thref{t:bipmodel}]
In the sparse case, given that the set $\D$ in \thref{t:sparseCaseBip} is nonempty, we define a set $\W$ in the proof of \thref{t:sparseCaseBip} and show  that $\Pr_{\mathcal{S}'}(\W) =  1-o(n^{-\omega})$ just before~\eqn{HConc}, where $\mathcal{S}'= \cD(\vec \mathcal{G}(n,m))$  or $\cD(\mathcal{G}(\ell,n,m))$ as the case may be, and also that $\Pr_{\mathcal{B}_m}(\W) =  1-o(n^{-\omega})$. 
As observed in that proof, the formula given in \thref{t:sparseCaseBip} holds for all ${\bf d}\in\W$, and also we can assume that $\corr{{\bf d}}\sim 1$ by~\eqn{HConc}. This gives the required a.q.e.\ property, for any triple $(\ell,n,m)$ such that the set $\D$ in that theorem is nonempty (for $n$ sufficiently large).
The proof of \thref{t:mainbip} implies a similar result, for any  $(\ell,n,m)$ satisfying that theorem's hypotheses. So all that is left to do is check which ordered triples $(\ell, n, m)$ are covered by these results,   and to supply the remaining cases using previously known results. 

We first concentrate on the bipartite case~\ref{model-b}. We claim that the conditions in \ref{model-b-ii} imply that the hypotheses for \thref{t:mainbip} are satisfied. Note first that $n^3 = o(\ell^2m^{1-\varepsilon})$ implies in particular that $\ell\to\infty$ with $n$, using the trivial $m\le n\ell$. The same asymptotic inequality, together with $\ell\le n$, implies that $n\ell^{\varepsilon}\le m$. The required bounds on $m$ in \thref{t:mainbip} then follow from $n\ell^{\varepsilon}\le m<\mu_0 n\ell$ by choosing, say, $\varphi = 1/2+\varepsilon/10.$
Next, we check that the conditions in \ref{model-b-iii} imply that the hypotheses for \thref{t:sparseCaseBip} are satisfied and that there exists some non-empty set $\D$ as in the theorem statement. Given $\ell,n$ and $m$, let ${\bf d}=({\bf s},{\bf t})$ be a sequence such that $M_1({\bf s})=M_1({\bf t})=m$, all elements of ${\bf s}$ are equal to $\lfloor m/\ell\rfloor$ or $\lceil m/\ell\rceil$ and all elements of ${\bf t}$ are equal to $\lfloor m/n\rfloor$ or $\lceil m/n\rceil$, respectively. 
Then the inequality 
$$ 
\Delta_S^3\Delta_T^3(n\ell)^{\varepsilon/2} 
\le \left(\frac{m}{\ell}+1\right)^3 \left(\frac{m}{n}+1\right)^3m^{\varepsilon} \ll \min\{sm,tm\}
$$ 
can be seen to follow from $m^{4+\varepsilon}=o(n^2\ell^2\min\{\ell,n\}).$  
Thus, for $n$ sufficiently large, the set $\D$ in \thref{t:sparseCaseBip} can be assumed to be non-empty and for \ref{model-b-iii}, the requirements of \thref{t:sparseCaseBip} are satisfied.
For $\log^3\ell+ \log ^3n\ll m \ll \min\{n/\log^2n,\ell/\log^2\ell\}$, \thref{l:sigmaConcBip} shows that with probability $1-n^{-\omega}-\ell^{-\omega}$ all vertices in $\mathcal{G}(\ell,n,m)$ have bounded degrees, so the main theorem of  Bender~\cite{b1974} applies. \thref{l:sigmaConcBip}  also shows that the terms $\sigma^2({\bf s})$ and $\sigma^2({\bf t})$ are  concentrated near their  expected values, to the extent that $\corr{{\bf d}} =1+o(1)$ with probability $1-n^{-\omega}-\ell^{-\omega}$. It is then a simple calculation to check that Bender's  formula corresponds asymptotically with the first formula in~\eqn{probbin}, noting  the adjustment required to count graphs (as in Remark~\ref{r:first}). This finishes the proof of part (b).

For the digraph case~\ref{model-a}, \thref{t:mainbip,t:sparseCaseBip} also supply the required statement when $\ell=n$. Here \thref{t:mainbip} covers the range $n^{1+\varepsilon}<m<\mu_0 n^2$ for any $\varepsilon>0$ and sufficiently small constant $\mu_0$, and \thref{t:sparseCaseBip} covers the range $n/\log^3n < m < n^{5/4-\varepsilon},$ say. Only the very dense and very sparse remain. McKay and Skerman~\cite[Theorem 1(d)]{MS}  immediately covers $\min\{m, n(n-1)-m) > n^2/c\log n$  for any  $c>0$. Larger values of $m$ than this are covered by complementation of the results for smaller values. On the other hand, for $\log ^3n\ll m= \ll n/\log^2n$, we  may again use  \thref{l:sigmaConcBip} and the main theorem of~\cite{b1974}. This works almost exactly the same as for the bipartite graph case. 
\end{proof}


\begin{proof}[Proof of \thref{t:edgeprobability}]
The stated formula is a by-product of the proof of \thref{t:mainbip}, so here we just point to the relevant spots within that proof. 
Recall the definition of $P^\ast$, which is our approximation to the edge probability, at the beginning of Section~\ref{s:denseBip}, and note that a parameterisation yields the formula given in the statement of \thref{t:edgeprobability}. 
\thref{RDenseBip} then yields the desired approximation since $\mu\varepsilon^4=O(\min\{s,t\}^{4\varphi-4}m/n\ell)$.
\end{proof}
  
   
 
2020-06-30T02:26:30.000
2006
2006.15797
en
https://arxiv.org/abs/2006.15797
We provide asymptotic formulae for the numbers of bipartite graphs with given degree sequence, and of loopless digraphs with given in- and out-degree sequences, for a wide range of parameters. Our results cover medium range densities and close the gaps between the results known for the sparse and dense ranges. In the case of bipartite graphs, these results were proved by Greenhill, McKay and Wang in 2006 and by Canfield, Greenhill and McKay in 2008, respectively. Our method also essentially covers the sparse range, for which much less was known in the case of loopless digraphs. For the range of densities which our results cover, they imply that the degree sequence of a random bipartite graph with m edges is accurately modelled by a sequence of independent binomial random variables, conditional upon the sum of variables in each part being equal to m. A similar model also holds for loopless digraphs.
Combinatorics (math.CO); Discrete Mathematics (cs.DM)
Asymptotic enumeration of digraphs and bipartite graphs by degree sequence
Qwen/Qwen-72B
1. YES
2. YES