File: test_label.propagation.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 (24 lines) | stat: -rw-r--r-- 850 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

context("cluster_label_prop")

test_that("label.probagation.community works", {

  library(igraph)

  g <- make_graph("Zachary")
  set.seed(42)
  lpc <- cluster_label_prop(g)
  expect_that(lpc$modularity, equals(modularity(g, lpc$membership)))
  expect_that(as.vector(membership(lpc)),
              equals(c(1, 1, 2, 1, 3, 3, 3, 1, 2, 2, 3, 1, 1, 1, 2, 2,
                       3, 1, 2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
                       2, 2)))
  expect_that(length(lpc), equals(3))
  expect_that(sizes(lpc),
              equals(structure(c(10L, 19L, 5L), .Dim = 3L, .Dimnames =
                               structure(list(`Community sizes` =
                                              c("1", "2", "3")),
                                         .Names = "Community sizes"),
                               class = "table")))

})