File: test_are.connected.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-- 682 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("are_adjacent")

test_that("are_adjacent works", {
  library(igraph)

  g <- graph_from_literal( A-B-C, B-D )
  expect_that(are_adjacent(g, "A", "B"), is_true())
  expect_that(are_adjacent(g, "B", "A"), is_true())
  expect_that(are_adjacent(g, "A", "D"), is_false())

  g2 <- graph( c(1,2, 2,3, 3,4), dir= FALSE )
  expect_that(are_adjacent(g2, 1,2), is_true())
  expect_that(are_adjacent(g2, 3,2), is_true())
  expect_that(are_adjacent(g2, 4,1), is_false())
  
  g3 <- graph_from_literal( A-+B-+C, B-+D )
  expect_that(are_adjacent(g3, "A", "C"), is_false())
  expect_that(are_adjacent(g3, "A", "B"), is_true())
  expect_that(are_adjacent(g3, "B", "A"), is_false())
})