Skip to content

Commit 39f4a85

Browse files
committed
test for plotting a bipartite graph
1 parent 07978c8 commit 39f4a85

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Loading
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
test_that("plot a bipartite graph", {
2+
3+
# Create a temporary directory so no permanent files are put on a package users directory
4+
temp_dir <- tempfile(pattern = "test_dir")
5+
dir.create(temp_dir)
6+
on.exit(unlink(temp_dir, recursive = TRUE))
7+
8+
# Create bipartite graph
9+
edges <- c("prot_1", "pep_1",
10+
"prot_1", "pep_2",
11+
"prot_1", "pep_3",
12+
"prot_2", "pep_2",
13+
"prot_2", "pep_3",
14+
"prot_3", "pep_2",
15+
"prot_3", "pep_3",
16+
"prot_3", "pep_4")
17+
types <- c(TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE)
18+
bipartite_graph <- igraph::make_graph(edges = edges, directed = FALSE)
19+
V(bipartite_graph)$type <- types
20+
21+
22+
# Plot graph
23+
png(filename = file.path(temp_dir, "bipartitGraph.png"))
24+
plotBipartiteGraph(bipartite_graph)
25+
dev.off()
26+
27+
28+
expect_snapshot_file(path = file.path(temp_dir, "bipartitGraph.png"), name = "plotBipartitGraph.png" )
29+
30+
})

0 commit comments

Comments
 (0)