add_random_module_to_network: Adds a random module of a given size to the network

Description Usage Arguments Value Examples

View source: R/networks.R

Description

Adds a random module of a given size to the network

Usage

1
add_random_module_to_network(network, module_size, ...)

Arguments

network

The 'network' object to modify.

module_size

The size of the module to generate.

...

Additional arguments passed into random_module().

Value

The modified 'network' object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# This function provides an alternative way to iteratively add random
# modules to the network. It uses a weighted sampling of nodes, where
# nodes that haven't been selected for a module have a higher probability 
# of being sampled for the new module.
nw <- create_empty_network(100)
plot(nw) # An empty network of 100 nodes.
# Add random modules of size 10 to the network, 1 at a time.
# By plotting the network each time, we can watch it grow.
set.seed(12345)
plot(nw <<- add_random_module_to_network(nw, 10))
plot(nw <<- add_random_module_to_network(nw, 10))
plot(nw <<- add_random_module_to_network(nw, 10))
plot(nw <<- add_random_module_to_network(nw, 10))
plot(nw <<- add_random_module_to_network(nw, 10))
plot(nw <<- add_random_module_to_network(nw, 10))
# Etc.

SeqNet documentation built on Dec. 19, 2019, 1:06 a.m.