This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

An impossibility result for Markov Chain Monte Carlo sampling
from micro-canonical bipartite graph ensembles

Giulia Preti giulia.preti@centai.eu    Gianmarco De Francisci Morales gdfm@acm.org CENTAI, Corso Inghilterra 3, 10138 Turin, Italy    Matteo Riondato mriondato@amherst.edu Amherst College, 25 East Drive, Amherst, 01002 Massachusetts, USA
Abstract

Markov Chain Monte Carlo (MCMC) algorithms are commonly used to sample from graph ensembles. Two graphs are neighbors in the state space if one can be obtained from the other with only a few modifications, e.g., edge rewirings. For many common ensembles, e.g., those preserving the degree sequences of bipartite graphs, rewiring operations involving two edges are sufficient to create a fully-connected state space, and they can be performed efficiently. We show that, for ensembles of bipartite graphs with fixed degree sequences and number of butterflies (k2,2k_{2,2} bi-cliques), there is no universal constant cc such that a rewiring of at most cc edges at every step is sufficient for any such ensemble to be fully connected. Our proof relies on an explicit construction of a family of pairs of graphs with the same degree sequences and number of butterflies, with each pair indexed by a natural cc, and such that any sequence of rewiring operations transforming one graph into the other must include at least one rewiring operation involving at least cc edges. Whether rewiring these many edges is sufficient to guarantee the full connectivity of the state space of any such ensemble remains an open question. Our result implies the impossibility of developing efficient, graph-agnostic, MCMC algorithms for these ensembles, as the necessity to rewire an impractically large number of edges may hinder taking a step on the state space.

I Introduction

Testing the statistical significance of properties of an observed network is a fundamental problem in network science [1]. The significance of the observed value is tested against a null model, an ensemble =(𝒢,π)\mathcal{H}=(\mathcal{G},{\color[rgb]{0,0,0}\pi}) composed of the set 𝒢\mathcal{G} of possible graphs that can be realized under the null hypothesis and a probability distribution π{\color[rgb]{0,0,0}\pi} over 𝒢\mathcal{G}. One typically selects some descriptive characteristics of the observed network, and either defines 𝒢\mathcal{G} and π{\color[rgb]{0,0,0}\pi} in such a way that the expectations w.r.t. π{\color[rgb]{0,0,0}\pi} of these characteristics over 𝒢\mathcal{G} are the same as the observed ones (a.k.a. the canonical model), or defines 𝒢\mathcal{G} as the set of all and only the graphs with exactly the same values for the characteristics as the observed network, and π{\color[rgb]{0,0,0}\pi} can be any distribution, often the uniform. Once the null model is defined, one proceeds by sampling several graphs from this ensemble. These graphs are used to approximate the distribution of the test statistic of interest under the null hypothesis. By comparing the observed statistic to this distribution one can compute an empirical pp-value.

For example, the widely used “configuration model” [2] considers the set of graphs with the same degree sequence as the observed network and the uniform distribution. This model has been instrumental in determining that clustering, assortativity, and community structure in real networks are not solely dependent on node degrees, hence highlighting their significance [3]. However, the configuration model fails to generate graphs with a local structure similar to the observed graph [4]. Researchers have thus explored alternative null models that sample from graph families defined by more complex characteristics of the observed graph, such as joint degree distribution  [5, 4, 6, 7], core-value sequence [8], and local triangle-count sequence [9].

In this work, we focus on bipartite graphs, i.e., networks whose nodes can be partitioned into two classes such that all edges go from one class to the other. Formally, a bipartite graph is a tuple G(L,R,E)G\doteq(L,R,E), where LL and RR are disjoint sets of nodes called left and right nodes, respectively, and EL×RE\subseteq L\times R is a set of edges connecting nodes in LL to nodes in RR. We consider undirected bipartite graphs, but for ease of presentation, we denote any edge (u,a)(u,a) so that uLu\in L and aRa\in R. For any vertex vLRv\in L\cup R we denote with ΓG(v)\Gamma_{G}\lparen v\rparen the set of neighbors of vv, i.e., the vertices to which vv is connected by an edge in GG, and we define the degree 𝖽G(v)\mathsf{d}_{G}\lparen v\rparen of vv in GG as 𝖽G(v)|ΓG(v)|\mathsf{d}_{G}\lparen v\rparen\doteq\left\lvert\Gamma_{G}\lparen v\rparen\right\rvert. Assuming an arbitrary but fixed labeling u1,,u|L|u_{1},\dotsc,u_{\left\lvert L\right\rvert} (resp. a1,,a|R|a_{1},\dotsc,a_{\left\lvert R\right\rvert}) of the nodes in LL (resp. RR), the vector 𝖽G(u1),,𝖽G(u|L|)\langle\mathsf{d}_{G}\lparen u_{1}\rparen,\dotsc,\mathsf{d}_{G}\lparen u_{\left\lvert L\right\rvert}\rparen\rangle (resp. 𝖽G(a1),,𝖽G(a|R|)\langle\mathsf{d}_{G}\lparen a_{1}\rparen,\dotsc,\mathsf{d}_{G}\lparen a_{\left\lvert R\right\rvert}\rparen\rangle) is known as the left (resp. right) degree sequence of GG.

Bipartite networks occur naturally in many applications: when representing words and documents [10], items and itemsets [11], higher-order networks such as hypergraphs and simplicial complexes [12], and many more. Null models and graph ensembles can also be defined on bipartite graphs [13, 11, 14]. For example, Preti et al. [11] introduce a null model that preserves the bipartite joint adjacency matrix (i.e., the matrix whose (i,j)(i,j)-th entry is the number of edges connecting nodes from LL with degree ii to nodes in RR with degree jj), of an observed network (thus the degree sequences and the number of caterpillars, i.e., paths of length 3), and give Markov Chain Monte Carlo (MCMC) algorithms to sample from this null model. Null models for bipartite graphs are also of particular interest because they align with null models for 0–1 binary matrices [15, Ch. 6]. For example, preserving the degree sequences in a bipartite graph corresponds to preserving the row and column marginals of the corresponding bi-adjacency matrix, and several MCMC algorithms have been developed to sample from this null model [16, 17, 18, 19, 20].

We consider graph ensembles for which 𝒢\mathcal{G} is the set of all bipartite graphs G(L,R,E)G\doteq(L,R,E) that share the same degree sequences and the same number of butterflies, i.e., k2,2k_{2,2} bi-cliques , defined as follows.

Definition 1 (Butterfly).

Let G(L,R,E)G\doteq(L,R,E) be a bipartite graph. Two distinct nodes u,vLu,v\in L and two distinct nodes a,bRa,b\in R belong to the butterfly A={u,v,a,b}A=\{u,v,a,b\} in GG if and only if {(u,a),(u,b),(v,a),(v,b)}E\{(u,a),(u,b),(v,a),(v,b)\}\subseteq E.

The following result, whose proof is immediate, gives an expression for the number of butterflies to which two nodes both belong.

Fact 1.

Let G(L,R,E)G\doteq(L,R,E) be a bipartite graph, and let uu and vv be distinct nodes in LL. The number 𝖻G(u,v)\mathsf{b}_{G}\lparen u,v\rparen of butterflies in GG to which both uu and vv belong is

𝖻G(u,v)=(|ΓG(u)ΓG(v)|2),\mathsf{b}_{G}\lparen u,v\rparen=\binom{\left\lvert\Gamma_{G}\lparen u\rparen\cap\Gamma_{G}\lparen v\rparen\right\rvert}{2}\,,

where we assume (02)=(12)=0\binom{0}{2}=\binom{1}{2}=0. A similar result holds for any two distinct nodes in RR.

For uLu\in L, we denote with 𝖻G(u)\mathsf{b}_{G}\lparen u\rparen the number of butterflies in GG to which uu belongs. It holds

𝖻G(u)=vLvu𝖻G(u,v).\mathsf{b}_{G}\lparen u\rparen=\sum_{\begin{subarray}{c}v\in L\\ v\neq u\end{subarray}}\mathsf{b}_{G}\lparen u,v\rparen\,. (1)

The total number 𝖻(G)\mathsf{b}\lparen G\rparen of butterflies in GG is then

𝖻(G)12uL𝖻G(u).\mathsf{b}\lparen G\rparen\doteq\frac{1}{2}\sum_{u\in L}\mathsf{b}_{G}\lparen u\rparen\,. (2)

The butterfly, being the smallest complete subgraph in a bipartite graph, is the most basic building block for composing more complex structures, analogous to the triangle in unipartite graphs. Consequently, preserving the number of butterflies emerges as a natural choice when defining null models that retain more graph properties beyond just the degree sequences. This concept finds applications in studying, e.g., clustering patterns [21].

MCMC methods are a popular approach to sample from an ensemble =(𝒢,π)\mathcal{H}=(\mathcal{G},{\color[rgb]{0,0,0}\pi}). They define a suitable Markov chain on the space 𝒢\mathcal{G} of all possible graphs, such that, after a sufficient burn-in period, the state of the Markov chain is approximately distributed according to π{\color[rgb]{0,0,0}\pi}. The correctness of this process requires the Markov chain to be finite, irreducible, and aperiodic [2]. Efficient sampling requires not only that the Markov chain has a fast mixing time, but also that the space can be explored quickly, i.e., that obtaining a neighbor from the current state is efficient. The double edge swap technique, also known as degree-preserving rewiring [22], checkerboard swap [23], or tetrad [17], is a simple yet fundamental randomization technique used to generate a new graph with the same degree sequence as a given graph. Its efficiency stems from the fact that it involves the rewiring of a small number of edges. In bipartite graphs, the most basic rewiring technique is known as the bipartite swap operation (BSO).

Definition 2 (BSO).

Let G(L,R,E)G\doteq(L,R,E) be a bipartite graph and uvLu\neq v\in L, abRa\neq b\in R such that (u,a),(v,b)E(u,a),(v,b)\in E and (u,b),(v,a)E(u,b),(v,a)\notin E. The BSO involving (u,a)(u,a) and (v,b)(v,b) removes (u,a)(u,a) and (v,b)(v,b) from EE, and adds (u,b)(u,b) and (v,a)(v,a) to EE. The resulting bipartite graph G=(L,R,(E{(u,a),(v,b)}){(u,b),(v,a)})G^{\prime}=(L,R,(E\setminus\{(u,a),(v,b)\})\cup\{(u,b),(v,a)\}) has the same left and right degree sequence of GG.

A more sophisticated operation is the qq-edge bipartite swap operation (qq-BSO), which may involve the simultaneous swapping of multiple edges, potentially between a large set of nodes, similar to the qq-switch operation defined by Tabourier et al. [24].

Definition 3 (qq-BSO).

Let G(L,R,E)G\doteq(L,R,E) be a bipartite graph and q+q\in\mathbb{N}^{+}. A qq-BSO is a pair 𝗌𝗐q(S,σ)\mathsf{sw}^{q}\doteq(S,\sigma) with S=e1,,eqS=\langle e_{1},\dotsc,e_{q}\rangle being a vector of qq distinct edges ei(ui,ai)Ee_{i}\doteq(u_{i},a_{i})\in E, and σ\sigma being a derangement of [q][q], i.e., a permutation of [q][q] with no element in its original position, s.t. (uj,aσ(j))E(u_{j},a_{\sigma(j)})\notin E for each j[1,q]j\in[1,q]. Replacing each eje_{j} with (uj,aσ(j))(u_{j},a_{\sigma(j)}) generates a bipartite graph G=(L,R,(ES){(uj,aσ(j)) for j[1,q]})G^{\prime}=\left(L,R,(E\setminus S)\cup\left\{\left(u_{j},a_{\sigma(j)}\right)\text{ for }j\in[1,q]\right\}\right) with the same left and right degree sequence as GG.

According to this definition, a BSO involving (u,a)(u,a) and (v,b)(v,b) can be seen as the 22-BSO ((u,a),(v,b),(2 1))(\langle(u,a),(v,b)\rangle,(2\ 1)). Algorithms such as Verhelst’s [17] and Curveball [20] aim to speed up the sampling from the ensemble of bipartite graphs with fixed degree sequences. They execute multiple BSO operations at each step by selecting nodes uu and vv from LL (or RR) and exchanging multiple edges originating from uu with edges originating from vv. Conversely, a qq-BSO may involve the simultaneous swapping of multiple edges originating from multiple source nodes. Thus, the moves considered by Curveball and Verhelst’s can be expressed as qq-BSOs, but qq-BSOs are more expressive, in the sense that there are qq-BSOs that do not correspond to possible moves for these algorithms.

II Connectivity of the state space

A key requirement to use an MCMC method for sampling from a graph ensemble is that the state space, where each state corresponds to a graph in the ensemble, is strongly connected , i.e., for any two states GG^{\prime} and G′′G^{\prime\prime} there is a sequence ρ1,ρ2,,ρ\langle\rho_{1},\rho_{2},\dotsc,\rho_{\ell}\rangle of graph-transforming operations for some \ell (which may depend on the chosen GG^{\prime} and G′′)G^{\prime\prime}), such that ρ1\rho_{1} transforms GG^{\prime} into some G1G_{1} that belongs to the state space, ρi\rho_{i} for 1<i<1<i<\ell transforms GiG_{i} into Gi+1G_{i+1} that also belongs to the state space, and ρ\rho_{\ell} transforms G1G_{\ell-1} into G′′G^{\prime\prime}. In other words, a class 𝒞\mathcal{C} of graph-transforming operations defines a neighborhood structure of the state space as follows: given any GG in the state space, a neighbor of GG is any state that can be obtained by applying a single operation from 𝒞\mathcal{C}, provided that the operation is applicable to GG. With this neighborhood structure, the state space is strongly connected if there is a path from any state to any other state.

We can immediately see that the state space 𝒢\mathcal{G} we consider is strongly connected by sequences of qq-BSOs when qq is large enough, for any left and right degree sequences, and any number of butterflies (see also [24, Sect. 3.2.2]). In fact, there is always a |EE′′|\left\lvert E^{\prime}\setminus E^{\prime\prime}\right\rvert-BSO that transforms any bipartite graph G(L,R,E)G^{\prime}\doteq(L,R,E^{\prime}) into another bipartite graph G′′(L,R,E′′)G^{\prime\prime}\doteq(L,R,E^{\prime\prime}) with the same left and right degree sequences, and number of butterflies (see Supplementary Material [25] for details). While this fact ensures the strong connectivity of the state space via the union of all qq-BSOs for q=2,,|E|q=2,\dotsc,\left\lvert E^{\prime}\right\rvert, it has little practical relevance, as we now explain. If we use all these qq-BSOs to define the neighborhood structure of the state space, the resulting space would be a complete graph, i.e., a clique. Consequently, drawing, according to any distribution, a neighbor of a given state would require a procedure to build an entirely new bipartite graph with the same degree sequences and the same number of butterflies from scratch. Developing such a procedure seems even harder than the problem we are attempting to solve, in the same way as devising algorithms for building a bipartite graph with prescribed degree sequences from scratch [26, 27, 28, 29, 30] is much harder than devising algorithms for sampling such a graph using MCMC approaches starting from an existing one [17, 20, 16, 18, 19].

The correct question to ask is therefore the following: is there a fixed, universal, constant qq^{*} such that, for any left and right degree sequences, and any number of butterflies, any two bipartite graphs with those left and right degree sequences, and that number of butterflies, are connected by sequences 𝗌𝗐1p1=(S1,σ1),,𝗌𝗐zpz=(Sz,σz)\langle\mathsf{sw}^{p_{1}}_{1}=(S_{1},\sigma_{1}),\dotsc,\mathsf{sw}^{p_{z}}_{z}=(S_{z},\sigma_{z})\rangle of pip_{i}-BSOs, with piqp_{i}\leq q^{*}, i=1,,zi=1,\dotsc,z, where zz may depend on the two graphs? By “universal”, we mean a quantity that in no way depends on properties of the ensemble (𝒢,π)(\mathcal{G},\pi), including properties of the observed network.

Asking this question is reasonable: it is known that q=2q^{*}=2 when one is only interested in preserving the degree sequences [15, Ch. 6], and it is also known that q=2q^{*}=2 for the case of preserving the degree sequences and the number of paths of length 3 (a.k.a. caterpillars), in which case the rewiring operations slightly differ from the traditional BSOs [11, 31].

Additionally, we would like qq^{*} to be small, because sampling a qq-BSO is not necessarily efficient: the naïve approach of independently sampling qq edges and then verifying whether they form a valid qq-BSO has an increasing probability of failure as qq increases [24]. As a result, the Markov chain would exhibit a high probability of staying in the same state for many consecutive steps, greatly increasing the mixing time.

For unipartite graphs, it has been proved that q=2q^{*}=2 is not always sufficient to ensure strong connectivity of spaces of graphs that share more complex properties [24, 31]. In this work, we demonstrate the nonexistence of a fixed, universal, constant qq^{*} for the ensemble of bipartite graphs with the same left and right degree sequences and the same number of butterflies.

Let us give some intuition with an example, which shows that it cannot be q<4q^{*}<4. Figure 1 shows two bipartite graphs G1G_{1} (upper) and G2G_{2} (lower) with the same left and right degree sequences, and the same number of butterflies 𝖻(G1)=𝖻(G2)=10\mathsf{b}\lparen G_{1}\rparen=\mathsf{b}\lparen G_{2}\rparen=10. There is no sequence of qq-BSO s for q<4q<4 that, when applied to G1G_{1}, generates a graph isomorphic to G2G_{2}: any qq-BSO for q<4q<4 applied to G1G_{1} either generates a graph with a different number of butterflies, or generates a graph isomorphic to G1G_{1}. On the other hand, the 44-BSO ([(x1,y5),(x5,y1),(x6,y10),(x10,y6)],σ)([(x_{1},y_{5}),(x_{5},y_{1}),(x_{6},y_{10}),(x_{10},y_{6})],\sigma) with σ(1)=3\sigma(1)=3, σ(2)=4\sigma(2)=4, σ(3)=1\sigma(3)=1, and σ(4)=2\sigma(4)=2 ensures that the two butterflies {x1,x5,y1,y5}\{x_{1},x_{5},y_{1},y_{5}\} and {x6,x10,y6,y10}\{x_{6},x_{10},y_{6},y_{10}\} disappear, while the two new butterflies {x1,x10,y1,y10}\{x_{1},x_{10},y_{1},y_{10}\} and {x5,x6,y5,y6}\{x_{5},x_{6},y_{5},y_{6}\} appear, hence preserving the total count 𝖻(G1)\mathsf{b}\lparen G_{1}\rparen.

Refer to caption
Figure 1: Graphs that are not connected by qq-BSOs for q<4q<4.

Our main result is the following theorem (proof in Supplementary Material [25]).

Theorem 1.

For any q¯\bar{q}\in\mathbb{N} with q¯>1\bar{q}>1, there exist two non-isomorphic bipartite graphs GbG_{\mathrm{b}} and GeG_{\mathrm{e}} with the same left and right degree sequences, and 𝖻(Gb)=𝖻(Ge)\mathsf{b}\lparen G_{\mathrm{b}}\rparen=\mathsf{b}\lparen G_{\mathrm{e}}\rparen, such that for any sequence 𝗌𝗐1p1=(S1,σ1),,𝗌𝗐zpz=(Sz,σz)\langle\mathsf{sw}^{p_{1}}_{1}=(S_{1},\sigma_{1}),\dotsc,\mathsf{sw}^{p_{z}}_{z}=(S_{z},\sigma_{z})\rangle of pip_{i}-BSOs with pi+p_{i}\in\mathbb{N}^{+}, i=1,,zi=1,\dotsc,z, that transforms GbG_{\mathrm{b}} into GeG_{\mathrm{e}}, there exists {1,,z}\ell\in\{1,\dotsc,z\} with pq¯p_{\ell}\geq\bar{q}.

Our proof consists of two parts. First, we construct two bipartite graphs GbG_{\mathrm{b}} and GeG_{\mathrm{e}} with the same left and right degree sequences (which will depend on q¯\bar{q} as the second largest left degree will be greater than q¯\bar{q}), and the same number of butterflies. Second, we demonstrate that any sequence of qq-BSOs applied to GbG_{\mathrm{b}} to obtain a graph isomorphic to GeG_{\mathrm{e}} must involve at least one qq-BSO for q>q¯q>\bar{q}. Since q¯\bar{q} can be arbitrarily large, a universal constant qq^{*} as above cannot exist.

This theorem proves that it is impossible to design efficient MCMC algorithms that sample from ensembles =(𝒢,π)\mathcal{H}=(\mathcal{G},{\color[rgb]{0,0,0}\pi}) of bipartite graphs with the same degree sequences and the same number of butterflies, because the state space is not strongly connected by edge swap operations that involve only up to a fixed, universal, number of edges, as is instead the case for simpler null models. Rather, the minimum number of edges that must be involved depends on properties of the state space 𝒢\mathcal{G} , not just of the observed network. These may not be easily computable, as they may not depend just on the observed network, if any.

This result has profound implications for the design of network null models and for network science in general. If it is unfeasible to preserve the occurrences of the simplest building block of bipartite graphs (the butterfly), it becomes unfeasible to preserve larger structures. When dealing with bipartite graphs and complex observed characteristics, ensembles with “soft” constraints, where the constraints are retained on average over all the graphs sampled from the ensemble [32], might be the only viable option.

Refer to caption
Figure 2: Bipartite graphs generated by our algorithm (see Supplementary Material [25]) for s=2s=2 and t=3t=3.

The algorithm to construct the graphs GbG_{\mathrm{b}} and GeG_{\mathrm{e}} is delineated in the Supplementary Material [25]. We now describe the main characteristics of such graphs.

Let ss and tt be two naturals with s>t2s>t\geq 2 and 2(s1)>q¯2(s-1)>\bar{q}. We define n(s2)+(t2)n\doteq\binom{s}{2}+\binom{t}{2} and a((s+1)mod 2)+((t+1)mod 2)a\doteq((s+1)\ \text{mod}\ 2)+((t+1)\ \text{mod}\ 2). The graphs GbG_{\mathrm{b}} and GeG_{\mathrm{e}} output by the algorithm with inputs ss and tt have the following properties:

  1. 1.

    GbG_{\mathrm{b}} and GeG_{\mathrm{e}} have 7+a7+a left nodes (denoted with the letter xx) and s+t+n+2+as+t+n+2+a right nodes (denoted with the letter yy);

  2. 2.

    GbG_{\mathrm{b}} and GeG_{\mathrm{e}} have the same left and right degree sequences. In particular, x1x_{1} and x2x_{2} have degree ss, x3x_{3} and x4x_{4} have degree tt, x5x_{5} and x6x_{6} have degree n+1n+1, yiy_{i} has degree 2 for 1is+t+n+11\leq i\leq s+t+n+1, and all the other left and right nodes have degree 11;

  3. 3.

    𝖻(Gb)=𝖻(Ge)=n+(n2)\mathsf{b}\lparen G_{\mathrm{b}}\rparen=\mathsf{b}\lparen G_{\mathrm{e}}\rparen=n+\binom{n}{2};

  4. 4.

    |ΓGe(x5)ΓGe(x6)|=n+1\left\lvert\Gamma_{G_{\mathrm{e}}}\lparen x_{5}\rparen\cap\Gamma_{G_{\mathrm{e}}}\lparen x_{6}\rparen\right\rvert=n+1, which, with the previous point, implies that x5x_{5} and x6x_{6} belong to all butterflies in GeG_{\mathrm{e}}, and every other node yRy\in R belongs to no butterfly;

  5. 5.

    |ΓGb(x5)ΓGb(x6)|=n\left\lvert\Gamma_{G_{\mathrm{b}}}\lparen x_{5}\rparen\cap\Gamma_{G_{\mathrm{b}}}\lparen x_{6}\rparen\right\rvert=n, |ΓGb(x1)ΓGb(x2)|=s\left\lvert\Gamma_{G_{\mathrm{b}}}\lparen x_{1}\rparen\cap\Gamma_{G_{\mathrm{b}}}\lparen x_{2}\rparen\right\rvert=s, |ΓGb(x3)ΓGb(x4)|=t\left\lvert\Gamma_{G_{\mathrm{b}}}\lparen x_{3}\rparen\cap\Gamma_{G_{\mathrm{b}}}\lparen x_{4}\rparen\right\rvert=t, which implies, with point 2, that x5x_{5} and x6x_{6} do not belong to all butterflies in GbG_{\mathrm{b}}.

Figure 2 shows the bipartite graphs generated for s=2s=2 and t=3t=3.

III Discussion

MCMC approaches based on swaps of pairs of edges can efficiently sample graphs from simple ensembles, such as those including graphs with prescribed degree sequences, or fixed number of paths of length up to three [11]. The correctness of these approaches relies on the fact that pairwise edge swaps create a strongly connected state space. They are efficient because proposing a neighbor to move to is relatively easy, requiring only to be able to efficiently sample pairs of edges.

In the case of ensembles preserving more complex properties of the networks, the strong connectivity of the state space may require more than two edges to be swapped at every step, i.e., performing qq-switches [24], or qq-BSOs, for some value of qq.

In this work, we consider the ensemble of bipartite graphs with fixed degree sequences and fixed number of butterflies (k2,2k_{2,2} bi-cliques), for its important role in a variety of applications, e.g., investigating clustering patterns [21]. We show that the state space is not strongly connected by sequences of qq-BSOs for any fixed, universal, constant qq. In other words, the number of edges to be rewired at each step is upper bounded by a quantity that depends on properties of the graphs in the ensemble. This result is in strong contrast with the cases for the space of bipartite graphs with fixed degree sequences, and for that of bipartite graphs with fixed degree sequences and fixed number of paths of length three (a.k.a. caterpillars), where q=2q=2 is sufficient for all ensembles [11, 31].

This discovery has far-reaching implications for network science. First and foremost, we rule out the possibility of designing efficient MCMC algorithms for sampling from the space of bipartite graphs with fixed degree sequences and fixed number of butterflies, specifically, from the micro-canonical ensemble that maintains these properties exactly. In fact, we demonstrate the necessity of swaps with size dependent on the characteristics of the graph space 𝒢\mathcal{G}, not necessarily just on the observed network. Finding what this size q𝒢q^{*}_{\mathcal{G}} is may not even be feasible. It may perhaps be possible to develop an efficient procedure to find this quantity, but then one also needs an efficient procedure to, at each step of the Markov chain, generate a qq-BSO for qq𝒢q\leq q^{*}_{\mathcal{G}}, to propose a neighbor to move to. Solving both these algorithmic questions seem challenging. Moreover, the lower bound q¯\bar{q} to the size of the BSOs needed to connect the two graphs GbG_{\mathrm{b}} and GeG_{\mathrm{e}} from Thm. 1 gives only a necessary condition for the strong connectivity of the graph space, not a sufficient one: we only know that one of the BSOs to connect these two graphs must contain more than q¯\bar{q} edges, but not how exactly how many. Even if we knew exactly this number q^\hat{q}, there may be other pairs of graphs in the same ensemble (i.e., with the same degree sequences and number of butterflies) such that any sequence of BSOs connecting these two graphs must have size even greater than q^\hat{q}. Therefore the situation might be even more dire than our findings suggest.

Given that sampling from a null model that preserves the number of butterflies is impractical, preserving larger structures seems an even more unattainable task. A butterfly is at the same time the smallest cycle and the smallest non-trivial bi-clique, hence it is a basic building block of bipartite graphs. Thus, our findings present a large obstacle to developing efficient algorithms to sample from more complex ensembles, and therefore to testing network properties under more descriptive null models.

What other options are then available, if any? If one wishes to maintain the number of butterflies as a hard constraint (i.e., to sample from the micro-canonical ensemble), one potential approach involves avoiding MCMC algorithms and opting for a direct-sampling algorithm like stub matching [33]. However, such algorithms are already limited to small graph instances, for the case of sampling from the space of graphs with the same degree sequence, due to their complexity scaling quadratically or cubically with the number of nodes, depending on the graph density [34, 35]. The straightforward application of existing stub-matching techniques may also suffer from generating graphs with a different number of butterflies, thus leading to a high rejection rate. Thus, we need to explore alternative methodologies or refine existing stub-matching algorithms to better accommodate these more complex constraints. Finally, implementations of canonical methods such as the Chung-Lu model [36] offer a more efficient alternative, albeit at the cost of imposing a soft constraint. Indeed, while the ensemble average aligns precisely with the desired value of each constraint, individual graph instances may lie far from the desired constraints. The canonical ensemble brings other challenges, including difficulties in generating graphs that closely match the desired expectations for certain degree distributions (degeneracy problem) [37, 38, 39, 40, 41].

Overall, our findings represent a strong negative result that the network science community needs to reckon with. By showing that this research avenue is not fruitful, we hope to spur alternative and innovative approaches to designing null models for graphs, and algorithms for sampling from them.

Acknowledgments. MR’s work was sponsored in part by NSF grants IIS-2006765 and CAREER-2238693.

References

  • Newman [2003] M. E. Newman, SIAM review 45, 167 (2003).
  • Fosdick et al. [2018] B. K. Fosdick, D. B. Larremore, J. Nishimura, and J. Ugander, Siam Review 60, 315 (2018).
  • Cimini et al. [2019] G. Cimini, T. Squartini, F. Saracco, D. Garlaschelli, A. Gabrielli, and G. Caldarelli, Nature Reviews Physics 1, 58 (2019).
  • Stanton and Pinar [2012] I. Stanton and A. Pinar, Journal of Experimental Algorithmics (JEA) 17, 3 (2012).
  • Mahadevan et al. [2006] P. Mahadevan, D. Krioukov, K. Fall, and A. Vahdat, ACM SIGCOMM Computer Communication Review 36, 135 (2006).
  • Orsini et al. [2015] C. Orsini, M. M. Dankulov, P. Colomer-de Simón, A. Jamakovic, P. Mahadevan, A. Vahdat, K. E. Bassler, Z. Toroczkai, M. Boguná, G. Caldarelli, et al., Nature communications 6, 8627 (2015).
  • Bassler et al. [2015] K. E. Bassler, C. I. Del Genio, P. L. Erdős, I. Miklós, and Z. Toroczkai, New Journal of Physics 17, 083052 (2015).
  • Van Koevering et al. [2021] K. Van Koevering, A. Benson, and J. Kleinberg, in The Web Conference 2021 (2021) pp. 367–378.
  • Newman [2009] M. E. Newman, Physical review letters 103, 058701 (2009).
  • Zha et al. [2001] H. Zha, X. He, C. Ding, H. Simon, and M. Gu, in CIKM (2001) pp. 25–32.
  • Preti et al. [2022] G. Preti, G. de Francisci Morales, and M. Riondato, in ICDM (IEEE, 2022) pp. 418–427.
  • Berge [1970] C. Berge, in Combinatorial Theory and its Applications I, Colloquia Mathematica Societatis János Bolyai, Vol. 4 (1970) pp. 119–133.
  • Saracco et al. [2015] F. Saracco, R. Di Clemente, A. Gabrielli, and T. Squartini, Scientific reports 5, 1 (2015).
  • Neal et al. [2023] Z. Neal, A. Cadieux, D. Garlaschelli, N. J. Gotelli, F. Saracco, T. Squartini, S. T. Shutters, W. Ulrich, G. Wang, and G. Strona (2023), arXiv 2310.01284.
  • Ryser [1963] H. J. Ryser, Combinatorial mathematics, Vol. 14 (American Mathematical Soc., 1963).
  • Carstens [2015] C. J. Carstens, Physical Review E 91, 042812 (2015).
  • Verhelst [2008] N. D. Verhelst, Psychometrika 73, 705 (2008).
  • Wang [2020] G. Wang, Electronic Journal of Statistics 14, 1690 (2020).
  • Kannan et al. [1999] R. Kannan, P. Tetali, and S. Vempala, Random Structures & Algorithms 14, 293 (1999).
  • Strona et al. [2014] G. Strona, D. Nappo, F. Boccacci, S. Fattorini, and J. San-Miguel-Ayanz, Nature communications 5, 1 (2014).
  • Nishimura [2017] J. Nishimura, arXiv preprint arXiv:1704.01951  (2017).
  • Cafieri et al. [2010] S. Cafieri, P. Hansen, and L. Liberti, Physical Review E 81, 046102 (2010).
  • Artzy-Randrup and Stone [2005] Y. Artzy-Randrup and L. Stone, Physical Review E 72, 056708 (2005).
  • Tabourier et al. [2011] L. Tabourier, C. Roth, and J.-P. Cointet, ACM Journal of Experimental Algorithmics 16, 7:1 (2011).
  • [25] See Supplemental Material at URL-will-be-inserted-by-publisher for proofs and algorithmic details.
  • Chen et al. [2005] Y. Chen, P. Diaconis, S. P. Holmes, and J. S. Liu, Journal of the American Statistical Association 100, 109 (2005).
  • Miller and Harrison [2013] J. W. Miller and M. T. Harrison, The Annals of Statistics 4110.1214/13-aos1131 (2013).
  • Holmes and Jones [1996] R. Holmes and L. Jones, The Annals of Statistics , 64 (1996).
  • Miklós and Podani [2004] I. Miklós and J. Podani, Ecology 85, 86 (2004).
  • Snijders [1991] T. A. Snijders, Psychometrika 56, 397 (1991).
  • Czabarka et al. [2015] É. Czabarka, A. Dutle, P. L. Erdős, and I. Miklós, Discrete Applied Mathematics 181, 283 (2015).
  • Robins et al. [2007] G. Robins, P. Pattison, Y. Kalish, and D. Lusher, Social networks 29, 173 (2007).
  • Bollobás [1980] B. Bollobás, European Journal of Combinatorics 1, 311 (1980).
  • Erdős et al. [2009] P. L. Erdős, I. Miklós, and Z. Toroczkai, arXiv preprint arXiv:0905.4913  (2009).
  • Kim et al. [2012] H. Kim, C. I. Del Genio, K. E. Bassler, and Z. Toroczkai, New Journal of Physics 14, 023012 (2012).
  • Chung and Lu [2002] F. Chung and L. Lu, Proceedings of the National Academy of Sciences 99, 15879 (2002).
  • Squartini and Garlaschelli [2011] T. Squartini and D. Garlaschelli, New Journal of Physics 13, 083001 (2011).
  • Squartini et al. [2015] T. Squartini, R. Mastrandrea, and D. Garlaschelli, New Journal of Physics 17, 023052 (2015).
  • Brissette and Slota [2022] C. Brissette and G. Slota, in Proceedings of the Tenth International Conference on Complex Networks and Their Applications (Springer, 2022) pp. 451–462.
  • Snijders et al. [2006] T. A. Snijders, P. E. Pattison, G. L. Robins, and M. S. Handcock, Sociological methodology 36, 99 (2006).
  • Vallarano et al. [2021] N. Vallarano, M. Bruno, E. Marchese, G. Trapani, F. Saracco, G. Cimini, M. Zanon, and T. Squartini, Scientific Reports 1110.1038/s41598-021-93830-4 (2021).

Appendix A Proofs

Our main result, Theorem 1, relies on the following lemma.

Lemma 1.

For any bipartite graph G(L,R,E)G\doteq(L,R,E) with 𝖽G(a)2\mathsf{d}_{G}\lparen a\rparen\leq 2, for each aRa\in R, and any uLu\in L, it holds

𝖻G(u)(𝖽G(u)2),\mathsf{b}_{G}\lparen u\rparen\leq\binom{\mathsf{d}_{G}\lparen u\rparen}{2},

with equality if and only if there exists vL{u}v\in L\setminus\{u\}, s.t. ΓG(u)ΓG(v)\Gamma_{G}\lparen u\rparen\subseteq\Gamma_{G}\lparen v\rparen.

The meaning of this Lemma is that, when all nodes in RR have degree at most 2 , each node uLu\in L can be part of at most one butterfly for each unordered pair (w,z)(w,z) of uu’s neighbors. Specifically, if either ww or vv has degree 11, then there can be no butterfly involving uu, ww, zz and another node in LL. If both ww and zz have degree 22, there may be at most one butterfly involving uu, ww, zz and another node in LL. If any node in RR has degree d>2d>2, a pair of neighbors of uLu\in L could be part of more than one butterfly together with uu (at most d1d-1).

We use the following technical lemma in the proof of Lemma 1.

Lemma 2.

Let dd\in\mathbb{N}, d2d\geq 2. For any sequence a1,,aza_{1},\dotsc,a_{z} of 1<zd1<z\leq d strictly positive naturals s.t. i=1zaid\sum_{i=1}^{z}a_{i}\leq d, it holds

(d2)>i=1z(ai2).\binom{d}{2}>\sum_{i=1}^{z}\binom{a_{i}}{2}\enspace.
Proof.

Assume by contradiction that there exists a sequence a1,,aza_{1},\dotsc,a_{z} of 1<zd1<z\leq d strictly positive naturals s.t. i=1zaid\sum_{i=1}^{z}a_{i}\leq d and for which

(d2)i=1z(ai2)=12i=1z(ai2ai).\binom{d}{2}\leq\sum_{i=1}^{z}\binom{a_{i}}{2}=\frac{1}{2}\sum_{i=1}^{z}(a_{i}^{2}-a_{i})\enspace. (3)

It holds

2(d2)=d2d(i=1zai)2i=1zai,2\binom{d}{2}=d^{2}-d\geq{\left(\sum_{i=1}^{z}a_{i}\right)}^{2}-\sum_{i=1}^{z}a_{i},

where the inequality comes from the fact that q2qg2gq^{2}-q\geq g^{2}-g for any q1q\geq 1, 0gq0\leq g\leq q. Expanding the r.h.s. of the last inequality, we obtain

2(d2)\displaystyle 2\binom{d}{2} i=1zai2+2i=1zh=i+1zaiahi=1zai\displaystyle\geq\sum_{i=1}^{z}a_{i}^{2}+2\sum_{i=1}^{z}\sum_{h=i+1}^{z}a_{i}a_{h}-\sum_{i=1}^{z}a_{i}
=i=1z(ai2ai)+2i=1zh=i+1zaiah.\displaystyle=\sum_{i=1}^{z}(a_{i}^{2}-a_{i})+2\sum_{i=1}^{z}\sum_{h=i+1}^{z}a_{i}a_{h}\enspace. (4)

We can combine (3) and (4) as

i=1z(ai2ai)+2i=1zh=i+1zaiah2(d2)i=1z(ai2ai),\sum_{i=1}^{z}(a_{i}^{2}-a_{i})+2\sum_{i=1}^{z}\sum_{h=i+1}^{z}a_{i}a_{h}\leq 2\binom{d}{2}\leq\sum_{i=1}^{z}(a_{i}^{2}-a_{i}),

which is clearly impossible because the aia_{i}’s are strictly positive, thus the second term on the leftmost side is strictly positive. Thus we reached a contradiction, and the sequence a1,,aza_{1},\dotsc,a_{z} cannot exists. ∎

Proof of Lemma 1.

We start by showing that if vv as in the thesis exists, then 𝖻G(u)=(𝖽G(u)2)\mathsf{b}_{G}\lparen u\rparen=\binom{\mathsf{d}_{G}\lparen u\rparen}{2}. Such a vv must be unique, due to the restrictions on the degree of the nodes in RR. It must then hold that ΓG(u)ΓG(w)=\Gamma_{G}\lparen u\rparen\cap\Gamma_{G}\lparen w\rparen=\emptyset for any wL{v,u}w\in L\setminus\{v,u\}, as all aΓG(u)a\in\Gamma_{G}\lparen u\rparen have degree exactly two and {(u,a),(v,a)}E\{(u,a),(v,a)\}\subseteq E. From this fact and Fact 1, we get that 𝖻G(u,w)=0\mathsf{b}_{G}\lparen u,w\rparen=0 for any wL{v,u}w\in L\setminus\{v,u\}, and that 𝖻G(u,v)=(𝖽G(u)2)\mathsf{b}_{G}\lparen u,v\rparen=\binom{\mathsf{d}_{G}\lparen u\rparen}{2}, as |ΓG(u)ΓG(v)|=|ΓG(u)|=𝖽G(u)\left\lvert\Gamma_{G}\lparen u\rparen\cap\Gamma_{G}\lparen v\rparen\right\rvert=\left\lvert\Gamma_{G}\lparen u\rparen\right\rvert=\mathsf{d}_{G}\lparen u\rparen from the hypothesis. The desired equality follows from these facts and the definition of 𝖻G(u)\mathsf{b}_{G}\lparen u\rparen from Equation (1) in the main text.

We now show that if vv as in the thesis does not exists, it must be 𝖻G(u)<(𝖽G(u)2)\mathsf{b}_{G}\lparen u\rparen<\binom{\mathsf{d}_{G}\lparen u\rparen}{2}. Assume that there is exactly one vL{u}v^{\prime}\in L\setminus\{u\} s.t. ΓG(u)ΓG(v)\Gamma_{G}\lparen u\rparen\cap\Gamma_{G}\lparen v^{\prime}\rparen\neq\emptyset. Then it must be |ΓG(u)ΓG(v)|<𝖽G(u)\left\lvert\Gamma_{G}\lparen u\rparen\cap\Gamma_{G}\lparen v^{\prime}\rparen\right\rvert<\mathsf{d}_{G}\lparen u\rparen, otherwise vv^{\prime} would be as vv in the thesis, which we just said can not happen. Then, from Fact 1, we get 𝖻G(u,v)<(𝖽G(u)2)\mathsf{b}_{G}\lparen u,v^{\prime}\rparen<\binom{\mathsf{d}_{G}\lparen u\rparen}{2}. From this fact, the fact that 𝖻G(u,w)=0\mathsf{b}_{G}\lparen u,w\rparen=0 for any wL{v,u}w\in L\setminus\{v^{\prime},u\}, and Eq. (1) from the text, we obtain the desired result.

Assume instead that there are 1<zd1<z\leq d distinct nodes v1,,vzL{u}v_{1},\dotsc,v_{z}\in L\setminus\{u\} s.t. ΓG(u)ΓG(vi)\Gamma_{G}\lparen u\rparen\cap\Gamma_{G}\lparen v_{i}\rparen\neq\emptyset. The desired result 𝖻G(u)<(𝖽G(u)2)\mathsf{b}_{G}\lparen u\rparen<\binom{\mathsf{d}_{G}\lparen u\rparen}{2} follows from Lemma 2 using ai=|ΓG(u)ΓG(vi)|a_{i}=\left\lvert\Gamma_{G}\lparen u\rparen\cap\Gamma_{G}\lparen v_{i}\rparen\right\rvert, 1iz1\leq i\leq z. ∎

Proof of Theorem 1.

Let GbG_{\mathrm{b}} and GeG_{\mathrm{e}} be the graphs output by Alg. 1 with inputs ss and tt. For completeness, let us recall the five properties satisfied by such graphs.

  1. 1.

    GbG_{\mathrm{b}} and GeG_{\mathrm{e}} have 7+a7+a left nodes (denoted with the letter xx) and s+t+n+2+as+t+n+2+a right nodes (denoted with the letter yy);

  2. 2.

    GbG_{\mathrm{b}} and GeG_{\mathrm{e}} have the same left and right degree sequences. In particular, x1x_{1} and x2x_{2} have degree ss, x3x_{3} and x4x_{4} have degree tt, x5x_{5} and x6x_{6} have degree n+1n+1, yiy_{i} has degree 2 for 1is+t+n+11\leq i\leq s+t+n+1, and all the other left and right nodes have degree 11;

  3. 3.

    𝖻(Gb)=𝖻(Ge)=n+(n2)\mathsf{b}\lparen G_{\mathrm{b}}\rparen=\mathsf{b}\lparen G_{\mathrm{e}}\rparen=n+\binom{n}{2};

  4. 4.

    |ΓGe(x5)ΓGe(x6)|=n+1\left\lvert\Gamma_{G_{\mathrm{e}}}\lparen x_{5}\rparen\cap\Gamma_{G_{\mathrm{e}}}\lparen x_{6}\rparen\right\rvert=n+1, which, with the previous point, implies that x5x_{5} and x6x_{6} belong to all butterflies in GeG_{\mathrm{e}}, and every other node yRy\in R belongs to no butterfly;

  5. 5.

    |ΓGb(x5)ΓGb(x6)|=n\left\lvert\Gamma_{G_{\mathrm{b}}}\lparen x_{5}\rparen\cap\Gamma_{G_{\mathrm{b}}}\lparen x_{6}\rparen\right\rvert=n, |ΓGb(x1)ΓGb(x2)|=s\left\lvert\Gamma_{G_{\mathrm{b}}}\lparen x_{1}\rparen\cap\Gamma_{G_{\mathrm{b}}}\lparen x_{2}\rparen\right\rvert=s, |ΓGb(x3)ΓGb(x4)|=t\left\lvert\Gamma_{G_{\mathrm{b}}}\lparen x_{3}\rparen\cap\Gamma_{G_{\mathrm{b}}}\lparen x_{4}\rparen\right\rvert=t, which implies, with point 2, that x5x_{5} and x6x_{6} do not belong to all butterflies in GbG_{\mathrm{b}}.

For each i[1,z]i\in[1,z], we denote with GiG^{i} the graph obtained from the application of 𝗌𝗐1p1,,𝗌𝗐ipi\mathsf{sw}^{p_{1}}_{1},\dotsc,\mathsf{sw}^{p_{i}}_{i} to GbG_{\mathrm{b}}. By definition of qq-BSO, each GiG^{i} has the same left and right degree sequences, and 𝖻(Gi)=𝖻(Gb)=𝖻(Ge)\mathsf{b}\lparen G^{i}\rparen=\mathsf{b}\lparen G_{\mathrm{b}}\rparen=\mathsf{b}\lparen G_{\mathrm{e}}\rparen. We set G0=GbG^{0}=G_{\mathrm{b}}.

From properties 4 and 5 of GbG_{\mathrm{b}} and GeG_{\mathrm{e}} listed above, there must be an index [1,z]\ell\in[1,z] s.t. in the graph GG^{\ell}, x5x_{5} and x6x_{6} share n+1n+1 neighbors. We now show that x5x_{5} and x6x_{6} must share exactly nn neighbors in G1G^{\ell-1}, i.e., |ΓG1(x5)ΓG1(x6)|=n\left\lvert\Gamma_{G^{\ell-1}}\lparen x_{5}\rparen\cap\Gamma_{G^{\ell-1}}\lparen x_{6}\rparen\right\rvert=n.

Assume by contradiction that |ΓG1(x5)ΓG1(x6)|\left\lvert\Gamma_{G^{\ell-1}}\lparen x_{5}\rparen\cap\Gamma_{G^{\ell-1}}\lparen x_{6}\rparen\right\rvert == r<nr<n. Then, 𝖻G1(x5,x6)=(r2)\mathsf{b}_{G^{\ell-1}}\lparen x_{5},x_{6}\rparen=\binom{r}{2}. From Equation (2) in the main text, given the degree sequence of the nodes in LL, we can write

𝖻(G1)=i=15j=i+16𝖻G1(xi,xj)=n+(n2).\mathsf{b}\lparen G^{\ell-1}\rparen=\sum_{i=1}^{5}\sum_{j=i+1}^{6}\mathsf{b}_{G^{\ell-1}}\lparen x_{i},x_{j}\rparen=n+\binom{n}{2}\enspace. (5)

It then must be

i=14j=i+16𝖻G1(xi,xj)=n+(n2)(r2).\sum_{i=1}^{4}\sum_{j=i+1}^{6}\mathsf{b}_{G^{\ell-1}}\lparen x_{i},x_{j}\rparen=n+\binom{n}{2}-\binom{r}{2}\enspace. (6)

It holds

i=14j=i+16𝖻G1(xi,xj)i=14𝖻G1(i),\sum_{i=1}^{4}\sum_{j=i+1}^{6}\mathsf{b}_{G^{\ell-1}}\lparen x_{i},x_{j}\rparen\leq\sum_{i=1}^{4}\mathsf{b}_{G^{\ell-1}}\lparen i\rparen,

as some butterflies may be counted twice in the sum on the r.h.s.. From Lemma 1 applied to each of x1x_{1}, x2x_{2}, x3x_{3}, and x4x_{4}, it holds that

i=14𝖻G1(i)2(s2)+2(t2)=2n.\sum_{i=1}^{4}\mathsf{b}_{G^{\ell-1}}\lparen i\rparen\leq 2\binom{s}{2}+2\binom{t}{2}=2n\enspace. (7)

Consider for now the case r<n1r<n-1. If we can show that

2n<n+(n2)(r2)2n<n+\binom{n}{2}-\binom{r}{2} (8)

then we would have reached a contradiction, because this inequality, together with Eq. 7, implies that Eq. 6 cannot be true. The r.h.s. of Eq. 8 decreases as rr increases, so if we can show that Eq. 8 holds for the maximum value of r=n2r=n-2, then it would hold for all rn2r\leq n-2. For r=n2r=n-2, we can rewrite Eq. 8 as

2n<n+(n2)(n22),2n<n+\binom{n}{2}-\binom{n-2}{2}, (9)

which is true for any n>3n>3, i.e., for all possible values of ss and tt. Thus we reached a contradiction and it cannot be r<n1r<n-1.

Consider now the case r=n1r=n-1. In this case,

n+(n2)(r2)=2n1.n+\binom{n}{2}-\binom{r}{2}=2n-1\enspace.

Using this fact and Eq. 6, we can write

2n1=i=13j=i+14𝖻G1(xi,xj)+i=14(𝖻G1(xi,x5)+𝖻G1(xi,x6)).\begin{split}2n-1=\sum_{i=1}^{3}\sum_{j=i+1}^{4}\mathsf{b}_{G^{\ell-1}}\lparen x_{i},x_{j}\rparen&+\\ \sum_{i=1}^{4}\left(\mathsf{b}_{G^{\ell-1}}\lparen x_{i},x_{5}\rparen\right.&+\left.\mathsf{b}_{G^{\ell-1}}\lparen x_{i},x_{6}\rparen\right).\end{split} (10)

Now, since r=n1r=n-1 and 𝖽G1(x5)=𝖽G1(x6)=n+1\mathsf{d}_{G^{\ell-1}}\lparen x_{5}\rparen=\mathsf{d}_{G^{\ell-1}}\lparen x_{6}\rparen=n+1, it must hold

i=14(𝖻G1(xi,x5)+𝖻G1(xi,x6))2\sum_{i=1}^{4}\left(\mathsf{b}_{G^{\ell-1}}\lparen x_{i},x_{5}\rparen+\mathsf{b}_{G^{\ell-1}}\lparen x_{i},x_{6}\rparen\right)\leq 2 (11)

because x5x_{5} and x6x_{6} can share at most two neighbors each in RR with one of x1x_{1}, x2x_{2}, x3x_{3}, and x4x_{4}. Due to the limitations on the degree of the nodes in RR, if any of xix_{i}, i=5,6i=5,6 shares a neighbor with any xjx_{j}, j=1,2,3,4j=1,2,3,4, then xix_{i} cannot share the same neighbor with any other of {x1,x2,x3,x4}{xj}\{x_{1},x_{2},x_{3},x_{4}\}\setminus\{x_{j}\}. Thus, combining Eq. 10 and Eq. 11, we get that

2n1i=13j=i+14𝖻G1(xi,xj)+2.2n-1\leq\sum_{i=1}^{3}\sum_{j=i+1}^{4}\mathsf{b}_{G^{\ell-1}}\lparen x_{i},x_{j}\rparen+2\enspace. (12)

It holds

i=13j=i+14𝖻G1(xi,xj)\displaystyle\sum_{i=1}^{3}\sum_{j=i+1}^{4}\mathsf{b}_{G^{\ell-1}}\lparen x_{i},x_{j}\rparen =12i=14j=1ji4𝖻G1(xi,xj)\displaystyle=\frac{1}{2}\sum_{i=1}^{4}\sum_{\begin{subarray}{c}j=1\\ j\neq i\end{subarray}}^{4}\mathsf{b}_{G^{\ell-1}}\lparen x_{i},x_{j}\rparen
12i=14𝖻G1(xi)n,\displaystyle\leq\frac{1}{2}\sum_{i=1}^{4}\mathsf{b}_{G^{\ell-1}}\lparen x_{i}\rparen\leq n,

where the last inequality comes from Eq. 7. Combining the above with Eq. 12 we obtain

2n1n+22n-1\leq n+2

which is only true for n3n\leq 3. But from our hypothesis on ss and tt, it must be n>3n>3, so we reached a contradiction, and it cannot be r=n1r=n-1.

Thus, it must be |ΓG1(x5)ΓG1(x6)|=n\left\lvert\Gamma_{G^{\ell-1}}\lparen x_{5}\rparen\cap\Gamma_{G^{\ell-1}}\lparen x_{6}\rparen\right\rvert=n, i.e., 𝖻G1(x5,x6)=(n2)\mathsf{b}_{G^{\ell-1}}\lparen x_{5},x_{6}\rparen=\binom{n}{2}. We now show that the remaining n=(s2)+(t2)n=\binom{s}{2}+\binom{t}{2} butterflies in G1G^{\ell-1} are s.t. x1x_{1} and x2x_{2} both belong to (s2)\binom{s}{2} of them, and x3x_{3} and x4x_{4} both belong to (t2)\binom{t}{2} of them. In other words 𝖻G1(x1,x2)=(s2)\mathsf{b}_{G^{\ell-1}}\lparen x_{1},x_{2}\rparen=\binom{s}{2}, 𝖻G1(x3,x4)=(t2)\mathsf{b}_{G^{\ell-1}}\lparen x_{3},x_{4}\rparen=\binom{t}{2}, and 𝖻G1(xi,xj)=0\mathsf{b}_{G^{\ell-1}}\lparen x_{i},x_{j}\rparen=0 for any other (i,j){(i,j):1i4,i<j6}{(1,2),(3,4)}(i,j)\in\{(i,j)\mathrel{:}1\leq i\leq 4,i<j\leq 6\}\setminus\{(1,2),(3,4)\}.

Clearly, it must hold 𝖻G1(xi,x5)=𝖻G1(xi,x6)=0\mathsf{b}_{G^{\ell-1}}\lparen x_{i},x_{5}\rparen=\mathsf{b}_{G^{\ell-1}}\lparen x_{i},x_{6}\rparen=0 because x5x_{5} and x6x_{6} can each at most share one neighbor with any of xix_{i}, 1i41\leq i\leq 4, which is not sufficient to obtain any butterfly to which both xix_{i} and x5x_{5} or both xix_{i} and x6x_{6} may belong. Thus, it must hold

i=13j=i+14𝖻G1(xi,xj)=n.\sum_{i=1}^{3}\sum_{j=i+1}^{4}\mathsf{b}_{G^{\ell-1}}\lparen x_{i},x_{j}\rparen=n\enspace.

We also have

i=13j=i+14𝖻G1(xi,xj)=12i=14𝖻G1(xi)n,\sum_{i=1}^{3}\sum_{j=i+1}^{4}\mathsf{b}_{G^{\ell-1}}\lparen x_{i},x_{j}\rparen=\frac{1}{2}\sum_{i=1}^{4}\mathsf{b}_{G^{\ell-1}}\lparen x_{i}\rparen\leq n,

where the last inequality comes from Eq. 7. To obtain equality, it must hold

i=14𝖻G1(xi)=2(s2)+2(t2).\sum_{i=1}^{4}\mathsf{b}_{G^{\ell-1}}\lparen x_{i}\rparen=2\binom{s}{2}+2\binom{t}{2}\enspace.

From Lemma 1, we have that

𝖻G1(xi){(s2)ifi=1,2(t2)ifi=3,4,\mathsf{b}_{G^{\ell-1}}\lparen x_{i}\rparen\leq\left\{\begin{array}[]{ll}\displaystyle\binom{s}{2}&\text{if}\ i=1,2\\ \\ \displaystyle\binom{t}{2}&\text{if}\ i=3,4\end{array}\right.,

with equality only if each of x1x_{1}, x2x_{2}, x3x_{3}, and x4x_{4} shares all its neighbors with another one of them. Thus, it must be that x1x_{1} shares all its neighbors with x2x_{2}, and that x3x_{3} shares all its neighbors with x4x_{4}, leading to the desired results that 𝖻G1(x1,x2)=(s2)\mathsf{b}_{G^{\ell-1}}\lparen x_{1},x_{2}\rparen=\binom{s}{2}, 𝖻G1(x3,x4)=(t2)\mathsf{b}_{G^{\ell-1}}\lparen x_{3},x_{4}\rparen=\binom{t}{2}, 𝖻G1(x5,x6)=(n2)\mathsf{b}_{G^{\ell-1}}\lparen x_{5},x_{6}\rparen=\binom{n}{2}, and 𝖻G1(xi,xj)=0\mathsf{b}_{G^{\ell-1}}\lparen x_{i},x_{j}\rparen=0 for any other (i,j){(i,j):1i5,i<j6}{(1,2),(3,4),(5,6)}(i,j)\in\{(i,j)\mathrel{:}1\leq i\leq 5,i<j\leq 6\}\setminus\{(1,2),(3,4),(5,6)\}.

At step \ell, the number of common neighbors between x5x_{5} and x6x_{6} increases to n+1n+1, meaning that the number of butterflies involving the pair (x5,x6)(x_{5},x_{6}) increases by (n+12)(n2)=n\binom{n+1}{2}-\binom{n}{2}=n. Since n=(s2)+(t2)n=\binom{s}{2}+\binom{t}{2}, the pp_{\ell}-BSO 𝗌𝗐p(S,σ)\mathsf{sw}^{p_{\ell}}_{\ell}\doteq(S_{\ell},\sigma) must transform all the butterflies in G1G^{\ell-1} to which x5x_{5} and x6x_{6} do not already belong, into an equal number of butterflies in GG^{\ell} to which both x5x_{5} and x6x_{6} belong.

To this end, 𝗌𝗐p\mathsf{sw}^{p_{\ell}}_{\ell} must swap at least

  • \bullet

    11 edge involving x5x_{5} (or x6x_{6}) to connect x5x_{5} (or x6)x_{6}) to a node in ΓG1(x6)ΓG1(x5)\Gamma_{G^{\ell-1}}\lparen x_{6}\rparen\setminus\Gamma_{G^{\ell-1}}\lparen x_{5}\rparen (or in ΓG1(x5)ΓG1(x6)\Gamma_{G^{\ell-1}}\lparen x_{5}\rparen\setminus\Gamma_{G^{\ell-1}}\lparen x_{6}\rparen): this way, |ΓG1(x5)ΓG1(x6)|=n+1\left\lvert\Gamma_{G^{\ell-1}}\lparen x_{5}\rparen\cap\Gamma_{G^{\ell-1}}\lparen x_{6}\rparen\right\rvert=n+1, i.e., x5x_{5} and x6x_{6} will share n+1n+1 neighbors in GG^{\ell};

  • \bullet

    s1s-1 edges involving either x1x_{1} or x2x_{2} to reduce the number of neighbors shared by these two nodes by at least s1s-1: this way |ΓG(x1)ΓG(x2)|1\left\lvert\Gamma_{G^{\ell}}\lparen x_{1}\rparen\cap\Gamma_{G^{\ell}}\lparen x_{2}\rparen\right\rvert\leq 1, implying 𝖻G(x1,x2)=0\mathsf{b}_{G^{\ell}}\lparen x_{1},x_{2}\rparen=0; and

  • \bullet

    t1t-1 edges involving either x3x_{3} or x4x_{4} to reduce the number of neighbors shared by these two nodes by at least t1t-1: this way |ΓG(x3)ΓG(x4)|1\left\lvert\Gamma_{G^{\ell}}\lparen x_{3}\rparen\cap\Gamma_{G^{\ell}}\lparen x_{4}\rparen\right\rvert\leq 1 and thus 𝖻G(x3,x4)=0\mathsf{b}_{G^{\ell}}\lparen x_{3},x_{4}\rparen=0.

Thus, S{(u1,a1),,(up,ap)}S_{\ell}\doteq\{(u_{1},a_{1}),\dotsc,(u_{p_{\ell}},a_{p_{\ell}})\} must have the following properties:

  • \bullet

    SS_{\ell} must contain at least s1s-1 edges (ui,ai)(u_{i},a_{i}) with ui{x1,x2}u_{i}\in\{x_{1},x_{2}\} and s.t. the edge (uσ(i),aσ(i))S(u_{\sigma(i)},a_{\sigma(i)})\in S_{\ell} has uσ(i){x1,x2}u_{\sigma(i)}\notin\{x_{1},x_{2}\}. Indeed if that was not the case, the edge (ui,aσ(i))(u_{i},a_{\sigma(i)}) would already exist in G1G^{\ell-1}, because, as previously discussed, x1x_{1} and x2x_{2} share all their neighbors in G1G^{\ell-1}. Thus, SS_{\ell} must contain, in addition to the s1s-1 edges as above, another s1s-1 edges whose endpoint in LL is neither x1x_{1} nor x2x_{2}. Additionally, of these s1s-1 edges, only at most 44 may have either x3x_{3} or x4x_{4} as endpoint in LL, as if there were more, then there would be xi{x1,x2}x_{i}\in\{x_{1},x_{2}\} and xj{x3,x4}x_{j}\in\{x_{3},x_{4}\} that would share at least two neighbors in GG^{\ell}, and therefore it would be 𝖻G(xi,xj)>0\mathsf{b}_{G^{\ell}}\lparen x_{i},x_{j}\rparen>0, which cannot be. SS_{\ell} is only required to have t1t-1 edges in the form (ui,ai(u_{i},a_{i}) with ui{x3,x4}u_{i}\in\{x_{3},x_{4}\}, thus really only at most min{4,t1}\min\{4,t-1\} can be as above.

  • \bullet

    Similarly, SS_{\ell} must contain at least t1t-1 edges (ui,ai)(u_{i},a_{i}) with ui{x3,x4}u_{i}\in\{x_{3},x_{4}\} and s.t. the edge (uσ(i),aσ(i))S(u_{\sigma(i)},a_{\sigma(i)})\in S_{\ell} has uσ(i){x3,x4}u_{\sigma(i)}\notin\{x_{3},x_{4}\}. Indeed if that was not the case, the edge (ui,aσ(i))(u_{i},a_{\sigma(i)}) would already exist in G1G^{\ell-1}, because, as previously discussed, x3x_{3} and x4x_{4} share all their neighbors in G1G^{\ell-1}; Thus, SS_{\ell} must contain, in addition to the t1t-1 edges as above, another t1t-1 edges whose node in LL is neither x3x_{3} nor x4x_{4}. Additionally, of these t1t-1 edges, only at most min{4,t1}\min\{4,t-1\} may have either x1x_{1} or x2x_{2} as endpoint in LL, as if there were more, then there would be xi{x1,x2}x_{i}\in\{x_{1},x_{2}\} and xj{x3,x4}x_{j}\in\{x_{3},x_{4}\} that would share at least two neighbors in GG^{\ell}, and therefore it would be 𝖻G(xi,xj)>0\mathsf{b}_{G^{\ell}}\lparen x_{i},x_{j}\rparen>0, which cannot be.

Thus, SS_{\ell} must contain at least (2(s1)min(4,t1))+(2(t1)min(4,t1))(2(s-1)-\min(4,t-1))+(2(t-1)-\min(4,t-1)) edges. For any value of tt, this quantity is at least 2(s1)2(s-1). We then have p2(s1)>q¯p_{\ell}\geq 2(s-1)>{\color[rgb]{0,0,0}\bar{q}}, where the last inequality comes from the definition of ss. This fact concludes the proof. ∎

Appendix B Bipartite Graph Generator

We present our algorithm to generate the two bipartite graphs GbG_{\mathrm{b}} and GeG_{\mathrm{e}} used in the proof of our main result.

Input: Naturals ss and tt with st2{\color[rgb]{0,0,0}s\neq t}\geq 2
Output: Two bipartite graphs with the same degree sequences and (n+12)\binom{n+1}{2} butterflies
1 n(s2)+(t2)n\leftarrow\binom{{\color[rgb]{0,0,0}s}}{2}+\binom{{\color[rgb]{0,0,0}t}}{2}; adds+t2\mathrm{add}\leftarrow{\color[rgb]{0,0,0}s+t}-2
2 if  ss is even then addadd+1\mathrm{add}\leftarrow\mathrm{add}+1
3 if  tt is even then addadd+1\mathrm{add}\leftarrow\mathrm{add}+1
4 L[x1,,x7+add]L\leftarrow[x_{1},\dotsc,x_{7+\mathrm{add}}]; R[y1,,ys+t+n+2+add]R\leftarrow[y_{1},\dotsc,y_{{\color[rgb]{0,0,0}s+t}+n+2+\mathrm{add}}]
/* butterflies btw x1x_{1} and x2x_{2} */
5 Eb{(x1,yl),(x2,yl)}E_{\mathrm{b}}\leftarrow\{(x_{1},y_{l}),(x_{2},y_{l})\} for l[1,s]l\in[1,{\color[rgb]{0,0,0}s}]
/* butterflies btw x3x_{3} and x4x_{4} */
6 EbEb{(x3,ys+l),(x4,ys+l)}E_{\mathrm{b}}\leftarrow E_{\mathrm{b}}\cup\{(x_{3},y_{{\color[rgb]{0,0,0}s}+l}),(x_{4},y_{{\color[rgb]{0,0,0}s}+l})\} for l[1,t]l\in[1,{\color[rgb]{0,0,0}t}]
/* butterflies btw x5x_{5} and x6x_{6} */
7 EbEb{(x5,ys+t+l),(x6,ys+t+l)}E_{\mathrm{b}}\leftarrow E_{\mathrm{b}}\cup\{(x_{5},y_{{\color[rgb]{0,0,0}s+t}+l}),(x_{6},y_{{\color[rgb]{0,0,0}s+t}+l})\} for l[1,n]l\in[1,n]
/* x5x_{5} and x6x_{6} have deg n+1n+1; ys+t+n+1y_{{\color[rgb]{0,0,0}s+t}+n+1} has deg 22 */
8 EbEb{(x5,ys+t+n+1),(x6,ys+t+n+2),(x7,ys+t+n+1)}E_{\mathrm{b}}\leftarrow E_{\mathrm{b}}\cup\{(x_{5},y_{{\color[rgb]{0,0,0}s+t}+n+1}),(x_{6},y_{{\color[rgb]{0,0,0}s+t}+n+2}),(x_{7},y_{{\color[rgb]{0,0,0}s+t}+n+1})\}
/* auxiliary isolated edges */
9 EbEb{(x7+l,ys+t+n+2+l)}E_{\mathrm{b}}\leftarrow E_{\mathrm{b}}\cup\{(x_{7+l},y_{{\color[rgb]{0,0,0}s+t}+n+2+l})\} for l[1,add]l\in[1,\mathrm{add}]
/* butterflies btw x5x_{5} and x6x_{6} */
10 Ee{(x5,ys+t+l),(x6,ys+t+l)}E_{\mathrm{e}}\leftarrow\{(x_{5},y_{{\color[rgb]{0,0,0}s+t}+l}),(x_{6},y_{{\color[rgb]{0,0,0}s+t}+l})\} for l[1,n+1]l\in[1,n+1]
/* x1x_{1},x2x_{2},x3x_{3} and x4x_{4} share at most 1 neighbor */
11 EeEe{(x1,y1),(x2,y1),(x3,ys+1),(x4,ys+1)}E_{\mathrm{e}}\leftarrow E_{\mathrm{e}}\cup\{(x_{1},y_{1}),(x_{2},y_{1}),(x_{3},y_{{\color[rgb]{0,0,0}s}+1}),(x_{4},y_{{\color[rgb]{0,0,0}s}+1})\}
12 h1(s1)/2h_{1}\leftarrow\left\lfloor({\color[rgb]{0,0,0}s}-1)/2\right\rfloor; h2(t1)/2h_{2}\leftarrow\left\lfloor({\color[rgb]{0,0,0}t}-1)/2\right\rfloor
/* we split s1{\color[rgb]{0,0,0}s}-1 right nodes btw x1x_{1} and x2x_{2} */
13 EeEe{(x1,y1+l),(x2,y1+h1+l)}E_{\mathrm{e}}\leftarrow E_{\mathrm{e}}\cup\{(x_{1},y_{1+l}),(x_{2},y_{1+h_{1}+l})\} for l[1,h1]l\in[1,h_{1}]
/* we split t1{\color[rgb]{0,0,0}t}-1 right nodes btw x3x_{3} and x4x_{4} */
14 EeEe{(x3,ys+1+l),(x4,ys+1+h2+l)}E_{\mathrm{e}}\leftarrow E_{\mathrm{e}}\cup\{(x_{3},y_{{\color[rgb]{0,0,0}s}+1+l}),(x_{4},y_{{\color[rgb]{0,0,0}s}+1+h_{2}+l})\} for l[1,h2]l\in[1,h_{2}]
/* x1x_{1}, x2x_{2} have deg s{\color[rgb]{0,0,0}s} and x3x_{3}, x4x_{4} have deg t{\color[rgb]{0,0,0}t} */
15 a1s(1+h1)a_{1}\leftarrow{\color[rgb]{0,0,0}s}-(1+h_{1}); a2t(1+h2)a_{2}\leftarrow{\color[rgb]{0,0,0}t}-(1+h_{2})
16 EeEe{(x1,ys+t+n+2+l),(x2,ys+t+n+2+a1+l)}E_{\mathrm{e}}\leftarrow E_{\mathrm{e}}\cup\{(x_{1},y_{{\color[rgb]{0,0,0}s+t}+n+2+l}),(x_{2},y_{{\color[rgb]{0,0,0}s+t}+n+2+a_{1}+l})\} for l[1,a1]l\in[1,a_{1}]
17 EeEe{(x3,ys+t+n+2+2a1+l),(x4,ys+t+n+2+2a1+a2+l)}E_{\mathrm{e}}\leftarrow E_{\mathrm{e}}\cup\{(x_{3},y_{{\color[rgb]{0,0,0}s+t}+n+2+2a_{1}+l}),(x_{4},y_{{\color[rgb]{0,0,0}s+t}+n+2+2a_{1}+a_{2}+l})\} for l[1,a2]l\in[1,a_{2}]
/* x7x_{7} and ys+t+n+2y_{{\color[rgb]{0,0,0}s+t}+n+2} have deg 11 */
18 EeEe{(x7,ys+t+n+2)}E_{\mathrm{e}}\leftarrow E_{\mathrm{e}}\cup\{(x_{7},y_{{\color[rgb]{0,0,0}s+t}+n+2})\}
/* the first (s+t)({\color[rgb]{0,0,0}s+t}) right nodes have deg 22 */
19 EeEe{(x7+l,y1+l)}E_{\mathrm{e}}\leftarrow E_{\mathrm{e}}\cup\{(x_{7+l},y_{1+l})\} for l[1,s1]l\in[1,{\color[rgb]{0,0,0}s}-1]
20 EeEe{(x7+s1+l,ys+1+l)}E_{\mathrm{e}}\leftarrow E_{\mathrm{e}}\cup\{(x_{7+{\color[rgb]{0,0,0}s}-1+l},y_{{\color[rgb]{0,0,0}s}+1+l})\} for l[1,t1]l\in[1,{\color[rgb]{0,0,0}t}-1]
21 add0\mathrm{add}\leftarrow 0
22 if  ss is even then EeEe{(x7+s+t1,ys)}E_{\mathrm{e}}\leftarrow E_{\mathrm{e}}\cup\{(x_{7+{\color[rgb]{0,0,0}s+t}-1},y_{\color[rgb]{0,0,0}s})\}; addadd+1\mathrm{add}\leftarrow\mathrm{add}+1
23 if  tt is even then EeEe{(x7+s+t1+add,ys+t)}E_{\mathrm{e}}\leftarrow E_{\mathrm{e}}\cup\{(x_{7+{\color[rgb]{0,0,0}s+t}-1+\mathrm{add}},y_{{\color[rgb]{0,0,0}s+t}})\}
24 Gb(L,R,Eb)G_{\mathrm{b}}\leftarrow(L,R,E_{\mathrm{b}}); Ge(L,R,Ee)G_{\mathrm{e}}\leftarrow(L,R,E_{\mathrm{e}})
25 return GbG_{\mathrm{b}}, GeG_{\mathrm{e}}
Algorithm 1 Bipartite Graph Constructor

The algorithm (pseudocode in Alg. 1) receives in input two naturals sts,t2{\color[rgb]{0,0,0}s\neq t}\in\mathbb{N}\,\wedge\,{\color[rgb]{0,0,0}s,t}\geq 2, and generates two bipartite Gb=(L,R,Eb)G_{\mathrm{b}}=(L,R,E_{\mathrm{b}}) and Ge=(L,R,Ee)G_{\mathrm{e}}=(L,R,E_{\mathrm{e}}) with the same left and right degree sequence and each with (n+12)\binom{n+1}{2} butterflies, where n=(s2)+(t2)n=\binom{{\color[rgb]{0,0,0}s}}{2}+\binom{{\color[rgb]{0,0,0}t}}{2}.

The algorithm starts with the creation of the set of left nodes LL (any node in this set will be denoted as xwx_{w}, for some ww) and of right nodes RR (any node in this set will be denoted as ywy_{w}, for some ww), equal for both graphs. Then, it populates the edge set EbE_{\mathrm{b}} of GbG_{\mathrm{b}} and the edge set EeE_{\mathrm{e}} of GeG_{\mathrm{e}}. In GbG_{\mathrm{b}}, the butterflies involve three pairs of left nodes: (x1,x2)(x_{1},x_{2}), (x3,x4)(x_{3},x_{4}), and (x5,x6)(x_{5},x_{6}). Nodes x1x_{1} and x2x_{2} have degree ss and share ss neighbors (line 1); nodes x3x_{3} and x4x_{4} have degree tt and share tt neighbors (line 1); and nodes x5x_{5} and x6x_{6} have degree n+1n+1 and share nn neighbors (line 1). In GeG_{\mathrm{e}}, the butterflies involve only the left nodes x5x_{5} and x6x_{6}, which share n+1n+1 neighbors (line 1).

We will construct the two edge sets so that any other pair of left nodes share at most one neighbor. Thus, it hols that 𝖻(Gb)=(s2)+(t2)+(n2)=(n+12)=𝖻(Ge)\mathsf{b}\lparen G_{\mathrm{b}}\rparen=\binom{{\color[rgb]{0,0,0}s}}{2}+\binom{{\color[rgb]{0,0,0}t}}{2}+\binom{n}{2}=\binom{n+1}{2}=\mathsf{b}\lparen G_{\mathrm{e}}\rparen. Nodes x5x_{5} and x6x_{6} have degree n+1n+1 in both graphs, but, so far, in GbG_{\mathrm{b}} we have added only nn edges to them. Similarly, node ys+t+n+1y_{{\color[rgb]{0,0,0}s+t}+n+1} have degree 22 in GeG_{\mathrm{e}}, but, so far, in GbG_{\mathrm{b}} it is connected to only one left node. Therefore, we insert in EbE_{\mathrm{b}} one edge involving x5x_{5}, one edge involving x6x_{6} (we connect them to different right nodes to avoid creating other butterflies between them), and one edge involving ys+t+n+1y_{{\color[rgb]{0,0,0}s+t}+n+1} (line 1). The construction of EbE_{\mathrm{b}} is completed the addition of up to s+ts+t isolated edges, i.e., edges not connected with any other edge (line 1). These edges do not participate in any butterfly, because they involve nodes with degree 11. They are needed to guarantee that GbG_{\mathrm{b}} and GeG_{\mathrm{e}} have the same degree sequences, as it will become evident as we outline the other edges included in EeE_{\mathrm{e}}.

We add edges to EeE_{\mathrm{e}} in such a way that the pairs of vertices (x1,x2)(x_{1},x_{2}) and (x3,x4)(x_{3},x_{4}) have no more than one neighbor in common, so they do not belong to any butterfly. The idea is to (i) connect both x1x_{1} and x2x_{2} to y1y_{1} (line 1), (ii) divide the remaining nodes to which x1x_{1} is connected in GbG_{\mathrm{b}} into two groups (y2,,yh1)(y_{2},\dotsc,y_{h_{1}}) and (yh1+1,,y2h1+1)(y_{h_{1}+1},\dotsc,y_{2h_{1}+1}) with h1=(s1)/2h_{1}=\left\lfloor({\color[rgb]{0,0,0}s}-1)/2\right\rfloor, and (iii) insert into EeE_{\mathrm{e}} one edge between x1x_{1} and each node in the first group, and one edge between x2x_{2} and each node in the second group (line 1). Similarly, to ensure that x3x_{3} and x4x_{4} only have one neighbor in common, we (i) connect both x3x_{3} and x4x_{4} to ys+1y_{{\color[rgb]{0,0,0}s}+1} (line 1), (ii) divide the remaining nodes to which x3x_{3} is connected in GbG_{\mathrm{b}} into two groups (ys+2,,ys+2+h2)(y_{{\color[rgb]{0,0,0}s}+2},\dotsc,y_{{\color[rgb]{0,0,0}s}+2+h_{2}}) and (ys+3+h2,,ys+1+2h2)(y_{{\color[rgb]{0,0,0}s}+3+h_{2}},\dotsc,y_{{\color[rgb]{0,0,0}s}+1+2h_{2}}) with h2=(t1)/2h_{2}=\left\lfloor({\color[rgb]{0,0,0}t}-1)/2\right\rfloor, and (iii) insert into EeE_{\mathrm{e}} one edge between x3x_{3} and each node in the first group, and one edge between x4x_{4} and each node in the second group (line 1). So far, in EeE_{\mathrm{e}} we have added only (1+h1)(1+h_{1}) of the ss neighbors that x1x_{1} and x2x_{2} must have, and only (1+h2)(1+h_{2}) of the tt neighbors that x3x_{3} and x4x_{4} must have. Thus, we include s(1+h1){\color[rgb]{0,0,0}s}-(1+h_{1}) edges to different right nodes (to avoid creating butterflies between them) for x1x_{1} and x2x_{2} (line 1), and t(1+h2){\color[rgb]{0,0,0}t}-(1+h_{2}) edges to different right nodes for x3x_{3} and x4x_{4} (line 1). Similarly, so far we have added only one edge to the right nodes y2,,ys1,ys+2,,ys+t1y_{2},\dotsc,y_{{\color[rgb]{0,0,0}s}-1},y_{{\color[rgb]{0,0,0}s}+2},\dotsc,y_{{\color[rgb]{0,0,0}s+t}-1}, and up to one edge to the right nodes ysy_{\color[rgb]{0,0,0}s} and ys+ty_{{\color[rgb]{0,0,0}s+t}}. In fact, depending on the value of h1h_{1} and h2h_{2}, such nodes are included/excluded from the group of nodes connected to x2x_{2} and x4x_{4}, respectively. Since all these nodes have degree 22 in GbG_{\mathrm{b}}, we add the missing edges to EeE_{\mathrm{e}} (lines 11). Lastly, nodes x7x_{7} and ys+t+n+2y_{{\color[rgb]{0,0,0}s+t}+n+2} have degree 11 in GbG_{\mathrm{b}}, and thus they must be connected to one neighbor also in GeG_{\mathrm{e}} (line 1). Finally, the two graphs Gb(L,R,Eb)G_{\mathrm{b}}\doteq(L,R,E_{\mathrm{b}}) and Ge(L,R,Ee)G_{\mathrm{e}}\doteq(L,R,E_{\mathrm{e}}) are returned.

Appendix C Connecting Arbitrary Bipartite Graphs in the State Space via qq-BSO

This section shows how to build a qq-BSO that transforms an arbitrary bipartite graph G(L,R,E)G^{\prime}\doteq(L,R,E^{\prime}) into another arbitrary graph G′′(L,R,E′′)G^{\prime\prime}\doteq(L,R,E^{\prime\prime}) with the same left and right degree sequences and number of butterflies. The qq-BSO needs to swap all links except those that are in common between the two graphs, i.e., q=|EE′′|q=\lvert E^{\prime}\setminus E^{\prime\prime}\rvert. Let EE′′=e1,,ec=e1′′,,ec′′E^{\prime}\cap E^{\prime\prime}=\langle e^{\prime}_{1},\dotsc,e^{\prime}_{c}\rangle=\langle e^{\prime\prime}_{1},\dotsc,e^{\prime\prime}_{c}\rangle be the list of cc edges in common to the two graphs, E=e1,,e|E|E^{\prime}=\langle e^{\prime}_{1},\dotsc,e^{\prime}_{\left\lvert E^{\prime}\right\rvert}\rangle the list of edges of GG^{\prime}, E′′=e1′′,,e|E|′′E^{\prime\prime}=\langle e^{\prime\prime}_{1},\dotsc,e^{\prime\prime}_{\left\lvert E^{\prime}\right\rvert}\rangle the list of edges of G′′G^{\prime\prime}, and q=|E|cq=\left\lvert E^{\prime}\right\rvert-c the number of edges unique to GG^{\prime}. We now show a qq-BSO operation 𝗌𝗐(ec+1,,e|E|,σ)\mathsf{sw}\doteq(\langle e^{\prime}_{c+1},\dotsc,e^{\prime}_{|E^{\prime}|}\rangle,\sigma) that transforms GG^{\prime} into G′′G^{\prime\prime}. We build the derangement σ\sigma incrementally, denoting with Im^(σ)\mathrm{\hat{Im}}(\sigma) the current (i.e., as σ\sigma is being built) image of σ\sigma. At the beginning of the construction process, Im^(σ)=\mathrm{\hat{Im}}(\sigma)=\emptyset, and at the end, Im^(σ)=Im(σ)={1,,q}\mathrm{\hat{Im}}(\sigma)=\mathrm{Im}(\sigma)=\{1,\dotsc,q\}. For each i{1,,q}i\in\{1,\dotsc,q\}, let ec+i(u,v)e^{\prime}_{c+i}\doteq(u,v) and k{1,,q}k\in\{1,\dotsc,q\} be any index such that kIm^(σ)k\notin\mathrm{\hat{Im}}(\sigma) and ec+k′′(u,w)e^{\prime\prime}_{c+k}\doteq(u,w). Then, we set σ(i)k\sigma(i)\doteq k. The index kk must always exist because GG^{\prime} and G′′G^{\prime\prime} have the same degree sequences.