From f78d0190ba111930627386ddcfaa995b307072eb Mon Sep 17 00:00:00 2001 From: David Schoch Date: Thu, 15 Oct 2026 21:20:39 +0200 Subject: [PATCH 1/8] refactor: Rename edge-selector arguments to `edges` `eids`, `es` and `e` unify on `edges` in `count_multiple()`, `reverse_edges()`, `subgraph_from_edges()`, `which_loop()`, `which_multiple()`, `which_mutual()`, `ends()`, `head_of()`, `tail_of()` and `edge_betweenness()`, mirroring `vertices`. Named legacy calls are recovered with a soft-deprecation. Part of #2788. Co-Authored-By: Claude Opus 5.5 (1M context) --- R/basic.R | 36 ++++- R/centrality.R | 35 +++-- R/interface.R | 33 ++-- R/iterators.R | 2 +- R/operators.R | 28 +++- R/structural-properties.R | 142 ++++++++++++++---- tests/testthat/_snaps/basic.md | 18 +++ .../testthat/_snaps/structural-properties.md | 9 ++ tests/testthat/test-basic.R | 15 ++ tests/testthat/test-centrality.R | 11 +- tests/testthat/test-constant-defaults.R | 12 +- tests/testthat/test-interface.R | 11 +- tests/testthat/test-operators.R | 7 + tests/testthat/test-structural-properties.R | 18 ++- tools/migrations/centrality.R | 5 +- tools/migrations/interface.R | 5 +- tools/migrations/structural-properties.R | 10 +- 17 files changed, 318 insertions(+), 79 deletions(-) create mode 100644 tests/testthat/_snaps/basic.md create mode 100644 tests/testthat/test-basic.R diff --git a/R/basic.R b/R/basic.R index 4769854df3..74bdb69bef 100644 --- a/R/basic.R +++ b/R/basic.R @@ -63,14 +63,26 @@ is_igraph <- function(graph) { #' `tail_of()` returns the other end(s) of the edge(s). #' #' @param graph The input graph. -#' @param es The edges to query. +#' @param edges The edges to query. +#' @param es `r lifecycle::badge("deprecated")` Use `edges` instead. #' @return A vertex sequence with the head(s) of the edge(s). #' #' @family structural queries #' #' @export -head_of <- function(graph, es) { - create_vs(graph, ends(graph, es, names = FALSE)[, 2]) +head_of <- function(graph, edges, es = deprecated()) { + if (lifecycle::is_present(es)) { + if (!missing(edges)) { + cli::cli_abort(c( + "Argument {.arg edges} of {.fn head_of} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg es}." + )) + } + lifecycle::deprecate_soft("3.0.0", "head_of(es = )", "head_of(edges = )") + edges <- es + } + + create_vs(graph, ends(graph, edges, names = FALSE)[, 2]) } #' Tails of the edge(s) in a graph @@ -80,12 +92,24 @@ head_of <- function(graph, es) { #' `head_of()` returns the other end(s) of the edge(s). #' #' @param graph The input graph. -#' @param es The edges to query. +#' @param edges The edges to query. +#' @param es `r lifecycle::badge("deprecated")` Use `edges` instead. #' @return A vertex sequence with the tail(s) of the edge(s). #' #' @family structural queries #' #' @export -tail_of <- function(graph, es) { - create_vs(graph, ends(graph, es, names = FALSE)[, 1]) +tail_of <- function(graph, edges, es = deprecated()) { + if (lifecycle::is_present(es)) { + if (!missing(edges)) { + cli::cli_abort(c( + "Argument {.arg edges} of {.fn tail_of} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg es}." + )) + } + lifecycle::deprecate_soft("3.0.0", "tail_of(es = )", "tail_of(edges = )") + edges <- es + } + + create_vs(graph, ends(graph, edges, names = FALSE)[, 1]) } diff --git a/R/centrality.R b/R/centrality.R index bb8ce9ff4e..00b6cce390 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -527,17 +527,19 @@ betweenness <- function( } #' @rdname betweenness -#' @param e The edges for which the edge betweenness will be calculated. +#' @param edges The edges for which the edge betweenness will be calculated. #' The default `NULL` selects all edges. +#' @param e `r lifecycle::badge("deprecated")` Use `edges` instead. #' @inheritParams rlang::args_dots_empty #' @export edge_betweenness <- function( graph, - e = NULL, + edges = NULL, ..., directed = TRUE, weights = NULL, - cutoff = -1 + cutoff = -1, + e = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: edge_betweenness, do not edit, see tools/generate-migrations.R # fmt: skip @@ -570,26 +572,41 @@ edge_betweenness <- function( "3.0.0", what = base::I("Calling `edge_betweenness()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: edge_betweenness(", base::paste(base::c("graph", "e", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: edge_betweenness(", base::paste(base::c("graph", "e", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: edge_betweenness(", base::paste(base::c("graph", "edges", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: edge_betweenness(", base::paste(base::c("graph", "edges", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE - if (is.null(e)) { - e <- E(graph) + if (lifecycle::is_present(e)) { + if (!missing(edges)) { + cli::cli_abort(c( + "Argument {.arg edges} of {.fn edge_betweenness} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg e}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "edge_betweenness(e = )", + "edge_betweenness(edges = )" + ) + edges <- e + } + + if (is.null(edges)) { + edges <- E(graph) } - e <- as_igraph_es(graph, e) + edges <- as_igraph_es(graph, edges) res <- edge_betweenness_cutoff_impl( graph = graph, directed = directed, weights = weights, cutoff = cutoff ) - res[as.numeric(e)] + res[as.numeric(edges)] } #' Deprecated version of `edge_betweenness()` diff --git a/R/interface.R b/R/interface.R index d04f148d3c..f5980be9b2 100644 --- a/R/interface.R +++ b/R/interface.R @@ -544,7 +544,8 @@ is_directed <- function(graph) { #' Incident vertices of some graph edges #' #' @param graph The input graph -#' @param es The sequence of edges to query +#' @param edges The sequence of edges to query +#' @param es `r lifecycle::badge("deprecated")` Use `edges` instead. #' @inheritParams rlang::args_dots_empty #' @param names Whether to return vertex names or #' numeric vertex IDs. By default vertex names are used. @@ -560,13 +561,16 @@ is_directed <- function(graph) { #' ends(g, E(g)) ends <- function( graph, - es, + edges, ..., - names = TRUE + names = TRUE, + es = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: ends, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { + .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("e")) + if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn ends}.", i = "Spell out the full argument name.")) # Pre-3.0.0 signature: ends(graph, es, names) .old_signature <- function(names, ...) { if (...length() > 0L) { @@ -591,24 +595,35 @@ ends <- function( "3.0.0", what = base::I("Calling `ends()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: ends(", base::paste(base::c("graph", "es", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: ends(", base::paste(base::c("graph", "es", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: ends(", base::paste(base::c("graph", "edges", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: ends(", base::paste(base::c("graph", "edges", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(es)) { + if (!missing(edges)) { + cli::cli_abort(c( + "Argument {.arg edges} of {.fn ends} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg es}." + )) + } + lifecycle::deprecate_soft("3.0.0", "ends(es = )", "ends(edges = )") + edges <- es + } + ensure_igraph(graph) - res <- matrix(NA_integer_, ncol = length(es), nrow = 2) + res <- matrix(NA_integer_, ncol = length(edges), nrow = 2) - if (length(es) > 0) { + if (length(edges) > 0) { edge_data <- edges_impl( graph = graph, - eids = es + eids = edges ) - res[, !is.na(es)] <- edge_data + res[, !is.na(edges)] <- edge_data } if (names && is_named(graph)) { diff --git a/R/iterators.R b/R/iterators.R index 7c3a3b0850..42e38e7d35 100644 --- a/R/iterators.R +++ b/R/iterators.R @@ -506,7 +506,7 @@ E <- function( names(res) <- edge_attr(graph)$name[res] } if (is_named(graph)) { - el <- ends(graph, es = res) + el <- ends(graph, edges = res) attr(res, "vnames") <- paste(el[, 1], el[, 2], sep = "|") } diff --git a/R/operators.R b/R/operators.R index 551d39e280..a85ef980b3 100644 --- a/R/operators.R +++ b/R/operators.R @@ -1610,12 +1610,13 @@ rep.igraph <- function(x, n, mark = TRUE, ...) { #' #' The new graph will contain the same vertices, edges and attributes as #' the original graph, except that the direction of the edges selected by -#' their edge IDs in the `eids` argument will be reversed. When reversing +#' their edge IDs in the `edges` argument will be reversed. When reversing #' all edges, this operation is also known as graph transpose. #' #' @param graph The input graph. -#' @param eids The edge IDs of the edges to reverse. The default `NULL` +#' @param edges The edge IDs of the edges to reverse. The default `NULL` #' reverses all edges. +#' @param eids `r lifecycle::badge("deprecated")` Use `edges` instead. #' @return The result graph where the direction of the edges with the given #' IDs are reversed #' @@ -1625,14 +1626,29 @@ rep.igraph <- function(x, n, mark = TRUE, ...) { #' reverse_edges(g, 2) #' @family functions for manipulating graph structure #' @export -reverse_edges <- function(graph, eids = NULL) { - if (is.null(eids)) { - eids <- E(graph) +reverse_edges <- function(graph, edges = NULL, eids = deprecated()) { + if (lifecycle::is_present(eids)) { + if (!missing(edges)) { + cli::cli_abort(c( + "Argument {.arg edges} of {.fn reverse_edges} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg eids}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "reverse_edges(eids = )", + "reverse_edges(edges = )" + ) + edges <- eids + } + + if (is.null(edges)) { + edges <- E(graph) } reverse_edges_impl( graph = graph, - eids = eids + eids = edges ) } diff --git a/R/structural-properties.R b/R/structural-properties.R index 9df4659911..552487c460 100644 --- a/R/structural-properties.R +++ b/R/structural-properties.R @@ -2152,20 +2152,24 @@ induced_subgraph <- function( } #' @rdname subgraph -#' @param eids The edge IDs of the edges that will be kept in the result graph. +#' @param edges The edge IDs of the edges that will be kept in the result graph. +#' @param eids `r lifecycle::badge("deprecated")` Use `edges` instead. #' @inheritParams rlang::args_dots_empty #' @param delete.vertices Logical, whether to remove vertices that do -#' not have any adjacent edges in `eids`. +#' not have any adjacent edges in `edges`. #' @export subgraph_from_edges <- function( graph, - eids, + edges, ..., - delete.vertices = TRUE + delete.vertices = TRUE, + eids = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: subgraph_from_edges, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { + .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("e")) + if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn subgraph_from_edges}.", i = "Spell out the full argument name.")) # Pre-3.0.0 signature: subgraph_from_edges(graph, eids, delete.vertices) .old_signature <- function(delete.vertices, ...) { if (...length() > 0L) { @@ -2190,24 +2194,39 @@ subgraph_from_edges <- function( "3.0.0", what = base::I("Calling `subgraph_from_edges()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: subgraph_from_edges(", base::paste(base::c("graph", "eids", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: subgraph_from_edges(", base::paste(base::c("graph", "eids", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: subgraph_from_edges(", base::paste(base::c("graph", "edges", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: subgraph_from_edges(", base::paste(base::c("graph", "edges", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(eids)) { + if (!missing(edges)) { + cli::cli_abort(c( + "Argument {.arg edges} of {.fn subgraph_from_edges} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg eids}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "subgraph_from_edges(eids = )", + "subgraph_from_edges(edges = )" + ) + edges <- eids + } + # Argument checks # Argument checks ensure_igraph(graph) - eids <- as_igraph_es(graph, eids) + edges <- as_igraph_es(graph, edges) delete.vertices <- as.logical(delete.vertices) # Function call res <- subgraph_from_edges_impl( graph = graph, - eids = eids, + eids = edges, delete_vertices = delete.vertices ) @@ -3631,8 +3650,9 @@ girth <- function( #' original multiplicity as an edge attribute. #' #' @param graph The input graph. -#' @param eids The edges to which the query is restricted. The default +#' @param edges The edges to which the query is restricted. The default #' `NULL` selects all edges. +#' @param eids `r lifecycle::badge("deprecated")` Use `edges` instead. #' @return `any_loop()` and `any_multiple()` return a Logical. #' `which_loop()` and `which_multiple()` return a logical vector. #' `count_loops()` returns a numeric scalar with the total number of loop edges. @@ -3669,14 +3689,29 @@ girth <- function( #' any(which_multiple(g)) #' E(g)$weight #' -which_multiple <- function(graph, eids = NULL) { - if (is.null(eids)) { - eids <- E(graph) +which_multiple <- function(graph, edges = NULL, eids = deprecated()) { + if (lifecycle::is_present(eids)) { + if (!missing(edges)) { + cli::cli_abort(c( + "Argument {.arg edges} of {.fn which_multiple} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg eids}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "which_multiple(eids = )", + "which_multiple(edges = )" + ) + edges <- eids + } + + if (is.null(edges)) { + edges <- E(graph) } is_multiple_impl( graph = graph, - eids = eids + eids = edges ) } #' @rdname which_multiple @@ -3688,26 +3723,56 @@ any_multiple <- function(graph) { } #' @rdname which_multiple #' @export -count_multiple <- function(graph, eids = NULL) { - if (is.null(eids)) { - eids <- E(graph) +count_multiple <- function(graph, edges = NULL, eids = deprecated()) { + if (lifecycle::is_present(eids)) { + if (!missing(edges)) { + cli::cli_abort(c( + "Argument {.arg edges} of {.fn count_multiple} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg eids}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "count_multiple(eids = )", + "count_multiple(edges = )" + ) + edges <- eids + } + + if (is.null(edges)) { + edges <- E(graph) } count_multiple_impl( graph = graph, - eids = eids + eids = edges ) } #' @rdname which_multiple #' @export -which_loop <- function(graph, eids = NULL) { - if (is.null(eids)) { - eids <- E(graph) +which_loop <- function(graph, edges = NULL, eids = deprecated()) { + if (lifecycle::is_present(eids)) { + if (!missing(edges)) { + cli::cli_abort(c( + "Argument {.arg edges} of {.fn which_loop} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg eids}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "which_loop(eids = )", + "which_loop(edges = )" + ) + edges <- eids + } + + if (is.null(edges)) { + edges <- E(graph) } is_loop_impl( graph = graph, - eids = eids + eids = edges ) } #' @rdname which_multiple @@ -4992,8 +5057,9 @@ max_bipartite_match <- function( #' Undirected graphs contain only mutual edges by definition. #' #' @param graph The input graph. -#' @param eids Edge sequence, the edges that will be probed. The default +#' @param edges Edge sequence, the edges that will be probed. The default #' `NULL` includes all edges in the order of their IDs. +#' @param eids `r lifecycle::badge("deprecated")` Use `edges` instead. #' @inheritParams rlang::args_dots_empty #' @param loops Logical, whether to consider directed self-loops to be mutual. #' @return A logical vector of the same length as the number of edges supplied. @@ -5012,13 +5078,16 @@ max_bipartite_match <- function( #' @export which_mutual <- function( graph, - eids = NULL, + edges = NULL, ..., - loops = TRUE + loops = TRUE, + eids = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: which_mutual, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { + .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("e")) + if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn which_mutual}.", i = "Spell out the full argument name.")) # Pre-3.0.0 signature: which_mutual(graph, eids, loops) .old_signature <- function(loops, ...) { if (...length() > 0L) { @@ -5043,21 +5112,36 @@ which_mutual <- function( "3.0.0", what = base::I("Calling `which_mutual()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: which_mutual(", base::paste(base::c("graph", "eids", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: which_mutual(", base::paste(base::c("graph", "eids", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: which_mutual(", base::paste(base::c("graph", "edges", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: which_mutual(", base::paste(base::c("graph", "edges", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE - if (is.null(eids)) { - eids <- E(graph) + if (lifecycle::is_present(eids)) { + if (!missing(edges)) { + cli::cli_abort(c( + "Argument {.arg edges} of {.fn which_mutual} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg eids}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "which_mutual(eids = )", + "which_mutual(edges = )" + ) + edges <- eids + } + + if (is.null(edges)) { + edges <- E(graph) } is_mutual_impl( graph = graph, - eids = eids, + eids = edges, loops = loops ) } diff --git a/tests/testthat/_snaps/basic.md b/tests/testthat/_snaps/basic.md new file mode 100644 index 0000000000..6aeac095b4 --- /dev/null +++ b/tests/testthat/_snaps/basic.md @@ -0,0 +1,18 @@ +# head_of(es = ) and tail_of(es = ) are deprecated but still work + + Code + res <- head_of(g, es = E(g)) + Condition + Warning: + The `es` argument of `head_of()` is deprecated as of igraph 3.0.0. + i Please use the `edges` argument instead. + +--- + + Code + head_of(g, edges = 1, es = 2) + Condition + Error in `head_of()`: + ! Argument `edges` of `head_of()` was supplied more than once. + i It was also supplied via its legacy name `es`. + diff --git a/tests/testthat/_snaps/structural-properties.md b/tests/testthat/_snaps/structural-properties.md index 3e830250fd..f59160e0e4 100644 --- a/tests/testthat/_snaps/structural-properties.md +++ b/tests/testthat/_snaps/structural-properties.md @@ -95,3 +95,12 @@ ! Argument `vertices` of `degree()` was supplied more than once. i It was also supplied via its legacy name `v`. +# edge queries with `eids = ` are deprecated but still work + + Code + res <- which_multiple(g, eids = 4:5) + Condition + Warning: + The `eids` argument of `which_multiple()` is deprecated as of igraph 3.0.0. + i Please use the `edges` argument instead. + diff --git a/tests/testthat/test-basic.R b/tests/testthat/test-basic.R new file mode 100644 index 0000000000..f7ec2017df --- /dev/null +++ b/tests/testthat/test-basic.R @@ -0,0 +1,15 @@ +test_that("head_of() and tail_of() work", { + g <- make_graph(c(1, 2, 2, 3), directed = TRUE) + expect_equal(as.numeric(head_of(g, E(g))), c(2, 3)) + expect_equal(as.numeric(tail_of(g, E(g))), c(1, 2)) +}) + +test_that("head_of(es = ) and tail_of(es = ) are deprecated but still work", { + rlang::local_options(lifecycle_verbosity = "warning") + g <- make_graph(c(1, 2, 2, 3), directed = TRUE) + expect_snapshot_igraph(res <- head_of(g, es = E(g))) + expect_equal(res, head_of(g, edges = E(g))) + lifecycle::expect_deprecated(res <- tail_of(g, es = E(g))) + expect_equal(res, tail_of(g, edges = E(g))) + expect_snapshot_igraph_error(head_of(g, edges = 1, es = 2)) +}) diff --git a/tests/testthat/test-centrality.R b/tests/testthat/test-centrality.R index eff3b742d3..9330f768c3 100644 --- a/tests/testthat/test-centrality.R +++ b/tests/testthat/test-centrality.R @@ -1030,7 +1030,7 @@ test_that("edge_betweenness() covers migrated tail args and positional recovery" res <- edge_betweenness( ring, - e = E(ring)[1:3], + edges = E(ring)[1:3], directed = FALSE, weights = rep(1, 5), cutoff = -1 @@ -1039,7 +1039,7 @@ test_that("edge_betweenness() covers migrated tail args and positional recovery" expect_equal(res, rep(3, 3)) # With a cutoff of 1 each edge only carries the path of its endpoints. expect_equal( - edge_betweenness(ring, e = E(ring)[1:3], weights = rep(1, 5), cutoff = 1), + edge_betweenness(ring, edges = E(ring)[1:3], weights = rep(1, 5), cutoff = 1), rep(1, 3) ) @@ -1355,3 +1355,10 @@ test_that("page_rank(vids = ) is recovered as `vertices`", { ) expect_identical(res_legacy, page_rank(g, vertices = 1:3)) }) + +test_that("edge_betweenness(e = ) is deprecated but still works", { + rlang::local_options(lifecycle_verbosity = "warning") + g <- make_ring(5) + lifecycle::expect_deprecated(res <- edge_betweenness(g, e = E(g)[1:2])) + expect_equal(res, edge_betweenness(g, edges = E(g)[1:2])) +}) diff --git a/tests/testthat/test-constant-defaults.R b/tests/testthat/test-constant-defaults.R index 0227b4417f..06f3fbcc34 100644 --- a/tests/testthat/test-constant-defaults.R +++ b/tests/testthat/test-constant-defaults.R @@ -12,7 +12,7 @@ test_that("NULL selector defaults stand for the full vertex/edge set", { expect_identical(degree(g, vertices = NULL), degree(g)) expect_identical(distances(g, vertices = NULL, to = NULL), distances(g)) expect_identical(diversity(g, vertices = NULL), diversity(g)) - expect_identical(which_mutual(g, eids = NULL), which_mutual(g)) + expect_identical(which_mutual(g, edges = NULL), which_mutual(g)) expect_identical(closeness(g, vertices = NULL), closeness(g)) }) @@ -34,13 +34,13 @@ test_that("NULL selector defaults of round-2 functions select the full set", { g <- make_ring(5) expect_identical(max_degree(g, vertices = NULL), max_degree(g)) - expect_identical(which_loop(g, eids = NULL), which_loop(g)) - expect_identical(which_multiple(g, eids = NULL), which_multiple(g)) - expect_identical(count_multiple(g, eids = NULL), count_multiple(g)) + expect_identical(which_loop(g, edges = NULL), which_loop(g)) + expect_identical(which_multiple(g, edges = NULL), which_multiple(g)) + expect_identical(count_multiple(g, edges = NULL), count_multiple(g)) expect_identical(count_triangles(g, vertices = NULL), count_triangles(g)) expect_identical(cocitation(g, vertices = NULL), cocitation(g)) expect_identical(similarity(g, vertices = NULL), similarity(g)) - expect_identical_graphs(reverse_edges(g, eids = NULL), reverse_edges(g)) + expect_identical_graphs(reverse_edges(g, edges = NULL), reverse_edges(g)) V(g)$name <- letters[1:5] expect_identical(vertex_attr(g, "name", index = NULL), vertex_attr(g, "name")) @@ -83,7 +83,7 @@ test_that("empty-sequence defaults are spelled as typed empty vectors", { # while NULL now always means "use the default". g <- make_graph(c(1, 2, 2, 2, 2, 3), directed = TRUE) expect_equal(max_degree(g, vertices = integer()), 0) - expect_identical(which_loop(g, eids = integer()), logical(0)) + expect_identical(which_loop(g, edges = integer()), logical(0)) expect_gt(max_degree(g, vertices = NULL), 0) # layout_as_tree(): the typed empty stays the documented default diff --git a/tests/testthat/test-interface.R b/tests/testthat/test-interface.R index 4a5a405be4..50ba5ecb5b 100644 --- a/tests/testthat/test-interface.R +++ b/tests/testthat/test-interface.R @@ -336,11 +336,11 @@ test_that("ends() tail arguments and legacy positional recovery", { # The endpoint matrix contains vertex names with names = TRUE # and vertex IDs with names = FALSE. expect_equal( - ends(g, es = 1:2), + ends(g, edges = 1:2), matrix(c("a", "b", "b", "c"), nrow = 2) ) expect_equal( - ends(g, es = 1:2, names = FALSE), + ends(g, edges = 1:2, names = FALSE), matrix(c(1, 2, 2, 3), nrow = 2) ) @@ -394,3 +394,10 @@ test_that("neighbors(v = ) and incident(v = ) are deprecated but still work", { expect_snapshot_igraph_error(neighbors(g, vertex = 1, v = 2)) }) + +test_that("ends(es = ) is deprecated but still works", { + rlang::local_options(lifecycle_verbosity = "warning") + g <- make_ring(5) + lifecycle::expect_deprecated(res <- ends(g, es = 1:2)) + expect_equal(res, ends(g, edges = 1:2)) +}) diff --git a/tests/testthat/test-operators.R b/tests/testthat/test-operators.R index fbf6bdb1ea..60af0c74fb 100644 --- a/tests/testthat/test-operators.R +++ b/tests/testthat/test-operators.R @@ -1561,3 +1561,10 @@ test_that("compose() recovers legacy positional arguments", { compose(g1, g2, byname = FALSE, edge_attr_combine = "concat") ) }) + +test_that("reverse_edges(eids = ) is deprecated but still works", { + rlang::local_options(lifecycle_verbosity = "warning") + g <- make_graph(c(1, 2, 2, 3), directed = TRUE) + lifecycle::expect_deprecated(res <- reverse_edges(g, eids = 1)) + expect_identical_graphs(res, reverse_edges(g, edges = 1)) +}) diff --git a/tests/testthat/test-structural-properties.R b/tests/testthat/test-structural-properties.R index 7fd1218369..8cad28f1ca 100644 --- a/tests/testthat/test-structural-properties.R +++ b/tests/testthat/test-structural-properties.R @@ -1529,7 +1529,7 @@ test_that("which_mutual() tail arguments and legacy positional recovery", { # loops = FALSE stops counting the self-loop as mutual. expect_equal( - which_mutual(g, eids = E(g), loops = FALSE), + which_mutual(g, edges = E(g), loops = FALSE), c(TRUE, TRUE, FALSE) ) @@ -1627,3 +1627,19 @@ test_that("subcomponent(v = ) is deprecated but still works", { ) expect_equal(res_legacy, subcomponent(g, vertex = 2, mode = "out")) }) + +test_that("edge queries with `eids = ` are deprecated but still work", { + rlang::local_options(lifecycle_verbosity = "warning") + g <- make_graph(c(1, 2, 2, 1, 1, 1, 2, 3, 2, 3), directed = TRUE) + + expect_snapshot_igraph(res <- which_multiple(g, eids = 4:5)) + expect_equal(res, which_multiple(g, edges = 4:5)) + lifecycle::expect_deprecated(res <- count_multiple(g, eids = 4:5)) + expect_equal(res, count_multiple(g, edges = 4:5)) + lifecycle::expect_deprecated(res <- which_loop(g, eids = 3)) + expect_equal(res, which_loop(g, edges = 3)) + lifecycle::expect_deprecated(res <- which_mutual(g, eids = 1:2)) + expect_equal(res, which_mutual(g, edges = 1:2)) + lifecycle::expect_deprecated(res <- subgraph_from_edges(g, eids = 1:2)) + expect_identical_graphs(res, subgraph_from_edges(g, edges = 1:2)) +}) diff --git a/tools/migrations/centrality.R b/tools/migrations/centrality.R index 3dde39758b..993c1af458 100644 --- a/tools/migrations/centrality.R +++ b/tools/migrations/centrality.R @@ -65,11 +65,12 @@ migrations <- list( old = function(graph, e, directed, weights, cutoff) {}, new = function( graph, - e = NULL, + edges = NULL, ..., directed = TRUE, weights = NULL, - cutoff = -1 + cutoff = -1, + e = deprecated() ) {}, when = "3.0.0" ), diff --git a/tools/migrations/interface.R b/tools/migrations/interface.R index a4f2684917..600b099634 100644 --- a/tools/migrations/interface.R +++ b/tools/migrations/interface.R @@ -19,9 +19,10 @@ migrations <- list( old = function(graph, es, names) {}, new = function( graph, - es, + edges, ..., - names = TRUE + names = TRUE, + es = deprecated() ) {}, when = "3.0.0" ), diff --git a/tools/migrations/structural-properties.R b/tools/migrations/structural-properties.R index d54b93bbda..de38ccdd96 100644 --- a/tools/migrations/structural-properties.R +++ b/tools/migrations/structural-properties.R @@ -405,9 +405,10 @@ migrations <- list( old = function(graph, eids, delete.vertices) {}, new = function( graph, - eids, + edges, ..., - delete.vertices = TRUE + delete.vertices = TRUE, + eids = deprecated() ) {}, when = "3.0.0" ), @@ -461,9 +462,10 @@ migrations <- list( old = function(graph, eids, loops) {}, new = function( graph, - eids = NULL, + edges = NULL, ..., - loops = TRUE + loops = TRUE, + eids = deprecated() ) {}, when = "3.0.0" ) From 332c66bf47735149a73e4824ff66e8b804567072 Mon Sep 17 00:00:00 2001 From: David Schoch Date: Thu, 15 Oct 2026 21:24:21 +0200 Subject: [PATCH 2/8] test: Accept the doubled deprecation in the `subgraph.edges()` snapshot The frozen wrapper forwards `eids = `, which now also soft-deprecates. Part of #2788. Co-Authored-By: Claude Opus 5.5 (1M context) --- tests/testthat/_snaps/trees.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/testthat/_snaps/trees.md b/tests/testthat/_snaps/trees.md index 91a639c3a3..59f2f7cc2b 100644 --- a/tests/testthat/_snaps/trees.md +++ b/tests/testthat/_snaps/trees.md @@ -6,6 +6,9 @@ Warning: `subgraph.edges()` was deprecated in igraph 2.1.0. i Please use `subgraph_from_edges()` instead. + Warning: + The `eids` argument of `subgraph_from_edges()` is deprecated as of igraph 3.0.0. + i Please use the `edges` argument instead. Output IGRAPH U--- 13 11 -- + attr: name_1 (g/c), name_2 (g/c), loops_1 (g/l), loops_2 (g/l) From 37b7e9b1cfe205505114556362f136154140a7d8 Mon Sep 17 00:00:00 2001 From: krlmlr Date: Sun, 18 Oct 2026 09:44:16 +0000 Subject: [PATCH 3/8] chore: Auto-update from GitHub Actions Run: https://github.com/igraph/rigraph/actions/runs/39115844445 --- man/betweenness.Rd | 9 ++++++--- man/count.multiple.Rd | 3 +-- man/edge.betweenness.Rd | 3 +-- man/ends.Rd | 6 ++++-- man/estimate_edge_betweenness.Rd | 3 +-- man/head_of.Rd | 6 ++++-- man/incident.Rd | 12 ++++++++++-- man/is.loop.Rd | 3 +-- man/is.multiple.Rd | 3 +-- man/is.mutual.Rd | 3 +-- man/neighbors.Rd | 12 ++++++++++-- man/reverse_edges.Rd | 8 +++++--- man/sample_spanning_tree.Rd | 4 ++-- man/subcomponent.Rd | 20 ++++++++++++++------ man/subgraph.Rd | 14 +++++++++++--- man/subgraph.edges.Rd | 4 ++-- man/tail_of.Rd | 6 ++++-- man/which_multiple.Rd | 10 ++++++---- man/which_mutual.Rd | 6 ++++-- tests/testthat/test-centrality.R | 7 ++++++- 20 files changed, 94 insertions(+), 48 deletions(-) diff --git a/man/betweenness.Rd b/man/betweenness.Rd index c0a9ef9979..bf6ecae18f 100644 --- a/man/betweenness.Rd +++ b/man/betweenness.Rd @@ -20,11 +20,12 @@ betweenness( edge_betweenness( graph, - e = NULL, + edges = NULL, ..., directed = TRUE, weights = NULL, - cutoff = -1 + cutoff = -1, + e = deprecated() ) } \arguments{ @@ -60,8 +61,10 @@ betweenness. If negative, then there is no such limit.} \item{v}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{vertices} instead.} -\item{e}{The edges for which the edge betweenness will be calculated. +\item{edges}{The edges for which the edge betweenness will be calculated. The default \code{NULL} selects all edges.} + +\item{e}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{edges} instead.} } \value{ A numeric vector with the betweenness score for each vertex in diff --git a/man/count.multiple.Rd b/man/count.multiple.Rd index a4e624fe0c..d97bbb990f 100644 --- a/man/count.multiple.Rd +++ b/man/count.multiple.Rd @@ -9,8 +9,7 @@ count.multiple(graph, eids = E(graph)) \arguments{ \item{graph}{The input graph.} -\item{eids}{The edges to which the query is restricted. The default -\code{NULL} selects all edges.} +\item{eids}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{edges} instead.} } \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} diff --git a/man/edge.betweenness.Rd b/man/edge.betweenness.Rd index a98737cf18..0ec479ca94 100644 --- a/man/edge.betweenness.Rd +++ b/man/edge.betweenness.Rd @@ -15,8 +15,7 @@ edge.betweenness( \arguments{ \item{graph}{The graph to analyze.} -\item{e}{The edges for which the edge betweenness will be calculated. -The default \code{NULL} selects all edges.} +\item{e}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{edges} instead.} \item{directed}{Logical, whether directed paths should be considered while determining the shortest paths.} diff --git a/man/ends.Rd b/man/ends.Rd index be8c438198..2fb27f521b 100644 --- a/man/ends.Rd +++ b/man/ends.Rd @@ -5,17 +5,19 @@ \alias{get.edges} \title{Incident vertices of some graph edges} \usage{ -ends(graph, es, ..., names = TRUE) +ends(graph, edges, ..., names = TRUE, es = deprecated()) } \arguments{ \item{graph}{The input graph} -\item{es}{The sequence of edges to query} +\item{edges}{The sequence of edges to query} \item{...}{These dots are for future extensions and must be empty.} \item{names}{Whether to return vertex names or numeric vertex IDs. By default vertex names are used.} + +\item{es}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{edges} instead.} } \value{ A two column matrix of vertex names or vertex IDs. diff --git a/man/estimate_edge_betweenness.Rd b/man/estimate_edge_betweenness.Rd index acd055427c..e04e407f35 100644 --- a/man/estimate_edge_betweenness.Rd +++ b/man/estimate_edge_betweenness.Rd @@ -15,8 +15,7 @@ estimate_edge_betweenness( \arguments{ \item{graph}{The graph to analyze.} -\item{e}{The edges for which the edge betweenness will be calculated. -The default \code{NULL} selects all edges.} +\item{e}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{edges} instead.} \item{directed}{Logical, whether directed paths should be considered while determining the shortest paths.} diff --git a/man/head_of.Rd b/man/head_of.Rd index 4e916b2631..eb29264e59 100644 --- a/man/head_of.Rd +++ b/man/head_of.Rd @@ -4,12 +4,14 @@ \alias{head_of} \title{Head of the edge(s) in a graph} \usage{ -head_of(graph, es) +head_of(graph, edges, es = deprecated()) } \arguments{ \item{graph}{The input graph.} -\item{es}{The edges to query.} +\item{edges}{The edges to query.} + +\item{es}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{edges} instead.} } \value{ A vertex sequence with the head(s) of the edge(s). diff --git a/man/incident.Rd b/man/incident.Rd index c0833e4639..d63f30112e 100644 --- a/man/incident.Rd +++ b/man/incident.Rd @@ -4,18 +4,26 @@ \alias{incident} \title{Incident edges of a vertex in a graph} \usage{ -incident(graph, v, ..., mode = c("all", "out", "in", "total")) +incident( + graph, + vertex, + ..., + mode = c("all", "out", "in", "total"), + v = deprecated() +) } \arguments{ \item{graph}{The input graph.} -\item{v}{The vertex of which the incident edges are queried.} +\item{vertex}{The vertex of which the incident edges are queried.} \item{...}{These dots are for future extensions and must be empty.} \item{mode}{Whether to query outgoing (\sQuote{out}), incoming (\sQuote{in}) edges, or both types (\sQuote{all}). This is ignored for undirected graphs.} + +\item{v}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{vertex} instead.} } \value{ An edge sequence containing the incident edges of diff --git a/man/is.loop.Rd b/man/is.loop.Rd index ce99c88946..6edd60a140 100644 --- a/man/is.loop.Rd +++ b/man/is.loop.Rd @@ -9,8 +9,7 @@ is.loop(graph, eids = E(graph)) \arguments{ \item{graph}{The input graph.} -\item{eids}{The edges to which the query is restricted. The default -\code{NULL} selects all edges.} +\item{eids}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{edges} instead.} } \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} diff --git a/man/is.multiple.Rd b/man/is.multiple.Rd index 8ea9bd2d76..c3c4ddc8cd 100644 --- a/man/is.multiple.Rd +++ b/man/is.multiple.Rd @@ -9,8 +9,7 @@ is.multiple(graph, eids = E(graph)) \arguments{ \item{graph}{The input graph.} -\item{eids}{The edges to which the query is restricted. The default -\code{NULL} selects all edges.} +\item{eids}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{edges} instead.} } \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} diff --git a/man/is.mutual.Rd b/man/is.mutual.Rd index 321108ac67..37b1dc1cf7 100644 --- a/man/is.mutual.Rd +++ b/man/is.mutual.Rd @@ -9,8 +9,7 @@ is.mutual(graph, eids = E(graph), loops = TRUE) \arguments{ \item{graph}{The input graph.} -\item{eids}{Edge sequence, the edges that will be probed. The default -\code{NULL} includes all edges in the order of their IDs.} +\item{eids}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{edges} instead.} \item{loops}{Logical, whether to consider directed self-loops to be mutual.} } diff --git a/man/neighbors.Rd b/man/neighbors.Rd index 7ddf86de6c..40d37357bf 100644 --- a/man/neighbors.Rd +++ b/man/neighbors.Rd @@ -4,18 +4,26 @@ \alias{neighbors} \title{Neighboring (adjacent) vertices in a graph} \usage{ -neighbors(graph, v, ..., mode = c("out", "in", "all", "total")) +neighbors( + graph, + vertex, + ..., + mode = c("out", "in", "all", "total"), + v = deprecated() +) } \arguments{ \item{graph}{The input graph.} -\item{v}{The vertex of which the adjacent vertices are queried.} +\item{vertex}{The vertex of which the adjacent vertices are queried.} \item{...}{These dots are for future extensions and must be empty.} \item{mode}{Whether to query outgoing (\sQuote{out}), incoming (\sQuote{in}) edges, or both types (\sQuote{all}). This is ignored for undirected graphs.} + +\item{v}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{vertex} instead.} } \value{ A vertex sequence containing the neighbors of the input vertex. diff --git a/man/reverse_edges.Rd b/man/reverse_edges.Rd index f4d0cd085f..08488ebddf 100644 --- a/man/reverse_edges.Rd +++ b/man/reverse_edges.Rd @@ -5,16 +5,18 @@ \alias{t.igraph} \title{Reverse edges in a graph} \usage{ -reverse_edges(graph, eids = NULL) +reverse_edges(graph, edges = NULL, eids = deprecated()) \method{t}{igraph}(x) } \arguments{ \item{graph}{The input graph.} -\item{eids}{The edge IDs of the edges to reverse. The default \code{NULL} +\item{edges}{The edge IDs of the edges to reverse. The default \code{NULL} reverses all edges.} +\item{eids}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{edges} instead.} + \item{x}{The input graph.} } \value{ @@ -24,7 +26,7 @@ IDs are reversed \description{ The new graph will contain the same vertices, edges and attributes as the original graph, except that the direction of the edges selected by -their edge IDs in the \code{eids} argument will be reversed. When reversing +their edge IDs in the \code{edges} argument will be reversed. When reversing all edges, this operation is also known as graph transpose. } \section{Related documentation in the C library}{ diff --git a/man/sample_spanning_tree.Rd b/man/sample_spanning_tree.Rd index a6b5665dbb..d6d02f4603 100644 --- a/man/sample_spanning_tree.Rd +++ b/man/sample_spanning_tree.Rd @@ -4,7 +4,7 @@ \alias{sample_spanning_tree} \title{Samples from the spanning trees of a graph randomly and uniformly} \usage{ -sample_spanning_tree(graph, ..., vid = 0) +sample_spanning_tree(graph, ..., vertex = 0) } \arguments{ \item{graph}{The input graph to sample from. Edge directions are ignored if @@ -12,7 +12,7 @@ the graph is directed.} \item{...}{These dots are for future extensions and must be empty.} -\item{vid}{When the graph is disconnected, this argument specifies how to +\item{vertex}{When the graph is disconnected, this argument specifies how to handle the situation. When the argument is zero (the default), the sampling will be performed component-wise, and the result will be a spanning forest. When the argument contains a vertex ID, only the component containing the diff --git a/man/subcomponent.Rd b/man/subcomponent.Rd index cd4092391c..4a0c9f63b2 100644 --- a/man/subcomponent.Rd +++ b/man/subcomponent.Rd @@ -4,31 +4,39 @@ \alias{subcomponent} \title{In- or out- component of a vertex} \usage{ -subcomponent(graph, v, ..., mode = c("all", "out", "in")) +subcomponent( + graph, + vertex, + ..., + mode = c("all", "out", "in"), + v = deprecated() +) } \arguments{ \item{graph}{The graph to analyze.} -\item{v}{The vertex to start the search from.} +\item{vertex}{The vertex to start the search from.} \item{...}{These dots are for future extensions and must be empty.} \item{mode}{Character string, either \dQuote{in}, \dQuote{out} or -\dQuote{all}. If \dQuote{in} all vertices from which \code{v} is reachable -are listed. If \dQuote{out} all vertices reachable from \code{v} are +\dQuote{all}. If \dQuote{in} all vertices from which \code{vertex} is reachable +are listed. If \dQuote{out} all vertices reachable from \code{vertex} are returned. If \dQuote{all} returns the union of these. It is ignored for undirected graphs.} + +\item{v}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{vertex} instead.} } \value{ Numeric vector, the IDs of the vertices in the same component as -\code{v}. +\code{vertex}. } \description{ Finds all vertices reachable from a given vertex, or the opposite: all vertices from which a given vertex is reachable via a directed path. } \details{ -A breadth-first search is conducted starting from vertex \code{v}. +A breadth-first search is conducted starting from vertex \code{vertex}. } \section{Related documentation in the C library}{ \href{https://igraph.org/c/html/0.10.17/igraph-Basic.html#igraph_vcount}{\code{vcount()}} diff --git a/man/subgraph.Rd b/man/subgraph.Rd index 3dd9858bb6..41ece1613b 100644 --- a/man/subgraph.Rd +++ b/man/subgraph.Rd @@ -16,7 +16,13 @@ induced_subgraph( vids = deprecated() ) -subgraph_from_edges(graph, eids, ..., delete.vertices = TRUE) +subgraph_from_edges( + graph, + edges, + ..., + delete.vertices = TRUE, + eids = deprecated() +) } \arguments{ \item{graph}{The original graph.} @@ -37,10 +43,12 @@ scratch. \sQuote{\code{auto}} chooses between the two implementations automatically, using heuristics based on the size of the original and the result graph.} -\item{eids}{The edge IDs of the edges that will be kept in the result graph.} +\item{edges}{The edge IDs of the edges that will be kept in the result graph.} \item{delete.vertices}{Logical, whether to remove vertices that do -not have any adjacent edges in \code{eids}.} +not have any adjacent edges in \code{edges}.} + +\item{eids}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{edges} instead.} } \value{ A new graph object. diff --git a/man/subgraph.edges.Rd b/man/subgraph.edges.Rd index 903f76914b..9b5d74bf5d 100644 --- a/man/subgraph.edges.Rd +++ b/man/subgraph.edges.Rd @@ -9,10 +9,10 @@ subgraph.edges(graph, eids, delete.vertices = TRUE) \arguments{ \item{graph}{The original graph.} -\item{eids}{The edge IDs of the edges that will be kept in the result graph.} +\item{eids}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{edges} instead.} \item{delete.vertices}{Logical, whether to remove vertices that do -not have any adjacent edges in \code{eids}.} +not have any adjacent edges in \code{edges}.} } \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} diff --git a/man/tail_of.Rd b/man/tail_of.Rd index 91f16cab2a..fb176dde06 100644 --- a/man/tail_of.Rd +++ b/man/tail_of.Rd @@ -4,12 +4,14 @@ \alias{tail_of} \title{Tails of the edge(s) in a graph} \usage{ -tail_of(graph, es) +tail_of(graph, edges, es = deprecated()) } \arguments{ \item{graph}{The input graph.} -\item{es}{The edges to query.} +\item{edges}{The edges to query.} + +\item{es}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{edges} instead.} } \value{ A vertex sequence with the tail(s) of the edge(s). diff --git a/man/which_multiple.Rd b/man/which_multiple.Rd index 4d166b4a5a..8fa03ad52c 100644 --- a/man/which_multiple.Rd +++ b/man/which_multiple.Rd @@ -9,13 +9,13 @@ \alias{count_loops} \title{Find the multiple or loop edges in a graph} \usage{ -which_multiple(graph, eids = NULL) +which_multiple(graph, edges = NULL, eids = deprecated()) any_multiple(graph) -count_multiple(graph, eids = NULL) +count_multiple(graph, edges = NULL, eids = deprecated()) -which_loop(graph, eids = NULL) +which_loop(graph, edges = NULL, eids = deprecated()) any_loop(graph) @@ -24,8 +24,10 @@ count_loops(graph) \arguments{ \item{graph}{The input graph.} -\item{eids}{The edges to which the query is restricted. The default +\item{edges}{The edges to which the query is restricted. The default \code{NULL} selects all edges.} + +\item{eids}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{edges} instead.} } \value{ \code{any_loop()} and \code{any_multiple()} return a Logical. diff --git a/man/which_mutual.Rd b/man/which_mutual.Rd index 46346529c7..a9ed74426e 100644 --- a/man/which_mutual.Rd +++ b/man/which_mutual.Rd @@ -4,17 +4,19 @@ \alias{which_mutual} \title{Find mutual edges in a directed graph} \usage{ -which_mutual(graph, eids = NULL, ..., loops = TRUE) +which_mutual(graph, edges = NULL, ..., loops = TRUE, eids = deprecated()) } \arguments{ \item{graph}{The input graph.} -\item{eids}{Edge sequence, the edges that will be probed. The default +\item{edges}{Edge sequence, the edges that will be probed. The default \code{NULL} includes all edges in the order of their IDs.} \item{...}{These dots are for future extensions and must be empty.} \item{loops}{Logical, whether to consider directed self-loops to be mutual.} + +\item{eids}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{edges} instead.} } \value{ A logical vector of the same length as the number of edges supplied. diff --git a/tests/testthat/test-centrality.R b/tests/testthat/test-centrality.R index 9330f768c3..30ccc0b138 100644 --- a/tests/testthat/test-centrality.R +++ b/tests/testthat/test-centrality.R @@ -1039,7 +1039,12 @@ test_that("edge_betweenness() covers migrated tail args and positional recovery" expect_equal(res, rep(3, 3)) # With a cutoff of 1 each edge only carries the path of its endpoints. expect_equal( - edge_betweenness(ring, edges = E(ring)[1:3], weights = rep(1, 5), cutoff = 1), + edge_betweenness( + ring, + edges = E(ring)[1:3], + weights = rep(1, 5), + cutoff = 1 + ), rep(1, 3) ) From 32b024c45f0ebb12d072c6e0e1198e4dca90df83 Mon Sep 17 00:00:00 2001 From: David Schoch Date: Wed, 2 Dec 2026 21:10:32 +0100 Subject: [PATCH 4/8] docs: Refer to `edges` in the edge_betweenness() return value The @return text still named the `e` argument, renamed to `edges` here. Co-Authored-By: Claude Opus 5.5 --- R/centrality.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/centrality.R b/R/centrality.R index d75efa2daa..462dc3ae06 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -415,7 +415,7 @@ betweenness.estimate <- estimate_betweenness #' @return A numeric vector with the betweenness score for each vertex in #' `vertices` for `betweenness()`. #' -#' A numeric vector with the edge betweenness score for each edge in `e` +#' A numeric vector with the edge betweenness score for each edge in `edges` #' for `edge_betweenness()`. #' #' @note `edge_betweenness()` might give false values for graphs with From 7ffe8563f5181233318ac26359bc2603516b6746 Mon Sep 17 00:00:00 2001 From: schochastics Date: Wed, 2 Dec 2026 20:40:38 +0000 Subject: [PATCH 5/8] chore: Auto-update from GitHub Actions Run: https://github.com/igraph/rigraph/actions/runs/46961976066 --- man/aaa-igraph-package.Rd | 2 +- man/betweenness.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/man/aaa-igraph-package.Rd b/man/aaa-igraph-package.Rd index ba36d5a127..3086894662 100644 --- a/man/aaa-igraph-package.Rd +++ b/man/aaa-igraph-package.Rd @@ -107,7 +107,7 @@ Some vertex/edge/graph attributes are treated specially. One of them is the \sQuote{name} attribute. This is used for printing the graph instead of the numerical IDs, if it exists. Vertex names can also be used to specify a vector or set of vertices, in all igraph -functions. E.g. \code{\link[=degree]{degree()}} has a \code{v} argument +functions. E.g. \code{\link[=degree]{degree()}} has a \code{vertices} argument that gives the vertices for which the degree is calculated. This argument can be given as a character vector of vertex names. diff --git a/man/betweenness.Rd b/man/betweenness.Rd index bf6ecae18f..9745b7116e 100644 --- a/man/betweenness.Rd +++ b/man/betweenness.Rd @@ -70,7 +70,7 @@ The default \code{NULL} selects all edges.} A numeric vector with the betweenness score for each vertex in \code{vertices} for \code{betweenness()}. -A numeric vector with the edge betweenness score for each edge in \code{e} +A numeric vector with the edge betweenness score for each edge in \code{edges} for \code{edge_betweenness()}. } \description{ From 71913b9b01b7d9b94e18599e8b2c35cfa83a360a Mon Sep 17 00:00:00 2001 From: David Schoch Date: Thu, 3 Dec 2026 11:21:45 +0100 Subject: [PATCH 6/8] test: Drop the duplicated inbound-edges snapshot Co-Authored-By: Claude Opus 5.5 --- tests/testthat/_snaps/structural-properties.md | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/tests/testthat/_snaps/structural-properties.md b/tests/testthat/_snaps/structural-properties.md index 154886918c..b40a478dae 100644 --- a/tests/testthat/_snaps/structural-properties.md +++ b/tests/testthat/_snaps/structural-properties.md @@ -129,20 +129,3 @@ The `eids` argument of `which_multiple()` is deprecated as of igraph 3.0.0. i Please use the `edges` argument instead. -# shortest_paths() returns inbound edges as an edge sequence - - Code - print(res$inbound_edges) - Output - + 5/5 edges: - [1] NA->NA 1-> 2 2-> 3 NA->NA NA->NA - ---- - - Code - print(res$inbound_edges) - Output - -- 5/5 --------------------------------------------------------- - [1] NA 1 -> 2 2 -> 3 NA NA - - From f81d253b9e945f91185c722b1c2689453d7bef41 Mon Sep 17 00:00:00 2001 From: David Schoch Date: Thu, 3 Dec 2026 15:21:52 +0100 Subject: [PATCH 7/8] refactor: Let the generator own the head renames The generator re-matches a call that uses an old head name against the old signature, so the hand-written bridges for registered functions are gone. Co-Authored-By: Claude Opus 5.5 --- R/centrality.R | 54 ++++++++++++++------ R/interface.R | 48 +++++++++++++----- R/structural-properties.R | 104 ++++++++++++++++++++++++++------------ 3 files changed, 146 insertions(+), 60 deletions(-) diff --git a/R/centrality.R b/R/centrality.R index e1cd5d2a1c..8cd6e427d4 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -571,7 +571,44 @@ edge_betweenness <- function( ) { # BEGIN GENERATED ARG_HANDLE: edge_betweenness, do not edit, see tools/generate-migrations.R # fmt: skip - if (...length() > 0L) { + if (!base::missing(e)) { + # Pre-3.0.0 signature: edge_betweenness(graph, e, directed, weights, cutoff) + .old_signature <- function(graph, e, directed, weights, cutoff, ...) { + base::list(env = base::environment(), n_extra = ...length(), extra = base::as.character(base::names(base::substitute(...()))), recovered = base::c( + if (!base::missing(graph)) base::c(graph = "graph"), + if (!base::missing(e)) base::c(edges = "e"), + if (!base::missing(directed)) base::c(directed = "directed"), + if (!base::missing(weights)) base::c(weights = "weights"), + if (!base::missing(cutoff)) base::c(cutoff = "cutoff") + )) + } + .arg_call <- base::sys.call() + .arg_call[[1L]] <- .old_signature + .arg_handle <- base::eval(.arg_call, base::parent.frame()) + .arg_extra <- .arg_handle$extra + if (.arg_handle$n_extra > base::sum(base::nzchar(.arg_extra))) cli::cli_abort("Too many arguments passed to {.fn edge_betweenness}.") + .arg_explicit <- base::c("graph", "edges", "directed", "weights", "cutoff", "e")[base::pmatch(.arg_extra, base::c("graph", "edges", "directed", "weights", "cutoff", "e"), duplicates.ok = TRUE)] + if (base::anyNA(.arg_explicit)) cli::cli_abort("Unexpected argument passed to {.fn edge_betweenness}: {.arg {(.arg_extra[base::is.na(.arg_explicit)])}}.") + .arg_recovered <- .arg_handle$recovered + .arg_names <- base::names(.arg_recovered) + .arg_conflict <- base::intersect(.arg_names, .arg_explicit) + if (base::length(.arg_conflict) > 0L) { + .arg_conflict <- .arg_conflict[[1L]] + .arg_via <- .arg_recovered[[.arg_conflict]] + cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn edge_betweenness} was supplied more than once.", i = if (base::is.element(.arg_via, base::names(.arg_call))) "It was also supplied via its legacy name {.arg {(.arg_via)}}." else "It was also passed by position, as {.arg {(.arg_via)}} of the old signature.")) + } + for (.arg_i in base::seq_along(.arg_recovered)) base::do.call(base::delayedAssign, base::list(.arg_names[[.arg_i]], base::call("[[", .arg_handle$env, .arg_recovered[[.arg_i]]), base::baseenv(), base::environment())) + if (!base::missing(e)) lifecycle::deprecate_soft("3.0.0", "edge_betweenness(e = )", "edge_betweenness(edges = )") + .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("directed", "weights", "cutoff"))] + .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] + if (base::length(.arg_tail) > 0L) { + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `edge_betweenness()` with positional, abbreviated or renamed arguments"), + details = base::c(i = base::paste0("Use instead: edge_betweenness(", base::paste(base::c("graph", "edges", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + ) + } + } else if (...length() > 0L) { # Pre-3.0.0 signature: edge_betweenness(graph, e, directed, weights, cutoff) .old_signature <- function(directed, weights, cutoff, ...) { if (...length() > 0L) { @@ -613,21 +650,6 @@ edge_betweenness <- function( } # END GENERATED ARG_HANDLE - if (lifecycle::is_present(e)) { - if (!missing(edges)) { - cli::cli_abort(c( - "Argument {.arg edges} of {.fn edge_betweenness} was supplied more than once.", - i = "It was also supplied via its legacy name {.arg e}." - )) - } - lifecycle::deprecate_soft( - "3.0.0", - "edge_betweenness(e = )", - "edge_betweenness(edges = )" - ) - edges <- e - } - if (is.null(edges)) { edges <- E(graph) } diff --git a/R/interface.R b/R/interface.R index 700ce1b387..b0f989c204 100644 --- a/R/interface.R +++ b/R/interface.R @@ -622,7 +622,42 @@ ends <- function( ) { # BEGIN GENERATED ARG_HANDLE: ends, do not edit, see tools/generate-migrations.R # fmt: skip - if (...length() > 0L) { + if (!base::missing(es)) { + # Pre-3.0.0 signature: ends(graph, es, names) + .old_signature <- function(graph, es, names, ...) { + base::list(env = base::environment(), n_extra = ...length(), extra = base::as.character(base::names(base::substitute(...()))), recovered = base::c( + if (!base::missing(graph)) base::c(graph = "graph"), + if (!base::missing(es)) base::c(edges = "es"), + if (!base::missing(names)) base::c(names = "names") + )) + } + .arg_call <- base::sys.call() + .arg_call[[1L]] <- .old_signature + .arg_handle <- base::eval(.arg_call, base::parent.frame()) + .arg_extra <- .arg_handle$extra + if (.arg_handle$n_extra > base::sum(base::nzchar(.arg_extra))) cli::cli_abort("Too many arguments passed to {.fn ends}.") + .arg_explicit <- base::c("graph", "edges", "names", "es")[base::pmatch(.arg_extra, base::c("graph", "edges", "names", "es"), duplicates.ok = TRUE)] + if (base::anyNA(.arg_explicit)) cli::cli_abort("Unexpected argument passed to {.fn ends}: {.arg {(.arg_extra[base::is.na(.arg_explicit)])}}.") + .arg_recovered <- .arg_handle$recovered + .arg_names <- base::names(.arg_recovered) + .arg_conflict <- base::intersect(.arg_names, .arg_explicit) + if (base::length(.arg_conflict) > 0L) { + .arg_conflict <- .arg_conflict[[1L]] + .arg_via <- .arg_recovered[[.arg_conflict]] + cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn ends} was supplied more than once.", i = if (base::is.element(.arg_via, base::names(.arg_call))) "It was also supplied via its legacy name {.arg {(.arg_via)}}." else "It was also passed by position, as {.arg {(.arg_via)}} of the old signature.")) + } + for (.arg_i in base::seq_along(.arg_recovered)) base::do.call(base::delayedAssign, base::list(.arg_names[[.arg_i]], base::call("[[", .arg_handle$env, .arg_recovered[[.arg_i]]), base::baseenv(), base::environment())) + if (!base::missing(es)) lifecycle::deprecate_soft("3.0.0", "ends(es = )", "ends(edges = )") + .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("names"))] + .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] + if (base::length(.arg_tail) > 0L) { + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `ends()` with positional, abbreviated or renamed arguments"), + details = base::c(i = base::paste0("Use instead: ends(", base::paste(base::c("graph", "edges", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + ) + } + } else if (...length() > 0L) { .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("e")) if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn ends}.", i = "Spell out the full argument name.")) # Pre-3.0.0 signature: ends(graph, es, names) @@ -662,17 +697,6 @@ ends <- function( } # END GENERATED ARG_HANDLE - if (lifecycle::is_present(es)) { - if (!missing(edges)) { - cli::cli_abort(c( - "Argument {.arg edges} of {.fn ends} was supplied more than once.", - i = "It was also supplied via its legacy name {.arg es}." - )) - } - lifecycle::deprecate_soft("3.0.0", "ends(es = )", "ends(edges = )") - edges <- es - } - ensure_igraph(graph) res <- matrix(NA_integer_, ncol = length(edges), nrow = 2) diff --git a/R/structural-properties.R b/R/structural-properties.R index 57500bfbed..e549fccf12 100644 --- a/R/structural-properties.R +++ b/R/structural-properties.R @@ -2311,7 +2311,42 @@ subgraph_from_edges <- function( ) { # BEGIN GENERATED ARG_HANDLE: subgraph_from_edges, do not edit, see tools/generate-migrations.R # fmt: skip - if (...length() > 0L) { + if (!base::missing(eids)) { + # Pre-3.0.0 signature: subgraph_from_edges(graph, eids, delete.vertices) + .old_signature <- function(graph, eids, delete.vertices, ...) { + base::list(env = base::environment(), n_extra = ...length(), extra = base::as.character(base::names(base::substitute(...()))), recovered = base::c( + if (!base::missing(graph)) base::c(graph = "graph"), + if (!base::missing(eids)) base::c(edges = "eids"), + if (!base::missing(delete.vertices)) base::c(delete.vertices = "delete.vertices") + )) + } + .arg_call <- base::sys.call() + .arg_call[[1L]] <- .old_signature + .arg_handle <- base::eval(.arg_call, base::parent.frame()) + .arg_extra <- .arg_handle$extra + if (.arg_handle$n_extra > base::sum(base::nzchar(.arg_extra))) cli::cli_abort("Too many arguments passed to {.fn subgraph_from_edges}.") + .arg_explicit <- base::c("graph", "edges", "delete.vertices", "eids")[base::pmatch(.arg_extra, base::c("graph", "edges", "delete.vertices", "eids"), duplicates.ok = TRUE)] + if (base::anyNA(.arg_explicit)) cli::cli_abort("Unexpected argument passed to {.fn subgraph_from_edges}: {.arg {(.arg_extra[base::is.na(.arg_explicit)])}}.") + .arg_recovered <- .arg_handle$recovered + .arg_names <- base::names(.arg_recovered) + .arg_conflict <- base::intersect(.arg_names, .arg_explicit) + if (base::length(.arg_conflict) > 0L) { + .arg_conflict <- .arg_conflict[[1L]] + .arg_via <- .arg_recovered[[.arg_conflict]] + cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn subgraph_from_edges} was supplied more than once.", i = if (base::is.element(.arg_via, base::names(.arg_call))) "It was also supplied via its legacy name {.arg {(.arg_via)}}." else "It was also passed by position, as {.arg {(.arg_via)}} of the old signature.")) + } + for (.arg_i in base::seq_along(.arg_recovered)) base::do.call(base::delayedAssign, base::list(.arg_names[[.arg_i]], base::call("[[", .arg_handle$env, .arg_recovered[[.arg_i]]), base::baseenv(), base::environment())) + if (!base::missing(eids)) lifecycle::deprecate_soft("3.0.0", "subgraph_from_edges(eids = )", "subgraph_from_edges(edges = )") + .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("delete.vertices"))] + .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] + if (base::length(.arg_tail) > 0L) { + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `subgraph_from_edges()` with positional, abbreviated or renamed arguments"), + details = base::c(i = base::paste0("Use instead: subgraph_from_edges(", base::paste(base::c("graph", "edges", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + ) + } + } else if (...length() > 0L) { .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("e")) if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn subgraph_from_edges}.", i = "Spell out the full argument name.")) # Pre-3.0.0 signature: subgraph_from_edges(graph, eids, delete.vertices) @@ -2351,21 +2386,6 @@ subgraph_from_edges <- function( } # END GENERATED ARG_HANDLE - if (lifecycle::is_present(eids)) { - if (!missing(edges)) { - cli::cli_abort(c( - "Argument {.arg edges} of {.fn subgraph_from_edges} was supplied more than once.", - i = "It was also supplied via its legacy name {.arg eids}." - )) - } - lifecycle::deprecate_soft( - "3.0.0", - "subgraph_from_edges(eids = )", - "subgraph_from_edges(edges = )" - ) - edges <- eids - } - # Argument checks # Argument checks ensure_igraph(graph) @@ -5423,7 +5443,42 @@ which_mutual <- function( ) { # BEGIN GENERATED ARG_HANDLE: which_mutual, do not edit, see tools/generate-migrations.R # fmt: skip - if (...length() > 0L) { + if (!base::missing(eids)) { + # Pre-3.0.0 signature: which_mutual(graph, eids, loops) + .old_signature <- function(graph, eids, loops, ...) { + base::list(env = base::environment(), n_extra = ...length(), extra = base::as.character(base::names(base::substitute(...()))), recovered = base::c( + if (!base::missing(graph)) base::c(graph = "graph"), + if (!base::missing(eids)) base::c(edges = "eids"), + if (!base::missing(loops)) base::c(loops = "loops") + )) + } + .arg_call <- base::sys.call() + .arg_call[[1L]] <- .old_signature + .arg_handle <- base::eval(.arg_call, base::parent.frame()) + .arg_extra <- .arg_handle$extra + if (.arg_handle$n_extra > base::sum(base::nzchar(.arg_extra))) cli::cli_abort("Too many arguments passed to {.fn which_mutual}.") + .arg_explicit <- base::c("graph", "edges", "loops", "eids")[base::pmatch(.arg_extra, base::c("graph", "edges", "loops", "eids"), duplicates.ok = TRUE)] + if (base::anyNA(.arg_explicit)) cli::cli_abort("Unexpected argument passed to {.fn which_mutual}: {.arg {(.arg_extra[base::is.na(.arg_explicit)])}}.") + .arg_recovered <- .arg_handle$recovered + .arg_names <- base::names(.arg_recovered) + .arg_conflict <- base::intersect(.arg_names, .arg_explicit) + if (base::length(.arg_conflict) > 0L) { + .arg_conflict <- .arg_conflict[[1L]] + .arg_via <- .arg_recovered[[.arg_conflict]] + cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn which_mutual} was supplied more than once.", i = if (base::is.element(.arg_via, base::names(.arg_call))) "It was also supplied via its legacy name {.arg {(.arg_via)}}." else "It was also passed by position, as {.arg {(.arg_via)}} of the old signature.")) + } + for (.arg_i in base::seq_along(.arg_recovered)) base::do.call(base::delayedAssign, base::list(.arg_names[[.arg_i]], base::call("[[", .arg_handle$env, .arg_recovered[[.arg_i]]), base::baseenv(), base::environment())) + if (!base::missing(eids)) lifecycle::deprecate_soft("3.0.0", "which_mutual(eids = )", "which_mutual(edges = )") + .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("loops"))] + .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] + if (base::length(.arg_tail) > 0L) { + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `which_mutual()` with positional, abbreviated or renamed arguments"), + details = base::c(i = base::paste0("Use instead: which_mutual(", base::paste(base::c("graph", "edges", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + ) + } + } else if (...length() > 0L) { .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("e")) if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn which_mutual}.", i = "Spell out the full argument name.")) # Pre-3.0.0 signature: which_mutual(graph, eids, loops) @@ -5463,21 +5518,6 @@ which_mutual <- function( } # END GENERATED ARG_HANDLE - if (lifecycle::is_present(eids)) { - if (!missing(edges)) { - cli::cli_abort(c( - "Argument {.arg edges} of {.fn which_mutual} was supplied more than once.", - i = "It was also supplied via its legacy name {.arg eids}." - )) - } - lifecycle::deprecate_soft( - "3.0.0", - "which_mutual(eids = )", - "which_mutual(edges = )" - ) - edges <- eids - } - if (is.null(edges)) { edges <- E(graph) } From 8d74693a6a32c6cc68728dd6de2763a20e45f6b5 Mon Sep 17 00:00:00 2001 From: David Schoch Date: Thu, 3 Dec 2026 15:41:25 +0100 Subject: [PATCH 8/8] chore: Regenerate the migration blocks Co-Authored-By: Claude Opus 5.5 --- R/centrality.R | 6 +++++- R/interface.R | 6 +++++- R/structural-properties.R | 12 ++++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/R/centrality.R b/R/centrality.R index 0aa99c1a7b..c3f9d40199 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -606,10 +606,14 @@ edge_betweenness <- function( .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("directed", "weights", "cutoff"))] .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] if (base::length(.arg_tail) > 0L) { + .arg_shown <- base::ifelse(base::is.element(.arg_tail, base::names(.arg_call)), base::paste0(.arg_tail, " = "), .arg_tail) lifecycle::deprecate_soft( "3.0.0", what = base::I("Calling `edge_betweenness()` with positional, abbreviated or renamed arguments"), - details = base::c(i = base::paste0("Use instead: edge_betweenness(", base::paste(base::c("graph", "edges", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + details = base::c( + i = base::paste0("Detected call: edge_betweenness(", base::paste(base::c("graph", "edges", .arg_shown), collapse = ", "), ")"), + i = base::paste0("Use instead: edge_betweenness(", base::paste(base::c("graph", "edges", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")") + ) ) } } else if (...length() > 0L) { diff --git a/R/interface.R b/R/interface.R index e95bb40c64..0663de343f 100644 --- a/R/interface.R +++ b/R/interface.R @@ -659,10 +659,14 @@ ends <- function( .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("names"))] .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] if (base::length(.arg_tail) > 0L) { + .arg_shown <- base::ifelse(base::is.element(.arg_tail, base::names(.arg_call)), base::paste0(.arg_tail, " = "), .arg_tail) lifecycle::deprecate_soft( "3.0.0", what = base::I("Calling `ends()` with positional, abbreviated or renamed arguments"), - details = base::c(i = base::paste0("Use instead: ends(", base::paste(base::c("graph", "edges", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + details = base::c( + i = base::paste0("Detected call: ends(", base::paste(base::c("graph", "edges", .arg_shown), collapse = ", "), ")"), + i = base::paste0("Use instead: ends(", base::paste(base::c("graph", "edges", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")") + ) ) } } else if (...length() > 0L) { diff --git a/R/structural-properties.R b/R/structural-properties.R index d3783312bc..bc513fcc7d 100644 --- a/R/structural-properties.R +++ b/R/structural-properties.R @@ -2356,10 +2356,14 @@ subgraph_from_edges <- function( .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("delete.vertices"))] .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] if (base::length(.arg_tail) > 0L) { + .arg_shown <- base::ifelse(base::is.element(.arg_tail, base::names(.arg_call)), base::paste0(.arg_tail, " = "), .arg_tail) lifecycle::deprecate_soft( "3.0.0", what = base::I("Calling `subgraph_from_edges()` with positional, abbreviated or renamed arguments"), - details = base::c(i = base::paste0("Use instead: subgraph_from_edges(", base::paste(base::c("graph", "edges", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + details = base::c( + i = base::paste0("Detected call: subgraph_from_edges(", base::paste(base::c("graph", "edges", .arg_shown), collapse = ", "), ")"), + i = base::paste0("Use instead: subgraph_from_edges(", base::paste(base::c("graph", "edges", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")") + ) ) } } else if (...length() > 0L) { @@ -5504,10 +5508,14 @@ which_mutual <- function( .arg_tail <- .arg_recovered[base::is.element(.arg_recovered, base::c("loops"))] .arg_tail <- .arg_tail[!base::is.element(.arg_tail, base::names(.arg_call)) | base::names(.arg_tail) != .arg_tail] if (base::length(.arg_tail) > 0L) { + .arg_shown <- base::ifelse(base::is.element(.arg_tail, base::names(.arg_call)), base::paste0(.arg_tail, " = "), .arg_tail) lifecycle::deprecate_soft( "3.0.0", what = base::I("Calling `which_mutual()` with positional, abbreviated or renamed arguments"), - details = base::c(i = base::paste0("Use instead: which_mutual(", base::paste(base::c("graph", "edges", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")")) + details = base::c( + i = base::paste0("Detected call: which_mutual(", base::paste(base::c("graph", "edges", .arg_shown), collapse = ", "), ")"), + i = base::paste0("Use instead: which_mutual(", base::paste(base::c("graph", "edges", base::paste0(base::names(.arg_tail), " = ")), collapse = ", "), ")") + ) ) } } else if (...length() > 0L) {