Structural transition in social networks: The role of homophily

We introduce a model for the formation of social networks, which takes into account the homophily or the tendency of individuals to associate and bond with similar others, and the mechanisms of global and local attachment as well as tie reinforcement due to social interactions between people. We generalize the weighted social network model such that the nodes or individuals have F features and each feature can have q different values. Here the tendency for the tie formation between two individuals due to the overlap in their features represents homophily. We find a phase transition as a function of F or q, resulting in a phase diagram. For fixed q and as a function of F the system shows two phases separated at Fc. For F < Fc large, homogeneous, and well separated communities can be identified within which the features match almost perfectly (segregated phase). When F becomes larger than Fc, the nodes start to belong to several communities and within a community the features match only partially (overlapping phase). Several quantities reflect this transition, including the average degree, clustering coefficient, feature overlap, and the number of communities per node. We also make an attempt to interpret these results in terms of observations on social behavior of humans.

constraints? They also discussed that "A thorough answer to this question would require the use of simulation models, in which choice homophily as well as focal and cyclic closure biases could be systematically varied". The purpose of this paper is to contribute to answering this question by studying the macroscopic consequences of the joint effect of focal and cyclic closure mechanisms.
To this end, we develop a model based on the weighted social network (WSN) model 7 . In the WSN model two main mechanisms for the tie-formation process were used, namely local attachment (LA) and global attachment (GA), corresponding to triadic and focal closure, respectively, together with link strength reinforcement. With this minimal model the complex Granovetterian weight-topology relation of social networks could be successfully reproduced 7 . More recently, this model was generalized to temporal and multiplex networks 17,22,23 .
In this paper the WSN model is generalized to enable homophilic relationships. We introduce features of the individuals (represented by the nodes of the network) in the spirit of the classical Axelrod model 24 by modeling the different traits of a node with components of an F-dimensional vector. The Axelrod model was intensively investigated by San Miguel and coworkers [25][26][27][28] focusing mainly on the problem of cultural drift and fragmentation by applying dynamic rules to describe the changes of the features of the nodes upon interactions. In most cases fixed network geometries were applied, except in ref. 27 , where the effect of network adaptation was studied. Here we take a different approach by considering the features fixed and model the tie formation based on homophilic interactions as suggested by social network theory. We show that homophily has a major impact on the emerging network structure. Depending on the number F of features there is a transition from a few large and homogeneous communities to many smaller and heterogeneous ones. The possible number q of different values a feature can take is also a relevant parameter and we show that a scaling relationship between the average degree of nodes, F, and q is approximately valid.
The paper is organized as follows: After we define the model in the next section, we demonstrate that the model exhibits two regimes depending on the parameter values. We also show that the similarity between nodes is very much amplified in one of the phases, and show that a global segregation is observed. Finally, we present a summary and discussion in the last section.

