Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/structural.properties.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion revdep/cran.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/graph.bfs.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
[1] "out"

$order
+ 5/5 vertices, named:
[1] b c <NA> <NA> <NA>
+ 2/5 vertices, named:
[1] b c

$rank
a b c z d
Expand Down
7 changes: 3 additions & 4 deletions tests/testthat/test-graph.bfs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
)
})

Expand Down
7 changes: 6 additions & 1 deletion tests/testthat/test-graph.dfs.R
Original file line number Diff line number Diff line change
@@ -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))
})