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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 45 additions & 11 deletions R/community.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
28 changes: 11 additions & 17 deletions R/layout.R
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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, ...) {
Expand All @@ -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(...)
Expand All @@ -1875,15 +1873,15 @@ 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())
lifecycle::deprecate_soft(
"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 = ", "), ")")
)
)
Expand All @@ -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)

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
}

Expand Down
72 changes: 8 additions & 64 deletions R/structural-properties.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()")
Expand All @@ -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

Expand Down Expand Up @@ -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()")
Expand All @@ -559,8 +556,7 @@ graph.bfs <- function(
dist = dist,
callback = callback,
extra = extra,
rho = rho,
neimode = neimode
rho = rho
)
} # nocov end

Expand Down Expand Up @@ -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.
Expand All @@ -3657,16 +3652,14 @@ 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{
#' \item{root}{
#' 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.
#' }
Expand All @@ -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
Expand Down Expand Up @@ -3751,9 +3741,7 @@ bfs <- function(
dist = FALSE,
callback = NULL,
extra = NULL,
rho = NULL,
neimode = deprecated(),
father = deprecated()
rho = NULL
) {
rlang::check_dots_empty()

Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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.
Expand All @@ -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.
#' }
Expand All @@ -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.
#' }
Expand Down Expand Up @@ -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()

Expand All @@ -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),
Expand Down Expand Up @@ -4084,9 +4034,6 @@ dfs <- function(
rho
)

# Remove in 1.4.0
res$neimode <- res$mode

if (order) {
res$order <- res$order + 1
}
Expand Down Expand Up @@ -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
}

Expand Down
Loading
Loading