Homophily within and across groups

Domain: physics
Published: 2025-12-13
Editorial outcome: minor_revision

Abstract
Homophily-the tendency of individuals to interact with similar others-shapes how networks form and function. Yet existing approaches typically collapse homophily to a single scale, either one parameter for the whole network or one per community, thereby detaching it from other structural features. Here, we introduce a maximum-entropy random graph model that moves beyond these limits, capturing homophily across all social scales in the network, with parameters for each group size. The framework decomposes homophily into within- and across-group contributions, recovering the stochastic block model as a special case. As an exponential-family model, it fits empirical data and enables inference of group-level variation of homophily that aggregate metrics miss. The group-dependence of homophily substantially impacts network percolation thresholds, altering predictions for epidemic spread, information diffusion, and the effectiveness of interventions. Ignoring such heterogeneity risks systematically misjudging connectivity and dynamics in complex systems.

Introduction
Homophily-the tendency for like to connect with like-shapes both the structure and function of networks1–5. In social systems, people tend to connect with others who share attributes such as gender, age, race, education, occupation, sexual preferences, socioeconomic background, or vaccination status6–17. Assortative mixing occurs in various settings, ranging from friendships and workplace ties to online platforms, peer influence networks18–21, and even graph neural networks22–25. It shapes interactions and governs processes like contagion, diffusion, and coordination26–30. In healthcare settings, the close contact between healthcare workers and vulnerable patients can alter outbreak patterns, as homophily interacts with variations in infectiousness and susceptibility, reshaping epidemic dynamics31–38.

Homophily varies by interaction type and tie strength39–41. Strong ties tend to form within close-knit groups, while weak ties more often bridge distant or dissimilar clusters40,42. Networks of citations and trade partnerships typically exhibit dual mixing patterns, combining dense local collaboration with broad cross-group exchange43,44. Gender homophily, in particular, is sensitive to the interaction context and size. On Instagram, women show strong same-gender preferences in comments, while men are largely neutral45. In face-to-face proximity networks, women tend to form homophilic triads, whereas men favor same-sex dyads46. In contrast, the teen-focused Spanish social network Tuenti shows the opposite: women sustain stronger same-gender dyads, and men more often form all-male triads than expected under null models47.

These observations suggest that homophily is influenced by both group composition and size, underscoring its variability across different social scales48,49. Small, cohesive groups often display high local homophily, whereas long-range connections mix more randomly, producing distinct within- and across-group connectivity essential for understanding collective behavior50. Nevertheless, many network models simplify homophily into a single, uniform parameter-essentially a summary statistic that captures only the network’s average mixing pattern14,26,51–55. On the other hand, models with explicit community structure, such as the Stochastic Block Model, allow different homophily values across communities but typically assign each node to a single group (and thus a single effective length scale), so they cannot capture overlapping, multiscale affiliations in which a node simultaneously participates in groups of different sizes.

Epidemiological studies emphasize the importance of this complexity, demonstrating that high within-group homophily can elevate epidemic thresholds, while increased cross-group interactions typically lower them6,56–60. Recent studies further show that variations in homophily across interaction sizes critically influence how quickly different groups gain access to information61. Therefore, to better understand network formation and dynamics, we should model homophily as a heterogeneous property that varies across social scales.

We introduce a network model that allows for homophily to operate across the network scale and scales of various finite social groups. These groups are operationalized by cliques, which serve as natural building blocks of human interactions. The cliques can represent various social foci62 and social circles39,63, which can consist of families, workplaces, organizations, friendship groups, and other social, physical, legal, or psychological entities. In our framework, as illustrated in Fig. 1, we model the homophily within cliques such that the level of homophily depends on the size of the cliques. This allows, for example, our model to have different homophily for interactions within groups and bridging groups (cliques with two nodes). By adopting a maximum-entropy formulation, the model captures homophilic structure beyond pairwise links and distinguishes between within- and across-group connections. This reveals scale-dependent patterns often overlooked by standard measures and aligns well with empirical studies. Our results show that such multi-scale homophily can raise or lower the percolation threshold, depending on how intra- and inter-group links are distributed. These findings offer new tools for understanding epidemic thresholds, designing interventions, and modeling the spread of information or behavior in social systems.

Results
We present the generative network model and demonstrate how it encodes multi-scale homophily. We validate the model against empirical data, illustrating how distinct within- and across-group mixing patterns emerge naturally within this unified framework. We then investigate how these multi-scale homophily patterns affect percolation thresholds and network connectivity, highlighting implications for epidemic control strategies and other contagion processes.

Model description
We introduce a generative maximum-entropy model that both fits empirical data and provides mechanistic insight, while serving as a statistical framework for inferring group-level variations in homophily. The model is a random graph construction designed to capture homophily across multiple social scales (clique sizes). Rather than enforcing node-specific degree constraints, we fix only the average degree, allowing node degrees to fluctuate around the mean, yielding an approximately Poisson distribution.

We begin with a binary attribute assignment: each of the N nodes is labeled red or blue, with N_r red nodes and N_b = N - N_r blue nodes. Their proportions are given by n_r = N_r/N and n_b = 1 - n_r. All subnetworks {G_c} are defined on this same node set, so red and blue labels are consistent across layers. (The framework extends to multiple attribute classes in Sec. IVE.) We classify the cliques within each subnetwork G_c based on the number of red or blue nodes they contain. A c-clique can be classified into one of c+1 types, that are specified by the number i of red nodes included. We denote by F_{c,i} the proportion of c-cliques in G_c that contain exactly i red nodes and c-i blue nodes. To ensure that the overall fraction of red and blue nodes is preserved in the large-network limit, the distributions {F_{c,i}} must satisfy

\sum_{i=0}^{c} F_{c,i} = n_r, \sum_{i=0}^{c} F_{c,i} = n_b : (1)

To construct each subnetwork G_c, we independently sample M_c cliques of size c from the total population of nodes according to the distribution {F_{c,i}}. Figure 1(a-c) illustrates the construction of three subnetworks with different clique-type distributions. In this framework, G_c is a stochastic graph model64. The final network, G, shown in Fig. 1d, is obtained by merging all subnetworks {G_c}, where each subnetwork consists of cliques of size c drawn over the same set of nodes;

G = \bigcup_{c} G_c : (2)

