context("test component detection")
test_that("components_sp and is_connected_sp agrees with igraph results", {
for (r in 1:15) {
n = rpois(1L, 15L)
k = rpois(1L, 2L)
p = 0.3
g = igraph::sample_gnp(n, p)
if (k > 1L) {
for (j in 1:k) {
g = g + igraph::sample_gnp(n, p)
}
}
c1 = igraph::components(g)$membership
A = igraph::as_adj(g)
c2 = components_adj(A)
expect_equivalent(c1, as.vector(c2))
expect_true(igraph::is.connected(g) == is_connected_adj(A))
}
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.