/usr/lib/R/site-library/igraph/tests/test_layout.mds.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 | context("layout.mds")
test_that("layout.mds works", {
library(igraph)
## A tree
g <- graph.tree(10, 2, "undirected")
mymds <- function(g) {
sp <- shortest.paths(g)
sp <- sp * sp
sp <- sp - rowMeans(sp) - rep(rowMeans(sp), each=nrow(sp)) + mean(sp)
sp <- sp / -2
ei <- eigen(sp)
va <- sqrt(abs(ei$values[1:2]))
ei$vectors[,1:2] * rep(va, each=nrow(sp))
}
expect_that(mymds(g), equals(layout.mds(g)))
## plot(g, layout=ll)
## A graph with multiple components, just test that it runs
set.seed(42)
g <- graph.ring(10) + graph.ring(3)
expect_that(ncol(layout.mds(g)), equals(2))
## Small stress test
for (i in 1:10) {
g <- erdos.renyi.game(100, 2/100)
l <- layout.mds(g)
expect_that(ncol(l), equals(2))
}
})
|