Skip to content

Commit 1fe81a2

Browse files
Add test for igraph with no edges and no names
Co-authored-by: frederikfabriciusbjerre <55752995+frederikfabriciusbjerre@users.noreply.github.com>
1 parent 8be48c8 commit 1fe81a2

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

tests/testthat/test-as_caugi.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,18 @@ test_that("igraph with no edges, but with nodes, works", {
219219
expect_setequal(nodes(cg0)[["name"]], c("A", "B", "C"))
220220
})
221221

222+
test_that("igraph with no edges and no names preserves order", {
223+
skip_if_not_installed("igraph")
224+
g0 <- igraph::make_empty_graph(n = 5, directed = TRUE)
225+
# Verify no names
226+
expect_null(igraph::V(g0)$name)
227+
228+
cg0 <- as_caugi(g0, class = "DAG")
229+
expect_equal(nrow(as.data.frame(edges(cg0))), 0L)
230+
# Should generate V1, V2, V3, V4, V5 in order
231+
expect_equal(cg0@nodes$name, paste0("V", 1:5))
232+
})
233+
222234
test_that("igraph vertex order is preserved when converting to caugi", {
223235
skip_if_not_installed("igraph")
224236

0 commit comments

Comments
 (0)