/usr/lib/R/site-library/igraph/tests/test_clusters.R is in r-cran-igraph 0.7.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | context("clusters")
test_that("clusters works", {
library(igraph)
set.seed(42)
gc <- function(graph) {
cl <- clusters(graph)
induced.subgraph(graph, which(cl$membership==which.max(cl$csize)))
}
rg <- function(n) {
gc(erdos.renyi.game(n, 1/n))
}
G <- lapply(1:30, function(x) rg(sample(100, 1)))
Gsize <- sapply(G, vcount)
allg <- graph.disjoint.union(G)
clu <- clusters(allg)
expect_that(as.numeric(table(clu$membership)), equals(clu$csize))
expect_that(sort(clu$csize), equals(sort(Gsize)))
expect_that(clu$no, equals(length(G)))
})
|