From ce32250d55050aea159c9bc637f16ad944b11c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Thu, 26 Jan 2023 08:26:34 +0100 Subject: [PATCH] Iterators created with E(P = ...) or E(path = ...) are incomplete --- R/iterators.R | 2 +- tests/testthat/test-iterators.R | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/R/iterators.R b/R/iterators.R index daa379fe6da..c5cae425fec 100644 --- a/R/iterators.R +++ b/R/iterators.R @@ -317,6 +317,7 @@ E <- function(graph, P = NULL, path = NULL, directed = TRUE) { if (is.null(P) && is.null(path)) { ec <- ecount(graph) res <- seq_len(ec) + res <- set_complete_iterator(res) } else if (!is.null(P)) { on.exit(.Call(C_R_igraph_finalizer)) res <- .Call( @@ -340,7 +341,6 @@ E <- function(graph, P = NULL, path = NULL, directed = TRUE) { } class(res) <- "igraph.es" - res <- set_complete_iterator(res) add_vses_graph_ref(res, graph) } diff --git a/tests/testthat/test-iterators.R b/tests/testthat/test-iterators.R index c39cdbd2952..b3370848aad 100644 --- a/tests/testthat/test-iterators.R +++ b/tests/testthat/test-iterators.R @@ -93,9 +93,11 @@ test_that("V(g) returns complete iterator, completeness is lost with next subset }) test_that("E(g) returns complete iterator, completeness is lost with next subsetting", { - g <- make_star(4) + g <- make_full_graph(4) iter <- E(g) expect_true(is_complete_iterator(iter)) expect_false(is_complete_iterator(iter[1])) expect_false(is_complete_iterator(iter[1:3])) + expect_false(is_complete_iterator(E(g, P = 1:4))) + expect_false(is_complete_iterator(E(g, path = 1:4))) })