nw <- network_initialize(n = 500)
set.seed(1)
fit <- ergm(nw ~ edges, target.stats = 250)
sim <- simulate(fit)
# Slow ERGM-based method
ergm.method <- unname(summary(sim ~ sociality(nodes = NULL)))
ergm.method
# Fast tabulate method with network object
deg.net <- get_degree(sim)
deg.net
# Even faster if network already transformed into an edgelist
el <- as.edgelist(sim)
deg.el <- get_degree(el)
deg.el
identical(as.integer(ergm.method), deg.net, deg.el)
Run the code above in your browser using DataLab