/usr/lib/R/site-library/igraph/tests/test_decompose.graph.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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | context("decompose.graph")
test_that("decompose.graph works", {
library(igraph)
g <- erdos.renyi.game(1000, 1/1500)
G <- decompose.graph(g)
clu <- clusters(g)
Gsizes <- sapply(G, vcount)
expect_that(sort(clu$csize), equals(sort(Gsizes)))
})
test_that("decompose.graph works for many components", {
library(igraph)
g <- graph.empty(50001)
tmp <- decompose.graph(g)
expect_that(1, equals(1))
})
test_that("decompose.graph works for many components and attributes", {
library(igraph)
g <- graph.empty(50001)
V(g)$name <- 1:vcount(g)
tmp <- decompose.graph(g)
expect_that(1, equals(1))
})
test_that("decompose.graph keeps attributes", {
library(igraph)
g <- graph.ring(10) + graph.ring(5)
V(g)$name <- letters[1:(10+5)]
E(g)$name <- apply(get.edgelist(g), 1, paste, collapse="-")
d <- decompose.graph(g)
d <- d[order(sapply(d, vcount))]
expect_that(length(d), equals(2))
expect_that(sapply(d, vcount), equals(c(5,10)))
expect_that(V(d[[1]])$name, equals(letters[1:5+10]))
expect_that(V(d[[2]])$name, equals(letters[1:10]))
e1 <- apply(get.edgelist(d[[1]]), 1, paste, collapse="-")
e2 <- apply(get.edgelist(d[[2]]), 1, paste, collapse="-")
expect_that(E(d[[1]])$name, equals(e1))
expect_that(E(d[[2]])$name, equals(e2))
})
|