Since cliques are sampled independently and we require the largest clique size to be finite, setting M_c = O(N) ensures that each layer G_c remains sparse and that the fraction of overlapping links vanishes in the large-network limit. For more details, see Methods “Network Sparsity”. Given a prescribed average degree 〈d〉, controlling M_c allows us to regulate the number of links from each clique size to the overall network. In practice, we sample fewer large cliques, reflecting empirical observations: larger cliques tend to be rarer in real-world networks due to cognitive and social constraints-a phenomenon known as “schisming”65,66. A more detailed discussion regarding finiteness and the effect of overlap on empirical networks is provided in Methods IVC.

A standard global measure for quantifying how nodes with categorical attributes (such as color) tend to connect is the Coleman index, also known as the assortativity coefficient67–69. It is defined as

h = \frac{k_r - n_r}{1 - n_r} = \frac{k_b - n_b}{1 - n_b} : (3)

where k_r and k_b are the fractions of red and blue nodes’ neighbors that are of the same color. By construction, |h| ≤ 1: values near 1 signal strong homophily or segregation; h ≈ 0 indicates random mixing; and negative values imply heterophily70.

In our framework, cliques are sampled independently, and each node participates in a Poisson-distributed number of cliques. Under these assumptions, the Coleman index (3) can be decomposed into contributions from each clique layer G_c, giving

h = \sum_{c≥2} α_c h_c , (4)

where h_c denotes the homophily of G_c, and α_c is the fraction of links contributed by layer G_c. Consider a network G constructed from two layers, G_2 and G_6. Here, h_2 quantifies across-group homophily and h_6 captures within-group homophily, assuming the groups are defined by the 6-cliques. The total homophily becomes h = α_2 h_2 + α_6 h_6, with each layer’s influence determined by its corresponding α_c. For instance, α_2 = α_6 = 0.5 gives equal weight to both layers, whereas α_2 > α_6 results in across-group homophily dominating, and vice versa. In general, the weights α_c can be computed as

α_c = \frac{c(c-1) M_c}{N 〈d〉} : (5)

Each h_c can further be decomposed into the weighted average of homophily contributions h_{c,i} from all c-cliques with i red nodes:

h_c = \sum_{i=0}^{c} h_{c,i} F_{c,i} : (6)

h_{c,i} measures the deviation of such a c-clique’s composition from random mixing and is defined as

h_{c,i} = \frac{2 \left( \frac{i(c-i)}{c(c-1)} \right) - (n_r^2 + n_b^2)}{1 - (n_r^2 + n_b^2)} : (7)

This equation defines homophily at the clique level, following the Coleman approach. It is worth noting that Eq. (3) can also be decomposed into contributions at the node or neighborhood level, where “node congruity” measures each node’s share of the overall homophily48,71,72. However, the formalism presented above provides sufficient measures for this study.

Since many different F_{c,i} distributions can produce the same overall homophily h_c, we use a maximum entropy approach to identify the least-biased distribution consistent with the desired group homophily h_c and the red and blue node fractions n_r and n_b. Specifically, we choose F_{c,i} to maximize entropy subject to two constraints: (i) the average fraction of red nodes in cliques equals n_r (Eq. (1)); and (ii) the resulting clique-layer homophily is h_c (Eq. (6)). Since the network contains only two colors, satisfying constraint (i) automatically ensures that the blue-node fraction n_b = 1 - n_r is preserved, so only one constraint is needed to fix both. The resulting distribution takes the exponential-family form:

F_{c,i} = \frac{1}{Z} \exp(\theta_r i + \theta_{hc} h_{c,i} ), (8)

where Z is the partition function normalizing over all c-clique compositions. The parameters θ_r and θ_{hc} are commonly referred to as conjugate couplings in statistical mechanics. This approach naturally accommodates networks with different degrees of mixing and handles both symmetric and skewed attribute distributions. Figure 1e shows three examples from this versatile family of distributions.

Analogous to spin models on hyperedges74–76, our framework can be viewed as a canonical ensemble, where clique homophily and color composition act as soft constraints-similar to inverse-temperature-like parameters in a spin system defined on a hypergraph. Each clique configuration corresponds to a microstate, weighted by a Boltzmann factor F ∝ e^{-H}. In this formulation, the Hamiltonian H depends on the full color composition of each clique. A c-clique thus represents a higher-order interaction among the spins (i.e., node attributes) of its c members.

The goal of this model is not to replicate every microscopic detail (such as exact degree distributions), but rather to serve as a minimal generative null model that clearly isolates the role of multiscale homophily. This two-color framework naturally generalizes to scenarios with multiple categories or even multidimensional homophily, allowing for the simultaneous consideration of various attributes. We explicitly present these extensions in Sections IVE and IVF.

Empirical Networks & Model Validation
To assess how well our model captures homophilic structure in real-world networks, we analyze six datasets with categorical node attributes: the Slovak social networking site Pokec77, the Copenhagen Networks Study (CPH)78, the music-sharing platform Last.fm79, a mobile phone call network80,81, the face-to-face proximity dataset SocioPatterns46,82, and 100 Facebook friendship networks83. These datasets, summarized in Table 1, span a broad spectrum of social interaction types-from digital connections to physical encounters.

For each empirical network G, we extract all maximal cliques and group them by size to form distinct layers {G_c}. As shown in Fig. 1a–d, this decomposition yields a family of subgraphs, each capturing interactions at a specific clique size. Some links appear in multiple layers, but this redundancy has a negligible effect on measured homophily. We fit the maximum-entropy model (8) to the observed clique-type distributions by maximizing the likelihood, thereby estimating the parameters {θ}. For details on link duplication and its impact, see Sec. IVC.

Our maximum-entropy approach closely matches the empirical distributions of clique compositions, as illustrated in Fig. 2a. Similar to Fig. 1, it compares observed histograms of F_{c,i} across several empirical networks with the model fits from Eq. (8). With only two parameters-the expected homophily h_c and the fraction of nodes of one type-the model accurately captures the full distribution of clique compositions F_{c,i} in our empirical data. This means that h_c values contain all the information about the completed distributions F_{c,i} of our data, and it is enough to report the h_c values to fully describe how the homophily is distributed within and across groups of different sizes.

