/usr/lib/R/site-library/igraph/tests/test_edge.betweenness.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("edge.betweenness")
test_that("edge.betweenness works", {
library(igraph)
kite <- graph.formula(Andre - Beverly:Carol:Diane:Fernando,
Beverly - Andre:Diane:Ed:Garth,
Carol - Andre:Diane:Fernando,
Diane - Andre:Beverly:Carol:Ed:Fernando:Garth,
Ed - Beverly:Diane:Garth,
Fernando - Andre:Carol:Diane:Garth:Heather,
Garth - Beverly:Diane:Ed:Fernando:Heather,
Heather - Fernando:Garth:Ike,
Ike - Heather:Jane,
Jane - Ike)
bet <- betweenness(kite)
ebet <- edge.betweenness(kite)
bet2 <- sapply(1:vcount(kite), function(x) {
ae <- E(kite)[ adj(x) ]
(sum(ebet[ae])-vcount(kite)+1) / 2
})
expect_that(unname(bet), equals(bet2))
#### Weighted
E(kite)$weight <- sample(1:10, ecount(kite), replace=TRUE)
bet <- betweenness(kite)
ebet <- edge.betweenness(kite)
bet2 <- sapply(1:vcount(kite), function(x) {
ae <- E(kite)[ adj(x) ]
(sum(ebet[ae])-vcount(kite)+1) / 2
})
expect_that(unname(bet), equals(bet2))
})
|