File: test_sbm.game.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-- 1,027 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("Stochastic block models")

test_that("Generating stochastic block models works", {

  library(igraph)
  pm <- matrix(1, nrow=2, ncol=2)
  bs <- c(4,6)
  g1 <- sample_sbm(10, pref.matrix=pm, block.sizes=bs,
                 directed=FALSE, loops=FALSE)
  expect_that(graph.isomorphic(g1, make_full_graph(10, directed=FALSE, loops=FALSE)),
              is_true())

  g2 <- sample_sbm(10, pref.matrix=pm, block.sizes=bs,
                directed=FALSE, loops=TRUE)
  g2x <- make_full_graph(10, directed=FALSE, loops=TRUE)
  expect_that(g2[sparse=FALSE], equals(g2x[sparse=FALSE]))

  g3 <- sample_sbm(10, pref.matrix=pm, block.sizes=bs,
                 directed=TRUE, loops=FALSE)
  g3x <- make_full_graph(10, directed=TRUE, loops=FALSE)
  expect_that(g3[sparse=FALSE], equals(g3x[sparse=FALSE]))

  g4 <- sample_sbm(10, pref.matrix=pm, block.sizes=bs,
                 directed=TRUE, loops=TRUE)
  g4x <- make_full_graph(10, directed=TRUE, loops=TRUE)
  expect_that(g4[sparse=FALSE], equals(g4x[sparse=FALSE]))
  
})