Model
First we briefly review the original weighted social network (WSN) model proposed in refs 7,17 , which is a dynamic, undirected, weighted network model leading to a stationary state. We start with N unconnected nodes and links between them are created and updated with the following three mechanisms: i. global attachment (GA): A node is selected at random, its degree is k. With probability δ 0,k + (1 − δ 0,k )p r it is connected with a new link of weight w 0 to a randomly chosen node. In the unlikely event that the two nodes are already connected, a new target node is chosen. ii. local attachment (LA): A randomly chosen node i (with k i ≠ 0) chooses one of its neighbors j with the probability proportional to w ij which stands for the weight of the link between nodes i and j. Then node j chooses one of its neighbors but i, say k, randomly with probability proportional to w jk and if nodes i and k are not connected, they are connected with probability p Δ with a link of weight w 0 . In addition, all the involved links increase the weights by w r , whether a new link is created or not. iii. link deletion (LD): Each link is removed from the system with probability p d at each time step. (Time is measured in sweeps).
Sequential update is applied, first GA, then LA to the nodes and then LD to the links. Over the wide range of the parameters this model produces Granovetterian structures with strongly wired communities connected by weak ties 7,17 .
In order to incorporate the effect of homophily into the model we extend the WSN model in the following way. Similarly to the Axelrod model and its variants [24][25][26][27][29][30][31] , we assign a vector of F components to each node i, corresponding to F different features of the node (related e.g. to gender, ethnicity, language, religion, etc.). Each feature can take one of q possible values. Then the feature vector of node i is a set of F integers: ( , , , ) The size of the vector, F, represents the social complexity of the population, i.e., the larger F implies the greater number of cultural characteristics that are attributable to each individual. The number of traits per feature, q, represents the heterogeneity of the population: The larger q means the greater number of cultural options in the society. Although F may depend on individuals and q may be different for each feature in reality, for simplicity we assume all nodes to have the same F and keep q constant. These will be parameters of our model.
The feature values or traits of the nodes are initially chosen to be uniformly random and then kept unchanged. This set-up is different from those in studies of the Axelrod model [24][25][26] , where traits change as a consequence of interaction with similar neighbors. People in reality have both changeable and rigid traits, and the degree of the changeability may also depend on the individual and cultural properties. In this paper we study the case with fixed traits as it is the simplest setting to provide a baseline for better understanding of the impact of homophily on the network structure. We will show that segregation may occur even without a trait changing mechanism, just as a consequence of tie formation influenced by homophily.
In our homophilic WSN model, the network is updated similarly to the simple WSN model but the features of nodes are taken into account, as shown in Fig. 1. In each GA and LA step, a feature f of the focal node i is randomly chosen from F features and it can make links only to the nodes sharing the same trait for the feature f, i.e., only to the nodes j satisfying σ σ = j f i f . More specifically, in a GA step, the node i chooses randomly a node, say j, sharing the same trait for the feature f in the network. If the node i has any neighbor sharing the same trait for the feature f, then the link between i and www.nature.com/scientificreports www.nature.com/scientificreports/ j is created with probability p r . Otherwise, the link is created with probability one. The weight of the created link is given as w 0 . In the LA step, among i's neighbors sharing the same trait for the feature f with i, choose a node, say j, with probability proportional to their link weights. Then, the node j chooses a random node, say k, among j's neighbors sharing the same trait for the feature f but i with probability proportional to the link weights. It implies All the links included in this triangle increase their weights by w r . If nodes i and k are not connected, a link between them is created with probability p Δ and its weight is set to w 0 . Note that this model reduces to the original WSN model when q = 1, because every node pair shares the same trait, i.e., σ =1 i f for all i and f. When F = 1, the network is decomposed into q disjoint subgraphs since the nodes with different traits have no chance to be connected, while the model dynamics in each subgraph is equivalent to the original WSN model but with a smaller system size of ~N/q.
Starting with a network with no links, GA, LA, and LD are applied in each time step. After a sufficiently long equilibration period, ranging from 5 × 10 4 to 8 × 10 5 Monte Carlo steps in our work depending on the relaxation time, statistically stationary states are reached. In the following, N = 50000, p Δ = 0.02, p r = 0.001, p d = 0.005, w r = 1 are used. In this study, OACIS was used for a systematic parameter scan 32 .

