Benchmarking results and comparision with other packages
benchmarks.Rmd
Microbenchmarks for Development
A. Scaling with network size
results <- bench::press(
Nsize = c(10, 25, 50, 75, 100),
{
G <- sample_ppm(Nsize, c=0.9, k=10, B=3)
G <- simplify(G)
G <- delete.vertices(G, degree(G) == 0)
p <- sample(1:3, Nsize, replace = TRUE)
bench::mark(
min_iterations = 5,
entropy = get_entropy(G, p),
mcmc_sweep = mcmc_single_sweep(G, p, 3),
agglomerative_merge = invisible(capture.output(dcsbm(G, n.moves=1, n.sweeps=0))),
check = FALSE
)
}
)
results
B. Entropy Convergence Tests
1. MCMC sweeps
# Initialize graph and a random starting partition
G <- sample_ppm(100, c = 0.9, k = 10, B = 3, directed = TRUE, loops = TRUE)
# Number of mcmcm sweeps
start_partition <- sample(1:3, size = 100, replace = TRUE)
# Perform Niter mcmc sweeps
result <- mcmc_sweep(G, start_partition, 3, n.sweeps = 100)
# Visualize start/end partition and entropy delta.
plot(G, vertex.color = start_partition, vertex.label = NA)
plot(result$entropy_delta/length(E(G)), type = "line")
plot(G, vertex.color = result$best_partition, vertex.label = NA)
2. Agglomerative Merge
G <- sample_ppm(100, 0.9, 10, 3, directed = TRUE, loops = TRUE)
model <- dcsbm(G, n.sweeps = 1, verbose = FALSE)
plot(G, vertex.color = model$best_partition, vertex.label = NA)
C. Degree correction tests
1. MCMC sweeps
# Initialize graph and a random starting partition
G <- sample_dcppm(100, 0.9, 10, 3, k_coef = 2, directed = TRUE, loops = TRUE)
start_partition <- sample(1:3, size = 100, replace = TRUE)
result <- mcmc_sweep(G, start_partition, 3, n.sweeps = 100, dc = TRUE)
# Visualize start/end partition and entropy delta.
plot(G, vertex.color = start_partition, vertex.label = NA)
plot(result$entropy_delta/length(E(G)), type = "line")
plot(G, vertex.color = result$best_partition, vertex.label = NA)
2. Agglomerative merge
G <- sample_dcppm(100, 0.9, 10, 3, k_coef = 2, directed = TRUE, loops = TRUE)
model <- dcsbm(G, degree_correction = TRUE, n.sweeps = 5, verbose = FALSE)
plot(G, vertex.color = model$best_partition, vertex.label = NA, sub = "Best partition")
plot(G, vertex.color = c(rep(1,34), rep(2,33), rep(3,33)), vertex.label = NA, sub = "True partition")