/usr/lib/R/site-library/igraph/tests/test_contract.vertices.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 | context("contract.vertices")
test_that("contract.vertices works", {
library(igraph)
set.seed(42)
g <- graph.ring(10)
g$name <- "Ring"
V(g)$name <- letters[1:vcount(g)]
E(g)$weight <- sample(ecount(g))
g2 <- contract.vertices(g, rep(1:5, each=2),
vertex.attr.comb=toString)
## graph and edge attributes are kept, vertex attributes are
## combined using the 'toString' function.
expect_that(g2$name, equals(g$name))
expect_that(V(g2)$name, equals(c("a, b", "c, d", "e, f", "g, h", "i, j")))
expect_that(as.matrix(g2[]),
is_equivalent_to(cbind(c(10,9,0,0,7), c(9,3,6,0,0),
c(0,6,4,8,0), c(0,0,8,5,1),
c(7,0,0,1,2))))
})
|