{'fraction_non_alphanumeric': 0.03913657454105306, 'fraction_numerical': 0.0058503126891264875, 'mean_word_length': 4.7024539877300615, 'pattern_counts': {'":': 0, '<': 2, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
The Grand Canonical ensemble of weighted networks

The cornerstone of statistical mechanics of complex networks is the idea that the links, and not the nodes, are the effective particles of the system. Here we formulate a mapping between weighted networks and lattice gasses, making the conceptual step forward of interpreting weighted links as particles with a generalised coordinate. This leads to the definition of the grand canonical ensemble of weighted complex networks. We derive exact expressions for the partition function and thermodynamic quantities, both in the cases of global and local (i.e., node-specific) constraints on density and mean energy of particles. We further show that, when modelling real cases of networks, the binary and weighted statistics of the ensemble can be disentangled, leading to a simplified framework for a range of practical applications.

The cornerstone of statistical mechanics of complex networks is the idea that the links, and not the nodes, are the effective particles of the system. Here we formulate a mapping between weighted networks and lattice gasses, making the conceptual step forward of interpreting weighted links as particles with a generalized coordinate. This leads to the definition of the grand canonical ensemble of weighted complex networks. We derive exact expressions for the partition function and thermodynamic quantities, both in the cases of global and local (i.e., node-specific) constraints on density and mean energy of particles. We further show that, when modeling real cases of networks, the binary and weighted statistics of the ensemble can be disentangled, leading to a simplified framework for a range of practical applications.
What distinguishes a network from the systems typically studied in physics is the complex heterogeneous pattern of interactions (links) among its constituent elements (nodes). Indeed, the statistical mechanics approach to networks has been developed treating the interactions themselves as the degrees of freedom of the system, pushing forward the interpretation of links as the actual particles of the system [1]. Under this view, the maximum number of particles V (i.e., the maximum number of links) is the equivalent of the volume of a physical system. For binary networks with fixed number N of nodes, a number of seminal works [2][3][4] defined the canonical ensemble by fixing the number of links L, and the grand canonical ensemble by letting L fluctuate around its expected value. For instance in the Erdös-Rényi model, these two cases correspond to G(L) and G(p) with p = L/V denoting the link probability. The microcanonical ensemble is retrieved in this framework upon defining an energy function of network configurations, which however unlike in physical systems cannot be derived from first principles [5,6]. This difficulty led statistical mechanics of networks to be reframed more closely to information theory, according to Jayne's formulation [7]. Indeed, nowadays the microcanonical ensemble is defined by assigning equal probability to the network configurations that satisfy a given set of structural constraints exactly, whereas, in the canonical ensembles network probabilities are such that the constraints are met on average over the ensemble [8,9]. Notably, this framework naturally incorporates networks with weighted interactions [10], by treating links as multiple particle states. In particular, the canonical ensemble has been derived for networks with links assuming integer weights [11,12] and approximately for networks with (distinguishable) multilinks [13,14].
In this work we push forward this idea of considering links as particles by assuming the weights of existing links to be generalized coordinates (e.g., energy or magnetic moment) associated to such particles [15]. This allows defining the proper statistical mechanics formulation of the grand canonical ensemble of networks-in strict anal-ogy with the case of lattice gases. Here for simplicity we focus our discussion on undirected networks with links assuming continuous weights.
We define a mapping between a simple undirected weighted network G with N nodes and a lattice gas as follows. First we note that each link of G corresponds to an edge of K, the complete simple graph of N nodes. Thus we define a lattice using the line graph of K, also called in this case the triangular graph T of order N [16]. This is the graph obtained by associating a vertex with each edge of K, and connecting two vertices with an edge iff the corresponding edges of K have a vertex in common. Given this representation, we map each link of G with weight w into a particle with internal coordinate w occupying the corresponding vertex (lattice site) of the graph T (see Fig. 1). Therefore we have that the binary adjacency matrix A = {a ij } (i,j)∈V of the network fixes the positions of the gas particles on the lattice T , whereas, its weighted adjacency matrix W = {w ij } (i,j)∈V defines the internal coordinates of existing particles. Here V denotes the set of all unordered node pairs, with |V| = V = N (N − 1)/2 being the volume of the system. This mapping allows formulating in rigorous way the Grand Canonical ensemble of complex weighted networks. We first define the configuration C of an undirected weighted network as the pair (A, W): the set of existing links (i, j) ∈ L ⊆ V with |L| = L (i.e., the set of node pairs with a ij = 1) and the set of weights {w ij } (i,j)∈L associated to them (meaning that only existing links/particles contribute to the statistics of the system). Therefore, the grand canonical probability distribution is P (C) = P (A, W) ≡ P (L, {w ij } (i,j)∈L ), and the sum over configuration is performed as The information entropy associated to the probability measure P (C) is as usual S = − C P (C) log P(C), and the shape of P (C) is found by maximizing S under given constraints. This is the framework of Exponential Ran- dom Graph models [3,11,17].
Global constraints -The simplest nontrivial ensemble of this kind is obtained by imposing the mean total number of links (particles) L ≡ V i<j a ij = L * and the mean total weight (e.g., energy) W ≡ L i<j w ij = W * , where the average is defined by the measure P (A, W). This is the weighted version of the Erdös-Rényi model. We get P (A, W, α, β) = where α and β are the Lagrange multipliers related to L and W respectively. Z G (α, β) is, in analogy with statistical mechanics, the grand canonical partition function L is the number of binary configurations with exactly L links. We finally have The equations determining the values of α and β are then from which we immediately find β −1 = W * /L * = w * , i.e., the mean weight, and 1 + e α /w * = V /L * . We thus see that while β controls for the mean weight (energy) of existing links (particles), α controls for the mean density of links (particles). Note that since between each pair of nodes there can be only a single link/particle, the system can be represented with V copies of a Fermi system having a single energy level ε = 1. Under this analogy, log β plays the role of the inverse absolute temperature (kT ) −1 , whereas, −α is the ratio µ(kT ) −1 between chemical potential and temperature.
Remarkably, we can perform the parameter transformation α = α + log β, so that α alone determines the mean link density and, given this density, β alone sets the mean weight of existing links: we have This shows that individual link occupations are all mutually independent events and that, given a binary configuration A, weight values of individual existing links are also independent events. Besides, moments of link occupation and of link weight probability distributions can be independently set in order to satisfy the constraints. As explicitly shown in the next section, this property is due to the global nature of the constraints. Note that as for equilibrium statistical mechanics with short range interactions, if the system is homogeneous then local and global measures coincide. Local constraints -We now impose for each node i the mean degree or number of incident links k i ≡ V j( =i) a ij = k * i and the mean strength or total weight of incident links s i = L j( =i) w ij = s * i . This grand canonical ensemble is analogous to the continuous version of the enhanced configuration model [12], whence we use the acronym CECM. We have P (A, W, and Performing the sum over all binary configurations leads to where U is a generic subset of V. The values of the multipliers are then found through the constraints equations: ∀i. Note that after some algebra we can rewrite P (A, W) as with π(A) being the unconditional probability distribution of the binary configuration A, and q(W L ) the probability density function of the weights of the existing links (i.e., the set L) conditional to A. The form of q(W L ) is exponential, differently from the geometric and Poissonian forms obtained in [12] and [14] respectively, due to the continuous nature of the weights. At this point some considerations are in order. I) Both π(A) and q(W L ) factorize into the product of single link probability distributions: occupations of different links are independent events and, conditional to the binary configuration, weights of different links are also independent. II) However the parameters defining single link probabilities and weights are entangled, which means that local link densities cannot be set independently on local weights, because of the simultaneous conservations of mean node degrees and strengths. Such an interplay allows better clarifying the role of nodes (and in particular of node heterogeneity), which play the role of interactions between links (particles). Indeed only if node properties are homogeneous, like when we impose global constraints, such topological interactions disappear: the system is spatially homogeneous in terms of density of particles and of energy, which can be thus set independently. The statistical mechanical case analogous to a heterogeneous network situation instead arises when we constrain the local mean particle and energy densities, n(x) and ε(x), to be heterogeneous, i.e., both dependent on x. This case is typically not encountered in ordinary equilibrium statistical mechanics, with the possible exception of glassy disordered systems and long range interactions. III) If we look at the generic link occupation probability from the viewpoint of statistical mechanics, we can again interpret the single link problem as a single state local Fermi system with energy level ε = 1, inverse local temperature (kT ij ) −1 = log(β i + β j ), and local chemical potential µ ij = −kT ij (α i + α j ). However, differently from the homogeneous case, different links are not independent copies of the same problem, but topologically interacting single-level Fermi systems with different local temperatures and chemical potentials-which are mutually related by local heterogeneous constraints. Separability of binary and weighted statistics -We finally explore the separability of local links densities and weights distribution also for the case of local constraints [21]. To this end we introduce a two-step entropy maximization procedure, the separable enhanced configuration model (SECM): 1. We first constrain the mean node degrees only, obtaining the probability of the binary configuration A as for the standard configuration model [3]: 2. Then, for each A, we constrain the mean node strengths, obtaining the probability density of the link weights conditional to A (coinciding with that of the CECM): The SECM is thus defined by the constraint equations FIG. 2. Properties of CECM and SECM ensembles in four real networks: the World Trade Web [12], the eMID interbank network [12], the neural network of C. elegans [18] and the human functional brain network (HFBN) [19]. The upper part of the figure shows the comparison of link probabilities (first row) and of expected weights (second row) obtained by CECM and SECM. The lower part of the figure instead shows how the two ensembles reproduce higher-order statistics of the real networks (defined in [20]): nearest neighbors degree k nn (third row), clustering coefficient c (fourth row), nearest neighbors strength s nn (fifth row) and weighted clustering c w (sixth row).
∀i, and by the joint probability distribution (19) By definition, in the SECM the parameters defining link probabilities and weights are disentangled, so that the local statistics for these quantities can be set independently. In the CECM instead the parameters controlling for link weights also play a role in determining connection probabilities-see eq. (14). Indeed in the CECM a link (i, j) with high expected weight (β i +β j → 0) is forced to be realized (p ij → 1), and viceversa a link with low expected weight (β i +β j → ∞) becomes unlikely (p ij → 0). Thanks to the interplay of its parameters, the CECM better captures the dispersion of higher order properties of the network with respect to the SECM, as shown in Fig. 2). However, in the CECM connection probabilities, the contribution of parameters {β i } N i=1 is logarithmic with respect to that of parameters {α i } N i=1 : weighted properties in general give only small perturbations to the Lagrange multipliers of node degrees. As such, CECM and SECM define similar link probabilities and expected weights (Fig. 2), and are almost interchangeable for all practical purposes-the advantage of SECM being an easier numerical implementation. Finally, it is noteworthy that CECM and SECM coincide when the constraints on strengths and degrees satisfy s * i = γk * i ∀i for constant γ. Indeed in this case β i = β 0 ∀i, and thus we have the exact correspondence α i ≡ α i + 1 2 log(2β 0 ) ∀i. This is for instance the case of HFBN of Fig. 2.
Final remarks -Ensembles of random graphs with given structural properties like those discussed here typically find a twofold application [1,22]. On one hand, they can be taken as null network models and thus be used to assess the significance of patterns observed for a real network. On the other hand, when details on the microscopic structure of a real network are unknown, they can be used to reconstruct the most likely network configuration. The grand canonical ensemble introduced here represents, both in its rigorous version and separable approximation, a very versatile tool for these tasks, being defined for the most general class of networks with continuous weights. For instance, the fitness-induced configuration model [20] used to reconstruct networks without degree information is easily implemented in our grand canonical framework [23]. Extensions of the framework to the case of multiplex networks [24] as well as to include higher order interactions between generalized coordinates will be covered in future work.