Skip to content

Commit b2fa62d

Browse files
committed
refactor: move optional arguments of conversion functions behind the ellipsis
Insert `...` between the defining arguments and the optional modifiers of 11 functions, following the zoning rules in CONTRIBUTING.md. Legacy positional and abbreviated calls are recovered by the generated ARG_HANDLE blocks (registry: tools/migrations/conversion.R) and emit a single soft deprecation for igraph 3.0.0. No defaults change and no arguments are renamed. Functions: as_adj_edge_list, as_adj_list, as_directed, as_edgelist, from_adjacency, graph_from_adj_list, graph_from_adjacency_matrix, graph_from_biadjacency_matrix, graph_from_data_frame, graph_from_edgelist, graph_from_graphnel Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016M32izVHZPfxAqemAe4BrX
1 parent acbf688 commit b2fa62d

20 files changed

Lines changed: 555 additions & 29 deletions

‎R/adjacency.R‎

Lines changed: 109 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ graph.adjacency <- function(
136136
#'
137137
#' @param adjmatrix A square adjacency matrix. From igraph version 0.5.1 this
138138
#' can be a sparse matrix created with the `Matrix` package.
139+
#' @inheritParams rlang::args_dots_empty
139140
#' @param mode Character scalar, specifies how igraph should interpret the
140141
#' supplied matrix. See also the `weighted` argument, the interpretation
141142
#' depends on that too. Possible values are: `directed`,
@@ -275,20 +276,65 @@ graph.adjacency <- function(
275276
#' @export
276277
graph_from_adjacency_matrix <- function(
277278
adjmatrix,
278-
mode = c(
279-
"directed",
280-
"undirected",
281-
"max",
282-
"min",
283-
"upper",
284-
"lower",
285-
"plus"
286-
),
279+
...,
280+
mode = c( "directed", "undirected", "max", "min", "upper", "lower", "plus" ),
287281
weighted = NULL,
288282
diag = TRUE,
289283
add.colnames = NULL,
290284
add.rownames = NA
291285
) {
286+
# BEGIN GENERATED ARG_HANDLE: graph_from_adjacency_matrix, do not edit, see tools/generate-migrations.R
287+
if (...length() > 0L) {
288+
.arg_handle <- migrate_recover_args(
289+
list(...),
290+
current = list(
291+
mode = mode,
292+
weighted = weighted,
293+
diag = diag,
294+
add.colnames = add.colnames,
295+
add.rownames = add.rownames
296+
),
297+
recover_new = c(
298+
"mode",
299+
"weighted",
300+
"diag",
301+
"add.colnames",
302+
"add.rownames"
303+
),
304+
recover_old = c(
305+
"mode",
306+
"weighted",
307+
"diag",
308+
"add.colnames",
309+
"add.rownames"
310+
),
311+
match_names = c(
312+
"mode",
313+
"weighted",
314+
"diag",
315+
"add.colnames",
316+
"add.rownames"
317+
),
318+
match_to = c("mode", "weighted", "diag", "add.colnames", "add.rownames"),
319+
defaults = list(
320+
mode = c("directed", "undirected", "max", "min", "upper", "lower", "plus"),
321+
weighted = NULL,
322+
diag = TRUE,
323+
add.colnames = NULL,
324+
add.rownames = NA
325+
),
326+
head_args = c("adjmatrix"),
327+
fn_name = "graph_from_adjacency_matrix"
328+
)
329+
list2env(.arg_handle$values, environment())
330+
lifecycle::deprecate_soft(
331+
"3.0.0",
332+
what = I(.arg_handle$what),
333+
details = .arg_handle$details
334+
)
335+
}
336+
# END GENERATED ARG_HANDLE
337+
292338
mode <- igraph_match_arg(mode)
293339
ensure_no_na(adjmatrix, "adjacency matrix", mode)
294340

@@ -388,16 +434,70 @@ is_symmetric <- function(x) {
388434
}
389435

390436
#' @rdname graph_from_adjacency_matrix
437+
#' @inheritParams rlang::args_dots_empty
391438
#' @family adjacency
392439
#' @export
393440
from_adjacency <- function(
394441
adjmatrix,
442+
...,
395443
mode = c("directed", "undirected", "max", "min", "upper", "lower", "plus"),
396444
weighted = NULL,
397445
diag = TRUE,
398446
add.colnames = NULL,
399447
add.rownames = NA
400448
) {
449+
# BEGIN GENERATED ARG_HANDLE: from_adjacency, do not edit, see tools/generate-migrations.R
450+
if (...length() > 0L) {
451+
.arg_handle <- migrate_recover_args(
452+
list(...),
453+
current = list(
454+
mode = mode,
455+
weighted = weighted,
456+
diag = diag,
457+
add.colnames = add.colnames,
458+
add.rownames = add.rownames
459+
),
460+
recover_new = c(
461+
"mode",
462+
"weighted",
463+
"diag",
464+
"add.colnames",
465+
"add.rownames"
466+
),
467+
recover_old = c(
468+
"mode",
469+
"weighted",
470+
"diag",
471+
"add.colnames",
472+
"add.rownames"
473+
),
474+
match_names = c(
475+
"mode",
476+
"weighted",
477+
"diag",
478+
"add.colnames",
479+
"add.rownames"
480+
),
481+
match_to = c("mode", "weighted", "diag", "add.colnames", "add.rownames"),
482+
defaults = list(
483+
mode = c("directed", "undirected", "max", "min", "upper", "lower", "plus"),
484+
weighted = NULL,
485+
diag = TRUE,
486+
add.colnames = NULL,
487+
add.rownames = NA
488+
),
489+
head_args = c("adjmatrix"),
490+
fn_name = "from_adjacency"
491+
)
492+
list2env(.arg_handle$values, environment())
493+
lifecycle::deprecate_soft(
494+
"3.0.0",
495+
what = I(.arg_handle$what),
496+
details = .arg_handle$details
497+
)
498+
}
499+
# END GENERATED ARG_HANDLE
500+
401501
constructor_spec(
402502
graph_from_adjacency_matrix,
403503
adjmatrix = adjmatrix,

0 commit comments

Comments
 (0)