File: test_get.diameter.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 (25 lines) | stat: -rw-r--r-- 516 bytes parent folder | download | duplicates (5)
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

context("get_diameter")

test_that("get_diameter works", {

  library(igraph)

  g <- make_ring(10)
  E(g)$weight <- sample(seq_len(ecount(g)))
  d <- diameter(g)
  gd <- get_diameter(g)
  sp <- distances(g)

  expect_that(d, equals(max(sp)))
  expect_that(sp[ gd[1], gd[length(gd)] ], equals(d))

  d <- diameter(g, weights=NA)
  gd <- get_diameter(g, weights=NA)
  sp <- distances(g, weights=NA)
  
  expect_that(d, equals(max(sp)))
  length(gd) == d + 1
  expect_that(sp[ gd[1], gd[length(gd)] ], equals(d))
})