# \donttest{
set.seed(123)
netwk1 <- rpanet(1e4, control = rpa_control_scenario(
alpha = 0.4, beta = 0.3, gamma = 0.3
))
## rewire a directed network
target.assortcoef <- list("outout" = -0.2, "outin" = 0.2)
ret1 <- dprewire(
netwk = netwk1,
target.assortcoef = target.assortcoef,
control = list(iteration = 200)
)
plot(ret1$assortcoef$Iteration, ret1$assortcoef$"outout")
plot(ret1$assortcoef$Iteration, ret1$assortcoef$"outin")
## rewire an undirected network
netwk2 <- rpanet(1e4,
control = rpa_control_scenario(
alpha = 0.3, beta = 0.1, gamma = 0.3, xi = 0.3
),
initial.network = list(
directed = FALSE)
)
ret2 <- dprewire(
netwk = netwk2,
target.assortcoef = 0.3,
control = list(
iteration = 300, eta.obj = CVXR::norm2,
history = TRUE
)
)
plot(ret2$assortcoef$Iteration, ret2$assortcoef$Value)
# }
Run the code above in your browser using DataLab