Although these networks differ in global properties, such as degree distributions that do not necessarily align with those generated by our model, the methods still effectively reproduce the patterns of homophily. This robustness stems from the fact that the model is directly constrained by empirical clique compositions or homophily values, rather than by assumptions about the degree sequence or other global network characteristics.

The Coleman indices for these datasets range from mildly homophilic (h=0.1 in the Last.fm network and h=0.2 in the University of Oklahoma Facebook network), to randomly mixed (h=0.0 in the CPH and SocioPatterns networks), and mildly heterophilic (h=−0.2 on the Pokec platform). However, these aggregate measures conceal substantial variation at the clique level. We observe diverging trends across datasets. In the mildly homophilic networks, homophily increases with clique size: Last.fm exhibits random mixing for dyads (h=0) but stronger homophily in larger cliques (h=0.3); Oklahoma shows heterophily among bridging links (h = − 0.2) and homophily only in larger groups. In contrast, CPH and SocioPatterns-despite appearing randomly mixed overall-display the opposite pattern: bridging links are homophilic, but larger cliques are heterophilic.

The Pokec network offers a particularly striking example of a pattern behind an average index. Its Coleman index h=−0.2 suggests mild heterophily, yet dyads (G_2) exhibit strong cross-sex preference with h_2 = −0.6. As clique size increases from 2 to 10, this intermingling turns into homophily. This transformation is not a minor refinement-it fundamentally changes the interpretation of the network: pairwise links reflect Pokec’s dating-oriented function, while larger cliques reflect its broader role as a social media platform where, at social scales, birds of a feather flock together1.

Facebook data from 100 U.S. universities and colleges offers a socially comparable set of environments with rich attribute annotations. Altenburger et al.84 previously showed that users tend to form highly sex-homogeneous friendship circles-often all-male or all-female-even though these preferences largely cancel out in aggregate, producing weak overall homophily. Figure 2c–e illustrates how homophily varies with clique size when nodes are grouped by (c) sex, (d) student status, and (e) class year. Each attribute captures distinct social dynamics, resulting in different homophily profiles. In Fig. 2c, sex-based homophily increases monotonically with clique size, suggesting that sex-based clustering intensifies in larger groups. In contrast, Fig. 2d shows an average trend with a medium level of homophily at the link level and only a slight dependency on group size. Our framework can analyze more complex scenarios involving multiple non-binary attributes. Figure 2e reveals a clearly non-monotonic pattern for class year in the Facebook network: homophily rises in smaller cliques but levels off as groups grow, likely reflecting increased mixing between cohorts in broader social circles.

Notably, similar multiscale mixing patterns have been reported by Peel et al.48, who demonstrated that even when the network exhibits modest overall homophily, certain subgroups (such as first-year students) display markedly higher local homophily.

These observations shed a new light on findings by Traud et al.83, who showed that communities in university Facebook networks tend to cluster by class year. Our analysis reveals that smaller cliques strongly reflect graduation-year homophily, but this pattern weakens in larger groups, where other attributes-such as sex or student status-become more prominent. Similar scale-dependent patterns are well documented in the broader sociological literature. Homophily is shaped by multiple, context-dependent mechanisms1; academic performance influences how students reorganize their friendships85; and ethnic background plays a significant role in network formation in educational settings86.

Percolation
The structure of the network determines how robust it is to being disintegrated into small, connected components when links or nodes are removed87–91. In social systems, these removals can stem from communication failures, a limited number of contacts, or other reasons, and the connectivity then determines the spread of ideas, behaviors, or diseases39,80. Removing across-group links-often corresponding to weak ties that bridge otherwise separate communities92-can trigger sudden fragmentation, severing pathways across the network. In contrast, losing within-group links, typically associated with strong local ties within groups, tend to undermine cohesion within groups without immediately disrupting global connectivity93–95. This distinction is central to our analysis, where we explicitly differentiate between links that connect groups (the G_2-layer of our model) and those that bind them internally (the G_c layers for c > 2).

To show how group homophily values {h_c} influence network behavior, we analyze their effect on connectivity and percolation thresholds. Since our model generates networks with nearly identical degree distributions across different homophily settings, any changes in percolation, such as shifts in the largest connected component or the threshold, reflect structural correlations induced by homophily, not degree variation96. This setup isolates the specific role of homophily within and across groups in shaping network robustness and percolation dynamics.

In a standard bond percolation process87, each link in a network G is retained with probability ϕ and removed with probability 1 − ϕ, independently and uniformly at random. As ϕ varies, we track the size of the giant component-the largest connected subgraph-to study how connectivity responds to random removal of links. This process is relevant to various simple dynamics such as epidemics, information spreading, or behavior adoption, where deleted links represent blocked transmission paths. For example, in the case of epidemic spreading, under certain assumptions, the giant component corresponds precisely to the final outbreak size95,97. As the disease becomes more infectious, ϕ increases, and the population undergoes a continuous phase transition from a contagion free to an endemic state. In more complex scenarios, link removal is not uniform and depends on node attributes. For example, disease transmission probabilities can differ based on age or vaccination status in a partially vaccinated population14,98–105. In such cases, percolation is no longer governed by a single parameter ϕ, but by a vector of link-type-specific probabilities.

In our colored network model, we remove links based on a vector (π_{rr}, π_{rb}, π_{bb}), where π_{kj} is the probability of removing a link between nodes of colors k and j (π_{kj} = π_{jk})106. In the large-network limit, this is equivalent to independently removing each kj-type link with probability π_{kj}. This is similar to the idea of neighbor-induced immunity percolation107. By varying these probabilities and observing how the giant component changes, we identify when the network undergoes a phase transition in connectivity.

Analytical solutions for percolation on non-tree-like networks are famously intractable108,109; yet, by isolating within-clique spreading from across-clique behavior, our framework breaks this impasse and provides a closed-form expression for the critical percolation threshold (see Section Derivation of the Percolation Threshold). Using a multi-type branching process, we show that the percolation vector π=(π_{rr}, π_{rb}, π_{bb}) is critical when there exists a non-negative vector v such that

v^2 ker(B(π) - I), v = |v| ≥ 0, (9)

