Skip to content

Commit

Permalink
test: add test for find_cycle()
Browse files Browse the repository at this point in the history
  • Loading branch information
szhorvat committed Nov 18, 2024
1 parent 9fbcd5d commit c0df132
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/testthat/test-cycles.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

test_that("find_cycle works", {
g <- make_graph(c(1,2, 2,3, 1,3, 1,1), directed = TRUE)

cycle <- find_cycle(g)
expect_equal(length(cycle$vertices), 1)
expect_equal(length(cycle$edges), 1)

# Finding a cycle of length 1 or 3 are both valid here
cycle <- find_cycle(g, mode = "all")
expect_equal(length(cycle$vertices), 3)
expect_equal(length(cycle$edges), 3)
})

0 comments on commit c0df132

Please sign in to comment.