tests/testthat/test-is.bipartite.R

test_that("is_bipartite works", {
  I <- matrix(sample(0:1, 35, replace = TRUE, prob = c(3, 1)), ncol = 5)
  g <- graph_from_incidence_matrix(I)
  expect_true(bipartite_mapping(g)$res)

  set.seed(42)
  I <- matrix(sample(0:1, 35, replace = TRUE, prob = c(3, 1)), ncol = 5)
  g <- graph_from_incidence_matrix(I)
  expect_that(
    bipartite_mapping(g),
    equals(list(res = TRUE, type = c(rep(FALSE, 7), rep(TRUE, 5))))
  )
})

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.