where I is the identity matrix and the matrix B = B(π) (see Eq. (21) in Methods) encodes the expected number of nodes of a given clique type reached from another via percolation. The condition det(B(π) - I) = 0 is necessary but not sufficient for criticality. In expression (9), ker(·) denotes the kernel (nullspace) of a matrix-i.e., the set of vectors mapped to zero-and det(·) is the determinant, indicating when the matrix becomes singular.

We explore this condition in networks parametrized by within-group homophily h_4 and across-group homophily h_2. Figure 3a, b shows heatmaps of the critical value π = π_{rr} = π_{bb} for different values of π_{rb}. When π_{rb} is low (Fig. 3a), increasing the global homophily expressed by the Coleman index h reduces the critical threshold. When π_{rb} is high (Fig. 3b), increasing h instead raises the threshold. Interestingly, these figures reveal how group homophilies affect connectivity, even when the Coleman index is fixed. We see that level curves for the critical value π = π_{rr} = π_{bb} are not vertically aligned, meaning that for fixed h, distinct combinations of h_2 and h_4 yield different percolation thresholds. In particular, when π_{rb} is low, percolation is more easily achieved if h_4 > h_2; vice versa, when π_{rb} is high, the percolation threshold is lower if h_2 > h_4. The importance of local homophily is more prominent when π_{rr} ≠ π_{bb}, as depicted in Fig. 3c. Here, the contour lines are roughly diagonal, indicating that the type of homophily is equally important to the amount of homophily for the percolation threshold. This means that the type of homophily can have a significant impact on the critical value of π_{rr}, which can range from 0.4 to 0.75 even when the Coleman homophily h remains fixed.

To illustrate the role of homophily within and across groups for the percolation threshold more systematically, we fix h = 0.5 with α_2 = α_4 = 0.5 and compare two configurations: (i) weak across-group homophily (h_2 = 0.1) and strong within-group homophily (h_4 = 0.9), and (ii) the reverse. We compute the difference in critical values: Δπ*.

Figure 3d shows that this difference can be either positive or negative, depending on π_{rb} and π_{bb}. Increasing the connectivity between groups (higher π_{rb}) enhances the effectiveness of across-group homophily in maintaining network connectivity. In other words, when many cross-group links are present, networks with stronger across-group homophily achieve percolation at lower thresholds compared to networks with stronger within-group homophily. Thus, stronger homophily within or across groups does not universally improve connectivity. The difference in critical π_{rr} values between networks with the same Coleman index can be as large as 0.8, showing that global homophily alone is insufficient to predict percolation behavior.

Epidemic spread & vaccination
We demonstrate how multiscale homophily influences epidemic dynamics by applying our percolation framework to contact networks. Homophily affects disease transmission through both vaccination behaviors and demographic mixing patterns. Age serves as a prime example: empirical contact matrices consistently show strong age-assortative mixing, with children primarily interacting with other children and adults exhibiting distinct interaction patterns depending on age and context101–105. Such structured contacts significantly reshape infection pathways, thereby affecting key epidemiological outcomes including herd immunity thresholds, expected epidemic sizes, and the effectiveness of interventions14,26,27. Our framework facilitates a detailed analysis of intervention strategies, providing a foundation for improved design and interpretation of public health policies110. To illustrate this, we analyze a vaccination scenario involving an imperfect vaccine, categorizing individuals as vaccinated (red) and unvaccinated (blue) nodes, to investigate how homophily shapes disease spread and influences the success of interventions.

With perfect vaccines, only red-red links remain active, and any link involving at least one vaccinated node is removed from the transmission network. However, with imperfect vaccines, vaccinated individuals can still transmit the disease, though at a reduced value, to both vaccinated and unvaccinated individuals compared to the baseline probability π between two unvaccinated nodes. If the across-group vaccine efficacy f_I reduces transmission between vaccinated and unvaccinated individuals, and the within-group efficacy f_v reduces transmission across vaccinated individuals, then the transmission probabilities are π_{rb} = f_I π and π_{bb} = f_v π, respectively14. Figure 3(e-g) shows that the impact of f_I and f_v on the critical percolation threshold is non-trivial. As in Fig. 3(a-c), the effect of homophily on the critical value can reverse. In Fig. 3e, increasing either homophily raises the critical threshold, while in Fig. 3g, it lowers it. This mirrors earlier results: for low π_{rb}, increasing homophily decreases the critical value. Since π_{rb} = f_I π, the values of f_I in these panels explain the observed shift-π_{rb} = π in Fig. 3e and 0.1π in Fig. 3g. Figure 3f shows that for certain combination of f_I and f_v, the critical value becomes nearly insensitive to either form of homophily.

In tree-like networks, the required vaccine coverage for herd immunity increases with the Coleman index h, and high homophily may render herd immunity unattainable14. Our results reveal that layered homophily creates far more complex outcomes. For example, in Fig. 3g, the critical threshold ranges from 0.5 to 0.64 when the Coleman homophily remains fixed at h=0.5, a 30% difference, highlighting the influence of homophily structure on epidemic dynamics and intervention outcomes.

Methods
Fitting the model to data
Given an empirical network, we identify all maximal cliques, group them by size c, and derive an empirical distribution representing the proportion of cliques containing different numbers of red nodes. Figure 2a shows such distributions. Since the maximum entropy distribution for clique configurations is constrained by the observed number of red nodes per clique and the overall homophily index, we infer the latent homophily parameters θ_r and θ_{hc} of Eq. (8) by maximizing the likelihood of the observed distributions.

To ensure robust estimates, we employ a bootstrap resampling procedure for each clique size, drawing the same number of cliques 1,000 times and computing mean homophily values and 95% confidence intervals. In Fig. 2b, confidence intervals follow from non-parametric bootstrap resampling of the cliques.

Network sparsity
Let the sets of clique sizes present in G be denoted by C. The number of links in the network can be upper-bounded by

\sum_{c \in C} \frac{c(c-1)}{2} M_c , (10)

as each subnetwork G_c contains M_c c-cliques. These cliques may overlap, so that Eq. (10) is an upper bound for the number of links. As sparse networks require the number of links to be O(N), this sets conditions on the maximal sizes of M_c and c. While several choices are possible to end up with a sparse network, in this manuscript we will take M_c = O(N) and max{c \in C} ≤ K for some K < ∞. This corresponds to many small, finite groups of interactions.

