Generate an edge dataframe from an Erdos-Renyi network. An edge will occur between two nodes with a uniform common probability.

sim_random_network(
  n_nodes = 5,
  prob_of_edge = 0.7,
  allow_self_edges = FALSE,
  setup_model = FALSE,
  random_seed = NULL
)

Arguments

n_nodes

Total number of unique nodes to simulate

prob_of_edge

Probability of any given edges between two nodes occuring

allow_self_edges

Should nodes be allowed to have edges to themselves?

setup_model

Should an SBM model object be added? Set to FALSE if network is just being visualized or described.

random_seed

Integer seed to be passed to model's internal random sampling engine. Note that if the model is restored from a saved state this seed will be initialized again to the start value which will harm reproducability.

Value

An S3 object of class sbm_network. For details see new_sbm_network section "Class structure."

See also

Examples

# Basic random network sim_random_network(n_nodes = 10, prob_of_edge = 0.5)
#> SBM Network with 10 nodes of a single type and 24 edges. #> #> Nodes: # A tibble: 6 x 3 #> id block type #> <chr> <chr> <chr> #> 1 node_1 node node #> 2 node_2 node node #> 3 node_3 node node #> 4 node_4 node node #> 5 node_5 node node #> 6 node_6 node node #> ... #> #> Edges: # A tibble: 6 x 3 #> from to edges #> <chr> <chr> <dbl> #> 1 node_1 node_2 1 #> 2 node_1 node_4 1 #> 3 node_1 node_5 1 #> 4 node_1 node_6 1 #> 5 node_1 node_7 1 #> 6 node_1 node_8 1 #> ... #>
# Simulate a fully connected network by setting probability of edge to 1 sim_random_network(n_nodes = 10, prob_of_edge = 1)
#> SBM Network with 10 nodes of a single type and 45 edges. #> #> Nodes: # A tibble: 6 x 3 #> id block type #> <chr> <chr> <chr> #> 1 node_1 node node #> 2 node_2 node node #> 3 node_3 node node #> 4 node_4 node node #> 5 node_5 node node #> 6 node_6 node node #> ... #> #> Edges: # A tibble: 6 x 3 #> from to edges #> <chr> <chr> <dbl> #> 1 node_1 node_2 1 #> 2 node_1 node_3 1 #> 3 node_1 node_4 1 #> 4 node_1 node_5 1 #> 5 node_1 node_6 1 #> 6 node_1 node_7 1 #> ... #>