randomize {nem}R Documentation

Randomize network

Description

Return randomized binary network with the same density as the initial network. Loops are not assumed. The randomized network is asymmetric.

Usage

randomize(network)

Arguments

network

the binary network, of class matrix, that has to be randomized

Examples

##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
randomize <- function(network){
  random <- matrix(sample(network), nrow = nrow(network))
  ndiag <- sum(diag(random))
  diag(random) <- -1

  random[sample(which(random == 0), replace = F, size = ndiag)] <- 1
  diag(random) <- 0
  return(random)
}

[Package nem version 0.12.33 Index]