Skip to content

Commit dce0759

Browse files
update tests for multiplex graphs
1 parent a80e5cb commit dce0759

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

R/find_partition.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ seed = NULL,
296296
n_iterations = 2L,
297297
max_comm_size = 0L,
298298
degree_as_node_size = TRUE,
299-
legacy = FALSE
299+
legacy = TRUE
300300
) {
301301
# disable printing numerals in scientific notation
302302
oo <- options(scipen = 100000000000)

tests/testthat/test_multiplex.R

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ skip_if_no_python <- function() {
215215
testthat::skip("leidenalg not available for testing")
216216
}
217217

218-
218+
set.seed(9000)
219219
test_that("run with CPMVertexPartition multiplexed", {
220220
skip_if_no_python()
221221
partition <- leiden(multiplex_graph,
@@ -227,11 +227,12 @@ test_that("run with CPMVertexPartition multiplexed", {
227227
expect_equal(partition,
228228
c(8, 2, 7, 5, 2, 5, 1, 2, 6, 5, 5, 2, 2, 5, 5, 5, 3, 6, 1, 2,
229229
7, 10, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 4, 2,
230-
2, 2, 6, 4, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 6, 7, 6, 4, 9, 4
230+
2, 2, 6, 4, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 3, 7, 6, 4, 9, 4
231231
))
232232
multiplex_graph
233233
})
234234

235+
set.seed(9000)
235236
test_that("run with ModularityVertexPartition multiplexed", {
236237
skip_if_no_python()
237238
partition <- leiden(multiplex_graph,
@@ -241,12 +242,17 @@ test_that("run with ModularityVertexPartition multiplexed", {
241242
seed = 9001)
242243
expect_length(partition, length(V(multiplex_graph[[1]])))
243244
expect_equal(sort(unique(partition)), 1:6)
245+
expect_equal(table(partition),
246+
structure(c(`1` = 15L, `2` = 13L, `3` = 13L, `4` = 11L, `5` = 8L,
247+
`6` = 1L), .Dim = 6L, .Dimnames = list(partition = c("1", "2",
248+
"3", "4", "5", "6")), class = "table"))
244249
expect_equal(partition,
245-
c(3, 3, 1, 4, 3, 4, 4, 3, 1, 4, 4, 3, 3, 4, 4, 4, 1, 1, 2, 3,
246-
1, 3, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 5, 5, 3, 3,
247-
3, 1, 5, 3, 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 1, 1, 1, 5, 6, 5))
250+
c(4, 2, 4, 4, 2, 4, 4, 2, 1, 4, 4, 2, 2, 4, 4, 4, 1, 1, 3, 2,
251+
2, 2, 1, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 5, 5, 2, 2,
252+
2, 1, 5, 2, 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 1, 4, 1, 5, 6, 5))
248253
})
249254

255+
set.seed(9000)
250256
test_that("run with ModularityVertexPartition multiplexed and max_comm_size", {
251257
skip_if_no_python()
252258
partition <- leiden(multiplex_graph,
@@ -258,8 +264,9 @@ test_that("run with ModularityVertexPartition multiplexed and max_comm_size", {
258264
expect_length(partition, length(V(multiplex_graph[[1]])))
259265
expect_equal(sort(unique(partition)), 1:10)
260266
expect_equal(max(table(partition)), 8)
261-
expect_equal(partition,
262-
c(4, 4, 2, 3, 8, 3, 3, 4, 2, 3, 3, 8, 8, 3, 3, 3, 6, 6, 5, 8,
263-
2, 8, 6, 7, 2, 5, 5, 5, 7, 5, 7, 7, 5, 5, 7, 5, 4, 1, 1, 4, 4,
264-
4, 2, 1, 4, 6, 6, 6, 6, 9, 2, 6, 1, 1, 1, 2, 2, 7, 1, 10, 1))
267+
expect_equal(table(partition),
268+
structure(c(`1` = 8L, `2` = 8L, `3` = 8L, `4` = 8L, `5` = 8L,
269+
`6` = 8L, `7` = 6L, `8` = 5L, `9` = 1L, `10` = 1L), .Dim = 10L, .Dimnames = list(
270+
partition = c("1", "2", "3", "4", "5", "6", "7", "8", "9",
271+
"10")), class = "table"))
265272
})

0 commit comments

Comments
 (0)