-
-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests for
feedback_arc_set()
and feedback_vertex_set()
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
test_that("feedback_arc_set works", { | ||
skip_if_no_glpk() | ||
|
||
g <- make_graph(c(1,2, 2,3, 3,1, 4,2, 3,4), directed = TRUE) | ||
fas <- feedback_arc_set(g) | ||
expect_equal(as.vector(fas), c(2)) | ||
}) | ||
|
||
test_that("feedback_arc_set works with weights", { | ||
skip_if_no_glpk() | ||
|
||
g <- make_ring(4, directed = TRUE) | ||
E(g)$weight <- 4:1 | ||
fas <- feedback_arc_set(g) | ||
expect_equal(as.vector(fas), c(4)) | ||
}) | ||
|
||
test_that("feedback_arc_set works with undirected graphs", { | ||
skip_if_no_glpk() | ||
|
||
g <- make_ring(10) | ||
fas <- feedback_arc_set(g) | ||
expect_equal(length(fas), 1) | ||
}) | ||
|
||
test_that("feedback_vertex_set works", { | ||
skip_if_no_glpk() | ||
|
||
g <- make_lattice(c(3, 3)) | ||
fvs <- feedback_vertex_set(g) | ||
expect_equal(length(fvs), 2) | ||
}) | ||
|
||
test_that("feedback_vertex_set works with weights", { | ||
skip_if_no_glpk() | ||
|
||
g <- make_ring(5, directed = TRUE) | ||
V(g)$weight <- 5:1 | ||
fvs <- feedback_vertex_set(g) | ||
expect_equal(as.vector(fvs), c(5)) | ||
}) |