diff --git a/R/structural.properties.R b/R/structural.properties.R index fdc5d43bb17..2a8e452b18c 100644 --- a/R/structural.properties.R +++ b/R/structural.properties.R @@ -2132,7 +2132,7 @@ bfs <- function( if (succ) res$succ <- res$succ + 1 if (igraph_opt("return.vs.es")) { - if (order) res$order <- create_vs(graph, res$order, na_ok = TRUE) + if (order) res$order <- V(graph)[.env$res$order, na_ok = TRUE] if (father) res$father <- create_vs(graph, res$father, na_ok = TRUE) if (pred) res$pred <- create_vs(graph, res$pred, na_ok = TRUE) if (succ) res$succ <- create_vs(graph, res$succ, na_ok = TRUE) diff --git a/revdep/cran.md b/revdep/cran.md index 6a55cc8f3f8..9aa7040968a 100644 --- a/revdep/cran.md +++ b/revdep/cran.md @@ -1,6 +1,6 @@ ## revdepcheck results -We checked 19 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. +We checked 17 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. * We saw 17 new problems * We failed to check 0 packages diff --git a/tests/testthat/_snaps/graph.bfs.md b/tests/testthat/_snaps/graph.bfs.md index c3c9dab82e4..8cd7490989f 100644 --- a/tests/testthat/_snaps/graph.bfs.md +++ b/tests/testthat/_snaps/graph.bfs.md @@ -12,8 +12,8 @@ [1] "out" $order - + 5/5 vertices, named: - [1] b c + + 2/5 vertices, named: + [1] b c $rank a b c z d diff --git a/tests/testthat/test-graph.bfs.R b/tests/testthat/test-graph.bfs.R index 60add677fe4..52c24a0fbe3 100644 --- a/tests/testthat/test-graph.bfs.R +++ b/tests/testthat/test-graph.bfs.R @@ -13,7 +13,7 @@ test_that("BFS works from multiple root vertices", { expect_that( as.vector(bfs(g, 1, unreachable = FALSE)$order), - equals(c(1, 2, 10, 3, 9, 4, 8, 5, 7, 6, rep(NA, 10))) + equals(c(1, 2, 10, 3, 9, 4, 8, 5, 7, 6)) ) expect_that( @@ -31,9 +31,8 @@ test_that("issue 133", { g <- graph_from_edgelist(matrix(c(1, 2, 2, 3), ncol = 2, byrow = TRUE)) expect_equal( - ignore_attr = TRUE, - bfs(g, 1, restricted = c(1, 2), unreachable = FALSE)$order, - V(g)[c(1, 2, NA_real_), na_ok = TRUE] + as.numeric(bfs(g, 1, restricted = c(1, 2), unreachable = FALSE)$order), + c(1, 2) ) }) diff --git a/tests/testthat/test-graph.dfs.R b/tests/testthat/test-graph.dfs.R index d495c9f9e2c..b6afe3d345a 100644 --- a/tests/testthat/test-graph.dfs.R +++ b/tests/testthat/test-graph.dfs.R @@ -1,4 +1,9 @@ test_that("DFS uses 1-based root vertex index", { g <- make_ring(3) - expect_that(dfs(g, root = 1)$root, equals(1)) + expect_equal(dfs(g, root = 1)$root, 1) +}) + +test_that("DFS does not pad order", { + g <- make_star(3) + expect_equal(as.numeric(dfs(g, root = 2, unreachable = FALSE)$order), c(2, 1)) })