diff --git a/R/aaa-operators.R b/R/aaa-operators.R index 1c81fcd5262..94994feeaad 100644 --- a/R/aaa-operators.R +++ b/R/aaa-operators.R @@ -35,7 +35,7 @@ connect_neighborhood_impl <- function( contract_vertices_impl <- function( graph, mapping, - vertex_attr_comb = igraph_opt("vertex.attr.comb") + vertex_attr_comb = igraph_opt("vertex_attr_combine") ) { # Argument checks ensure_igraph(graph) @@ -245,7 +245,7 @@ simplify_impl <- function( graph, remove_multiple = TRUE, remove_loops = TRUE, - edge_attr_comb = igraph_opt("edge.attr.comb") + edge_attr_comb = igraph_opt("edge_attr_combine") ) { # Argument checks ensure_igraph(graph) diff --git a/R/aaa-structural.R b/R/aaa-structural.R index de9543e847b..21d3795e887 100644 --- a/R/aaa-structural.R +++ b/R/aaa-structural.R @@ -166,7 +166,7 @@ to_directed_impl <- function( to_undirected_impl <- function( graph, mode = c("collapse", "each", "mutual"), - edge_attr_comb = igraph_opt("edge.attr.comb") + edge_attr_comb = igraph_opt("edge_attr_combine") ) { # Argument checks ensure_igraph(graph) diff --git a/R/attributes.R b/R/attributes.R index 13824155c1c..051f570ff6e 100644 --- a/R/attributes.R +++ b/R/attributes.R @@ -1387,7 +1387,7 @@ igraph.i.attribute.combination <- function(comb, allow_rename = FALSE) { #' vertex/edge attributes in these cases. #' #' The functions that support the combination of attributes have one or two -#' extra arguments called `vertex.attr.comb` and/or `edge.attr.comb` +#' extra arguments called `vertex_attr_combine` and/or `edge_attr_combine` #' that specify how to perform the mapping of the attributes. E.g. #' [contract()] contracts many vertices into a single one, the #' attributes of the vertices can be combined and stores as the vertex @@ -1498,22 +1498,22 @@ igraph.i.attribute.combination <- function(comb, allow_rename = FALSE) { #' igraph_options(print.edge.attributes = TRUE) #' #' ## new attribute is the sum of the old ones -#' simplify(g, edge.attr.comb = "sum") +#' simplify(g, edge_attr_combine = "sum") #' #' ## collect attributes into a string -#' simplify(g, edge.attr.comb = toString) +#' simplify(g, edge_attr_combine = toString) #' #' ## concatenate them into a vector, this creates a complex #' ## attribute -#' simplify(g, edge.attr.comb = "concat") +#' simplify(g, edge_attr_combine = "concat") #' #' E(g)$name <- letters[seq_len(ecount(g))] #' #' ## both attributes are collected into strings -#' simplify(g, edge.attr.comb = toString) +#' simplify(g, edge_attr_combine = toString) #' #' ## harmonic average of weights, names are dropped -#' simplify(g, edge.attr.comb = list( +#' simplify(g, edge_attr_combine = list( #' weight = function(x) length(x) / sum(1 / x), #' name = "ignore" #' )) diff --git a/R/community.R b/R/community.R index 783f7676000..0da12547515 100644 --- a/R/community.R +++ b/R/community.R @@ -417,14 +417,14 @@ cutat <- function(communities, no, steps) { contract.vertices <- function( graph, mapping, - vertex.attr.comb = igraph_opt("vertex.attr.comb") + vertex.attr.comb = igraph_opt("vertex_attr_combine") ) { # nocov start lifecycle::deprecate_warn("2.0.0", "contract.vertices()", "contract()") contract( graph = graph, mapping = mapping, - vertex.attr.comb = vertex.attr.comb + vertex_attr_combine = vertex.attr.comb ) } # nocov end @@ -3620,15 +3620,16 @@ communities <- groups.communities #' #' The attributes of the graph are kept. Graph and edge attributes are #' unchanged, vertex attributes are combined, according to the -#' `vertex.attr.comb` parameter. +#' `vertex_attr_combine` parameter. #' #' @param graph The input graph, it can be directed or undirected. #' @param mapping A numeric vector that specifies the mapping. Its elements #' correspond to the vertices, and for each element the ID in the new graph is #' given. -#' @param vertex.attr.comb Specifies how to combine the vertex attributes in +#' @inheritParams rlang::args_dots_empty +#' @param vertex_attr_combine Specifies how to combine the vertex attributes in #' the new graph. Please see [attribute.combination()] for details. The -#' default `NULL` uses the `vertex.attr.comb` igraph option. +#' default `NULL` uses the `vertex_attr_combine` igraph option. #' @return A new graph object. #' @author Gabor Csardi \email{csardi.gabor@@gmail.com} #' @keywords graphs @@ -3640,7 +3641,7 @@ communities <- groups.communities #' E(g)$weight <- runif(ecount(g)) #' #' g2 <- contract(g, rep(1:5, each = 2), -#' vertex.attr.comb = toString +#' vertex_attr_combine = toString #' ) #' #' ## graph and edge attributes are kept, vertex attributes are @@ -3652,16 +3653,54 @@ communities <- groups.communities contract <- function( graph, mapping, - vertex.attr.comb = NULL + ..., + vertex_attr_combine = NULL ) { - if (is.null(vertex.attr.comb)) { - vertex.attr.comb <- igraph_opt("vertex.attr.comb") + # BEGIN GENERATED ARG_HANDLE: contract, 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 contract}.") + # Pre-3.0.0 signature: contract(graph, mapping, vertex.attr.comb) + .old_signature <- function(vertex.attr.comb, ...) { + 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 contract}.", call = base::parent.frame()) + cli::cli_abort(base::c("Unexpected argument passed to {.fn contract}: {.arg {(.arg_extra)}}.", i = "Arguments after {.arg ...} must be spelled out in full."), call = base::parent.frame()) + } + base::c( + if (!base::missing(vertex.attr.comb)) base::list(vertex_attr_combine = vertex.attr.comb) + ) + } + .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_attr_combine)) "vertex_attr_combine" + )) + if (base::length(.arg_conflict) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn contract} 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 `contract()` with positional or abbreviated arguments"), + details = base::c( + i = base::paste0("Detected call: contract(", base::paste(base::c("graph", "mapping", base::c(vertex_attr_combine = "vertex.attr.comb")[.arg_names]), collapse = ", "), ")"), + i = base::paste0("Use instead: contract(", base::paste(base::c("graph", "mapping", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + ) + ) + } + } + # END GENERATED ARG_HANDLE + + if (is.null(vertex_attr_combine)) { + vertex_attr_combine <- igraph_opt("vertex_attr_combine") } contract_vertices_impl( graph = graph, mapping = mapping, - vertex_attr_comb = vertex.attr.comb + vertex_attr_comb = vertex_attr_combine ) } diff --git a/R/conversion.R b/R/conversion.R index 61791722a72..1148042d472 100644 --- a/R/conversion.R +++ b/R/conversion.R @@ -740,7 +740,7 @@ as_edgelist <- function( #' E(g4)$weight <- seq_len(ecount(g4)) #' ug4 <- as_undirected(g4, #' mode = "mutual", -#' edge.attr.comb = list(weight = length) +#' edge_attr_combine = list(weight = length) #' ) #' print(ug4, e = TRUE) #' @@ -791,21 +791,59 @@ as_directed <- function( } #' @rdname as_directed -#' @param edge.attr.comb Specifies what to do with edge attributes, if +#' @param edge_attr_combine Specifies what to do with edge attributes, if #' `mode="collapse"` or `mode="mutual"`. In these cases many edges #' might be mapped to a single one in the new graph, and their attributes are #' combined. Please see [attribute.combination()] for details on -#' this. The default `NULL` uses the `edge.attr.comb` igraph option. +#' this. The default `NULL` uses the `edge_attr_combine` igraph option. #' @export as_undirected <- function( graph, mode = c("collapse", "each", "mutual"), - edge.attr.comb = NULL + ..., + edge_attr_combine = NULL ) { + # BEGIN GENERATED ARG_HANDLE: as_undirected, do not edit, see tools/generate-migrations.R + # fmt: skip + if (...length() > 0L) { + .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("e", "ed", "edg", "edge")) + if (base::length(.arg_ambiguous) > 0L) cli::cli_abort("Argument {.arg {(.arg_ambiguous[[1L]])}} matches multiple arguments of {.fn as_undirected}.") + # Pre-3.0.0 signature: as_undirected(graph, mode, edge.attr.comb) + .old_signature <- function(edge.attr.comb, ...) { + 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 as_undirected}.", call = base::parent.frame()) + cli::cli_abort(base::c("Unexpected argument passed to {.fn as_undirected}: {.arg {(.arg_extra)}}.", i = "Arguments after {.arg ...} must be spelled out in full."), call = base::parent.frame()) + } + base::c( + if (!base::missing(edge.attr.comb)) base::list(edge_attr_combine = edge.attr.comb) + ) + } + .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(edge_attr_combine)) "edge_attr_combine" + )) + if (base::length(.arg_conflict) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn as_undirected} 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 `as_undirected()` with positional or abbreviated arguments"), + details = base::c( + i = base::paste0("Detected call: as_undirected(", base::paste(base::c("graph", "mode", base::c(edge_attr_combine = "edge.attr.comb")[.arg_names]), collapse = ", "), ")"), + i = base::paste0("Use instead: as_undirected(", base::paste(base::c("graph", "mode", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + ) + ) + } + } + # END GENERATED ARG_HANDLE + # Argument checks ensure_igraph(graph) - if (is.null(edge.attr.comb)) { - edge.attr.comb <- igraph_opt("edge.attr.comb") + if (is.null(edge_attr_combine)) { + edge_attr_combine <- igraph_opt("edge_attr_combine") } mode <- igraph_match_arg(mode) @@ -814,7 +852,7 @@ as_undirected <- function( res <- to_undirected_impl( graph = graph, mode = mode, - edge_attr_comb = edge.attr.comb + edge_attr_comb = edge_attr_combine ) res @@ -1792,10 +1830,10 @@ as.directed <- function( as.undirected <- function( graph, mode = c("collapse", "each", "mutual"), - edge.attr.comb = igraph_opt("edge.attr.comb") + edge.attr.comb = igraph_opt("edge_attr_combine") ) { lifecycle::deprecate_warn("2.1.0", "as.undirected()", "as_undirected()") - as_undirected(graph = graph, mode = mode, edge.attr.comb = edge.attr.comb) + as_undirected(graph = graph, mode = mode, edge_attr_combine = edge.attr.comb) } #' Create a graph from an edge list matrix diff --git a/R/make.R b/R/make.R index 7f245ca01ea..b1bef361fcf 100644 --- a/R/make.R +++ b/R/make.R @@ -1918,7 +1918,7 @@ graph_from_literal_i <- function(mf) { # to simplify (#824, #1981): `simplify()` rebuilds the graph sorted by # endpoint, and a formula that declares no loops and no multiple edges has no # reason to be rebuilt. The check belongs here rather than inside - # `simplify()`, where it also suppressed `edge.attr.comb` -- see the note + # `simplify()`, where it also suppressed `edge_attr_combine` -- see the note # there. `res` has no attributes yet, so skipping is unobservable beyond the # order. if (simplify && !is_simple(res)) { diff --git a/R/migration-fixture.R b/R/migration-fixture.R index 9d9de569d20..db00cc6d84b 100644 --- a/R/migration-fixture.R +++ b/R/migration-fixture.R @@ -1,5 +1,6 @@ -# Test fixture for the in-place argument-migration generator (tools/migrations.R, -# tools/generate-migrations.R). `migration_fixture()` carries a generated +# Test fixture for the in-place argument-migration generator +# (tools/migrations/fixture.R, tools/generate-migrations.R). +# `migration_fixture()` carries a generated # ARG_HANDLE block that recovers a legacy call to its pre-3.0.0 signature # f(graph, n, weight, kind, directed) -- now # f(graph, n, ..., weights, type, directed), with `weight` renamed to `weights` diff --git a/R/operators.R b/R/operators.R index 7b558ebcd61..bbd2c12a834 100644 --- a/R/operators.R +++ b/R/operators.R @@ -275,7 +275,7 @@ apply_one_combiner <- function(comb, x) { #' function. For graphs that lack some vertex/edge attribute, the corresponding #' values in the new graph are set to a missing value (`NA` for scalar attributes, #' `NULL` for list attributes). Graph attributes are combined according to -#' `graph.attr.comb`; by default any name clash is resolved by adding +#' `graph_attr_combine`; by default any name clash is resolved by adding #' suffixes (`_1`, `_2`, ...). See [igraph-attribute-combination] for the #' available combiners. #' @@ -289,8 +289,8 @@ apply_one_combiner <- function(comb, x) { #' @aliases %du% #' @param \dots Graph objects or lists of graph objects. #' @param x,y Graph objects. -#' @param graph.attr.comb Specification for combining shared graph attributes. -#' The default `NULL` uses the `graph.attr.comb` igraph option (`"rename"` +#' @param graph_attr_combine Specification for combining shared graph attributes. +#' The default `NULL` uses the `graph_attr_combine` igraph option (`"rename"` #' unless changed via [igraph_options()]), which preserves the historical #' behaviour of appending `_1`, `_2`, ... suffixes to clashing attribute #' names. See [igraph-attribute-combination] for the available combiners. @@ -309,10 +309,10 @@ apply_one_combiner <- function(comb, x) { #' @export disjoint_union <- function( ..., - graph.attr.comb = NULL + graph_attr_combine = NULL ) { - if (is.null(graph.attr.comb)) { - graph.attr.comb <- igraph_opt("graph.attr.comb") + if (is.null(graph_attr_combine)) { + graph_attr_combine <- igraph_opt("graph_attr_combine") } graphs <- unlist( @@ -327,11 +327,11 @@ disjoint_union <- function( res <- .Call(Rx_igraph_disjoint_union, graphs) ## Graph attributes - graph.attr.comb <- igraph.i.attribute.combination( - graph.attr.comb, + graph_attr_combine <- igraph.i.attribute.combination( + graph_attr_combine, allow_rename = TRUE ) - graph.attributes(res) <- combine.attrs("g", graphs, comb = graph.attr.comb) + graph.attributes(res) <- combine.attrs("g", graphs, comb = graph_attr_combine) ## Vertex attributes attr <- list() @@ -406,9 +406,9 @@ disjoint_union <- function( ..., byname, keep.all.vertices, - graph.attr.comb = "rename", - vertex.attr.comb = "rename", - edge.attr.comb = "rename" + graph_attr_combine = "rename", + vertex_attr_combine = "rename", + edge_attr_combine = "rename" ) { graphs <- unlist( recursive = FALSE, @@ -432,16 +432,16 @@ disjoint_union <- function( cli::cli_abort("Some graphs are not named.") } - graph.attr.comb <- igraph.i.attribute.combination( - graph.attr.comb, + graph_attr_combine <- igraph.i.attribute.combination( + graph_attr_combine, allow_rename = TRUE ) - vertex.attr.comb <- igraph.i.attribute.combination( - vertex.attr.comb, + vertex_attr_combine <- igraph.i.attribute.combination( + vertex_attr_combine, allow_rename = TRUE ) - edge.attr.comb <- igraph.i.attribute.combination( - edge.attr.comb, + edge_attr_combine <- igraph.i.attribute.combination( + edge_attr_combine, allow_rename = TRUE ) @@ -475,14 +475,14 @@ disjoint_union <- function( graph.attributes(res) <- combine.attrs( "g", newgraphs, - comb = graph.attr.comb + comb = graph_attr_combine ) vertex.attributes(res) <- combine.attrs( "v", newgraphs, vcount(res), ignore = "name", - comb = vertex.attr.comb + comb = vertex_attr_combine ) V(res)$name <- uninames @@ -493,7 +493,7 @@ disjoint_union <- function( newgraphs, ecount(res), maps = maps, - comb = edge.attr.comb + comb = edge_attr_combine ) } } else { @@ -520,13 +520,13 @@ disjoint_union <- function( graph.attributes(res) <- combine.attrs( "g", graphs, - comb = graph.attr.comb + comb = graph_attr_combine ) vertex.attributes(res) <- combine.attrs( "v", graphs, vcount(res), - comb = vertex.attr.comb + comb = vertex_attr_combine ) ## Edges are a bit more difficult, we need a mapping @@ -536,7 +536,7 @@ disjoint_union <- function( graphs, ecount(res), maps = maps, - comb = edge.attr.comb + comb = edge_attr_combine ) } } @@ -586,8 +586,8 @@ union.default <- function(...) { #' `union()` keeps the attributes of all graphs. All graph, vertex and #' edge attributes are copied to the result. By default, if an attribute is #' present in multiple graphs and would result in a name clash, that attribute -#' is renamed by adding suffixes: `_1`, `_2`, etc. Pass `graph.attr.comb`, -#' `vertex.attr.comb` or `edge.attr.comb` to combine clashing attributes +#' is renamed by adding suffixes: `_1`, `_2`, etc. Pass `graph_attr_combine`, +#' `vertex_attr_combine` or `edge_attr_combine` to combine clashing attributes #' instead, e.g. by summing or by taking the first non-`NA` value. See #' [igraph-attribute-combination] for the available combiners. #' @@ -605,10 +605,10 @@ union.default <- function(...) { #' `auto`, that means `TRUE` if all graphs are named and `FALSE` #' otherwise. A warning is generated if `auto` and some (but not all) #' graphs are named. -#' @param graph.attr.comb,vertex.attr.comb,edge.attr.comb Specification for -#' combining clashing graph, vertex and edge attributes. `vertex.attr.comb` -#' and `edge.attr.comb` default to `"rename"`; `graph.attr.comb` defaults to -#' the `graph.attr.comb` igraph option (`"rename"` unless changed via +#' @param graph_attr_combine,vertex_attr_combine,edge_attr_combine Specification for +#' combining clashing graph, vertex and edge attributes. `vertex_attr_combine` +#' and `edge_attr_combine` default to `"rename"`; `graph_attr_combine` defaults to +#' the `graph_attr_combine` igraph option (`"rename"` unless changed via #' [igraph_options()]). `"rename"` preserves the historical behaviour of #' appending `_1`, `_2`, ... suffixes. See [igraph-attribute-combination] for #' the available combiners. @@ -630,18 +630,18 @@ union.default <- function(...) { union.igraph <- function( ..., byname = "auto", - graph.attr.comb = igraph_opt("graph.attr.comb"), - vertex.attr.comb = "rename", - edge.attr.comb = "rename" + graph_attr_combine = igraph_opt("graph_attr_combine"), + vertex_attr_combine = "rename", + edge_attr_combine = "rename" ) { .igraph.graph.union.or.intersection( "union", ..., byname = byname, keep.all.vertices = TRUE, - graph.attr.comb = graph.attr.comb, - vertex.attr.comb = vertex.attr.comb, - edge.attr.comb = edge.attr.comb + graph_attr_combine = graph_attr_combine, + vertex_attr_combine = vertex_attr_combine, + edge_attr_combine = edge_attr_combine ) } @@ -687,7 +687,7 @@ intersection <- function(...) { #' vertex and edge attributes are copied to the result. By default, if an #' attribute is present in multiple graphs and would result in a name clash, #' that attribute is renamed by adding suffixes: `_1`, `_2`, etc. Pass -#' `graph.attr.comb`, `vertex.attr.comb` or `edge.attr.comb` to combine +#' `graph_attr_combine`, `vertex_attr_combine` or `edge_attr_combine` to combine #' clashing attributes instead; see [igraph-attribute-combination] for the #' available combiners. #' @@ -707,10 +707,10 @@ intersection <- function(...) { #' graphs are named. #' @param keep.all.vertices Logical, whether to keep vertices that only #' appear in a subset of the input graphs. -#' @param graph.attr.comb,vertex.attr.comb,edge.attr.comb Specification for -#' combining clashing graph, vertex and edge attributes. `vertex.attr.comb` -#' and `edge.attr.comb` default to `"rename"`; `graph.attr.comb` defaults to -#' the `graph.attr.comb` igraph option (`"rename"` unless changed via +#' @param graph_attr_combine,vertex_attr_combine,edge_attr_combine Specification for +#' combining clashing graph, vertex and edge attributes. `vertex_attr_combine` +#' and `edge_attr_combine` default to `"rename"`; `graph_attr_combine` defaults to +#' the `graph_attr_combine` igraph option (`"rename"` unless changed via #' [igraph_options()]). See [igraph-attribute-combination] for the available #' combiners. #' @return A new graph object. @@ -732,18 +732,18 @@ intersection.igraph <- function( ..., byname = "auto", keep.all.vertices = TRUE, - graph.attr.comb = igraph_opt("graph.attr.comb"), - vertex.attr.comb = "rename", - edge.attr.comb = "rename" + graph_attr_combine = igraph_opt("graph_attr_combine"), + vertex_attr_combine = "rename", + edge_attr_combine = "rename" ) { .igraph.graph.union.or.intersection( "intersection", ..., byname = byname, keep.all.vertices = keep.all.vertices, - graph.attr.comb = graph.attr.comb, - vertex.attr.comb = vertex.attr.comb, - edge.attr.comb = edge.attr.comb + graph_attr_combine = graph_attr_combine, + vertex_attr_combine = vertex_attr_combine, + edge_attr_combine = edge_attr_combine ) } @@ -966,8 +966,8 @@ complementer <- function( #' `compose()` keeps the attributes of both graphs. All graph, vertex #' and edge attributes are copied to the result. By default, if an attribute #' is present in both graphs and would result in a name clash, that attribute -#' is renamed by adding suffixes: `_1`, `_2`. Pass `graph.attr.comb`, -#' `vertex.attr.comb` or `edge.attr.comb` to combine clashing attributes +#' is renamed by adding suffixes: `_1`, `_2`. Pass `graph_attr_combine`, +#' `vertex_attr_combine` or `edge_attr_combine` to combine clashing attributes #' instead; see [igraph-attribute-combination] for the available combiners. #' #' The `name` vertex attribute is treated specially if the operation is @@ -998,10 +998,10 @@ complementer <- function( #' `auto`, that means `TRUE` if both graphs are named and #' `FALSE` otherwise. A warning is generated if `auto` and one graph, #' but not both graphs are named. -#' @param graph.attr.comb,vertex.attr.comb,edge.attr.comb Specification for -#' combining clashing graph, vertex and edge attributes. `vertex.attr.comb` -#' and `edge.attr.comb` default to `"rename"`; `graph.attr.comb` defaults to -#' the `graph.attr.comb` igraph option (`"rename"` unless changed via +#' @param graph_attr_combine,vertex_attr_combine,edge_attr_combine Specification for +#' combining clashing graph, vertex and edge attributes. `vertex_attr_combine` +#' and `edge_attr_combine` default to `"rename"`; `graph_attr_combine` defaults to +#' the `graph_attr_combine` igraph option (`"rename"` unless changed via #' [igraph_options()]). See [igraph-attribute-combination] for the available #' combiners. #' @return A new graph object. @@ -1022,13 +1022,15 @@ compose <- function( g2, ..., byname = "auto", - graph.attr.comb = NULL, - vertex.attr.comb = "rename", - edge.attr.comb = "rename" + graph_attr_combine = NULL, + vertex_attr_combine = "rename", + edge_attr_combine = "rename" ) { # BEGIN GENERATED ARG_HANDLE: compose, do not edit, see tools/generate-migrations.R # fmt: skip if (...length() > 0L) { + .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("g", "gr", "gra", "grap", "graph", "v", "ve", "ver", "vert", "verte", "vertex", "e", "ed", "edg", "edge")) + if (base::length(.arg_ambiguous) > 0L) cli::cli_abort("Argument {.arg {(.arg_ambiguous[[1L]])}} matches multiple arguments of {.fn compose}.") # Pre-3.0.0 signature: compose(g1, g2, byname, graph.attr.comb, vertex.attr.comb, edge.attr.comb) .old_signature <- function(byname, graph.attr.comb, vertex.attr.comb, edge.attr.comb, ...) { if (...length() > 0L) { @@ -1039,9 +1041,9 @@ compose <- function( } base::c( if (!base::missing(byname)) base::list(byname = byname), - if (!base::missing(graph.attr.comb)) base::list(graph.attr.comb = graph.attr.comb), - if (!base::missing(vertex.attr.comb)) base::list(vertex.attr.comb = vertex.attr.comb), - if (!base::missing(edge.attr.comb)) base::list(edge.attr.comb = edge.attr.comb) + if (!base::missing(graph.attr.comb)) base::list(graph_attr_combine = graph.attr.comb), + if (!base::missing(vertex.attr.comb)) base::list(vertex_attr_combine = vertex.attr.comb), + if (!base::missing(edge.attr.comb)) base::list(edge_attr_combine = edge.attr.comb) ) } .arg_handle <- .old_signature(...) @@ -1049,9 +1051,9 @@ compose <- function( .arg_names <- base::names(.arg_handle) .arg_conflict <- base::intersect(.arg_names, base::c( if (!base::missing(byname)) "byname", - if (!base::missing(graph.attr.comb)) "graph.attr.comb", - if (!base::missing(vertex.attr.comb)) "vertex.attr.comb", - if (!base::missing(edge.attr.comb)) "edge.attr.comb" + if (!base::missing(graph_attr_combine)) "graph_attr_combine", + if (!base::missing(vertex_attr_combine)) "vertex_attr_combine", + if (!base::missing(edge_attr_combine)) "edge_attr_combine" )) if (base::length(.arg_conflict) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn compose} was supplied more than once.", i = "Pass it exactly once, by its new name {.arg {(.arg_conflict)}}.")) base::list2env(.arg_handle, base::environment()) @@ -1059,7 +1061,7 @@ compose <- function( "3.0.0", what = base::I("Calling `compose()` with positional or abbreviated arguments"), details = base::c( - i = base::paste0("Detected call: compose(", base::paste(base::c("g1", "g2", .arg_names), collapse = ", "), ")"), + i = base::paste0("Detected call: compose(", base::paste(base::c("g1", "g2", base::c(byname = "byname", graph_attr_combine = "graph.attr.comb", vertex_attr_combine = "vertex.attr.comb", edge_attr_combine = "edge.attr.comb")[.arg_names]), collapse = ", "), ")"), i = base::paste0("Use instead: compose(", base::paste(base::c("g1", "g2", base::paste0(.arg_names, " = ")), collapse = ", "), ")") ) ) @@ -1070,8 +1072,8 @@ compose <- function( ensure_igraph(g1) ensure_igraph(g2) - if (is.null(graph.attr.comb)) { - graph.attr.comb <- igraph_opt("graph.attr.comb") + if (is.null(graph_attr_combine)) { + graph_attr_combine <- igraph_opt("graph_attr_combine") } if (byname != "auto" && !is.logical(byname)) { @@ -1089,16 +1091,16 @@ compose <- function( cli::cli_abort("Some graphs are not named.") } - graph.attr.comb <- igraph.i.attribute.combination( - graph.attr.comb, + graph_attr_combine <- igraph.i.attribute.combination( + graph_attr_combine, allow_rename = TRUE ) - vertex.attr.comb <- igraph.i.attribute.combination( - vertex.attr.comb, + vertex_attr_combine <- igraph.i.attribute.combination( + vertex_attr_combine, allow_rename = TRUE ) - edge.attr.comb <- igraph.i.attribute.combination( - edge.attr.comb, + edge_attr_combine <- igraph.i.attribute.combination( + edge_attr_combine, allow_rename = TRUE ) @@ -1127,7 +1129,7 @@ compose <- function( res <- res$graph graphs <- list(g1, g2) - graph.attributes(res) <- combine.attrs("g", graphs, comb = graph.attr.comb) + graph.attributes(res) <- combine.attrs("g", graphs, comb = graph_attr_combine) if (byname) { vertex.attributes(res) <- combine.attrs( @@ -1135,7 +1137,7 @@ compose <- function( graphs, vcount(res), ignore = "name", - comb = vertex.attr.comb + comb = vertex_attr_combine ) V(res)$name <- uninames } else { @@ -1143,7 +1145,7 @@ compose <- function( "v", graphs, vcount(res), - comb = vertex.attr.comb + comb = vertex_attr_combine ) } @@ -1153,7 +1155,7 @@ compose <- function( graphs, ecount(res), maps2 = maps, - comb = edge.attr.comb + comb = edge_attr_combine ) } diff --git a/R/par.R b/R/par.R index a57b7e8f9dc..7fe1f65d2ca 100644 --- a/R/par.R +++ b/R/par.R @@ -61,9 +61,9 @@ getIgraphOpt <- function(x, default = NULL) { "print.edge.attributes" = FALSE, "print.graph.attributes" = FALSE, "verbose" = FALSE, - "graph.attr.comb" = "rename", - "vertex.attr.comb" = list(name = "concat", "ignore"), - "edge.attr.comb" = list(weight = "sum", name = "concat", "ignore"), + "graph_attr_combine" = "rename", + "vertex_attr_combine" = list(name = "concat", "ignore"), + "edge_attr_combine" = list(weight = "sum", name = "concat", "ignore"), "sparsematrices" = TRUE, "add.params" = TRUE, "add.vertex.names" = TRUE, @@ -76,6 +76,39 @@ getIgraphOpt <- function(x, default = NULL) { "print.style" = "cli" ) +# Option keys that were renamed to snake_case. Reading or setting an option by +# its old dotted name still works, but maps to the canonical key and emits a +# soft-deprecation. +.igraph.pars.aliases <- c( + "graph.attr.comb" = "graph_attr_combine", + "vertex.attr.comb" = "vertex_attr_combine", + "edge.attr.comb" = "edge_attr_combine" +) + +# Map any deprecated option names in `x` to their canonical keys, warning once +# per deprecated name encountered. +# +# `user_env` must be the environment of whoever spelled the option name -- it +# is what `deprecate_soft()` consults to decide whether the deprecation is +# worth reporting. Its default would resolve to a frame inside igraph, which +# marks every alias use as indirect and emits nothing, so the public entry +# points pass their own caller down. +igraph_normalize_par_name <- function(x, user_env = rlang::caller_env(2)) { + for (i in seq_along(x)) { + new <- unname(.igraph.pars.aliases[x[i]]) + if (!is.na(new)) { + lifecycle::deprecate_soft( + "3.0.0", + I(paste0("The igraph option `", x[i], "`")), + I(paste0("the `", new, "` option")), + user_env = user_env + ) + x[i] <- new + } + } + x +} + igraph.pars.set.verbose <- function(verbose) { if (is.logical(verbose)) { .Call(Rx_igraph_set_verbose, verbose) @@ -139,12 +172,13 @@ igraph.pars.callbacks <- list("verbose" = igraph.pars.set.verbose) #' Possible values are \sQuote{auto} (the default), \sQuote{phylo}, \sQuote{hclust} and \sQuote{dendrogram}. #' See [plot_dendrogram()] for details. #' } -#' \item{edge.attr.comb}{ +#' \item{edge_attr_combine}{ #' Specifies what to do with the edge attributes if the graph is modified. #' The default value is `list(weight="sum", name="concat", "ignore")`. -#' See [attribute.combination()] for details on this. +#' See [attribute.combination()] for details on this. The former dotted +#' name `edge.attr.comb` still works but is soft-deprecated. #' } -#' \item{graph.attr.comb}{ +#' \item{graph_attr_combine}{ #' Specifies what to do with the graph attributes when graphs are #' combined, e.g. via [union()], [intersection()], [disjoint_union()] #' or [compose()]. The default value is `"rename"`, which resolves any @@ -188,10 +222,11 @@ igraph.pars.callbacks <- list("verbose" = igraph.pars.set.verbose) #' Logical constant, whether igraph functions should talk more than minimal. #' E.g. if `TRUE` then some functions will use progress bars while computing. Defaults to `FALSE`. #' } -#' \item{vertex.attr.comb}{ +#' \item{vertex_attr_combine}{ #' Specifies what to do with the vertex attributes if the graph is modified. #' The default value is `list(name="concat", "ignore")`. -#' See [attribute.combination()] for details on this. +#' See [attribute.combination()] for details on this. The former dotted +#' name `vertex.attr.comb` still works but is soft-deprecated. #' } #' } #' @@ -229,10 +264,14 @@ igraph.pars.callbacks <- list("verbose" = igraph.pars.set.verbose) #' @family igraph options #' @importFrom pkgconfig set_config_in get_config igraph_options <- function(...) { - igraph_i_options(...) + igraph_i_options(..., .user_env = parent.frame()) } -igraph_i_options <- function(..., .in = parent.frame()) { +igraph_i_options <- function( + ..., + .in = parent.frame(), + .user_env = parent.frame() +) { if (...length() == 0) { return(get_all_options()) } @@ -243,7 +282,7 @@ igraph_i_options <- function(..., .in = parent.frame()) { arg <- temp[[1]] if (mode(arg) == "character") { - return(.igraph.pars[arg]) + return(.igraph.pars[igraph_normalize_par_name(arg, .user_env)]) } if (mode(arg) != "list") { @@ -262,6 +301,8 @@ igraph_i_options <- function(..., .in = parent.frame()) { if (is.null(n)) { cli::cli_abort("options must be given by name.") } + names(temp) <- igraph_normalize_par_name(n, .user_env) + n <- names(temp) cb <- intersect(names(igraph.pars.callbacks), n) for (cn in cb) { temp[[cn]] <- igraph.pars.callbacks[[cn]](temp[[cn]]) @@ -337,6 +378,7 @@ igraph_opt <- function( } # END GENERATED ARG_HANDLE + x <- igraph_normalize_par_name(x, parent.frame()) if (missing(default)) { get_config(paste0("igraph::", x), .igraph.pars[[x]]) } else { diff --git a/R/simple.R b/R/simple.R index 9276307ac24..8ea5ebcc21b 100644 --- a/R/simple.R +++ b/R/simple.R @@ -68,11 +68,12 @@ is.simple <- function(graph) { #' @param remove.loops Logical, whether the loop edges are to be removed. #' @param remove.multiple Logical, whether the multiple edges are to be #' removed. -#' @param edge.attr.comb Specifies what to do with edge attributes, if +#' @inheritParams rlang::args_dots_empty +#' @param edge_attr_combine Specifies what to do with edge attributes, if #' `remove.multiple=TRUE`. In this case many edges might be mapped to a #' single one in the new graph, and their attributes are combined. Please see #' [attribute.combination()] for details on this. The default `NULL` uses -#' the `edge.attr.comb` igraph option. +#' the `edge_attr_combine` igraph option. #' @return a graph object with the loop and/or multiple edges removed; the #' input graph is returned unchanged if it is already simple. #' @author Gabor Csardi \email{csardi.gabor@@gmail.com} @@ -95,17 +96,55 @@ simplify <- function( graph, remove.multiple = TRUE, remove.loops = TRUE, - edge.attr.comb = NULL + ..., + edge_attr_combine = NULL ) { + # BEGIN GENERATED ARG_HANDLE: simplify, do not edit, see tools/generate-migrations.R + # fmt: skip + if (...length() > 0L) { + .arg_ambiguous <- base::intersect(base::names(base::substitute(...())), base::c("e", "ed", "edg", "edge")) + if (base::length(.arg_ambiguous) > 0L) cli::cli_abort("Argument {.arg {(.arg_ambiguous[[1L]])}} matches multiple arguments of {.fn simplify}.") + # Pre-3.0.0 signature: simplify(graph, remove.multiple, remove.loops, edge.attr.comb) + .old_signature <- function(edge.attr.comb, ...) { + 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 simplify}.", call = base::parent.frame()) + cli::cli_abort(base::c("Unexpected argument passed to {.fn simplify}: {.arg {(.arg_extra)}}.", i = "Arguments after {.arg ...} must be spelled out in full."), call = base::parent.frame()) + } + base::c( + if (!base::missing(edge.attr.comb)) base::list(edge_attr_combine = edge.attr.comb) + ) + } + .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(edge_attr_combine)) "edge_attr_combine" + )) + if (base::length(.arg_conflict) > 0L) cli::cli_abort(base::c("Argument {.arg {(.arg_conflict)}} of {.fn simplify} 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 `simplify()` with positional or abbreviated arguments"), + details = base::c( + i = base::paste0("Detected call: simplify(", base::paste(base::c("graph", "remove.multiple", "remove.loops", base::c(edge_attr_combine = "edge.attr.comb")[.arg_names]), collapse = ", "), ")"), + i = base::paste0("Use instead: simplify(", base::paste(base::c("graph", "remove.multiple", "remove.loops", base::paste0(.arg_names, " = ")), collapse = ", "), ")") + ) + ) + } + } + # END GENERATED ARG_HANDLE + # There was a short-circuit here -- `if (is_simple(graph)) return(graph)` -- # on the grounds that a graph with no loops and no multiple edges has # nothing for simplify_impl() to remove. That is true of its *structure* and - # false of its attributes: `edge.attr.comb` does not only combine attributes + # false of its attributes: `edge_attr_combine` does not only combine attributes # across merged edges, it decides which survive at all, and an attribute the # combination list does not name is dropped even when every group has one # member. The default list ends in `"ignore"`, so `simplify(g)` on a simple # graph is meant to keep `weight` and drop everything else, and - # `edge.attr.comb = "ignore"` is meant to leave no edge attributes at all. + # `edge_attr_combine = "ignore"` is meant to leave no edge attributes at all. # Returning `graph` untouched silently kept them both. # # Guarding the short-circuit on the graph having no edge attributes does not @@ -122,14 +161,14 @@ simplify <- function( # which simplifies a graph it has only just built from the formula, before # any attribute is set on it. Everywhere else `simplify()` goes through # `simplify_impl()` as it always did. - if (is.null(edge.attr.comb)) { - edge.attr.comb <- igraph_opt("edge.attr.comb") + if (is.null(edge_attr_combine)) { + edge_attr_combine <- igraph_opt("edge_attr_combine") } simplify_impl( graph = graph, remove_multiple = remove.multiple, remove_loops = remove.loops, - edge_attr_comb = edge.attr.comb + edge_attr_comb = edge_attr_combine ) } diff --git a/R/structural-properties.R b/R/structural-properties.R index c2970ebc5a9..be6b9422efa 100644 --- a/R/structural-properties.R +++ b/R/structural-properties.R @@ -3530,7 +3530,7 @@ girth <- function( #' # Remove multiple edges but keep multiplicity #' g <- sample_pa(10, m = 3, algorithm = "bag") #' E(g)$weight <- count_multiple(g) -#' g <- simplify(g, edge.attr.comb = list(weight = "min")) +#' g <- simplify(g, edge_attr_combine = list(weight = "min")) #' any(which_multiple(g)) #' E(g)$weight #' diff --git a/man/as.undirected.Rd b/man/as.undirected.Rd index 63476faf18b..073076eef72 100644 --- a/man/as.undirected.Rd +++ b/man/as.undirected.Rd @@ -7,7 +7,7 @@ as.undirected( graph, mode = c("collapse", "each", "mutual"), - edge.attr.comb = igraph_opt("edge.attr.comb") + edge.attr.comb = igraph_opt("edge_attr_combine") ) } \arguments{ @@ -17,12 +17,6 @@ as.undirected( \code{as_directed()} it can be \code{mutual} or \code{arbitrary}. For \code{as_undirected()} it can be \code{each}, \code{collapse} or \code{mutual}. See details below.} - -\item{edge.attr.comb}{Specifies what to do with edge attributes, if -\code{mode="collapse"} or \code{mode="mutual"}. In these cases many edges -might be mapped to a single one in the new graph, and their attributes are -combined. Please see \code{\link[=attribute.combination]{attribute.combination()}} for details on -this. The default \code{NULL} uses the \code{edge.attr.comb} igraph option.} } \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/as_directed.Rd b/man/as_directed.Rd index ca83689eb05..9ac1f884dd8 100644 --- a/man/as_directed.Rd +++ b/man/as_directed.Rd @@ -10,7 +10,8 @@ as_directed(graph, ..., mode = c("mutual", "arbitrary", "random", "acyclic")) as_undirected( graph, mode = c("collapse", "each", "mutual"), - edge.attr.comb = NULL + ..., + edge_attr_combine = NULL ) } \arguments{ @@ -23,11 +24,11 @@ as_undirected( \code{as_undirected()} it can be \code{each}, \code{collapse} or \code{mutual}. See details below.} -\item{edge.attr.comb}{Specifies what to do with edge attributes, if +\item{edge_attr_combine}{Specifies what to do with edge attributes, if \code{mode="collapse"} or \code{mode="mutual"}. In these cases many edges might be mapped to a single one in the new graph, and their attributes are combined. Please see \code{\link[=attribute.combination]{attribute.combination()}} for details on -this. The default \code{NULL} uses the \code{edge.attr.comb} igraph option.} +this. The default \code{NULL} uses the \code{edge_attr_combine} igraph option.} } \value{ A new graph object. @@ -117,7 +118,7 @@ g4 <- make_graph(c( E(g4)$weight <- seq_len(ecount(g4)) ug4 <- as_undirected(g4, mode = "mutual", - edge.attr.comb = list(weight = length) + edge_attr_combine = list(weight = length) ) print(ug4, e = TRUE) diff --git a/man/compose.Rd b/man/compose.Rd index ff5e5adcf7b..7f2c9029cde 100644 --- a/man/compose.Rd +++ b/man/compose.Rd @@ -10,9 +10,9 @@ compose( g2, ..., byname = "auto", - graph.attr.comb = NULL, - vertex.attr.comb = "rename", - edge.attr.comb = "rename" + graph_attr_combine = NULL, + vertex_attr_combine = "rename", + edge_attr_combine = "rename" ) } \arguments{ @@ -28,10 +28,10 @@ to perform the operation based on symbolic vertex names. If it is \code{FALSE} otherwise. A warning is generated if \code{auto} and one graph, but not both graphs are named.} -\item{graph.attr.comb, vertex.attr.comb, edge.attr.comb}{Specification for -combining clashing graph, vertex and edge attributes. \code{vertex.attr.comb} -and \code{edge.attr.comb} default to \code{"rename"}; \code{graph.attr.comb} defaults to -the \code{graph.attr.comb} igraph option (\code{"rename"} unless changed via +\item{graph_attr_combine, vertex_attr_combine, edge_attr_combine}{Specification for +combining clashing graph, vertex and edge attributes. \code{vertex_attr_combine} +and \code{edge_attr_combine} default to \code{"rename"}; \code{graph_attr_combine} defaults to +the \code{graph_attr_combine} igraph option (\code{"rename"} unless changed via \code{\link[=igraph_options]{igraph_options()}}). See \link{igraph-attribute-combination} for the available combiners.} } @@ -57,8 +57,8 @@ names. Otherwise numeric vertex IDs are used. \code{compose()} keeps the attributes of both graphs. All graph, vertex and edge attributes are copied to the result. By default, if an attribute is present in both graphs and would result in a name clash, that attribute -is renamed by adding suffixes: \verb{_1}, \verb{_2}. Pass \code{graph.attr.comb}, -\code{vertex.attr.comb} or \code{edge.attr.comb} to combine clashing attributes +is renamed by adding suffixes: \verb{_1}, \verb{_2}. Pass \code{graph_attr_combine}, +\code{vertex_attr_combine} or \code{edge_attr_combine} to combine clashing attributes instead; see \link{igraph-attribute-combination} for the available combiners. The \code{name} vertex attribute is treated specially if the operation is diff --git a/man/contract.Rd b/man/contract.Rd index aa11b59eced..a4c745dcf00 100644 --- a/man/contract.Rd +++ b/man/contract.Rd @@ -4,7 +4,7 @@ \alias{contract} \title{Contract several vertices into a single one} \usage{ -contract(graph, mapping, vertex.attr.comb = NULL) +contract(graph, mapping, ..., vertex_attr_combine = NULL) } \arguments{ \item{graph}{The input graph, it can be directed or undirected.} @@ -13,9 +13,11 @@ contract(graph, mapping, vertex.attr.comb = NULL) correspond to the vertices, and for each element the ID in the new graph is given.} -\item{vertex.attr.comb}{Specifies how to combine the vertex attributes in +\item{...}{These dots are for future extensions and must be empty.} + +\item{vertex_attr_combine}{Specifies how to combine the vertex attributes in the new graph. Please see \code{\link[=attribute.combination]{attribute.combination()}} for details. The -default \code{NULL} uses the \code{vertex.attr.comb} igraph option.} +default \code{NULL} uses the \code{vertex_attr_combine} igraph option.} } \value{ A new graph object. @@ -27,7 +29,7 @@ vertices in the new graph correspond to sets of vertices in the input graph. \details{ The attributes of the graph are kept. Graph and edge attributes are unchanged, vertex attributes are combined, according to the -\code{vertex.attr.comb} parameter. +\code{vertex_attr_combine} parameter. } \section{Related documentation in the C library}{ \href{https://igraph.org/c/html/0.10.17/igraph-Operators.html#igraph_contract_vertices}{\code{contract_vertices()}} @@ -41,7 +43,7 @@ V(g)$name <- letters[1:vcount(g)] E(g)$weight <- runif(ecount(g)) g2 <- contract(g, rep(1:5, each = 2), - vertex.attr.comb = toString + vertex_attr_combine = toString ) ## graph and edge attributes are kept, vertex attributes are diff --git a/man/contract.vertices.Rd b/man/contract.vertices.Rd index b527e63f73d..c5141e96353 100644 --- a/man/contract.vertices.Rd +++ b/man/contract.vertices.Rd @@ -7,7 +7,7 @@ contract.vertices( graph, mapping, - vertex.attr.comb = igraph_opt("vertex.attr.comb") + vertex.attr.comb = igraph_opt("vertex_attr_combine") ) } \arguments{ @@ -16,10 +16,6 @@ contract.vertices( \item{mapping}{A numeric vector that specifies the mapping. Its elements correspond to the vertices, and for each element the ID in the new graph is given.} - -\item{vertex.attr.comb}{Specifies how to combine the vertex attributes in -the new graph. Please see \code{\link[=attribute.combination]{attribute.combination()}} for details. The -default \code{NULL} uses the \code{vertex.attr.comb} igraph option.} } \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/disjoint_union.Rd b/man/disjoint_union.Rd index c0ae54327cf..11ae520fc29 100644 --- a/man/disjoint_union.Rd +++ b/man/disjoint_union.Rd @@ -5,15 +5,15 @@ \alias{\%du\%} \title{Disjoint union of graphs} \usage{ -disjoint_union(..., graph.attr.comb = NULL) +disjoint_union(..., graph_attr_combine = NULL) x \%du\% y } \arguments{ \item{\dots}{Graph objects or lists of graph objects.} -\item{graph.attr.comb}{Specification for combining shared graph attributes. -The default \code{NULL} uses the \code{graph.attr.comb} igraph option (\code{"rename"} +\item{graph_attr_combine}{Specification for combining shared graph attributes. +The default \code{NULL} uses the \code{graph_attr_combine} igraph option (\code{"rename"} unless changed via \code{\link[=igraph_options]{igraph_options()}}), which preserves the historical behaviour of appending \verb{_1}, \verb{_2}, ... suffixes to clashing attribute names. See \link{igraph-attribute-combination} for the available combiners.} @@ -38,7 +38,7 @@ particular, it merges vertex and edge attributes using the \code{\link[vctrs:vec function. For graphs that lack some vertex/edge attribute, the corresponding values in the new graph are set to a missing value (\code{NA} for scalar attributes, \code{NULL} for list attributes). Graph attributes are combined according to -\code{graph.attr.comb}; by default any name clash is resolved by adding +\code{graph_attr_combine}; by default any name clash is resolved by adding suffixes (\verb{_1}, \verb{_2}, ...). See \link{igraph-attribute-combination} for the available combiners. diff --git a/man/igraph-attribute-combination.Rd b/man/igraph-attribute-combination.Rd index 03e5e10f460..b36ff376c89 100644 --- a/man/igraph-attribute-combination.Rd +++ b/man/igraph-attribute-combination.Rd @@ -13,7 +13,7 @@ vertex/edge attributes in these cases. } \details{ The functions that support the combination of attributes have one or two -extra arguments called \code{vertex.attr.comb} and/or \code{edge.attr.comb} +extra arguments called \code{vertex_attr_combine} and/or \code{edge_attr_combine} that specify how to perform the mapping of the attributes. E.g. \code{\link[=contract]{contract()}} contracts many vertices into a single one, the attributes of the vertices can be combined and stores as the vertex @@ -119,22 +119,22 @@ igraph_options(print.vertex.attributes = TRUE) igraph_options(print.edge.attributes = TRUE) ## new attribute is the sum of the old ones -simplify(g, edge.attr.comb = "sum") +simplify(g, edge_attr_combine = "sum") ## collect attributes into a string -simplify(g, edge.attr.comb = toString) +simplify(g, edge_attr_combine = toString) ## concatenate them into a vector, this creates a complex ## attribute -simplify(g, edge.attr.comb = "concat") +simplify(g, edge_attr_combine = "concat") E(g)$name <- letters[seq_len(ecount(g))] ## both attributes are collected into strings -simplify(g, edge.attr.comb = toString) +simplify(g, edge_attr_combine = toString) ## harmonic average of weights, names are dropped -simplify(g, edge.attr.comb = list( +simplify(g, edge_attr_combine = list( weight = function(x) length(x) / sum(1 / x), name = "ignore" )) diff --git a/man/igraph_options.Rd b/man/igraph_options.Rd index 8ba971f89fc..0cce7d7eccb 100644 --- a/man/igraph_options.Rd +++ b/man/igraph_options.Rd @@ -65,12 +65,13 @@ The plotting function to use when plotting community structure dendrograms via \ Possible values are \sQuote{auto} (the default), \sQuote{phylo}, \sQuote{hclust} and \sQuote{dendrogram}. See \code{\link[=plot_dendrogram]{plot_dendrogram()}} for details. } -\item{edge.attr.comb}{ +\item{edge_attr_combine}{ Specifies what to do with the edge attributes if the graph is modified. The default value is \code{list(weight="sum", name="concat", "ignore")}. -See \code{\link[=attribute.combination]{attribute.combination()}} for details on this. +See \code{\link[=attribute.combination]{attribute.combination()}} for details on this. The former dotted +name \code{edge.attr.comb} still works but is soft-deprecated. } -\item{graph.attr.comb}{ +\item{graph_attr_combine}{ Specifies what to do with the graph attributes when graphs are combined, e.g. via \code{\link[=union]{union()}}, \code{\link[=intersection]{intersection()}}, \code{\link[=disjoint_union]{disjoint_union()}} or \code{\link[=compose]{compose()}}. The default value is \code{"rename"}, which resolves any @@ -114,10 +115,11 @@ It is recommended, if the user works with larger graphs. Logical constant, whether igraph functions should talk more than minimal. E.g. if \code{TRUE} then some functions will use progress bars while computing. Defaults to \code{FALSE}. } -\item{vertex.attr.comb}{ +\item{vertex_attr_combine}{ Specifies what to do with the vertex attributes if the graph is modified. The default value is \code{list(name="concat", "ignore")}. -See \code{\link[=attribute.combination]{attribute.combination()}} for details on this. +See \code{\link[=attribute.combination]{attribute.combination()}} for details on this. The former dotted +name \code{vertex.attr.comb} still works but is soft-deprecated. } } } diff --git a/man/intersection.igraph.Rd b/man/intersection.igraph.Rd index 6a07aae79f7..a4aa3acbedf 100644 --- a/man/intersection.igraph.Rd +++ b/man/intersection.igraph.Rd @@ -9,9 +9,9 @@ ..., byname = "auto", keep.all.vertices = TRUE, - graph.attr.comb = igraph_opt("graph.attr.comb"), - vertex.attr.comb = "rename", - edge.attr.comb = "rename" + graph_attr_combine = igraph_opt("graph_attr_combine"), + vertex_attr_combine = "rename", + edge_attr_combine = "rename" ) } \arguments{ @@ -26,10 +26,10 @@ graphs are named.} \item{keep.all.vertices}{Logical, whether to keep vertices that only appear in a subset of the input graphs.} -\item{graph.attr.comb, vertex.attr.comb, edge.attr.comb}{Specification for -combining clashing graph, vertex and edge attributes. \code{vertex.attr.comb} -and \code{edge.attr.comb} default to \code{"rename"}; \code{graph.attr.comb} defaults to -the \code{graph.attr.comb} igraph option (\code{"rename"} unless changed via +\item{graph_attr_combine, vertex_attr_combine, edge_attr_combine}{Specification for +combining clashing graph, vertex and edge attributes. \code{vertex_attr_combine} +and \code{edge_attr_combine} default to \code{"rename"}; \code{graph_attr_combine} defaults to +the \code{graph_attr_combine} igraph option (\code{"rename"} unless changed via \code{\link[=igraph_options]{igraph_options()}}). See \link{igraph-attribute-combination} for the available combiners.} } @@ -53,7 +53,7 @@ of the internal numeric vertex IDs. vertex and edge attributes are copied to the result. By default, if an attribute is present in multiple graphs and would result in a name clash, that attribute is renamed by adding suffixes: \verb{_1}, \verb{_2}, etc. Pass -\code{graph.attr.comb}, \code{vertex.attr.comb} or \code{edge.attr.comb} to combine +\code{graph_attr_combine}, \code{vertex_attr_combine} or \code{edge_attr_combine} to combine clashing attributes instead; see \link{igraph-attribute-combination} for the available combiners. diff --git a/man/simplify.Rd b/man/simplify.Rd index 91a279f97b4..22217b30177 100644 --- a/man/simplify.Rd +++ b/man/simplify.Rd @@ -10,7 +10,8 @@ simplify( graph, remove.multiple = TRUE, remove.loops = TRUE, - edge.attr.comb = NULL + ..., + edge_attr_combine = NULL ) is_simple(graph) @@ -25,11 +26,13 @@ removed.} \item{remove.loops}{Logical, whether the loop edges are to be removed.} -\item{edge.attr.comb}{Specifies what to do with edge attributes, if +\item{...}{These dots are for future extensions and must be empty.} + +\item{edge_attr_combine}{Specifies what to do with edge attributes, if \code{remove.multiple=TRUE}. In this case many edges might be mapped to a single one in the new graph, and their attributes are combined. Please see \code{\link[=attribute.combination]{attribute.combination()}} for details on this. The default \code{NULL} uses -the \code{edge.attr.comb} igraph option.} +the \code{edge_attr_combine} igraph option.} } \value{ a graph object with the loop and/or multiple edges removed; the diff --git a/man/union.igraph.Rd b/man/union.igraph.Rd index f75202bc1d8..b21a049e67d 100644 --- a/man/union.igraph.Rd +++ b/man/union.igraph.Rd @@ -8,9 +8,9 @@ \method{union}{igraph}( ..., byname = "auto", - graph.attr.comb = igraph_opt("graph.attr.comb"), - vertex.attr.comb = "rename", - edge.attr.comb = "rename" + graph_attr_combine = igraph_opt("graph_attr_combine"), + vertex_attr_combine = "rename", + edge_attr_combine = "rename" ) } \arguments{ @@ -22,10 +22,10 @@ to perform the operation based on symbolic vertex names. If it is otherwise. A warning is generated if \code{auto} and some (but not all) graphs are named.} -\item{graph.attr.comb, vertex.attr.comb, edge.attr.comb}{Specification for -combining clashing graph, vertex and edge attributes. \code{vertex.attr.comb} -and \code{edge.attr.comb} default to \code{"rename"}; \code{graph.attr.comb} defaults to -the \code{graph.attr.comb} igraph option (\code{"rename"} unless changed via +\item{graph_attr_combine, vertex_attr_combine, edge_attr_combine}{Specification for +combining clashing graph, vertex and edge attributes. \code{vertex_attr_combine} +and \code{edge_attr_combine} default to \code{"rename"}; \code{graph_attr_combine} defaults to +the \code{graph_attr_combine} igraph option (\code{"rename"} unless changed via \code{\link[=igraph_options]{igraph_options()}}). \code{"rename"} preserves the historical behaviour of appending \verb{_1}, \verb{_2}, ... suffixes. See \link{igraph-attribute-combination} for the available combiners.} @@ -49,8 +49,8 @@ of the internal numeric vertex IDs. \code{union()} keeps the attributes of all graphs. All graph, vertex and edge attributes are copied to the result. By default, if an attribute is present in multiple graphs and would result in a name clash, that attribute -is renamed by adding suffixes: \verb{_1}, \verb{_2}, etc. Pass \code{graph.attr.comb}, -\code{vertex.attr.comb} or \code{edge.attr.comb} to combine clashing attributes +is renamed by adding suffixes: \verb{_1}, \verb{_2}, etc. Pass \code{graph_attr_combine}, +\code{vertex_attr_combine} or \code{edge_attr_combine} to combine clashing attributes instead, e.g. by summing or by taking the first non-\code{NA} value. See \link{igraph-attribute-combination} for the available combiners. diff --git a/man/which_multiple.Rd b/man/which_multiple.Rd index a705616f7d6..4d166b4a5a2 100644 --- a/man/which_multiple.Rd +++ b/man/which_multiple.Rd @@ -88,7 +88,7 @@ which_multiple(make_graph(c(1, 2, 2, 1), dir = FALSE)) # Remove multiple edges but keep multiplicity g <- sample_pa(10, m = 3, algorithm = "bag") E(g)$weight <- count_multiple(g) -g <- simplify(g, edge.attr.comb = list(weight = "min")) +g <- simplify(g, edge_attr_combine = list(weight = "min")) any(which_multiple(g)) E(g)$weight diff --git a/tests/testthat/test-attributes.R b/tests/testthat/test-attributes.R index f46f03db367..b407cb5482a 100644 --- a/tests/testthat/test-attributes.R +++ b/tests/testthat/test-attributes.R @@ -214,11 +214,11 @@ test_that("attribute combinations handle errors correctly", { g <- make_graph(c(1, 2, 2, 1)) E(g)$weight <- c("a", "b") expect_error( - as_undirected(g, edge.attr.comb = list(weight = "sum")), + as_undirected(g, edge_attr_combine = list(weight = "sum")), "invalid 'type'" ) expect_error( - as_undirected(g, edge.attr.comb = list(weight = sum)), + as_undirected(g, edge_attr_combine = list(weight = sum)), "invalid 'type'" ) }) diff --git a/tests/testthat/test-community.R b/tests/testthat/test-community.R index 65183998533..952fba7f71f 100644 --- a/tests/testthat/test-community.R +++ b/tests/testthat/test-community.R @@ -646,7 +646,7 @@ test_that("contract works", { V(g)$name <- letters[1:vcount(g)] E(g)$weight <- sample(ecount(g)) - g2 <- contract(g, rep(1:5, each = 2), vertex.attr.comb = toString) + g2 <- contract(g, rep(1:5, each = 2), vertex_attr_combine = toString) expect_equal(g2$name, g$name) expect_equal(V(g2)$name, c("a, b", "c, d", "e, f", "g, h", "i, j")) diff --git a/tests/testthat/test-constant-defaults.R b/tests/testthat/test-constant-defaults.R index f8770f4eb44..064da70e73a 100644 --- a/tests/testthat/test-constant-defaults.R +++ b/tests/testthat/test-constant-defaults.R @@ -54,11 +54,11 @@ test_that("NULL non-selector defaults of round-2 functions resolve in the body", # option-backed defaults fall back to the igraph option expect_identical_graphs( - simplify(g + edge(1, 2), edge.attr.comb = NULL), + simplify(g + edge(1, 2), edge_attr_combine = NULL), simplify(g + edge(1, 2)) ) expect_identical_graphs( - as_undirected(as_directed(g), edge.attr.comb = NULL), + as_undirected(as_directed(g), edge_attr_combine = NULL), as_undirected(as_directed(g)) ) diff --git a/tests/testthat/test-operators.R b/tests/testthat/test-operators.R index d818c2089d5..fbf6bdb1eaa 100644 --- a/tests/testthat/test-operators.R +++ b/tests/testthat/test-operators.R @@ -1306,14 +1306,14 @@ test_that("union() defaults to rename behaviour", { test_that("union() combines vertex attributes with sum", { gs <- make_named_pair() - u <- union(gs$g1, gs$g2, vertex.attr.comb = "sum") + u <- union(gs$g1, gs$g2, vertex_attr_combine = "sum") expect_setequal(vertex_attr_names(u), c("name", "weight")) expect_equal(sort(V(u)$weight), sort(c(11, 22, 33))) }) test_that("union() combines edge attributes with sum", { gs <- make_named_pair() - u <- union(gs$g1, gs$g2, edge.attr.comb = "sum") + u <- union(gs$g1, gs$g2, edge_attr_combine = "sum") expect_setequal(edge_attr_names(u), c("weight")) expect_equal(sort(E(u)$weight), sort(c(11, 22, 33))) }) @@ -1325,7 +1325,7 @@ test_that("union() honours per-attribute list spec with rename fallback", { u <- union( gs$g1, gs$g2, - vertex.attr.comb = list(weight = "sum", "rename") + vertex_attr_combine = list(weight = "sum", "rename") ) expect_setequal( vertex_attr_names(u), @@ -1335,7 +1335,7 @@ test_that("union() honours per-attribute list spec with rename fallback", { test_that("union() can drop clashing attributes with ignore", { gs <- make_named_pair() - u <- union(gs$g1, gs$g2, edge.attr.comb = "ignore") + u <- union(gs$g1, gs$g2, edge_attr_combine = "ignore") expect_length(edge_attr_names(u), 0) }) @@ -1344,14 +1344,14 @@ test_that("union() supports custom function combiner", { u <- union( gs$g1, gs$g2, - vertex.attr.comb = list(weight = function(x) mean(x)) + vertex_attr_combine = list(weight = function(x) mean(x)) ) expect_equal(sort(V(u)$weight), sort(c(5.5, 11, 16.5))) }) test_that("union() picks first non-NA when only one input has the attr", { gs <- make_named_pair() - u <- union(gs$g1, gs$g2, vertex.attr.comb = "first", byname = TRUE) + u <- union(gs$g1, gs$g2, vertex_attr_combine = "first", byname = TRUE) expect_setequal(vertex_attr_names(u), c("name", "weight")) expect_equal( V(u)$weight[match(c("A", "B", "C"), V(u)$name)], @@ -1359,19 +1359,19 @@ test_that("union() picks first non-NA when only one input has the attr", { ) }) -test_that("intersection() takes attr.comb args", { +test_that("intersection() takes attr_combine args", { gs <- make_named_pair() - i <- intersection(gs$g1, gs$g2, edge.attr.comb = "sum") + i <- intersection(gs$g1, gs$g2, edge_attr_combine = "sum") expect_setequal(edge_attr_names(i), c("weight")) expect_equal(sort(E(i)$weight), sort(c(11, 22, 33))) }) -test_that("compose() takes attr.comb args", { +test_that("compose() takes attr_combine args", { g1 <- graph_from_literal(A - B:D:E, B - C:D, C - D, D - E) g2 <- graph_from_literal(A - B - E - A) V(g1)$foo <- seq_len(vcount(g1)) V(g2)$foo <- 10 * seq_len(vcount(g2)) - g <- compose(g1, g2, vertex.attr.comb = "sum") + g <- compose(g1, g2, vertex_attr_combine = "sum") expect_true("foo" %in% vertex_attr_names(g)) expect_false("foo_1" %in% vertex_attr_names(g)) }) @@ -1381,12 +1381,12 @@ test_that("disjoint_union() combines graph attrs via comb", { g2 <- make_ring(3) g1$label <- "first" g2$label <- "second" - u <- disjoint_union(g1, g2, graph.attr.comb = "concat") + u <- disjoint_union(g1, g2, graph_attr_combine = "concat") expect_equal(u$label, c("first", "second")) }) -test_that("graph.attr.comb defaults to the graph.attr.comb igraph option", { - expect_equal(igraph_opt("graph.attr.comb"), "rename") +test_that("graph_attr_combine defaults to the graph_attr_combine igraph option", { + expect_equal(igraph_opt("graph_attr_combine"), "rename") g1 <- make_ring(3) g2 <- make_ring(3) @@ -1398,7 +1398,7 @@ test_that("graph.attr.comb defaults to the graph.attr.comb igraph option", { expect_all_true(c("label_1", "label_2") %in% graph_attr_names(u)) # Setting the option changes the default for the graph operators. - local_igraph_options(graph.attr.comb = "ignore") + local_igraph_options(graph_attr_combine = "ignore") expect_length(graph_attr_names(union(g1, g2)), 0) expect_length(graph_attr_names(intersection(g1, g2)), 0) expect_length(graph_attr_names(disjoint_union(g1, g2)), 0) @@ -1417,8 +1417,8 @@ simple_graph_with_attrs <- function() { g } -test_that("simplify() applies edge.attr.comb to an already-simple graph", { - # `edge.attr.comb` does not only combine attributes across merged edges, it +test_that("simplify() applies edge_attr_combine to an already-simple graph", { + # `edge_attr_combine` does not only combine attributes across merged edges, it # decides which survive at all: an attribute the list does not name is # dropped even when every group has one member. So a graph that is already # simple still has to go through the combination. @@ -1428,14 +1428,14 @@ test_that("simplify() applies edge.attr.comb to an already-simple graph", { expect_length( edge_attr_names(simplify( simple_graph_with_attrs(), - edge.attr.comb = "ignore" + edge_attr_combine = "ignore" )), 0 ) expect_setequal( edge_attr_names(simplify( simple_graph_with_attrs(), - edge.attr.comb = list(weight = "sum", foo = "first") + edge_attr_combine = list(weight = "sum", foo = "first") )), c("weight", "foo") ) @@ -1459,9 +1459,12 @@ test_that("simplify() is still cache-sensitive, which is a C-core issue", { warm <- simple_graph_with_attrs() invisible(is_simple(warm)) - expect_length(edge_attr_names(simplify(cold, edge.attr.comb = "ignore")), 0) + expect_length( + edge_attr_names(simplify(cold, edge_attr_combine = "ignore")), + 0 + ) expect_setequal( - edge_attr_names(simplify(warm, edge.attr.comb = "ignore")), + edge_attr_names(simplify(warm, edge_attr_combine = "ignore")), c("weight", "foo") ) }) @@ -1471,7 +1474,7 @@ test_that("graph_from_literal() keeps the formula's edge order", { # reason to be rebuilt, so the edges come back in the order they were # written. `graph_from_literal_i()` skips `simplify()` outright to get that, # rather than `simplify()` skipping itself -- which would also suppress - # `edge.attr.comb` for every other caller. + # `edge_attr_combine` for every other caller. expect_equal( as_edgelist(graph_from_literal(X - +Z - +Y, Y - +X, X - +Y)), rbind(c("X", "Z"), c("Z", "Y"), c("Y", "X"), c("X", "Y")) @@ -1488,7 +1491,7 @@ test_that("simplify() rejects 'rename' combiner", { g <- make_graph(c(1, 2, 1, 2, 1, 2, 2, 3, 3, 4)) E(g)$weight <- 1:5 expect_error( - simplify(g, edge.attr.comb = "rename"), + simplify(g, edge_attr_combine = "rename"), "rename" ) }) @@ -1524,9 +1527,9 @@ test_that("compose() takes all tail arguments by name", { g1, g2, byname = FALSE, - graph.attr.comb = "first", - vertex.attr.comb = "first", - edge.attr.comb = "concat" + graph_attr_combine = "first", + vertex_attr_combine = "first", + edge_attr_combine = "concat" ) # By vertex ID the graphs overlap; by name they are disjoint (6 vertices, no edge). @@ -1548,4 +1551,13 @@ test_that("compose() recovers legacy positional arguments", { res <- compose(g1, g2, FALSE) ) expect_identical_graphs(res, compose(g1, g2, byname = FALSE)) + + # The old dotted argument names are recovered from `...` and soft-deprecate. + lifecycle::expect_deprecated( + res_dotted <- compose(g1, g2, byname = FALSE, edge.attr.comb = "concat") + ) + expect_identical_graphs( + res_dotted, + compose(g1, g2, byname = FALSE, edge_attr_combine = "concat") + ) }) diff --git a/tools/migrations/attr-comb.R b/tools/migrations/attr-comb.R new file mode 100644 index 00000000000..4f9987ed501 --- /dev/null +++ b/tools/migrations/attr-comb.R @@ -0,0 +1,46 @@ +# Argument-signature migrations: attribute combination +# Schema: see tools/migrations/README.md. Regenerate with: +# Rscript tools/generate-migrations.R + +migrations <- list( + # Dotted `*.attr.comb` arguments renamed to snake_case. The old dotted names + # keep working (recovered from `...`) under a single soft-deprecation. + simplify = list( + old = function( + graph, + remove.multiple, + remove.loops, + edge.attr.comb = edge_attr_combine + ) {}, + new = function( + graph, + remove.multiple = TRUE, + remove.loops = TRUE, + ..., + edge_attr_combine = NULL + ) {}, + when = "3.0.0" + ), + + as_undirected = list( + old = function(graph, mode, edge.attr.comb = edge_attr_combine) {}, + new = function( + graph, + mode = c("collapse", "each", "mutual"), + ..., + edge_attr_combine = NULL + ) {}, + when = "3.0.0" + ), + + contract = list( + old = function(graph, mapping, vertex.attr.comb = vertex_attr_combine) {}, + new = function( + graph, + mapping, + ..., + vertex_attr_combine = NULL + ) {}, + when = "3.0.0" + ) +) diff --git a/tools/migrations/centrality.R b/tools/migrations/centrality.R index 4e6c02ac37f..394818faff1 100644 --- a/tools/migrations/centrality.R +++ b/tools/migrations/centrality.R @@ -1,5 +1,5 @@ # Argument-signature migrations: centrality -# Schema: see tools/migrations.R. Regenerate with: +# Schema: see tools/migrations/README.md. Regenerate with: # Rscript tools/generate-migrations.R migrations <- list( diff --git a/tools/migrations/centralization.R b/tools/migrations/centralization.R index 0844a295b1b..3f7d94bcdf8 100644 --- a/tools/migrations/centralization.R +++ b/tools/migrations/centralization.R @@ -1,5 +1,5 @@ # Argument-signature migrations: centralization -# Schema: see tools/migrations.R. Regenerate with: +# Schema: see tools/migrations/README.md. Regenerate with: # Rscript tools/generate-migrations.R migrations <- list( diff --git a/tools/migrations/community.R b/tools/migrations/community.R index d8cb12bc310..a5d6afb3a9e 100644 --- a/tools/migrations/community.R +++ b/tools/migrations/community.R @@ -1,5 +1,5 @@ # Argument-signature migrations: community -# Schema: see tools/migrations.R. Regenerate with: +# Schema: see tools/migrations/README.md. Regenerate with: # Rscript tools/generate-migrations.R migrations <- list( diff --git a/tools/migrations/operators.R b/tools/migrations/operators.R index fb6ac480c24..4d988fac2bc 100644 --- a/tools/migrations/operators.R +++ b/tools/migrations/operators.R @@ -18,18 +18,18 @@ migrations <- list( g1, g2, byname, - graph.attr.comb, - vertex.attr.comb, - edge.attr.comb + graph.attr.comb = graph_attr_combine, + vertex.attr.comb = vertex_attr_combine, + edge.attr.comb = edge_attr_combine ) {}, new = function( g1, g2, ..., byname = "auto", - graph.attr.comb = NULL, - vertex.attr.comb = "rename", - edge.attr.comb = "rename" + graph_attr_combine = NULL, + vertex_attr_combine = "rename", + edge_attr_combine = "rename" ) {}, when = "3.0.0" ), diff --git a/tools/migrations/structural-properties.R b/tools/migrations/structural-properties.R index b7b781964f5..bcd7229fbb8 100644 --- a/tools/migrations/structural-properties.R +++ b/tools/migrations/structural-properties.R @@ -1,5 +1,5 @@ # Argument-signature migrations: structural-properties -# Schema: see tools/migrations.R. Regenerate with: +# Schema: see tools/migrations/README.md. Regenerate with: # Rscript tools/generate-migrations.R migrations <- list( diff --git a/tools/stimulus/types-RR.yaml b/tools/stimulus/types-RR.yaml index bfb5ca69ed8..0594b749682 100644 --- a/tools/stimulus/types-RR.yaml +++ b/tools/stimulus/types-RR.yaml @@ -531,12 +531,12 @@ SUBGRAPH_IMPL: EDGE_ATTRIBUTE_COMBINATION: DEFAULT: - Default: igraph_opt("edge.attr.comb") + Default: igraph_opt("edge_attr_combine") INCONV: '%I% <- igraph.i.attribute.combination(%I%)' VERTEX_ATTRIBUTE_COMBINATION: DEFAULT: - Default: igraph_opt("vertex.attr.comb") + Default: igraph_opt("vertex_attr_combine") INCONV: '%I% <- igraph.i.attribute.combination(%I%)' ADD_WEIGHTS: