Entropy of microcanonical finite-graph ensembles

The entropy of random graph ensembles has gained widespread attention in the field of graph theory and network science. We consider microcanonical ensembles of simple graphs with prescribed degree sequences. We demonstrate that the mean-field approximations of the generating function using the Chebyshev-Hermite polynomials provide estimates for the entropy of finite-graph ensembles. Our estimate reproduces the Bender-Canfield formula in the limit of large graphs.


I. INTRODUCTION
The entropy of physical systems is a fundamental quantity in statistical physics. For microcanonical ensembles, the entropy is represented as the logarithm of the total number of realizations or states in the system (Boltzmann's principle [1]). When the system is represented as a graph, a microcanonical ensemble is a set of graphs wherein every graph satisfies specific macroscopic constraints. Calculating the entropy amounts to calculating the total number of graphs allowed in the ensemble, denoted as N G in this study. By contrast, a canonical ensemble is a set of graphs wherein the macroscopic constraints are satisfied as an expectation. Throughout this study, we only consider microcanonical graph ensembles that include simple (no multi-edges or self-loops) undirected graphs.
Initially, the entropy of the graph ensembles received attention in graph theory, particularly in the 1980s [2,3]. The exact number of graphs in an ensemble cannot be expressed in a compact form in many cases, and several bounds and estimates have been proposed in the literature [3]. One of the early results is an asymptotic formula referred to as the Bender-Canfield formula [4], which is introduced later in this study. Although the original study considered only graphs with degrees of O(1), finer conditions for the formula were considered in later studies [5][6][7][8][9]. Statistical physicists also studied the entropy of graph ensembles. Bianconi et al. [10][11][12][13] derived entropies for graph ensembles with constraints that are often considered in the field of network science, such as degree correlations, community structures, and spatial embedding structures. In Ref. [14], Peixoto used a combinatorial approach to evaluate the entropy of stochastic block models. See Refs. [15][16][17][18][19][20][21] for other recent related works in the physics community.
The entropy of microcanonical ensembles provides the probability of instances in randomized graphs. Thus, entropy and related quantities (e.g., moments) can be useful for the statistical evaluation of random graph models and are also related to the graph sampling problem [22,23]. Moreover, the entropy of stochastic block models [14,[24][25][26][27] can be utilized for the statistical inference of module structures. We note that entropy is a primary quantity in statistical physics, and we estimate the number of graphs because entropy is obtained as the logarithm of the num-ber of graphs.
This study focuses on ensembles of finite-size graphs, particularly those with N G < 10 6 , which often correspond to graphs with less than ten vertices. We consider the mean-field estimates of N G , while maintaining a connection with its combinatorial estimations. After deriving a formula for finite graphs, a large size limit is considered to verify the reproduction of the asymptotic formula.
The rest of the study is structured as follows. Section II introduces a generating function approach to the calculation of the number of graphs by considering a simple example. Whereas generating functions are common in the literature, their mean-field estimates for finitegraph ensembles have not been investigated. Section III considers the mean-field estimates for a nontrivial graph ensemble. The second-order (Sec. III A) and corrected second-order (Sec. III B) approximations provide combinatorially interpretable estimates. In contrast, the estimate with the fourth-order approximation (Sec. III C) is novel, combinatorially nontrivial, and sufficient to reproduce the Bender-Canfield formula. Section IV evaluates the accuracy of each approximation for small graph ensembles through numerical experiments. Finally, Sec. V is devoted to the discussion of the obtained results.

II. NUMBER OF GRAPHS
For a graph G = (V, E) with vertices V and edges E, we denote |V | = N and |E| = M . We denote the adjacency matrix of a graph as A; A ij = 1 when vertex pair i and j is connected and A ij = 0 otherwise. Because we consider undirected simple graphs, the adjacency matrix is a binary symmetric matrix. We assume that each vertex is distinguishable (labeled graph), and hence, graph isomorphisms are counted as different graph instances.
Let {A ij ∈ {0, 1}} be the set of 2 ( N 2 ) configurations in the upper-right part of the adjacency matrix elements. The number of graphs N G can be formally counted as the sum over {A ij ∈ {0, 1}} with constraints. For example, when the total number of edges is constrained to M , where i<j A ij is the sum of all upper-right elements in A and δ(x, y) represents the Kronecker delta, which is one when x = y and zero otherwise. In the Erdős-Rényi random graph model [28,29], each instance in the N G graphs is realized with equal probability. The Kronecker delta has the following integral representation: where x and y are discrete variables. In Eq. (2), the integral is along an arbitrary loop around the origin in the complex plane; the integral is one only when the exponent of z is equal to one, and zero otherwise, according to Cauchy's integral theorem. Using this trick and the residue theorem, we obtain a combinatorial expression for N G in Eq. (1): This is a simple example of counting the number of graphs. We can clearly interpret this solution through the combinatorial expression; that is, N G is simply the number of ways to select M nonzero elements from the N 2 upper-right cells of the adjacency matrix elements. However, exact combinatorial expressions cannot always be obtained in compact and interpretable forms. We must rely on the approximations in such cases, and we consider such cases for the remainder of this study.

III. MEAN-FIELD SOLUTIONS FOR GRAPHS WITH PRESCRIBED DEGREE SEQUENCE
We evaluate the number of graphs in the ensemble where the degree sequence is constrained. The degree d j of vertex j is expressed as i A ij . We denote {d 1 , . . . , d N } =: d for the degree sequence. The total number of graphs N G (d) is where Here, z represents the set of auxiliary variables {z 1 , . . . , z N }. The final expression in Eq. (4) indicates that e F (z) is a generating function of N G (d). The general solution for a higher-order derivative can be provided in the form of the Faà di Bruno's formula [30]. Nevertheless, approximations are often required, because this formula involves a complicated sum. N G (d) is a nontrivial quantity and an asymptotic solution was found in graph theory. The so-called Bender-Canfield formula estimates that where This solution becomes accurate when N is sufficiently large as long as max j d j is sufficiently small (see Ref. [9] for a more precise argument on the scaling of degrees). Here, the double factorial is defined as and ⌈·⌉ is the ceil function. The standard derivation of Eq. (6) is based on combinatorial and probabilistic arguments (see Refs. [3,31] for details). In contrast, we consider meanfield approximations of F (z) and examine the resulting estimate of the number of graphs.

A. Second-order approximation
First, we consider the following second-order approximation for F (z): This is attributed to the lowest-order expansion Note that j z 2 j /2 must be subtracted from Eq. (8) to be more precise. Although this correction is considered in the next section, it is neglected assuming that its contribution is not dominant.
Using the Hubbard-Stratonovich transform, the number of graphs N 2nd G (d) under this approximation can be evaluated as Note that j d j = 2M . In the last equality, an identity of the Gaussian integral, +∞ −∞ dx x n e − x 2 2 = (n − 1)!! for an even integer n is used.
A combinatorial explanation for Eq. (10) can be obtained by considering the stub-labeled graphs (also called the configurations [5,14]). A stub is a "half-edge" that is incident on a vertex. Every stub is distinguishable in a stub-labeled graph. For a given degree sequence, the number of stub-labeled graphs can be counted by pairing all 2M stubs. This pairing is known as the perfect matching, and the number of perfect matching is (2M − 1)!!. A specific example is shown in Fig. 1. However, this is an overestimation because the stubs are indistinguishable in the considered graphs. That is, different stub-labeled graphs are obtained by permuting the stubs incident on the same vertex. The factor j d j ! corrects these degrees of freedom.
The solution is not precise even after the correction by j d j !. When the perfect matching is considered in the stub pairing, the vertex on which each stub is incident is ignored. The pairings represent simple graphs as well as graphs with multi-edges and self-loops. Therefore, finer estimates are required.

B. Corrected second-order expansion
Next, we consider a slightly more accurate expansion of F 2nd (z) in which the contribution from the diagonal elements in Eq. (8) is corrected: Applying the Hubbard-Stratonovich transform again, we obtain N 2nd+ He dj (Q) =: Here, He n (x) is the Chebyshev-Hermite polynomial: where ⌊·⌋ is the floor function. J (d 1 , . . . , d N ) represents the Gaussian integral of the product of N Chebyshev-Hermite polynomials. J (d 1 , . . . , d N ) is equivalent to the number of perfect matchings in a complete N -partite graph (a graph with N independent vertex sets) [32]. Equation (10) considered the pairing of stubs without distinguishing the vertex on which each stub is incident. In contrast, Eq. (12) distinguishes the vertices to prohibit the self-loops in its pairing. However, this counting is still not precise, because multi-edges are not prohibited.
Let us express Eq. (12) using the second equality in Eq. (13): where we used the Gaussian identity of the double factorial again and introduced k(d,K) to simplify the notation. Note that 0!! = (−1)!! = 1. k(d, K) = {k 1 , . . . , k N } represents a sequence of nonnegative integers that is constrained locally by ⌊d j /2⌋ for each vertex and globally by N j=1 k j = K. Equation (14) is an expansion with respect to the least number of self-loops. When K > 0 is ignored, it coincides with N 2nd G (d). For a given k(d, K), is the number of stub-labeled graphs in which each vertex has at least k j self-loops. Note that the self-loops are still included in Eq. (16) within the pairing of 2(M −K) stubs.
In this term, the number of stub-labeled graphs with at  1. Possible graphs and the corresponding stub-labeled graphs (configurations) for a degree sequence. The white circles represent three vertices i, j, and k. The black circles represent stubs and the vertex that each stub is incident on is indicated as a subscript of the index label.
least K + 1 self-loops is overcounted. The (K + 1)th term corrects this overcounting, although the term again includes some overcounting, and so on. In the end, the entire sum counts the pairing of stubs without self-loops.
To see how Eq. (14) is related to Eq. (6), we assume that N and M are sufficiently large and approximate Eq. (14) as where λ is defined in Eq. (7). In the second equality, we neglected the contributions of the sums with o(N K ) elements in the numerator and approximated that (2M −1) · · · (2(M −K)+1) ≈ (2M ) K in the denominator. Compared with Eq. (10), Eq. (17) includes e −λ as a correction factor, which partially reproduces Eq. (6). In the standard derivation of the Bender-Canfield formula, e −λ is interpreted as a factor based on the probability that a graph includes self-loops in a uniformly random graphgeneration process. The present derivation also indicates that this correction can be attributed to the exclusion of self-loops. Next, we reproduce the remaining correction factor e −λ 2 in Eq. (6).

C. Fourth-order expansion
Let us consider a fourth-order expansion of F (z): Note that this is not a precise fourth-order expansion with respect to {z j } because the contribution from j z 4 j /4 is not corrected. However, as shown below, this is sufficient for reproducing Eq. (6) in the asymptotic regime.
Once again, the Hubbard-Stratonovich transform is used to estimate the number of graphs N 4th G (d) as follows: He dj Q 1 The expansion of the Chebyshev-Hermite polynomial yields The former part of the above equation is equivalent to Eq. (14). The integral in the latter part is where K = j k j and H n (x) is the (physicist's) Hermite polynomial, which is related to the Chebyshev-Hermite polynomial as H n (x) = 2 n/2 He n ( √ 2x). Analogous to Eq. (14), Eq. (20) is recast as In the asymptotic regime, by applying the same approximation as in Eq. (17), we obtain Here, we used the identity The fourth-order expansion reproduced Eq. (6). In the standard derivation of the Bender-Canfield formula, the correction factor e −λ 2 is interpreted as a factor based on the probability that a graph includes multi-edges with the multiplicity of two in a uniformly random graphgeneration process. In contrast, Eq. (22) is still an expansion with respect to the least number of self-loops K, but with a correction factor H K (1/2). Although this correction factor should be related to the exclusion of multi-edges, Eq. (22) does not explicitly corrects the contribution of the multi-edges. Interestingly, this approximation is sufficient for reproducing Eq. (6) in the asymptotic regime. To the best of our knowledge, the series expansion (22) has not been previously reported, and as demonstrated in the next section, it is often more accurate than the asymptotic form (6) when N is small.

IV. EXPERIMENTS
While the fourth-order expansion yields an estimate N 4th G (d) of N G (d) for finite graphs, it is not obvious whether the estimate is closer to the exact value than N BC G (d). Furthermore, the amount of deviations of N 2nd G (d) and N 2nd+ G (d) from N G (d) for small graphs is noteworthy. Note that our enumeration does not require the graphs to be connected; unless very dense graph ensembles are considered, some of the graphs comprise disconnected components. Thus, the total number of vertices N in a graph is always fixed to the specified number. Note also that although the summation (15) is apparently complicated, this operation can be easily coded using the itertools.product function in Python. are respectively the estimates in Eqs. (10), (14), (6), and (22). NG is the exact number of graphs in the ensemble. Figure 2 compares, for a given N , the estimates of the number of graphs in the microcanonical ensemble of 3regular graphs with the exact value N G , which is counted through the brute-force enumeration. Whereas N 2nd G (d) and N 2nd+ G (d) largely overestimate the number of graphs, N BC G (d) is closer to N G (d), and N 4th G (d) is even closer to N G (d) for N = 6, 7, and 8. For N = 7, N G (d) = 0 because graphs cannot be constructed when the total degree is odd. The mean-field estimates do not take this feature into account.
Next, the dependence of the degree distribution is evaluated on the estimates N 4th G (d) and N BC G (d) for N = 6. Herein, all possible graphic degree sequences of six vertices are considered, that is, the sum of degrees is even and the Erdős-Gallai condition [33] is satisfied. Figure 3 shows the results with such degree sequences. Without the loss of generality, each degree sequence can be assumed to have a non-descending order because N G (d) is invariant under the permutation of elements within a degree sequence. Again, the estimate N 4th G (d) is often closer to the exact value N G (d) than N BC G (d). The results also indicate that, although N 4th G (d) tends to underestimate N G (d), it is not a lower bound. By contrast,

V. DISCUSSION
To obtain the entropy of the finite-graph ensembles, we estimated the total number of instances N G (d) by expanding the generating function. In statistical physics, although generating function techniques are common, a large-size (or a thermo-dynamic) limit is usually considered, and the saddle-point approximation is often ap-plied. By contrast, we established a mean-field approach to evaluate finite-size graphs using the Chebyshev-Hermite polynomials.
While many of discrete system problems are combinatorial, the combinatorial aspect is often more pronounced when the system is small. Therefore, the method used in this study, which allowed us to observe the connection to combinatorial evaluations, is particularly important for ensembles of small systems. Even when the number of vertices N is small, N G (d) can be considerably large, and its accurate estimation can be computationally demanding.
Although we analyzed up to the incomplete fourthorder expansion of the generating function, it is not clear whether even finer expansions still yield concise solutions that can be interpreted in a combinatorial manner. Furthermore, it would be interesting to determine whether a mean-field estimate can be sufficiently sophisticated to distinguish a non-graphic degree sequence as N G (d) = 0.
Quantitatively estimating the accuracy of the estimation of N G (d) is an interesting problem. For an ensemble of d-regular graphs, the multiplicative error between the Bender-Canfield formula and N G (d) is O(exp(d 3 /N )) [6]. Thus, the formula is asymptotically accurate when the degree is sufficiently small. By contrast, our mean-field expansion does not manifestly bound N G (d) in terms of N . Although N 4th G (d) is relatively accurate, it was confirmed that it is not a bound of N G (d).
This study focused on microcanonical graph ensembles with relatively simple constraints. We believe that an analogous analysis can be performed for graph ensembles that allow multi-edges and self-loops. Furthermore, we expect that the mean-field approach considered in this study can be applied to various problems involving finite discrete systems.