File: test_multilevel.community.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 (22 lines) | stat: -rw-r--r-- 748 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

context("cluster_louvain")

test_that("cluster_louvain works", {

  library(igraph)

  g <- make_graph("Zachary")
  mc <- cluster_louvain(g)
  
  expect_that(as.vector(membership(mc)),
              equals(c(2, 2, 2, 2, 1, 1, 1, 2, 4, 2, 1, 2, 2, 2, 4, 4,
                       1, 2, 4, 2, 4, 2, 4, 3, 3, 3, 4, 3, 3, 4, 4, 3,
                       4, 4) ))
  expect_that(modularity(g, mc$membership), equals(max(mc$modularity)))
  expect_that(length(mc), equals(4))
  expect_that(sizes(mc),
              equals(structure(c(5L, 12L, 6L, 11L), .Dim = 4L,
                .Dimnames = structure(list(`Community sizes` = c("1",
                     "2", "3", "4")), .Names = "Community sizes"),
                               class = "table") ))
})