tests/testthat/test-graphs_regular.R

context("regular graph generation")
library(graphR)

# test --------------------------------------------------------------------
test_that("Returned matrix has correct degree distribution", {

  # params
  N <- 20
  k <- 4
  degree_dist <- rep(k, N)

  # generate graph with R
  graph <- regular_matrix(N, k)

  # calculate degree distribution
  graph_dist <- rowSums(graph)

  # expect
  expect_equal(degree_dist, graph_dist)


})


# test --------------------------------------------------------------------
test_that("Returned list has correct degree distribution", {

  # params
  N <- 20
  k <- 4
  degree_dist <- rep(k, N)

  # generate graph
  graph <- regular_list(N, k)

  # calculate degree distribution
  graph_dist <- unlist(lapply(graph, length))

  # expect
  expect_equal(degree_dist, graph_dist)

})
tjtnew/graphr documentation built on May 19, 2019, 9:38 p.m.