File: test-make_graph.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 (57 lines) | stat: -rw-r--r-- 1,149 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

context("make_graph")

test_that("make_graph works", {

  g <- make_graph(1:10)
  g2 <- make_empty_graph(n = 10) + edges(1:10)
  expect_true(identical_graphs(g, g2))

})

test_that("make_graph works for numeric edges and isolates", {

  g <- make_graph(1:10, n = 20)
  g2 <- make_empty_graph(n = 20) + edges(1:10)
  expect_true(identical_graphs(g, g2))

})

test_that("make_graph handles names", {

  g <- make_graph(letters[1:10])
  g2 <- make_empty_graph() + vertices(letters[1:10]) + edges(letters[1:10])
  expect_true(identical_graphs(g, g2))

})

test_that("make_graph hadles names and isolates", {

  g <- make_graph(letters[1:10], isolates = letters[11:20])
  g2 <- make_empty_graph() + vertices(letters[1:20]) + edges(letters[1:10])
  expect_true(identical_graphs(g, g2))

})

test_that("make_graph gives warning for ignored arguments", {

  expect_warning(
    make_graph(letters[1:10], n = 10)
  )

  expect_warning(
    make_graph(1:10, isolates = 11:12)
  )

})

test_that("a make_graph bug is fixed", {

  E <- cbind(1, 3)
  d <- 3
  g <- graph(as.vector(t(E)), d, FALSE)

  expect_equal(vcount(g), 3)
  expect_equal(ecount(g), 1)

})