test_that("cluster_louvain works", {
withr::local_seed(20231029)
g <- make_graph("Zachary")
mc <- cluster_louvain(g)
expect_true(all(as.vector(membership(mc)) %in% 1:4))
expect_equal(modularity(g, mc$membership), max(mc$modularity))
# 3 4
# 2 998
expect_true(length(mc) %in% 3:4)
expect_true(all(as.vector(membership(mc)) %in% seq_len(length(mc))))
expect_s3_class(sizes(mc), "table")
expect_equal(sum(sizes(mc)), vcount(g))
expect_identical(sizes(mc), table(membership(mc), dnn = "Community sizes"))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.