  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 $F_c$. For $F{<}F_c$ large, homogeneous, and well
separated communities can be identified within which the features match almost
perfectly (segregated phase). When $F$ becomes larger than $F_c$, 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.