Link duplication
In large, sparse networks where cliques rarely overlap, Eq. (3) (the Coleman index) and Eq. (6) (the clique-based homophily formula) are equivalent. However, in finite-size empirical networks, c-cliques often share links, leading to redundancy. In a network G_c, the number of links, denoted by L_c, is always less than or equal to the total number of links in the M_c maximal c-cliques. The duplication ratio captures the extent of this redundancy

δ_c = 1 - \frac{2L_c}{M_c c(c-1)} , (11)

where higher δ_c indicates greater link-sharing among cliques. When δ_c is small, we can approximate the actual fraction of same-color links by expanding around the nominal (no-overlap) value:

e_{kk} = e_{kk}^{(c)} + γ_c δ_c + O(δ_c^2) , (12)

where k ∈ {b,r} and the coefficients γ_c capture how color-biased the overlap is: if duplication disproportionately affects red–red links, then γ_r ≠ 0, etc. The difference in the same color duplicated links will be

(e_{rr} + e_{bb}) - (e_{rr}^{(c)} + e_{bb}^{(c)}) = γδ_c + O(δ_c^2) , (13)

where γ = γ_r + γ_b. Substituting into Eq. (3) yields

h = h_c + \frac{γδ_c}{1 - n_r^2 - n_b^2} + O(δ_c^2) : (14)

Hence, if duplication is color-unbiased (γ=0), the overlap does not alter homophily at first order, implying

h = h_c + O(δ_c^2) ≈ h_c : (15)

Conversely, a nonzero γ indicates color-biased overlap, shifting the actual Coleman index away from the nominal h_c by roughly γδ_c.

When measuring the duplication ratio in an empirical network, a larger variance in node degrees can lead to a higher duplication ratio as the likelihood of the same link appearing in multiple maximal cliques increases. High-degree nodes participate in many cliques, and if their neighbors also belong to overlapping groups, shared links are counted repeatedly. In contrast, in networks where node degrees are more uniform, the chances of a link being reused across multiple cliques are lower. Additionally, if the network exhibits positive degree assortativity, where high-degree nodes preferentially connect to other high-degree nodes, this effect is further amplified, leading to even greater duplication.

Table 2 shows that real networks may have a high duplication ratio. Despite that, in practice Eq. (15) remains accurate and h_c and h_c^0 remain reasonably close. Eq. (3) is best suited for measuring homophily directly from the adjacency matrix, making it useful for assessing network-wide segregation, while Eq. (6) provides a more refined approach for parameter inference in clique-based models, such as the maximum-entropy distribution of clique compositions.

Aggregating node statuses
Consider a discrete spectrum of colors where we aim to combine colors into S < s colors. We can achieve this by merging certain original colors using the mapping function

φ: {1, ..., s} → {1, ..., S} ,

which assigns each original color a new “merged” color φ(k). Say, all shades of blue to blue. After this identification, the new distribution

F_i(j_1, ..., j_S) = \sum_{i_1, ..., i_s} F(i_1, ..., i_s) , \text{where } j_α = \sum_{k:φ(k)=α} i_k

This procedure lumps together all old configurations whose new color composition is j. Although F is a valid probability distribution, it typically does not remain in the same exponential-family form unless every group of merged colors was already indistinguishable in the exponent. In that renormalizable scenario, the new F preserves the same functional shape112. This coarse-graining remains an exponential family without further re-fitting if the original model assigned identical roles to those merged categories. Otherwise, one must solve a new maximum-entropy problem in the reduced color space, and any notion of homophily now reflects only these broader, less granular labels. This is analogous to lumping the s-state Potts model into S=2 (red vs. blue), which does not necessarily result in a simple Ising model with the standard coupling75,76.

Beyond two colors
In the definition of h_c in Eq (6), we have focused on networks where nodes possess binary attributes, such as male and female or red and blue, for the sake of simplicity. However, this framework can be extended to nodes with discrete states or categorical attributes. Each clique network G_c, and consequently the mixed clique network G=⋃G_c, can be extended to a multi-color version. Different colors may represent different social groups, features, or functionalities within the network.

The number of nodes of each color is denoted by N_k where k=1,⋯ ,s, while their fraction over the total number of nodes N is denoted by n_k. For fixed clique size c, each clique type can be uniquely specified by a vector i=(i_1,⋯ ,i_s) encoding the number of nodes of each color in the clique. For example, if s=3 (red, blue, or green nodes) and c=4, the vector (2, 1, 1) corresponds to the 4-clique with 2 red nodes, 1 blue node, and 1 green node. Similarly, as in the 2-color case, different c-clique types and hence s(s+1)/2 different link types can be present.

Multidimensional homophily: beyond colors
Consider nodes characterized by multiple discrete attributes (e.g., color and temperature). To describe cliques, we define a composition vector I, where each element I_j indicates the number of nodes in the clique with attribute combination j, satisfying ∑ I_j = c. Under the maximum-entropy framework, the probability distribution generalizes naturally to:

F_{c,I} = \frac{1}{Z} \exp(\sum_k θ_k ϕ_k(I)) ,

where statistics {ϕ_k} encode relevant constraints (such as homophily per attribute or interactions between attributes), and the conjugate parameters {θ_k} enforce these constraints.

Derivation of the percolation threshold
To analyze the critical percolation value analytically, we map the percolation process on the clique network to a percolation process on a tree-like network by analyzing the spreading within the clique separately from the behavior across cliques. We therefore calculate the average number of infected I_0-cliques caused by a percolated node in an I-clique.

The average number of type I-cliques that are adjacent to a randomly chosen red or blue node equals

F_{r,I}^* := M_c n_{r,I} / N_r, F_{b,I}^* := M_c n_{b,I} / N_b , (20)

where n_{r,I}, n_{b,I} denote the number of red, blue nodes in a type I clique, and M_c the total number of cliques of the same size as I. Furthermore, let π=[π_{rr}, π_{rb}, π_{bb}] be the values quantifying the probabilities that red-red, red-blue, and blue-blue links are kept active after percolation. Finally, let g_r(I,π,n_r,n_b) denote the probability that, after percolation, a randomly chosen red node is still connected to n_r red and n_b blue nodes within the same clique of type I; similarly, g_b(I,π,n_r,n_b) denotes the probability that a randomly chosen blue node remains connected to n_r and n_b nodes within I.