Results
First, we show the dependence of the average degree on F and q in Fig. 2(a). For q > 1 we find two regimes: The average degree decreases as F increases up to a certain value, F c , then it increases for F > F c . Such non-monotonic dependence is also observed for the clustering coefficient in Fig. 2(b). The clustering coefficient shows increasing and decreasing behaviors for F < F c and F > F c , respectively, hence it has a peak at around F c , implying that the network structure qualitatively changes at around F c .
The transition point F c depends on the WSN parameters but, more importantly, also on q; as it is clear from Fig. 2 the function F c (q) is decreasing. Consequently, for a given F a similar transition takes place as a function of q thus one can define q c (F).  www.nature.com/scientificreports www.nature.com/scientificreports/ To investigate what is happening at the transition point, we measure how many of the features are shared between the neighboring nodes. We define the feature overlap between nodes i and j as the fraction of shared features: Figure 3(a) shows the feature overlap averaged over the connected node pairs, 〈o F 〉, as a function of F. 〈o F 〉 stays close to 1 in the low F phase indicating that most of the links are created between the nodes having completely identical features. Hereafter, we denote the nodes having o F = 1 as "matching nodes". On the other hand, as F becomes greater than F c , the feature overlap quickly drops from unity and converges to a value slightly greater than 1/q. Due to the above results we denote the two regimes of F < F c and F > F c as "segregated" and "overlapping" phases, respectively, since nodes are segregated into loosely-connected homogeneous communities in the former phase, while the majority of the communities overlap with each other in the latter phase. The corresponding phase diagram is shown in Fig. 4(a).
Let us shed light onto the origin of the transition. Since the feature values are drawn from a uniform discrete distribution from {1, …, q}, the number of nodes sharing a specific set of traits is on average Ñ ≈ N/q F . The transition occurs when Ñ becomes less than the typical degree for the original WSN model. For instance, the transition point F c = 4 for q = 5 leads to Ñ = 5 × 10 4 /5 4 = 80, which is of the order of the average degree 47 for the original WSN model with the same parameters. Therefore, we expect that N/q F is a scaling variable for the average density, see Fig. 4(b).
By the model definition, each node has a strong tendency to connect to matching nodes as long as a matching node can be found, i.e., in the segregated phase. In the overlapping phase, on the other hand, the chance to find  www.nature.com/scientificreports www.nature.com/scientificreports/ matching nodes becomes small thus the feature overlap cannot be one anymore. The nodes compromise with partially matching nodes as few matching nodes exist in the whole population.
When F < F c , the average degree decreases as a function of F as shown in Fig. 2(a). This is because the number of matching nodes Ñ, which is equal to the number of potential neighbors, decreases with F. The opposite behavior is found in the other phase, where the nodes are connected to others that share at least one feature. The number of nodes sharing at least one feature is calculated as N[1 − (1 − 1/q) F ], which is an increasing function of F. Since there is no chance for building communities of matching nodes for F > F c the nodes have more potential neighbors with increasing F thus they will have higher degrees. The spike found in the clustering coefficient [ Fig. 2(b)] can also be explained similarly. When F gets closer to F c in the segregated phase, the number of potential neighbors decreases and eventually becomes the same order as the degree. Since nodes are partitioned into groups of matching nodes and its size is comparable to the average degree, the nodes within a group are mostly connected to each other, while the number of links bridging the groups is small. Thus, the network is mostly composed of q F clique-like components, yielding a high clustering coefficient as well as a high assortativity (not shown).
This transition behavior cannot be simply explained by the naive assumption that the probability of making a link is proportional to o F . Let us consider a null model in which links are randomly created between nodes i and j with a probability proportional to o F (i, j). The expected number of links between the node pairs having o F = n/F is given by the binomial form as where c is a coefficient for the probability of creating links. Therefore, the average feature overlap in the network is calculated as This null model predicts a smooth monotonic decrease without a transition with increasing F [see Fig. 3(a)], which is significantly different from the simulation results and with which it agrees only asymptotically.
Next we test a model with GA and LD but without LA by setting p Δ = 0. The results in Fig. 3(a) do not show a transition and reproduce a curve similar to the null model. Thus, a key ingredient for the transition is the presence of LA rule. In other words, LA promotes a much stronger preference in link formation between matching pairs than predicted by the null model. Indeed, the link reinforcement in LA plays here a key role as initially minor differences between the probabilities of choosing neighbors with perfect matching and partial overlaps get strongly amplified due to the positive feedback produced by the weight-dependence at the selection of the neighbors. As a consequence, the links created by triadic closures are almost always between matching nodes in the segregated phase. This argument has been numerically confirmed by disabling the link reinforcement by setting w r = 0 while keeping a positive p Δ , as shown in Fig. 3(a).
While the above amplification effect exists in the overlapping phase too, it cannot fully develop as the low number of available matching nodes results in a partial overlap. For instance, even when nodes A and B are both connected to C and differ in their traits from those of C's in one feature only, when A and B get connected by cyclic closure their traits may differ already in two features. Thus, the feature overlap between neighbors significantly decreases when nodes cannot connect to matching nodes.
The fact that 〈o F 〉 ≈ 1 in the segregated phase indicates that the nodes in the network form q F communities, each of which mostly consisting of matching nodes. Whether this segregation sets in or not depends on the value of F: At F c the network structure changes from large homogeneous, segregated clusters to smaller more heterogeneous groups. This transition can be directly observed by applying the community detection to the generated networks. We use the multi-level Infomap algorithm 16 to detect a hierarchical structure of the communities. Since we are interested in the global segregation, we pick up the communities on the top of the hierarchy, and their overlap is measured by the number of communities per node as shown in Fig. 3(b) as a function of F. We clearly see two distinct regimes. When F < F c , we have homogeneous communities consisting mainly of matching nodes thus the number of communities per node is close to one, indicating that there is little overlap of the membership between communities. For F > F c the feature overlap between linked nodes is suppressed. As a consequence, the membership overlap between communities increases, which works against segregation. This is why we named the two phases as segregated and overlapping phases.
These differences are illustrated in Fig. 5(a) where the egocentric network of a typical node is shown, and clearly all acquaintances have identical traits, i.e., matching nodes. There are, however, some (~5%) nodes which connect these large homogeneous communities. A typical example of these connecting nodes is shown in Fig. 5(b). Near the transition point, as shown in Fig. 5(c), a node typically has a smaller degree and shares less feature with its neighbors than those in the segregated phase. Figure 5(d) shows a sample from the overlapping regime. The ego is a part of more distinct communities that have small feature overlap because of a large q, as shown in Fig. 3(a). As nodes are part of more and more communities the number of communities per node increases as shown in Fig. 3(b).
Another way to investigate the segregation is to see information spreading on the network. We simulate the susceptible-infected (SI) dynamics 33 on the networks assuming that the transmission probability is simply proportional to link weights, irrespective of the features of nodes. The information starts to spread from a randomly chosen node and the fraction of infected nodes are calculated until all the nodes become infected. The SI model is able to detect the influence of the topology and the link weights onto the spreading speed 20,34 . Figure 6 shows www.nature.com/scientificreports www.nature.com/scientificreports/ typical dynamics of spreading on the networks for F = 2 (segregated phase) and F = 8 (overlapping phase) when q = 5. These two networks have been chosen because they have similar average degrees (46.5 and 47.4, respectively) and average link weights (21.8 and 21.3, respectively). Although these two networks have comparable local network statistics, the spreading for the segregated phase is much slower than that for the overlapping phase. In the segregated phase, the spreading is trapped in a community of matching nodes: It takes a longer time to convey information to a node having different features than for the overlapping phase, in which spreading between different groups occurs more easily.

