Usage Arguments Value Examples
1 |
type |
a |
randomShare |
a level of errors (a single value between 0 (ideal network) and 1 (random network)) |
symmetric |
should the network be symmetric |
n |
number of unnits in a network |
size |
specify the size of each cluster; specify the vector of sizes (the elements of the vector have sum to 1) |
The function returns a binary network of class matrix
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (type = type, randomShare = 0.4, symmetric = F, n = 42,
size = c(1/3, 1/3, 1/3))
{
initialNetwork <- gen.network(type = type, errors = 0, symmetric = symmetric,
n = n, size = size)
newNetwork <- initialNetwork
kriterij <- (1 - (sum(initialNetwork == 1)/length(initialNetwork))) *
randomShare
if (randomShare != 0) {
while (mean(newNetwork[which(initialNetwork == 1)] ==
0) <= kriterij) {
newNetwork[sample(which(newNetwork == 0), size = 1)] <- 1
newNetwork[sample(which(newNetwork == 1), size = 1)] <- 0
}
nloops <- sum(diag(newNetwork) == 1)
diag(newNetwork) <- 1
changeToOne <- sample(which(newNetwork == 0), size = nloops,
replace = F)
newNetwork[changeToOne] <- 1
diag(newNetwork) <- 0
return(newNetwork)
}
if (randomShare == 0)
return(initialNetwork)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.