From 30726320cddca137f9aca3116ae5537bbc7612b5 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 17 Aug 2026 17:49:27 +0000 Subject: [PATCH 1/6] refactor: Rename `algo` to `algorithm` in `page_rank()`, `feedback_arc_set()` and `feedback_vertex_set()` (#2788, #526) The legacy `algo` spelling is recovered by the generated ARG_HANDLE blocks and soft-deprecated; abbreviations of both spellings are guarded as ambiguous. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01RTPj4qNv2FWui6etixZeuR --- R/centrality.R | 18 +++++++------ R/structural-properties.R | 30 ++++++++++++--------- man/feedback_arc_set.Rd | 6 ++--- man/feedback_vertex_set.Rd | 4 +-- man/page.rank.Rd | 10 ++----- man/page_rank.Rd | 4 +-- tests/testthat/_snaps/centrality.md | 10 +++++++ tests/testthat/test-centrality.R | 15 ++++++++--- tests/testthat/test-structural-properties.R | 24 +++++++++++++++-- tools/migrations/centrality.R | 4 +-- tools/migrations/structural-properties.R | 8 +++--- 11 files changed, 86 insertions(+), 47 deletions(-) diff --git a/R/centrality.R b/R/centrality.R index aa62926c4be..49d184830a4 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -26,6 +26,8 @@ subgraph.centrality <- function(graph, diag = FALSE) { #' `page.rank()` was renamed to [page_rank()] to create a more #' consistent API. #' @inheritParams page_rank +#' @param algo `r lifecycle::badge("deprecated")` Use `algorithm` in +#' [page_rank()] instead. #' @keywords internal #' @export page.rank <- function( @@ -42,7 +44,7 @@ page.rank <- function( lifecycle::deprecate_warn("2.0.0", "page.rank()", "page_rank()") page_rank( graph = graph, - algo = algo, + algorithm = algo, vids = vids, directed = directed, damping = damping, @@ -1884,7 +1886,7 @@ hub_score <- function( #' #' @param graph The graph object. #' @inheritParams rlang::args_dots_empty -#' @param algo Character scalar, which implementation to use to carry out the +#' @param algorithm Character scalar, which implementation to use to carry out the #' calculation. The default is `"prpack"`, which uses the PRPACK library #' () to calculate PageRank scores #' by solving a set of linear equations. This is a new implementation in igraph @@ -1953,7 +1955,7 @@ hub_score <- function( page_rank <- function( graph, ..., - algo = c("prpack", "arpack"), + algorithm = c("prpack", "arpack"), vids = NULL, directed = TRUE, damping = 0.85, @@ -1964,7 +1966,7 @@ page_rank <- function( # BEGIN GENERATED ARG_HANDLE: page_rank, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { - .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("d")) + .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("a", "al", "alg", "d")) if (base::length(.arg_ambiguous) > 0L) cli::cli_abort("Argument {.arg {(.arg_ambiguous[[1L]])}} matches multiple arguments of {.fn page_rank}.") # Pre-3.0.0 signature: page_rank(graph, algo, vids, directed, damping, personalized, weights, options) .old_signature <- function(algo, vids, directed, damping, personalized, weights, options, ...) { @@ -1975,7 +1977,7 @@ page_rank <- function( cli::cli_abort(base::c("Unexpected argument passed to {.fn page_rank}: {.arg {(.arg_extra)}}.", i = "Arguments after {.arg ...} must be spelled out in full."), call = base::parent.frame()) } base::c( - if (!base::missing(algo)) base::list(algo = algo), + if (!base::missing(algo)) base::list(algorithm = algo), if (!base::missing(vids)) base::list(vids = vids), if (!base::missing(directed)) base::list(directed = directed), if (!base::missing(damping)) base::list(damping = damping), @@ -1988,7 +1990,7 @@ page_rank <- function( if (base::length(.arg_handle) > 0L) { .arg_names <- base::names(.arg_handle) .arg_conflict <- base::intersect(.arg_names, base::c( - if (!base::missing(algo)) "algo", + if (!base::missing(algorithm)) "algorithm", if (!base::missing(vids)) "vids", if (!base::missing(directed)) "directed", if (!base::missing(damping)) "damping", @@ -2002,7 +2004,7 @@ page_rank <- function( "3.0.0", what = base::I("Calling `page_rank()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: page_rank(", base::paste(base::c("graph", .arg_names), collapse = ", "), ")"), + i = base::paste0("Detected call: page_rank(", base::paste(base::c("graph", base::c(algorithm = "algo", vids = "vids", directed = "directed", damping = "damping", personalized = "personalized", weights = "weights", options = "options")[.arg_names]), collapse = ", "), ")"), i = base::paste0("Use instead: page_rank(", base::paste(base::c("graph", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) @@ -2016,7 +2018,7 @@ page_rank <- function( personalized_pagerank_impl( graph = graph, - algo = algo, + algo = algorithm, vids = vids, directed = directed, damping = damping, diff --git a/R/structural-properties.R b/R/structural-properties.R index c2970ebc5a9..36b37f0e397 100644 --- a/R/structural-properties.R +++ b/R/structural-properties.R @@ -3216,7 +3216,7 @@ topo_sort <- function( #' `NULL`, then the edge attribute is used automatically. The goal of #' the feedback arc set problem is to find a feedback arc set with the smallest #' total weight. -#' @param algo Specifies the algorithm to use. \dQuote{`exact_ip`} solves +#' @param algorithm Specifies the algorithm to use. \dQuote{`exact_ip`} solves #' the feedback arc set problem with an exact integer programming algorithm that #' guarantees that the total weight of the removed edges is as small as possible. #' \dQuote{`approx_eades`} uses a fast (linear-time) approximation @@ -3236,16 +3236,18 @@ topo_sort <- function( #' #' g <- sample_gnm(20, 40, directed = TRUE) #' feedback_arc_set(g) -#' feedback_arc_set(g, algo = "approx_eades") +#' feedback_arc_set(g, algorithm = "approx_eades") feedback_arc_set <- function( graph, ..., weights = NULL, - algo = c("approx_eades", "exact_ip") + algorithm = c("approx_eades", "exact_ip") ) { # BEGIN GENERATED ARG_HANDLE: feedback_arc_set, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { + .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("a", "al", "alg")) + if (base::length(.arg_ambiguous) > 0L) cli::cli_abort("Argument {.arg {(.arg_ambiguous[[1L]])}} matches multiple arguments of {.fn feedback_arc_set}.") # Pre-3.0.0 signature: feedback_arc_set(graph, weights, algo) .old_signature <- function(weights, algo, ...) { if (...length() > 0L) { @@ -3256,7 +3258,7 @@ feedback_arc_set <- function( } base::c( if (!base::missing(weights)) base::list(weights = weights), - if (!base::missing(algo)) base::list(algo = algo) + if (!base::missing(algo)) base::list(algorithm = algo) ) } .arg_handle <- .old_signature(...) @@ -3264,7 +3266,7 @@ feedback_arc_set <- function( .arg_names <- base::names(.arg_handle) .arg_conflict <- base::intersect(.arg_names, base::c( if (!base::missing(weights)) "weights", - if (!base::missing(algo)) "algo" + if (!base::missing(algorithm)) "algorithm" )) if (base::length(.arg_conflict) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn feedback_arc_set} was supplied more than once.", i = "Pass it exactly once, by its new name {.arg {(.arg_conflict)}}.")) base::list2env(.arg_handle, base::environment()) @@ -3272,7 +3274,7 @@ feedback_arc_set <- function( "3.0.0", what = base::I("Calling `feedback_arc_set()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: feedback_arc_set(", base::paste(base::c("graph", .arg_names), collapse = ", "), ")"), + i = base::paste0("Detected call: feedback_arc_set(", base::paste(base::c("graph", base::c(weights = "weights", algorithm = "algo")[.arg_names]), collapse = ", "), ")"), i = base::paste0("Use instead: feedback_arc_set(", base::paste(base::c("graph", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) @@ -3283,7 +3285,7 @@ feedback_arc_set <- function( feedback_arc_set_impl( graph = graph, weights = weights, - algo = algo + algo = algorithm ) } @@ -3303,7 +3305,7 @@ feedback_arc_set <- function( #' `NULL`, then the vertex attribute is used automatically. The goal of #' the feedback vertex set problem is to find a feedback vertex set with #' the smallest total weight. -#' @param algo Specifies the algorithm to use. Currently, \dQuote{`exact_ip`}, +#' @param algorithm Specifies the algorithm to use. Currently, \dQuote{`exact_ip`}, #' which solves the feedback vertex set problem with an exact integer #' programming approach, is the only option. #' @return A vertex sequence (by default, but see the `return.vs.es` option @@ -3320,11 +3322,13 @@ feedback_vertex_set <- function( graph, ..., weights = NULL, - algo = c("exact_ip") + algorithm = c("exact_ip") ) { # BEGIN GENERATED ARG_HANDLE: feedback_vertex_set, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { + .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("a", "al", "alg")) + if (base::length(.arg_ambiguous) > 0L) cli::cli_abort("Argument {.arg {(.arg_ambiguous[[1L]])}} matches multiple arguments of {.fn feedback_vertex_set}.") # Pre-3.0.0 signature: feedback_vertex_set(graph, weights, algo) .old_signature <- function(weights, algo, ...) { if (...length() > 0L) { @@ -3335,7 +3339,7 @@ feedback_vertex_set <- function( } base::c( if (!base::missing(weights)) base::list(weights = weights), - if (!base::missing(algo)) base::list(algo = algo) + if (!base::missing(algo)) base::list(algorithm = algo) ) } .arg_handle <- .old_signature(...) @@ -3343,7 +3347,7 @@ feedback_vertex_set <- function( .arg_names <- base::names(.arg_handle) .arg_conflict <- base::intersect(.arg_names, base::c( if (!base::missing(weights)) "weights", - if (!base::missing(algo)) "algo" + if (!base::missing(algorithm)) "algorithm" )) if (base::length(.arg_conflict) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn feedback_vertex_set} was supplied more than once.", i = "Pass it exactly once, by its new name {.arg {(.arg_conflict)}}.")) base::list2env(.arg_handle, base::environment()) @@ -3351,7 +3355,7 @@ feedback_vertex_set <- function( "3.0.0", what = base::I("Calling `feedback_vertex_set()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: feedback_vertex_set(", base::paste(base::c("graph", .arg_names), collapse = ", "), ")"), + i = base::paste0("Detected call: feedback_vertex_set(", base::paste(base::c("graph", base::c(weights = "weights", algorithm = "algo")[.arg_names]), collapse = ", "), ")"), i = base::paste0("Use instead: feedback_vertex_set(", base::paste(base::c("graph", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) @@ -3362,7 +3366,7 @@ feedback_vertex_set <- function( feedback_vertex_set_impl( graph = graph, weights = weights, - algo = algo + algo = algorithm ) } diff --git a/man/feedback_arc_set.Rd b/man/feedback_arc_set.Rd index 4e243de7630..b356af260c0 100644 --- a/man/feedback_arc_set.Rd +++ b/man/feedback_arc_set.Rd @@ -8,7 +8,7 @@ feedback_arc_set( graph, ..., weights = NULL, - algo = c("approx_eades", "exact_ip") + algorithm = c("approx_eades", "exact_ip") ) } \arguments{ @@ -22,7 +22,7 @@ attribute called \sQuote{\code{weight}}, and this argument is the feedback arc set problem is to find a feedback arc set with the smallest total weight.} -\item{algo}{Specifies the algorithm to use. \dQuote{\code{exact_ip}} solves +\item{algorithm}{Specifies the algorithm to use. \dQuote{\code{exact_ip}} solves the feedback arc set problem with an exact integer programming algorithm that guarantees that the total weight of the removed edges is as small as possible. \dQuote{\code{approx_eades}} uses a fast (linear-time) approximation @@ -53,7 +53,7 @@ component is a tree). g <- sample_gnm(20, 40, directed = TRUE) feedback_arc_set(g) -feedback_arc_set(g, algo = "approx_eades") +feedback_arc_set(g, algorithm = "approx_eades") } \references{ Peter Eades, Xuemin Lin and W.F.Smyth: A fast and effective diff --git a/man/feedback_vertex_set.Rd b/man/feedback_vertex_set.Rd index 89dd657e20d..660dd399f66 100644 --- a/man/feedback_vertex_set.Rd +++ b/man/feedback_vertex_set.Rd @@ -4,7 +4,7 @@ \alias{feedback_vertex_set} \title{Finding a feedback vertex set in a graph} \usage{ -feedback_vertex_set(graph, ..., weights = NULL, algo = c("exact_ip")) +feedback_vertex_set(graph, ..., weights = NULL, algorithm = c("exact_ip")) } \arguments{ \item{graph}{The input graph} @@ -17,7 +17,7 @@ attribute called \sQuote{\code{weight}}, and this argument is the feedback vertex set problem is to find a feedback vertex set with the smallest total weight.} -\item{algo}{Specifies the algorithm to use. Currently, \dQuote{\code{exact_ip}}, +\item{algorithm}{Specifies the algorithm to use. Currently, \dQuote{\code{exact_ip}}, which solves the feedback vertex set problem with an exact integer programming approach, is the only option.} } diff --git a/man/page.rank.Rd b/man/page.rank.Rd index 0c81f6fdfc3..41839e26df2 100644 --- a/man/page.rank.Rd +++ b/man/page.rank.Rd @@ -18,14 +18,8 @@ page.rank( \arguments{ \item{graph}{The graph object.} -\item{algo}{Character scalar, which implementation to use to carry out the -calculation. The default is \code{"prpack"}, which uses the PRPACK library -(\url{https://github.com/dgleich/prpack}) to calculate PageRank scores -by solving a set of linear equations. This is a new implementation in igraph -version 0.7, and the suggested one, as it is the most stable and the fastest -for all but small graphs. \code{"arpack"} uses the ARPACK library, the -default implementation from igraph version 0.5 until version 0.7. It computes -PageRank scores by solving an eingevalue problem.} +\item{algo}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{algorithm} in +\code{\link[=page_rank]{page_rank()}} instead.} \item{vids}{The vertices of interest. The default \code{NULL} selects all vertices.} diff --git a/man/page_rank.Rd b/man/page_rank.Rd index 58937b15dfc..c205f129a6b 100644 --- a/man/page_rank.Rd +++ b/man/page_rank.Rd @@ -7,7 +7,7 @@ page_rank( graph, ..., - algo = c("prpack", "arpack"), + algorithm = c("prpack", "arpack"), vids = NULL, directed = TRUE, damping = 0.85, @@ -21,7 +21,7 @@ page_rank( \item{...}{These dots are for future extensions and must be empty.} -\item{algo}{Character scalar, which implementation to use to carry out the +\item{algorithm}{Character scalar, which implementation to use to carry out the calculation. The default is \code{"prpack"}, which uses the PRPACK library (\url{https://github.com/dgleich/prpack}) to calculate PageRank scores by solving a set of linear equations. This is a new implementation in igraph diff --git a/tests/testthat/_snaps/centrality.md b/tests/testthat/_snaps/centrality.md index bcb12bae957..fd6a1913e6f 100644 --- a/tests/testthat/_snaps/centrality.md +++ b/tests/testthat/_snaps/centrality.md @@ -59,3 +59,13 @@ Error in `arpack()`: ! Can't use unkown ARPACK options: unknown_thing1, unknown_thing2 +# page_rank(algo = ) is deprecated but still works + + Code + res_legacy <- page_rank(star, algo = "prpack") + Condition + Warning: + Calling `page_rank()` with positional or abbreviated arguments was deprecated in igraph 3.0.0. + i Detected call: page_rank(graph, algo) + i Use instead: page_rank(graph, algorithm = ) + diff --git a/tests/testthat/test-centrality.R b/tests/testthat/test-centrality.R index b7abe50bec2..240ac2ab849 100644 --- a/tests/testthat/test-centrality.R +++ b/tests/testthat/test-centrality.R @@ -1074,12 +1074,12 @@ test_that("page_rank() covers migrated tail args and positional recovery", { # The weight attribute is a decoy that the explicit `weights` must override. E(star)$weight <- c(10, rep(1, 8)) - # `algo` keeps its default value: + # `algorithm` keeps its default value: # non-default values select the legacy ARPACK implementation, # and `options` is only consumed by that implementation. res <- page_rank( star, - algo = "prpack", + algorithm = "prpack", vids = V(star)[1:5], directed = FALSE, damping = 0.9, @@ -1106,7 +1106,16 @@ test_that("page_rank() covers migrated tail args and positional recovery", { lifecycle::expect_deprecated( res_legacy <- page_rank(star, "prpack") ) - expect_identical(res_legacy, page_rank(star, algo = "prpack")) + expect_identical(res_legacy, page_rank(star, algorithm = "prpack")) +}) + +test_that("page_rank(algo = ) is deprecated but still works", { + rlang::local_options(lifecycle_verbosity = "warning") + star <- make_star(10, mode = "undirected") + expect_snapshot( + res_legacy <- page_rank(star, algo = "prpack") + ) + expect_identical(res_legacy, page_rank(star, algorithm = "prpack")) }) test_that("strength() covers migrated tail args and positional recovery", { diff --git a/tests/testthat/test-structural-properties.R b/tests/testthat/test-structural-properties.R index 6c4e5752024..d1a5424489e 100644 --- a/tests/testthat/test-structural-properties.R +++ b/tests/testthat/test-structural-properties.R @@ -1398,11 +1398,21 @@ test_that("feedback_arc_set() tail arguments and legacy positional recovery", { g <- make_ring(4, directed = TRUE) # The exact algorithm removes the cheapest edge of the single cycle. - fas <- feedback_arc_set(g, weights = c(4, 3, 2, 1), algo = "exact_ip") + fas <- feedback_arc_set(g, weights = c(4, 3, 2, 1), algorithm = "exact_ip") expect_equal(as.numeric(fas), 4) lifecycle::expect_deprecated(res <- feedback_arc_set(g, c(4, 3, 2, 1))) expect_equal(res, feedback_arc_set(g, weights = c(4, 3, 2, 1))) + + # The legacy `algo` name is recovered as `algorithm`. + lifecycle::expect_deprecated( + res_legacy <- feedback_arc_set( + g, + weights = c(4, 3, 2, 1), + algo = "exact_ip" + ) + ) + expect_equal(res_legacy, fas) }) test_that("feedback_vertex_set() tail arguments and legacy positional recovery", { @@ -1411,11 +1421,21 @@ test_that("feedback_vertex_set() tail arguments and legacy positional recovery", g <- make_ring(4, directed = TRUE) # The cheapest vertex of the single cycle is removed. - fvs <- feedback_vertex_set(g, weights = c(4, 3, 2, 1), algo = "exact_ip") + fvs <- feedback_vertex_set(g, weights = c(4, 3, 2, 1), algorithm = "exact_ip") expect_equal(as.numeric(fvs), 4) lifecycle::expect_deprecated(res <- feedback_vertex_set(g, c(4, 3, 2, 1))) expect_equal(res, feedback_vertex_set(g, weights = c(4, 3, 2, 1))) + + # The legacy `algo` name is recovered as `algorithm`. + lifecycle::expect_deprecated( + res_legacy <- feedback_vertex_set( + g, + weights = c(4, 3, 2, 1), + algo = "exact_ip" + ) + ) + expect_equal(res_legacy, fvs) }) test_that("girth() tail arguments and legacy positional recovery", { diff --git a/tools/migrations/centrality.R b/tools/migrations/centrality.R index 4e6c02ac37f..09b62a0fcb4 100644 --- a/tools/migrations/centrality.R +++ b/tools/migrations/centrality.R @@ -88,7 +88,7 @@ migrations <- list( page_rank = list( old = function( graph, - algo, + algo = algorithm, vids, directed, damping, @@ -99,7 +99,7 @@ migrations <- list( new = function( graph, ..., - algo = c("prpack", "arpack"), + algorithm = c("prpack", "arpack"), vids = NULL, directed = TRUE, damping = 0.85, diff --git a/tools/migrations/structural-properties.R b/tools/migrations/structural-properties.R index b7b781964f5..b0581d12904 100644 --- a/tools/migrations/structural-properties.R +++ b/tools/migrations/structural-properties.R @@ -218,23 +218,23 @@ migrations <- list( ), feedback_arc_set = list( - old = function(graph, weights, algo) {}, + old = function(graph, weights, algo = algorithm) {}, new = function( graph, ..., weights = NULL, - algo = c("approx_eades", "exact_ip") + algorithm = c("approx_eades", "exact_ip") ) {}, when = "3.0.0" ), feedback_vertex_set = list( - old = function(graph, weights, algo) {}, + old = function(graph, weights, algo = algorithm) {}, new = function( graph, ..., weights = NULL, - algo = c("exact_ip") + algorithm = c("exact_ip") ) {}, when = "3.0.0" ), From 3ad95b8d5b302d025595d02a5cc5bf7a2b8cd0a8 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 17 Aug 2026 18:14:17 +0000 Subject: [PATCH 2/6] refactor: Rename `nodes` to `n` in generators and `centr_*_tmax()` (#2788, #692) Vertex-count arguments unify on `n`: 11 game generators and their spec twins, the four `centr_*_tmax()` functions (`centr_degree_tmax()` and `centr_eigen_tmax()` newly gain their keyword-only migration on the way), and `graph_from_graphdb()`. Head positions keep working positionally; named `nodes =` callers are soft-deprecated via surviving sentinel formals or registry recovery. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01RTPj4qNv2FWui6etixZeuR --- R/centralization.R | 204 +++++++++++++--- R/foreign.R | 26 ++- R/games.R | 310 +++++++++++++++++++------ man/asymmetric.preference.game.Rd | 2 +- man/callaway.traits.game.Rd | 2 +- man/centr_betw_tmax.Rd | 14 +- man/centr_clo_tmax.Rd | 11 +- man/centr_degree_tmax.Rd | 14 +- man/centr_eigen_tmax.Rd | 14 +- man/centralization.betweenness.tmax.Rd | 5 +- man/centralization.closeness.tmax.Rd | 5 +- man/centralization.degree.tmax.Rd | 4 +- man/centralization.evcent.tmax.Rd | 5 +- man/establishment.game.Rd | 2 +- man/forest.fire.game.Rd | 2 +- man/graph.graphdb.Rd | 3 +- man/graph_from_graphdb.Rd | 6 +- man/grg.game.Rd | 2 +- man/preference.game.Rd | 2 +- man/sample_forestfire.Rd | 9 +- man/sample_grg.Rd | 8 +- man/sample_pref.Rd | 24 +- man/sample_traits_callaway.Rd | 24 +- tests/testthat/_snaps/foreign.md | 6 +- tests/testthat/_snaps/games.md | 18 ++ tests/testthat/test-centralization.R | 21 +- tests/testthat/test-foreign.R | 10 +- tests/testthat/test-games.R | 40 ++++ tools/migrations/centralization.R | 36 ++- tools/migrations/games.R | 55 +++-- tools/migrations/misc.R | 4 +- 31 files changed, 684 insertions(+), 204 deletions(-) diff --git a/R/centralization.R b/R/centralization.R index 5d9a3cd52c5..94734e09f3e 100644 --- a/R/centralization.R +++ b/R/centralization.R @@ -42,7 +42,7 @@ centralization.evcent.tmax <- function( ) centr_eigen_tmax( graph = graph, - nodes = nodes, + n = nodes, directed = directed, scale = scale ) @@ -98,7 +98,7 @@ centralization.degree.tmax <- function( "centralization.degree.tmax()", "centr_degree_tmax()" ) - centr_degree_tmax(graph = graph, nodes = nodes, mode = mode, loops = loops) + centr_degree_tmax(graph = graph, n = nodes, mode = mode, loops = loops) } # nocov end #' Centralize a graph according to the degrees of vertices @@ -152,7 +152,7 @@ centralization.closeness.tmax <- function( "centralization.closeness.tmax()", "centr_clo_tmax()" ) - centr_clo_tmax(graph = graph, nodes = nodes, mode = mode) + centr_clo_tmax(graph = graph, n = nodes, mode = mode) } # nocov end #' Centralize a graph according to the closeness of vertices @@ -200,7 +200,7 @@ centralization.betweenness.tmax <- function( "centralization.betweenness.tmax()", "centr_betw_tmax()" ) - centr_betw_tmax(graph = graph, nodes = nodes, directed = directed) + centr_betw_tmax(graph = graph, n = nodes, directed = directed) } # nocov end #' Centralize a graph according to the betweenness of vertices @@ -463,8 +463,10 @@ centr_degree <- function( #' #' See [centralize()] for a summary of graph centralization. #' -#' @param graph The input graph. It can also be `NULL` if `nodes` is given. -#' @param nodes The number of vertices. This is ignored if the graph is given. +#' @param graph The input graph. It can also be `NULL` if `n` is given. +#' @param n The number of vertices. This is ignored if the graph is given. +#' @param nodes `r lifecycle::badge("deprecated")` Use `n` instead. +#' @inheritParams rlang::args_dots_empty #' @param mode This is the same as the `mode` argument of `degree()`. Ignored #' if `graph` is given and the graph is undirected. #' @inheritParams centr_degree @@ -483,10 +485,64 @@ centr_degree <- function( #' centr_degree(g, normalized = TRUE)$centralization centr_degree_tmax <- function( graph = NULL, - nodes = 0, + n = 0, + ..., mode = c("all", "out", "in", "total"), - loops + loops, + nodes = deprecated() ) { + # BEGIN GENERATED ARG_HANDLE: centr_degree_tmax, do not edit, see tools/generate-migrations.R + # fmt: skip + if (...length() > 0L) { + # Pre-3.0.0 signature: centr_degree_tmax(graph, nodes, mode, loops) + .old_signature <- function(mode, loops, ...) { + if (...length() > 0L) { + .arg_extra <- base::names(base::substitute(...())) + .arg_extra <- .arg_extra[base::nzchar(.arg_extra)] + if (base::length(.arg_extra) == 0L) cli::cli_abort("Too many arguments passed to {.fn centr_degree_tmax}.", call = base::parent.frame()) + cli::cli_abort(base::c("Unexpected argument passed to {.fn centr_degree_tmax}: {.arg {(.arg_extra)}}.", i = "Arguments after {.arg ...} must be spelled out in full."), call = base::parent.frame()) + } + base::c( + if (!base::missing(mode)) base::list(mode = mode), + if (!base::missing(loops)) base::list(loops = loops) + ) + } + .arg_handle <- .old_signature(...) + if (base::length(.arg_handle) > 0L) { + .arg_names <- base::names(.arg_handle) + .arg_conflict <- base::intersect(.arg_names, base::c( + if (!base::missing(mode)) "mode", + if (!base::missing(loops)) "loops" + )) + if (base::length(.arg_conflict) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn centr_degree_tmax} was supplied more than once.", i = "Pass it exactly once, by its new name {.arg {(.arg_conflict)}}.")) + base::list2env(.arg_handle, base::environment()) + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `centr_degree_tmax()` with positional or abbreviated arguments"), + details = base::c( + i = base::paste0("Detected call: centr_degree_tmax(", base::paste(base::c("graph", "n", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: centr_degree_tmax(", base::paste(base::c("graph", "n", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + ) + ) + } + } + # END GENERATED ARG_HANDLE + + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn centr_degree_tmax} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "centr_degree_tmax(nodes = )", + "centr_degree_tmax(n = )" + ) + n <- nodes + } + if (!lifecycle::is_present(loops)) { lifecycle::deprecate_stop( when = "2.0.0", @@ -498,14 +554,14 @@ centr_degree_tmax <- function( # Argument checks ensure_igraph(graph, optional = TRUE) - nodes <- as.numeric(nodes) + n <- as.numeric(n) loops <- as.logical(loops) # Function call res <- centralization_degree_tmax_impl( graph = graph, - nodes = nodes, + nodes = n, mode = mode, loops = loops ) @@ -615,9 +671,10 @@ centr_betw <- function( #' See [centralize()] for a summary of graph centralization. #' #' @param graph The input graph. It can also be `NULL` if -#' `nodes` and `directed` are both given. -#' @param nodes The number of vertices. This is ignored if the graph is +#' `n` and `directed` are both given. +#' @param n The number of vertices. This is ignored if the graph is #' given. +#' @param nodes `r lifecycle::badge("deprecated")` Use `n` instead. #' @inheritParams rlang::args_dots_empty #' @param directed Logical, whether to use directed shortest paths #' for calculating betweenness. Ignored if an undirected graph was @@ -638,9 +695,10 @@ centr_betw <- function( #' centr_betw(g, normalized = TRUE)$centralization centr_betw_tmax <- function( graph = NULL, - nodes = 0, + n = 0, ..., - directed = TRUE + directed = TRUE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: centr_betw_tmax, do not edit, see tools/generate-migrations.R # fmt: skip @@ -669,17 +727,32 @@ centr_betw_tmax <- function( "3.0.0", what = base::I("Calling `centr_betw_tmax()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: centr_betw_tmax(", base::paste(base::c("graph", "nodes", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: centr_betw_tmax(", base::paste(base::c("graph", "nodes", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: centr_betw_tmax(", base::paste(base::c("graph", "n", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: centr_betw_tmax(", base::paste(base::c("graph", "n", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn centr_betw_tmax} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "centr_betw_tmax(nodes = )", + "centr_betw_tmax(n = )" + ) + n <- nodes + } + centralization_betweenness_tmax_impl( graph = graph, - nodes = nodes, + nodes = n, directed = directed ) } @@ -776,9 +849,10 @@ centr_clo <- function( #' See [centralize()] for a summary of graph centralization. #' #' @param graph The input graph. It can also be `NULL` if -#' `nodes` is given. -#' @param nodes The number of vertices. This is ignored if the graph is +#' `n` is given. +#' @param n The number of vertices. This is ignored if the graph is #' given. +#' @param nodes `r lifecycle::badge("deprecated")` Use `n` instead. #' @inheritParams rlang::args_dots_empty #' @param mode This is the same as the `mode` argument of #' `closeness()`. Ignored if an undirected graph is given. @@ -798,9 +872,10 @@ centr_clo <- function( #' centr_clo(g, normalized = TRUE)$centralization centr_clo_tmax <- function( graph = NULL, - nodes = 0, + n = 0, ..., - mode = c("out", "in", "all", "total") + mode = c("out", "in", "all", "total"), + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: centr_clo_tmax, do not edit, see tools/generate-migrations.R # fmt: skip @@ -829,17 +904,32 @@ centr_clo_tmax <- function( "3.0.0", what = base::I("Calling `centr_clo_tmax()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: centr_clo_tmax(", base::paste(base::c("graph", "nodes", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: centr_clo_tmax(", base::paste(base::c("graph", "nodes", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: centr_clo_tmax(", base::paste(base::c("graph", "n", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: centr_clo_tmax(", base::paste(base::c("graph", "n", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn centr_clo_tmax} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "centr_clo_tmax(nodes = )", + "centr_clo_tmax(n = )" + ) + n <- nodes + } + centralization_closeness_tmax_impl( graph = graph, - nodes = nodes, + nodes = n, mode = mode ) } @@ -923,9 +1013,11 @@ centr_eigen <- function( #' See [centralize()] for a summary of graph centralization. #' #' @param graph The input graph. It can also be `NULL`, if -#' `nodes` is given. -#' @param nodes The number of vertices. This is ignored if the graph is +#' `n` is given. +#' @param n The number of vertices. This is ignored if the graph is #' given. +#' @param nodes `r lifecycle::badge("deprecated")` Use `n` instead. +#' @inheritParams rlang::args_dots_empty #' @param directed Logical, whether to consider edge directions #' during the calculation. Ignored in undirected graphs. #' @param scale `r lifecycle::badge("deprecated")` Ignored. Computing @@ -946,10 +1038,64 @@ centr_eigen <- function( #' centr_eigen(g, normalized = TRUE)$centralization centr_eigen_tmax <- function( graph = NULL, - nodes = 0, + n = 0, + ..., directed = FALSE, - scale = deprecated() + scale = deprecated(), + nodes = deprecated() ) { + # BEGIN GENERATED ARG_HANDLE: centr_eigen_tmax, do not edit, see tools/generate-migrations.R + # fmt: skip + if (...length() > 0L) { + # Pre-3.0.0 signature: centr_eigen_tmax(graph, nodes, directed, scale) + .old_signature <- function(directed, scale, ...) { + if (...length() > 0L) { + .arg_extra <- base::names(base::substitute(...())) + .arg_extra <- .arg_extra[base::nzchar(.arg_extra)] + if (base::length(.arg_extra) == 0L) cli::cli_abort("Too many arguments passed to {.fn centr_eigen_tmax}.", call = base::parent.frame()) + cli::cli_abort(base::c("Unexpected argument passed to {.fn centr_eigen_tmax}: {.arg {(.arg_extra)}}.", i = "Arguments after {.arg ...} must be spelled out in full."), call = base::parent.frame()) + } + base::c( + if (!base::missing(directed)) base::list(directed = directed), + if (!base::missing(scale)) base::list(scale = scale) + ) + } + .arg_handle <- .old_signature(...) + if (base::length(.arg_handle) > 0L) { + .arg_names <- base::names(.arg_handle) + .arg_conflict <- base::intersect(.arg_names, base::c( + if (!base::missing(directed)) "directed", + if (!base::missing(scale)) "scale" + )) + if (base::length(.arg_conflict) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn centr_eigen_tmax} was supplied more than once.", i = "Pass it exactly once, by its new name {.arg {(.arg_conflict)}}.")) + base::list2env(.arg_handle, base::environment()) + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `centr_eigen_tmax()` with positional or abbreviated arguments"), + details = base::c( + i = base::paste0("Detected call: centr_eigen_tmax(", base::paste(base::c("graph", "n", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: centr_eigen_tmax(", base::paste(base::c("graph", "n", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + ) + ) + } + } + # END GENERATED ARG_HANDLE + + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn centr_eigen_tmax} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "centr_eigen_tmax(nodes = )", + "centr_eigen_tmax(n = )" + ) + n <- nodes + } + if (lifecycle::is_present(scale)) { lifecycle::deprecate_warn( "2.2.0", @@ -961,7 +1107,7 @@ centr_eigen_tmax <- function( centralization_eigenvector_centrality_tmax_impl( graph = graph, - nodes = nodes, + nodes = n, directed = directed, scale = TRUE ) diff --git a/R/foreign.R b/R/foreign.R index d0768024e41..52b7f517fe0 100644 --- a/R/foreign.R +++ b/R/foreign.R @@ -67,6 +67,8 @@ read.graph <- function( #' `graph.graphdb()` was renamed to [graph_from_graphdb()] to create a more #' consistent API. #' @inheritParams graph_from_graphdb +#' @param nodes `r lifecycle::badge("deprecated")` Use `n` in +#' [graph_from_graphdb()] instead. #' @keywords internal #' @export graph.graphdb <- function( @@ -86,7 +88,7 @@ graph.graphdb <- function( url = url, prefix = prefix, type = type, - nodes = nodes, + n = nodes, pair = pair, which = which, base = base, @@ -785,7 +787,7 @@ write.graph.dot <- function(graph, file) { #' [read_graph()] with the proper arguments to read the file. #' #' If `url` is `NULL`, and this is the default, then the filename is -#' assembled from the `base`, `prefix`, `type`, `nodes`, +#' assembled from the `base`, `prefix`, `type`, `n`, #' `pair` and `which` arguments. #' #' Unfortunately the original graph database homepage is now defunct, but see @@ -804,7 +806,7 @@ write.graph.dot <- function(graph, file) { #' `m3Dr4`, `m3Dr6`, `m4D`, `m4Dr2`, `m4Dr4`, #' `m4Dr6`, `b03`, `b03m`, `b06`, `b06m`, `b09`, #' `b09m`. -#' @param nodes The number of vertices in the graph. +#' @param n The number of vertices in the graph. #' @param pair Specifies which graph of the pair to read. Possible values: #' `A` and `B`. #' @param which Gives the number of the graph to read. For every graph type @@ -829,7 +831,7 @@ graph_from_graphdb <- function( ..., prefix = "iso", type = "r001", - nodes = NULL, + n = NULL, pair = "A", which = 0, base = "https://github.com/igraph/graphsdb/raw/refs/heads/main", @@ -852,7 +854,7 @@ graph_from_graphdb <- function( base::c( if (!base::missing(prefix)) base::list(prefix = prefix), if (!base::missing(type)) base::list(type = type), - if (!base::missing(nodes)) base::list(nodes = nodes), + if (!base::missing(nodes)) base::list(n = nodes), if (!base::missing(pair)) base::list(pair = pair), if (!base::missing(which)) base::list(which = which), if (!base::missing(base)) base::list(base = base), @@ -866,7 +868,7 @@ graph_from_graphdb <- function( .arg_conflict <- base::intersect(.arg_names, base::c( if (!base::missing(prefix)) "prefix", if (!base::missing(type)) "type", - if (!base::missing(nodes)) "nodes", + if (!base::missing(n)) "n", if (!base::missing(pair)) "pair", if (!base::missing(which)) "which", if (!base::missing(base)) "base", @@ -879,7 +881,7 @@ graph_from_graphdb <- function( "3.0.0", what = base::I("Calling `graph_from_graphdb()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: graph_from_graphdb(", base::paste(base::c("url", .arg_names), collapse = ", "), ")"), + i = base::paste0("Detected call: graph_from_graphdb(", base::paste(base::c("url", base::c(prefix = "prefix", type = "type", n = "nodes", pair = "pair", which = "which", base = "base", compressed = "compressed", directed = "directed")[.arg_names]), collapse = ", "), ")"), i = base::paste0("Use instead: graph_from_graphdb(", base::paste(base::c("url", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) @@ -887,8 +889,8 @@ graph_from_graphdb <- function( } # END GENERATED ARG_HANDLE - if (is.null(nodes) && is.null(url)) { - cli::cli_abort("Either {.arg nodes}' or `{.arg url}' must be non-null.") + if (is.null(n) && is.null(url)) { + cli::cli_abort("Either {.arg n}' or `{.arg url}' must be non-null.") } if (is.null(url)) { @@ -917,9 +919,9 @@ graph_from_graphdb <- function( "b09", "b09m" ) - sizecode <- if (nodes <= 100) { + sizecode <- if (n <= 100) { "s" - } else if (nodes < 2000) { + } else if (n < 2000) { "m" } else { "l" @@ -958,7 +960,7 @@ graph_from_graphdb <- function( type, "_", sizecode, - nodes, + n, ".", pair, formatC(which, width = 2, flag = "0"), diff --git a/R/games.R b/R/games.R index eda1cb03a22..9eaf4e5b47a 100644 --- a/R/games.R +++ b/R/games.R @@ -150,7 +150,7 @@ preference.game <- function( # nocov start lifecycle::deprecate_warn("2.0.0", "preference.game()", "sample_pref()") sample_pref( - nodes = nodes, + n = nodes, types = types, type.dist = type.dist, fixed.sizes = fixed.sizes, @@ -252,7 +252,7 @@ interconnected.islands.game <- function( grg.game <- function(nodes, radius, torus = FALSE, coords = FALSE) { # nocov start lifecycle::deprecate_warn("2.0.0", "grg.game()", "sample_grg()") - sample_grg(nodes = nodes, radius = radius, torus = torus, coords = coords) + sample_grg(n = nodes, radius = radius, torus = torus, coords = coords) } # nocov end #' Growing random graph generation @@ -299,7 +299,7 @@ forest.fire.game <- function( "sample_forestfire()" ) sample_forestfire( - nodes = nodes, + n = nodes, fw.prob = fw.prob, bw.factor = bw.factor, ambs = ambs, @@ -328,7 +328,7 @@ establishment.game <- function( # nocov start lifecycle::deprecate_warn("2.0.0", "establishment.game()", "sample_traits()") sample_traits( - nodes = nodes, + n = nodes, types = types, k = k, type.dist = type.dist, @@ -470,7 +470,7 @@ callaway.traits.game <- function( "sample_traits_callaway()" ) sample_traits_callaway( - nodes = nodes, + n = nodes, types = types, edge.per.step = edge.per.step, type.dist = type.dist, @@ -605,7 +605,7 @@ asymmetric.preference.game <- function( "sample_asym_pref()" ) sample_asym_pref( - nodes = nodes, + n = nodes, types = types, type.dist.matrix = type.dist.matrix, pref.matrix = pref.matrix, @@ -2200,7 +2200,8 @@ pa_age <- function( #' depends on the types of the vertices involved and is taken from #' `pref.matrix`. #' -#' @param nodes The number of vertices in the graph. +#' @param n The number of vertices in the graph. +#' @param nodes `r lifecycle::badge("deprecated")` Use `n` instead. #' @param types The number of different vertex types. #' @inheritParams rlang::args_dots_empty #' @param edge.per.step The number of edges to add to the graph per time step. @@ -2222,13 +2223,14 @@ pa_age <- function( #' g1 <- sample_traits_callaway(1000, 2, pref.matrix = matrix(c(1, 0, 0, 1), ncol = 2)) #' g2 <- sample_traits(1000, 2, k = 2, pref.matrix = matrix(c(1, 0, 0, 1), ncol = 2)) sample_traits_callaway <- function( - nodes, + n, types, ..., edge.per.step = 1, type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: sample_traits_callaway, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2265,14 +2267,29 @@ sample_traits_callaway <- function( "3.0.0", what = base::I("Calling `sample_traits_callaway()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: sample_traits_callaway(", base::paste(base::c("nodes", "types", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: sample_traits_callaway(", base::paste(base::c("nodes", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: sample_traits_callaway(", base::paste(base::c("n", "types", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: sample_traits_callaway(", base::paste(base::c("n", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn sample_traits_callaway} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "sample_traits_callaway(nodes = )", + "sample_traits_callaway(n = )" + ) + n <- nodes + } + if (is.null(type.dist)) { type.dist <- rep(1, types) } @@ -2281,7 +2298,7 @@ sample_traits_callaway <- function( } res <- callaway_traits_game_impl( - nodes = nodes, + nodes = n, types = types, edges_per_step = edge.per.step, type_dist = type.dist, @@ -2306,13 +2323,14 @@ sample_traits_callaway <- function( #' @inheritParams rlang::args_dots_empty #' @export traits_callaway <- function( - nodes, + n, types, ..., edge.per.step = 1, type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: traits_callaway, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2349,14 +2367,29 @@ traits_callaway <- function( "3.0.0", what = base::I("Calling `traits_callaway()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: traits_callaway(", base::paste(base::c("nodes", "types", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: traits_callaway(", base::paste(base::c("nodes", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: traits_callaway(", base::paste(base::c("n", "types", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: traits_callaway(", base::paste(base::c("n", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn traits_callaway} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "traits_callaway(nodes = )", + "traits_callaway(n = )" + ) + n <- nodes + } + if (is.null(type.dist)) { type.dist <- rep(1, types) } @@ -2366,7 +2399,7 @@ traits_callaway <- function( constructor_spec( sample_traits_callaway, - nodes, + n, types, edge.per.step = edge.per.step, type.dist = type.dist, @@ -2379,13 +2412,14 @@ traits_callaway <- function( #' @inheritParams rlang::args_dots_empty #' @export sample_traits <- function( - nodes, + n, types, k = 1, ..., type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: sample_traits, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2420,14 +2454,29 @@ sample_traits <- function( "3.0.0", what = base::I("Calling `sample_traits()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: sample_traits(", base::paste(base::c("nodes", "types", "k", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: sample_traits(", base::paste(base::c("nodes", "types", "k", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: sample_traits(", base::paste(base::c("n", "types", "k", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: sample_traits(", base::paste(base::c("n", "types", "k", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn sample_traits} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "sample_traits(nodes = )", + "sample_traits(n = )" + ) + n <- nodes + } + if (is.null(type.dist)) { type.dist <- rep(1, types) } @@ -2436,7 +2485,7 @@ sample_traits <- function( } res <- establishment_game_impl( - nodes = nodes, + nodes = n, types = types, k = k, type_dist = type.dist, @@ -2457,13 +2506,14 @@ sample_traits <- function( #' @inheritParams rlang::args_dots_empty #' @export traits <- function( - nodes, + n, types, k = 1, ..., type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: traits, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2498,14 +2548,29 @@ traits <- function( "3.0.0", what = base::I("Calling `traits()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: traits(", base::paste(base::c("nodes", "types", "k", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: traits(", base::paste(base::c("nodes", "types", "k", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: traits(", base::paste(base::c("n", "types", "k", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: traits(", base::paste(base::c("n", "types", "k", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn traits} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "traits(nodes = )", + "traits(n = )" + ) + n <- nodes + } + if (is.null(type.dist)) { type.dist <- rep(1, types) } @@ -2515,7 +2580,7 @@ traits <- function( constructor_spec( sample_traits, - nodes, + n, types, k = k, type.dist = type.dist, @@ -2537,7 +2602,8 @@ traits <- function( #' Euclidean norm than a given radius. If the `torus` argument is #' `TRUE` then a unit area torus is used instead of a square. #' -#' @param nodes The number of vertices in the graph. +#' @param n The number of vertices in the graph. +#' @param nodes `r lifecycle::badge("deprecated")` Use `n` instead. #' @param radius The radius within which the vertices will be connected by an #' edge. #' @inheritParams rlang::args_dots_empty @@ -2557,11 +2623,12 @@ traits <- function( #' g2 <- sample_grg(1000, 0.05, torus = TRUE) #' sample_grg <- function( - nodes, + n, radius, ..., torus = FALSE, - coords = FALSE + coords = FALSE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: sample_grg, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2592,18 +2659,33 @@ sample_grg <- function( "3.0.0", what = base::I("Calling `sample_grg()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: sample_grg(", base::paste(base::c("nodes", "radius", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: sample_grg(", base::paste(base::c("nodes", "radius", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: sample_grg(", base::paste(base::c("n", "radius", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: sample_grg(", base::paste(base::c("n", "radius", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn sample_grg} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "sample_grg(nodes = )", + "sample_grg(n = )" + ) + n <- nodes + } + on.exit(.Call(Rx_igraph_finalizer)) res <- .Call( Rx_igraph_grg_game, - as.double(nodes), + as.double(n), as.double(radius), as.logical(torus), as.logical(coords) @@ -2624,11 +2706,12 @@ sample_grg <- function( #' @inheritParams rlang::args_dots_empty #' @export grg <- function( - nodes, + n, radius, ..., torus = FALSE, - coords = FALSE + coords = FALSE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: grg, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2659,17 +2742,32 @@ grg <- function( "3.0.0", what = base::I("Calling `grg()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: grg(", base::paste(base::c("nodes", "radius", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: grg(", base::paste(base::c("nodes", "radius", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: grg(", base::paste(base::c("n", "radius", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: grg(", base::paste(base::c("n", "radius", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn grg} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "grg(nodes = )", + "grg(n = )" + ) + n <- nodes + } + constructor_spec( sample_grg, - nodes = nodes, + n = n, radius = radius, torus = torus, coords = coords @@ -2700,7 +2798,8 @@ grg <- function( #' `type` vertex attribute for `sample_pref()` and from the #' `intype` and `outtype` vertex attribute for `sample_asym_pref()`. #' -#' @param nodes The number of vertices in the graphs. +#' @param n The number of vertices in the graphs. +#' @param nodes `r lifecycle::badge("deprecated")` Use `n` instead. #' @param types The number of different vertex types. #' @inheritParams rlang::args_dots_empty #' @param type.dist The distribution of the vertex types, a numeric vector of @@ -2740,14 +2839,15 @@ grg <- function( #' tkplot(g, layout = layout_in_circle) #' sample_pref <- function( - nodes, + n, types, ..., type.dist = NULL, fixed.sizes = FALSE, pref.matrix = NULL, directed = FALSE, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: sample_pref, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2786,14 +2886,29 @@ sample_pref <- function( "3.0.0", what = base::I("Calling `sample_pref()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: sample_pref(", base::paste(base::c("nodes", "types", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: sample_pref(", base::paste(base::c("nodes", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: sample_pref(", base::paste(base::c("n", "types", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: sample_pref(", base::paste(base::c("n", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn sample_pref} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "sample_pref(nodes = )", + "sample_pref(n = )" + ) + n <- nodes + } + if (is.null(type.dist)) { type.dist <- rep(1, types) } @@ -2809,7 +2924,7 @@ sample_pref <- function( } res <- preference_game_impl( - nodes = nodes, + nodes = n, types = types, type_dist = type.dist, fixed_sizes = fixed.sizes, @@ -2833,14 +2948,15 @@ sample_pref <- function( #' @inheritParams rlang::args_dots_empty #' @export pref <- function( - nodes, + n, types, ..., type.dist = NULL, fixed.sizes = FALSE, pref.matrix = NULL, directed = FALSE, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: pref, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2879,14 +2995,29 @@ pref <- function( "3.0.0", what = base::I("Calling `pref()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: pref(", base::paste(base::c("nodes", "types", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: pref(", base::paste(base::c("nodes", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: pref(", base::paste(base::c("n", "types", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: pref(", base::paste(base::c("n", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn pref} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "pref(nodes = )", + "pref(n = )" + ) + n <- nodes + } + if (is.null(type.dist)) { type.dist <- rep(1, types) } @@ -2896,7 +3027,7 @@ pref <- function( constructor_spec( sample_pref, - nodes, + n, types, type.dist = type.dist, fixed.sizes = fixed.sizes, @@ -2910,12 +3041,13 @@ pref <- function( #' @inheritParams rlang::args_dots_empty #' @export sample_asym_pref <- function( - nodes, + n, types, ..., type.dist.matrix = NULL, pref.matrix = NULL, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: sample_asym_pref, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2950,14 +3082,29 @@ sample_asym_pref <- function( "3.0.0", what = base::I("Calling `sample_asym_pref()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: sample_asym_pref(", base::paste(base::c("nodes", "types", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: sample_asym_pref(", base::paste(base::c("nodes", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: sample_asym_pref(", base::paste(base::c("n", "types", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: sample_asym_pref(", base::paste(base::c("n", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn sample_asym_pref} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "sample_asym_pref(nodes = )", + "sample_asym_pref(n = )" + ) + n <- nodes + } + if (is.null(type.dist.matrix)) { type.dist.matrix <- matrix(1, types, types) } @@ -2979,7 +3126,7 @@ sample_asym_pref <- function( } res <- asymmetric_preference_game_impl( - nodes = nodes, + nodes = n, out_types = types, in_types = types, type_dist_matrix = type.dist.matrix, @@ -3003,12 +3150,13 @@ sample_asym_pref <- function( #' @inheritParams rlang::args_dots_empty #' @export asym_pref <- function( - nodes, + n, types, ..., type.dist.matrix = NULL, pref.matrix = NULL, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: asym_pref, do not edit, see tools/generate-migrations.R # fmt: skip @@ -3043,14 +3191,29 @@ asym_pref <- function( "3.0.0", what = base::I("Calling `asym_pref()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: asym_pref(", base::paste(base::c("nodes", "types", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: asym_pref(", base::paste(base::c("nodes", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: asym_pref(", base::paste(base::c("n", "types", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: asym_pref(", base::paste(base::c("n", "types", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn asym_pref} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "asym_pref(nodes = )", + "asym_pref(n = )" + ) + n <- nodes + } + if (is.null(type.dist.matrix)) { type.dist.matrix <- matrix(1, types, types) } @@ -3060,7 +3223,7 @@ asym_pref <- function( constructor_spec( sample_asym_pref, - nodes, + n, types, type.dist.matrix = type.dist.matrix, pref.matrix = pref.matrix, @@ -4954,7 +5117,8 @@ sample_fitness_pl <- function( #' available then we cite all of them. \item The same procedure is applied to #' all the newly cited vertices. } #' -#' @param nodes The number of vertices in the graph. +#' @param n The number of vertices in the graph. +#' @param nodes `r lifecycle::badge("deprecated")` Use `n` instead. #' @param fw.prob The forward burning probability, see details below. #' @inheritParams rlang::args_dots_empty #' @param bw.factor The backward burning ratio. The backward burning @@ -4991,12 +5155,13 @@ sample_fitness_pl <- function( #' plot(seq(along.with = dd1) - 1, dd1, log = "xy") #' points(seq(along.with = dd2) - 1, dd2, col = 2, pch = 2) sample_forestfire <- function( - nodes, + n, fw.prob, ..., bw.factor = 1, ambs = 1, - directed = TRUE + directed = TRUE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: sample_forestfire, do not edit, see tools/generate-migrations.R # fmt: skip @@ -5029,16 +5194,31 @@ sample_forestfire <- function( "3.0.0", what = base::I("Calling `sample_forestfire()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: sample_forestfire(", base::paste(base::c("nodes", "fw.prob", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: sample_forestfire(", base::paste(base::c("nodes", "fw.prob", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: sample_forestfire(", base::paste(base::c("n", "fw.prob", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: sample_forestfire(", base::paste(base::c("n", "fw.prob", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(n)) { + cli::cli_abort(c( + "Argument {.arg n} of {.fn sample_forestfire} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "sample_forestfire(nodes = )", + "sample_forestfire(n = )" + ) + n <- nodes + } + res <- forest_fire_game_impl( - nodes = nodes, + nodes = n, fw_prob = fw.prob, bw_factor = bw.factor, ambs = ambs, diff --git a/man/asymmetric.preference.game.Rd b/man/asymmetric.preference.game.Rd index a25892561c8..59208d16a4a 100644 --- a/man/asymmetric.preference.game.Rd +++ b/man/asymmetric.preference.game.Rd @@ -13,7 +13,7 @@ asymmetric.preference.game( ) } \arguments{ -\item{nodes}{The number of vertices in the graphs.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} \item{types}{The number of different vertex types.} diff --git a/man/callaway.traits.game.Rd b/man/callaway.traits.game.Rd index 487c8855995..06b6e30f608 100644 --- a/man/callaway.traits.game.Rd +++ b/man/callaway.traits.game.Rd @@ -14,7 +14,7 @@ callaway.traits.game( ) } \arguments{ -\item{nodes}{The number of vertices in the graph.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} \item{types}{The number of different vertex types.} diff --git a/man/centr_betw_tmax.Rd b/man/centr_betw_tmax.Rd index 6da3968daf7..0b6e02683d5 100644 --- a/man/centr_betw_tmax.Rd +++ b/man/centr_betw_tmax.Rd @@ -4,13 +4,19 @@ \alias{centr_betw_tmax} \title{Theoretical maximum for betweenness centralization} \usage{ -centr_betw_tmax(graph = NULL, nodes = 0, ..., directed = TRUE) +centr_betw_tmax( + graph = NULL, + n = 0, + ..., + directed = TRUE, + nodes = deprecated() +) } \arguments{ \item{graph}{The input graph. It can also be \code{NULL} if -\code{nodes} and \code{directed} are both given.} +\code{n} and \code{directed} are both given.} -\item{nodes}{The number of vertices. This is ignored if the graph is +\item{n}{The number of vertices. This is ignored if the graph is given.} \item{...}{These dots are for future extensions and must be empty.} @@ -18,6 +24,8 @@ given.} \item{directed}{Logical, whether to use directed shortest paths for calculating betweenness. Ignored if an undirected graph was given.} + +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} } \value{ Real scalar, the theoretical maximum (unnormalized) graph diff --git a/man/centr_clo_tmax.Rd b/man/centr_clo_tmax.Rd index 93fbe09cde8..c7c5b500a13 100644 --- a/man/centr_clo_tmax.Rd +++ b/man/centr_clo_tmax.Rd @@ -6,22 +6,25 @@ \usage{ centr_clo_tmax( graph = NULL, - nodes = 0, + n = 0, ..., - mode = c("out", "in", "all", "total") + mode = c("out", "in", "all", "total"), + nodes = deprecated() ) } \arguments{ \item{graph}{The input graph. It can also be \code{NULL} if -\code{nodes} is given.} +\code{n} is given.} -\item{nodes}{The number of vertices. This is ignored if the graph is +\item{n}{The number of vertices. This is ignored if the graph is given.} \item{...}{These dots are for future extensions and must be empty.} \item{mode}{This is the same as the \code{mode} argument of \code{closeness()}. Ignored if an undirected graph is given.} + +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} } \value{ Real scalar, the theoretical maximum (unnormalized) graph diff --git a/man/centr_degree_tmax.Rd b/man/centr_degree_tmax.Rd index 7a6f8cae489..a5a22e4c863 100644 --- a/man/centr_degree_tmax.Rd +++ b/man/centr_degree_tmax.Rd @@ -6,21 +6,27 @@ \usage{ centr_degree_tmax( graph = NULL, - nodes = 0, + n = 0, + ..., mode = c("all", "out", "in", "total"), - loops + loops, + nodes = deprecated() ) } \arguments{ -\item{graph}{The input graph. It can also be \code{NULL} if \code{nodes} is given.} +\item{graph}{The input graph. It can also be \code{NULL} if \code{n} is given.} -\item{nodes}{The number of vertices. This is ignored if the graph is given.} +\item{n}{The number of vertices. This is ignored if the graph is given.} + +\item{...}{These dots are for future extensions and must be empty.} \item{mode}{This is the same as the \code{mode} argument of \code{degree()}. Ignored if \code{graph} is given and the graph is undirected.} \item{loops}{Logical, whether to consider loops edges when calculating the degree.} + +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} } \value{ Real scalar, the theoretical maximum (unnormalized) graph degree diff --git a/man/centr_eigen_tmax.Rd b/man/centr_eigen_tmax.Rd index 86ce59f90da..c68f1151f1a 100644 --- a/man/centr_eigen_tmax.Rd +++ b/man/centr_eigen_tmax.Rd @@ -6,23 +6,29 @@ \usage{ centr_eigen_tmax( graph = NULL, - nodes = 0, + n = 0, + ..., directed = FALSE, - scale = deprecated() + scale = deprecated(), + nodes = deprecated() ) } \arguments{ \item{graph}{The input graph. It can also be \code{NULL}, if -\code{nodes} is given.} +\code{n} is given.} -\item{nodes}{The number of vertices. This is ignored if the graph is +\item{n}{The number of vertices. This is ignored if the graph is given.} +\item{...}{These dots are for future extensions and must be empty.} + \item{directed}{Logical, whether to consider edge directions during the calculation. Ignored in undirected graphs.} \item{scale}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Ignored. Computing eigenvector centralization requires normalized eigenvector centrality scores.} + +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} } \value{ Real scalar, the theoretical maximum (unnormalized) graph diff --git a/man/centralization.betweenness.tmax.Rd b/man/centralization.betweenness.tmax.Rd index fb9bbfd5864..dcd8de0d6a8 100644 --- a/man/centralization.betweenness.tmax.Rd +++ b/man/centralization.betweenness.tmax.Rd @@ -8,10 +8,9 @@ centralization.betweenness.tmax(graph = NULL, nodes = 0, directed = TRUE) } \arguments{ \item{graph}{The input graph. It can also be \code{NULL} if -\code{nodes} and \code{directed} are both given.} +\code{n} and \code{directed} are both given.} -\item{nodes}{The number of vertices. This is ignored if the graph is -given.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} \item{directed}{Logical, whether to use directed shortest paths for calculating betweenness. Ignored if an undirected graph was diff --git a/man/centralization.closeness.tmax.Rd b/man/centralization.closeness.tmax.Rd index e1560171fcd..7263c0ab325 100644 --- a/man/centralization.closeness.tmax.Rd +++ b/man/centralization.closeness.tmax.Rd @@ -12,10 +12,9 @@ centralization.closeness.tmax( } \arguments{ \item{graph}{The input graph. It can also be \code{NULL} if -\code{nodes} is given.} +\code{n} is given.} -\item{nodes}{The number of vertices. This is ignored if the graph is -given.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} \item{mode}{This is the same as the \code{mode} argument of \code{closeness()}. Ignored if an undirected graph is given.} diff --git a/man/centralization.degree.tmax.Rd b/man/centralization.degree.tmax.Rd index 29d7b242e75..18095638185 100644 --- a/man/centralization.degree.tmax.Rd +++ b/man/centralization.degree.tmax.Rd @@ -12,9 +12,9 @@ centralization.degree.tmax( ) } \arguments{ -\item{graph}{The input graph. It can also be \code{NULL} if \code{nodes} is given.} +\item{graph}{The input graph. It can also be \code{NULL} if \code{n} is given.} -\item{nodes}{The number of vertices. This is ignored if the graph is given.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} \item{mode}{This is the same as the \code{mode} argument of \code{degree()}. Ignored if \code{graph} is given and the graph is undirected.} diff --git a/man/centralization.evcent.tmax.Rd b/man/centralization.evcent.tmax.Rd index 7800a83252c..f03685e7972 100644 --- a/man/centralization.evcent.tmax.Rd +++ b/man/centralization.evcent.tmax.Rd @@ -13,10 +13,9 @@ centralization.evcent.tmax( } \arguments{ \item{graph}{The input graph. It can also be \code{NULL}, if -\code{nodes} is given.} +\code{n} is given.} -\item{nodes}{The number of vertices. This is ignored if the graph is -given.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} \item{directed}{Logical, whether to consider edge directions during the calculation. Ignored in undirected graphs.} diff --git a/man/establishment.game.Rd b/man/establishment.game.Rd index c27ce60c400..aad71dc1eab 100644 --- a/man/establishment.game.Rd +++ b/man/establishment.game.Rd @@ -14,7 +14,7 @@ establishment.game( ) } \arguments{ -\item{nodes}{The number of vertices in the graph.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} \item{types}{The number of different vertex types.} diff --git a/man/forest.fire.game.Rd b/man/forest.fire.game.Rd index 28aa158ba63..6acc3c63bf4 100644 --- a/man/forest.fire.game.Rd +++ b/man/forest.fire.game.Rd @@ -7,7 +7,7 @@ forest.fire.game(nodes, fw.prob, bw.factor = 1, ambs = 1, directed = TRUE) } \arguments{ -\item{nodes}{The number of vertices in the graph.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} \item{fw.prob}{The forward burning probability, see details below.} diff --git a/man/graph.graphdb.Rd b/man/graph.graphdb.Rd index bc45919b8a4..309ad93fe87 100644 --- a/man/graph.graphdb.Rd +++ b/man/graph.graphdb.Rd @@ -30,7 +30,8 @@ values: \code{r001}, \code{r005}, \code{r01}, \code{r02}, \code{m2D}, \code{m4Dr6}, \code{b03}, \code{b03m}, \code{b06}, \code{b06m}, \code{b09}, \code{b09m}.} -\item{nodes}{The number of vertices in the graph.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} in +\code{\link[=graph_from_graphdb]{graph_from_graphdb()}} instead.} \item{pair}{Specifies which graph of the pair to read. Possible values: \code{A} and \code{B}.} diff --git a/man/graph_from_graphdb.Rd b/man/graph_from_graphdb.Rd index 3b87c241a5c..b6218cef771 100644 --- a/man/graph_from_graphdb.Rd +++ b/man/graph_from_graphdb.Rd @@ -9,7 +9,7 @@ graph_from_graphdb( ..., prefix = "iso", type = "r001", - nodes = NULL, + n = NULL, pair = "A", which = 0, base = "https://github.com/igraph/graphsdb/raw/refs/heads/main", @@ -33,7 +33,7 @@ values: \code{r001}, \code{r005}, \code{r01}, \code{r02}, \code{m2D}, \code{m4Dr6}, \code{b03}, \code{b03m}, \code{b06}, \code{b06m}, \code{b09}, \code{b09m}.} -\item{nodes}{The number of vertices in the graph.} +\item{n}{The number of vertices in the graph.} \item{pair}{Specifies which graph of the pair to read. Possible values: \code{A} and \code{B}.} @@ -66,7 +66,7 @@ a local or remote graph database file. In this case we simply call \code{\link[=read_graph]{read_graph()}} with the proper arguments to read the file. If \code{url} is \code{NULL}, and this is the default, then the filename is -assembled from the \code{base}, \code{prefix}, \code{type}, \code{nodes}, +assembled from the \code{base}, \code{prefix}, \code{type}, \code{n}, \code{pair} and \code{which} arguments. Unfortunately the original graph database homepage is now defunct, but see diff --git a/man/grg.game.Rd b/man/grg.game.Rd index 22343e30481..f87b55774ca 100644 --- a/man/grg.game.Rd +++ b/man/grg.game.Rd @@ -7,7 +7,7 @@ grg.game(nodes, radius, torus = FALSE, coords = FALSE) } \arguments{ -\item{nodes}{The number of vertices in the graph.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} \item{radius}{The radius within which the vertices will be connected by an edge.} diff --git a/man/preference.game.Rd b/man/preference.game.Rd index d55dea83770..4f269e429ee 100644 --- a/man/preference.game.Rd +++ b/man/preference.game.Rd @@ -15,7 +15,7 @@ preference.game( ) } \arguments{ -\item{nodes}{The number of vertices in the graphs.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} \item{types}{The number of different vertex types.} diff --git a/man/sample_forestfire.Rd b/man/sample_forestfire.Rd index aeff07ef5f8..c15e7baebe5 100644 --- a/man/sample_forestfire.Rd +++ b/man/sample_forestfire.Rd @@ -5,16 +5,17 @@ \title{Forest Fire Network Model} \usage{ sample_forestfire( - nodes, + n, fw.prob, ..., bw.factor = 1, ambs = 1, - directed = TRUE + directed = TRUE, + nodes = deprecated() ) } \arguments{ -\item{nodes}{The number of vertices in the graph.} +\item{n}{The number of vertices in the graph.} \item{fw.prob}{The forward burning probability, see details below.} @@ -26,6 +27,8 @@ probability is calculated as \code{bw.factor*fw.prob}.} \item{ambs}{The number of ambassador vertices.} \item{directed}{Logical, whether to create a directed graph.} + +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} } \value{ A simple graph, possibly directed if the \code{directed} argument is diff --git a/man/sample_grg.Rd b/man/sample_grg.Rd index 8b83e6b1402..72bf143bb03 100644 --- a/man/sample_grg.Rd +++ b/man/sample_grg.Rd @@ -5,12 +5,12 @@ \alias{grg} \title{Geometric random graphs} \usage{ -sample_grg(nodes, radius, ..., torus = FALSE, coords = FALSE) +sample_grg(n, radius, ..., torus = FALSE, coords = FALSE, nodes = deprecated()) -grg(nodes, radius, ..., torus = FALSE, coords = FALSE) +grg(n, radius, ..., torus = FALSE, coords = FALSE, nodes = deprecated()) } \arguments{ -\item{nodes}{The number of vertices in the graph.} +\item{n}{The number of vertices in the graph.} \item{radius}{The radius within which the vertices will be connected by an edge.} @@ -21,6 +21,8 @@ edge.} \item{coords}{Logical, whether to add the positions of the vertices as vertex attributes called \sQuote{\code{x}} and \sQuote{\code{y}}.} + +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} } \value{ A graph object. If \code{coords} is \code{TRUE} then with vertex diff --git a/man/sample_pref.Rd b/man/sample_pref.Rd index 35b69cbd0d6..a26ffb9eb79 100644 --- a/man/sample_pref.Rd +++ b/man/sample_pref.Rd @@ -8,47 +8,51 @@ \title{Trait-based random generation} \usage{ sample_pref( - nodes, + n, types, ..., type.dist = NULL, fixed.sizes = FALSE, pref.matrix = NULL, directed = FALSE, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) pref( - nodes, + n, types, ..., type.dist = NULL, fixed.sizes = FALSE, pref.matrix = NULL, directed = FALSE, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) sample_asym_pref( - nodes, + n, types, ..., type.dist.matrix = NULL, pref.matrix = NULL, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) asym_pref( - nodes, + n, types, ..., type.dist.matrix = NULL, pref.matrix = NULL, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) } \arguments{ -\item{nodes}{The number of vertices in the graphs.} +\item{n}{The number of vertices in the graphs.} \item{types}{The number of different vertex types.} @@ -72,6 +76,8 @@ preferences to one.} \item{loops}{Logical, whether self-loops are allowed in the graph.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} + \item{type.dist.matrix}{The joint distribution of the in- and out-vertex types. The default \code{NULL} gives a uniform distribution.} } diff --git a/man/sample_traits_callaway.Rd b/man/sample_traits_callaway.Rd index 29f831bc9b7..a86d5de32dd 100644 --- a/man/sample_traits_callaway.Rd +++ b/man/sample_traits_callaway.Rd @@ -8,47 +8,51 @@ \title{Graph generation based on different vertex types} \usage{ sample_traits_callaway( - nodes, + n, types, ..., edge.per.step = 1, type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) traits_callaway( - nodes, + n, types, ..., edge.per.step = 1, type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) sample_traits( - nodes, + n, types, k = 1, ..., type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) traits( - nodes, + n, types, k = 1, ..., type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) } \arguments{ -\item{nodes}{The number of vertices in the graph.} +\item{n}{The number of vertices in the graph.} \item{types}{The number of different vertex types.} @@ -65,6 +69,8 @@ The default \code{NULL} sets all preferences to one.} \item{directed}{Logical, whether to generate directed graphs.} +\item{nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{n} instead.} + \item{k}{The number of trials per time step, see details below.} } \value{ diff --git a/tests/testthat/_snaps/foreign.md b/tests/testthat/_snaps/foreign.md index 412dbd28ffe..efa04eaf471 100644 --- a/tests/testthat/_snaps/foreign.md +++ b/tests/testthat/_snaps/foreign.md @@ -48,12 +48,12 @@ graph_from_graphdb() Condition Error in `graph_from_graphdb()`: - ! Either `nodes`' or ``url`' must be non-null. + ! Either `n`' or ``url`' must be non-null. --- Code - graph_from_graphdb(nodes = 10, prefix = "not_existing") + graph_from_graphdb(n = 10, prefix = "not_existing") Condition Error in `graph_from_graphdb()`: ! not_existing is not a valid prefix. @@ -62,7 +62,7 @@ --- Code - graph_from_graphdb(nodes = 10, type = "not_existing") + graph_from_graphdb(n = 10, type = "not_existing") Condition Error in `graph_from_graphdb()`: ! not_existing is not a valid graph type. diff --git a/tests/testthat/_snaps/games.md b/tests/testthat/_snaps/games.md index 56ba3f05339..77558b79c65 100644 --- a/tests/testthat/_snaps/games.md +++ b/tests/testthat/_snaps/games.md @@ -16,3 +16,21 @@ ! Cannot realize the given degree sequence as an undirected, simple graph. Invalid value Source: : +# sample_grg(nodes = ) is deprecated but still works + + Code + g <- sample_grg(nodes = 10, radius = 1) + Condition + Warning: + The `nodes` argument of `sample_grg()` is deprecated as of igraph 3.0.0. + i Please use the `n` argument instead. + +# sample_grg() rejects `n` supplied both directly and as `nodes` + + Code + sample_grg(10, radius = 1, nodes = 10) + Condition + Error in `sample_grg()`: + ! Argument `n` of `sample_grg()` was supplied more than once. + i It was also supplied via its legacy name `nodes`. + diff --git a/tests/testthat/test-centralization.R b/tests/testthat/test-centralization.R index 9161e1262e2..7fb01e91c6f 100644 --- a/tests/testthat/test-centralization.R +++ b/tests/testthat/test-centralization.R @@ -70,7 +70,7 @@ test_that("centr_betw_tmax() covers migrated tail args and positional recovery", # The graph form and the vertex-count form must agree. expect_equal(centr_betw_tmax(g, directed = FALSE), 24) - expect_equal(centr_betw_tmax(nodes = 5, directed = FALSE), 24) + expect_equal(centr_betw_tmax(n = 5, directed = FALSE), 24) # And they match what centr_betw() reports. expect_equal( centr_betw(g, directed = FALSE, normalized = FALSE)$theoretical_max, @@ -110,7 +110,7 @@ test_that("centr_clo_tmax() covers migrated tail args and positional recovery", # The graph form and the vertex-count form must agree. expect_equal(centr_clo_tmax(g, mode = "in"), 3.2) - expect_equal(centr_clo_tmax(nodes = 5, mode = "in"), 3.2) + expect_equal(centr_clo_tmax(n = 5, mode = "in"), 3.2) # And they match what centr_clo() reports. expect_equal( centr_clo(g, mode = "in", normalized = FALSE)$theoretical_max, @@ -136,3 +136,20 @@ test_that("centralize() covers migrated tail args and positional recovery", { ) expect_identical(res_legacy, centralize(scores, theoretical.max = 12)) }) + +# ---- nodes -> n rename ------------------------------------------------ + +test_that("centr_*_tmax(nodes = ) is deprecated but still works", { + lifecycle::expect_deprecated( + res_betw <- centr_betw_tmax(nodes = 5, directed = FALSE) + ) + expect_identical(res_betw, centr_betw_tmax(n = 5, directed = FALSE)) + + lifecycle::expect_deprecated( + res_degree <- centr_degree_tmax(nodes = 5, mode = "all", loops = TRUE) + ) + expect_identical( + res_degree, + centr_degree_tmax(n = 5, mode = "all", loops = TRUE) + ) +}) diff --git a/tests/testthat/test-foreign.R b/tests/testthat/test-foreign.R index 0332707c7e9..29e59cc6d51 100644 --- a/tests/testthat/test-foreign.R +++ b/tests/testthat/test-foreign.R @@ -66,13 +66,13 @@ test_that("graph_from_graphdb works", { # docker run --rm -ti -v $PWD:/rigraph -e MAKEFLAGS=-j4 ghcr.io/cynkra/r-debug/r-debug-csan-igraph:latest RDcsan -q -e 'filename <- "/rigraph/DESCRIPTION"; gz_file_con <- file(filename, open = "rb"); file_con <- gzcon(gz_file_con); close(file_con); gc()' skip_if(Sys.getenv("R_SANITIZER") == "true") - expect_silent(graph_from_graphdb(nodes = 1000)) + expect_silent(graph_from_graphdb(n = 1000)) expect_snapshot_igraph_error(graph_from_graphdb()) expect_snapshot_igraph_error( - graph_from_graphdb(nodes = 10, prefix = "not_existing") + graph_from_graphdb(n = 10, prefix = "not_existing") ) expect_snapshot_igraph_error( - graph_from_graphdb(nodes = 10, type = "not_existing") + graph_from_graphdb(n = 10, type = "not_existing") ) }) @@ -95,7 +95,7 @@ test_that("graph_from_graphdb() accepts every tail argument by name", { url = NULL, prefix = "iso", type = "r001", - nodes = 1000, + n = 1000, pair = "A", which = 0, base = "https://github.com/igraph/graphsdb/raw/refs/heads/main", @@ -120,7 +120,7 @@ test_that("graph_from_graphdb() wires up legacy positional recovery", { # a download. lifecycle::expect_deprecated( expect_error( - graph_from_graphdb(NULL, "not_existing", nodes = 10), + graph_from_graphdb(NULL, "not_existing", n = 10), regexp = "not a valid prefix" ) ) diff --git a/tests/testthat/test-games.R b/tests/testthat/test-games.R index f2034ffd21e..fdbb330e228 100644 --- a/tests/testthat/test-games.R +++ b/tests/testthat/test-games.R @@ -1702,3 +1702,43 @@ test_that("sample_correlated_gnp() recovers positional p", { sample_correlated_gnp(base_graph, 0.8, p = 0.3) ) }) + +# ---- nodes -> n rename ------------------------------------------------ + +test_that("sample_grg(nodes = ) is deprecated but still works", { + rlang::local_options(lifecycle_verbosity = "warning") + igraph_local_seed(42) + expected <- sample_grg(n = 10, radius = 1) + igraph_local_seed(42) + expect_snapshot( + g <- sample_grg(nodes = 10, radius = 1) + ) + expect_identical_graphs(g, expected) +}) + +test_that("sample_grg() rejects `n` supplied both directly and as `nodes`", { + rlang::local_options(lifecycle_verbosity = "warning") + expect_snapshot( + sample_grg(10, radius = 1, nodes = 10), + error = TRUE + ) +}) + +test_that("sample_pref(nodes = ) and sample_forestfire(nodes = ) are deprecated but still work", { + igraph_local_seed(1) + lifecycle::expect_deprecated( + g_pref_legacy <- sample_pref(nodes = 20, types = 2) + ) + igraph_local_seed(1) + expect_identical_graphs(g_pref_legacy, sample_pref(n = 20, types = 2)) + + igraph_local_seed(1) + lifecycle::expect_deprecated( + g_fire_legacy <- sample_forestfire(nodes = 30, fw.prob = 0.2) + ) + igraph_local_seed(1) + expect_identical_graphs( + g_fire_legacy, + sample_forestfire(n = 30, fw.prob = 0.2) + ) +}) diff --git a/tools/migrations/centralization.R b/tools/migrations/centralization.R index 0844a295b1b..019e811c216 100644 --- a/tools/migrations/centralization.R +++ b/tools/migrations/centralization.R @@ -18,9 +18,10 @@ migrations <- list( old = function(graph, nodes, directed) {}, new = function( graph = NULL, - nodes = 0, + n = 0, ..., - directed = TRUE + directed = TRUE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -40,9 +41,10 @@ migrations <- list( old = function(graph, nodes, mode) {}, new = function( graph = NULL, - nodes = 0, + n = 0, ..., - mode = c("out", "in", "all", "total") + mode = c("out", "in", "all", "total"), + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -59,6 +61,32 @@ migrations <- list( when = "3.0.0" ), + centr_degree_tmax = list( + old = function(graph, nodes, mode, loops) {}, + new = function( + graph = NULL, + n = 0, + ..., + mode = c("all", "out", "in", "total"), + loops, + nodes = deprecated() + ) {}, + when = "3.0.0" + ), + + centr_eigen_tmax = list( + old = function(graph, nodes, directed, scale) {}, + new = function( + graph = NULL, + n = 0, + ..., + directed = FALSE, + scale = deprecated(), + nodes = deprecated() + ) {}, + when = "3.0.0" + ), + centralize = list( old = function(scores, theoretical.max, normalized) {}, new = function( diff --git a/tools/migrations/games.R b/tools/migrations/games.R index 89d95e6fc17..d2e54ddbee7 100644 --- a/tools/migrations/games.R +++ b/tools/migrations/games.R @@ -6,12 +6,13 @@ migrations <- list( asym_pref = list( old = function(nodes, types, type.dist.matrix, pref.matrix, loops) {}, new = function( - nodes, + n, types, ..., type.dist.matrix = NULL, pref.matrix = NULL, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -81,11 +82,12 @@ migrations <- list( grg = list( old = function(nodes, radius, torus, coords) {}, new = function( - nodes, + n, radius, ..., torus = FALSE, - coords = FALSE + coords = FALSE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -180,14 +182,15 @@ migrations <- list( loops ) {}, new = function( - nodes, + n, types, ..., type.dist = NULL, fixed.sizes = FALSE, pref.matrix = NULL, directed = FALSE, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -195,12 +198,13 @@ migrations <- list( sample_asym_pref = list( old = function(nodes, types, type.dist.matrix, pref.matrix, loops) {}, new = function( - nodes, + n, types, ..., type.dist.matrix = NULL, pref.matrix = NULL, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -311,12 +315,13 @@ migrations <- list( sample_forestfire = list( old = function(nodes, fw.prob, bw.factor, ambs, directed) {}, new = function( - nodes, + n, fw.prob, ..., bw.factor = 1, ambs = 1, - directed = TRUE + directed = TRUE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -348,11 +353,12 @@ migrations <- list( sample_grg = list( old = function(nodes, radius, torus, coords) {}, new = function( - nodes, + n, radius, ..., torus = FALSE, - coords = FALSE + coords = FALSE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -463,14 +469,15 @@ migrations <- list( loops ) {}, new = function( - nodes, + n, types, ..., type.dist = NULL, fixed.sizes = FALSE, pref.matrix = NULL, directed = FALSE, - loops = FALSE + loops = FALSE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -505,13 +512,14 @@ migrations <- list( sample_traits = list( old = function(nodes, types, k, type.dist, pref.matrix, directed) {}, new = function( - nodes, + n, types, k = 1, ..., type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -526,13 +534,14 @@ migrations <- list( directed ) {}, new = function( - nodes, + n, types, ..., edge.per.step = 1, type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -567,13 +576,14 @@ migrations <- list( traits = list( old = function(nodes, types, k, type.dist, pref.matrix, directed) {}, new = function( - nodes, + n, types, k = 1, ..., type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -588,13 +598,14 @@ migrations <- list( directed ) {}, new = function( - nodes, + n, types, ..., edge.per.step = 1, type.dist = NULL, pref.matrix = NULL, - directed = FALSE + directed = FALSE, + nodes = deprecated() ) {}, when = "3.0.0" ) diff --git a/tools/migrations/misc.R b/tools/migrations/misc.R index 471d08a71aa..dfb74867dd7 100644 --- a/tools/migrations/misc.R +++ b/tools/migrations/misc.R @@ -28,7 +28,7 @@ migrations <- list( url, prefix, type, - nodes, + nodes = n, pair, which, base, @@ -40,7 +40,7 @@ migrations <- list( ..., prefix = "iso", type = "r001", - nodes = NULL, + n = NULL, pair = "A", which = 0, base = "https://github.com/igraph/graphsdb/raw/refs/heads/main", From 1a574c11b24c6e96e2009b2402734ba3c940b197 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 17 Aug 2026 18:18:59 +0000 Subject: [PATCH 3/6] refactor: snake_case weights arguments in clique functions and `cluster_infomap()` (#2788) `vertex.weights` -> `vertex_weights`, `min.weight` -> `min_weight`, `max.weight` -> `max_weight` in the weighted-clique functions, and `e.weights` -> `weights`, `v.weights` -> `vertex_weights` in `cluster_infomap()`, via registry renames with soft-deprecated recovery. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01RTPj4qNv2FWui6etixZeuR --- R/cliques.R | 58 +++++++++++++++++--------------- R/community.R | 34 +++++++++++-------- man/cliques.Rd | 6 ++-- man/cluster_infomap.Rd | 8 ++--- man/infomap.community.Rd | 15 +++------ man/weighted_cliques.Rd | 12 +++---- tests/testthat/_snaps/cliques.md | 10 ++++++ tests/testthat/test-cliques.R | 57 +++++++++++++++++++++---------- tests/testthat/test-community.R | 22 ++++++++++-- tools/migrations/cliques.R | 22 +++++++----- tools/migrations/community.R | 12 +++++-- 11 files changed, 159 insertions(+), 97 deletions(-) create mode 100644 tests/testthat/_snaps/cliques.md diff --git a/R/cliques.R b/R/cliques.R index 29fefbe4a65..8b2edcc09a9 100644 --- a/R/cliques.R +++ b/R/cliques.R @@ -475,12 +475,12 @@ clique_num <- function(graph) { #' #' @param graph The input graph, directed graphs will be considered as #' undirected ones, multiple edges and loops are ignored. -#' @param min.weight Numeric constant, lower limit on the weight of the cliques to find. +#' @param min_weight Numeric constant, lower limit on the weight of the cliques to find. #' `NULL` means no limit, i.e. it is the same as 0. -#' @param max.weight Numeric constant, upper limit on the weight of the cliques to find. +#' @param max_weight Numeric constant, upper limit on the weight of the cliques to find. #' `NULL` means no limit. #' @inheritParams rlang::args_dots_empty -#' @param vertex.weights Vertex weight vector. If the graph has a `weight` +#' @param vertex_weights Vertex weight vector. If the graph has a `weight` #' vertex attribute, then this is used by default. If the graph does not have a #' `weight` vertex attribute and this argument is `NULL`, then every #' vertex is assumed to have a weight of 1. Note that the current implementation @@ -510,15 +510,15 @@ clique_num <- function(graph) { weighted_cliques <- function( graph, ..., - vertex.weights = NULL, - min.weight = 0, - max.weight = 0, + vertex_weights = NULL, + min_weight = 0, + max_weight = 0, maximal = FALSE ) { # BEGIN GENERATED ARG_HANDLE: weighted_cliques, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { - .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("m", "ma", "max")) + .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("v", "ve", "ver", "vert", "verte", "vertex", "m", "mi", "min", "ma", "max")) if (base::length(.arg_ambiguous) > 0L) cli::cli_abort("Argument {.arg {(.arg_ambiguous[[1L]])}} matches multiple arguments of {.fn weighted_cliques}.") # Pre-3.0.0 signature: weighted_cliques(graph, vertex.weights, min.weight, max.weight, maximal) .old_signature <- function(vertex.weights, min.weight, max.weight, maximal, ...) { @@ -529,9 +529,9 @@ weighted_cliques <- function( cli::cli_abort(base::c("Unexpected argument passed to {.fn weighted_cliques}: {.arg {(.arg_extra)}}.", i = "Arguments after {.arg ...} must be spelled out in full."), call = base::parent.frame()) } base::c( - if (!base::missing(vertex.weights)) base::list(vertex.weights = vertex.weights), - if (!base::missing(min.weight)) base::list(min.weight = min.weight), - if (!base::missing(max.weight)) base::list(max.weight = max.weight), + if (!base::missing(vertex.weights)) base::list(vertex_weights = vertex.weights), + if (!base::missing(min.weight)) base::list(min_weight = min.weight), + if (!base::missing(max.weight)) base::list(max_weight = max.weight), if (!base::missing(maximal)) base::list(maximal = maximal) ) } @@ -539,9 +539,9 @@ weighted_cliques <- function( if (base::length(.arg_handle) > 0L) { .arg_names <- base::names(.arg_handle) .arg_conflict <- base::intersect(.arg_names, base::c( - if (!base::missing(vertex.weights)) "vertex.weights", - if (!base::missing(min.weight)) "min.weight", - if (!base::missing(max.weight)) "max.weight", + if (!base::missing(vertex_weights)) "vertex_weights", + if (!base::missing(min_weight)) "min_weight", + if (!base::missing(max_weight)) "max_weight", if (!base::missing(maximal)) "maximal" )) if (base::length(.arg_conflict) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn weighted_cliques} was supplied more than once.", i = "Pass it exactly once, by its new name {.arg {(.arg_conflict)}}.")) @@ -550,7 +550,7 @@ weighted_cliques <- function( "3.0.0", what = base::I("Calling `weighted_cliques()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: weighted_cliques(", base::paste(base::c("graph", .arg_names), collapse = ", "), ")"), + i = base::paste0("Detected call: weighted_cliques(", base::paste(base::c("graph", base::c(vertex_weights = "vertex.weights", min_weight = "min.weight", max_weight = "max.weight", maximal = "maximal")[.arg_names]), collapse = ", "), ")"), i = base::paste0("Use instead: weighted_cliques(", base::paste(base::c("graph", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) @@ -560,9 +560,9 @@ weighted_cliques <- function( weighted_cliques_impl( graph = graph, - vertex_weights = vertex.weights, - min_weight = min.weight, - max_weight = max.weight, + vertex_weights = vertex_weights, + min_weight = min_weight, + max_weight = max_weight, maximal = maximal ) } @@ -572,11 +572,13 @@ weighted_cliques <- function( largest_weighted_cliques <- function( graph, ..., - vertex.weights = NULL + vertex_weights = NULL ) { # BEGIN GENERATED ARG_HANDLE: largest_weighted_cliques, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { + .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("v", "ve", "ver", "vert", "verte", "vertex")) + if (base::length(.arg_ambiguous) > 0L) cli::cli_abort("Argument {.arg {(.arg_ambiguous[[1L]])}} matches multiple arguments of {.fn largest_weighted_cliques}.") # Pre-3.0.0 signature: largest_weighted_cliques(graph, vertex.weights) .old_signature <- function(vertex.weights, ...) { if (...length() > 0L) { @@ -586,14 +588,14 @@ largest_weighted_cliques <- function( cli::cli_abort(base::c("Unexpected argument passed to {.fn largest_weighted_cliques}: {.arg {(.arg_extra)}}.", i = "Arguments after {.arg ...} must be spelled out in full."), call = base::parent.frame()) } base::c( - if (!base::missing(vertex.weights)) base::list(vertex.weights = vertex.weights) + if (!base::missing(vertex.weights)) base::list(vertex_weights = vertex.weights) ) } .arg_handle <- .old_signature(...) if (base::length(.arg_handle) > 0L) { .arg_names <- base::names(.arg_handle) .arg_conflict <- base::intersect(.arg_names, base::c( - if (!base::missing(vertex.weights)) "vertex.weights" + if (!base::missing(vertex_weights)) "vertex_weights" )) if (base::length(.arg_conflict) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn largest_weighted_cliques} was supplied more than once.", i = "Pass it exactly once, by its new name {.arg {(.arg_conflict)}}.")) base::list2env(.arg_handle, base::environment()) @@ -601,7 +603,7 @@ largest_weighted_cliques <- function( "3.0.0", what = base::I("Calling `largest_weighted_cliques()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: largest_weighted_cliques(", base::paste(base::c("graph", .arg_names), collapse = ", "), ")"), + i = base::paste0("Detected call: largest_weighted_cliques(", base::paste(base::c("graph", base::c(vertex_weights = "vertex.weights")[.arg_names]), collapse = ", "), ")"), i = base::paste0("Use instead: largest_weighted_cliques(", base::paste(base::c("graph", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) @@ -611,7 +613,7 @@ largest_weighted_cliques <- function( largest_weighted_cliques_impl( graph = graph, - vertex_weights = vertex.weights + vertex_weights = vertex_weights ) } #' @inheritParams rlang::args_dots_empty @@ -620,11 +622,13 @@ largest_weighted_cliques <- function( weighted_clique_num <- function( graph, ..., - vertex.weights = NULL + vertex_weights = NULL ) { # BEGIN GENERATED ARG_HANDLE: weighted_clique_num, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { + .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("v", "ve", "ver", "vert", "verte", "vertex")) + if (base::length(.arg_ambiguous) > 0L) cli::cli_abort("Argument {.arg {(.arg_ambiguous[[1L]])}} matches multiple arguments of {.fn weighted_clique_num}.") # Pre-3.0.0 signature: weighted_clique_num(graph, vertex.weights) .old_signature <- function(vertex.weights, ...) { if (...length() > 0L) { @@ -634,14 +638,14 @@ weighted_clique_num <- function( cli::cli_abort(base::c("Unexpected argument passed to {.fn weighted_clique_num}: {.arg {(.arg_extra)}}.", i = "Arguments after {.arg ...} must be spelled out in full."), call = base::parent.frame()) } base::c( - if (!base::missing(vertex.weights)) base::list(vertex.weights = vertex.weights) + if (!base::missing(vertex.weights)) base::list(vertex_weights = vertex.weights) ) } .arg_handle <- .old_signature(...) if (base::length(.arg_handle) > 0L) { .arg_names <- base::names(.arg_handle) .arg_conflict <- base::intersect(.arg_names, base::c( - if (!base::missing(vertex.weights)) "vertex.weights" + if (!base::missing(vertex_weights)) "vertex_weights" )) if (base::length(.arg_conflict) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn weighted_clique_num} was supplied more than once.", i = "Pass it exactly once, by its new name {.arg {(.arg_conflict)}}.")) base::list2env(.arg_handle, base::environment()) @@ -649,7 +653,7 @@ weighted_clique_num <- function( "3.0.0", what = base::I("Calling `weighted_clique_num()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: weighted_clique_num(", base::paste(base::c("graph", .arg_names), collapse = ", "), ")"), + i = base::paste0("Detected call: weighted_clique_num(", base::paste(base::c("graph", base::c(vertex_weights = "vertex.weights")[.arg_names]), collapse = ", "), ")"), i = base::paste0("Use instead: weighted_clique_num(", base::paste(base::c("graph", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) @@ -659,7 +663,7 @@ weighted_clique_num <- function( weighted_clique_number_impl( graph = graph, - vertex_weights = vertex.weights + vertex_weights = vertex_weights ) } diff --git a/R/community.R b/R/community.R index 783f7676000..7218fdcfe58 100644 --- a/R/community.R +++ b/R/community.R @@ -282,6 +282,10 @@ is.hierarchical <- function(communities) { #' `infomap.community()` was renamed to [cluster_infomap()] to create a more #' consistent API. #' @inheritParams cluster_infomap +#' @param e.weights `r lifecycle::badge("deprecated")` Use `weights` in +#' [cluster_infomap()] instead. +#' @param v.weights `r lifecycle::badge("deprecated")` Use `vertex_weights` in +#' [cluster_infomap()] instead. #' @keywords internal #' @export infomap.community <- function( @@ -295,8 +299,8 @@ infomap.community <- function( lifecycle::deprecate_warn("2.0.0", "infomap.community()", "cluster_infomap()") cluster_infomap( graph = graph, - e.weights = e.weights, - v.weights = v.weights, + weights = e.weights, + vertex_weights = v.weights, nb.trials = nb.trials, modularity = modularity ) @@ -3020,12 +3024,12 @@ cluster_optimal <- function( #' #' @param graph The input graph. Edge directions will be taken into account. #' @inheritParams rlang::args_dots_empty -#' @param e.weights Numeric vector of edge weights. +#' @param weights Numeric vector of edge weights. #' The length must match the number of edges in the graph. By default (`NULL`) the #' \sQuote{`weight`} edge attribute is used as weights. If it is not #' present, then all edges are considered to have the same weight. #' Larger edge weights correspond to stronger connections. -#' @param v.weights Numeric vector of vertex +#' @param vertex_weights Numeric vector of vertex #' weights. The length must match the number of vertices in the graph. By #' default (`NULL`) the \sQuote{`weight`} vertex attribute is used as weights. If #' it is not present, then all vertices are considered to have the same weight. @@ -3063,14 +3067,16 @@ cluster_optimal <- function( cluster_infomap <- function( graph, ..., - e.weights = NULL, - v.weights = NULL, + weights = NULL, + vertex_weights = NULL, nb.trials = 10, modularity = TRUE ) { # BEGIN GENERATED ARG_HANDLE: cluster_infomap, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { + .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("v")) + if (base::length(.arg_ambiguous) > 0L) cli::cli_abort("Argument {.arg {(.arg_ambiguous[[1L]])}} matches multiple arguments of {.fn cluster_infomap}.") # Pre-3.0.0 signature: cluster_infomap(graph, e.weights, v.weights, nb.trials, modularity) .old_signature <- function(e.weights, v.weights, nb.trials, modularity, ...) { if (...length() > 0L) { @@ -3080,8 +3086,8 @@ cluster_infomap <- function( cli::cli_abort(base::c("Unexpected argument passed to {.fn cluster_infomap}: {.arg {(.arg_extra)}}.", i = "Arguments after {.arg ...} must be spelled out in full."), call = base::parent.frame()) } base::c( - if (!base::missing(e.weights)) base::list(e.weights = e.weights), - if (!base::missing(v.weights)) base::list(v.weights = v.weights), + if (!base::missing(e.weights)) base::list(weights = e.weights), + if (!base::missing(v.weights)) base::list(vertex_weights = v.weights), if (!base::missing(nb.trials)) base::list(nb.trials = nb.trials), if (!base::missing(modularity)) base::list(modularity = modularity) ) @@ -3090,8 +3096,8 @@ cluster_infomap <- function( if (base::length(.arg_handle) > 0L) { .arg_names <- base::names(.arg_handle) .arg_conflict <- base::intersect(.arg_names, base::c( - if (!base::missing(e.weights)) "e.weights", - if (!base::missing(v.weights)) "v.weights", + if (!base::missing(weights)) "weights", + if (!base::missing(vertex_weights)) "vertex_weights", if (!base::missing(nb.trials)) "nb.trials", if (!base::missing(modularity)) "modularity" )) @@ -3101,7 +3107,7 @@ cluster_infomap <- function( "3.0.0", what = base::I("Calling `cluster_infomap()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: cluster_infomap(", base::paste(base::c("graph", .arg_names), collapse = ", "), ")"), + i = base::paste0("Detected call: cluster_infomap(", base::paste(base::c("graph", base::c(weights = "e.weights", vertex_weights = "v.weights", nb.trials = "nb.trials", modularity = "modularity")[.arg_names]), collapse = ", "), ")"), i = base::paste0("Use instead: cluster_infomap(", base::paste(base::c("graph", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) @@ -3111,8 +3117,8 @@ cluster_infomap <- function( res <- community_infomap_impl( graph = graph, - e_weights = e.weights, - v_weights = v.weights, + e_weights = weights, + v_weights = vertex_weights, nb_trials = nb.trials ) @@ -3123,7 +3129,7 @@ cluster_infomap <- function( res$algorithm <- "infomap" res$membership <- res$membership + 1 if (modularity) { - res$modularity <- modularity(graph, res$membership, weights = e.weights) + res$modularity <- modularity(graph, res$membership, weights = weights) } class(res) <- "communities" res diff --git a/man/cliques.Rd b/man/cliques.Rd index 61c8ea492c2..dd2361c35ad 100644 --- a/man/cliques.Rd +++ b/man/cliques.Rd @@ -30,9 +30,9 @@ count_max_cliques(graph, min = NULL, max = NULL, ..., subset = NULL) clique_num(graph) -largest_weighted_cliques(graph, ..., vertex.weights = NULL) +largest_weighted_cliques(graph, ..., vertex_weights = NULL) -weighted_clique_num(graph, ..., vertex.weights = NULL) +weighted_clique_num(graph, ..., vertex_weights = NULL) clique_size_counts(graph, ..., min = 0, max = 0, maximal = FALSE) @@ -73,7 +73,7 @@ it exists, then it will be overwritten.) Each clique will be a separate line in the file, given with the numeric IDs of its vertices, separated by whitespace.} -\item{vertex.weights}{Vertex weight vector. If the graph has a \code{weight} +\item{vertex_weights}{Vertex weight vector. If the graph has a \code{weight} vertex attribute, then this is used by default. If the graph does not have a \code{weight} vertex attribute and this argument is \code{NULL}, then every vertex is assumed to have a weight of 1. Note that the current implementation diff --git a/man/cluster_infomap.Rd b/man/cluster_infomap.Rd index 4fdd32e356d..ddb7d066425 100644 --- a/man/cluster_infomap.Rd +++ b/man/cluster_infomap.Rd @@ -7,8 +7,8 @@ cluster_infomap( graph, ..., - e.weights = NULL, - v.weights = NULL, + weights = NULL, + vertex_weights = NULL, nb.trials = 10, modularity = TRUE ) @@ -18,13 +18,13 @@ cluster_infomap( \item{...}{These dots are for future extensions and must be empty.} -\item{e.weights}{Numeric vector of edge weights. +\item{weights}{Numeric vector of edge weights. The length must match the number of edges in the graph. By default (\code{NULL}) the \sQuote{\code{weight}} edge attribute is used as weights. If it is not present, then all edges are considered to have the same weight. Larger edge weights correspond to stronger connections.} -\item{v.weights}{Numeric vector of vertex +\item{vertex_weights}{Numeric vector of vertex weights. The length must match the number of vertices in the graph. By default (\code{NULL}) the \sQuote{\code{weight}} vertex attribute is used as weights. If it is not present, then all vertices are considered to have the same weight. diff --git a/man/infomap.community.Rd b/man/infomap.community.Rd index a8da00bd7a5..e40f8931249 100644 --- a/man/infomap.community.Rd +++ b/man/infomap.community.Rd @@ -15,18 +15,11 @@ infomap.community( \arguments{ \item{graph}{The input graph. Edge directions will be taken into account.} -\item{e.weights}{Numeric vector of edge weights. -The length must match the number of edges in the graph. By default (\code{NULL}) the -\sQuote{\code{weight}} edge attribute is used as weights. If it is not -present, then all edges are considered to have the same weight. -Larger edge weights correspond to stronger connections.} +\item{e.weights}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{weights} in +\code{\link[=cluster_infomap]{cluster_infomap()}} instead.} -\item{v.weights}{Numeric vector of vertex -weights. The length must match the number of vertices in the graph. By -default (\code{NULL}) the \sQuote{\code{weight}} vertex attribute is used as weights. If -it is not present, then all vertices are considered to have the same weight. -A larger vertex weight means a larger probability that the random surfer -jumps to that vertex.} +\item{v.weights}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{vertex_weights} in +\code{\link[=cluster_infomap]{cluster_infomap()}} instead.} \item{nb.trials}{The number of attempts to partition the network (can be any integer value equal or larger than 1).} diff --git a/man/weighted_cliques.Rd b/man/weighted_cliques.Rd index b9f03e0bd94..d83f7e4e531 100644 --- a/man/weighted_cliques.Rd +++ b/man/weighted_cliques.Rd @@ -7,9 +7,9 @@ weighted_cliques( graph, ..., - vertex.weights = NULL, - min.weight = 0, - max.weight = 0, + vertex_weights = NULL, + min_weight = 0, + max_weight = 0, maximal = FALSE ) } @@ -19,16 +19,16 @@ undirected ones, multiple edges and loops are ignored.} \item{...}{These dots are for future extensions and must be empty.} -\item{vertex.weights}{Vertex weight vector. If the graph has a \code{weight} +\item{vertex_weights}{Vertex weight vector. If the graph has a \code{weight} vertex attribute, then this is used by default. If the graph does not have a \code{weight} vertex attribute and this argument is \code{NULL}, then every vertex is assumed to have a weight of 1. Note that the current implementation of the weighted clique finder supports positive integer weights only.} -\item{min.weight}{Numeric constant, lower limit on the weight of the cliques to find. +\item{min_weight}{Numeric constant, lower limit on the weight of the cliques to find. \code{NULL} means no limit, i.e. it is the same as 0.} -\item{max.weight}{Numeric constant, upper limit on the weight of the cliques to find. +\item{max_weight}{Numeric constant, upper limit on the weight of the cliques to find. \code{NULL} means no limit.} \item{maximal}{Specifies whether to look for all weighted cliques (\code{FALSE}) diff --git a/tests/testthat/_snaps/cliques.md b/tests/testthat/_snaps/cliques.md new file mode 100644 index 00000000000..c10a77633da --- /dev/null +++ b/tests/testthat/_snaps/cliques.md @@ -0,0 +1,10 @@ +# weighted_cliques(vertex.weights = ) is deprecated but still works + + Code + res <- weighted_cliques(g, vertex.weights = w, min.weight = 6) + Condition + Warning: + Calling `weighted_cliques()` with positional or abbreviated arguments was deprecated in igraph 3.0.0. + i Detected call: weighted_cliques(graph, vertex.weights, min.weight) + i Use instead: weighted_cliques(graph, vertex_weights = , min_weight = ) + diff --git a/tests/testthat/test-cliques.R b/tests/testthat/test-cliques.R index 9d14e3d84a2..5cac8e696ff 100644 --- a/tests/testthat/test-cliques.R +++ b/tests/testthat/test-cliques.R @@ -48,13 +48,13 @@ test_that("weighted_cliques works", { } expect_equal( - lapply(largest_weighted_cliques(g, vertex.weights = weights), as.numeric), + lapply(largest_weighted_cliques(g, vertex_weights = weights), as.numeric), list(c(1, 2, 3)) ) V(g)$weight <- weights cl <- sapply( - weighted_cliques(g, min.weight = 9), + weighted_cliques(g, min_weight = 9), is_clique_weight, graph = g, min_weight = 9 @@ -64,7 +64,7 @@ test_that("weighted_cliques works", { karate <- make_graph("zachary") weights <- rep(1, vcount(karate)) weights[c(1, 2, 3, 4, 14)] <- 3 - expect_equal(weighted_clique_num(karate, vertex.weights = weights), 15) + expect_equal(weighted_clique_num(karate, vertex_weights = weights), 15) V(karate)$weight <- weights * 2 expect_equal(weighted_clique_num(karate), 30) @@ -522,19 +522,19 @@ test_that("weighted_cliques() covers all tail arguments", { # Under the attribute weights only the edge satisfies the weight bounds. res_attr <- weighted_cliques( g, - min.weight = 6, - max.weight = 9, + min_weight = 6, + max_weight = 9, maximal = TRUE ) expect_identical(lapply(res_attr, as.numeric), list(c(4, 5))) - # An explicit `vertex.weights` overrides the attribute, + # An explicit `vertex_weights` overrides the attribute, # flipping the selection to the triangle. res <- weighted_cliques( g, - vertex.weights = w, - min.weight = 6, - max.weight = 9, + vertex_weights = w, + min_weight = 6, + max_weight = 9, maximal = TRUE ) expect_identical(lapply(res, as.numeric), list(c(1, 2, 3))) @@ -543,21 +543,42 @@ test_that("weighted_cliques() covers all tail arguments", { lifecycle::expect_deprecated( res <- weighted_cliques(g, w, 6) ) - expect_identical(res, weighted_cliques(g, vertex.weights = w, min.weight = 6)) + expect_identical(res, weighted_cliques(g, vertex_weights = w, min_weight = 6)) }) -test_that("largest_weighted_cliques() covers vertex.weights", { +test_that("weighted_cliques(vertex.weights = ) is deprecated but still works", { + rlang::local_options(lifecycle_verbosity = "warning") + g <- make_weighted_clique_graph() + w <- c(3, 3, 3, 1, 1) + + expect_snapshot( + res <- weighted_cliques(g, vertex.weights = w, min.weight = 6) + ) + expect_identical(res, weighted_cliques(g, vertex_weights = w, min_weight = 6)) + + lifecycle::expect_deprecated( + res_num <- weighted_clique_num(g, vertex.weights = w) + ) + expect_identical(res_num, weighted_clique_num(g, vertex_weights = w)) + + lifecycle::expect_deprecated( + res_largest <- largest_weighted_cliques(g, vertex.weights = w) + ) + expect_identical(res_largest, largest_weighted_cliques(g, vertex_weights = w)) +}) + +test_that("largest_weighted_cliques() covers vertex_weights", { g <- make_weighted_clique_graph() w <- c(3, 3, 3, 1, 1) # Attribute weights favor the edge, - # the explicit `vertex.weights` vector overrides them. + # the explicit `vertex_weights` vector overrides them. expect_identical( lapply(largest_weighted_cliques(g), as.numeric), list(c(4, 5)) ) expect_identical( - lapply(largest_weighted_cliques(g, vertex.weights = w), as.numeric), + lapply(largest_weighted_cliques(g, vertex_weights = w), as.numeric), list(c(1, 2, 3)) ) @@ -565,21 +586,21 @@ test_that("largest_weighted_cliques() covers vertex.weights", { lifecycle::expect_deprecated( res <- largest_weighted_cliques(g, w) ) - expect_identical(res, largest_weighted_cliques(g, vertex.weights = w)) + expect_identical(res, largest_weighted_cliques(g, vertex_weights = w)) }) -test_that("weighted_clique_num() covers vertex.weights", { +test_that("weighted_clique_num() covers vertex_weights", { g <- make_weighted_clique_graph() w <- c(3, 3, 3, 1, 1) # Attribute weights favor the edge, - # the explicit `vertex.weights` vector overrides them. + # the explicit `vertex_weights` vector overrides them. expect_equal(weighted_clique_num(g), 8) - expect_equal(weighted_clique_num(g, vertex.weights = w), 9) + expect_equal(weighted_clique_num(g, vertex_weights = w), 9) # Legacy positional `vertex.weights` is recovered with a deprecation warning. lifecycle::expect_deprecated( res <- weighted_clique_num(g, w) ) - expect_identical(res, weighted_clique_num(g, vertex.weights = w)) + expect_identical(res, weighted_clique_num(g, vertex_weights = w)) }) diff --git a/tests/testthat/test-community.R b/tests/testthat/test-community.R index 65183998533..df5bdf71efd 100644 --- a/tests/testthat/test-community.R +++ b/tests/testthat/test-community.R @@ -787,8 +787,8 @@ test_that("cluster_infomap() covers migrated tail args and positional recovery", res <- cluster_infomap( karate, - e.weights = rep(1, ecount(karate)), - v.weights = rep(1, vcount(karate)), + weights = rep(1, ecount(karate)), + vertex_weights = rep(1, vcount(karate)), nb.trials = 3, modularity = FALSE ) @@ -804,7 +804,23 @@ test_that("cluster_infomap() covers migrated tail args and positional recovery", res_legacy <- cluster_infomap(karate, ew) ) set.seed(1) - expect_identical(res_legacy, cluster_infomap(karate, e.weights = ew)) + expect_identical(res_legacy, cluster_infomap(karate, weights = ew)) + + # The legacy `e.weights` and `v.weights` names are recovered. + set.seed(1) + lifecycle::expect_deprecated( + res_enamed <- cluster_infomap(karate, e.weights = ew) + ) + expect_identical(res_enamed, res_legacy) + set.seed(1) + lifecycle::expect_deprecated( + res_vnamed <- cluster_infomap(karate, v.weights = rep(1, vcount(karate))) + ) + set.seed(1) + expect_identical( + res_vnamed, + cluster_infomap(karate, vertex_weights = rep(1, vcount(karate))) + ) }) test_that("cluster_louvain() covers migrated tail args and positional recovery", { diff --git a/tools/migrations/cliques.R b/tools/migrations/cliques.R index 9a63c393a80..e3db3df8d1f 100644 --- a/tools/migrations/cliques.R +++ b/tools/migrations/cliques.R @@ -39,33 +39,39 @@ migrations <- list( ), largest_weighted_cliques = list( - old = function(graph, vertex.weights) {}, + old = function(graph, vertex.weights = vertex_weights) {}, new = function( graph, ..., - vertex.weights = NULL + vertex_weights = NULL ) {}, when = "3.0.0" ), weighted_clique_num = list( - old = function(graph, vertex.weights) {}, + old = function(graph, vertex.weights = vertex_weights) {}, new = function( graph, ..., - vertex.weights = NULL + vertex_weights = NULL ) {}, when = "3.0.0" ), weighted_cliques = list( - old = function(graph, vertex.weights, min.weight, max.weight, maximal) {}, + old = function( + graph, + vertex.weights = vertex_weights, + min.weight = min_weight, + max.weight = max_weight, + maximal + ) {}, new = function( graph, ..., - vertex.weights = NULL, - min.weight = 0, - max.weight = 0, + vertex_weights = NULL, + min_weight = 0, + max_weight = 0, maximal = FALSE ) {}, when = "3.0.0" diff --git a/tools/migrations/community.R b/tools/migrations/community.R index d8cb12bc310..3dd8eade1e9 100644 --- a/tools/migrations/community.R +++ b/tools/migrations/community.R @@ -42,12 +42,18 @@ migrations <- list( ), cluster_infomap = list( - old = function(graph, e.weights, v.weights, nb.trials, modularity) {}, + old = function( + graph, + e.weights = weights, + v.weights = vertex_weights, + nb.trials, + modularity + ) {}, new = function( graph, ..., - e.weights = NULL, - v.weights = NULL, + weights = NULL, + vertex_weights = NULL, nb.trials = 10, modularity = TRUE ) {}, From 691dc3d675ec6024a9f7f1153f0de20f0df284f2 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 17 Aug 2026 18:24:05 +0000 Subject: [PATCH 4/6] refactor: Rename normalization flags to `normalized` (#2788) `power_centrality(rescale = )`, `hits_scores(scale = )` and `tk_coords(norm = )` unify on `normalized`, matching the nine functions that already use that name. Legacy spellings are soft-deprecated. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01RTPj4qNv2FWui6etixZeuR --- R/centrality.R | 49 ++++++++++++++++++++--------- R/tkplot.R | 20 +++++++----- man/bonpow.Rd | 4 +-- man/hits_scores.Rd | 13 ++++++-- man/power_centrality.Rd | 4 +-- man/tkplot.Rd | 4 +-- man/tkplot.getcoords.Rd | 3 +- tests/testthat/_snaps/centrality.md | 18 +++++++++++ tests/testthat/test-centrality.R | 34 +++++++++++++++++++- tests/testthat/test-tkplot.R | 12 +++++-- tools/migrations/centrality.R | 4 +-- tools/migrations/plotting.R | 4 +-- 12 files changed, 131 insertions(+), 38 deletions(-) diff --git a/R/centrality.R b/R/centrality.R index 49d184830a4..7717abf8db1 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -233,6 +233,8 @@ edge.betweenness <- function( #' `bonpow()` was renamed to [power_centrality()] to create a more #' consistent API. #' @inheritParams power_centrality +#' @param rescale `r lifecycle::badge("deprecated")` Use `normalized` in +#' [power_centrality()] instead. #' @keywords internal #' @export bonpow <- function( @@ -251,7 +253,7 @@ bonpow <- function( nodes = nodes, loops = loops, exponent = exponent, - rescale = rescale, + normalized = rescale, tol = tol, sparse = sparse ) @@ -1719,7 +1721,7 @@ diversity <- function( #' scores are the same as authority scores. #' #' @param graph The input graph. -#' @param scale Logical, whether to scale the result to have a maximum +#' @param normalized Logical, whether to scale the result to have a maximum #' score of one. If no scaling is used then the result vector has unit length #' in the Euclidean norm. #' @param weights Optional positive weight vector for calculating weighted @@ -1729,6 +1731,7 @@ diversity <- function( #' edges are effectively added up. #' @param options A named list, to override some ARPACK options. See #' [arpack()] for details. The default `NULL` uses [arpack_defaults()]. +#' @param scale `r lifecycle::badge("deprecated")` Use `normalized` instead. #' @inheritParams rlang::args_dots_empty #' @return A named list with members: #' \describe{ @@ -1766,19 +1769,35 @@ diversity <- function( hits_scores <- function( graph, ..., - scale = TRUE, + normalized = TRUE, weights = NULL, - options = NULL + options = NULL, + scale = deprecated() ) { rlang::check_dots_empty() + if (lifecycle::is_present(scale)) { + if (!missing(normalized)) { + cli::cli_abort(c( + "Argument {.arg normalized} of {.fn hits_scores} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg scale}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "hits_scores(scale = )", + "hits_scores(normalized = )" + ) + normalized <- scale + } + if (is.null(options)) { options <- arpack_defaults() } hub_and_authority_scores_impl( graph = graph, - scale = scale, + scale = normalized, weights = weights, options = options ) @@ -1810,7 +1829,7 @@ authority_score <- function( scores <- hits_scores( graph = graph, - scale = scale, + normalized = scale, weights = weights, options = options ) @@ -1855,7 +1874,7 @@ hub_score <- function( scores <- hits_scores( graph = graph, - scale = scale, + normalized = scale, weights = weights, options = options ) @@ -2266,7 +2285,7 @@ bonpow.sparse <- function( #' loops. `loops` is `FALSE` by default. #' @param exponent exponent (decay rate) for the Bonacich power centrality #' score; can be negative -#' @param rescale if true, centrality scores are rescaled such that they sum to +#' @param normalized if true, centrality scores are rescaled such that they sum to #' 1. #' @param tol tolerance for near-singularities during matrix inversion (see #' [Matrix::solve()]) @@ -2325,7 +2344,7 @@ power_centrality <- function( ..., loops = FALSE, exponent = 1, - rescale = FALSE, + normalized = FALSE, tol = 1e-7, sparse = TRUE, weights = NULL @@ -2333,6 +2352,8 @@ power_centrality <- function( # BEGIN GENERATED ARG_HANDLE: power_centrality, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { + .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("n", "no")) + if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn power_centrality}.", i = "Spell out the full argument name.")) # Pre-3.0.0 signature: power_centrality(graph, nodes, loops, exponent, rescale, tol, sparse, weights) .old_signature <- function(loops, exponent, rescale, tol, sparse, weights, ...) { if (...length() > 0L) { @@ -2344,7 +2365,7 @@ power_centrality <- function( base::c( if (!base::missing(loops)) base::list(loops = loops), if (!base::missing(exponent)) base::list(exponent = exponent), - if (!base::missing(rescale)) base::list(rescale = rescale), + if (!base::missing(rescale)) base::list(normalized = rescale), if (!base::missing(tol)) base::list(tol = tol), if (!base::missing(sparse)) base::list(sparse = sparse), if (!base::missing(weights)) base::list(weights = weights) @@ -2356,7 +2377,7 @@ power_centrality <- function( .arg_conflict <- base::intersect(.arg_names, base::c( if (!base::missing(loops)) "loops", if (!base::missing(exponent)) "exponent", - if (!base::missing(rescale)) "rescale", + if (!base::missing(normalized)) "normalized", if (!base::missing(tol)) "tol", if (!base::missing(sparse)) "sparse", if (!base::missing(weights)) "weights" @@ -2367,7 +2388,7 @@ power_centrality <- function( "3.0.0", what = base::I("Calling `power_centrality()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: power_centrality(", base::paste(base::c("graph", "nodes", .arg_names), collapse = ", "), ")"), + i = base::paste0("Detected call: power_centrality(", base::paste(base::c("graph", "nodes", base::c(loops = "loops", exponent = "exponent", normalized = "rescale", tol = "tol", sparse = "sparse", weights = "weights")[.arg_names]), collapse = ", "), ")"), i = base::paste0("Use instead: power_centrality(", base::paste(base::c("graph", "nodes", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) @@ -2386,7 +2407,7 @@ power_centrality <- function( nodes, loops, exponent, - rescale, + normalized, tol, weights = weights ) @@ -2396,7 +2417,7 @@ power_centrality <- function( nodes, loops, exponent, - rescale, + normalized, tol, weights = weights ) diff --git a/R/tkplot.R b/R/tkplot.R index 9342a284939..11c81bb35e6 100644 --- a/R/tkplot.R +++ b/R/tkplot.R @@ -71,12 +71,14 @@ tkplot.off <- function() { #' `tkplot.getcoords()` was renamed to [tk_coords()] to create a more #' consistent API. #' @inheritParams tk_coords +#' @param norm `r lifecycle::badge("deprecated")` Use `normalized` in +#' [tk_coords()] instead. #' @keywords internal #' @export tkplot.getcoords <- function(tkp.id, norm = FALSE) { # nocov start lifecycle::deprecate_warn("2.0.0", "tkplot.getcoords()", "tk_coords()") - tk_coords(tkp.id = tkp.id, norm = norm) + tk_coords(tkp.id = tkp.id, normalized = norm) } # nocov end #' Interactive plotting of graphs @@ -271,7 +273,7 @@ assign(".next", 1, .tkplot.env) #' @param width The width of the rectangle for generating new coordinates. #' @param height The height of the rectangle for generating new coordinates. #' @param newlayout The new layout, see the `layout` parameter of tkplot. -#' @param norm Logical, should we norm the coordinates. +#' @param normalized Logical, should we norm the coordinates. #' @param coords Two-column numeric matrix, the new coordinates of the #' vertices, in absolute coordinates. #' @param degree The degree to rotate the plot. @@ -734,11 +736,13 @@ tk_postscript <- function(tkp.id) { tk_coords <- function( tkp.id, ..., - norm = FALSE + normalized = FALSE ) { # BEGIN GENERATED ARG_HANDLE: tk_coords, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { + .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("n", "no", "nor")) + if (base::length(.arg_ambiguous) > 0L) cli::cli_abort("Argument {.arg {(.arg_ambiguous[[1L]])}} matches multiple arguments of {.fn tk_coords}.") # Pre-3.0.0 signature: tk_coords(tkp.id, norm) .old_signature <- function(norm, ...) { if (...length() > 0L) { @@ -748,14 +752,14 @@ tk_coords <- function( cli::cli_abort(base::c("Unexpected argument passed to {.fn tk_coords}: {.arg {(.arg_extra)}}.", i = "Arguments after {.arg ...} must be spelled out in full."), call = base::parent.frame()) } base::c( - if (!base::missing(norm)) base::list(norm = norm) + if (!base::missing(norm)) base::list(normalized = norm) ) } .arg_handle <- .old_signature(...) if (base::length(.arg_handle) > 0L) { .arg_names <- base::names(.arg_handle) .arg_conflict <- base::intersect(.arg_names, base::c( - if (!base::missing(norm)) "norm" + if (!base::missing(normalized)) "normalized" )) if (base::length(.arg_conflict) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn tk_coords} was supplied more than once.", i = "Pass it exactly once, by its new name {.arg {(.arg_conflict)}}.")) base::list2env(.arg_handle, base::environment()) @@ -763,7 +767,7 @@ tk_coords <- function( "3.0.0", what = base::I("Calling `tk_coords()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: tk_coords(", base::paste(base::c("tkp.id", .arg_names), collapse = ", "), ")"), + i = base::paste0("Detected call: tk_coords(", base::paste(base::c("tkp.id", base::c(normalized = "norm")[.arg_names]), collapse = ", "), ")"), i = base::paste0("Use instead: tk_coords(", base::paste(base::c("tkp.id", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) @@ -774,7 +778,7 @@ tk_coords <- function( # nocov start coords <- .tkplot.get(tkp.id, "coords") coords[, 2] <- max(coords[, 2]) - coords[, 2] - if (norm) { + if (normalized) { # Shift coords[, 1] <- coords[, 1] - min(coords[, 1]) coords[, 2] <- coords[, 2] - min(coords[, 2]) @@ -1845,7 +1849,7 @@ tk_canvas <- function(tkp.id) { layout$params[[i]]$type == "initial" && params[[i]] ) { - realparams[[i]] <- tk_coords(tkp.id, norm = TRUE) + realparams[[i]] <- tk_coords(tkp.id, normalized = TRUE) } } if (as.logical(tcltk::tclvalue(save.default))) { diff --git a/man/bonpow.Rd b/man/bonpow.Rd index b2afd4d8004..ae394851f64 100644 --- a/man/bonpow.Rd +++ b/man/bonpow.Rd @@ -27,8 +27,8 @@ loops. \code{loops} is \code{FALSE} by default.} \item{exponent}{exponent (decay rate) for the Bonacich power centrality score; can be negative} -\item{rescale}{if true, centrality scores are rescaled such that they sum to -1.} +\item{rescale}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{normalized} in +\code{\link[=power_centrality]{power_centrality()}} instead.} \item{tol}{tolerance for near-singularities during matrix inversion (see \code{\link[Matrix:solve]{Matrix::solve()}})} diff --git a/man/hits_scores.Rd b/man/hits_scores.Rd index ee1440b68c5..d9f1562f766 100644 --- a/man/hits_scores.Rd +++ b/man/hits_scores.Rd @@ -4,14 +4,21 @@ \alias{hits_scores} \title{Kleinberg's hub and authority centrality scores.} \usage{ -hits_scores(graph, ..., scale = TRUE, weights = NULL, options = NULL) +hits_scores( + graph, + ..., + normalized = TRUE, + weights = NULL, + options = NULL, + scale = deprecated() +) } \arguments{ \item{graph}{The input graph.} \item{...}{These dots are for future extensions and must be empty.} -\item{scale}{Logical, whether to scale the result to have a maximum +\item{normalized}{Logical, whether to scale the result to have a maximum score of one. If no scaling is used then the result vector has unit length in the Euclidean norm.} @@ -23,6 +30,8 @@ edges are effectively added up.} \item{options}{A named list, to override some ARPACK options. See \code{\link[=arpack]{arpack()}} for details. The default \code{NULL} uses \code{\link[=arpack_defaults]{arpack_defaults()}}.} + +\item{scale}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{normalized} instead.} } \value{ A named list with members: diff --git a/man/power_centrality.Rd b/man/power_centrality.Rd index 7bd3a990d65..afe35228b59 100644 --- a/man/power_centrality.Rd +++ b/man/power_centrality.Rd @@ -10,7 +10,7 @@ power_centrality( ..., loops = FALSE, exponent = 1, - rescale = FALSE, + normalized = FALSE, tol = 1e-07, sparse = TRUE, weights = NULL @@ -31,7 +31,7 @@ loops. \code{loops} is \code{FALSE} by default.} \item{exponent}{exponent (decay rate) for the Bonacich power centrality score; can be negative} -\item{rescale}{if true, centrality scores are rescaled such that they sum to +\item{normalized}{if true, centrality scores are rescaled such that they sum to 1.} \item{tol}{tolerance for near-singularities during matrix inversion (see diff --git a/man/tkplot.Rd b/man/tkplot.Rd index f601f105f74..1013f77d1dd 100644 --- a/man/tkplot.Rd +++ b/man/tkplot.Rd @@ -28,7 +28,7 @@ tk_reshape(tkp.id, newlayout, ..., params) tk_postscript(tkp.id) -tk_coords(tkp.id, ..., norm = FALSE) +tk_coords(tkp.id, ..., normalized = FALSE) tk_set_coords(tkp.id, coords) @@ -56,7 +56,7 @@ the complete list.} \item{params}{Extra parameters in a list, to pass to the layout function.} -\item{norm}{Logical, should we norm the coordinates.} +\item{normalized}{Logical, should we norm the coordinates.} \item{coords}{Two-column numeric matrix, the new coordinates of the vertices, in absolute coordinates.} diff --git a/man/tkplot.getcoords.Rd b/man/tkplot.getcoords.Rd index e764d774690..0b21a844598 100644 --- a/man/tkplot.getcoords.Rd +++ b/man/tkplot.getcoords.Rd @@ -9,7 +9,8 @@ tkplot.getcoords(tkp.id, norm = FALSE) \arguments{ \item{tkp.id}{The ID of the tkplot window to close/reshape/etc.} -\item{norm}{Logical, should we norm the coordinates.} +\item{norm}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{normalized} in +\code{\link[=tk_coords]{tk_coords()}} 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/tests/testthat/_snaps/centrality.md b/tests/testthat/_snaps/centrality.md index fd6a1913e6f..ab3d6b88bdc 100644 --- a/tests/testthat/_snaps/centrality.md +++ b/tests/testthat/_snaps/centrality.md @@ -24,6 +24,24 @@ i Please use `arpack_defaults()` instead. i So the function arpack_defaults(), not an object called arpack_defaults. +# hits_scores(scale = ) is deprecated but still works + + Code + res_legacy <- hits_scores(g, scale = FALSE) + Condition + Warning: + The `scale` argument of `hits_scores()` is deprecated as of igraph 3.0.0. + i Please use the `normalized` argument instead. + +--- + + Code + hits_scores(g, normalized = FALSE, scale = FALSE) + Condition + Error in `hits_scores()`: + ! Argument `normalized` of `hits_scores()` was supplied more than once. + i It was also supplied via its legacy name `scale`. + # eigen_centrality() deprecated scale argument Code diff --git a/tests/testthat/test-centrality.R b/tests/testthat/test-centrality.R index 240ac2ab849..94b24ca791c 100644 --- a/tests/testthat/test-centrality.R +++ b/tests/testthat/test-centrality.R @@ -173,6 +173,25 @@ test_that("authority_score survives stress test", { } }) +test_that("hits_scores(scale = ) is deprecated but still works", { + rlang::local_options(lifecycle_verbosity = "warning") + g <- make_star(10) + + expect_snapshot( + res_legacy <- hits_scores(g, scale = FALSE) + ) + # ARPACK starts from a random vector, so compare with a tolerance. + expect_equal( + res_legacy[c("hub", "authority")], + hits_scores(g, normalized = FALSE)[c("hub", "authority")] + ) + + expect_snapshot( + error = TRUE, + hits_scores(g, normalized = FALSE, scale = FALSE) + ) +}) + test_that("`hits_score()` works -- authority", { igraph_local_seed(42) mscale <- function(x) { @@ -1199,7 +1218,7 @@ test_that("power_centrality() covers migrated tail args and positional recovery" nodes = V(ring)[1:3], loops = FALSE, exponent = 0.2, - rescale = TRUE, + normalized = TRUE, tol = 1e-10, sparse = FALSE, weights = rep(1, 5) @@ -1207,6 +1226,19 @@ test_that("power_centrality() covers migrated tail args and positional recovery" # With unit weights the ring is symmetric and rescaled scores sum to one. expect_equal(res, rep(1 / 5, 3)) + # The legacy `rescale` name is recovered as `normalized`. + lifecycle::expect_deprecated( + res_legacy <- power_centrality( + ring, + nodes = V(ring)[1:3], + exponent = 0.2, + rescale = TRUE, + sparse = FALSE, + weights = rep(1, 5) + ) + ) + expect_equal(res_legacy, res) + # `loops` toggles the adjacency diagonal of a path with a loop on vertex 2. looped <- make_graph(c(1, 2, 2, 3, 2, 2), directed = FALSE) expect_false(isTRUE(all.equal( diff --git a/tests/testthat/test-tkplot.R b/tests/testthat/test-tkplot.R index b86df647d9c..1050285f03e 100644 --- a/tests/testthat/test-tkplot.R +++ b/tests/testthat/test-tkplot.R @@ -32,8 +32,8 @@ test_that("tk_fit() recovers positional `width`/`height` with a deprecation", { ) }) -test_that("tk_coords() covers `norm` by name", { - expect_error(tk_coords(9999, norm = TRUE), "not found") +test_that("tk_coords() covers `normalized` by name", { + expect_error(tk_coords(9999, normalized = TRUE), "not found") }) test_that("tk_coords() recovers a positional `norm` with a deprecation", { @@ -44,6 +44,14 @@ test_that("tk_coords() recovers a positional `norm` with a deprecation", { ) }) +test_that("tk_coords() recovers the legacy `norm` name with a deprecation", { + rlang::local_options(lifecycle_verbosity = "warning") + + lifecycle::expect_deprecated( + expect_error(tk_coords(9999, norm = TRUE), "not found") + ) +}) + test_that("tk_rotate() covers `degree` and `rad` by name", { expect_error(tk_rotate(9999, degree = 90), "not found") expect_error(tk_rotate(9999, rad = pi / 2), "not found") diff --git a/tools/migrations/centrality.R b/tools/migrations/centrality.R index 09b62a0fcb4..44d94eece58 100644 --- a/tools/migrations/centrality.R +++ b/tools/migrations/centrality.R @@ -116,7 +116,7 @@ migrations <- list( nodes, loops, exponent, - rescale, + rescale = normalized, tol, sparse, weights @@ -127,7 +127,7 @@ migrations <- list( ..., loops = FALSE, exponent = 1, - rescale = FALSE, + normalized = FALSE, tol = 1e-7, sparse = TRUE, weights = NULL diff --git a/tools/migrations/plotting.R b/tools/migrations/plotting.R index 22036c7f6a6..756ee2689a2 100644 --- a/tools/migrations/plotting.R +++ b/tools/migrations/plotting.R @@ -46,11 +46,11 @@ migrations <- list( ), tk_coords = list( - old = function(tkp.id, norm) {}, + old = function(tkp.id, norm = normalized) {}, new = function( tkp.id, ..., - norm = FALSE + normalized = FALSE ) {}, when = "3.0.0" ), From 1733f27f582bc8d4989007c14315e2e1dfeabfca Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 17 Aug 2026 18:40:11 +0000 Subject: [PATCH 5/6] refactor: Purge legacy alias formals via the migration registry (#2788) `layout_with_fr(maxiter = )` folds into the registry as a rename to `niter` (the alias was silent before, now it soft-deprecates), `layout_with_kk(start = )` gains its missing soft-deprecation, `cluster_leiden()` joins the registry with `resolution_parameter` recovered as `resolution`, and the long-dead `neimode`/`father` formals and result aliases of `bfs()`/`dfs()` are removed. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01RTPj4qNv2FWui6etixZeuR --- R/community.R | 56 ++++++++++++--- R/layout.R | 28 +++----- R/structural-properties.R | 72 +++---------------- man/bfs.Rd | 14 +--- man/cluster_leiden.Rd | 3 - man/dfs.Rd | 14 +--- man/graph.bfs.Rd | 6 +- man/graph.dfs.Rd | 6 +- man/layout_with_fr.Rd | 5 +- man/layout_with_kk.Rd | 2 +- tests/testthat/_snaps/community.md | 10 +++ .../testthat/_snaps/structural-properties.md | 24 +++---- tests/testthat/test-community.R | 15 ++++ tools/migrations/community.R | 25 +++++++ tools/migrations/layout.R | 5 +- 15 files changed, 134 insertions(+), 151 deletions(-) diff --git a/R/community.R b/R/community.R index 7218fdcfe58..750634847ee 100644 --- a/R/community.R +++ b/R/community.R @@ -1758,7 +1758,6 @@ cluster_spinglass <- function( #' @param resolution The resolution parameter to use. Higher #' resolutions lead to more smaller communities, while lower resolutions lead #' to fewer larger communities. -#' @param resolution_parameter `r lifecycle::badge("superseded")` Use `resolution` instead. #' @param beta Parameter affecting the randomness in the Leiden algorithm. #' This affects only the refinement step of the algorithm. #' @param initial_membership If provided, the Leiden algorithm @@ -1809,22 +1808,57 @@ cluster_leiden <- function( ..., weights = NULL, resolution = 1, - resolution_parameter = deprecated(), beta = 0.01, initial_membership = NULL, n_iterations = 2, vertex_weights = NULL ) { - check_dots_empty() - - if (lifecycle::is_present(resolution_parameter)) { - lifecycle::deprecate_warn( - "2.1.0", - "cluster_leiden(resolution_parameter)", - "cluster_leiden(resolution)" - ) - resolution <- resolution_parameter + # BEGIN GENERATED ARG_HANDLE: cluster_leiden, do not edit, see tools/generate-migrations.R + # fmt: skip + if (...length() > 0L) { + .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("r", "re", "res", "reso", "resol", "resolu", "resolut", "resoluti", "resolutio")) + if (base::length(.arg_ambiguous) > 0L) cli::cli_abort("Argument {.arg {(.arg_ambiguous[[1L]])}} matches multiple arguments of {.fn cluster_leiden}.") + # Pre-3.0.0 signature: cluster_leiden(graph, objective_function, weights, resolution_parameter, beta, initial_membership, n_iterations, vertex_weights) + .old_signature <- function(weights, resolution_parameter, beta, initial_membership, n_iterations, vertex_weights, ...) { + if (...length() > 0L) { + .arg_extra <- base::names(base::substitute(...())) + .arg_extra <- .arg_extra[base::nzchar(.arg_extra)] + if (base::length(.arg_extra) == 0L) cli::cli_abort("Too many arguments passed to {.fn cluster_leiden}.", call = base::parent.frame()) + cli::cli_abort(base::c("Unexpected argument passed to {.fn cluster_leiden}: {.arg {(.arg_extra)}}.", i = "Arguments after {.arg ...} must be spelled out in full."), call = base::parent.frame()) + } + base::c( + if (!base::missing(weights)) base::list(weights = weights), + if (!base::missing(resolution_parameter)) base::list(resolution = resolution_parameter), + if (!base::missing(beta)) base::list(beta = beta), + if (!base::missing(initial_membership)) base::list(initial_membership = initial_membership), + if (!base::missing(n_iterations)) base::list(n_iterations = n_iterations), + if (!base::missing(vertex_weights)) base::list(vertex_weights = vertex_weights) + ) + } + .arg_handle <- .old_signature(...) + if (base::length(.arg_handle) > 0L) { + .arg_names <- base::names(.arg_handle) + .arg_conflict <- base::intersect(.arg_names, base::c( + if (!base::missing(weights)) "weights", + if (!base::missing(resolution)) "resolution", + if (!base::missing(beta)) "beta", + if (!base::missing(initial_membership)) "initial_membership", + if (!base::missing(n_iterations)) "n_iterations", + if (!base::missing(vertex_weights)) "vertex_weights" + )) + if (base::length(.arg_conflict) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn cluster_leiden} was supplied more than once.", i = "Pass it exactly once, by its new name {.arg {(.arg_conflict)}}.")) + base::list2env(.arg_handle, base::environment()) + lifecycle::deprecate_soft( + "3.0.0", + what = base::I("Calling `cluster_leiden()` with positional or abbreviated arguments"), + details = base::c( + i = base::paste0("Detected call: cluster_leiden(", base::paste(base::c("graph", "objective_function", base::c(weights = "weights", resolution = "resolution_parameter", beta = "beta", initial_membership = "initial_membership", n_iterations = "n_iterations", vertex_weights = "vertex_weights")[.arg_names]), collapse = ", "), ")"), + i = base::paste0("Use instead: cluster_leiden(", base::paste(base::c("graph", "objective_function", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + ) + ) + } } + # END GENERATED ARG_HANDLE ensure_igraph(graph) diff --git a/R/layout.R b/R/layout.R index 5c028fe8959..f23edb879b9 100644 --- a/R/layout.R +++ b/R/layout.R @@ -1766,7 +1766,6 @@ with_dh <- function(...) layout_spec(layout_with_dh, ...) #' @param coolexp,maxdelta,area,repulserad `r lifecycle::badge("deprecated")` These #' arguments are not supported from igraph version 0.8.0 and are ignored #' (with a warning). -#' @param maxiter A deprecated synonym of `niter`, for compatibility. #' @return A two- or three-column matrix, each row giving the coordinates of a #' vertex, according to the IDs of the vertex IDs. #' @author Gabor Csardi \email{csardi.gabor@@gmail.com} @@ -1817,15 +1816,14 @@ layout_with_fr <- function( coolexp = deprecated(), maxdelta = deprecated(), area = deprecated(), - repulserad = deprecated(), - maxiter = deprecated() + repulserad = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: layout_with_fr, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("g", "gr")) if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn layout_with_fr}.", i = "Spell out the full argument name.")) - .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("c", "co", "coo", "m", "mi", "min", "ma", "max")) + .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("m", "ma", "max", "c", "co", "coo", "mi", "min")) if (base::length(.arg_ambiguous) > 0L) cli::cli_abort("Argument {.arg {(.arg_ambiguous[[1L]])}} matches multiple arguments of {.fn layout_with_fr}.") # Pre-3.0.0 signature: layout_with_fr(graph, coords, dim, niter, start.temp, grid, weights, minx, maxx, miny, maxy, minz, maxz, coolexp, maxdelta, area, repulserad, maxiter) .old_signature <- function(coords, dim, niter, start.temp, grid, weights, minx, maxx, miny, maxy, minz, maxz, coolexp, maxdelta, area, repulserad, maxiter, ...) { @@ -1852,7 +1850,7 @@ layout_with_fr <- function( if (!base::missing(maxdelta)) base::list(maxdelta = maxdelta), if (!base::missing(area)) base::list(area = area), if (!base::missing(repulserad)) base::list(repulserad = repulserad), - if (!base::missing(maxiter)) base::list(maxiter = maxiter) + if (!base::missing(maxiter)) base::list(niter = maxiter) ) } .arg_handle <- .old_signature(...) @@ -1875,7 +1873,7 @@ layout_with_fr <- function( if (!base::missing(maxdelta)) "maxdelta", if (!base::missing(area)) "area", if (!base::missing(repulserad)) "repulserad", - if (!base::missing(maxiter)) "maxiter" + if (!base::missing(niter)) "niter" )) if (base::length(.arg_conflict) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn layout_with_fr} was supplied more than once.", i = "Pass it exactly once, by its new name {.arg {(.arg_conflict)}}.")) base::list2env(.arg_handle, base::environment()) @@ -1883,7 +1881,7 @@ layout_with_fr <- function( "3.0.0", what = base::I("Calling `layout_with_fr()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: layout_with_fr(", base::paste(base::c("graph", .arg_names), collapse = ", "), ")"), + i = base::paste0("Detected call: layout_with_fr(", base::paste(base::c("graph", base::c(coords = "coords", dim = "dim", niter = "niter", start.temp = "start.temp", grid = "grid", weights = "weights", minx = "minx", maxx = "maxx", miny = "miny", maxy = "maxy", minz = "minz", maxz = "maxz", coolexp = "coolexp", maxdelta = "maxdelta", area = "area", repulserad = "repulserad", niter = "maxiter")[.arg_names]), collapse = ", "), ")"), i = base::paste0("Use instead: layout_with_fr(", base::paste(base::c("graph", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) @@ -1899,15 +1897,6 @@ layout_with_fr <- function( coords[] <- as.numeric(coords) dim <- igraph_match_arg(dim) - if (!missing(niter) && !missing(maxiter)) { - cli::cli_abort(c( - "{.arg niter} and {.arg maxiter} must not be specified at the same time.", - i = "Specify only {.arg niter}, {.arg maxiter} is deprecated." - )) - } - if (!missing(maxiter)) { - niter <- maxiter - } niter <- as.numeric(niter) start.temp <- as.numeric(start.temp) @@ -2322,7 +2311,7 @@ with_graphopt <- function(...) layout_spec(layout_with_graphopt, ...) #' \sQuote{z} coordinates. #' @param niter,sigma,initemp,coolexp `r lifecycle::badge("deprecated")` These #' arguments are not supported from igraph version 0.8.0 and are ignored (with a warning). -#' @param start Deprecated synonym for `coords`, for compatibility. +#' @param start `r lifecycle::badge("deprecated")` Use `coords` instead. #' @return A numeric matrix with two (dim=2) or three (dim=3) columns, and as #' many rows as the number of vertices, the x, y and potentially z coordinates #' of the vertices. @@ -2445,6 +2434,11 @@ layout_with_kk <- function( )) } if (!missing(start)) { + lifecycle::deprecate_soft( + "3.0.0", + "layout_with_kk(start = )", + "layout_with_kk(coords = )" + ) coords <- start } diff --git a/R/structural-properties.R b/R/structural-properties.R index 36b37f0e397..7790956ce80 100644 --- a/R/structural-properties.R +++ b/R/structural-properties.R @@ -461,8 +461,7 @@ graph.dfs <- function( in.callback = NULL, out.callback = NULL, extra = NULL, - rho = parent.frame(), - neimode + rho = parent.frame() ) { # nocov start lifecycle::deprecate_warn("2.0.0", "graph.dfs()", "dfs()") @@ -478,8 +477,7 @@ graph.dfs <- function( in.callback = in.callback, out.callback = out.callback, extra = extra, - rho = rho, - neimode = neimode + rho = rho ) } # nocov end @@ -540,8 +538,7 @@ graph.bfs <- function( dist = FALSE, callback = NULL, extra = NULL, - rho = parent.frame(), - neimode + rho = parent.frame() ) { # nocov start lifecycle::deprecate_warn("2.0.0", "graph.bfs()", "bfs()") @@ -559,8 +556,7 @@ graph.bfs <- function( dist = dist, callback = callback, extra = extra, - rho = rho, - neimode = neimode + rho = rho ) } # nocov end @@ -3642,7 +3638,6 @@ count_loops <- function(graph) { #' given vertices. #' @param order Logical, whether to return the ordering of the vertices. #' @param rank Logical, whether to return the rank of the vertices. -#' @param father `r lifecycle::badge("deprecated")` Use `parent` instead. #' @param parent Logical, whether to return the parent of the vertices. #' @param pred Logical, whether to return the predecessors of the #' vertices. @@ -3657,8 +3652,6 @@ count_loops <- function(graph) { #' @param extra Additional argument to supply to the callback function. #' @param rho The environment in which the callback function is evaluated. #' The default `NULL` uses the caller's environment. -#' @param neimode `r lifecycle::badge("deprecated")` This argument is deprecated -#' from igraph 1.3.0; use `mode` instead. #' @inheritParams rlang::args_dots_empty #' @return A named list with the following entries: #' \describe{ @@ -3666,7 +3659,7 @@ count_loops <- function(graph) { #' Numeric vector. The root vertex (or vertices) that was used as the #' starting point of the search, as supplied in the `root` argument. #' } -#' \item{neimode}{ +#' \item{mode}{ #' Character scalar. The `mode` argument of the function call. #' Note that for undirected graphs this is always \sQuote{all}, irrespectively of the supplied value. #' } @@ -3683,9 +3676,6 @@ count_loops <- function(graph) { #' A vertex sequence (`igraph.vs`), or a numeric vector if the #' `return.vs.es` option is `FALSE`. #' } -#' \item{father}{ -#' Like parent, kept for compatibility for now. -#' } #' \item{pred}{ #' The previously visited vertex for each vertex, or 0 if there was no such vertex. #' A vertex sequence (`igraph.vs`), or a numeric vector if the @@ -3751,9 +3741,7 @@ bfs <- function( dist = FALSE, callback = NULL, extra = NULL, - rho = NULL, - neimode = deprecated(), - father = deprecated() + rho = NULL ) { rlang::check_dots_empty() @@ -3763,18 +3751,6 @@ bfs <- function( rho <- parent.frame() } - if (lifecycle::is_present(neimode)) { - lifecycle::deprecate_stop( - "1.3.0", - "bfs(neimode = )", - "bfs(mode = )" - ) - } - - if (lifecycle::is_present(father)) { - lifecycle::deprecate_stop("2.2.0", "bfs(father = )", "bfs(parent = )") - } - if (length(root) == 1) { root <- as_igraph_vs(graph, root) - 1 roots <- NULL @@ -3827,9 +3803,6 @@ bfs <- function( # https://github.com/igraph/rigraph/issues/1639 res$root <- requested_roots - # Remove in 1.4.0 - res$neimode <- res$mode - if (order) { res$order <- res$order + 1 } @@ -3885,9 +3858,6 @@ bfs <- function( res$dist[is.nan(res$dist)] <- -3 } - # Remove this later? https://github.com/igraph/rigraph/issues/1576 - res$father <- res$parent - res } @@ -3927,7 +3897,6 @@ bfs <- function( #' vertices. #' @param order.out Logical, whether to return the ordering based on #' leaving the subtree of the vertex. -#' @param father `r lifecycle::badge("deprecated")`, use `parent` instead. #' @param parent Logical, whether to return the parent of the vertices. #' @param dist Logical, whether to return the distance from the root of #' the search tree. @@ -3941,15 +3910,13 @@ bfs <- function( #' @param extra Additional argument to supply to the callback function. #' @param rho The environment in which the callback function is evaluated. #' The default `NULL` uses the caller's environment. -#' @param neimode `r lifecycle::badge("deprecated")` This argument is deprecated from igraph 1.3.0; use -#' `mode` instead. #' @inheritParams rlang::args_dots_empty #' @return A named list with the following entries: #' \describe{ #' \item{root}{ #' Numeric scalar. The root vertex that was used as the starting point of the search. #' } -#' \item{neimode}{ +#' \item{mode}{ #' Character scalar. The `mode` argument of the function call. #' Note that for undirected graphs this is always \sQuote{all}, irrespectively of the supplied value. #' } @@ -3962,9 +3929,6 @@ bfs <- function( #' \item{parent}{ #' Numeric vector. The parent of each vertex, i.e. the vertex it was discovered from. #' } -#' \item{father}{ -#' Like parent, kept for compatibility for now. -#' } #' \item{dist}{ #' Numeric vector, for each vertex its distance from the root of the search tree. #' } @@ -4028,9 +3992,7 @@ dfs <- function( in.callback = NULL, out.callback = NULL, extra = NULL, - rho = NULL, - neimode = deprecated(), - father = deprecated() + rho = NULL ) { rlang::check_dots_empty() @@ -4039,18 +4001,6 @@ dfs <- function( rho <- parent.frame() } - if (lifecycle::is_present(neimode)) { - lifecycle::deprecate_stop( - "1.3.0", - "dfs(neimode = )", - "dfs(mode = )" - ) - } - - if (lifecycle::is_present(father)) { - lifecycle::deprecate_stop("2.2.0", "dfs(father = )", "dfs(parent = )") - } - root <- as_igraph_vs(graph, root) - 1 mode <- switch( igraph_match_arg(mode), @@ -4084,9 +4034,6 @@ dfs <- function( rho ) - # Remove in 1.4.0 - res$neimode <- res$mode - if (order) { res$order <- res$order + 1 } @@ -4119,9 +4066,6 @@ dfs <- function( if (dist) names(res$dist) <- V(graph)$name } - # Remove this later? https://github.com/igraph/rigraph/issues/1576 - res$father <- res$parent - res } diff --git a/man/bfs.Rd b/man/bfs.Rd index b18e9a28f94..9dc75241f63 100644 --- a/man/bfs.Rd +++ b/man/bfs.Rd @@ -19,9 +19,7 @@ bfs( dist = FALSE, callback = NULL, extra = NULL, - rho = NULL, - neimode = deprecated(), - father = deprecated() + rho = NULL ) } \arguments{ @@ -73,11 +71,6 @@ Default: \code{NULL}.} \item{rho}{The environment in which the callback function is evaluated. The default \code{NULL} uses the caller's environment.} - -\item{neimode}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} This argument is deprecated -from igraph 1.3.0; use \code{mode} instead.} - -\item{father}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{parent} instead.} } \value{ A named list with the following entries: @@ -86,7 +79,7 @@ A named list with the following entries: Numeric vector. The root vertex (or vertices) that was used as the starting point of the search, as supplied in the \code{root} argument. } -\item{neimode}{ +\item{mode}{ Character scalar. The \code{mode} argument of the function call. Note that for undirected graphs this is always \sQuote{all}, irrespectively of the supplied value. } @@ -103,9 +96,6 @@ The parent of each vertex, i.e. the vertex it was discovered from. A vertex sequence (\code{igraph.vs}), or a numeric vector if the \code{return.vs.es} option is \code{FALSE}. } -\item{father}{ -Like parent, kept for compatibility for now. -} \item{pred}{ The previously visited vertex for each vertex, or 0 if there was no such vertex. A vertex sequence (\code{igraph.vs}), or a numeric vector if the diff --git a/man/cluster_leiden.Rd b/man/cluster_leiden.Rd index cb4b00aacef..95d3cee34d3 100644 --- a/man/cluster_leiden.Rd +++ b/man/cluster_leiden.Rd @@ -11,7 +11,6 @@ cluster_leiden( ..., weights = NULL, resolution = 1, - resolution_parameter = deprecated(), beta = 0.01, initial_membership = NULL, n_iterations = 2, @@ -38,8 +37,6 @@ edge weight means a stronger connection for this function.} resolutions lead to more smaller communities, while lower resolutions lead to fewer larger communities.} -\item{resolution_parameter}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}} Use \code{resolution} instead.} - \item{beta}{Parameter affecting the randomness in the Leiden algorithm. This affects only the refinement step of the algorithm.} diff --git a/man/dfs.Rd b/man/dfs.Rd index 5364bfd8605..583fb7ee63c 100644 --- a/man/dfs.Rd +++ b/man/dfs.Rd @@ -17,9 +17,7 @@ dfs( in.callback = NULL, out.callback = NULL, extra = NULL, - rho = NULL, - neimode = deprecated(), - father = deprecated() + rho = NULL ) } \arguments{ @@ -63,11 +61,6 @@ Default: \code{NULL}.} \item{rho}{The environment in which the callback function is evaluated. The default \code{NULL} uses the caller's environment.} - -\item{neimode}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} This argument is deprecated from igraph 1.3.0; use -\code{mode} instead.} - -\item{father}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}, use \code{parent} instead.} } \value{ A named list with the following entries: @@ -75,7 +68,7 @@ A named list with the following entries: \item{root}{ Numeric scalar. The root vertex that was used as the starting point of the search. } -\item{neimode}{ +\item{mode}{ Character scalar. The \code{mode} argument of the function call. Note that for undirected graphs this is always \sQuote{all}, irrespectively of the supplied value. } @@ -88,9 +81,6 @@ Numeric vector, the vertex IDs, in the order of the completion of their subtree. \item{parent}{ Numeric vector. The parent of each vertex, i.e. the vertex it was discovered from. } -\item{father}{ -Like parent, kept for compatibility for now. -} \item{dist}{ Numeric vector, for each vertex its distance from the root of the search tree. } diff --git a/man/graph.bfs.Rd b/man/graph.bfs.Rd index 56642407ca8..5b402308d08 100644 --- a/man/graph.bfs.Rd +++ b/man/graph.bfs.Rd @@ -18,8 +18,7 @@ graph.bfs( dist = FALSE, callback = NULL, extra = NULL, - rho = parent.frame(), - neimode + rho = parent.frame() ) } \arguments{ @@ -69,9 +68,6 @@ Default: \code{NULL}.} \item{rho}{The environment in which the callback function is evaluated. The default \code{NULL} uses the caller's environment.} - -\item{neimode}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} This argument is deprecated -from igraph 1.3.0; use \code{mode} 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/graph.dfs.Rd b/man/graph.dfs.Rd index cdb45188a12..dfa73f18c80 100644 --- a/man/graph.dfs.Rd +++ b/man/graph.dfs.Rd @@ -16,8 +16,7 @@ graph.dfs( in.callback = NULL, out.callback = NULL, extra = NULL, - rho = parent.frame(), - neimode + rho = parent.frame() ) } \arguments{ @@ -59,9 +58,6 @@ Default: \code{NULL}.} \item{rho}{The environment in which the callback function is evaluated. The default \code{NULL} uses the caller's environment.} - -\item{neimode}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} This argument is deprecated from igraph 1.3.0; use -\code{mode} 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/layout_with_fr.Rd b/man/layout_with_fr.Rd index 90f32995dcd..a13c6cb8ace 100644 --- a/man/layout_with_fr.Rd +++ b/man/layout_with_fr.Rd @@ -23,8 +23,7 @@ layout_with_fr( coolexp = deprecated(), maxdelta = deprecated(), area = deprecated(), - repulserad = deprecated(), - maxiter = deprecated() + repulserad = deprecated() ) with_fr(...) @@ -82,8 +81,6 @@ Default: \code{NULL}.} \item{coolexp, maxdelta, area, repulserad}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} These arguments are not supported from igraph version 0.8.0 and are ignored (with a warning).} - -\item{maxiter}{A deprecated synonym of \code{niter}, for compatibility.} } \value{ A two- or three-column matrix, each row giving the coordinates of a diff --git a/man/layout_with_kk.Rd b/man/layout_with_kk.Rd index 7d9d6dfda7b..ed47e74bf4e 100644 --- a/man/layout_with_kk.Rd +++ b/man/layout_with_kk.Rd @@ -80,7 +80,7 @@ Default: \code{NULL}.} \item{niter, sigma, initemp, coolexp}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} These arguments are not supported from igraph version 0.8.0 and are ignored (with a warning).} -\item{start}{Deprecated synonym for \code{coords}, for compatibility.} +\item{start}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{coords} instead.} } \value{ A numeric matrix with two (dim=2) or three (dim=3) columns, and as diff --git a/tests/testthat/_snaps/community.md b/tests/testthat/_snaps/community.md index b9b5d32ceed..0413f88a9d7 100644 --- a/tests/testthat/_snaps/community.md +++ b/tests/testthat/_snaps/community.md @@ -1,3 +1,13 @@ +# cluster_leiden() recovers the renamed resolution_parameter argument + + Code + res <- cluster_leiden(g, "modularity", resolution_parameter = 1.5) + Condition + Warning: + Calling `cluster_leiden()` with positional or abbreviated arguments was deprecated in igraph 3.0.0. + i Detected call: cluster_leiden(graph, objective_function, resolution_parameter) + i Use instead: cluster_leiden(graph, objective_function, resolution = ) + # modularity_matrix no longer accepts a membership argument for compatibility Code diff --git a/tests/testthat/_snaps/structural-properties.md b/tests/testthat/_snaps/structural-properties.md index e006e10afcb..13b5bc079bf 100644 --- a/tests/testthat/_snaps/structural-properties.md +++ b/tests/testthat/_snaps/structural-properties.md @@ -3,9 +3,11 @@ Code d <- dfs(g, root = 2, unreachable = FALSE, neimode = "out", father = TRUE) Condition - Error: - ! The `neimode` argument of `dfs()` was deprecated in igraph 1.3.0 and is now defunct. - i Please use the `mode` argument instead. + Error in `dfs()`: + ! `...` must be empty. + x Problematic arguments: + * neimode = "out" + * father = TRUE # bfs() works @@ -47,14 +49,6 @@ a b c z d -1 0 1 -1 -1 - $neimode - [1] "out" - - $father - + 5/5 vertices, named: - a b c z d - b - # bfs() deprecated arguments @@ -62,9 +56,11 @@ b <- bfs(g, root = 2, neimode = "out", unreachable = FALSE, order = TRUE, rank = TRUE, father = TRUE, pred = TRUE, succ = TRUE, dist = TRUE) Condition - Error: - ! The `neimode` argument of `bfs()` was deprecated in igraph 1.3.0 and is now defunct. - i Please use the `mode` argument instead. + Error in `bfs()`: + ! `...` must be empty. + x Problematic arguments: + * neimode = "out" + * father = TRUE # laplacian_matrix() works diff --git a/tests/testthat/test-community.R b/tests/testthat/test-community.R index df5bdf71efd..5ac42b57548 100644 --- a/tests/testthat/test-community.R +++ b/tests/testthat/test-community.R @@ -455,6 +455,21 @@ test_that("cluster_leiden works", { ) }) +test_that("cluster_leiden() recovers the renamed resolution_parameter argument", { + g <- make_graph("Zachary") + + rlang::local_options(lifecycle_verbosity = "warning") + igraph_with_seed(42, { + expect_snapshot( + res <- cluster_leiden(g, "modularity", resolution_parameter = 1.5) + ) + }) + igraph_with_seed(42, { + ref <- cluster_leiden(g, "modularity", resolution = 1.5) + }) + expect_equal(res, ref) +}) + test_that("modularity_matrix works", { karate <- make_graph("zachary") diff --git a/tools/migrations/community.R b/tools/migrations/community.R index 3dd8eade1e9..94641d39add 100644 --- a/tools/migrations/community.R +++ b/tools/migrations/community.R @@ -60,6 +60,31 @@ migrations <- list( when = "3.0.0" ), + cluster_leiden = list( + old = function( + graph, + objective_function, + weights, + resolution_parameter = resolution, + beta, + initial_membership, + n_iterations, + vertex_weights + ) {}, + new = function( + graph, + objective_function = c("CPM", "modularity"), + ..., + weights = NULL, + resolution = 1, + beta = 0.01, + initial_membership = NULL, + n_iterations = 2, + vertex_weights = NULL + ) {}, + when = "3.0.0" + ), + cluster_louvain = list( old = function(graph, weights, resolution) {}, new = function( diff --git a/tools/migrations/layout.R b/tools/migrations/layout.R index b9ac4be5254..fd76e224954 100644 --- a/tools/migrations/layout.R +++ b/tools/migrations/layout.R @@ -125,7 +125,7 @@ migrations <- list( maxdelta, area, repulserad, - maxiter + maxiter = niter ) {}, new = function( graph, @@ -145,8 +145,7 @@ migrations <- list( coolexp = deprecated(), maxdelta = deprecated(), area = deprecated(), - repulserad = deprecated(), - maxiter = deprecated() + repulserad = deprecated() ) {}, when = "3.0.0" ), From c597e14338c15f30513b04b66235ed29d5a62242 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 17 Aug 2026 19:12:46 +0000 Subject: [PATCH 6/6] refactor: Rename vertex-selector arguments to `vertices` (#2788, #692) The subset selectors `v`, `vids` and `nodes` unify on `vertices` across 24 functions, implementing the #692 scheme: `vertices` selects a subset, `n` counts (previous PR), and single-vertex arguments keep `v` (`neighbors()`, `incident()`, `subcomponent()`). Head selectors keep positional calls working and recover named legacy spellings via surviving sentinel formals; tail selectors ride the registry recovery. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01RTPj4qNv2FWui6etixZeuR --- R/centrality.R | 286 ++++++++++----- R/cocitation.R | 67 +++- R/cohesive.blocks.R | 2 +- R/efficiency.R | 35 +- R/indexing.R | 4 +- R/interface.R | 82 ++++- R/scan.R | 7 +- R/similarity.R | 47 ++- R/structural-properties.R | 347 +++++++++++++----- R/topology.R | 26 +- R/triangles.R | 30 +- man/adjacent.triangles.Rd | 4 +- man/adjacent_vertices.Rd | 12 +- man/alpha.centrality.Rd | 4 +- man/alpha_centrality.Rd | 9 +- man/betweenness.Rd | 13 +- man/bonpow.Rd | 3 +- man/closeness.Rd | 11 +- man/cocitation.Rd | 18 +- man/constraint.Rd | 6 +- man/count_triangles.Rd | 8 +- man/degree.Rd | 16 +- man/delete.vertices.Rd | 2 +- man/delete_vertices.Rd | 6 +- man/distances.Rd | 16 +- man/diversity.Rd | 4 +- man/ego.Rd | 34 +- man/estimate_closeness.Rd | 3 +- man/global_efficiency.Rd | 9 +- man/graph.diversity.Rd | 4 +- man/graph.knn.Rd | 5 +- man/graph.neighborhood.Rd | 3 +- man/graph.strength.Rd | 3 +- man/harmonic_centrality.Rd | 13 +- man/incident_edges.Rd | 12 +- man/induced.subgraph.Rd | 3 +- man/isomorphism_class.Rd | 8 +- man/knn.Rd | 11 +- man/neighborhood.size.Rd | 3 +- man/page.rank.Rd | 4 +- man/page_rank.Rd | 4 +- man/power_centrality.Rd | 13 +- man/shortest.paths.Rd | 3 +- man/similarity.Rd | 11 +- man/similarity.dice.Rd | 3 +- man/similarity.invlogweighted.Rd | 3 +- man/similarity.jaccard.Rd | 3 +- man/strength.Rd | 9 +- man/subgraph.Rd | 11 +- man/transitivity.Rd | 12 +- tests/testthat/_snaps/centrality.md | 9 + .../testthat/_snaps/structural-properties.md | 18 + tests/testthat/test-centrality.R | 71 +++- tests/testthat/test-constant-defaults.R | 22 +- tests/testthat/test-efficiency.R | 2 +- tests/testthat/test-interface.R | 25 +- tests/testthat/test-iterators.R | 2 +- tests/testthat/test-similarity.R | 2 +- tests/testthat/test-structural-properties.R | 93 ++++- tools/migrations/centrality.R | 38 +- tools/migrations/interface.R | 10 +- tools/migrations/similarity-efficiency.R | 10 +- tools/migrations/structural-properties.R | 44 ++- vignettes/igraph.Rmd | 4 +- vignettes/igraph_ES.rmd | 4 +- 65 files changed, 1125 insertions(+), 481 deletions(-) diff --git a/R/centrality.R b/R/centrality.R index 7717abf8db1..645c74f0ae7 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -28,6 +28,8 @@ subgraph.centrality <- function(graph, diag = FALSE) { #' @inheritParams page_rank #' @param algo `r lifecycle::badge("deprecated")` Use `algorithm` in #' [page_rank()] instead. +#' @param vids `r lifecycle::badge("deprecated")` Use `vertices` in +#' [page_rank()] instead. #' @keywords internal #' @export page.rank <- function( @@ -45,7 +47,7 @@ page.rank <- function( page_rank( graph = graph, algorithm = algo, - vids = vids, + vertices = vids, directed = directed, damping = damping, personalized = personalized, @@ -113,7 +115,7 @@ graph.strength <- function( lifecycle::deprecate_warn("2.0.0", "graph.strength()", "strength()") strength( graph = graph, - vids = vids, + vertices = vids, mode = mode, loops = loops, weights = weights @@ -161,12 +163,14 @@ graph.eigen <- function( #' `graph.diversity()` was renamed to [diversity()] to create a more #' consistent API. #' @inheritParams diversity +#' @param vids `r lifecycle::badge("deprecated")` Use `vertices` in +#' [diversity()] instead. #' @keywords internal #' @export graph.diversity <- function(graph, weights = NULL, vids = V(graph)) { # nocov start lifecycle::deprecate_warn("2.0.0", "graph.diversity()", "diversity()") - diversity(graph = graph, weights = weights, vids = vids) + diversity(graph = graph, weights = weights, vertices = vids) } # nocov end #' Find Eigenvector Centrality Scores of Network Positions @@ -250,7 +254,7 @@ bonpow <- function( lifecycle::deprecate_warn("2.0.0", "bonpow()", "power_centrality()") power_centrality( graph = graph, - nodes = nodes, + vertices = nodes, loops = loops, exponent = exponent, normalized = rescale, @@ -283,7 +287,7 @@ alpha.centrality <- function( lifecycle::deprecate_warn("2.0.0", "alpha.centrality()", "alpha_centrality()") alpha_centrality( graph = graph, - nodes = nodes, + vertices = nodes, alpha = alpha, loops = loops, exo = exo, @@ -340,7 +344,7 @@ estimate_betweenness <- function( betweenness( graph, - v = vids, + vertices = vids, directed = directed, cutoff = cutoff, weights = weights @@ -385,8 +389,9 @@ betweenness.estimate <- estimate_betweenness #' @aliases betweenness.estimate #' @aliases edge.betweenness.estimate #' @param graph The graph to analyze. -#' @param v The vertices for which the vertex betweenness will be calculated. -#' The default `NULL` selects all vertices. +#' @param vertices The vertices for which the vertex betweenness will be +#' calculated. The default `NULL` selects all vertices. +#' @param v `r lifecycle::badge("deprecated")` Use `vertices` instead. #' @inheritParams rlang::args_dots_empty #' @param directed Logical, whether directed paths should be considered while #' determining the shortest paths. @@ -408,7 +413,7 @@ betweenness.estimate <- estimate_betweenness #' @param cutoff The maximum shortest path length to consider when calculating #' betweenness. If negative, then there is no such limit. #' @return A numeric vector with the betweenness score for each vertex in -#' `v` for `betweenness()`. +#' `vertices` for `betweenness()`. #' #' A numeric vector with the edge betweenness score for each edge in `e` #' for `edge_betweenness()`. @@ -435,12 +440,13 @@ betweenness.estimate <- estimate_betweenness #' betweenness <- function( graph, - v = NULL, + vertices = NULL, ..., directed = TRUE, weights = NULL, normalized = FALSE, - cutoff = -1 + cutoff = -1, + v = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: betweenness, do not edit, see tools/generate-migrations.R # fmt: skip @@ -475,21 +481,36 @@ betweenness <- function( "3.0.0", what = base::I("Calling `betweenness()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: betweenness(", base::paste(base::c("graph", "v", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: betweenness(", base::paste(base::c("graph", "v", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: betweenness(", base::paste(base::c("graph", "vertices", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: betweenness(", base::paste(base::c("graph", "vertices", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE - if (is.null(v)) { - v <- V(graph) + if (lifecycle::is_present(v)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn betweenness} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg v}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "betweenness(v = )", + "betweenness(vertices = )" + ) + vertices <- v + } + + if (is.null(vertices)) { + vertices <- V(graph) } res <- betweenness_cutoff_impl( graph = graph, - vids = v, + vids = vertices, directed = directed, weights = weights, cutoff = cutoff @@ -632,8 +653,9 @@ edge.betweenness.estimate <- estimate_edge_betweenness #' #' @aliases closeness.estimate #' @param graph The graph to analyze. -#' @param vids The vertices for which closeness will be calculated. +#' @param vertices The vertices for which closeness will be calculated. #' The default `NULL` selects all vertices. +#' @param vids `r lifecycle::badge("deprecated")` Use `vertices` instead. #' @inheritParams rlang::args_dots_empty #' @param mode Character string, defined the types of the paths used for #' measuring the distance in directed graphs. \dQuote{in} measures the paths @@ -651,7 +673,7 @@ edge.betweenness.estimate <- estimate_edge_betweenness #' @param cutoff The maximum path length to consider when calculating the #' closeness. If zero or negative then there is no such limit. #' @return Numeric vector with the closeness values of all the vertices in -#' `v`. +#' `vertices`. #' @author Gabor Csardi \email{csardi.gabor@@gmail.com} #' @references Freeman, L.C. (1979). Centrality in Social Networks I: #' Conceptual Clarification. *Social Networks*, 1, 215-239. @@ -669,16 +691,19 @@ edge.betweenness.estimate <- estimate_edge_betweenness #' closeness <- function( graph, - vids = NULL, + vertices = NULL, ..., mode = c("out", "in", "all", "total"), weights = NULL, normalized = FALSE, - cutoff = -1 + cutoff = -1, + vids = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: closeness, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { + .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("v")) + if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn closeness}.", i = "Spell out the full argument name.")) # Pre-3.0.0 signature: closeness(graph, vids, mode, weights, normalized, cutoff) .old_signature <- function(mode, weights, normalized, cutoff, ...) { if (...length() > 0L) { @@ -709,21 +734,36 @@ closeness <- function( "3.0.0", what = base::I("Calling `closeness()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: closeness(", base::paste(base::c("graph", "vids", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: closeness(", base::paste(base::c("graph", "vids", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: closeness(", base::paste(base::c("graph", "vertices", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: closeness(", base::paste(base::c("graph", "vertices", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE - if (is.null(vids)) { - vids <- V(graph) + if (lifecycle::is_present(vids)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn closeness} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg vids}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "closeness(vids = )", + "closeness(vertices = )" + ) + vertices <- vids + } + + if (is.null(vertices)) { + vertices <- V(graph) } closeness_cutoff_impl( graph = graph, - vids = vids, + vids = vertices, mode = mode, weights = weights, normalized = normalized, @@ -1517,8 +1557,9 @@ eigen_centrality <- function( #' #' #' @param graph The input graph. -#' @param vids The vertices for which the strength will be calculated. +#' @param vertices The vertices for which the strength will be calculated. #' The default `NULL` selects all vertices. +#' @param vids `r lifecycle::badge("deprecated")` Use `vertices` instead. #' @inheritParams rlang::args_dots_empty #' @param mode Character string, \dQuote{out} for out-degree, \dQuote{in} for #' in-degree or \dQuote{all} for the sum of the two. For undirected graphs this @@ -1551,15 +1592,18 @@ eigen_centrality <- function( #' @export strength <- function( graph, - vids = NULL, + vertices = NULL, ..., mode = c("all", "out", "in", "total"), loops = TRUE, - weights = NULL + weights = NULL, + vids = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: strength, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { + .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("v")) + if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn strength}.", i = "Spell out the full argument name.")) # Pre-3.0.0 signature: strength(graph, vids, mode, loops, weights) .old_signature <- function(mode, loops, weights, ...) { if (...length() > 0L) { @@ -1588,21 +1632,36 @@ strength <- function( "3.0.0", what = base::I("Calling `strength()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: strength(", base::paste(base::c("graph", "vids", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: strength(", base::paste(base::c("graph", "vids", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: strength(", base::paste(base::c("graph", "vertices", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: strength(", base::paste(base::c("graph", "vertices", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE - if (is.null(vids)) { - vids <- V(graph) + if (lifecycle::is_present(vids)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn strength} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg vids}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "strength(vids = )", + "strength(vertices = )" + ) + vertices <- vids + } + + if (is.null(vertices)) { + vertices <- V(graph) } strength_impl( graph = graph, - vids = vids, + vids = vertices, mode = mode, loops = loops, weights = weights @@ -1632,7 +1691,7 @@ strength <- function( #' @param weights `NULL`, or the vector of edge weights to use for the #' computation. If `NULL`, then the \sQuote{weight} attibute is used. Note #' that this measure is not defined for unweighted graphs. -#' @param vids The vertex IDs for which to calculate the measure. +#' @param vertices The vertex IDs for which to calculate the measure. #' The default `NULL` selects all vertices. #' @return A numeric vector, its length is the number of vertices. #' @author Gabor Csardi \email{csardi.gabor@@gmail.com} @@ -1656,11 +1715,13 @@ diversity <- function( graph, ..., weights = NULL, - vids = NULL + vertices = NULL ) { # BEGIN GENERATED ARG_HANDLE: diversity, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { + .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("v")) + if (base::length(.arg_ambiguous) > 0L) cli::cli_abort("Argument {.arg {(.arg_ambiguous[[1L]])}} matches multiple arguments of {.fn diversity}.") # Pre-3.0.0 signature: diversity(graph, weights, vids) .old_signature <- function(weights, vids, ...) { if (...length() > 0L) { @@ -1671,7 +1732,7 @@ diversity <- function( } base::c( if (!base::missing(weights)) base::list(weights = weights), - if (!base::missing(vids)) base::list(vids = vids) + if (!base::missing(vids)) base::list(vertices = vids) ) } .arg_handle <- .old_signature(...) @@ -1679,7 +1740,7 @@ diversity <- function( .arg_names <- base::names(.arg_handle) .arg_conflict <- base::intersect(.arg_names, base::c( if (!base::missing(weights)) "weights", - if (!base::missing(vids)) "vids" + if (!base::missing(vertices)) "vertices" )) if (base::length(.arg_conflict) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn diversity} was supplied more than once.", i = "Pass it exactly once, by its new name {.arg {(.arg_conflict)}}.")) base::list2env(.arg_handle, base::environment()) @@ -1687,7 +1748,7 @@ diversity <- function( "3.0.0", what = base::I("Calling `diversity()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: diversity(", base::paste(base::c("graph", .arg_names), collapse = ", "), ")"), + i = base::paste0("Detected call: diversity(", base::paste(base::c("graph", base::c(weights = "weights", vertices = "vids")[.arg_names]), collapse = ", "), ")"), i = base::paste0("Use instead: diversity(", base::paste(base::c("graph", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) @@ -1695,14 +1756,14 @@ diversity <- function( } # END GENERATED ARG_HANDLE - if (is.null(vids)) { - vids <- V(graph) + if (is.null(vertices)) { + vertices <- V(graph) } diversity_impl( graph = graph, weights = weights, - vids = vids + vids = vertices ) } @@ -1913,7 +1974,7 @@ hub_score <- function( #' for all but small graphs. `"arpack"` uses the ARPACK library, the #' default implementation from igraph version 0.5 until version 0.7. It computes #' PageRank scores by solving an eingevalue problem. -#' @param vids The vertices of interest. +#' @param vertices The vertices of interest. #' The default `NULL` selects all vertices. #' @param directed Logical, if true directed paths will be considered for #' directed graphs. It is ignored for undirected graphs. @@ -1975,7 +2036,7 @@ page_rank <- function( graph, ..., algorithm = c("prpack", "arpack"), - vids = NULL, + vertices = NULL, directed = TRUE, damping = 0.85, personalized = NULL, @@ -1985,7 +2046,7 @@ page_rank <- function( # BEGIN GENERATED ARG_HANDLE: page_rank, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { - .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("a", "al", "alg", "d")) + .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("a", "al", "alg", "v", "d")) if (base::length(.arg_ambiguous) > 0L) cli::cli_abort("Argument {.arg {(.arg_ambiguous[[1L]])}} matches multiple arguments of {.fn page_rank}.") # Pre-3.0.0 signature: page_rank(graph, algo, vids, directed, damping, personalized, weights, options) .old_signature <- function(algo, vids, directed, damping, personalized, weights, options, ...) { @@ -1997,7 +2058,7 @@ page_rank <- function( } base::c( if (!base::missing(algo)) base::list(algorithm = algo), - if (!base::missing(vids)) base::list(vids = vids), + if (!base::missing(vids)) base::list(vertices = vids), if (!base::missing(directed)) base::list(directed = directed), if (!base::missing(damping)) base::list(damping = damping), if (!base::missing(personalized)) base::list(personalized = personalized), @@ -2010,7 +2071,7 @@ page_rank <- function( .arg_names <- base::names(.arg_handle) .arg_conflict <- base::intersect(.arg_names, base::c( if (!base::missing(algorithm)) "algorithm", - if (!base::missing(vids)) "vids", + if (!base::missing(vertices)) "vertices", if (!base::missing(directed)) "directed", if (!base::missing(damping)) "damping", if (!base::missing(personalized)) "personalized", @@ -2023,7 +2084,7 @@ page_rank <- function( "3.0.0", what = base::I("Calling `page_rank()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: page_rank(", base::paste(base::c("graph", base::c(algorithm = "algo", vids = "vids", directed = "directed", damping = "damping", personalized = "personalized", weights = "weights", options = "options")[.arg_names]), collapse = ", "), ")"), + i = base::paste0("Detected call: page_rank(", base::paste(base::c("graph", base::c(algorithm = "algo", vertices = "vids", directed = "directed", damping = "damping", personalized = "personalized", weights = "weights", options = "options")[.arg_names]), collapse = ", "), ")"), i = base::paste0("Use instead: page_rank(", base::paste(base::c("graph", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) @@ -2031,14 +2092,14 @@ page_rank <- function( } # END GENERATED ARG_HANDLE - if (is.null(vids)) { - vids <- V(graph) + if (is.null(vertices)) { + vertices <- V(graph) } personalized_pagerank_impl( graph = graph, algo = algorithm, - vids = vids, + vids = vertices, directed = directed, damping = damping, personalized = personalized, @@ -2058,8 +2119,9 @@ page_rank <- function( #' default), then the function calculates the exact harmonic centrality scores. #' #' @param graph The graph to analyze. -#' @param vids The vertices for which harmonic centrality will be calculated. -#' The default `NULL` selects all vertices. +#' @param vertices The vertices for which harmonic centrality will be +#' calculated. The default `NULL` selects all vertices. +#' @param vids `r lifecycle::badge("deprecated")` Use `vertices` instead. #' @inheritParams rlang::args_dots_empty #' @param mode Character string, defining the types of the paths used for #' measuring the distance in directed graphs. \dQuote{out} follows paths along @@ -2078,7 +2140,7 @@ page_rank <- function( #' harmonic centrality. There is no such limit when the cutoff is negative. Note that #' zero cutoff means that only paths of at most length 0 are considered. #' @return Numeric vector with the harmonic centrality scores of all the vertices in -#' `v`. +#' `vertices`. #' @seealso [betweenness()], [closeness()] #' @references M. Marchiori and V. Latora, Harmony in the small-world, #' *Physica A* 285, pp. 539-546 (2000). @@ -2096,16 +2158,19 @@ page_rank <- function( #' harmonic_centrality <- function( graph, - vids = NULL, + vertices = NULL, ..., mode = c("out", "in", "all", "total"), weights = NULL, normalized = FALSE, - cutoff = -1 + cutoff = -1, + vids = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: harmonic_centrality, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { + .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("v")) + if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn harmonic_centrality}.", i = "Spell out the full argument name.")) # Pre-3.0.0 signature: harmonic_centrality(graph, vids, mode, weights, normalized, cutoff) .old_signature <- function(mode, weights, normalized, cutoff, ...) { if (...length() > 0L) { @@ -2136,21 +2201,36 @@ harmonic_centrality <- function( "3.0.0", what = base::I("Calling `harmonic_centrality()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: harmonic_centrality(", base::paste(base::c("graph", "vids", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: harmonic_centrality(", base::paste(base::c("graph", "vids", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: harmonic_centrality(", base::paste(base::c("graph", "vertices", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: harmonic_centrality(", base::paste(base::c("graph", "vertices", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE - if (is.null(vids)) { - vids <- V(graph) + if (lifecycle::is_present(vids)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn harmonic_centrality} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg vids}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "harmonic_centrality(vids = )", + "harmonic_centrality(vertices = )" + ) + vertices <- vids + } + + if (is.null(vertices)) { + vertices <- V(graph) } harmonic_centrality_cutoff_impl( graph = graph, - vids = vids, + vids = vertices, mode = mode, weights = weights, normalized = normalized, @@ -2226,7 +2306,7 @@ bonpow.sparse <- function( #' Find Bonacich Power Centrality Scores of Network Positions #' #' `power_centrality()` takes a graph (`dat`) and returns the Boncich power -#' centralities of positions (selected by `nodes`). The decay rate for +#' centralities of positions (selected by `vertices`). The decay rate for #' power contributions is specified by `exponent` (1 by default). #' #' Bonacich's power centrality measure is defined by @@ -2277,8 +2357,9 @@ bonpow.sparse <- function( #' is important to think about the edge direction and what it represents. #' #' @param graph the input graph. -#' @param nodes vertex sequence indicating which vertices are to be included in -#' the calculation. The default `NULL` selects all vertices. +#' @param vertices vertex sequence indicating which vertices are to be included +#' in the calculation. The default `NULL` selects all vertices. +#' @param nodes `r lifecycle::badge("deprecated")` Use `vertices` instead. #' @inheritParams rlang::args_dots_empty #' @param loops Logical indicating whether or not the diagonal should be #' treated as valid data. Set this true if and only if the data can contain @@ -2340,20 +2421,21 @@ bonpow.sparse <- function( #' power_centrality <- function( graph, - nodes = NULL, + vertices = NULL, ..., loops = FALSE, exponent = 1, normalized = FALSE, tol = 1e-7, sparse = TRUE, - weights = NULL + weights = NULL, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: power_centrality, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { - .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("n", "no")) - if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn power_centrality}.", i = "Spell out the full argument name.")) + .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("n", "no")) + if (base::length(.arg_ambiguous) > 0L) cli::cli_abort("Argument {.arg {(.arg_ambiguous[[1L]])}} matches multiple arguments of {.fn power_centrality}.") # Pre-3.0.0 signature: power_centrality(graph, nodes, loops, exponent, rescale, tol, sparse, weights) .old_signature <- function(loops, exponent, rescale, tol, sparse, weights, ...) { if (...length() > 0L) { @@ -2388,23 +2470,38 @@ power_centrality <- function( "3.0.0", what = base::I("Calling `power_centrality()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: power_centrality(", base::paste(base::c("graph", "nodes", base::c(loops = "loops", exponent = "exponent", normalized = "rescale", tol = "tol", sparse = "sparse", weights = "weights")[.arg_names]), collapse = ", "), ")"), - i = base::paste0("Use instead: power_centrality(", base::paste(base::c("graph", "nodes", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: power_centrality(", base::paste(base::c("graph", "vertices", base::c(loops = "loops", exponent = "exponent", normalized = "rescale", tol = "tol", sparse = "sparse", weights = "weights")[.arg_names]), collapse = ", "), ")"), + i = base::paste0("Use instead: power_centrality(", base::paste(base::c("graph", "vertices", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE - if (is.null(nodes)) { - nodes <- V(graph) + if (lifecycle::is_present(nodes)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn power_centrality} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "power_centrality(nodes = )", + "power_centrality(vertices = )" + ) + vertices <- nodes + } + + if (is.null(vertices)) { + vertices <- V(graph) } - nodes <- as_igraph_vs(graph, nodes) + vertices <- as_igraph_vs(graph, vertices) if (sparse) { res <- bonpow.sparse( graph, - nodes, + vertices, loops, exponent, normalized, @@ -2414,7 +2511,7 @@ power_centrality <- function( } else { res <- bonpow.dense( graph, - nodes, + vertices, loops, exponent, normalized, @@ -2424,7 +2521,7 @@ power_centrality <- function( } if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res) <- vertex_attr(graph, "name", nodes) + names(res) <- vertex_attr(graph, "name", vertices) } res @@ -2512,9 +2609,10 @@ alpha.centrality.sparse <- function( #' #' @param graph The input graph, can be directed or undirected. In undirected #' graphs, edges are treated as if they were reciprocal directed ones. -#' @param nodes Vertex sequence, the vertices for which the alpha centrality +#' @param vertices Vertex sequence, the vertices for which the alpha centrality #' values are returned. The default `NULL` selects all vertices. #' (For technical reasons they will be calculated for all vertices, anyway.) +#' @param nodes `r lifecycle::badge("deprecated")` Use `vertices` instead. #' @inheritParams rlang::args_dots_empty #' @param alpha Parameter specifying the relative importance of endogenous #' versus exogenous factors in the determination of centrality. See details @@ -2555,14 +2653,15 @@ alpha.centrality.sparse <- function( #' alpha_centrality <- function( graph, - nodes = NULL, + vertices = NULL, ..., alpha = 1, loops = FALSE, exo = 1, weights = NULL, tol = 1e-7, - sparse = TRUE + sparse = TRUE, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: alpha_centrality, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2601,23 +2700,38 @@ alpha_centrality <- function( "3.0.0", what = base::I("Calling `alpha_centrality()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: alpha_centrality(", base::paste(base::c("graph", "nodes", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: alpha_centrality(", base::paste(base::c("graph", "nodes", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: alpha_centrality(", base::paste(base::c("graph", "vertices", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: alpha_centrality(", base::paste(base::c("graph", "vertices", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE - if (is.null(nodes)) { - nodes <- V(graph) + if (lifecycle::is_present(nodes)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn alpha_centrality} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "alpha_centrality(nodes = )", + "alpha_centrality(vertices = )" + ) + vertices <- nodes + } + + if (is.null(vertices)) { + vertices <- V(graph) } - nodes <- as_igraph_vs(graph, nodes) + vertices <- as_igraph_vs(graph, vertices) if (sparse) { res <- alpha.centrality.sparse( graph, - nodes, + vertices, alpha, loops, exo, @@ -2627,7 +2741,7 @@ alpha_centrality <- function( } else { res <- alpha.centrality.dense( graph, - nodes, + vertices, alpha, loops, exo, @@ -2636,7 +2750,7 @@ alpha_centrality <- function( ) } if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res) <- vertex_attr(graph, "name", nodes) + names(res) <- vertex_attr(graph, "name", vertices) } res } diff --git a/R/cocitation.R b/R/cocitation.R index f5c67ab2774..ff5e012d935 100644 --- a/R/cocitation.R +++ b/R/cocitation.R @@ -27,22 +27,23 @@ #' both cite, `bibcoupling()` calculates this. #' #' `cocitation()` calculates the cocitation counts for the vertices in the -#' `v` argument and all vertices in the graph. +#' `vertices` argument and all vertices in the graph. #' #' `bibcoupling()` calculates the bibliographic coupling for vertices in -#' `v` and all vertices in the graph. +#' `vertices` and all vertices in the graph. #' #' Calculating the cocitation or bibliographic coupling for only one vertex #' costs the same amount of computation as for all vertices. This might change #' in the future. #' #' @param graph The graph object to analyze -#' @param v Vertex sequence or numeric vector, the vertex IDs for which the -#' cocitation or bibliographic coupling values we want to calculate. The +#' @param vertices Vertex sequence or numeric vector, the vertex IDs for which +#' the cocitation or bibliographic coupling values we want to calculate. The #' default `NULL` selects all vertices. -#' @return A numeric matrix with `length(v)` lines and +#' @param v `r lifecycle::badge("deprecated")` Use `vertices` instead. +#' @return A numeric matrix with `length(vertices)` lines and #' `vcount(graph)` columns. Element `(i,j)` contains the cocitation -#' or bibliographic coupling for vertices `v[i]` and `j`. +#' or bibliographic coupling for vertices `vertices[i]` and `j`. #' @author Gabor Csardi \email{csardi.gabor@@gmail.com} #' @family cocitation #' @export @@ -53,18 +54,33 @@ #' cocitation(g) #' bibcoupling(g) #' -cocitation <- function(graph, v = NULL) { - if (is.null(v)) { - v <- V(graph) +cocitation <- function(graph, vertices = NULL, v = deprecated()) { + if (lifecycle::is_present(v)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn cocitation} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg v}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "cocitation(v = )", + "cocitation(vertices = )" + ) + vertices <- v + } + + if (is.null(vertices)) { + vertices <- V(graph) } res <- cocitation_impl( graph = graph, - vids = v + vids = vertices ) if (igraph_opt("add.vertex.names") && is_named(graph)) { - v <- as_igraph_vs(graph, v) - rownames(res) <- vertex_attr(graph, "name", v) + vertices <- as_igraph_vs(graph, vertices) + rownames(res) <- vertex_attr(graph, "name", vertices) colnames(res) <- vertex_attr(graph, "name") } res @@ -72,18 +88,33 @@ cocitation <- function(graph, v = NULL) { #' @rdname cocitation #' @export -bibcoupling <- function(graph, v = NULL) { - if (is.null(v)) { - v <- V(graph) +bibcoupling <- function(graph, vertices = NULL, v = deprecated()) { + if (lifecycle::is_present(v)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn bibcoupling} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg v}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "bibcoupling(v = )", + "bibcoupling(vertices = )" + ) + vertices <- v + } + + if (is.null(vertices)) { + vertices <- V(graph) } res <- bibcoupling_impl( graph = graph, - vids = v + vids = vertices ) if (igraph_opt("add.vertex.names") && is_named(graph)) { - v <- as_igraph_vs(graph, v) - rownames(res) <- vertex_attr(graph, "name", v) + vertices <- as_igraph_vs(graph, vertices) + rownames(res) <- vertex_attr(graph, "name", vertices) colnames(res) <- vertex_attr(graph, "name") } res diff --git a/R/cohesive.blocks.R b/R/cohesive.blocks.R index 18eef59d2ef..f75f842da72 100644 --- a/R/cohesive.blocks.R +++ b/R/cohesive.blocks.R @@ -472,7 +472,7 @@ print.cohesiveBlocks <- function(x, ...) { cs <- 3 + 2 + nchar(length(x)) + - max(distances(hierarchy(x), mode = "out", v = 1)) * 3 + max(distances(hierarchy(x), mode = "out", vertices = 1)) * 3 .plot <- function(b, ind = "") { if (b != 1) { diff --git a/R/efficiency.R b/R/efficiency.R index c572f7f3aa8..7d015fa3180 100644 --- a/R/efficiency.R +++ b/R/efficiency.R @@ -41,9 +41,10 @@ #' @param weights The edge weights. All edge weights must be non-negative; #' additionally, no edge weight may be NaN. If it is `NULL` (the default) #' and the graph has a `weight` edge attribute, then it is used automatically. -#' @param vids The vertex IDs of the vertices for which the calculation will be done. +#' @param vertices The vertex IDs of the vertices for which the calculation will be done. #' Applies to the local efficiency calculation only. The default `NULL` #' selects all vertices. +#' @param vids `r lifecycle::badge("deprecated")` Use `vertices` instead. #' @param directed Logical, whether to consider directed paths. Ignored #' for undirected graphs. #' @param mode Specifies how to define the local neighborhood of a vertex in @@ -123,15 +124,18 @@ global_efficiency <- function( #' @export local_efficiency <- function( graph, - vids = NULL, + vertices = NULL, ..., weights = NULL, directed = TRUE, - mode = c("all", "out", "in", "total") + mode = c("all", "out", "in", "total"), + vids = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: local_efficiency, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { + .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("v")) + if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn local_efficiency}.", i = "Spell out the full argument name.")) # Pre-3.0.0 signature: local_efficiency(graph, vids, weights, directed, mode) .old_signature <- function(weights, directed, mode, ...) { if (...length() > 0L) { @@ -160,21 +164,36 @@ local_efficiency <- function( "3.0.0", what = base::I("Calling `local_efficiency()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: local_efficiency(", base::paste(base::c("graph", "vids", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: local_efficiency(", base::paste(base::c("graph", "vids", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: local_efficiency(", base::paste(base::c("graph", "vertices", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: local_efficiency(", base::paste(base::c("graph", "vertices", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE - if (is.null(vids)) { - vids <- V(graph) + if (lifecycle::is_present(vids)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn local_efficiency} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg vids}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "local_efficiency(vids = )", + "local_efficiency(vertices = )" + ) + vertices <- vids + } + + if (is.null(vertices)) { + vertices <- V(graph) } local_efficiency_impl( graph = graph, - vids = vids, + vids = vertices, weights = weights, directed = directed, mode = mode diff --git a/R/indexing.R b/R/indexing.R index 1f61e246621..2135d3b9666 100644 --- a/R/indexing.R +++ b/R/indexing.R @@ -538,9 +538,9 @@ expand.grid.unordered <- function(i, j, loops = FALSE, directed = FALSE) { if (missing(i) && missing(j)) { todel <- seq_len(ecount(x)) } else if (missing(j)) { - todel <- unlist(incident_edges(x, v = i, mode = "out")) + todel <- unlist(incident_edges(x, vertices = i, mode = "out")) } else if (missing(i)) { - todel <- unlist(incident_edges(x, v = j, mode = "in")) + todel <- unlist(incident_edges(x, vertices = j, mode = "in")) } else { edge_pairs <- expand.grid(i, j) edge_ids <- get_edge_ids(x, c(rbind(edge_pairs[, 1], edge_pairs[, 2]))) diff --git a/R/interface.R b/R/interface.R index 59ce5d4178e..09fcbaab1f8 100644 --- a/R/interface.R +++ b/R/interface.R @@ -27,7 +27,7 @@ is.directed <- function(graph) { delete.vertices <- function(graph, v) { # nocov start lifecycle::deprecate_warn("2.0.0", "delete.vertices()", "delete_vertices()") - delete_vertices(graph = graph, v = v) + delete_vertices(graph = graph, vertices = v) } # nocov end #' Delete edges from a graph @@ -273,7 +273,8 @@ delete_edges <- function(graph, edges) { #' Delete vertices from a graph #' #' @param graph The input graph. -#' @param v The vertices to remove, a vertex sequence. +#' @param vertices The vertices to remove, a vertex sequence. +#' @param v `r lifecycle::badge("deprecated")` Use `vertices` instead. #' @return The graph, with the vertices removed. #' #' @family functions for manipulating graph structure @@ -289,10 +290,25 @@ delete_edges <- function(graph, edges) { #' delete_vertices("B") #' g2 #' V(g2) -delete_vertices <- function(graph, v) { +delete_vertices <- function(graph, vertices, v = deprecated()) { + if (lifecycle::is_present(v)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn delete_vertices} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg v}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "delete_vertices(v = )", + "delete_vertices(vertices = )" + ) + vertices <- v + } + delete_vertices_impl( graph = graph, - vertices = v + vertices = vertices ) } @@ -787,7 +803,8 @@ gorder <- vcount #' the adjacent vertices for multiple vertices at once. #' #' @param graph Input graph. -#' @param v The vertices to query. +#' @param vertices The vertices to query. +#' @param v `r lifecycle::badge("deprecated")` Use `vertices` instead. #' @inheritParams neighbors #' @inheritParams rlang::args_dots_empty #' @return A list of vertex sequences. @@ -799,9 +816,10 @@ gorder <- vcount #' adjacent_vertices(g, c(1, 34)) adjacent_vertices <- function( graph, - v, + vertices, ..., - mode = c("out", "in", "all", "total") + mode = c("out", "in", "all", "total"), + v = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: adjacent_vertices, do not edit, see tools/generate-migrations.R # fmt: skip @@ -830,17 +848,32 @@ adjacent_vertices <- function( "3.0.0", what = base::I("Calling `adjacent_vertices()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: adjacent_vertices(", base::paste(base::c("graph", "v", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: adjacent_vertices(", base::paste(base::c("graph", "v", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: adjacent_vertices(", base::paste(base::c("graph", "vertices", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: adjacent_vertices(", base::paste(base::c("graph", "vertices", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(v)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn adjacent_vertices} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg v}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "adjacent_vertices(v = )", + "adjacent_vertices(vertices = )" + ) + vertices <- v + } + ensure_igraph(graph) - vv <- as_igraph_vs(graph, v) - 1 + vv <- as_igraph_vs(graph, vertices) - 1 mode <- switch(match.arg(mode), "out" = 1, "in" = 2, "all" = 3, "total" = 3) on.exit(.Call(Rx_igraph_finalizer)) @@ -865,7 +898,8 @@ adjacent_vertices <- function( #' queries multiple vertices at once. #' #' @param graph Input graph. -#' @param v The vertices to query +#' @param vertices The vertices to query +#' @param v `r lifecycle::badge("deprecated")` Use `vertices` instead. #' @inheritParams neighbors #' @inheritParams rlang::args_dots_empty #' @return A list of edge sequences. @@ -877,9 +911,10 @@ adjacent_vertices <- function( #' incident_edges(g, c(1, 34)) incident_edges <- function( graph, - v, + vertices, ..., - mode = c("out", "in", "all", "total") + mode = c("out", "in", "all", "total"), + v = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: incident_edges, do not edit, see tools/generate-migrations.R # fmt: skip @@ -908,17 +943,32 @@ incident_edges <- function( "3.0.0", what = base::I("Calling `incident_edges()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: incident_edges(", base::paste(base::c("graph", "v", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: incident_edges(", base::paste(base::c("graph", "v", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: incident_edges(", base::paste(base::c("graph", "vertices", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: incident_edges(", base::paste(base::c("graph", "vertices", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(v)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn incident_edges} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg v}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "incident_edges(v = )", + "incident_edges(vertices = )" + ) + vertices <- v + } + ensure_igraph(graph) - vv <- as_igraph_vs(graph, v) - 1 + vv <- as_igraph_vs(graph, vertices) - 1 mode <- switch(match.arg(mode), "out" = 1, "in" = 2, "all" = 3, "total" = 3) on.exit(.Call(Rx_igraph_finalizer)) diff --git a/R/scan.R b/R/scan.R index a719650c8d1..e39b84c7e64 100644 --- a/R/scan.R +++ b/R/scan.R @@ -287,7 +287,12 @@ local_scan <- function( ## General } else { sapply(V(graph.us), function(x) { - vei <- neighborhood(graph.us, order = k, nodes = x, mode = mode)[[1]] + vei <- neighborhood( + graph.us, + order = k, + vertices = x, + mode = mode + )[[1]] if (!is.function(FUN)) { FUN <- getFunction(FUN, where = environment()) } diff --git a/R/similarity.R b/R/similarity.R index 1b4b2313b15..98743a323ef 100644 --- a/R/similarity.R +++ b/R/similarity.R @@ -26,8 +26,9 @@ #' 25(3):211-230, 2003. #' #' @param graph The input graph. -#' @param vids The vertex IDs for which the similarity is calculated. The +#' @param vertices The vertex IDs for which the similarity is calculated. The #' default `NULL` selects all vertices. +#' @param vids `r lifecycle::badge("deprecated")` Use `vertices` instead. #' @inheritParams rlang::args_dots_empty #' @param mode The type of neighboring vertices to use for the calculation, #' possible values: \sQuote{`out`}, \sQuote{`in`}, @@ -35,7 +36,7 @@ #' @param loops Whether to include vertices themselves in the neighbor #' sets. #' @param method The method to use. -#' @return A `length(vids)` by `length(vids)` numeric matrix +#' @return A `length(vertices)` by `length(vertices)` numeric matrix #' containing the similarity scores. This argument is ignored by the #' `invlogweighted` method. #' @author Tamas Nepusz \email{ntamas@@gmail.com} and Gabor Csardi @@ -53,7 +54,7 @@ #' similarity(g, method = "jaccard") similarity <- function( graph, - vids = NULL, + vertices = NULL, ..., mode = c( "all", @@ -66,11 +67,14 @@ similarity <- function( "jaccard", "dice", "invlogweighted" - ) + ), + vids = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: similarity, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { + .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("v")) + if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn similarity}.", i = "Spell out the full argument name.")) .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("m")) if (base::length(.arg_ambiguous) > 0L) cli::cli_abort("Argument {.arg {(.arg_ambiguous[[1L]])}} matches multiple arguments of {.fn similarity}.") # Pre-3.0.0 signature: similarity(graph, vids, mode, loops, method) @@ -101,37 +105,52 @@ similarity <- function( "3.0.0", what = base::I("Calling `similarity()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: similarity(", base::paste(base::c("graph", "vids", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: similarity(", base::paste(base::c("graph", "vids", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: similarity(", base::paste(base::c("graph", "vertices", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: similarity(", base::paste(base::c("graph", "vertices", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE - if (is.null(vids)) { - vids <- V(graph) + if (lifecycle::is_present(vids)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn similarity} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg vids}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "similarity(vids = )", + "similarity(vertices = )" + ) + vertices <- vids + } + + if (is.null(vertices)) { + vertices <- V(graph) } method <- igraph_match_arg(method) if (method == "jaccard") { similarity_jaccard_impl( graph = graph, - vids = vids, + vids = vertices, mode = mode, loops = loops ) } else if (method == "dice") { similarity_dice_impl( graph = graph, - vids = vids, + vids = vertices, mode = mode, loops = loops ) } else if (method == "invlogweighted") { similarity_inverse_log_weighted_impl( graph = graph, - vids = vids, + vids = vertices, mode = mode ) } @@ -161,7 +180,7 @@ similarity.jaccard <- function( similarity( graph = graph, - vids = vids, + vertices = vids, mode = mode, loops = loops, method = "jaccard" @@ -192,7 +211,7 @@ similarity.dice <- function( similarity( graph = graph, - vids = vids, + vertices = vids, mode = mode, loops = loops, method = "dice" @@ -222,7 +241,7 @@ similarity.invlogweighted <- function( similarity( graph = graph, - vids = vids, + vertices = vids, mode = mode, method = "invlogweighted" ) diff --git a/R/structural-properties.R b/R/structural-properties.R index 7790956ce80..d762068bbdc 100644 --- a/R/structural-properties.R +++ b/R/structural-properties.R @@ -154,7 +154,7 @@ shortest.paths <- function( mode <- igraph_match_arg(mode) distances( graph = graph, - v = v, + vertices = v, to = to, mode = mode, weights = weights, @@ -184,7 +184,7 @@ neighborhood.size <- function( ego_size( graph = graph, order = order, - nodes = nodes, + vertices = nodes, mode = mode, mindist = mindist ) @@ -337,7 +337,7 @@ induced.subgraph <- function( ) { # nocov start lifecycle::deprecate_warn("2.0.0", "induced.subgraph()", "induced_subgraph()") - induced_subgraph(graph = graph, vids = vids, impl = impl) + induced_subgraph(graph = graph, vertices = vids, impl = impl) } # nocov end #' Find the multiple or loop edges in a graph @@ -378,7 +378,7 @@ graph.neighborhood <- function( make_ego_graph( graph = graph, order = order, - nodes = nodes, + vertices = nodes, mode = mode, mindist = mindist ) @@ -431,7 +431,7 @@ graph.knn <- function( lifecycle::deprecate_warn("2.0.0", "graph.knn()", "knn()") knn( graph = graph, - vids = vids, + vertices = vids, mode = mode, neighbor.degree.mode = neighbor.degree.mode, weights = weights @@ -1038,8 +1038,9 @@ mean_distance <- function( #' #' #' @param graph The graph to analyze. -#' @param v The IDs of vertices of which the degree will be calculated. +#' @param vertices The IDs of vertices of which the degree will be calculated. #' The default `NULL` selects all vertices. +#' @param v `r lifecycle::badge("deprecated")` Use `vertices` instead. #' @param mode Character string, \dQuote{out} for out-degree, \dQuote{in} for #' in-degree or \dQuote{total} for the sum of the two. For undirected graphs #' this argument is ignored. \dQuote{all} is a synonym of \dQuote{total}. @@ -1049,7 +1050,7 @@ mean_distance <- function( #' number of vertices in the graph. #' @inheritParams rlang::args_dots_empty #' @return For `degree()` a numeric vector of the same length as argument -#' `v`. +#' `vertices`. #' #' For `degree_distribution()` a numeric vector of the same length as the #' maximum degree plus one. The first element is the relative frequency zero @@ -1077,11 +1078,12 @@ mean_distance <- function( #' degree <- function( graph, - v = NULL, + vertices = NULL, ..., mode = c("all", "out", "in", "total"), loops = TRUE, - normalized = FALSE + normalized = FALSE, + v = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: degree, do not edit, see tools/generate-migrations.R # fmt: skip @@ -1114,24 +1116,35 @@ degree <- function( "3.0.0", what = base::I("Calling `degree()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: degree(", base::paste(base::c("graph", "v", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: degree(", base::paste(base::c("graph", "v", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: degree(", base::paste(base::c("graph", "vertices", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: degree(", base::paste(base::c("graph", "vertices", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(v)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn degree} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg v}." + )) + } + lifecycle::deprecate_soft("3.0.0", "degree(v = )", "degree(vertices = )") + vertices <- v + } + ensure_igraph(graph) - if (is.null(v)) { - v <- V(graph) + if (is.null(vertices)) { + vertices <- V(graph) } - v <- as_igraph_vs(graph, v) + vertices <- as_igraph_vs(graph, vertices) mode <- igraph_match_arg(mode) res <- degree_impl( graph = graph, - vids = v, + vids = vertices, mode = mode, loops = loops ) @@ -1140,7 +1153,7 @@ degree <- function( res <- res / (vcount(graph) - 1) } if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res) <- V(graph)$name[v] + names(res) <- V(graph)$name[vertices] } res } @@ -1150,17 +1163,33 @@ degree <- function( max_degree <- function( graph, ..., - v = NULL, + vertices = NULL, mode = c("all", "out", "in", "total"), - loops = TRUE + loops = TRUE, + v = deprecated() ) { - if (is.null(v)) { - v <- V(graph) + if (lifecycle::is_present(v)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn max_degree} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg v}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "max_degree(v = )", + "max_degree(vertices = )" + ) + vertices <- v + } + + if (is.null(vertices)) { + vertices <- V(graph) } maxdegree_impl( graph = graph, - v = v, + v = vertices, mode = mode, loops = loops ) @@ -1294,8 +1323,9 @@ degree_distribution <- function(graph, cumulative = FALSE, ...) { #' histogram. #' #' @param graph The graph to work on. -#' @param v Numeric vector, the vertices from which the shortest paths will be -#' calculated. The default `NULL` selects all vertices. +#' @param vertices Numeric vector, the vertices from which the shortest paths +#' will be calculated. The default `NULL` selects all vertices. +#' @param v `r lifecycle::badge("deprecated")` Use `vertices` instead. #' @param to Numeric vector, the vertices to which the shortest paths will be #' calculated. The default `NULL` includes all vertices. Note that for #' `distances()` every vertex must be included here at most once. (This @@ -1332,8 +1362,9 @@ degree_distribution <- function(graph, cumulative = FALSE, ...) { #' FALSE, the length of the missing paths are considered as having infinite #' length, making the mean distance infinite as well. #' @return For `distances()` a numeric matrix with `length(to)` -#' columns and `length(v)` rows. The shortest path length from a vertex to -#' itself is always zero. For unreachable vertices `Inf` is included. +#' columns and `length(vertices)` rows. The shortest path length from a +#' vertex to itself is always zero. For unreachable vertices `Inf` is +#' included. #' #' For `shortest_paths()` a named list with four entries is returned: #' \item{vpath}{This itself is a list, of length `length(to)`; list @@ -1440,7 +1471,7 @@ degree_distribution <- function(graph, cumulative = FALSE, ...) { #' distances <- function( graph, - v = NULL, + vertices = NULL, to = NULL, ..., mode = c("all", "out", "in"), @@ -1452,7 +1483,8 @@ distances <- function( "bellman-ford", "johnson", "floyd-warshall" - ) + ), + v = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: distances, do not edit, see tools/generate-migrations.R # fmt: skip @@ -1485,17 +1517,32 @@ distances <- function( "3.0.0", what = base::I("Calling `distances()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: distances(", base::paste(base::c("graph", "v", "to", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: distances(", base::paste(base::c("graph", "v", "to", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: distances(", base::paste(base::c("graph", "vertices", "to", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: distances(", base::paste(base::c("graph", "vertices", "to", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(v)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn distances} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg v}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "distances(v = )", + "distances(vertices = )" + ) + vertices <- v + } + ensure_igraph(graph) - if (is.null(v)) { - v <- V(graph) + if (is.null(vertices)) { + vertices <- V(graph) } if (is.null(to)) { to <- V(graph) @@ -1508,7 +1555,7 @@ distances <- function( mode <- "out" } - v <- as_igraph_vs(graph, v) + vertices <- as_igraph_vs(graph, vertices) to <- as_igraph_vs(graph, to) mode <- igraph_match_arg(mode) mode <- switch(mode, "out" = 1, "in" = 2, "all" = 3) @@ -1544,7 +1591,7 @@ distances <- function( res <- .Call( Rx_igraph_shortest_paths, graph, - v - 1, + vertices - 1, to - 1, as.numeric(mode), weights, @@ -1552,7 +1599,7 @@ distances <- function( ) if (igraph_opt("add.vertex.names") && is_named(graph)) { - rownames(res) <- V(graph)$name[v] + rownames(res) <- V(graph)$name[vertices] colnames(res) <- V(graph)$name[to] } res @@ -2006,8 +2053,9 @@ subgraph <- function(graph, vids) { } #' @rdname subgraph -#' @param vids Numeric vector, the vertices of the original graph which will -#' form the subgraph. +#' @param vertices Numeric vector, the vertices of the original graph which +#' will form the subgraph. +#' @param vids `r lifecycle::badge("deprecated")` Use `vertices` instead. #' @inheritParams rlang::args_dots_empty #' @param impl Character scalar, to choose between two implementation of the #' subgraph calculation. \sQuote{`copy_and_delete`} copies the graph @@ -2020,13 +2068,16 @@ subgraph <- function(graph, vids) { #' @export induced_subgraph <- function( graph, - vids, + vertices, ..., - impl = c("auto", "copy_and_delete", "create_from_scratch") + impl = c("auto", "copy_and_delete", "create_from_scratch"), + vids = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: induced_subgraph, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { + .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("v")) + if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn induced_subgraph}.", i = "Spell out the full argument name.")) # Pre-3.0.0 signature: induced_subgraph(graph, vids, impl) .old_signature <- function(impl, ...) { if (...length() > 0L) { @@ -2051,23 +2102,38 @@ induced_subgraph <- function( "3.0.0", what = base::I("Calling `induced_subgraph()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: induced_subgraph(", base::paste(base::c("graph", "vids", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: induced_subgraph(", base::paste(base::c("graph", "vids", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: induced_subgraph(", base::paste(base::c("graph", "vertices", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: induced_subgraph(", base::paste(base::c("graph", "vertices", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(vids)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn induced_subgraph} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg vids}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "induced_subgraph(vids = )", + "induced_subgraph(vertices = )" + ) + vertices <- vids + } + # Argument checks ensure_igraph(graph) - vids <- as_igraph_vs(graph, vids) + vertices <- as_igraph_vs(graph, vertices) impl <- igraph_match_arg(impl) # Function call res <- induced_subgraph_impl( graph = graph, - vids = vids, + vids = vertices, impl = impl ) @@ -2199,7 +2265,7 @@ subgraph.edges <- function(graph, eids, delete.vertices = TRUE) { #' } #' \item{"local"}{ #' The local transitivity of an undirected graph. -#' It is calculated for each vertex given in the `vids` argument. +#' It is calculated for each vertex given in the `vertices` argument. #' The local transitivity of a vertex is the ratio of the count of triangles connected to the vertex #' and the triples centered on the vertex. #' In directed graphs, edge directions are ignored. @@ -2221,7 +2287,7 @@ subgraph.edges <- function(graph, eids, delete.vertices = TRUE) { #' } #' } #' @inheritParams rlang::args_dots_empty -#' @param vids The vertex IDs for the local transitivity will be calculated. +#' @param vertices The vertex IDs for the local transitivity will be calculated. #' This will be ignored for global transitivity types. The default value is #' `NULL`, in this case all vertices are considered. It is slightly faster #' to supply `NULL` here than `V(graph)`. @@ -2243,7 +2309,7 @@ subgraph.edges <- function(graph, eids, delete.vertices = TRUE) { #' are no connected triples in the graph. #' #' For \sQuote{`local`} a vector of transitivity scores, one for each -#' vertex in \sQuote{`vids`}. +#' vertex in \sQuote{`vertices`}. #' @author Gabor Csardi \email{csardi.gabor@@gmail.com} #' @references Wasserman, S., and Faust, K. (1994). *Social Network #' Analysis: Methods and Applications.* Cambridge: Cambridge University Press. @@ -2265,8 +2331,8 @@ subgraph.edges <- function(graph, eids, delete.vertices = TRUE) { #' gw <- graph_from_literal(A - B:C:D:E, B - C:D, C - D) #' E(gw)$weight <- 1 #' E(gw)[V(gw)[name == "A"] %--% V(gw)[name == "E"]]$weight <- 5 -#' transitivity(gw, vids = "A", type = "local") -#' transitivity(gw, vids = "A", type = "weighted") +#' transitivity(gw, vertices = "A", type = "local") +#' transitivity(gw, vertices = "A", type = "weighted") #' #' # Weighted reduces to "local" if weights are the same #' gw2 <- sample_gnp(1000, 10 / 1000) @@ -2291,13 +2357,15 @@ transitivity <- function( "weighted" ), ..., - vids = NULL, + vertices = NULL, weights = NULL, isolates = c("NaN", "zero") ) { # BEGIN GENERATED ARG_HANDLE: transitivity, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { + .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("v")) + if (base::length(.arg_ambiguous) > 0L) cli::cli_abort("Argument {.arg {(.arg_ambiguous[[1L]])}} matches multiple arguments of {.fn transitivity}.") # Pre-3.0.0 signature: transitivity(graph, type, vids, weights, isolates) .old_signature <- function(vids, weights, isolates, ...) { if (...length() > 0L) { @@ -2307,7 +2375,7 @@ transitivity <- function( cli::cli_abort(base::c("Unexpected argument passed to {.fn transitivity}: {.arg {(.arg_extra)}}.", i = "Arguments after {.arg ...} must be spelled out in full."), call = base::parent.frame()) } base::c( - if (!base::missing(vids)) base::list(vids = vids), + if (!base::missing(vids)) base::list(vertices = vids), if (!base::missing(weights)) base::list(weights = weights), if (!base::missing(isolates)) base::list(isolates = isolates) ) @@ -2316,7 +2384,7 @@ transitivity <- function( if (base::length(.arg_handle) > 0L) { .arg_names <- base::names(.arg_handle) .arg_conflict <- base::intersect(.arg_names, base::c( - if (!base::missing(vids)) "vids", + if (!base::missing(vertices)) "vertices", if (!base::missing(weights)) "weights", if (!base::missing(isolates)) "isolates" )) @@ -2326,7 +2394,7 @@ transitivity <- function( "3.0.0", what = base::I("Calling `transitivity()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: transitivity(", base::paste(base::c("graph", "type", .arg_names), collapse = ", "), ")"), + i = base::paste0("Detected call: transitivity(", base::paste(base::c("graph", "type", base::c(vertices = "vids", weights = "weights", isolates = "isolates")[.arg_names]), collapse = ", "), ")"), i = base::paste0("Use instead: transitivity(", base::paste(base::c("graph", "type", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) @@ -2368,7 +2436,7 @@ transitivity <- function( ) } else if (type == 1) { isolates_num <- as.double(switch(isolates, "nan" = 0, "zero" = 1)) - if (is.null(vids)) { + if (is.null(vertices)) { res <- .Call( Rx_igraph_transitivity_local_undirected_all, graph, @@ -2381,11 +2449,11 @@ transitivity <- function( } else { res <- transitivity_local_undirected_impl( graph = graph, - vids = vids, + vids = vertices, mode = isolates ) if (igraph_opt("add.vertex.names") && is_named(graph)) { - vids_indices <- as_igraph_vs(graph, vids) + vids_indices <- as_igraph_vs(graph, vertices) names(res) <- V(graph)$name[vids_indices] } res @@ -2396,11 +2464,11 @@ transitivity <- function( mode = isolates ) } else if (type == 3) { - # Save original vids for naming if needed - vids_for_names <- if (is.null(vids)) V(graph) else vids + # Save original vertices for naming if needed + vids_for_names <- if (is.null(vertices)) V(graph) else vertices res <- if (is.null(weights)) { - if (is.null(vids)) { + if (is.null(vertices)) { transitivity_local_undirected_impl( graph = graph, mode = isolates @@ -2408,12 +2476,12 @@ transitivity <- function( } else { transitivity_local_undirected_impl( graph = graph, - vids = vids, + vids = vertices, mode = isolates ) } } else { - if (is.null(vids)) { + if (is.null(vertices)) { transitivity_barrat_impl( graph = graph, weights = weights, @@ -2422,7 +2490,7 @@ transitivity <- function( } else { transitivity_barrat_impl( graph = graph, - vids = vids, + vids = vertices, weights = weights, mode = isolates ) @@ -2461,8 +2529,9 @@ transitivity <- function( #' graph adjacency matrix. For isolated vertices, constraint is undefined. #' #' @param graph A graph object, the input graph. -#' @param nodes The vertices for which the constraint will be calculated. +#' @param vertices The vertices for which the constraint will be calculated. #' The default `NULL` selects all vertices. +#' @param nodes `r lifecycle::badge("deprecated")` Use `vertices` instead. #' @inheritParams rlang::args_dots_empty #' @param weights The weights of the edges. If this is `NULL` and there is #' a `weight` edge attribute this is used. If there is no such edge @@ -2483,9 +2552,10 @@ transitivity <- function( #' constraint <- function( graph, - nodes = NULL, + vertices = NULL, ..., - weights = NULL + weights = NULL, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: constraint, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2514,19 +2584,34 @@ constraint <- function( "3.0.0", what = base::I("Calling `constraint()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: constraint(", base::paste(base::c("graph", "nodes", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: constraint(", base::paste(base::c("graph", "nodes", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: constraint(", base::paste(base::c("graph", "vertices", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: constraint(", base::paste(base::c("graph", "vertices", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn constraint} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "constraint(nodes = )", + "constraint(vertices = )" + ) + vertices <- nodes + } + ensure_igraph(graph) - if (is.null(nodes)) { - nodes <- V(graph) + if (is.null(vertices)) { + vertices <- V(graph) } - nodes <- as_igraph_vs(graph, nodes) + vertices <- as_igraph_vs(graph, vertices) if (is.null(weights)) { if ("weight" %in% edge_attr_names(graph)) { @@ -2536,11 +2621,11 @@ constraint <- function( res <- constraint_impl( graph = graph, - vids = nodes, + vids = vertices, weights = weights ) if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res) <- V(graph)$name[nodes] + names(res) <- V(graph)$name[vertices] } res } @@ -2721,10 +2806,11 @@ edge_density <- function( ego_size <- function( graph, order = 1, - nodes = NULL, + vertices = NULL, ..., mode = c("all", "out", "in"), - mindist = 0 + mindist = 0, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: ego_size, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2757,17 +2843,32 @@ ego_size <- function( "3.0.0", what = base::I("Calling `ego_size()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: ego_size(", base::paste(base::c("graph", "order", "nodes", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: ego_size(", base::paste(base::c("graph", "order", "nodes", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: ego_size(", base::paste(base::c("graph", "order", "vertices", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: ego_size(", base::paste(base::c("graph", "order", "vertices", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn ego_size} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "ego_size(nodes = )", + "ego_size(vertices = )" + ) + vertices <- nodes + } + ensure_igraph(graph) - if (is.null(nodes)) { - nodes <- V(graph) + if (is.null(vertices)) { + vertices <- V(graph) } mode <- igraph_match_arg(mode) mode <- switch(mode, "out" = 1, "in" = 2, "all" = 3) @@ -2777,7 +2878,7 @@ ego_size <- function( .Call( Rx_igraph_neighborhood_size, graph, - as_igraph_vs(graph, nodes) - 1, + as_igraph_vs(graph, vertices) - 1, as.numeric(order), as.numeric(mode), mindist @@ -2820,8 +2921,9 @@ neighborhood_size <- ego_size #' @param graph The input graph. #' @param order Integer giving the order of the neighborhood. Negative values #' indicate an infinite order. -#' @param nodes The vertices for which the calculation is performed. +#' @param vertices The vertices for which the calculation is performed. #' The default `NULL` selects all vertices. +#' @param nodes `r lifecycle::badge("deprecated")` Use `vertices` instead. #' @inheritParams rlang::args_dots_empty #' @param mode Character constant, it specifies how to use the direction of #' the edges if a directed graph is analyzed. For \sQuote{out} only the @@ -2880,10 +2982,11 @@ neighborhood_size <- ego_size ego <- function( graph, order = 1, - nodes = NULL, + vertices = NULL, ..., mode = c("all", "out", "in"), - mindist = 0 + mindist = 0, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: ego, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2916,17 +3019,28 @@ ego <- function( "3.0.0", what = base::I("Calling `ego()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: ego(", base::paste(base::c("graph", "order", "nodes", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: ego(", base::paste(base::c("graph", "order", "nodes", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: ego(", base::paste(base::c("graph", "order", "vertices", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: ego(", base::paste(base::c("graph", "order", "vertices", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn ego} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft("3.0.0", "ego(nodes = )", "ego(vertices = )") + vertices <- nodes + } + ensure_igraph(graph) - if (is.null(nodes)) { - nodes <- V(graph) + if (is.null(vertices)) { + vertices <- V(graph) } mode <- igraph_match_arg(mode) mode <- switch(mode, "out" = 1, "in" = 2, "all" = 3) @@ -2936,7 +3050,7 @@ ego <- function( res <- .Call( Rx_igraph_neighborhood, graph, - as_igraph_vs(graph, nodes) - 1, + as_igraph_vs(graph, vertices) - 1, as.numeric(order), as.numeric(mode), mindist @@ -2959,10 +3073,11 @@ neighborhood <- ego make_ego_graph <- function( graph, order = 1, - nodes = NULL, + vertices = NULL, ..., mode = c("all", "out", "in"), - mindist = 0 + mindist = 0, + nodes = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: make_ego_graph, do not edit, see tools/generate-migrations.R # fmt: skip @@ -2995,17 +3110,32 @@ make_ego_graph <- function( "3.0.0", what = base::I("Calling `make_ego_graph()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: make_ego_graph(", base::paste(base::c("graph", "order", "nodes", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: make_ego_graph(", base::paste(base::c("graph", "order", "nodes", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: make_ego_graph(", base::paste(base::c("graph", "order", "vertices", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: make_ego_graph(", base::paste(base::c("graph", "order", "vertices", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE + if (lifecycle::is_present(nodes)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn make_ego_graph} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg nodes}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "make_ego_graph(nodes = )", + "make_ego_graph(vertices = )" + ) + vertices <- nodes + } + ensure_igraph(graph) - if (is.null(nodes)) { - nodes <- V(graph) + if (is.null(vertices)) { + vertices <- V(graph) } mode <- igraph_match_arg(mode) mode <- switch(mode, "out" = 1L, "in" = 2L, "all" = 3L) @@ -3015,7 +3145,7 @@ make_ego_graph <- function( res <- .Call( Rx_igraph_neighborhood_graphs, graph, - as_igraph_vs(graph, nodes) - 1, + as_igraph_vs(graph, vertices) - 1, as.numeric(order), as.integer(mode), mindist @@ -4898,10 +5028,11 @@ which_mutual <- function( #' and \eqn{k_v}{k_v} is the neighbors' degree, specified by `neighbor_degree_mode`. #' #' @param graph The input graph. It may be directed. -#' @param vids The vertices for which the calculation is performed. +#' @param vertices The vertices for which the calculation is performed. #' The default `NULL` includes all vertices. Note, that if not all vertices are given here, then #' both \sQuote{`knn`} and \sQuote{`knnk`} will be calculated based #' on the given vertices only. +#' @param vids `r lifecycle::badge("deprecated")` Use `vertices` instead. #' @inheritParams rlang::args_dots_empty #' @param mode Character constant to indicate the type of neighbors to consider #' in directed graphs. `out` considers out-neighbors, `in` considers @@ -4919,7 +5050,7 @@ which_mutual <- function( #' @return A list with two members: #' \describe{ #' \item{knn}{ -#' A numeric vector giving the average nearest neighbor degree for all vertices in `vids`. +#' A numeric vector giving the average nearest neighbor degree for all vertices in `vertices`. #' } #' \item{knnk}{ #' A numeric vector, its length is the maximum (total) vertex degree in the graph. @@ -4955,15 +5086,18 @@ which_mutual <- function( #' @export knn <- function( graph, - vids = NULL, + vertices = NULL, ..., mode = c("all", "out", "in", "total"), neighbor.degree.mode = c("all", "out", "in", "total"), - weights = NULL + weights = NULL, + vids = deprecated() ) { # BEGIN GENERATED ARG_HANDLE: knn, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { + .arg_forbidden <- base::intersect(base::names(base::sys.call()), base::c("v")) + if (base::length(.arg_forbidden) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_forbidden)}} matches multiple formal arguments of {.fn knn}.", i = "Spell out the full argument name.")) # Pre-3.0.0 signature: knn(graph, vids, mode, neighbor.degree.mode, weights) .old_signature <- function(mode, neighbor.degree.mode, weights, ...) { if (...length() > 0L) { @@ -4992,21 +5126,32 @@ knn <- function( "3.0.0", what = base::I("Calling `knn()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: knn(", base::paste(base::c("graph", "vids", .arg_names), collapse = ", "), ")"), - i = base::paste0("Use instead: knn(", base::paste(base::c("graph", "vids", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + i = base::paste0("Detected call: knn(", base::paste(base::c("graph", "vertices", .arg_names), collapse = ", "), ")"), + i = base::paste0("Use instead: knn(", base::paste(base::c("graph", "vertices", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) } } # END GENERATED ARG_HANDLE - if (is.null(vids)) { - vids <- V(graph) + if (lifecycle::is_present(vids)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn knn} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg vids}." + )) + } + lifecycle::deprecate_soft("3.0.0", "knn(vids = )", "knn(vertices = )") + vertices <- vids + } + + if (is.null(vertices)) { + vertices <- V(graph) } avg_nearest_neighbor_degree_impl( graph = graph, - vids = vids, + vids = vertices, mode = mode, neighbor_degree_mode = neighbor.degree.mode, weights = weights diff --git a/R/topology.R b/R/topology.R index 1069c076de5..c1a7f802b6e 100644 --- a/R/topology.R +++ b/R/topology.R @@ -1251,8 +1251,9 @@ subgraph_isomorphisms <- function( #' vertices and undirected graphs with 3 to 6 vertices. #' #' @param graph The input graph. -#' @param v Optionally a vertex sequence. If not missing, then an induced -#' subgraph of the input graph, consisting of this vertices, is used. +#' @param vertices Optionally a vertex sequence. If not missing, then an +#' induced subgraph of the input graph, consisting of this vertices, is used. +#' @param v `r lifecycle::badge("deprecated")` Use `vertices` instead. #' @return An integer number. #' #' @aliases graph.isoclass graph.isoclass.subgraph @@ -1266,11 +1267,26 @@ subgraph_isomorphisms <- function( #' isomorphism_class(g1) #' isomorphism_class(g2) #' isomorphic(g1, g2) -isomorphism_class <- function(graph, v) { - if (missing(v)) { +isomorphism_class <- function(graph, vertices, v = deprecated()) { + if (lifecycle::is_present(v)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn isomorphism_class} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg v}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "isomorphism_class(v = )", + "isomorphism_class(vertices = )" + ) + vertices <- v + } + + if (missing(vertices)) { graph.isoclass(graph) } else { - graph.isoclass.subgraph(graph, v) + graph.isoclass.subgraph(graph, vertices) } } diff --git a/R/triangles.R b/R/triangles.R index 5a0e5ebb9d9..d4dcf18a788 100644 --- a/R/triangles.R +++ b/R/triangles.R @@ -15,7 +15,7 @@ adjacent.triangles <- function(graph, vids = V(graph)) { "adjacent.triangles()", "count_triangles()" ) - count_triangles(graph = graph, vids = vids) + count_triangles(graph = graph, vertices = vids) } # nocov end ## ----------------------------------------------------------------------- @@ -55,9 +55,10 @@ adjacent.triangles <- function(graph, vids = V(graph)) { #' @aliases triangles #' @param graph The input graph. It might be directed, but edge directions are #' ignored. -#' @param vids The vertices to query. This might be a vector of numeric IDs, -#' or a character vector of symbolic vertex names for named graphs. The +#' @param vertices The vertices to query. This might be a vector of numeric +#' IDs, or a character vector of symbolic vertex names for named graphs. The #' default `NULL` selects all vertices. +#' @param vids `r lifecycle::badge("deprecated")` Use `vertices` instead. #' @return For `triangles()` a numeric vector of vertex IDs, the first three #' vertices belong to the first triangle found, etc. #' @@ -96,13 +97,28 @@ triangles <- function(graph) { #' @export #' @rdname count_triangles -count_triangles <- function(graph, vids = NULL) { - if (is.null(vids)) { - vids <- V(graph) +count_triangles <- function(graph, vertices = NULL, vids = deprecated()) { + if (lifecycle::is_present(vids)) { + if (!missing(vertices)) { + cli::cli_abort(c( + "Argument {.arg vertices} of {.fn count_triangles} was supplied more than once.", + i = "It was also supplied via its legacy name {.arg vids}." + )) + } + lifecycle::deprecate_soft( + "3.0.0", + "count_triangles(vids = )", + "count_triangles(vertices = )" + ) + vertices <- vids + } + + if (is.null(vertices)) { + vertices <- V(graph) } count_adjacent_triangles_impl( graph = graph, - vids = vids + vids = vertices ) } diff --git a/man/adjacent.triangles.Rd b/man/adjacent.triangles.Rd index 88abc2cda05..a111c0a6a01 100644 --- a/man/adjacent.triangles.Rd +++ b/man/adjacent.triangles.Rd @@ -10,9 +10,7 @@ adjacent.triangles(graph, vids = V(graph)) \item{graph}{The input graph. It might be directed, but edge directions are ignored.} -\item{vids}{The vertices to query. This might be a vector of numeric IDs, -or a character vector of symbolic vertex names for named graphs. The -default \code{NULL} selects all vertices.} +\item{vids}{\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.} } \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/adjacent_vertices.Rd b/man/adjacent_vertices.Rd index 7cd09d74caa..9afaa6c1cad 100644 --- a/man/adjacent_vertices.Rd +++ b/man/adjacent_vertices.Rd @@ -4,18 +4,26 @@ \alias{adjacent_vertices} \title{Adjacent vertices of multiple vertices in a graph} \usage{ -adjacent_vertices(graph, v, ..., mode = c("out", "in", "all", "total")) +adjacent_vertices( + graph, + vertices, + ..., + mode = c("out", "in", "all", "total"), + v = deprecated() +) } \arguments{ \item{graph}{Input graph.} -\item{v}{The vertices to query.} +\item{vertices}{The vertices to query.} \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{vertices} instead.} } \value{ A list of vertex sequences. diff --git a/man/alpha.centrality.Rd b/man/alpha.centrality.Rd index c9c87f8d343..e22e89823a6 100644 --- a/man/alpha.centrality.Rd +++ b/man/alpha.centrality.Rd @@ -19,9 +19,7 @@ alpha.centrality( \item{graph}{The input graph, can be directed or undirected. In undirected graphs, edges are treated as if they were reciprocal directed ones.} -\item{nodes}{Vertex sequence, the vertices for which the alpha centrality -values are returned. The default \code{NULL} selects all vertices. -(For technical reasons they will be calculated for all vertices, anyway.)} +\item{nodes}{\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{alpha}{Parameter specifying the relative importance of endogenous versus exogenous factors in the determination of centrality. See details diff --git a/man/alpha_centrality.Rd b/man/alpha_centrality.Rd index 29b1404c764..7da97c0d2c9 100644 --- a/man/alpha_centrality.Rd +++ b/man/alpha_centrality.Rd @@ -6,21 +6,22 @@ \usage{ alpha_centrality( graph, - nodes = NULL, + vertices = NULL, ..., alpha = 1, loops = FALSE, exo = 1, weights = NULL, tol = 1e-07, - sparse = TRUE + sparse = TRUE, + nodes = deprecated() ) } \arguments{ \item{graph}{The input graph, can be directed or undirected. In undirected graphs, edges are treated as if they were reciprocal directed ones.} -\item{nodes}{Vertex sequence, the vertices for which the alpha centrality +\item{vertices}{Vertex sequence, the vertices for which the alpha centrality values are returned. The default \code{NULL} selects all vertices. (For technical reasons they will be calculated for all vertices, anyway.)} @@ -57,6 +58,8 @@ is included in the matrix.} \item{sparse}{Logical, whether to use sparse matrices for the calculation. The \sQuote{Matrix} package is required for sparse matrix support} + +\item{nodes}{\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.} } \value{ A numeric vector contaning the centrality scores for the selected diff --git a/man/betweenness.Rd b/man/betweenness.Rd index f8dbd6d4a34..c0a9ef99791 100644 --- a/man/betweenness.Rd +++ b/man/betweenness.Rd @@ -9,12 +9,13 @@ \usage{ betweenness( graph, - v = NULL, + vertices = NULL, ..., directed = TRUE, weights = NULL, normalized = FALSE, - cutoff = -1 + cutoff = -1, + v = deprecated() ) edge_betweenness( @@ -29,8 +30,8 @@ edge_betweenness( \arguments{ \item{graph}{The graph to analyze.} -\item{v}{The vertices for which the vertex betweenness will be calculated. -The default \code{NULL} selects all vertices.} +\item{vertices}{The vertices for which the vertex betweenness will be +calculated. The default \code{NULL} selects all vertices.} \item{...}{These dots are for future extensions and must be empty.} @@ -57,12 +58,14 @@ from each other may be less than \eqn{(n-1)(n-2)/2}.} \item{cutoff}{The maximum shortest path length to consider when calculating 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. The default \code{NULL} selects all edges.} } \value{ A numeric vector with the betweenness score for each vertex in -\code{v} for \code{betweenness()}. +\code{vertices} for \code{betweenness()}. A numeric vector with the edge betweenness score for each edge in \code{e} for \code{edge_betweenness()}. diff --git a/man/bonpow.Rd b/man/bonpow.Rd index ae394851f64..1b967a28376 100644 --- a/man/bonpow.Rd +++ b/man/bonpow.Rd @@ -17,8 +17,7 @@ bonpow( \arguments{ \item{graph}{the input graph.} -\item{nodes}{vertex sequence indicating which vertices are to be included in -the calculation. The default \code{NULL} selects all vertices.} +\item{nodes}{\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{loops}{Logical indicating whether or not the diagonal should be treated as valid data. Set this true if and only if the data can contain diff --git a/man/closeness.Rd b/man/closeness.Rd index 3103521ed9b..3eea243c009 100644 --- a/man/closeness.Rd +++ b/man/closeness.Rd @@ -7,18 +7,19 @@ \usage{ closeness( graph, - vids = NULL, + vertices = NULL, ..., mode = c("out", "in", "all", "total"), weights = NULL, normalized = FALSE, - cutoff = -1 + cutoff = -1, + vids = deprecated() ) } \arguments{ \item{graph}{The graph to analyze.} -\item{vids}{The vertices for which closeness will be calculated. +\item{vertices}{The vertices for which closeness will be calculated. The default \code{NULL} selects all vertices.} \item{...}{These dots are for future extensions and must be empty.} @@ -41,10 +42,12 @@ all reachable vertices.} \item{cutoff}{The maximum path length to consider when calculating the closeness. If zero or negative then there is no such limit.} + +\item{vids}{\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.} } \value{ Numeric vector with the closeness values of all the vertices in -\code{v}. +\code{vertices}. } \description{ Closeness centrality measures how many steps are required to access every other diff --git a/man/cocitation.Rd b/man/cocitation.Rd index e148aecbf82..2a264ec9dc4 100644 --- a/man/cocitation.Rd +++ b/man/cocitation.Rd @@ -5,21 +5,23 @@ \alias{bibcoupling} \title{Cocitation coupling} \usage{ -cocitation(graph, v = NULL) +cocitation(graph, vertices = NULL, v = deprecated()) -bibcoupling(graph, v = NULL) +bibcoupling(graph, vertices = NULL, v = deprecated()) } \arguments{ \item{graph}{The graph object to analyze} -\item{v}{Vertex sequence or numeric vector, the vertex IDs for which the -cocitation or bibliographic coupling values we want to calculate. The +\item{vertices}{Vertex sequence or numeric vector, the vertex IDs for which +the cocitation or bibliographic coupling values we want to calculate. The default \code{NULL} selects all vertices.} + +\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.} } \value{ -A numeric matrix with \code{length(v)} lines and +A numeric matrix with \code{length(vertices)} lines and \code{vcount(graph)} columns. Element \verb{(i,j)} contains the cocitation -or bibliographic coupling for vertices \code{v[i]} and \code{j}. +or bibliographic coupling for vertices \code{vertices[i]} and \code{j}. } \description{ Two vertices are cocited if there is another vertex citing both of them. @@ -29,10 +31,10 @@ both cite, \code{bibcoupling()} calculates this. } \details{ \code{cocitation()} calculates the cocitation counts for the vertices in the -\code{v} argument and all vertices in the graph. +\code{vertices} argument and all vertices in the graph. \code{bibcoupling()} calculates the bibliographic coupling for vertices in -\code{v} and all vertices in the graph. +\code{vertices} and all vertices in the graph. Calculating the cocitation or bibliographic coupling for only one vertex costs the same amount of computation as for all vertices. This might change diff --git a/man/constraint.Rd b/man/constraint.Rd index 3dd16200b38..f8b148eee1e 100644 --- a/man/constraint.Rd +++ b/man/constraint.Rd @@ -4,12 +4,12 @@ \alias{constraint} \title{Burt's constraint} \usage{ -constraint(graph, nodes = NULL, ..., weights = NULL) +constraint(graph, vertices = NULL, ..., weights = NULL, nodes = deprecated()) } \arguments{ \item{graph}{A graph object, the input graph.} -\item{nodes}{The vertices for which the constraint will be calculated. +\item{vertices}{The vertices for which the constraint will be calculated. The default \code{NULL} selects all vertices.} \item{...}{These dots are for future extensions and must be empty.} @@ -17,6 +17,8 @@ The default \code{NULL} selects all vertices.} \item{weights}{The weights of the edges. If this is \code{NULL} and there is a \code{weight} edge attribute this is used. If there is no such edge attribute all edges will have the same weight.} + +\item{nodes}{\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.} } \value{ A numeric vector of constraint scores diff --git a/man/count_triangles.Rd b/man/count_triangles.Rd index 99af82f07da..071823cac23 100644 --- a/man/count_triangles.Rd +++ b/man/count_triangles.Rd @@ -7,15 +7,17 @@ \usage{ triangles(graph) -count_triangles(graph, vids = NULL) +count_triangles(graph, vertices = NULL, vids = deprecated()) } \arguments{ \item{graph}{The input graph. It might be directed, but edge directions are ignored.} -\item{vids}{The vertices to query. This might be a vector of numeric IDs, -or a character vector of symbolic vertex names for named graphs. The +\item{vertices}{The vertices to query. This might be a vector of numeric +IDs, or a character vector of symbolic vertex names for named graphs. The default \code{NULL} selects all vertices.} + +\item{vids}{\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.} } \value{ For \code{triangles()} a numeric vector of vertex IDs, the first three diff --git a/man/degree.Rd b/man/degree.Rd index ec7c9277b44..2ea46e2c9f9 100644 --- a/man/degree.Rd +++ b/man/degree.Rd @@ -9,19 +9,21 @@ \usage{ degree( graph, - v = NULL, + vertices = NULL, ..., mode = c("all", "out", "in", "total"), loops = TRUE, - normalized = FALSE + normalized = FALSE, + v = deprecated() ) max_degree( graph, ..., - v = NULL, + vertices = NULL, mode = c("all", "out", "in", "total"), - loops = TRUE + loops = TRUE, + v = deprecated() ) mean_degree(graph, ..., loops = TRUE) @@ -31,7 +33,7 @@ degree_distribution(graph, cumulative = FALSE, ...) \arguments{ \item{graph}{The graph to analyze.} -\item{v}{The IDs of vertices of which the degree will be calculated. +\item{vertices}{The IDs of vertices of which the degree will be calculated. The default \code{NULL} selects all vertices.} \item{...}{These dots are for future extensions and must be empty.} @@ -46,12 +48,14 @@ this argument is ignored. \dQuote{all} is a synonym of \dQuote{total}.} \code{TRUE} then the result is divided by \eqn{n-1}, where \eqn{n} is the number of vertices in the graph.} +\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{cumulative}{Logical; whether the cumulative degree distribution is to be calculated.} } \value{ For \code{degree()} a numeric vector of the same length as argument -\code{v}. +\code{vertices}. For \code{degree_distribution()} a numeric vector of the same length as the maximum degree plus one. The first element is the relative frequency zero diff --git a/man/delete.vertices.Rd b/man/delete.vertices.Rd index a956f6e4657..6da08a31b46 100644 --- a/man/delete.vertices.Rd +++ b/man/delete.vertices.Rd @@ -9,7 +9,7 @@ delete.vertices(graph, v) \arguments{ \item{graph}{The input graph.} -\item{v}{The vertices to remove, a vertex sequence.} +\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.} } \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/delete_vertices.Rd b/man/delete_vertices.Rd index 5703eb9e502..8aac339c655 100644 --- a/man/delete_vertices.Rd +++ b/man/delete_vertices.Rd @@ -4,12 +4,14 @@ \alias{delete_vertices} \title{Delete vertices from a graph} \usage{ -delete_vertices(graph, v) +delete_vertices(graph, vertices, v = deprecated()) } \arguments{ \item{graph}{The input graph.} -\item{v}{The vertices to remove, a vertex sequence.} +\item{vertices}{The vertices to remove, a vertex sequence.} + +\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.} } \value{ The graph, with the vertices removed. diff --git a/man/distances.Rd b/man/distances.Rd index 2e84b17143a..abeb683a349 100644 --- a/man/distances.Rd +++ b/man/distances.Rd @@ -21,13 +21,14 @@ mean_distance( distances( graph, - v = NULL, + vertices = NULL, to = NULL, ..., mode = c("all", "out", "in"), weights = NULL, algorithm = c("automatic", "unweighted", "dijkstra", "bellman-ford", "johnson", - "floyd-warshall") + "floyd-warshall"), + v = deprecated() ) shortest_paths( @@ -77,8 +78,8 @@ Functions accepting this argument (like \code{mean_distance()}) return additional information like the number of disconnected vertex pairs in the result when this parameter is set to \code{TRUE}.} -\item{v}{Numeric vector, the vertices from which the shortest paths will be -calculated. The default \code{NULL} selects all vertices.} +\item{vertices}{Numeric vector, the vertices from which the shortest paths +will be calculated. The default \code{NULL} selects all vertices.} \item{to}{Numeric vector, the vertices to which the shortest paths will be calculated. The default \code{NULL} includes all vertices. Note that for @@ -103,6 +104,8 @@ that the igraph C core might still override your choice in obvious cases, i.e. if there are no edge weights, then the unweighted algorithm will be used, regardless of this argument.} +\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{from}{Numeric constant, the vertex from or to the shortest paths will be calculated. Note that right now this is not a vector of vertex IDs, but only a single vertex.} @@ -130,8 +133,9 @@ are reached.} } \value{ For \code{distances()} a numeric matrix with \code{length(to)} -columns and \code{length(v)} rows. The shortest path length from a vertex to -itself is always zero. For unreachable vertices \code{Inf} is included. +columns and \code{length(vertices)} rows. The shortest path length from a +vertex to itself is always zero. For unreachable vertices \code{Inf} is +included. For \code{shortest_paths()} a named list with four entries is returned: \item{vpath}{This itself is a list, of length \code{length(to)}; list diff --git a/man/diversity.Rd b/man/diversity.Rd index 0fe5d21dfd4..a2663c07308 100644 --- a/man/diversity.Rd +++ b/man/diversity.Rd @@ -4,7 +4,7 @@ \alias{diversity} \title{Graph diversity} \usage{ -diversity(graph, ..., weights = NULL, vids = NULL) +diversity(graph, ..., weights = NULL, vertices = NULL) } \arguments{ \item{graph}{The input graph. Edge directions are ignored.} @@ -15,7 +15,7 @@ diversity(graph, ..., weights = NULL, vids = NULL) computation. If \code{NULL}, then the \sQuote{weight} attibute is used. Note that this measure is not defined for unweighted graphs.} -\item{vids}{The vertex IDs for which to calculate the measure. +\item{vertices}{The vertex IDs for which to calculate the measure. The default \code{NULL} selects all vertices.} } \value{ diff --git a/man/ego.Rd b/man/ego.Rd index 67ddfceda02..dbff6b1e0c0 100644 --- a/man/ego.Rd +++ b/man/ego.Rd @@ -16,55 +16,61 @@ connect(graph, order, ..., mode = c("all", "out", "in", "total")) ego_size( graph, order = 1, - nodes = NULL, + vertices = NULL, ..., mode = c("all", "out", "in"), - mindist = 0 + mindist = 0, + nodes = deprecated() ) neighborhood_size( graph, order = 1, - nodes = NULL, + vertices = NULL, ..., mode = c("all", "out", "in"), - mindist = 0 + mindist = 0, + nodes = deprecated() ) ego( graph, order = 1, - nodes = NULL, + vertices = NULL, ..., mode = c("all", "out", "in"), - mindist = 0 + mindist = 0, + nodes = deprecated() ) neighborhood( graph, order = 1, - nodes = NULL, + vertices = NULL, ..., mode = c("all", "out", "in"), - mindist = 0 + mindist = 0, + nodes = deprecated() ) make_ego_graph( graph, order = 1, - nodes = NULL, + vertices = NULL, ..., mode = c("all", "out", "in"), - mindist = 0 + mindist = 0, + nodes = deprecated() ) make_neighborhood_graph( graph, order = 1, - nodes = NULL, + vertices = NULL, ..., mode = c("all", "out", "in"), - mindist = 0 + mindist = 0, + nodes = deprecated() ) } \arguments{ @@ -83,10 +89,12 @@ vertices from which the source vertex is reachable in at most \code{order} steps are counted. \sQuote{"all"} ignores the direction of the edges. This argument is ignored for undirected graphs.} -\item{nodes}{The vertices for which the calculation is performed. +\item{vertices}{The vertices for which the calculation is performed. The default \code{NULL} selects all vertices.} \item{mindist}{The minimum distance to include the vertex in the result.} + +\item{nodes}{\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.} } \value{ \itemize{ diff --git a/man/estimate_closeness.Rd b/man/estimate_closeness.Rd index 2b7d031524d..7b823331419 100644 --- a/man/estimate_closeness.Rd +++ b/man/estimate_closeness.Rd @@ -16,8 +16,7 @@ estimate_closeness( \arguments{ \item{graph}{The graph to analyze.} -\item{vids}{The vertices for which closeness will be calculated. -The default \code{NULL} selects all vertices.} +\item{vids}{\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{mode}{Character string, defined the types of the paths used for measuring the distance in directed graphs. \dQuote{in} measures the paths diff --git a/man/global_efficiency.Rd b/man/global_efficiency.Rd index 2a390554fa2..d007fe8edc4 100644 --- a/man/global_efficiency.Rd +++ b/man/global_efficiency.Rd @@ -10,11 +10,12 @@ global_efficiency(graph, ..., weights = NULL, directed = TRUE) local_efficiency( graph, - vids = NULL, + vertices = NULL, ..., weights = NULL, directed = TRUE, - mode = c("all", "out", "in", "total") + mode = c("all", "out", "in", "total"), + vids = deprecated() ) average_local_efficiency( @@ -37,13 +38,15 @@ and the graph has a \code{weight} edge attribute, then it is used automatically. \item{directed}{Logical, whether to consider directed paths. Ignored for undirected graphs.} -\item{vids}{The vertex IDs of the vertices for which the calculation will be done. +\item{vertices}{The vertex IDs of the vertices for which the calculation will be done. Applies to the local efficiency calculation only. The default \code{NULL} selects all vertices.} \item{mode}{Specifies how to define the local neighborhood of a vertex in directed graphs. \dQuote{out} considers out-neighbors only, \dQuote{in} considers in-neighbors only, \dQuote{all} considers both.} + +\item{vids}{\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.} } \value{ For \code{global_efficiency()}, the global efficiency of the graph as a diff --git a/man/graph.diversity.Rd b/man/graph.diversity.Rd index bd1ca92af59..ba558ee3f9e 100644 --- a/man/graph.diversity.Rd +++ b/man/graph.diversity.Rd @@ -13,8 +13,8 @@ graph.diversity(graph, weights = NULL, vids = V(graph)) computation. If \code{NULL}, then the \sQuote{weight} attibute is used. Note that this measure is not defined for unweighted graphs.} -\item{vids}{The vertex IDs for which to calculate the measure. -The default \code{NULL} selects all vertices.} +\item{vids}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{vertices} in +\code{\link[=diversity]{diversity()}} 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/graph.knn.Rd b/man/graph.knn.Rd index 70c502f64e1..739826451e3 100644 --- a/man/graph.knn.Rd +++ b/man/graph.knn.Rd @@ -15,10 +15,7 @@ graph.knn( \arguments{ \item{graph}{The input graph. It may be directed.} -\item{vids}{The vertices for which the calculation is performed. -The default \code{NULL} includes all vertices. Note, that if not all vertices are given here, then -both \sQuote{\code{knn}} and \sQuote{\code{knnk}} will be calculated based -on the given vertices only.} +\item{vids}{\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{mode}{Character constant to indicate the type of neighbors to consider in directed graphs. \code{out} considers out-neighbors, \verb{in} considers diff --git a/man/graph.neighborhood.Rd b/man/graph.neighborhood.Rd index 2ed769672d3..1c9c159e636 100644 --- a/man/graph.neighborhood.Rd +++ b/man/graph.neighborhood.Rd @@ -18,8 +18,7 @@ graph.neighborhood( \item{order}{Integer giving the order of the neighborhood. Negative values indicate an infinite order.} -\item{nodes}{The vertices for which the calculation is performed. -The default \code{NULL} selects all vertices.} +\item{nodes}{\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{mode}{Character constant, it specifies how to use the direction of the edges if a directed graph is analyzed. For \sQuote{out} only the diff --git a/man/graph.strength.Rd b/man/graph.strength.Rd index daf41c663fa..0904fc8214b 100644 --- a/man/graph.strength.Rd +++ b/man/graph.strength.Rd @@ -15,8 +15,7 @@ graph.strength( \arguments{ \item{graph}{The input graph.} -\item{vids}{The vertices for which the strength will be calculated. -The default \code{NULL} selects all vertices.} +\item{vids}{\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{mode}{Character string, \dQuote{out} for out-degree, \dQuote{in} for in-degree or \dQuote{all} for the sum of the two. For undirected graphs this diff --git a/man/harmonic_centrality.Rd b/man/harmonic_centrality.Rd index 1c93bc61cac..fca01107a7d 100644 --- a/man/harmonic_centrality.Rd +++ b/man/harmonic_centrality.Rd @@ -6,19 +6,20 @@ \usage{ harmonic_centrality( graph, - vids = NULL, + vertices = NULL, ..., mode = c("out", "in", "all", "total"), weights = NULL, normalized = FALSE, - cutoff = -1 + cutoff = -1, + vids = deprecated() ) } \arguments{ \item{graph}{The graph to analyze.} -\item{vids}{The vertices for which harmonic centrality will be calculated. -The default \code{NULL} selects all vertices.} +\item{vertices}{The vertices for which harmonic centrality will be +calculated. The default \code{NULL} selects all vertices.} \item{...}{These dots are for future extensions and must be empty.} @@ -41,10 +42,12 @@ If false, the result is the sum of inverse path lengths to other vertices.} \item{cutoff}{The maximum path length to consider when calculating the harmonic centrality. There is no such limit when the cutoff is negative. Note that zero cutoff means that only paths of at most length 0 are considered.} + +\item{vids}{\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.} } \value{ Numeric vector with the harmonic centrality scores of all the vertices in -\code{v}. +\code{vertices}. } \description{ The harmonic centrality of a vertex is the mean inverse distance to all other diff --git a/man/incident_edges.Rd b/man/incident_edges.Rd index 325ae62623c..359a2b288d5 100644 --- a/man/incident_edges.Rd +++ b/man/incident_edges.Rd @@ -4,18 +4,26 @@ \alias{incident_edges} \title{Incident edges of multiple vertices in a graph} \usage{ -incident_edges(graph, v, ..., mode = c("out", "in", "all", "total")) +incident_edges( + graph, + vertices, + ..., + mode = c("out", "in", "all", "total"), + v = deprecated() +) } \arguments{ \item{graph}{Input graph.} -\item{v}{The vertices to query} +\item{vertices}{The vertices to query} \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{vertices} instead.} } \value{ A list of edge sequences. diff --git a/man/induced.subgraph.Rd b/man/induced.subgraph.Rd index 78e14f9f85c..9df044903c7 100644 --- a/man/induced.subgraph.Rd +++ b/man/induced.subgraph.Rd @@ -13,8 +13,7 @@ induced.subgraph( \arguments{ \item{graph}{The original graph.} -\item{vids}{Numeric vector, the vertices of the original graph which will -form the subgraph.} +\item{vids}{\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{impl}{Character scalar, to choose between two implementation of the subgraph calculation. \sQuote{\code{copy_and_delete}} copies the graph diff --git a/man/isomorphism_class.Rd b/man/isomorphism_class.Rd index 86bc8544fa3..0501bd10dc8 100644 --- a/man/isomorphism_class.Rd +++ b/man/isomorphism_class.Rd @@ -6,13 +6,15 @@ \alias{graph.isoclass.subgraph} \title{Isomorphism class of a graph} \usage{ -isomorphism_class(graph, v) +isomorphism_class(graph, vertices, v = deprecated()) } \arguments{ \item{graph}{The input graph.} -\item{v}{Optionally a vertex sequence. If not missing, then an induced -subgraph of the input graph, consisting of this vertices, is used.} +\item{vertices}{Optionally a vertex sequence. If not missing, then an +induced subgraph of the input graph, consisting of this vertices, is used.} + +\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.} } \value{ An integer number. diff --git a/man/knn.Rd b/man/knn.Rd index 96ba5158ecf..bcde8cd2b48 100644 --- a/man/knn.Rd +++ b/man/knn.Rd @@ -6,17 +6,18 @@ \usage{ knn( graph, - vids = NULL, + vertices = NULL, ..., mode = c("all", "out", "in", "total"), neighbor.degree.mode = c("all", "out", "in", "total"), - weights = NULL + weights = NULL, + vids = deprecated() ) } \arguments{ \item{graph}{The input graph. It may be directed.} -\item{vids}{The vertices for which the calculation is performed. +\item{vertices}{The vertices for which the calculation is performed. The default \code{NULL} includes all vertices. Note, that if not all vertices are given here, then both \sQuote{\code{knn}} and \sQuote{\code{knnk}} will be calculated based on the given vertices only.} @@ -38,12 +39,14 @@ degree. But note that \code{knnk} is still given in the function of the normal vertex degree. Weights are are used to calculate a weighted degree (also called \code{\link[=strength]{strength()}}) instead of the degree.} + +\item{vids}{\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.} } \value{ A list with two members: \describe{ \item{knn}{ -A numeric vector giving the average nearest neighbor degree for all vertices in \code{vids}. +A numeric vector giving the average nearest neighbor degree for all vertices in \code{vertices}. } \item{knnk}{ A numeric vector, its length is the maximum (total) vertex degree in the graph. diff --git a/man/neighborhood.size.Rd b/man/neighborhood.size.Rd index 3264876a6fe..3a2fdbcdc01 100644 --- a/man/neighborhood.size.Rd +++ b/man/neighborhood.size.Rd @@ -18,8 +18,7 @@ neighborhood.size( \item{order}{Integer giving the order of the neighborhood. Negative values indicate an infinite order.} -\item{nodes}{The vertices for which the calculation is performed. -The default \code{NULL} selects all vertices.} +\item{nodes}{\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{mode}{Character constant, it specifies how to use the direction of the edges if a directed graph is analyzed. For \sQuote{out} only the diff --git a/man/page.rank.Rd b/man/page.rank.Rd index 41839e26df2..5ffe00dc689 100644 --- a/man/page.rank.Rd +++ b/man/page.rank.Rd @@ -21,8 +21,8 @@ page.rank( \item{algo}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{algorithm} in \code{\link[=page_rank]{page_rank()}} instead.} -\item{vids}{The vertices of interest. -The default \code{NULL} selects all vertices.} +\item{vids}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{vertices} in +\code{\link[=page_rank]{page_rank()}} instead.} \item{directed}{Logical, if true directed paths will be considered for directed graphs. It is ignored for undirected graphs.} diff --git a/man/page_rank.Rd b/man/page_rank.Rd index c205f129a6b..202b2fc7da8 100644 --- a/man/page_rank.Rd +++ b/man/page_rank.Rd @@ -8,7 +8,7 @@ page_rank( graph, ..., algorithm = c("prpack", "arpack"), - vids = NULL, + vertices = NULL, directed = TRUE, damping = 0.85, personalized = NULL, @@ -30,7 +30,7 @@ for all but small graphs. \code{"arpack"} uses the ARPACK library, the default implementation from igraph version 0.5 until version 0.7. It computes PageRank scores by solving an eingevalue problem.} -\item{vids}{The vertices of interest. +\item{vertices}{The vertices of interest. The default \code{NULL} selects all vertices.} \item{directed}{Logical, if true directed paths will be considered for diff --git a/man/power_centrality.Rd b/man/power_centrality.Rd index afe35228b59..aeeae309434 100644 --- a/man/power_centrality.Rd +++ b/man/power_centrality.Rd @@ -6,21 +6,22 @@ \usage{ power_centrality( graph, - nodes = NULL, + vertices = NULL, ..., loops = FALSE, exponent = 1, normalized = FALSE, tol = 1e-07, sparse = TRUE, - weights = NULL + weights = NULL, + nodes = deprecated() ) } \arguments{ \item{graph}{the input graph.} -\item{nodes}{vertex sequence indicating which vertices are to be included in -the calculation. The default \code{NULL} selects all vertices.} +\item{vertices}{vertex sequence indicating which vertices are to be included +in the calculation. The default \code{NULL} selects all vertices.} \item{...}{These dots are for future extensions and must be empty.} @@ -53,13 +54,15 @@ used as weights. The attribute must be numeric or logical. } If multiple edges share endpoints, the value of an arbitrarily chosen edge is included in the matrix.} + +\item{nodes}{\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.} } \value{ A vector, containing the centrality scores. } \description{ \code{power_centrality()} takes a graph (\code{dat}) and returns the Boncich power -centralities of positions (selected by \code{nodes}). The decay rate for +centralities of positions (selected by \code{vertices}). The decay rate for power contributions is specified by \code{exponent} (1 by default). } \details{ diff --git a/man/shortest.paths.Rd b/man/shortest.paths.Rd index 041f8de75b4..a1347e4da4b 100644 --- a/man/shortest.paths.Rd +++ b/man/shortest.paths.Rd @@ -16,8 +16,7 @@ shortest.paths( \arguments{ \item{graph}{The graph to work on.} -\item{v}{Numeric vector, the vertices from which the shortest paths will be -calculated. The default \code{NULL} selects all vertices.} +\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{to}{Numeric vector, the vertices to which the shortest paths will be calculated. The default \code{NULL} includes all vertices. Note that for diff --git a/man/similarity.Rd b/man/similarity.Rd index 505e887ec6d..da7f3fb7a47 100644 --- a/man/similarity.Rd +++ b/man/similarity.Rd @@ -6,17 +6,18 @@ \usage{ similarity( graph, - vids = NULL, + vertices = NULL, ..., mode = c("all", "out", "in", "total"), loops = FALSE, - method = c("jaccard", "dice", "invlogweighted") + method = c("jaccard", "dice", "invlogweighted"), + vids = deprecated() ) } \arguments{ \item{graph}{The input graph.} -\item{vids}{The vertex IDs for which the similarity is calculated. The +\item{vertices}{The vertex IDs for which the similarity is calculated. The default \code{NULL} selects all vertices.} \item{...}{These dots are for future extensions and must be empty.} @@ -29,9 +30,11 @@ possible values: \sQuote{\code{out}}, \sQuote{\verb{in}}, sets.} \item{method}{The method to use.} + +\item{vids}{\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.} } \value{ -A \code{length(vids)} by \code{length(vids)} numeric matrix +A \code{length(vertices)} by \code{length(vertices)} numeric matrix containing the similarity scores. This argument is ignored by the \code{invlogweighted} method. } diff --git a/man/similarity.dice.Rd b/man/similarity.dice.Rd index eef1059ad76..7f19c480ca5 100644 --- a/man/similarity.dice.Rd +++ b/man/similarity.dice.Rd @@ -14,8 +14,7 @@ similarity.dice( \arguments{ \item{graph}{The input graph.} -\item{vids}{The vertex IDs for which the similarity is calculated. The -default \code{NULL} selects all vertices.} +\item{vids}{\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{mode}{The type of neighboring vertices to use for the calculation, possible values: \sQuote{\code{out}}, \sQuote{\verb{in}}, diff --git a/man/similarity.invlogweighted.Rd b/man/similarity.invlogweighted.Rd index 8fbc142be0f..ea618ec1838 100644 --- a/man/similarity.invlogweighted.Rd +++ b/man/similarity.invlogweighted.Rd @@ -13,8 +13,7 @@ similarity.invlogweighted( \arguments{ \item{graph}{The input graph.} -\item{vids}{The vertex IDs for which the similarity is calculated. The -default \code{NULL} selects all vertices.} +\item{vids}{\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{mode}{The type of neighboring vertices to use for the calculation, possible values: \sQuote{\code{out}}, \sQuote{\verb{in}}, diff --git a/man/similarity.jaccard.Rd b/man/similarity.jaccard.Rd index f28b381f80a..081e73e158c 100644 --- a/man/similarity.jaccard.Rd +++ b/man/similarity.jaccard.Rd @@ -14,8 +14,7 @@ similarity.jaccard( \arguments{ \item{graph}{The input graph.} -\item{vids}{The vertex IDs for which the similarity is calculated. The -default \code{NULL} selects all vertices.} +\item{vids}{\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{mode}{The type of neighboring vertices to use for the calculation, possible values: \sQuote{\code{out}}, \sQuote{\verb{in}}, diff --git a/man/strength.Rd b/man/strength.Rd index cf0e0765c59..cf7b2356626 100644 --- a/man/strength.Rd +++ b/man/strength.Rd @@ -6,17 +6,18 @@ \usage{ strength( graph, - vids = NULL, + vertices = NULL, ..., mode = c("all", "out", "in", "total"), loops = TRUE, - weights = NULL + weights = NULL, + vids = deprecated() ) } \arguments{ \item{graph}{The input graph.} -\item{vids}{The vertices for which the strength will be calculated. +\item{vertices}{The vertices for which the strength will be calculated. The default \code{NULL} selects all vertices.} \item{...}{These dots are for future extensions and must be empty.} @@ -32,6 +33,8 @@ attribute, then this is used by default. If the graph does not have a \code{weight} edge attribute and this argument is \code{NULL}, then a \code{\link[=degree]{degree()}} is called. If this is \code{NA}, then no edge weights are used (even if the graph has a \code{weight} edge attribute).} + +\item{vids}{\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.} } \value{ A numeric vector giving the strength of the vertices. diff --git a/man/subgraph.Rd b/man/subgraph.Rd index fd06736e8e7..3dd9858bb68 100644 --- a/man/subgraph.Rd +++ b/man/subgraph.Rd @@ -10,9 +10,10 @@ subgraph(graph, vids) induced_subgraph( graph, - vids, + vertices, ..., - impl = c("auto", "copy_and_delete", "create_from_scratch") + impl = c("auto", "copy_and_delete", "create_from_scratch"), + vids = deprecated() ) subgraph_from_edges(graph, eids, ..., delete.vertices = TRUE) @@ -20,8 +21,10 @@ subgraph_from_edges(graph, eids, ..., delete.vertices = TRUE) \arguments{ \item{graph}{The original graph.} -\item{vids}{Numeric vector, the vertices of the original graph which will -form the subgraph.} +\item{vids}{\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{vertices}{Numeric vector, the vertices of the original graph which +will form the subgraph.} \item{...}{These dots are for future extensions and must be empty.} diff --git a/man/transitivity.Rd b/man/transitivity.Rd index e40240a408c..66c838b76e8 100644 --- a/man/transitivity.Rd +++ b/man/transitivity.Rd @@ -9,7 +9,7 @@ transitivity( type = c("undirected", "global", "globalundirected", "localundirected", "local", "average", "localaverage", "localaverageundirected", "barrat", "weighted"), ..., - vids = NULL, + vertices = NULL, weights = NULL, isolates = c("NaN", "zero") ) @@ -26,7 +26,7 @@ In directed graphs, edge directions are ignored. } \item{"local"}{ The local transitivity of an undirected graph. -It is calculated for each vertex given in the \code{vids} argument. +It is calculated for each vertex given in the \code{vertices} argument. The local transitivity of a vertex is the ratio of the count of triangles connected to the vertex and the triples centered on the vertex. In directed graphs, edge directions are ignored. @@ -50,7 +50,7 @@ The same as \code{barrat}. \item{...}{These dots are for future extensions and must be empty.} -\item{vids}{The vertex IDs for the local transitivity will be calculated. +\item{vertices}{The vertex IDs for the local transitivity will be calculated. This will be ignored for global transitivity types. The default value is \code{NULL}, in this case all vertices are considered. It is slightly faster to supply \code{NULL} here than \code{V(graph)}.} @@ -76,7 +76,7 @@ For \sQuote{\code{global}} a single number, or \code{NaN} if there are no connected triples in the graph. For \sQuote{\code{local}} a vector of transitivity scores, one for each -vertex in \sQuote{\code{vids}}. +vertex in \sQuote{\code{vertices}}. } \description{ Transitivity measures the probability that the adjacent vertices of a vertex @@ -120,8 +120,8 @@ transitivity(g2) # this is about 10/1000 gw <- graph_from_literal(A - B:C:D:E, B - C:D, C - D) E(gw)$weight <- 1 E(gw)[V(gw)[name == "A"] \%--\% V(gw)[name == "E"]]$weight <- 5 -transitivity(gw, vids = "A", type = "local") -transitivity(gw, vids = "A", type = "weighted") +transitivity(gw, vertices = "A", type = "local") +transitivity(gw, vertices = "A", type = "weighted") # Weighted reduces to "local" if weights are the same gw2 <- sample_gnp(1000, 10 / 1000) diff --git a/tests/testthat/_snaps/centrality.md b/tests/testthat/_snaps/centrality.md index ab3d6b88bdc..c937c394aee 100644 --- a/tests/testthat/_snaps/centrality.md +++ b/tests/testthat/_snaps/centrality.md @@ -87,3 +87,12 @@ i Detected call: page_rank(graph, algo) i Use instead: page_rank(graph, algorithm = ) +# closeness(vids = ) is deprecated but still works + + Code + res_legacy <- closeness(g, vids = 1:3) + Condition + Warning: + The `vids` argument of `closeness()` is deprecated as of igraph 3.0.0. + i Please use the `vertices` argument instead. + diff --git a/tests/testthat/_snaps/structural-properties.md b/tests/testthat/_snaps/structural-properties.md index 13b5bc079bf..42e969a4446 100644 --- a/tests/testthat/_snaps/structural-properties.md +++ b/tests/testthat/_snaps/structural-properties.md @@ -73,3 +73,21 @@ [2,] -210 590 -380 [3,] -200 -380 580 +# degree(v = ) is deprecated but still works + + Code + res_legacy <- degree(g, v = 1:3) + Condition + Warning: + The `v` argument of `degree()` is deprecated as of igraph 3.0.0. + i Please use the `vertices` argument instead. + +# degree() rejects `vertices` supplied both directly and as `v` + + Code + degree(g, vertices = 1:3, v = 1:3) + Condition + Error in `degree()`: + ! Argument `vertices` of `degree()` was supplied more than once. + i It was also supplied via its legacy name `v`. + diff --git a/tests/testthat/test-centrality.R b/tests/testthat/test-centrality.R index 94b24ca791c..d38c2b7e64b 100644 --- a/tests/testthat/test-centrality.R +++ b/tests/testthat/test-centrality.R @@ -967,7 +967,7 @@ test_that("betweenness() covers migrated tail args and positional recovery", { res <- betweenness( ring, - v = V(ring)[1:3], + vertices = V(ring)[1:3], directed = FALSE, weights = rep(1, 5), normalized = TRUE, @@ -996,7 +996,7 @@ test_that("closeness() covers migrated tail args and positional recovery", { res <- closeness( path, - vids = V(path)[3], + vertices = V(path)[3], mode = "in", weights = c(1, 1), normalized = TRUE, @@ -1008,7 +1008,7 @@ test_that("closeness() covers migrated tail args and positional recovery", { expect_equal( closeness( path, - vids = V(path)[3], + vertices = V(path)[3], mode = "in", weights = c(1, 1), cutoff = 1 @@ -1060,7 +1060,7 @@ test_that("harmonic_centrality() covers migrated tail args and positional recove res <- harmonic_centrality( path, - vids = V(path)[3], + vertices = V(path)[3], mode = "in", weights = c(1, 1), normalized = TRUE, @@ -1072,7 +1072,7 @@ test_that("harmonic_centrality() covers migrated tail args and positional recove expect_equal( harmonic_centrality( path, - vids = V(path)[3], + vertices = V(path)[3], mode = "in", weights = c(1, 1), normalized = TRUE, @@ -1099,7 +1099,7 @@ test_that("page_rank() covers migrated tail args and positional recovery", { res <- page_rank( star, algorithm = "prpack", - vids = V(star)[1:5], + vertices = V(star)[1:5], directed = FALSE, damping = 0.9, personalized = c(1, rep(0, 9)), @@ -1145,7 +1145,7 @@ test_that("strength() covers migrated tail args and positional recovery", { res <- strength( star, - vids = V(star)[1:3], + vertices = V(star)[1:3], mode = "out", loops = FALSE, weights = 1:6 @@ -1156,7 +1156,7 @@ test_that("strength() covers migrated tail args and positional recovery", { expect_equal( strength( star, - vids = V(star)[1:3], + vertices = V(star)[1:3], mode = "out", loops = TRUE, weights = 1:6 @@ -1174,7 +1174,7 @@ test_that("diversity() covers migrated tail args and positional recovery", { rlang::local_options(lifecycle_verbosity = "warning") ring <- make_ring(10) - res <- diversity(ring, weights = 1:10, vids = V(ring)[1:4]) + res <- diversity(ring, weights = 1:10, vertices = V(ring)[1:4]) # Scaled entropy of the two incident edge weights, e.g. {10, 1} for vertex 1. expect_equal( res, @@ -1215,7 +1215,7 @@ test_that("power_centrality() covers migrated tail args and positional recovery" res <- power_centrality( ring, - nodes = V(ring)[1:3], + vertices = V(ring)[1:3], loops = FALSE, exponent = 0.2, normalized = TRUE, @@ -1230,7 +1230,7 @@ test_that("power_centrality() covers migrated tail args and positional recovery" lifecycle::expect_deprecated( res_legacy <- power_centrality( ring, - nodes = V(ring)[1:3], + vertices = V(ring)[1:3], exponent = 0.2, rescale = TRUE, sparse = FALSE, @@ -1273,7 +1273,7 @@ test_that("alpha_centrality() covers migrated tail args and positional recovery" # The scores are linear in the exogenous input. res <- alpha_centrality( dag, - nodes = V(dag)[1:3], + vertices = V(dag)[1:3], alpha = 0.5, loops = TRUE, exo = 2, @@ -1299,3 +1299,50 @@ test_that("alpha_centrality() covers migrated tail args and positional recovery" ) expect_identical(res_legacy, alpha_centrality(dag, V(dag), alpha = 0.75)) }) + +# ---- vertex selector rename: v/vids/nodes -> vertices ----------------- + +test_that("closeness(vids = ) is deprecated but still works", { + rlang::local_options(lifecycle_verbosity = "warning") + g <- make_ring(10) + expect_snapshot( + res_legacy <- closeness(g, vids = 1:3) + ) + expect_identical(res_legacy, closeness(g, vertices = 1:3)) +}) + +test_that("betweenness(v = ) and strength(vids = ) are deprecated but still work", { + rlang::local_options(lifecycle_verbosity = "warning") + g <- make_ring(10) + + lifecycle::expect_deprecated( + res_legacy <- betweenness(g, v = 1:3) + ) + expect_identical(res_legacy, betweenness(g, vertices = 1:3)) + + lifecycle::expect_deprecated( + res_legacy <- strength(g, vids = 1:3) + ) + expect_identical(res_legacy, strength(g, vertices = 1:3)) +}) + +test_that("power_centrality(nodes = ) is deprecated but still works", { + rlang::local_options(lifecycle_verbosity = "warning") + g <- make_ring(10) + lifecycle::expect_deprecated( + res_legacy <- power_centrality(g, nodes = 1:3, exponent = 0.2) + ) + expect_identical( + res_legacy, + power_centrality(g, vertices = 1:3, exponent = 0.2) + ) +}) + +test_that("page_rank(vids = ) is recovered as `vertices`", { + rlang::local_options(lifecycle_verbosity = "warning") + g <- make_ring(10) + lifecycle::expect_deprecated( + res_legacy <- page_rank(g, vids = 1:3) + ) + expect_identical(res_legacy, page_rank(g, vertices = 1:3)) +}) diff --git a/tests/testthat/test-constant-defaults.R b/tests/testthat/test-constant-defaults.R index f8770f4eb44..55c14f7e642 100644 --- a/tests/testthat/test-constant-defaults.R +++ b/tests/testthat/test-constant-defaults.R @@ -9,11 +9,11 @@ test_that("NULL selector defaults stand for the full vertex/edge set", { # Passing NULL explicitly is now the same as not passing the argument. # (Before the constant-defaults cleanup an explicit NULL was coerced to an # empty selection -- an accident of as_igraph_vs(), never documented.) - expect_identical(degree(g, v = NULL), degree(g)) - expect_identical(distances(g, v = NULL, to = NULL), distances(g)) - expect_identical(diversity(g, vids = NULL), diversity(g)) + 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(closeness(g, vids = NULL), closeness(g)) + expect_identical(closeness(g, vertices = NULL), closeness(g)) }) test_that("NULL non-selector defaults resolve in the body", { @@ -33,13 +33,13 @@ test_that("NULL non-selector defaults resolve in the body", { test_that("NULL selector defaults of round-2 functions select the full set", { g <- make_ring(5) - expect_identical(max_degree(g, v = NULL), max_degree(g)) + 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(count_triangles(g, vids = NULL), count_triangles(g)) - expect_identical(cocitation(g, v = NULL), cocitation(g)) - expect_identical(similarity(g, vids = NULL), similarity(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)) V(g)$name <- letters[1:5] @@ -82,9 +82,9 @@ test_that("empty-sequence defaults are spelled as typed empty vectors", { # NULL: an explicit empty selection keeps meaning "nothing selected", # 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, v = integer()), 0) + expect_equal(max_degree(g, vertices = integer()), 0) expect_identical(which_loop(g, eids = integer()), logical(0)) - expect_gt(max_degree(g, v = NULL), 0) + expect_gt(max_degree(g, vertices = NULL), 0) # layout_as_tree(): the typed empty stays the documented default tree <- make_tree(5) @@ -106,5 +106,5 @@ test_that("positional recovery of a selector with a NULL default works", { lifecycle::expect_deprecated( res <- diversity(g, NULL, V(g)[1:3]) ) - expect_identical(res, diversity(g, weights = NULL, vids = V(g)[1:3])) + expect_identical(res, diversity(g, weights = NULL, vertices = V(g)[1:3])) }) diff --git a/tests/testthat/test-efficiency.R b/tests/testthat/test-efficiency.R index 0d05c2ff558..3ab4a44cfe1 100644 --- a/tests/testthat/test-efficiency.R +++ b/tests/testthat/test-efficiency.R @@ -57,7 +57,7 @@ test_that("local_efficiency() covers vids, weights and directed", { # the neighbors of vertex 2 reconnect at distance 7 # and those of vertex 4 at distance 3. expect_equal( - local_efficiency(g, vids = c(2, 4), weights = 1:4, directed = FALSE), + local_efficiency(g, vertices = c(2, 4), weights = 1:4, directed = FALSE), c(1 / 7, 1 / 3) ) }) diff --git a/tests/testthat/test-interface.R b/tests/testthat/test-interface.R index a9c36f18c90..29cc6ecb9ac 100644 --- a/tests/testthat/test-interface.R +++ b/tests/testthat/test-interface.R @@ -109,7 +109,7 @@ test_that("adjacent_vertices works", { g <- sample_gnp(100, 20 / 100) al <- as_adj_list(g, mode = "all") test_vertices <- c(1, 7, 38, 75, 99) - adj_vertices <- adjacent_vertices(g, v = test_vertices) + adj_vertices <- adjacent_vertices(g, vertices = test_vertices) expect_s3_class(adj_vertices[[1]], "igraph.vs") for (i in seq_along(test_vertices)) { expect_setequal(adj_vertices[[i]], al[[test_vertices[i]]]) @@ -121,7 +121,7 @@ test_that("adjacent_vertices works", { al <- as_adj_list(g, mode = "all") test_vertices <- c(1, 7, 38, 75, 99) - adj_vertices <- adjacent_vertices(g, v = test_vertices) + adj_vertices <- adjacent_vertices(g, vertices = test_vertices) expect_s3_class(adj_vertices[[1]], NA) for (i in seq_along(test_vertices)) { expect_setequal(adj_vertices[[i]], al[[test_vertices[i]]]) @@ -134,7 +134,7 @@ test_that("incident_edges works", { g <- sample_gnp(100, 20 / 100) el <- as_adj_edge_list(g, mode = "all") test_vertices <- c(1, 7, 38, 75, 99) - inc_edges <- incident_edges(g, v = test_vertices) + inc_edges <- incident_edges(g, vertices = test_vertices) expect_s3_class(inc_edges[[1]], "igraph.es") for (i in seq_along(test_vertices)) { expect_setequal(inc_edges[[i]], el[[test_vertices[i]]]) @@ -146,7 +146,7 @@ test_that("incident_edges works", { el <- as_adj_edge_list(g, mode = "all") test_vertices <- c(1, 7, 38, 75, 99) - inc_edges <- incident_edges(g, v = test_vertices) + inc_edges <- incident_edges(g, vertices = test_vertices) expect_s3_class(inc_edges[[1]], NA) for (i in seq_along(test_vertices)) { expect_setequal(inc_edges[[i]], el[[test_vertices[i]]]) @@ -364,3 +364,20 @@ test_that("get_edge_ids() tail arguments and legacy positional recovery", { ) expect_identical(res, get_edge_ids(g, c(2, 1), directed = FALSE)) }) + +# ---- vertex selector rename: v -> vertices ---------------------------- + +test_that("adjacent_vertices(v = ) and delete_vertices(v = ) are deprecated but still work", { + rlang::local_options(lifecycle_verbosity = "warning") + g <- make_ring(10) + + lifecycle::expect_deprecated( + res_legacy <- adjacent_vertices(g, v = 1:2) + ) + expect_equal(res_legacy, adjacent_vertices(g, vertices = 1:2)) + + lifecycle::expect_deprecated( + g_legacy <- delete_vertices(g, v = 1:2) + ) + expect_identical_graphs(g_legacy, delete_vertices(g, vertices = 1:2)) +}) diff --git a/tests/testthat/test-iterators.R b/tests/testthat/test-iterators.R index 59a6a274fee..3fd8f91060e 100644 --- a/tests/testthat/test-iterators.R +++ b/tests/testthat/test-iterators.R @@ -404,7 +404,7 @@ test_that("unconnected vs/es can be reused with the same graph", { load(tmp) - expect_equal(degree(g, v = vs), rep(2, 10)) + expect_equal(degree(g, vertices = vs), rep(2, 10)) expect_identical_graphs( delete_edges(g, es), delete_edges(g, 1:5) diff --git a/tests/testthat/test-similarity.R b/tests/testthat/test-similarity.R index 3e741a0055d..795f769ab9d 100644 --- a/tests/testthat/test-similarity.R +++ b/tests/testthat/test-similarity.R @@ -38,7 +38,7 @@ test_that("similarity() covers vids, mode, loops and method", { # so consecutive vertices share exactly one of their two out-neighbors. sim <- similarity( g, - vids = V(g)[1:3], + vertices = V(g)[1:3], mode = "out", loops = TRUE, method = "dice" diff --git a/tests/testthat/test-structural-properties.R b/tests/testthat/test-structural-properties.R index d1a5424489e..2ec694687b9 100644 --- a/tests/testthat/test-structural-properties.R +++ b/tests/testthat/test-structural-properties.R @@ -69,8 +69,8 @@ test_that("max_degree() works", { expect_equal(max_degree(g, loops = FALSE), 2) expect_equal(max_degree(g, mode = "out", loops = FALSE), 1) expect_equal(max_degree(g, mode = "in", loops = FALSE), 1) - expect_equal(max_degree(g, v = integer()), 0) - expect_equal(max_degree(g, v = NULL), max_degree(g)) + expect_equal(max_degree(g, vertices = integer()), 0) + expect_equal(max_degree(g, vertices = NULL), max_degree(g)) expect_equal(max_degree(make_empty_graph()), 0) }) @@ -352,7 +352,7 @@ test_that("farthest_vertices() works", { expect_equal(fn, list(vertices = c(1, 10), distance = 4)) expect_equal( - distances(kite, v = fn$vertices[1], to = fn$vertices[2])[1], + distances(kite, vertices = fn$vertices[1], to = fn$vertices[2])[1], fn$distance ) expect_equal(diameter(kite), fn$distance) @@ -510,7 +510,7 @@ test_that("transitivity() works", { t2 <- transitivity(g, type = "average") expect_equal(t2, 0.10159943848720931481) - t3 <- transitivity(g, type = "local", vids = V(g)) + t3 <- transitivity(g, type = "local", vertices = V(g)) t33 <- transitivity(g, type = "local") est3 <- structure( c(0, 0.06667, 0.1028, 0.1016, 0.1333, 0.2222), @@ -547,10 +547,10 @@ test_that("local transitivity() produces named vectors", { expect_named(t2, V(g)$name) vs <- c("a", "c") - t3 <- transitivity(g, type = "local", vids = vs) + t3 <- transitivity(g, type = "local", vertices = vs) expect_named(t3, vs) - t4 <- transitivity(g, type = "barrat", vids = vs) + t4 <- transitivity(g, type = "barrat", vertices = vs) expect_named(t4, vs) }) @@ -1194,7 +1194,7 @@ test_that("distances() legacy positional recovery", { g <- make_ring(5, directed = TRUE) lifecycle::expect_deprecated(res <- distances(g, V(g), V(g), "out")) - expect_identical(res, distances(g, v = V(g), to = V(g), mode = "out")) + expect_identical(res, distances(g, vertices = V(g), to = V(g), mode = "out")) }) test_that("shortest_paths() tail arguments and legacy positional recovery", { @@ -1284,7 +1284,7 @@ test_that("transitivity() tail arguments and legacy positional recovery", { transitivity( g, type = "barrat", - vids = V(g), + vertices = V(g), weights = rep(1, 4), isolates = "zero" ), @@ -1292,7 +1292,7 @@ test_that("transitivity() tail arguments and legacy positional recovery", { ) lifecycle::expect_deprecated(res <- transitivity(g, "local", V(g))) - expect_identical(res, transitivity(g, type = "local", vids = V(g))) + expect_identical(res, transitivity(g, type = "local", vertices = V(g))) }) test_that("constraint() tail arguments and legacy positional recovery", { @@ -1302,7 +1302,7 @@ test_that("constraint() tail arguments and legacy positional recovery", { # Explicit unit weights override the weight attribute: # every vertex of an unweighted triangle has constraint 1.125. expect_equal( - constraint(g, nodes = V(g), weights = rep(1, 3)), + constraint(g, vertices = V(g), weights = rep(1, 3)), c(a = 1.125, b = 1.125, c = 1.125) ) @@ -1333,7 +1333,10 @@ test_that("edge_density() tail arguments and legacy positional recovery", { test_that("ego_size() tail arguments and legacy positional recovery", { g <- make_ring(5, directed = TRUE) - expect_equal(ego_size(g, order = 1, nodes = 1, mode = "out", mindist = 1), 1) + expect_equal( + ego_size(g, order = 1, vertices = 1, mode = "out", mindist = 1), + 1 + ) lifecycle::expect_deprecated(res <- ego_size(g, 1, 1, "out")) expect_identical(res, ego_size(g, 1, 1, mode = "out")) @@ -1342,7 +1345,7 @@ test_that("ego_size() tail arguments and legacy positional recovery", { test_that("ego() tail arguments and legacy positional recovery", { g <- make_ring(5, directed = TRUE) - e <- ego(g, order = 1, nodes = 1, mode = "out", mindist = 1) + e <- ego(g, order = 1, vertices = 1, mode = "out", mindist = 1) expect_equal(as.numeric(e[[1]]), 2) lifecycle::expect_deprecated(res <- ego(g, 1, 1, "out")) @@ -1352,7 +1355,7 @@ test_that("ego() tail arguments and legacy positional recovery", { test_that("make_ego_graph() tail arguments and legacy positional recovery", { g <- make_ring(5, directed = TRUE) - mg <- make_ego_graph(g, order = 1, nodes = 1, mode = "out", mindist = 1) + mg <- make_ego_graph(g, order = 1, vertices = 1, mode = "out", mindist = 1) expect_length(mg, 1) expect_equal(vcount(mg[[1]]), 1) expect_equal(ecount(mg[[1]]), 0) @@ -1542,7 +1545,7 @@ test_that("knn() tail arguments and legacy positional recovery", { # only the centre has out-neighbours, each with in-degree 1. r <- knn( g, - vids = V(g), + vertices = V(g), mode = "out", neighbor.degree.mode = "in", weights = NA @@ -1553,3 +1556,65 @@ test_that("knn() tail arguments and legacy positional recovery", { lifecycle::expect_deprecated(res <- knn(g, V(g), "out")) expect_identical(res, knn(g, V(g), mode = "out")) }) + +# ---- vertex selector rename: v/vids/nodes -> vertices ----------------- + +test_that("degree(v = ) is deprecated but still works", { + rlang::local_options(lifecycle_verbosity = "warning") + g <- make_ring(10) + expect_snapshot( + res_legacy <- degree(g, v = 1:3) + ) + expect_identical(res_legacy, degree(g, vertices = 1:3)) +}) + +test_that("degree() rejects `vertices` supplied both directly and as `v`", { + rlang::local_options(lifecycle_verbosity = "warning") + g <- make_ring(10) + expect_snapshot( + degree(g, vertices = 1:3, v = 1:3), + error = TRUE + ) +}) + +test_that("ego(nodes = ) and induced_subgraph(vids = ) are deprecated but still work", { + rlang::local_options(lifecycle_verbosity = "warning") + g <- make_ring(10) + + lifecycle::expect_deprecated( + res_legacy <- ego(g, order = 1, nodes = 1:3) + ) + expect_equal(res_legacy, ego(g, order = 1, vertices = 1:3)) + + lifecycle::expect_deprecated( + res_legacy <- induced_subgraph(g, vids = 1:5) + ) + expect_identical_graphs(res_legacy, induced_subgraph(g, vertices = 1:5)) +}) + +test_that("distances(v = ) and max_degree(v = ) are deprecated but still work", { + rlang::local_options(lifecycle_verbosity = "warning") + g <- make_ring(10) + + lifecycle::expect_deprecated( + res_legacy <- distances(g, v = 1:3) + ) + expect_identical(res_legacy, distances(g, vertices = 1:3)) + + lifecycle::expect_deprecated( + res_legacy <- max_degree(g, v = 1:3) + ) + expect_identical(res_legacy, max_degree(g, vertices = 1:3)) +}) + +test_that("transitivity(vids = ) is recovered as `vertices`", { + rlang::local_options(lifecycle_verbosity = "warning") + g <- make_graph(~ a - b - c - a - d) + lifecycle::expect_deprecated( + res_legacy <- transitivity(g, type = "local", vids = c("a", "c")) + ) + expect_identical( + res_legacy, + transitivity(g, type = "local", vertices = c("a", "c")) + ) +}) diff --git a/tools/migrations/centrality.R b/tools/migrations/centrality.R index 44d94eece58..29e29502e86 100644 --- a/tools/migrations/centrality.R +++ b/tools/migrations/centrality.R @@ -7,14 +7,15 @@ migrations <- list( old = function(graph, nodes, alpha, loops, exo, weights, tol, sparse) {}, new = function( graph, - nodes = NULL, + vertices = NULL, ..., alpha = 1, loops = FALSE, exo = 1, weights = NULL, tol = 1e-7, - sparse = TRUE + sparse = TRUE, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -23,12 +24,13 @@ migrations <- list( old = function(graph, v, directed, weights, normalized, cutoff) {}, new = function( graph, - v = NULL, + vertices = NULL, ..., directed = TRUE, weights = NULL, normalized = FALSE, - cutoff = -1 + cutoff = -1, + v = deprecated() ) {}, when = "3.0.0" ), @@ -37,23 +39,24 @@ migrations <- list( old = function(graph, vids, mode, weights, normalized, cutoff) {}, new = function( graph, - vids = NULL, + vertices = NULL, ..., mode = c("out", "in", "all", "total"), weights = NULL, normalized = FALSE, - cutoff = -1 + cutoff = -1, + vids = deprecated() ) {}, when = "3.0.0" ), diversity = list( - old = function(graph, weights, vids) {}, + old = function(graph, weights, vids = vertices) {}, new = function( graph, ..., weights = NULL, - vids = NULL + vertices = NULL ) {}, when = "3.0.0" ), @@ -75,12 +78,13 @@ migrations <- list( old = function(graph, vids, mode, weights, normalized, cutoff) {}, new = function( graph, - vids = NULL, + vertices = NULL, ..., mode = c("out", "in", "all", "total"), weights = NULL, normalized = FALSE, - cutoff = -1 + cutoff = -1, + vids = deprecated() ) {}, when = "3.0.0" ), @@ -89,7 +93,7 @@ migrations <- list( old = function( graph, algo = algorithm, - vids, + vids = vertices, directed, damping, personalized, @@ -100,7 +104,7 @@ migrations <- list( graph, ..., algorithm = c("prpack", "arpack"), - vids = NULL, + vertices = NULL, directed = TRUE, damping = 0.85, personalized = NULL, @@ -123,14 +127,15 @@ migrations <- list( ) {}, new = function( graph, - nodes = NULL, + vertices = NULL, ..., loops = FALSE, exponent = 1, normalized = FALSE, tol = 1e-7, sparse = TRUE, - weights = NULL + weights = NULL, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -139,11 +144,12 @@ migrations <- list( old = function(graph, vids, mode, loops, weights) {}, new = function( graph, - vids = NULL, + vertices = NULL, ..., mode = c("all", "out", "in", "total"), loops = TRUE, - weights = NULL + weights = NULL, + vids = deprecated() ) {}, when = "3.0.0" ), diff --git a/tools/migrations/interface.R b/tools/migrations/interface.R index f9af26fef85..b84ced9047c 100644 --- a/tools/migrations/interface.R +++ b/tools/migrations/interface.R @@ -7,9 +7,10 @@ migrations <- list( old = function(graph, v, mode) {}, new = function( graph, - v, + vertices, ..., - mode = c("out", "in", "all", "total") + mode = c("out", "in", "all", "total"), + v = deprecated() ) {}, when = "3.0.0" ), @@ -52,9 +53,10 @@ migrations <- list( old = function(graph, v, mode) {}, new = function( graph, - v, + vertices, ..., - mode = c("out", "in", "all", "total") + mode = c("out", "in", "all", "total"), + v = deprecated() ) {}, when = "3.0.0" ), diff --git a/tools/migrations/similarity-efficiency.R b/tools/migrations/similarity-efficiency.R index 18607786045..c1cebe7ea5d 100644 --- a/tools/migrations/similarity-efficiency.R +++ b/tools/migrations/similarity-efficiency.R @@ -52,11 +52,12 @@ migrations <- list( old = function(graph, vids, weights, directed, mode) {}, new = function( graph, - vids = NULL, + vertices = NULL, ..., weights = NULL, directed = TRUE, - mode = c("all", "out", "in", "total") + mode = c("all", "out", "in", "total"), + vids = deprecated() ) {}, when = "3.0.0" ), @@ -65,7 +66,7 @@ migrations <- list( old = function(graph, vids, mode, loops, method) {}, new = function( graph, - vids = NULL, + vertices = NULL, ..., mode = c( "all", @@ -78,7 +79,8 @@ migrations <- list( "jaccard", "dice", "invlogweighted" - ) + ), + vids = deprecated() ) {}, when = "3.0.0" ) diff --git a/tools/migrations/structural-properties.R b/tools/migrations/structural-properties.R index b0581d12904..961dbf48f88 100644 --- a/tools/migrations/structural-properties.R +++ b/tools/migrations/structural-properties.R @@ -86,9 +86,10 @@ migrations <- list( old = function(graph, nodes, weights) {}, new = function( graph, - nodes = NULL, + vertices = NULL, ..., - weights = NULL + weights = NULL, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -127,11 +128,12 @@ migrations <- list( old = function(graph, v, mode, loops, normalized) {}, new = function( graph, - v = NULL, + vertices = NULL, ..., mode = c("all", "out", "in", "total"), loops = TRUE, - normalized = FALSE + normalized = FALSE, + v = deprecated() ) {}, when = "3.0.0" ), @@ -152,7 +154,7 @@ migrations <- list( old = function(graph, v, to, mode, weights, algorithm) {}, new = function( graph, - v = NULL, + vertices = NULL, to = NULL, ..., mode = c("all", "out", "in"), @@ -164,7 +166,8 @@ migrations <- list( "bellman-ford", "johnson", "floyd-warshall" - ) + ), + v = deprecated() ) {}, when = "3.0.0" ), @@ -184,10 +187,11 @@ migrations <- list( new = function( graph, order = 1, - nodes = NULL, + vertices = NULL, ..., mode = c("all", "out", "in"), - mindist = 0 + mindist = 0, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -197,10 +201,11 @@ migrations <- list( new = function( graph, order = 1, - nodes = NULL, + vertices = NULL, ..., mode = c("all", "out", "in"), - mindist = 0 + mindist = 0, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -265,9 +270,10 @@ migrations <- list( old = function(graph, vids, impl) {}, new = function( graph, - vids, + vertices, ..., - impl = c("auto", "copy_and_delete", "create_from_scratch") + impl = c("auto", "copy_and_delete", "create_from_scratch"), + vids = deprecated() ) {}, when = "3.0.0" ), @@ -286,11 +292,12 @@ migrations <- list( old = function(graph, vids, mode, neighbor.degree.mode, weights) {}, new = function( graph, - vids = NULL, + vertices = NULL, ..., mode = c("all", "out", "in", "total"), neighbor.degree.mode = c("all", "out", "in", "total"), - weights = NULL + weights = NULL, + vids = deprecated() ) {}, when = "3.0.0" ), @@ -300,10 +307,11 @@ migrations <- list( new = function( graph, order = 1, - nodes = NULL, + vertices = NULL, ..., mode = c("all", "out", "in"), - mindist = 0 + mindist = 0, + nodes = deprecated() ) {}, when = "3.0.0" ), @@ -414,7 +422,7 @@ migrations <- list( ), transitivity = list( - old = function(graph, type, vids, weights, isolates) {}, + old = function(graph, type, vids = vertices, weights, isolates) {}, new = function( graph, type = c( @@ -430,7 +438,7 @@ migrations <- list( "weighted" ), ..., - vids = NULL, + vertices = NULL, weights = NULL, isolates = c("NaN", "zero") ) {}, diff --git a/vignettes/igraph.Rmd b/vignettes/igraph.Rmd index 6682bc6b3fc..196cf7a41cb 100644 --- a/vignettes/igraph.Rmd +++ b/vignettes/igraph.Rmd @@ -328,13 +328,13 @@ degree(g, 7) ``` ```{r echo = TRUE} -degree(g, v = c(3, 4, 5)) +degree(g, vertices = c(3, 4, 5)) ``` Most functions that accept vertex IDs also accept vertex _names_ (the values of the `name` vertex attribute) as long as the names are unique: ```{r echo = TRUE} -degree(g, v = c("Carmina", "Moshe", "Nang")) +degree(g, vertices = c("Carmina", "Moshe", "Nang")) ``` It also works for single vertices: diff --git a/vignettes/igraph_ES.rmd b/vignettes/igraph_ES.rmd index c102c204450..4ed608c10cc 100644 --- a/vignettes/igraph_ES.rmd +++ b/vignettes/igraph_ES.rmd @@ -340,13 +340,13 @@ degree(g, 7) ``` ```{r echo = TRUE} -degree(g, v = c(3,4,5)) +degree(g, vertices = c(3,4,5)) ``` La mayoría de las funciones que aceptan los IDs de los vértices también aceptan los "nombres" de los vértices (es decir, los valores del atributo `name` del vértice) siempre que los nombres sean únicos: ```{r echo = TRUE} -degree(g, v = c("Carmina", "Moshe", "Nang")) +degree(g, vertices = c("Carmina", "Moshe", "Nang")) ``` También funciona para vértices individuales: