tests/testthat/test-girth.R

test_that("girth works", {
  ## No circle in a tree
  g <- make_tree(1000, 3)
  gi <- girth(g)
  expect_that(gi$girth, equals(0))
  expect_that(as.vector(gi$circle), equals(numeric()))

  ## The worst case running time is for a ring
  g <- make_ring(100)
  gi <- girth(g)
  expect_that(gi$girth, equals(100))
  expect_that(sort(diff(as.vector(gi$circle))), equals(c(-99, rep(1, 98))))
})

Try the igraph package in your browser

Any scripts or data that you put into this service are public.

igraph documentation built on Aug. 10, 2023, 9:08 a.m.