R/randomize.R

Defines functions randomize

Documented in randomize

randomize <- function(network){
  random <- matrix(sample(network), nrow = nrow(network))
  ndiag <- sum(diag(random))
  diag(random) <- -1

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

Try the nem package in your browser

Any scripts or data that you put into this service are public.

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