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
58 changes: 31 additions & 27 deletions R/cliques.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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, ...) {
Expand All @@ -529,19 +529,19 @@ 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)
)
}
.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(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)}}."))
Expand All @@ -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 = ", "), ")")
)
)
Expand All @@ -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
)
}
Expand All @@ -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) {
Expand All @@ -586,22 +588,22 @@ 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())
lifecycle::deprecate_soft(
"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 = ", "), ")")
)
)
Expand All @@ -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
Expand All @@ -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) {
Expand All @@ -634,22 +638,22 @@ 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())
lifecycle::deprecate_soft(
"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 = ", "), ")")
)
)
Expand All @@ -659,7 +663,7 @@ weighted_clique_num <- function(

weighted_clique_number_impl(
graph = graph,
vertex_weights = vertex.weights
vertex_weights = vertex_weights
)
}

Expand Down
34 changes: 20 additions & 14 deletions R/community.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
)
Expand All @@ -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"
))
Expand All @@ -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 = ", "), ")")
)
)
Expand All @@ -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
)

Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions man/cliques.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/cluster_infomap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 4 additions & 11 deletions man/infomap.community.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions man/weighted_cliques.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading