randomize: Randomize network

Description Usage Arguments Examples

View source: R/randomize.R

Description

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

Usage

1
randomize(network)

Arguments

network

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
##---- 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)
}

nem documentation built on April 23, 2021, 3 p.m.

Related to randomize in nem...