Then, the average number of type I_0 cliques that are reached after percolation from a node of color (*) ∈ {r,b} from a red node in a clique of type I equals

B_{I,I_0}(*) = F_{r,I}^* \sum_{n_b=0}^{n_{b,I}} \sum_{n_r=1}^{n_{r,I}} (n_{r,I} - δ_{r,(*)} ) g_r(I,π,n_r,n_b) : (21)

The term inside the inner summation is the average number of nodes of color (*) in the I-clique that are still connected to the red node after percolation. The term in front is the average number of type I_0 cliques adjacent to (*) colored nodes. The average number of I_0 cliques reached from a blue node in I is denoted by B_{I,I_0}(*), calculated similarly.

Therefore, the matrix B = B(π) encodes the average number of nodes of specific clique types that are reached through percolation starting within another specific clique type. The percolation vector π is critical when there is a vector v, for which

v^2 ker[B(π) - I], v = |v| ≥ 0, (22)

where I denotes the identity matrix. Note that det(B(π) - I) = 0 is a necessary condition for this to hold.

The elements of the matrix B require the probabilities g_r(I,π,n_r,n_b) and g_b(I,π,n_r,n_b). For any clique of type I with n_{r,I} red nodes and n_{b,I} blue nodes, the probability that the clique remains connected after percolation is g_r(I,π,n_{r,I},n_{b,I}) = g_b(I,π,n_{r,I},n_{b,I}). This probability equals one minus the probability that there exists a cut in the clique, and can be written recursively as

g_r(I,π,n_{r,I},n_{b,I}) = 1 - \sum_{j=1}^{n_{b,I}} \sum_{i=0}^{n_{r,I}-1} g_r(I_{i,j},π,i,j) (1-π_{rr})^{i(d_r-i)} (1-π_{bb})^{j(d_b-j)} (1-π_{rb})^{i(d_b-j)+j(d_r-i)} ,

(23)

g_b(I,π,n_{r,I},n_{b,I}) = 1 - \sum_{j=0}^{n_{b,I}-1} \sum_{i=1}^{n_{r,I}} g_b(I_{i,j},π,i,j) (1-π_{rr})^{i(d_r-i)} (1-π_{bb})^{j(d_b-j)} (1-π_{rb})^{i(d_b-j)+j(d_r-i)} :

(24)

From these equations, we can compute g_r(I,π,n,n) when n_r ≤ n_{r,I} or n_b ≤ n_{b,I}, as

g_r(I,π,n,n) = \frac{n_{b,I} n_{r,I}}{n_b n_r} g_r(I_{n_r,n_b},π,n,n) (1-π_{rr})^{n_r(n_{r,I}-n_r)} (1-π_{bb})^{n_b(n_{b,I}-n_b)} (1-π_{rb})^{n_r(n_{b,I}-n_b)+n_b(n_{r,I}-n_r)} ,

(25)

g_b(I,π,n,n) = \frac{n_{b,I} n_{r,I}}{n_b n_r} g_b(I_{n_r,n_b},π,n,n) (1-π_{rr})^{n_r(n_{r,I}-n_r)} (1-π_{bb})^{n_b(n_{b,I}-n_b)} (1-π_{rb})^{n_r(n_{b,I}-n_b)+n_b(n_{r,I}-n_r)} :

(26)

These equations take the probability that a clique with n_r and n_b red and blue nodes remains connected from Eq. (23) and (24), and multiplies it with the probability that these nodes are not connected to any remaining nodes of the clique.

