From c522a052105cfccb01d64b2bc218e12ad0525077 Mon Sep 17 00:00:00 2001 From: Alex Hayes Date: Mon, 14 Aug 2023 12:02:51 -0500 Subject: [PATCH] Add test for #35 --- tests/testthat/test-sample_igraph.R | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/testthat/test-sample_igraph.R diff --git a/tests/testthat/test-sample_igraph.R b/tests/testthat/test-sample_igraph.R new file mode 100644 index 0000000..3920566 --- /dev/null +++ b/tests/testthat/test-sample_igraph.R @@ -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 + ) + +})