/usr/share/doc/r-cran-igraph/tests/testthat/test_get.all.shortest.paths.R is in r-cran-igraph 1.1.2-2ubuntu3.
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 44 45 46 47 48 | context("all_shortest_paths")
test_that("all_shortest_paths works", {
library(igraph)
edges <- matrix(c("s", "a", 2,
"s", "b", 4,
"a", "t", 4,
"b", "t", 2,
"a", "1", 1,
"a", "2", 1,
"a", "3", 2,
"1", "b", 1,
"2", "b", 2,
"3", "b", 1),
byrow=TRUE, ncol=3,
dimnames=list(NULL, c("from", "to", "weight")))
edges <- as.data.frame(edges)
edges[[3]] <- as.numeric(as.character(edges[[3]]))
g <- graph_from_data_frame(as.data.frame(edges))
sortlist <- function(list) {
list <- lapply(list, sort)
list <- lapply(list, as.vector)
list[order(sapply(list, paste, collapse="!"))]
}
sp1 <- all_shortest_paths(g, "s", "t", weights=NA)
expect_that(sortlist(sp1$res),
equals(list(c(1, 2, 7), c(1, 3, 7))))
expect_that(sp1$nrgeo,
equals(c(1,1,1,1,1,1,2)))
sp2 <- all_shortest_paths(g, "s", "t")
expect_that(sortlist(sp2$res),
equals(list(c(1, 2, 3, 4, 7), c(1, 2, 7), c(1, 3, 7))))
expect_that(sp2$nrgeo, equals(c(1,1,2,1,1,1,3)))
## TODO
## E(g)$weight <- E(g)$weight - 1
## all_shortest_paths(g, "s", "t")
})
|