Peer review rounds
[{"round": 1, "reviewer_comments": {"reviewer_1": "This paper describes a new random graph model for heterogeneous homophily in social networks based on random cliques, and a mechanism for fitting it to observational data. Unlike conventional work using, for example, the stochastic block model, the communities within the network are assumed to be known, typically based on categorical attribute data on the nodes, and the goal of the fit is to determine the remaining model parameters, primarily the distributions of cliques and the degree of homophily within each community. The fitted parameters shed light on the extent to which homophily varies with scale in networks, typically being higher in smaller groups of nodes and lower in larger ones. The authors then use their model to analyze how percolation and epidemic properties of networks change with varying degrees of with- and between-group homophily.\n\nThis is an interesting paper. It makes novel points, does so with clarity and rigor, and makes a good case for the variation of mixing with length scale in networks. I recommend acceptance, but have a number of minor points that the authors may wish to address.\n\n1. The authors motivate their approach by saying that previous approaches have assumed a uniform degree of homophily throughout a network, whereas the new model allows for variation. However, there is an intermediate level of analysis between these two extremes, widely adopted in the networks literature, in which homophily varies from community to community within a network, but there is only one length scale for each community: communities may be large or small, have high homophily or low, but each node belongs to only one community, whose size sets the effective length scale for that node. The new model goes beyond this by allowing each node to belong to multiple cliques at different scales, which is an advance, however it is perhaps not entirely fair to say that previous work does not allow for heterogeneity or variation with scale -- it does, but in a different way. (There also exist some older models that do capture homophily at multiple scales, such as hierarchical random graphs and core-periphery models.)\n\n2. Some further motivation for the model would be good. How should I think about these cliques? Why should cliques be the fundamental unit of formation in a social network? A model such as the stochastic block model makes some sense from a social point of view: people with membership of various groups have various probabilities of being acquainted, perhaps because of physical proximity or social commonalities. What is the equivalent mechanism in this case? I understand that the model is a flexible construct for describing homophily on multiple scales, but does it also make social sense as a generative process?\n\n3. The model is not \"degree-corrected\" in the jargon of the networks literature -- it does not allow for the possible (wide) variation of node degrees. The authors do address this point in the \"Conclusion and discussion\" section, but it might be worth mentioning it when introducing the model, to make readers aware of this simplification and avoid possible confusion.\n\n4. Related to point (3), the Coleman index used by the authors (Eq. 3) is described as being a normalized version of modularity, but this is not exactly correct. The Coleman index measures assortativity relative to an Erdos-Renyi style null model with Poisson degree distribution, which would normally be considered unrealistic. The modularity replaces the variable n_k, measuring the fraction of nodes in group k, by another variable measuring the fraction of edge-ends in group k. This simple substitution makes a big difference in real-world situations, so it is worth being clear about this.", "reviewer_2": "In this strong work, the authors make three main contributions: First, they introduce a group-size dependent notion of homophily on networks of pairwise interactions. Second, they formulate an exponential random graph model with a given level of homophily and fit it to empirical networks. Finally, they study the influence of homophily on the percolation threshold and apply their insights to spreading phenomena.\n\nMy overall impression of this work is very positive. The authors honestly engage with classic and recent literature on homophily and modeling of group interactions. Even though one of their key observations—the group-size dependence of homophily in empirical networks—has been made before in the literature on higher-order networks, the pairwise network perspective in the present work makes clear that this is not a curiosity that is only worth studying in hypergraphs. I believe that this work will receive broad attention from the network science and computational social science community by making the issue of group-size dependent homophily known outside the circles studying higher-order structures. The results in the manuscript are mathematically well-motivated and come with clear derivations. The balance of details between the main text and the appendix is reasonable and results in a good flow of the manuscript. The authors’ results on percolation are interesting to me for two reasons: First, the multi-type branching process framework is conceptually insightful, and I found it to be quite elegant. Second, I found the authors’ measure of homophily to be a really useful lens through which to examine contagion and interventions in new ways.\n\nI have a few minor critical remarks about the manuscript, which I’m sure the authors can address. Ultimately, after these changes, I strongly endorse this article being published in Nature Communications.\n\nSpecific comments and requests for changes:\n\n1. The authors point out that their model will generate sparse graphs, because they set the number of cliques of size c as Mc = O(N), where N is the number of nodes, and thus obtain Ec = cMc = O(N) links per clique-layer and (neglecting overlap) to E = ∑cmax c=2 Ec = O(N) edges in the whole network. This does, however, implicitly assume that the size of the largest clique cmax does not scale with N. This observation is certainly defensible, but I think the manuscript would improve by having it more explicitly discussed (maybe as an SI subsection).\n\n2. I would ask the authors to clarify the assumptions underlying their maximum likelihood fitting procedure: One potential concern is that an edge in an empirically observed graph could be generated (in the model) at multiple, different clique sizes. The authors address this concern in the appendices, where they show that under the model, clique overlap is (in first order approximation and under mild assumptions) negligible. However, in many datasets on group interactions, the same nodes participate in interactions of different sizes. This phenomenon is studied under the name of hyperedge overlap in the literature on hypergraphs. I wonder whether this tendency in real-world data leads to model misspecification for the authors’ clique-based generative model?\n\n3. Figure 1a: I kept staring at this — aren’t there 2 blue-blue edges, 2 blue-red edges, and 4 red-red edges? This would mean that the purple bar in the histogram should be the same height as the blue one, right?\n\nMinor comments:\n\n1. Introduction, Paragraph 2: “Gender homophily, in particular, is sensitive to both medium and group size.” Does “medium” here refer to the platform or domain of interest? Or is there a missing word (e.g. “medium and large group size.”)? Or should “medium” be “tie strength”?\n\n2. (Very minor) Figure 1, caption: I believe the “With two colors, each ...” bit is meant to be un-bolded.\n\n3. (Very minor) Figure 1, caption: “...homophily levels of h5 = 0.2 and h5 = 0.6, across several values...” h5 = 0.0 was omitted from this but is included in the figure.", "reviewer_3": "I co-reviewed this manuscript with one of the reviewers who provided the listed reports. This is part of the Nature Communications initiative to facilitate training in peer review and to provide appropriate recognition for Early Career Researchers who co-review manuscripts."}, "author_response": "Dear Reviewers,\nThank you for your constructive comments and thoughtful feedback, which have significantly strengthened the manuscript. We have revised our manuscript further to address the remaining concerns. Below, we provide our point-to-point reply to each of the comments. All changes below are highlighted in the tracked-changes version of the manuscript. We hope that you will find the revised manuscript suitable for publication.\n\nReviewer #1\n\nResponse:\nThis is a valid point, and we appreciate the reviewer for bringing it to our attention. Indeed, the literature already contains models that address homophily at fine levels, including node-level formulations such as the work of Leto et al., which we cite in the sentence “These observations suggest that homophily is influenced by both group composition and size, underscoring its variability across different social scales”.\nTo avoid any chance of misrepresenting the state of the literature and our contributions, as brought up by the reviewer, we have revised the manuscript in the following places:\nIn the abstract, we have reformulated the sentence:\n“Yet existing approaches typically collapse homophily to a single scale, either one parameter for the whole network or one per community, thereby detaching it from other structural features.”\nMoreover, when discussing in the introduction existing network models that treat homophily as a single-scale parameter, we have included the following sentence:\n“On the other hand, models with explicit community structure, such as the Stochastic Block Model, allow different homophilies across communities but typically assign each node to a single group (and thus a single effective length scale), so they cannot capture overlapping, multiscale affiliations in which a node simultaneously participates in groups of different sizes.”\nFinally, to better position our contribution in this context and to clarify that by 'different scales' we mean cliques of varying sizes, we have revised:\nA) the Introduction:\n“We introduce a network model that allows for homophily to operate across the network scale and scales of various finite social groups. These groups are operationalized by cliques, which serve as natural building blocks of human interactions…”\nB) the opening of the Model Description (Section II). The updated text now reads as:\n“We introduce a generative maximum-entropy model that both fits empirical data and provides mechanistic insight, while serving as a statistical framework for inferring group-level variations in homophily. The model is a random graph construction designed to capture homophily across multiple social scales (clique sizes).”\n\nResponse:\nThis is an excellent question, and we thank the reviewer for raising it. To begin with, when our model is restricted to cliques of size two, it reduces exactly to the stochastic block model (SBM). Thus, any structure representable by the SBM is a special case of our framework. From this perspective, the SBM can be interpreted as a dilute model that emphasizes pairwise interactions between communities, whereas our formulation offers finer control over group composition and the distribution of homophily across multiple social scales.\nThe social justification for our modeling choice for cliques is that social networks can be viewed as the aggregated imprint of group interactions of varying sizes and compositions. Human relationships often take place in group contexts. In this sense, the clique functions as an “archetypical structural pattern” which captures a meeting of a group of people. Thus, our model represents, for example, a social setting in which different groups of people meet in different contexts. Whereas in the SBM, the different groups are typically large (scale with the network size), our groups are of bounded size, and therefore, assuming clique-like interactions is reasonable.\nSmall social groups have been recognized as a mechanism for generating social networks by many seminal sociologists, who laid the foundations for the field. We appreciate the reviewer pushing us to recognize that this should not be taken for granted, and we have now added citations to such work by Simmel, Granovetter, and Feld, together with a short description of what the social mechanisms behind such groups could be. The 4th paragraph of the introduction now reads as:\n“We introduce a network model that allows for homophily to operate across the network scale and scales of various finite social groups. These groups are operationalised by cliques, which serve as natural building blocks of human interactions. The cliques can represent various social foci [62] and social circles [39, 63], which can consist of families, workplaces, organisations, friendship groups, and other social, physical, legal, or psychological entities. In our framework, ...”\n\nResponse:\nWe thank the reviewer for this helpful remark. We now state this simplification explicitly when introducing the model and have updated the first paragraph in Model Description as follows:\n“We introduce a generative maximum-entropy model that both fits empirical data and provides mechanistic insight, while serving as a statistical framework for inferring group-level variations in homophily. The model is a random graph construction designed to capture homophily across multiple social scales. Rather than enforcing node-specific degree constraints, we fix only the average degree, allowing node degrees to fluctuate around the mean, yielding an approximately Poisson distribution. ”\n\nResponse:\nWe thank the reviewer for this necessary clarification. Given the design of our model, we were taking the null model to be an ER graph. Therefore, Eq. (3) was the Coleman homophily index, which could be written as the ER-null modularity normalized by its maximum. While modularity is sometimes formulated with this alternative null model, this indeed differs from the standard Newman–Girvan modularity, which uses the configuration-model null and replaces node fractions with edge-end fractions, thereby incorporating degree heterogeneity. We are sorry about this apparent omission, which was likely removed during some editing round of our manuscript.\nAfter deliberation, we realised that any comparison with modularity would require significantly more opening up and would bring very little overall to the manuscript. We have therefore decided to remove the sentence after equating Eq. (3) about modularity, as this clarification does not affect the flow or substance of the paper.\n\nReviewer #2\n\nResponse:\nThank you for raising this point. We agree that, in theory, allowing many large cliques could compromise sparsity. In practice, however, we sample progressively fewer large cliques, consistent with empirical observations that large groups are rare due to cognitive and social constraints (“schisming”). Accordingly, we assume c_{\\max} is finite (or grows slowly enough that \\sum_c c\\,M_c=O(N)) and take M_c=O(N). This maintains sparsity and keeps edge overlap negligible in our datasets. For intuition, this is analogous to the Erdős–Rényi case, where choosing small values for p yields sparse graphs.\nWe have added a paragraph to the Methods section explaining the conditions for sparsity in more detail. Moreover, we have now updated the opening of the last paragraph in the Modeling Description to make the case more straightforward:\n“Since cliques are sampled independently and we require the largest clique size to be finite, setting M_c = \\mathcal{O}(N) ensures that each layer G_c remains sparse and that the fraction of overlapping links vanishes in the large-network limit.”\n\nResponse:\nThank you for bringing this up. We agree that, in principle, an observed edge could arise from cliques of different sizes. In our model, however, independently sampled cliques with bounded maximum size imply that such overlap vanishes in the thermodynamic limit, so edge “double counting” is negligible asymptotically. For finite empirical graphs, we make this explicit with the duplication ratio 𝛅_c in Methods Table II, which quantifies link reuse among maximal c-cliques in the data. As shown in Table II, even when 𝛅_c is non-zero, the homophily measured from edges in the c-layer (h’_c) closely matches the clique-based estimate (h_c) within bootstrap confidence intervals, supporting the validity of the approximation. Thus, the effect of link overlap on our model seems limited for the data sets we have used, even though the link overlap can be high.\nIn practice, before using the model as an inference baseline, we compute and report 𝛅_c. If it is small, the approximation holds and Maximum Likelihood Estimation is well-behaved; if large and color-biased, we flag the limitation and avoid over-interpreting clique-level parameters. Our likelihood is based on the composition counts of maximal cliques (rather than all cliques), which prevents double-counting of sub-cliques and reduces overlap by design. For static graphs, we decompose the network into maximal cliques by size; for event-based data, one can treat events directly as cliques or aggregate to a static graph, in both cases reporting 𝛅_c as a validation step. Section 3 of the Methods part is now improved to clarify these experiments in the sentences:\n“Table II shows that real networks may have a high duplication ratio. Despite that, in practice, Eq. (15) remains accurate, and h_c and h'_c remain reasonably close. “\n\nResponse:\nThank you for noticing this. We have now updated our schematic figure to fix this issue.\n\nResponse:\nBy ‘medium’ we mean ‘context’. So, homophily is sensitive to the interaction context and size. Thanks for noticing that this may not be clear for the reader. We changed the word to interaction context to make it more straightforward.\n\nResponse:\nThank you for this point. We removed unintended bolding in the sentence beginning and corrected the typesetting. It is more readable now.\n\nResponse:\nThanks again. It is now mentioned in the caption.\n\nReviewer #3\n\nResponse:\nMany thanks for your time, and all the best for your future endeavors."}, {"round": 2, "reviewer_comments": {"reviewer_1": "The authors have dealt forthrightly with my comments from the first round of reviews. I recommend publication without further changes.", "reviewer_2": "I'm pleased with the authors' responses to the points raised in these reviews. The original submission was already quite strong, and this new version has satisfied the few small concerns. I'm looking forward to seeing this paper progress.\n\nSmall note (note sure if this is for the authors or the journal) -- the codeocean platform is great, but I couldn't do the \"Reproducible Run\" due because \"Access to create Capsules in the OSL is available for publishers and collaborating institutions. If you need to publish a Capsule in an article, please reach out to support@codeocean.com information about your publication for assistance.\"\nFrom what I looked at the code seems very well-documented, clear, and reproducible.", "reviewer_3": "I co-reviewed this manuscript with one of the reviewers who provided the listed reports. This is part of the Nature Communications initiative to facilitate training in peer review and to provide appropriate recognition for Early Career Researchers who co-review manuscripts."}, "author_response": ""}]

Decision letter