File: test_transitivity.R

package info (click to toggle)
r-cran-igraph 1.0.1-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 18,232 kB
  • sloc: ansic: 173,538; cpp: 19,365; fortran: 4,550; yacc: 1,164; tcl: 931; lex: 484; makefile: 149; sh: 9
file content (33 lines) | stat: -rw-r--r-- 943 bytes parent folder | download | duplicates (2)
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

context("transitivity")

test_that("transitivity works", {
  library(igraph)
  set.seed(42)
  g <- sample_gnp(100, p=10/100)

  t1 <- transitivity(g, type="global")
  expect_that(t1, equals(0.10483870967741935887))

  t2 <- transitivity(g, type="average")
  expect_that(t2, equals(0.10159943848720931481))

  t3 <- transitivity(g, type="local", vids=V(g))
  t33 <- transitivity(g, type="local")
  est3 <- structure(c(0, 0.06667, 0.1028, 0.1016, 0.1333, 0.2222),
                    .Names = c("Min.", "1st Qu.", "Median", "Mean",
                      "3rd Qu.", "Max."),
                    class = c("summaryDefault", "table"))
  expect_that(summary(t3), equals(est3))
  expect_that(summary(t33), equals(est3))
})

test_that("no integer overflow", {

  library(igraph)
  set.seed(42)
  g <- graph.star(80000, mode="undirected") + edges(sample(2:1000), 100)
  mtr <- min(transitivity(g, type="local"), na.rm=TRUE)
  expect_true(mtr > 0)

})