File: test_forestfire.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 (29 lines) | stat: -rw-r--r-- 757 bytes parent folder | download | duplicates (4)
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

context("sample_forestfire")

test_that("sample_forestfire works", {
  
  library(igraph)
  set.seed(42)

  pars <- list(sparse=c(0.35, 0.2/0.35),
               densifying=c(0.37, 0.32/0.37),
               dense=c(0.38, 0.38/0.37))

  N <- 5000
  G <- lapply(pars, function(x) sample_forestfire(N, fw=x[1], bw=x[2]))
  
  xv <- log(2:N)
  
  co <- sapply(G, function(x) {
    yv <- log(cumsum(degree(x, mode="out"))[-1])
    coef(lm( yv ~ xv ))[2]
  })
  
  expect_that(co, equals(structure(c(1.06045500245466,
                                     1.22800967143684,
                                     1.96234121488344),
                                   .Names = c("sparse.xv",
                                     "densifying.xv", "dense.xv"))))

})