Skip to content
Merged
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
108 changes: 108 additions & 0 deletions R/adjacency.R
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ graph.adjacency <- function(
#'
#' @param adjmatrix A square adjacency matrix. From igraph version 0.5.1 this
#' can be a sparse matrix created with the `Matrix` package.
#' @inheritParams rlang::args_dots_empty
#' @param mode Character scalar, specifies how igraph should interpret the
#' supplied matrix. See also the `weighted` argument, the interpretation
#' depends on that too. Possible values are: `directed`,
Expand Down Expand Up @@ -275,6 +276,7 @@ graph.adjacency <- function(
#' @export
graph_from_adjacency_matrix <- function(
adjmatrix,
...,
mode = c(
"directed",
"undirected",
Expand All @@ -289,6 +291,58 @@ graph_from_adjacency_matrix <- function(
add.colnames = NULL,
add.rownames = NA
) {
# BEGIN GENERATED ARG_HANDLE: graph_from_adjacency_matrix, do not edit, see tools/generate-migrations.R
if (...length() > 0L) {
.arg_handle <- migrate_recover_args(
list(...),
current = list(
mode = mode,
weighted = weighted,
diag = diag,
add.colnames = add.colnames,
add.rownames = add.rownames
),
recover_new = c(
"mode",
"weighted",
"diag",
"add.colnames",
"add.rownames"
),
recover_old = c(
"mode",
"weighted",
"diag",
"add.colnames",
"add.rownames"
),
match_names = c(
"mode",
"weighted",
"diag",
"add.colnames",
"add.rownames"
),
match_to = c("mode", "weighted", "diag", "add.colnames", "add.rownames"),
defaults = list(
mode = c("directed", "undirected", "max", "min", "upper", "lower", "plus"),
weighted = NULL,
diag = TRUE,
add.colnames = NULL,
add.rownames = NA
),
head_args = c("adjmatrix"),
fn_name = "graph_from_adjacency_matrix"
)
list2env(.arg_handle$values, environment())
lifecycle::deprecate_soft(
"3.0.0",
what = I(.arg_handle$what),
details = .arg_handle$details
)
}
# END GENERATED ARG_HANDLE

mode <- igraph_match_arg(mode)
ensure_no_na(adjmatrix, "adjacency matrix", mode)

Expand Down Expand Up @@ -388,16 +442,70 @@ is_symmetric <- function(x) {
}

#' @rdname graph_from_adjacency_matrix
#' @inheritParams rlang::args_dots_empty
#' @family adjacency
#' @export
from_adjacency <- function(
adjmatrix,
...,
mode = c("directed", "undirected", "max", "min", "upper", "lower", "plus"),
weighted = NULL,
diag = TRUE,
add.colnames = NULL,
add.rownames = NA
) {
# BEGIN GENERATED ARG_HANDLE: from_adjacency, do not edit, see tools/generate-migrations.R
if (...length() > 0L) {
.arg_handle <- migrate_recover_args(
list(...),
current = list(
mode = mode,
weighted = weighted,
diag = diag,
add.colnames = add.colnames,
add.rownames = add.rownames
),
recover_new = c(
"mode",
"weighted",
"diag",
"add.colnames",
"add.rownames"
),
recover_old = c(
"mode",
"weighted",
"diag",
"add.colnames",
"add.rownames"
),
match_names = c(
"mode",
"weighted",
"diag",
"add.colnames",
"add.rownames"
),
match_to = c("mode", "weighted", "diag", "add.colnames", "add.rownames"),
defaults = list(
mode = c("directed", "undirected", "max", "min", "upper", "lower", "plus"),
weighted = NULL,
diag = TRUE,
add.colnames = NULL,
add.rownames = NA
),
head_args = c("adjmatrix"),
fn_name = "from_adjacency"
)
list2env(.arg_handle$values, environment())
lifecycle::deprecate_soft(
"3.0.0",
what = I(.arg_handle$what),
details = .arg_handle$details
)
}
# END GENERATED ARG_HANDLE

constructor_spec(
graph_from_adjacency_matrix,
adjmatrix = adjmatrix,
Expand Down
Loading
Loading