summary and Discussion
In this paper we have generalized the weighted social network model to incorporate homophily and to study its effect on the emerging network structure. We introduced F features for each node and every feature could have q different values. The GA and LA steps were made then dependent on the overlap between the nodes' features. The model shows two phases depending on the parameters F and q. For a given value of q and F < F c the nodes in the whole network are segregated into non-overlapping communities, consisting mostly of matching nodes. On the other hand, when F > F c , such segregation is not observed. Nodes partially share features with their neighbors yielding significantly larger amount of overlapping communities. Thus, if the selection mechanism of acquaintances is based on very few features (F is small) and/or if traits a feature can take are limited only to few options (q is small), then the society will be segregated.
What is the relevance of this finding, considering that in reality every person has a large number of features? We note that the features are not equally important in tie formation. There are cultures and situations, in which a few features get extreme importance. This is the case, in times of sharpening political situations, turmoils or wars. Another relevant example can be social groups in the online social networks, where people get into contact based on very few features. This (especially if amplified by the mentioned political conditions) leads then to the When a feature of an acquaintance is identical to that of the ego it is colored otherwise left white. In the segregated phase, a node is typically connected to its matching nodes (a) while a small fraction of nodes have links to a few other types of nodes, bridging communities (b). (c) A node has a smaller degree, and some of its neighbors are not matching nodes. (d) Feature overlap between neighboring nodes becomes even less and the ego belongs to more diverse communities.
www.nature.com/scientificreports www.nature.com/scientificreports/ well-known effect of "echo chambers" 35 and our results indicate that perceiving the complexity of the world or allowing for more subtle opinions can break up these bubbles.
The overlapping phase is thus a more realistic model of a normal society where one has acquaintances of different gender, age, location, political view, sport preference, etc. Each of these traits has its own communities in which there is no perfect feature overlap. For example, why should we do sports with people of the same political preference?
We demonstrated that the feature similarity between nodes can be much more amplified if the local attachment mechanism is taken into account. In other words, the homophily principle and the local attachment mechanism including reinforcement have a joint effect in increasing segregation in social networks. Our study implies strategies to avoid segregation and splitting of the society by maintaining cultural diversity.
The relationship between homophily and segregation has been recognized long ago. In the Schelling-type models 2,36 people change their position in a fixed geometry (usually a lattice) to better satisfy their preferences. In another approach to social segregation, opinion dynamics is used so that similar people can influence each other [24][25][26]37,38 . In these models similarity is amplified by the changes in the opinions (or features). The model proposed in this paper has a different mechanism. Our aim was to investigate how homophily influences the social network if such elementary tie formation mechanisms like focal and cyclic closure (mimicked by our model as GA and LA, respectively) are taken into account. Our conclusion is that social segregation may be intensified by LA and link reinforcement even without changing the features in interactions. For more realistic modeling, we can of course think of a combined model incorporating both the feature updates and the triadic closure with reinforcement. Although we leave it for future studies, we expect that the segregation is observed in a wider range of parameter space as the feature updates promote segregation in general.
There are many further ways to extend our model and make it more realistic. A possible extension is to allow different q values for each feature. This is a much more realistic setting and will be necessary, when comparing with a data. Also, individual differences in the number of features could be considered.

Data Availability
All data generated or analyzed during this study are included in this published article. Figure 6. Information spreading on the networks obtained for F = 2 (segregated phase) and 8 (overlapping phase) when q = 5. Simulations of the SI model are conducted where the spreading probability is assumed to be proportional to the link weights. Note that the unit of the horizontal axis is arbitrarily scaled without loss of generality. The infection starts from a randomly chosen node and continues until all the nodes are infected. Even though these two networks have similar degree and average link weight, the spreading speed in the overlapping phase is approximately two times faster than for the segregated phase. These are the results of single Monte Carlo runs.