~gabor.csardi/igraph/develop

« back to all changes in this revision

Viewing changes to interfaces/R/igraph/inst/tests/test_hrg.R

  • Committer: Gabor Csardi
  • Date: 2013-11-14 15:32:41 UTC
  • Revision ID: git-v1:50150d16791efe51abda9b3343e6beb69fd3cf99
Implement the 'start' argument in igraph_hrg_fit (#225).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
context("Hierarchical random graphs")
 
3
 
 
4
test_that("Starting from state works (#225)", {
 
5
  library(igraph)
 
6
  set.seed(42)
 
7
 
 
8
  res <- structure(list(left = c(-12, 13, -19, 4, 15, -3, 0, -13, -15, 
 
9
                          -18, -6, -14, -7, -9, -8, 2, -10, 10, 11),
 
10
                        right = c(-17, -5, 17, 7, 16, -2, 1, -4, 5,
 
11
                          14, 12, 8, 3, 6, -16, 9, 18, -11, 19),
 
12
                        prob = c(0, 0.5, 0, 0, 0, 0.888888888888889,
 
13
                          0, 0.5, 0.714285714285714, 0.375,
 
14
                          0.333333333333333, 0.444444444444444, 1,
 
15
                          0.625, 0.8, 0,  0.222222222222222,
 
16
                          0.714285714285714, 1),
 
17
                        edges = c(0, 1, 0, 0, 0, 8, 0, 3, 5, 3, 2, 4,
 
18
                          2, 5, 8, 0, 2, 5, 1),
 
19
                        vertices = c(20, 3, 3, 2, 2, 6, 2, 5, 8, 9, 7,
 
20
                          10, 3, 9, 7, 2, 10, 8, 2)),
 
21
                   .Names = c("left", "right", "prob", "edges",
 
22
                     "vertices"),
 
23
                   class = "igraphHRG")
 
24
  
 
25
  g <- erdos.renyi.game(10, p=1/2) + erdos.renyi.game(10, p=1/2)
 
26
  hrg <- hrg.fit(g)
 
27
  hrg
 
28
 
 
29
  expect_that(hrg, is_equivalent_to(res))
 
30
  
 
31
  hrg2 <- hrg.fit(g, hrg=hrg, start=TRUE, steps=1)
 
32
  expect_that(hrg2, is_equivalent_to(res))
 
33
  
 
34
})