Skip to content

Commit

Permalink
More tests of importNet.STRING(); added test for igraph::simplify() i…
Browse files Browse the repository at this point in the history
…n .df2gG()
  • Loading branch information
hyginn committed Feb 28, 2017
1 parent fa48fe3 commit 696322c
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions tests/testthat/testImport.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
# testMultiply.R
# testImport.R
#
#
context("import networks")

test_that("importNet.STRING reads STRING data", {
test_that("importNet.STRING produces gG from STRING data", {
gG <- importNet.STRING(fName = "dataString.txt",
net = "experimental",
silent = TRUE,
noLog = TRUE)
expect_equal(igraph::vcount(gG), 5)
expect_equal(igraph::vcount(gG), 5) # correct number of vertices
expect_equal(igraph::ecount(gG), 4) # correct number of edges
expect_equal(igraph::graph_attr(gG)$gGversion, "1.0") # correct version
expect_equal(igraph::graph_attr(gG)$inFile, "dataString.txt") # metadata
# has been
# set
})

test_that(".df2gG simplifies the graph", {
netDF <- data.frame(a = c("crow", "duck", "crow", "crow"),
b = c("duck", "crow", "duck", "crow"),
weight = c(1, 2, 3, 4),
stringsAsFactors = FALSE)
gG <- .df2gG(inFile = "dummy.txt", call = "dummy(arg = 1)")
expect_equal(igraph::vcount(gG), 2) # only duck and crow
expect_equal(igraph::ecount(gG), 2) # 1 duplicate, 1 self-edge removed
expect_equal(igraph::edge_attr(gG)$weight, c(3, 2)) # correct weights
})



# [END]

0 comments on commit 696322c

Please sign in to comment.