tests/testthat/test-graph_measures.R

test_that("graph measures returns scalars", {
  gr <- create_notable('housex') %>%
    mutate(type = c(1, 1, 1, 2, 2))
  .graph_context$set(gr)
  expect_length(graph_adhesion(), 1)
  expect_length(graph_assortativity(type), 1)
  expect_length(graph_automorphisms(), 1)
  expect_length(graph_clique_count(), 1)
  expect_length(graph_clique_num(), 1)
  expect_length(graph_component_count(), 1)
  expect_length(graph_diameter(), 1)
  expect_length(graph_girth(), 1)
  expect_length(graph_mean_dist(), 1)
  expect_length(graph_min_cut(), 1)
  expect_length(graph_motif_count(), 1)
  expect_length(graph_order(), 1)
  expect_length(graph_radius(), 1)
  expect_length(graph_reciprocity(), 1)
  expect_length(graph_size(), 1)
  expect_length(graph_modularity(type), 1)
  expect_length(graph_efficiency(), 1)
  .graph_context$clear()
  gr <- create_ring(5, TRUE) %>%
    mutate(type = c(1, 1, 1, 2, 2))
  .graph_context$set(gr)
  expect_length(graph_asym_count(), 1)
  expect_length(graph_mutual_count(), 1)
  expect_length(graph_unconn_count(), 1)
  .graph_context$clear()
})

test_empty_context()

Try the tidygraph package in your browser

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

tidygraph documentation built on June 22, 2024, 11:32 a.m.