# Simulation of a scale-free graph with 20 nodes
adjacency <- SimulateAdjacency(pk = 20, topology = "scale-free")
plot(adjacency)
# Simulation of a random graph with three connected components
adjacency <- SimulateAdjacency(
pk = rep(10, 3),
nu_within = 0.7, nu_between = 0
)
plot(adjacency)
# Simulation of a random graph with block structure
adjacency <- SimulateAdjacency(
pk = rep(10, 3),
nu_within = 0.7, nu_between = 0.03
)
plot(adjacency)
# User-defined function for graph simulation
CentralNode <- function(pk, hub = 1) {
theta <- matrix(0, nrow = sum(pk), ncol = sum(pk))
theta[hub, ] <- 1
theta[, hub] <- 1
diag(theta) <- 0
return(theta)
}
simul <- SimulateAdjacency(pk = 10, implementation = CentralNode)
plot(simul) # star
simul <- SimulateAdjacency(pk = 10, implementation = CentralNode, hub = 2)
plot(simul) # variable 2 is the central node
Run the code above in your browser using DataLab