Skip to contents

Creates a network with an arbitrary number of groups of arbitrary size with arbitrary homophily levels. Homophily can take values from -1 (totally anti-homophilous) to +1 (totally homophilous), and 0 indicates equal probability of connecting within group as between groups. The algorithm builds the network by first assigning all within-group edges.

Usage

make_homophily_network(
  group_sizes = c(3, 7),
  mean_degree = 2,
  homophily = c(0),
  group_names = NULL,
  add_to_complete = FALSE
)

Arguments

group_sizes

The population (size) of each group

mean_degree

Desired mean degree

homophily

Singleton or vector; if vector must be length of group_sizes

group_names

Optional parameter to specify group names

add_to_complete

Boolean to specify whether to complete the network if there's only one group left needing out-edges

Value

igraph Graph

Examples

# Two groups size 5 and 10.
hnet_2grp <- make_homophily_network(c(5, 10), mean_degree = 3, homophily = 0.5)
plot_homophilynet(hnet_2grp)


# Five groups all size 5 with out-group preference (neg. homophily).
hnet_5grp <- make_homophily_network(rep(5, 5), mean_degree = 2, homophily = -0.5)
plot_homophilynet(hnet_5grp)