stir_ER: Stir an Erdos-Renyi Random Network

View source: R/stir_ER.R

stir_ERR Documentation

Stir an Erdos-Renyi Random Network

Description

Stirs an already existing network by rewiring a node according to the Erdos-Renyi random mechanism.

Usage

stir_ER(matrix, x, p, directed = TRUE, retcon = FALSE)

Arguments

matrix

Existing network to experience growth.

x

The ID of the node to be rewired (stirred).

p

Probability possible edges exist. Needs to be between zero and one.

directed

Binary variable determining if the network is directed, resulting in off-diagonal asymmetry in the adjacency matrix.

retcon

Binary variable determining if already existing nodes can attach to new nodes. Defaults to FALSE.

Details

Different from Duplication & Mutation models in that edges can only be lost.

Value

An adjacency matrix.

References

Erdos, P. and Renyi, A., On random graphs, Publicationes Mathematicae 6, 290–297 (1959).

Examples

# Import netcom
library(netcom)

size <- 10
existing_network <- matrix(sample(c(0,1), size = size^2, replace = TRUE), nrow = size, ncol = size)
new_network_prep <- matrix(0, nrow = size + 1, ncol = size + 1)
new_network_prep[1:size, 1:size] = existing_network
new_network <- stir_ER(matrix = new_network_prep, x = size + 1, p = 0.5)


langendorfr/netcom documentation built on July 23, 2022, 5:19 p.m.