-
-
Notifications
You must be signed in to change notification settings - Fork 203
/
Copy pathtest-centralization.R
47 lines (41 loc) · 1.25 KB
/
test-centralization.R
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
test_that("centr_eigen_tmax() works", {
withr::local_seed(42)
g <- sample_pa(1000, m = 4)
expect_equal(centr_eigen_tmax(g), 998)
})
test_that("centr_eigen_tmax() deprecated argument", {
g <- sample_pa(1000, m = 4)
expect_snapshot(c <- centr_eigen_tmax(g, scale = FALSE))
})
test_that("centr_eigen() works", {
withr::local_seed(42)
g <- sample_pa(1000, m = 4)
centr_eigen <- centr_eigen(g)
expect_setequal(
names(centr_eigen),
c("vector", "value", "options", "centralization", "theoretical_max")
)
expect_equal(centr_eigen$centralization, 0.9432924, tolerance = 1e-06)
})
test_that("centr_eigen() deprecated argument", {
g <- sample_pa(1000, m = 4)
expect_snapshot(c <- centr_eigen(g, scale = FALSE))
})
test_that("centr_degree_tmax() works", {
withr::local_seed(42)
g <- sample_pa(1000, m = 4)
expect_gt(centr_degree_tmax(g, loops = TRUE), 1990000)
})
test_that("centr_degree_tmax() deprecated argument", {
g <- sample_pa(1000, m = 4)
expect_snapshot(c <- centr_degree_tmax(g))
})
test_that("centr_betw() works", {
withr::local_seed(42)
g <- sample_pa(1000, m = 4)
expect_setequal(
names(centr_betw(g)),
c("res", "centralization", "theoretical_max")
)
expect_equal(centr_betw(g)$theoretical_max, 996004998)
})