Skip to content

Commit

Permalink
Add test for #35
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpghayes committed Aug 14, 2023
1 parent c1f229f commit c522a05
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/testthat/test-sample_igraph.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
test_that("doesn't drop isolated nodes (#35)", {

set.seed(32)

bm <- as.matrix(cbind(
c(.3, .005, .005, .005, .005),
c(.002, .3, .005, .005, .005),
c(.002, .01, .3, .005, .005),
c(.002, .01, .005, .2, .005),
c(.002, .005, .005, .005, .2)
))

pi <- c(5, 50, 20, 25, 100)

sbm <- fastRG::directed_dcsbm(
B = bm,
pi_in = pi,
pi_out = pi,
theta_in = rep(1, 200),
theta_out = rep(1, 200),
expected_out_degree = 3,
allow_self_loops = FALSE,
sort_nodes = TRUE
)

net <- fastRG::sample_igraph(sbm)

expect_equal(
igraph::vcount(net),
200
)

})

0 comments on commit c522a05

Please sign in to comment.